option to disable mapsave

This commit is contained in:
Tyler Murphy 2022-05-06 12:22:04 -04:00
parent bd37044e10
commit 134444243a
9 changed files with 48 additions and 22 deletions

View file

@ -36,6 +36,10 @@ public class SaveMap implements ICommand {
public static boolean runningBackup = false;
public void execute(CommandSender sender, String[] args) {
if(!mapSaveEnabled){
sender.sendMessage(errorPrefix + message("MAPSAVE_DISABLED"));
return;
}
if(Game.status != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;

View file

@ -56,7 +56,7 @@ public class SetSpawnLocation implements ICommand {
if(world == null){
throw new RuntimeException("Unable to get world: " + spawnWorld);
}
if(!world.getName().equals(spawnWorld)){
if(mapSaveEnabled && !world.getName().equals(spawnWorld)){
Game.worldLoader.unloadMap();
Game.worldLoader = new WorldLoader(world.getName());
}

View file

@ -19,6 +19,7 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.game.Game;
import org.bukkit.command.CommandSender;
import net.tylermurphy.hideAndSeek.Main;
@ -51,11 +52,13 @@ public class Setup implements ICommand {
msg = msg + "\n" + message("SETUP_BOUNDS");
count++;
}
File destenation = new File(Main.root+File.separator+"hideandseek_"+spawnWorld);
if(!destenation.exists()) {
if(mapSaveEnabled) {
File destenation = new File(Main.root + File.separator + Game.getGameWorld());
if (!destenation.exists()) {
msg = msg + "\n" + message("SETUP_SAVEMAP");
count++;
}
}
if(count < 1) {
sender.sendMessage(messagePrefix + message("SETUP_COMPLETE"));
} else {

View file

@ -78,7 +78,8 @@ public class Config {
seekerPing,
bungeeLeave,
lobbyItemStartAdmin,
leaveOnEnd;
leaveOnEnd,
mapSaveEnabled;
public static int
minPlayers,
@ -201,6 +202,7 @@ public class Config {
saveMinZ = config.getInt("bounds.min.z");
saveMaxX = config.getInt("bounds.max.x");
saveMaxZ = config.getInt("bounds.max.z");
mapSaveEnabled = config.getBoolean("mapSaveEnabled");
//Taunt
tauntEnabled = config.getBoolean("taunt.enabled");

View file

@ -61,12 +61,12 @@ public class EventListener implements Listener {
if(autoJoin){
Game.join(event.getPlayer());
} else if(teleportToExit) {
if (event.getPlayer().getWorld().getName().equals("hideandseek_" + spawnWorld) || event.getPlayer().getWorld().getName().equals(lobbyWorld)) {
if (event.getPlayer().getWorld().getName().equals(Game.getGameWorld()) || event.getPlayer().getWorld().getName().equals(lobbyWorld)) {
event.getPlayer().teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
event.getPlayer().setGameMode(GameMode.ADVENTURE);
}
} else {
if (event.getPlayer().getWorld().getName().equals("hideandseek_" + spawnWorld)) {
if (event.getPlayer().getWorld().getName().equals(Game.getGameWorld())) {
if(Game.status != Status.STANDBY){
Game.join(event.getPlayer());
} else {
@ -115,10 +115,10 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onMove(PlayerMoveEvent event){
if(!event.getPlayer().getWorld().getName().equals("hideandseek_" + spawnWorld)) return;
if(!event.getPlayer().getWorld().getName().equals(Game.getGameWorld())) return;
if(event.getPlayer().hasPermission("hideandseek.leavebounds")) return;
if(event.getTo() == null || event.getTo().getWorld() == null) return;
if(!event.getTo().getWorld().getName().equals("hideandseek_" + spawnWorld)) return;
if(!event.getTo().getWorld().getName().equals(Game.getGameWorld())) return;
if(event.getTo().getBlockX() < saveMinX || event.getTo().getBlockX() > saveMaxX || event.getTo().getBlockZ() < saveMinZ || event.getTo().getBlockZ() > saveMaxZ){
event.setCancelled(true);
}
@ -211,7 +211,7 @@ public class EventListener implements Listener {
} else {
player.setHealth(player.getMaxHealth());
}
player.teleport(new Location(Bukkit.getWorld("hideandseek_" + spawnWorld), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
player.teleport(new Location(Bukkit.getWorld(Game.getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
if(Version.atLeast("1.9")){
XSound.ENTITY_PLAYER_DEATH.play(player, 1, 1);
} else {

View file

@ -89,7 +89,7 @@ public class Game {
public static void start(Player seeker){
if(status == Status.STARTING || status == Status.PLAYING) return;
if(worldLoader.getWorld() != null) {
if(mapSaveEnabled && worldLoader.getWorld() != null) {
worldLoader.rollback();
} else {
worldLoader.loadMap();
@ -105,7 +105,7 @@ public class Game {
for(Player player : Board.getPlayers()) {
player.getInventory().clear();
player.setGameMode(GameMode.ADVENTURE);
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
player.teleport(new Location(Bukkit.getWorld(getGameWorld()), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
for(PotionEffect effect : player.getActivePotionEffects()){
player.removePotionEffect(effect.getType());
}
@ -125,7 +125,7 @@ public class Game {
if (glowEnabled)
glow = new Glow();
worldBorder = new Border();
worldBorder.resetWorldborder("hideandseek_"+spawnWorld);
worldBorder.resetWorldborder(getGameWorld());
if(gameLength > 0)
timeLeft = gameLength;
for(Player player : Board.getPlayers())
@ -184,7 +184,7 @@ public class Game {
winners.add(Board.getFirstSeeker().getUniqueId());
Database.playerInfo.addWins(players, winners, type);
}
worldBorder.resetWorldborder("hideandseek_"+spawnWorld);
worldBorder.resetWorldborder(getGameWorld());
for(Player player : Board.getPlayers()) {
if(Version.atLeast("1.9")){
for(Player temp : Board.getPlayers()) {
@ -220,7 +220,7 @@ public class Game {
}
}
EventListener.temp_loc.clear();
worldLoader.unloadMap();
if(mapSaveEnabled) worldLoader.unloadMap();
Board.reloadLobbyBoards();
}
@ -228,11 +228,18 @@ public class Game {
if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) return true;
if(lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) return true;
if(exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) return true;
File destenation = new File(Main.root+File.separator+"hideandseek_"+spawnWorld);
if(!destenation.exists()) return true;
if(mapSaveEnabled) {
File destenation = new File(Main.root + File.separator + getGameWorld());
if (!destenation.exists()) return true;
}
return saveMinX == 0 || saveMinZ == 0 || saveMaxX == 0 || saveMaxZ == 0;
}
public static String getGameWorld(){
if(mapSaveEnabled) return "hideandseek_"+spawnWorld;
else return spawnWorld;
}
public static void onTick() {
if(isNotSetup()) return;
if(status == Status.STANDBY) whileWaiting();
@ -294,7 +301,7 @@ public class Game {
player.sendMessage(messagePrefix + message("GAME_JOIN_SPECTATOR"));
player.setGameMode(GameMode.SPECTATOR);
Board.createGameBoard(player);
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
player.teleport(new Location(Bukkit.getWorld(getGameWorld()), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
Titles.sendTitle(player, 10, 70, 20, ChatColor.GRAY + "" + ChatColor.BOLD + "SPECTATING", ChatColor.WHITE + message("SPECTATOR_SUBTITLE").toString());
}
@ -601,7 +608,7 @@ class Border {
running = true;
broadcastMessage(worldborderPrefix + message("WORLDBORDER_DECREASING").addAmount(change));
currentWorldborderSize -= worldborderChange;
World world = Bukkit.getWorld("hideandseek_"+spawnWorld);
World world = Bukkit.getWorld(Game.getGameWorld());
assert world != null;
org.bukkit.WorldBorder border = world.getWorldBorder();
border.setSize(border.getSize()-change,30);

View file

@ -60,12 +60,12 @@ teleportToExit: false
# Normally when the game ends, players are set back to the lobby to play another game.
# You can disable this, and empty the lobby after the game finishes. This is like everyone
# running /hs leave at the end of the game. Players will leave either to the exit position
# or another server depending what you have `leaveType` set too.
# or another server depending on what you have `leaveType` set too.
# default: false
leaveOnEnd: false
# What do you want to happen when a player leaves the lobby. If you are running a single server, maybe you want to send
# them to the world hub. But if you are running a bungee-cord or velocity server, maybe you want to send them to the servers
# them to the world hub. But if you are running a bungee-cord or velocity server, maybe you want to send them to the servers'
# hub.
#
# EXIT - Sends the player to the specified exit position set by /hs setexit
@ -79,6 +79,14 @@ leaveType: EXIT
# players too.
leaveServer: hub
# By default, the plugin forces you to use a map save to protect from changes to a map thought a game play though. It copies your
# hide-and-seek world to a separate world, and loads the game there to contain the game in an isolated and backed up map This allows you to
# not worry about your hide-and-seek map from changing, as all changes are made are in a separate world file that doesn't get saved. Once the game
# ends, it unloads the map and doesn't save. Then reloads the duplicate to the original state, rolling back the map for the next game.
# It is highly recommended that you keep this set to true unless you have other means of protecting your hide-and-seek map.
# default: true
mapSaveEnabled: true
# The worldborder closes every interval, which is evey [delay] in minutes.
# Thw worldborder starts at [size], and decreases 100 blocks every interval.
# x & z are the center location. [enabled] is whenever the border is enabled.

View file

@ -30,6 +30,7 @@ Localization:
MAPSAVE_WARNING: "All commands will be disabled whenthe save is in progress. Do not turn off the server."
MAPSAVE_END: "Speichervorgang abgeschlossen."
MAPSAVE_ERROR: "Aktuelle Weltkarte konnte nicht gefunden werden."
MAPSAVE_DISABLED: "Mapsave ist in config.yml deaktiviert."
WORLDBORDER_DISABLE: "World Border ausgeschaltet."
WORLDBORDER_INVALID_INPUT: "Ungültiger Wert: {AMOUNT}"
WORLDBORDER_MIN_SIZE: "World Border darf nicht geringer als 100 Blöcke sein."

View file

@ -30,6 +30,7 @@ Localization:
MAPSAVE_WARNING: "All commands will be disabled when the save is in progress. Do not turn off the server."
MAPSAVE_END: "Map save complete."
MAPSAVE_ERROR: "Couldn't find current map."
MAPSAVE_DISABLED: "Mapsave is disabled in config.yml."
WORLDBORDER_DISABLE: "Disabled world border."
WORLDBORDER_INVALID_INPUT: "Invalid integer {AMOUNT}."
WORLDBORDER_MIN_SIZE: "World border cannot be smaller than 100 blocks."