Some more encapsulation

This commit is contained in:
Daniil Z committed 2021-03-01 21:05:59 +03:00
1 parent afafcee2bb
commit 45f99cacf6
8 files changed
+33 -17

No files matched your search

@@ -136,12 +136,12 @@ public class SettingHandler {
plugin.saveConfig();
// Update the current spawn location
TeleportManager.spawnLocation = new TeleportationPoint(location, HuskHomes.getSettings().getServerID());
TeleportManager.setSpawnLocation(new TeleportationPoint(location, HuskHomes.getSettings().getServerID()));
}
// Update current spawn location from config
public static void fetchSpawnLocation() {
TeleportManager.spawnLocation = getSpawnLocation();
TeleportManager.setSpawnLocation(getSpawnLocation());
}
// Get spawn location from config
@@ -12,12 +12,13 @@ import org.bukkit.entity.Player;
import java.time.Instant;
import java.util.HashSet;
import java.util.Set;
public class TeleportManager {
public static HashSet<TimedTeleport> queuedTeleports = new HashSet<>();
private static Set<TimedTeleport> queuedTeleports = new HashSet<>();
public static TeleportationPoint spawnLocation = null;
private static TeleportationPoint spawnLocation;
public static void teleportPlayer(Player player, String targetPlayer) {
DataManager.setPlayerLastPosition(player, new TeleportationPoint(player.getLocation(), HuskHomes.getSettings().getServerID()));
@@ -54,7 +55,7 @@ public class TeleportManager {
return;
}
queuedTeleports.add(new TimedTeleport(player, targetPlayer));
getQueuedTeleports().add(new TimedTeleport(player, targetPlayer));
}
public static void queueTimedTeleport(Player player, TeleportationPoint point) {
@@ -63,7 +64,7 @@ public class TeleportManager {
return;
}
queuedTeleports.add(new TimedTeleport(player, point));
getQueuedTeleports().add(new TimedTeleport(player, point));
}
public static void queueRandomTeleport(Player player) {
@@ -99,7 +100,7 @@ public class TeleportManager {
return;
}
queuedTeleports.add(new TimedTeleport(player));
getQueuedTeleports().add(new TimedTeleport(player));
}
public static void teleportHere(Player requester, String targetPlayerName) {
@@ -146,4 +147,15 @@ public class TeleportManager {
}
}
public static Set<TimedTeleport> getQueuedTeleports() {
return queuedTeleports;
}
public static TeleportationPoint getSpawnLocation() {
return spawnLocation;
}
public static void setSpawnLocation(TeleportationPoint spawnLocation) {
TeleportManager.spawnLocation = spawnLocation;
}
}
@@ -166,8 +166,8 @@ public class TeleportRequestHandler {
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
// Update active timed teleports
if (!TeleportManager.queuedTeleports.isEmpty()) {
for (TimedTeleport timedTeleport : TeleportManager.queuedTeleports) {
if (!TeleportManager.getQueuedTeleports().isEmpty()) {
for (TimedTeleport timedTeleport : TeleportManager.getQueuedTeleports()) {
Player teleporter = Bukkit.getPlayer(timedTeleport.getTeleporter().getUniqueId());
if (teleporter != null) {
if (timedTeleport.getTimeRemaining() > 0) {
@@ -226,7 +226,7 @@ public class TeleportRequestHandler {
// Clear completed teleports
if (!completedTeleports.isEmpty()) {
for (TimedTeleport timedTeleport : completedTeleports) {
TeleportManager.queuedTeleports.remove(timedTeleport);
TeleportManager.getQueuedTeleports().remove(timedTeleport);
}
}
completedTeleports.clear();