getLosers() {
+ return losers;
+ }
+}
+
+
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/EndPhaseMinigameEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/EndPhaseMinigameEvent.java
deleted file mode 100644
index c514e7c2c..000000000
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/EndPhaseMinigameEvent.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package au.com.mineauz.minigames.events;
-
-import au.com.mineauz.minigames.minigame.Minigame;
-import au.com.mineauz.minigames.objects.MinigamePlayer;
-
-import java.util.List;
-
-/**
- * This event is called whenever a minigame enters it's endphase.
- * This happens amongst others if a team wins or a finished sign was used.
- * However, this is NOT a guaranteed indicator that a minigame is about to end.
- * While the Endphase will lead to the end of a minigame, this event will NOT be called if certain circumstances happen,
- * like if the /mg quit command was called.
- *
- * if you need an event for cleanup use {@link EndedMinigameEvent}
- */
-public class EndPhaseMinigameEvent extends AbstractCancellableMinigameEvent {
- private final List winners;
- private final List losers;
-
-
- public EndPhaseMinigameEvent(List winners, List losers, Minigame minigame) {
- super(minigame);
- this.winners = winners;
- this.losers = losers;
- }
-
- public List getWinners() {
- return winners;
- }
-
- public List getLosers() {
- return losers;
- }
-}
-
-
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/EndedMinigameEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/EndedMinigameEvent.java
deleted file mode 100644
index 6cf1254fe..000000000
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/EndedMinigameEvent.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package au.com.mineauz.minigames.events;
-
-import au.com.mineauz.minigames.minigame.Minigame;
-
-/**
- * this event indicates the minigame has definitely ended now and is in the process of clearing up
- */
-public class EndedMinigameEvent extends AbstractMinigameEvent {
- public EndedMinigameEvent(Minigame minigame) {
- super(minigame);
- }
-}
\ No newline at end of file
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/FlagCaptureEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/FlagCaptureEvent.java
index f8e56a225..6cd341071 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/FlagCaptureEvent.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/events/FlagCaptureEvent.java
@@ -4,7 +4,7 @@
import au.com.mineauz.minigames.objects.CTFFlag;
import au.com.mineauz.minigames.objects.MinigamePlayer;
-public class FlagCaptureEvent extends AbstractCancellableMinigameEvent {
+public class FlagCaptureEvent extends AbstractMinigameEvent {
private final MinigamePlayer player;
private final CTFFlag flag;
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/JoinMinigameEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/JoinMinigameEvent.java
index 7da259c51..84b71eb4b 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/JoinMinigameEvent.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/events/JoinMinigameEvent.java
@@ -4,7 +4,7 @@
import au.com.mineauz.minigames.objects.MinigamePlayer;
import org.bukkit.entity.Player;
-public class JoinMinigameEvent extends AbstractCancellableMinigameEvent {
+public class JoinMinigameEvent extends AbstractMinigameEvent {
private final MinigamePlayer player;
private final boolean betting;
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/MinigameTimerTickEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/MinigameTimerTickEvent.java
index e02e430a1..50d8bcae7 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/MinigameTimerTickEvent.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/events/MinigameTimerTickEvent.java
@@ -3,7 +3,7 @@
import au.com.mineauz.minigames.MinigameTimer;
import au.com.mineauz.minigames.minigame.Minigame;
-public class MinigameTimerTickEvent extends AbstractCancellableMinigameEvent {
+public class MinigameTimerTickEvent extends AbstractMinigameEvent {
private final MinigameTimer timer;
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/MinigamesBroadcastEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/MinigamesBroadcastEvent.java
index 1f38b7473..c5195e2e9 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/MinigamesBroadcastEvent.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/events/MinigamesBroadcastEvent.java
@@ -2,7 +2,7 @@
import au.com.mineauz.minigames.minigame.Minigame;
-public class MinigamesBroadcastEvent extends AbstractCancellableMinigameEvent {
+public class MinigamesBroadcastEvent extends AbstractMinigameEvent {
private String message;
private final String prefix;
private boolean cancelled = false;
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/QuitMinigameEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/QuitMinigameEvent.java
index c87c42756..48f9a9c6d 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/QuitMinigameEvent.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/events/QuitMinigameEvent.java
@@ -4,7 +4,7 @@
import au.com.mineauz.minigames.objects.MinigamePlayer;
import org.bukkit.entity.Player;
-public class QuitMinigameEvent extends AbstractCancellableMinigameEvent {
+public class QuitMinigameEvent extends AbstractMinigameEvent {
private final MinigamePlayer player;
private final boolean isForced;
private final boolean isWinner;
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/RevertCheckpointEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/RevertCheckpointEvent.java
index 75ae902ea..a0c3424b3 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/RevertCheckpointEvent.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/events/RevertCheckpointEvent.java
@@ -3,7 +3,7 @@
import au.com.mineauz.minigames.objects.MinigamePlayer;
import org.bukkit.entity.Player;
-public class RevertCheckpointEvent extends AbstractCancellableMinigameEvent {
+public class RevertCheckpointEvent extends AbstractMinigameEvent {
private final MinigamePlayer player;
public RevertCheckpointEvent(MinigamePlayer player) {
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/SpectateMinigameEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/SpectateMinigameEvent.java
index 0d6f08245..691fcecdb 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/SpectateMinigameEvent.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/events/SpectateMinigameEvent.java
@@ -4,7 +4,7 @@
import au.com.mineauz.minigames.objects.MinigamePlayer;
import org.bukkit.entity.Player;
-public class SpectateMinigameEvent extends AbstractCancellableMinigameEvent {
+public class SpectateMinigameEvent extends AbstractMinigameEvent {
private final MinigamePlayer player;
public SpectateMinigameEvent(MinigamePlayer player, Minigame minigame) {
@@ -19,4 +19,6 @@ public MinigamePlayer getMinigamePlayer() {
public Player getPlayer() {
return player.getPlayer();
}
+
+
}
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/StartGlobalMinigameEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/StartGlobalMinigameEvent.java
index 23f39f261..78c5f9d77 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/StartGlobalMinigameEvent.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/events/StartGlobalMinigameEvent.java
@@ -3,7 +3,7 @@
import au.com.mineauz.minigames.minigame.Minigame;
import au.com.mineauz.minigames.objects.MinigamePlayer;
-public class StartGlobalMinigameEvent extends AbstractCancellableMinigameEvent {
+public class StartGlobalMinigameEvent extends AbstractMinigameEvent {
private final String mechanic;
private final MinigamePlayer caller;
@@ -14,6 +14,7 @@ public StartGlobalMinigameEvent(Minigame mgm, MinigamePlayer caller) {
this.caller = caller;
}
+
public String getMechanic() {
return mechanic;
}
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/StartMinigameEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/StartMinigameEvent.java
index 7b6dbd641..aaebcca6d 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/StartMinigameEvent.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/events/StartMinigameEvent.java
@@ -9,7 +9,7 @@
/**
* You cannot cancel this event
*/
-public class StartMinigameEvent extends AbstractCancellableMinigameEvent {
+public class StartMinigameEvent extends AbstractMinigameEvent {
private final boolean willTeleport;
private final List players;
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/StopGlobalMinigameEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/StopGlobalMinigameEvent.java
index 0ffb47ff0..5ecf6f97b 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/StopGlobalMinigameEvent.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/events/StopGlobalMinigameEvent.java
@@ -3,7 +3,7 @@
import au.com.mineauz.minigames.minigame.Minigame;
import au.com.mineauz.minigames.objects.MinigamePlayer;
-public class StopGlobalMinigameEvent extends AbstractCancellableMinigameEvent {
+public class StopGlobalMinigameEvent extends AbstractMinigameEvent {
private final String mechanic;
private final MinigamePlayer caller;
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/TakeFlagEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/TakeFlagEvent.java
index 84342ebac..9eefee23c 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/TakeFlagEvent.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/events/TakeFlagEvent.java
@@ -4,7 +4,7 @@
import au.com.mineauz.minigames.objects.CTFFlag;
import au.com.mineauz.minigames.objects.MinigamePlayer;
-public class TakeFlagEvent extends AbstractCancellableMinigameEvent {
+public class TakeFlagEvent extends AbstractMinigameEvent {
private final CTFFlag flag;
private final String flagName;
private boolean displayMessage = true;
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/events/TimerExpireEvent.java b/Minigames/src/main/java/au/com/mineauz/minigames/events/TimerExpireEvent.java
index c489467ab..94f37ed9b 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/events/TimerExpireEvent.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/events/TimerExpireEvent.java
@@ -3,7 +3,9 @@
import au.com.mineauz.minigames.minigame.Minigame;
import au.com.mineauz.minigames.minigame.MinigameState;
-public class TimerExpireEvent extends AbstractCancellableMinigameEvent {
+public class TimerExpireEvent extends AbstractMinigameEvent {
+
+
public TimerExpireEvent(Minigame minigame) {
super(minigame);
}
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/gametypes/MinigameTypeBase.java b/Minigames/src/main/java/au/com/mineauz/minigames/gametypes/MinigameTypeBase.java
index 856495e2e..8062d50ab 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/gametypes/MinigameTypeBase.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/gametypes/MinigameTypeBase.java
@@ -45,12 +45,12 @@ public void setType(MinigameType type) {
public void callGeneralQuit(MinigamePlayer player, Minigame minigame) {
if (!player.getPlayer().isDead()) {
- if (player.getPlayer().getWorld() != minigame.getQuitLocation().getWorld() && player.getPlayer().hasPermission("minigame.set.quit") && plugin.getConfig().getBoolean("warnings")) {
+ if (player.getPlayer().getWorld() != minigame.getQuitPosition().getWorld() && player.getPlayer().hasPermission("minigame.set.quit") && plugin.getConfig().getBoolean("warnings")) {
player.sendMessage(ChatColor.RED + "WARNING: " + ChatColor.WHITE + "Quit location is across worlds! This may cause some server performance issues!", MinigameMessageType.ERROR);
}
- player.teleport(minigame.getQuitLocation());
+ player.teleport(minigame.getQuitPosition());
} else {
- player.setQuitPos(minigame.getQuitLocation());
+ player.setQuitPos(minigame.getQuitPosition());
player.setRequiredQuit(true);
}
}
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/gametypes/MultiplayerType.java b/Minigames/src/main/java/au/com/mineauz/minigames/gametypes/MultiplayerType.java
index de830740f..a1e425eba 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/gametypes/MultiplayerType.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/gametypes/MultiplayerType.java
@@ -47,7 +47,7 @@ public boolean cannotStart(Minigame mgm, MinigamePlayer player) {
boolean cannotStart;
cannotStart = mgm.getPlayers().size() >= mgm.getMaxPlayers();
if (cannotStart) message = MinigameUtils.getLang("minigame.full");
- cannotStart = mgm.getLobbyLocation() == null;
+ cannotStart = mgm.getLobbyPosition() == null;
if (cannotStart) message = MinigameUtils.getLang("minigame.error.noLobby");
if (cannotStart) player.sendMessage(message, MinigameMessageType.ERROR);
return cannotStart;
@@ -55,7 +55,7 @@ public boolean cannotStart(Minigame mgm, MinigamePlayer player) {
@Override
public boolean teleportOnJoin(MinigamePlayer player, Minigame mgm) {
- Location location = mgm.getLobbyLocation();
+ Location location = mgm.getLobbyPosition();
boolean result = false;
if (location == null) {
plugin.getLogger().warning("Game has no lobby set and it was expected:" + mgm.getName(true));
@@ -151,7 +151,7 @@ public void quitMinigame(MinigamePlayer player, Minigame mgm, boolean forced) {
if (mgm.isTeamGame()) {
player.removeTeam();
for (Team t : TeamsModule.getMinigameModule(mgm).getTeams()) {
- if (!t.getPlayers().isEmpty())
+ if (t.getPlayers().size() > 0)
teamsWithPlayers++;
}
@@ -179,7 +179,7 @@ public void quitMinigame(MinigamePlayer player, Minigame mgm, boolean forced) {
if (TeamsModule.getMinigameModule(mgm).getTeams().size() != 1) {
Team winner = null;
for (Team t : TeamsModule.getMinigameModule(mgm).getTeams()) {
- if (!t.getPlayers().isEmpty()) {
+ if (t.getPlayers().size() > 0) {
winner = t;
break;
}
@@ -262,7 +262,7 @@ public void playerRespawn(PlayerRespawnEvent event) {
}
ply.getLoadout().equiptLoadout(ply);
} else {
- respawnPos = mg.getLobbyLocation();
+ respawnPos = mg.getLobbyPosition();
}
} else {
if (mg.hasStarted() && !ply.isLatejoining()) {
@@ -276,7 +276,7 @@ public void playerRespawn(PlayerRespawnEvent event) {
ply.getLoadout().equiptLoadout(ply);
} else {
- respawnPos = mg.getLobbyLocation();
+ respawnPos = mg.getLobbyPosition();
}
}
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/gametypes/SingleplayerType.java b/Minigames/src/main/java/au/com/mineauz/minigames/gametypes/SingleplayerType.java
index 662cd4be2..26fc94834 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/gametypes/SingleplayerType.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/gametypes/SingleplayerType.java
@@ -14,7 +14,6 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerRespawnEvent;
-import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Calendar;
@@ -40,11 +39,6 @@ public boolean cannotStart(Minigame mgm, MinigamePlayer player) {
@Override
public boolean teleportOnJoin(MinigamePlayer player, Minigame mgm) {
List locs = new ArrayList<>(mgm.getStartLocations());
-
- if (locs.isEmpty()) {
- return false;
- }
-
Collections.shuffle(locs);
boolean result = player.teleport(locs.get(0));
if (plugin.getConfig().getBoolean("warnings") && player.getPlayer().getWorld() != locs.get(0).getWorld() &&
@@ -57,7 +51,8 @@ public boolean teleportOnJoin(MinigamePlayer player, Minigame mgm) {
@Override
public boolean joinMinigame(MinigamePlayer player, Minigame mgm) {
- if (mgm.getLives() > 0 && Math.abs(mgm.getLives()) < Integer.MAX_VALUE) {
+
+ if (mgm.getLives() > 0 && !Float.isFinite(mgm.getLives())) {
player.sendInfoMessage(MessageManager.getMinigamesMessage("minigame.livesLeft", mgm.getLives()));
}
if (!mgm.isAllowedFlight()) {
@@ -122,7 +117,7 @@ public void endMinigame(List winners, List loser
}
@Override
- public void quitMinigame(final @NotNull MinigamePlayer player, final @NotNull Minigame mgm, boolean forced) {
+ public void quitMinigame(final MinigamePlayer player, final Minigame mgm, boolean forced) {
if (mgm.canSaveCheckpoint()) {
StoredPlayerCheckpoints spc = player.getStoredPlayerCheckpoints();
spc.addCheckpoint(mgm.getName(false), player.getCheckpoint());
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/managers/MessageManager.java b/Minigames/src/main/java/au/com/mineauz/minigames/managers/MessageManager.java
index c0f92ea01..b2c6e2ba3 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/managers/MessageManager.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/managers/MessageManager.java
@@ -32,27 +32,27 @@ public class MessageManager {
* Stores each prop file with an identifier
*/
private static final Hashtable propertiesHashMap = new Hashtable<>();
+ private static Locale locale = Locale.getDefault();
private static Logger logger = null;
+ public static void setLocale(Locale locale) {
+ MessageManager.locale = locale;
+ }
+
public static void setLogger(Logger logger) {
MessageManager.logger = logger;
}
public static void registerCoreLanguage() {
String tag = Minigames.getPlugin().getConfig().getString("lang", Locale.getDefault().toLanguageTag());
- Locale locale = Locale.forLanguageTag(tag.replace("_", "-"));
-
- // fall back if locale is undefined
- if (locale.getLanguage().isEmpty()) {
- locale = Locale.getDefault();
- }
-
+ locale = Locale.forLanguageTag(tag);
Minigames.log().info("MessageManager set locale for language:" + locale.toLanguageTag());
File file = new File(new File(Minigames.getPlugin().getDataFolder(), "lang"), "minigames.properties");
- registerCoreLanguage(file, locale);
+ registerCoreLanguage(file, Locale.getDefault());
}
public static void registerCoreLanguage(File file, Locale locale) {
+ MessageManager.setLocale(locale);
ResourceBundle minigames = null;
if (file.exists()) {
try {
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/managers/MinigameManager.java b/Minigames/src/main/java/au/com/mineauz/minigames/managers/MinigameManager.java
index 3ca9da771..1987defa8 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/managers/MinigameManager.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/managers/MinigameManager.java
@@ -4,6 +4,7 @@
import au.com.mineauz.minigames.MinigameUtils;
import au.com.mineauz.minigames.Minigames;
import au.com.mineauz.minigames.PlayerLoadout;
+import au.com.mineauz.minigames.blockRecorder.RecorderData;
import au.com.mineauz.minigames.config.MinigameSave;
import au.com.mineauz.minigames.config.RewardsFlag;
import au.com.mineauz.minigames.events.StartGlobalMinigameEvent;
@@ -18,13 +19,11 @@
import au.com.mineauz.minigames.objects.MgRegion;
import au.com.mineauz.minigames.objects.MinigamePlayer;
import au.com.mineauz.minigames.objects.ResourcePack;
-import au.com.mineauz.minigames.recorder.RecorderData;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -137,9 +136,10 @@ public void addMinigame(final Minigame game) {
if (Minigames.getPlugin().includesPapi()) {
Minigames.getPlugin().getPlaceHolderManager().addGameIdentifiers(game);
}
+
}
- public @Nullable Minigame getMinigame(final String minigame) {
+ public Minigame getMinigame(final String minigame) {
if (this.minigames.containsKey(minigame)) {
return this.minigames.get(minigame);
}
@@ -230,6 +230,7 @@ public Set getMinigameTypes() {
return this.minigameTypes.keySet();
}
+
public void addLoadout(final String name) {
this.globalLoadouts.put(name, new PlayerLoadout(name));
}
@@ -314,11 +315,11 @@ private void sendBroadcastMessage(Minigame minigame, String message, MinigameMes
type = MinigameMessageType.INFO;
}
finalMessage += message;
- final Set sendto = new HashSet<>();
+ final List sendto = new ArrayList<>();
sendto.addAll(minigame.getPlayers());
sendto.addAll(minigame.getSpectators());
if (exclude != null) {
- exclude.forEach(sendto::remove);
+ sendto.removeAll(exclude);
}
for (final MinigamePlayer pl : sendto) {
pl.sendMessage(finalMessage, type);
@@ -444,10 +445,10 @@ public boolean minigameStartStateCheck(final Minigame minigame, final MinigamePl
}
public boolean minigameStartSetupCheck(final Minigame minigame, final MinigamePlayer player) {
- if (minigame.getEndLocation() == null) {
+ if (minigame.getEndPosition() == null) {
player.sendMessage(MinigameUtils.getLang("minigame.error.noEnd"), MinigameMessageType.ERROR);
return false;
- } else if (minigame.getQuitLocation() == null) {
+ } else if (minigame.getQuitPosition() == null) {
player.sendMessage(MinigameUtils.getLang("minigame.error.noQuit"), MinigameMessageType.ERROR);
return false;
} else if (minigame.getType() == null || this.minigameType(minigame.getType()).cannotStart(minigame, player)) { //type specific reasons we cannot start.
@@ -466,7 +467,7 @@ public boolean minigameStartSetupCheck(final Minigame minigame, final MinigamePl
public boolean teleportPlayerOnJoin(@NotNull final Minigame minigame, final MinigamePlayer player) {
if (this.minigameType(minigame.getType()) == null) {
- Minigames.log().warning(MessageManager.getMinigamesMessage("minigame.error.invalidType") + " : " + minigame.getName(true));
+ Minigames.log().warning(MessageManager.getMinigamesMessage("error.invalidType") + " : " + minigame.getName(true));
}
return this.minigameType(minigame.getType()).teleportOnJoin(player, minigame);
}
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/managers/MinigamePlayerManager.java b/Minigames/src/main/java/au/com/mineauz/minigames/managers/MinigamePlayerManager.java
index 2d46cb01d..8959238de 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/managers/MinigamePlayerManager.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/managers/MinigamePlayerManager.java
@@ -4,6 +4,7 @@
import au.com.mineauz.minigames.MinigameUtils;
import au.com.mineauz.minigames.Minigames;
import au.com.mineauz.minigames.MultiplayerBets;
+import au.com.mineauz.minigames.blockRecorder.RegenRecorder;
import au.com.mineauz.minigames.events.*;
import au.com.mineauz.minigames.gametypes.MinigameType;
import au.com.mineauz.minigames.mechanics.GameMechanicBase;
@@ -14,7 +15,6 @@
import au.com.mineauz.minigames.minigame.modules.*;
import au.com.mineauz.minigames.objects.MinigamePlayer;
import au.com.mineauz.minigames.objects.ResourcePack;
-import au.com.mineauz.minigames.recorder.RegenRecorder;
import au.com.mineauz.minigames.sounds.MGSounds;
import au.com.mineauz.minigames.sounds.PlayMGSound;
import au.com.mineauz.minigames.stats.DynamicMinigameStat;
@@ -34,7 +34,6 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.potion.PotionEffect;
-import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -257,9 +256,7 @@ public void spectateMinigame(MinigamePlayer player, Minigame minigame) {
pl.getPlayer().hidePlayer(plugin, player.getPlayer());
}
- if (minigame.canDisplayScoreboard()) {
- player.getPlayer().setScoreboard(minigame.getScoreboardManager());
- }
+ player.getPlayer().setScoreboard(minigame.getScoreboardManager());
for (PotionEffect potion : player.getPlayer().getActivePotionEffects()) {
player.getPlayer().removePotionEffect(potion.getType());
@@ -448,6 +445,7 @@ public void getStartLocations(List players, Minigame game) {
}
public void revertToCheckpoint(MinigamePlayer player) {
+
RevertCheckpointEvent event = new RevertCheckpointEvent(player);
Bukkit.getServer().getPluginManager().callEvent(event);
@@ -471,7 +469,7 @@ public void revertToCheckpoint(MinigamePlayer player) {
}
}
- public void quitMinigame(@NotNull MinigamePlayer player, boolean forced) {
+ public void quitMinigame(MinigamePlayer player, boolean forced) {
Minigame minigame = player.getMinigame();
boolean isWinner = GameOverModule.getMinigameModule(minigame).getWinners().contains(player);
@@ -479,48 +477,7 @@ public void quitMinigame(@NotNull MinigamePlayer player, boolean forced) {
QuitMinigameEvent event = new QuitMinigameEvent(player, minigame, forced, isWinner);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
- if (minigame.isSpectator(player)) {
- if (player.getPlayer().getVehicle() != null) {
- Vehicle vehicle = (Vehicle) player.getPlayer().getVehicle();
- vehicle.eject();
- }
- player.getPlayer().setFallDistance(0);
- player.getPlayer().setNoDamageTicks(60);
- final Player fplayer = player.getPlayer();
- for (PotionEffect potion : player.getPlayer().getActivePotionEffects()) {
- player.getPlayer().removePotionEffect(potion.getType());
- }
- Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> fplayer.setFireTicks(0));
-
- player.getPlayer().closeInventory();
- if (player.isLiving()) {
- player.restorePlayerData();
- }
-
- Location loc;
- if (minigame.getEndLocation() != null) {
- loc = minigame.getEndLocation();
- } else {
- loc = minigame.getQuitLocation();
- }
-
- if (loc != null) {
- player.teleport(loc);
- } else {
- Minigames.log.warning("Minigame " + minigame.getName(true) + " has no end location set! (Player: " + player.getName() + ")");
- }
-
- player.setStartPos(null);
- player.removeMinigame();
- minigame.removeSpectator(player);
-
- for (MinigamePlayer pl : minigame.getPlayers()) {
- pl.getPlayer().showPlayer(plugin, player.getPlayer());
- }
-
- player.sendMessage(MessageManager.getMinigamesMessage("player.spectate.quit.plyMsg", minigame.getName(true)), MinigameMessageType.ERROR);
- mgManager.sendMinigameMessage(minigame, MessageManager.getMinigamesMessage("player.spectate.quit.minigameMsg", player.getName(), minigame.getName(true)), MinigameMessageType.ERROR, player);
- } else {
+ if (!minigame.isSpectator(player)) {
if (player.getEndTime() == 0)
player.setEndTime(System.currentTimeMillis());
@@ -531,9 +488,8 @@ public void quitMinigame(@NotNull MinigamePlayer player, boolean forced) {
player.setCompleteTime(player.getEndTime() - player.getStartTime() + player.getStoredTime());
}
- } else {
+ } else
GameOverModule.getMinigameModule(minigame).getLosers().remove(player);
- }
if (!isWinner) {
if (!minigame.canSaveCheckpoint() && minigame.isEnabled()) {
@@ -583,29 +539,28 @@ public void quitMinigame(@NotNull MinigamePlayer player, boolean forced) {
player.restorePlayerData();
Location loc;
if (!isWinner) {
- if (minigame.getQuitLocation() != null) {
- loc = minigame.getQuitLocation();
+ if (minigame.getQuitPosition() != null) {
+ loc = minigame.getQuitPosition();
} else {
- loc = minigame.getEndLocation();
+ loc = minigame.getEndPosition();
}
} else {
- if (minigame.getEndLocation() != null) {
- loc = minigame.getEndLocation();
+ if (minigame.getEndPosition() != null) {
+ loc = minigame.getEndPosition();
} else {
- loc = minigame.getQuitLocation();
+ loc = minigame.getQuitPosition();
}
}
if (loc != null) {
player.teleport(loc);
} else {
- Minigames.log.warning("Minigame " + minigame.getName(true) + " has no end location set! (Player: " + player.getName() + ")");
+ Minigames.log.warning("Minigame " + minigame.getName(true) + " has no end position set! (Player: " + player.getName() + ")");
}
} else {
- if (!isWinner) {
- player.setQuitPos(minigame.getQuitLocation());
- } else {
- player.setQuitPos(minigame.getEndLocation());
- }
+ if (!isWinner)
+ player.setQuitPos(minigame.getQuitPosition());
+ else
+ player.setQuitPos(minigame.getEndPosition());
player.setRequiredQuit(true);
}
player.setStartPos(null);
@@ -617,10 +572,7 @@ public void quitMinigame(@NotNull MinigamePlayer player, boolean forced) {
player.claimRewards();
//Reset Minigame
- if (minigame.getPlayers().isEmpty()) {
- //call event about this minigame has come to an end (and therefor is past an optional end phase)
- Bukkit.getServer().getPluginManager().callEvent(new EndedMinigameEvent(minigame));
-
+ if (minigame.getPlayers().size() == 0) {
if (minigame.getMinigameTimer() != null) {
minigame.getMinigameTimer().stopTimer();
minigame.setMinigameTimer(null);
@@ -650,17 +602,15 @@ public void quitMinigame(@NotNull MinigamePlayer player, boolean forced) {
}
mgManager.clearClaimedScore(minigame);
-
WeatherTimeModule mod = WeatherTimeModule.getMinigameModule(minigame);
if (mod != null) {
mod.stopTimeLoop();
}
-
GameOverModule.getMinigameModule(minigame).stopEndGameTimer();
-
for (Team team : TeamsModule.getMinigameModule(minigame).getTeams()) {
team.setScore(0);
}
+
}
minigame.getScoreboardManager().resetScores(player.getName());
@@ -679,6 +629,34 @@ public void quitMinigame(@NotNull MinigamePlayer player, boolean forced) {
}
plugin.getLogger().info(player.getName() + " quit " + minigame);
player.updateInventory();
+ } else {
+ if (player.getPlayer().getVehicle() != null) {
+ Vehicle vehicle = (Vehicle) player.getPlayer().getVehicle();
+ vehicle.eject();
+ }
+ player.getPlayer().setFallDistance(0);
+ player.getPlayer().setNoDamageTicks(60);
+ final Player fplayer = player.getPlayer();
+ for (PotionEffect potion : player.getPlayer().getActivePotionEffects()) {
+ player.getPlayer().removePotionEffect(potion.getType());
+ }
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> fplayer.setFireTicks(0));
+
+ player.getPlayer().closeInventory();
+ if (player.isLiving()) {
+ player.restorePlayerData();
+ }
+ player.teleport(minigame.getQuitPosition());
+ player.setStartPos(null);
+ player.removeMinigame();
+ minigame.removeSpectator(player);
+
+ for (MinigamePlayer pl : minigame.getPlayers()) {
+ pl.getPlayer().showPlayer(plugin, player.getPlayer());
+ }
+
+ player.sendMessage(MessageManager.getMinigamesMessage("player.spectate.quit.plyMsg", minigame.getName(true)), MinigameMessageType.ERROR);
+ mgManager.sendMinigameMessage(minigame, MessageManager.getMinigamesMessage("player.spectate.quit.minigameMsg", player.getName(), minigame.getName(true)), MinigameMessageType.ERROR, player);
}
if (ResourcePackModule.getMinigameModule(minigame).isEnabled()) {
if (player.applyResourcePack(plugin.getResourceManager().getResourcePack("empty"))) {
@@ -703,10 +681,11 @@ public void endMinigame(MinigamePlayer player) {
endMinigame(player.getMinigame(), w, l);
}
+
public void endMinigame(Minigame minigame, List winners, List losers) {
//When the minigame ends, the flag for recognizing the start teleportation needs to be resetted
minigame.setPlayersAtStart(false);
- EndPhaseMinigameEvent event = new EndPhaseMinigameEvent(winners, losers, minigame);
+ EndMinigameEvent event = new EndMinigameEvent(winners, losers, minigame);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
@@ -756,7 +735,7 @@ public void endMinigame(Minigame minigame, List winners, List winners, Minigame minigame) {
}
}
+
@Deprecated
public boolean playerInMinigame(Player player) {
return minigamePlayers.get(player.getName()).isInMinigame();
@@ -937,9 +917,8 @@ public void removeMinigamePlayer(Player player) {
public @Nullable MinigamePlayer getMinigamePlayer(UUID uuid) {
for (MinigamePlayer p : minigamePlayers.values()) {
- if (p.getUUID() == uuid) {
+ if (p.getUUID() == uuid)
return p;
- }
}
return getMinigamePlayer(Bukkit.getPlayer(uuid));
@@ -1044,4 +1023,15 @@ public void saveDeniedCommands() {
public void loadDeniedCommands() {
setDeniedCommands(plugin.getConfig().getStringList("disabledCommands"));
}
+
+ private class PlayerLocation {
+ final Location location;
+ final Integer position;
+
+ public PlayerLocation(int pos) {
+ location = null;
+ this.position = pos;
+ }
+ }
+
}
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/mechanics/CTFMechanic.java b/Minigames/src/main/java/au/com/mineauz/minigames/mechanics/CTFMechanic.java
index 902c2d279..129bf6141 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/mechanics/CTFMechanic.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/mechanics/CTFMechanic.java
@@ -125,7 +125,7 @@ public void takeFlag(PlayerInteractEvent event) {
(TeamsModule.getMinigameModule(mgm).hasTeam(TeamColor.matchColor(ChatColor.stripColor(sign.getLine(2)))) ||
sign.getLine(2).equalsIgnoreCase(ChatColor.GRAY + "Neutral"))) {
Team oTeam = TeamsModule.getMinigameModule(mgm).getTeam(TeamColor.matchColor(ChatColor.stripColor(sign.getLine(2))));
- CTFFlag flag = new CTFFlag(sign, oTeam, mgm);
+ CTFFlag flag = new CTFFlag(event.getClickedBlock().getLocation(), oTeam, mgm);
ev = new TakeFlagEvent(mgm, ply, flag);
Bukkit.getPluginManager().callEvent(ev);
if (!ev.isCancelled()) {
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/mechanics/LivesMechanic.java b/Minigames/src/main/java/au/com/mineauz/minigames/mechanics/LivesMechanic.java
index 73cda201c..0216340a4 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/mechanics/LivesMechanic.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/mechanics/LivesMechanic.java
@@ -67,13 +67,13 @@ private void minigameStart(StartMinigameEvent event) {
final List players = event.getPlayers();
final Minigame minigame = event.getMinigame();
for (MinigamePlayer player : players) {
- if (Math.abs(minigame.getLives()) < Integer.MAX_VALUE) {
- int lives = minigame.getLives();
- player.setScore(lives);
- minigame.setScore(player, lives);
- } else {
+ if (!Float.isFinite(minigame.getLives())) {
player.setScore(Integer.MAX_VALUE);
minigame.setScore(player, Integer.MAX_VALUE);
+ } else {
+ int lives = Float.floatToIntBits(minigame.getLives());
+ player.setScore(lives);
+ minigame.setScore(player, lives);
}
}
}
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/mechanics/TreasureHuntMechanic.java b/Minigames/src/main/java/au/com/mineauz/minigames/mechanics/TreasureHuntMechanic.java
index d15486a71..d7849da18 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/mechanics/TreasureHuntMechanic.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/mechanics/TreasureHuntMechanic.java
@@ -18,7 +18,6 @@
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
-import org.bukkit.block.Container;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
@@ -69,7 +68,7 @@ public static void spawnTreasure(final Minigame mgm) {
double ry;
double rz;
final int maxradius;
- if (thm.getMaxRadius() <= 0) {
+ if (thm.getMaxRadius() == 0) {
maxradius = 1000;
} else {
maxradius = thm.getMaxRadius();
@@ -90,41 +89,40 @@ public static void spawnTreasure(final Minigame mgm) {
//Add a new Chest
//TODO: Improve so no invalid spawns (Not over void, Strict containment)
- if (rpos.getBlock().getType().isAir()) {
- int minWorldHeight = rpos.getWorld().getMinHeight();
- // find first block below that is not air anymore to spawn on top of
- while (rpos.getBlock().getType().isAir() && rpos.getY() > minWorldHeight) {
- rpos.setY(rpos.getY() - 1);
- }
- rpos.setY(rpos.getY() + 1);
- } else {
- int maxWorldHeight = rpos.getWorld().getMaxHeight();
- // find first block above that is air to spawn into
- while (!rpos.getBlock().getType().isAir() && rpos.getY() < maxWorldHeight) {
+ switch (rpos.getBlock().getType()) {
+ case AIR, CAVE_AIR, VOID_AIR -> {
+ while (rpos.getBlock().getType() == Material.AIR && rpos.getY() > 1) {
+ rpos.setY(rpos.getY() - 1);
+ }
rpos.setY(rpos.getY() + 1);
+ Bukkit.getScheduler().runTaskLater(plugin, () -> rpos.getBlock().setType(Material.CHEST), 1L);
+ }
+ default -> {
+ while (rpos.getBlock().getType() != Material.AIR && rpos.getY() < 255) {
+ rpos.setY(rpos.getY() + 1);
+ }
+ Bukkit.getScheduler().runTaskLater(plugin, () -> rpos.getBlock().setType(Material.CHEST), 1L);
}
}
- Bukkit.getScheduler().runTaskLater(plugin, () -> rpos.getBlock().setType(Material.CHEST), 1L);
-
- //Fill new container
+ //Fill new chest
Bukkit.getScheduler().runTaskLater(plugin, () -> {
- if (rpos.getBlock().getState() instanceof Container container) {
+ if (rpos.getBlock().getState() instanceof Chest chest) {
// TODO: Treasure hunt needs own rewards specification
RewardsModule rewards = RewardsModule.getModule(mgm);
if (rewards.getScheme() instanceof StandardRewardScheme) {
if (!((StandardRewardScheme) rewards.getScheme()).getPrimaryReward().getRewards().isEmpty()) {
- int numItems = (int) Math.min(container.getInventory().getSize(), Math.round(Math.random() * (thm.getMaxTreasure() - thm.getMinTreasure())) + thm.getMinTreasure());
+ int numitems = (int) Math.round(Math.random() * (thm.getMaxTreasure() - thm.getMinTreasure())) + thm.getMinTreasure();
final ItemStack[] items = new ItemStack[27];
- for (int i = 0; i < numItems; i++) {
+ for (int i = 0; i < numitems; i++) {
RewardType rew = ((StandardRewardScheme) rewards.getScheme()).getPrimaryReward().getReward().get(0);
if (rew instanceof ItemReward irew) {
items[i] = irew.getRewardItem();
}
}
Collections.shuffle(Arrays.asList(items));
- container.getInventory().setContents(items);
+ chest.getInventory().setContents(items);
}
}
}
@@ -164,14 +162,13 @@ public void startMinigame(Minigame minigame, MinigamePlayer caller) {
if (thm.getLocation() != null) {
spawnTreasure(minigame);
- if (Bukkit.getOnlinePlayers().isEmpty())
+ if (Bukkit.getOnlinePlayers().size() == 0)
minigame.getMinigameTimer().stopTimer();
} else {
- if (caller == null) {
+ if (caller == null)
Bukkit.getLogger().info("Treasure Hunt requires a location name to run!");
- } else {
+ else
caller.sendMessage("Treasure Hunt requires a location name to run!", MinigameMessageType.ERROR);
- }
}
}
@@ -346,4 +343,5 @@ private void interactEvent(PlayerInteractEvent event) {
}
}
}
+
}
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/menu/MenuItemAddWhitelistBlock.java b/Minigames/src/main/java/au/com/mineauz/minigames/menu/MenuItemAddWhitelistBlock.java
index 83ad857fa..a422fda0d 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/menu/MenuItemAddWhitelistBlock.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/menu/MenuItemAddWhitelistBlock.java
@@ -2,13 +2,13 @@
import au.com.mineauz.minigames.MinigameMessageType;
import au.com.mineauz.minigames.objects.MinigamePlayer;
-import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public class MenuItemAddWhitelistBlock extends MenuItem {
+
private final List whitelist;
public MenuItemAddWhitelistBlock(String name, List whitelist) {
@@ -42,37 +42,24 @@ public ItemStack onClick() {
@Override
public void checkValidEntry(String entry) {
- // try a direct match in case of a chat input
- Material mat = Material.matchMaterial(entry);
-
- // didn't work, now try the input as a block data, as we get when a block was clicked
- if (mat == null) {
- try {
- mat = Bukkit.createBlockData(entry).getMaterial();
-
- } catch (IllegalArgumentException ignored) {
- }
- }
-
- if (mat == null) {
- // still didn't work.
- getContainer().getViewer().sendMessage("No material with BlockData \"" + entry + "\" was found!", MinigameMessageType.ERROR);
- } else {
- // nice we got a Material! try to add it!
+ entry = entry.toUpperCase();
+ if (Material.getMaterial(entry) != null) {
+ Material mat = Material.getMaterial(entry);
if (!whitelist.contains(mat)) {
- // intern
whitelist.add(mat);
-
- // visual
getContainer().addItem(new MenuItemWhitelistBlock(mat, whitelist));
-
} else {
getContainer().getViewer().sendMessage("Whitelist/Blacklist already contains this material", MinigameMessageType.ERROR);
}
+
+ getContainer().cancelReopenTimer();
+ getContainer().displayMenu(getContainer().getViewer());
+ return;
}
- /* cancel automatic reopening and reopen {@link MenuItemDisplayWhitelist}*/
getContainer().cancelReopenTimer();
getContainer().displayMenu(getContainer().getViewer());
+
+ getContainer().getViewer().sendMessage("No material by the name \"" + entry + "\" was found!", MinigameMessageType.ERROR);
}
}
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/menu/MenuItemBlockData.java b/Minigames/src/main/java/au/com/mineauz/minigames/menu/MenuItemBlockData.java
index e8d8d7302..af8052e25 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/menu/MenuItemBlockData.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/menu/MenuItemBlockData.java
@@ -14,23 +14,23 @@
import java.util.List;
public class MenuItemBlockData extends MenuItem {
- private Callback dataCallback;
+ private Callback data;
public MenuItemBlockData(String name, Material displayItem) {
super(name, displayItem);
- dataCallback.setValue(displayItem.createBlockData());
- setDescription(createDescription(dataCallback.getValue()));
+ data.setValue(displayItem.createBlockData());
+ setDescription(createDescription(data.getValue()));
}
public MenuItemBlockData(String name, Material displayItem, Callback callback) {
super(name, displayItem);
- this.dataCallback = callback;
- setDescription(createDescription(dataCallback.getValue()));
+ this.data = callback;
+ setDescription(createDescription(data.getValue()));
}
@Override
public void update() {
- setDescription(createDescription(this.dataCallback.getValue()));
+ setDescription(createDescription(this.data.getValue()));
}
/**
@@ -61,12 +61,7 @@ private List createDescription(BlockData data) {
public ItemStack onClickWithItem(@Nullable ItemStack item) {
try {
BlockData data = item.getType().createBlockData();
- this.dataCallback.setValue(data);
-
- // update the display item
- ItemStack stackUpdate = getItem();
- stackUpdate.setType(item.getType());
- setItem(stackUpdate);
+ this.data.setValue(data);
} catch (IllegalArgumentException | NullPointerException e) {
String name = "unknown";
if (item != null) {
@@ -82,16 +77,8 @@ public void checkValidEntry(String entry) {
String err = "No MgBlockData detected";
try {
BlockData d = Bukkit.createBlockData(entry);
- dataCallback.setValue(d);
-
- // update the display item
- setDescription(createDescription(dataCallback.getValue()));
- if (d.getMaterial().isItem()) {
- ItemStack stackUpdate = getItem();
- stackUpdate.setType(d.getMaterial());
- setItem(stackUpdate);
- }
-
+ data.setValue(d);
+ setDescription(createDescription(data.getValue()));
getContainer().cancelReopenTimer();
getContainer().displayMenu(getContainer().getViewer());
return;
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/menu/MenuItemString.java b/Minigames/src/main/java/au/com/mineauz/minigames/menu/MenuItemString.java
index b04188bdc..40e6c0b42 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/menu/MenuItemString.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/menu/MenuItemString.java
@@ -72,11 +72,10 @@ public ItemStack onDoubleClick() {
@Override
public void checkValidEntry(String entry) {
- if (entry.equals("null") && allowNull) {
+ if (entry.equals("null") && allowNull)
str.setValue(null);
- } else {
+ else
str.setValue(entry);
- }
updateDescription();
getContainer().cancelReopenTimer();
diff --git a/Minigames/src/main/java/au/com/mineauz/minigames/minigame/Minigame.java b/Minigames/src/main/java/au/com/mineauz/minigames/minigame/Minigame.java
index fe580feea..3267939f9 100644
--- a/Minigames/src/main/java/au/com/mineauz/minigames/minigame/Minigame.java
+++ b/Minigames/src/main/java/au/com/mineauz/minigames/minigame/Minigame.java
@@ -1,6 +1,7 @@
package au.com.mineauz.minigames.minigame;
import au.com.mineauz.minigames.*;
+import au.com.mineauz.minigames.blockRecorder.RecorderData;
import au.com.mineauz.minigames.config.*;
import au.com.mineauz.minigames.gametypes.MinigameType;
import au.com.mineauz.minigames.mechanics.GameMechanicBase;
@@ -14,7 +15,6 @@
import au.com.mineauz.minigames.objects.MgRegion;
import au.com.mineauz.minigames.objects.MinigamePlayer;
import au.com.mineauz.minigames.objects.RegenRegionSetResult;
-import au.com.mineauz.minigames.recorder.RecorderData;
import au.com.mineauz.minigames.script.ScriptCollection;
import au.com.mineauz.minigames.script.ScriptObject;
import au.com.mineauz.minigames.script.ScriptReference;
@@ -32,7 +32,10 @@
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.scoreboard.*;
+import org.bukkit.scoreboard.DisplaySlot;
+import org.bukkit.scoreboard.Objective;
+import org.bukkit.scoreboard.Scoreboard;
+import org.bukkit.scoreboard.ScoreboardManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -63,9 +66,9 @@ public class Minigame implements ScriptObject {
private final BooleanFlag respawn = new BooleanFlag(Minigames.getPlugin().getConfig().getBoolean("has-respawn"), "respawn");
private final LocationListFlag startLocations = new LocationListFlag(null, "startpos");
private final BooleanFlag randomizeStart = new BooleanFlag(false, "ranndomizeStart");
- private final LocationFlag endLocation = new LocationFlag(null, "endpos");
- private final LocationFlag quitLocation = new LocationFlag(null, "quitpos");
- private final LocationFlag lobbyLocation = new LocationFlag(null, "lobbypos");
+ private final LocationFlag endPosition = new LocationFlag(null, "endpos");
+ private final LocationFlag quitPosition = new LocationFlag(null, "quitpos");
+ private final LocationFlag lobbyPosition = new LocationFlag(null, "lobbypos");
private final LocationFlag spectatorPosition = new LocationFlag(null, "spectatorpos");
private final BooleanFlag usePermissions = new BooleanFlag(false, "usepermissions");
@@ -99,7 +102,6 @@ public class Minigame implements ScriptObject {
private final BooleanFlag unlimitedAmmo = new BooleanFlag(false, "unlimitedammo");
private final BooleanFlag saveCheckpoints = new BooleanFlag(false, "saveCheckpoints");
private final BooleanFlag lateJoin = new BooleanFlag(false, "latejoin");
- // just to stay backwards compatible we have
private final FloatFlag lives = new FloatFlag(0F, "lives");
private final RegionMapFlag regenRegions = new RegionMapFlag(new HashMap<>(), "regenRegions", "regenarea.1", "regenarea.2");
@@ -120,7 +122,6 @@ public class Minigame implements ScriptObject {
@NotNull
private final ScoreboardData sbData = new ScoreboardData();
private final Map statSettings = Maps.newHashMap();
- private final BooleanFlag activatePlayerRecorder = new BooleanFlag(true, "activatePlayerRecorder");
//Unsaved data
private final List players = new ArrayList<>();
@@ -169,19 +170,19 @@ private void setup(MinigameType type, Location start) {
if (start != null)
startLocations.getFlag().add(start);
if (sbManager != null) {
- sbManager.registerNewObjective(this.name, Criteria.DUMMY, this.name).setDisplaySlot(DisplaySlot.SIDEBAR);
+ sbManager.registerNewObjective(this.name, "dummy", this.name);
+ sbManager.getObjective(this.name).setDisplaySlot(DisplaySlot.SIDEBAR);
}
for (Class extends MinigameModule> mod : Minigames.getPlugin().getMinigameManager().getModules()) {
try {
addModule(mod.getDeclaredConstructor(Minigame.class).newInstance(this));
} catch (Exception e) {
- Minigames.getPlugin().getLogger().log(Level.WARNING, "Couldn't construct Module.", e);
+ e.printStackTrace();
}
}
flags.setFlag(new ArrayList<>());
- addConfigFlag(activatePlayerRecorder);
addConfigFlag(allowEnderPearls);
addConfigFlag(allowFlight);
addConfigFlag(allowMPCheckpoints);
@@ -196,7 +197,7 @@ private void setup(MinigameType type, Location start) {
addConfigFlag(displayName);
addConfigFlag(enableFlight);
addConfigFlag(enabled);
- addConfigFlag(endLocation);
+ addConfigFlag(endPosition);
addConfigFlag(flags);
addConfigFlag(floorDegen);
addConfigFlag(floorDegenTime);
@@ -205,7 +206,7 @@ private void setup(MinigameType type, Location start) {
addConfigFlag(itemPickup);
addConfigFlag(lateJoin);
addConfigFlag(lives);
- addConfigFlag(lobbyLocation);
+ addConfigFlag(lobbyPosition);
addConfigFlag(maxChestRandom);
addConfigFlag(maxPlayers);
addConfigFlag(maxScore);
@@ -221,7 +222,7 @@ private void setup(MinigameType type, Location start) {
addConfigFlag(objective);
addConfigFlag(paintBallDamage);
addConfigFlag(paintBallMode);
- addConfigFlag(quitLocation);
+ addConfigFlag(quitPosition);
addConfigFlag(randomizeChests);
addConfigFlag(regenRegions);
addConfigFlag(regenDelay);
@@ -308,11 +309,7 @@ public boolean removeFlag(String flag) {
}
public void setStartLocation(Location loc) {
- if (startLocations.getFlag().isEmpty()) {
- startLocations.getFlag().add(loc);
- } else {
- startLocations.getFlag().set(0, loc);
- }
+ startLocations.getFlag().set(0, loc);
}
public void addStartLocation(Location loc) {
@@ -455,28 +452,28 @@ public void setDegenRandomChance(int degenRandomChance) {
this.degenRandomChance.setFlag(degenRandomChance);
}
- public @Nullable Location getEndLocation() {
- return endLocation.getFlag();
+ public Location getEndPosition() {
+ return endPosition.getFlag();
}
- public void setEndLocation(Location endLocation) {
- this.endLocation.setFlag(endLocation);
+ public void setEndPosition(Location endPosition) {
+ this.endPosition.setFlag(endPosition);
}
- public @Nullable Location getQuitLocation() {
- return quitLocation.getFlag();
+ public Location getQuitPosition() {
+ return quitPosition.getFlag();
}
- public void setQuitLocation(Location quitLocation) {
- this.quitLocation.setFlag(quitLocation);
+ public void setQuitPosition(Location quitPosition) {
+ this.quitPosition.setFlag(quitPosition);
}
- public @Nullable Location getLobbyLocation() {
- return lobbyLocation.getFlag();
+ public Location getLobbyPosition() {
+ return lobbyPosition.getFlag();
}
- public void setLobbyLocation(Location lobbyLocation) {
- this.lobbyLocation.setFlag(lobbyLocation);
+ public void setLobbyPosition(Location lobbyPosisiton) {
+ this.lobbyPosition.setFlag(lobbyPosisiton);
}
public String getName(boolean useDisplay) {
@@ -900,14 +897,6 @@ public void setMaxChestRandom(int maxChestRandom) {
this.maxChestRandom.setFlag(maxChestRandom);
}
- public boolean getActivatePlayerRecorder() {
- return activatePlayerRecorder.getFlag();
- }
-
- public void setActivatePlayerRecorder(boolean activatePlayerRecorder) {
- this.activatePlayerRecorder.setFlag(activatePlayerRecorder);
- }
-
public Collection getRegenRegions() {
return regenRegions.getFlag().values();
}
@@ -973,12 +962,12 @@ public void setRegenDelay(int regenDelay) {
this.regenDelay.setFlag(regenDelay);
}
- public int getLives() {
- return lives.getFlag().intValue();
+ public float getLives() {
+ return lives.getFlag();
}
- public void setLives(int lives) {
- this.lives.setFlag((float) lives);
+ public void setLives(float lives) {
+ this.lives.setFlag(lives);
}
public int getFloorDegenTime() {
@@ -1131,10 +1120,10 @@ public void setValue(String value) {
MenuItemString obj = (MenuItemString) objective.getMenuItem("Objective Description", Material.DIAMOND);
obj.setAllowNull(true);
itemsMain.add(obj);
- obj = (MenuItemString) gameTypeName.getMenuItem("Gametype Description", Material.OAK_SIGN);
+ obj = (MenuItemString) gameTypeName.getMenuItem("Gametype Description", Material.OAK_WALL_SIGN);
obj.setAllowNull(true);
itemsMain.add(obj);
- obj = (MenuItemString) displayName.getMenuItem("Display Name", Material.OAK_SIGN);
+ obj = (MenuItemString) displayName.getMenuItem("Display Name", Material.OAK_WALL_SIGN);
obj.setAllowNull(true);
itemsMain.add(obj);
itemsMain.add(new MenuItemNewLine());
@@ -1228,7 +1217,7 @@ public void setValue(Integer value) {
}, 0, null));
itemsMain.add(new MenuItemNewLine());
itemsMain.add(new MenuItemPage("Player Settings", Material.SKELETON_SKULL, playerMenu));
-// List thDes = new ArrayList<>();
+// List thDes = new ArrayList<>();
// thDes.add("Treasure hunt related");
// thDes.add("settings.");
// itemsMain.add(new MenuItemPage("Treasure Hunt Settings", thDes, Material.CHEST, treasureHunt));
@@ -1248,7 +1237,6 @@ public void setValue(Integer value) {
rndChstDes.add("Max. item randomization");
itemsMain.add(maxChestRandom.getMenuItem("Max. Chest Random", Material.STONE, rndChstDes, 0, null));
itemsMain.add(new MenuItemStatisticsSettings(this, "Stat Settings", Material.WRITABLE_BOOK));
- itemsMain.add(activatePlayerRecorder.getMenuItem("Activate Player Block Recorder", Material.COMMAND_BLOCK));
itemsMain.add(new MenuItemNewLine());
//--------------//
@@ -1314,7 +1302,7 @@ public void setValue(Integer value) {
//--------------//
List