Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onEnable() {
- inst = this;
- loadData();
- getCommand("kslots").setExecutor(new CmdReload());
- listenPackets();
- }
- public static Main getInst(){
- return inst;
- }
- private void listenPackets() {
- this.manager.addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Status.Server.OUT_SERVER_INFO) {
- public void onPacketSending(PacketEvent e) {
- int actualNum = Bukkit.getOnlinePlayers().length;
- if (e.getPacketType() != PacketType.Status.Server.OUT_SERVER_INFO) return;
- WrapperStatusServerOutServerInfo w = new WrapperStatusServerOutServerInfo(e.getPacket());
- WrappedServerPing ping = w.getServerPing();
- if (changeMotd) ping.setMotD(WrappedChatComponent.fromText(
- ChatColor.translateAlternateColorCodes('&', (String) motds.get(rand.nextInt(motds.size())))));
- if (changeNum) ping.setPlayersOnline(actualNum >= maxToChangeNum ? actualNum : actualNum + numToAdd);
- if (changeMax) ping.setPlayersMaximum(actualNum >= maxToChangeMax ? actualNum + maxToAdd : actualNum >= numSlots ? numSlots : maxToChangeMax);
- List<WrappedGameProfile> wgp = new ArrayList<WrappedGameProfile>();
- int i = 0;
- for (String s : profiles) {
- wgp.add(new WrappedGameProfile(String.valueOf(i++), ChatColor.translateAlternateColorCodes('&', s)));
- }
- if (changeProfiles) ping.setPlayers(wgp);
- if(enableFakeProtocol){
- ping.setVersionProtocol(protocolVersion);
- ping.setVersionName(ChatColor.translateAlternateColorCodes('&', protocolName.replace("%numPlayers%", String.valueOf(ping.getPlayersOnline())).replace("%numMax%", String.valueOf(ping.getPlayersMaximum()))));
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement