mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-01 05:57:54 +01:00
Cleaned up a vunerability and some code smells.
This commit is contained in:
parent
bdca10636e
commit
e598fa7c93
@ -76,9 +76,9 @@ public class Panel {
|
||||
* @param users
|
||||
*/
|
||||
public void open(User... users) {
|
||||
for (User user : users) {
|
||||
user.getPlayer().openInventory(inventory);
|
||||
PanelListenerManager.getOpenPanels().put(user.getUniqueId(), this);
|
||||
for (User u : users) {
|
||||
u.getPlayer().openInventory(inventory);
|
||||
PanelListenerManager.getOpenPanels().put(u.getUniqueId(), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class PanelItemBuilder {
|
||||
*/
|
||||
public PanelItemBuilder description(String... description) {
|
||||
List<String> additions = Arrays.asList(description);
|
||||
ArrayList<String> updatableList = new ArrayList<String>();
|
||||
ArrayList<String> updatableList = new ArrayList<>();
|
||||
updatableList.addAll(this.description);
|
||||
updatableList.addAll(additions);
|
||||
this.description = updatableList;
|
||||
|
@ -6,16 +6,14 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
import us.tastybento.bskyblock.Constants;
|
||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||
import us.tastybento.bskyblock.api.commands.User;
|
||||
import us.tastybento.bskyblock.util.Util;
|
||||
|
||||
/**
|
||||
* A safe common space for team commands to share data
|
||||
@ -24,7 +22,7 @@ import us.tastybento.bskyblock.api.commands.User;
|
||||
*/
|
||||
public abstract class AbstractIslandTeamCommand extends CompositeCommand {
|
||||
|
||||
protected final static boolean DEBUG = false;
|
||||
protected static final boolean DEBUG = false;
|
||||
protected static BiMap<UUID, UUID> inviteList = HashBiMap.create();
|
||||
// The time a player has to wait until they can reset their island again
|
||||
protected static HashMap<UUID, Long> resetWaitTime = new HashMap<>();
|
||||
@ -45,41 +43,10 @@ public abstract class AbstractIslandTeamCommand extends CompositeCommand {
|
||||
}
|
||||
|
||||
protected int getMaxTeamSize(User user) {
|
||||
return getMaxPermSize(user, "team.maxsize.", getSettings().getMaxTeamSize());
|
||||
return Util.getPermValue(user.getPlayer(), "team.maxsize.", getSettings().getMaxTeamSize());
|
||||
}
|
||||
|
||||
protected int getMaxRangeSize(User user) {
|
||||
return getMaxPermSize(user, "island.range.", getSettings().getIslandProtectionRange());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max size based on permissions
|
||||
* @param playerUUID - the player's UUID
|
||||
* @return the max permission for this perm
|
||||
*/
|
||||
private int getMaxPermSize(User user, String perm, int maxSize) {
|
||||
for (PermissionAttachmentInfo perms : user.getEffectivePermissions()) {
|
||||
if (perms.getPermission().startsWith(Constants.PERMPREFIX + perm)) {
|
||||
if (perms.getPermission().contains(Constants.PERMPREFIX + perm + "*")) {
|
||||
maxSize = getSettings().getMaxTeamSize();
|
||||
break;
|
||||
} else {
|
||||
// Get the max value should there be more than one
|
||||
String[] spl = perms.getPermission().split(Constants.PERMPREFIX + perm);
|
||||
if (spl.length > 1) {
|
||||
if (!NumberUtils.isDigits(spl[1])) {
|
||||
getPlugin().getLogger().severe("Player " + user.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
|
||||
} else {
|
||||
maxSize = Math.max(maxSize, Integer.valueOf(spl[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Do some sanity checking
|
||||
if (maxSize < 1) {
|
||||
maxSize = 1;
|
||||
}
|
||||
}
|
||||
return maxSize;
|
||||
return Util.getPermValue(user.getPlayer(), "island.range.", getSettings().getIslandProtectionRange());
|
||||
}
|
||||
}
|
||||
|
@ -134,10 +134,8 @@ public class FlatFileDatabaseConnecter implements DatabaseConnecter {
|
||||
Files.write(commentedFile.toPath(), (Iterable<String>)newFile.stream()::iterator);
|
||||
Files.move(commentedFile.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
plugin.getLogger().severe(() -> "Could not comment config file " + file.getName() + " " + e1.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
Loading…
Reference in New Issue
Block a user