From d331302e3d203a7716195aa66c4bc8e0b19099d0 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Tue, 24 Aug 2021 23:43:01 -0400 Subject: [PATCH] fixed snowball, changed config, added blocked commands, bug fixes i guess --- pom.xml | 2 +- src/main/java/Store.java | 67 +++++++++++++++ .../hideAndSeek/CommandHandler.java | 12 +-- .../net/tylermurphy/hideAndSeek/Main.java | 18 +--- .../net/tylermurphy/hideAndSeek/Store.java | 82 ++++++++++++++++++- .../hideAndSeek/commands/About.java | 2 +- .../hideAndSeek/commands/Reload.java | 29 +++++++ .../hideAndSeek/commands/SetBorder.java | 24 ++++-- .../commands/SetSpawnLocation.java | 16 ++-- .../hideAndSeek/commands/Start.java | 2 +- .../hideAndSeek/commands/Stop.java | 4 +- .../hideAndSeek/events/EventListener.java | 20 ++++- .../hideAndSeek/events/EventTick.java | 12 +-- .../hideAndSeek/util/Functions.java | 29 +++---- src/main/resources/plugin.yml | 2 +- 15 files changed, 249 insertions(+), 72 deletions(-) create mode 100644 src/main/java/Store.java create mode 100644 src/main/java/net/tylermurphy/hideAndSeek/commands/Reload.java diff --git a/pom.xml b/pom.xml index 93b6b6a..5a78364 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ 4.0.0 net.tylermurphy HideAndSeek - 1.2.0 + 1.3.0 Hide and Seek Plugin diff --git a/src/main/java/Store.java b/src/main/java/Store.java new file mode 100644 index 0000000..f1aec4d --- /dev/null +++ b/src/main/java/Store.java @@ -0,0 +1,67 @@ + + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.bukkit.ChatColor; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.scoreboard.Scoreboard; +import org.bukkit.scoreboard.Team; +import org.bukkit.util.Vector; + +import net.tylermurphy.hideAndSeek.Main; + +public class Store { + + public static Map playerList = new HashMap(); + + public static Scoreboard board; + public static Team Hider,Seeker,Spectator; + + public static String status = "Setup"; + + public static String messagePrefix = String.format("%sHide and Seek > %s", ChatColor.BLUE, ChatColor.WHITE); + public static String errorPrefix = String.format("%sError > %s", ChatColor.RED, ChatColor.WHITE); + + public static Vector spawnPosition; + + public static Vector worldborderPosition; + public static int worldborderSize,worldborderDelay,currentWorldborderSize; + public static boolean worldborderEnabled = false, decreaseBorder = false; + + public static List blockedCommands; + + public static String tauntPlayer = ""; + + public static int glowTime = 0; + + public static int gameId = 0; + + public static FileConfiguration getConfig() { + return Main.plugin.getConfig(); + } + + public static void saveConfig() { + Main.plugin.saveConfig(); + } + + public static void loadConfig() { + ConfigurationSection spawnConfig = getConfig().getConfigurationSection("spawn"); + if(spawnConfig == null) spawnConfig = getConfig().createSection("spawn"); + spawnPosition = new Vector(spawnConfig.getDouble("x", 0), spawnConfig.getDouble("y", 0), spawnConfig.getDouble("z", 0)); + getConfig().createSection("spawn", spawnConfig.getValues(true)); + ConfigurationSection worldBorderConfig = getConfig().getConfigurationSection("worldBorder"); + if(worldBorderConfig == null) worldBorderConfig = getConfig().createSection("worldBorder"); + worldborderPosition = new Vector(worldBorderConfig.getInt("x", 0), 0, worldBorderConfig.getInt("z", 0)); + worldborderSize = worldBorderConfig.getInt("x", 500); + worldborderEnabled = worldBorderConfig.getBoolean("enabled", false); + getConfig().createSection("worldBorder", worldBorderConfig.getValues(true)); + getConfig().addDefault("blockedCommands", new ArrayList()); + blockedCommands = getConfig().getStringList("blockedCommands"); + } + +} \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/CommandHandler.java b/src/main/java/net/tylermurphy/hideAndSeek/CommandHandler.java index 2703145..b1a6f89 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/CommandHandler.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/CommandHandler.java @@ -1,5 +1,7 @@ package net.tylermurphy.hideAndSeek; +import static net.tylermurphy.hideAndSeek.Store.*; + import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; @@ -8,16 +10,9 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import net.tylermurphy.hideAndSeek.commands.About; -import net.tylermurphy.hideAndSeek.commands.Help; -import net.tylermurphy.hideAndSeek.commands.SetBorder; -import net.tylermurphy.hideAndSeek.commands.SetSpawnLocation; -import net.tylermurphy.hideAndSeek.commands.Start; -import net.tylermurphy.hideAndSeek.commands.Stop; +import net.tylermurphy.hideAndSeek.commands.*; import net.tylermurphy.hideAndSeek.util.ICommand; -import static net.tylermurphy.hideAndSeek.Store.*; - public class CommandHandler { public static Map COMMAND_REGISTER = new LinkedHashMap(); @@ -35,6 +30,7 @@ public class CommandHandler { registerCommand(new Stop()); registerCommand(new SetSpawnLocation()); registerCommand(new SetBorder()); + registerCommand(new Reload()); } public static boolean handleCommand(CommandSender sender, Command cmd, String label, String[] args) { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/Main.java b/src/main/java/net/tylermurphy/hideAndSeek/Main.java index 508f4d1..2a31169 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/Main.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/Main.java @@ -11,7 +11,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.util.Vector; import net.tylermurphy.hideAndSeek.events.EventListener; import net.tylermurphy.hideAndSeek.events.EventTick; @@ -31,18 +30,7 @@ public class Main extends JavaPlugin implements Listener { } // Init Configuration - Vector spawnPositionVector = getConfig().getVector("spawnPosition"); - if(spawnPositionVector != null) { - spawnPosition = spawnPositionVector; - status = "Standby"; - } - Vector worldborderPositionVector = getConfig().getVector("borderPosition"); - if(worldborderPositionVector != null) { - worldborderPosition = worldborderPositionVector; - worldborderSize = getConfig().getInt("borderSize"); - worldborderDelay = getConfig().getInt("borderDelay"); - } - worldborderEnabled = getConfig().getBoolean("borderEnabled"); + Store.loadConfig(); // Register Commands CommandHandler.registerCommands(); @@ -60,10 +48,6 @@ public class Main extends JavaPlugin implements Listener { } - public void onDisable() { - saveConfig(); - } - public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { return CommandHandler.handleCommand(sender, cmd, label, args); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/Store.java b/src/main/java/net/tylermurphy/hideAndSeek/Store.java index 85cef2a..c39b16d 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/Store.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/Store.java @@ -1,9 +1,12 @@ package net.tylermurphy.hideAndSeek; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Map.Entry; -import org.bukkit.ChatColor; +import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.scoreboard.Scoreboard; @@ -19,15 +22,19 @@ public class Store { public static String status = "Setup"; - public static String messagePrefix = String.format("%sHide and Seek > %s", ChatColor.BLUE, ChatColor.WHITE); - public static String errorPrefix = String.format("%sError > %s", ChatColor.RED, ChatColor.WHITE); + public static String messagePrefix,errorPrefix,tauntPrefix,worldborderPrefix,abortPrefix,gameoverPrefix; public static Vector spawnPosition; + public static String spawnWorld; public static Vector worldborderPosition; public static int worldborderSize,worldborderDelay,currentWorldborderSize; public static boolean worldborderEnabled = false, decreaseBorder = false; + public static List blockedCommands; + + public static boolean nametagsVisible; + public static String tauntPlayer = ""; public static int glowTime = 0; @@ -42,4 +49,73 @@ public class Store { Main.plugin.saveConfig(); } + public static void loadConfig() { + + Main.plugin.reloadConfig(); + + getConfig().addDefault("spawn.x", 0); + getConfig().addDefault("spawn.y", 0); + getConfig().addDefault("spawn.z", 0); + getConfig().addDefault("spawn.world", "world"); + getConfig().addDefault("worldBorder.x", 0); + getConfig().addDefault("worldBorder.z", 0); + getConfig().addDefault("worldBorder.delay", 10); + getConfig().addDefault("worldBorder.size", 500); + getConfig().addDefault("worldBorder.enabled", false); + getConfig().addDefault("blockedCommands", Arrays.asList("tp","kill","gamemode","effect","clear")); + getConfig().addDefault("prefix.default", "&9Hide and Seek > &f"); + getConfig().addDefault("prefix.error", "&cError > &f"); + getConfig().addDefault("prefix.taunt", "&eTaunt > &f"); + getConfig().addDefault("prefix.border", "&cWorld Border > &f"); + getConfig().addDefault("prefix.abort", "&cAbort > &f"); + getConfig().addDefault("prefix.gameover", "&aGame Over > &f"); + getConfig().addDefault("nametagsVisible", false); + + spawnPosition = new Vector( + getConfig().getDouble("spawn.x"), + getConfig().getDouble("spawn.y"), + getConfig().getDouble("spawn.z") + ); + spawnWorld = getConfig().getString("spawn.world"); + + worldborderPosition = new Vector( + getConfig().getInt("worldBorder.x"), + 0, + getConfig().getInt("worldBorder.z") + ); + worldborderSize = getConfig().getInt("worldBorder.size"); + worldborderDelay = getConfig().getInt("worldBorder.delay"); + worldborderEnabled = getConfig().getBoolean("worldBorder.enabled"); + + blockedCommands = getConfig().getStringList("blockedCommands"); + + messagePrefix = getConfig().getString("prefix.default").replace("&", "§"); + errorPrefix = getConfig().getString("prefix.error").replace("&", "§"); + tauntPrefix = getConfig().getString("prefix.taunt").replace("&", "§"); + worldborderPrefix = getConfig().getString("prefix.border").replace("&", "§"); + abortPrefix = getConfig().getString("prefix.abort").replace("&", "§"); + gameoverPrefix = getConfig().getString("prefix.gameover").replace("&", "§"); + + nametagsVisible = getConfig().getBoolean("nametagsVisible"); + + getConfig().options().copyDefaults(true); + saveConfig(); + + if(spawnPosition.getBlockX() != 0 || spawnPosition.getBlockY() != 0 || spawnPosition.getBlockZ() != 0) { + status = "Standby"; + } + + } + + public static void addToSection(String sectionName, Map values) { + ConfigurationSection section = getConfig().getConfigurationSection(sectionName); + if(section == null) section = getConfig().createSection(sectionName); + Map sectionValues = section.getValues(true); + for(Entry entry : values.entrySet()) { + sectionValues.put(entry.getKey(), entry.getValue()); + } + getConfig().createSection(sectionName, sectionValues); + saveConfig(); + } + } \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/commands/About.java b/src/main/java/net/tylermurphy/hideAndSeek/commands/About.java index c500dd6..76cd28b 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/commands/About.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/commands/About.java @@ -9,7 +9,7 @@ public class About implements ICommand { public void execute(CommandSender sender, String[] args) { sender.sendMessage( - String.format("%s%sHide and Seek %s(1.2.0%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) + + String.format("%s%sHide and Seek %s(1.3.0%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) + String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) + String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE) ); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/commands/Reload.java b/src/main/java/net/tylermurphy/hideAndSeek/commands/Reload.java new file mode 100644 index 0000000..04128c5 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/commands/Reload.java @@ -0,0 +1,29 @@ +package net.tylermurphy.hideAndSeek.commands; + +import org.bukkit.command.CommandSender; + +import net.tylermurphy.hideAndSeek.Store; +import net.tylermurphy.hideAndSeek.util.ICommand; + +import static net.tylermurphy.hideAndSeek.Store.*; + +public class Reload implements ICommand { + + public void execute(CommandSender sender, String[] args) { + Store.loadConfig(); + sender.sendMessage(messagePrefix + "Reloaded the config"); + } + + public String getLabel() { + return "reload"; + } + + public String getUsage() { + return ""; + } + + public String getDescription() { + return "Reloads the config"; + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/commands/SetBorder.java b/src/main/java/net/tylermurphy/hideAndSeek/commands/SetBorder.java index a485c91..e94c781 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/commands/SetBorder.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/commands/SetBorder.java @@ -1,5 +1,10 @@ package net.tylermurphy.hideAndSeek.commands; +import static net.tylermurphy.hideAndSeek.Store.*; + +import java.util.HashMap; +import java.util.Map; + import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -7,8 +12,6 @@ import org.bukkit.util.Vector; import net.tylermurphy.hideAndSeek.util.Functions; import net.tylermurphy.hideAndSeek.util.ICommand; -import static net.tylermurphy.hideAndSeek.Store.*; - public class SetBorder implements ICommand { public void execute(CommandSender sender, String[] args) { @@ -21,8 +24,10 @@ public class SetBorder implements ICommand { return; } if(args.length < 2) { - getConfig().set("borderEnabled", false); worldborderEnabled = false; + Map temp = new HashMap(); + temp.put("enabled", false); + addToSection("worldBorder",temp); saveConfig(); sender.sendMessage(messagePrefix + "Disabled worldborder."); Functions.resetWorldborder(); @@ -53,12 +58,15 @@ public class SetBorder implements ICommand { worldborderPosition = newWorldborderPosition; worldborderSize = num; worldborderDelay = delay; - sender.sendMessage(messagePrefix + "Set border center to current location, size to "+num+", and delay to "+delay); - getConfig().set("borderPosition", newWorldborderPosition); - getConfig().set("borderSize", num); - getConfig().set("borderDelay", delay); - getConfig().set("borderEnabled", false); worldborderEnabled = true; + Map temp = new HashMap(); + temp.put("x", worldborderPosition.getBlockX()); + temp.put("z", worldborderPosition.getBlockZ()); + temp.put("delay", worldborderDelay); + temp.put("size", worldborderSize); + temp.put("enabled", true); + addToSection("worldBorder",temp); + sender.sendMessage(messagePrefix + "Set border center to current location, size to "+num+", and delay to "+delay); saveConfig(); Functions.resetWorldborder(); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/commands/SetSpawnLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/commands/SetSpawnLocation.java index 48a8d60..89b6baf 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/commands/SetSpawnLocation.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/commands/SetSpawnLocation.java @@ -1,13 +1,16 @@ package net.tylermurphy.hideAndSeek.commands; +import static net.tylermurphy.hideAndSeek.Store.*; + +import java.util.HashMap; +import java.util.Map; + import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.util.Vector; import net.tylermurphy.hideAndSeek.util.ICommand; -import static net.tylermurphy.hideAndSeek.Store.*; - public class SetSpawnLocation implements ICommand { public void execute(CommandSender sender, String[] args) { @@ -23,10 +26,13 @@ public class SetSpawnLocation implements ICommand { spawnPosition = newSpawnPosition; status = "Standby"; sender.sendMessage(messagePrefix + "Set spawn position to current location"); - getConfig().set("spawnPosition", newSpawnPosition); + Map temp = new HashMap(); + temp.put("x", spawnPosition.getX()); + temp.put("y", spawnPosition.getY()); + temp.put("z", spawnPosition.getZ()); + temp.put("world", player.getLocation().getWorld().getName()); + addToSection("spawn",temp); saveConfig(); -// Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("setworldspawn %s %s %s", player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ())); -// Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("spawnpoint @a %s %s %s", player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ())); } public String getLabel() { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/commands/Start.java b/src/main/java/net/tylermurphy/hideAndSeek/commands/Start.java index 45797b8..58d6143 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/commands/Start.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/commands/Start.java @@ -52,7 +52,7 @@ public class Start implements ICommand { for(Player player : playerList.values()) { player.getInventory().clear(); player.setGameMode(GameMode.ADVENTURE); - player.teleport(new Location(player.getWorld(), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); + player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); for(PotionEffect effect : player.getActivePotionEffects()){ player.removePotionEffect(effect.getType()); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/commands/Stop.java b/src/main/java/net/tylermurphy/hideAndSeek/commands/Stop.java index 1c31ccd..e55675e 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/commands/Stop.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/commands/Stop.java @@ -17,7 +17,7 @@ public class Stop implements ICommand { public void execute(CommandSender sender, String[] args) { if(status.equals("Starting") || status.equals("Playing")) { - Bukkit.broadcastMessage(messagePrefix + "Game has been force stopped."); + Bukkit.broadcastMessage(abortPrefix + "Game has been force stopped."); onStop(); } else { @@ -38,7 +38,7 @@ public class Stop implements ICommand { player.setGameMode(GameMode.ADVENTURE); Hider.addEntry(player.getName()); player.getInventory().clear(); - player.teleport(new Location(player.getWorld(), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); + player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); for(PotionEffect effect : player.getActivePotionEffects()){ player.removePotionEffect(effect.getType()); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/events/EventListener.java b/src/main/java/net/tylermurphy/hideAndSeek/events/EventListener.java index 7c095b1..8ac7d29 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/events/EventListener.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/events/EventListener.java @@ -17,6 +17,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.potion.PotionEffect; @@ -37,7 +38,7 @@ public class EventListener implements Listener { for(PotionEffect effect : event.getPlayer().getActivePotionEffects()){ event.getPlayer().removePotionEffect(effect.getType()); } - event.getPlayer().teleport(new Location(event.getPlayer().getWorld(), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); + event.getPlayer().teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); } else if(status.equals("Setup") || status.equals("Standby")) { Hider.addEntry(event.getPlayer().getName()); } @@ -64,10 +65,10 @@ public class EventListener implements Listener { if(spawnPosition == null) return; event.setCancelled(true); player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); - player.teleport(new Location(player.getWorld(), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ())); + player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ())); Functions.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1); if(Hider.hasEntry(event.getEntity().getName())) { - Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has died and become a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE)); + Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has died and became a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE)); } if(Seeker.hasEntry(event.getEntity().getName())) { Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has been beat by a hider", ChatColor.RED, event.getEntity().getName(), ChatColor.WHITE)); @@ -112,4 +113,17 @@ public class EventListener implements Listener { if(event.getRegainReason() == RegainReason.SATIATED || event.getRegainReason() == RegainReason.REGEN) event.setCancelled(true); } + + @EventHandler + public void onPlayerCommandPreProccess(PlayerCommandPreprocessEvent event) { + if(status.equals("Setup") || status.equals("Standby")) return; + String handle = event.getMessage().split(" ")[0].substring(1); + for(String blocked : blockedCommands) { + if(handle.equalsIgnoreCase(blocked) || handle.equalsIgnoreCase("minecraft:"+blocked)) { + event.setCancelled(true); + event.getPlayer().sendMessage(errorPrefix + "This command is blocked during gameplay!"); + break; + } + } + } } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java b/src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java index a0bf36a..2198c05 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java @@ -3,7 +3,6 @@ package net.tylermurphy.hideAndSeek.events; import static net.tylermurphy.hideAndSeek.Store.*; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Location; @@ -41,11 +40,11 @@ public class EventTick { tick ++; if(( status.equals("Starting") || status.equals("Playing") ) && Hider.getSize() < 1) { - Bukkit.broadcastMessage(messagePrefix + "Game over! All hiders have been found."); + Bukkit.broadcastMessage(gameoverPrefix + "All hiders have been found."); Stop.onStop(); } if(( status.equals("Starting") || status.equals("Playing") ) && Seeker.getSize() < 1) { - Bukkit.broadcastMessage(messagePrefix + "Game has ended as all seekers have quit."); + Bukkit.broadcastMessage(abortPrefix + "All seekers have quit."); Stop.onStop(); } } @@ -54,7 +53,7 @@ public class EventTick { for(String playerName : Seeker.getEntries()) { Player player = playerList.get(playerName); if(player != null) { - player.teleport(new Location(player.getWorld(), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); + player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); } } } @@ -83,7 +82,7 @@ public class EventTick { .withTrail() .build()); fw.setFireworkMeta(fwm); - Bukkit.getServer().broadcastMessage(ChatColor.YELLOW + "Taunt >" + ChatColor.WHITE + " Taunt has been activated"); + Bukkit.getServer().broadcastMessage(tauntPrefix + " Taunt has been activated"); } tauntPlayer = ""; } @@ -98,6 +97,9 @@ public class EventTick { player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 1000000, 1, false, false)); player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 10, false, false)); } + for(Player temp : playerList.values()) { + Functions.setGlow(player, temp, false); + } } for(String playerName : Hider.getEntries()) { Player player = playerList.get(playerName); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/Functions.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Functions.java index 73d6e94..3f3b54d 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/util/Functions.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/Functions.java @@ -1,18 +1,6 @@ package net.tylermurphy.hideAndSeek.util; -import static net.tylermurphy.hideAndSeek.Store.Hider; -import static net.tylermurphy.hideAndSeek.Store.Seeker; -import static net.tylermurphy.hideAndSeek.Store.Spectator; -import static net.tylermurphy.hideAndSeek.Store.board; -import static net.tylermurphy.hideAndSeek.Store.currentWorldborderSize; -import static net.tylermurphy.hideAndSeek.Store.decreaseBorder; -import static net.tylermurphy.hideAndSeek.Store.gameId; -import static net.tylermurphy.hideAndSeek.Store.playerList; -import static net.tylermurphy.hideAndSeek.Store.tauntPlayer; -import static net.tylermurphy.hideAndSeek.Store.worldborderDelay; -import static net.tylermurphy.hideAndSeek.Store.worldborderEnabled; -import static net.tylermurphy.hideAndSeek.Store.worldborderPosition; -import static net.tylermurphy.hideAndSeek.Store.worldborderSize; +import static net.tylermurphy.hideAndSeek.Store.*; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; @@ -102,6 +90,7 @@ public class Functions { snowballLore.add("Last 30s, all hiders can see it"); snowballLore.add("Time stacks on multi use"); snowballMeta.setLore(snowballLore); + snowball.setItemMeta(snowballMeta); player.getInventory().addItem(snowball); } } @@ -135,13 +124,19 @@ public class Functions { try { mainBoard.registerNewTeam("Seeker");} catch(Exception e) {} Seeker = mainBoard.getTeam("Seeker"); Seeker.setColor(ChatColor.RED); - Seeker.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER); + if(nametagsVisible) + Seeker.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OTHER_TEAMS); + else + Seeker.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER); Seeker.setAllowFriendlyFire(false); try { mainBoard.registerNewTeam("Hider");} catch(Exception e) {} Hider = mainBoard.getTeam("Hider"); Hider.setColor(ChatColor.GOLD); - Hider.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER); + if(nametagsVisible) + Hider.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OWN_TEAM); + else + Hider.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER); Hider.setAllowFriendlyFire(false); try { mainBoard.registerNewTeam("Spectator");} catch(Exception e) {} @@ -215,7 +210,7 @@ public class Functions { } if(taunted != null) { taunted.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Oh no! You have been chosed to be taunted."); - Bukkit.getServer().broadcastMessage(ChatColor.YELLOW + "Taunt >" + ChatColor.WHITE + " A random hider will be taunted in the next 30s"); + Bukkit.getServer().broadcastMessage(tauntPrefix + " A random hider will be taunted in the next 30s"); try { Thread.sleep(1000*30); } catch (InterruptedException e) {} if(gameId != temp) break; tauntPlayer = taunted.getName(); @@ -236,7 +231,7 @@ public class Functions { try { Thread.sleep(1000*60*worldborderDelay); } catch (InterruptedException e) {} if(gameId != temp) break; if(currentWorldborderSize-100 > 100) { - Bukkit.getServer().broadcastMessage(ChatColor.RED + "World Border> " + ChatColor.WHITE + "Worldborder decreacing by 100 blocks over the next 30s"); + Bukkit.getServer().broadcastMessage(worldborderPrefix + "Worldborder decreacing by 100 blocks over the next 30s"); currentWorldborderSize -= 100; decreaseBorder = true; } else { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 4250258..61d8b88 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: HideAndSeek main: net.tylermurphy.hideAndSeek.Main -version: 1.2.0 +version: 1.3.0 author: KenshinEto load: STARTUP api-version: 1.17