Skip to content

Commit

Permalink
Merge pull request #383 from BentoBoxWorld/allow_team_member_islands
Browse files Browse the repository at this point in the history
Allow team member islands
  • Loading branch information
tastybento authored Apr 7, 2024
2 parents e18e7b9 + 91a2cc7 commit d1d0f2c
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.0.0-SNAPSHOT</bentobox.version>
<bentobox.version>2.3.0-SNAPSHOT</bentobox.version>
<level.version>2.6.2</level.version>
<bank.version>1.3.0</bank.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- 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.16.0</build.version>
<build.version>1.17.0</build.version>
<!-- SonarCloud -->
<sonar.projectKey>BentoBoxWorld_AOneBlock</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/world/bentobox/aoneblock/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ public class Settings implements WorldSettings {
@ConfigEntry(path = "world.holograms")
private boolean useHolograms = true;

@ConfigComment("Hologram position - the offset to the magic block where holograms will appear")
@ConfigEntry(path = "world.hologram-offset")
private String offset = "0.5, 1.1, 0.5";

@ConfigComment("Duration in seconds that phase holograms will exist after being displayed, if used.")
@ConfigComment("If set to 0, then holograms will persist until cleared some other way.")
@ConfigEntry(path = "world.hologram-duration")
Expand Down Expand Up @@ -192,6 +196,10 @@ public class Settings implements WorldSettings {
@ConfigEntry(path = "world.island-height")
private int islandHeight = 120;

@ConfigComment("Disallow team members from having their own islands.")
@ConfigEntry(path = "world.disallow-team-member-islands")
private boolean disallowTeamMemberIslands = false;

@ConfigComment("Use your own world generator for this world.")
@ConfigComment("In this case, the plugin will not generate anything.")
@ConfigComment("If used, you must specify the world name and generator in the bukkit.yml file.")
Expand Down Expand Up @@ -2176,4 +2184,33 @@ public String getClickType() {
public void setClickType(String clickType) {
this.clickType = clickType;
}

/**
* @return the disallowTeamMemberIslands
*/
@Override
public boolean isDisallowTeamMemberIslands() {
return disallowTeamMemberIslands;
}

/**
* @param disallowTeamMemberIslands the disallowTeamMemberIslands to set
*/
public void setDisallowTeamMemberIslands(boolean disallowTeamMemberIslands) {
this.disallowTeamMemberIslands = disallowTeamMemberIslands;
}

/**
* @return the offset
*/
public String getOffset() {
return offset;
}

/**
* @param offset the offset to set
*/
public void setOffset(String offset) {
this.offset = offset;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.NonNull;

import world.bentobox.aoneblock.AOneBlock;
Expand Down Expand Up @@ -50,7 +51,7 @@ private Optional<TextDisplay> getHologram(Island island) {
}

private TextDisplay createHologram(Island island) {
Location pos = island.getCenter().clone().add(0.5, 1.1, 0.5);
Location pos = island.getCenter().clone().add(parseVector(addon.getSettings().getOffset()));
World world = pos.getWorld();
assert world != null;

Expand All @@ -63,6 +64,25 @@ private TextDisplay createHologram(Island island) {
return newDisplay;
}

private static Vector parseVector(String str) {
if (str == null) {
return new Vector(0.5, 1.1, 0.5);
}
String[] parts = str.split(",");
if (parts.length != 3) {
return new Vector(0.5, 1.1, 0.5);
}

try {
double x = Double.parseDouble(parts[0].trim());
double y = Double.parseDouble(parts[1].trim());
double z = Double.parseDouble(parts[2].trim());
return new Vector(x, y, z);
} catch (NumberFormatException e) {
return new Vector(0.5, 1.1, 0.5);
}
}

private void clearIfInitialized(TextDisplay hologram) {
if (hologram.isValid()) {
hologram.remove();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/addon.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: AOneBlock
main: world.bentobox.aoneblock.AOneBlock
version: ${version}${build.number}
api-version: 1.24
api-version: 2.3.0
metrics: true
icon: "STONE"
repository: "BentoBoxWorld/AOneBlock"
Expand Down
10 changes: 7 additions & 3 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ world:
difficulty: NORMAL
# Display holograms
holograms: true
# Hologram position - the offset to the magic block where holograms will appear
hologram-offset: 0.5, 1.1, 0.5
# Duration in seconds that phase holograms will exist after being displayed, if used.
# If set to 0, then holograms will persist until cleared some other way.
hologram-duration: 10
Expand All @@ -65,10 +67,10 @@ world:
# Block identification appearance.
# Click type that will make particles appear. Options are:
# LEFT (default), RIGHT, or NONE
click-type: RIGHT
# Size of particles. Default is 0.7. Must be greater than 0.
click-type: LEFT
# Size of particles. Default is 0.5. Must be greater than 0.
particle-size: 0.5
# Density of particles - Value from 0.1 to 1. Default is 0.5. Smaller values are more dense, higher are less.
# Density of particles - Value from 0.1 to 1. Default is 0.65. Smaller values are more dense, higher are less.
particle-density: 0.65
# Color of particles
particle-color:
Expand Down Expand Up @@ -123,6 +125,8 @@ world:
# Island height - Lowest is 5.
# It is the y coordinate of the bedrock block in the schem.
island-height: 80
# Disallow team members from having their own islands.
disallow-team-member-islands: false
# Use your own world generator for this world.
# In this case, the plugin will not generate anything.
# If used, you must specify the world name and generator in the bukkit.yml file.
Expand Down

0 comments on commit d1d0f2c

Please sign in to comment.