Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.66 KB | None | 0 0
  1. package me.nosma_stew.thewalkingdead;
  2.  
  3. import java.util.Random;
  4. import java.util.logging.Logger;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.Material;
  9. import org.bukkit.command.Command;
  10. import org.bukkit.command.CommandSender;
  11. import org.bukkit.command.ConsoleCommandSender;
  12. import org.bukkit.entity.Entity;
  13. import org.bukkit.entity.LivingEntity;
  14. import org.bukkit.entity.Player;
  15. import org.bukkit.entity.Zombie;
  16. import org.bukkit.event.EventHandler;
  17. import org.bukkit.event.Listener;
  18. import org.bukkit.event.entity.CreatureSpawnEvent;
  19. import org.bukkit.event.entity.EntityCombustEvent;
  20. import org.bukkit.event.entity.EntityDamageByEntityEvent;
  21. import org.bukkit.event.entity.EntityDeathEvent;
  22. import org.bukkit.event.entity.EntityTargetEvent;
  23. import org.bukkit.inventory.ItemStack;
  24. import org.bukkit.plugin.Plugin;
  25. import org.bukkit.plugin.RegisteredServiceProvider;
  26. import org.bukkit.plugin.java.JavaPlugin;
  27. import org.bukkit.potion.PotionEffect;
  28. import org.bukkit.potion.PotionEffectType;
  29.  
  30. import net.milkbowl.vault.economy.Economy;
  31.  
  32. public class Main extends JavaPlugin implements Listener {
  33.  
  34. public static Plugin plugin;
  35. private static final Logger log = Logger.getLogger("Minecraft");
  36. public static Economy econ = null;
  37.  
  38. public void onEnable() {
  39. getConfig().options().copyDefaults(true);
  40. saveConfig();
  41. Bukkit.getServer().getPluginManager().registerEvents(new InfiniteCauldron(this), this);
  42. Bukkit.getServer().getPluginManager().registerEvents(new CustomZombie(this), this);
  43. Bukkit.getServer().getPluginManager().registerEvents(this, this);
  44. Bukkit.getConsoleSender().sendMessage(org.bukkit.ChatColor.GREEN + "TheWalkingDead is now enabled - Version Using: " + getDescription().getVersion());
  45. if (!setupEconomy() ) {
  46. log.severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
  47. getServer().getPluginManager().disablePlugin(this);
  48. return;
  49. }
  50. }
  51.  
  52.  
  53. private boolean setupEconomy() {
  54. if (getServer().getPluginManager().getPlugin("Vault") == null) {
  55. return false;
  56. }
  57. RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
  58. if (rsp == null) {
  59. return false;
  60. }
  61. econ = rsp.getProvider();
  62. return econ != null;
  63. }
  64.  
  65.  
  66. public void onDisable() {
  67. saveConfig();
  68. Bukkit.getConsoleSender().sendMessage(org.bukkit.ChatColor.GREEN + "TheWalkingDead is now disabled - Version Using: " + getDescription().getVersion());
  69. }
  70.  
  71. @EventHandler
  72. public void onEntityDeath(EntityDeathEvent e)
  73. {
  74. if (this.getConfig().getBoolean("Zombies-MoneyReward") == true) {
  75. if (e.getEntity().getKiller() instanceof Player && e.getEntity() instanceof Zombie) {
  76. Player p = e.getEntity().getKiller();
  77. econ.depositPlayer(p, getConfig().getDouble("Zombies-SetMoneyReward", 10.00));
  78. p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("Zombies-RewardMessage")));
  79. }
  80. }
  81. }
  82.  
  83. @EventHandler
  84. public void onEntityTarget(EntityTargetEvent e)
  85. {
  86. Entity z = e.getEntity();
  87. if (e.getTarget() instanceof Player)
  88. {
  89. Player p = (Player) e.getTarget();
  90. if(z instanceof Zombie && p instanceof Player)
  91. {
  92. if(p.getInventory().getChestplate() != null)
  93. {
  94. if(p.getInventory().getChestplate().getType() == Material.GOLD_CHESTPLATE)
  95. {
  96. p.getInventory().getChestplate().setDurability((short) +1);
  97. e.setCancelled(true);
  98. }
  99. }
  100. }
  101. }
  102. }
  103.  
  104. @EventHandler
  105. public void onZombieSpawn(CreatureSpawnEvent e)
  106. {
  107. Entity zombie = e.getEntity();
  108. int hp = getConfig().getInt("Zombies-SetHealth");
  109.  
  110. if ((zombie instanceof Zombie)) {
  111. ((Zombie)zombie).setHealth(hp);
  112. zombie.setCustomName(ChatColor.translateAlternateColorCodes('&', getConfig().getString("Zombies-SetName")));
  113. }
  114. }
  115.  
  116. @EventHandler
  117. public void entityCombust(EntityCombustEvent e)
  118. {
  119. Entity entity = e.getEntity();
  120. if(entity instanceof LivingEntity)
  121. {
  122. LivingEntity le = (LivingEntity) entity;
  123. if(le instanceof Zombie)
  124. {
  125. Zombie zombie = (Zombie) le;
  126. if(zombie.getWorld().getTime() >= 0L && zombie.getWorld().getTime() <= 24000L)
  127. {
  128. e.setCancelled(true);
  129. }
  130. }
  131. }
  132.  
  133. }
  134.  
  135. @EventHandler
  136. public void onentitydie(EntityDeathEvent e)
  137. {
  138. e.setDroppedExp(0);
  139. if ((e.getEntity() instanceof Zombie)) {
  140. e.getDrops().clear();
  141. Random ob = new Random();
  142.  
  143. for (int counter = 1; counter <= 1; counter++) {
  144. int num = 1 + ob.nextInt(4);
  145. if (num == 3) {
  146. e.getEntity().getLocation().getWorld().dropItemNaturally(e.getEntity().getLocation(), new ItemStack(Material.ROTTEN_FLESH, 0));
  147. }
  148. }
  149. }
  150. if ((e.getEntity() instanceof Zombie))
  151. e.getDrops().clear();
  152.  
  153. }
  154.  
  155. @EventHandler
  156. public void ZombieStrength(EntityDamageByEntityEvent e)
  157. {
  158. int strength = getConfig().getInt("Zombies-SetStrength");
  159. if ((e.getDamager() instanceof Zombie))
  160. e.setDamage(strength);
  161. }
  162.  
  163. @EventHandler
  164. public void onZombieHitPlayer(EntityDamageByEntityEvent e) {
  165. int poison = getConfig().getInt("PoisonEffect");
  166. int nausea = getConfig().getInt("NauseaEffect");
  167. int blindness = getConfig().getInt("BlindnessEffect");
  168. int saturation = getConfig().getInt("SaturationEffect");
  169. int harm = getConfig().getInt("HarmEffect");
  170. int slowness = getConfig().getInt("SlownessEffect");
  171. int weakness = getConfig().getInt("WeaknessEffect");
  172. int increasedamage = getConfig().getInt("IncreaseDamageEffect");
  173.  
  174. if (((e.getDamager() instanceof Zombie)) && ((e.getEntity() instanceof Player))) {
  175.  
  176. ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, slowness, 1));
  177. ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.POISON, poison, 1));
  178. ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, nausea, 5));
  179. ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindness, 1));
  180. ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, saturation, 1));
  181. ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.HARM, harm, 1));
  182. ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, weakness, 1));
  183. ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, increasedamage, 1));
  184. }
  185.  
  186. }
  187.  
  188. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
  189. {
  190. if (cmd.getName().equalsIgnoreCase("twd-reload") || (cmd.getName().equalsIgnoreCase("thewalkingdead-reload")))
  191. {
  192. if (sender instanceof Player)
  193. {
  194. Player player = (Player) sender;
  195. if (player.hasPermission("thewalkingdead.reload"))
  196. {
  197. player.sendMessage(ChatColor.GREEN + ("TheWalkingDead config was successful reloaded!"));
  198. this.reloadConfig();
  199. }
  200. else
  201. {
  202. player.sendMessage(ChatColor.RED + ("You don't have the permission to do that"));
  203. }
  204. }
  205. else if (sender instanceof ConsoleCommandSender)
  206. {
  207. ConsoleCommandSender console = (ConsoleCommandSender) sender;
  208. this.reloadConfig();
  209. console.sendMessage(ChatColor.GREEN + ("TheWalkingDead config was successful reloaded!"));
  210. }
  211. }
  212. else if (cmd.getName().equalsIgnoreCase("twd-version") || (cmd.getName().equalsIgnoreCase("thewalkingdead-version")))
  213. {
  214. if (sender instanceof Player)
  215. {
  216. Player player = (Player) sender;
  217. if (player.hasPermission("thewalkingdead.version"))
  218. {
  219. player.sendMessage(ChatColor.GREEN + ("Current Version Using: " + getDescription().getVersion()));
  220. }
  221. else
  222. {
  223. player.sendMessage(ChatColor.RED + ("You don't have the permission to do that"));
  224. }
  225. }
  226. else if (sender instanceof ConsoleCommandSender)
  227. {
  228. ConsoleCommandSender console = (ConsoleCommandSender) sender;
  229. console.sendMessage(ChatColor.GREEN + ("Current Version Using: " + getDescription().getVersion()));
  230. }
  231. }
  232. else if (cmd.getName().equalsIgnoreCase("twd") || (cmd.getName().equalsIgnoreCase("thewalkingdead")))
  233. {
  234. if (sender instanceof Player)
  235. {
  236. Player player = (Player) sender;
  237. if (player.hasPermission("thewalkingdead.use"))
  238. {
  239. player.sendMessage(ChatColor.RED + (" ------[") + ChatColor.WHITE + (" The Walking Dead ") + ChatColor.RED + ("]------"));
  240. player.sendMessage(ChatColor.RED + (" Author:") + ChatColor.GRAY + (" Nosma_Stew "));
  241. player.sendMessage(ChatColor.RED + (" Version:") + ChatColor.GRAY + (" ") + getDescription().getVersion());
  242. player.sendMessage(ChatColor.RED + (" Aliases:") + ChatColor.GRAY + (" /twd, /thewalkingdead "));
  243. player.sendMessage(ChatColor.RED + (" Commands:"));
  244. player.sendMessage(ChatColor.RED + (" - ") + ChatColor.GRAY + ("/twd-reload - Reloads The Config."));
  245. player.sendMessage(ChatColor.RED + (" - ") + ChatColor.GRAY + ("/twd-version - Current Version Using."));
  246. }
  247. else
  248. {
  249. player.sendMessage(ChatColor.RED + ("You don't have the permission to do that"));
  250. }
  251. }
  252. else if (sender instanceof ConsoleCommandSender)
  253. {
  254. ConsoleCommandSender console = (ConsoleCommandSender) sender;
  255. console.sendMessage(ChatColor.RED + (" ------[") + ChatColor.WHITE + (" The Walking Dead ") + ChatColor.RED + ("]------"));
  256. console.sendMessage(ChatColor.RED + (" Author:") + ChatColor.GRAY + (" Nosma_Stew "));
  257. console.sendMessage(ChatColor.RED + (" Version:") + ChatColor.GRAY + (" ") + getDescription().getVersion());
  258. console.sendMessage(ChatColor.RED + (" Aliases:") + ChatColor.GRAY + (" /twd, /thewalkingdead "));
  259. console.sendMessage(ChatColor.RED + (" Commands:"));
  260. console.sendMessage(ChatColor.RED + (" - ") + ChatColor.GRAY + ("/twd-reload - Reloads The Config."));
  261. console.sendMessage(ChatColor.RED + (" - ") + ChatColor.GRAY + ("/twd-version - Current Version Using."));
  262. }
  263. }
  264. return false;
  265. }
  266. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement