SHARE
TWEET

Untitled

a guest Sep 13th, 2017 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.hockey.RP.Events;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.event.EventHandler;
  9. import org.bukkit.event.Listener;
  10. import org.bukkit.event.player.AsyncPlayerChatEvent;
  11. import org.bukkit.event.player.PlayerJoinEvent;
  12.  
  13. import com.hockey.RP.Main;
  14.  
  15. public class Name implements Listener {
  16.  
  17.     ArrayList<String> names = new ArrayList<>();
  18.  
  19.     @EventHandler
  20.     public void onJoin(PlayerJoinEvent event) {
  21.         Player player = event.getPlayer();
  22.  
  23.         names.add(player.getName());
  24.     }
  25.  
  26.     @EventHandler
  27.     public void onChat(AsyncPlayerChatEvent event) {
  28.         Player player = event.getPlayer();
  29.         String name = event.getMessage();
  30.  
  31.         if (names.contains(player.getName())) {
  32.             if (name.contains("!") || name.contains("?") || name.contains("1") || name.contains("2")
  33.                     || name.contains("3") || name.contains("4") || name.contains("5") || name.contains("6")
  34.                     || name.contains("7") || name.contains("8") || name.contains("9") || name.contains("0")
  35.                     || name.contains("<") || name.contains(">") || name.contains("/") || name.contains("'")
  36.                     || name.contains(";") || name.contains(":") || name.contains("[") || name.contains("{")
  37.                     || name.contains("]") || name.contains("}") || name.contains("+") || name.contains("=")
  38.                     || name.contains("-") || name.contains("_") || name.contains(")") || name.contains("(")
  39.                     || name.contains("*") || name.contains("&") || name.contains("^") || name.contains("%")
  40.                     || name.contains("$") || name.contains("€") || name.contains("#") || name.contains("@")) {
  41.  
  42.                 event.setCancelled(true);
  43.                 player.sendMessage(ChatColor.RED + "Sorry! You can't take that as a name!");
  44.             }
  45.             else if (name.equalsIgnoreCase("cancer") || name.equalsIgnoreCase("aids") || name.equalsIgnoreCase("moaning")
  46.                     || name.equalsIgnoreCase("kanker") || name.equalsIgnoreCase("the") || name.equalsIgnoreCase("it")
  47.                     || name.equalsIgnoreCase("this") || name.equalsIgnoreCase("dayum") || name.equalsIgnoreCase("cunt")
  48.                     || name.equalsIgnoreCase("nigger") || name.equalsIgnoreCase("faggot")
  49.                     || name.equalsIgnoreCase("fag") || name.equalsIgnoreCase("bastard") || name.equalsIgnoreCase("fuck")
  50.                     || name.equalsIgnoreCase("fucking") || name.equalsIgnoreCase("shit")
  51.                     || name.equalsIgnoreCase("twat") || name.equalsIgnoreCase("gay") || name.equalsIgnoreCase("lesbian")
  52.                     || name.equalsIgnoreCase("poo") || name.equalsIgnoreCase("wee") || name.equalsIgnoreCase("pee")
  53.                     || name.equalsIgnoreCase("bitch") || name.equalsIgnoreCase("whore")) {
  54.                 event.setCancelled(true);
  55.                 player.sendMessage("Sorry! You can't pick this ugly word! Choose a different name!");
  56.             }
  57.             else if (name.equalsIgnoreCase("Harry") || name.equalsIgnoreCase("Malfoy") || name.equalsIgnoreCase("Potter")
  58.                     || name.equalsIgnoreCase("Weasley") || name.equalsIgnoreCase("Lord")
  59.                     || name.equalsIgnoreCase("Voldemort") || name.equalsIgnoreCase("Harry")
  60.                     || name.equalsIgnoreCase("Hermione") || name.equalsIgnoreCase("Dumbledore")
  61.                     || name.equalsIgnoreCase("black") || name.equalsIgnoreCase("Bellatrix")
  62.                     || name.equalsIgnoreCase("Neville") || name.equalsIgnoreCase("longbottom")
  63.                     || name.equalsIgnoreCase("sirius") || name.equalsIgnoreCase("snape")
  64.                     || name.equalsIgnoreCase("Draco") || name.equalsIgnoreCase("lovegood")
  65.                     || name.equalsIgnoreCase("Hargid") || name.equalsIgnoreCase("minerva")
  66.                     || name.equalsIgnoreCase("Hedwig") || name.equalsIgnoreCase("Ollivander")
  67.                     || name.equalsIgnoreCase("slughorn") || name.equalsIgnoreCase("quirrell")) {
  68.                 event.setCancelled(true);
  69.                 player.sendMessage(ChatColor.RED + "Sorry! Your name can't be " + event.getMessage()
  70.                         + ". Choose a different name!");
  71.             }
  72.         }
  73.         else if (name.equalsIgnoreCase(player.getName())) {
  74.             event.setCancelled(true);
  75.             player.sendMessage(ChatColor.RED + "Sorry! Your name can't be your IGN!");
  76.         } else {
  77.             event.setCancelled(true);
  78.             names.remove(player.getName());
  79.             Main.config.set(player.getUniqueId() + ".RpName", name);
  80.             Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "/ConfigSave");
  81.  
  82.         }
  83.     }
  84. }
RAW Paste Data
Pastebin PRO Autumn Special!
Get 40% OFF on Pastebin PRO accounts!
Top