Advertisement
Guest User

GommeNick - OpenSourceCode by DoggiSpielt

a guest
Mar 28th, 2017
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.54 KB | None | 0 0
  1. package de.doggispielt.gommenick;
  2.  
  3. import java.lang.reflect.Field;
  4. import java.lang.reflect.Method;
  5. import java.util.ArrayList;
  6. import java.util.Random;
  7.  
  8. import org.bukkit.Bukkit;
  9. import org.bukkit.command.Command;
  10. import org.bukkit.command.CommandSender;
  11. import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
  12. import org.bukkit.entity.Player;
  13. import org.bukkit.event.Listener;
  14. import org.bukkit.plugin.java.JavaPlugin;
  15.  
  16. import com.mojang.authlib.GameProfile;
  17. import com.mojang.authlib.properties.Property;
  18.  
  19. public class Main
  20. extends JavaPlugin
  21. implements Listener
  22. {
  23. public static Main plugin;
  24.  
  25. public static Main getPlugin()
  26. {
  27. return plugin;
  28. }
  29.  
  30. public ArrayList<String> Names = new ArrayList<>();
  31. public ArrayList<Player> nicked = new ArrayList<>();
  32. public ArrayList<String> random_nicked = new ArrayList<>();
  33.  
  34. public void onEnable()
  35. {
  36. getCommand("nick").setExecutor(this);
  37.  
  38. getServer().getPluginManager().registerEvents(this, this);
  39.  
  40. this.Names.add("Infamus");
  41. this.Names.add("Rufus1852");
  42. this.Names.add("Java_Code");
  43. this.Names.add("timba");
  44. this.Names.add("metalchaos");
  45. this.Names.add("Aquaah");
  46. this.Names.add("BearExplosive");
  47. this.Names.add("ZerolHD");
  48. this.Names.add("GreenSoldier");
  49. this.Names.add("KevinHDLP");
  50. this.Names.add("QuickScope");
  51. this.Names.add("SkillerLP");
  52. this.Names.add("GGGGGGA");
  53. this.Names.add("MalexPVP");
  54. this.Names.add("Gomze");
  55. this.Names.add("GAWhay");
  56. this.Names.add("DerZockerHD");
  57. this.Names.add("GamingHD");
  58. this.Names.add("GamePlayerYT");
  59. this.Names.add("MlgLucasHD");
  60. this.Names.add("StoneHD");
  61. this.Names.add("WoodLP");
  62. this.Names.add("JustYouDad");
  63. this.Names.add("MegaLP");
  64. this.Names.add("StrawberryShake");
  65. this.Names.add("ReuZEron");
  66. this.Names.add("DerSeltrox");
  67. this.Names.add("BananaHD");
  68. this.Names.add("SchoolHDLP");
  69. this.Names.add("MegaDev");
  70. this.Names.add("SpigotEU");
  71. this.Names.add("_BukkitPvP_");
  72. this.Names.add("YoutubeProHD");
  73. this.Names.add("SongsLP");
  74. this.Names.add("Gmanda");
  75. this.Names.add("PaulZocker");
  76. this.Names.add("JustDavid");
  77. this.Names.add("BambusMeister");
  78. this.Names.add("rektusio_");
  79. this.Names.add("dragonsX_");
  80. this.Names.add("Squeez");
  81. this.Names.add("PlayToWin");
  82. this.Names.add("DasDevHorn");
  83. this.Names.add("AchtungIchHacke");
  84. this.Names.add("DerInvisClient");
  85. this.Names.add("DasAbstauber");
  86. this.Names.add("Aaroncvx");
  87. this.Names.add("AJD25");
  88. this.Names.add("ABCCOOL");
  89. this.Names.add("asona56");
  90. this.Names.add("blar210");
  91. this.Names.add("baka245");
  92. this.Names.add("azgoo");
  93. this.Names.add("adamofire2");
  94. this.Names.add("270midnight");
  95. this.Names.add("ajs111");
  96. this.Names.add("bestmobbin");
  97. this.Names.add("Alkoed");
  98. this.Names.add("Arrrg");
  99. this.Names.add("cchuck");
  100. this.Names.add("bzoro1");
  101. this.Names.add("brent8");
  102. this.Names.add("9001RageQuits");
  103. this.Names.add("blaze42");
  104. this.Names.add("bennstone");
  105. this.Names.add("alle28");
  106. this.Names.add("aerkake");
  107. this.Names.add("5k337");
  108. this.Names.add("Capt_Danger_");
  109. this.Names.add("cbauer1127");
  110. this.Names.add("AshrafAnsari");
  111. this.Names.add("bacardee");
  112. this.Names.add("buster88");
  113. this.Names.add("azgoo");
  114. this.Names.add("bast_e");
  115. this.Names.add("brain_knight");
  116. this.Names.add("bombmaker13");
  117. this.Names.add("buy2k8");
  118. this.Names.add("BoneHunter");
  119. this.Names.add("cherle");
  120. this.Names.add("BlueCar15");
  121. this.Names.add("chase132");
  122. this.Names.add("GGPlayer031");
  123. this.Names.add("awesomenick01");
  124. this.Names.add("Alienate");
  125. this.Names.add("Bademind");
  126. this.Names.add("Barbarian22");
  127. this.Names.add("Canedis");
  128. this.Names.add("camcar1");
  129. this.Names.add("Chicken500");
  130. this.Names.add("coco113");
  131. this.Names.add("cruyff14");
  132. this.Names.add("darkwalker247");
  133. this.Names.add("coolwalker");
  134. this.Names.add("colonetrip");
  135. this.Names.add("cjoli");
  136. this.Names.add("cookie10");
  137. this.Names.add("clone01");
  138. this.Names.add("chipandew");
  139. this.Names.add("consoso");
  140. this.Names.add("cougar88");
  141. this.Names.add("demon1972");
  142. this.Names.add("christionvork");
  143. this.Names.add("domthebom123");
  144. this.Names.add("hansjoegl");
  145. this.Names.add("farrar1");
  146. this.Names.add("gnomar97");
  147. this.Names.add("harry0214");
  148. this.Names.add("joshmc");
  149. this.Names.add("fredddi");
  150. this.Names.add("FaTaLwassap");
  151. this.Names.add("DA_SWAMPMONSTA");
  152. this.Names.add("demon1972");
  153. this.Names.add("nextDoor");
  154. this.Names.add("manu75176");
  155. this.Names.add("nonatz");
  156. this.Names.add("moshi01");
  157. this.Names.add("lolzlord55");
  158. this.Names.add("mmerlin");
  159. this.Names.add("mgk103");
  160. this.Names.add("niks");
  161. this.Names.add("jutske");
  162. this.Names.add("OprahChrist");
  163. this.Names.add("PokeGoPlayer");
  164. this.Names.add("macejoe");
  165. this.Names.add("nessling");
  166. this.Names.add("porty101");
  167. this.Names.add("megalennie1");
  168. this.Names.add("rawn");
  169. this.Names.add("robbekes");
  170. this.Names.add("robotronic");
  171. this.Names.add("perryplat98");
  172. this.Names.add("Rybeez55");
  173. this.Names.add("Stimmy");
  174. this.Names.add("Stuk");
  175. this.Names.add("sweenyb");
  176. this.Names.add("robdee");
  177. this.Names.add("sammydog1997");
  178. this.Names.add("slim08");
  179. this.Names.add("Niki2007");
  180. this.Names.add("rumblefish");
  181. this.Names.add("NightScope");
  182. this.Names.add("pipola");
  183. this.Names.add("spin810");
  184. this.Names.add("schaun1998");
  185. this.Names.add("pompmaker1");
  186. this.Names.add("sam444");
  187. this.Names.add("runthistown");
  188. this.Names.add("semoyu");
  189. this.Names.add("percal");
  190. this.Names.add("Messy_Turkey");
  191. this.Names.add("sambridger");
  192. this.Names.add("ry22an");
  193. this.Names.add("rutetid");
  194. this.Names.add("pongolongo");
  195. this.Names.add("spykey123");
  196. this.Names.add("perryplat98");
  197. this.Names.add("papthedog05");
  198. this.Names.add("Sk11lsT3R");
  199. this.Names.add("semoyu");
  200. this.Names.add("runthistown");
  201. this.Names.add("Singular");
  202. this.Names.add("timchen");
  203. this.Names.add("timonde");
  204. this.Names.add("robdee");
  205. this.Names.add("spikey123");
  206. this.Names.add("tapout10");
  207. this.Names.add("thamightybobo");
  208. this.Names.add("tapout10");
  209. this.Names.add("sakux");
  210. this.Names.add("sellbram");
  211. this.Names.add("The_SnowBro");
  212. this.Names.add("ultimatebag");
  213. this.Names.add("Der_Uli");
  214. this.Names.add("Wondwi");
  215. this.Names.add("ur_dead");
  216. this.Names.add("xXNiclasPvPXx");
  217. this.Names.add("MayoInstrument");
  218. this.Names.add("SechsMitDir");
  219. this.Names.add("DerPedoMichi");
  220. this.Names.add("SchinkenLP");
  221. this.Names.add("SnailYT");
  222. this.Names.add("zebbe9999");
  223. this.Names.add("ukcats");
  224. this.Names.add("x_kyle_x");
  225. this.Names.add("wolpaladin");
  226. this.Names.add("speeeder86");
  227. this.Names.add("tapout10");
  228. this.Names.add("stickzer0");
  229. this.Names.add("sureynot");
  230. this.Names.add("waltisawesome");
  231. this.Names.add("timperi");
  232. this.Names.add("shak1145");
  233. this.Names.add("theSero");
  234. this.Names.add("thetangledhand");
  235. this.Names.add("wildii");
  236. this.Names.add("wilde_katze");
  237. this.Names.add("viking58");
  238. this.Names.add("timii");
  239. this.Names.add("rumblefish");
  240. this.Names.add("pigman21");
  241. this.Names.add("TauFirewarrior");
  242. this.Names.add("Tavorrik");
  243. this.Names.add("tcassel9898");
  244. this.Names.add("TehTeNdEnCiEs");
  245. this.Names.add("tenshispawn");
  246. this.Names.add("terrorist_109");
  247. this.Names.add("tesla2000");
  248. this.Names.add("tgy320");
  249. this.Names.add("Th1Alchemyst");
  250. this.Names.add("tharcon");
  251. this.Names.add("thatspercy");
  252. this.Names.add("TheAmazingTwix");
  253. this.Names.add("TheBladerSL");
  254. this.Names.add("thebrowns");
  255. this.Names.add("TheCars");
  256. this.Names.add("thecatman23");
  257.  
  258. getConfig().addDefault("Nickname.Format", "&6");
  259. getConfig().addDefault("Nickname.Reset-Format", "&4");
  260. getConfig().addDefault("Messages.Unnick-Message", "&8[&5NICK&8] &4Dein Nickname wurde entfernt");
  261. getConfig().addDefault("Messages.Nick-Message", "&8[&5NICK&8] &4Du spielst nun als&7: &6");
  262. getConfig().addDefault("Messages.TooLong-Message", "&8[&5NICK&8] &4Dein Nickname darf nicht länger als &b16 Zeichen &4sein");
  263. getConfig().options().copyDefaults(true);
  264. saveConfig();
  265. reloadConfig();
  266.  
  267. System.out.println("[NICK] Plugin wurde aktiviert");
  268. }
  269.  
  270. public void onDisable()
  271. {
  272. System.out.println("[NICK] Plugin wurde deaktiviert");
  273. }
  274.  
  275. public static void setNameTag(String name, Player player)
  276. {
  277. try
  278. {
  279. Method getHandle = player.getClass().getMethod("getHandle");
  280. try
  281. {
  282. Class.forName("com.mojang.authlib.GameProfile");
  283. }
  284. catch (ClassNotFoundException e)
  285. {
  286. Bukkit.broadcastMessage("§cDO NOT USE 1.7 OR LOWER!");
  287. return;
  288. }
  289. Object profile = getHandle.invoke(player, new Object[0]).getClass()
  290. .getMethod("getProfile", new Class[0])
  291. .invoke(getHandle.invoke(player, new Object[0]), new Object[0]);
  292. Field ff = profile.getClass().getDeclaredField("name");
  293. ff.setAccessible(true);
  294. ff.set(profile, name);
  295. for (Player players : Bukkit.getOnlinePlayers())
  296. {
  297. players.hidePlayer(player);
  298. players.showPlayer(player);
  299. }
  300. }
  301. catch (Exception e)
  302. {
  303. e.printStackTrace();
  304. }
  305. }
  306.  
  307. @SuppressWarnings("deprecation")
  308. public String getUUID(String name)
  309. {
  310. return
  311. Bukkit.getOfflinePlayer(name).getUniqueId().toString().replace("-", "");
  312. }
  313.  
  314. public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
  315. {
  316. if (getConfig().contains("Nickname.Format"))
  317. {
  318. String format = getConfig().getString("Nickname.Format");
  319. format = format.replace("&", "§");
  320. if (getConfig().contains("Messages.Unnick-Message"))
  321. {
  322. String unnickmsg = getConfig().getString("Messages.Unnick-Message");
  323. unnickmsg = unnickmsg.replace("&", "§");
  324. if (getConfig().contains("Messages.Nick-Message"))
  325. {
  326. String nickmsg = getConfig().getString("Messages.Nick-Message");
  327. nickmsg = nickmsg.replace("&", "§");
  328. if (getConfig().contains("Nickname.Reset-Format"))
  329. {
  330. String resetformat = getConfig().getString("Nickname.Reset-Format");
  331. resetformat = resetformat.replace("&", "§");
  332. if (getConfig().contains("Messages.TooLong-Message"))
  333. {
  334. String toolongmsg = getConfig().getString("Messages.TooLong-Message");
  335. toolongmsg = toolongmsg.replace("&", "§");
  336.  
  337. Player p = (Player)sender;
  338. if ((sender instanceof Player)) {
  339. if (p.getPlayer().hasPermission("nick.use"))
  340. {
  341. Skin skin;
  342. if (args.length == 0)
  343. {
  344. if (!this.nicked.contains(p.getPlayer()))
  345. {
  346. Random r = new Random();
  347. String randomNick = "";
  348. randomNick = (String)this.Names.get(r.nextInt(this.Names.size()));
  349.  
  350. String nick = randomNick;
  351.  
  352. p.setCustomName(p.getName());
  353.  
  354. setNameTag(nick, p);
  355.  
  356. GameProfile gp = ((CraftPlayer)p).getProfile();
  357. gp.getProperties().clear();
  358. skin = new Skin(getUUID(nick));
  359. if (skin.getSkinName() != null) {
  360. gp.getProperties().put(skin.getSkinName(),
  361. new Property(skin.getSkinName(), skin
  362. .getSkinValue(), skin
  363. .getSkinSignatur()));
  364. }
  365. for (Player a : Bukkit.getOnlinePlayers()) {
  366. a.hidePlayer(p);
  367. }
  368. for (Player a : Bukkit.getOnlinePlayers()) {
  369. a.showPlayer(p);
  370. }
  371. this.nicked.add(p.getPlayer());
  372. this.random_nicked.add(p.getName());
  373.  
  374. p.setDisplayName(format + nick);
  375. p.setPlayerListName(format + nick);
  376.  
  377. p.sendMessage(nickmsg + nick);
  378. }
  379. else if (this.nicked.contains(p.getPlayer()))
  380. {
  381. this.nicked.remove(p.getPlayer());
  382. this.random_nicked.remove(p.getName());
  383.  
  384. String nick = p.getCustomName();
  385.  
  386. setNameTag(p.getCustomName(), p);
  387.  
  388. GameProfile gp = ((CraftPlayer)p).getProfile();
  389. gp.getProperties().clear();
  390. Skin skin1 = new Skin(getUUID(nick));
  391. if (skin1.getSkinName() != null) {
  392. gp.getProperties().put(skin1.getSkinName(),
  393. new Property(skin1.getSkinName(), skin1
  394. .getSkinValue(), skin1
  395. .getSkinSignatur()));
  396. }
  397. for (Player a : Bukkit.getOnlinePlayers()) {
  398. a.hidePlayer(p);
  399. }
  400. for (Player a : Bukkit.getOnlinePlayers()) {
  401. a.showPlayer(p);
  402. }
  403. p.setDisplayName(resetformat + nick);
  404. p.setPlayerListName(resetformat + nick);
  405.  
  406. p.sendMessage(unnickmsg);
  407. }
  408. else
  409. {
  410. return true;
  411. }
  412. }
  413. else if (args.length == 1) {
  414. if (!this.nicked.contains(p.getPlayer()))
  415. {
  416. if(args[0].length() < 17){
  417.  
  418. String nick = args[0];
  419.  
  420. p.setCustomName(p.getName());
  421.  
  422. setNameTag(nick, p);
  423.  
  424. this.nicked.add(p.getPlayer());
  425. this.random_nicked.add(p.getName());
  426.  
  427. GameProfile gp = ((CraftPlayer)p).getProfile();
  428. gp.getProperties().clear();
  429. Skin skin2 = new Skin(getUUID(nick));
  430. if (skin2.getSkinName() != null) {
  431. gp.getProperties().put(skin2.getSkinName(),
  432. new Property(skin2.getSkinName(), skin2
  433. .getSkinValue(), skin2
  434. .getSkinSignatur()));
  435. }
  436. for (Player a : Bukkit.getOnlinePlayers()) {
  437. a.hidePlayer(p);
  438. }
  439. for (Player a : Bukkit.getOnlinePlayers()) {
  440. a.showPlayer(p);
  441. }
  442. p.setDisplayName(format + nick);
  443. p.setPlayerListName(format + nick);
  444.  
  445. p.sendMessage(nickmsg + nick);
  446. } else {
  447. p.sendMessage(toolongmsg);
  448. return true;
  449. }
  450. }
  451. else if (this.nicked.contains(p.getPlayer()))
  452. {
  453. this.nicked.remove(p.getPlayer());
  454. this.random_nicked.remove(p.getName());
  455.  
  456. String nick = p.getCustomName();
  457.  
  458. setNameTag(p.getCustomName(), p);
  459.  
  460. GameProfile gp = ((CraftPlayer)p).getProfile();
  461. gp.getProperties().clear();
  462. Skin skin3 = new Skin(getUUID(nick));
  463. if (skin3.getSkinName() != null) {
  464. gp.getProperties().put(skin3.getSkinName(),
  465. new Property(skin3.getSkinName(), skin3
  466. .getSkinValue(), skin3
  467. .getSkinSignatur()));
  468. }
  469. for (Player a : Bukkit.getOnlinePlayers()) {
  470. a.hidePlayer(p);
  471. }
  472. for (Player a : Bukkit.getOnlinePlayers()) {
  473. a.showPlayer(p);
  474. }
  475. p.setDisplayName(resetformat + nick);
  476. p.setPlayerListName(resetformat + nick);
  477.  
  478. p.sendMessage(unnickmsg);
  479. }
  480. else
  481. {
  482. return true;
  483. }
  484. }
  485. }
  486. else
  487. {
  488. p.sendMessage("§cI'm sorry, but you do not hav epermission to perform this command. Please contact the server administrators if you believe that this is in error.");
  489. }
  490. }
  491. }
  492. }
  493. }
  494. }
  495. }
  496. return true;
  497. }
  498. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement