Skip to content

Commit 14b10b4

Browse files
authored
Merge pull request #380 from BentoBoxWorld/develop
Release 1.16.0
2 parents 27a9bcb + e18e7b9 commit 14b10b4

File tree

13 files changed

+970
-107
lines changed

13 files changed

+970
-107
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
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.15.0</build.version>
70+
<build.version>1.16.0</build.version>
7171
<!-- SonarCloud -->
7272
<sonar.projectKey>BentoBoxWorld_AOneBlock</sonar.projectKey>
7373
<sonar.organization>bentobox-world</sonar.organization>

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

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Objects;
55

66
import org.bukkit.Bukkit;
7+
import org.bukkit.Material;
78
import org.bukkit.World;
89
import org.bukkit.World.Environment;
910
import org.bukkit.WorldCreator;
@@ -24,6 +25,7 @@
2425
import world.bentobox.aoneblock.listeners.ItemsAdderListener;
2526
import world.bentobox.aoneblock.listeners.JoinLeaveListener;
2627
import world.bentobox.aoneblock.listeners.NoBlockHandler;
28+
import world.bentobox.aoneblock.listeners.StartSafetyListener;
2729
import world.bentobox.aoneblock.oneblocks.OneBlockCustomBlockCreator;
2830
import world.bentobox.aoneblock.oneblocks.OneBlocksManager;
2931
import world.bentobox.aoneblock.oneblocks.customblock.ItemsAdderCustomBlock;
@@ -32,6 +34,9 @@
3234
import world.bentobox.bentobox.api.addons.GameModeAddon;
3335
import world.bentobox.bentobox.api.configuration.Config;
3436
import world.bentobox.bentobox.api.configuration.WorldSettings;
37+
import world.bentobox.bentobox.api.flags.Flag;
38+
import world.bentobox.bentobox.api.flags.Flag.Mode;
39+
import world.bentobox.bentobox.api.flags.Flag.Type;
3540
import world.bentobox.bentobox.database.objects.Island;
3641

3742
/**
@@ -51,8 +56,16 @@ public class AOneBlock extends GameModeAddon {
5156
private final Config<Settings> configObject = new Config<>(this, Settings.class);
5257
private BlockListener blockListener;
5358
private OneBlocksManager oneBlockManager;
54-
private PlaceholdersManager phManager;
59+
private AOneBlockPlaceholders phManager;
5560
private HoloListener holoListener;
61+
62+
// Flag
63+
public final Flag START_SAFETY = new Flag.Builder("START_SAFETY", Material.BAMBOO_BLOCK)
64+
.mode(Mode.BASIC)
65+
.type(Type.WORLD_SETTING)
66+
.listener(new StartSafetyListener(this))
67+
.defaultSetting(false)
68+
.build();
5669

5770
@Override
5871
public void onLoad() {
@@ -73,10 +86,13 @@ public void onLoad() {
7386
// Register commands
7487
playerCommand = new PlayerCommand(this);
7588
adminCommand = new AdminCommand(this);
89+
// Register flag with BentoBox
90+
// Register protection flag with BentoBox
91+
getPlugin().getFlagsManager().registerFlag(this, START_SAFETY);
7692
}
7793
}
7894

79-
private boolean loadSettings() {
95+
private boolean loadSettings() {
8096
// Load settings again to get worlds
8197
settings = configObject.loadConfigObject();
8298
if (settings == null) {
@@ -105,7 +121,7 @@ public void onEnable() {
105121
registerListener(new JoinLeaveListener(this));
106122
registerListener(new InfoListener(this));
107123
// Register placeholders
108-
registerPlaceholders();
124+
phManager = new AOneBlockPlaceholders(this, getPlugin().getPlaceholdersManager());
109125

110126
// Register request handlers
111127
registerRequestHandler(new IslandStatsHandler(this));
@@ -130,37 +146,6 @@ public boolean loadData() {
130146
return false;
131147
}
132148

133-
private void registerPlaceholders() {
134-
phManager = new PlaceholdersManager(this);
135-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_phase",
136-
phManager::getPhaseByLocation);
137-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_count",
138-
phManager::getCountByLocation);
139-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "my_island_phase", phManager::getPhase);
140-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "my_island_count", phManager::getCount);
141-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_next_phase",
142-
phManager::getNextPhaseByLocation);
143-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "my_island_next_phase", phManager::getNextPhase);
144-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "my_island_blocks_for_phase",
145-
phManager::getPhaseBlocks);
146-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "my_island_blocks_to_next_phase",
147-
phManager::getNextPhaseBlocks);
148-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_blocks_to_next_phase",
149-
phManager::getNextPhaseBlocksByLocation);
150-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "my_island_percent_done",
151-
phManager::getPercentDone);
152-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_percent_done",
153-
phManager::getPercentDoneByLocation);
154-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "my_island_done_scale", phManager::getDoneScale);
155-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_done_scale",
156-
phManager::getDoneScaleByLocation);
157-
// Since 1.10
158-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_lifetime_count",
159-
phManager::getLifetimeByLocation);
160-
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "my_island_lifetime_count",
161-
phManager::getLifetime);
162-
}
163-
164149
@Override
165150
public void onDisable() {
166151
// save cache
@@ -319,7 +304,7 @@ public BlockListener getBlockListener() {
319304
*
320305
* @return the phManager
321306
*/
322-
public PlaceholdersManager getPlaceholdersManager() {
307+
public AOneBlockPlaceholders getPlaceholdersManager() {
323308
return phManager;
324309
}
325310

@@ -336,4 +321,18 @@ public HoloListener getHoloListener() {
336321
public boolean hasItemsAdder() {
337322
return hasItemsAdder;
338323
}
324+
325+
/**
326+
* Set the addon's world. Used only for testing.
327+
* @param world world
328+
*/
329+
public void setIslandWorld(World world) {
330+
this.islandWorld = world;
331+
332+
}
333+
334+
public void setSettings(Settings settings) {
335+
this.settings = settings;
336+
}
337+
339338
}

src/main/java/world/bentobox/aoneblock/PlaceholdersManager.java renamed to src/main/java/world/bentobox/aoneblock/AOneBlockPlaceholders.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import world.bentobox.bentobox.api.user.User;
88
import world.bentobox.bentobox.database.objects.Island;
99

10-
public class PlaceholdersManager {
10+
public class AOneBlockPlaceholders {
1111

1212
private static final TreeMap<Double, String> SCALE;
1313
private static final String INFINITE = "aoneblock.placeholders.infinite";
@@ -26,8 +26,26 @@ public class PlaceholdersManager {
2626

2727
private final AOneBlock addon;
2828

29-
public PlaceholdersManager(AOneBlock addon) {
29+
public AOneBlockPlaceholders(AOneBlock addon,
30+
world.bentobox.bentobox.managers.PlaceholdersManager placeholdersManager) {
3031
this.addon = addon;
32+
placeholdersManager.registerPlaceholder(addon, "visited_island_phase", this::getPhaseByLocation);
33+
placeholdersManager.registerPlaceholder(addon, "visited_island_count", this::getCountByLocation);
34+
placeholdersManager.registerPlaceholder(addon, "my_island_phase", this::getPhase);
35+
placeholdersManager.registerPlaceholder(addon, "my_island_count", this::getCount);
36+
placeholdersManager.registerPlaceholder(addon, "visited_island_next_phase", this::getNextPhaseByLocation);
37+
placeholdersManager.registerPlaceholder(addon, "my_island_next_phase", this::getNextPhase);
38+
placeholdersManager.registerPlaceholder(addon, "my_island_blocks_for_phase", this::getPhaseBlocks);
39+
placeholdersManager.registerPlaceholder(addon, "my_island_blocks_to_next_phase", this::getNextPhaseBlocks);
40+
placeholdersManager.registerPlaceholder(addon, "visited_island_blocks_to_next_phase",
41+
this::getNextPhaseBlocksByLocation);
42+
placeholdersManager.registerPlaceholder(addon, "my_island_percent_done", this::getPercentDone);
43+
placeholdersManager.registerPlaceholder(addon, "visited_island_percent_done", this::getPercentDoneByLocation);
44+
placeholdersManager.registerPlaceholder(addon, "my_island_done_scale", this::getDoneScale);
45+
placeholdersManager.registerPlaceholder(addon, "visited_island_done_scale", this::getDoneScaleByLocation);
46+
// Since 1.10
47+
placeholdersManager.registerPlaceholder(addon, "visited_island_lifetime_count", this::getLifetimeByLocation);
48+
placeholdersManager.registerPlaceholder(addon, "my_island_lifetime_count", this::getLifetime);
3149
}
3250

3351
/**

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

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.Map;
99
import java.util.Set;
1010

11+
import org.bukkit.Color;
1112
import org.bukkit.Difficulty;
1213
import org.bukkit.GameMode;
1314
import org.bukkit.block.Biome;
@@ -111,6 +112,28 @@ public class Settings implements WorldSettings {
111112
@ConfigEntry(path = "world.hologram-duration")
112113
private int hologramDuration = 10;
113114

115+
@ConfigComment("Duration in seconds that players cannot move when they start a new one block.")
116+
@ConfigComment("Used only if the Starting Safety world setting is active.")
117+
@ConfigEntry(path = "world.starting-safety-duration")
118+
private int startingSafetyDuration = 10;
119+
120+
@ConfigComment("Block identification appearance.")
121+
@ConfigComment("Click type that will make particles appear. Options are:")
122+
@ConfigComment("LEFT (default), RIGHT, or NONE")
123+
@ConfigEntry(path = "world.block-id.click-type")
124+
private String clickType = "LEFT";
125+
126+
@ConfigComment("Size of particles. Default is 0.5. Must be greater than 0.")
127+
@ConfigEntry(path = "world.block-id.particle-size")
128+
private Double particleSize = 0.5;
129+
@ConfigComment("Density of particles - Value from 0.1 to 1. Default is 0.65. Smaller values are more dense, higher are less.")
130+
@ConfigEntry(path = "world.block-id.particle-density")
131+
private Double particleDensity = 0.65D;
132+
@ConfigComment("Color of particles")
133+
@ConfigEntry(path = "world.block-id.particle-color")
134+
private Color particleColor = Color.GREEN;
135+
136+
114137
@ConfigComment("Clear blocks when spawning mobs.")
115138
@ConfigComment("Mobs break blocks when they spawn is to prevent players from building a box around the magic block,")
116139
@ConfigComment("having the mob spawn, and then die by suffocation, i.e., it's a cheat prevention.")
@@ -2061,4 +2084,96 @@ public boolean isClearBlocks() {
20612084
public void setClearBlocks(boolean clearBlocks) {
20622085
this.clearBlocks = clearBlocks;
20632086
}
2087+
2088+
/**
2089+
* @return the startingSafetyDuration
2090+
*/
2091+
public int getStartingSafetyDuration() {
2092+
return startingSafetyDuration;
2093+
}
2094+
2095+
/**
2096+
* @param startingSafetyDuration the startingSafetyDuration to set
2097+
*/
2098+
public void setStartingSafetyDuration(int startingSafetyDuration) {
2099+
this.startingSafetyDuration = startingSafetyDuration;
2100+
}
2101+
2102+
/**
2103+
* @return the particleSize
2104+
*/
2105+
public Double getParticleSize() {
2106+
if (particleSize == null) {
2107+
particleSize = 0.8;
2108+
}
2109+
if (particleSize < 0.0) {
2110+
particleSize = 0.0;
2111+
}
2112+
return particleSize;
2113+
}
2114+
2115+
2116+
/**
2117+
* @param particleSize the particleSize to set
2118+
*/
2119+
public void setParticleSize(Double particleSize) {
2120+
this.particleSize = particleSize;
2121+
}
2122+
2123+
/**
2124+
* @return the particleColor
2125+
*/
2126+
public Color getParticleColor() {
2127+
if (particleColor == null) {
2128+
particleColor = Color.GREEN;
2129+
}
2130+
return particleColor;
2131+
}
2132+
2133+
/**
2134+
* @param particleColor the particleColor to set
2135+
*/
2136+
public void setParticleColor(Color particleColor) {
2137+
this.particleColor = particleColor;
2138+
}
2139+
2140+
/**
2141+
* @return the particleDensity
2142+
*/
2143+
public Double getParticleDensity() {
2144+
if (particleDensity == null) {
2145+
particleDensity = 0.5;
2146+
}
2147+
if (particleDensity < 0.1D) {
2148+
particleDensity = 0.1D;
2149+
}
2150+
if (particleDensity > 1D) {
2151+
particleDensity = 1D;
2152+
}
2153+
return particleDensity;
2154+
}
2155+
2156+
/**
2157+
* @param particleDensity the particleDensity to set
2158+
*/
2159+
public void setParticleDensity(Double particleDensity) {
2160+
this.particleDensity = particleDensity;
2161+
}
2162+
2163+
/**
2164+
* @return the clickType
2165+
*/
2166+
public String getClickType() {
2167+
if (clickType == null || (!clickType.equalsIgnoreCase("LEFT") && !clickType.equalsIgnoreCase("RIGHT")
2168+
&& !clickType.equalsIgnoreCase("NONE"))) {
2169+
clickType = "LEFT";
2170+
}
2171+
return clickType;
2172+
}
2173+
/**
2174+
* @param clickType the clickType to set
2175+
*/
2176+
public void setClickType(String clickType) {
2177+
this.clickType = clickType;
2178+
}
20642179
}

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

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import java.util.List;
44

55
import org.bukkit.Bukkit;
6-
import org.bukkit.Color;
76
import org.bukkit.Material;
87
import org.bukkit.Particle;
98
import org.bukkit.event.block.BlockBreakEvent;
109
import org.bukkit.util.Vector;
1110

11+
import world.bentobox.aoneblock.listeners.BlockProtect;
1212
import world.bentobox.bentobox.api.commands.CompositeCommand;
1313
import world.bentobox.bentobox.api.user.User;
1414
import world.bentobox.bentobox.database.objects.Island;
@@ -20,6 +20,7 @@
2020
*/
2121
public class IslandRespawnBlockCommand extends CompositeCommand
2222
{
23+
2324
/**
2425
* Instantiates a new Island respawn block command.
2526
*
@@ -83,32 +84,14 @@ else if (Material.BEDROCK.equals(island.getCenter().getBlock().getType()) ||
8384
}
8485
else
8586
{
86-
// Spawn 6 particles where block is located.
87-
island.getWorld().spawnParticle(Particle.REDSTONE,
88-
island.getCenter().add(new Vector(0.5, 1.0, 0.5)),
89-
5, 0.1, 0, 0.1, 1,
90-
new Particle.DustOptions(Color.fromBGR(0, 100, 0), 1));
91-
island.getWorld().spawnParticle(Particle.REDSTONE,
92-
island.getCenter().add(new Vector(1.0, 0.5, 0.5)),
93-
5, 0.1, 0, 0.1, 1,
94-
new Particle.DustOptions(Color.fromBGR(0, 100, 0), 1));
95-
island.getWorld().spawnParticle(Particle.REDSTONE,
96-
island.getCenter().add(new Vector(0.5, 0.5, 1.0)),
97-
5, 0.1, 0, 0.1, 1,
98-
new Particle.DustOptions(Color.fromBGR(0, 100, 0), 1));
99-
island.getWorld().spawnParticle(Particle.REDSTONE,
100-
island.getCenter().add(new Vector(0.5, 0.0, 0.5)),
101-
5, 0.1, 0, 0.1, 1,
102-
new Particle.DustOptions(Color.fromBGR(0, 100, 0), 1));
103-
island.getWorld().spawnParticle(Particle.REDSTONE,
104-
island.getCenter().add(new Vector(0.0, 0.5, 0.5)),
105-
5, 0.1, 0, 0.1, 1,
106-
new Particle.DustOptions(Color.fromBGR(0, 100, 0), 1));
107-
island.getWorld().spawnParticle(Particle.REDSTONE,
108-
island.getCenter().add(new Vector(0.5, 0.5, 0.0)),
109-
5, 0.1, 0, 0.1, 1,
110-
new Particle.DustOptions(Color.fromBGR(0, 100, 0), 1));
111-
87+
for (double x = 0.0; x <= 1.0; x += 0.5) {
88+
for (double y = 0.0; y <= 1.0; y += 0.5) {
89+
for (double z = 0.0; z < 1.0; z += 0.5) {
90+
island.getWorld().spawnParticle(Particle.REDSTONE, island.getCenter().add(new Vector(x, y, z)),
91+
5, 0.1, 0, 0.1, 1, new Particle.DustOptions(BlockProtect.GREEN, 1));
92+
}
93+
}
94+
}
11295
user.sendMessage("aoneblock.commands.respawn-block.block-exist");
11396
}
11497

0 commit comments

Comments
 (0)