Advertisement
4epB9Ik

[Auto] Pokename chat викторина

Jul 22nd, 2024
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. @SubscribeEvent
  2.     public void onChat(ClientChatEvent event)
  3.     {
  4.         String[] words = event.getMessage().split(" ");
  5.         for (String word : words) {
  6.             String pokemon_name = getPokemonName(word);
  7.             if (!pokemon_name.equals("not_pokemon")){
  8.                 CPacketChatMessage packet = new CPacketChatMessage(pokemon_name); //Если надо в глобал слать то <pokemon_name> заменить на <"!" + pokemon_name>
  9.                 Minecraft.getMinecraft().getConnection().sendPacket(packet);
  10.             }
  11.         }
  12.     }
  13.    
  14.     private String getPokemonName(String word) {
  15.         String result = "not_pokemon";
  16.         for (com.pixelmonmod.pixelmon.enums.EnumSpecies pokename : com.pixelmonmod.pixelmon.enums.EnumSpecies.values()) {
  17.             boolean equals = true;
  18.             for (char c : word.toCharArray()) {
  19.                 if (!pokename.toString().contains(String.valueOf(c))) {
  20.                     equals = false;
  21.                 }  
  22.             }
  23.             if (equals) {
  24.                 result = pokename.toString();
  25.             }
  26.         }
  27.         return result;
  28.            
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement