mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-01 14:38:55 +00:00
refactor: rename main package
This commit is contained in:
87 files changed
No files matched your search
@@ -0,0 +1,40 @@
|
||||
package com.github.alathra.alathranwars.data;
|
||||
|
||||
import com.github.alathra.alathranwars.AlathranWars;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.palmergames.bukkit.towny.object.metadata.LocationDataField;
|
||||
import com.palmergames.bukkit.towny.utils.MetaDataUtil;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class TownMetaController {
|
||||
private AlathranWars plugin;
|
||||
private static LocationDataField defendersSpawn = new LocationDataField("alathranwars_defendersSpawn");
|
||||
|
||||
TownMetaController(AlathranWars plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static boolean hasDefendersSpawn(Town town) {
|
||||
return town.hasMeta(defendersSpawn.getKey());
|
||||
}
|
||||
|
||||
public static Location getDefendersSpawn(Town town) {
|
||||
if (hasDefendersSpawn(town)) {
|
||||
return MetaDataUtil.getLocation(town, defendersSpawn);
|
||||
} else {
|
||||
Location location = town.getSpawnOrNull();
|
||||
|
||||
setDefendersSpawn(town, location);
|
||||
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setDefendersSpawn(Town town, Location location) {
|
||||
if (hasDefendersSpawn(town)) {
|
||||
MetaDataUtil.setLocation(town, defendersSpawn, location, true);
|
||||
} else {
|
||||
town.addMetaData(new LocationDataField(defendersSpawn.getKey(), location));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user