Skip to content

Commit dbdbab5

Browse files
authored
Merge pull request #2 from BentoBoxWorld/code_clean_up
Code clean up
2 parents ea24fc5 + e028e66 commit dbdbab5

17 files changed

+529
-540
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ Encourage players to join and grow your server with the Dynamic World Border opt
4141

4242
The main player command is `/strange` or `/st` and the admin command is `/stranger`
4343

44-
| Command | Description |
45-
| :--- | :--- |
46-
| `/st claim` | Creates a claim at your current location (if you have room). |
47-
| `/st info` | Shows information about the claim you are currently standing in. |
48-
| `/st settings` | Opens the GUI to manage claim permissions (e.g., visitor block break, chest access). |
49-
| `/st team` | Goes the Team GUI where you can invites players to become a member of your claim, which also increases the claim size. |
44+
| Command | Description |
45+
|:---------------|:-----------------------------------------------------------------------------------------------------------------------|
46+
| `/st claim` | Creates a claim at your current location (if you have room). |
47+
| `/st info` | Shows information about the claim you are currently standing in. |
48+
| `/st settings` | Opens the GUI to manage claim permissions (e.g., visitor block break, chest access). |
49+
| `/st team` | Goes the Team GUI where you can invites players to become a member of your claim, which also increases the claim size. |
5050

5151
## Use with Other Addons
5252

StrangerRealms.iml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module version="4">
3+
<component name="FacetManager">
4+
<facet type="minecraft" name="Minecraft">
5+
<configuration>
6+
<autoDetectTypes>
7+
<platformType>PAPER</platformType>
8+
</autoDetectTypes>
9+
<projectReimportVersion>1</projectReimportVersion>
10+
</configuration>
11+
</facet>
12+
</component>
13+
</module>

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@
174174
</dependencies>
175175

176176
<build>
177-
<!-- By default ${revision} is ${build.version}-SNAPSHOT -->
177+
<!-- By default, ${revision} is ${build.version}-SNAPSHOT -->
178178
<!-- If GIT_BRANCH variable is set to origin/master, then it will
179179
be only ${build.version}. -->
180180

181-
<!-- By default ${build.number} is -LOCAL. -->
181+
<!-- By default, ${build.number} is -LOCAL. -->
182182
<!-- If the BUILD_NUMBER variable is set, then it will be -b[number]. -->
183183
<!-- If GIT_BRANCH variable is set to origin/master, then it will
184184
be the empty string. -->

src/main/java/world/bentobox/stranger/Settings.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.bukkit.GameMode;
1313
import org.bukkit.entity.EntityType;
1414

15+
import org.jetbrains.annotations.NotNull;
1516
import world.bentobox.bentobox.BentoBox;
1617
import world.bentobox.bentobox.api.configuration.ConfigComment;
1718
import world.bentobox.bentobox.api.configuration.ConfigEntry;
@@ -771,18 +772,6 @@ public void setIslandProtectionRange(int islandProtectionRange) {
771772
this.islandDistance = islandProtectionRange;
772773
}
773774

