1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-10 16:48:05 +02:00

Merge branch 'refs/heads/master' into 3.0

Conflicts:
	.gitignore
	Essentials/src/com/earth2me/essentials/Essentials.java
	Essentials/src/com/earth2me/essentials/EssentialsTimer.java
	Essentials/src/com/earth2me/essentials/ISettings.java
	Essentials/src/com/earth2me/essentials/Jails.java
	Essentials/src/com/earth2me/essentials/OfflinePlayer.java
	Essentials/src/com/earth2me/essentials/Settings.java
	Essentials/src/com/earth2me/essentials/User.java
	Essentials/src/com/earth2me/essentials/UserData.java
	Essentials/src/com/earth2me/essentials/UserMap.java
	Essentials/src/com/earth2me/essentials/Util.java
	Essentials/src/com/earth2me/essentials/commands/Commandnear.java
	Essentials/src/com/earth2me/essentials/commands/Commandping.java
	Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
	Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
	Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java
	Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
	Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
	Essentials/src/messages_en.properties
	Essentials2Compat/src/com/earth2me/essentials/EssentialsConf.java
	Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java
	EssentialsChat/src/plugin.yml
	EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
	EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
	EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
This commit is contained in:
snowleo
2012-02-21 18:34:53 +01:00
79 changed files with 1236 additions and 661 deletions

4
.gitignore vendored
View File

@@ -41,4 +41,6 @@
/EssentialsSigns/nbproject/private/
/Essentials2Compat/nbproject/private/
/Essentials2Compat/dist/
/Essentials2Compat/build/
/Essentials2Compat/build/
/EssentialsGroupManager/bin
/EssentialsGroupManager/.externalToolBuilders

View File

@@ -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
@@ -76,6 +77,7 @@ file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
file.reference.Permissions3.jar=../lib/Permissions3.jar
file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
file.reference.Privileges.jar=..\\lib\\Privileges.jar
file.reference.Vault.jar=../lib/Vault.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
@@ -95,7 +97,9 @@ javac.classpath=\
${reference.EssentialsGroupManager.jar}:\
${file.reference.bukkit.jar}:\
${file.reference.craftbukkit.jar}:\
${file.reference.Vault.jar}
${file.reference.Vault.jar}:\
${file.reference.Privileges.jar}:\
${file.reference.bpermissions2.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false

View File

@@ -27,15 +27,20 @@ import com.earth2me.essentials.user.UserMap;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -52,7 +57,7 @@ import org.yaml.snakeyaml.error.YAMLException;
public class Essentials extends JavaPlugin implements IEssentials
{
public static final int BUKKIT_VERSION = 1818;
public static final int BUKKIT_VERSION = 1952;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);

View File

@@ -10,6 +10,7 @@ import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
@@ -73,8 +74,31 @@ public class EssentialsCommandHandler implements ICommandHandler
final PluginCommand pc = getAlternative(commandLabel);
if (pc != null)
{
executed(commandLabel, pc.getLabel());
return pc.execute(sender, commandLabel, args);
try
{
return pc.execute(sender, commandLabel, args);
}
catch (final Exception ex)
{
final ArrayList<StackTraceElement> elements = new ArrayList<StackTraceElement>(Arrays.asList(ex.getStackTrace()));
elements.remove(0);
final ArrayList<StackTraceElement> toRemove = new ArrayList<StackTraceElement>();
for (final StackTraceElement e : elements)
{
if (e.getClassName().equals("com.earth2me.essentials.Essentials"))
{
toRemove.add(e);
}
}
elements.removeAll(toRemove);
final StackTraceElement[] trace = elements.toArray(new StackTraceElement[elements.size()]);
ex.setStackTrace(trace);
ex.printStackTrace();
sender.sendMessage(ChatColor.RED + "An internal error occurred while attempting to perform this command");
return true;
}
}
}

View File

@@ -10,6 +10,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import org.bukkit.entity.Player;
@@ -29,27 +30,38 @@ public class EssentialsTimer implements Runnable
final long currentTime = System.currentTimeMillis();
for (Player player : ess.getServer().getOnlinePlayers())
{
final IUser user = ess.getUser(player);
onlineUsers.add(user);
user.setLastOnlineActivity(currentTime);
user.checkActivity();
boolean mailDisabled = false;
ISettings settings = ess.getSettings();
settings.acquireReadLock();
try {
mailDisabled = settings.getData().getCommands().isDisabled("mail");
} finally {
settings.unlock();
}
// New mail notification
if (user != null && !mailDisabled && Permissions.MAIL.isAuthorized(user) && !user.gotMailInfo())
try
{
final List<String> mail = user.getMails();
if (mail != null && !mail.isEmpty())
final IUser user = ess.getUser(player);
onlineUsers.add(user);
user.setLastOnlineActivity(currentTime);
user.checkActivity();
boolean mailDisabled = false;
ISettings settings = ess.getSettings();
settings.acquireReadLock();
try
{
user.sendMessage(_("youHaveNewMail", mail.size()));
mailDisabled = settings.getData().getCommands().isDisabled("mail");
}
finally
{
settings.unlock();
}
// New mail notification
if (user != null && !mailDisabled && Permissions.MAIL.isAuthorized(user) && !user.gotMailInfo())
{
final List<String> mail = user.getMails();
if (mail != null && !mail.isEmpty())
{
user.sendMessage(_("youHaveNewMail", mail.size()));
}
}
}
catch (Exception e)
{
ess.getLogger().log(Level.WARNING, "EssentialsTimer Error:", e);
}
}

View File

@@ -12,13 +12,16 @@ import java.util.logging.Logger;
import lombok.Cleanup;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.plugin.PluginManager;
@@ -39,13 +42,8 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
final PluginManager pluginManager = ess.getServer().getPluginManager();
final JailBlockListener blockListener = new JailBlockListener();
final JailPlayerListener playerListener = new JailPlayerListener();
pluginManager.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Low, ess);
pluginManager.registerEvent(Type.BLOCK_DAMAGE, blockListener, Priority.Low, ess);
pluginManager.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Low, ess);
pluginManager.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, ess);
pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, Priority.Highest, ess);
pluginManager.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.Highest, ess);
pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Highest, ess);
pluginManager.registerEvents(blockListener, ess);
pluginManager.registerEvents(playerListener, ess);
}
@Override
@@ -160,9 +158,9 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
private class JailBlockListener extends BlockListener
private class JailBlockListener implements Listener
{
@Override
@EventHandler(priority = EventPriority.LOW)
public void onBlockBreak(final BlockBreakEvent event)
{
@Cleanup
@@ -174,7 +172,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@Override
@EventHandler(priority = EventPriority.LOW)
public void onBlockPlace(final BlockPlaceEvent event)
{
@Cleanup
@@ -186,7 +184,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@Override
@EventHandler(priority = EventPriority.LOW)
public void onBlockDamage(final BlockDamageEvent event)
{
@Cleanup
@@ -200,9 +198,9 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
private class JailPlayerListener extends PlayerListener
private class JailPlayerListener implements Listener
{
@Override
@EventHandler(priority = EventPriority.LOW)
public void onPlayerInteract(final PlayerInteractEvent event)
{
@Cleanup
@@ -214,7 +212,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerRespawn(final PlayerRespawnEvent event)
{
@Cleanup
@@ -231,11 +229,18 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
catch (Exception ex)
{
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
}
else
{
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
}
}
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(final PlayerTeleportEvent event)
{
@Cleanup
@@ -252,12 +257,19 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
catch (Exception ex)
{
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
}
else
{
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
}
}
user.sendMessage(_("jailMessage"));
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerJoin(final PlayerJoinEvent event)
{
@Cleanup
@@ -274,7 +286,14 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
catch (Exception ex)
{
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
}
else
{
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
}
}
user.sendMessage(_("jailMessage"));
}

View File

@@ -19,6 +19,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import lombok.Cleanup;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
@@ -113,9 +114,25 @@ public class Trade
if (dropItems)
{
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
final Location loc = user.getLocation();
for (ItemStack itemStack : leftOver.values())
{
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
final int maxStackSize = itemStack.getType().getMaxStackSize();
final int stacks = itemStack.getAmount() / maxStackSize;
final int leftover = itemStack.getAmount() % maxStackSize;
final Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
for (int i = 0; i < stacks; i++)
{
final ItemStack stack = itemStack.clone();
stack.setAmount(maxStackSize);
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
}
if (leftover > 0)
{
final ItemStack stack = itemStack.clone();
stack.setAmount(leftover);
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
}
}
}
else

View File

@@ -30,9 +30,8 @@ public final class Util
private Util()
{
}
private final static Logger logger = Logger.getLogger("Minecraft");
private static Pattern unsafeChars = Pattern.compile("[^a-z0-9]");
private static Pattern unsafeFileChars = Pattern.compile("[\u0000-\u001f]+");
private final static Pattern INVALIDFILECHARS = Pattern.compile("[^\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
public static String sanitizeFileName(String name) throws InvalidNameException
{
@@ -50,7 +49,7 @@ public final class Util
r = r.replace('*', (char)('\ue200' + '*'));
r = r.replace(':', (char)('\ue200' + ':'));
r = r.replace('-', (char)('\ue200' + '-'));
r = unsafeFileChars.matcher(r).replaceAll("");
r = INVALIDFILECHARS.matcher(r).replaceAll("");
return Punycode.encode(r);
}
catch (PunycodeException ex)
@@ -85,7 +84,12 @@ public final class Util
public static String sanitizeKey(String name)
{
return unsafeChars.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
return INVALIDCHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
}
public static String sanitizeString(final String string)
{
return INVALIDCHARS.matcher(string).replaceAll("");
}
public static String formatDateDiff(long date)

View File

@@ -14,5 +14,6 @@ public class Commandback extends EssentialsCommand
charge.isAffordableFor(user);
user.sendMessage(_("backUsageMsg"));
user.getTeleport().back(charge);
throw new NoChargeException();
}
}

View File

@@ -43,7 +43,7 @@ public class Commandhome extends EssentialsCommand
if ("bed".equalsIgnoreCase(homeName))
{
final Location bed = player.getBedSpawnLocation();
if (bed != null)
if (bed != null && bed.getBlock().getType() == Material.BED_BLOCK)
{
user.getTeleport().teleport(bed, charge, TeleportCause.COMMAND);
throw new NoChargeException();

View File

@@ -25,6 +25,7 @@ public class Commandkill extends EssentialsCommand
continue;
}
matchPlayer.damage(1000);
matchPlayer.setHealth(0);
sender.sendMessage(_("kill", matchPlayer.getDisplayName()));
}

View File

@@ -53,7 +53,8 @@ public class Commandmail extends EssentialsCommand
}
if (!u.isIgnoringPlayer(user.getName()))
{
u.addMail(user.getName() + ": " + Util.stripColor(getFinalArg(args, 2)));
final String mail = Util.sanitizeString(Util.stripColor(getFinalArg(args, 2)));
u.addMail(user.getName() + ": " + mail);
}
user.sendMessage(_("mailSent"));
return;

View File

@@ -15,6 +15,7 @@ public class Commandnear extends EssentialsCommand
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
long radius = 200;
IUser otherUser = null;
if (args.length > 0)
@@ -33,15 +34,15 @@ public class Commandnear extends EssentialsCommand
{
}
}
}
if (args.length > 1 && otherUser != null)
{
try
{
radius = Long.parseLong(args[1]);
}
catch (NumberFormatException e)
if (args.length > 1 && otherUser != null)
{
try
{
radius = Long.parseLong(args[1]);
}
catch (NumberFormatException e)
{
}
}
}
if (otherUser == null || Permissions.NEAR_OTHERS.isAuthorized(user))
@@ -57,16 +58,11 @@ public class Commandnear extends EssentialsCommand
@Override
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
IUser otherUser = null;
if (args.length > 0)
{
otherUser = getPlayer(args, 0);
}
else
if (args.length == 0)
{
throw new NotEnoughArgumentsException();
}
final IUser otherUser = getPlayer(args, 0);
long radius = 200;
if (args.length > 1)
{

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.api.IUser;
@@ -9,6 +10,13 @@ public class Commandping extends EssentialsCommand
@Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
user.sendMessage(_("pong"));
if (args.length < 1)
{
user.sendMessage(_("pong"));
}
else
{
user.sendMessage(Util.replaceColor(getFinalArg(args, 0)));
}
}
}

View File

@@ -48,7 +48,7 @@ public class Commandr extends EssentialsCommand
final CommandSender target = replyTo.getReplyTo();
final String targetName = target instanceof Player ? ((Player)target).getDisplayName() : Console.NAME;
if (target == null)
if (target == null || ((target instanceof Player) && !((Player)target).isOnline()))
{
throw new Exception(_("foreverAlone"));
}

View File

@@ -77,7 +77,7 @@ public class Commandrepair extends EssentialsCommand
private void repairItem(final ItemStack item) throws Exception
{
final Material material = Material.getMaterial(item.getTypeId());
if (material.isBlock() || material.getMaxDurability() < 0)
if (material.isBlock() || material.getMaxDurability() < 1)
{
throw new Exception(_("repairInvalidType"));
}

View File

@@ -2,9 +2,11 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.perm.SpawnerPermissions;
import java.util.Locale;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.CreatureSpawner;
@@ -41,7 +43,10 @@ public class Commandspawner extends EssentialsCommand
{
throw new Exception(_("unableToSpawnMob"));
}
final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
charge.isAffordableFor(user);
((CreatureSpawner)target.getBlock().getState()).setCreatureType(mob.getType());
charge.charge(user);
user.sendMessage(_("setSpawner", mob.name));
}
catch (Throwable ex)

View File

@@ -9,6 +9,7 @@ import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.perm.SpawnmobPermissions;
import java.util.Locale;
import java.util.Random;
import java.util.Set;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.block.Block;
@@ -22,7 +23,19 @@ public class Commandspawnmob extends EssentialsCommand
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(Mob.getMobList())));
Set<String> availableList = Mob.getMobList();
for (String mob : availableList)
{
if (!SpawnmobPermissions.getPermission(mob).isAuthorized(user))
{
availableList.remove(mob);
}
}
if (availableList.isEmpty())
{
availableList.add(_("none"));
}
throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(availableList)));
}

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.perm.Permissions;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
@@ -24,7 +25,13 @@ public class Commandsudo extends EssentialsCommand
}
//TODO: Translate this.
sender.sendMessage("Running the command as " + user.getDisplayName());
if (Permissions.SUDO_EXEMPT.isAuthorized(user))
{
throw new Exception("You cannot sudo this user");
}
//TODO: Translate this.
sender.sendMessage("Forcing " + user.getDisplayName() + " to run: /" + command + " " + arguments);
final PluginCommand execCommand = ess.getServer().getPluginCommand(command);
if (execCommand != null)

View File

@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IUser;
import org.bukkit.event.entity.EntityDamageEvent;
public class Commandsuicide extends EssentialsCommand
@@ -9,9 +10,11 @@ public class Commandsuicide extends EssentialsCommand
@Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
EntityDamageEvent ede = new EntityDamageEvent(user.getBase(), EntityDamageEvent.DamageCause.SUICIDE, 1000);
server.getPluginManager().callEvent(ede);
user.damage(1000);
user.setHealth(0);
user.sendMessage(_("suicideMessage"));
ess.broadcastMessage(user,
_("suicideSuccess", user.getDisplayName()));
ess.broadcastMessage(user,_("suicideSuccess", user.getDisplayName()));
}
}

View File

@@ -20,8 +20,15 @@ public class Commandtpaccept extends EssentialsCommand
}
final IUser target = user.getTeleportRequester();
if (target.getBase() instanceof OfflinePlayer
|| (user.isTeleportRequestHere() && !Permissions.TPAHERE.isAuthorized(target)))
if (target == null
|| target.getBase() instanceof OfflinePlayer
|| (user.isTeleportRequestHere() && !Permissions.TPAHERE.isAuthorized(target))
|| (!user.isTeleportRequestHere() && !Permissions.TPA.isAuthorized(target) && !Permissions.TPAALL.isAuthorized(target)))
{
throw new Exception(_("noPendingRequest"));
}
if (args.length > 0 && !target.getName().contains(args[0]))
{
throw new Exception(_("noPendingRequest"));
}

View File

@@ -10,6 +10,7 @@ import com.earth2me.essentials.perm.WarpPermissions;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import org.bukkit.command.CommandSender;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -61,7 +62,7 @@ public class Commandwarp extends EssentialsCommand
{
throw new Exception(_("playerNotFound"));
}
warpUser(otherUser, args[0]);
otherUser.getTeleport().warp(args[0], null, TeleportCause.COMMAND);
throw new NoChargeException();
}
@@ -110,9 +111,8 @@ public class Commandwarp extends EssentialsCommand
private void warpUser(final IUser user, final String name) throws Exception
{
final Trade charge = new Trade(commandName, ess);
final Trade charge = new Trade("warp-" + name.toLowerCase(Locale.ENGLISH).replace('_', '-'), ess);
charge.isAffordableFor(user);
if (WarpPermissions.getPermission(name).isAuthorized(user))
{
user.getTeleport().warp(name, charge, TeleportCause.COMMAND);

View File

@@ -231,12 +231,6 @@ public class FakeWorld implements World
return name;
}
@Override
public long getId()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Location getSpawnLocation()
{
@@ -548,4 +542,46 @@ public class FakeWorld implements World
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean canGenerateStructures()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public long getTicksPerAnimalSpawns()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setTicksPerAnimalSpawns(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public long getTicksPerMonsterSpawns()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setTicksPerMonsterSpawns(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T extends Entity> Collection<T> getEntitiesByClass(Class<T> type)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Collection<Entity> getEntitiesByClasses(Class<?>... types)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -2,15 +2,11 @@ package com.earth2me.essentials.craftbukkit;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
/*
* This class can be removed when
* https://github.com/Bukkit/CraftBukkit/pull/193
* is accepted to CraftBukkit
* This class can be removed when https://github.com/Bukkit/CraftBukkit/pull/193 is accepted to CraftBukkit
*/
public final class InventoryWorkaround
@@ -46,7 +42,7 @@ public final class InventoryWorkaround
{
return firstPartial(cinventory, item, forceDurability, item.getType().getMaxStackSize());
}
public static int firstPartial(final Inventory cinventory, final ItemStack item, final boolean forceDurability, final int maxAmount)
{
if (item == null)
@@ -92,10 +88,9 @@ public final class InventoryWorkaround
{
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
/* TODO: some optimization
* - Create a 'firstPartial' with a 'fromIndex'
* - Record the lastPartial per Material
* - Cache firstEmpty result
/*
* TODO: some optimization - Create a 'firstPartial' with a 'fromIndex' - Record the lastPartial per Material -
* Cache firstEmpty result
*/
// combine items
@@ -174,7 +169,7 @@ public final class InventoryWorkaround
final int amount = item.getAmount();
final int partialAmount = partialItem.getAmount();
// Check if it fully fits
if (amount + partialAmount <= maxAmount)
{
@@ -324,25 +319,4 @@ public final class InventoryWorkaround
}
return leftover.isEmpty();
}
public static Item[] dropItem(final Location loc, final ItemStack itm)
{
final int maxStackSize = itm.getType().getMaxStackSize();
final int stacks = itm.getAmount() / maxStackSize;
final int leftover = itm.getAmount() % maxStackSize;
final Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
for (int i = 0; i < stacks; i++)
{
final ItemStack stack = itm.clone();
stack.setAmount(maxStackSize);
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
}
if (leftover > 0)
{
final ItemStack stack = itm.clone();
stack.setAmount(leftover);
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
}
return itemStacks;
}
}

View File

@@ -11,22 +11,24 @@ import org.bukkit.Material;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.*;
import org.bukkit.inventory.ItemStack;
public class EssentialsEntityListener extends EntityListener
public class EssentialsEntityListener implements Listener
{
private final transient IEssentials ess;
public EssentialsEntityListener(final IEssentials ess)
{
super();
this.ess = ess;
}
@Override
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(final EntityDamageEvent event)
{
if (event instanceof EntityDamageByEntityEvent)
@@ -80,7 +82,7 @@ public class EssentialsEntityListener extends EntityListener
}
}
@Override
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityCombust(final EntityCombustEvent event)
{
if (event.getEntity() instanceof Player && ess.getUser((Player)event.getEntity()).isGodModeEnabled())
@@ -89,7 +91,7 @@ public class EssentialsEntityListener extends EntityListener
}
}
@Override
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDeath(final EntityDeathEvent event)
{
if (event instanceof PlayerDeathEvent)
@@ -111,7 +113,7 @@ public class EssentialsEntityListener extends EntityListener
}
}
@Override
@EventHandler(priority = EventPriority.LOWEST)
public void onFoodLevelChange(final FoodLevelChangeEvent event)
{
if (event.getEntity() instanceof Player && ess.getUser((Player)event.getEntity()).isGodModeEnabled())
@@ -120,7 +122,7 @@ public class EssentialsEntityListener extends EntityListener
}
}
@Override
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityRegainHealth(final EntityRegainHealthEvent event)
{

View File

@@ -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<String> groups = getGroups(base);
if (groups == null || groups.isEmpty())
{
return null;
}
return groups.get(0);
}
@Override
public List<String> 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");
}
}

View File

@@ -58,6 +58,7 @@ public enum Permissions implements IPermission
SETHOME_OTHERS,
SLEEPINGIGNORED,
SPAWN_OTHERS,
SUDO_EXEMPT,
TELEPORT_COOLDOWN_BYPASS,
TELEPORT_HIDDEN,
TELEPORT_TIMER_BYPASS,
@@ -65,6 +66,8 @@ public enum Permissions implements IPermission
TEMPBAN_OFFLINE,
TIME_SET,
TOGGLEJAIL_OFFLINE,
TPA,
TPAALL,
TPAHERE,
TPOHERE,
UNLIMITED_OTHERS,

View File

