From d336b79cf293d7a3253b7ef273cbcf47774e25e5 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Thu, 16 Feb 2012 16:57:50 +0000 Subject: Fixing being charged twice for /back. --- Essentials/src/com/earth2me/essentials/commands/Commandback.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandback.java b/Essentials/src/com/earth2me/essentials/commands/Commandback.java index 67698598a..2ad39ceea 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandback.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandback.java @@ -20,5 +20,6 @@ public class Commandback extends EssentialsCommand charge.isAffordableFor(user); user.sendMessage(_("backUsageMsg")); user.getTeleport().back(charge); + throw new NoChargeException(); } } -- cgit v1.2.3 From bccd39a62385561d74a5de3613e42a8a8ed4c56f Mon Sep 17 00:00:00 2001 From: KHobbits Date: Thu, 16 Feb 2012 23:44:13 +0000 Subject: Don't try to use old bPerms API if it is not available. --- .../essentials/perm/PermissionsHandler.java | 32 ++++++++++++++-------- .../essentials/perm/SuperpermsHandler.java | 2 +- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java index aa786934e..70a9e582c 100644 --- a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.perm; +import com.earth2me.essentials.Util; import java.util.Collections; import java.util.List; import java.util.logging.Level; @@ -111,17 +112,6 @@ public class PermissionsHandler implements IPermissionsHandler return; } - final Plugin bPermPlugin = pluginManager.getPlugin("bPermissions"); - if (bPermPlugin != null && bPermPlugin.isEnabled()) - { - if (!(handler instanceof BPermissionsHandler)) - { - LOGGER.log(Level.INFO, "Essentials: Using bPermissions based permissions."); - handler = new BPermissionsHandler(); - } - return; - } - final Plugin GMplugin = pluginManager.getPlugin("GroupManager"); if (GMplugin != null && GMplugin.isEnabled()) { @@ -155,6 +145,26 @@ public class PermissionsHandler implements IPermissionsHandler return; } + final Plugin bPermPlugin = pluginManager.getPlugin("bPermissions"); + if (bPermPlugin != null && bPermPlugin.isEnabled()) + { + final String bVer = bPermPlugin.getDescription().getVersion().replace(".", ""); + if (Util.isInt(bVer) && Integer.parseInt(bVer) < 284) + { + if (!(handler instanceof BPermissionsHandler)) + { + LOGGER.log(Level.INFO, "Essentials: Using bPermissions based permissions."); + handler = new BPermissionsHandler(); + } + return; + } + if (!(handler instanceof SuperpermsHandler)) + { + LOGGER.log(Level.INFO, "Essentials: bPermissions api broken, switching to superperms based permissions."); + handler = new SuperpermsHandler(); + } + return; + } final Plugin permPlugin = pluginManager.getPlugin("Permissions"); if (permPlugin != null && permPlugin.isEnabled()) { diff --git a/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java b/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java index 70a118bcf..2e767cb72 100644 --- a/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java @@ -27,7 +27,7 @@ public class SuperpermsHandler implements IPermissionsHandler @Override public boolean inGroup(final Player base, final String group) { - return false; + return hasPermission(base, "group." + group); } @Override -- cgit v1.2.3 From d0c89f4e9f4df6756707031ba397c7e8185f9c42 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 18 Feb 2012 21:09:18 +0000 Subject: Adding full keyword support for newb join message. Also adding {ADDRESS} and {USERNAME} as new keywords. --- .../src/com/earth2me/essentials/ISettings.java | 19 ++++++------ .../src/com/earth2me/essentials/Settings.java | 32 +++++++++----------- .../essentials/textreader/KeywordReplacer.java | 8 ++++- .../essentials/textreader/SimpleTextInput.java | 35 ++++++++++++++++++++++ .../essentials/textreader/SimpleTextPager.java | 31 +++++++++++++++++++ Essentials/src/info.txt | 3 ++ .../spawn/EssentialsSpawnPlayerListener.java | 7 ++++- 7 files changed, 105 insertions(+), 30 deletions(-) create mode 100644 Essentials/src/com/earth2me/essentials/textreader/SimpleTextInput.java create mode 100644 Essentials/src/com/earth2me/essentials/textreader/SimpleTextPager.java diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 560eb6f79..c29cc5b1a 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -2,6 +2,7 @@ package com.earth2me.essentials; import com.earth2me.essentials.commands.IEssentialsCommand; import com.earth2me.essentials.signs.EssentialsSign; +import com.earth2me.essentials.textreader.IText; import java.text.MessageFormat; import java.util.List; import java.util.Map; @@ -14,9 +15,7 @@ public interface ISettings extends IConf { boolean areSignsDisabled(); - String format(String format, IUser user); - - String getAnnounceNewPlayerFormat(IUser user); + IText getAnnounceNewPlayerFormat(); boolean getAnnounceNewPlayers(); @@ -35,7 +34,7 @@ public interface ISettings extends IConf String getCurrencySymbol(); int getOversizedStackSize(); - + int getDefaultStackSize(); double getHealCooldown(); @@ -101,7 +100,7 @@ public interface ISettings extends IConf boolean isTradeInStacks(int id); List itemSpawnBlacklist(); - + List enabledSigns(); boolean permissionBasedItemSpawn(); @@ -143,18 +142,18 @@ public interface ISettings extends IConf public void setDebug(boolean debug); Set getNoGodWorlds(); - + boolean getUpdateBedAtDaytime(); - + boolean getRepairEnchanted(); - + boolean getIsWorldTeleportPermissions(); - + boolean registerBackInListener(); boolean getDisableItemPickupWhileAfk(); EventPriority getRespawnPriority(); - + long getTpaAcceptCancellation(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 6b81753b6..3307945f2 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -4,6 +4,10 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.commands.IEssentialsCommand; import com.earth2me.essentials.signs.EssentialsSign; import com.earth2me.essentials.signs.Signs; +import com.earth2me.essentials.textreader.IText; +import com.earth2me.essentials.textreader.KeywordReplacer; +import com.earth2me.essentials.textreader.SimpleTextInput; +import com.earth2me.essentials.textreader.SimpleTextPager; import java.io.File; import java.text.MessageFormat; import java.util.*; @@ -324,15 +328,9 @@ public class Settings implements ISettings } @Override - public String getAnnounceNewPlayerFormat(IUser user) + public IText getAnnounceNewPlayerFormat() { - return format(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!"), user); - } - - @Override - public String format(String format, IUser user) - { - return format.replace('&', '§').replace("§§", "&").replace("{PLAYER}", user.getDisplayName()).replace("{DISPLAYNAME}", user.getDisplayName()).replace("{GROUP}", user.getGroup()).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getAddress().toString()); + return new SimpleTextInput(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")); } @Override @@ -362,19 +360,19 @@ public class Settings implements ISettings itemSpawnBl = getItemSpawnBlacklist(); chatFormats.clear(); } - private List itemSpawnBl = new ArrayList(); - + @Override public List itemSpawnBlacklist() { return itemSpawnBl; } - + private List getItemSpawnBlacklist() { final List epItemSpwn = new ArrayList(); - if (ess.getItemDb() == null) { + if (ess.getItemDb() == null) + { logger.log(Level.FINE, "Aborting ItemSpawnBL read, itemDB not yet loaded."); return epItemSpwn; } @@ -384,7 +382,7 @@ public class Settings implements ISettings if (itemName.isEmpty()) { continue; - } + } try { final ItemStack iStack = ess.getItemDb().get(itemName); @@ -397,19 +395,18 @@ public class Settings implements ISettings } return epItemSpwn; } - private List enabledSigns = new ArrayList(); - + @Override public List enabledSigns() { return enabledSigns; } - + private List getEnabledSigns() { List newSigns = new ArrayList(); - + for (String signName : config.getStringList("enabledSigns", null)) { signName = signName.trim().toUpperCase(Locale.ENGLISH); @@ -604,7 +601,6 @@ public class Settings implements ISettings { return config.getBoolean("death-messages", true); } - private Set noGodWorlds = new HashSet(); @Override diff --git a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java index a7aab67ba..4c4e3364b 100644 --- a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java +++ b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java @@ -33,12 +33,14 @@ public class KeywordReplacer implements IText String displayName, ipAddress, balance, mails, world; String worlds, online, unique, playerlist, date, time; String worldTime12, worldTime24, worldDate, plugins; - String version; + String userName, address, version; if (sender instanceof Player) { final User user = ess.getUser(sender); displayName = user.getDisplayName(); + userName = user.getName(); ipAddress = user.getAddress().getAddress().toString(); + address = user.getAddress().toString(); balance = Double.toString(user.getMoney()); mails = Integer.toString(user.getMails().size()); world = user.getLocation().getWorld().getName(); @@ -107,8 +109,12 @@ public class KeywordReplacer implements IText for (int i = 0; i < input.getLines().size(); i++) { String line = input.getLines().get(i); + line = line.replace("{PLAYER}", displayName); + line = line.replace("{DISPLAYNAME}", displayName); + line = line.replace("{USERNAME}", displayName); line = line.replace("{IP}", ipAddress); + line = line.replace("{ADDRESS}", ipAddress); line = line.replace("{BALANCE}", balance); line = line.replace("{MAILS}", mails); line = line.replace("{WORLD}", world); diff --git a/Essentials/src/com/earth2me/essentials/textreader/SimpleTextInput.java b/Essentials/src/com/earth2me/essentials/textreader/SimpleTextInput.java new file mode 100644 index 000000000..a9f9e1480 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/textreader/SimpleTextInput.java @@ -0,0 +1,35 @@ +package com.earth2me.essentials.textreader; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + + +public class SimpleTextInput implements IText +{ + private final transient List lines = new ArrayList(); + + public SimpleTextInput (final String input) { + lines.add(input); + } + + @Override + public List getLines() + { + return lines; + } + + @Override + public List getChapters() + { + return Collections.emptyList(); + } + + @Override + public Map getBookmarks() + { + return Collections.emptyMap(); + } + +} diff --git a/Essentials/src/com/earth2me/essentials/textreader/SimpleTextPager.java b/Essentials/src/com/earth2me/essentials/textreader/SimpleTextPager.java new file mode 100644 index 000000000..ea1b787d5 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/textreader/SimpleTextPager.java @@ -0,0 +1,31 @@ +package com.earth2me.essentials.textreader; + +import org.bukkit.command.CommandSender; + + +public class SimpleTextPager +{ + private final transient IText text; + + public SimpleTextPager(final IText text) + { + this.text = text; + } + + public void showPage(final CommandSender sender) + { + for (String line : text.getLines()) + { + sender.sendMessage(line); + } + } + + public String getString(int line) + { + if (text.getLines().size() < line) + { + return null; + } + return text.getLines().get(line); + } +} diff --git a/Essentials/src/info.txt b/Essentials/src/info.txt index e05843dcb..694093bbf 100644 --- a/Essentials/src/info.txt +++ b/Essentials/src/info.txt @@ -25,7 +25,9 @@ Minecraft colors: #Tags PLAYER: {PLAYER} +USERNAME: {PLAYER} IP: {IP} +ADDRESS: {ADDRESS} BALANCE: {BALANCE} MAILS: {MAILS} WORLD: {WORLD} @@ -39,3 +41,4 @@ WORLDTIME12: {WORLDTIME12} WORLDTIME24: {WORLDTIME24} WORLDDATE: {WORLDDATE} PLUGINS: {PLUGINS} +VERSION: {VERSION} \ No newline at end of file diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java index b68b4e350..083fd66a5 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java @@ -4,6 +4,9 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.OfflinePlayer; import com.earth2me.essentials.User; +import com.earth2me.essentials.textreader.IText; +import com.earth2me.essentials.textreader.KeywordReplacer; +import com.earth2me.essentials.textreader.SimpleTextPager; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Bukkit; @@ -73,7 +76,9 @@ public class EssentialsSpawnPlayerListener implements Listener if (ess.getSettings().getAnnounceNewPlayers()) { - ess.broadcastMessage(user, ess.getSettings().getAnnounceNewPlayerFormat(user)); + final IText output = new KeywordReplacer(ess.getSettings().getAnnounceNewPlayerFormat(), user, ess); + final SimpleTextPager pager = new SimpleTextPager(output); + ess.broadcastMessage(user, pager.getString(0)); } LOGGER.log(Level.FINE, "New player join"); -- cgit v1.2.3 From 8de2b1520fa4778051339978941762c17a9d6dc9 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 18 Feb 2012 21:34:05 +0000 Subject: Re-allow colours in newb welcome messages. --- Essentials/src/com/earth2me/essentials/Settings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 3307945f2..592b80694 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -330,7 +330,7 @@ public class Settings implements ISettings @Override public IText getAnnounceNewPlayerFormat() { - return new SimpleTextInput(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")); + return new SimpleTextInput(Util.replaceColor(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!"))); } @Override -- cgit v1.2.3 From 984bd949fd98d18bd0af3943964f0de83f61c8d6 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 18 Feb 2012 22:08:18 +0000 Subject: Little bit of extra info in the default /einfo file --- Essentials/src/info.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Essentials/src/info.txt b/Essentials/src/info.txt index 694093bbf..efc629923 100644 --- a/Essentials/src/info.txt +++ b/Essentials/src/info.txt @@ -7,6 +7,10 @@ Name it info_username.txt or info_groupname.txt This also works with motd and rules. +Extra pages: +Type /info Colours +Type /info Tags + It can contain chapters like the Chapter1 below: #Chapter1 -- cgit v1.2.3 From 2b4b2034ae39c6c4cc0eca09552394fc3627e49a Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 18 Feb 2012 22:47:38 +0000 Subject: Add bPerm2 support for chat prefixes. --- Essentials/nbproject/project.properties | 4 +- .../essentials/perm/BPermissions2Handler.java | 62 ++++++++++++++++++++++ .../essentials/perm/PermissionsHandler.java | 7 +-- 3 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 Essentials/src/com/earth2me/essentials/perm/BPermissions2Handler.java diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties index 71fea5cf9..7a5ffe7bb 100644 --- a/Essentials/nbproject/project.properties +++ b/Essentials/nbproject/project.properties @@ -66,6 +66,7 @@ endorsed.classpath= excludes= file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar file.reference.bPermissions.jar=../lib/bPermissions.jar +file.reference.bpermissions2.jar=../lib/bpermissions2.jar file.reference.bukkit.jar=../lib/bukkit.jar file.reference.craftbukkit.jar=../lib/craftbukkit.jar file.reference.iCo4.jar=../lib/iCo4.jar @@ -97,7 +98,8 @@ javac.classpath=\ ${file.reference.bukkit.jar}:\ ${file.reference.craftbukkit.jar}:\ ${file.reference.Vault.jar}:\ - ${file.reference.Privileges.jar} + ${file.reference.Privileges.jar}:\ + ${file.reference.bpermissions2.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false diff --git a/Essentials/src/com/earth2me/essentials/perm/BPermissions2Handler.java b/Essentials/src/com/earth2me/essentials/perm/BPermissions2Handler.java new file mode 100644 index 000000000..f4122bf53 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/perm/BPermissions2Handler.java @@ -0,0 +1,62 @@ +package com.earth2me.essentials.perm; + +import de.bananaco.bpermissions.api.ApiLayer; +import de.bananaco.bpermissions.api.World; +import de.bananaco.bpermissions.api.WorldManager; +import de.bananaco.bpermissions.api.util.Calculable; +import de.bananaco.bpermissions.api.util.CalculableType; +import java.util.Arrays; +import java.util.List; +import org.bukkit.entity.Player; + + +public class BPermissions2Handler extends SuperpermsHandler +{ + public BPermissions2Handler() + { + + } + + @Override + public String getGroup(final Player base) + { + final List groups = getGroups(base); + if (groups == null || groups.isEmpty()) + { + return null; + } + return groups.get(0); + } + + @Override + public List getGroups(final Player base) + { + final String[] groups = ApiLayer.getGroups(base.getWorld().getName(), CalculableType.USER, base.getName()); + return Arrays.asList(groups); + } + + @Override + public boolean inGroup(final Player base, final String group) + { + return ApiLayer.hasGroup(base.getWorld().getName(), CalculableType.USER, base.getName(), group); + } + + @Override + public boolean canBuild(final Player base, final String group) + { + return hasPermission(base, "essentials.build") || hasPermission(base, "bPermissions.build"); + } + + @Override + public String getPrefix(final Player base) + { + return ApiLayer.getValue(base.getWorld().getName(), CalculableType.USER, base.getName(), "prefix"); + } + + @Override + public String getSuffix(final Player base) + { + return ApiLayer.getValue(base.getWorld().getName(), CalculableType.USER, base.getName(), "suffix"); + } + +} diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java index 70a9e582c..a344968c2 100644 --- a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java @@ -158,12 +158,13 @@ public class PermissionsHandler implements IPermissionsHandler } return; } - if (!(handler instanceof SuperpermsHandler)) + if (!(handler instanceof BPermissions2Handler)) { - LOGGER.log(Level.INFO, "Essentials: bPermissions api broken, switching to superperms based permissions."); - handler = new SuperpermsHandler(); + LOGGER.log(Level.INFO, "Essentials: Using bPermissions2 based permissions."); + handler = new BPermissions2Handler(); } return; + } final Plugin permPlugin = pluginManager.getPlugin("Permissions"); if (permPlugin != null && permPlugin.isEnabled()) -- cgit v1.2.3