Skip to content

Commit

Permalink
Merge pull request #204 from BentoBoxWorld/develop
Browse files Browse the repository at this point in the history
Release 1.25.0
  • Loading branch information
tastybento authored Oct 5, 2024
2 parents 88cc3be + 2bb48e0 commit e79eb8f
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 179 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>1.24.0</build.version>
<build.version>1.25.0</build.version>
<sonar.projectKey>BentoBoxWorld_Limits</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
Expand Down
32 changes: 25 additions & 7 deletions src/main/java/world/bentobox/limits/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

public class Settings {

enum GeneralGroup {
ANIMALS, MOBS
}

private final Map<GeneralGroup, Integer> general = new EnumMap<>(GeneralGroup.class);
private final Map<EntityType, Integer> limits = new EnumMap<>(EntityType.class);
private final Map<EntityType, List<EntityGroup>> groupLimits = new EnumMap<>(EntityType.class);
private final List<String> gameModes;
Expand Down Expand Up @@ -56,15 +61,21 @@ public Settings(Limits addon) {
ConfigurationSection el = addon.getConfig().getConfigurationSection("entitylimits");
if (el != null) {
for (String key : el.getKeys(false)) {
EntityType type = getType(key);
if (type != null) {
if (DISALLOWED.contains(type)) {
addon.logError("Entity type: " + key + " is not supported - skipping...");
if (key.equalsIgnoreCase("ANIMALS")) {
general.put(GeneralGroup.ANIMALS, el.getInt(key, 0));
} else if (key.equalsIgnoreCase("MOBS")) {
general.put(GeneralGroup.MOBS, el.getInt(key, 0));
} else {
EntityType type = getType(key);
if (type != null) {
if (DISALLOWED.contains(type)) {
addon.logError("Entity type: " + key + " is not supported - skipping...");
} else {
limits.put(type, el.getInt(key, 0));
}
} else {
limits.put(type, el.getInt(key, 0));
addon.logError("Unknown entity type: " + key + " - skipping...");
}
} else {
addon.logError("Unknown entity type: " + key + " - skipping...");
}
}
}
Expand Down Expand Up @@ -153,4 +164,11 @@ public List<String> getGameModes() {
public boolean isAsyncGolums() {
return asyncGolums;
}

/**
* @return the general coverage map
*/
public Map<GeneralGroup, Integer> getGeneral() {
return general;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package world.bentobox.limits.commands.player;

import java.util.List;
import java.util.Optional;

import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.limits.Limits;

/**
Expand Down Expand Up @@ -46,7 +48,22 @@ public boolean execute(User user, String label, List<String> args) {
showHelp(this, user);
return false;
} else {
new LimitPanel(addon).showLimits((GameModeAddon)getAddon(), user, user.getUniqueId());
// Report the limit for the island, which is governed by the owner of the island
Optional<Island> opIsland = getIslands().getIslandAt(user.getLocation());
if (opIsland.isEmpty()) {
user.sendMessage("general.errors.no-island");
return false;
}
Island island = opIsland.get();
if (!island.getWorld().equals(getWorld())) {
user.sendMessage("general.errors.wrong-world");
return false;
}
if (island.getOwner() == null) {
user.sendMessage("general.errors.no-owner");
return false;
}
new LimitPanel(addon).showLimits((GameModeAddon) getAddon(), user, island.getOwner());
return true;
}
}
Expand Down
Loading

0 comments on commit e79eb8f

Please sign in to comment.