mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-17 12:01:20 +02:00
Merge branch 'refs/heads/master' into release
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.command.PluginCommandYamlParser;
|
import org.bukkit.command.PluginCommandYamlParser;
|
||||||
@@ -11,6 +10,7 @@ import org.bukkit.plugin.Plugin;
|
|||||||
public class AlternativeCommandsHandler
|
public class AlternativeCommandsHandler
|
||||||
{
|
{
|
||||||
private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>();
|
private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>();
|
||||||
|
private final transient Map<String, String> executed = new HashMap<String, String>();
|
||||||
private final transient IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
|
|
||||||
public AlternativeCommandsHandler(final IEssentials ess)
|
public AlternativeCommandsHandler(final IEssentials ess)
|
||||||
@@ -18,7 +18,8 @@ public class AlternativeCommandsHandler
|
|||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
for (Plugin plugin : ess.getServer().getPluginManager().getPlugins())
|
for (Plugin plugin : ess.getServer().getPluginManager().getPlugins())
|
||||||
{
|
{
|
||||||
if (plugin.isEnabled()) {
|
if (plugin.isEnabled())
|
||||||
|
{
|
||||||
addPlugin(plugin);
|
addPlugin(plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,12 +107,24 @@ public class AlternativeCommandsHandler
|
|||||||
return commands.get(0);
|
return commands.get(0);
|
||||||
}
|
}
|
||||||
// return the first command that is not an alias
|
// return the first command that is not an alias
|
||||||
for (PluginCommand command : commands) {
|
for (PluginCommand command : commands)
|
||||||
if (command.getName().equalsIgnoreCase(label)) {
|
{
|
||||||
|
if (command.getName().equalsIgnoreCase(label))
|
||||||
|
{
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// return the first alias
|
// return the first alias
|
||||||
return commands.get(0);
|
return commands.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void executed(final String label, final String otherlabel)
|
||||||
|
{
|
||||||
|
executed.put(label, otherlabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> disabledCommands()
|
||||||
|
{
|
||||||
|
return executed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -273,7 +273,8 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||||||
final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel);
|
final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel);
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
{
|
{
|
||||||
LOGGER.info("Essentials: Alternative command " + commandLabel + " found, using " + pc.getLabel());
|
alternativeCommandsHandler.executed(commandLabel, pc.getLabel());
|
||||||
|
LOGGER.log(Level.FINE,"Essentials: Alternative command " + commandLabel + " found, using " + pc.getLabel());
|
||||||
return pc.execute(sender, commandLabel, args);
|
return pc.execute(sender, commandLabel, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,7 +346,8 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||||||
{
|
{
|
||||||
sender.sendMessage(command.getDescription());
|
sender.sendMessage(command.getDescription());
|
||||||
sender.sendMessage(command.getUsage().replaceAll("<command>", commandLabel));
|
sender.sendMessage(command.getUsage().replaceAll("<command>", commandLabel));
|
||||||
if (!ex.getMessage().isEmpty()) {
|
if (!ex.getMessage().isEmpty())
|
||||||
|
{
|
||||||
sender.sendMessage(ex.getMessage());
|
sender.sendMessage(ex.getMessage());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -420,14 +422,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||||||
}
|
}
|
||||||
if (base instanceof String)
|
if (base instanceof String)
|
||||||
{
|
{
|
||||||
try
|
return userMap.getUser((String)base);
|
||||||
{
|
|
||||||
return userMap.getUser((String)base);
|
|
||||||
}
|
|
||||||
catch (NullPointerException ex)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -443,27 +438,21 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||||||
{
|
{
|
||||||
return (User)base;
|
return (User)base;
|
||||||
}
|
}
|
||||||
try
|
User user = userMap.getUser(base.getName());
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
{
|
{
|
||||||
return userMap.getUser(base.getName()).update(base);
|
user = new User(base, this);
|
||||||
}
|
} else {
|
||||||
catch (NullPointerException ex)
|
user.update(base);
|
||||||
{
|
|
||||||
return new User(base, this);
|
|
||||||
}
|
}
|
||||||
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User getOfflineUser(final String name)
|
public User getOfflineUser(final String name)
|
||||||
{
|
{
|
||||||
try
|
return userMap.getUser(name);
|
||||||
{
|
|
||||||
return userMap.getUser(name);
|
|
||||||
}
|
|
||||||
catch (NullPointerException ex)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -232,21 +232,25 @@ public class EssentialsConf extends Configuration
|
|||||||
Material.valueOf(getString(path + ".type", "AIR")),
|
Material.valueOf(getString(path + ".type", "AIR")),
|
||||||
getInt(path + ".amount", 1),
|
getInt(path + ".amount", 1),
|
||||||
(short)getInt(path + ".damage", 0));
|
(short)getInt(path + ".damage", 0));
|
||||||
List<String> enchants = getKeys(path + ".enchant");
|
final List<String> enchants = getKeys(path + ".enchant");
|
||||||
for (String enchant : enchants)
|
if (enchants != null)
|
||||||
{
|
{
|
||||||
Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
|
for (String enchant : enchants)
|
||||||
if (enchantment == null) {
|
{
|
||||||
continue;
|
final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
|
||||||
|
if (enchantment == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final int level = getInt(path + ".enchant." + enchant, enchantment.getStartLevel());
|
||||||
|
stack.addUnsafeEnchantment(enchantment, level);
|
||||||
}
|
}
|
||||||
int level = getInt(path+ ".enchant."+enchant, enchantment.getStartLevel());
|
|
||||||
stack.addUnsafeEnchantment(enchantment, level);
|
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
/*
|
/*
|
||||||
* ,
|
* ,
|
||||||
* (byte)getInt(path + ".data", 0)
|
* (byte)getInt(path + ".data", 0)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProperty(final String path, final ItemStack stack)
|
public void setProperty(final String path, final ItemStack stack)
|
||||||
|
@@ -120,33 +120,6 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||||||
}
|
}
|
||||||
user.updateActivity(false);
|
user.updateActivity(false);
|
||||||
user.dispose();
|
user.dispose();
|
||||||
if (!ess.getSettings().getReclaimSetting())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final Thread thread = new Thread(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Thread.sleep(1000);
|
|
||||||
Runtime rt = Runtime.getRuntime();
|
|
||||||
double mem = rt.freeMemory();
|
|
||||||
rt.runFinalization();
|
|
||||||
rt.gc();
|
|
||||||
mem = rt.freeMemory() - mem;
|
|
||||||
mem /= 1024 * 1024;
|
|
||||||
LOGGER.log(Level.INFO, _("freedMemory", mem));
|
|
||||||
}
|
|
||||||
catch (InterruptedException ex)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
thread.setPriority(Thread.MIN_PRIORITY);
|
|
||||||
thread.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -69,6 +69,9 @@ public class I18n
|
|||||||
|
|
||||||
public static String _(final String string, final Object... objects)
|
public static String _(final String string, final Object... objects)
|
||||||
{
|
{
|
||||||
|
if (instance == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
if (objects.length == 0)
|
if (objects.length == 0)
|
||||||
{
|
{
|
||||||
return instance.translate(string);
|
return instance.translate(string);
|
||||||
|
@@ -59,8 +59,6 @@ public interface ISettings extends IConf
|
|||||||
|
|
||||||
String getProtectString(final String configName);
|
String getProtectString(final String configName);
|
||||||
|
|
||||||
boolean getReclaimSetting();
|
|
||||||
|
|
||||||
boolean getRespawnAtHome();
|
boolean getRespawnAtHome();
|
||||||
|
|
||||||
List getMultipleHomes();
|
List getMultipleHomes();
|
||||||
|
@@ -76,8 +76,7 @@ public enum Mob
|
|||||||
|
|
||||||
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
|
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
|
||||||
{
|
{
|
||||||
|
final LivingEntity entity = player.getWorld().spawn(loc, (Class<? extends LivingEntity>)this.bukkitType.getEntityClass());
|
||||||
final LivingEntity entity = player.getWorld().spawnCreature(loc, this.bukkitType);
|
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
{
|
{
|
||||||
logger.log(Level.WARNING, _("unableToSpawnMob"));
|
logger.log(Level.WARNING, _("unableToSpawnMob"));
|
||||||
|
@@ -243,12 +243,6 @@ public class Settings implements ISettings
|
|||||||
return ChatColor.getByCode(Integer.parseInt(colorName, 16));
|
return ChatColor.getByCode(Integer.parseInt(colorName, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getReclaimSetting()
|
|
||||||
{
|
|
||||||
return config.getBoolean("reclaim-onlogout", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSpawnMobLimit()
|
public int getSpawnMobLimit()
|
||||||
{
|
{
|
||||||
|
@@ -4,11 +4,14 @@ import com.google.common.cache.Cache;
|
|||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ConcurrentHashMultiset;
|
import com.google.common.collect.ConcurrentHashMultiset;
|
||||||
|
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
@@ -57,7 +60,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
|||||||
return keys.contains(name.toLowerCase(Locale.ENGLISH));
|
return keys.contains(name.toLowerCase(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getUser(final String name) throws NullPointerException
|
public User getUser(final String name)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -65,7 +68,11 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
|||||||
}
|
}
|
||||||
catch (ExecutionException ex)
|
catch (ExecutionException ex)
|
||||||
{
|
{
|
||||||
throw new NullPointerException();
|
return null;
|
||||||
|
}
|
||||||
|
catch (UncheckedExecutionException ex)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -376,9 +376,9 @@ public class Util
|
|||||||
buf.append(seperator);
|
buf.append(seperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (each instanceof List)
|
if (each instanceof Collection)
|
||||||
{
|
{
|
||||||
buf.append(joinList(seperator, ((List)each).toArray()));
|
buf.append(joinList(seperator, ((Collection)each).toArray()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.Util;
|
import com.earth2me.essentials.Util;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -15,7 +16,6 @@ public class Commandbalancetop extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
super("balancetop");
|
super("balancetop");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int CACHETIME = 5 * 60 * 1000;
|
private static final int CACHETIME = 5 * 60 * 1000;
|
||||||
public static final int MINUSERS = 50;
|
public static final int MINUSERS = 50;
|
||||||
private static List<String> cache = new ArrayList<String>();
|
private static List<String> cache = new ArrayList<String>();
|
||||||
@@ -107,12 +107,10 @@ public class Commandbalancetop extends EssentialsCommand
|
|||||||
final Map<String, Double> balances = new HashMap<String, Double>();
|
final Map<String, Double> balances = new HashMap<String, Double>();
|
||||||
for (String u : ess.getUserMap().getAllUniqueUsers())
|
for (String u : ess.getUserMap().getAllUniqueUsers())
|
||||||
{
|
{
|
||||||
try
|
final User user = ess.getUserMap().getUser(u);
|
||||||
{
|
if (user != null)
|
||||||
balances.put(u, ess.getUserMap().getUser(u).getMoney());
|
|
||||||
}
|
|
||||||
catch (NullPointerException ex)
|
|
||||||
{
|
{
|
||||||
|
balances.put(u, user.getMoney());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -67,6 +67,8 @@ public class Commandenchant extends EssentialsCommand
|
|||||||
super("enchant");
|
super("enchant");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TODO: Implement charge costs: final Trade charge = new Trade("enchant-" + enchantmentName, ess);
|
||||||
@Override
|
@Override
|
||||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
|
import com.earth2me.essentials.Util;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -23,12 +24,52 @@ public class Commandessentials extends EssentialsCommand
|
|||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
if (args.length > 0 && args[0].equalsIgnoreCase("debug"))
|
if (args.length == 0) {
|
||||||
{
|
run_disabled(server, sender, commandLabel, args);
|
||||||
ess.getSettings().setDebug(!ess.getSettings().isDebug());
|
|
||||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("debug"))
|
||||||
|
{
|
||||||
|
run_debug(server, sender, commandLabel, args);
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("nya"))
|
||||||
|
{
|
||||||
|
run_nya(server, sender, commandLabel, args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
run_reload(server, sender, commandLabel, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run_disabled(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
|
{
|
||||||
|
sender.sendMessage("Essentials " + ess.getDescription().getVersion());
|
||||||
|
sender.sendMessage("/<command> <reload/debug>");
|
||||||
|
sender.sendMessage("Essentials blocked the following commands, due to command conflicts:");
|
||||||
|
final StringBuilder disabledCommands = new StringBuilder();
|
||||||
|
for (Map.Entry<String, String> entry : ess.getAlternativeCommandsHandler().disabledCommands().entrySet())
|
||||||
|
{
|
||||||
|
if (disabledCommands.length() > 0) {
|
||||||
|
disabledCommands.append(", ");
|
||||||
|
}
|
||||||
|
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
|
||||||
|
}
|
||||||
|
sender.sendMessage(disabledCommands.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
|
{
|
||||||
|
ess.getSettings().setDebug(!ess.getSettings().isDebug());
|
||||||
|
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run_reload(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
|
{
|
||||||
|
ess.reload();
|
||||||
|
sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run_nya(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
|
{
|
||||||
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
|
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
|
||||||
noteMap.put("1F#", (byte)0x0);
|
noteMap.put("1F#", (byte)0x0);
|
||||||
noteMap.put("1G", (byte)0x1);
|
noteMap.put("1G", (byte)0x1);
|
||||||
@@ -54,8 +95,6 @@ public class Commandessentials extends EssentialsCommand
|
|||||||
noteMap.put("2D#", (byte)(0x9 + 0xC));
|
noteMap.put("2D#", (byte)(0x9 + 0xC));
|
||||||
noteMap.put("2E", (byte)(0xA + 0xC));
|
noteMap.put("2E", (byte)(0xA + 0xC));
|
||||||
noteMap.put("2F", (byte)(0xB + 0xC));
|
noteMap.put("2F", (byte)(0xB + 0xC));
|
||||||
if (args.length > 0 && args[0].equalsIgnoreCase("nya"))
|
|
||||||
{
|
|
||||||
if (!noteBlocks.isEmpty())
|
if (!noteBlocks.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -106,9 +145,6 @@ public class Commandessentials extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
}, 20, 2);
|
}, 20, 2);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
ess.reload();
|
|
||||||
sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopTune()
|
private void stopTune()
|
||||||
|
@@ -21,6 +21,10 @@ public class GroupManagerHandler implements IPermissionsHandler
|
|||||||
public String getGroup(final Player base)
|
public String getGroup(final Player base)
|
||||||
{
|
{
|
||||||
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||||
|
if (handler == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return handler.getGroup(base.getName());
|
return handler.getGroup(base.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,6 +32,10 @@ public class GroupManagerHandler implements IPermissionsHandler
|
|||||||
public List<String> getGroups(final Player base)
|
public List<String> getGroups(final Player base)
|
||||||
{
|
{
|
||||||
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||||
|
if (handler == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return Arrays.asList(handler.getGroups(base.getName()));
|
return Arrays.asList(handler.getGroups(base.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +43,10 @@ public class GroupManagerHandler implements IPermissionsHandler
|
|||||||
public boolean canBuild(final Player base, final String group)
|
public boolean canBuild(final Player base, final String group)
|
||||||
{
|
{
|
||||||
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||||
|
if (handler == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return handler.canUserBuild(base.getName());
|
return handler.canUserBuild(base.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,6 +54,10 @@ public class GroupManagerHandler implements IPermissionsHandler
|
|||||||
public boolean inGroup(final Player base, final String group)
|
public boolean inGroup(final Player base, final String group)
|
||||||
{
|
{
|
||||||
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||||
|
if (handler == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return handler.inGroup(base.getName(), group);
|
return handler.inGroup(base.getName(), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +65,10 @@ public class GroupManagerHandler implements IPermissionsHandler
|
|||||||
public boolean hasPermission(final Player base, final String node)
|
public boolean hasPermission(final Player base, final String node)
|
||||||
{
|
{
|
||||||
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||||
|
if (handler == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return handler.has(base, node);
|
return handler.has(base, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,6 +76,10 @@ public class GroupManagerHandler implements IPermissionsHandler
|
|||||||
public String getPrefix(final Player base)
|
public String getPrefix(final Player base)
|
||||||
{
|
{
|
||||||
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||||
|
if (handler == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return handler.getUserPrefix(base.getName());
|
return handler.getUserPrefix(base.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,6 +87,10 @@ public class GroupManagerHandler implements IPermissionsHandler
|
|||||||
public String getSuffix(final Player base)
|
public String getSuffix(final Player base)
|
||||||
{
|
{
|
||||||
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||||
|
if (handler == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return handler.getUserSuffix(base.getName());
|
return handler.getUserSuffix(base.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -68,11 +68,6 @@ item-spawn-blacklist:
|
|||||||
# - essentials.give.item-[itemid]
|
# - essentials.give.item-[itemid]
|
||||||
permission-based-item-spawn: false
|
permission-based-item-spawn: false
|
||||||
|
|
||||||
# Whether or not to reclaim memory on player logout; this is technical, and should only be changed under special circumstances.
|
|
||||||
# This generally increases server stability unless very specific runtime configurations are used.
|
|
||||||
# HOWEVER, it is known to cause lag upon users logging OUT, so beware!
|
|
||||||
reclaim-onlogout: false
|
|
||||||
|
|
||||||
# Mob limit on spawnmob
|
# Mob limit on spawnmob
|
||||||
spawnmob-limit: 10
|
spawnmob-limit: 10
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@ settings:
|
|||||||
# user/groups permissions as the parent.
|
# user/groups permissions as the parent.
|
||||||
world:
|
world:
|
||||||
- world_nether
|
- world_nether
|
||||||
|
- world_the_end
|
||||||
- world2
|
- world2
|
||||||
- world3
|
- world3
|
||||||
# world4:
|
# world4:
|
||||||
|
@@ -294,7 +294,7 @@ public class GlobalGroups {
|
|||||||
*/
|
*/
|
||||||
public boolean hasPermission(String groupName, String permissionNode) {
|
public boolean hasPermission(String groupName, String permissionNode) {
|
||||||
|
|
||||||
if (!hasGroup(groupName.toLowerCase()))
|
if (!hasGroup(groupName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return groups.get(groupName.toLowerCase()).hasSamePermissionNode(permissionNode);
|
return groups.get(groupName.toLowerCase()).hasSamePermissionNode(permissionNode);
|
||||||
@@ -315,7 +315,7 @@ public class GlobalGroups {
|
|||||||
result.askedPermission = permissionNode;
|
result.askedPermission = permissionNode;
|
||||||
result.resultType = PermissionCheckResult.Type.NOTFOUND;
|
result.resultType = PermissionCheckResult.Type.NOTFOUND;
|
||||||
|
|
||||||
if (!hasGroup(groupName.toLowerCase()))
|
if (!hasGroup(groupName))
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
Group tempGroup = groups.get(groupName.toLowerCase());
|
Group tempGroup = groups.get(groupName.toLowerCase());
|
||||||
@@ -337,7 +337,7 @@ public class GlobalGroups {
|
|||||||
* @return List of all group names
|
* @return List of all group names
|
||||||
*/
|
*/
|
||||||
public List<String> getGroupsPermissions(String groupName) {
|
public List<String> getGroupsPermissions(String groupName) {
|
||||||
if (!hasGroup(groupName.toLowerCase()))
|
if (!hasGroup(groupName))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return groups.get(groupName.toLowerCase()).getPermissionList();
|
return groups.get(groupName.toLowerCase()).getPermissionList();
|
||||||
@@ -374,7 +374,7 @@ public class GlobalGroups {
|
|||||||
* @return Group object
|
* @return Group object
|
||||||
*/
|
*/
|
||||||
public Group getGroup(String groupName) {
|
public Group getGroup(String groupName) {
|
||||||
if (!hasGroup(groupName.toLowerCase()))
|
if (!hasGroup(groupName))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return groups.get(groupName.toLowerCase());
|
return groups.get(groupName.toLowerCase());
|
||||||
|
@@ -195,7 +195,7 @@ public class WorldDataHolder {
|
|||||||
* @return a group if it is found. null if not found.
|
* @return a group if it is found. null if not found.
|
||||||
*/
|
*/
|
||||||
public Group getGroup(String groupName) {
|
public Group getGroup(String groupName) {
|
||||||
if (groupName.startsWith("g:"))
|
if (groupName.toLowerCase().startsWith("g:"))
|
||||||
return GroupManager.getGlobalGroups().getGroup(groupName);
|
return GroupManager.getGlobalGroups().getGroup(groupName);
|
||||||
else
|
else
|
||||||
return groups.get(groupName.toLowerCase());
|
return groups.get(groupName.toLowerCase());
|
||||||
@@ -208,7 +208,7 @@ public class WorldDataHolder {
|
|||||||
* @return true if exists. false if not.
|
* @return true if exists. false if not.
|
||||||
*/
|
*/
|
||||||
public boolean groupExists(String groupName) {
|
public boolean groupExists(String groupName) {
|
||||||
if (groupName.startsWith("g:"))
|
if (groupName.toLowerCase().startsWith("g:"))
|
||||||
return GroupManager.getGlobalGroups().hasGroup(groupName);
|
return GroupManager.getGlobalGroups().hasGroup(groupName);
|
||||||
else
|
else
|
||||||
return groups.containsKey(groupName.toLowerCase());
|
return groups.containsKey(groupName.toLowerCase());
|
||||||
@@ -219,7 +219,7 @@ public class WorldDataHolder {
|
|||||||
* @param groupToAdd
|
* @param groupToAdd
|
||||||
*/
|
*/
|
||||||
public void addGroup(Group groupToAdd) {
|
public void addGroup(Group groupToAdd) {
|
||||||
if (groupToAdd.getName().startsWith("g:")) {
|
if (groupToAdd.getName().toLowerCase().startsWith("g:")) {
|
||||||
GroupManager.getGlobalGroups().addGroup(groupToAdd);
|
GroupManager.getGlobalGroups().addGroup(groupToAdd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,7 @@ public class WorldDataHolder {
|
|||||||
* @return true if had something to remove. false the group was default or non-existant
|
* @return true if had something to remove. false the group was default or non-existant
|
||||||
*/
|
*/
|
||||||
public boolean removeGroup(String groupName) {
|
public boolean removeGroup(String groupName) {
|
||||||
if (groupName.startsWith("g:")) {
|
if (groupName.toLowerCase().startsWith("g:")) {
|
||||||
return GroupManager.getGlobalGroups().removeGroup(groupName);
|
return GroupManager.getGlobalGroups().removeGroup(groupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ public class WorldDataHolder {
|
|||||||
* @return null if group already exists. or new Group
|
* @return null if group already exists. or new Group
|
||||||
*/
|
*/
|
||||||
public Group createGroup(String groupName) {
|
public Group createGroup(String groupName) {
|
||||||
if (groupName.startsWith("g:")) {
|
if (groupName.toLowerCase().startsWith("g:")) {
|
||||||
Group newGroup = new Group(groupName);
|
Group newGroup = new Group(groupName);
|
||||||
return GroupManager.getGlobalGroups().newGroup(newGroup);
|
return GroupManager.getGlobalGroups().newGroup(newGroup);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user