Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. package ru.dondays.dapi.api.extra;
  2.  
  3. import com.google.common.io.ByteArrayDataInput;
  4. import com.google.common.io.ByteArrayDataOutput;
  5. import com.google.common.io.ByteStreams;
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.plugin.messaging.PluginMessageListener;
  9. import ru.dondays.dapi.DAPI;
  10. import ru.dondays.dapi.utils.ChatUtil;
  11.  
  12. import java.util.HashMap;
  13.  
  14. public class SkinsReceiver
  15. implements PluginMessageListener {
  16.  
  17. public static HashMap<String, String> skins = new HashMap<>();
  18.  
  19. @Override
  20. public void onPluginMessageReceived(String channel, Player player, byte[] message) {
  21. if(!channel.equals("BungeeCord")) {
  22. return;
  23. }
  24. ByteArrayDataInput in = ByteStreams.newDataInput(message);
  25. String subChannel = in.readUTF();
  26. if(!subChannel.equals("ReceiveSkin")) {
  27. return;
  28. }
  29. skins.put(in.readUTF(), in.readUTF());
  30. }
  31.  
  32. public static String getSkin(Player p) {
  33. String player = p.getName().toLowerCase();
  34. ByteArrayDataOutput out = ByteStreams.newDataOutput();
  35. out.writeUTF("GetSkin");
  36. out.writeUTF(player);
  37. p.sendPluginMessage(DAPI.getInstance(), "BungeeCord", out.toByteArray());
  38. if(skins.get(player) == null) {
  39. return player;
  40. }
  41. return skins.get(player);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement