Skip to content

Commit

Permalink
3.15.2 Update Towny
Browse files Browse the repository at this point in the history
  • Loading branch information
okx-code committed Mar 5, 2025
1 parent ed93790 commit 9496337
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pitest {
}

group 'sh.okx'
version '3.15.1'
version '3.15.2'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -73,8 +73,8 @@ dependencies {

compileOnly 'net.luckperms:api:5.4'

compileOnly 'com.github.LlmDl:Towny:25fc18a'
testImplementation 'com.github.LlmDl:Towny:25fc18a'
compileOnly 'com.github.TownyAdvanced.Towny:towny:d71ad25'
testImplementation 'com.github.TownyAdvanced.Towny:towny:d71ad25'

implementation('io.pebbletemplates:pebble:3.1.5') {
exclude group: 'org.slf4j'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package sh.okx.rankup.requirements.requirement.towny;

import com.palmergames.bukkit.towny.TownyUniverse;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.object.Nation;
import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import org.bukkit.entity.Player;

public class TownyUtils {
Expand All @@ -19,53 +19,49 @@ public static TownyUtils getInstance() {

public boolean isResident(Player player) {
try {
Town town = TownyUniverse.getDataSource().getResident(player.getName()).getTown();
Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
if (resident == null) {
return false;
}
Town town = resident.getTown();

return town != null;
} catch (NotRegisteredException e) {
return false;
}
}

public Resident getResident(Player player) {
try {
return TownyUniverse.getDataSource().getResident(player.getName());
} catch (NotRegisteredException e) {
return null;
}
}

public Town getTown(Player player) {
try {
return TownyUniverse.getDataSource().getResident(player.getName()).getTown();
} catch (NotRegisteredException e) {
Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
if (resident == null) {
return null;
}
return resident.getTownOrNull();
}

public Nation getNation(Player player) {
Town town = getTown(player);

try {
return getTown(player) == null ? null : town.getNation();
return town == null ? null : town.getNation();
} catch (NotRegisteredException e) {
return null;
}
}

public boolean isMayor(Player player) {
try {
return TownyUniverse.getDataSource().getResident(player.getName()).isMayor();
} catch (NotRegisteredException e) {
Resident resident = TownyUniverse.getInstance().getResident(player.getName());
if (resident == null) {
return false;
}
return resident.isMayor();
}

public boolean isKing(Player player) {
try {
return TownyUniverse.getDataSource().getResident(player.getName()).isKing();
} catch (NotRegisteredException e) {
Resident resident = TownyUniverse.getInstance().getResident(player.getName());
if (resident == null) {
return false;
}
return resident.isKing();
}
}

0 comments on commit 9496337

Please sign in to comment.