Advertisement
Guest User

Untitled

a guest
Sep 5th, 2015
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.36 KB | None | 0 0
  1. package freecore.grapplinghook;
  2.  
  3. import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
  4. import freecore.grapplinghook.api.HookAPI;
  5. import org.bukkit.*;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.configuration.file.FileConfiguration;
  9. import org.bukkit.entity.Firework;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.inventory.ItemStack;
  13. import org.bukkit.inventory.ShapedRecipe;
  14. import org.bukkit.inventory.meta.FireworkMeta;
  15. import org.bukkit.plugin.Plugin;
  16. import org.bukkit.plugin.java.JavaPlugin;
  17. import org.bukkit.potion.PotionEffect;
  18. import org.bukkit.potion.PotionEffectType;
  19. import org.bukkit.util.Vector;
  20.  
  21. import java.io.File;
  22. import java.util.Random;
  23.  
  24. public class GrapplingHook extends JavaPlugin
  25. {
  26. FireworkEffect.Type[] TypeList;
  27.  
  28. public final GrapplingListener alisten;
  29. public static GrapplingHook plugin;
  30. public static WorldGuardPlugin worldGuard;
  31. protected FileConfiguration config;
  32.  
  33. public GrapplingHook() {
  34. this.alisten = new GrapplingListener(this);
  35. this.TypeList = new FireworkEffect.Type[] { FireworkEffect.Type.BALL, FireworkEffect.Type.BALL_LARGE, FireworkEffect.Type.BURST, FireworkEffect.Type.CREEPER, FireworkEffect.Type.STAR };
  36. }
  37.  
  38. public void onEnable() {
  39. getLogger().info("=--------------------------------------------=");
  40. getLogger().info("| Successfully started! Beta v0.2 |");
  41. getLogger().info("| Thanks for download our plugin! |");
  42. getLogger().info("| Type /fcteam to see FREECORE team |");
  43. getLogger().info("=--------------------------------------------=");
  44. GrapplingHook.plugin = this;
  45. this.getServer().getPluginManager().registerEvents((Listener)this.alisten, (Plugin)this);
  46. final File configFile = new File(this.getDataFolder() + "/config.yml");
  47. if (!configFile.exists()) {
  48. this.saveDefaultConfig();
  49. }
  50. final Plugin plugin = this.getServer().getPluginManager().getPlugin("WorldGuard");
  51. if (plugin != null && plugin instanceof WorldGuardPlugin) {
  52. GrapplingHook.worldGuard = (WorldGuardPlugin)plugin;
  53. }
  54. /**StaticVars.usePerms = this.getConfig().getBoolean("usePermissions");**/
  55. StaticVars.teleportHooked = this.getConfig().getBoolean("teleportToHook");
  56. StaticVars.fallDamage = this.getConfig().getBoolean("fallDamageWithHook");
  57. /**StaticVars.disableCrafting = this.getConfig().getBoolean("disableCrafting");**/
  58. /**StaticVars.woodUses = this.getConfig().getConfigurationSection("Uses").getInt("wood");**/
  59. /**StaticVars.stoneUses = this.getConfig().getConfigurationSection("Uses").getInt("stone");**/
  60. /**StaticVars.ironUses = this.getConfig().getConfigurationSection("Uses").getInt("iron");**/
  61. /**StaticVars.goldUses = this.getConfig().getConfigurationSection("Uses").getInt("gold");**/
  62. /**StaticVars.diamondUses = this.getConfig().getConfigurationSection("Uses").getInt("diamond");**/
  63. StaticVars.timeBetweenUses = this.getConfig().getInt("timeBetweenGrapples");
  64. /**if (!StaticVars.disableCrafting) {
  65. final ShapedRecipe woodRecipe = new ShapedRecipe(HookAPI.createGrapplingHook(StaticVars.woodUses)).shape(new String[] { " **", " &*", " " }).setIngredient('*', Material.WOOD).setIngredient('&', Material.FISHING_ROD);
  66. final ShapedRecipe stoneRecipe = new ShapedRecipe(HookAPI.createGrapplingHook(StaticVars.stoneUses)).shape(new String[] { " **", " &*", " " }).setIngredient('*', Material.COBBLESTONE).setIngredient('&', Material.FISHING_ROD);
  67. final ShapedRecipe ironRecipe = new ShapedRecipe(HookAPI.createGrapplingHook(StaticVars.ironUses)).shape(new String[] { " **", " &*", " " }).setIngredient('*', Material.IRON_INGOT).setIngredient('&', Material.FISHING_ROD);
  68. final ShapedRecipe goldRecipe = new ShapedRecipe(HookAPI.createGrapplingHook(StaticVars.goldUses)).shape(new String[] { " **", " &*", " " }).setIngredient('*', Material.GOLD_INGOT).setIngredient('&', Material.FISHING_ROD);
  69. final ShapedRecipe diamondRecipe = new ShapedRecipe(HookAPI.createGrapplingHook(StaticVars.diamondUses)).shape(new String[] { " **", " &*", " " }).setIngredient('*', Material.DIAMOND).setIngredient('&', Material.FISHING_ROD);**/
  70. /**this.getServer().addRecipe((Recipe)woodRecipe);
  71. this.getServer().addRecipe((Recipe)stoneRecipe);
  72. this.getServer().addRecipe((Recipe)ironRecipe);
  73. this.getServer().addRecipe((Recipe)goldRecipe);
  74. this.getServer().addRecipe((Recipe)diamondRecipe);**/
  75. }
  76. /**}**/
  77.  
  78. public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
  79.  
  80. final Player player = (Player) sender;
  81.  
  82. if (sender instanceof Player) {
  83. if (label.equalsIgnoreCase("fch")) {
  84. if (player.hasPermission("freecore.grapplinghook.give")) {
  85. player.setItemInHand(HookAPI.createGrapplingHook(9999));
  86. } else {
  87. player.sendMessage(ChatColor.DARK_RED + "You don't have permission.");
  88. }
  89.  
  90. }
  91. } else {
  92. sender.sendMessage("You must be a player to preform this command.");
  93. return true;
  94. }
  95.  
  96. final Player player1 = (Player) sender;
  97. if (sender instanceof Player) {
  98. if (label.equalsIgnoreCase("fcf")) {
  99. {
  100. if (player1.hasPermission("freecore.fireworks")) {
  101. player1.sendMessage(ChatColor.GREEN + "Firework send! Yeeeah!");
  102. this.shootFireworks((Player) sender);
  103. }
  104. }
  105.  
  106. }
  107.  
  108. } else {
  109. sender.sendMessage("You must be a player to preform this command.");
  110. return true;
  111. }
  112.  
  113. /** **/
  114. final Player player2 = (Player) sender;
  115. if (sender instanceof Player) {
  116. if (label.equalsIgnoreCase("fcj")) {
  117. {
  118. if (player2.hasPermission("freecore.jump")) {
  119. player2.setVelocity(new Vector(player2.getVelocity().getX(), 10, player2.getVelocity().getZ()));
  120. player2.sendMessage(ChatColor.AQUA + "Jump! Jump! Jump!");
  121. }
  122. }
  123. }
  124. } else {
  125. sender.sendMessage("You must be a player to preform this command.");
  126. return true;
  127. }
  128. /** **/
  129.  
  130. final Player player3 = (Player) sender;
  131. if (sender instanceof Player) {
  132. if (label.equalsIgnoreCase("fcteam")) {
  133. player3.sendMessage("=-----------------------------------=");
  134. player3.sendMessage("| Our team: |");
  135. player3.sendMessage("|Deppylute - main developer |");
  136. player3.sendMessage("=-----------------------------------=");
  137.  
  138. }
  139. } else {
  140. sender.sendMessage("You must be a player to preform this command.");
  141. return true;
  142. }
  143.  
  144.  
  145.  
  146.  
  147. /**==============================================================================================================**/
  148.  
  149. final Player player4 = (Player) sender;
  150. if (sender instanceof Player) {
  151. if (label.equalsIgnoreCase("fcnv")) {
  152. if (player4.hasPermission("freecore.nightvision")) {
  153. final Location loc = player.getLocation();
  154. player4.playSound(loc, Sound.ITEM_PICKUP, 1.0f, 0.0f);
  155. loc.getWorld().playEffect(loc, Effect.MOBSPAWNER_FLAMES, 2004);
  156. if (player4.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
  157. player4.sendMessage(ChatColor.GOLD + "Yeah! Nightvision disabled!");
  158. player4.removePotionEffect(PotionEffectType.NIGHT_VISION);
  159. return false;
  160. }
  161. player4.sendMessage(ChatColor.GOLD + "Yeah! Nightvision enabled!");
  162. player4.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 100000, 1));
  163. return true;
  164. } else {
  165. player4.sendMessage(ChatColor.GOLD + "You don't have permissions!");
  166. }
  167. }
  168. } else {
  169. sender.sendMessage("You must be a player to preform this command.");
  170. return true;
  171. }
  172.  
  173. /**==============================================================================================================**/
  174.  
  175. return false;
  176. }
  177.  
  178.  
  179. private static boolean isInteger(final String s) {
  180. try {
  181. Integer.parseInt(s);
  182. }
  183. catch (NumberFormatException e) {
  184. return false;
  185. }
  186. return true;
  187. }
  188.  
  189.  
  190. /**==============================================================================================================**/
  191.  
  192. private void shootFireworks(final Player player) {
  193. final Firework fws = (Firework)player.getWorld().spawn(player.getLocation(), (Class)Firework.class);
  194. final FireworkMeta fm = fws.getFireworkMeta();
  195. final Random r = new Random();
  196. final FireworkEffect.Type type = this.TypeList[r.nextInt(5)];
  197. final Color c1i = this.getColour(r.nextInt(16) + 1);
  198. final Color c2i = this.getColour(r.nextInt(16) + 1);
  199. final FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1i).withFade(c2i).with(type).trail(r.nextBoolean()).build();
  200. fm.addEffect(effect);
  201. fm.setPower(r.nextInt(2) + 1);
  202. fws.setFireworkMeta(fm);
  203. }
  204.  
  205. public Color getColour(final int c) {
  206. switch (c) {
  207. default: {
  208. return Color.AQUA;
  209. }
  210. case 2: {
  211. return Color.BLACK;
  212. }
  213. case 3: {
  214. return Color.BLUE;
  215. }
  216. case 4: {
  217. return Color.FUCHSIA;
  218. }
  219. case 5: {
  220. return Color.GRAY;
  221. }
  222. case 6: {
  223. return Color.GREEN;
  224. }
  225. case 7: {
  226. return Color.LIME;
  227. }
  228. case 8: {
  229. return Color.MAROON;
  230. }
  231. case 9: {
  232. return Color.NAVY;
  233. }
  234. case 10: {
  235. return Color.OLIVE;
  236. }
  237. case 11: {
  238. return Color.ORANGE;
  239. }
  240. case 12: {
  241. return Color.PURPLE;
  242. }
  243. case 13: {
  244. return Color.RED;
  245. }
  246. case 14: {
  247. return Color.SILVER;
  248. }
  249. case 15: {
  250. return Color.TEAL;
  251. }
  252. case 16: {
  253. return Color.WHITE;
  254. }
  255. case 17: {
  256. return Color.YELLOW;
  257. }
  258. }
  259. }
  260. /**==============================================================================================================**/
  261. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement