From a2f727bebcccfed44e604fbc09327c408b50919d Mon Sep 17 00:00:00 2001 From: KHobbits Date: Fri, 19 Aug 2011 12:06:35 +0100 Subject: [PATCH 01/10] Success message on /spawner Switch to use mob class. --- .../src/com/earth2me/essentials/Mob.java | 3 +++ .../src/com/earth2me/essentials/Util.java | 5 +++++ .../essentials/commands/Commandspawner.java | 19 ++++++++++++++----- .../essentials/commands/Commandspawnmob.java | 17 ++++++----------- Essentials/src/messages.properties | 1 + Essentials/src/messages_da.properties | 1 + Essentials/src/messages_de.properties | 1 + Essentials/src/messages_en.properties | 1 + Essentials/src/messages_fr.properties | 1 + Essentials/src/messages_nl.properties | 1 + 10 files changed, 34 insertions(+), 16 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Mob.java b/Essentials/src/com/earth2me/essentials/Mob.java index f5e1aea3d..5ada086d9 100644 --- a/Essentials/src/com/earth2me/essentials/Mob.java +++ b/Essentials/src/com/earth2me/essentials/Mob.java @@ -86,6 +86,9 @@ public enum Mob final protected String type; } + public CreatureType getType () { + return bukkitType; + } public static class MobException extends Exception { diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index 614e9b2b9..82231cb06 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -483,4 +483,9 @@ public class Util } return buf.toString(); } + + public static String capitalCase(String s) + { + return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1); + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java index ae92670ca..15f5910af 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.Mob; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import org.bukkit.Material; @@ -22,6 +23,7 @@ public class Commandspawner extends EssentialsCommand if (args.length < 1 || args[0].length() < 2) { throw new NotEnoughArgumentsException(); + //TODO: user.sendMessage("§7Mobs: Zombie PigZombie Skeleton Slime Chicken Pig Monster Spider Creeper Ghast Squid Giant Cow Sheep Wolf"); } final Block target = user.getTarget().getTargetBlock(); @@ -33,11 +35,18 @@ public class Commandspawner extends EssentialsCommand charge(user); try { - String name = args[0].substring(0, 1).toUpperCase() + args[0].substring(1).toLowerCase(); - if (name.equalsIgnoreCase("Pigzombie")) { - name = "PigZombie"; - } - new CraftCreatureSpawner(target).setCreatureType(CreatureType.fromName(name)); + String name = args[0]; + name = name.equalsIgnoreCase("PigZombie") ? "PigZombie" : Util.capitalCase(name); + + Mob mob = null; + mob = Mob.fromName(name); + if (mob == null) + { + user.sendMessage(Util.i18n("invalidMob")); + return; + } + new CraftCreatureSpawner(target).setCreatureType(mob.getType()); + user.sendMessage(Util.format("setSpawner", mob.name)); } catch (Throwable ex) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index 86d2beac4..188edab27 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -40,7 +40,7 @@ public class Commandspawnmob extends EssentialsCommand String[] mountparts = args[0].split(","); String[] parts = mountparts[0].split(":"); String mobType = parts[0]; - mobType = mobType.equalsIgnoreCase("PigZombie") ? "PigZombie" : capitalCase(mobType); + mobType = mobType.equalsIgnoreCase("PigZombie") ? "PigZombie" : Util.capitalCase(mobType); String mobData = null; if (parts.length == 2) { @@ -52,7 +52,7 @@ public class Commandspawnmob extends EssentialsCommand { parts = mountparts[1].split(":"); mountType = parts[0]; - mountType = mountType.equalsIgnoreCase("PigZombie") ? "PigZombie" : capitalCase(mountType); + mountType = mountType.equalsIgnoreCase("PigZombie") ? "PigZombie" : Util.capitalCase(mountType); if (parts.length == 2) { mountData = parts[1]; @@ -186,11 +186,6 @@ public class Commandspawnmob extends EssentialsCommand } } - private String capitalCase(String s) - { - return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1); - } - private void changeMobData(String type, Entity spawned, String data, User user) throws Exception { if ("Slime".equalsIgnoreCase(type)) @@ -210,11 +205,11 @@ public class Commandspawnmob extends EssentialsCommand { if (data.equalsIgnoreCase("random")) { - Random rand = new Random(); - ((CraftSheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]); + Random rand = new Random(); + ((CraftSheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]); } - else - { + else + { ((CraftSheep)spawned).setColor(DyeColor.valueOf(data.toUpperCase())); } } diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 9bbcd7a87..912b14c67 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -240,6 +240,7 @@ seconds = seconds seenOffline = Player {0} is offline since {1} seenOnline = Player {0} is online since {1} serverFull = Server is full +setSpawner = Changed spawner type to {0} sheepMalformedColor = Malformed color. shoutFormat = \u00a77[Shout]\u00a7f {0} similarWarpExist = A warp with a similar name already exists. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index de0c930bc..37f5449ec 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -240,6 +240,7 @@ seconds = sekunder seenOffline = Spiller {0} er offline siden {1} seenOnline = Spiller {0} er online siden {1} serverFull = Server er fuld +setSpawner = Changed spawner type to {0} sheepMalformedColor = Misdannet farve. shoutFormat = \u00a77[R\u00e5b]\u00a7f {0} similarWarpExist = En warp med lignende tekst eksisterer allerede. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 3da16d3f9..c9b6e2705 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -238,6 +238,7 @@ seconds = Sekunden seenOffline = Spieler {0} ist offline seit {1} seenOnline = Spieler {0} ist online seit {1} serverFull = Server ist voll +setSpawner = Changed spawner type to {0} sheepMalformedColor = Ung\u00fcltige Farbe. shoutFormat = \u00a77[Schrei]\u00a7f {0} similarWarpExist = Ein Warp-Punkt mit einem \u00e4hnlichen Namen existiert bereits. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 84a843dc7..244340750 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -240,6 +240,7 @@ seconds = seconds seenOffline = Player {0} is offline since {1} seenOnline = Player {0} is online since {1} serverFull = Server is full +setSpawner = Changed spawner type to {0} sheepMalformedColor = Malformed color. shoutFormat = \u00a77[Shout]\u00a7f {0} similarWarpExist = A warp with a similar name already exists. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index a4c007a1a..af74e9fff 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -238,6 +238,7 @@ seconds = secondes seenOffline = Le joueur {0} est hors ligne depuis {1} seenOnline = Le joueur {0} est en ligne depuis {1} serverFull = Le serveur est plein. +setSpawner = Changed spawner type to {0} sheepMalformedColor = Couleur mal form\u00e9e. shoutFormat = \u00a77[Crie]\u00a7f {0} similarWarpExist = Un warp avec un nom similaire existe d\u00e9j\u00e0. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 375d9248f..8d0c2ac77 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -239,6 +239,7 @@ seconds = seconde seenOffline = Speler {0} is offline vanaf {1} seenOnline = Speler {0} is online vanaf {1} serverFull = Server is vol +setSpawner = Changed spawner type to {0} sheepMalformedColor = Misvoormde kleur. shoutFormat = \u00a77[Shout]\u00a7f {0} similarWarpExist = Er bestaat al een warp met dezelfde naam. From 8d1262fc916fa763189a9cfd6a55cdbd4d7cdc58 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Fri, 19 Aug 2011 12:16:28 +0100 Subject: [PATCH 02/10] Check jail first, before setting. --- .../com/earth2me/essentials/commands/Commandtogglejail.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java index 5fafe3374..c88cdc5a6 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java @@ -45,9 +45,6 @@ public class Commandtogglejail extends EssentialsCommand } } charge(sender); - p.setJailed(true); - p.sendMessage(Util.i18n("userJailed")); - p.setJail(null); if (!(p.getBase() instanceof OfflinePlayer)) { ess.getJail().sendToJail(p, args[1]); @@ -57,6 +54,9 @@ public class Commandtogglejail extends EssentialsCommand // Check if jail exists ess.getJail().getJail(args[1]); } + p.setJailed(true); + p.sendMessage(Util.i18n("userJailed")); + p.setJail(null); p.setJail(args[1]); long timeDiff = 0; if (args.length > 2) From a32b55e28f88e068135e2bb6afe62c6464679057 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 20 Aug 2011 16:44:42 +0100 Subject: [PATCH 03/10] Translation for tpall + tidy. --- Essentials/src/messages.properties | 2 +- Essentials/src/messages_da.properties | 7 ++++--- Essentials/src/messages_de.properties | 6 ++++-- Essentials/src/messages_en.properties | 3 ++- Essentials/src/messages_fr.properties | 4 ++++ Essentials/src/messages_nl.properties | 8 +++++--- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 912b14c67..f739ead42 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -1,6 +1,7 @@ #version: TeamCity # Single quotes have to be doubled: '' # Translations start here +# by: addedToAccount = \u00a7a{0} has been added to your account. addedToOthersAccount = \u00a7a{0} has been added to {1} account. alertBroke = broke: @@ -281,7 +282,6 @@ typeTpaccept = \u00a77To teleport, type \u00a7c/tpaccept\u00a77. typeTpdeny = \u00a77To deny this request, type \u00a7c/tpdeny\u00a77. typeWorldName = \u00a77You can also type the name of a specific world. unableToSpawnMob = Unable to spawn mob. -unableToSpawnMob = Unable to spawn mob. unbannedIP = Unbanned IP address. unbannedPlayer = Unbanned player. unignorePlayer = You are not ignoring player {0} anymore. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 37f5449ec..2d22bd848 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -1,8 +1,7 @@ #version: TeamCity # Single quotes have to be doubled: '' # Translations start here -#Danish Translation by papand13, papand13@gmail.com -#Danish Translation Version: 1.0 +# by: papand13, papand13@gmail.com addedToAccount = \u00a7a{0} er tilf\u00f8jet til din konto. addedToOthersAccount = \u00a7a{0} er blevet tilf\u00f8jet til {1} konto. alertBroke = \u00f8delagde: @@ -232,7 +231,9 @@ protectionOwner = \u00a76[EssentialsProtect] Beskyttelses ejer: {0} questionFormat = \u00a77[Sp\u00f8rgsm\u00e5l]\u00a7f {0} reloadAllPlugins = \u00a77Genindl\u00e6ste alle tilf\u00f8jelser. requestAccepted = \u00a77Teleporterings anmodning n\u00e6gtet. +requestAcceptedFrom = \u00a77{0} accepted your teleport request. requestDenied = \u00a77Teleporterings anmodning n\u00e6gtet. +requestDeniedFrom = \u00a77{0} denied your teleport request. requestSent = \u00a77Anmodning sendt til {0}\u00a77. returnPlayerToJailError = En fejl opstod ved fors\u00f8g p\u00e5 at returnere spiller til f\u00e6ngsel. second = sekunde @@ -252,6 +253,7 @@ suicideMessage = \u00a77Farvel grusomme verden... suicideSuccess = \u00a77{0} tog sit eget liv takenFromAccount = \u00a7c{0} er taget fra din konto. takenFromOthersAccount = \u00a7c{0} er blevet taget fra {1} konto. +teleportAAll = \u00a77Teleporting request sent to all players... teleportAll = \u00a77Teleportere alle spillere... teleportAtoB = \u00a77{0}\u00a77 teleporterede dig til {1}\u00a77. teleportDisabled = {0} har teleportation deaktiveret. @@ -279,7 +281,6 @@ treeSpawned = \u00a77Tr\u00e6 fremkaldt. typeTpaccept = \u00a77For at teleportere, skriv \u00a7c/tpaccept\u00a77. typeTpdeny = \u00a77For at n\u00e6gte denne anmodning, skriv \u00a7c/tpdeny\u00a77. typeWorldName = \u00a77Du kan ogs\u00e5 skrive nanvet p\u00e5 en specifik verden. -unableToSpawnMob = Kan ikke spawne mob. unableToSpawnMob = Kunne ikke fremkalde mob. unbannedIP = Tilgav IP addresse, ikke l\u00e6ngere bannet. unbannedPlayer = Tilgav spiller, ikke l\u00e6ngere bannet. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index c9b6e2705..0522d90d1 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -1,6 +1,7 @@ #version: TeamCity # Single quotes have to be doubled: '' # Translations start here +# by: addedToAccount = \u00a7a{0} wurden zu deiner Geldb\u00f6rse hinzugef\u00fcgt. addedToOthersAccount = \u00a7a{0} wurden zu {1}s Konto hinzugef\u00fcgt. alertBroke = zerst\u00f6rt: @@ -230,7 +231,9 @@ protectionOwner = \u00a76[EssentialsProtect] Besitzer dieses Blocks: {0} questionFormat = \u00a77[Frage]\u00a7f {0} reloadAllPlugins = \u00a77Alle plugins neu geladen. requestAccepted = \u00a77Teleportierungsanfrage akzeptiert. +requestAcceptedFrom = \u00a77{0} accepted your teleport request. requestDenied = \u00a77Teleportierungsanfrage verweigert. +requestDeniedFrom = \u00a77{0} denied your teleport request. requestSent = \u00a77Anfrage gesendet an {0}\u00a77. returnPlayerToJailError = Fehler beim Versuch, den Spieler ins Gef\u00e4ngnis zu teleportieren. second = Sekunde @@ -250,6 +253,7 @@ suicideMessage = \u00a77Lebewohl grausame Welt... suicideSuccess = \u00a77{0} hat sich das Leben genommen. takenFromAccount = \u00a7c{0} wurden aus deiner Geldb\u00f6rse genommen. takenFromOthersAccount = \u00a7c{0} wurde von {1} wurde Rechnung getragen. +teleportAAll = \u00a77Teleporting request sent to all players... teleportAll = \u00a77Teleportiere alle Spieler... teleportAtoB = \u00a77{0}\u00a77 teleportiert dich zu {1}\u00a77. teleportDisabled = {0} verweigert die Teleportierung. @@ -277,7 +281,6 @@ treeSpawned = \u00a77Baum gepflanzt. typeTpaccept = \u00a77Um zu teleportieren, schreibe \u00a7c/tpaccept\u00a77. typeTpdeny = \u00a77Um diese Anfrage abzulehnen, schreibe \u00a7c/tpdeny\u00a77. typeWorldName = \u00a77Du kannst auch den Namen der Welt eingeben. -unableToSpawnMob = Erzeugen eines Monsters gescheitert unableToSpawnMob = Fehler beim Erzeugen eines Monster. unbannedIP = Verbannung von IP-Adresse r\u00fcckg\u00e4ngig gemacht. unbannedPlayer = Verbannung von Spieler r\u00fcckg\u00e4ngig gemacht. @@ -327,4 +330,3 @@ year = Jahr years = Jahre youAreHealed = \u00a77Du wurdest geheilt. youHaveNewMail = \u00a7cDu hast {0} Nachrichten!\u00a7f Schreibe \u00a77/mail read\u00a7f um deine Nachrichten anzuzeigen. -invalidCharge = \u00a7cUng\u00fcltige Verf\u00fcgung. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 244340750..e04736152 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -1,6 +1,7 @@ #version: TeamCity # Single quotes have to be doubled: '' # Translations start here +# by: addedToAccount = \u00a7a{0} has been added to your account. addedToOthersAccount = \u00a7a{0} has been added to {1} account. alertBroke = broke: @@ -252,6 +253,7 @@ suicideMessage = \u00a77Goodbye Cruel World... suicideSuccess = \u00a77{0} took their own life takenFromAccount = \u00a7c{0} has been taken from your account. takenFromOthersAccount = \u00a7c{0} has been taken from {1} account. +teleportAAll = \u00a77Teleporting request sent to all players... teleportAll = \u00a77Teleporting all players... teleportAtoB = \u00a77{0}\u00a77 teleported you to {1}\u00a77. teleportDisabled = {0} has teleportation disabled. @@ -280,7 +282,6 @@ typeTpaccept = \u00a77To teleport, type \u00a7c/tpaccept\u00a77. typeTpdeny = \u00a77To deny this request, type \u00a7c/tpdeny\u00a77. typeWorldName = \u00a77You can also type the name of a specific world. unableToSpawnMob = Unable to spawn mob. -unableToSpawnMob = Unable to spawn mob. unbannedIP = Unbanned IP address. unbannedPlayer = Unbanned player. unignorePlayer = You are not ignoring player {0} anymore. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index af74e9fff..e2aa8e5a9 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -1,6 +1,7 @@ #version: TeamCity # Single quotes have to be doubled: '' # Translations start here +# by: addedToAccount = \u00a7a{0} a \u00e9t\u00e9 rajout\u00e9 a votre compte. addedToOthersAccount = \u00a7a{0} a \u00e9t\u00e9 ajout\u00e9 \u00e0 {1} compte. alertBroke = a cass\u00e9: @@ -230,7 +231,9 @@ protectionOwner = \u00a76[EssentialsProtect] Propri\u00e9taire de la protection questionFormat = \u00a77[Question]\u00a7f {0} reloadAllPlugins = \u00a77Tous les plugins ont \u00e9t\u00e9 recharg\u00e9s. requestAccepted = \u00a77Demande de t\u00e9l\u00e9portation accept\u00e9e. +requestAcceptedFrom = \u00a77{0} accepted your teleport request. requestDenied = \u00a77Demande de t\u00e9l\u00e9portation refus\u00e9e. +requestDeniedFrom = \u00a77{0} denied your teleport request. requestSent = \u00a77Requ\u00eate envoy\u00e9e \u00e0 {0}\u00a77. returnPlayerToJailError = Erreur survenue lors de la tentative d''emprisonner de nouveau un joueur. second = seconde @@ -250,6 +253,7 @@ suicideMessage = \u00a77Au revoir monde cruel... suicideSuccess = \u00a77{0} a pris sa propre vie. takenFromAccount = \u00a7c{0} ont \u00e9t\u00e9 pris de votre compte. takenFromOthersAccount = \u00a7c{0} a \u00e9t\u00e9 prise de {1} compte. +teleportAAll = \u00a77Teleporting request sent to all players... teleportAll = \u00a77T\u00e9l\u00e9poration de tous les joueurs. teleportAtoB = \u00a77{0}\u00a77 vous a t\u00e9l\u00e9port\u00e9 \u00e0 {1}\u00a77. teleportDisabled = {0} a la t\u00e9l\u00e9portation d\u00e9sactiv\u00e9. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 8d0c2ac77..036976f9e 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -1,7 +1,7 @@ #version: TeamCity # Single quotes have to be doubled: '' # Translations start here -# by Geertje123 +# by: Geertje123 addedToAccount = \u00a7a{0} is gestort op je account. addedToOthersAccount = \u00a7a{0} is overgemaakt naar {1}''s rekening alertBroke = gebroken: @@ -231,7 +231,9 @@ protectionOwner = \u00a76[EssentialsProtect] Beschermingeigenaar: {0} questionFormat = \u00a77[Vraag]\u00a7f {0} reloadAllPlugins = \u00a77Alle plugins zijn herladen. requestAccepted = \u00a77Teleporteer aanvraag geaccepteerd. +requestAcceptedFrom = \u00a77{0} accepted your teleport request. requestDenied = \u00a77Teleporteer aanvraag geweigerd. +requestDeniedFrom = \u00a77{0} denied your teleport request. requestSent = \u00a77Aanvraag verstuurd naar {0}\u00a77. returnPlayerToJailError = Fout opgetreden bij terugzetten van speler in gevangenis. second = seconde @@ -251,6 +253,7 @@ suicideMessage = \u00a77Vaarwel vreedzame wereld... suicideSuccess = \u00a77{0} pleegde zelfmoord takenFromAccount = \u00a7c{0} is van je bank rekening afgehaald. takenFromOthersAccount = \u00a7c{0} is overgenomen uit {1} account. +teleportAAll = \u00a77Teleporting request sent to all players... teleportAll = \u00a77Bezig met teleporteren van alle spelers... teleportAtoB = \u00a77{0}\u00a77 is naar {1}\u00a77 geteleporteerd. teleportDisabled = {0} heeft teleporteren uit gezet. @@ -279,7 +282,6 @@ typeTpaccept = \u00a77Om te teleporten, type \u00a7c/tpaccept\u00a77. typeTpdeny = \u00a77Om te weigeren, type \u00a7c/tpdeny\u00a77. typeWorldName = \u00a77Je kan ook de exacte naam van de wereld typen. unableToSpawnMob = De mob kan niet gespawned worden. -unableToSpawnMob = Mob kon niet gespawnd worden. unbannedIP = IP adres ontbannen. unbannedPlayer = Speler ontbannen. unignorePlayer = Je negeert {0} niet meer. @@ -327,4 +329,4 @@ worthSet = Waarde ingesteld year = jaar years = jaren youAreHealed = \u00a77Je bent genezen. -youHaveNewMail = \u00a7cJe hebt {0} berichten!\u00a7f Type \u00a77/mail read\u00a7f om je berichten te bekijken. \ No newline at end of file +youHaveNewMail = \u00a7cJe hebt {0} berichten!\u00a7f Type \u00a77/mail read\u00a7f om je berichten te bekijken. From 84068c18b1790f50f40b7989f1b56aef10ff86a1 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 20 Aug 2011 18:06:43 +0100 Subject: [PATCH 04/10] Updating default permissions. --- EssentialsGroupManager/src/groups.yml | 93 ++++++++++++++------------- EssentialsGroupManager/src/users.yml | 9 +-- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/EssentialsGroupManager/src/groups.yml b/EssentialsGroupManager/src/groups.yml index 87033cdc9..371c169dd 100644 --- a/EssentialsGroupManager/src/groups.yml +++ b/EssentialsGroupManager/src/groups.yml @@ -13,43 +13,6 @@ groups: prefix: '&e' build: false suffix: '' - SemiAdmin: - default: false - permissions: - - -groupmanager.mantogglesave - - essentials - - essentials.antioch - - essentials.burn - - essentials.clearinventory - - essentials.cooldown.bypass - - essentials.deljail - - essentials.fireball - - essentials.gc - - essentials.give - - essentials.god - - essentials.heal - - essentials.heal.others - - essentials.lightning - - essentials.invsee - - essentials.item - - essentials.jails - - essentials.kickall - - essentials.kit.* - - essentials.mute - - essentials.sell - - essentials.setjail - - essentials.signs.* - - essentials.spawnmob - - essentials.teleport.cooldown.bypass - - essentials.teleport.timer.bypass - - essentials.togglejail - - groupmanager.* - inheritance: - - moderator - info: - prefix: '&c' - build: true - suffix: '' Builder: default: false permissions: @@ -57,10 +20,15 @@ groups: - essentials.back - essentials.back.ondeath - essentials.balance + - essentials.balance.others + - essentials.balancetop + - essentials.chat.color - essentials.chat.shout + - essentials.chat.question - essentials.compass - - essentials.home - essentials.depth + - essentials.home + - essentials.ignore - essentials.kit - essentials.kit.tools - essentials.mail @@ -69,6 +37,7 @@ groups: - essentials.msg - essentials.nick - essentials.pay + - essentials.ping - essentials.portal - essentials.powertool - essentials.protect @@ -83,6 +52,7 @@ groups: - essentials.signs.break.protection - essentials.signs.break.trade - essentials.suicide + - essentials.time - essentials.tpa - essentials.tpaccept - essentials.tpahere @@ -100,28 +70,41 @@ groups: default: false permissions: - essentials.ban + - essentials.ban.notify - essentials.banip - essentials.broadcast + - essentials.clearinventory - essentials.delwarp - - essentials.eco + - essentials.eco.loan - essentials.ext - essentials.getpos + - essentials.helpop.recieve + - essentials.home.others + - essentials.invsee + - essentials.jails - essentials.jump - essentials.kick + - essentials.kick.notify - essentials.kill + - essentials.mute + - essentials.nick.others + - essentials.realname - essentials.setwarp - essentials.signs.create.* - essentials.signs.break.* - essentials.spawner - essentials.thunder - essentials.time - - essentials.time.world + - essentials.time.set + - essentials.protect.alerts + - essentials.protect.admin + - essentials.protect.ownerinfo + - essentials.ptime + - essentials.ptime.others - essentials.togglejail - essentials.top - essentials.tp - essentials.tphere - - essentials.tpo - - essentials.tpohere - essentials.tppos - essentials.tptoggle - essentials.unban @@ -131,12 +114,11 @@ groups: - essentials.world - groupmanager.listgroups - groupmanager.mandemote - - groupmanager.manload - groupmanager.manpromote - - groupmanager.mansave - groupmanager.manselect - groupmanager.manuadd - groupmanager.manudel + - groupmanager.manwhois inheritance: - builder info: @@ -144,11 +126,32 @@ groups: build: true suffix: '' Admin: + default: false + permissions: + - -essentials.backup + - -essentials.essentials + - -essentials.setspawn + - -essentials.reloadall + - -essentials.plugin + - essentials.* + - groupmanager.mantogglevalidate + - groupmanager.mansave + - groupmanager.mangcheckp + - groupmanager.manglistp + - groupmanager.manucheckp + - groupmanager.manulistp + inheritance: + - moderator + info: + prefix: '&c' + build: true + suffix: '' + Owner: default: false permissions: - '*' inheritance: - - semiadmin + - admin info: prefix: '&4' build: true diff --git a/EssentialsGroupManager/src/users.yml b/EssentialsGroupManager/src/users.yml index c3324f0c0..5eb841c97 100644 --- a/EssentialsGroupManager/src/users.yml +++ b/EssentialsGroupManager/src/users.yml @@ -1,14 +1,11 @@ # "For a more advanced configuration example utilizing the advanced features of GroupManager, see http://pastebin.com/a8ZA0j5G" +# "You will want to remove these users and replace them with your own" users: - kimkandor: + snowleo: subgroups: [] permissions: [] group: Admin - mudzereli: - subgroups: [] - permissions: [] - group: Builder - zenexer: + khobbits: subgroups: [] permissions: [] group: Admin From 9791dcc0bc5f9342f5f00844baa4d752dd4f79c3 Mon Sep 17 00:00:00 2001 From: okamosy Date: Sat, 20 Aug 2011 18:09:55 +0100 Subject: [PATCH 05/10] Reformatted ptime and time messages fixed typo in plugin --- .../essentials/DescParseTickFormat.java | 15 +-- .../essentials/commands/Commandptime.java | 96 +++++++------------ .../essentials/commands/Commandtime.java | 33 ++----- Essentials/src/messages.properties | 12 +++ Essentials/src/messages_da.properties | 12 +++ Essentials/src/messages_de.properties | 12 +++ Essentials/src/messages_en.properties | 12 +++ Essentials/src/messages_fr.properties | 12 +++ Essentials/src/messages_nl.properties | 12 +++ Essentials/src/plugin.yml | 2 +- 10 files changed, 116 insertions(+), 102 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java b/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java index 21ca8feff..a64f8e3c7 100755 --- a/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java +++ b/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java @@ -35,7 +35,6 @@ public final class DescParseTickFormat SDFTwelve.setTimeZone(TimeZone.getTimeZone("GMT")); nameToTicks.put("sunrise", 23000); - nameToTicks.put("rise", 23000); nameToTicks.put("dawn", 23000); nameToTicks.put("daystart", 0); @@ -49,7 +48,6 @@ public final class DescParseTickFormat nameToTicks.put("afternoon", 9000); nameToTicks.put("sunset", 12000); - nameToTicks.put("set", 12000); nameToTicks.put("dusk", 12000); nameToTicks.put("sundown", 12000); nameToTicks.put("nightfall", 12000); @@ -227,18 +225,7 @@ public final class DescParseTickFormat // -------------------------------------------- public static String format(final long ticks) { - final StringBuilder msg = new StringBuilder(); - msg.append(Commandtime.colorHighlight1); - msg.append(format24(ticks)); - msg.append(Commandtime.colorDefault); - msg.append(" or "); - msg.append(Commandtime.colorHighlight1); - msg.append(format12(ticks)); - msg.append(Commandtime.colorDefault); - msg.append(" or "); - msg.append(Commandtime.colorHighlight1); - msg.append(formatTicks(ticks)); - return msg.toString(); + return Util.format("timeFormat", format24(ticks), format12(ticks), formatTicks(ticks)); } public static String formatTicks(final long ticks) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java index bbf1dfdcc..2eb580ea4 100755 --- a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java @@ -4,6 +4,7 @@ import com.earth2me.essentials.DescParseTickFormat; import org.bukkit.Server; import org.bukkit.command.CommandSender; import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import java.util.Collection; import java.util.Comparator; import java.util.HashSet; @@ -17,12 +18,6 @@ import org.bukkit.entity.Player; public class Commandptime extends EssentialsCommand { - // TODO: I suggest that the chat colors be centralized in the config file. - public static final ChatColor colorDefault = ChatColor.YELLOW; - public static final ChatColor colorChrome = ChatColor.GOLD; - public static final ChatColor colorLogo = ChatColor.GREEN; - public static final ChatColor colorHighlight1 = ChatColor.AQUA; - public static final ChatColor colorBad = ChatColor.RED; public static final Set getAliases = new HashSet(); static @@ -57,10 +52,10 @@ public class Commandptime extends EssentialsCommand } User user = ess.getUser(sender); - if (user != null && !user.isAuthorized("essentials.ptime.others")) + if ((!users.contains(user) || users.size() > 1) && user != null && !user.isAuthorized("essentials.ptime.others")) { - // TODO should not be hardcoded !! - throw new Exception(colorBad + "You are not authorized to set others PlayerTime"); + user.sendMessage(Util.i18n("pTimeOthersPermission")); + return; } Long ticks; @@ -102,41 +97,29 @@ public class Commandptime extends EssentialsCommand */ private void getUsersTime(final CommandSender sender, final Collection users) { - if (users.size() == 1) + if (users.size() > 1) { - final User user = users.iterator().next(); - - if (user.getPlayerTimeOffset() == 0) - { - sender.sendMessage(colorDefault + user.getName() + "'s time is normal. Time is the same as on the server."); - } - else - { - String time = DescParseTickFormat.format(user.getPlayerTime()); - if (!user.isPlayerTimeRelative()) - { - time = "fixed to " + time; - } - sender.sendMessage(colorDefault + user.getName() + "'s time is " + time); - } - return; + sender.sendMessage(Util.format("pTimePlayers")); } - - sender.sendMessage(colorDefault + "These players have their own time:"); - - for (User user : users) + + for (User user : users) { - //if (!user.isPlayerTimeRelative()) - if (user.getPlayerTimeOffset() != 0) + if(user.getPlayerTimeOffset() == 0) { + sender.sendMessage(Util.format("pTimeNormal", user.getName())); + } + else { String time = DescParseTickFormat.format(user.getPlayerTime()); - if (!user.isPlayerTimeRelative()) + if(!user.isPlayerTimeRelative()) { - time = "fixed to " + time; + sender.sendMessage(Util.format("pTimeCurrentFixed", user.getName(), time)); + } + else { + sender.sendMessage(Util.format("pTimeCurrent", user.getName(), time)); } - sender.sendMessage(colorDefault + user.getName() + "'s time is " + time); } } + return; } @@ -171,44 +154,33 @@ public class Commandptime extends EssentialsCommand } } + final StringBuilder msg = new StringBuilder(); + for (User user : users) + { + if (msg.length() > 0) + { + msg.append(", "); + } + + msg.append(user.getName()); + } // Inform the sender of the change - sender.sendMessage(""); - final StringBuilder msg = new StringBuilder(); if (ticks == null) { - sender.sendMessage(colorDefault + "The players time was reset for:"); + sender.sendMessage(Util.format("pTimeReset", msg.toString())); } else { String time = DescParseTickFormat.format(ticks); if (!relative) { - time = "fixed to " + time; + sender.sendMessage(Util.format("pTimeSetFixed", time, msg.toString())); + } + else { + sender.sendMessage(Util.format("pTimeSet", time, msg.toString())); } - sender.sendMessage(colorDefault + "The players time is " + time); - msg.append(colorDefault); - msg.append("For: "); } - - boolean first = true; - for (User user : users) - { - if (!first) - { - msg.append(colorDefault); - msg.append(", "); - } - else - { - first = false; - } - - msg.append(colorHighlight1); - msg.append(user.getName()); - } - - sender.sendMessage(msg.toString()); } /** @@ -258,7 +230,7 @@ public class Commandptime extends EssentialsCommand // We failed to understand the world target... else { - throw new Exception("Could not find the player(s) \"" + selector + "\""); + throw new Exception(Util.i18n("playerNotFound")); } return users; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java index 331fff019..72bb2b65f 100755 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java @@ -5,19 +5,12 @@ import org.bukkit.Server; import org.bukkit.World; import org.bukkit.command.CommandSender; import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import java.util.*; -import org.bukkit.ChatColor; public class Commandtime extends EssentialsCommand { - // TODO: I suggest that the chat colors be centralized in the config file. - public static final ChatColor colorDefault = ChatColor.YELLOW; - public static final ChatColor colorChrome = ChatColor.GOLD; - public static final ChatColor colorLogo = ChatColor.GREEN; - public static final ChatColor colorHighlight1 = ChatColor.AQUA; - public static final ChatColor colorBad = ChatColor.RED; - public Commandtime() { super("time"); @@ -44,8 +37,8 @@ public class Commandtime extends EssentialsCommand User user = ess.getUser(sender); if (user != null && !user.isAuthorized("essentials.time.set")) { - // TODO should not be hardcoded !! - throw new Exception(colorBad + "You are not authorized to set the time"); + user.sendMessage(Util.i18n("timeSetPermission")); + return; } // Parse the target time int ticks from args[0] @@ -67,7 +60,6 @@ public class Commandtime extends EssentialsCommand */ private void getWorldsTime(CommandSender sender, Collection worlds) { - // TODO do we need to check for the essentials.time permission? Or is that tested for us already. if (worlds.size() == 1) { Iterator iter = worlds.iterator(); @@ -77,7 +69,7 @@ public class Commandtime extends EssentialsCommand for (World world : worlds) { - sender.sendMessage(colorDefault + world.getName() + ": " + DescParseTickFormat.format(world.getTime())); + sender.sendMessage(Util.format("timeCurrentWorld", world.getName(), DescParseTickFormat.format(world.getTime()))); } return; } @@ -96,30 +88,21 @@ public class Commandtime extends EssentialsCommand } // Inform the sender of the change - sender.sendMessage(""); - sender.sendMessage(colorDefault + "The time was set to " + DescParseTickFormat.format(ticks)); + //sender.sendMessage(""); StringBuilder msg = new StringBuilder(); - msg.append(colorDefault); - msg.append("In "); boolean first = true; for (World world : worlds) { - if (!first) + if (msg.length() > 0) { - msg.append(colorDefault); msg.append(", "); } - else - { - first = false; - } - msg.append(colorHighlight1); msg.append(world.getName()); } - sender.sendMessage(msg.toString()); + sender.sendMessage(Util.format("timeWorldSet", DescParseTickFormat.format(ticks), msg.toString())); } /** @@ -158,7 +141,7 @@ public class Commandtime extends EssentialsCommand // We failed to understand the world target... else { - throw new Exception("Could not find the world(s) \"" + selector + "\""); + throw new Exception(Util.i18n("invalidWorld")); } return worlds; diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 912b14c67..519fdd180 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -227,6 +227,14 @@ powerToolAir = Command can''t be attached to air. powerToolAttach = Command assigned to {0} powerToolRemove = Command removed from {0} protectionOwner = \u00a76[EssentialsProtect] Protection owner: {0} +pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. +pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. +pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. +pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. +pTimePlayers = These players have their own time: +pTimeReset = Player time has been reset for: \u00a7e{0} +pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} +pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Question]\u00a7f {0} reloadAllPlugins = \u00a77Reloaded all plugins. requestAccepted = \u00a77Teleport request accepted. @@ -271,8 +279,12 @@ thunder = You {0} thunder in your world thunderDuration = You {0} thunder in your world for {1} seconds. timeBeforeHeal = Time before next heal: {0} timeBeforeTeleport = Time before next teleport: {0} +timeFormat = \u00a73{0}\u00a7f or \u00a73{1}\u00a7f or \u00a73{2}\u00a7f timePattern = (?:([0-9]+)\\s*y[a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)? timeSet = Time set in all worlds. +timeSetPermission = \u00a7cYou are not authorized to set the time. +timeWorldCurrent = The current time in {0} is \u00a73{1} +timeWorldSet = The time was set to {0} in: \u00a7c{1} tradeCompleted = \u00a77Trade completed. tradeSignEmpty = The trade sign does not have enough supply left. treeFailure = \u00a7cTree generation failure. Try again on grass or dirt. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 37f5449ec..c497ff893 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -229,6 +229,14 @@ powerToolAir = Kommando kan ikke blive tildelt luft. powerToolAttach = Kommando tildelt til {0} powerToolRemove = Kommando fjernet fra {0} protectionOwner = \u00a76[EssentialsProtect] Beskyttelses ejer: {0} +pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. +pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. +pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. +pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. +pTimePlayers = These players have their own time: +pTimeReset = Player time has been reset for: \u00a7e{0} +pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} +pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Sp\u00f8rgsm\u00e5l]\u00a7f {0} reloadAllPlugins = \u00a77Genindl\u00e6ste alle tilf\u00f8jelser. requestAccepted = \u00a77Teleporterings anmodning n\u00e6gtet. @@ -270,8 +278,12 @@ thunder = Du {0} torden i din verden thunderDuration = Du {0} torden i din verden i {1} sekunder. timeBeforeHeal = Tid inden n\u00e6ste helbredelse: {0} timeBeforeTeleport = Tid f\u00f8r n\u00e6ste teleportering: {0} +timeFormat = \u00a73{0}\u00a7f or \u00a73{1}\u00a7f or \u00a73{2}\u00a7f timePattern = (?:([0-9]+)\\s*[a\u00e5y][a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:([0-9]+)\\s*[wu][a-z]*[,\\s]*)?(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?(?:([0-9]+)\\s*[ht][a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)? timeSet = Tid er sat i alle verdener. +timeSetPermission = \u00a7cYou are not authorized to set the time. +timeWorldCurrent = The current time in {0} is \u00a73{1} +timeWorldSet = The time was set to {0} in: \u00a7c{1} tradeCompleted = \u00a77Forhandling fuldf\u00f8rt. tradeSignEmpty = Forhandlings skiltet har ikke nok forsyning tilbage. treeFailure = \u00a7cTr\u00e6 genererings fejl. Pr\u00f8v igen p\u00e5 gr\u00e6s eller jord. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index c9b6e2705..a562fed14 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -227,6 +227,14 @@ powerToolAir = Befehl kann nicht mit Luft verbunden werden. powerToolAttach = Befehl verbunden mit {0} powerToolRemove = Befehl entfernt von {0} protectionOwner = \u00a76[EssentialsProtect] Besitzer dieses Blocks: {0} +pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. +pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. +pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. +pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. +pTimePlayers = These players have their own time: +pTimeReset = Player time has been reset for: \u00a7e{0} +pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} +pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Frage]\u00a7f {0} reloadAllPlugins = \u00a77Alle plugins neu geladen. requestAccepted = \u00a77Teleportierungsanfrage akzeptiert. @@ -268,8 +276,12 @@ thunder = Es donnert nun in deiner Welt {0}. thunderDuration = Es donnert nun f\u00fcr {1} Sekunden in deiner Welt {0}. timeBeforeHeal = Zeit bis zur n\u00e4chsten Heilung: {0} timeBeforeTeleport = Zeit bis zum n\u00e4chsten Teleport: {0} +timeFormat = \u00a73{0}\u00a7f or \u00a73{1}\u00a7f or \u00a73{2}\u00a7f timePattern = (?:([0-9]+)\\s*[yj][a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?(?:([0-9]+)\\s*[dt][a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:h|st)[a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)? timeSet = Zeit in allen Welten gesetzt. +timeSetPermission = \u00a7cYou are not authorized to set the time. +timeWorldCurrent = The current time in {0} is \u00a73{1} +timeWorldSet = The time was set to {0} in: \u00a7c{1} tradeCompleted = \u00a77Handel abgeschlossen. tradeSignEmpty = Der Bestand des Trade-Schild ist aufgebraucht. treeFailure = \u00a7cBaumpflanzung gescheitert. Versuche es auf Gras oder Dreck. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 244340750..36987b99b 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -227,6 +227,14 @@ powerToolAir = Command can''t be attached to air. powerToolAttach = Command assigned to {0} powerToolRemove = Command removed from {0} protectionOwner = \u00a76[EssentialsProtect] Protection owner: {0} +pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. +pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. +pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. +pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. +pTimePlayers = These players have their own time: +pTimeReset = Player time has been reset for: \u00a7e{0} +pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} +pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Question]\u00a7f {0} reloadAllPlugins = \u00a77Reloaded all plugins. requestAccepted = \u00a77Teleport request accepted. @@ -270,8 +278,12 @@ thunder = You {0} thunder in your world thunderDuration = You {0} thunder in your world for {1} seconds. timeBeforeHeal = Time before next heal: {0} timeBeforeTeleport = Time before next teleport: {0} +timeFormat = \u00a73{0}\u00a7f or \u00a73{1}\u00a7f or \u00a73{2}\u00a7f timePattern = (?:([0-9]+)\\s*y[a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)? timeSet = Time set in all worlds. +timeSetPermission = \u00a7cYou are not authorized to set the time. +timeWorldCurrent = The current time in {0} is \u00a73{1} +timeWorldSet = The time was set to {0} in: \u00a7c{1} tradeCompleted = \u00a77Trade completed. tradeSignEmpty = The trade sign does not have enough supply left. treeFailure = \u00a7cTree generation failure. Try again on grass or dirt. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index af74e9fff..2d46c1d1a 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -227,6 +227,14 @@ powerToolAir = La commande ne peut pas \u00eatre attach\u00e9e \u00e0 l''air. powerToolAttach = Commande assign\u00e9e \u00e0 {0} powerToolRemove = Commande enlev\u00e9e \u00e0 {0} protectionOwner = \u00a76[EssentialsProtect] Propri\u00e9taire de la protection : {0} +pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. +pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. +pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. +pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. +pTimePlayers = These players have their own time: +pTimeReset = Player time has been reset for: \u00a7e{0} +pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} +pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Question]\u00a7f {0} reloadAllPlugins = \u00a77Tous les plugins ont \u00e9t\u00e9 recharg\u00e9s. requestAccepted = \u00a77Demande de t\u00e9l\u00e9portation accept\u00e9e. @@ -268,8 +276,12 @@ thunder = Vous avez {0} la foudre dans votre monde. thunderDuration = Vous avez {0} la foudre dans le serveur {1} secondes. timeBeforeHeal = Temps avant le prochain soin : {0} timeBeforeTeleport = Temps avant prochaine t\u00e9l\u00e9portation {0} +timeFormat = \u00a73{0}\u00a7f or \u00a73{1}\u00a7f or \u00a73{2}\u00a7f timePattern = (?:([0-9]+)\\\\s*[ya][a-z]*[,\\\\s]*)?(?:([0-9]+)\\\\s*mo[a-z]*[,\\\\s]*)?(?:([0-9]+)\\\\s*(?:sem|w)[a-z]*[,\\\\s]*)?(?:([0-9]+)\\\\s*[dj][a-z]*[,\\\\s]*)?(?:([0-9]+)\\\\s*h[a-z]*[,\\\\s]*)?(?:([0-9]+)\\\\s*m[a-z]*[,\\\\s]*)?(?:([0-9]+)\\\\s*(?:s[a-z]*)?)? timeSet = Heure modifi\u00e9e dans tous les mondes. +timeSetPermission = \u00a7cYou are not authorized to set the time. +timeWorldCurrent = The current time in {0} is \u00a73{1} +timeWorldSet = The time was set to {0} in: \u00a7c{1} tradeCompleted = \u00a77\u00c9change termin\u00e9. tradeSignEmpty = Le panneau de vente n''as pas encore assez de stock. treeFailure = \u00a7cEchec de la g\u00e9n\u00e9ration de l''arbre. Essayez de nouveau sur de l''herbe ou de la terre. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 8d0c2ac77..91feb519a 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -228,6 +228,14 @@ powerToolAir = Command kan niet worden bevestigd aan lucht. powerToolAttach = Command toegewezen aan {0} powerToolRemove = Command verwijderd van {0} protectionOwner = \u00a76[EssentialsProtect] Beschermingeigenaar: {0} +pTimeCurrent = \u00a7e{0}''s\u00a7f time is {1}. +pTimeCurrentFixed = \u00a7e{0}''s\u00a7f time is fixed to {1}. +pTimeNormal = \u00a7e{0}''s\u00a7f time is normal and matches the server. +pTimeOthersPermission = \u00a7cYou are not authorized to set other players'' time. +pTimePlayers = These players have their own time: +pTimeReset = Player time has been reset for: \u00a7e{0} +pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} +pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Vraag]\u00a7f {0} reloadAllPlugins = \u00a77Alle plugins zijn herladen. requestAccepted = \u00a77Teleporteer aanvraag geaccepteerd. @@ -269,8 +277,12 @@ thunder = Je {0} onweert de wereld thunderDuration = Je {0} onweert de wereld voor {1} seconde. timeBeforeHeal = Afkoeltijd tot de volgende heal: {0} timeBeforeTeleport = Afkoeltijd tot de volgende teleport: {0} +timeFormat = \u00a73{0}\u00a7f or \u00a73{1}\u00a7f or \u00a73{2}\u00a7f timePattern = (?:([0-9]+)\\s*[yj][a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[oa][a-z]*[,\\s]*)?(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?(?:([0-9]+)\\s*[hu][a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)? timeSet = Tijd ingesteld in alle werelden. +timeSetPermission = \u00a7cYou are not authorized to set the time. +timeWorldCurrent = The current time in {0} is \u00a73{1} +timeWorldSet = The time was set to {0} in: \u00a7c{1} tradeCompleted = \u00a77Ruil verricht. tradeSignEmpty = Het handelsbordje heeft een te kleine voorraad. treeFailure = \u00a7cFout bij het genereren van boom. Pobeer het opnieuw op gras of dirt. diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index d1da3f224..42960031b 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -275,7 +275,7 @@ commands: usage: / [duration] aliases: [ethunder] time: - description: Change the world time. Defaults tos current world. + description: Change the world time. Defaults to current world. usage: / [day|night|dawn|17:30|4pm|4000ticks] [worldname|all] aliases: [etime, day, night] togglejail: From 3e9b27e3ef2f7d8fdd4da6699fe903974173ddb3 Mon Sep 17 00:00:00 2001 From: okamosy Date: Sat, 20 Aug 2011 20:49:17 +0100 Subject: [PATCH 06/10] Added command repair [hand|all] fixed if statements in commandsell --- .../essentials/commands/Commandrepair.java | 124 ++++++++++++++++++ .../essentials/commands/Commandsell.java | 4 +- Essentials/src/messages.properties | 4 + Essentials/src/messages_da.properties | 4 + Essentials/src/messages_de.properties | 4 + Essentials/src/messages_en.properties | 4 + Essentials/src/messages_fr.properties | 4 + Essentials/src/messages_nl.properties | 4 + Essentials/src/plugin.yml | 4 + 9 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 Essentials/src/com/earth2me/essentials/commands/Commandrepair.java diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java new file mode 100644 index 000000000..a388f92d2 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java @@ -0,0 +1,124 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.earth2me.essentials.commands; + +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; +import org.bukkit.Material; +import org.bukkit.Server; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.MaterialData; + + +/** + * + * @author Seiji + */ +public class Commandrepair extends EssentialsCommand +{ + public Commandrepair() + { + super("repair"); + } + + @Override + public void run(Server server, User user, String commandLabel, String[] args) throws Exception + { + if (args.length < 1) + { + throw new NotEnoughArgumentsException(); + } + + if (args[0].equalsIgnoreCase("hand")) + { + ItemStack item = user.getItemInHand(); + try + { + repairItem(item); + } + catch (Exception e) + { + user.sendMessage(e.getMessage()); + return; + } + + String itemName = item.getType().toString().toLowerCase().replace('_', ' '); + user.sendMessage(Util.format("repair", itemName)); + } + else if (args[0].equalsIgnoreCase("all")) + { + StringBuilder itemList = new StringBuilder(); + itemList.append(repairItems(user.getInventory().getContents())); + + String armor = repairItems(user.getInventory().getArmorContents()); + + if(armor.length() > 0) + { + if(itemList.length() > 0) + { + itemList.append(", "); + } + + itemList.append(armor); + } + + if (itemList.length() == 0) + { + user.sendMessage(Util.format("repairNone")); + } + else + { + user.sendMessage(Util.format("repair", itemList.toString())); + } + + } + else + { + throw new NotEnoughArgumentsException(); + } + } + + private void repairItem(ItemStack item) throws Exception + { + Material material = Material.getMaterial(item.getTypeId()); + String error = null; + if (material.isBlock() || material.getMaxDurability() < 0) + { + throw new Exception(Util.i18n("repairInvalidType")); + } + + if (item.getDurability() == 0) + { + throw new Exception(Util.i18n("repairAlreadyFixed")); + } + + item.setDurability((short)0); + } + + private String repairItems(ItemStack[] items) + { + StringBuilder itemList = new StringBuilder(); + for (ItemStack item : items) + { + try + { + repairItem(item); + if (itemList.length() > 0) + { + itemList.append(", "); + } + + String itemName = item.getType().toString().toLowerCase().replace('_', ' '); + itemList.append(itemName); + } + catch (Exception e) + { + } + + } + + return itemList.toString(); + } +} diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java index 56f6cb2fc..f471364d5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java @@ -29,7 +29,7 @@ public class Commandsell extends EssentialsCommand { is = user.getItemInHand(); } - if (args[0].equalsIgnoreCase("inventory")) + else if (args[0].equalsIgnoreCase("inventory")) { for (ItemStack stack : user.getInventory().getContents()) { @@ -47,7 +47,7 @@ public class Commandsell extends EssentialsCommand } return; } - if (args[0].equalsIgnoreCase("blocks")) + else if (args[0].equalsIgnoreCase("blocks")) { for (ItemStack stack : user.getInventory().getContents()) { diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index b84d05994..089d05670 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -238,6 +238,10 @@ pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Question]\u00a7f {0} reloadAllPlugins = \u00a77Reloaded all plugins. +repair = You have successfully repaired your: \u00a7e{0}. +repairAlreadyFixed = \u00a77This item does not need repairing. +repairInvalidType = \u00a7cThis item cannot be repaired. +repairNone = There were no items that needing repairing. requestAccepted = \u00a77Teleport request accepted. requestAcceptedFrom = \u00a77{0} accepted your teleport request. requestDenied = \u00a77Teleport request denied. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index fe45b375f..41b34ab0e 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -238,6 +238,10 @@ pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Sp\u00f8rgsm\u00e5l]\u00a7f {0} reloadAllPlugins = \u00a77Genindl\u00e6ste alle tilf\u00f8jelser. +repair = You have successfully repaired your: \u00a7e{0}. +repairAlreadyFixed = \u00a77This item does not need repairing. +repairInvalidType = \u00a7cThis item cannot be repaired. +repairNone = There were no items that needing repairing. requestAccepted = \u00a77Teleporterings anmodning n\u00e6gtet. requestAcceptedFrom = \u00a77{0} accepted your teleport request. requestDenied = \u00a77Teleporterings anmodning n\u00e6gtet. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index a429d1aa6..d85cd4350 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -238,6 +238,10 @@ pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Frage]\u00a7f {0} reloadAllPlugins = \u00a77Alle plugins neu geladen. +repair = You have successfully repaired your: \u00a7e{0}. +repairAlreadyFixed = \u00a77This item does not need repairing. +repairInvalidType = \u00a7cThis item cannot be repaired. +repairNone = There were no items that needing repairing. requestAccepted = \u00a77Teleportierungsanfrage akzeptiert. requestAcceptedFrom = \u00a77{0} accepted your teleport request. requestDenied = \u00a77Teleportierungsanfrage verweigert. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index e2aa6793c..4c1ad26d4 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -238,6 +238,10 @@ pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Question]\u00a7f {0} reloadAllPlugins = \u00a77Reloaded all plugins. +repair = You have successfully repaired your: \u00a7e{0}. +repairAlreadyFixed = \u00a77This item does not need repairing. +repairInvalidType = \u00a7cThis item cannot be repaired. +repairNone = There were no items that needing repairing. requestAccepted = \u00a77Teleport request accepted. requestAcceptedFrom = \u00a77{0} accepted your teleport request. requestDenied = \u00a77Teleport request denied. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 9d9dd23fc..0849c78d6 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -238,6 +238,10 @@ pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Question]\u00a7f {0} reloadAllPlugins = \u00a77Tous les plugins ont \u00e9t\u00e9 recharg\u00e9s. +repair = You have successfully repaired your: \u00a7e{0}. +repairAlreadyFixed = \u00a77This item does not need repairing. +repairInvalidType = \u00a7cThis item cannot be repaired. +repairNone = There were no items that needing repairing. requestAccepted = \u00a77Demande de t\u00e9l\u00e9portation accept\u00e9e. requestAcceptedFrom = \u00a77{0} accepted your teleport request. requestDenied = \u00a77Demande de t\u00e9l\u00e9portation refus\u00e9e. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 1d086ee34..a76084a55 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -238,6 +238,10 @@ pTimeSet = Player time is set to \u00a73{0}\u00a7f for: \u00a7e{1} pTimeSetFixed = Player time is fixed to \u00a73{0}\u00a7f for: \u00a7e{1} questionFormat = \u00a77[Vraag]\u00a7f {0} reloadAllPlugins = \u00a77Alle plugins zijn herladen. +repair = You have successfully repaired your: \u00a7e{0}. +repairAlreadyFixed = \u00a77This item does not need repairing. +repairInvalidType = \u00a7cThis item cannot be repaired. +repairNone = There were no items that needing repairing. requestAccepted = \u00a77Teleporteer aanvraag geaccepteerd. requestAcceptedFrom = \u00a77{0} accepted your teleport request. requestDenied = \u00a77Teleporteer aanvraag geweigerd. diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 42960031b..1acef22e8 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -222,6 +222,10 @@ commands: description: Reloads all plugins. usage: / aliases: [rel,ereloadall,ereload,erel] + repair: + description: Repairs the item in hand, or all items in the current inventory. + usage: / [hand|all] + aliases: [fix] rules: description: Views the server rules. usage: / From 2c787e07ec934df12e0e61c464cb45d095da06e3 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 20 Aug 2011 20:54:54 +0100 Subject: [PATCH 07/10] Switching trade sign flag --- Essentials/src/com/earth2me/essentials/signs/SignTrade.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java index 37f56d9fb..ccbd4fd9d 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java @@ -20,7 +20,7 @@ public class SignTrade extends EssentialsSign { validateTrade(sign, 1, false, ess); validateTrade(sign, 2, true, ess); - final Trade charge = getTrade(sign, 2, true, true, ess); + final Trade charge = getTrade(sign, 2, true, false, ess); charge.isAffordableFor(player); sign.setLine(3, "§8" + username); charge.charge(player); From d14f278ecf7e6a4f3c851a8b28a052d15d47771b Mon Sep 17 00:00:00 2001 From: okamosy Date: Sat, 20 Aug 2011 21:23:44 +0100 Subject: [PATCH 08/10] added charge command fixed formatting --- .../essentials/commands/Commandrepair.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java index a388f92d2..e98deeab7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java @@ -45,22 +45,23 @@ public class Commandrepair extends EssentialsCommand } String itemName = item.getType().toString().toLowerCase().replace('_', ' '); + charge(user); user.sendMessage(Util.format("repair", itemName)); } else if (args[0].equalsIgnoreCase("all")) { StringBuilder itemList = new StringBuilder(); itemList.append(repairItems(user.getInventory().getContents())); - + String armor = repairItems(user.getInventory().getArmorContents()); - - if(armor.length() > 0) + + if (armor.length() > 0) { - if(itemList.length() > 0) + if (itemList.length() > 0) { itemList.append(", "); } - + itemList.append(armor); } @@ -70,6 +71,7 @@ public class Commandrepair extends EssentialsCommand } else { + charge(user); user.sendMessage(Util.format("repair", itemList.toString())); } @@ -88,15 +90,15 @@ public class Commandrepair extends EssentialsCommand { throw new Exception(Util.i18n("repairInvalidType")); } - + if (item.getDurability() == 0) { throw new Exception(Util.i18n("repairAlreadyFixed")); } - + item.setDurability((short)0); } - + private String repairItems(ItemStack[] items) { StringBuilder itemList = new StringBuilder(); From 83fc7de01a5a54182061681ee2f59a957e0da112 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 20 Aug 2011 21:58:26 +0100 Subject: [PATCH 09/10] Fixing trade message to be more user friendly. --- .../earth2me/essentials/signs/SignTrade.java | 39 +++++++++++++------ Essentials/src/messages.properties | 3 +- Essentials/src/messages_da.properties | 1 + Essentials/src/messages_de.properties | 1 + Essentials/src/messages_en.properties | 1 + Essentials/src/messages_fr.properties | 1 + Essentials/src/messages_nl.properties | 1 + 7 files changed, 34 insertions(+), 13 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java index ccbd4fd9d..a1a066088 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java @@ -10,6 +10,7 @@ import org.bukkit.inventory.ItemStack; public class SignTrade extends EssentialsSign { + public SignTrade() { super("Trade"); @@ -33,10 +34,17 @@ public class SignTrade extends EssentialsSign { if (sign.getLine(3).substring(2).equalsIgnoreCase(username)) { - final Trade stored = getTrade(sign, 1, true, true, ess); - substractAmount(sign, 1, stored, ess); - stored.pay(player); - Trade.log("Sign", "Trade", "OwnerInteract", username, null, username, stored, sign.getBlock().getLocation(), ess); + try + { + final Trade stored = getTrade(sign, 1, true, true, ess); + substractAmount(sign, 1, stored, ess); + stored.pay(player); + Trade.log("Sign", "Trade", "OwnerInteract", username, null, username, stored, sign.getBlock().getLocation(), ess); + } + catch (SignException e) + { + throw new SignException(Util.i18n("tradeSignEmptyOwner")); + } } else { @@ -141,7 +149,7 @@ public class SignTrade extends EssentialsSign sign.setLine(index, stackamount + " " + split[1] + ":" + amount); return; } - throw new SignException(Util.format("invalidSignLine", index+1)); + throw new SignException(Util.format("invalidSignLine", index + 1)); } protected final Trade getTrade(final ISign sign, final int index, final boolean fullAmount, final boolean notEmpty, final IEssentials ess) throws SignException @@ -155,11 +163,18 @@ public class SignTrade extends EssentialsSign if (split.length == 2) { - final Double money = getMoney(split[0]); - final Double amount = notEmpty ? getDoublePositive(split[1]) : getDouble(split[1]); - if (money != null && amount != null) + try { - return new Trade(fullAmount ? amount : money, ess); + final Double money = getMoney(split[0]); + final Double amount = notEmpty ? getDoublePositive(split[1]) : getDouble(split[1]); + if (money != null && amount != null) + { + return new Trade(fullAmount ? amount : money, ess); + } + } + catch (SignException e) + { + throw new SignException(Util.i18n("tradeSignEmpty")); } } @@ -171,12 +186,12 @@ public class SignTrade extends EssentialsSign amount -= amount % stackamount; if (notEmpty && (amount < 1 || stackamount < 1 || item.getTypeId() == 0)) { - throw new SignException(Util.i18n("moreThanZero")); + throw new SignException(Util.i18n("tradeSignEmpty")); } item.setAmount(fullAmount ? amount : stackamount); return new Trade(item, ess); } - throw new SignException(Util.format("invalidSignLine", index+1)); + throw new SignException(Util.format("invalidSignLine", index + 1)); } protected final void substractAmount(final ISign sign, final int index, final Trade trade, final IEssentials ess) throws SignException @@ -235,6 +250,6 @@ public class SignTrade extends EssentialsSign sign.setLine(index, stackamount + " " + split[1] + ":" + (amount + Math.round(value))); return; } - throw new SignException(Util.format("invalidSignLine", index+1)); + throw new SignException(Util.format("invalidSignLine", index + 1)); } } diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 089d05670..964060099 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -291,7 +291,8 @@ timeSetPermission = \u00a7cYou are not authorized to set the time. timeWorldCurrent = The current time in {0} is \u00a73{1} timeWorldSet = The time was set to {0} in: \u00a7c{1} tradeCompleted = \u00a77Trade completed. -tradeSignEmpty = The trade sign does not have enough supply left. +tradeSignEmpty = The trade sign has nothing available for you. +tradeSignEmptyOwner = There is nothing to collect from this trade sign. treeFailure = \u00a7cTree generation failure. Try again on grass or dirt. treeSpawned = \u00a77Tree spawned. typeTpaccept = \u00a77To teleport, type \u00a7c/tpaccept\u00a77. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 41b34ab0e..a94a04a33 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -292,6 +292,7 @@ timeWorldCurrent = The current time in {0} is \u00a73{1} timeWorldSet = The time was set to {0} in: \u00a7c{1} tradeCompleted = \u00a77Forhandling fuldf\u00f8rt. tradeSignEmpty = Forhandlings skiltet har ikke nok forsyning tilbage. +tradeSignEmptyOwner = There is nothing to collect from this trade sign. treeFailure = \u00a7cTr\u00e6 genererings fejl. Pr\u00f8v igen p\u00e5 gr\u00e6s eller jord. treeSpawned = \u00a77Tr\u00e6 fremkaldt. typeTpaccept = \u00a77For at teleportere, skriv \u00a7c/tpaccept\u00a77. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index d85cd4350..1360bc3cc 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -292,6 +292,7 @@ timeWorldCurrent = The current time in {0} is \u00a73{1} timeWorldSet = The time was set to {0} in: \u00a7c{1} tradeCompleted = \u00a77Handel abgeschlossen. tradeSignEmpty = Der Bestand des Trade-Schild ist aufgebraucht. +tradeSignEmptyOwner = There is nothing to collect from this trade sign. treeFailure = \u00a7cBaumpflanzung gescheitert. Versuche es auf Gras oder Dreck. treeSpawned = \u00a77Baum gepflanzt. typeTpaccept = \u00a77Um zu teleportieren, schreibe \u00a7c/tpaccept\u00a77. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 4c1ad26d4..0673d41ed 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -292,6 +292,7 @@ timeWorldCurrent = The current time in {0} is \u00a73{1} timeWorldSet = The time was set to {0} in: \u00a7c{1} tradeCompleted = \u00a77Trade completed. tradeSignEmpty = The trade sign does not have enough supply left. +tradeSignEmptyOwner = There is nothing to collect from this trade sign. treeFailure = \u00a7cTree generation failure. Try again on grass or dirt. treeSpawned = \u00a77Tree spawned. typeTpaccept = \u00a77To teleport, type \u00a7c/tpaccept\u00a77. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 0849c78d6..ea5af2d44 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -292,6 +292,7 @@ timeWorldCurrent = The current time in {0} is \u00a73{1} timeWorldSet = The time was set to {0} in: \u00a7c{1} tradeCompleted = \u00a77\u00c9change termin\u00e9. tradeSignEmpty = Le panneau de vente n''as pas encore assez de stock. +tradeSignEmptyOwner = There is nothing to collect from this trade sign. treeFailure = \u00a7cEchec de la g\u00e9n\u00e9ration de l''arbre. Essayez de nouveau sur de l''herbe ou de la terre. treeSpawned = \u00a77Arbre cr\u00e9\u00e9. typeTpaccept = \u00a77Pour le t\u00e9l\u00e9porter, tapez \u00a7c/tpaccept\u00a77. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index a76084a55..3dbb00a74 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -292,6 +292,7 @@ timeWorldCurrent = The current time in {0} is \u00a73{1} timeWorldSet = The time was set to {0} in: \u00a7c{1} tradeCompleted = \u00a77Ruil verricht. tradeSignEmpty = Het handelsbordje heeft een te kleine voorraad. +tradeSignEmptyOwner = There is nothing to collect from this trade sign. treeFailure = \u00a7cFout bij het genereren van boom. Pobeer het opnieuw op gras of dirt. treeSpawned = \u00a77Boom gespawned. typeTpaccept = \u00a77Om te teleporten, type \u00a7c/tpaccept\u00a77. From 040e2bee86c65002a9f3c1bea67b14fbb2eb5b5f Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sun, 21 Aug 2011 17:08:32 +0100 Subject: [PATCH 10/10] Fixing trade sign messages Unifying tree/spawnmob code for block selection Adding TL notes --- .../essentials/commands/Commandbigtree.java | 29 ++++----------- .../essentials/commands/Commandgive.java | 1 + .../essentials/commands/Commandlist.java | 1 + .../essentials/commands/Commandspawnmob.java | 11 ++---- .../commands/Commandtogglejail.java | 1 + .../essentials/commands/Commandtree.java | 35 ++++++------------- .../essentials/signs/SignProtection.java | 1 + .../earth2me/essentials/signs/SignTrade.java | 2 +- 8 files changed, 23 insertions(+), 58 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java index f02b99b15..8370896b1 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.TargetBlock; import org.bukkit.Server; import org.bukkit.TreeType; import com.earth2me.essentials.User; @@ -31,30 +32,12 @@ public class Commandbigtree extends EssentialsCommand throw new NotEnoughArgumentsException(); } - double x = user.getLocation().getX(); - double y = user.getLocation().getY(); - double z = user.getLocation().getZ(); - - // offset tree in direction player is facing - final int r = (int)user.getCorrectedYaw(); - if (r < 68 || r > 292) // north + final int[] ignore = { - x -= 3.0D; - } - else if (r > 112 && r < 248) // south - { - x += 3.0D; - } - if (r > 22 && r < 158) // east - { - z -= 3.0D; - } - else if (r > 202 && r < 338) // west - { - z += 3.0D; - } - - final Location safeLocation = Util.getSafeDestination(new Location(user.getWorld(), x, y, z)); + 8, 9 + }; + final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation(); + final Location safeLocation = Util.getSafeDestination(loc); final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree); if (success) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java index 21eea2c70..68bfe8a30 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java @@ -16,6 +16,7 @@ public class Commandgive extends EssentialsCommand super("give"); } + //TODO: move these messages to message file @Override public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java index d5f946bf9..ef7d6e9f8 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java @@ -45,6 +45,7 @@ public class Commandlist extends EssentialsCommand } } charge(sender); + //TODO: move these to messages file StringBuilder online = new StringBuilder(); online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden); if (showhidden && playerHidden > 0) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index 188edab27..9514bc767 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -83,17 +83,10 @@ public class Commandspawnmob extends EssentialsCommand 8, 9 }; Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation(); - - Block block = user.getWorld().getBlockAt(loc); - while (!(block.getType() == Material.AIR || block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER)) - { - loc.setY(loc.getY() + 1); - block = user.getWorld().getBlockAt(loc); - } - + Location sloc = Util.getSafeDestination(loc); try { - spawnedMob = mob.spawn(user, server, loc); + spawnedMob = mob.spawn(user, server, sloc); } catch (MobException e) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java index c88cdc5a6..75abda4bb 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java @@ -15,6 +15,7 @@ public class Commandtogglejail extends EssentialsCommand super("togglejail"); } + //TODO: move these to messages file @Override public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java index 8e3b567b4..81be2a329 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java @@ -1,10 +1,13 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.TargetBlock; import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.TreeType; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Material; +import org.bukkit.block.Block; public class Commandtree extends EssentialsCommand @@ -38,32 +41,14 @@ public class Commandtree extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - - double x = user.getLocation().getX(); - double y = user.getLocation().getY(); - double z = user.getLocation().getZ(); - - // offset tree in direction player is facing - int r = (int)user.getCorrectedYaw(); - if (r < 68 || r > 292) // north + + final int[] ignore = { - x -= 3.0D; - } - else if (r > 112 && r < 248) // south - { - x += 3.0D; - } - if (r > 22 && r < 158) // east - { - z -= 3.0D; - } - else if (r > 202 && r < 338) // west - { - z += 3.0D; - } - - Location safeLocation = Util.getSafeDestination(new Location(user.getWorld(), x, y, z)); - boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree); + 8, 9 + }; + final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation(); + final Location safeLocation = Util.getSafeDestination(loc); + final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree); if (success) { charge(user); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index 99aa62434..c595d9b03 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -41,6 +41,7 @@ public class SignProtection extends EssentialsSign sign.setLine(3, "§1" + username); return true; } + //TODO: move to messages player.sendMessage("§4You are not allowed to create sign here."); return false; } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java index a1a066088..bf85d827c 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java @@ -21,7 +21,7 @@ public class SignTrade extends EssentialsSign { validateTrade(sign, 1, false, ess); validateTrade(sign, 2, true, ess); - final Trade charge = getTrade(sign, 2, true, false, ess); + final Trade charge = getTrade(sign, 2, true, true, ess); charge.isAffordableFor(player); sign.setLine(3, "§8" + username); charge.charge(player);