@@ -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;
@@ -112,17 +113,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())
{
@@ -145,6 +135,38 @@ public class PermissionsHandler implements IPermissionsHandler
return;
}
final Plugin privPlugin = pluginManager.getPlugin("Privileges");
if (privPlugin != null && privPlugin.isEnabled())
{
if (!(handler instanceof PrivilegesHandler))
{
LOGGER.log(Level.INFO, "Essentials: Using Privileges based permissions.");
handler = new PrivilegesHandler(privPlugin);
}
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 BPermissions2Handler))
{
LOGGER.log(Level.INFO, "Essentials: Using bPermissions2 based permissions.");
handler = new BPermissions2Handler();
}
return;
}
final Plugin permPlugin = pluginManager.getPlugin("Permissions");
if (permPlugin != null && permPlugin.isEnabled())
{

View File

@@ -0,0 +1,61 @@
package com.earth2me.essentials.perm;
import java.util.ArrayList;
import java.util.List;
import net.krinsoft.privileges.Privileges;
import net.krinsoft.privileges.groups.Group;
import net.krinsoft.privileges.groups.GroupManager;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class PrivilegesHandler extends SuperpermsHandler
{
private final transient Privileges plugin;
private final GroupManager manager;
public PrivilegesHandler(final Plugin plugin)
{
this.plugin = (Privileges) plugin;
this.manager = this.plugin.getGroupManager();
}
@Override
public String getGroup(final Player base)
{
Group group = manager.getGroup(base);
if (group == null)
{
return null;
}
return group.getName();
}
@Override
public List<String> getGroups(final Player base)
{
Group group = manager.getGroup(base);
if (group == null)
{
return new ArrayList<String>();
}
return group.getGroupTree();
}
@Override
public boolean inGroup(final Player base, final String group)
{
Group pGroup = manager.getGroup(base);
if (pGroup == null)
{
return false;
}
return pGroup.isMemberOf(group);
}
@Override
public boolean canBuild(Player base, String group)
{
return base.hasPermission("essentials.build") || base.hasPermission("privileges.build");
}
}

View File

@@ -27,7 +27,7 @@ public class SuperpermsHandler extends AbstractPermissionsHandler
@Override
public boolean inGroup(final Player base, final String group)
{
return false;
return hasPermission(base, "group." + group);
}
@Override

View File

@@ -34,14 +34,16 @@ 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)
{
@Cleanup
final IUser user = ess.getUser((Player)sender);
user.acquireReadLock();
displayName = user.getDisplayName();
userName = user.getName();
ipAddress = user.getAddress().getAddress().toString();
address = user.getAddress().toString();
balance = Double.toString(user.getMoney());
mails = Integer.toString(user.getData().getMails() == null ? 0 : user.getData().getMails().size());
world = user.getLocation().getWorld().getName();
@@ -110,8 +112,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);

View File

@@ -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<String> lines = new ArrayList<String>();
public SimpleTextInput (final String input) {
lines.add(input);
}
@Override
public List<String> getLines()
{
return lines;
}
@Override
public List<String> getChapters()
{
return Collections.emptyList();
}
@Override
public Map<String, Integer> getBookmarks()
{
return Collections.emptyMap();
}
}

View File

@@ -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);
}
}

View File

@@ -157,6 +157,7 @@ player-commands:
- xmpp
# Note: All items MUST be followed by a quantity!
# All kit names should be lower case, and will be treated as lower in permissions/costs.
# Times are measured in seconds.
kits:
tools:
@@ -166,8 +167,28 @@ kits:
- 278 1
- 279 1
# Disable all signs
signs-disabled: false
# Essentials Sign Control
# See http://ess.khhq.net/wiki/Sign_Tutorial for instructions on how to use these.
# To enable signs, remove # symbol. To disable all signs, comment/remove each sign.
# We recommend not enabling chest protection signs if you don't intend to use them, (or are using LWC/Lockette).
enabledSigns:
#- balance
#- buy
#- sell
#- trade
#- free
#- disposal
#- warp
#- kit
#- mail
#- enchant
#- gamemode
#- heal
#- spawnmob
#- time
#- weather
#- protection
# Backup runs a command while saving is disabled
backup:
@@ -277,8 +298,8 @@ sethome-multiple:
# essentials.sethome.multiple.staff
staff: 10
#Set timeout in seconds for players to accept tpa before request is cancelled.
#Set to 0 for no timeout
# Set timeout in seconds for players to accept tpa before request is cancelled.
# Set to 0 for no timeout
tpa-accept-cancellation: 0
############################################################
@@ -299,7 +320,7 @@ command-costs:
#example: 1000
# /kit tools costs $1500 PER USE
#kit-tools: 1500
# Set this to a currency symbol you want to use.
currency-symbol: '$'
@@ -321,7 +342,7 @@ non-ess-in-help: true
# Hide plugins which dont give a permission
# You can override a true value here for a single plugin by adding a permission to a user/group.
# The indervidual permission is: essentials.help.<plugin>, anyone with essentials.* or '*' will see all help this setting reguardless.
# The individual permission is: essentials.help.<plugin>, anyone with essentials.* or '*' will see all help this setting reguardless.
# You can use negitive permissions to remove access to just a single plugins help if the following is enabled.
hide-permissionless-help: true
@@ -332,22 +353,22 @@ hide-permissionless-help: true
############################################################
chat:
# If EssentialsChat is installed, this will define how far a player's voice travels, in blocks. Set to 0 to make all chat global.
# Note that users with the "essentials.chat.spy" permission will hear everything, regardless of this setting.
# Users with essentials.chat.shout can override this by prefixing text with an exclamation mark (!)
# Or with essentials.chat.question can override this by prefixing text with a question mark (?)
# You can add command costs for shout/question by adding chat-shout and chat-question to the command costs section."
radius: 0
# Chat formatting can be done in two ways, you can either define a standard format for all chat
# Or you can give a group specific chat format, to give some extra variation.
# If set to the default chat format which "should" be compatible with ichat.
# For more information of chat formatting, check out the wiki: http://ess.khhq.net/wiki/Chat_Formatting
format: '<{DISPLAYNAME}> {MESSAGE}'
#format: '&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}'
group-formats:
# Default: '{WORLDNAME} {DISPLAYNAME}&7:&f {MESSAGE}'
# Admins: '{WORLDNAME} &c[{GROUP}]&f {DISPLAYNAME}&7:&c {MESSAGE}'
@@ -386,13 +407,13 @@ protect:
# Which blocks should people be prevented from placing
placement: 10,11,46,327
# Which items should people be prevented from using
usage: 327
# Which blocks should people be prevented from breaking
break:
# Which blocks should not be pushed by pistons
piston:
@@ -446,12 +467,12 @@ protect:
mushroom_cow: false
magma_cube: false
snowman: false
# Maximum height the creeper should explode. -1 allows them to explode everywhere.
# Set prevent.creeper-explosion to true, if you want to disable creeper explosions.
creeper:
max-height: -1
# Protect various blocks.
protect:
# Protect all signs
@@ -467,7 +488,7 @@ protect:
# Prevent placing blocks above protected rails, this is to stop a potential griefing
prevent-block-on-rails: false
# Store blocks / signs in memory before writing
memstore: false
@@ -496,16 +517,16 @@ protect:
# Burn, baby, burn! Should fire damage be disabled?
firedmg: false
# Should the damage after hit by a lightning be disabled?
lightning: false
# Should people with build: false in permissions be allowed to build
# Set true to disable building for those people
build: true
# Should people with build: false in permissions be allowed to use items
# Set true to disable useing for those people
# Set true to disable using for those people
use: true
# Should we tell people they are not allowed to build
@@ -530,7 +551,7 @@ newbies:
# If not, set to ''
#announce-format: ''
announce-format: '&dWelcome {DISPLAYNAME}&d to the server!'
# When we spawn for the first time, which spawnpoint do we use?
# Set to "none" if you want to use the spawn point of the world.
spawnpoint: newbies

View File

@@ -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
@@ -25,7 +29,9 @@ Minecraft colors:
#Tags
PLAYER: {PLAYER}
USERNAME: {PLAYER}
IP: {IP}
ADDRESS: {ADDRESS}
BALANCE: {BALANCE}
MAILS: {MAILS}
WORLD: {WORLD}
@@ -39,3 +45,4 @@ WORLDTIME12: {WORLDTIME12}
WORLDTIME24: {WORLDTIME24}
WORLDDATE: {WORLDDATE}
PLUGINS: {PLUGINS}
VERSION: {VERSION}

View File

@@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} denied your teleport request.
requestSent=\u00a77Request sent to {0}\u00a77.
requestTimedOut=\u00a7cTeleport request has timed out
requiredBukkit= * ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
returnPlayerToJailError=Error occurred when trying to return player to jail.
returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=second
seconds=seconds
seenBanReason=Reason: {0}

View File

@@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} afviste din anmodning om teleport.
requestSent=\u00a77Anmodning sendt til {0}\u00a77.
requestTimedOut=\u00a7cTeleport request has timed out
requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
returnPlayerToJailError=En fejl opstod ved fors\u00f8g p\u00e5 at returnere spilleren til f\u00e6ngsel.
returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=sekund
seconds=sekunder
seenBanReason=Reason: {0}

View File

@@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} hat deine Teleportierungsanfrage abgelehnt.
requestSent=\u00a77Anfrage gesendet an {0}\u00a77.
requestTimedOut=\u00a7cTeleport request has timed out
requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
returnPlayerToJailError=Fehler beim Versuch, den Spieler ins Gef\u00e4ngnis zu teleportieren.
returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=Sekunde
seconds=Sekunden
seenBanReason=Reason: {0}

View File

@@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} denied your teleport request.
requestSent=\u00a77Request sent to {0}\u00a77.
requestTimedOut=\u00a7cTeleport request has timed out
requiredBukkit= * ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
returnPlayerToJailError=Error occurred when trying to return player to jail.
returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=second
seconds=seconds
seenBanReason=Reason: {0}

View File

@@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} ha denegado tu peticion de teletransporte.
requestSent=\u00a77Peticion enviada a {0}\u00a77.
requestTimedOut=\u00a7cTeleport request has timed out
requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
returnPlayerToJailError=Error al intentar quitar al jugador de la carcel.
returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=segundo
seconds=segundos
seenBanReason=Reason: {0}

View File

@@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} a refus\u00e9 votre demande de t\u00e9l\u00e9portat
requestSent=\u00a77Requ\u00eate envoy\u00e9e \u00e0 {0}\u00a77.
requestTimedOut=\u00a7cLa de mande de t\u00e9l\u00e9portation a expir\u00e9.
requiredBukkit=* ! * Vous avez besoin au moins de la version {0} de CraftBukkit. T\u00e9l\u00e9chargez-la ici http://ci.bukkit.org.
returnPlayerToJailError=Erreur survenue lors de la tentative d'emprisonner de nouveau un joueur.
returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=seconde
seconds=secondes
seenBanReason=Reason: {0}

View File

@@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} denied your teleport request.
requestSent=\u00a77Aanvraag verstuurd naar {0}\u00a77.
requestTimedOut=\u00a7cTeleport request has timed out
requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
returnPlayerToJailError=Fout opgetreden bij terugzetten van speler in gevangenis.
returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=seconde
seconds=seconde
seenBanReason=Reason: {0}

View File

@@ -5,7 +5,7 @@ main: com.earth2me.essentials.Essentials
version: TeamCity
website: http://tiny.cc/EssentialsWiki
description: Provides an essential, core set of commands for Bukkit.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits]
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5]
commands:
afk:
description: Marks you as away-from-keyboard.
@@ -120,7 +120,7 @@ commands:
aliases: [mem,memory,egc,emem,ememory]
give:
description: Give a player an item.
usage: /<command> <player> <item|numeric> [amount <enchantmentname[:level]> ...]
usage: /<command> <player> <item|numeric> [amount <enchantmentname[:level]> ...]
aliases: [egive]
god:
description: Enables your godly powers.
@@ -220,7 +220,7 @@ commands:
aliases: [emute]
near:
description: Lists the players near by or around a player
usage: /<command> [playername] [radius]
usage: /<command> [playername] [radius]
aliases: [nearby,enear,enearby]
nick:
description: Change your nickname or that of another player.
@@ -348,7 +348,7 @@ commands:
aliases: [etpaall]
tpaccept:
description: Accepts a teleport request.
usage: /<command>
usage: /<command> [otherplayer]
aliases: [tpyes,etpaccept,etpyes]
tpahere:
description: Request that the specified player teleport to you.

View File

