Skip to content

Commit

Permalink
Implement ability to limit island biome change to be limited via prot…
Browse files Browse the repository at this point in the history
…ection range, instead of using whole island.

Comes from # 34.
Allows to block ability to change biome in between space.
  • Loading branch information
BuildTools committed Jun 20, 2019
1 parent 5fdadfe commit e548de0
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 6 deletions.
26 changes: 26 additions & 0 deletions src/main/java/world/bentobox/biomes/config/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ public int getLoreLineLength()
}


/**
* This method returns the useProtectionRange value
* @return the useProtectionRange value.
*/
public boolean isUseProtectionRange()
{
return this.useProtectionRange;
}


// ---------------------------------------------------------------------
// Section: Setters
// ---------------------------------------------------------------------
Expand Down Expand Up @@ -215,6 +225,16 @@ public void setLoreLineLength(int loreLineLength)
}


/**
* This method sets the useProtectionRange object value.
* @param useProtectionRange the useProtectionRange object new value.
*/
public void setUseProtectionRange(boolean useProtectionRange)
{
this.useProtectionRange = useProtectionRange;
}


// ---------------------------------------------------------------------
// Section: Enums used for Settings.
// ---------------------------------------------------------------------
Expand Down Expand Up @@ -325,6 +345,12 @@ public static VisibilityMode getMode(String parameter)
@ConfigEntry(path = "default-size")
private int defaultSize = 3;

@ConfigComment("")
@ConfigComment("This indicates if changing biome will affect whole island or just protection range.")
@ConfigComment("Allows to fix issues when biome is changed in space between islands.")
@ConfigEntry(path = "use-protection-range")
private boolean useProtectionRange = false;

@ConfigComment("")
@ConfigComment("This indicates if biome on island must be restored to default biome, if")
@ConfigComment("island changes owner and it does not have biome set ability.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void build()
panelBuilder.item(30, this.createButton(Button.LORE_LENGTH));

panelBuilder.item(23, this.createButton(Button.COOLDOWN));
panelBuilder.item(24, this.createButton(Button.PROTECTION_RANGE));
panelBuilder.item(25, this.createButton(Button.RESET));

panelBuilder.item(44, this.returnButton);
Expand Down Expand Up @@ -345,6 +346,29 @@ else if (this.settings.getVisibilityMode().equals(Settings.VisibilityMode.ACCESS
glow = this.settings.isResetBiomes();
break;
}
case PROTECTION_RANGE:
{
description = new ArrayList<>(2);
description.add(this.user.getTranslation("biomes.gui.descriptions.admin.use-protection-range"));
description.add(this.user.getTranslation("biomes.gui.descriptions.current-value",
"[value]",
this.settings.isUseProtectionRange() ?
this.user.getTranslation("biomes.gui.descriptions.enabled") :
this.user.getTranslation("biomes.gui.descriptions.disabled")));
name = this.user.getTranslation("biomes.gui.buttons.admin.use-protection-range");
icon = new ItemStack(Material.FILLED_MAP);

clickHandler = (panel, user1, clickType, i) -> {
this.settings.setUseProtectionRange(
!this.settings.isUseProtectionRange());

panel.getInventory().setItem(i, this.createButton(button).getItem());
return true;
};

glow = this.settings.isUseProtectionRange();
break;
}
default:
{
return new PanelItemBuilder().build();
Expand Down Expand Up @@ -429,6 +453,7 @@ private enum Button
LORE_LENGTH,
LORE_MESSAGE,
COOLDOWN,
PROTECTION_RANGE,
RESET
}

Expand Down
22 changes: 16 additions & 6 deletions src/main/java/world/bentobox/biomes/tasks/BiomeUpdateHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,25 @@ public void updateIslandBiome()
if (this.worldProtectionFlag)
{
Island island = this.addon.getIslands().getIsland(this.world, this.targetUser);
int range = island.getRange();

minX = island.getMinX();
minZ = island.getMinZ();
// This is implemented to fix issue when biome is changed in space between islands. #34

// That's how it is in Island#inIslandSpace
if (this.addon.getSettings().isUseProtectionRange())
{
minX = island.getMinProtectedX();
minZ = island.getMinProtectedZ();

maxX = island.getMaxProtectedX() - 1;
maxZ = island.getMaxProtectedZ() - 1;
}
else
{
minX = island.getMinX();
minZ = island.getMinZ();

maxX = island.getMinX() + range * 2 - 1;
maxZ = island.getMinZ() + range * 2 - 1;
maxX = island.getMaxX() - 1;
maxZ = island.getMaxZ() - 1;
}
}
else
{
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ default-mode: ISLAND
# then update algorithm will use this value as update range.
default-size: 3
#
# This indicates if changing biome will affect whole island or just protection range.
# Allows to fix issues when biome is changed in space between islands.
use-protection-range: false
#
# This indicates if biome on island must be restored to default biome, if
# island changes owner and it does not have biome set ability.
# 'true' means that biome will be reset.
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ biomes:
biomes-lore: "Biome Lore"
cooldown: "Cooldown"
reset-biomes: "Reset Event"
use-protection-range: "Use Protection Range"

toggle-user-list: "Toggle Player List"

Expand Down Expand Up @@ -101,6 +102,7 @@ biomes:
biomes-lore: "Allows to modify which elements in lore message will be displayed.|Check config for more infromation."
cooldown: "Allows to change cooldown in seconds between player can change biome again."
reset-biomes: "Allows to enable/disable biomes resetting if player with biome permission leave island."
use-protection-range: "Allows to enable/disable biome update to be limited by island protection range. If this is disabled, then it will use whole island range."

toggle-user-list: "Allows to switch which players should be displayed in current Menu."

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/locales/lv-LV.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ biomes:
biomes-lore: "Biomu Apraksts"
cooldown: "Atlikšanas Laiks"
reset-biomes: "Noņemt Biomus"
use-protection-range: "Aizsardzības Distance"

toggle-user-list: "Pārslēgs Sarakstu"

Expand Down Expand Up @@ -101,6 +102,7 @@ biomes:
biomes-lore: "Ļauj mainīt kādus elementus bioma aprakstā rādīs.|Skatīt konfigurācijas failu, lai redzētu aprakstu."
cooldown: "Ļauj mainīt cik ilgi spēlētājam jāgaida pirms tiek ļauts nomainīt biomu vēlreiz."
reset-biomes: "Ļauj ieslēgt/izslēgt biomu noņemšanu, ja spēlētājs, kam bija bioma atļauja pamet salu, un pārējiem spēlētājiem nav atļauja lietot šo biomu."
use-protection-range: "Ļauj ieslēgt/izslēgt bioma mainīšanas distances ierobežojumu uz aizsardzības distanci. Ļauj ierobežot bioma mainīšanu starpsalu reģionā."

toggle-user-list: "Ļauj pārslēgt spēlētāja sarakstus."

Expand Down

0 comments on commit e548de0

Please sign in to comment.