Skip to content

Commit a7e1318

Browse files
authored
Merge pull request #316 from BentoBoxWorld/develop
Release 1.13.0
2 parents 3976383 + 86ae5d1 commit a7e1318

File tree

16 files changed

+627
-138
lines changed

16 files changed

+627
-138
lines changed

pom.xml

+3-10
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@
5858
<!-- Non-minecraft related dependencies -->
5959
<powermock.version>2.0.9</powermock.version>
6060
<!-- More visible way how to change dependency versions -->
61-
<spigot.version>1.19-R0.1-SNAPSHOT</spigot.version>
62-
<bentobox.version>1.21.0</bentobox.version>
61+
<spigot.version>1.19.4-R0.1-SNAPSHOT</spigot.version>
62+
<bentobox.version>1.22.0</bentobox.version>
6363
<level.version>2.6.2</level.version>
6464
<bank.version>1.3.0</bank.version>
6565
<!-- Revision variable removes warning about dynamic version -->
6666
<revision>${build.version}-SNAPSHOT</revision>
6767
<!-- Do not change unless you want different name for local builds. -->
6868
<build.number>-LOCAL</build.number>
6969
<!-- This allows to change between versions. -->
70-
<build.version>1.12.3</build.version>
70+
<build.version>1.13.0</build.version>
7171
<!-- SonarCloud -->
7272
<sonar.projectKey>BentoBoxWorld_AOneBlock</sonar.projectKey>
7373
<sonar.organization>bentobox-world</sonar.organization>
@@ -157,13 +157,6 @@
157157
<version>1.2.3-SNAPSHOT</version>
158158
<scope>compile</scope>
159159
</dependency>
160-
<!-- Holographic Displays API -->
161-
<dependency>
162-
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
163-
<artifactId>holographicdisplays-api</artifactId>
164-
<version>2.4.0</version>
165-
<scope>provided</scope>
166-
</dependency>
167160
<!-- Apache Commons Text -->
168161
<dependency>
169162
<groupId>org.apache.commons</groupId>

src/main/java/world/bentobox/aoneblock/AOneBlock.java

+8-38
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,15 @@
33
import java.io.IOException;
44
import java.util.Objects;
55

6-
import org.bukkit.Bukkit;
7-
import org.bukkit.ChatColor;
8-
import org.bukkit.Location;
96
import org.bukkit.World;
107
import org.bukkit.World.Environment;
11-
import org.bukkit.entity.SpawnCategory;
128
import org.bukkit.WorldCreator;
139
import org.bukkit.WorldType;
10+
import org.bukkit.entity.SpawnCategory;
1411
import org.bukkit.generator.ChunkGenerator;
1512
import org.eclipse.jdt.annotation.NonNull;
1613
import org.eclipse.jdt.annotation.Nullable;
1714

18-
import com.gmail.filoghost.holographicdisplays.api.Hologram;
19-
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
20-
2115
import world.bentobox.aoneblock.commands.admin.AdminCommand;
2216
import world.bentobox.aoneblock.commands.island.PlayerCommand;
2317
import world.bentobox.aoneblock.dataobjects.OneBlockIslands;
@@ -30,7 +24,6 @@
3024
import world.bentobox.aoneblock.oneblocks.OneBlocksManager;
3125
import world.bentobox.aoneblock.requests.IslandStatsHandler;
3226
import world.bentobox.aoneblock.requests.LocationStatsHandler;
33-
import world.bentobox.bentobox.BentoBox;
3427
import world.bentobox.bentobox.api.addons.GameModeAddon;
3528
import world.bentobox.bentobox.api.configuration.Config;
3629
import world.bentobox.bentobox.api.configuration.WorldSettings;
@@ -53,7 +46,6 @@ public class AOneBlock extends GameModeAddon {
5346
private BlockListener blockListener;
5447
private OneBlocksManager oneBlockManager;
5548
private PlaceholdersManager phManager;
56-
private boolean useHolographicDisplays;
5749
private HoloListener holoListener;
5850

5951
@Override
@@ -109,12 +101,9 @@ public void onEnable() {
109101
registerRequestHandler(new IslandStatsHandler(this));
110102
registerRequestHandler(new LocationStatsHandler(this));
111103

112-
// Decide if HolographicDisplays is Usable
113-
useHolographicDisplays = Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays");
114-
if (this.useHolographicDisplays) {
115-
holoListener = new HoloListener(this);
116-
registerListener(holoListener);
117-
}
104+
// Register Holograms
105+
holoListener = new HoloListener(this);
106+
registerListener(holoListener);
118107
}
119108

120109
private void registerPlaceholders() {
@@ -140,6 +129,9 @@ private void registerPlaceholders() {
140129
public void onDisable() {
141130
// save cache
142131
blockListener.saveCache();
132+
133+
// Clear holograms
134+
holoListener.clear();
143135
}
144136

145137
@Override
@@ -263,21 +255,7 @@ public void allLoaded() {
263255
this.saveWorldSettings();
264256

265257
// Manage Old Holograms
266-
if (useHolographicDisplays()) {
267-
getIslands().getIslands().stream()
268-
.filter(i -> this.inWorld(i.getWorld()))
269-
.forEach(island -> {
270-
OneBlockIslands oneBlockIsland = getOneBlocksIsland(island);
271-
String hololine = oneBlockIsland.getHologram();
272-
Location center = island.getCenter();
273-
if (!hololine.isEmpty()) {
274-
final Hologram hologram = HologramsAPI.createHologram(BentoBox.getInstance(), center.add(0.5, 2.6, 0.5));
275-
for (String line : hololine.split("\\n")) {
276-
hologram.appendTextLine(ChatColor.translateAlternateColorCodes('&', line));
277-
}
278-
}
279-
});
280-
}
258+
holoListener.setUp();
281259
}
282260

283261
/**
@@ -315,12 +293,4 @@ public PlaceholdersManager getPlaceholdersManager() {
315293
public HoloListener getHoloListener() {
316294
return holoListener;
317295
}
318-
319-
/**
320-
* @return whether to use Holographic Displays or Not
321-
*/
322-
public boolean useHolographicDisplays() {
323-
return useHolographicDisplays;
324-
}
325-
326296
}

src/main/java/world/bentobox/aoneblock/AOneBlockPladdon.java

-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
package world.bentobox.aoneblock;
22

3-
import org.bukkit.plugin.java.annotation.dependency.Dependency;
4-
import org.bukkit.plugin.java.annotation.plugin.ApiVersion;
5-
import org.bukkit.plugin.java.annotation.plugin.Plugin;
6-
73
import world.bentobox.bentobox.api.addons.Addon;
84
import world.bentobox.bentobox.api.addons.Pladdon;
95

10-
11-
@Plugin(name="Pladdon", version="1.0")
12-
@ApiVersion(ApiVersion.Target.v1_17)
13-
@Dependency(value = "BentoBox")
146
public class AOneBlockPladdon extends Pladdon {
157

168
@Override

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

+37
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ public class Settings implements WorldSettings {
7272
@ConfigEntry(path = "aoneblock.command.set-count-command", since = "1.10.0")
7373
private String setCountCommand = "setCount";
7474

75+
@ConfigComment("How long a player must wait until they can use the setCount command again. In minutes.")
76+
@ConfigComment("This is the command that is run from the phases panel.")
77+
@ConfigEntry(path = "aoneblock.command.set-count-cooldown", since = "1.13.0")
78+
private int setCountCooldown = 5;
79+
7580
@ConfigComment("The command label that allows to check if magic block is present and respawns it if not.")
7681
@ConfigComment("By default it is 'respawnBlock check'.")
7782
@ConfigEntry(path = "aoneblock.command.respawn-block-command", since = "1.10.0")
@@ -96,6 +101,10 @@ public class Settings implements WorldSettings {
96101
@ConfigComment("Other plugins may override this setting")
97102
@ConfigEntry(path = "world.difficulty")
98103
private Difficulty difficulty = Difficulty.NORMAL;
104+
105+
@ConfigComment("Display holograms")
106+
@ConfigEntry(path = "world.holograms")
107+
private boolean useHolograms = true;
99108

100109
@ConfigComment("Duration in seconds that phase holograms will exist after being displayed, if used.")
101110
@ConfigComment("If set to 0, then holograms will persist until cleared some other way.")
@@ -2004,4 +2013,32 @@ public int getHologramDuration() {
20042013
public void setHologramDuration(int hologramDuration) {
20052014
this.hologramDuration = hologramDuration;
20062015
}
2016+
2017+
/**
2018+
* @return the setCountCooldown
2019+
*/
2020+
public int getSetCountCooldown() {
2021+
return setCountCooldown;
2022+
}
2023+
2024+
/**
2025+
* @param setCountCooldown the setCountCooldown to set
2026+
*/
2027+
public void setSetCountCooldown(int setCountCooldown) {
2028+
this.setCountCooldown = setCountCooldown;
2029+
}
2030+
2031+
/**
2032+
* @return the useHolograms
2033+
*/
2034+
public boolean isUseHolograms() {
2035+
return useHolograms;
2036+
}
2037+
2038+
/**
2039+
* @param useHolograms the useHolograms to set
2040+
*/
2041+
public void setUseHolograms(boolean useHolograms) {
2042+
this.useHolograms = useHolograms;
2043+
}
20072044
}

src/main/java/world/bentobox/aoneblock/commands/island/IslandSetCountCommand.java

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package world.bentobox.aoneblock.commands.island;
22

33
import java.util.List;
4+
import java.util.Objects;
45

56
import org.eclipse.jdt.annotation.NonNull;
67

@@ -35,6 +36,16 @@ public void setup() {
3536
// Permission
3637
setPermission("island.setcount");
3738
addon = getAddon();
39+
setConfigurableRankCommand();
40+
}
41+
42+
@Override
43+
public boolean canExecute(User user, String label, List<String> args) {
44+
// Check cooldown
45+
if (addon.getSettings().getSetCountCooldown() > 0 && checkCooldown(user)) {
46+
return false;
47+
}
48+
return true;
3849
}
3950

4051
@Override
@@ -43,15 +54,16 @@ public boolean execute(User user, String label, List<String> args) {
4354
showHelp(this, user);
4455
return false;
4556
}
46-
// Get their island
47-
Island island = getIslands().getIsland(getWorld(), user);
48-
if (island == null) {
57+
// Player issuing the command must have an island or be in a team
58+
if (!getIslands().inTeam(getWorld(), user.getUniqueId()) && !getIslands().hasIsland(getWorld(), user.getUniqueId())) {
4959
user.sendMessage("general.errors.no-island");
5060
return false;
5161
}
52-
// Check ownership
53-
if (!getIslands().hasIsland(getWorld(), user)) {
54-
user.sendMessage("general.errors.not-owner");
62+
// Check rank to use command
63+
Island island = Objects.requireNonNull(getIslands().getIsland(getWorld(), user));
64+
int rank = island.getRank(user);
65+
if (rank < island.getRankCommand(getUsage())) {
66+
user.sendMessage("general.errors.insufficient-rank", TextVariables.RANK, user.getTranslation(getPlugin().getRanksManager().getRank(rank)));
5567
return false;
5668
}
5769
// Get value
@@ -72,6 +84,7 @@ public boolean execute(User user, String label, List<String> args) {
7284
i.setBlockNumber(count);
7385
i.clearQueue();
7486
user.sendMessage("aoneblock.commands.island.setcount.set", TextVariables.NUMBER, String.valueOf(i.getBlockNumber()));
87+
setCooldown(user.getUniqueId(), addon.getSettings().getSetCountCooldown() * 60);
7588
return true;
7689
}
7790

src/main/java/world/bentobox/aoneblock/listeners/BlockListener.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,7 @@ private void setUp(@NonNull Island island) {
332332
OneBlockIslands is = new OneBlockIslands(island.getUniqueId());
333333
cache.put(island.getUniqueId(), is);
334334
handler.saveObjectAsync(is);
335-
if (addon.useHolographicDisplays()) {
336-
addon.getHoloListener().setUp(island, is);
337-
}
335+
addon.getHoloListener().setUp(island, is, true);
338336
}
339337

340338

@@ -389,9 +387,7 @@ private void process(@NonNull Cancellable e, @NonNull Island i, @Nullable Player
389387
}
390388
}
391389
// Manage Holograms
392-
if (addon.useHolographicDisplays()) {
393-
addon.getHoloListener().process(i, is, phase);
394-
}
390+
addon.getHoloListener().process(i, is, phase);
395391
// Play warning sound for upcoming mobs
396392
if (addon.getSettings().getMobWarning() > 0) {
397393
playWarning(is, block);
@@ -505,7 +501,7 @@ private void playWarning(@NonNull OneBlockIslands is, @NonNull Block block) {
505501
* @param phase - current phase name
506502
* @return true if this is a new phase, false if not
507503
*/
508-
private boolean checkPhase(@Nullable Player player, @NonNull Island i, @NonNull OneBlockIslands is, @NonNull OneBlockPhase phase) {
504+
protected boolean checkPhase(@Nullable Player player, @NonNull Island i, @NonNull OneBlockIslands is, @NonNull OneBlockPhase phase) {
509505
// Handle NPCs
510506
User user;
511507
if (player == null || player.hasMetadata("NPC")) {
@@ -523,6 +519,12 @@ private boolean checkPhase(@Nullable Player player, @NonNull Island i, @NonNull
523519
Util.runCommands(user,
524520
replacePlaceholders(player, oldPhaseName, phase.getBlockNumber(), i, oldPhase.getEndCommands()),
525521
"Commands run for end of " + oldPhaseName);
522+
// If first time
523+
if (is.getBlockNumber() >= is.getLifetime()) {
524+
Util.runCommands(user,
525+
replacePlaceholders(player, oldPhaseName, phase.getBlockNumber(), i, oldPhase.getFirstTimeEndCommands()),
526+
"Commands run for first time completing " + oldPhaseName);
527+
}
526528
});
527529
// Set the phase name
528530
is.setPhaseName(phaseName);

0 commit comments

Comments
 (0)