@@ -14,11 +14,9 @@ import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.map.MapView;
import org.bukkit.permissions.Permissible;
@@ -144,195 +142,190 @@ public class FakeServer implements Server
}
return matches;
}
private PluginManager pManager = new PluginManager() {
private Set<Permission> permissions = new HashSet<Permission>();
private PluginManager pManager = new PluginManager()
{
private Set<Permission> permissions = new HashSet<Permission>();
@Override
public void registerInterface(Class<? extends PluginLoader> type) throws IllegalArgumentException
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void registerInterface(Class<? extends PluginLoader> type) throws IllegalArgumentException
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Plugin getPlugin(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Plugin getPlugin(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Plugin[] getPlugins()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Plugin[] getPlugins()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isPluginEnabled(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isPluginEnabled(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isPluginEnabled(Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isPluginEnabled(Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Plugin[] loadPlugins(File file)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Plugin[] loadPlugins(File file)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void disablePlugins()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void disablePlugins()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void clearPlugins()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void clearPlugins()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void callEvent(Event event)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void callEvent(Event event)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void registerEvent(Type type, Listener ll, Priority prt, Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void registerEvents(Listener ll, Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void registerEvent(Type type, Listener ll, EventExecutor ee, Priority prt, Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void registerEvent(Class<? extends Event> type, Listener ll, EventPriority ep, EventExecutor ee, Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void registerEvents(Listener ll, Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void enablePlugin(Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void registerEvent(Class<? extends Event> type, Listener ll, EventPriority ep, EventExecutor ee, Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void disablePlugin(Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void enablePlugin(Plugin plugin)
@Override
public Permission getPermission(String string)
{
for (Permission permission : permissions)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void disablePlugin(Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Permission getPermission(String string)
{
for (Permission permission : permissions)
if (permission.getName().equals(string))
{
if (permission.getName().equals(string)) {
return permission;
}
return permission;
}
return null;
}
return null;
}
@Override
public void addPermission(Permission prmsn)
{
permissions.add(prmsn);
}
@Override
public void addPermission(Permission prmsn)
{
permissions.add(prmsn);
}
@Override
public void removePermission(Permission prmsn)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removePermission(Permission prmsn)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removePermission(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removePermission(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set<Permission> getDefaultPermissions(boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set<Permission> getDefaultPermissions(boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void recalculatePermissionDefaults(Permission prmsn)
{
}
@Override
public void recalculatePermissionDefaults(Permission prmsn)
{
}
@Override
public void subscribeToPermission(String string, Permissible prmsbl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void subscribeToPermission(String string, Permissible prmsbl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void unsubscribeFromPermission(String string, Permissible prmsbl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void unsubscribeFromPermission(String string, Permissible prmsbl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set<Permissible> getPermissionSubscriptions(String string)
{
return Collections.emptySet();
}
@Override
public Set<Permissible> getPermissionSubscriptions(String string)
{
return Collections.emptySet();
}
@Override
public void subscribeToDefaultPerms(boolean bln, Permissible prmsbl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void subscribeToDefaultPerms(boolean bln, Permissible prmsbl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void unsubscribeFromDefaultPerms(boolean bln, Permissible prmsbl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void unsubscribeFromDefaultPerms(boolean bln, Permissible prmsbl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set<Permissible> getDefaultPermSubscriptions(boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set<Permissible> getDefaultPermSubscriptions(boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set<Permission> getPermissions()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set<Permission> getPermissions()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean useTimings()
{
throw new UnsupportedOperationException("Not supported yet.");
}
};
@Override
public boolean useTimings()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void registerEvent(Class<? extends Event> type, Listener ll, EventPriority ep, EventExecutor ee, Plugin plugin, boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
};
@Override
public PluginManager getPluginManager()
@@ -444,7 +437,6 @@ public class FakeServer implements Server
return worlds;
}
@Override
public World createWorld(String string, Environment e)
{
World w = new FakeWorld(string, e);
@@ -452,7 +444,6 @@ public class FakeServer implements Server
return w;
}
@Override
public World createWorld(String string, Environment e, long l)
{
World w = new FakeWorld(string, e);
@@ -518,18 +509,6 @@ public class FakeServer implements Server
players.add(base1);
}
@Override
public World createWorld(String string, Environment e, ChunkGenerator cg)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public World createWorld(String string, Environment e, long l, ChunkGenerator cg)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public World createWorld(WorldCreator creator)
{
@@ -835,4 +814,46 @@ public class FakeServer implements Server
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean useExactLoginLocation()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getTicksPerAnimalSpawns()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getTicksPerMonsterSpawns()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<Recipe> getRecipesFor(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Iterator<Recipe> recipeIterator()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void clearRecipes()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void resetRecipes()
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -3,7 +3,6 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
@@ -12,13 +11,15 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.config.Configuration;
@Deprecated
public class EssentialsConf extends Configuration
public class EssentialsConf extends YamlConfiguration
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient File configFile;
@@ -27,15 +28,10 @@ public class EssentialsConf extends Configuration
public EssentialsConf(final File configFile)
{
super(configFile);
super();
this.configFile = configFile;
if (this.root == null)
{
this.root = new HashMap<String, Object>();
}
}
@Override
public void load()
{
configFile = configFile.getAbsoluteFile();
@@ -106,19 +102,24 @@ public class EssentialsConf extends Configuration
}
}
try
{
super.load();
super.load(configFile);
}
catch (RuntimeException e)
catch (FileNotFoundException ex)
{
LOGGER.log(Level.SEVERE, "File broken: " + configFile.toString());
throw e;
LOGGER.log(Level.SEVERE, null, ex);
}
if (this.root == null)
catch (IOException ex)
{
this.root = new HashMap<String, Object>();
LOGGER.log(Level.SEVERE, null, ex);
}
catch (InvalidConfigurationException ex)
{
File broken = new File(configFile.getAbsolutePath() + ".broken." + System.currentTimeMillis());
configFile.renameTo(broken);
LOGGER.log(Level.SEVERE, "The file " + configFile.toString() + " is broken, it has been renamed to " + broken.toString(), ex.getCause());
}
}
@@ -193,7 +194,7 @@ public class EssentialsConf extends Configuration
public boolean hasProperty(final String path)
{
return getProperty(path) != null;
return isSet(path);
}
public Location getLocation(final String path, final Server server) throws Exception
@@ -218,24 +219,25 @@ public class EssentialsConf extends Configuration
public void setProperty(final String path, final Location loc)
{
setProperty((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
setProperty((path == null ? "" : path + ".") + "x", loc.getX());
setProperty((path == null ? "" : path + ".") + "y", loc.getY());
setProperty((path == null ? "" : path + ".") + "z", loc.getZ());
setProperty((path == null ? "" : path + ".") + "yaw", loc.getYaw());
setProperty((path == null ? "" : path + ".") + "pitch", loc.getPitch());
set((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
set((path == null ? "" : path + ".") + "x", loc.getX());
set((path == null ? "" : path + ".") + "y", loc.getY());
set((path == null ? "" : path + ".") + "z", loc.getZ());
set((path == null ? "" : path + ".") + "yaw", loc.getYaw());
set((path == null ? "" : path + ".") + "pitch", loc.getPitch());
}
@Override
public ItemStack getItemStack(final String path)
{
final ItemStack stack = new ItemStack(
Material.valueOf(getString(path + ".type", "AIR")),
getInt(path + ".amount", 1),
(short)getInt(path + ".damage", 0));
final List<String> enchants = getKeys(path + ".enchant");
final ConfigurationSection enchants = getConfigurationSection(path + ".enchant");
if (enchants != null)
{
for (String enchant : enchants)
for (String enchant : enchants.getKeys(false))
{
final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
if (enchantment == null)
@@ -271,14 +273,14 @@ public class EssentialsConf extends Configuration
}
// getData().getData() is broken
//map.put("data", stack.getDurability());
setProperty(path, map);
set(path, map);
}
public long getLong(final String path, final long def)
{
try
{
final Number num = (Number)getProperty(path);
final Number num = (Number)get(path);
return num == null ? def : num.longValue();
}
catch (ClassCastException ex)
@@ -292,7 +294,7 @@ public class EssentialsConf extends Configuration
{
try
{
Number num = (Number)getProperty(path);
Number num = (Number)get(path);
return num == null ? def : num.doubleValue();
}
catch (ClassCastException ex)
@@ -300,4 +302,27 @@ public class EssentialsConf extends Configuration
return def;
}
}
public void save() {
try
{
save(configFile);
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, null, ex);
}
}
public Object getProperty(String path) {
return get(path);
}
public void setProperty(String path, Object object) {
set(path, object);
}
public void removeProperty(String path) {
set(path, null);
}
}

View File

@@ -96,7 +96,7 @@ public class EssentialsUpgrade
}
final EssentialsConf conf = new EssentialsConf(configFile);
conf.load();
List<String> lines = conf.getStringList(name, null);
List<String> lines = conf.getStringList(name);
if (lines != null && !lines.isEmpty())
{
if (!file.createNewFile())
@@ -329,7 +329,7 @@ public class EssentialsUpgrade
config.setProperty("homes.home", defloc);
}
List<String> worlds = config.getKeys("home.worlds");
Set<String> worlds = config.getConfigurationSection("home.worlds").getKeys(false);
Location loc;
String worldName;
@@ -384,6 +384,7 @@ public class EssentialsUpgrade
* ((Number)vals.get(4)).floatValue())); } } } } usersFile.renameTo(new File(usersFile.getAbsolutePath() + ".old"));
* }
*/
private void convertWarps()
{
final File warpsFolder = new File(ess.getDataFolder(), "warps");
@@ -610,7 +611,7 @@ public class EssentialsUpgrade
if (!config.hasProperty("spawns"))
{
final Spawns spawns = new Spawns();
List<String> keys = config.getKeys();
Set<String> keys = config.getKeys(false);
for (String group : keys)
{
Location loc = getFakeLocation(config, group);
@@ -657,7 +658,7 @@ public class EssentialsUpgrade
if (!config.hasProperty("jails"))
{
final com.earth2me.essentials.settings.Jails jails = new com.earth2me.essentials.settings.Jails();
List<String> keys = config.getKeys();
Set<String> keys = config.getKeys(false);
for (String jailName : keys)
{
Location loc = getFakeLocation(config, jailName);

View File

@@ -35,6 +35,6 @@ public class ChatStore
public final String getLongType()
{
return type.length() > 0 ? "chat" : "chat-" + type;
return type.length() == 0 ? "chat" : "chat-" + type;
}
}

View File

@@ -5,6 +5,6 @@ main: com.earth2me.essentials.chat.EssentialsChat
version: TeamCity
website: http://tiny.cc/EssentialsWiki
description: Provides chat control features for Essentials. Requires Permissions.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, Okamosy]
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5, Okamosy]
depend: [Essentials3]
#softdepend: [Factions]

View File

@@ -10,6 +10,16 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/GroupManager.launch</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>

View File

@@ -90,7 +90,7 @@ v 1.7:
v 1.8:
- Changed ServicesManager registration to lowest from normal.
- Fixed 'manucheckp' returning a null for the searched node when it's a group/subgroup.
- manpromote and mandemote now correctly send the notification to the console if the command was issued there.
- 'manpromote' and 'mandemote' now correctly send the notification to the console if the command was issued there.
- Expanded GlobalGroups.yml and Groups.yml to include Towny permissions.
- Delayed GroupManager events so Superperms will be fully updated before plugins receive the events.
- Changed the way events are raised to prevent variable corruption.
@@ -124,4 +124,21 @@ v 1.9:
- Trap errors in fetching the mirrors map.
- Fixed an infinite loop error when using '/manudel' on a logged in player. It caused setDefaultGroup to trigger a bukkit update when no GM User existed yet.
- do not allow inherited permissions to negate higher perms.
- Fixed a bug when pushing superperms in the wrong order.
- Fixed a bug when pushing superperms in the wrong order.
- Fix players retaining permissions when demoted.
- Auto sort permissions on load to speed up population of superperms.
- Negating a parent node after adding all nodes with * will now correctly remove all child nodes of that parent before populating superperms.
eg.
- '*'
- -vanish.*
- vanish.standard
- Track the 'onPlayerChangeWorld' event as some teleports seem to not be triggering a world move.
- Catch all errors in badly formatted groups.
- Fix a bug with getWorldData return the main world data for all mirrors, instead of the worlds parent data.
- Prevent getAllPlayersPermissions() processing a group more than once. Improves performance when using complex inheritance structures.
- Fix world mirroring so it correctly creates data files and data sources for partially mirrored worlds.
- Fixed world mirroring so it returns the correct data for the requested world.
- Change Service registration to register WorldsHolder instead of AnjoPermissionsHandler. This is the correct entry point for all data.
- Depreciate PlayerTeleportEvent, PlayerRespawnEvent and PlayerPortalEvent as it's all handled in PlayerChangedWorldEvent.
This also means we no longer update permissions before we change worlds.
- A command of '/manload' with no world arguments now performs a full reload of GM.

View File

@@ -25,7 +25,10 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder;
import org.anjocaido.groupmanager.events.GMSystemEvent;
import org.anjocaido.groupmanager.events.GMWorldListener;
import org.anjocaido.groupmanager.events.GroupManagerEventHandler;
import org.anjocaido.groupmanager.events.GMGroupEvent.Action;
import org.anjocaido.groupmanager.utils.GMLoggerHandler;
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
import org.anjocaido.groupmanager.utils.Tasks;
@@ -158,7 +161,7 @@ public class GroupManager extends JavaPlugin {
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
// Register as a service
this.getServer().getServicesManager().register(AnjoPermissionsHandler.class, this.permissionHandler, this, ServicePriority.Lowest);
this.getServer().getServicesManager().register(WorldsHolder.class, this.worldsHolder, this, ServicePriority.Lowest);
}
public static boolean isLoaded() {
@@ -415,9 +418,9 @@ public class GroupManager extends JavaPlugin {
if (!sender.hasPermission("groupmanager.notify.other") || (isConsole))
sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' group to '" + auxGroup.getName() + "'.");
targetPlayer = this.getServer().getPlayer(auxUser.getName());
if (targetPlayer != null)
BukkitPermissions.updatePermissions(targetPlayer);
//targetPlayer = this.getServer().getPlayer(auxUser.getName());
//if (targetPlayer != null)
// BukkitPermissions.updatePermissions(targetPlayer);
return true;
// break;
@@ -450,6 +453,7 @@ public class GroupManager extends JavaPlugin {
dataHolder.removeUser(auxUser.getName());
sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' to default settings.");
// If the player is online, this will create new data for the user.
targetPlayer = this.getServer().getPlayer(auxUser.getName());
if (targetPlayer != null)
BukkitPermissions.updatePermissions(targetPlayer);
@@ -494,9 +498,9 @@ public class GroupManager extends JavaPlugin {
else
sender.sendMessage(ChatColor.RED + "The subgroup '" + auxGroup.getName() + "' is already available to '" + auxUser.getName() + "'.");
targetPlayer = this.getServer().getPlayer(auxUser.getName());
if (targetPlayer != null)
BukkitPermissions.updatePermissions(targetPlayer);
//targetPlayer = this.getServer().getPlayer(auxUser.getName());
//if (targetPlayer != null)
// BukkitPermissions.updatePermissions(targetPlayer);
return true;
case manudelsub:
@@ -534,9 +538,9 @@ public class GroupManager extends JavaPlugin {
auxUser.removeSubGroup(auxGroup);
sender.sendMessage(ChatColor.YELLOW + "You removed subgroup '" + auxGroup.getName() + "' from player '" + auxUser.getName() + "' list.");
targetPlayer = this.getServer().getPlayer(auxUser.getName());
if (targetPlayer != null)
BukkitPermissions.updatePermissions(targetPlayer);
//targetPlayer = this.getServer().getPlayer(auxUser.getName());
//if (targetPlayer != null)
// BukkitPermissions.updatePermissions(targetPlayer);
return true;
case mangadd:
@@ -1484,14 +1488,16 @@ public class GroupManager extends JavaPlugin {
try {
worldsHolder.saveChanges(forced);
sender.sendMessage(ChatColor.YELLOW + " The changes were saved.");
sender.sendMessage(ChatColor.YELLOW + " All changes were saved.");
} catch (IllegalStateException ex) {
sender.sendMessage(ChatColor.RED + ex.getMessage());
}
return true;
case manload:
// THIS CASE DONT NEED SENDER
/**
* Attempt to reload a specific world
*/
if (args.length > 0) {
auxString = "";
for (int i = 0; i < args.length; i++) {
@@ -1501,50 +1507,34 @@ public class GroupManager extends JavaPlugin {
}
}
isLoaded = false; // Disable Bukkit Perms update
isLoaded = false; // Disable Bukkit Perms update and event triggers
globalGroups.load();
worldsHolder.loadWorld(auxString);
sender.sendMessage("The request to world '" + auxString + "' was sent.");
sender.sendMessage("The request to reload world '" + auxString + "' was attempted.");
isLoaded = true;
BukkitPermissions.updateAllPlayers();
return true;
}
// VALIDANDO ESTADO DO SENDER
if (dataHolder == null || permissionHandler == null) {
if (!setDefaultWorldHandler(sender))
return true;
}
// WORKING
config.load();
worldsHolder.mirrorSetUp();
isLoaded = false;
if (args.length > 0) {
auxString = "";
for (int i = 0; i < args.length; i++) {
auxString += args[i];
if ((i + 1) < args.length) {
auxString += " ";
}
}
worldsHolder.loadWorld(auxString);
sender.sendMessage("The request to world '" + auxString + "' was sent.");
} else {
worldsHolder.reloadAll();
sender.sendMessage(ChatColor.YELLOW + " The current world was reloaded.");
/**
* Reload all settings and data as no world was specified.
*/
onDisable();
onEnable();
}
isLoaded = true;
BukkitPermissions.updateAllPlayers();
/**
* Fire an event as none will have been triggered in the reload.
*/
if (GroupManager.isLoaded())
GroupManagerEventHandler.callEvent(GMSystemEvent.Action.RELOADED);
return true;
case listgroups:
// VALIDANDO ESTADO DO SENDER
if (dataHolder == null || permissionHandler == null) {
@@ -1614,9 +1604,9 @@ public class GroupManager extends JavaPlugin {
if (!sender.hasPermission("groupmanager.notify.other") || (isConsole))
sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + ".");
targetPlayer = this.getServer().getPlayer(auxUser.getName());
if (targetPlayer != null)
BukkitPermissions.updatePermissions(targetPlayer);
//targetPlayer = this.getServer().getPlayer(auxUser.getName());
//if (targetPlayer != null)
// BukkitPermissions.updatePermissions(targetPlayer);
return true;
// break;
@@ -1670,9 +1660,9 @@ public class GroupManager extends JavaPlugin {
if (!sender.hasPermission("groupmanager.notify.other") || (isConsole))
sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + ".");
targetPlayer = this.getServer().getPlayer(auxUser.getName());
if (targetPlayer != null)
BukkitPermissions.updatePermissions(targetPlayer);
//targetPlayer = this.getServer().getPlayer(auxUser.getName());
//if (targetPlayer != null)
// BukkitPermissions.updatePermissions(targetPlayer);
return true;
// break;
@@ -1761,9 +1751,9 @@ public class GroupManager extends JavaPlugin {
dataHolder = worldsHolder.getWorldData(worldsHolder.getDefaultWorld().getName());
permissionHandler = dataHolder.getPermissionsHandler();
selectedWorlds.put(sender, dataHolder.getName());
if ((dataHolder != null) && (permissionHandler != null)) {
selectedWorlds.put(sender, dataHolder.getName());
sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. Default world '" + worldsHolder.getDefaultWorld().getName() + "' selected.");
return true;
}

View File

@@ -65,8 +65,19 @@ public abstract class DataUnit {
hash = 71 * hash + (this.name != null ? this.name.toLowerCase().hashCode() : 0);
return hash;
}
/**
* Set the data source to point to a different worldDataHolder
*
* @param source
*/
public void setDataSource(WorldDataHolder source) {
this.dataSource = source;
}
/**
* Get the current worldDataHolder this object is pointing to
*
* @return the dataSource
*/
public WorldDataHolder getDataSource() {

View File

@@ -138,8 +138,8 @@ public class User extends DataUnit implements Cloneable {
String oldGroup = this.group;
this.group = group.getName();
flagAsChanged();
if (GroupManager.isLoaded() && (updatePerms)) {
if (!GroupManager.BukkitPermissions.isPlayer_join())
if (GroupManager.isLoaded()) {
if (!GroupManager.BukkitPermissions.isPlayer_join() && (updatePerms))
GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer());
// Do we notify of the group change?

View File

@@ -9,15 +9,14 @@ import org.anjocaido.groupmanager.data.Group;
/**
* This container holds all Groups loaded from the relevant groupsFile.
*
* @author ElgarL
*
*/
public class GroupsDataHolder {
/**
* Root World name this set of groups is associated with.
*/
private String name;
private WorldDataHolder dataSource;
private Group defaultGroup = null;
private File groupsFile;
private boolean haveGroupsChanged = false;
@@ -33,16 +32,12 @@ public class GroupsDataHolder {
*/
protected GroupsDataHolder() {
}
protected void setWorldName(String worldName) {
name = worldName;
}
/**
* @return the name
*/
public String getWorldName() {
return name;
public void setDataSource(WorldDataHolder dataSource) {
this.dataSource = dataSource;
//push this data source to the users, so they pull the correct groups data.
for (Group group : groups.values())
group.setDataSource(this.dataSource);
}
/**

View File

@@ -9,15 +9,14 @@ import org.anjocaido.groupmanager.data.User;
/**
* This container holds all Users loaded from the relevant usersFile.
*
* @author ElgarL
*
*/
public class UsersDataHolder {
/**
* Root World name this set of groups is associated with.
*/
private String name;
private WorldDataHolder dataSource;
private File usersFile;
private boolean haveUsersChanged = false;
private long timeStampUsers = 0;
@@ -32,19 +31,13 @@ public class UsersDataHolder {
*/
protected UsersDataHolder() {
}
/**
* @param worldName
*/
public void setWorldName(String worldName) {
this.name = worldName;
}
/**
* @return the name
*/
public String getWorldName() {
return this.name;
public void setDataSource(WorldDataHolder dataSource) {
this.dataSource = dataSource;
//push this data source to the users, so they pull the correct groups data.
for (User user : users.values())
user.setDataSource(this.dataSource);
}
/**

View File

@@ -36,8 +36,11 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.reader.UnicodeReader;
/**
*
* @author gabrielcouto
* One instance of this should exist per world/mirror
* it contains all functions to manage these data sets
* and points to the relevant users and groups objects.
*
* @author gabrielcouto, ElgarL
*/
public class WorldDataHolder {
@@ -80,6 +83,16 @@ public class WorldDataHolder {
//this.defaultGroup = defaultGroup;
}
/**
* update the dataSource to point to this object.
*
* This should be called whenever a set of world data is fetched.
*/
public void updateDataSource() {
this.groups.setDataSource(this);
this.users.setDataSource(this);
}
/**
* Search for a user. If it doesn't exist, create a new one with
@@ -445,13 +458,13 @@ public class WorldDataHolder {
//PROCESS GROUPS FILE
Map<String, List<String>> inheritance = new HashMap<String, List<String>>();
//try {
try {
Map<String, Object> allGroupsNode = (Map<String, Object>) groupsRootDataNode.get("groups");
for (String groupKey : allGroupsNode.keySet()) {
Map<String, Object> thisGroupNode = (Map<String, Object>) allGroupsNode.get(groupKey);
Group thisGrp = ph.createGroup(groupKey);
if (thisGrp == null) {
throw new IllegalArgumentException("I think this user was declared more than once: " + groupKey + " in file: " + groupsFile.getPath());
throw new IllegalArgumentException("I think this Group was declared more than once: " + groupKey + " in file: " + groupsFile.getPath());
}
if (thisGroupNode.get("default") == null) {
thisGroupNode.put("default", false);
@@ -465,57 +478,72 @@ public class WorldDataHolder {
}
//PERMISSIONS NODE
if (thisGroupNode.get("permissions") == null) {
thisGroupNode.put("permissions", new ArrayList<String>());
}
if (thisGroupNode.get("permissions") instanceof List) {
for (Object o : ((List) thisGroupNode.get("permissions"))) {
try {
thisGrp.addPermission(o.toString());
} catch (NullPointerException e) {
// Ignore this entry as it's null.
//throw new IllegalArgumentException("Invalid permission node in group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
}
}
} else if (thisGroupNode.get("permissions") instanceof String) {
thisGrp.addPermission((String) thisGroupNode.get("permissions"));
} else {
throw new IllegalArgumentException("Unknown type of permissions node(Should be String or List<String>) for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
try {
if (thisGroupNode.get("permissions") == null) {
thisGroupNode.put("permissions", new ArrayList<String>());
} else {
if (thisGroupNode.get("permissions") instanceof List) {
for (Object o : ((List) thisGroupNode.get("permissions"))) {
try {
thisGrp.addPermission(o.toString());
} catch (NullPointerException e) {
// Ignore this entry as it's null.
//throw new IllegalArgumentException("Invalid permission node in group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
}
}
} else if (thisGroupNode.get("permissions") instanceof String) {
thisGrp.addPermission((String) thisGroupNode.get("permissions"));
} else {
throw new IllegalArgumentException("Unknown type of permissions node(Should be String or List<String>) for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
}
thisGrp.sortPermissions();
}
} catch (Exception e) {
throw new IllegalArgumentException("Invalid formatting found in permissions section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
}
//INFO NODE
if (thisGroupNode.get("info") instanceof Map) {
Map<String, Object> infoNode = (Map<String, Object>) thisGroupNode.get("info");
if (infoNode != null) {
thisGrp.setVariables(infoNode);
}
} else
throw new IllegalArgumentException("Unknown entry found in Info section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
try {
if (thisGroupNode.get("info") instanceof Map) {
Map<String, Object> infoNode = (Map<String, Object>) thisGroupNode.get("info");
if (infoNode != null) {
thisGrp.setVariables(infoNode);
}
} else
throw new IllegalArgumentException("Unknown entry found in Info section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
} catch (Exception e1) {
throw new IllegalArgumentException("Invalid formatting found in info section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
}
//END INFO NODE
if (thisGroupNode.get("inheritance") == null || thisGroupNode.get("inheritance") instanceof List) {
Object inheritNode = thisGroupNode.get("inheritance");
if (inheritNode == null) {
thisGroupNode.put("inheritance", new ArrayList<String>());
} else if (inheritNode instanceof List) {
List<String> groupsInh = (List<String>) inheritNode;
for (String grp : groupsInh) {
if (inheritance.get(groupKey) == null) {
List<String> thisInherits = new ArrayList<String>();
inheritance.put(groupKey, thisInherits);
}
inheritance.get(groupKey).add(grp);
}
}
}else
throw new IllegalArgumentException("Unknown entry found in inheritance section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
try {
if (thisGroupNode.get("inheritance") == null || thisGroupNode.get("inheritance") instanceof List) {
Object inheritNode = thisGroupNode.get("inheritance");
if (inheritNode == null) {
thisGroupNode.put("inheritance", new ArrayList<String>());
} else if (inheritNode instanceof List) {
List<String> groupsInh = (List<String>) inheritNode;
for (String grp : groupsInh) {
if (inheritance.get(groupKey) == null) {
List<String> thisInherits = new ArrayList<String>();
inheritance.put(groupKey, thisInherits);
}
inheritance.get(groupKey).add(grp);
}
}
}else
throw new IllegalArgumentException("Unknown entry found in inheritance section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
} catch (Exception e2) {
throw new IllegalArgumentException("Invalid formatting found in inheritance section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
}
}
//} catch (Exception ex) {
// ex.printStackTrace();
// throw new IllegalArgumentException("Your Permissions config file is invalid. See console for details.");
//}
} catch (Exception ex) {
ex.printStackTrace();
throw new IllegalArgumentException("Your " + groupsFile.getPath() + " file is invalid. See console for details.");
}
if (ph.getDefaultGroup() == null) {
throw new IllegalArgumentException("There was no Default Group declared in file: " + groupsFile.getPath());
}
@@ -581,18 +609,20 @@ public class WorldDataHolder {
}
if (thisUserNode.get("permissions") == null) {
thisUserNode.put("permissions", new ArrayList<String>());
}
if (thisUserNode.get("permissions") instanceof List) {
for (Object o : ((List) thisUserNode.get("permissions"))) {
thisUser.addPermission(o.toString());
}
} else if (thisUserNode.get("permissions") instanceof String) {
try {
thisUser.addPermission(thisUserNode.get("permissions").toString());
} catch (NullPointerException e) {
// Ignore this entry as it's null.
//throw new IllegalArgumentException("Invalid permission node for user: " + thisUser.getName() + " in file: " + UserFile.getPath());
}
} else {
if (thisUserNode.get("permissions") instanceof List) {
for (Object o : ((List) thisUserNode.get("permissions"))) {
thisUser.addPermission(o.toString());
}
} else if (thisUserNode.get("permissions") instanceof String) {
try {
thisUser.addPermission(thisUserNode.get("permissions").toString());
} catch (NullPointerException e) {
// Ignore this entry as it's null.
//throw new IllegalArgumentException("Invalid permission node for user: " + thisUser.getName() + " in file: " + UserFile.getPath());
}
}
thisUser.sortPermissions();
}
//SUBGROUPS LOADING
@@ -826,7 +856,7 @@ public class WorldDataHolder {
PluginManager pm = server.getPluginManager();
Plugin[] plugins = pm.getPlugins();
for (int i = 0; i < plugins.length; i++) {
plugins[i].getConfiguration().load();
//plugins[i].getConfiguration().load();
try {
plugins[i].getClass().getMethod("setupPermissions").invoke(plugins[i]);
} catch (Exception ex) {

View File

@@ -10,6 +10,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -45,7 +46,7 @@ public class WorldsHolder {
private Map<String, String> mirrorsGroup = new HashMap<String, String>();
private Map<String, String> mirrorsUser = new HashMap<String, String>();
private OverloadedWorldHolder defaultWorld;
//private OverloadedWorldHolder defaultWorld;
private String serverDefaultWorldName;
private GroupManager plugin;
private File worldsFolder;
@@ -59,7 +60,7 @@ public class WorldsHolder {
// Setup folders and check files exist for the primary world
verifyFirstRun();
initialLoad();
if (defaultWorld == null) {
if (serverDefaultWorldName == null) {
throw new IllegalStateException("There is no default group! OMG!");
}
}
@@ -76,7 +77,7 @@ public class WorldsHolder {
private void initialWorldLoading() {
//Load the default world
loadWorld(serverDefaultWorldName);
defaultWorld = worldsData.get(serverDefaultWorldName);
//defaultWorld = getUpdatedWorldData(serverDefaultWorldName);
}
private void loadAllSearchedWorlds() {
@@ -117,6 +118,8 @@ public class WorldsHolder {
mirrorsGroup.clear();
mirrorsUser.clear();
Map<String, Object> mirrorsMap = plugin.getGMConfig().getMirrorsMap();
HashSet<String> mirroredWorlds = new HashSet<String>();
if (mirrorsMap != null) {
for (String source : mirrorsMap.keySet()) {
@@ -140,6 +143,10 @@ public class WorldsHolder {
}
mirrorsGroup.put(world, getWorldData(source).getName());
mirrorsUser.put(world, getWorldData(source).getName());
// Track this world so we can create a datasource for it later
mirroredWorlds.add(o.toString());
} else
GroupManager.logger.log(Level.WARNING, "Mirroring error with " + o.toString() + ". Recursive loop detected!");
}
@@ -171,11 +178,13 @@ public class WorldsHolder {
if (type.equals("users"))
mirrorsUser.put(key.toLowerCase(), getWorldData(source).getName());
}
// Track this world so we can create a datasource for it later
mirroredWorlds.add(key);
} else
GroupManager.logger.log(Level.WARNING, "Mirroring error with " + key + ". Recursive loop detected!");
} else {
throw new IllegalStateException("Unknown mirroring format for " + key);
}
@@ -183,6 +192,14 @@ public class WorldsHolder {
}
}
}
// Create a datasource for any worlds not already loaded
for (String world : mirroredWorlds){
if (!worldsData.containsKey(world.toLowerCase())) {
setupWorldFolder(world);
loadWorld(world, true);
}
}
}
}
@@ -320,7 +337,8 @@ public class WorldsHolder {
* If the world is not on the worlds list, returns the default world
* holder.
*
* Mirrors return original world data.
* Mirrors return their parent world data.
* If no mirroring data it returns the default world.
*
* @param worldName
* @return OverloadedWorldHolder
@@ -328,12 +346,55 @@ public class WorldsHolder {
public OverloadedWorldHolder getWorldData(String worldName) {
String worldNameLowered = worldName.toLowerCase();
if (worldsData.containsKey(worldNameLowered))
return worldsData.get(worldNameLowered);
// Find this worlds data
if (worldsData.containsKey(worldNameLowered)) {
String usersMirror = mirrorsUser.get(worldNameLowered);
String groupsMirror = mirrorsGroup.get(worldNameLowered);
if (usersMirror != null) {
// If both are mirrored
if (groupsMirror != null) {
// if the data sources are the same, return the parent
if (usersMirror == groupsMirror)
return getUpdatedWorldData(usersMirror.toLowerCase());
// Both data sources are mirrors, but they are from different parents
// so we return the actual data object.
return getUpdatedWorldData(worldNameLowered);
}
// Groups isn't a mirror so return this this worlds data source
return getUpdatedWorldData(worldNameLowered);
}
// users isn't mirrored so we need to return this worlds data source
return getUpdatedWorldData(worldNameLowered);
}
// Oddly no data source was found for this world so return the default.
GroupManager.logger.finest("Requested world " + worldName + " not found or badly mirrored. Returning default world...");
return getDefaultWorld();
}
/**
* Get the requested world data and update it's dataSource to be relevant for this world
*
* @param worldName
* @return updated world holder
*/
private OverloadedWorldHolder getUpdatedWorldData(String worldName) {
if (worldsData.containsKey(worldName.toLowerCase())) {
OverloadedWorldHolder data = worldsData.get(worldName.toLowerCase());
data.updateDataSource();
return data;
}
return null;
}
/**
* Do a matching of playerName, if its found only one player, do
@@ -353,6 +414,7 @@ public class WorldsHolder {
/**
* Retrieves the field player.getWorld().getName() and do
* getWorld(worldName)
*
* @param player
* @return OverloadedWorldHolder
*/
@@ -476,18 +538,29 @@ public class WorldsHolder {
}
/**
* Wrapper for LoadWorld(String,Boolean) for backwards compatibility
*
* Load a world from file.
* If it already been loaded, summon reload method from dataHolder.
* @param worldName
*/
public void loadWorld(String worldName) {
loadWorld(worldName, false);
}
/**
* Load a world from file.
* If it already been loaded, summon reload method from dataHolder.
* @param worldName
*/
public void loadWorld(String worldName, Boolean isMirror) {
if (worldsData.containsKey(worldName.toLowerCase())) {
worldsData.get(worldName.toLowerCase()).reload();
return;
}
GroupManager.logger.finest("Trying to load world " + worldName + "...");
File thisWorldFolder = new File(worldsFolder, worldName);
if (thisWorldFolder.exists() && thisWorldFolder.isDirectory()) {
if ((isMirror) || (thisWorldFolder.exists() && thisWorldFolder.isDirectory())) {
// Setup file handles, if not mirrored
File groupsFile = (mirrorsGroup.containsKey(worldName.toLowerCase()))? null : new File(thisWorldFolder, "groups.yml");
@@ -564,17 +637,43 @@ public class WorldsHolder {
* @return the defaultWorld
*/
public OverloadedWorldHolder getDefaultWorld() {
return defaultWorld;
return getUpdatedWorldData(serverDefaultWorldName);
}
/**
* Returns all physically loaded worlds.
* Returns all physically loaded worlds which have at least
* one of their own data sets for users or groups.
*
* @return ArrayList<OverloadedWorldHolder> of all loaded worlds
*/
public ArrayList<OverloadedWorldHolder> allWorldsDataList() {
ArrayList<OverloadedWorldHolder> list = new ArrayList<OverloadedWorldHolder>();
for (OverloadedWorldHolder data : worldsData.values()) {
if (!list.contains(data)) {
if ((!list.contains(data)) && (!mirrorsGroup.containsKey(data.getName().toLowerCase()) || !mirrorsUser.containsKey(data.getName().toLowerCase()))) {
String worldNameLowered = data.getName().toLowerCase();
String usersMirror = mirrorsUser.get(worldNameLowered);
String groupsMirror = mirrorsGroup.get(worldNameLowered);
// is users mirrored?
if (usersMirror != null) {
// If both are mirrored
if (groupsMirror != null) {
// if the data sources are the same, return the parent
if (usersMirror == groupsMirror) {
if (!list.contains(usersMirror.toLowerCase()))
list.add(worldsData.get(usersMirror.toLowerCase()));
continue;
}
// Both data sources are mirrors, but they are from different parents
// so fall through to add the actual data object.
}
// Groups isn't a mirror so fall through to add this this worlds data source
}
// users isn't mirrored so we need to add this worlds data source
list.add(data);
}
}

View File

@@ -37,7 +37,7 @@ public class GMGroupEvent extends Event {
protected Action action;
public GMGroupEvent(Group group, Action action) {
super(action.toString());
super();
this.group = group;
this.action = action;
@@ -45,7 +45,7 @@ public class GMGroupEvent extends Event {
}
public GMGroupEvent(String groupName, Action action) {
super(action.toString());
super();
this.groupName = groupName;
this.action = action;

View File

@@ -32,7 +32,7 @@ public class GMSystemEvent extends Event {
protected Action action;
public GMSystemEvent(Action action) {
super(action.toString());
super();
this.action = action;
}

View File

@@ -37,7 +37,7 @@ public class GMUserEvent extends Event {
protected Action action;
public GMUserEvent(User user, Action action) {
super(action.toString());
super();
this.user = user;
this.action = action;
@@ -45,7 +45,7 @@ public class GMUserEvent extends Event {
}
public GMUserEvent(String userName, Action action) {
super(action.toString());
super();
this.userName = userName;
this.action = action;

View File

@@ -121,27 +121,34 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
// Add the players own permissions.
playerPermArray.addAll(populatePerms(ph.getUser(userName).getPermissionList(), includeChildren));
ArrayList<String> alreadyProcessed = new ArrayList<String>();
// fetch all group permissions
for (String group : getGroups(userName)) {
Set<String> groupPermArray = new HashSet<String>();
if (group.startsWith("g:") && GroupManager.getGlobalGroups().hasGroup(group)) {
// GlobalGroups
groupPermArray = populatePerms(GroupManager.getGlobalGroups().getGroupsPermissions(group), includeChildren);
// Don't process a group more than once.
if (!alreadyProcessed.contains(group)) {
alreadyProcessed.add(group);
} else {
// World Groups
groupPermArray = populatePerms(ph.getGroup(group).getPermissionList(), includeChildren);
}
// Add all group permissions, unless negated by earlier permissions.
for (String perm : groupPermArray) {
boolean negated = (perm.startsWith("-"));
// Perm doesn't already exists and there is no negation for it
// or It's a negated perm where a normal perm doesn't exists (don't allow inheritance to negate higher perms)
if ((!negated && !playerPermArray.contains(perm) && !playerPermArray.contains("-" + perm))
|| (negated && !playerPermArray.contains(perm.substring(1))))
playerPermArray.add(perm);
Set<String> groupPermArray = new HashSet<String>();
if (group.startsWith("g:") && GroupManager.getGlobalGroups().hasGroup(group)) {
// GlobalGroups
groupPermArray = populatePerms(GroupManager.getGlobalGroups().getGroupsPermissions(group), includeChildren);
} else {
// World Groups
groupPermArray = populatePerms(ph.getGroup(group).getPermissionList(), includeChildren);
}
// Add all group permissions, unless negated by earlier permissions.
for (String perm : groupPermArray) {
boolean negated = (perm.startsWith("-"));
// Perm doesn't already exists and there is no negation for it
// or It's a negated perm where a normal perm doesn't exists (don't allow inheritance to negate higher perms)
if ((!negated && !playerPermArray.contains(perm) && !playerPermArray.contains("-" + perm))
|| (negated && !playerPermArray.contains(perm.substring(1))))
playerPermArray.add(perm);
}
}
}
@@ -153,15 +160,23 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
private Set<String> populatePerms (List<String> perms, boolean includeChildren) {
Set<String> permArray = new HashSet<String>();
Boolean allPerms = false;
// Allow * node to populate ALL perms in Bukkit.
// Allow * node to populate ALL permissions to Bukkit.
if (perms.contains("*")) {
permArray.addAll(GroupManager.BukkitPermissions.getAllRegisteredPermissions(includeChildren));
allPerms = true;
}
for (String perm : perms) {
if (!perm.equalsIgnoreCase("*")) {
/**
* all permission sets are passed here pre-sorted, alphabetically.
* This means negated nodes will be processed before all permissions
* other than *.
*/
boolean negated = false;
if (perm.startsWith("-"))
negated = true;
@@ -172,12 +187,17 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
if ((negated) && (permArray.contains(perm.substring(1))))
permArray.remove(perm.substring(1));
if (includeChildren) {
/**
* Process child nodes if required,
* or this is a negated node AND we used * to include all permissions,
* in which case we need to remove all children of that node.
*/
if ((includeChildren) || (negated && allPerms)) {
Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren((negated ? perm.substring(1) : perm), new HashSet<String>());
if (children != null) {
if (negated) {
if (negated || (negated && allPerms)) {
// Remove children of negated nodes
for (String child : children.keySet())
@@ -185,7 +205,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
if (permArray.contains(child))
permArray.remove(child);
} else {
} else if (!negated){
// Add child nodes
for (String child : children.keySet())

View File

@@ -28,19 +28,16 @@ import java.util.Map;
import java.util.Set;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.permissions.Permission;
@@ -136,33 +133,30 @@ public class BukkitPermissions {
}
PermissionAttachment attachment;
// Find the players current attachment, or add a new one.
if (this.attachments.containsKey(player)) {
attachment = this.attachments.get(player);
} else {
attachment = player.addAttachment(plugin);
this.attachments.put(player, attachment);;
this.attachments.put(player, attachment);
}
if (world == null) {
world = player.getWorld().getName();
}
OverloadedWorldHolder worldData = plugin.getWorldsHolder().getWorldData(world);
Boolean value = false;
// Add all permissions for this player (GM only)
// child nodes will be calculated by Bukkit.
List<String> playerPermArray = new ArrayList<String>(worldData.getPermissionsHandler().getAllPlayersPermissions(player.getName(), false));
List<String> playerPermArray = new ArrayList<String>(plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getAllPlayersPermissions(player.getName(), false));
LinkedHashMap<String, Boolean> newPerms = new LinkedHashMap<String, Boolean>();
// Sort the perm list by parent/child, so it will push to superperms correctly.
playerPermArray = sort(playerPermArray);
Boolean value = false;
for (String permission : playerPermArray) {
value = (!permission.startsWith("-"));
newPerms.put((value? permission : permission.substring(1)), value);
}
@@ -178,7 +172,8 @@ public class BukkitPermissions {
// Then whack our map into there
orig.putAll(newPerms);
// That's all folks!
attachment.getPermissible().recalculatePermissions();
//attachment.getPermissible().recalculatePermissions();
player.recalculatePermissions();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
@@ -348,6 +343,12 @@ public class BukkitPermissions {
this.updatePermissions(player, null);
}
/**
* Player events tracked to cause Superperms updates
*
* @author ElgarL
*
*/
protected class PlayerEvents implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
@@ -361,24 +362,10 @@ public class BukkitPermissions {
}
setPlayer_join(false);
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerPortal(PlayerPortalEvent event) { // will portal into another world
if ((event.getTo() != null) && (!event.getFrom().getWorld().equals(event.getTo().getWorld()))) { // only if world actually changed
updatePermissions(event.getPlayer(), event.getTo().getWorld().getName());
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerRespawn(PlayerRespawnEvent event) { // can be respawned in another world
updatePermissions(event.getPlayer(), event.getRespawnLocation().getWorld().getName());
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerTeleport(PlayerTeleportEvent event) { // can be teleported into another world
if ((event.getTo() != null) && (event.getPlayer() != null) && (!event.getFrom().getWorld().equals(event.getTo().getWorld()))) { // only if world actually changed
updatePermissions(event.getPlayer(), event.getTo().getWorld().getName());
}
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) { // has changed worlds
updatePermissions(event.getPlayer(), event.getPlayer().getWorld().getName());
}
@EventHandler(priority = EventPriority.LOWEST)

View File

@@ -63,6 +63,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
{
final EmergencyListener emListener = new EmergencyListener();
pm.registerEvents(emListener, this);
for (Player player : getServer().getOnlinePlayers())
{
player.sendMessage("Essentials Protect is in emergency mode. Check your log for errors.");

View File

@@ -322,7 +322,7 @@ public class EssentialsProtectEntityListener implements Listener
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onEndermanPickup(final EndermanPickupEvent event)
public void onEntityChangeBlock(final EntityChangeBlockEvent event)
{
if (event.isCancelled())
{

View File

@@ -44,9 +44,9 @@ public class SignBlockListener implements Listener
if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId())
{
final Sign csign = (Sign)block.getState();
for (Signs signs : Signs.values())
for (EssentialsSign sign : ess.getSettings().enabledSigns())
{
final EssentialsSign sign = signs.getSign();
if (csign.getLine(0).equalsIgnoreCase(sign.getSuccessName())
&& !sign.onSignBreak(block, player, ess))
{
@@ -62,9 +62,8 @@ public class SignBlockListener implements Listener
LOGGER.log(Level.INFO, "Prevented that a block was broken next to a sign.");
return true;
}
for (Signs signs : Signs.values())
for (EssentialsSign sign : ess.getSettings().enabledSigns())
{
final EssentialsSign sign = signs.getSign();
if (sign.getBlocks().contains(block.getType())
&& !sign.onBlockBreak(block, player, ess))
{
@@ -159,9 +158,8 @@ public class SignBlockListener implements Listener
event.setCancelled(true);
return;
}
for (Signs signs : Signs.values())
for (EssentialsSign sign : ess.getSettings().enabledSigns())
{
final EssentialsSign sign = signs.getSign();
if (sign.getBlocks().contains(block.getType())
&& !sign.onBlockBurn(block, ess))
{
@@ -188,9 +186,8 @@ public class SignBlockListener implements Listener
event.setCancelled(true);
return;
}
for (Signs signs : Signs.values())
for (EssentialsSign sign : ess.getSettings().enabledSigns())
{
final EssentialsSign sign = signs.getSign();
if (sign.getBlocks().contains(block.getType())
&& !sign.onBlockIgnite(block, ess))
{
@@ -213,9 +210,8 @@ public class SignBlockListener implements Listener
event.setCancelled(true);
return;
}
for (Signs signs : Signs.values())
for (EssentialsSign sign : ess.getSettings().enabledSigns())
{
final EssentialsSign sign = signs.getSign();
if (sign.getBlocks().contains(block.getType())
&& !sign.onBlockPush(block, ess))
{
@@ -240,9 +236,8 @@ public class SignBlockListener implements Listener
event.setCancelled(true);
return;
}
for (Signs signs : Signs.values())
for (EssentialsSign sign : ess.getSettings().enabledSigns())
{
final EssentialsSign sign = signs.getSign();
if (sign.getBlocks().contains(block.getType())
&& !sign.onBlockPush(block, ess))
{

View File

@@ -6,7 +6,7 @@ import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EndermanPickupEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
@@ -32,9 +32,8 @@ public class SignEntityListener implements Listener
event.setCancelled(true);
return;
}
for (Signs signs : Signs.values())
for (EssentialsSign sign : ess.getSettings().enabledSigns())
{
final EssentialsSign sign = signs.getSign();
if (sign.getBlocks().contains(block.getType()))
{
event.setCancelled(!sign.onBlockExplode(block, ess));
@@ -45,7 +44,7 @@ public class SignEntityListener implements Listener
}
@EventHandler(priority = EventPriority.LOW)
public void onEndermanPickup(final EndermanPickupEvent event)
public void onEntityChangeBlock(final EntityChangeBlockEvent event)
{
if (event.isCancelled())
{
@@ -61,9 +60,8 @@ public class SignEntityListener implements Listener
event.setCancelled(true);
return;
}
for (Signs signs : Signs.values())
for (EssentialsSign sign : ess.getSettings().enabledSigns())
{
final EssentialsSign sign = signs.getSign();
if (sign.getBlocks().contains(block.getType())
&& !sign.onBlockBreak(block, ess))
{

View File

@@ -41,9 +41,8 @@ public class SignPlayerListener implements Listener
return;
}
final Sign csign = (Sign)block.getState();
for (Signs signs : Signs.values())
for (EssentialsSign sign : ess.getSettings().enabledSigns())
{
final EssentialsSign sign = signs.getSign();
if (csign.getLine(0).equalsIgnoreCase(sign.getSuccessName()))
{
sign.onSignInteract(block, event.getPlayer(), ess);
@@ -54,9 +53,8 @@ public class SignPlayerListener implements Listener
}
else
{
for (Signs signs : Signs.values())
for (EssentialsSign sign : ess.getSettings().enabledSigns())
{
final EssentialsSign sign = signs.getSign();
if (sign.getBlocks().contains(block.getType())
&& !sign.onBlockInteract(block, event.getPlayer(), ess))
{

View File

@@ -129,7 +129,7 @@ public class SignProtection extends EssentialsSign
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
{
final BlockSign sign = new BlockSign(block);
if (sign.getLine(0).equalsIgnoreCase(this.getSuccessName()))
if (sign.getLine(0).equals(this.getSuccessName()))
{
return checkProtectionSign(sign, user, username, ess);
}

View File

@@ -40,7 +40,7 @@ public class SignTrade extends EssentialsSign
try
{
stored = getTrade(sign, 1, true, true, ess);
substractAmount(sign, 1, stored, ess);
subtractAmount(sign, 1, stored, ess);
stored.pay(player);
}
catch (SignException e)
@@ -57,12 +57,14 @@ public class SignTrade extends EssentialsSign
final Trade charge = getTrade(sign, 1, false, false, ess);
final Trade trade = getTrade(sign, 2, false, true, ess);
charge.isAffordableFor(player);
addAmount(sign, 1, charge, ess);
subtractAmount(sign, 2, trade, ess);
if (!trade.pay(player, false))
{
subtractAmount(sign, 1, charge, ess);
addAmount(sign, 2, trade, ess);
throw new ChargeException("Full inventory");
}
substractAmount(sign, 2, trade, ess);
addAmount(sign, 1, charge, ess);
charge.charge(player);
Trade.log("Sign", "Trade", "Interact", sign.getLine(3), charge, username, trade, sign.getBlock().getLocation(), ess);
}
@@ -260,7 +262,7 @@ public class SignTrade extends EssentialsSign
throw new SignException(_("invalidSignLine", index + 1));
}
protected final void substractAmount(final ISign sign, final int index, final Trade trade, final IEssentials ess) throws SignException
protected final void subtractAmount(final ISign sign, final int index, final Trade trade, final IEssentials ess) throws SignException
{
final Double money = trade.getMoney();
if (money != null)
@@ -298,6 +300,7 @@ public class SignTrade extends EssentialsSign
}
}
//TODO: Translate these exceptions.
private void changeAmount(final ISign sign, final int index, final double value, final IEssentials ess) throws SignException
{
@@ -317,7 +320,7 @@ public class SignTrade extends EssentialsSign
final String newline = Util.formatCurrency(money, ess) + ":" + Util.formatCurrency(amount + value, ess).substring(1);
if (newline.length() > 15)
{
throw new SignException("Line too long!");
throw new SignException("This sign is full: Line too long!");
}
sign.setLine(index, newline);
return;
@@ -333,7 +336,7 @@ public class SignTrade extends EssentialsSign
final String newline = stackamount + " " + split[1] + ":" + (amount + Math.round(value));
if (newline.length() > 15)
{
throw new SignException("Line too long!");
throw new SignException("This sign is full: Line too long!");
}
sign.setLine(index, newline);
return;
@@ -347,7 +350,7 @@ public class SignTrade extends EssentialsSign
final String newline = stackamount + " " + split[1] + ":" + (amount + Math.round(value));
if (newline.length() > 15)
{
throw new SignException("Line too long!");
throw new SignException("This sign is full: Line too long!");
}
sign.setLine(index, newline);
return;

View File

@@ -4,6 +4,10 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.ISettings;
import com.earth2me.essentials.api.IUser;
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.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -83,7 +87,9 @@ public class EssentialsSpawnPlayerListener implements Listener
if (spawns.getAnnounceNewPlayers())
{
ess.broadcastMessage(user, spawns.getAnnounceNewPlayerFormat(user));
final IText output = new KeywordReplacer(new SimpleTextInput(spawns.getAnnounceNewPlayerFormat(user)), user, ess);
final SimpleTextPager pager = new SimpleTextPager(output);
ess.broadcastMessage(user, pager.getString(0));
}
}

View File

@@ -7,16 +7,15 @@ import java.util.Map;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
public class EssentialsHelp extends PlayerListener
public class EssentialsHelp implements Listener
{
private transient Player chatUser;
private final transient Server server;
@@ -39,8 +38,7 @@ public class EssentialsHelp extends PlayerListener
public void registerEvents()
{
final PluginManager pluginManager = server.getPluginManager();
pluginManager.registerEvent(Type.PLAYER_QUIT, this, Priority.Low, plugin);
pluginManager.registerEvent(Type.PLAYER_CHAT, this, Priority.Low, plugin);
pluginManager.registerEvents(this, plugin);
}
public void onCommand(final CommandSender sender)
@@ -155,18 +153,17 @@ public class EssentialsHelp extends PlayerListener
ircBot = new IrcBot(player, "Ess_" + player.getName(), UsernameUtil.createUsername(player));
}
@Override
@EventHandler
public void onPlayerChat(final PlayerChatEvent event)
{
if (event.getPlayer() == chatUser)
{
final boolean success = sendChatMessage(event.getPlayer(), event.getMessage());
event.setCancelled(success);
return;
}
}
@Override
@EventHandler
public void onPlayerQuit(final PlayerQuitEvent event)
{
closeConnection();

View File

@@ -7,18 +7,15 @@ import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.CustomEventListener;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
public class UpdateProcess extends PlayerListener
public class UpdateProcess implements Listener
{
private transient Player currentPlayer;
private final transient Plugin plugin;
@@ -34,21 +31,7 @@ public class UpdateProcess extends PlayerListener
public void registerEvents()
{
final PluginManager pluginManager = plugin.getServer().getPluginManager();
pluginManager.registerEvent(Type.PLAYER_QUIT, this, Priority.Low, plugin);
pluginManager.registerEvent(Type.PLAYER_CHAT, this, Priority.Lowest, plugin);
pluginManager.registerEvent(Type.PLAYER_JOIN, this, Priority.Normal, plugin);
pluginManager.registerEvent(Type.CUSTOM_EVENT, new CustomEventListener()
{
@Override
public void onCustomEvent(final Event event)
{
if (event instanceof InstallationFinishedEvent)
{
UpdateProcess.this.currentPlayer = null;
}
}
}, Priority.Normal, plugin);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
public boolean selfUpdate()
@@ -110,7 +93,13 @@ public class UpdateProcess extends PlayerListener
return false;
}
@Override
@EventHandler
public void onInstallationFinished(final InstallationFinishedEvent event)
{
UpdateProcess.this.currentPlayer = null;
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerChat(final PlayerChatEvent event)
{
if (event.getPlayer() == currentPlayer)
@@ -130,7 +119,7 @@ public class UpdateProcess extends PlayerListener
}
}
@Override
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent event)
{
final Player player = event.getPlayer();

View File

@@ -7,6 +7,6 @@ public class InstallationFinishedEvent extends Event
{
public InstallationFinishedEvent()
{
super(Type.CUSTOM_EVENT);
super();
}
}

View File

@@ -36,7 +36,7 @@ public class UserManager implements IReload
public final String getUserByAddress(final String search)
{
final List<String> usernames = users.getKeys(null);
final Set<String> usernames = users.getKeys(false);
for (String username : usernames)
{
final String address = users.getString(username + "." + ADDRESS, null);
@@ -73,7 +73,7 @@ public class UserManager implements IReload
{
users.load();
spyusers.clear();
final List<String> keys = users.getKeys(null);
final Set<String> keys = users.getKeys(false);
for (String key : keys)
{
if (isSpy(key))

View File

@@ -182,7 +182,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
if (config.getBoolean("log-enabled", false))
{
LOGGER.addHandler(this);
logUsers = config.getStringList("log-users", new ArrayList<String>());
logUsers = config.getStringList("log-users");
final String level = config.getString("log-level", "info");
try
{
@@ -350,7 +350,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
private void sendCommand(final Chat chat, final String message)
{
if (config.getStringList("op-users", new ArrayList<String>()).contains(StringUtils.parseBareAddress(chat.getParticipant())))
if (config.getStringList("op-users").contains(StringUtils.parseBareAddress(chat.getParticipant())))
{
try
{

BIN
lib/Privileges.jar Normal file

Binary file not shown.

BIN
lib/bpermissions2.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.