diff --git a/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java b/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java index b8ad2bd..c04e93d 100644 --- a/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java +++ b/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java @@ -1,91 +1,95 @@ -package buttondevteam.alipresents.components.dungeons.dungeons; - -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.plugin.java.JavaPlugin; - -public class GenericDungeonA1 extends Dungeon{ - private Location entrance; - private Location exit; - private JavaPlugin plugin; - - public GenericDungeonA1(JavaPlugin plugin){ - if(!initDungeon(plugin)){ - plugin.getServer().broadcastMessage("DungeonA1 cant be initialized!"); - } - this.plugin = plugin; - } - private boolean initDungeon(JavaPlugin plugin){ - /* - if (plugin.getServer().getWorld("Dungeons") == null || plugin.getServer().getWorld("world") == null){ - plugin.getServer().broadcastMessage("GenericDungeonA1Error! One of the worlds is null!"); - plugin.getServer().broadcastMessage("Available Worlds... " + plugin.getServer().getWorlds().toString()); - return false; - }*/ - Location temp; - if ((temp = loadLocation(plugin, "dungeons.dungeona1.enter")) != null){ - entrance = temp; - }else if(plugin.getServer().getWorld("Dungeons") != null){ - entrance = new Location(plugin.getServer().getWorld("Dungeons"), -7.5, 138.0, -91.5); - }else{ - plugin.getServer().broadcastMessage("There is no working default dungeon entrance for A1, setting to null"); - entrance = null; - } - - temp = null; - if ((temp = loadLocation(plugin, "dungeons.dungeona1.exit")) != null){ - exit = temp; - }else if (plugin.getServer().getWorld("world") != null){ - exit = plugin.getServer().getWorld("world").getSpawnLocation().clone(); - }else{ - plugin.getServer().broadcastMessage("There is no working default dungeon exit for A1, setting to null"); - exit = null; - } - - if (entrance == null || exit == null){ - plugin.getServer().broadcastMessage("DungeonA1Error! Dungeon Entrance or Exit is null!"); - plugin.getServer().broadcastMessage("Dungeon Entrance: " + entrance.toString()); - plugin.getServer().broadcastMessage("Dungeon Exit: " + exit.toString()); - return false; - } - return true; - } - @Override - public void setEntrance(Location location){ - saveLocation(plugin, "dungeons.dungeona1.enter", location); - entrance = location; - } - @Override - public void setExit(Location location){ - saveLocation(plugin, "dungeons.dungeona1.exit", location); - exit = location; - } - @Override - public Location getDungeonEntrance() { - return entrance; - } - @Override - public Location getDungeonExit() { - return exit; - } - private void saveLocation(JavaPlugin plugin, String path, Location location){ - plugin.getConfig().set(path+".world", location.getWorld().getName()); - plugin.getConfig().set(path+".x", location.getX()); - plugin.getConfig().set(path+".y", location.getY()); - plugin.getConfig().set(path+".z", location.getZ()); - plugin.saveConfig(); - } - private Location loadLocation(JavaPlugin plugin, String path){ - try{ - World world = plugin.getServer().getWorld(plugin.getConfig().getString(path+".world")); - double x = plugin.getConfig().getDouble(path+".x"); - double y = plugin.getConfig().getDouble(path+".y"); - double z = plugin.getConfig().getDouble(path+".z"); - - return new Location(world, x, y, z); - }catch(Exception e){ - e.printStackTrace(); - return null; - } - } -} +package buttondevteam.alipresents.components.dungeons.dungeons; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.plugin.java.JavaPlugin; + +public class GenericDungeonA1 extends Dungeon{ + private Location entrance; + private Location exit; + private JavaPlugin plugin; + + public GenericDungeonA1(JavaPlugin plugin){ + if(!initDungeon(plugin)){ + plugin.getServer().broadcastMessage("DungeonA1 cant be initialized!"); + } + this.plugin = plugin; + } + private boolean initDungeon(JavaPlugin plugin){ + /* + if (plugin.getServer().getWorld("Dungeons") == null || plugin.getServer().getWorld("world") == null){ + plugin.getServer().broadcastMessage("GenericDungeonA1Error! One of the worlds is null!"); + plugin.getServer().broadcastMessage("Available Worlds... " + plugin.getServer().getWorlds().toString()); + return false; + }*/ + Location temp; + if ((temp = loadLocation(plugin, "dungeons.dungeona1.enter")) != null){ + entrance = temp; + }else if(plugin.getServer().getWorld("Dungeons") != null){ + entrance = new Location(plugin.getServer().getWorld("Dungeons"), -7.5, 138.0, -91.5); + }else{ + plugin.getServer().broadcastMessage("There is no working default dungeon entrance for A1, setting to null"); + entrance = null; + } + + temp = null; + if ((temp = loadLocation(plugin, "dungeons.dungeona1.exit")) != null){ + exit = temp; + }else if (plugin.getServer().getWorld("world") != null){ + exit = plugin.getServer().getWorld("world").getSpawnLocation().clone(); + }else{ + plugin.getServer().broadcastMessage("There is no working default dungeon exit for A1, setting to null"); + exit = null; + } + + if (entrance == null || exit == null){ + plugin.getServer().broadcastMessage("DungeonA1Error! Dungeon Entrance or Exit is null!"); + plugin.getServer().broadcastMessage("Dungeon Entrance: " + entrance.toString()); + plugin.getServer().broadcastMessage("Dungeon Exit: " + exit.toString()); + return false; + } + return true; + } + @Override + public void setEntrance(Location location){ + saveLocation(plugin, "dungeons.dungeona1.enter", location); + entrance = location; + } + @Override + public void setExit(Location location){ + saveLocation(plugin, "dungeons.dungeona1.exit", location); + exit = location; + } + @Override + public Location getDungeonEntrance() { + return entrance; + } + @Override + public Location getDungeonExit() { + return exit; + } + private void saveLocation(JavaPlugin plugin, String path, Location location){ + plugin.getConfig().set(path+".world", location.getWorld().getName()); + plugin.getConfig().set(path+".x", location.getX()); + plugin.getConfig().set(path+".y", location.getY()); + plugin.getConfig().set(path+".z", location.getZ()); + plugin.saveConfig(); + } + private Location loadLocation(JavaPlugin plugin, String path){ + try{ + String worldname = plugin.getConfig().getString(path+".world"); + if(worldname == null) return null; + + World world = plugin.getServer().getWorld(worldname); + double x = plugin.getConfig().getDouble(path+".x"); + double y = plugin.getConfig().getDouble(path+".y"); + double z = plugin.getConfig().getDouble(path+".z"); + if (world == null) return null; + + return new Location(world, x, y, z); + }catch(Exception e){ + e.printStackTrace(); + return null; + } + } +} diff --git a/src/buttondevteam/alipresents/components/hotfix/HotfixComponent.java b/src/buttondevteam/alipresents/components/hotfix/HotfixComponent.java index 708d127..abd2393 100644 --- a/src/buttondevteam/alipresents/components/hotfix/HotfixComponent.java +++ b/src/buttondevteam/alipresents/components/hotfix/HotfixComponent.java @@ -1,27 +1,27 @@ -package buttondevteam.alipresents.components.hotfix; - -import org.bukkit.Bukkit; -import org.bukkit.plugin.java.JavaPlugin; - -import com.earth2me.essentials.Essentials; - -import buttondevteam.alipresents.architecture.Component; -import buttondevteam.alipresents.components.hotfix.hotfixes.CowSpawnLoop; -import buttondevteam.alipresents.components.hotfix.hotfixes.CreativeKillLoop; -import buttondevteam.alipresents.components.hotfix.hotfixes.GrassBreakListener; -import buttondevteam.alipresents.components.hotfix.hotfixes.MobKillListener; -import buttondevteam.alipresents.components.hotfix.hotfixes.NetherDisableListener; - -public class HotfixComponent extends Component { - - @Override - public void register(JavaPlugin plugin) { - registerListener(plugin, new NetherDisableListener()); - registerListener(plugin, new CowSpawnLoop(plugin)); - registerListener(plugin, new MobKillListener((Essentials) Bukkit.getPluginManager().getPlugin("Essentials"))); - registerListener(plugin, new GrassBreakListener()); - registerListener(plugin, new CreativeKillLoop(plugin)); - - } - -} +package buttondevteam.alipresents.components.hotfix; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; + +import com.earth2me.essentials.Essentials; + +import buttondevteam.alipresents.architecture.Component; +import buttondevteam.alipresents.components.hotfix.hotfixes.CowSpawnLoop; +import buttondevteam.alipresents.components.hotfix.hotfixes.CreativeKillLoop; +import buttondevteam.alipresents.components.hotfix.hotfixes.GrassBreakListener; +import buttondevteam.alipresents.components.hotfix.hotfixes.MobKillListener; +import buttondevteam.alipresents.components.hotfix.hotfixes.NetherDisableListener; + +public class HotfixComponent extends Component { + + @Override + public void register(JavaPlugin plugin) { + registerListener(plugin, new NetherDisableListener()); + registerListener(plugin, new CowSpawnLoop(plugin)); + registerListener(plugin, new MobKillListener((Essentials) Bukkit.getPluginManager().getPlugin("Essentials"))); + registerListener(plugin, new GrassBreakListener()); + registerListener(plugin, new CreativeKillLoop(plugin)); + + } + +} diff --git a/src/buttondevteam/alipresents/components/hotfix/hotfixes/CreativeKillLoop.java b/src/buttondevteam/alipresents/components/hotfix/hotfixes/CreativeKillLoop.java index e8f7680..e90ea0a 100644 --- a/src/buttondevteam/alipresents/components/hotfix/hotfixes/CreativeKillLoop.java +++ b/src/buttondevteam/alipresents/components/hotfix/hotfixes/CreativeKillLoop.java @@ -1,40 +1,27 @@ -package buttondevteam.alipresents.components.hotfix.hotfixes; - -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; - -public class CreativeKillLoop extends BukkitRunnable implements Listener { - private JavaPlugin plugin; - - public CreativeKillLoop(JavaPlugin plugin){ - this.plugin = plugin; - this.runTaskTimer(plugin, 40, 40); - } - - @Override - public void run() { - Location location; - for (Player player : plugin.getServer().getOnlinePlayers()){ - if (player.getGameMode() == GameMode.SURVIVAL) continue; - if (!player.getWorld().getName().equalsIgnoreCase("world")) continue; - if (player.isOp()) continue; - - player.sendMessage("[Hotfix] Every Gamemode other than survival is disabled in the new world"); - player.setGameMode(GameMode.SURVIVAL); - - location = player.getLocation(); - if (location.getBlockX() < 250 && location.getBlockX() > -250) continue; - if (location.getBlockZ() < 250 && location.getBlockZ() > -250) continue; - - player.sendMessage("[Hotfix] Unless you are in Spawn Island!"); - player.setGameMode(GameMode.SURVIVAL); - - } - - } - -} +package buttondevteam.alipresents.components.hotfix.hotfixes; + +import org.bukkit.GameMode; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + +public class CreativeKillLoop extends BukkitRunnable implements Listener { + private JavaPlugin plugin; + + public CreativeKillLoop(JavaPlugin plugin){ + this.plugin = plugin; + this.runTaskTimer(plugin, 40, 40); + } + + @Override + public void run() { + for (Player player : plugin.getServer().getOnlinePlayers()){ + if(player.getGameMode() != GameMode.SURVIVAL && player.getWorld().getName().equalsIgnoreCase("world") && player.isOp() == false){ + player.sendMessage("[Hotfix] Every Gamemode other than survival is disabled in the new world!"); + player.setGameMode(GameMode.SURVIVAL); + } + } + } + +} diff --git a/src/buttondevteam/alipresents/components/hotfix/hotfixes/ElytraFireworks.java b/src/buttondevteam/alipresents/components/hotfix/hotfixes/ElytraFireworks.java new file mode 100644 index 0000000..c7101a7 --- /dev/null +++ b/src/buttondevteam/alipresents/components/hotfix/hotfixes/ElytraFireworks.java @@ -0,0 +1,36 @@ +package buttondevteam.alipresents.components.hotfix.hotfixes; + +import org.bukkit.FireworkEffect; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.FireworkMeta; +import org.bukkit.plugin.java.JavaPlugin; + +public class ElytraFireworks implements Listener { + JavaPlugin plugin; + public ElytraFireworks(JavaPlugin plugin) { + this.plugin = plugin; + } + public void onRightClick(PlayerInteractEvent event){ + //ACTION SANITATION + if(!(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) return; + if(!(event.getPlayer().isGliding())) return; + if(!(event.getMaterial() == Material.FIREWORK)) return; + + //BOW SANITATION + ItemStack firework = event.getItem(); + FireworkMeta fireworkMeta= (FireworkMeta) firework.getItemMeta(); + for (FireworkEffect effect : fireworkMeta.getEffects()){ + event.getPlayer().sendMessage(effect.toString()); + } + + //PLAYER SANITATION + Player player = event.getPlayer(); + if(player.getGameMode().equals(GameMode.SPECTATOR))return; + } +} diff --git a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java index cee7da0..85dbd81 100644 --- a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java +++ b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java @@ -20,30 +20,29 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; public class CannonBowListener implements Listener { - private static String savePath = "magic.cannonbow"; - + private static double maxSpeedMultiplier = 4; private static double minSpeedMultiplier = 0; private static double defaultSpeedMultiplier = 1; - private static String speedMultiplierPath = savePath + ".speedmultiplier"; + private static String speedMultiplierPath = "magic.cannonbow.speedmultiplier"; private static int maxFuseTicks = 400; private static int minFuseTicks = 0; private static int defaultFuseTicks = 30; - private static String fuseTicksPath = savePath + ".fuseticks"; + private static String fuseTicksPath = "magic.cannonbow.fuseticks"; private static double maxMinForce = 1; private static double minMinForce = 0; private static double defaultMinForce = 0.2; - private static String minForcePath = savePath + ".minforce"; + private static String minForcePath = "magic.cannonbow.minforce"; private static double maxRecoil = 20; private static double minRecoil = -5; private static double defaultRecoil = 1; - private static String recoilPath = savePath + ".recoil"; + private static String recoilPath = "magic.cannonbow.recoil"; private static boolean defaultIsDestructive = false; - private static String isDestructivePath = savePath + ".isdestructive"; + private static String isDestructivePath = "magic.cannonbow.isdestructive"; private static double speedMultiplier = defaultSpeedMultiplier; private static double minForce = defaultMinForce; diff --git a/src/buttondevteam/alipresents/components/metrics/MetricsComponent.java b/src/buttondevteam/alipresents/components/metrics/MetricsComponent.java index 0e561a6..ea57a09 100644 --- a/src/buttondevteam/alipresents/components/metrics/MetricsComponent.java +++ b/src/buttondevteam/alipresents/components/metrics/MetricsComponent.java @@ -11,20 +11,15 @@ import buttondevteam.alipresents.components.metrics.files.MetricsFile; import buttondevteam.alipresents.components.metrics.output.GetLoginMetrics; public class MetricsComponent extends Component{ - String defaultPath; - String defaultFilePath; - String playerLoginsFilePath; + String defaultPath = "src/alisolarflare/resources"; + String defaultFilePath = (defaultPath + "/metrics.txt"); + String playerLoginsFilePath = (defaultPath + "/playerLogins.txt"); public MetricsFile playerLoginsFile; // DATA - STRING public List metricsList; @Override public void register(JavaPlugin plugin){ - - defaultPath = plugin.getDataFolder().getAbsolutePath(); - defaultFilePath = defaultPath + "/metrics.txt"; - playerLoginsFilePath = defaultPath + "/playerLogins.txt"; - playerLoginsFile = new MetricsFile(playerLoginsFilePath); registerCommand(plugin, new GetLoginMetrics(this)); registerListener(plugin, new PlayerJoinListener(this, playerLoginsFile));