Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Zegar {
- static String IP_Adrr="";
- static String Log="";
- static String Pass="";
- static String Nick="";
- static String ID1="";
- static String ID2="";
- static String ID3="";
- static String ID4="";
- static String Port="";
- public static void main(String[] args) {
- Properties prop = new Properties();
- try {
- prop.setProperty("IP", "xxx.xxx.xxx.xxx");
- prop.setProperty("Login", "xxxx");
- prop.setProperty("Pass", "xxxxx");
- prop.setProperty("Nick", "xxxxx");
- prop.setProperty("Port", "xxxxx");
- prop.setProperty("1ID", "xxx");
- prop.setProperty("2ID", "xxx");
- prop.setProperty("3ID", "xxx");
- prop.setProperty("4ID", "xxx");
- File f = new File("server.properties");
- if(!f.exists()){
- PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f, false), "UTF-8")), true);
- prop.store(out, "Autoconfig, generated by ZegarBot");
- }
- } catch (Exception io) {
- io.printStackTrace();
- }
- try {
- BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("server.properties"), "UTF8"));
- prop.load(in);
- IP_Adrr=prop.getProperty("IP");
- Log=prop.getProperty("Login");
- Pass=prop.getProperty("Pass");
- Nick=prop.getProperty("Nick");
- ID1=prop.getProperty("1ID");
- ID2=prop.getProperty("2ID");
- ID3=prop.getProperty("3ID");
- ID4=prop.getProperty("4ID");
- Port=prop.getProperty("Port");
- } catch (IOException | NumberFormatException e) {
- System.err.println("Utworzono plik konfiguracyjny, edytuj jego wartości na poprawne.");
- }
- final TS3Config config = new TS3Config();
- final TS3Query query = new TS3Query(config);
- final TS3Api api = query.getApi();
- try {
- config.setHost((IP_Adrr));
- config.setQueryPort(Integer.parseInt(Port));
- config.setDebugLevel(Level.SEVERE);
- config.setFloodRate(FloodRate.UNLIMITED);
- query.connect();
- api.login((Log), (Pass));
- api.selectVirtualServerById(1);
- api.setNickname((Nick));
- api.registerAllEvents();
- } catch(NumberFormatException e) {
- System.err.println("Uruchom ponownie po edycji zmiennych");
- }
- ScheduledExecutorService ses2 = Executors.newSingleThreadScheduledExecutor();
- ses2.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- String[][] czcionka ={{"▄▀▀▀█─", "─█─", "─▀▀▀█─", "─▀▀▀█─", "▄───█─", "▄▀▀▀▀─", "▄▀▀▀▀─", "▄▀▀▀█─", "▄▀▀▀█─", "▄▀▀▀█─", "────"},
- {"█───█─", "─█─", "▄▄▄▄█─", "─▄▄▄█─", "█▄▄▄█─", "█▄▄▄▄─", "█▄▄▄▄─", "────█─", "█▄▄▄█─", "█▄▄▄█─", "─▀──"},
- {"█───█─", "─█─", "█─────", "────█─", "────█─", "────█─", "█───█─", "────█─", "█───█─", "────█─", "─▄──"},
- {"▀▀▀▀──", "─▀─", "▀▀▀▀──", "▀▀▀▀──", "────▀─", "▀▀▀▀──", "▀▀▀▀──", "────▀─", "▀▀▀▀──", "▀▀▀▀──", "────"}};
- Calendar teraz = Calendar.getInstance();
- int hours = teraz.get(Calendar.HOUR_OF_DAY);
- int minutes = teraz.get(Calendar.MINUTE);
- String[] linie= {"", "", "", ""};
- for(int i = 0; i<4;i++) {
- linie[i]="[cspacer]-";
- if(hours>=10) {
- linie[i] +=czcionka[i][(int) Math.floor(hours / 10)];
- }
- linie[i]+=czcionka[i][hours % 10];
- linie[i]+=czcionka[i][10];
- linie[i]+=czcionka[i][(int) Math.floor(minutes / 10)];
- linie[i]+=czcionka[i][minutes%10];
- }
- final HashMap<ChannelProperty, String> zegar1 = new HashMap<>();
- final HashMap<ChannelProperty, String> zegar2 = new HashMap<>();
- final HashMap<ChannelProperty, String> zegar3 = new HashMap<>();
- final HashMap<ChannelProperty, String> zegar4 = new HashMap<>();
- zegar1.put(ChannelProperty.CHANNEL_NAME, linie[0]);
- zegar2.put(ChannelProperty.CHANNEL_NAME, linie[1]);
- zegar3.put(ChannelProperty.CHANNEL_NAME, linie[2]);
- zegar4.put(ChannelProperty.CHANNEL_NAME, linie[3]);
- api.editChannel(Integer.parseInt(ID1), zegar1);
- api.editChannel(Integer.parseInt((ID2)), zegar2);
- api.editChannel(Integer.parseInt((ID3)), zegar3);
- api.editChannel(Integer.parseInt((ID4)), zegar4);
- }
- }, 0, 1, TimeUnit.MINUTES);
- System.err.println("Zegarynka Dziala");
- api.addTS3Listeners(new TS3Listener() {
- @Override
- public void onTextMessage(TextMessageEvent e) {
- }
- @Override
- public void onServerEdit(ServerEditedEvent e) {
- }
- @Override
- public void onClientMoved(ClientMovedEvent e) {
- }
- @Override
- public void onClientLeave(ClientLeaveEvent e) {
- }
- @Override
- public void onClientJoin(ClientJoinEvent e) {
- // ...
- }
- @Override
- public void onChannelEdit(ChannelEditedEvent e) {
- // ...
- }
- @Override
- public void onChannelDescriptionChanged(ChannelDescriptionEditedEvent e) {
- // ...
- }
- @Override
- public void onChannelCreate(ChannelCreateEvent e) {
- // ...
- }
- @Override
- public void onChannelDeleted(ChannelDeletedEvent e) {
- // ...
- }
- @Override
- public void onChannelMoved(ChannelMovedEvent e) {
- // ...
- }
- @Override
- public void onChannelPasswordChanged(ChannelPasswordChangedEvent e) {
- // ...
- }
- @Override
- public void onPrivilegeKeyUsed(PrivilegeKeyUsedEvent e) {
- // ...
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment