From 498a7f59a2915a37e94c2f45229944e9d01d0637 Mon Sep 17 00:00:00 2001 From: Khyperia Date: Wed, 30 Nov 2011 21:02:57 -0500 Subject: Added {DATE} and {TIME} to motd --- .../src/com/earth2me/essentials/textreader/KeywordReplacer.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java index 29e44a682..84cd63f68 100644 --- a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java +++ b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java @@ -2,6 +2,8 @@ package com.earth2me.essentials.textreader; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; import java.util.Map; import org.bukkit.World; @@ -24,7 +26,7 @@ public class KeywordReplacer implements IText private void replaceKeywords(final CommandSender sender) { String displayName, ipAddress, balance, mails, world; - String worlds, online, unique, playerlist; + String worlds, online, unique, playerlist, date, time; if (sender instanceof Player) { final User user = ess.getUser(sender); @@ -75,6 +77,9 @@ public class KeywordReplacer implements IText playerlistBuilder.append(p.getDisplayName()); } playerlist = playerlistBuilder.toString(); + + date = new SimpleDateFormat("MMMM/dd/yyyy").format(new Date()); + time = new SimpleDateFormat("hh:mm:ss").format(new Date()); for (int i = 0; i < input.getLines().size(); i++) { @@ -88,6 +93,8 @@ public class KeywordReplacer implements IText line = line.replace("{UNIQUE}", unique); line = line.replace("{WORLDS}", worlds); line = line.replace("{PLAYERLIST}", playerlist); + line = line.replace("{TIME}", time); + line = line.replace("{DATE}", date); input.getLines().set(i, line); } } -- cgit v1.2.3 From a5a230749ff6484a39aad64ee2eb5e1db802db88 Mon Sep 17 00:00:00 2001 From: Khyperia Date: Thu, 1 Dec 2011 19:37:12 -0500 Subject: Added many new MOTD possibilities + getI18n() to Essentials.java --- .../src/com/earth2me/essentials/Essentials.java | 6 +++++ .../src/com/earth2me/essentials/IEssentials.java | 2 ++ .../essentials/textreader/KeywordReplacer.java | 31 ++++++++++++++++++---- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 80fbd7265..dc2f46259 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -597,4 +597,10 @@ public class Essentials extends JavaPlugin implements IEssentials { return userMap; } + + @Override + public I18n getI18n() + { + return i18n; + } } diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java index ef54b0776..a56fc790c 100644 --- a/Essentials/src/com/earth2me/essentials/IEssentials.java +++ b/Essentials/src/com/earth2me/essentials/IEssentials.java @@ -18,6 +18,8 @@ public interface IEssentials extends Plugin boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix); User getUser(Object base); + + I18n getI18n(); User getOfflineUser(String name); diff --git a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java index 84cd63f68..79710a822 100644 --- a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java +++ b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java @@ -1,14 +1,16 @@ package com.earth2me.essentials.textreader; +import com.earth2me.essentials.DescParseTickFormat; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; -import java.text.SimpleDateFormat; +import java.text.DateFormat; import java.util.Date; import java.util.List; import java.util.Map; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; public class KeywordReplacer implements IText @@ -27,6 +29,7 @@ public class KeywordReplacer implements IText { String displayName, ipAddress, balance, mails, world; String worlds, online, unique, playerlist, date, time; + String worldTime12, worldTime24, worldDate, plugins; if (sender instanceof Player) { final User user = ess.getUser(sender); @@ -35,10 +38,13 @@ public class KeywordReplacer implements IText balance = Double.toString(user.getMoney()); mails = Integer.toString(user.getMails().size()); world = user.getLocation().getWorld().getName(); + worldTime12 = DescParseTickFormat.format12(user.getWorld().getTime()); + worldTime24 = DescParseTickFormat.format24(user.getWorld().getTime()); + worldDate = DateFormat.getDateInstance(DateFormat.MEDIUM, ess.getI18n().getCurrentLocale()).format(DescParseTickFormat.ticksToDate(user.getWorld().getTime())); } else { - displayName = ipAddress = balance = mails = world = ""; + displayName = ipAddress = balance = mails = world = worldTime12 = worldTime24= worldDate = ""; } int playerHidden = 0; @@ -77,9 +83,20 @@ public class KeywordReplacer implements IText playerlistBuilder.append(p.getDisplayName()); } playerlist = playerlistBuilder.toString(); - - date = new SimpleDateFormat("MMMM/dd/yyyy").format(new Date()); - time = new SimpleDateFormat("hh:mm:ss").format(new Date()); + + final StringBuilder pluginlistBuilder = new StringBuilder(); + for (Plugin p : ess.getServer().getPluginManager().getPlugins()) + { + if (pluginlistBuilder.length() > 0) + { + pluginlistBuilder.append(", "); + } + pluginlistBuilder.append(p.getDescription().getName()); + } + plugins = pluginlistBuilder.toString(); + + date = DateFormat.getDateInstance(DateFormat.MEDIUM, ess.getI18n().getCurrentLocale()).format(new Date()); + time = DateFormat.getTimeInstance(DateFormat.MEDIUM, ess.getI18n().getCurrentLocale()).format(new Date()); for (int i = 0; i < input.getLines().size(); i++) { @@ -95,6 +112,10 @@ public class KeywordReplacer implements IText line = line.replace("{PLAYERLIST}", playerlist); line = line.replace("{TIME}", time); line = line.replace("{DATE}", date); + line = line.replace("{WORLDTIME12}", worldTime12); + line = line.replace("{WORLDTIME24}", worldTime24); + line = line.replace("{WORLDDATE}", worldDate); + line = line.replace("{PLUGINS}", plugins); input.getLines().set(i, line); } } -- cgit v1.2.3 From dd017870be5ea7cd3d4fa7e636407d79bb6147d1 Mon Sep 17 00:00:00 2001 From: Khyperia Date: Fri, 2 Dec 2011 20:55:43 -0500 Subject: Fixed accedental typo --- Essentials/src/com/earth2me/essentials/commands/Commandremove.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java index 938e8adeb..3839ee81d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java @@ -83,7 +83,7 @@ public class Commandremove extends EssentialsCommand continue; } } - else if (toRemove == ToRemove.DROPS) + if (toRemove == ToRemove.DROPS) { if (e instanceof Item) { -- cgit v1.2.3 From 3007e9346b9633563b1c45f7d26e06027f2ce512 Mon Sep 17 00:00:00 2001 From: Khyperia Date: Sat, 3 Dec 2011 12:13:42 -0500 Subject: Added per-world permissions for /world --- .../src/com/earth2me/essentials/ISettings.java | 2 ++ .../src/com/earth2me/essentials/Settings.java | 21 ++++++++++++++------- .../earth2me/essentials/commands/Commandworld.java | 9 +++++++++ Essentials/src/config.yml | 4 ++++ 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index d7764ed16..41e99c29c 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -140,4 +140,6 @@ public interface ISettings extends IConf boolean getUpdateBedAtDaytime(); boolean getRepairEnchanted(); + + boolean getIsWorldTeleportPermissions(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index b65d53616..1683fd7ef 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -29,7 +29,7 @@ public class Settings implements ISettings { return config.getBoolean("respawn-at-home", false); } - + @Override public boolean getUpdateBedAtDaytime() { @@ -332,7 +332,7 @@ public class Settings implements ISettings public void reloadConfig() { config.load(); - noGodWorlds = new HashSet(config.getStringList("no-god-in-worlds",Collections.emptyList())); + noGodWorlds = new HashSet(config.getStringList("no-god-in-worlds", Collections.emptyList())); } @Override @@ -535,13 +535,12 @@ public class Settings implements ISettings { return config.getBoolean("death-messages", true); } - - Set noGodWorlds = new HashSet(); + Set noGodWorlds = new HashSet(); + @Override public Set getNoGodWorlds() { return noGodWorlds; - } @Override @@ -549,8 +548,16 @@ public class Settings implements ISettings { this.debug = debug; } - - public boolean getRepairEnchanted() { + + @Override + public boolean getRepairEnchanted() + { return config.getBoolean("repair-enchanted", true); } + + @Override + public boolean getIsWorldTeleportPermissions() + { + return config.getBoolean("world-teleport-permissions", false); + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java index 7380b23ae..b62276cf8 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java @@ -53,6 +53,15 @@ public class Commandworld extends EssentialsCommand } } + if (ess.getSettings().getIsWorldTeleportPermissions()) + { + if (!user.isAuthorized("essentials.world." + world.getName())) + { + user.sendMessage(_("invalidWorld")); //TODO: Make a "world teleport denied" translation + throw new NoChargeException(); + } + } + double factor; if (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL) { diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 2f43cde1e..2bb8dbd0c 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -220,6 +220,10 @@ death-messages: true no-god-in-worlds: # - world_nether +# Set to true to enable per-world permissions for teleporting with /world +# Give someone permission to teleport to a world with essentials.world. +world-teleport-permissions: false + # Oversized stacks are stacks that ignore the normal max stacksize. # They can be obtained using /give and /item, if the player has essentials.oversizedstacks permission. # How many items should be in a oversized stack? -- cgit v1.2.3