mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-07 19:40:23 +01:00
Don't look up valid looking IP's in the player database.
This commit is contained in:
parent
9976cc847f
commit
c476471978
@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -25,20 +26,28 @@ public class Commandbanip extends EssentialsCommand
|
||||
}
|
||||
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
final String ipAddress;
|
||||
|
||||
final User player = ess.getUser(args[0]);
|
||||
if (player == null)
|
||||
String ipAddress;
|
||||
if (FormatUtil.validIP(args[0]))
|
||||
{
|
||||
ipAddress = args[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
ipAddress = player.getLastLoginAddress();
|
||||
if (ipAddress.length() == 0)
|
||||
try
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
User player = getPlayer(server, args, 0, true, true);
|
||||
ipAddress = player.getLastLoginAddress();
|
||||
}
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
ipAddress = args[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (ipAddress.isEmpty())
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
ess.getServer().banIP(ipAddress);
|
||||
|
@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Server;
|
||||
@ -25,6 +24,7 @@ public class Commandunbanip extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
String ipAddress;
|
||||
if (FormatUtil.validIP(args[0]))
|
||||
{
|
||||
@ -32,13 +32,21 @@ public class Commandunbanip extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
final User user = getPlayer(server, args, 0, true, true);
|
||||
ipAddress = user.getLastLoginAddress();
|
||||
try
|
||||
{
|
||||
User player = getPlayer(server, args, 0, true, true);
|
||||
ipAddress = player.getLastLoginAddress();
|
||||
}
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
ipAddress = args[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (ipAddress.isEmpty())
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
ess.getServer().unbanIP(ipAddress);
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
@ -1,74 +0,0 @@
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import de.bananaco.permissions.Permissions;
|
||||
import de.bananaco.permissions.info.InfoReader;
|
||||
import de.bananaco.permissions.interfaces.PermissionSet;
|
||||
import de.bananaco.permissions.worlds.WorldPermissionsManager;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class BPermissionsHandler extends SuperpermsHandler
|
||||
{
|
||||
private final transient WorldPermissionsManager wpm;
|
||||
private final transient InfoReader info;
|
||||
|
||||
public BPermissionsHandler()
|
||||
{
|
||||
wpm = Permissions.getWorldPermissionsManager();
|
||||
info = new InfoReader();
|
||||
info.instantiate();
|
||||
}
|
||||
|
||||
@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 PermissionSet pset = wpm.getPermissionSet(base.getWorld());
|
||||
if (pset == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return pset.getGroups(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
final List<String> groups = getGroups(base);
|
||||
if (groups == null || groups.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return groups.contains(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group)
|
||||
{
|
||||
return hasPermission(base, "bPermissions.build");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final Player base)
|
||||
{
|
||||
return info.getPrefix(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix(final Player base)
|
||||
{
|
||||
return info.getSuffix(base);
|
||||
}
|
||||
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class Permissions2Handler implements IPermissionsHandler
|
||||
{
|
||||
private final transient PermissionHandler permissionHandler;
|
||||
|
||||
public Permissions2Handler(final Plugin permissionsPlugin)
|
||||
{
|
||||
permissionHandler = ((Permissions)permissionsPlugin).getHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
return permissionHandler.getGroup(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(final Player base)
|
||||
{
|
||||
return Arrays.asList(permissionHandler.getGroups(base.getWorld().getName(), base.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group)
|
||||
{
|
||||
return permissionHandler.canGroupBuild(base.getWorld().getName(), getGroup(base));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
return permissionHandler.inGroup(base.getWorld().getName(), base.getName(), group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final Player base, final String node)
|
||||
{
|
||||
return permissionHandler.permission(base, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final Player base)
|
||||
{
|
||||
return permissionHandler.getGroupPrefix(base.getWorld().getName(), getGroup(base));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix(final Player base)
|
||||
{
|
||||
return permissionHandler.getGroupSuffix(base.getWorld().getName(), getGroup(base));
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class Permissions3Handler implements IPermissionsHandler
|
||||
{
|
||||
private final transient PermissionHandler permissionHandler;
|
||||
|
||||
public Permissions3Handler(final Plugin permissionsPlugin)
|
||||
{
|
||||
permissionHandler = ((Permissions)permissionsPlugin).getHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
return permissionHandler.getPrimaryGroup(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(final Player base)
|
||||
{
|
||||
return Arrays.asList(permissionHandler.getGroups(base.getWorld().getName(), base.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group)
|
||||
{
|
||||
return permissionHandler.canUserBuild(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
return permissionHandler.inGroup(base.getWorld().getName(), base.getName(), group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final Player base, final String node)
|
||||
{
|
||||
return permissionHandler.has(base, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final Player base)
|
||||
{
|
||||
return permissionHandler.getUserPrefix(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix(final Player base)
|
||||
{
|
||||
return permissionHandler.getUserSuffix(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@ -160,44 +158,12 @@ public class PermissionsHandler implements IPermissionsHandler
|
||||
final Plugin bPermPlugin = pluginManager.getPlugin("bPermissions");
|
||||
if (bPermPlugin != null && bPermPlugin.isEnabled())
|
||||
{
|
||||
final String bVer = bPermPlugin.getDescription().getVersion().replace(".", "");
|
||||
if (NumberUtil.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())
|
||||
{
|
||||
if (permPlugin.getDescription().getVersion().charAt(0) == '3')
|
||||
{
|
||||
if (!(handler instanceof Permissions3Handler))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Using Permissions 3 based permissions.");
|
||||
handler = new Permissions3Handler(permPlugin);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(handler instanceof Permissions2Handler))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Using Permissions 2 based permissions.");
|
||||
handler = new Permissions2Handler(permPlugin);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (useSuperperms)
|
||||
|
Loading…
Reference in New Issue
Block a user