Skip to content

Commit 280efbc

Browse files
authored
Merge pull request #2787 from BentoBoxWorld/static_code_analysis
Changes to improve code per IntelliJ
2 parents 3ba7856 + 94c4979 commit 280efbc

26 files changed

+79
-106
lines changed

build.gradle.kts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,15 @@ tasks.processResources {
283283
// This allows version info to be read at runtime by the plugin
284284
filesMatching(listOf("plugin.yml", "config.yml")) {
285285
filter { line ->
286-
line.replace("\${mysql.version}", mysqlVersion)
287-
.replace("\${mariadb.version}", mariadbVersion)
288-
.replace("\${postgresql.version}", postgresqlVersion)
289-
.replace("\${mongodb.version}", mongodbVersion)
290-
.replace("\${hikaricp.version}", hikaricpVersion)
291-
.replace("\${build.number}", finalBuildNumber)
292-
.replace("\${project.version}", project.version.toString())
293-
.replace("\${project.description}", project.description ?: "")
294-
.replace("\${revision}", project.version.toString())
286+
line.replace($$"${mysql.version}", mysqlVersion)
287+
.replace($$"${mariadb.version}", mariadbVersion)
288+
.replace($$"${postgresql.version}", postgresqlVersion)
289+
.replace($$"${mongodb.version}", mongodbVersion)
290+
.replace($$"${hikaricp.version}", hikaricpVersion)
291+
.replace($$"${build.number}", finalBuildNumber)
292+
.replace($$"${project.version}", project.version.toString())
293+
.replace($$"${project.description}", project.description ?: "")
294+
.replace($$"${revision}", project.version.toString())
295295
}
296296
}
297297

src/main/java/world/bentobox/bentobox/BStats.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private void registerPlayersPerServerChart() {
157157
int players = this.connectedPlayerSet.size();
158158
this.connectedPlayerSet.clear();
159159

160-
if (players <= 0) return "0";
160+
if (players == 0) return "0";
161161
else if (players <= 10) return "1-10";
162162
else if (players <= 30) return "11-30";
163163
else if (players <= 50) return "31-50";

src/main/java/world/bentobox/bentobox/BentoBox.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
import org.apache.commons.lang3.exception.ExceptionUtils;
1111
import org.bukkit.Bukkit;
12-
import org.bukkit.event.EventHandler;
1312
import org.bukkit.event.Listener;
14-
import org.bukkit.event.server.ServerCommandEvent;
1513
import org.bukkit.generator.ChunkGenerator;
1614
import org.bukkit.plugin.PluginManager;
1715
import org.bukkit.plugin.java.JavaPlugin;
@@ -151,7 +149,7 @@ public void onEnable(){
151149
saveConfig();
152150

153151
// Set up click timeout
154-
lastClick = new ExpiringMap<Pair<UUID, String>, Boolean>(getSettings().getClickCooldownMs(), TimeUnit.MILLISECONDS);
152+
lastClick = new ExpiringMap<>(getSettings().getClickCooldownMs(), TimeUnit.MILLISECONDS);
155153

156154
// Start Database managers
157155
playersManager = new PlayersManager(this);
@@ -376,18 +374,6 @@ public void onDisable() {
376374

377375
}
378376

379-
@EventHandler
380-
public void onServerStop(ServerCommandEvent e) {
381-
/* This is no longer needed as with https://github.com/Multiverse/Multiverse-Core/releases/tag/4.3.12 (or maybe earlier) the issue
382-
* is fixed where the generator was not remembered across reboots.
383-
*/
384-
/*
385-
if (islandWorldManager != null && (e.getCommand().equalsIgnoreCase("stop") || e.getCommand().equalsIgnoreCase("restart"))) {
386-
// Unregister any MV worlds if () {
387-
//islandWorldManager.registerWorldsToMultiverse(false);
388-
}*/
389-
}
390-
391377
/**
392378
* Returns the player manager
393379
* @return the player manager
@@ -675,11 +661,11 @@ public boolean isShutdown() {
675661
* @return false if they can click and the timeout is started, otherwise true.
676662
*/
677663
public boolean onTimeout(User user, Panel panel) {
678-
if (lastClick.containsKey(new Pair<UUID, String>(user.getUniqueId(), panel.getName()))) {
664+
if (lastClick.containsKey(new Pair<>(user.getUniqueId(), panel.getName()))) {
679665
user.notify("general.errors.slow-down");
680666
return true;
681667
}
682-
lastClick.put(new Pair<UUID, String>(user.getUniqueId(), panel.getName()), true);
668+
lastClick.put(new Pair<>(user.getUniqueId(), panel.getName()), true);
683669
return false;
684670
}
685671
}

src/main/java/world/bentobox/bentobox/api/addons/AddonClassLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* Each addon is loaded with its own {@link AddonClassLoader}, which allows for
3232
* class isolation and management. This loader also facilitates inter-addon
3333
* class sharing by coordinating with the {@link AddonsManager}.
34-
*
34+
* <p>
3535
* This approach is now rarely used as most addons are now Plugin-based and so are loaded by the server as plugins.
3636
*
3737
* @author tastybento, ComminQ

src/main/java/world/bentobox/bentobox/api/addons/package-info.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/**
22
* This package contains classes and interfaces related to BentoBox addons.
3-
*
3+
* <p>
44
* Addons are modular extensions that enhance BentoBox functionality. Game-specific
55
* addons (e.g., BSkyBlock, AcidIsland) as well as generic addons (e.g., Challenges, Warps)
66
* are supported by this system. Developers can create custom addons to introduce
77
* new features or gamemodes.
8-
*
8+
* <p>
99
* Since BentoBox was created, server tech has changed and code remapping is done and that
1010
* is usually only applied when a Plugin is loaded, so developers should use Pladdons
1111
* which are a wrapper for Addons in a Plugin.
12-
*
12+
* <p>
1313
* Key components:
1414
* - AddonLoader: Manages the lifecycle of addons.
1515
* - AddonConfig: Handles addon-specific configurations.

src/main/java/world/bentobox/bentobox/api/commands/island/IslandGoCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private boolean checkReserved(User user, List<Island> islands) {
154154

155155
@Override
156156
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
157-
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
157+
String lastArg = !args.isEmpty() ? args.getLast() : "";
158158

159159
return Optional.of(Util.tabLimit(new ArrayList<>(getNameIslandMap(user, getWorld()).keySet()), lastArg));
160160

src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamPromoteCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public boolean execute(User user, String label, List<String> args) {
141141
* - Must be at least member rank
142142
* For demotion:
143143
* - Decreases rank but not below member
144-
*
144+
* <p>
145145
* Fires IslandEvent.Reason.RANK_CHANGE on success
146146
*
147147
* @param user command issuer

src/main/java/world/bentobox/bentobox/api/commands/package-info.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* This package contains classes and handlers for BentoBox commands.
3-
*
3+
* <p>
44
* Commands allow players and administrators to interact with BentoBox, including
55
* managing islands, settings, and other in-game features. This package ensures
66
* smooth integration and execution of commands within the plugin.
@@ -15,7 +15,7 @@
1515
* their own custom help if required, but most of the time it is not.
1616
* </p>
1717
* @author tastybento
18-
*
18+
* <p>
1919
* Key features:
2020
* - Command registration and parsing.
2121
* - Support for custom addon-specific commands.

src/main/java/world/bentobox/bentobox/api/configuration/ConfigObject.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
*/
1111
public interface ConfigObject extends DataObject {
1212

13-
@Override
14-
default BentoBox getPlugin() {
15-
return BentoBox.getInstance();
16-
}
17-
1813
/**
1914
* @return the uniqueId
2015
*/

src/main/java/world/bentobox/bentobox/api/events/package-info.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
22
* This package defines events used within the BentoBox framework.
3-
*
3+
* <p>
44
* Events are triggered during key gameplay actions, such as island creation,
55
* deletion, or player interactions. Developers can use these events to customize
66
* behaviors or respond to actions in their addons.
7-
*
7+
* <p>
88
* Key features:
99
* - Custom event classes (e.g., IslandCreateEvent, PlayerJoinEvent).
1010
* - Integration with Bukkit's event system.

0 commit comments

Comments
 (0)