Skip to content

Commit

Permalink
1.0.1:
Browse files Browse the repository at this point in the history
  - Fix missing `/t set homeblock` test that allowed players to set
their spawn, bypassing the y level tests.
  - Fix lowest and highest test values being swapped.
  • Loading branch information
LlmDl committed May 7, 2024
1 parent 20868fe commit b510c7a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.townyadvanced</groupId>
<artifactId>TownySpawnPointLimits9000</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<name>townyspawnointlimits9000</name> <!-- Leave lower-cased -->

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.palmergames.bukkit.towny.event.CancellableTownyEvent;
import com.palmergames.bukkit.towny.event.TranslationLoadEvent;
import com.palmergames.bukkit.towny.event.nation.NationSetSpawnEvent;
import com.palmergames.bukkit.towny.event.town.TownPreSetHomeBlockEvent;
import com.palmergames.bukkit.towny.event.town.TownSetOutpostSpawnEvent;
import com.palmergames.bukkit.towny.event.town.TownSetSpawnEvent;
import com.palmergames.bukkit.towny.object.Translatable;
Expand All @@ -37,6 +38,13 @@ public void onTownyLoadLang(TranslationLoadEvent event) {
event.addTranslation(language, map.getKey(), map.getValue());
}

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTownSetHomeblock(TownPreSetHomeBlockEvent event) {
if (!Settings.isSpawnYLevelLimitingEnabled())
return;
testY(event, event.getPlayer(), event.getPlayer().getLocation().getY());
}

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTownSetSpawn(TownSetSpawnEvent event) {
if (!Settings.isSpawnYLevelLimitingEnabled())
Expand All @@ -59,9 +67,9 @@ public void onNationSetSpawn(NationSetSpawnEvent event) {
}

private void testY(CancellableTownyEvent event, Player player, double y) {
if (y <= Settings.getSpawningHighestYLevelAllowed())
if (y <= Settings.getSpawningLowestYLevelAllowed())
cancelEventTooLow(event, player);
else if (y >= Settings.getSpawningLowestYLevelAllowed())
else if (y >= Settings.getSpawningHighestYLevelAllowed())
cancelEventTooHigh(event, player);
}

Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
1.0.0:
1.0.0:
- Initial release.
1.0.1:
- Fix missing `/t set homeblock` test that allowed players to set their spawn, bypassing the y level tests.
- Fix lowest and highest test values being swapped.

0 comments on commit b510c7a

Please sign in to comment.