Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SubscribeEvent
- public void onChat(ClientChatEvent event)
- {
- String[] words = event.getMessage().split(" ");
- for (String word : words) {
- String pokemon_name = getPokemonName(word);
- if (!pokemon_name.equals("not_pokemon")){
- CPacketChatMessage packet = new CPacketChatMessage(pokemon_name); //Если надо в глобал слать то <pokemon_name> заменить на <"!" + pokemon_name>
- Minecraft.getMinecraft().getConnection().sendPacket(packet);
- }
- }
- }
- private String getPokemonName(String word) {
- String result = "not_pokemon";
- for (com.pixelmonmod.pixelmon.enums.EnumSpecies pokename : com.pixelmonmod.pixelmon.enums.EnumSpecies.values()) {
- boolean equals = true;
- for (char c : word.toCharArray()) {
- if (!pokename.toString().contains(String.valueOf(c))) {
- equals = false;
- }
- }
- if (equals) {
- result = pokename.toString();
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement