localization

This commit is contained in:
Tyler Murphy 2021-10-22 20:03:15 -04:00
parent 91311dd23d
commit 0015592730
25 changed files with 336 additions and 144 deletions

View file

@ -18,6 +18,8 @@ import net.tylermurphy.hideAndSeek.bukkit.CommandHandler;
import net.tylermurphy.hideAndSeek.bukkit.EventListener; import net.tylermurphy.hideAndSeek.bukkit.EventListener;
import net.tylermurphy.hideAndSeek.bukkit.TabCompleter; import net.tylermurphy.hideAndSeek.bukkit.TabCompleter;
import net.tylermurphy.hideAndSeek.bukkit.Tick; import net.tylermurphy.hideAndSeek.bukkit.Tick;
import net.tylermurphy.hideAndSeek.configuration.Config;
import net.tylermurphy.hideAndSeek.configuration.Localization;
import net.tylermurphy.hideAndSeek.events.Glow; import net.tylermurphy.hideAndSeek.events.Glow;
import net.tylermurphy.hideAndSeek.events.Taunt; import net.tylermurphy.hideAndSeek.events.Taunt;
import net.tylermurphy.hideAndSeek.events.Worldborder; import net.tylermurphy.hideAndSeek.events.Worldborder;
@ -26,7 +28,7 @@ import net.tylermurphy.hideAndSeek.util.Board;
public class Main extends JavaPlugin implements Listener { public class Main extends JavaPlugin implements Listener {
public static Main plugin; public static Main plugin;
public static File root; public static File root, data;
public Taunt taunt; public Taunt taunt;
public Glow glow; public Glow glow;
@ -49,15 +51,19 @@ public class Main extends JavaPlugin implements Listener {
// Setup Initial Player Count // Setup Initial Player Count
getServer().getPluginManager().registerEvents(new EventListener(), this); getServer().getPluginManager().registerEvents(new EventListener(), this);
// Get Data Folder
root = this.getServer().getWorldContainer();
data = this.getDataFolder();
// Init Configuration // Init Configuration
Main.plugin.saveResource("localization.yml", false);
Main.plugin.saveResource("config.yml", false);
Config.loadConfig(); Config.loadConfig();
Localization.init();
// Register Commands // Register Commands
CommandHandler.registerCommands(); CommandHandler.registerCommands();
// Get Data Folder
root = this.getServer().getWorldContainer();
//Board //Board
board = new Board(); board = new Board();
board.reload(); board.reload();

View file

@ -1,6 +1,7 @@
package net.tylermurphy.hideAndSeek.bukkit; package net.tylermurphy.hideAndSeek.bukkit;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -40,18 +41,18 @@ public class CommandHandler {
public static boolean handleCommand(CommandSender sender, Command cmd, String label, String[] args) { public static boolean handleCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(sender instanceof Player == false) { if(sender instanceof Player == false) {
sender.sendMessage(errorPrefix + "This command can only be run as a player."); sender.sendMessage(errorPrefix + message("COMMAND_PLAYER_ONLY"));
} else if(args.length < 1 || !COMMAND_REGISTER.containsKey(args[0].toLowerCase()) ) { } else if(args.length < 1 || !COMMAND_REGISTER.containsKey(args[0].toLowerCase()) ) {
if(permissionsRequired && !sender.hasPermission("hideandseek.about")) { if(permissionsRequired && !sender.hasPermission("hideandseek.about")) {
sender.sendMessage(errorPrefix + "You are not allowed to run this command."); sender.sendMessage(errorPrefix + LOCAL.get(""));
} else { } else {
COMMAND_REGISTER.get("about").execute(sender, null); COMMAND_REGISTER.get("about").execute(sender, null);
} }
} else { } else {
if(!args[0].toLowerCase().equals("about") && !args[0].toLowerCase().equals("help") && SaveMap.runningBackup) { if(!args[0].toLowerCase().equals("about") && !args[0].toLowerCase().equals("help") && SaveMap.runningBackup) {
sender.sendMessage(errorPrefix + "Map save is currently in progress. Try again later."); sender.sendMessage(errorPrefix + message("MAPSAVE_INPROGRESS"));
} else if(permissionsRequired && !sender.hasPermission("hideandseek."+args[0].toLowerCase())) { } else if(permissionsRequired && !sender.hasPermission("hideandseek."+args[0].toLowerCase())) {
sender.sendMessage(errorPrefix + "You are not allowed to run this command."); sender.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED"));
} else { } else {
try { try {
COMMAND_REGISTER.get(args[0].toLowerCase()).execute(sender,Arrays.copyOfRange(args, 1, args.length)); COMMAND_REGISTER.get(args[0].toLowerCase()).execute(sender,Arrays.copyOfRange(args, 1, args.length));

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.bukkit; package net.tylermurphy.hideAndSeek.bukkit;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -24,11 +24,11 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.util.Packet; import net.tylermurphy.hideAndSeek.util.Packet;
import net.tylermurphy.hideAndSeek.util.Util; import net.tylermurphy.hideAndSeek.util.Util;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.Start; import net.tylermurphy.hideAndSeek.command.Start;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class EventListener implements Listener { public class EventListener implements Listener {
@ -79,13 +79,13 @@ public class EventListener implements Listener {
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ())); player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
Packet.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1); Packet.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1);
if(Main.plugin.board.isSeeker(player)) { if(Main.plugin.board.isSeeker(player)) {
Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s was killed", ChatColor.RED, event.getEntity().getName(), ChatColor.WHITE)); Bukkit.broadcastMessage(message("GAME_PLAYER_DEATH").addPlayer(event.getEntity()).toString());
} }
if(Main.plugin.board.isHider(player)) { if(Main.plugin.board.isHider(player)) {
if(attacker == null) { if(attacker == null) {
Util.broadcastMessage(String.format(messagePrefix + "%s%s%s was found and became a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE)); Util.broadcastMessage(message("GAME_PLAYER_FOUND").addPlayer(event.getEntity()).toString());
} else { } else {
Util.broadcastMessage(String.format(messagePrefix + "%s%s%s was found by %s%s%s and became a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE, ChatColor.RED, attacker.getName(), ChatColor.WHITE)); Util.broadcastMessage(message("GAME_PLAYER_FOUND_BY").addPlayer(event.getEntity()).addPlayer(attacker).toString());
} }
Main.plugin.board.addSeeker(player); Main.plugin.board.addSeeker(player);
} }

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.bukkit; package net.tylermurphy.hideAndSeek.bukkit;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -10,6 +10,7 @@ import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.Stop; import net.tylermurphy.hideAndSeek.command.Stop;
import net.tylermurphy.hideAndSeek.util.Packet; import net.tylermurphy.hideAndSeek.util.Packet;
import net.tylermurphy.hideAndSeek.util.Util; import net.tylermurphy.hideAndSeek.util.Util;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class Tick { public class Tick {
@ -21,13 +22,13 @@ public class Tick {
else if(Main.plugin.status.equals("Playing")) onPlaying(); else if(Main.plugin.status.equals("Playing")) onPlaying();
if(( Main.plugin.status.equals("Starting") || Main.plugin.status.equals("Playing") ) && Main.plugin.board.sizeHider() < 1) { if(( Main.plugin.status.equals("Starting") || Main.plugin.status.equals("Playing") ) && Main.plugin.board.sizeHider() < 1) {
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + "All hiders have been found."); if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND"));
else Util.broadcastMessage(gameoverPrefix + "All hiders have been found."); else Util.broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND"));
Stop.onStop(); Stop.onStop();
} }
if(( Main.plugin.status.equals("Starting") || Main.plugin.status.equals("Playing") ) && Main.plugin.board.sizeSeeker() < 1) { if(( Main.plugin.status.equals("Starting") || Main.plugin.status.equals("Playing") ) && Main.plugin.board.sizeSeeker() < 1) {
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + "All seekers have quit."); if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + message("GAME_GAMEOVER_SEEKERS_QUIT"));
else Util.broadcastMessage(abortPrefix + "All seekers have quit."); else Util.broadcastMessage(abortPrefix + message("GAME_GAMEOVER_SEEKERS_QUIT"));
Stop.onStop(); Stop.onStop();
} }
@ -73,8 +74,8 @@ public class Tick {
player.setLevel(Main.plugin.timeLeft); player.setLevel(Main.plugin.timeLeft);
} }
if(Main.plugin.timeLeft < 1) { if(Main.plugin.timeLeft < 1) {
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + "Seekers ran out of time. Hiders win!"); if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_TIME"));
else Util.broadcastMessage(gameoverPrefix + "Seekers ran out of time. Hiders win!"); else Util.broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_TIME"));
Stop.onStop(); Stop.onStop();
} }
} }

View file

@ -1,5 +1,7 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -9,36 +11,35 @@ import org.bukkit.entity.Player;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.Util; import net.tylermurphy.hideAndSeek.util.Util;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
import static net.tylermurphy.hideAndSeek.Config.*;
public class Join implements ICommand { public class Join implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(!Util.isSetup()) { if(!Util.isSetup()) {
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do"); sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return; return;
} }
Player player = Bukkit.getServer().getPlayer(sender.getName()); Player player = Bukkit.getServer().getPlayer(sender.getName());
if(player == null) { if(player == null) {
sender.sendMessage(errorPrefix + "An internal error has occured"); sender.sendMessage(errorPrefix + message("COMMAND_ERROR"));
return; return;
} }
if(Main.plugin.board.isPlayer(player)){ if(Main.plugin.board.isPlayer(player)){
sender.sendMessage(errorPrefix + "You are already in the lobby/game"); sender.sendMessage(errorPrefix + message("GAME_INGAME"));
return; return;
} }
if(Main.plugin.status.equals("Standby")) { if(Main.plugin.status.equals("Standby")) {
Main.plugin.board.addHider(player); Main.plugin.board.addHider(player);
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + sender.getName() + " has joined the HideAndSeek lobby"); if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_JOIN").addPlayer(player));
else Util.broadcastMessage(messagePrefix + sender.getName() + " has joined the HideAndSeek lobby"); else Util.broadcastMessage(messagePrefix + message("GAME_JOIN").addPlayer(player));
player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ())); player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ()));
player.setGameMode(GameMode.ADVENTURE); player.setGameMode(GameMode.ADVENTURE);
Main.plugin.board.reloadLobbyBoards(); Main.plugin.board.reloadLobbyBoards();
} else { } else {
Main.plugin.board.addSeeker(player); Main.plugin.board.addSeeker(player);
player.sendMessage(messagePrefix + "You have joined mid game and became a spectator"); player.sendMessage(messagePrefix + message("GAME_JOIN_SPECTATOR"));
player.setGameMode(GameMode.SPECTATOR); player.setGameMode(GameMode.SPECTATOR);
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
} }

View file

@ -1,5 +1,7 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -7,27 +9,26 @@ import org.bukkit.entity.Player;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.Util; import net.tylermurphy.hideAndSeek.util.Util;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
import static net.tylermurphy.hideAndSeek.Config.*;
public class Leave implements ICommand { public class Leave implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(!Util.isSetup()) { if(!Util.isSetup()) {
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do"); sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return; return;
} }
Player player = Bukkit.getServer().getPlayer(sender.getName()); Player player = Bukkit.getServer().getPlayer(sender.getName());
if(player == null) { if(player == null) {
sender.sendMessage(errorPrefix + "An internal error has occured"); sender.sendMessage(errorPrefix + message("COMMAND_ERROR"));
return; return;
} }
if(!Main.plugin.board.isPlayer(player)) { if(!Main.plugin.board.isPlayer(player)) {
sender.sendMessage(errorPrefix + "You are currently not in the lobby"); sender.sendMessage(errorPrefix + message("GAME_NOT_INGAME"));
return; return;
} }
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + sender.getName() + " has left the HideAndSeek lobby"); if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player));
else Util.broadcastMessage(messagePrefix + sender.getName() + " has left the HideAndSeek lobby"); else Util.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player));
Main.plugin.board.removeBoard(player); Main.plugin.board.removeBoard(player);
Main.plugin.board.remove(player); Main.plugin.board.remove(player);
player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ())); player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));

View file

@ -1,22 +1,26 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.Config; import net.tylermurphy.hideAndSeek.configuration.Config;
import net.tylermurphy.hideAndSeek.configuration.Localization;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class Reload implements ICommand { public class Reload implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(!Main.plugin.status.equals("Standby")) { if(!Main.plugin.status.equals("Standby")) {
sender.sendMessage(errorPrefix + "Game is currently in session"); sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return; return;
} }
Config.loadConfig(); Config.loadConfig();
sender.sendMessage(messagePrefix + "Reloaded the config"); Localization.init();
sender.sendMessage(messagePrefix + message("CONFIG_RELOAD"));
} }
public String getLabel() { public String getLabel() {

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -16,6 +16,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class SaveMap implements ICommand { public class SaveMap implements ICommand {
@ -23,15 +24,15 @@ public class SaveMap implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(!Main.plugin.status.equals("Standby")) { if(!Main.plugin.status.equals("Standby")) {
sender.sendMessage(errorPrefix + "Game is currently in session"); sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return; return;
} }
if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) { if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
sender.sendMessage(errorPrefix + "Please set spawn location first"); sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return; return;
} }
sender.sendMessage(messagePrefix + "Starting map save"); sender.sendMessage(messagePrefix + message("MAPSAVE_START"));
sender.sendMessage(warningPrefix + "All commands will be disabled when the save is in progress. Do not turn off the server."); sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING"));
Bukkit.getServer().getWorld(spawnWorld).save(); Bukkit.getServer().getWorld(spawnWorld).save();
BukkitRunnable runnable = new BukkitRunnable() { BukkitRunnable runnable = new BukkitRunnable() {
public void run() { public void run() {
@ -45,10 +46,10 @@ public class SaveMap implements ICommand {
destenation.mkdir(); destenation.mkdir();
} }
temp_destenation.renameTo(destenation); temp_destenation.renameTo(destenation);
sender.sendMessage(messagePrefix + "Map save complete"); sender.sendMessage(messagePrefix + message("MAPSAVE_END"));
runningBackup = false; runningBackup = false;
} else { } else {
sender.sendMessage(errorPrefix + "Coudnt find current map"); sender.sendMessage(errorPrefix + message("MAPSAVE_ERROR"));
} }
} }
}; };

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -11,16 +11,17 @@ import org.bukkit.util.Vector;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.events.Worldborder; import net.tylermurphy.hideAndSeek.events.Worldborder;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class SetBorder implements ICommand { public class SetBorder implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(!Main.plugin.status.equals("Standby")) { if(!Main.plugin.status.equals("Standby")) {
sender.sendMessage(errorPrefix + "Game is currently in session"); sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return; return;
} }
if(spawnPosition == null) { if(spawnPosition == null) {
sender.sendMessage(errorPrefix + "Please set spawn position first"); sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return; return;
} }
if(args.length < 2) { if(args.length < 2) {
@ -29,21 +30,21 @@ public class SetBorder implements ICommand {
temp.put("enabled", false); temp.put("enabled", false);
addToSection("worldBorder",temp); addToSection("worldBorder",temp);
saveConfig(); saveConfig();
sender.sendMessage(messagePrefix + "Disabled worldborder."); sender.sendMessage(messagePrefix + message("WORLDBORDER_DISABLE"));
Worldborder.resetWorldborder(spawnWorld); Worldborder.resetWorldborder(spawnWorld);
return; return;
} }
int num,delay; int num,delay;
try { num = Integer.parseInt(args[0]); } catch (Exception e) { try { num = Integer.parseInt(args[0]); } catch (Exception e) {
sender.sendMessage(errorPrefix + "Invalid integer: "+args[0]); sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[0]));
return; return;
} }
try { delay = Integer.parseInt(args[1]); } catch (Exception e) { try { delay = Integer.parseInt(args[1]); } catch (Exception e) {
sender.sendMessage(errorPrefix + "Invalid integer: "+args[1]); sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[1]));
return; return;
} }
if(num < 100) { if(num < 100) {
sender.sendMessage(errorPrefix + "Worldborder cannot be smaller than 100 blocks."); sender.sendMessage(errorPrefix + message("WORLDBORDER_MIN_SIZE"));
return; return;
} }
Vector newWorldborderPosition = new Vector(); Vector newWorldborderPosition = new Vector();
@ -52,7 +53,7 @@ public class SetBorder implements ICommand {
newWorldborderPosition.setY(0); newWorldborderPosition.setY(0);
newWorldborderPosition.setZ(player.getLocation().getBlockZ()); newWorldborderPosition.setZ(player.getLocation().getBlockZ());
if(spawnPosition.distance(newWorldborderPosition) > 100) { if(spawnPosition.distance(newWorldborderPosition) > 100) {
sender.sendMessage(errorPrefix + "Spawn position must be 100 from worldborder center"); sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
return; return;
} }
worldborderPosition = newWorldborderPosition; worldborderPosition = newWorldborderPosition;
@ -66,7 +67,7 @@ public class SetBorder implements ICommand {
temp.put("size", worldborderSize); temp.put("size", worldborderSize);
temp.put("enabled", true); temp.put("enabled", true);
addToSection("worldBorder",temp); addToSection("worldBorder",temp);
sender.sendMessage(messagePrefix + "Set border center to current location, size to "+num+", and delay to "+delay); sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay));
saveConfig(); saveConfig();
Worldborder.resetWorldborder(spawnWorld); Worldborder.resetWorldborder(spawnWorld);
} }

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class SetExitLocation implements ICommand { public class SetExitLocation implements ICommand {
@ -20,11 +21,11 @@ public class SetExitLocation implements ICommand {
newExitPosition.setY(player.getLocation().getBlockY()); newExitPosition.setY(player.getLocation().getBlockY());
newExitPosition.setZ(player.getLocation().getBlockZ()); newExitPosition.setZ(player.getLocation().getBlockZ());
if(!Main.plugin.status.equals("Standby")) { if(!Main.plugin.status.equals("Standby")) {
sender.sendMessage(errorPrefix + "Game is currently in session"); sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return; return;
} }
exitPosition = newExitPosition; exitPosition = newExitPosition;
sender.sendMessage(messagePrefix + "Set exit position to current location"); sender.sendMessage(messagePrefix + message("EXIT_SPAWN"));
Map<String, Object> temp = new HashMap<String,Object>(); Map<String, Object> temp = new HashMap<String,Object>();
temp.put("x", exitPosition.getX()); temp.put("x", exitPosition.getX());
temp.put("y", exitPosition.getY()); temp.put("y", exitPosition.getY());

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class SetLobbyLocation implements ICommand { public class SetLobbyLocation implements ICommand {
@ -20,11 +21,11 @@ public class SetLobbyLocation implements ICommand {
newLobbyPosition.setY(player.getLocation().getBlockY()); newLobbyPosition.setY(player.getLocation().getBlockY());
newLobbyPosition.setZ(player.getLocation().getBlockZ()); newLobbyPosition.setZ(player.getLocation().getBlockZ());
if(!Main.plugin.status.equals("Standby")) { if(!Main.plugin.status.equals("Standby")) {
sender.sendMessage(errorPrefix + "Game is currently in session"); sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return; return;
} }
lobbyPosition = newLobbyPosition; lobbyPosition = newLobbyPosition;
sender.sendMessage(messagePrefix + "Set lobby position to current location"); sender.sendMessage(messagePrefix + message("LOBBY_SPAWN"));
Map<String, Object> temp = new HashMap<String,Object>(); Map<String, Object> temp = new HashMap<String,Object>();
temp.put("x", lobbyPosition.getX()); temp.put("x", lobbyPosition.getX());
temp.put("y", lobbyPosition.getY()); temp.put("y", lobbyPosition.getY());

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class SetSpawnLocation implements ICommand { public class SetSpawnLocation implements ICommand {
@ -20,15 +21,15 @@ public class SetSpawnLocation implements ICommand {
newSpawnPosition.setY(player.getLocation().getBlockY()); newSpawnPosition.setY(player.getLocation().getBlockY());
newSpawnPosition.setZ(player.getLocation().getBlockZ()); newSpawnPosition.setZ(player.getLocation().getBlockZ());
if(!Main.plugin.status.equals("Standby")) { if(!Main.plugin.status.equals("Standby")) {
sender.sendMessage(errorPrefix + "Game is currently in session"); sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return; return;
} }
if(worldborderEnabled && spawnPosition.distance(worldborderPosition) > 100) { if(worldborderEnabled && spawnPosition.distance(worldborderPosition) > 100) {
sender.sendMessage(errorPrefix + "Spawn position must be 100 from worldborder center"); sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
return; return;
} }
spawnPosition = newSpawnPosition; spawnPosition = newSpawnPosition;
sender.sendMessage(messagePrefix + "Set spawn position to current location"); sender.sendMessage(messagePrefix + message("GAME_SPAWN"));
Map<String, Object> temp = new HashMap<String,Object>(); Map<String, Object> temp = new HashMap<String,Object>();
temp.put("x", spawnPosition.getX()); temp.put("x", spawnPosition.getX());
temp.put("y", spawnPosition.getY()); temp.put("y", spawnPosition.getY());

View file

@ -2,42 +2,41 @@ package net.tylermurphy.hideAndSeek.command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import java.io.File; import java.io.File;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class Setup implements ICommand { public class Setup implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
String message = String.format("%s%sThe following is needed for setup...", ChatColor.WHITE, ChatColor.BOLD); String msg = message("SETUP").toString();
int count = 0; int count = 0;
if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) { if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
message = String.format("%s\n%s%s-%s%s", message, ChatColor.RED, ChatColor.BOLD, ChatColor.WHITE, "Game spawn isnt set, /hs setspawn"); msg = msg + "\n" + message("SETUP_GAME").toString();
count++; count++;
} }
if(lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) { if(lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) {
message = String.format("%s\n%s%s-%s%s", message, ChatColor.RED, ChatColor.BOLD, ChatColor.WHITE, "Lobby spawn isnt set, /hs setlobby"); msg = msg + "\n" + message("SETUP_LOBBY").toString();
sender.sendMessage(errorPrefix + "Please set lobby location first");
count++; count++;
} }
if(exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) { if(exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) {
message = String.format("%s\n%s%s-%s%s", message, ChatColor.RED, ChatColor.BOLD, ChatColor.WHITE, "Quit/exit teleport location isnt set, /hs setexit"); msg = msg + "\n" + message("SETUP_EXIT").toString();
count++; count++;
} }
File destenation = new File(Main.root+File.separator+"hideandseek_"+spawnWorld); File destenation = new File(Main.root+File.separator+"hideandseek_"+spawnWorld);
if(!destenation.exists()) { if(!destenation.exists()) {
message = String.format("%s\n%s%s-%s%s", message, ChatColor.RED, ChatColor.BOLD, ChatColor.WHITE, "Hide and seek map isnt saved, /hs savemap (after /hs setspawn)"); msg = msg + "\n" + message("SETUP_MAPSAVE").toString();
count++; count++;
} }
if(count < 1) { if(count < 1) {
sender.sendMessage(messagePrefix + "Everything is setup and ready to go!"); sender.sendMessage(messagePrefix + message("SETUP_COMPLETE"));
} else { } else {
sender.sendMessage(message); sender.sendMessage(msg);
} }
} }

View file

@ -1,4 +1,5 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -22,7 +23,7 @@ import net.tylermurphy.hideAndSeek.events.Taunt;
import net.tylermurphy.hideAndSeek.events.Worldborder; import net.tylermurphy.hideAndSeek.events.Worldborder;
import net.tylermurphy.hideAndSeek.util.Util; import net.tylermurphy.hideAndSeek.util.Util;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -32,19 +33,19 @@ public class Start implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(!Util.isSetup()) { if(!Util.isSetup()) {
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do"); sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return; return;
} }
if(!Main.plugin.status.equals("Standby")) { if(!Main.plugin.status.equals("Standby")) {
sender.sendMessage(errorPrefix + "Game is already in session"); sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return; return;
} }
if(!Main.plugin.board.isPlayer(sender)) { if(!Main.plugin.board.isPlayer(sender)) {
sender.sendMessage(errorPrefix + "You are not in the lobby"); sender.sendMessage(errorPrefix + message("GAME_NOT_INGAME"));
return; return;
} }
if(Main.plugin.board.size() < minPlayers) { if(Main.plugin.board.size() < minPlayers) {
sender.sendMessage(errorPrefix + "You must have at least "+minPlayers+" players to start"); sender.sendMessage(errorPrefix + message("START_MIN_PLAYERS").addAmount(minPlayers));
return; return;
} }
if(Bukkit.getServer().getWorld("hideandseek_"+spawnWorld) != null) { if(Bukkit.getServer().getWorld("hideandseek_"+spawnWorld) != null) {
@ -60,7 +61,7 @@ public class Start implements ICommand {
} }
Player seeker = Main.plugin.board.getPlayer(seekerName); Player seeker = Main.plugin.board.getPlayer(seekerName);
if(seeker == null) { if(seeker == null) {
sender.sendMessage(errorPrefix + "Invalid player: " + seekerName); sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(seekerName));
return; return;
} }
Main.plugin.board.reload(); Main.plugin.board.reload();
@ -82,27 +83,27 @@ public class Start implements ICommand {
for(Player player : Main.plugin.board.getSeekers()) { for(Player player : Main.plugin.board.getSeekers()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,1000000,127,false,false)); player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,1000000,127,false,false));
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,1000000,127,false,false)); player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,1000000,127,false,false));
player.sendTitle(ChatColor.RED + "" + ChatColor.BOLD + "SEEKER", ChatColor.WHITE + "Eliminate all hiders", 10, 70, 20); player.sendTitle(ChatColor.RED + "" + ChatColor.BOLD + "SEEKER", ChatColor.WHITE + message("SEEKERS_SUBTITLE").toString(), 10, 70, 20);
} }
for(Player player : Main.plugin.board.getHiders()) { for(Player player : Main.plugin.board.getHiders()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false)); player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false));
player.sendTitle(ChatColor.GOLD + "" + ChatColor.BOLD + "HIDER", ChatColor.WHITE + "Hide away from the seekers", 10, 70, 20); player.sendTitle(ChatColor.GOLD + "" + ChatColor.BOLD + "HIDER", ChatColor.WHITE + message("HIDERS_SUBTITLE").toString(), 10, 70, 20);
} }
Worldborder.resetWorldborder("hideandseek_"+spawnWorld); Worldborder.resetWorldborder("hideandseek_"+spawnWorld);
Main.plugin.board.reloadGameBoards(); Main.plugin.board.reloadGameBoards();
Main.plugin.status = "Starting"; Main.plugin.status = "Starting";
int temp = Main.plugin.gameId; int temp = Main.plugin.gameId;
Util.broadcastMessage(messagePrefix + "Hiders have 30 seconds to hide!"); Util.broadcastMessage(messagePrefix + message("START_COUNTDOWN").addAmount(30));
Util.sendDelayedMessage(messagePrefix + "Hiders have 20 seconds to hide!", Main.plugin.gameId, 20 * 10); Util.sendDelayedMessage(messagePrefix + message("START_COUNTDOWN").addAmount(20), Main.plugin.gameId, 20 * 10);
Util.sendDelayedMessage(messagePrefix + "Hiders have 10 seconds to hide!", Main.plugin.gameId, 20 * 20); Util.sendDelayedMessage(messagePrefix + message("START_COUNTDOWN").addAmount(10), Main.plugin.gameId, 20 * 20);
Util.sendDelayedMessage(messagePrefix + "Hiders have 5 seconds to hide!", Main.plugin.gameId, 20 * 25); Util.sendDelayedMessage(messagePrefix + message("START_COUNTDOWN").addAmount(5), Main.plugin.gameId, 20 * 25);
Util.sendDelayedMessage(messagePrefix + "Hiders have 3 seconds to hide!", Main.plugin.gameId, 20 * 27); Util.sendDelayedMessage(messagePrefix + message("START_COUNTDOWN").addAmount(3), Main.plugin.gameId, 20 * 27);
Util.sendDelayedMessage(messagePrefix + "Hiders have 2 seconds to hide!", Main.plugin.gameId, 20 * 28); Util.sendDelayedMessage(messagePrefix + message("START_COUNTDOWN").addAmount(2), Main.plugin.gameId, 20 * 28);
Util.sendDelayedMessage(messagePrefix + "Hiders have 1 seconds to hide!", Main.plugin.gameId, 20 * 29); Util.sendDelayedMessage(messagePrefix + message("START_COUNTDOWN").addAmount(1), Main.plugin.gameId, 20 * 29);
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() { Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
public void run() { public void run() {
if(temp != Main.plugin.gameId) return; if(temp != Main.plugin.gameId) return;
Util.broadcastMessage(messagePrefix + "Attetion SEEKERS, its time to find the hiders!"); Util.broadcastMessage(messagePrefix + message("START"));
Main.plugin.status = "Playing"; Main.plugin.status = "Playing";
for(Player player : Main.plugin.board.getPlayers()) { for(Player player : Main.plugin.board.getPlayers()) {
resetPlayer(player); resetPlayer(player);

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -14,6 +14,7 @@ import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.events.Worldborder; import net.tylermurphy.hideAndSeek.events.Worldborder;
import net.tylermurphy.hideAndSeek.util.Packet; import net.tylermurphy.hideAndSeek.util.Packet;
import net.tylermurphy.hideAndSeek.util.Util; import net.tylermurphy.hideAndSeek.util.Util;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class Stop implements ICommand { public class Stop implements ICommand {
@ -23,12 +24,12 @@ public class Stop implements ICommand {
return; return;
} }
if(Main.plugin.status.equals("Starting") || Main.plugin.status.equals("Playing")) { if(Main.plugin.status.equals("Starting") || Main.plugin.status.equals("Playing")) {
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + "Game has been force stopped."); if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + message("STOP"));
else Util.broadcastMessage(abortPrefix + "Game has been force stopped."); else Util.broadcastMessage(abortPrefix + message("STOP"));
onStop(); onStop();
} else { } else {
sender.sendMessage(errorPrefix + "There is no game in progress"); sender.sendMessage(errorPrefix + message("GAME_NOT_INPROGRESS"));
return; return;
} }
} }

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek; package net.tylermurphy.hideAndSeek.configuration;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -7,6 +7,8 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.tylermurphy.hideAndSeek.Main;
public class Config { public class Config {
public static String public static String
@ -52,37 +54,6 @@ public class Config {
Main.plugin.reloadConfig(); Main.plugin.reloadConfig();
//Default
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("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("prefix.warning", "&cWarning > &f");
getConfig().addDefault("nametagsVisible", false);
getConfig().addDefault("permissionsRequired", true);
getConfig().addDefault("announceMessagesToNonPlayers", false);
getConfig().addDefault("spawns.lobby.x", 0);
getConfig().addDefault("spawns.lobby.y", 0);
getConfig().addDefault("spawns.lobby.z", 0);
getConfig().addDefault("spawns.lobby.world", "world");
getConfig().addDefault("spawns.exit.x", 0);
getConfig().addDefault("spawns.exit.y", 0);
getConfig().addDefault("spawns.exit.z", 0);
getConfig().addDefault("spawns.exit.world", "world");
getConfig().addDefault("spawns.game.x", 0);
getConfig().addDefault("spawns.game.y", 0);
getConfig().addDefault("spawns.game.z", 0);
getConfig().addDefault("spawns.game.world", "world");
getConfig().addDefault("minPlayers", 2);
getConfig().addDefault("gameLength", 600);
//Spawn //Spawn
spawnPosition = new Vector( spawnPosition = new Vector(
getConfig().getDouble("spawns.game.x"), getConfig().getDouble("spawns.game.x"),

View file

@ -0,0 +1,37 @@
package net.tylermurphy.hideAndSeek.configuration;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.configuration.file.YamlConfiguration;
import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.Main;
public class Localization {
public static final Map<String,LocalizationString> LOCAL = new HashMap<String,LocalizationString>();
static YamlConfiguration config;
public static boolean init() {
Main.plugin.saveResource("localization.yml", false);
String path = Main.data.getAbsolutePath()+File.separator + "localization.yml";
config = YamlConfiguration.loadConfiguration(new File(path));
for(String key : config.getConfigurationSection("Localization").getKeys(false)) {
LOCAL.put(
key,
new LocalizationString( ChatColor.translateAlternateColorCodes('&', config.getString("Localization."+key) ) )
);
}
return true;
}
public static LocalizationString message(String key) {
LocalizationString temp = LOCAL.get(key);
if(temp == null)
return new LocalizationString(key+" missing from localization.yml");
return temp;
}
}

View file

@ -0,0 +1,48 @@
package net.tylermurphy.hideAndSeek.configuration;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
public class LocalizationString {
String message;
public LocalizationString(String message) {
this.message = message;
}
public LocalizationString addPlayer(Entity player) {
this.message = message.replaceFirst("\\{PLAYER\\}", player.getName());
return this;
}
public LocalizationString addPlayer(CommandSender player) {
this.message = message.replaceFirst("\\{PLAYER\\}", player.getName());
return this;
}
public LocalizationString addPlayer(String player) {
this.message = message.replaceFirst("\\{PLAYER\\}", player);
return this;
}
public LocalizationString addAmount(Integer value) {
this.message = message.replaceFirst("\\{AMOUNT\\}", value.toString());
return this;
}
public LocalizationString addAmount(String value) {
this.message = message.replaceFirst("\\{AMOUNT\\}", value.toString());
return this;
}
public LocalizationString addAmount(Float value) {
this.message = message.replaceFirst("\\{AMOUNT\\}", value.toString());
return this;
}
public String toString() {
return message;
}
}

View file

@ -1,9 +1,8 @@
package net.tylermurphy.hideAndSeek.events; package net.tylermurphy.hideAndSeek.events;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -13,6 +12,7 @@ import org.bukkit.inventory.meta.FireworkMeta;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.Util; import net.tylermurphy.hideAndSeek.util.Util;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class Taunt { public class Taunt {
@ -65,8 +65,8 @@ public class Taunt {
} }
} }
if(taunted != null) { if(taunted != null) {
taunted.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Oh no! You have been chosed to be taunted."); taunted.sendMessage(message("TAUNTED").toString());
Util.broadcastMessage(tauntPrefix + " A random hider will be taunted in the next 30s"); Util.broadcastMessage(tauntPrefix + message("TAUNT"));
tauntPlayer = taunted.getName(); tauntPlayer = taunted.getName();
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
public void run() { public void run() {
@ -87,7 +87,7 @@ public class Taunt {
.withTrail() .withTrail()
.build()); .build());
fw.setFireworkMeta(fwm); fw.setFireworkMeta(fwm);
Util.broadcastMessage(tauntPrefix + " Taunt has been activated"); Util.broadcastMessage(tauntPrefix + message("TAUNT_ACTIVATE"));
} }
tauntPlayer = ""; tauntPlayer = "";
waitTaunt(); waitTaunt();

View file

@ -1,5 +1,8 @@
package net.tylermurphy.hideAndSeek.events; package net.tylermurphy.hideAndSeek.events;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldBorder; import org.bukkit.WorldBorder;
@ -7,8 +10,6 @@ import org.bukkit.WorldBorder;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.Util; import net.tylermurphy.hideAndSeek.util.Util;
import static net.tylermurphy.hideAndSeek.Config.*;
public class Worldborder { public class Worldborder {
private final int temp; private final int temp;
@ -28,7 +29,7 @@ public class Worldborder {
private void decreaceWorldborder() { private void decreaceWorldborder() {
if(temp != Main.plugin.gameId) return; if(temp != Main.plugin.gameId) return;
if(currentWorldborderSize-100 > 100) { if(currentWorldborderSize-100 > 100) {
Util.broadcastMessage(worldborderPrefix + "Worldborder decreacing by 100 blocks over the next 30s"); Util.broadcastMessage(worldborderPrefix + message("WORLDBORDER_DECREASING"));
currentWorldborderSize -= 100; currentWorldborderSize -= 100;
World world = Bukkit.getWorld("hideandseek_"+spawnWorld); World world = Bukkit.getWorld("hideandseek_"+spawnWorld);
WorldBorder border = world.getWorldBorder(); WorldBorder border = world.getWorldBorder();

View file

@ -1,5 +1,7 @@
package net.tylermurphy.hideAndSeek.util; package net.tylermurphy.hideAndSeek.util;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -20,8 +22,6 @@ import org.bukkit.scoreboard.Team.OptionStatus;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import static net.tylermurphy.hideAndSeek.Config.*;
public class Board { public class Board {
private List<String> Hider, Seeker, Spectator; private List<String> Hider, Seeker, Spectator;

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.util; package net.tylermurphy.hideAndSeek.util;
import static net.tylermurphy.hideAndSeek.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import java.io.File; import java.io.File;

View file

@ -0,0 +1,61 @@
# How long in seconds will the game last, set it < 1 to disable
# default: 1200 aka 20min
gameLength: 1200
# Announce join/leave/game over messages to people not playing the game
# default: true
announceMessagesToNonPlayers: true
# Allow Hiders to see their own teams nametags as well as seekers. Seekers can never see nametags regardless.
# default: false
nametagsVisible: false
# Require bukkit permessions though a plugin to run commands, recomended on large servers
# default: true
permissionsRequired: true
# Minimum ammount of players to start the game. Cannot go lower than 2.
# default: 2
minPlayers: 2
# Spawn locations where players are teleported
spawns:
# Location where players are teleported into the game (/hs start)
game:
x: 0
y: 0
z: 0
world: world
# Location where players are teleported into the lobby (/hs join)
lobby:
x: 0
y: 0
z: 0
world: world
# Location where players are teleported when they exit (/hs leave)
exit:
x: 0
y: 0
z: 0
world: world
# The worldborder closes every interval, whish is evey [delay] in minutes.
# Thw worldborder stharts at [size], and decreaces 100 blocks every interval.
# x & z are the center location. [enabled] is whenever the border is enabled.
worldBorder:
x: 0
z: 0
delay: 10
size: 500
enabled: false
# The message prefixes displayed before messages. The message contents themselvs
# can be changed in localization.yml.
prefix:
default: '&9Hide and Seek > &f'
error: '&cError > &f'
taunt: '&eTaunt > &f'
border: '&cWorld Border > &f'
abort: '&cAbort > &f'
gameover: '&aGame Over > &f'
warning: '&cWarning > &f'

View file

@ -0,0 +1,50 @@
Localization:
COMMAND_PLAYER_ONLY: "This command can only be run as a player."
COMMAND_NOT_ALLOWED: "You are not allowed to run this command."
COMMAND_ERROR: "An internal error has occoured."
GAME_PLAYER_DEATH: "&c{PLAYER}&f was killed."
GAME_PLAYER_FOUND: "&e{PLAYER}&f was found and became a seeker."
GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f was found by &c{PLAYER}&f and became a seeker."
GAME_GAMEOVER_HIDERS_FOUND: "All hiders have been found."
GAME_GAMEOVER_SEEKERS_QUIT: "All seekers have quit."
GAME_GAMEOVER_TIME: "Seekers ran out of time. Hiders win!"
GAME_SETUP: "Game is not setup. Run /hs setup to see what you need to do."
GAME_INGAME: "You are already in the lobby/game."
GAME_NOT_INGAME: "You are not in a lobby/game."
GAME_INPROGRESS: "There is currently a game inprogress."
GAME_NOT_INPROGRESS: "There is no game inprogress."
GAME_JOIN: "{PLAYER} has joined the HideAndSeek lobby."
GAME_JOIN_SPECTATOR: "You have joined midgame and are now a spectator."
GAME_LEAVE: "{PLAYER} has left the HideAndSeek lobby."
CONFIG_RELOAD: "Reloaded the config."
MAPSAVE_INPROGRESS: "Map save is currently in progress. Try again later."
MAPSAVE_START: "Starting map save."
MAPSAVE_WARNING: "All commands will be disabled whenthe save is in progress. Do not turn off the server."
MAPSAVE_END: "Map save complete."
MAPSAVE_ERROR: "Coudnt find current map."
WORLDBORDER_DISABLE: "Disabled worldborder."
WORLDBORDER_INVALID_INPUT: "Invalid integer {AMOUNT}."
WORLDBORDER_MIN_SIZE: "Worldborder cannot be smaller than 100 blocks."
WORLDBORDER_POSITION: "Spawn position must be 100 from worldborder center."
WORLDBORDER_ENABLE: "Set border center to current location, size to {AMOUNT}, and delay to {AMOUNT}."
WORLDBORDER_DECREASING: "Worlderborder decreasing by 100 blocks over the next 30s."
TAUNTED: "$c$oOh no! You have been chosen to be taunted."
TAUNT: "A random hider will be taunted in the next 30s."
TAUNT_ACTIVATE: "Taunt has been activated."
ERROR_GAME_SPAWN: "Please set game spawn location first"
SETUP: "&f&lThe following is needed for setup..."
SETUP_GAME: "&c&l- &fGame spawn isnt set, /hs setspawn"
SETUP_LOBBY: "&c&l- &fLobby spawn isnt set, /hs setlobby"
SETUP_EXIT: "&c&l- &fQuit/exit teleport location isnt set, /hs setexit"
SETUP_SAVEMAP: "&c&l- &fHide and seek map isnt saved, /hs savemap (after /hs setspawn)"
SETUP_COMPLETE: "Everything is setup and ready to go!"
GAME_SPAWN: "Set game spawn position to current location"
LOBBY_SPAWN: "Set lobby position to current location"
EXIT_SPAWN: "Set exit position to current location"
START_MIN_PLAYERS: "You must have at least {AMOUNT} players to start."
START_INVALID_NAME: "Invalid player: {PLAYER}."
START_COUNTDOWN: "Hiders have {AMOUNT} seconds to hide!"
START: "Attetion SEEKERS, its time to fin the hiders!"
STOP: "Game has been force stopped"
HIDERS_SUBTITLE: "Hide away from the seekers"
SEEKERS_SUBTITLE: "Eliminate all hiders"

View file

@ -8,7 +8,7 @@ depend: [ProtocolLib]
commands: commands:
hideandseek: hideandseek:
description: Hide and Seek command description: Hide and Seek command
usage: /hideandseek [about|help|start|stop|setspawn|setseeker] usage: /hideandseek [command]
aliases: hs aliases: hs
permissions: permissions:
hideandseek.*: hideandseek.*:
@ -20,10 +20,11 @@ permissions:
hideandseek.setborder: true hideandseek.setborder: true
hideandseek.setspawn: true hideandseek.setspawn: true
hideandseek.setlobby: true hideandseek.setlobby: true
hideandseek.setexit: true
hideandseek.setup: true
hideandseek.start: true hideandseek.start: true
hideandseek.stop: true hideandseek.stop: true
hideandseek.savemap: true hideandseek.savemap: true
hideandseek.blockbypass: true
hideandseek.join: true hideandseek.join: true
hideandseek.leave: true hideandseek.leave: true
hideandseek.about: hideandseek.about:
@ -44,6 +45,12 @@ permissions:
hideandseek.setlobby: hideandseek.setlobby:
description: Allows you to set the game lobby point description: Allows you to set the game lobby point
default: op default: op
hideandseek.setexit:
description: Allows you to set the game exit point
default: op
hideandseek.setup:
description: Allows you to see what needs to be setup for the plugin to function
default: op
hideandseek.start: hideandseek.start:
description: Allows you to start the game description: Allows you to start the game
default: op default: op
@ -53,9 +60,6 @@ permissions:
hideandseek.savemap: hideandseek.savemap:
description: Allows you to set the current game map description: Allows you to set the current game map
default: op default: op
hideandseek.blockbypass:
description: Allows you to bypass the block break prevention
default: op
hideandseek.join: hideandseek.join:
description: Allows you to join the game manual lobby description: Allows you to join the game manual lobby
default: true default: true