Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
1,198
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package chillinq.ffa;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.io.PrintStream;
  6. import java.util.ArrayList;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.UUID;
  10. import net.minecraft.server.v1_7_R4.EntityPlayer;
  11. import org.bukkit.Bukkit;
  12. import org.bukkit.ChatColor;
  13. import org.bukkit.Location;
  14. import org.bukkit.Material;
  15. import org.bukkit.Server;
  16. import org.bukkit.Sound;
  17. import org.bukkit.World;
  18. import org.bukkit.command.Command;
  19. import org.bukkit.command.CommandExecutor;
  20. import org.bukkit.command.CommandSender;
  21. import org.bukkit.command.PluginCommand;
  22. import org.bukkit.configuration.file.FileConfiguration;
  23. import org.bukkit.configuration.file.YamlConfiguration;
  24. import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
  25. import org.bukkit.entity.Damageable;
  26. import org.bukkit.entity.Player;
  27. import org.bukkit.event.EventHandler;
  28. import org.bukkit.event.EventPriority;
  29. import org.bukkit.event.Listener;
  30. import org.bukkit.event.block.BlockBreakEvent;
  31. import org.bukkit.event.entity.EntityDamageByEntityEvent;
  32. import org.bukkit.event.entity.EntityDamageEvent;
  33. import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
  34. import org.bukkit.event.entity.EntityShootBowEvent;
  35. import org.bukkit.event.entity.FoodLevelChangeEvent;
  36. import org.bukkit.event.entity.PlayerDeathEvent;
  37. import org.bukkit.event.player.PlayerDropItemEvent;
  38. import org.bukkit.event.player.PlayerItemBreakEvent;
  39. import org.bukkit.event.player.PlayerJoinEvent;
  40. import org.bukkit.event.player.PlayerLevelChangeEvent;
  41. import org.bukkit.event.player.PlayerPickupItemEvent;
  42. import org.bukkit.event.player.PlayerQuitEvent;
  43. import org.bukkit.event.player.PlayerRespawnEvent;
  44. import org.bukkit.inventory.ItemStack;
  45. import org.bukkit.inventory.PlayerInventory;
  46. import org.bukkit.inventory.meta.ItemMeta;
  47. import org.bukkit.plugin.PluginManager;
  48. import org.bukkit.plugin.java.JavaPlugin;
  49. import org.bukkit.scheduler.BukkitScheduler;
  50.  
  51. public class Main extends JavaPlugin
  52. implements CommandExecutor, Listener
  53. {
  54. HashMap<UUID, UUID> lastSentMessages = new HashMap();
  55. List<String> fly = new ArrayList();
  56. public ArrayList<Player> vanished = new ArrayList();
  57.  
  58. HashMap<UUID, Long> Cooldown = new HashMap();
  59. double hearts = 5.5D;
  60. String prefix = ChatColor.translateAlternateColorCodes('&', getConfig().getString("FFA Prefix"));
  61. int count = 5;
  62. boolean modc = true;
  63.  
  64. public static File file = new File("plugins/ChillinqFFA", "stats.yml");
  65. public static FileConfiguration stats = YamlConfiguration.loadConfiguration(file);
  66.  
  67. public int i = 3;
  68.  
  69. public void onEnable()
  70. {
  71. System.out.println("[ChillinqFFA] Enabled.");
  72. System.out.print("=======> FFA by Chillinq <=======");
  73. System.out.print("Plugin Enabled.");
  74. System.out.print("You're using version: 4.6");
  75. System.out.print("=======> FFA by Chillinq <=======");
  76. getCommand("ffa").setExecutor(this);
  77. getCommand("ffasetspawn").setExecutor(this);
  78. getCommand("ffakit").setExecutor(this);
  79. getCommand("ffareload").setExecutor(this);
  80. getCommand("spawn").setExecutor(this);
  81. getCommand("fix").setExecutor(this);
  82. getCommand("vanish").setExecutor(this);
  83. getCommand("v").setExecutor(this);
  84. getCommand("ping").setExecutor(this);
  85. getCommand("fly").setExecutor(this);
  86. getCommand("flyspeed").setExecutor(this);
  87. getCommand("clearchat").setExecutor(this);
  88. getCommand("cc").setExecutor(this);
  89. getCommand("tc").setExecutor(this);
  90. getCommand("teamchat").setExecutor(this);
  91. getCommand("team").setExecutor(this);
  92. getCommand("msg").setExecutor(this);
  93. getCommand("message").setExecutor(this);
  94. getCommand("stats").setExecutor(this);
  95. getCommand("records").setExecutor(this);
  96. Bukkit.getPluginManager().registerEvents(this, this);
  97. saveDefaultConfig();
  98. try {
  99. stats.save(file);
  100. } catch (IOException e1) {
  101. e1.printStackTrace();
  102. }
  103. super.onEnable();
  104. }
  105.  
  106. public void onDisable() {
  107. System.out.println("[ChillinqFFA] Disabled.");
  108. System.out.print("=======> FFA by Chillinq <=======");
  109. System.out.print("Plugin Disabled.");
  110. System.out.print("=======> FFA by Chillinq <=======");
  111. reloadConfig();
  112. saveDefaultConfig();
  113. super.onDisable();
  114. }
  115.  
  116. public int getPointsEntity(Player t) {
  117. String name = t.getDisplayName();
  118. int Points = stats.getInt("Stats.Players." + name + ".Points");
  119. return Points;
  120. }
  121.  
  122. public int getPoints(Player P)
  123. {
  124. String name = P.getDisplayName();
  125. int Points = stats.getInt("Stats.Players." + name + ".Points");
  126. return Points;
  127. }
  128.  
  129. public void ChillinqStyle(Player P, Player t)
  130. {
  131. int a = (int)(getPoints(P) * 0.3D);
  132. int newPoints = a;
  133. String pname = P.getDisplayName();
  134. String tname = t.getDisplayName();
  135. if (getPoints(P) >= 20) {
  136. stats.set("Stats.Players." + pname + ".Points", Integer.valueOf(getPoints(P) - a));
  137. P.sendMessage(this.prefix + " §3You have lost §e" + newPoints + " §3Points.");
  138. stats.set("Stats.Players." + tname + ".Points", Integer.valueOf(getPointsEntity(t) + newPoints));
  139. t.sendMessage(this.prefix + " §3You have gained §e" + a + " §3Points.");
  140. }
  141. else if ((getPoints(P) <= 199) && (getPoints(P) != 5) && (getPoints(P) > 5)) {
  142. stats.set("Stats.Players." + pname + ".Points", Integer.valueOf(getPoints(P) - 5));
  143. stats.set("Stats.Players." + tname + ".Points", Integer.valueOf(getPointsEntity(t) + 5));
  144. t.sendMessage(this.prefix + " §3You have gained §e5 §3Points.");
  145. P.sendMessage(this.prefix + " §3You have lost §e5 §3Points.");
  146. } else if (getPoints(P) <= 5) {
  147. int zero = 0;
  148. stats.set("Stats.Players." + pname + ".Points", Integer.valueOf(zero));
  149. stats.set("Stats.Players." + tname + ".Points", Integer.valueOf(getPointsEntity(t) + 5));
  150. t.sendMessage(this.prefix + " §3You have gained §e5 §3Points.");
  151. P.sendMessage(this.prefix + " §3You have lost §e5 §3Points.");
  152. }
  153. }
  154.  
  155. @EventHandler
  156. public void onJoin(PlayerJoinEvent e)
  157. {
  158. Player p = e.getPlayer();
  159. p.getInventory().clear();
  160. p.performCommand("spawn");
  161. p.performCommand("ffakit");
  162. String name = p.getDisplayName();
  163. if (!getConfig().contains("Players." + name)) {
  164. getConfig().set("Stats.Players." + name + ".Points", Integer.valueOf(0));
  165. getConfig().set("Stats.Players." + name + ".Kills", Integer.valueOf(0));
  166. getConfig().set("Stats.Players." + name + ".Deaths", Integer.valueOf(0));
  167. try {
  168. stats.save(file);
  169. } catch (IOException e1) {
  170. e1.printStackTrace();
  171. }
  172. }
  173. }
  174.  
  175. @EventHandler
  176. public void onQuit(PlayerQuitEvent e) { Player p = e.getPlayer();
  177. p.getInventory().clear();
  178. p.setLevel(0);
  179. }
  180.  
  181. @EventHandler
  182. public void hunger(FoodLevelChangeEvent e)
  183. {
  184. if (getConfig().getBoolean("Disable-FoodLevel-Change")) {
  185. e.setCancelled(true);
  186. return;
  187. }
  188. }
  189.  
  190. @EventHandler
  191. public void onbreak(BlockBreakEvent e) {
  192. if (getConfig().getBoolean("Disable-Block-Break")) {
  193. e.setCancelled(true);
  194. return;
  195. }
  196. }
  197.  
  198. @EventHandler
  199. public void onPick(PlayerPickupItemEvent e)
  200. {
  201. if (getConfig().getBoolean("Disable-Item-Pickup")) {
  202. e.setCancelled(true);
  203. return;
  204. }
  205. }
  206.  
  207. @EventHandler
  208. public void itemdrop(PlayerDropItemEvent e) { if (getConfig().getBoolean("Disable-ItemDrop")) {
  209. e.setCancelled(true);
  210. return;
  211. }
  212. }
  213.  
  214. @EventHandler
  215. public void onDeath(PlayerDeathEvent e)
  216. {
  217. if ((!(e.getEntity() instanceof Player)) ||
  218. ((e.getEntity().getKiller() instanceof Player)));
  219. e.getDrops().clear();
  220. Player p = e.getEntity().getPlayer();
  221. Player k = e.getEntity().getKiller();
  222. e.setDroppedExp(0);
  223. Damageable pl = k;
  224. int health = (int)pl.getHealth();
  225. int rounded = (int)Math.round(pl.getHealth() * 10.0D) / 10;
  226.  
  227. String ksound = getConfig().getString("On Kill Sound");
  228. String dsound = getConfig().getString("On Death Sound");
  229. if (getConfig().getBoolean("Sounds")) {
  230. k.playSound(k.getLocation(), Sound.valueOf(ksound), 1.0F, 1.0F);
  231. p.playSound(p.getLocation(), Sound.valueOf(dsound), 1.0F, 1.0F);
  232. }
  233. if (getConfig().getBoolean("Flint-And-Steel")) {
  234. k.getInventory().addItem(new ItemStack[] { new ItemStack(Material.FIRE, 1) });
  235. k.setFireTicks(0);
  236. }
  237.  
  238. String pname = p.getDisplayName();
  239. String kname = k.getDisplayName();
  240. int kills = stats.getInt("Stats.Players." + kname + ".Kills");
  241. int deaths = stats.getInt("Stats.Players." + pname + ".Deaths");
  242.  
  243. ChillinqStyle(p, k);
  244.  
  245. stats.set("Stats.Players." + kname + ".Kills", Integer.valueOf(kills + 1));
  246. stats.set("Stats.Players." + pname + ".Deaths", Integer.valueOf(deaths + 1));
  247. try
  248. {
  249. stats.save(file);
  250. } catch (IOException e1) {
  251. e1.printStackTrace();
  252. }
  253.  
  254. if (getConfig().getBoolean("KillStreak"))
  255. {
  256. k.setLevel(k.getLevel() + 1);
  257. p.setLevel(0);
  258. }
  259.  
  260. k.setHealth(20.0D);
  261. e.setDeathMessage(null);
  262. p.sendMessage(this.prefix + " §3You have been killed by §e" + k.getDisplayName() + " §3with §e" + rounded + " §3hearts left.");
  263. k.sendMessage(this.prefix + " §3You have killed §e" + p.getDisplayName() + " §3with §e" + rounded + " §3hearts left.");
  264.  
  265. if (getConfig().getBoolean("Bow and Arrows"))
  266. k.getInventory().addItem(new ItemStack[] { new ItemStack(Material.ARROW, 2) });
  267. }
  268.  
  269. @EventHandler
  270. public void PlayerLevel(PlayerLevelChangeEvent e)
  271. {
  272. Player p = e.getPlayer();
  273. String name = "";
  274. name = name.replace("%NAME%", p.getDisplayName());
  275. if (getConfig().getBoolean("KillStreak")) {
  276. if (e.getNewLevel() == 5) {
  277. Bukkit.broadcastMessage(this.prefix + " §e" + p.getDisplayName() + " §3has reached a killstreak of §e5§3.");
  278. p.playSound(p.getLocation(), Sound.WITHER_SHOOT, 1.0F, 1.0F);
  279. }
  280. if (e.getNewLevel() == 10) {
  281. Bukkit.broadcastMessage(this.prefix + " §e" + p.getDisplayName() + " §3has reached a killstreak of §e10§3.");
  282. p.playSound(p.getLocation(), Sound.WITHER_SHOOT, 1.0F, 1.0F);
  283. }
  284. if (e.getNewLevel() == 15) {
  285. Bukkit.broadcastMessage(this.prefix + " §e" + p.getDisplayName() + " §3has reached a killstreak of §e15§3.");
  286. p.playSound(p.getLocation(), Sound.WITHER_SHOOT, 1.0F, 1.0F);
  287. }
  288. if (e.getNewLevel() == 20) {
  289. Bukkit.broadcastMessage(this.prefix + " §e" + p.getDisplayName() + " §3has reached a killstreak of §e20§3.");
  290. p.playSound(p.getLocation(), Sound.WITHER_SHOOT, 1.0F, 1.0F);
  291. }
  292. if (e.getNewLevel() == 25) {
  293. Bukkit.broadcastMessage(this.prefix + " §e" + p.getDisplayName() + " §3has reached a killstreak of §e25§3.");
  294. p.playSound(p.getLocation(), Sound.WITHER_SHOOT, 1.0F, 1.0F);
  295. }
  296. if (e.getNewLevel() == 30) {
  297. Bukkit.broadcastMessage(this.prefix + " §e" + p.getDisplayName() + " §3has reached a killstreak of §e30§3.");
  298. p.playSound(p.getLocation(), Sound.WITHER_SHOOT, 1.0F, 1.0F);
  299. }
  300. if (e.getNewLevel() == 35) {
  301. Bukkit.broadcastMessage(this.prefix + " §e" + p.getDisplayName() + " §3has reached a killstreak of §e35§3.");
  302. p.playSound(p.getLocation(), Sound.WITHER_SHOOT, 1.0F, 1.0F);
  303. }
  304. if (e.getNewLevel() == 40) {
  305. Bukkit.broadcastMessage(this.prefix + " §e" + p.getDisplayName() + " §3has reached a killstreak of §e40§3.");
  306. p.playSound(p.getLocation(), Sound.WITHER_SHOOT, 1.0F, 1.0F);
  307. }
  308. if (e.getNewLevel() == 45) {
  309. Bukkit.broadcastMessage(this.prefix + " §e" + p.getDisplayName() + " §3has reached a killstreak of §e45§3.");
  310. p.playSound(p.getLocation(), Sound.WITHER_SHOOT, 1.0F, 1.0F);
  311. }
  312. if (e.getNewLevel() == 50) {
  313. Bukkit.broadcastMessage(this.prefix + " §e" + p.getDisplayName() + " §3has reached a killstreak of §e50§3.");
  314. p.playSound(p.getLocation(), Sound.WITHER_SHOOT, 1.0F, 1.0F);
  315. }
  316. }
  317. }
  318.  
  319. @EventHandler
  320. public void onRespawn(PlayerRespawnEvent e) {
  321. Player p = e.getPlayer();
  322. p.getInventory().clear();
  323. p.performCommand("spawn");
  324. p.performCommand("ffakit");
  325. }
  326. public int getPing(Player p) {
  327. CraftPlayer cp = (CraftPlayer)p; EntityPlayer ep = cp.getHandle(); return ep.ping;
  328. }
  329.  
  330. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  331. Player p = (Player)sender;
  332. if ((!(sender instanceof Player)) ||
  333. (cmd.getName().equalsIgnoreCase("ffa")))
  334. {
  335. if (p.hasPermission("Chillinq.ffa.help")) {
  336. p.sendMessage("§8§m----------------------- " + this.prefix + " §eCommands §8§m-----------------------");
  337. p.sendMessage(" ");
  338. p.sendMessage("§e/ffa §3to get this menu");
  339. p.sendMessage("§e/ffasetspawn §3set the spawn for ffa.");
  340. p.sendMessage("§e/spawn §3to teleport to the ffaspawn.");
  341. p.sendMessage("§e/records §3or §e/stats §3to see your statistics");
  342. p.sendMessage("§e/fly §3to toggle flight. ");
  343. p.sendMessage("§e/fix §3to deghost your self.");
  344. p.sendMessage("§e/ping §3to see your ping.");
  345. p.sendMessage("§e/vanish §3or §e/v §3to toggle vanish");
  346. p.sendMessage("§e/ffareload §3to reload the plugin.");
  347. p.sendMessage("§e/flyspeed §3to set fly speed.");
  348. p.sendMessage("§e/clearchat §3or §e/cc §3to clear the chat.");
  349. p.sendMessage(" ");
  350. p.sendMessage("§8§m----------------------- " + this.prefix + " §eCommands §8§m-----------------------");
  351. } else {
  352. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("No Permission message")));
  353. return true;
  354. }
  355. }
  356. ItemStack arrow;
  357. if (cmd.getName().equalsIgnoreCase("ffakit")) {
  358. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("Gain kit message")));
  359.  
  360. p.setHealth(20.0D);
  361.  
  362. p.getInventory().setHelmet(new ItemStack(Material.getMaterial(getConfig().getInt("Helmet"))));
  363. p.getInventory().setChestplate(new ItemStack(Material.getMaterial(getConfig().getInt("Chestplate"))));
  364. p.getInventory().setLeggings(new ItemStack(Material.getMaterial(getConfig().getInt("Leggings"))));
  365. p.getInventory().setBoots(new ItemStack(Material.getMaterial(getConfig().getInt("Boots"))));
  366. p.getInventory().addItem(new ItemStack[] { Sword() });
  367. p.getInventory().setItem(0, Sword());
  368.  
  369. p.getInventory().addItem(new ItemStack[] { Item1() });
  370. p.getInventory().setItem(4, Item1());
  371. p.getInventory().addItem(new ItemStack[] { Item2() });
  372. p.getInventory().setItem(5, Item2());
  373.  
  374. if (getConfig().getBoolean("Fishing-Rod")) {
  375. ItemStack rod = new ItemStack(Material.FISHING_ROD, 1);
  376. p.getInventory().setItem(1, rod);
  377. }
  378. if (getConfig().getBoolean("Bow and Arrows")) {
  379. ItemStack bow = new ItemStack(Material.BOW, 1);
  380. p.getInventory().setItem(2, bow);
  381. arrow = new ItemStack(Material.ARROW, 2);
  382. p.getInventory().setItem(3, arrow);
  383. }
  384.  
  385. if (getConfig().getBoolean("Flint-And-Steel")) {
  386. ItemStack fns = new ItemStack(Material.FIRE);
  387. p.getInventory().setItem(8, fns);
  388. }
  389.  
  390. }
  391.  
  392. if (cmd.getName().equalsIgnoreCase("fix"))
  393. {
  394. p.teleport(p);
  395. p.teleport(p.getLocation().add(2.5D, 0.0D, 0.0D));
  396. p.teleport(p.getLocation().add(-2.5D, 0.0D, 0.0D));
  397. p.teleport(p.getLocation().add(0.0D, 2.5D, 0.0D));
  398. p.teleport(p.getLocation().add(0.0D, -2.5D, 0.0D));
  399. if ((arrow = Bukkit.getOnlinePlayers()).length != 0) { Player h = arrow[0];
  400. h.hidePlayer(p);
  401. p.hidePlayer(h);
  402. h.showPlayer(p);
  403. p.showPlayer(h);
  404.  
  405. if (getConfig().getBoolean("Sounds")) {
  406. p.playSound(p.getLocation(), Sound.NOTE_PLING, 1.0F, 1.0F);
  407. }
  408. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("Fix message")));
  409. return true;
  410. }
  411. }
  412.  
  413. if (cmd.getName().equalsIgnoreCase("fly")) {
  414. if (p.hasPermission("Chillinq.ffa.fly")) {
  415. if (!this.fly.contains(p)) {
  416. if (p.getAllowFlight()) {
  417. p.setAllowFlight(false);
  418. p.setFlying(false);
  419. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("Fly Disable message")));
  420. if (getConfig().getBoolean("Sounds")) {
  421. p.playSound(p.getLocation(), Sound.NOTE_PLING, 1.0F, 1.0F);
  422. }
  423. return true;
  424. }
  425. if (!p.getAllowFlight()) {
  426. p.setAllowFlight(true);
  427. p.setFlying(true);
  428. if (getConfig().getBoolean("Sounds")) {
  429. p.playSound(p.getLocation(), Sound.NOTE_PLING, 1.0F, 1.0F);
  430. }
  431. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("Fly Enable message")));
  432. return true;
  433. }
  434. }
  435. } else {
  436. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("No Permission message")));
  437. return true;
  438. }
  439. }
  440.  
  441. if (cmd.getName().equalsIgnoreCase("ffasetspawn")) {
  442. if (p.hasPermission("Chillinq.ffa.setspawn")) {
  443. getConfig().set("FFASpawn.X", Double.valueOf(p.getLocation().getX()));
  444. getConfig().set("FFASpawn.Y", Double.valueOf(p.getLocation().getY()));
  445. getConfig().set("FFASpawn.Z", Double.valueOf(p.getLocation().getZ()));
  446. getConfig().set("FFASpawn.Pitch", Float.valueOf(p.getLocation().getPitch()));
  447. getConfig().set("FFASpawn.Yaw", Float.valueOf(p.getLocation().getYaw()));
  448. getConfig().set("FFASpawn.World", p.getLocation().getWorld().getName());
  449. p.getWorld().setSpawnLocation(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ());
  450. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("Set spawn message")));
  451.  
  452. if (getConfig().getBoolean("Sounds")) {
  453. p.playSound(p.getLocation(), Sound.ANVIL_USE, 1.0F, 1.0F);
  454. }
  455. saveDefaultConfig();
  456. return true;
  457. }
  458. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("No Permission message")));
  459. }
  460.  
  461. if (cmd.getName().equalsIgnoreCase("spawn")) {
  462. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("Spawn message")));
  463. p.teleport(p.getWorld().getSpawnLocation());
  464. }
  465.  
  466. if ((cmd.getName().equalsIgnoreCase("vanish")) || (cmd.getName().equalsIgnoreCase("v")))
  467. {
  468. if (p.hasPermission("Chillinq.ffa.vanish"))
  469. {
  470. Player[] arrayOfPlayer1;
  471. if (!this.vanished.contains(p)) {
  472. ItemStack localItemStack1 = (arrayOfPlayer1 = Bukkit.getOnlinePlayers()).length; for (arrow = 0; arrow < localItemStack1; arrow++) { Player pl = arrayOfPlayer1[arrow];
  473. pl.hidePlayer(p);
  474. }
  475. this.vanished.add(p);
  476. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("Vanish message")));
  477.  
  478. if (getConfig().getBoolean("Sounds")) {
  479. p.playSound(p.getLocation(), Sound.NOTE_PIANO, 1.0F, 1.0F);
  480. }
  481. return true;
  482. }
  483. ItemStack localItemStack2 = (arrayOfPlayer1 = Bukkit.getOnlinePlayers()).length; for (arrow = 0; arrow < localItemStack2; arrow++) { Player po = arrayOfPlayer1[arrow];
  484. po.showPlayer(p);
  485. }
  486. this.vanished.remove(p);
  487. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("Unvanish message")));
  488.  
  489. if (getConfig().getBoolean("Sounds")) {
  490. p.playSound(p.getLocation(), Sound.NOTE_PIANO, 1.0F, 1.0F);
  491. }
  492. return true;
  493. }
  494.  
  495. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("No Permission message")));
  496. return true;
  497. }
  498.  
  499. if (cmd.getName().equalsIgnoreCase("ffareload")) {
  500. final Player p1 = (Player)sender;
  501. if ((!(sender instanceof Player)) ||
  502. (p.hasPermission("Chillinq.ffa.reload"))) {
  503. getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
  504. public void run() {
  505. if (Main.this.i != -1)
  506. if (Main.this.i != 0) {
  507. p1.sendMessage(Main.this.prefix + " §aReloading config in §e" + Main.this.i);
  508. p1.playSound(p1.getLocation(), Sound.NOTE_PLING, 1.0F, 1.0F);
  509. Main.this.i -= 1;
  510. } else {
  511. Main.this.reloadConfig();
  512. Main.this.saveDefaultConfig();
  513. p1.sendMessage(Main.this.prefix + " §aConfig successfully reloaded.");
  514. p1.playSound(p1.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
  515. Main.this.i -= 1;
  516. }
  517. }
  518. }
  519. , 0L, 20L);
  520. } else {
  521. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("No Permission message")));
  522. return true;
  523. }
  524.  
  525. }
  526.  
  527. if (cmd.getName().equalsIgnoreCase("ping")) {
  528. p.sendMessage(this.prefix + " §3Your ping is §e" + getPing(p) + " §3ms.");
  529. return true;
  530. }
  531.  
  532. if (cmd.getName().equalsIgnoreCase("flyspeed")) {
  533. if (p.hasPermission("Chillinq.ffa.flyspeed")) {
  534. if (args.length == 1)
  535. try {
  536. int speed = Integer.parseInt(args[0]);
  537. p.setFlySpeed(speed / 10.0F);
  538. p.sendMessage(this.prefix + " §3Fly speed set to §e" + speed);
  539. } catch (IllegalArgumentException e) {
  540. p.sendMessage(this.prefix + "§cSpeed §e" + args[0] + " §cis invalid.");
  541. }
  542. else
  543. p.sendMessage(this.prefix + " §c/flyspeed [1 - 10]");
  544. }
  545. else {
  546. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("No Permission message")));
  547. return true;
  548. }
  549. }
  550.  
  551. if ((cmd.getName().equalsIgnoreCase("clearchat")) || (cmd.getName().equalsIgnoreCase("cc"))) {
  552. if (p.hasPermission("Chillinq.ffa.clearchat")) {
  553. Bukkit.broadcastMessage("");
  554. Bukkit.broadcastMessage("");
  555. Bukkit.broadcastMessage("");
  556. Bukkit.broadcastMessage("");
  557. Bukkit.broadcastMessage("");
  558. Bukkit.broadcastMessage("");
  559. Bukkit.broadcastMessage("");
  560. Bukkit.broadcastMessage("");
  561. Bukkit.broadcastMessage("");
  562. Bukkit.broadcastMessage("");
  563. Bukkit.broadcastMessage("");
  564. Bukkit.broadcastMessage("");
  565. Bukkit.broadcastMessage("");
  566. Bukkit.broadcastMessage("");
  567. Bukkit.broadcastMessage("");
  568. Bukkit.broadcastMessage("");
  569. Bukkit.broadcastMessage("");
  570. Bukkit.broadcastMessage("");
  571. Bukkit.broadcastMessage("");
  572. Bukkit.broadcastMessage("");
  573. Bukkit.broadcastMessage("");
  574. Bukkit.broadcastMessage("");
  575. Bukkit.broadcastMessage("");
  576. Bukkit.broadcastMessage("");
  577. Bukkit.broadcastMessage("");
  578. Bukkit.broadcastMessage("");
  579. Bukkit.broadcastMessage("");
  580. Bukkit.broadcastMessage("");
  581. Bukkit.broadcastMessage("");
  582. Bukkit.broadcastMessage("");
  583. Bukkit.broadcastMessage("");
  584. Bukkit.broadcastMessage("");
  585. Bukkit.broadcastMessage("");
  586. Bukkit.broadcastMessage("");
  587. Bukkit.broadcastMessage("");
  588. Bukkit.broadcastMessage("");
  589. Bukkit.broadcastMessage("");
  590. Bukkit.broadcastMessage("");
  591. Bukkit.broadcastMessage("");
  592. Bukkit.broadcastMessage("");
  593. Bukkit.broadcastMessage("");
  594. Bukkit.broadcastMessage("");
  595. Bukkit.broadcastMessage("");
  596. Bukkit.broadcastMessage("");
  597. Bukkit.broadcastMessage("");
  598. Bukkit.broadcastMessage("");
  599. Bukkit.broadcastMessage("");
  600. Bukkit.broadcastMessage("");
  601. Bukkit.broadcastMessage("");
  602. Bukkit.broadcastMessage("");
  603. Bukkit.broadcastMessage("");
  604. Bukkit.broadcastMessage("");
  605. Bukkit.broadcastMessage("");
  606. Bukkit.broadcastMessage("");
  607. Bukkit.broadcastMessage("");
  608. Bukkit.broadcastMessage("");
  609. Bukkit.broadcastMessage("");
  610. Bukkit.broadcastMessage("");
  611. Bukkit.broadcastMessage("");
  612. Bukkit.broadcastMessage("");
  613. Bukkit.broadcastMessage("");
  614. Bukkit.broadcastMessage("");
  615. Bukkit.broadcastMessage("");
  616. Bukkit.broadcastMessage("");
  617. Bukkit.broadcastMessage("");
  618. Bukkit.broadcastMessage("");
  619. Bukkit.broadcastMessage("");
  620. Bukkit.broadcastMessage("");
  621. Bukkit.broadcastMessage("");
  622. Bukkit.broadcastMessage("");
  623. Bukkit.broadcastMessage("");
  624. Bukkit.broadcastMessage("");
  625. Bukkit.broadcastMessage("");
  626. Bukkit.broadcastMessage("");
  627. Bukkit.broadcastMessage("");
  628. Bukkit.broadcastMessage("");
  629. Bukkit.broadcastMessage("");
  630.  
  631. String clear = getConfig().getString("ClearChat broadcast message");
  632. clear = ChatColor.translateAlternateColorCodes('&', clear);
  633. clear = clear.replace("%PLAYERNAME%", p.getDisplayName());
  634. Bukkit.broadcastMessage(this.prefix + " " + clear);
  635. } else {
  636. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("No Permission message")));
  637. return true;
  638. }
  639. }
  640.  
  641. if ((cmd.getName().equalsIgnoreCase("tc")) || (cmd.getName().equalsIgnoreCase("Teamchat")) || (cmd.getName().equalsIgnoreCase("Team"))) {
  642. if (p.hasPermission("Chillinq.ffa.teamchat")) {
  643. if (args.length == 0) {
  644. p.sendMessage(this.prefix + " §e/teamchat <MSG>");
  645. }
  646. if (args.length >= 1) {
  647. String message = "";
  648. for (int i = 0; i < args.length; i++) {
  649. message = message + args[i];
  650. }
  651. for (Player pl : Bukkit.getOnlinePlayers())
  652. if (pl.hasPermission("Chillinq.ffa.teamchat"))
  653. pl.sendMessage(this.prefix + " §cTeam§8» §e" + p.getDisplayName() + " §8»" + " §r" + message);
  654. }
  655. }
  656. else {
  657. p.sendMessage(this.prefix + " " + ChatColor.translateAlternateColorCodes('&', getConfig().getString("No Permission message")));
  658. return true;
  659. }
  660. }
  661.  
  662. if ((cmd.getName().equalsIgnoreCase("msg")) || (cmd.getName().equalsIgnoreCase("message")))
  663. {
  664. if (args.length == 0) {
  665. p.sendMessage("§8│ §3PRIVATE §8│ §3Usage| §e/MSG <PLAYER> <MSG>");
  666. } else if (args.length == 1) {
  667. p.sendMessage("§8│ §3PRIVATE §8│ §3Usage| §e/MSG <PLAYER> <MSG>");
  668. } else if (args.length >= 2) {
  669. Player t = Bukkit.getPlayer(args[0]);
  670.  
  671. if (t != null)
  672. {
  673. String message = "";
  674.  
  675. for (int i = 1; i != args.length; i++)
  676. {
  677. message = message + args[i] + " ";
  678. }
  679.  
  680. t.sendMessage("§8│ §3PRIVATE §8│ §e" + p.getDisplayName() + " §a→" + " §e" + t.getDisplayName() + "§8| §r" + message);
  681.  
  682. p.sendMessage("§8│ §3PRIVATE §8│ §e" + p.getDisplayName() + " §a→" + " §e" + t.getDisplayName() + "§8| §r" + message);
  683. }
  684. else if (t == null)
  685. {
  686. p.sendMessage(this.prefix + " §3Player §e" + args[0] + " §3is not online.");
  687. }
  688.  
  689. }
  690.  
  691. return true;
  692. }
  693.  
  694. if ((cmd.getName().equalsIgnoreCase("Stats")) || (cmd.getName().equalsIgnoreCase("records")))
  695. {
  696. if (args.length == 0)
  697. {
  698. String name = p.getDisplayName();
  699. int kills = stats.getInt("Stats.Players." + name + ".Kills");
  700. int deaths = stats.getInt("Stats.Players." + name + ".Deaths");
  701.  
  702. p.sendMessage("§8§m-------------- §aF§eF§3A §6Stats §8§m--------------");
  703. p.sendMessage("§3Username: §e" + p.getDisplayName());
  704. p.sendMessage("§3Points: §e" + getPoints(p));
  705. p.sendMessage("§3Kills: §e" + kills);
  706. p.sendMessage("§3Deaths: §e" + deaths);
  707. p.sendMessage("§8§m-------------- §aF§eF§3A §6Stats §8§m--------------");
  708. return true;
  709. }
  710. if (args.length == 1) {
  711. Player target = Bukkit.getPlayerExact(args[0]);
  712.  
  713. if (target == null) {
  714. p.sendMessage(this.prefix + " §3The player §e" + args[0] + " §3is not online.");
  715. } else {
  716. String name = target.getDisplayName();
  717. int kills = stats.getInt("Stats.Players." + name + ".Kills");
  718. int deaths = stats.getInt("Stats.Players." + name + ".Deaths");
  719.  
  720. p.sendMessage("§8§m-------------- §aF§eF§3A §6Stats §8§m--------------");
  721. p.sendMessage("§3Username: §e" + target.getDisplayName());
  722. p.sendMessage("§3Points: §e" + getPoints(target));
  723. p.sendMessage("§3Kills: §e" + kills);
  724. p.sendMessage("§3Deaths: §e" + deaths);
  725. p.sendMessage("§8§m-------------- §aF§eF§3A §6Stats §8§m--------------");
  726. return true;
  727. }
  728. }
  729. }
  730.  
  731. return false;
  732. }
  733.  
  734. public ItemStack Sword()
  735. {
  736. ItemStack sword = new ItemStack(new ItemStack(Material.getMaterial(getConfig().getInt("Sword"))));
  737. ItemMeta sw = sword.getItemMeta();
  738. sword.setItemMeta(sw);
  739. return sword;
  740. }
  741.  
  742. public ItemStack Item1()
  743. {
  744. ItemStack item1 = new ItemStack(new ItemStack(Material.getMaterial(getConfig().getInt("Item-1"))));
  745. ItemMeta it = item1.getItemMeta();
  746. item1.setItemMeta(it);
  747.  
  748. return item1;
  749. }
  750.  
  751. public ItemStack Item2()
  752. {
  753. ItemStack item2 = new ItemStack(new ItemStack(Material.getMaterial(getConfig().getInt("Item-2"))));
  754. ItemMeta it = item2.getItemMeta();
  755. item2.setItemMeta(it);
  756.  
  757. return item2;
  758. }
  759.  
  760. @EventHandler(priority=EventPriority.HIGH)
  761. public void onFallDamage(EntityDamageEvent e)
  762. {
  763. if (((e.getEntity() instanceof Player)) && (e.getCause() == EntityDamageEvent.DamageCause.FALL))
  764. {
  765. if (getConfig().getBoolean("Disable-Fall-Damage"))
  766. e.setCancelled(true);
  767. }
  768. }
  769.  
  770. @EventHandler
  771. public void unbreakablearmoranditems(EntityDamageByEntityEvent e) {
  772. if (getConfig().getBoolean("Unbreakable-Items"))
  773. {
  774. if ((e.getDamager() instanceof Player)) {
  775. ((Player)e.getDamager()).getInventory().getItemInHand().setDurability((short)1);
  776. } else if ((e.getEntity() instanceof Player)) {
  777. ItemStack[] armor = ((Player)e.getEntity()).getInventory().getArmorContents();
  778. for (ItemStack i : armor)
  779. i.setDurability((short)0);
  780. }
  781. }
  782. }
  783.  
  784. @EventHandler
  785. public void unbreakablebow(EntityShootBowEvent e)
  786. {
  787. if (getConfig().getBoolean("Unbreakable-Items"))
  788. {
  789. if ((e.getEntity() instanceof Player))
  790. e.getBow().setDurability((short)1);
  791. }
  792. }
  793.  
  794. @EventHandler
  795. public void onItemDamage(PlayerItemBreakEvent e)
  796. {
  797. if (getConfig().getBoolean("Unbreakable-Items"))
  798. {
  799. ItemStack item = e.getBrokenItem().clone();
  800. item.setDurability((short)0);
  801. e.getPlayer().getInventory().addItem(new ItemStack[] { item });
  802. }
  803. }
  804. }
Advertisement
RAW Paste Data Copied
Advertisement