Skip to content

Commit 9496337

Browse files
committed
3.15.2 Update Towny
1 parent ed93790 commit 9496337

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pitest {
1313
}
1414

1515
group 'sh.okx'
16-
version '3.15.1'
16+
version '3.15.2'
1717

1818
java {
1919
sourceCompatibility = JavaVersion.VERSION_1_8
@@ -73,8 +73,8 @@ dependencies {
7373

7474
compileOnly 'net.luckperms:api:5.4'
7575

76-
compileOnly 'com.github.LlmDl:Towny:25fc18a'
77-
testImplementation 'com.github.LlmDl:Towny:25fc18a'
76+
compileOnly 'com.github.TownyAdvanced.Towny:towny:d71ad25'
77+
testImplementation 'com.github.TownyAdvanced.Towny:towny:d71ad25'
7878

7979
implementation('io.pebbletemplates:pebble:3.1.5') {
8080
exclude group: 'org.slf4j'
Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package sh.okx.rankup.requirements.requirement.towny;
22

3+
import com.palmergames.bukkit.towny.TownyUniverse;
34
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
45
import com.palmergames.bukkit.towny.object.Nation;
56
import com.palmergames.bukkit.towny.object.Resident;
67
import com.palmergames.bukkit.towny.object.Town;
7-
import com.palmergames.bukkit.towny.object.TownyUniverse;
88
import org.bukkit.entity.Player;
99

1010
public class TownyUtils {
@@ -19,53 +19,49 @@ public static TownyUtils getInstance() {
1919

2020
public boolean isResident(Player player) {
2121
try {
22-
Town town = TownyUniverse.getDataSource().getResident(player.getName()).getTown();
22+
Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
23+
if (resident == null) {
24+
return false;
25+
}
26+
Town town = resident.getTown();
2327

2428
return town != null;
2529
} catch (NotRegisteredException e) {
2630
return false;
2731
}
2832
}
2933

30-
public Resident getResident(Player player) {
31-
try {
32-
return TownyUniverse.getDataSource().getResident(player.getName());
33-
} catch (NotRegisteredException e) {
34-
return null;
35-
}
36-
}
37-
3834
public Town getTown(Player player) {
39-
try {
40-
return TownyUniverse.getDataSource().getResident(player.getName()).getTown();
41-
} catch (NotRegisteredException e) {
35+
Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
36+
if (resident == null) {
4237
return null;
4338
}
39+
return resident.getTownOrNull();
4440
}
4541

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

4945
try {
50-
return getTown(player) == null ? null : town.getNation();
46+
return town == null ? null : town.getNation();
5147
} catch (NotRegisteredException e) {
5248
return null;
5349
}
5450
}
5551

5652
public boolean isMayor(Player player) {
57-
try {
58-
return TownyUniverse.getDataSource().getResident(player.getName()).isMayor();
59-
} catch (NotRegisteredException e) {
53+
Resident resident = TownyUniverse.getInstance().getResident(player.getName());
54+
if (resident == null) {
6055
return false;
6156
}
57+
return resident.isMayor();
6258
}
6359

6460
public boolean isKing(Player player) {
65-
try {
66-
return TownyUniverse.getDataSource().getResident(player.getName()).isKing();
67-
} catch (NotRegisteredException e) {
61+
Resident resident = TownyUniverse.getInstance().getResident(player.getName());
62+
if (resident == null) {
6863
return false;
6964
}
65+
return resident.isKing();
7066
}
7167
}

0 commit comments

Comments
 (0)