Advertisement
Guest User

Untitled

a guest
Nov 18th, 2015
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. public void onEnable() {
  2.     inst = this;
  3.     loadData();
  4.     getCommand("kslots").setExecutor(new CmdReload());
  5.     listenPackets();
  6. }
  7.    
  8. public static Main getInst(){
  9.     return inst;
  10. }
  11.  
  12. private void listenPackets() {
  13.     this.manager.addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Status.Server.OUT_SERVER_INFO) {
  14.         public void onPacketSending(PacketEvent e) {
  15.             int actualNum = Bukkit.getOnlinePlayers().length;
  16.             if (e.getPacketType() != PacketType.Status.Server.OUT_SERVER_INFO) return;
  17.            
  18.             WrapperStatusServerOutServerInfo w = new WrapperStatusServerOutServerInfo(e.getPacket());
  19.             WrappedServerPing ping = w.getServerPing();
  20.                
  21.             if (changeMotd) ping.setMotD(WrappedChatComponent.fromText(
  22.                     ChatColor.translateAlternateColorCodes('&', (String) motds.get(rand.nextInt(motds.size())))));
  23.                
  24.             if (changeNum) ping.setPlayersOnline(actualNum >= maxToChangeNum ? actualNum : actualNum + numToAdd);
  25.                
  26.             if (changeMax) ping.setPlayersMaximum(actualNum >= maxToChangeMax ? actualNum + maxToAdd : actualNum >= numSlots ? numSlots : maxToChangeMax);
  27.                
  28.             List<WrappedGameProfile> wgp = new ArrayList<WrappedGameProfile>();
  29.             int i = 0;
  30.             for (String s : profiles) {
  31.                 wgp.add(new WrappedGameProfile(String.valueOf(i++), ChatColor.translateAlternateColorCodes('&', s)));
  32.             }
  33.             if (changeProfiles) ping.setPlayers(wgp);
  34.                
  35.             if(enableFakeProtocol){
  36.                 ping.setVersionProtocol(protocolVersion);
  37.                 ping.setVersionName(ChatColor.translateAlternateColorCodes('&', protocolName.replace("%numPlayers%", String.valueOf(ping.getPlayersOnline())).replace("%numMax%", String.valueOf(ping.getPlayersMaximum()))));
  38.             }
  39.         }
  40.     });
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement