Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package freecore.grapplinghook;
- import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
- import freecore.grapplinghook.api.HookAPI;
- import org.bukkit.*;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.entity.Firework;
- import org.bukkit.entity.Player;
- import org.bukkit.event.Listener;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.ShapedRecipe;
- import org.bukkit.inventory.meta.FireworkMeta;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- import org.bukkit.util.Vector;
- import java.io.File;
- import java.util.Random;
- public class GrapplingHook extends JavaPlugin
- {
- FireworkEffect.Type[] TypeList;
- public final GrapplingListener alisten;
- public static GrapplingHook plugin;
- public static WorldGuardPlugin worldGuard;
- protected FileConfiguration config;
- public GrapplingHook() {
- this.alisten = new GrapplingListener(this);
- this.TypeList = new FireworkEffect.Type[] { FireworkEffect.Type.BALL, FireworkEffect.Type.BALL_LARGE, FireworkEffect.Type.BURST, FireworkEffect.Type.CREEPER, FireworkEffect.Type.STAR };
- }
- public void onEnable() {
- getLogger().info("=--------------------------------------------=");
- getLogger().info("| Successfully started! Beta v0.2 |");
- getLogger().info("| Thanks for download our plugin! |");
- getLogger().info("| Type /fcteam to see FREECORE team |");
- getLogger().info("=--------------------------------------------=");
- GrapplingHook.plugin = this;
- this.getServer().getPluginManager().registerEvents((Listener)this.alisten, (Plugin)this);
- final File configFile = new File(this.getDataFolder() + "/config.yml");
- if (!configFile.exists()) {
- this.saveDefaultConfig();
- }
- final Plugin plugin = this.getServer().getPluginManager().getPlugin("WorldGuard");
- if (plugin != null && plugin instanceof WorldGuardPlugin) {
- GrapplingHook.worldGuard = (WorldGuardPlugin)plugin;
- }
- /**StaticVars.usePerms = this.getConfig().getBoolean("usePermissions");**/
- StaticVars.teleportHooked = this.getConfig().getBoolean("teleportToHook");
- StaticVars.fallDamage = this.getConfig().getBoolean("fallDamageWithHook");
- /**StaticVars.disableCrafting = this.getConfig().getBoolean("disableCrafting");**/
- /**StaticVars.woodUses = this.getConfig().getConfigurationSection("Uses").getInt("wood");**/
- /**StaticVars.stoneUses = this.getConfig().getConfigurationSection("Uses").getInt("stone");**/
- /**StaticVars.ironUses = this.getConfig().getConfigurationSection("Uses").getInt("iron");**/
- /**StaticVars.goldUses = this.getConfig().getConfigurationSection("Uses").getInt("gold");**/
- /**StaticVars.diamondUses = this.getConfig().getConfigurationSection("Uses").getInt("diamond");**/
- StaticVars.timeBetweenUses = this.getConfig().getInt("timeBetweenGrapples");
- /**if (!StaticVars.disableCrafting) {
- final ShapedRecipe woodRecipe = new ShapedRecipe(HookAPI.createGrapplingHook(StaticVars.woodUses)).shape(new String[] { " **", " &*", " " }).setIngredient('*', Material.WOOD).setIngredient('&', Material.FISHING_ROD);
- final ShapedRecipe stoneRecipe = new ShapedRecipe(HookAPI.createGrapplingHook(StaticVars.stoneUses)).shape(new String[] { " **", " &*", " " }).setIngredient('*', Material.COBBLESTONE).setIngredient('&', Material.FISHING_ROD);
- final ShapedRecipe ironRecipe = new ShapedRecipe(HookAPI.createGrapplingHook(StaticVars.ironUses)).shape(new String[] { " **", " &*", " " }).setIngredient('*', Material.IRON_INGOT).setIngredient('&', Material.FISHING_ROD);
- final ShapedRecipe goldRecipe = new ShapedRecipe(HookAPI.createGrapplingHook(StaticVars.goldUses)).shape(new String[] { " **", " &*", " " }).setIngredient('*', Material.GOLD_INGOT).setIngredient('&', Material.FISHING_ROD);
- final ShapedRecipe diamondRecipe = new ShapedRecipe(HookAPI.createGrapplingHook(StaticVars.diamondUses)).shape(new String[] { " **", " &*", " " }).setIngredient('*', Material.DIAMOND).setIngredient('&', Material.FISHING_ROD);**/
- /**this.getServer().addRecipe((Recipe)woodRecipe);
- this.getServer().addRecipe((Recipe)stoneRecipe);
- this.getServer().addRecipe((Recipe)ironRecipe);
- this.getServer().addRecipe((Recipe)goldRecipe);
- this.getServer().addRecipe((Recipe)diamondRecipe);**/
- }
- /**}**/
- public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
- final Player player = (Player) sender;
- if (sender instanceof Player) {
- if (label.equalsIgnoreCase("fch")) {
- if (player.hasPermission("freecore.grapplinghook.give")) {
- player.setItemInHand(HookAPI.createGrapplingHook(9999));
- } else {
- player.sendMessage(ChatColor.DARK_RED + "You don't have permission.");
- }
- }
- } else {
- sender.sendMessage("You must be a player to preform this command.");
- return true;
- }
- final Player player1 = (Player) sender;
- if (sender instanceof Player) {
- if (label.equalsIgnoreCase("fcf")) {
- {
- if (player1.hasPermission("freecore.fireworks")) {
- player1.sendMessage(ChatColor.GREEN + "Firework send! Yeeeah!");
- this.shootFireworks((Player) sender);
- }
- }
- }
- } else {
- sender.sendMessage("You must be a player to preform this command.");
- return true;
- }
- /** **/
- final Player player2 = (Player) sender;
- if (sender instanceof Player) {
- if (label.equalsIgnoreCase("fcj")) {
- {
- if (player2.hasPermission("freecore.jump")) {
- player2.setVelocity(new Vector(player2.getVelocity().getX(), 10, player2.getVelocity().getZ()));
- player2.sendMessage(ChatColor.AQUA + "Jump! Jump! Jump!");
- }
- }
- }
- } else {
- sender.sendMessage("You must be a player to preform this command.");
- return true;
- }
- /** **/
- final Player player3 = (Player) sender;
- if (sender instanceof Player) {
- if (label.equalsIgnoreCase("fcteam")) {
- player3.sendMessage("=-----------------------------------=");
- player3.sendMessage("| Our team: |");
- player3.sendMessage("|Deppylute - main developer |");
- player3.sendMessage("=-----------------------------------=");
- }
- } else {
- sender.sendMessage("You must be a player to preform this command.");
- return true;
- }
- /**==============================================================================================================**/
- final Player player4 = (Player) sender;
- if (sender instanceof Player) {
- if (label.equalsIgnoreCase("fcnv")) {
- if (player4.hasPermission("freecore.nightvision")) {
- final Location loc = player.getLocation();
- player4.playSound(loc, Sound.ITEM_PICKUP, 1.0f, 0.0f);
- loc.getWorld().playEffect(loc, Effect.MOBSPAWNER_FLAMES, 2004);
- if (player4.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
- player4.sendMessage(ChatColor.GOLD + "Yeah! Nightvision disabled!");
- player4.removePotionEffect(PotionEffectType.NIGHT_VISION);
- return false;
- }
- player4.sendMessage(ChatColor.GOLD + "Yeah! Nightvision enabled!");
- player4.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 100000, 1));
- return true;
- } else {
- player4.sendMessage(ChatColor.GOLD + "You don't have permissions!");
- }
- }
- } else {
- sender.sendMessage("You must be a player to preform this command.");
- return true;
- }
- /**==============================================================================================================**/
- return false;
- }
- private static boolean isInteger(final String s) {
- try {
- Integer.parseInt(s);
- }
- catch (NumberFormatException e) {
- return false;
- }
- return true;
- }
- /**==============================================================================================================**/
- private void shootFireworks(final Player player) {
- final Firework fws = (Firework)player.getWorld().spawn(player.getLocation(), (Class)Firework.class);
- final FireworkMeta fm = fws.getFireworkMeta();
- final Random r = new Random();
- final FireworkEffect.Type type = this.TypeList[r.nextInt(5)];
- final Color c1i = this.getColour(r.nextInt(16) + 1);
- final Color c2i = this.getColour(r.nextInt(16) + 1);
- final FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1i).withFade(c2i).with(type).trail(r.nextBoolean()).build();
- fm.addEffect(effect);
- fm.setPower(r.nextInt(2) + 1);
- fws.setFireworkMeta(fm);
- }
- public Color getColour(final int c) {
- switch (c) {
- default: {
- return Color.AQUA;
- }
- case 2: {
- return Color.BLACK;
- }
- case 3: {
- return Color.BLUE;
- }
- case 4: {
- return Color.FUCHSIA;
- }
- case 5: {
- return Color.GRAY;
- }
- case 6: {
- return Color.GREEN;
- }
- case 7: {
- return Color.LIME;
- }
- case 8: {
- return Color.MAROON;
- }
- case 9: {
- return Color.NAVY;
- }
- case 10: {
- return Color.OLIVE;
- }
- case 11: {
- return Color.ORANGE;
- }
- case 12: {
- return Color.PURPLE;
- }
- case 13: {
- return Color.RED;
- }
- case 14: {
- return Color.SILVER;
- }
- case 15: {
- return Color.TEAL;
- }
- case 16: {
- return Color.WHITE;
- }
- case 17: {
- return Color.YELLOW;
- }
- }
- }
- /**==============================================================================================================**/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement