Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.24.0 #2152

Merged
merged 47 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5f6b91b
Version 1.23.3
tastybento May 28, 2023
7bb1907
Version 1.24.0
tastybento Jun 7, 2023
e4a3891
Add new IslandNameEvent and test class for command
tastybento Jun 7, 2023
38ddeff
Merge pull request #2133 from BentoBoxWorld/2132_IslandNameEvent
tastybento Jun 7, 2023
6932ce3
Added support for 1.20
tastybento Jun 10, 2023
d25d171
Adds protection for sign editing for 1.20
tastybento Jun 10, 2023
2672ee5
Handle Boats and other Materials for 1.20. Uses Tags a lot.
tastybento Jun 11, 2023
c000da6
Update GitHub actions to NodeJS 16
ThexXTURBOXx Jun 11, 2023
b64015e
Update ServerCompatibility.java
tastybento Jun 16, 2023
5a52978
Add perms test for admin teleport command
tastybento Jun 18, 2023
e9067cf
Add bbox admin perms command and adjust perms for commands
tastybento Jun 18, 2023
b512975
Updated BentoBox perms in plugin.yml to add perm command
tastybento Jun 18, 2023
09c60f2
Add IslandInfoEvent to allow addons to add to the island info command
tastybento Jun 19, 2023
a90a00b
Fix new permission tests
tastybento Jun 19, 2023
5c2166f
Add some NPE protection for variable substitutions
tastybento Jun 19, 2023
c0beba7
Formatting
tastybento Jun 19, 2023
393a013
Improved IslandInfoEvent to include the calling addon.
tastybento Jun 19, 2023
372f3f1
Rename getter to be more generic
tastybento Jun 19, 2023
c6a8f7c
Add API to enable gamemodes to register ownership over additional worlds
tastybento Jun 21, 2023
d6d86d3
Merge pull request #2143 from BentoBoxWorld/register_other_worlds
tastybento Jun 21, 2023
bcb4ed2
Fixes #2142 (#2144)
tastybento Jun 21, 2023
4d29506
Fix onlyConsole usage and added test class
tastybento Jun 24, 2023
0856d48
Proactively clear Users before tests just in case.
tastybento Jun 24, 2023
a7ffb79
Merge branch 'develop' into bbox_perms_command
tastybento Jun 24, 2023
2805e58
Merge pull request #2141 from BentoBoxWorld/bbox_perms_command
tastybento Jun 24, 2023
01313de
Merge pull request #2139 from ThexXTURBOXx/patch-1
tastybento Jun 24, 2023
b500636
If sign is waxed (not editable) then no check is required
tastybento Jun 24, 2023
89a9b13
Hidden commands can be seen by console, but are hidden from players
tastybento Jun 24, 2023
2b4e1dd
Update to 1.21.1 to get isWaxed API
tastybento Jun 24, 2023
2ed2492
Merge pull request #2146 from BentoBoxWorld/Ignore_waxed_signs
tastybento Jun 24, 2023
74e053e
Protect against brushing
tastybento Jun 24, 2023
1a416d9
Fixes #2137 adds calibrated sculk sensor and test class
tastybento Jun 24, 2023
4b0c5ec
Merge pull request #2147 from BentoBoxWorld/suspicious_brushing
tastybento Jun 24, 2023
66d27e7
Merge pull request #2148 from BentoBoxWorld/sculk_cal
tastybento Jun 24, 2023
0038c3f
Remove boolean return for listener. Check event cancelation instead.
tastybento Jun 24, 2023
4c0cb9f
Unregisters worlds with MV on shutdown.
tastybento Jun 27, 2023
e846d26
Fix test
tastybento Jun 29, 2023
cbed9ac
Merge pull request #2150 from BentoBoxWorld/mv_remove_on_disable
tastybento Jun 29, 2023
c28ecb1
Add null check. Not really needed but make Sonar happy.
tastybento Jun 30, 2023
9c6cc78
Adjust priority of PlayerInteraction event listener to NORMAL
tastybento Jul 1, 2023
f23ebec
Merge branch 'develop' of https://github.com/BentoBoxWorld/BentoBox.g…
tastybento Jul 1, 2023
7b8e18a
Adds Chiseled Bookshelf protection #2136
tastybento Jul 1, 2023
9bd0104
Put island deletion under one class manager
tastybento Jul 1, 2023
6d3349a
Merge pull request #2153 from BentoBoxWorld/delete_manager_refactor
tastybento Jul 1, 2023
f47e87a
Added test class for PanelItem
tastybento Jul 2, 2023
7d25aff
Added test class for DefaultPlayerCommand
tastybento Jul 2, 2023
9334858
Added IslandDeletehomeCommand test class
tastybento Jul 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'
- name: Cache SonarCloud packages
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand All @@ -38,7 +38,7 @@ jobs:
- run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install
- run: mkdir staging && cp target/*.jar staging
- name: Save artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Package
path: staging
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
<postgresql.version>42.2.18</postgresql.version>
<hikaricp.version>5.0.1</hikaricp.version>
<!-- More visible way to change dependency versions -->
<spigot.version>1.19.4-R0.1-SNAPSHOT</spigot.version>
<spigot.version>1.20.1-R0.1-SNAPSHOT</spigot.version>
<!-- Might differ from the last Spigot release for short periods
of time -->
<paper.version>1.19.3-R0.1-SNAPSHOT</paper.version>
<paper.version>1.20.1-R0.1-SNAPSHOT</paper.version>
<bstats.version>3.0.0</bstats.version>
<vault.version>1.7.1</vault.version>
<placeholderapi.version>2.10.9</placeholderapi.version>
Expand All @@ -88,7 +88,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.23.2</build.version>
<build.version>1.24.0</build.version>
<sonar.organization>bentobox-world</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<server.jars>${project.basedir}/lib</server.jars>
Expand Down
28 changes: 16 additions & 12 deletions src/main/java/world/bentobox/bentobox/BentoBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
Expand Down Expand Up @@ -36,7 +39,6 @@
import world.bentobox.bentobox.managers.CommandsManager;
import world.bentobox.bentobox.managers.FlagsManager;
import world.bentobox.bentobox.managers.HooksManager;
import world.bentobox.bentobox.managers.IslandChunkDeletionManager;
import world.bentobox.bentobox.managers.IslandDeletionManager;
import world.bentobox.bentobox.managers.IslandWorldManager;
import world.bentobox.bentobox.managers.IslandsManager;
Expand All @@ -52,7 +54,7 @@
* Main BentoBox class
* @author tastybento, Poslovitch
*/
public class BentoBox extends JavaPlugin {
public class BentoBox extends JavaPlugin implements Listener {

private static BentoBox instance;

Expand All @@ -71,7 +73,6 @@ public class BentoBox extends JavaPlugin {
private HooksManager hooksManager;
private PlaceholdersManager placeholdersManager;
private IslandDeletionManager islandDeletionManager;
private IslandChunkDeletionManager islandChunkDeletionManager;
private WebManager webManager;

// Settings
Expand Down Expand Up @@ -227,7 +228,7 @@ private void completeSetup(long loadTime) {
// Make sure all worlds are already registered to Multiverse.
hooksManager.registerHook(new MultiverseCoreHook());
hooksManager.registerHook(new MyWorldsHook());
islandWorldManager.registerWorldsToMultiverse();
islandWorldManager.registerWorldsToMultiverse(true);

// TODO: re-enable after implementation
//hooksManager.registerHook(new DynmapHook());
Expand Down Expand Up @@ -300,8 +301,9 @@ private void registerListeners() {
manager.registerEvents(new BannedCommands(this), this);
// Death counter
manager.registerEvents(new DeathListener(this), this);
// MV unregister
manager.registerEvents(this, this);
// Island Delete Manager
islandChunkDeletionManager = new IslandChunkDeletionManager(this);
islandDeletionManager = new IslandDeletionManager(this);
manager.registerEvents(islandDeletionManager, this);
}
Expand All @@ -321,6 +323,15 @@ public void onDisable() {
if (islandsManager != null) {
islandsManager.shutdown();
}

}

@EventHandler
public void onServerStop(ServerCommandEvent e) {
if (islandWorldManager != null && (e.getCommand().equalsIgnoreCase("stop") || e.getCommand().equalsIgnoreCase("restart"))) {
// Unregister any MV worlds if () {
islandWorldManager.registerWorldsToMultiverse(false);
}
}

/**
Expand Down Expand Up @@ -531,13 +542,6 @@ public IslandDeletionManager getIslandDeletionManager() {
return islandDeletionManager;
}

/**
* @return the islandChunkDeletionManager
*/
public IslandChunkDeletionManager getIslandChunkDeletionManager() {
return islandChunkDeletionManager;
}

/**
* @return an optional of the Bstats instance
* @since 1.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
*/
private boolean onlyPlayer = false;

/**
* True if the command is only for the console
* @since 1.24.0
*/
private boolean onlyConsole = false;


/**
* True if command is a configurable rank
*/
Expand Down Expand Up @@ -241,7 +248,6 @@ public boolean execute(@NonNull CommandSender sender, @NonNull String label, Str
CompositeCommand cmd = getCommandFromArgs(args);
String cmdLabel = (cmd.subCommandLevel > 0) ? args[cmd.subCommandLevel-1] : label;
List<String> cmdArgs = Arrays.asList(args).subList(cmd.subCommandLevel, args.length);
// Call
return cmd.call(user, cmdLabel, cmdArgs);
}

Expand All @@ -257,17 +263,21 @@ public boolean execute(@NonNull CommandSender sender, @NonNull String label, Str
*/
public boolean call(User user, String cmdLabel, List<String> cmdArgs) {
// Check for console and permissions
if (onlyPlayer && !user.isPlayer()) {
if (isOnlyPlayer() && !user.isPlayer()) {
user.sendMessage("general.errors.use-in-game");
return false;
}

if (isOnlyConsole() && user.isPlayer()) {
user.sendMessage("general.errors.use-in-console");
return false;
}

if (!this.runPermissionCheck(user))
{
// Error message is displayed by permission check.
return false;
}

// Set the user's addon context
user.setAddon(addon);
// Execute and trim args
Expand Down Expand Up @@ -513,6 +523,14 @@ public boolean isOnlyPlayer() {
return onlyPlayer;
}

/**
* Check if this command is only for consoles.
* @return true or false
*/
public boolean isOnlyConsole() {
return onlyConsole;
}

/**
* Sets whether this command should only be run by players.
* If this is set to {@code true}, this command will only be runnable by objects implementing {@link Player}.
Expand All @@ -525,6 +543,18 @@ public void setOnlyPlayer(boolean onlyPlayer) {
this.onlyPlayer = onlyPlayer;
}

/**
* Sets whether this command should only be run in the console.
* This is for commands that dump a lot of data or are for debugging.
* The default value provided when instantiating this CompositeCommand is {@code false}.
* Therefore, this method should only be used in case you want to explicitly edit the value.
* @param onlyConsole {@code true} if this command should only be run in the console.
* @since 1.24.0
*/
public void setOnlyConsole(boolean onlyConsole) {
this.onlyConsole = onlyConsole;
}

/**
* Sets locale reference to this command's description.
* It is used to display the help of this command.
Expand Down Expand Up @@ -623,16 +653,17 @@ public void inheritPermission() {
@Override
@NonNull
public List<String> tabComplete(final @NonNull CommandSender sender, final @NonNull String alias, final String[] args) {
List<String> options = new ArrayList<>();
// Get command object based on args entered so far
CompositeCommand command = getCommandFromArgs(args);
// Check for console and permissions
if (command.isOnlyPlayer() && !(sender instanceof Player)) {
return options;
if ((command.isOnlyPlayer() && !(sender instanceof Player))
|| (command.isOnlyConsole() && sender instanceof Player)) {
return List.of();
}
if (command.getPermission() != null && !command.getPermission().isEmpty() && !sender.hasPermission(command.getPermission()) && !sender.isOp()) {
return options;
return List.of();
}
List<String> options = new ArrayList<>();
// Add any tab completion from the subcommand
options.addAll(command.tabComplete(User.getInstance(sender), alias, new LinkedList<>(Arrays.asList(args))).orElseGet(ArrayList::new));
if (command.hasSubCommands()) {
Expand All @@ -654,17 +685,26 @@ public List<String> tabComplete(final @NonNull CommandSender sender, final @NonN
}

/**
* Returns a list containing all the labels of the subcommands for the provided CompositeCommand excluding any hidden commands
* Returns a list containing all the labels of the subcommands for the provided
* CompositeCommand excluding any hidden commands
* @param sender the CommandSender
* @param command the CompositeCommand to get the subcommands from
* @return a list of subcommands labels or an empty list.
*/
@NonNull
private List<String> getSubCommandLabels(@NonNull CommandSender sender, @NonNull CompositeCommand command) {
return command.getSubCommands().values().stream()
.filter(cmd -> !cmd.isHidden())
.filter(cmd -> !cmd.isOnlyPlayer() || sender.isOp() || (sender instanceof Player && cmd.getPermission() != null && (cmd.getPermission().isEmpty() || sender.hasPermission(cmd.getPermission()))) )
.map(CompositeCommand::getLabel).toList();
List<String> result = new ArrayList<>();
for (CompositeCommand cc: command.getSubCommands().values()) {
// Player or not
if (sender instanceof Player) {
if (!cc.isHidden() && !cc.isOnlyConsole() && (cc.getPermission().isEmpty() || sender.hasPermission(cc.getPermission()))) {
result.add(cc.getLabel());
}
} else if (!cc.isOnlyPlayer()) {
result.add(cc.getLabel());
}
}
return result;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public boolean execute(User user, String label, List<String> args) {
}
// If there are no args, then the player wants info on the island at this location
if (args.isEmpty()) {
getIslands().getIslandAt(user.getLocation()).ifPresentOrElse(i -> new IslandInfo(i).showAdminInfo(user), () ->
getIslands().getIslandAt(user.getLocation()).ifPresentOrElse(i -> new IslandInfo(i).showAdminInfo(user, getAddon()), () ->
user.sendMessage("commands.admin.info.no-island"));
return true;
}
Expand All @@ -48,7 +48,7 @@ public boolean execute(User user, String label, List<String> args) {
// Show info for this player
Island island = getIslands().getIsland(getWorld(), targetUUID);
if (island != null) {
new IslandInfo(island).showAdminInfo(user);
new IslandInfo(island).showAdminInfo(user, getAddon());
if (!getIslands().getQuarantinedIslandByUser(getWorld(), targetUUID).isEmpty()) {
user.sendMessage("commands.admin.info.islands-in-trash");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public AdminBlueprintCopyCommand(AdminBlueprintCommand parent)
@Override
public void setup()
{
inheritPermission();
setPermission("admin.blueprint.copy");
setParametersHelp("commands.admin.blueprint.copy.parameters");
setDescription("commands.admin.blueprint.copy.description");
}
Expand All @@ -37,7 +37,7 @@ public boolean execute(User user, String label, List<String> args)
AdminBlueprintCommand parent = (AdminBlueprintCommand) getParent();

BlueprintClipboard clipboard =
parent.getClipboards().computeIfAbsent(user.getUniqueId(), v -> new BlueprintClipboard());
parent.getClipboards().computeIfAbsent(user.getUniqueId(), v -> new BlueprintClipboard());

boolean copyAir = args.stream().anyMatch(key -> key.equalsIgnoreCase("air"));
boolean copyBiome = args.stream().anyMatch(key -> key.equalsIgnoreCase("biome"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public AdminBlueprintDeleteCommand(AdminBlueprintCommand parent)
@Override
public void setup()
{
this.inheritPermission();
setPermission("admin.blueprint.delete");
this.setParametersHelp("commands.admin.blueprint.delete.parameters");
this.setDescription("commands.admin.blueprint.delete.description");
}
Expand All @@ -47,10 +47,10 @@ public boolean execute(User user, String label, List<String> args)
if (this.getPlugin().getBlueprintsManager().getBlueprints(this.getAddon()).containsKey(blueprintName))
{
this.askConfirmation(user, user.getTranslation("commands.admin.blueprint.delete.confirmation"),
() -> {
this.getPlugin().getBlueprintsManager().deleteBlueprint(this.getAddon(), blueprintName);
user.sendMessage("commands.admin.blueprint.delete.success", TextVariables.NAME, blueprintName);
});
() -> {
this.getPlugin().getBlueprintsManager().deleteBlueprint(this.getAddon(), blueprintName);
user.sendMessage("commands.admin.blueprint.delete.success", TextVariables.NAME, blueprintName);
});
return true;
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public AdminBlueprintListCommand(AdminBlueprintCommand parent)
@Override
public void setup()
{
this.inheritPermission();
setPermission("admin.blueprint.list");
this.setDescription("commands.admin.blueprint.list.description");
}

Expand Down Expand Up @@ -54,8 +54,8 @@ public boolean execute(User user, String label, List<String> args)
FilenameFilter blueprintFilter = (File dir, String name) -> name.endsWith(BlueprintsManager.BLUEPRINT_SUFFIX);

List<String> blueprintList = Arrays.stream(Objects.requireNonNull(blueprints.list(blueprintFilter))).
map(name -> name.substring(0, name.length() - BlueprintsManager.BLUEPRINT_SUFFIX.length())).
toList();
map(name -> name.substring(0, name.length() - BlueprintsManager.BLUEPRINT_SUFFIX.length())).
toList();

if (blueprintList.isEmpty())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public AdminBlueprintLoadCommand(AdminBlueprintCommand parent) {

@Override
public void setup() {
inheritPermission();
setPermission("admin.blueprint.load");
setParametersHelp("commands.admin.blueprint.load.parameters");
setDescription("commands.admin.blueprint.load.description");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public AdminBlueprintOriginCommand(AdminBlueprintCommand parent) {

@Override
public void setup() {
inheritPermission();
setPermission("admin.blueprint.origin");
setParametersHelp("commands.admin.blueprint.origin.parameters");
setDescription("commands.admin.blueprint.origin.description");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public AdminBlueprintPasteCommand(AdminBlueprintCommand parent) {

@Override
public void setup() {
inheritPermission();
setPermission("admin.blueprint.paste");
setParametersHelp("commands.admin.blueprint.paste.parameters");
setDescription("commands.admin.blueprint.paste.description");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public AdminBlueprintPos1Command(AdminBlueprintCommand parent) {

@Override
public void setup() {
inheritPermission();
setPermission("admin.blueprint.pos1");
setParametersHelp("commands.admin.blueprint.pos1.parameters");
setDescription("commands.admin.blueprint.pos1.description");
}
Expand Down
Loading