774-
/**
775-
* @param islandStartX the islandStartX to set
776-
*/
777-
public void setIslandStartX(int islandStartX) {
778-
}
779-
780-
/**
781-
* @param islandStartZ the islandStartZ to set
782-
*/
783-
public void setIslandStartZ(int islandStartZ) {
784-
}
785-
786775
/**
787776
* @param maxIslands the maxIslands to set
788777
*/
@@ -970,7 +959,7 @@ public boolean isDeathsResetOnNewIsland() {
970959
* @return the onJoinCommands
971960
*/
972961
@Override
973-
public List<String> getOnJoinCommands() {
962+
public @NotNull List<String> getOnJoinCommands() {
974963
return onJoinCommands;
975964
}
976965

@@ -985,7 +974,7 @@ public void setOnJoinCommands(List<String> onJoinCommands) {
985974
* @return the onLeaveCommands
986975
*/
987976
@Override
988-
public List<String> getOnLeaveCommands() {
977+
public @NotNull List<String> getOnLeaveCommands() {
989978
return onLeaveCommands;
990979
}
991980

@@ -1000,7 +989,7 @@ public void setOnLeaveCommands(List<String> onLeaveCommands) {
1000989
* @return the onRespawnCommands
1001990
*/
1002991
@Override
1003-
public List<String> getOnRespawnCommands() {
992+
public @NotNull List<String> getOnRespawnCommands() {
1004993
return onRespawnCommands;
1005994
}
1006995

src/main/java/world/bentobox/stranger/ShowBarrier.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ public ShowBarrier(StrangerRealms addon) {
5252
/**
5353
* Show the barrier to the player on an island
5454
* @param player - player to show
55-
* @param island - island
5655
*/
5756
@Override
5857
public void showBorder(Player player) {
@@ -118,10 +117,10 @@ private void showWalls(Player player, Location loc, int xMin, int xMax, int zMin
118117

119118
/**
120119
* @param player player
121-
* @param i
122-
* @param j
123-
* @param k
124-
* @param max
120+
* @param i x coord
121+
* @param j y coord
122+
* @param k z coord
123+
* @param max whether the max border should be shown or not
125124
*/
126125
private void showPlayer(Player player, int i, int j, int k, boolean max) {
127126
// Get if on or in border
@@ -192,7 +191,7 @@ public void refreshView(User user) {
192191
this.showBorder(user.getPlayer());
193192
}
194193

195-
private class BarrierBlock {
194+
private static class BarrierBlock {
196195
Location l;
197196
BlockData oldBlockData;
198197
public BarrierBlock(Location l, BlockData oldBlockData) {

src/main/java/world/bentobox/stranger/ShowWorldBorder.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ public void showBorder(Player player) {
4343
double dist = addon.getBorderSize() / 2D;
4444
BoundingBox worldBB = BoundingBox.of(center.toVector(), dist, dist, dist);
4545
if (worldBB.contains(island.getBoundingBox())) {
46-
/*
47-
BentoBox.getInstance().logDebug("Claim is within the world barrier");
48-
BentoBox.getInstance().logDebug("world barrier bb = " + worldBB);
49-
BentoBox.getInstance().logDebug("Player location = " + player.getLocation());
50-
BentoBox.getInstance().logDebug("Player in world border? " + worldBB.contains(player.getLocation().toVector()));
51-
*/
5246
showWorldBarrier(player);
5347
return;
5448
}

src/main/java/world/bentobox/stranger/StrangerRealms.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class StrangerRealms extends GameModeAddon {
6262
private BorderShower borderShower;
6363
private final Set<BorderType> availableBorderTypes = EnumSet.of(BorderType.VANILLA, BorderType.BARRIER);
6464
private int borderSize;
65-
private @NotNull BukkitTask task;
65+
private BukkitTask task;
6666
private PlayerListener playerListener;
6767
private NetherChunkMaker netherChunkMaker;
6868

@@ -291,11 +291,9 @@ public double getBorderSize() {
291291
int newBorderSize = getSettings().isManualBorderSize() ? borderSize :
292292
Math.max(getSettings().getBarrierIncreaseBlocks(), (this.getSettings().getBarrierIncreaseBlocks() * Bukkit.getServer().getOnlinePlayers().size()));
293293
if (newBorderSize < borderSize) {
294-
if (task != null) {
295-
// End any current task to replace it
296-
task.cancel();
297-
}
298-
// Trigger gradual reduction of border
294+
// End any current task to replace it
295+
task.cancel();
296+
// Trigger gradual reduction of border
299297
task = Bukkit.getScheduler().runTaskTimer(getPlugin(), () -> {
300298
//BentoBox.getInstance().logDebug("Get border size = " + newBorderSize + " old = " + borderSize);
301299
if (borderSize > newBorderSize) {
@@ -325,9 +323,7 @@ public void setBorderSize(int borderSize) {
325323
* Cancels any active border reduction task
326324
*/
327325
public void cancelBorderTask() {
328-
if (this.task != null) {
329-
this.task.cancel();
330-
}
326+
this.task.cancel();
331327
}
332328

333329
/**

src/main/java/world/bentobox/stranger/commands/admin/WorldBorderCommand.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
public class WorldBorderCommand extends CompositeCommand {
1818

19-
private StrangerRealms addon;
19+
private final StrangerRealms addon;
2020
/**
2121
* Command to create a claim
2222
*
@@ -71,7 +71,7 @@ public boolean execute(User user, String label, List<String> args) {
7171
private boolean turnOn(User user) {
7272
addon.getSettings().setDisableWorldBorder(false);
7373
addon.saveWorldSettings();
74-
Bukkit.getServer().getOnlinePlayers().stream().forEach(addon.getBorderShower()::showBorder);
74+
Bukkit.getServer().getOnlinePlayers().forEach(addon.getBorderShower()::showBorder);
7575
user.sendMessage("general.success");
7676
return true;
7777
}
@@ -89,7 +89,7 @@ private boolean setAuto(User user) {
8989
// Turn on auto
9090
addon.getSettings().setManualBorderSize(false);
9191
addon.saveWorldSettings();
92-
Bukkit.getServer().getOnlinePlayers().stream().forEach(addon.getBorderShower()::showBorder);
92+
Bukkit.getServer().getOnlinePlayers().forEach(addon.getBorderShower()::showBorder);
9393
user.sendMessage("general.success");
9494
return true;
9595
}
@@ -117,7 +117,7 @@ private boolean setSize(User user, List<String> args) {
117117
addon.getSettings().setManualBorderSize(true);
118118
addon.saveWorldSettings();
119119
// Update all players
120-
Bukkit.getServer().getOnlinePlayers().stream().forEach(addon.getBorderShower()::showBorder);
120+
Bukkit.getServer().getOnlinePlayers().forEach(addon.getBorderShower()::showBorder);
121121
user.sendMessage("general.success");
122122
return true;
123123

src/main/java/world/bentobox/stranger/commands/player/ClaimCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
/**
1919
* Handles the claim creation command.
20-
* A lot of this code comes from the stock create command in BentoBox and it uses
20+
* A lot of this code comes from the stock create command in BentoBox, and it uses
2121
* locale from that too often. References to "island" can be read as "claim".
2222
* <p>
2323
* Features:

src/main/java/world/bentobox/stranger/commands/player/ClaimLocationStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
public class ClaimLocationStrategy implements NewIslandLocationStrategy {
1616

1717
protected final BentoBox plugin = BentoBox.getInstance();
18-
private StrangerRealms addon;
18+
private final StrangerRealms addon;
1919

2020
public ClaimLocationStrategy(StrangerRealms addon) {
2121
this.addon = addon;

0 commit comments

Comments
 (0)