generate(final World world, final int spawnCount, final int
random((int) (zCenter - Math.floor(regionDiameter / 2)), (int) (zCenter + (int) Math.floor(regionDiameter / 2))));
// Inside the region?
- if (!p.getBorderManager().isInsideBorder(randomPoint, regionDiameter))
+ if (!borderModule.isInsideBorder(randomPoint, regionDiameter))
{
continue; // outside: nope
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/SpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/SpawnPointsGenerator.java
similarity index 94%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/SpawnPointsGenerator.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/SpawnPointsGenerator.java
index 3342a25..8bb1207 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/SpawnPointsGenerator.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/SpawnPointsGenerator.java
@@ -29,9 +29,9 @@
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.spawns.generators;
+package eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators;
-import eu.carrade.amaury.UHCReloaded.spawns.exceptions.CannotGenerateSpawnPointsException;
+import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException;
import org.bukkit.Location;
import org.bukkit.World;
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java
new file mode 100644
index 0000000..186eb04
--- /dev/null
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
+ *
+ * http://amaury.carrade.eu
+ *
+ * This software is governed by the CeCILL-B license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL-B
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL-B license and that you accept its terms.
+ */
+package eu.carrade.amaury.UHCReloaded.modules.core.timers;
+
+import fr.zcraft.zlib.components.configuration.ConfigurationParseException;
+import fr.zcraft.zlib.components.configuration.ConfigurationValueHandler;
+import fr.zcraft.zlib.components.configuration.ConfigurationValueHandlers;
+
+import java.util.Objects;
+
+
+public class TimeDelta
+{
+ private final long seconds;
+
+ static
+ {
+ ConfigurationValueHandlers.registerHandlers(TimeDelta.class);
+ }
+
+ /**
+ * Constructs a time delta.
+ *
+ * @param seconds The number of seconds in this delta.
+ */
+ public TimeDelta(long seconds)
+ {
+ this.seconds = seconds;
+ }
+
+ /**
+ * Constructs a time delta.
+ *
+ * @param hours The number of hours.
+ * @param minutes The number of minutes.
+ * @param seconds The number of seconds.
+ */
+ public TimeDelta(long hours, long minutes, long seconds)
+ {
+ this(seconds + minutes * 60 + hours * 3600);
+ }
+
+ /**
+ * Constructs a time delta from a raw string representing a time.
+ *
+ * Allowed formats:
+ *
+ *
+ * - mm – number of minutes;
+ * - mm:ss – minutes and seconds;
+ * - hh:mm:ss – hours, minutes and seconds.
+ *
+ *
+ * @param rawTime The raw time text.
+ *
+ * @throws IllegalArgumentException if the text is not formatted as above.
+ * @throws NumberFormatException if the text between the colons cannot be converted in integers.
+ */
+ public TimeDelta(final String rawTime) throws IllegalArgumentException, NumberFormatException
+ {
+ final String[] split = rawTime.split(":");
+
+ if (rawTime.isEmpty() || split.length > 3)
+ {
+ throw new IllegalArgumentException("Badly formatted string in TimeDelta(String); formats allowed are mm, mm:ss or hh:mm:ss.");
+ }
+
+ if (split.length == 1) // "mm"
+ {
+ this.seconds = Integer.valueOf(split[0]) * 60;
+ }
+ else if (split.length == 2) // "mm:ss"
+ {
+ this.seconds = Integer.valueOf(split[0]) * 60 + Integer.valueOf(split[1]);
+ }
+ else // "hh:mm:ss"
+ {
+ this.seconds = Integer.valueOf(split[0]) * 3600 + Integer.valueOf(split[1]) * 60 + Integer.valueOf(split[2]);
+ }
+ }
+
+ public long getSeconds()
+ {
+ return seconds;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ return this == o || o != null && getClass() == o.getClass() && seconds == ((TimeDelta) o).seconds;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(seconds);
+ }
+
+
+ @ConfigurationValueHandler
+ public static TimeDelta handleTimeDelta(String rawDelta) throws ConfigurationParseException
+ {
+ try
+ {
+ return new TimeDelta(rawDelta);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new ConfigurationParseException("Invalid time delta format", rawDelta);
+ }
+ }
+}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/UHTimer.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/Timer.java
similarity index 56%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/UHTimer.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/Timer.java
index 2058d2d..b5273b8 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/UHTimer.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/Timer.java
@@ -30,10 +30,10 @@
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.old.timers;
+package eu.carrade.amaury.UHCReloaded.modules.core.timers;
-import eu.carrade.amaury.UHCReloaded.events.TimerEndsEvent;
-import eu.carrade.amaury.UHCReloaded.events.TimerStartsEvent;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerStartsEvent;
import fr.zcraft.zlib.components.i18n.I;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
@@ -49,7 +49,7 @@
*
* @author Amaury Carrade
*/
-public class UHTimer
+public class Timer
{
private static final NumberFormat formatter = new DecimalFormat("00");
@@ -58,29 +58,20 @@ public class UHTimer
private Boolean registered = false;
private Boolean running = false;
private Boolean displayed = false;
+ private Boolean nameDisplayed = true;
private Long startTime = 0L;
private Integer duration = 0; // seconds
- // Cached values
- private Integer hoursLeft = 0;
- private Integer minutesLeft = 0;
- private Integer secondsLeft = 0;
-
- // Old values, used by the scoreboard to reset the scores.
- private Integer oldHoursLeft = -1;
- private Integer oldMinutesLeft = -1;
- private Integer oldSecondsLeft = -1;
-
// Pause
private Boolean paused = false;
private Long pauseTime = 0L;
+ private Integer elapsedWhenPaused = 0;
- // Display this timer following the format "hh:mm:ss"?
- private Boolean displayHoursInTimer = false;
+ private Boolean system = false;
- public UHTimer(String name)
+ public Timer(String name)
{
Validate.notNull(name, "The name cannot be null");
@@ -88,6 +79,17 @@ public UHTimer(String name)
this.name = name;
}
+ public Timer(final String name, final int seconds)
+ {
+ this(name);
+ setDuration(seconds);
+ }
+
+ public Timer(final String name, final TimeDelta duration)
+ {
+ this(name, Math.toIntExact(duration.getSeconds()));
+ }
+
/**
* Sets the duration of the timer, in seconds.
*
@@ -96,12 +98,16 @@ public UHTimer(String name)
public void setDuration(int seconds)
{
this.duration = seconds;
+ }
- this.hoursLeft = (int) Math.floor(this.duration / 3600);
- this.minutesLeft = (int) (Math.floor(this.duration / 60) - (this.hoursLeft * 60));
- this.secondsLeft = this.duration - (this.minutesLeft * 60 + this.hoursLeft * 3600);
-
- this.displayHoursInTimer = (this.hoursLeft != 0);
+ /**
+ * Sets the duration of the timer.
+ *
+ * @param duration The duration.
+ */
+ public void setDuration(TimeDelta duration)
+ {
+ this.duration = Math.toIntExact(duration.getSeconds());
}
/**
@@ -143,45 +149,20 @@ private void stop(boolean wasUp)
}
else
{
- this.running = false;
- this.startTime = 0L;
-
- this.hoursLeft = 0;
- this.minutesLeft = 0;
- this.secondsLeft = 0;
-
- this.oldHoursLeft = 0;
- this.oldMinutesLeft = 0;
- this.oldSecondsLeft = 0;
+ running = false;
+ startTime = 0L;
}
}
}
/**
- * Updates the timer.
+ * Updates the timer to check if it is up and terminate it.
*/
public void update()
{
- if (running && !paused)
+ if (running && !paused && getElapsed() >= getDuration())
{
- oldHoursLeft = hoursLeft;
- oldMinutesLeft = minutesLeft;
- oldSecondsLeft = secondsLeft;
-
- long timeSinceStart = System.currentTimeMillis() - this.startTime; // ms
-
- if (timeSinceStart >= getDuration() * 1000)
- {
- stop(true);
- }
- else
- {
- int countSecondsLeft = (int) (getDuration() - Math.floor(timeSinceStart / 1000));
-
- secondsLeft = countSecondsLeft % 60;
- minutesLeft = (countSecondsLeft % 3600) / 60;
- hoursLeft = (int) Math.floor(countSecondsLeft / 3600);
- }
+ stop(true);
}
}
@@ -194,29 +175,35 @@ public void update()
*/
public void setPaused(boolean pause)
{
- if (this.running)
+ if (running)
{
// The pause is only set once (as example if the user executes /uh freeze all twice).
- if (pause && !this.paused)
+ if (pause != paused)
{
- this.paused = true;
- this.pauseTime = System.currentTimeMillis();
- }
-
- if (!pause && this.paused)
- {
- // We have to add to the time of the start of the episode the elapsed time
- // during the pause.
- this.startTime += (System.currentTimeMillis() - this.pauseTime);
- this.pauseTime = 0l;
-
- this.paused = false;
+ if (pause)
+ {
+ elapsedWhenPaused = getElapsed();
+
+ paused = true;
+ pauseTime = System.currentTimeMillis();
+ }
+
+ else
+ {
+ // We have to add to the time of the start of the episode the elapsed time
+ // during the pause.
+ startTime += (System.currentTimeMillis() - pauseTime);
+ pauseTime = 0L;
+
+ paused = false;
+ elapsedWhenPaused = 0;
+ }
}
}
}
/**
- * Checks if the timer is registered in the TimerManager.
+ * Checks if the timer is registered in the TimersModule.
*
* @return true if the timer is registered.
*/
@@ -269,7 +256,7 @@ public Boolean isRunning()
}
/**
- * Checks if the timer is currently displayed in the scoreboard.
+ * Checks if the timer is currently displayed in the sidebar.
*
* @return {@code true} if displayed.
*/
@@ -279,7 +266,7 @@ public Boolean isDisplayed()
}
/**
- * Display or hide this timer in/from the scoreboard.
+ * Display or hide this timer in/from the sidebar.
*
* @param displayed {@code true} to display, and {@code false} to hide.
*/
@@ -289,79 +276,75 @@ public void setDisplayed(Boolean displayed)
}
/**
- * Returns the duration of the timer, in seconds.
+ * Checks if the name of this timer should be displayed in the sidebar.
*
- * @return The duration.
+ * @return {@code true} if name displayed.
*/
- public Integer getDuration()
+ public Boolean isNameDisplayed()
{
- return duration;
+ return nameDisplayed;
}
/**
- * Returns the number of hours left until the end of this countdown.
+ * Displays or hides the timer's name in/from the sidebar.
*
- * @return The number of hours left.
+ * @param nameDisplayed {@code true} to display, and {@code false} to hide.
*/
- public Integer getHoursLeft()
+ public void setNameDisplayed(Boolean nameDisplayed)
{
- return hoursLeft;
+ this.nameDisplayed = nameDisplayed;
}
/**
- * Returns the number of minutes left until the end of this countdown.
- *
- * @return The number of minutes left.
+ * @return {@code true} if this is a system timer that cannot be altered by the user.
*/
- public Integer getMinutesLeft()
+ public Boolean isSystem()
{
- return minutesLeft;
+ return system;
}
/**
- * Returns the number of seconds left until the end of this countdown.
+ * Sets if this timer is a system timer that cannot be altered by the user.
*
- * @return The number of seconds left.
+ * @param system {@code true} if this timer is an internal system timer.
*/
- public Integer getSecondsLeft()
+ public void setSystem(Boolean system)
{
- return secondsLeft;
+ this.system = system;
}
/**
- * Returns the number of hours left until the end of this countdown, before the last update.
- *
- * Used by the scoreboard, to remove the old score.
+ * Returns the duration of the timer, in seconds.
*
- * @return The old number of hours left, or -1 if the timer was never updated.
+ * @return The duration.
*/
- public Integer getOldHoursLeft()
+ public Integer getDuration()
{
- return oldHoursLeft;
+ return duration;
}
/**
- * Returns the number of minutes left until the end of this countdown, before the last update.
- *
- * Used by the scoreboard, to remove the old score.
- *
- * @return The old number of minutes left, or -1 if the timer was never updated.
+ * @return The elapsed time since the beginning of the timer (not including pauses), in seconds.
*/
- public Integer getOldMinutesLeft()
+ public int getElapsed()
{
- return oldMinutesLeft;
+ if (isRunning())
+ {
+ if (isPaused())
+ return elapsedWhenPaused;
+ else
+ return (int) Math.floor((System.currentTimeMillis() - startTime) / 1000);
+ }
+
+ else return 0;
}
/**
- * Returns the number of seconds left until the end of this countdown, before the last update.
- *
- * Used by the scoreboard, to remove the old score.
- *
- * @return The old number of seconds left, or -1 if the timer was never updated.
+ * @return The number of seconds left before this timer is up.
*/
- public Integer getOldSecondsLeft()
+ public int getTimeLeft()
{
- return oldSecondsLeft;
+ return getDuration() - getElapsed();
}
/**
@@ -374,45 +357,45 @@ public Boolean isPaused()
return paused;
}
- /**
- * Returns true if this timer is displayed as "hh:mm:ss" in the scoreboard.
- *
- * @return true if this timer is displayed as "hh:mm:ss" in the scoreboard.
- */
- public Boolean getDisplayHoursInTimer()
+ @Override
+ public String toString()
{
- return displayHoursInTimer;
+ return formatTime(getTimeLeft());
}
@Override
public boolean equals(Object other)
{
- return other instanceof UHTimer && ((UHTimer) other).getName().equals(this.getName());
+ return other instanceof Timer && ((Timer) other).getName().equals(this.getName());
}
@Override
- public String toString()
+ public int hashCode()
{
- return toString(displayHoursInTimer);
+ return id.hashCode();
}
- public String toString(boolean displayHours)
+ /**
+ * Formats a given number of seconds into [hh:]mm:ss.
+ *
+ * @param seconds The number of seconds.
+ * @return The formatted time (includes color codes).
+ */
+ public static String formatTime(final int seconds)
{
- if (displayHours)
+ final int secondsLeft = seconds % 60;
+ final int minutesLeft = (seconds % 3600) / 60;
+ final int hoursLeft = (int) Math.floor(seconds / 3600);
+
+ if (hoursLeft != 0)
{
/// Timer. {0} = hours; {1} = minutes; {2} = seconds.
- return I.t("{0}{gray}:{white}{1}{gray}:{white}{2}", formatter.format(hoursLeft), formatter.format(minutesLeft), formatter.format(secondsLeft));
+ return ChatColor.WHITE + I.t("{0}{gray}:{white}{1}{gray}:{white}{2}", formatter.format(hoursLeft), formatter.format(minutesLeft), formatter.format(secondsLeft));
}
else
{
/// Timer. {0} = minutes; {1} = seconds.
- return I.t("{white}{0}{gray}:{white}{1}", formatter.format(minutesLeft), formatter.format(secondsLeft));
+ return ChatColor.WHITE +I.t("{white}{0}{gray}:{white}{1}", formatter.format(minutesLeft), formatter.format(secondsLeft));
}
}
-
- @Override
- public int hashCode()
- {
- return id.hashCode();
- }
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/TimerManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java
similarity index 56%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/TimerManager.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java
index 48702ff..f43538f 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/TimerManager.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java
@@ -30,53 +30,90 @@
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.old.timers;
-
+package eu.carrade.amaury.UHCReloaded.modules.core.timers;
+
+import eu.carrade.amaury.UHCReloaded.core.ModuleInfo;
+import eu.carrade.amaury.UHCReloaded.core.UHModule;
+import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.commands.TimersCommand;
+import fr.zcraft.zlib.components.commands.Command;
+import fr.zcraft.zlib.tools.runners.RunTask;
+import org.apache.commons.lang3.tuple.Pair;
+import org.bukkit.entity.Player;
+
+import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.stream.Collectors;
-public class TimerManager
+@ModuleInfo (
+ name = "Timers",
+ description = "The timekeeper of the whole UHCReloaded plugin & companions",
+ internal = true,
+ can_be_disabled = false
+)
+public class TimersModule extends UHModule
{
- private Map timers = new ConcurrentHashMap<>();
- private UHTimer mainTimer = null;
+ private Set timers = new CopyOnWriteArraySet<>();
/**
* Cached list of the running timers
*/
- private Map runningTimers = new ConcurrentHashMap<>();
+ private Set runningTimers = new CopyOnWriteArraySet<>();
/**
* List of the timers to resume if running timers are paused.
*
- * @see {@link #pauseAllRunning(boolean)}.
+ * @see #pauseAllRunning(boolean)
*/
- private Set timersToResume = new CopyOnWriteArraySet<>();
-
+ private Set timersToResume = new CopyOnWriteArraySet<>();
/**
- * Registers the main timer, used to display the episodes countdown.
- *
- * @param timer The timer.
+ * Sidebar cache.
*/
- public void registerMainTimer(UHTimer timer)
+ private List> sidebarInjection = new LinkedList<>();
+
+
+ @Override
+ protected void onEnable()
{
- this.mainTimer = timer;
- timer.setRegistered(true);
+ RunTask.timer(() -> timers.forEach(Timer::update), 1L, 20L);
}
- /**
- * Returns the main timer, used to display the episodes countdown.
- *
- * @return The main timer.
- */
- public UHTimer getMainTimer()
+
+ @Override
+ public List> getCommands()
{
- return this.mainTimer;
+ return Collections.singletonList(TimersCommand.class);
+ }
+
+
+ @Override
+ public void prepareInjectionIntoSidebar()
+ {
+ sidebarInjection.clear();
+ sidebarInjection = timers.stream()
+ .filter(Timer::isDisplayed)
+ .map(timer -> Pair.of(timer.isNameDisplayed() ? timer.getDisplayName() : null, timer.toString()))
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public void injectIntoSidebar(Player player, SidebarInjector injector)
+ {
+ sidebarInjection.forEach(timer -> {
+ final List lines;
+
+ if (timer.getLeft() == null) lines = Collections.singletonList(timer.getRight());
+ else lines = Arrays.asList(timer.getLeft(), timer.getRight());
+
+ injector.injectLines(SidebarInjector.SidebarPriority.VERY_BOTTOM, true, lines);
+ });
}
/**
@@ -85,14 +122,14 @@ public UHTimer getMainTimer()
* @param timer The timer to register.
* @throws IllegalArgumentException if a timer with the same name is already registered.
*/
- public void registerTimer(UHTimer timer)
+ public void registerTimer(final Timer timer)
{
- if (timers.get(timer.getName()) != null)
+ if (timers.contains(timer))
{
- throw new IllegalArgumentException("A timer with the name " + timer.getName() + " is already registered.");
+ throw new IllegalArgumentException("The timer " + timer.getName() + " is already registered.");
}
- timers.put(timer.getName(), timer);
+ timers.add(timer);
timer.setRegistered(true);
}
@@ -104,10 +141,10 @@ public void registerTimer(UHTimer timer)
*
* @param timer The timer to unregister.
*/
- public void unregisterTimer(UHTimer timer)
+ public void unregisterTimer(final Timer timer)
{
- timers.remove(timer.getName());
- runningTimers.remove(timer.getName());
+ timers.remove(timer);
+ runningTimers.remove(timer);
timer.setRegistered(false);
}
@@ -117,16 +154,7 @@ public void unregisterTimer(UHTimer timer)
*/
public void updateStartedTimersList()
{
- runningTimers = new HashMap<>();
-
- if (getMainTimer() != null && getMainTimer().isRunning())
- {
- runningTimers.put(getMainTimer().getName(), getMainTimer());
- }
-
- timers.values().stream()
- .filter(UHTimer::isRunning)
- .forEach(timer -> runningTimers.put(timer.getName(), timer));
+ runningTimers = timers.stream().filter(Timer::isRunning).collect(Collectors.toSet());
}
/**
@@ -134,11 +162,11 @@ public void updateStartedTimersList()
*
* @param name The name of the timer.
*
- * @return The timer, or null if there isn't any timer with this name.
+ * @return The first timer with this name, or null if there isn't any timer with this name.
*/
- public UHTimer getTimer(String name)
+ public Timer getTimer(final String name)
{
- return timers.get(name);
+ return timers.stream().filter(timer -> timer.getName().equals(name)).findFirst().orElse(null);
}
/**
@@ -146,9 +174,9 @@ public UHTimer getTimer(String name)
*
* @return The collection.
*/
- public Collection getTimers()
+ public Collection getTimers()
{
- return timers.values();
+ return Collections.unmodifiableSet(timers);
}
/**
@@ -156,9 +184,9 @@ public Collection getTimers()
*
* @return The collection.
*/
- public Collection getRunningTimers()
+ public Collection getRunningTimers()
{
- return runningTimers.values();
+ return Collections.unmodifiableSet(runningTimers);
}
/**
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java
new file mode 100644
index 0000000..86c0e11
--- /dev/null
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java
@@ -0,0 +1,388 @@
+/*
+ * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
+ *
+ * http://amaury.carrade.eu
+ *
+ * This software is governed by the CeCILL-B license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL-B
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL-B license and that you accept its terms.
+ */
+package eu.carrade.amaury.UHCReloaded.modules.core.timers.commands;
+
+import eu.carrade.amaury.UHCReloaded.UHCReloaded;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule;
+import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
+import fr.zcraft.zlib.components.commands.Command;
+import fr.zcraft.zlib.components.commands.CommandException;
+import fr.zcraft.zlib.components.commands.CommandInfo;
+import fr.zcraft.zlib.components.commands.WithFlags;
+import fr.zcraft.zlib.components.i18n.I;
+import fr.zcraft.zlib.components.rawtext.RawText;
+import fr.zcraft.zlib.components.rawtext.RawTextPart;
+import fr.zcraft.zlib.tools.text.MessageSender;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+
+import java.util.Collection;
+
+
+@CommandInfo (name = "timers", usageParameters = "[add|display|hide|list|pause|resume|remove|set|start|stop|help]", aliases = {"timer"})
+@WithFlags
+public class TimersCommand extends Command
+{
+ private final TimersModule timersModule = UHCReloaded.getModule(TimersModule.class);
+
+ @Override
+ protected void run() throws CommandException
+ {
+ if (args.length == 0)
+ {
+ list();
+ return;
+ }
+
+ switch (args[0].toLowerCase())
+ {
+ case "add":
+ add(); break;
+
+ case "display":
+ display(); break;
+
+ case "hide":
+ hide(); break;
+
+ case "list":
+ list(); break;
+
+ case "pause":
+ pause(); break;
+
+ case "resume":
+ resume(); break;
+
+ case "remove":
+ remove(); break;
+
+ case "set":
+ set(); break;
+
+ case "start":
+ start(); break;
+
+ case "stop":
+ stop(); break;
+
+ case "help":
+ default:
+ help();
+ }
+ }
+
+ private void help()
+ {
+ info(I.t("{blue}{bold}Command help for {cc}{bold}/uh timers"));
+ info(I.t("{cc}/uh timers add {ci}: adds a timer."));
+ info(I.t("{cc}/uh timers display [--without-name] {ci}: displays a timer in the scoreboard. Automatic when a timer is started."));
+ info(I.t("{cc}/uh timers hide {ci}: removes a timer from the scoreboard. Don't stops the timer."));
+ info(I.t("{cc}/uh timers list {ci}: lists the registered timers."));
+ info(I.t("{cc}/uh timers pause {ci}: pauses a timer."));
+ info(I.t("{cc}/uh timers resume {ci}: resumes a timer."));
+ info(I.t("{cc}/uh timers remove {ci}: deletes a timer."));
+ info(I.t("{cc}/uh timers set {ci}: sets the duration of a timer."));
+ info(I.t("{cc}/uh timers start {ci}: starts a timer."));
+ info(I.t("{cc}/uh timers stop {ci}: stops a timer. The timer will be removed from the scoreboard."));
+ }
+
+ private void add() throws CommandException
+ {
+ if (args.length < 3) throwInvalidArgument(I.t("You must specify both a duration and a name."));
+
+ final String name = UHUtils.getStringFromCommandArguments(args, 2);
+
+ if (timersModule.getTimer(name) != null)
+ throwInvalidArgument(I.t("{ce}A timer called {0}{ce} already exists; please choose another name.", name));
+
+ final Timer timer = new Timer(name, getTimeDeltaParameter(1));
+ timersModule.registerTimer(timer);
+
+ success(I.t("{cs}The timer {0}{cs} (duration {1}) has been registered.", timer.getDisplayName(), args[1]));
+ }
+
+ private void display() throws CommandException
+ {
+ final Timer timer = getTimerParameter(1);
+
+ timer.setDisplayed(true);
+ timer.setNameDisplayed(!hasFlag("without-name"));
+
+ reply(I.t("{cs}The timer {0}{cs} is now displayed.", timer.getDisplayName()));
+ }
+
+ private void hide() throws CommandException
+ {
+ final Timer timer = getTimerParameter(1);
+
+ timer.setDisplayed(false);
+
+ reply(I.t("{cs}The timer {0}{cs} is now hidden.", timer.getDisplayName()));
+ }
+
+ private void list()
+ {
+ final Collection timers = timersModule.getTimers();
+
+ info("");
+ info(I.tn("{ci}{0} timer is registered.", "{ci}{0} timers are registered.", timers.size()));
+
+ for (final Timer timer : timers)
+ {
+ final RawTextPart timerText = new RawText()
+ .then(" • ").color(timer.isRunning() ? (timer.isPaused() ? ChatColor.YELLOW : ChatColor.GREEN) : ChatColor.RED)
+ .then(timer.getDisplayName())
+ .hover(
+ new RawText()
+ .then(timer.getDisplayName())
+ .then("\n")
+ .then(timer.isRunning() ? (timer.isPaused() ? I.t("Paused") : I.t("Running")) : I.t("Not started"))
+ .then("\n\n")
+ .then(timer.toString() + (timer.isRunning() ? " " + I.t("{gray}(total: {0}{gray})", Timer.formatTime(timer.getDuration())) : ""))
+ .then(timer.isSystem() ? "\n\n" + I.t("{gray}{bold}System timer") : "")
+ .then(timer.isSystem() ? "\n" + I.t("{gray}This timer is a system timer, it cannot be modified (you can still display or hide it to/from the sidebar).") : "")
+ )
+ .then(" ")
+ .then("[ \u272F ]")
+ .color(timer.isDisplayed() ? ChatColor.DARK_PURPLE : ChatColor.LIGHT_PURPLE)
+ .hover(
+ new RawText()
+ .then(timer.getDisplayName())
+ .then("\n").then(timer.isDisplayed() ? I.t("{white}Hide this timer from the sidebar") : I.t("{white}Show this timer in the sidebar"))
+ )
+ .command(TimersCommand.class, timer.isDisplayed() ? "hide" : "display", timer.getName(), "--from-list-command")
+ .then(" ");
+
+ if (!timer.isSystem())
+ {
+ if (!timer.isRunning())
+ {
+ timerText
+ .then("[ \u25B6 ]")
+ .style(ChatColor.GREEN)
+ .hover(
+ new RawText()
+ .then(timer.getDisplayName())
+ .then("\n").then(I.t("{white}Start this timer"))
+ )
+ .command(TimersCommand.class, "start", timer.getName(), "--from-list-command");
+ }
+ else
+ {
+ timerText
+ .then("[ \u2B1B ]")
+ .style(ChatColor.RED)
+ .hover(
+ new RawText()
+ .then(timer.getDisplayName())
+ .then("\n").then(I.t("{white}Stop this timer"))
+ )
+ .command(TimersCommand.class, "stop", timer.getName(), "--from-list-command");
+ }
+
+ timerText.then(" ");
+
+ if (timer.isRunning())
+ {
+ timerText
+ .then("[ \u2759 \u2759 ]")
+ .style(timer.isPaused() ? ChatColor.GOLD : ChatColor.YELLOW)
+ .hover(
+ new RawText()
+ .then(timer.getDisplayName())
+ .then("\n").then(timer.isPaused() ? I.t("{white}Resume this timer") : I.t("{white}Pause this timer"))
+ )
+ .command(TimersCommand.class, timer.isPaused() ? "resume" : "pause", timer.getName(), "--from-list-command")
+ .then(" ");
+ }
+
+ timerText
+ .then("[ × ]")
+ .style(ChatColor.DARK_RED)
+ .hover(
+ new RawText()
+ .then(timer.getDisplayName())
+ .then("\n").then(I.t("{white}Delete this timer"))
+ )
+ .command(TimersCommand.class, "remove", timer.getName(), "--from-list-command");
+ }
+
+ send(timerText.build());
+ }
+
+ if (sender instanceof Player)
+ {
+ send(
+ /// Button in /uh timers
+ new RawText(I.t("[ Create a new timer ]"))
+ .color(ChatColor.GREEN)
+ .hover(I.t("{white}Click here to create a timer\n{gray}/uh timers add mm:ss "))
+ .suggest(TimersCommand.class, "add", "")
+
+ /// Button in /uh timers
+ .then(" ").then(I.t("[ Display Help ]"))
+ .color(ChatColor.YELLOW)
+ .hover(I.t("{white}Get some help about the commands\n{gray}/uh timers help"))
+ .command(TimersCommand.class, "help")
+ .build()
+ );
+ }
+ }
+
+ private void pause() throws CommandException
+ {
+ final Timer timer = getTimerParameter(1);
+
+ if (timer.isSystem()) throwNotAuthorized();
+
+ timer.setPaused(true);
+
+ reply(I.t("{cs}The timer {0}{cs} is now paused.", timer.getDisplayName()));
+ }
+
+ private void resume() throws CommandException
+ {
+ final Timer timer = getTimerParameter(1);
+
+ if (timer.isSystem()) throwNotAuthorized();
+
+ timer.setPaused(false);
+
+ reply(I.t("{cs}The timer {0}{cs} was resumed.", timer.getDisplayName()));
+ }
+
+ private void remove() throws CommandException
+ {
+ final Timer timer = getTimerParameter(1);
+
+ if (timer.isSystem()) throwNotAuthorized();
+
+ timer.stop();
+ timersModule.unregisterTimer(timer);
+
+ reply(I.t("{cs}The timer {0}{cs} has been deleted.", timer.getDisplayName()));
+ }
+
+ private void set() throws CommandException
+ {
+ if (args.length < 3) throwInvalidArgument(I.t("You must specify both a duration and a name."));
+
+ final Timer timer = getTimerParameter(2);
+ if (timer.isSystem()) throwNotAuthorized();
+
+ timer.setDuration(getTimeDeltaParameter(1));
+
+ success(I.t("{cs}The duration of the timer {0}{cs} is now {1}.", timer.getDisplayName(), args[1]));
+ }
+
+ private void start() throws CommandException
+ {
+ final Timer timer = getTimerParameter(1);
+
+ if (timer.isSystem()) throwNotAuthorized();
+
+ if (!hasFlag("--hidden"))
+ {
+ timer.setDisplayed(true);
+ timer.setNameDisplayed(!hasFlag("without-name"));
+ }
+
+ if (timer.isRunning()) timer.stop();
+ timer.start();
+
+ reply(I.t("{cs}The timer {0}{cs} was started.", timer.getDisplayName()));
+ }
+
+ private void stop() throws CommandException
+ {
+ final Timer timer = getTimerParameter(1);
+
+ if (timer.isSystem()) throwNotAuthorized();
+
+ timer.stop();
+
+ reply(I.t("{cs}The timer {0}{cs} was stopped.", timer.getDisplayName()));
+ }
+
+
+ private void reply(final String reply) throws CommandException
+ {
+ if (hasFlag("from-list-command") && sender instanceof Player)
+ {
+ MessageSender.sendActionBarMessage(playerSender(), reply);
+ list();
+ }
+
+ else success(reply);
+ }
+
+
+ private Timer getTimerParameter(int index) throws CommandException
+ {
+ try
+ {
+ final String timerName = UHUtils.getStringFromCommandArguments(args, index);
+ final Timer timer = UHCReloaded.getModule(TimersModule.class).getTimer(timerName);
+
+ if (timer == null)
+ throwInvalidArgument(I.t("{ce}This timer is not registered.", timerName));
+
+ return timer;
+ }
+ catch (IllegalArgumentException e)
+ {
+ throwInvalidArgument(I.t("A timer name is required as argument #{0}", index + 1));
+ return null;
+ }
+ }
+
+ private TimeDelta getTimeDeltaParameter(final int index) throws CommandException
+ {
+ try
+ {
+ return new TimeDelta(args[index]);
+ }
+ catch (final ArrayIndexOutOfBoundsException e)
+ {
+ throwInvalidArgument(I.t("A duration is required as argument #{0}. Format: “mm”, “mm:ss” or “hh:mm:ss”.", index + 1));
+ return new TimeDelta(0); // Dummy value never reached to avoid “can be null” lint warnings
+ }
+ catch (final IllegalArgumentException e)
+ {
+ throwInvalidArgument(I.t("The duration provided as argument #{0} is invalid. Format: “mm”, “mm:ss” or “hh:mm:ss”.", index + 1));
+ return new TimeDelta(0); // Dummy value never reached to avoid “can be null” lint warnings
+ }
+ }
+}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerEndsEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerEndsEvent.java
similarity index 92%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerEndsEvent.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerEndsEvent.java
index 626fc2b..4fe5a45 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerEndsEvent.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerEndsEvent.java
@@ -30,9 +30,9 @@
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.events;
+package eu.carrade.amaury.UHCReloaded.modules.core.timers.events;
-import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@@ -44,12 +44,12 @@
*/
public final class TimerEndsEvent extends Event
{
- private UHTimer timer;
+ private Timer timer;
private Boolean timerWasUp = false;
private Boolean restart = false;
- public TimerEndsEvent(UHTimer timer, Boolean timerUp)
+ public TimerEndsEvent(Timer timer, Boolean timerUp)
{
this.timer = timer;
@@ -61,7 +61,7 @@ public TimerEndsEvent(UHTimer timer, Boolean timerUp)
*
* @return the timer.
*/
- public UHTimer getTimer()
+ public Timer getTimer()
{
return timer;
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerStartsEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerStartsEvent.java
similarity index 90%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerStartsEvent.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerStartsEvent.java
index b4c191c..f015d16 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerStartsEvent.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerStartsEvent.java
@@ -30,9 +30,9 @@
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.events;
+package eu.carrade.amaury.UHCReloaded.modules.core.timers.events;
-import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@@ -44,9 +44,9 @@
*/
public final class TimerStartsEvent extends Event
{
- private UHTimer timer;
+ private Timer timer;
- public TimerStartsEvent(UHTimer timer)
+ public TimerStartsEvent(Timer timer)
{
this.timer = timer;
}
@@ -56,7 +56,7 @@ public TimerStartsEvent(UHTimer timer)
*
* @return
*/
- public UHTimer getTimer()
+ public Timer getTimer()
{
return timer;
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java
index 0ec6754..03d7f6e 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java
@@ -54,7 +54,6 @@
import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTPCommand;
import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTPSpawnCommand;
import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTeamCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTimersCommand;
import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
@@ -94,7 +93,6 @@ public UHRootCommand(UHCReloaded plugin)
// Misc
registerSubCommand(new UHFinishCommand(p));
registerSubCommand(new UHFreezeCommand(p));
- registerSubCommand(new UHTimersCommand(p));
registerSubCommand(new UHTPCommand(p));
registerSubCommand(new UHInfosCommand(p));
registerSubCommand(new UHRulesCommand(p));
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java
index 5a92695..ea42728 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java
@@ -32,7 +32,6 @@
package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh;
import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.borders.exceptions.CannotGenerateWallsException;
import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category;
import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
@@ -90,23 +89,22 @@ else if (sender instanceof BlockCommandSender)
sender.sendMessage(I.t("{ci}From the console, generating the walls of the default world, {0}", world.getName()));
}
- try
- {
- p.getBorderManager().generateWalls(world);
-
- }
- catch (CannotGenerateWallsException e)
- {
- sender.sendMessage(I.t("{ce}Unable to generate the wall: see logs for details. The blocks set in the config are probably invalid."));
- return;
-
- }
- catch (Exception e)
- {
- sender.sendMessage(I.t("{ce}An error occurred, see console for details."));
- e.printStackTrace();
- return;
- }
+// try
+// {
+// p.getBorderManager().generateWalls(world);
+// }
+// catch (CannotGenerateWallsException e)
+// {
+// sender.sendMessage(I.t("{ce}Unable to generate the wall: see logs for details. The blocks set in the config are probably invalid."));
+// return;
+//
+// }
+// catch (Exception e)
+// {
+// sender.sendMessage(I.t("{ce}An error occurred, see console for details."));
+// e.printStackTrace();
+// return;
+// }
sender.sendMessage(I.t("{cst}Generation done."));
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTimersCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTimersCommand.java
deleted file mode 100644
index 04f0526..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTimersCommand.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersAddCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersDisplayCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersHideCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersListCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersPauseCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersRemoveCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersResumeCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersSetCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersStartCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersStopCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * This command manages timers.
- *
- * Usage: /uh timers < add | set | display | hide | start | pause | resume | stop | remove | list >
- */
-@Command (name = "timers")
-public class UHTimersCommand extends AbstractCommand
-{
- public UHTimersCommand(UHCReloaded plugin)
- {
- registerSubCommand(new UHTimersAddCommand(plugin));
- registerSubCommand(new UHTimersSetCommand(plugin));
- registerSubCommand(new UHTimersDisplayCommand(plugin));
- registerSubCommand(new UHTimersHideCommand(plugin));
- registerSubCommand(new UHTimersStartCommand(plugin));
- registerSubCommand(new UHTimersPauseCommand(plugin));
- registerSubCommand(new UHTimersResumeCommand(plugin));
- registerSubCommand(new UHTimersStopCommand(plugin));
- registerSubCommand(new UHTimersRemoveCommand(plugin));
- registerSubCommand(new UHTimersListCommand(plugin));
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this);
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- return null;
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return Collections.singletonList(I.t("{aqua}------ Timers commands ------"));
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh timers {ci}: manages the timers. See /uh timers for details."));
- }
-
- @Override
- public String getCategory()
- {
- return Category.MISC.getTitle();
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java
index 7dc54ee..51b7bdd 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java
@@ -64,8 +64,7 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand
{
try
{
- p.getBorderManager().sendCheckMessage(sender, Integer.valueOf(args[0]));
-
+// p.getBorderManager().sendCheckMessage(sender, Integer.valueOf(args[0]));
}
catch (NumberFormatException e)
{
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java
index f319394..66cab42 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java
@@ -32,7 +32,6 @@
package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border;
import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.borders.MapShape;
import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
@@ -55,14 +54,14 @@ public UHBorderGetCommand(UHCReloaded p)
@Override
public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
{
- if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR)
- {
- sender.sendMessage(I.tn("{ci}The current diameter of the map is {0} block.", "{ci}The current diameter of the map is {0} blocks.", p.getBorderManager().getCurrentBorderDiameter()));
- }
- else
- {
- sender.sendMessage(I.t("{ci}The current map size is {0}×{0}.", p.getBorderManager().getCurrentBorderDiameter()));
- }
+// if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR)
+// {
+// sender.sendMessage(I.tn("{ci}The current diameter of the map is {0} block.", "{ci}The current diameter of the map is {0} blocks.", p.getBorderManager().getCurrentBorderDiameter()));
+// }
+// else
+// {
+// sender.sendMessage(I.t("{ci}The current map size is {0}×{0}.", p.getBorderManager().getCurrentBorderDiameter()));
+// }
}
@Override
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java
index 916d686..ec83ece 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java
@@ -32,7 +32,6 @@
package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border;
import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.borders.MapShape;
import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
@@ -56,75 +55,75 @@ public UHBorderSetCommand(UHCReloaded p)
@Override
public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
{
- // /uh border set
- if (args.length == 0)
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
- }
-
- // /uh border set >
- else if (args.length == 1)
- {
- try
- {
- final int newDiameter = Integer.valueOf(args[0]);
-
- // Some players are outside
- if (p.getBorderManager().getPlayersOutside(newDiameter).size() != 0)
- {
- sender.sendMessage(I.t("{ce}Some players are outside the future border, so this operation was cancelled."));
- sender.sendMessage(I.t("{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to this point.", args[0]));
-
- if (!p.getWorldBorderIntegration().isWBIntegrationEnabled())
- {
- sender.sendMessage(I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!"));
- }
-
- p.getBorderManager().sendCheckMessage(sender, newDiameter);
- }
- else
- {
- p.getBorderManager().setCurrentBorderDiameter(newDiameter);
-
- if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR)
- {
- p.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter));
- }
- else
- {
- p.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter));
- }
- }
- }
- catch (NumberFormatException e)
- {
- sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0]));
- }
- }
-
- // /uh border set > force
- else if (args.length == 2 && args[1].equalsIgnoreCase("force"))
- {
- try
- {
- Integer newDiameter = Integer.valueOf(args[0]);
-
- p.getBorderManager().setCurrentBorderDiameter(newDiameter);
-
- if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR)
- {
- p.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter));
- }
- else
- {
- p.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter));
- }
- }
- catch (NumberFormatException e)
- {
- sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0]));
- }
- }
+// // /uh border set
+// if (args.length == 0)
+// {
+// throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
+// }
+//
+// // /uh border set >
+// else if (args.length == 1)
+// {
+// try
+// {
+// final int newDiameter = Integer.valueOf(args[0]);
+//
+// // Some players are outside
+// if (p.getBorderManager().getPlayersOutside(newDiameter).size() != 0)
+// {
+// sender.sendMessage(I.t("{ce}Some players are outside the future border, so this operation was cancelled."));
+// sender.sendMessage(I.t("{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to this point.", args[0]));
+//
+// if (!p.getWorldBorderIntegration().isWBIntegrationEnabled())
+// {
+// sender.sendMessage(I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!"));
+// }
+//
+// p.getBorderManager().sendCheckMessage(sender, newDiameter);
+// }
+// else
+// {
+// p.getBorderManager().setCurrentBorderDiameter(newDiameter);
+//
+// if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR)
+// {
+// p.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter));
+// }
+// else
+// {
+// p.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter));
+// }
+// }
+// }
+// catch (NumberFormatException e)
+// {
+// sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0]));
+// }
+// }
+//
+// // /uh border set > force
+// else if (args.length == 2 && args[1].equalsIgnoreCase("force"))
+// {
+// try
+// {
+// Integer newDiameter = Integer.valueOf(args[0]);
+//
+// p.getBorderManager().setCurrentBorderDiameter(newDiameter);
+//
+// if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR)
+// {
+// p.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter));
+// }
+// else
+// {
+// p.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter));
+// }
+// }
+// catch (NumberFormatException e)
+// {
+// sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0]));
+// }
+// }
}
@Override
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java
index 481bd91..807e3d7 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java
@@ -69,7 +69,7 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand
}
else if (args[0].equalsIgnoreCase("cancel"))
{ // /uh border warning cancel
- p.getBorderManager().cancelWarning();
+ // p.getBorderManager().cancelWarning();
sender.sendMessage(I.t("{cs}Warning canceled."));
}
else
@@ -85,7 +85,7 @@ else if (args[0].equalsIgnoreCase("cancel"))
warnTime = Integer.parseInt(args[1]);
}
- p.getBorderManager().setWarningSize(warnDiameter, warnTime, sender);
+ // p.getBorderManager().setWarningSize(warnDiameter, warnTime, sender);
sender.sendMessage(I.tn("{cs}Future size saved. All players outside this future border will be warned every {0} second.", "{cs}Future size saved. All players outside this future border will be warned every {0} seconds.", WARNING_INTERVAL));
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java
index 12347b2..9df5607 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java
@@ -93,7 +93,7 @@ else if (sender instanceof BlockCommandSender)
Player pl = (Player) sender; // Just a way to avoid casts everywhere.
try
{
- p.getSpawnsManager().addSpawnPoint(pl.getLocation());
+ // p.getSpawnsManager().addSpawnPoint(pl.getLocation());
sender.sendMessage(I.t("{cs}Spawn added in the world {0}: {1};{2}", world.getName(), String.valueOf(pl.getLocation().getBlockX()), String.valueOf(pl.getLocation().getBlockZ())));
}
catch (IllegalArgumentException e)
@@ -118,7 +118,7 @@ else if (args.length == 1)
{
try
{
- p.getSpawnsManager().addSpawnPoint(world, Double.parseDouble(args[0]), Double.parseDouble(args[1]));
+ // p.getSpawnsManager().addSpawnPoint(world, Double.parseDouble(args[0]), Double.parseDouble(args[1]));
sender.sendMessage(I.t("{cs}Spawn added in the world {0}: {1};{2}", world.getName(), args[0], args[1]));
}
catch (NumberFormatException e)
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java
index 45c6fed..cf1cddf 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java
@@ -75,10 +75,10 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand
spanwsInWorlds.put(world, new LinkedList<>());
}
- for (Location spawn : p.getSpawnsManager().getSpawnPoints())
- {
- spanwsInWorlds.get(spawn.getWorld()).add(spawn);
- }
+// for (Location spawn : p.getSpawnsManager().getSpawnPoints())
+// {
+// spanwsInWorlds.get(spawn.getWorld()).add(spawn);
+// }
StringBuilder dump = new StringBuilder();
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java
index 35bfeba..50640bf 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java
@@ -32,13 +32,11 @@
package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns;
import eu.carrade.amaury.UHCReloaded.UHCReloaded;
+import eu.carrade.amaury.UHCReloaded.modules.core.spawns.Generator;
import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.spawns.Generator;
-import eu.carrade.amaury.UHCReloaded.spawns.exceptions.CannotGenerateSpawnPointsException;
-import eu.carrade.amaury.UHCReloaded.spawns.exceptions.UnknownGeneratorException;
import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam;
import fr.zcraft.zlib.components.i18n.I;
import org.bukkit.World;
@@ -73,7 +71,6 @@ public UHSpawnsGenerateCommand(UHCReloaded plugin)
@Override
public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
{
-
if (args.length == 0)
{ // Help
throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this);
@@ -82,7 +79,7 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand
String generationMethod = args[0];
// Default values
- int size = p.getBorderManager().getCurrentBorderDiameter() - 25; // Avoid spawn points being too close to the border
+ int size = 0; //p.getBorderManager().getCurrentBorderDiameter() - 25; // Avoid spawn points being too close to the border
int distanceMinBetweenTwoPoints = 250;
World world = p.getServer().getWorlds().get(0);
double xCenter = world.getSpawnLocation().getX();
@@ -195,22 +192,21 @@ else if (sender instanceof BlockCommandSender)
}
- try
- {
- p.getSpawnsManager().generateSpawnPoints(generationMethod, world, spawnsCount, size, distanceMinBetweenTwoPoints, xCenter, zCenter);
-
- }
- catch (UnknownGeneratorException e)
- {
- sender.sendMessage(I.t("{ce}The generation method “{0}” is not (yet?) supported.", generationMethod));
- return;
-
- }
- catch (CannotGenerateSpawnPointsException e)
- {
- sender.sendMessage(I.t("{ce}You asked for the impossible: there are too many spawn points on a too small surface. Decrease the spawn count or the minimal distance between two points."));
- return;
- }
+// try
+// {
+// p.getSpawnsManager().generateSpawnPoints(generationMethod, world, spawnsCount, size, distanceMinBetweenTwoPoints, xCenter, zCenter);
+// }
+// catch (UnknownGeneratorException e)
+// {
+// sender.sendMessage(I.t("{ce}The generation method “{0}” is not (yet?) supported.", generationMethod));
+// return;
+//
+// }
+// catch (CannotGenerateSpawnPointsException e)
+// {
+// sender.sendMessage(I.t("{ce}You asked for the impossible: there are too many spawn points on a too small surface. Decrease the spawn count or the minimal distance between two points."));
+// return;
+// }
sender.sendMessage(I.t("{cs}Successfully generated the asked spawn points."));
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java
index 87700e8..eecf361 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java
@@ -40,6 +40,7 @@
import org.bukkit.World;
import org.bukkit.command.CommandSender;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
@@ -68,7 +69,7 @@ public UHSpawnsListCommand(UHCReloaded plugin)
@Override
public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
{
- List spawnPoints = p.getSpawnsManager().getSpawnPoints();
+ List spawnPoints = new ArrayList<>(); // p.getSpawnsManager().getSpawnPoints();
if (spawnPoints.size() == 0)
{
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java
index db1e09e..b0f3917 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java
@@ -36,7 +36,6 @@
import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -76,7 +75,7 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand
else
{
Player pl = (Player) sender; // Just a way to avoid casts everywhere.
- p.getSpawnsManager().removeSpawnPoint(pl.getLocation(), false);
+ // p.getSpawnsManager().removeSpawnPoint(pl.getLocation(), false);
sender.sendMessage(I.t("{cs}The spawn point {1};{2} in the world {0} was removed.", pl.getWorld().getName(), String.valueOf(pl.getLocation().getBlockX()), String.valueOf(pl.getLocation().getBlockZ())));
}
}
@@ -98,7 +97,7 @@ else if (args.length == 1)
world = p.getServer().getWorlds().get(0);
}
- p.getSpawnsManager().removeSpawnPoint(new Location(world, Double.parseDouble(args[2]), 0, Double.parseDouble(args[3])), true);
+ // p.getSpawnsManager().removeSpawnPoint(new Location(world, Double.parseDouble(args[2]), 0, Double.parseDouble(args[3])), true);
sender.sendMessage(I.t("{cs}The spawn point {1};{2} in the world {0} was removed.", p.getServer().getWorlds().get(0).getName(), args[2], args[3]));
}
catch (NumberFormatException e)
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java
index 3f8cc14..f06e09a 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java
@@ -63,7 +63,7 @@ public UHSpawnsResetCommand(UHCReloaded plugin)
@Override
public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
{
- p.getSpawnsManager().reset();
+ // p.getSpawnsManager().reset();
sender.sendMessage(I.t("{cs}All the spawn points were removed."));
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersAddCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersAddCommand.java
deleted file mode 100644
index 36fa46d..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersAddCommand.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.Collections;
-import java.util.List;
-
-
-/**
- * Usage: /uh timers add
- */
-@Command (name = "add")
-public class UHTimersAddCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHTimersAddCommand(UHCReloaded p)
- {
- this.p = p;
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
-
- if (args.length < 2)
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
- }
-
- else
- {
- try
- {
- Integer duration = UHUtils.string2Time(args[0]);
- String timerName = UHUtils.getStringFromCommandArguments(args, 1);
-
- if (p.getTimerManager().getTimer(timerName) != null)
- {
- sender.sendMessage(I.t("{ce}A timer called {0}{ce} already exists; please choose another name.", timerName));
- return;
- }
-
- UHTimer timer = new UHTimer(timerName);
- timer.setDuration(duration);
-
- p.getTimerManager().registerTimer(timer);
- sender.sendMessage(I.t("{cs}The timer {0}{cs} (duration {1}) has been registered.", timer.getDisplayName(), args[0]));
-
- }
- catch (IllegalArgumentException e)
- {
- sender.sendMessage(I.t("{ce}The duration' syntax is invalid; accepted formats are mm, mm:ss or hh:mm:ss."));
- }
- }
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- return null;
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh timers add {ci}: adds a timer."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersDisplayCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersDisplayCommand.java
deleted file mode 100644
index c6e4504..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersDisplayCommand.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-
-@Command (name = "display")
-public class UHTimersDisplayCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHTimersDisplayCommand(UHCReloaded p)
- {
- this.p = p;
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- if (args.length == 0)
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
- }
-
- String timerName = UHUtils.getStringFromCommandArguments(args, 0);
- UHTimer timer = p.getTimerManager().getTimer(timerName);
-
- if (timer == null)
- {
- sender.sendMessage(I.t("{ce}This timer is not registered."));
- return;
- }
-
- sender.sendMessage(I.t("{cs}The timer {0}{cs} is now displayed.", timer.getDisplayName()));
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- List suggestions = new ArrayList<>();
-
- for (UHTimer timer : p.getTimerManager().getTimers())
- {
- suggestions.add(timer.getName());
- }
-
- return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1);
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh timers display {ci}: displays a timer in the scoreboard. Automatic when a timer is started."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersHideCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersHideCommand.java
deleted file mode 100644
index 3575b22..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersHideCommand.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-
-@Command (name = "hide")
-public class UHTimersHideCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHTimersHideCommand(UHCReloaded p)
- {
- this.p = p;
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- if (args.length == 0)
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
- }
-
- String timerName = UHUtils.getStringFromCommandArguments(args, 0);
-
- UHTimer timer = p.getTimerManager().getTimer(timerName);
- if (timer == null)
- {
- sender.sendMessage(I.t("{ce}This timer is not registered."));
- return;
- }
-
- sender.sendMessage(I.t("{cs}The timer {0}{cs} is now hidden.", timer.getDisplayName()));
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- List suggestions = new ArrayList<>();
-
- for (UHTimer timer : p.getTimerManager().getTimers())
- {
- suggestions.add(timer.getName());
- }
-
- return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1);
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh timers hide {ci}: removes a timer from the scoreboard. Don't stops the timer."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersListCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersListCommand.java
deleted file mode 100644
index ac08925..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersListCommand.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-
-@Command (name = "list")
-public class UHTimersListCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHTimersListCommand(UHCReloaded p)
- {
- this.p = p;
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- Collection timers = p.getTimerManager().getTimers();
-
- sender.sendMessage(I.tn("{ci}{0} timer is registered.", "{ci}{0} timers are registered.", timers.size()));
-
- for (UHTimer timer : timers)
- {
- if (timer.isRunning())
- {
- if (timer.isPaused())
- {
- sender.sendMessage(I.tn("{yellow} • {{ci}{0}{ci} - total {1} second - {2}", "{yellow} • {{ci}{0}{ci} - total {1} seconds - {2}",
- timer.getDuration(),
- timer.getDisplayName(),
- timer.getDuration(),
- timer.toString()
- ));
- }
- else
- {
- sender.sendMessage(I.tn("{green} • {ci}{0}{ci} - total {1} second - {2}", "{green} • {ci}{0}{ci} - total {1} seconds - {2}",
- timer.getDuration(),
- timer.getDisplayName(),
- timer.getDuration(),
- timer.toString()
- ));
- }
- }
- else
- {
- sender.sendMessage(I.tn("{red} • {ci}{0}{ci} - total {1} second", "{red} • {ci}{0}{ci} - total {1} seconds",
- timer.getDuration(),
- timer.getDisplayName(),
- timer.getDuration()
- ));
- }
- }
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- List suggestions = new ArrayList<>();
-
- for (UHTimer timer : p.getTimerManager().getTimers())
- {
- suggestions.add(timer.getName());
- }
-
- return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1);
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh timers list {ci}: lists the registered timers."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersPauseCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersPauseCommand.java
deleted file mode 100644
index edff3a6..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersPauseCommand.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-
-@Command (name = "pause")
-public class UHTimersPauseCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHTimersPauseCommand(UHCReloaded p)
- {
- this.p = p;
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- if (args.length == 0)
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
- }
-
- String timerName = UHUtils.getStringFromCommandArguments(args, 0);
- UHTimer timer = p.getTimerManager().getTimer(timerName);
-
- if (timer == null)
- {
- sender.sendMessage(I.t("{ce}This timer is not registered."));
- return;
- }
-
- timer.setPaused(true);
- sender.sendMessage(I.t("{cs}The timer {0}{cs} is now paused.", timer.getDisplayName()));
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- List suggestions = new ArrayList<>();
-
- for (UHTimer timer : p.getTimerManager().getTimers())
- {
- suggestions.add(timer.getName());
- }
-
- return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1);
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh timers pause {ci}: pauses a timer."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersRemoveCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersRemoveCommand.java
deleted file mode 100644
index 3b47183..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersRemoveCommand.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-
-@Command (name = "remove")
-public class UHTimersRemoveCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHTimersRemoveCommand(UHCReloaded p)
- {
- this.p = p;
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- if (args.length == 0)
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
- }
-
- String timerName = UHUtils.getStringFromCommandArguments(args, 0);
- UHTimer timer = p.getTimerManager().getTimer(timerName);
-
- if (timer == null)
- {
- sender.sendMessage(I.t("{ce}This timer is not registered."));
- return;
- }
-
- p.getTimerManager().unregisterTimer(timer);
- timer.stop();
-
- sender.sendMessage(I.t("{cs}The timer {0}{cs} has been deleted.", timer.getDisplayName()));
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- List suggestions = new ArrayList<>();
-
- for (UHTimer timer : p.getTimerManager().getTimers())
- {
- suggestions.add(timer.getName());
- }
-
- return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1);
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh timers remove {ci}: deletes a timer."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersResumeCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersResumeCommand.java
deleted file mode 100644
index aeb4b2c..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersResumeCommand.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-
-@Command (name = "resume")
-public class UHTimersResumeCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHTimersResumeCommand(UHCReloaded p)
- {
- this.p = p;
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- if (args.length == 0)
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
- }
-
- String timerName = UHUtils.getStringFromCommandArguments(args, 0);
- UHTimer timer = p.getTimerManager().getTimer(timerName);
-
- if (timer == null)
- {
- sender.sendMessage(I.t("{ce}This timer is not registered."));
- return;
- }
-
- timer.setPaused(false);
- sender.sendMessage(I.t("{cs}The timer {0}{cs} was resumed.", timer.getDisplayName()));
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- List suggestions = new ArrayList<>();
-
- for (UHTimer timer : p.getTimerManager().getTimers())
- {
- suggestions.add(timer.getName());
- }
-
- return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1);
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh timers resume {ci}: resumes a timer."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersSetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersSetCommand.java
deleted file mode 100644
index 08cce95..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersSetCommand.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-
-/**
- * Usage: /uh timers set
- */
-@Command (name = "set")
-public class UHTimersSetCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHTimersSetCommand(UHCReloaded p)
- {
- this.p = p;
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
-
- if (args.length < 2)
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
- }
-
- else
- {
- try
- {
- Integer duration = UHUtils.string2Time(args[0]);
- String timerName = UHUtils.getStringFromCommandArguments(args, 1);
-
- UHTimer timer = p.getTimerManager().getTimer(timerName);
- if (timer == null)
- {
- sender.sendMessage(I.t("{ce}This timer is not registered."));
- return;
- }
-
- timer.setDuration(duration);
- sender.sendMessage(I.t("{cs}The duration of the timer {0}{cs} is now {1}.", timer.getDisplayName(), args[0]));
-
- }
- catch (IllegalArgumentException e)
- {
- sender.sendMessage(I.t("{ce}The duration' syntax is invalid; accepted formats are mm, mm:ss or hh:mm:ss."));
- }
- }
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
-
- if (args.length >= 2)
- {
- List suggestions = new ArrayList<>();
-
- for (UHTimer timer : p.getTimerManager().getTimers())
- {
- suggestions.add(timer.getName());
- }
-
- return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 1), suggestions, args.length - 2);
- }
-
- else return null;
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh timers set {ci}: sets the duration of a timer."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStartCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStartCommand.java
deleted file mode 100644
index 398440f..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStartCommand.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-
-@Command (name = "start")
-public class UHTimersStartCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHTimersStartCommand(UHCReloaded p)
- {
- this.p = p;
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- if (args.length == 0)
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
- }
-
- String timerName = UHUtils.getStringFromCommandArguments(args, 0);
- UHTimer timer = p.getTimerManager().getTimer(timerName);
-
- if (timer == null)
- {
- sender.sendMessage(I.t("{ce}This timer is not registered."));
- return;
- }
-
- if (timer.isRunning())
- {
- timer.stop();
- }
-
- timer.start();
- sender.sendMessage(I.t("{cs}The timer {0}{cs} was started.", timer.getDisplayName()));
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- List suggestions = new ArrayList<>();
-
- for (UHTimer timer : p.getTimerManager().getTimers())
- {
- suggestions.add(timer.getName());
- }
-
- return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1);
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh timers start {ci}: starts a timer."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStopCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStopCommand.java
deleted file mode 100644
index 6107a46..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStopCommand.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-
-@Command (name = "stop")
-public class UHTimersStopCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHTimersStopCommand(UHCReloaded p)
- {
- this.p = p;
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- if (args.length == 0)
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
- }
-
- String timerName = UHUtils.getStringFromCommandArguments(args, 0);
- UHTimer timer = p.getTimerManager().getTimer(timerName);
-
- if (timer == null)
- {
- sender.sendMessage(I.t("{ce}This timer is not registered."));
- return;
- }
-
- timer.stop();
- sender.sendMessage(I.t("{cs}The timer {0}{cs} was stopped.", timer.getDisplayName()));
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- List suggestions = new ArrayList<>();
-
- for (UHTimer timer : p.getTimerManager().getTimers())
- {
- suggestions.add(timer.getName());
- }
-
- return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1);
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh timers stop {ci}: stops a timer. The timer will be removed from the scoreboard."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java
index 5c6276f..5897dc2 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java
@@ -35,8 +35,8 @@
import eu.carrade.amaury.UHCReloaded.UHCReloaded;
import eu.carrade.amaury.UHCReloaded.UHConfig;
import eu.carrade.amaury.UHCReloaded.events.EpisodeChangedCause;
-import eu.carrade.amaury.UHCReloaded.events.TimerEndsEvent;
-import eu.carrade.amaury.UHCReloaded.events.TimerStartsEvent;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerStartsEvent;
import eu.carrade.amaury.UHCReloaded.events.UHEpisodeChangedEvent;
import eu.carrade.amaury.UHCReloaded.events.UHGameEndsEvent;
import eu.carrade.amaury.UHCReloaded.events.UHGameStartsEvent;
@@ -560,24 +560,24 @@ else if (p.getTeamChatManager().isOtherTeamChatEnabled(ev.getPlayer()))
@EventHandler
public void onTimerEnds(final TimerEndsEvent ev)
{
- p.getTimerManager().updateStartedTimersList();
-
- if (ev.getTimer().equals(p.getTimerManager().getMainTimer()))
- {
- // If this timer is the main one, we shifts an episode.
- p.getGameManager().shiftEpisode();
- ev.setRestart(true);
- }
- else
- {
- ev.getTimer().setDisplayed(false);
- }
-
- if (ev.getTimer().equals(p.getBorderManager().getWarningTimer()) && ev.wasTimerUp())
- {
- p.getBorderManager().getWarningSender().sendMessage(I.t("{cs}The timer before the new border is up!"));
- p.getBorderManager().sendCheckMessage(p.getBorderManager().getWarningSender(), p.getBorderManager().getWarningSize());
- }
+// p.getTimerManager().updateStartedTimersList();
+//
+// if (ev.getTimer().equals(p.getTimerManager().getMainTimer()))
+// {
+// // If this timer is the main one, we shifts an episode.
+// p.getGameManager().shiftEpisode();
+// ev.setRestart(true);
+// }
+// else
+// {
+// ev.getTimer().setDisplayed(false);
+// }
+//
+// if (ev.getTimer().equals(p.getBorderManager().getWarningTimer()) && ev.wasTimerUp())
+// {
+// p.getBorderManager().getWarningSender().sendMessage(I.t("{cs}The timer before the new border is up!"));
+// p.getBorderManager().sendCheckMessage(p.getBorderManager().getWarningSender(), p.getBorderManager().getWarningSize());
+// }
}
/**
@@ -588,12 +588,12 @@ public void onTimerEnds(final TimerEndsEvent ev)
@EventHandler
public void onTimerStarts(final TimerStartsEvent ev)
{
- p.getTimerManager().updateStartedTimersList();
-
- if (!ev.getTimer().equals(p.getTimerManager().getMainTimer()))
- {
- ev.getTimer().setDisplayed(true);
- }
+// p.getTimerManager().updateStartedTimersList();
+//
+// if (!ev.getTimer().equals(p.getTimerManager().getMainTimer()))
+// {
+// ev.getTimer().setDisplayed(true);
+// }
}
@@ -665,7 +665,7 @@ public void onGameStarts(final UHGameStartsEvent ev)
p.getRuntimeCommandsExecutor().registerCommandsInScheduler(RuntimeCommandsExecutor.AFTER_GAME_START);
// Border shrinking
- p.getBorderManager().scheduleBorderReduction();
+// p.getBorderManager().scheduleBorderReduction();
// MOTD
p.getMOTDManager().updateMOTDDuringGame();
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java
index 6f25beb..359c0e3 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java
@@ -118,7 +118,7 @@ public void setGlobalFreezeState(Boolean frozen, Boolean showStateInScoreboard)
.forEach(entity -> freezeCreature((Creature) entity, true));
// Freezes the timers.
- p.getTimerManager().pauseAllRunning(true);
+ // TODO p.getTimerManager().pauseAllRunning(true);
}
else
@@ -136,7 +136,7 @@ public void setGlobalFreezeState(Boolean frozen, Boolean showStateInScoreboard)
.forEach(entity -> freezeCreature((Creature) entity, false));
// Unfreezes the timers.
- p.getTimerManager().pauseAllRunning(false);
+ // TODO p.getTimerManager().pauseAllRunning(false);
}
updateListenerRegistration();
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java
index 3e5f900..dcdcf3d 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java
@@ -33,12 +33,12 @@
import eu.carrade.amaury.UHCReloaded.UHCReloaded;
import eu.carrade.amaury.UHCReloaded.UHConfig;
-import eu.carrade.amaury.UHCReloaded.old.borders.MapShape;
-import eu.carrade.amaury.UHCReloaded.old.borders.worldborders.WorldBorder;
+import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape;
+import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder;
import eu.carrade.amaury.UHCReloaded.game.UHGameManager;
import eu.carrade.amaury.UHCReloaded.old.misc.Freezer;
import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam;
-import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer;
import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
import fr.zcraft.zlib.components.i18n.I;
import fr.zcraft.zlib.components.scoreboard.Sidebar;
@@ -56,7 +56,7 @@
public class GameSidebar extends Sidebar
{
private final UHGameManager gameManager;
- private final WorldBorder border;
+ private final WorldBorder border = null;
private final boolean EPISODES_ENABLED;
private final boolean EPISODES_IN_SIDEBAR;
@@ -92,7 +92,7 @@ public class GameSidebar extends Sidebar
public GameSidebar()
{
gameManager = UHCReloaded.get().getGameManager();
- border = UHCReloaded.get().getBorderManager().getBorderProxy();
+ // border = UHCReloaded.get().getBorderManager().getBorderProxy();
EPISODES_ENABLED = UHConfig.EPISODES.ENABLED.get();
EPISODES_IN_SIDEBAR = UHConfig.SCOREBOARD.EPISODE.get();
@@ -116,7 +116,7 @@ public GameSidebar()
BORDER_DISPLAY_DIAMETER = UHConfig.SCOREBOARD.BORDER.DISPLAY_DIAMETER.get();
- FROOZEN_NULL_TIMER_TEXT = new UHTimer("").toString();
+ FROOZEN_NULL_TIMER_TEXT = new Timer("").toString();
setAsync(true);
setAutoRefreshDelay(20);
@@ -181,8 +181,8 @@ public void preRender()
sidebarTimers.add(FROOZEN_NULL_TIMER_TEXT);
else
{
- final UHTimer mainTimer = UHCReloaded.get().getTimerManager().getMainTimer();
- if (mainTimer != null) sidebarTimers.add(mainTimer.toString());
+ //final Timer mainTimer = UHCReloaded.get().getTimerManager().getMainTimer();
+ //if (mainTimer != null) sidebarTimers.add(mainTimer.toString());
}
}
}
@@ -357,11 +357,11 @@ private void insertBorder(List sidebar)
*/
private void insertTimers(List sidebar)
{
- UHCReloaded.get().getTimerManager().getTimers().stream().filter(UHTimer::isDisplayed).forEach(timer -> {
- sidebar.add(timer.getDisplayName());
- sidebar.add(timer.toString());
- sidebar.add("");
- });
+// UHCReloaded.get().getTimerManager().getTimers().stream().filter(Timer::isDisplayed).forEach(timer -> {
+// sidebar.add(timer.getDisplayName());
+// sidebar.add(timer.toString());
+// sidebar.add("");
+// });
}
/**
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index b5d5558..bb43f46 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -13,8 +13,18 @@
# Available languages: en_US, fr_FR, pt_PT, pt_BR, cs_CZ, zh_CN.
# Empty value: system language.
-lang:
-
+lang:
+
+# The modules to load & enable. You can add modules provided by other plugins.
+# Each module's configuration is in plugins/UHPlugin/modules/.yml .
+modules:
+
+# The worlds to use as main worlds.
+# If not found, fallbacks on the first world found with the right type.
+worlds:
+ overworld: world
+ nether: world_nether
+ the_end: world_the_end
episodes:
From 091c3e60a3cd15459c898a0248f911f8a9b450eb Mon Sep 17 00:00:00 2001
From: Amaury Carrade
Date: Thu, 22 Nov 2018 02:30:00 +0100
Subject: [PATCH 03/91] Continuous improvements on modules and border modules.
- NEW: Finished border modules (split into four different modules) and commands.
- OPT: Improved modules discovery from string, with better handling of modules in sub-packages.
- NEW: Added toString method to TimeDelta (displaying mm:ss or hh:mm:ss).
- NEW: Commands should be registerable anytime now, including when the game is started/ended.
- NEW: Added a specific logger for each module.
- NEW: Added shortcuts classes for better and easier development and module/logger access from non-main module class.
- OPT: Improved /uh modules with colored dot for status and ordered modules by status/internal/name.
- OPT: The log is more verbose.
---
.../amaury/UHCReloaded/UHCReloaded.java | 80 ++++---
.../amaury/UHCReloaded/core/ModuleInfo.java | 2 +-
.../amaury/UHCReloaded/core/ModuleLogger.java | 108 ++++++++++
.../UHCReloaded/core/ModuleWrapper.java | 23 +-
.../amaury/UHCReloaded/core/UHModule.java | 12 ++
.../events}/AllModulesLoadedEvent.java | 2 +-
.../events}/ModuleLoadedEvent.java | 10 +-
.../events}/ModuleUnloadedEvent.java | 2 +-
.../UHCReloaded/game/UHGameManager.java | 8 +-
.../modules/border/check/CheckCommand.java | 63 ++++++
.../modules/border/check/CheckModule.java | 55 +++++
.../modules/border/walls/Config.java | 62 ++++++
.../modules/border/walls/WallsCommand.java | 89 ++++++++
.../modules/border/walls/WallsModule.java | 98 +++++++++
.../CannotGenerateWallsException.java | 2 +-
.../exceptions/UnknownWallGenerator.java | 4 +-
.../generators/CircularWallGenerator.java | 2 +-
.../generators/SquaredWallGenerator.java | 2 +-
.../walls}/generators/WallGenerator.java | 34 ++-
.../walls}/generators/WallPosition.java | 2 +-
.../warning}/BorderWarningTask.java | 21 +-
.../modules/border/warning/Config.java | 51 +++++
.../border/warning/WarningCommand.java | 102 +++++++++
.../modules/border/warning/WarningModule.java | 198 ++++++++++++++++++
.../modules/core/border/BorderManager.java | 55 -----
.../modules/core/border/BorderModule.java | 182 ++--------------
.../modules/core/border/Config.java | 23 +-
.../modules/core/border/MapShape.java | 60 +-----
.../core/border/commands/BorderCommand.java | 179 ++++++++++++++++
.../border/events/BorderChangedEvent.java | 65 ++++++
.../worldborders/BrettflanWorldBorder.java | 6 +
.../border/worldborders/FakeWorldBorder.java | 6 +
.../worldborders/VanillaWorldBorder.java | 6 +
.../core/border/worldborders/WorldBorder.java | 5 +
.../modules/core/game/GameModule.java | 6 +-
.../game/events/GamePhaseChangedEvent.java | 10 +-
.../modules/core/modules/ModulesCommand.java | 37 +++-
.../modules/core/timers/TimeDelta.java | 21 ++
.../old/commands/commands/UHRootCommand.java | 26 +--
.../commands/commands/uh/UHBorderCommand.java | 97 ---------
.../commands/uh/UHGenerateWallsCommand.java | 143 -------------
.../commands/commands/uh/UHTeamCommand.java | 127 -----------
.../uh/border/UHBorderCheckCommand.java | 93 --------
.../uh/border/UHBorderGetCommand.java | 84 --------
.../uh/border/UHBorderSetCommand.java | 151 -------------
.../uh/border/UHBorderWarningCommand.java | 121 -----------
.../commands/uh/team/UHTeamAddCommand.java | 166 ---------------
.../commands/uh/team/UHTeamBannerCommand.java | 111 ----------
.../uh/team/UHTeamBannerResetCommand.java | 110 ----------
.../commands/uh/team/UHTeamGUICommand.java | 82 --------
.../commands/uh/team/UHTeamJoinCommand.java | 185 ----------------
.../commands/uh/team/UHTeamLeaveCommand.java | 145 -------------
.../commands/uh/team/UHTeamListCommand.java | 122 -----------
.../commands/uh/team/UHTeamRemoveCommand.java | 121 -----------
.../commands/uh/team/UHTeamResetCommand.java | 95 ---------
.../commands/uh/team/UHTeamSpyCommand.java | 125 -----------
.../{ => old}/events/EpisodeChangedCause.java | 2 +-
.../events/UHEpisodeChangedEvent.java | 2 +-
.../{ => old}/events/UHGameEndsEvent.java | 2 +-
.../{ => old}/events/UHGameStartsEvent.java | 2 +-
.../{ => old}/events/UHPlayerDeathEvent.java | 2 +-
.../events/UHPlayerResurrectedEvent.java | 2 +-
.../{ => old}/events/UHTeamDeathEvent.java | 2 +-
.../old/listeners/BeforeGameListener.java | 2 +-
.../old/listeners/GameListener.java | 14 +-
.../scoreboard/ScoreboardListener.java | 4 +-
.../amaury/UHCReloaded/shortcuts/UR.java | 86 ++++++++
.../UHCReloaded/utils/ModulesUtils.java | 21 +-
src/main/resources/config.yml | 5 +
69 files changed, 1447 insertions(+), 2496 deletions(-)
create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java
rename src/main/java/eu/carrade/amaury/UHCReloaded/{events/modules => core/events}/AllModulesLoadedEvent.java (97%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/{events/modules => core/events}/ModuleLoadedEvent.java (89%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/{events/modules => core/events}/ModuleUnloadedEvent.java (97%)
create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckCommand.java
create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java
create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java
create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java
create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java
rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/walls}/exceptions/CannotGenerateWallsException.java (96%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/walls}/exceptions/UnknownWallGenerator.java (92%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/walls}/generators/CircularWallGenerator.java (99%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/walls}/generators/SquaredWallGenerator.java (98%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/walls}/generators/WallGenerator.java (84%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/walls}/generators/WallPosition.java (96%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/warning}/BorderWarningTask.java (72%)
create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java
create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java
create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderManager.java
create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java
create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/events/BorderChangedEvent.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHBorderCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTeamCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamAddCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerResetCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamGUICommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamJoinCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamLeaveCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamListCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamRemoveCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamResetCommand.java
delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamSpyCommand.java
rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/EpisodeChangedCause.java (97%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/UHEpisodeChangedEvent.java (98%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/UHGameEndsEvent.java (98%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/UHGameStartsEvent.java (97%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/UHPlayerDeathEvent.java (98%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/UHPlayerResurrectedEvent.java (98%)
rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/UHTeamDeathEvent.java (97%)
create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java
index fdc7900..11a4b50 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java
@@ -34,9 +34,9 @@
import eu.carrade.amaury.UHCReloaded.core.ModuleInfo;
import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper;
import eu.carrade.amaury.UHCReloaded.core.UHModule;
-import eu.carrade.amaury.UHCReloaded.events.modules.AllModulesLoadedEvent;
+import eu.carrade.amaury.UHCReloaded.core.events.AllModulesLoadedEvent;
+import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent;
import eu.carrade.amaury.UHCReloaded.game.UHGameManager;
-import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderManager;
import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule;
import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule;
import eu.carrade.amaury.UHCReloaded.modules.core.game.events.GamePhaseChangedEvent;
@@ -49,12 +49,7 @@
import eu.carrade.amaury.UHCReloaded.old.integration.UHProtocolLibIntegrationWrapper;
import eu.carrade.amaury.UHCReloaded.old.integration.UHSpectatorPlusIntegration;
import eu.carrade.amaury.UHCReloaded.old.integration.UHWorldBorderIntegration;
-import eu.carrade.amaury.UHCReloaded.old.misc.Freezer;
-import eu.carrade.amaury.UHCReloaded.old.misc.MOTDManager;
-import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader;
-import eu.carrade.amaury.UHCReloaded.old.misc.PlayerListHeaderFooterManager;
-import eu.carrade.amaury.UHCReloaded.old.misc.RulesManager;
-import eu.carrade.amaury.UHCReloaded.old.misc.RuntimeCommandsExecutor;
+import eu.carrade.amaury.UHCReloaded.old.misc.*;
import eu.carrade.amaury.UHCReloaded.old.recipes.RecipesManager;
import eu.carrade.amaury.UHCReloaded.old.spectators.SpectatorsManager;
import eu.carrade.amaury.UHCReloaded.old.teams.TeamChatManager;
@@ -87,16 +82,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
+import java.util.*;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
@@ -123,7 +109,6 @@ public class UHCReloaded extends ZPlugin implements Listener
private MOTDManager motdManager = null;
private RulesManager rulesManager = null;
private PlayerListHeaderFooterManager playerListHeaderFooterManager = null;
- private BorderManager borderManager = null;
private RecipesManager recipesManager = null;
private TeamChatManager teamChatManager = null;
@@ -222,7 +207,6 @@ private void onEnableWhenWorldsAvailable()
worldTheEnd = setDefaultWorld(World.Environment.THE_END, UHConfig.WORLDS.THE_END.get());
loadModules(ModuleInfo.ModuleLoadTime.POST_WORLD);
- collectCommandsFromModules();
});
worldsLoaded = true;
@@ -326,7 +310,7 @@ public void registerModule(final String module)
private void registerModule(final String module, boolean enabledAtStartup)
{
final Class extends UHModule> moduleClass = ModulesUtils.getClassFromName(
- module,
+ module.replace('-', '.'),
"eu.carrade.amaury.UHCReloaded.modules",
"Module",
UHModule.class
@@ -369,6 +353,8 @@ private void loadModules(final ModuleInfo.ModuleLoadTime loadTime)
loadedPriorities.add(loadTime);
+ collectCommandsFromModules();
+
getServer().getPluginManager().callEvent(new AllModulesLoadedEvent(loadTime));
}
@@ -379,7 +365,7 @@ private void loadModules(final ModuleInfo.ModuleLoadTime loadTime)
* @throws IllegalArgumentException if the module was not registered using {@link #registerModules(Class[])} or
* {@link #registerModule(String)} before.
*/
- public void loadModule(Class extends UHModule> moduleClass)
+ public void loadModule(final Class extends UHModule> moduleClass)
{
final ModuleWrapper module = modules.get(moduleClass);
@@ -396,7 +382,7 @@ public void loadModule(Class extends UHModule> moduleClass)
* @throws IllegalArgumentException if the module was not registered using {@link #registerModules(Class[])} or
* {@link #registerModule(String)} before.
*/
- public void unloadModule(Class extends UHModule> moduleClass)
+ public void unloadModule(final Class extends UHModule> moduleClass)
{
final ModuleWrapper module = modules.get(moduleClass);
@@ -415,7 +401,7 @@ public void unloadModule(Class extends UHModule> moduleClass)
*
* @return The module's instance.
*/
- public static M getModule(Class moduleClass)
+ public static M getModule(final Class moduleClass)
{
final ModuleWrapper module = get().modules.get(moduleClass);
@@ -458,7 +444,7 @@ public World getWorld(final World.Environment environment)
@EventHandler (priority = EventPriority.LOWEST)
- public final void onWorldsLoaded(WorldLoadEvent e)
+ public final void onWorldsLoaded(final WorldLoadEvent e)
{
if (!worldsLoaded) onEnableWhenWorldsAvailable();
}
@@ -466,6 +452,8 @@ public final void onWorldsLoaded(WorldLoadEvent e)
@EventHandler
public void onGamePhaseChanged(final GamePhaseChangedEvent ev)
{
+ PluginLogger.info("Game phase changed to {0}.", ev.getNewPhase());
+
switch (ev.getNewPhase())
{
case IN_GAME:
@@ -478,6 +466,12 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev)
}
}
+ @EventHandler
+ public void onModuleLoaded(final ModuleLoadedEvent e)
+ {
+ PluginLogger.info("Module {0} loaded.", e.getModule().getName());
+ }
+
@EventHandler (priority = EventPriority.LOWEST)
public final void onPlayerJoin(final PlayerJoinEvent ev)
{
@@ -506,7 +500,7 @@ private void collectCommandsFromModules()
// As they are not registered in the plugin.yml, for each command, we have to force-register
// the name manually.
- final List pluginCommands = new ArrayList<>();
+ final Map> pluginCommands = new HashMap<>();
final Set registered = new HashSet<>();
try
@@ -514,16 +508,16 @@ private void collectCommandsFromModules()
final Constructor pluginCommandConstructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
pluginCommandConstructor.setAccessible(true);
- for (final String commandName : commandAliases.keySet())
+ for (final Map.Entry> commandAlias : commandAliases.entrySet())
{
try
{
- pluginCommands.add(pluginCommandConstructor.newInstance(commandName, this));
- registered.add(commandName);
+ pluginCommands.put(pluginCommandConstructor.newInstance(commandAlias.getKey(), this), commandAlias.getValue());
+ registered.add(commandAlias.getKey());
}
catch (InstantiationException | InvocationTargetException | IllegalAccessException e)
{
- PluginLogger.error("Unable to register plugin command for {0}, is this version supported by UHCReloaded?", e, commandName);
+ PluginLogger.error("Unable to register plugin command for {0}, is this version supported by UHCReloaded?", e, commandAlias);
}
}
@@ -531,10 +525,22 @@ private void collectCommandsFromModules()
{
final CommandMap commandMap = (CommandMap) Reflection.getFieldValue(Bukkit.getServer(), "commandMap");
- String prefix = getDescription().getPrefix();
- if (prefix == null) prefix = getDescription().getName().toLowerCase();
+ String mutPrefix = getDescription().getPrefix();
+ if (mutPrefix == null) mutPrefix = getDescription().getName().toLowerCase();
+
+ final String prefix = mutPrefix;
- commandMap.registerAll(prefix, pluginCommands);
+ pluginCommands.forEach((pluginCommand, commandClass) ->
+ {
+ if (commandMap.register(prefix, pluginCommand))
+ {
+ PluginLogger.info(
+ "Hot-registered new command /{0} for class “{1}”.",
+ pluginCommand.getName(),
+ commandClass.getName().replace("eu.carrade.amaury.UHCReloaded.", "...")
+ );
+ }
+ });
}
catch (NoSuchFieldException | IllegalAccessException e)
{
@@ -634,14 +640,6 @@ public PlayerListHeaderFooterManager getPlayerListHeaderFooterManager()
return playerListHeaderFooterManager;
}
- /**
- * Returns the border manager.
- */
- public BorderManager getBorderManager()
- {
- return borderManager;
- }
-
/**
* Returns the recipe manager.
*/
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java
index 0972341..4797487 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java
@@ -95,7 +95,7 @@ enum ModuleLoadTime
/**
* Loads the module at startup, before the worlds are loaded.
*
- * Please note that most core modules (an localization) are not loaded at this point. Use that
+ * Please note that most core modules (and localization) are not loaded at this point. Use that
* for modules altering the world generation.
*/
STARTUP,
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java
new file mode 100644
index 0000000..7d5c3c6
--- /dev/null
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java
@@ -0,0 +1,108 @@
+/*
+ * Plugin UHCReloaded : Alliances
+ *
+ * Copyright ou © ou Copr. Amaury Carrade (2016)
+ * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan".
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ */
+package eu.carrade.amaury.UHCReloaded.core;
+
+import fr.zcraft.zlib.core.ZLib;
+
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+public class ModuleLogger extends Logger
+{
+ private final String loggerName;
+
+ ModuleLogger(Class module)
+ {
+ super(ZLib.getPlugin().getClass().getCanonicalName(), null);
+
+ setParent(ZLib.getPlugin().getLogger());
+ setLevel(Level.ALL);
+
+ loggerName = "[" + ZLib.getPlugin().getName() + "] [" + ModuleWrapper.computeModuleName(module) + " Module] ";
+ }
+
+ @Override
+ public void log(LogRecord logRecord)
+ {
+ logRecord.setMessage(loggerName + logRecord.getMessage());
+ super.log(logRecord);
+ }
+
+ public void log(Level level, String message, Throwable ex, Object... args)
+ {
+ log(level, message, args);
+ log(level, "Exception : ", ex);
+ }
+
+ public void info(String message, Object...args)
+ {
+ log(Level.INFO, message, args);
+ }
+
+ public void warning(String message, Object... args)
+ {
+ log(Level.WARNING, message, args);
+ }
+
+ public void warning(String message, Throwable ex)
+ {
+ log(Level.WARNING, message, ex);
+ }
+
+ public void warning(String message, Throwable ex, Object... args)
+ {
+ log(Level.WARNING, message, ex, args);
+ }
+
+ public void error(String message)
+ {
+ log(Level.SEVERE, message);
+ }
+
+ public void error(String message, Throwable ex)
+ {
+ log(Level.SEVERE, message, ex);
+ }
+
+ public void error(String message, Throwable ex, Object... args)
+ {
+ log(Level.SEVERE, message, ex, args);
+ }
+
+ public void error(String message, Object... args)
+ {
+ log(Level.SEVERE, message, args);
+ }
+}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java
index 239c1fc..243d766 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java
@@ -32,8 +32,8 @@
package eu.carrade.amaury.UHCReloaded.core;
import com.google.common.base.CaseFormat;
-import eu.carrade.amaury.UHCReloaded.events.modules.ModuleLoadedEvent;
-import eu.carrade.amaury.UHCReloaded.events.modules.ModuleUnloadedEvent;
+import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent;
+import eu.carrade.amaury.UHCReloaded.core.events.ModuleUnloadedEvent;
import fr.zcraft.zlib.components.configuration.ConfigurationInstance;
import fr.zcraft.zlib.core.ZLib;
import fr.zcraft.zlib.tools.PluginLogger;
@@ -73,7 +73,7 @@ public ModuleWrapper(
final Class extends ConfigurationInstance> moduleConfiguration,
final String settingsFileName)
{
- this.name = name;
+ this.name = computeModuleName(moduleClass);
this.description = description;
this.internal = internal;
this.enabledAtStartup = enabledAtStartup;
@@ -91,7 +91,8 @@ public ModuleWrapper(
public void enable()
{
instance = ZLib.loadComponent(moduleClass);
- Bukkit.getPluginManager().callEvent(new ModuleLoadedEvent(instance));
+
+ Bukkit.getPluginManager().callEvent(new ModuleLoadedEvent(this));
}
/**
@@ -127,9 +128,7 @@ public void setEnabledAtStartup(boolean enabledAtStartup)
*/
public String getName()
{
- return name != null && !name.isEmpty()
- ? name
- : StringUtils.capitalize(String.join(" ", StringUtils.splitByCharacterTypeCamelCase(moduleClass.getSimpleName())));
+ return name;
}
/**
@@ -240,4 +239,14 @@ public UHModule get()
{
return instance;
}
+
+ static String computeModuleName(Class extends UHModule> moduleClass)
+ {
+ final ModuleInfo info = moduleClass.getAnnotation(ModuleInfo.class);
+
+ if (info == null || info.name().isEmpty())
+ return StringUtils.capitalize(String.join(" ", StringUtils.splitByCharacterTypeCamelCase(moduleClass.getSimpleName())));
+
+ else return info.name();
+ }
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java
index 35f45b0..64e94e4 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java
@@ -44,6 +44,13 @@
public abstract class UHModule extends ZLibComponent implements Listener
{
+ protected ModuleLogger logger;
+
+ public UHModule()
+ {
+ logger = new ModuleLogger(getClass());
+ }
+
/**
* Called when the configuration is loaded.
*/
@@ -81,4 +88,9 @@ public void prepareInjectionIntoSidebar() {}
* @param injector The injector will allows you to inject content in specific parts of the sidebar.
*/
public void injectIntoSidebar(final Player player, final SidebarInjector injector) {}
+
+ public ModuleLogger log()
+ {
+ return logger;
+ }
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/AllModulesLoadedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/AllModulesLoadedEvent.java
similarity index 97%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/AllModulesLoadedEvent.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/core/events/AllModulesLoadedEvent.java
index 33b0136..e4ebb7f 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/AllModulesLoadedEvent.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/AllModulesLoadedEvent.java
@@ -29,7 +29,7 @@
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.events.modules;
+package eu.carrade.amaury.UHCReloaded.core.events;
import eu.carrade.amaury.UHCReloaded.core.ModuleInfo;
import org.bukkit.event.Event;
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleLoadedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleLoadedEvent.java
similarity index 89%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleLoadedEvent.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleLoadedEvent.java
index 5d460ba..5180f8d 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleLoadedEvent.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleLoadedEvent.java
@@ -29,9 +29,9 @@
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.events.modules;
+package eu.carrade.amaury.UHCReloaded.core.events;
-import eu.carrade.amaury.UHCReloaded.core.UHModule;
+import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@@ -43,10 +43,10 @@ public class ModuleLoadedEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
- private final UHModule module;
+ private final ModuleWrapper module;
- public ModuleLoadedEvent(final UHModule module)
+ public ModuleLoadedEvent(final ModuleWrapper module)
{
this.module = module;
}
@@ -54,7 +54,7 @@ public ModuleLoadedEvent(final UHModule module)
/**
* @return the loaded module.
*/
- public UHModule getModule()
+ public ModuleWrapper getModule()
{
return module;
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleUnloadedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleUnloadedEvent.java
similarity index 97%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleUnloadedEvent.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleUnloadedEvent.java
index 9c59e73..51f8b22 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleUnloadedEvent.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleUnloadedEvent.java
@@ -29,7 +29,7 @@
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.events.modules;
+package eu.carrade.amaury.UHCReloaded.core.events;
import eu.carrade.amaury.UHCReloaded.core.UHModule;
import org.bukkit.event.Event;
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java
index 201434c..f26d263 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java
@@ -33,10 +33,10 @@
import eu.carrade.amaury.UHCReloaded.UHCReloaded;
import eu.carrade.amaury.UHCReloaded.UHConfig;
-import eu.carrade.amaury.UHCReloaded.events.EpisodeChangedCause;
-import eu.carrade.amaury.UHCReloaded.events.UHEpisodeChangedEvent;
-import eu.carrade.amaury.UHCReloaded.events.UHGameStartsEvent;
-import eu.carrade.amaury.UHCReloaded.events.UHPlayerResurrectedEvent;
+import eu.carrade.amaury.UHCReloaded.old.events.EpisodeChangedCause;
+import eu.carrade.amaury.UHCReloaded.old.events.UHEpisodeChangedEvent;
+import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent;
+import eu.carrade.amaury.UHCReloaded.old.events.UHPlayerResurrectedEvent;
import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer;
import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader;
import eu.carrade.amaury.UHCReloaded.old.protips.ProTips;
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckCommand.java
new file mode 100644
index 0000000..d7d697f
--- /dev/null
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckCommand.java
@@ -0,0 +1,63 @@
+/*
+ * Plugin UHCReloaded : Alliances
+ *
+ * Copyright ou © ou Copr. Amaury Carrade (2016)
+ * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan".
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ */
+package eu.carrade.amaury.UHCReloaded.modules.border.check;
+
+import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule;
+import eu.carrade.amaury.UHCReloaded.shortcuts.UR;
+import fr.zcraft.zlib.components.commands.Command;
+import fr.zcraft.zlib.components.commands.CommandException;
+import fr.zcraft.zlib.components.commands.CommandInfo;
+import fr.zcraft.zlib.components.i18n.I;
+
+@CommandInfo(name = "border-check", usageParameters = "", aliases = {"bordercheck", "bcheck", "bc"})
+public class CheckCommand extends Command
+{
+ @Override
+ protected void run() throws CommandException
+ {
+ if (args.length == 0)
+ {
+ throwInvalidArgument(I.t("You must provide a check radius."));
+ }
+
+ try
+ {
+ UR.module(BorderModule.class).sendCheckMessage(sender, Integer.valueOf(args[0]));
+ }
+ catch (NumberFormatException e)
+ {
+ sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0]));
+ }
+ }
+}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java
new file mode 100644
index 0000000..7630216
--- /dev/null
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java
@@ -0,0 +1,55 @@
+/*
+ * Plugin UHCReloaded : Alliances
+ *
+ * Copyright ou © ou Copr. Amaury Carrade (2016)
+ * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan".
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ */
+package eu.carrade.amaury.UHCReloaded.modules.border.check;
+
+import eu.carrade.amaury.UHCReloaded.core.ModuleInfo;
+import eu.carrade.amaury.UHCReloaded.core.UHModule;
+import fr.zcraft.zlib.components.commands.Command;
+
+import java.util.Collections;
+import java.util.List;
+
+@ModuleInfo (
+ name = "Border Check",
+ description = "Offers a command to check how far players are from a given border size.",
+ when = ModuleInfo.ModuleLoadTime.ON_GAME_START
+)
+public class CheckModule extends UHModule
+{
+ @Override
+ public List> getCommands()
+ {
+ return Collections.singletonList(CheckCommand.class);
+ }
+}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java
new file mode 100644
index 0000000..64542e2
--- /dev/null
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java
@@ -0,0 +1,62 @@
+/*
+ * Plugin UHCReloaded : Alliances
+ *
+ * Copyright ou © ou Copr. Amaury Carrade (2016)
+ * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan".
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ */
+package eu.carrade.amaury.UHCReloaded.modules.border.walls;
+
+import fr.zcraft.zlib.components.configuration.ConfigurationInstance;
+import fr.zcraft.zlib.components.configuration.ConfigurationItem;
+import fr.zcraft.zlib.components.configuration.ConfigurationSection;
+import org.bukkit.Material;
+
+import java.io.File;
+
+import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item;
+import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section;
+
+public class Config extends ConfigurationInstance
+{
+ public Config(File file)
+ {
+ super(file);
+ }
+
+ public static final ConfigurationItem HEIGHT = item("height", 128);
+
+ public static final BlockSection BLOCK = section("block", BlockSection.class);
+
+ static public class BlockSection extends ConfigurationSection
+ {
+ public final ConfigurationItem REPLACE_AIR = item("replaceAir", Material.GLASS);
+ public final ConfigurationItem REPLACE_SOLID = item("replaceSolid", Material.BEDROCK);
+ }
+}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java
new file mode 100644
index 0000000..23a7a7b
--- /dev/null
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java
@@ -0,0 +1,89 @@
+/*
+ * Plugin UHCReloaded : Alliances
+ *
+ * Copyright ou © ou Copr. Amaury Carrade (2016)
+ * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan".
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ */
+package eu.carrade.amaury.UHCReloaded.modules.border.walls;
+
+import eu.carrade.amaury.UHCReloaded.UHCReloaded;
+import eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions.CannotGenerateWallsException;
+import fr.zcraft.zlib.components.commands.Command;
+import fr.zcraft.zlib.components.commands.CommandException;
+import fr.zcraft.zlib.components.commands.CommandInfo;
+import fr.zcraft.zlib.components.i18n.I;
+import org.bukkit.World;
+import org.bukkit.command.BlockCommandSender;
+import org.bukkit.entity.Player;
+
+@CommandInfo(name = "build-walls", aliases = {"buildwalls", "generate-walls", "generatewalls"})
+public class WallsCommand extends Command
+{
+ @Override
+ protected void run() throws CommandException
+ {
+ info(I.t("{cst}Generating the walls..."));
+
+ final World world;
+
+ if (sender instanceof Player)
+ {
+ world = ((Player) sender).getWorld();
+ }
+ else if (sender instanceof BlockCommandSender)
+ {
+ world = ((BlockCommandSender) sender).getBlock().getWorld();
+ }
+ else
+ {
+ world = UHCReloaded.get().getWorld(World.Environment.NORMAL);
+ info(I.t("{ci}From the console, generating the walls of the default world, {0}", world.getName()));
+ }
+
+ try
+ {
+ UHCReloaded.getModule(WallsModule.class).generateWalls(world);
+ }
+ catch (CannotGenerateWallsException e)
+ {
+ error(I.t("{ce}Unable to generate the wall: see logs for details. The blocks set in the config are probably invalid."));
+ return;
+
+ }
+ catch (Exception e)
+ {
+ error(I.t("{ce}An error occurred, see console for details."));
+ e.printStackTrace();
+ return;
+ }
+
+ success(I.t("{cst}Generation done."));
+ }
+}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java
new file mode 100644
index 0000000..11d5351
--- /dev/null
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java
@@ -0,0 +1,98 @@
+/*
+ * Plugin UHCReloaded : Alliances
+ *
+ * Copyright ou © ou Copr. Amaury Carrade (2016)
+ * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan".
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ */
+package eu.carrade.amaury.UHCReloaded.modules.border.walls;
+
+import eu.carrade.amaury.UHCReloaded.UHCReloaded;
+import eu.carrade.amaury.UHCReloaded.core.ModuleInfo;
+import eu.carrade.amaury.UHCReloaded.core.UHModule;
+import eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions.CannotGenerateWallsException;
+import eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions.UnknownWallGenerator;
+import eu.carrade.amaury.UHCReloaded.modules.border.walls.generators.WallGenerator;
+import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule;
+import fr.zcraft.zlib.components.commands.Command;
+import org.bukkit.Material;
+import org.bukkit.World;
+
+import java.util.Collections;
+import java.util.List;
+
+
+@ModuleInfo (
+ name = "Walls generator",
+ description = "Generates a solid wall around the arena",
+ when = ModuleInfo.ModuleLoadTime.POST_WORLD,
+ settings = Config.class
+)
+public class WallsModule extends UHModule
+{
+ private BorderModule borderModule;
+
+ @Override
+ protected void onEnable()
+ {
+ borderModule = UHCReloaded.getModule(BorderModule.class);
+ }
+
+ @Override
+ public List> getCommands()
+ {
+ return Collections.singletonList(WallsCommand.class);
+ }
+
+ /**
+ * Generates the walls in the given world, following the current border configuration.
+ *
+ * @param world The world were the walls will be built in.
+ * @throws CannotGenerateWallsException If an error occurred while generating the wall.
+ */
+ public void generateWalls(final World world) throws CannotGenerateWallsException
+ {
+ final Integer wallHeight = Config.HEIGHT.get();
+
+ final Material wallBlockAir = Config.BLOCK.REPLACE_AIR.get();
+ final Material wallBlockSolid = Config.BLOCK.REPLACE_SOLID.get();
+
+ if (wallBlockAir == null || !wallBlockAir.isSolid() || wallBlockSolid == null || !wallBlockSolid.isSolid())
+ {
+ throw new CannotGenerateWallsException("Cannot generate the walls: invalid blocks set in the config");
+ }
+
+ final WallGenerator generator = WallGenerator.fromShape(borderModule.getMapShape(), wallBlockAir, wallBlockSolid);
+
+ if (generator != null)
+ generator.build(world, borderModule.getCurrentBorderDiameter(), wallHeight);
+ else
+ throw new UnknownWallGenerator("Unable to load walls generator.");
+ }
+}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/CannotGenerateWallsException.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/CannotGenerateWallsException.java
similarity index 96%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/CannotGenerateWallsException.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/CannotGenerateWallsException.java
index 5cbb9c4..c47db3a 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/CannotGenerateWallsException.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/CannotGenerateWallsException.java
@@ -29,7 +29,7 @@
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.modules.core.border.exceptions;
+package eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions;
public class CannotGenerateWallsException extends Exception
{
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/UnknownWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/UnknownWallGenerator.java
similarity index 92%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/UnknownWallGenerator.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/UnknownWallGenerator.java
index 68829ce..fa31faf 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/UnknownWallGenerator.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/UnknownWallGenerator.java
@@ -29,9 +29,9 @@
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.modules.core.border.exceptions;
+package eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions;
-public class UnknownWallGenerator extends Exception
+public class UnknownWallGenerator extends CannotGenerateWallsException
{
public UnknownWallGenerator(String message)
{
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/CircularWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/CircularWallGenerator.java
similarity index 99%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/CircularWallGenerator.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/CircularWallGenerator.java
index 51e8164..e6158f6 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/CircularWallGenerator.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/CircularWallGenerator.java
@@ -29,7 +29,7 @@
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.modules.core.border.generators;
+package eu.carrade.amaury.UHCReloaded.modules.border.walls.generators;
import org.bukkit.Material;
import org.bukkit.World;
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/SquaredWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/SquaredWallGenerator.java
similarity index 98%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/SquaredWallGenerator.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/SquaredWallGenerator.java
index 7239677..6a54e7d 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/SquaredWallGenerator.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/SquaredWallGenerator.java
@@ -29,7 +29,7 @@
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.modules.core.border.generators;
+package eu.carrade.amaury.UHCReloaded.modules.border.walls.generators;
import org.bukkit.Material;
import org.bukkit.World;
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallGenerator.java
similarity index 84%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallGenerator.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallGenerator.java
index bc8a868..225a21b 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallGenerator.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallGenerator.java
@@ -30,8 +30,10 @@
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.modules.core.border.generators;
+package eu.carrade.amaury.UHCReloaded.modules.border.walls.generators;
+import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape;
+import org.apache.commons.lang3.Validate;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
@@ -46,8 +48,8 @@ public abstract class WallGenerator
public WallGenerator(Material wallBlockAir, Material wallBlockSolid)
{
- this.wallBlockAir = wallBlockAir;
- this.wallBlockSolid = wallBlockSolid;
+ this.wallBlockAir = wallBlockAir != null ? wallBlockAir : Material.GLASS;
+ this.wallBlockSolid = wallBlockSolid != null ? wallBlockSolid : Material.BEDROCK;
}
@@ -186,4 +188,30 @@ public int getBlocksSet()
{
return blocksSet;
}
+
+ /**
+ * Returns a new instance of the wall generator for the given shape.
+ *
+ * @param shape The shape.
+ * @param wallBlockAir The block to use to replace air.
+ * @param wallBlockSolid The block to use to replace solid blocks.
+ *
+ * @return The instance.
+ * @see WallGenerator#WallGenerator(Material, Material)
+ */
+ public static WallGenerator fromShape(final MapShape shape, final Material wallBlockAir, final Material wallBlockSolid)
+ {
+ Validate.notNull(shape, "Map shape must not be null.");
+
+ switch (shape)
+ {
+ case CIRCULAR:
+ return new CircularWallGenerator(wallBlockAir, wallBlockSolid);
+
+ case SQUARED:
+ return new SquaredWallGenerator(wallBlockAir, wallBlockSolid);
+ }
+
+ return null;
+ }
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallPosition.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallPosition.java
similarity index 96%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallPosition.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallPosition.java
index 426d731..873b7b9 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallPosition.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallPosition.java
@@ -30,7 +30,7 @@
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.modules.core.border.generators;
+package eu.carrade.amaury.UHCReloaded.modules.border.walls.generators;
/**
* Used to determine in witch wall we are, to get the "inner" block.
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderWarningTask.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/BorderWarningTask.java
similarity index 72%
rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderWarningTask.java
rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/BorderWarningTask.java
index 755eb47..be7d87a 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderWarningTask.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/BorderWarningTask.java
@@ -29,9 +29,11 @@
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-B license and that you accept its terms.
*/
-package eu.carrade.amaury.UHCReloaded.modules.core.border;
+package eu.carrade.amaury.UHCReloaded.modules.border.warning;
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
+import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule;
+import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape;
+import eu.carrade.amaury.UHCReloaded.shortcuts.UR;
import fr.zcraft.zlib.components.i18n.I;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@@ -39,29 +41,30 @@
public class BorderWarningTask extends BukkitRunnable
{
- private final BorderModule module = UHCReloaded.getModule(BorderModule.class);
+ private final BorderModule borderModule = UR.module(BorderModule.class);
+ private final WarningModule warningModule = UR.module(WarningModule.class);
@Override
public void run()
{
-// final FreezerModule freezer = UHCReloaded.getModule(FreezerModule.class);
+// final FreezerModule freezer = UR.module(FreezerModule.class);
// if (freezer != null && freezer.getGlobalFreezeState())
// {
// return; // No messages are sent if the game is frozen.
// }
// Message sent to all players outside the border
- for (Player player : module.getPlayersOutside(module.getWarningSize()))
+ for (Player player : borderModule.getPlayersOutside(warningModule.getWarningSize()))
{
- double distance = module.getDistanceToBorder(player.getLocation(), module.getWarningSize());
+ double distance = borderModule.getDistanceToBorder(player.getLocation(), warningModule.getWarningSize());
- if (module.getMapShape() == MapShape.CIRCULAR)
+ if (borderModule.getMapShape() == MapShape.CIRCULAR)
{
- player.sendMessage(I.tn("{ce}You are currently out of the future border (diameter of {0} block).", "{ce}You are currently out of the future border (diameter of {0} blocks).", module.getWarningSize()));
+ player.sendMessage(I.tn("{ce}You are currently out of the future border (diameter of {0} block).", "{ce}You are currently out of the future border (diameter of {0} blocks).", warningModule.getWarningSize()));
}
else
{
- player.sendMessage(I.t("{ce}You are currently out of the future border of {0}×{0} blocks.", module.getWarningSize()));
+ player.sendMessage(I.t("{ce}You are currently out of the future border of {0}×{0} blocks.", warningModule.getWarningSize()));
}
player.sendMessage(I.tn("{ci}You have {0} block to go before being inside.", "{ci}You have {0} blocks to go before being inside.", (int) distance));
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java
new file mode 100644
index 0000000..c88b807
--- /dev/null
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java
@@ -0,0 +1,51 @@
+/*
+ * Plugin UHCReloaded : Alliances
+ *
+ * Copyright ou © ou Copr. Amaury Carrade (2016)
+ * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan".
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ */
+package eu.carrade.amaury.UHCReloaded.modules.border.warning;
+
+import fr.zcraft.zlib.components.configuration.ConfigurationInstance;
+import fr.zcraft.zlib.components.configuration.ConfigurationItem;
+
+import java.io.File;
+
+import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item;
+
+public class Config extends ConfigurationInstance
+{
+ public Config(File file)
+ {
+ super(file);
+ }
+
+ public static final ConfigurationItem WARNING_INTERVAL = item("warningInterval", 90);
+}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java
new file mode 100644
index 0000000..2b08ba5
--- /dev/null
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java
@@ -0,0 +1,102 @@
+/*
+ * Plugin UHCReloaded : Alliances
+ *
+ * Copyright ou © ou Copr. Amaury Carrade (2016)
+ * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan".
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ */
+package eu.carrade.amaury.UHCReloaded.modules.border.warning;
+
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta;
+import eu.carrade.amaury.UHCReloaded.shortcuts.UR;
+import fr.zcraft.zlib.components.commands.Command;
+import fr.zcraft.zlib.components.commands.CommandException;
+import fr.zcraft.zlib.components.commands.CommandInfo;
+import fr.zcraft.zlib.components.i18n.I;
+
+import java.util.List;
+
+@CommandInfo (
+ name = "border-warning",
+ usageParameters = " [time delta (minutes or mm:ss or hh:mm:ss) until border reduction]",
+ aliases = {"borderwarning", "borderwarn", "bw"}
+)
+public class WarningCommand extends Command
+{
+ @Override
+ protected void run() throws CommandException
+ {
+ final WarningModule warnings = UR.module(WarningModule.class);
+
+ // /uh border warning
+ if (args.length == 0)
+ {
+ throwInvalidArgument(I.t("Missing future border size."));
+ }
+
+ // /uh border warning cancel
+ else if (args[0].equalsIgnoreCase("cancel"))
+ {
+ warnings.cancelWarning();
+ success(I.t("{cs}Warning canceled."));
+ }
+
+ // /uh border warning >
+ // or
+ // /uh border warning > >
+ else
+ {
+ try
+ {
+ final int warnDiameter = Integer.parseInt(args[0]);
+ TimeDelta warnTime = null;
+
+ // /uh border warning > >
+ if (args.length >= 2)
+ {
+ warnTime = new TimeDelta(args[1]);
+ }
+
+ warnings.setWarningSize(warnDiameter, warnTime, sender);
+ success(I.tn("{cs}Future size saved. All players outside this future border will be warned every {0} second.", "{cs}Future size saved. All players outside this future border will be warned every {0} seconds.", Config.WARNING_INTERVAL.get()));
+
+ }
+ catch (NumberFormatException e)
+ {
+ error(I.t("{ce}“{0}” is not a number...", args[0]));
+ }
+ }
+ }
+
+ @Override
+ protected List complete() throws CommandException
+ {
+ return args.length == 1 ? getMatchingSubset(args[0], "cancel") : null;
+ }
+}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java
new file mode 100644
index 0000000..7b6d60c
--- /dev/null
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java
@@ -0,0 +1,198 @@
+/*
+ * Plugin UHCReloaded : Alliances
+ *
+ * Copyright ou © ou Copr. Amaury Carrade (2016)
+ * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan".
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ */
+package eu.carrade.amaury.UHCReloaded.modules.border.warning;
+
+import eu.carrade.amaury.UHCReloaded.core.ModuleInfo;
+import eu.carrade.amaury.UHCReloaded.core.UHModule;
+import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule;
+import eu.carrade.amaury.UHCReloaded.modules.core.border.events.BorderChangedEvent;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule;
+import eu.carrade.amaury.UHCReloaded.shortcuts.UR;
+import fr.zcraft.zlib.components.commands.Command;
+import fr.zcraft.zlib.components.i18n.I;
+import fr.zcraft.zlib.tools.runners.RunTask;
+import org.bukkit.command.CommandSender;
+import org.bukkit.event.EventHandler;
+import org.bukkit.scheduler.BukkitRunnable;
+
+import java.util.Collections;
+import java.util.List;
+
+@ModuleInfo (
+ name = "Border Warning",
+ description = "Warns players about the future border size",
+ when = ModuleInfo.ModuleLoadTime.ON_GAME_START,
+ settings = Config.class
+)
+public class WarningModule extends UHModule
+{
+ private BorderModule borderModule;
+
+ private Integer warningSize = 0;
+ private BukkitRunnable warningTask = null;
+
+ private Boolean warningFinalTimeEnabled = false;
+ private Timer warningTimer = null;
+ private String warningTimerName = null;
+ private CommandSender warningSender = null;
+
+
+ @Override
+ protected void onEnable()
+ {
+ /// The name of the warning timer displaying the time left before the next border
+ warningTimerName = I.t("Border shrinking");
+
+ borderModule = UR.module(BorderModule.class);
+ }
+
+ @Override
+ public List> getCommands()
+ {
+ return Collections.singletonList(WarningCommand.class);
+ }
+
+ /**
+ * Returns the size of the future border, used in the warning messages sent to the
+ * players out of this future border.
+ *
+ * @return the future border diameter.
+ */
+ public int getWarningSize()
+ {
+ return this.warningSize;
+ }
+
+ /**
+ * @return true if there is currently a warning with a time left displayed.
+ */
+ public boolean getWarningFinalTimeEnabled()
+ {
+ return this.warningFinalTimeEnabled;
+ }
+
+ /**
+ * @return the sender of the last warning configured.
+ */
+ public CommandSender getWarningSender()
+ {
+ return this.warningSender;
+ }
+
+ /**
+ * Sets the size of the future border, used in the warning messages sent to the
+ * players out of this future border.
+ *
+ * This also starts the display of the warning messages, every 90 seconds by default
+ * (configurable, see config.yml, map.border.warningInterval).
+ *
+ * If timeLeft is not null, the time available for the players to go inside the future
+ * border is displayed in the warning message.
+ *
+ * @param diameter The future diameter.
+ * @param timeLeft The time available for the players to go inside the future border.
+ * @param sender The user who requested this change.
+ */
+ public void setWarningSize(final int diameter, final TimeDelta timeLeft, final CommandSender sender)
+ {
+ cancelWarning();
+
+ this.warningSize = diameter;
+
+ if (timeLeft != null)
+ {
+ warningTimer = new Timer(this.warningTimerName);
+ warningTimer.setDuration((int) timeLeft.getSeconds());
+
+ UR.module(TimersModule.class).registerTimer(warningTimer);
+
+ warningTimer.start();
+ }
+
+ if (sender != null)
+ {
+ this.warningSender = sender;
+ }
+
+ RunTask.timer(
+ warningTask = new BorderWarningTask(),
+ 20L,
+ 20L * Config.WARNING_INTERVAL.get()
+ );
+ }
+
+ /**
+ * Sets the size of the future border, used in the warning messages sent to the
+ * players out of this future border.
+ *
+ * This also starts the display of the warning messages, every 90 seconds by default
+ * (configurable, see config.yml, map.border.warningInterval).
+ *
+ * @param diameter The diameter of the future border.
+ */
+ public void setWarningSize(final int diameter)
+ {
+ setWarningSize(diameter, null, null);
+ }
+
+ /**
+ * Stops the display of the warning messages.
+ */
+ public void cancelWarning()
+ {
+ if (warningTask != null)
+ {
+ try
+ {
+ warningTask.cancel();
+ }
+ catch (IllegalStateException ignored) {}
+ }
+
+ if (warningTimer != null)
+ {
+ warningTimer.stop();
+ UR.module(TimersModule.class).unregisterTimer(warningTimer);
+ }
+ }
+
+
+ @EventHandler
+ public void onBorderChanged(final BorderChangedEvent ev)
+ {
+ cancelWarning();
+ }
+}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderManager.java
deleted file mode 100644
index 1c7e8da..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderManager.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-
-package eu.carrade.amaury.UHCReloaded.modules.core.border;
-
-import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder;
-import org.bukkit.command.CommandSender;
-import org.bukkit.scheduler.BukkitRunnable;
-
-
-public class BorderManager
-{
- private WorldBorder border = null;
-
- private Integer warningSize = 0;
- private BukkitRunnable warningTask = null;
-
- private Boolean warningFinalTimeEnabled = false;
- private String warningTimerName = null;
- private CommandSender warningSender = null;
-
- private MapShape mapShape = null;
-
-
-
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java
index 72ae9f8..2058df9 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java
@@ -35,22 +35,21 @@
import eu.carrade.amaury.UHCReloaded.UHConfig;
import eu.carrade.amaury.UHCReloaded.core.ModuleInfo;
import eu.carrade.amaury.UHCReloaded.core.UHModule;
-import eu.carrade.amaury.UHCReloaded.modules.core.border.exceptions.CannotGenerateWallsException;
-import eu.carrade.amaury.UHCReloaded.modules.core.border.generators.WallGenerator;
+import eu.carrade.amaury.UHCReloaded.modules.core.border.commands.BorderCommand;
+import eu.carrade.amaury.UHCReloaded.modules.core.border.events.BorderChangedEvent;
import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder;
-import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule;
-import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer;
+import eu.carrade.amaury.UHCReloaded.shortcuts.UR;
+import fr.zcraft.zlib.components.commands.Command;
import fr.zcraft.zlib.components.i18n.I;
-import fr.zcraft.zlib.tools.PluginLogger;
-import fr.zcraft.zlib.tools.runners.RunTask;
+import org.bukkit.Bukkit;
import org.bukkit.Location;
-import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
+import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
@@ -63,24 +62,12 @@
)
public class BorderModule extends UHModule
{
- private WorldBorder border = null;
-
- private Integer warningSize = 0;
- private BukkitRunnable warningTask = null;
-
- private Boolean warningFinalTimeEnabled = false;
- private Timer warningTimer = null;
- private String warningTimerName = null;
- private CommandSender warningSender = null;
-
private MapShape mapShape = null;
+ private WorldBorder border = null;
@Override
public void onEnable()
{
- /// The name of the warning timer displaying the time left before the next border
- warningTimerName = I.t("Border shrinking");
-
mapShape = Config.SHAPE.get();
final World world = UHCReloaded.get().getWorld(World.Environment.NORMAL);
@@ -93,10 +80,13 @@ public void onEnable()
border.init();
- PluginLogger.info("Using {0} to set the world border.", border.getClass().getSimpleName());
+ log().info("Using {0} to set the world border.", border.getClass().getSimpleName());
+ }
-// BORDER_SHRINKING_STARTS_AFTER = UHUtils.string2Time(UHConfig.MAP.BORDER.SHRINKING.STARTS_AFTER.get(), 30*60); // Seconds
-// BORDER_SHRINKING_DURATION = UHUtils.string2Time(UHConfig.MAP.BORDER.SHRINKING.SHRINKS_DURING.get(), 60*60*2); // Same
+ @Override
+ public List> getCommands()
+ {
+ return Collections.singletonList(BorderCommand.class);
}
/**
@@ -182,7 +172,7 @@ public Set getPlayersOutside(int diameter)
final Set playersOutside = new HashSet<>();
// TODO
-// for (final Player player : UHCReloaded.getModule(GameModule.class).getOnlineAlivePlayers())
+// for (final Player player : UR.module(GameModule.class).getOnlineAlivePlayers())
// {
// if (!isInsideBorder(player.getLocation(), diameter))
// {
@@ -193,110 +183,6 @@ public Set getPlayersOutside(int diameter)
return playersOutside;
}
- /**
- * Returns the size of the future border, used in the warning messages sent to the
- * players out of this future border.
- *
- * @return the future border diameter.
- */
- public int getWarningSize()
- {
- return this.warningSize;
- }
-
- /**
- * @return true if there is currently a warning with a time left displayed.
- */
- public boolean getWarningFinalTimeEnabled()
- {
- return this.warningFinalTimeEnabled;
- }
-
- /**
- * @return the sender of the last warning configured.
- */
- public CommandSender getWarningSender()
- {
- return this.warningSender;
- }
-
- /**
- * Sets the size of the future border, used in the warning messages sent to the
- * players out of this future border.
- *
- * This also starts the display of the warning messages, every 90 seconds by default
- * (configurable, see config.yml, map.border.warningInterval).
- *
- * If timeLeft is not null, the time available for the players to go inside the future
- * border is displayed in the warning message.
- *
- * @param diameter The future diameter.
- * @param timeLeft The time available for the players to go inside the future border (minutes).
- * @param sender The user who requested this change.
- */
- public void setWarningSize(int diameter, int timeLeft, CommandSender sender)
- {
- cancelWarning();
-
- this.warningSize = diameter;
-
- if (timeLeft != 0)
- {
- warningTimer = new Timer(this.warningTimerName);
- warningTimer.setDuration(timeLeft * 60);
-
- UHCReloaded.getModule(TimersModule.class).registerTimer(warningTimer);
-
- warningTimer.start();
- }
-
- if (sender != null)
- {
- this.warningSender = sender;
- }
-
- RunTask.timer(
- warningTask = new BorderWarningTask(),
- 20L,
- 20L * Config.WARNING_INTERVAL.get()
- );
- }
-
- /**
- * Sets the size of the future border, used in the warning messages sent to the
- * players out of this future border.
- *
- * This also starts the display of the warning messages, every 90 seconds by default
- * (configurable, see config.yml, map.border.warningInterval).
- *
- * @param diameter The diameter of the future border.
- */
- public void setWarningSize(int diameter)
- {
- setWarningSize(diameter, 0, null);
- }
-
- /**
- * Stops the display of the warning messages.
- */
- public void cancelWarning()
- {
- if (warningTask != null)
- {
- try
- {
- warningTask.cancel();
- }
- catch (IllegalStateException ignored) {}
- }
-
- if (warningTimer != null)
- {
- warningTimer.stop();
- UHCReloaded.getModule(TimersModule.class).unregisterTimer(warningTimer);
- }
- }
-
/**
* @return the current border diameter.
*/
@@ -316,21 +202,20 @@ public int getCurrentBorderDiameter()
*/
public void setCurrentBorderDiameter(int diameter)
{
- cancelWarning();
-
border.setDiameter(diameter);
+ Bukkit.getPluginManager().callEvent(new BorderChangedEvent(diameter));
}
-
/**
* Sends a list of the players outside the given border to the specified sender.
*
* @param to The player/console to send the check.
* @param diameter The diameter of the border to be checked.
*/
- public void sendCheckMessage(CommandSender to, int diameter)
+ public void sendCheckMessage(final CommandSender to, final int diameter)
{
- Set playersOutside = getPlayersOutside(diameter);
+ final BorderModule borderModule = UR.module(BorderModule.class);
+ final Set playersOutside = borderModule.getPlayersOutside(diameter);
if (playersOutside.size() == 0)
{
@@ -339,9 +224,9 @@ public void sendCheckMessage(CommandSender to, int diameter)
else
{
to.sendMessage(I.t("{ci}There are {0} players outside the given border.", String.valueOf(playersOutside.size())));
- for (Player player : getPlayersOutside(diameter))
+ for (Player player : borderModule.getPlayersOutside(diameter))
{
- double distance = getDistanceToBorder(player.getLocation(), diameter);
+ double distance = borderModule.getDistanceToBorder(player.getLocation(), diameter);
if (distance > 150)
{
to.sendMessage(I.t("{lightpurple} - {red}{0}{ci} (far away from the border)", player.getName()));
@@ -358,31 +243,6 @@ else if (distance > 25)
}
}
- /**
- * Generates the walls in the given world, following the current border configuration.
- *
- * @param world The world were the walls will be built in.
- * @throws CannotGenerateWallsException If an error occurred while generating the wall.
- */
- public void generateWalls(World world) throws CannotGenerateWallsException
- {
- Integer wallHeight = Config.WALL.HEIGHT.get();
-
- Material wallBlockAir = Config.WALL.BLOCK.REPLACE_AIR.get();
- Material wallBlockSolid = Config.WALL.BLOCK.REPLACE_SOLID.get();
-
- if (wallBlockAir == null || !wallBlockAir.isSolid() || wallBlockSolid == null || !wallBlockSolid.isSolid())
- {
- throw new CannotGenerateWallsException("Cannot generate the walls: invalid blocks set in the config");
- }
-
- final WallGenerator generator = mapShape.getWallGeneratorInstance(wallBlockAir, wallBlockSolid);
- if (generator != null)
- generator.build(world, getCurrentBorderDiameter(), wallHeight);
- else
- throw new CannotGenerateWallsException("Unable to load walls generator.");
- }
-
/**
* Schedules the automatic border reduction, if enabled in the configuration.
*/
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java
index f4f528e..c15d00f 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java
@@ -32,10 +32,10 @@
package eu.carrade.amaury.UHCReloaded.modules.core.border;
import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta;
import fr.zcraft.zlib.components.configuration.ConfigurationInstance;
import fr.zcraft.zlib.components.configuration.ConfigurationItem;
import fr.zcraft.zlib.components.configuration.ConfigurationSection;
-import org.bukkit.Material;
import java.io.File;
@@ -63,25 +63,8 @@ public Config(File file)
static public class ShrinkingSection extends ConfigurationSection
{
public final ConfigurationItem ENABLED = item("enabled", false);
- public final ConfigurationItem STARTS_AFTER = item("startsAfter", "30:00");
- public final ConfigurationItem SHRINKS_DURING = item("shrinksDuring", "2:00:00");
+ public final ConfigurationItem STARTS_AFTER = item("startsAfter", new TimeDelta(0, 30, 0));
+ public final ConfigurationItem SHRINKS_DURING = item("shrinksDuring", new TimeDelta(2, 0, 0));
public final ConfigurationItem DIAMETER_AFTER_SHRINK = item("diameterAfterShrink", 200);
}
-
- public static final ConfigurationItem WARNING_INTERVAL = item("warningInterval", 90);
-
- public static final WallSection WALL = section("wall", WallSection.class);
-
- static public class WallSection extends ConfigurationSection
- {
- public final ConfigurationItem HEIGHT = item("height", 128);
-
- public final BlockSection BLOCK = section("block", BlockSection.class);
-
- static public class BlockSection extends ConfigurationSection
- {
- public final ConfigurationItem REPLACE_AIR = item("replaceAir", Material.GLASS);
- public final ConfigurationItem REPLACE_SOLID = item("replaceSolid", Material.BEDROCK);
- }
- }
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java
index a2e2438..362a2af 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java
@@ -31,55 +31,27 @@
*/
package eu.carrade.amaury.UHCReloaded.modules.core.border;
-import eu.carrade.amaury.UHCReloaded.modules.core.border.generators.CircularWallGenerator;
-import eu.carrade.amaury.UHCReloaded.modules.core.border.generators.SquaredWallGenerator;
-import eu.carrade.amaury.UHCReloaded.modules.core.border.generators.WallGenerator;
import eu.carrade.amaury.UHCReloaded.modules.core.border.shapes.CircularMapShape;
import eu.carrade.amaury.UHCReloaded.modules.core.border.shapes.MapShapeDescriptor;
import eu.carrade.amaury.UHCReloaded.modules.core.border.shapes.SquaredMapShape;
-import fr.zcraft.zlib.tools.PluginLogger;
-import org.bukkit.Material;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
public enum MapShape
{
- CIRCULAR(new CircularMapShape(), CircularWallGenerator.class),
- SQUARED(new SquaredMapShape(), SquaredWallGenerator.class);
+ CIRCULAR(new CircularMapShape()),
+ SQUARED(new SquaredMapShape()),
+
+ ;
private MapShapeDescriptor shape;
- private Class extends WallGenerator> generatorClass;
/**
- * @param generator The wall generator class associated with this shape.
+ * @param shape The shape descriptor to use for border-checks.
*/
- MapShape(MapShapeDescriptor shape, Class extends WallGenerator> generator)
+ MapShape(MapShapeDescriptor shape)
{
this.shape = shape;
- this.generatorClass = generator;
- }
-
- /**
- * Returns a new instance of the wall generator for this shape.
- *
- * @return The instance.
- */
- public WallGenerator getWallGeneratorInstance(Material wallBlockAir, Material wallBlockSolid)
- {
- try
- {
- Constructor constructor = generatorClass.getConstructor(Material.class, Material.class);
- return (WallGenerator) constructor.newInstance(wallBlockAir, wallBlockSolid);
-
- }
- catch (NoSuchMethodException | InstantiationException | InvocationTargetException | IllegalAccessException e)
- {
- PluginLogger.error("Cannot instantiate the walls generator: invalid class.", e);
- return null;
- }
}
/**
@@ -91,24 +63,4 @@ public MapShapeDescriptor getShape()
{
return shape;
}
-
- /**
- * Returns a shape based on his name.
- *
- * Not case sensitive.
- *
- * @param name The name.
- * @return The MapShape, or {@code null} if not found.
- */
- public static MapShape fromString(String name)
- {
- try
- {
- return MapShape.valueOf(name.trim().toUpperCase());
- }
- catch (IllegalArgumentException e)
- {
- return null;
- }
- }
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java
new file mode 100644
index 0000000..27d50d2
--- /dev/null
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java
@@ -0,0 +1,179 @@
+/*
+ * Plugin UHCReloaded : Alliances
+ *
+ * Copyright ou © ou Copr. Amaury Carrade (2016)
+ * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan".
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ */
+package eu.carrade.amaury.UHCReloaded.modules.core.border.commands;
+
+import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule;
+import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape;
+import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta;
+import eu.carrade.amaury.UHCReloaded.shortcuts.UR;
+import fr.zcraft.zlib.components.commands.Command;
+import fr.zcraft.zlib.components.commands.CommandException;
+import fr.zcraft.zlib.components.commands.CommandInfo;
+import fr.zcraft.zlib.components.i18n.I;
+import org.bukkit.Bukkit;
+
+
+@CommandInfo (name = "border", usageParameters = "[new diameter] [duration]", aliases = "b")
+public class BorderCommand extends Command
+{
+ @Override
+ protected void run() throws CommandException
+ {
+ final BorderModule border = UR.module(BorderModule.class);
+
+ // No arguments: displays current size
+ if (args.length == 0)
+ {
+ if (border.getMapShape() == MapShape.CIRCULAR)
+ {
+ sender.sendMessage(I.tn("{ci}The current diameter of the map is {0} block.", "{ci}The current diameter of the map is {0} blocks.", border.getCurrentBorderDiameter()));
+ }
+ else
+ {
+ sender.sendMessage(I.t("{ci}The current map size is {0}×{0}.", border.getCurrentBorderDiameter()));
+ }
+ }
+
+ else
+ {
+ // /uh border
+ if (args.length == 1)
+ {
+ try
+ {
+ final int newDiameter = Integer.valueOf(args[0]);
+
+ // Some players are outside
+ if (border.getPlayersOutside(newDiameter).size() != 0)
+ {
+ sender.sendMessage(I.t("{ce}Some players are outside the future border, so this operation was cancelled."));
+ sender.sendMessage(I.t("{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to this point.", args[0]));
+
+// TODO WorldBorder plugin
+// if (!p.getWorldBorderIntegration().isWBIntegrationEnabled())
+// {
+// sender.sendMessage(I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!"));
+// }
+
+ border.sendCheckMessage(sender, newDiameter);
+ }
+ else
+ {
+ border.setCurrentBorderDiameter(newDiameter);
+
+ if (border.getMapShape() == MapShape.CIRCULAR)
+ {
+ Bukkit.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter));
+ }
+ else
+ {
+ Bukkit.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter));
+ }
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ error(I.t("{ce}“{0}” is not a number...", args[0]));
+ }
+ }
+
+ // /uh border force
+ else if (args.length == 2 && args[1].equalsIgnoreCase("force"))
+ {
+ try
+ {
+ final Integer newDiameter = Integer.valueOf(args[0]);
+
+ border.setCurrentBorderDiameter(newDiameter);
+
+ if (border.getMapShape() == MapShape.CIRCULAR)
+ {
+ Bukkit.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter));
+ }
+ else
+ {
+ Bukkit.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter));
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ error(I.t("{ce}“{0}” is not a number...", args[0]));
+ }
+ }
+
+ // /uh border
+ else if (args.length == 2)
+ {
+ if (!border.getBorderProxy().supportsProgressiveResize())
+ {
+ error(I.t("The border motor ({0}) does not supports progressive resizes.", border.getBorderProxy().getClass().getSimpleName()));
+ }
+
+ final Integer newDiameter;
+ final TimeDelta delta;
+
+ try
+ {
+ newDiameter = Integer.valueOf(args[0]);
+ }
+ catch (NumberFormatException e)
+ {
+ error(I.t("{ce}“{0}” is not a number...", args[0]));
+ return;
+ }
+
+ try
+ {
+ delta = new TimeDelta(args[1]);
+ }
+ catch (IllegalArgumentException e)
+ {
+ error(I.t("{ce}“{0}” is not a valid time delta... Accepted formats are mm, mm:ss or hh:mm:ss.", args[1]));
+ return;
+ }
+
+ border.getBorderProxy().setDiameter(newDiameter, delta.getSeconds() * 20L);
+
+ if (border.getMapShape() == MapShape.CIRCULAR)
+ {
+ Bukkit.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map will be set to {0} block over {1}.", "{lightpurple}The diameter of the map will be set to {0} blocks over {1}.", newDiameter, newDiameter, delta));
+ }
+ else
+ {
+ Bukkit.getServer().broadcastMessage(I.t("{lightpurple}The size of the map will be set to {0}×{0} over {1}.", newDiameter, delta));
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/events/BorderChangedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/events/BorderChangedEvent.java
new file mode 100644
index 0000000..67bb055
--- /dev/null
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/events/BorderChangedEvent.java
@@ -0,0 +1,65 @@
+/*
+ * Plugin UHCReloaded : Alliances
+ *
+ * Copyright ou © ou Copr. Amaury Carrade (2016)
+ * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan".
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ */
+package eu.carrade.amaury.UHCReloaded.modules.core.border.events;
+
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+public class BorderChangedEvent extends Event
+{
+ private static final HandlerList handlers = new HandlerList();
+
+ private final int newDiameter;
+
+ public BorderChangedEvent(final int newDiameter)
+ {
+ this.newDiameter = newDiameter;
+ }
+
+ public int getNewDiameter()
+ {
+ return newDiameter;
+ }
+
+ @Override
+ public HandlerList getHandlers()
+ {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList()
+ {
+ return handlers;
+ }
+}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java
index b03c467..e5e3a0c 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java
@@ -222,4 +222,10 @@ public void setShape(MapShape shape)
{
border.setShape(shape == MapShape.CIRCULAR);
}
+
+ @Override
+ public boolean supportsProgressiveResize()
+ {
+ return true;
+ }
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java
index 6818f56..e90fcdf 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java
@@ -133,4 +133,10 @@ public void setShape(MapShape shape)
{
this.shape = shape;
}
+
+ @Override
+ public boolean supportsProgressiveResize()
+ {
+ return false;
+ }
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java
index c3ed1cf..d084305 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java
@@ -163,4 +163,10 @@ public MapShape getShape()
@Override
public void setShape(MapShape shape) {}
+
+ @Override
+ public boolean supportsProgressiveResize()
+ {
+ return true;
+ }
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java
index 7ce4b3b..787ad81 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java
@@ -145,6 +145,11 @@ public void init() {}
*/
public abstract void setShape(MapShape shape);
+ /**
+ * @return {@code true} if this border supports progressive resizes using {@link #setDiameter(double, long)}.
+ */
+ public abstract boolean supportsProgressiveResize();
+
/**
* Returns a new instance of a WorldBorder proxy using the requested types.
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java
index 28320de..9835b86 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java
@@ -58,7 +58,7 @@
)
public class GameModule extends UHModule implements Listener
{
- private GamePhase phase = GamePhase.WAIT;
+ private GamePhase phase = null;
private final Set players = new HashSet<>();
private final Set spectators = new HashSet<>();
@@ -66,7 +66,7 @@ public class GameModule extends UHModule implements Listener
@Override
protected void onEnable()
{
-
+ setPhase(GamePhase.WAIT);
}
@Override
@@ -99,7 +99,7 @@ public GamePhase getPhase()
*/
public void setPhase(GamePhase phase)
{
- if (this.phase != phase && phase.ordinal() > this.phase.ordinal())
+ if (this.phase == null || (this.phase != phase && phase.ordinal() > this.phase.ordinal()))
{
final GamePhase oldPhase = this.phase;
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java
index c2392cf..f30ea0d 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java
@@ -37,7 +37,7 @@
/**
- * Fired after a module was loaded.
+ * Fired when the game phase changes.
*/
public class GamePhaseChangedEvent extends Event
{
@@ -52,11 +52,19 @@ public GamePhaseChangedEvent(final GamePhase oldPhase, final GamePhase newPhase)
this.newPhase = newPhase;
}
+ /**
+ * The old phase. May be {@code null} if this is the first phase ever (i.e. {@link GamePhase#WAIT}).
+ *
+ * @return The old phase.
+ */
public GamePhase getOldPhase()
{
return oldPhase;
}
+ /**
+ * @return The new phase.
+ */
public GamePhase getNewPhase()
{
return newPhase;
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java
index db67d31..2786599 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java
@@ -38,7 +38,8 @@
import fr.zcraft.zlib.components.commands.CommandInfo;
import fr.zcraft.zlib.components.i18n.I;
-import java.util.Collection;
+import java.util.Set;
+import java.util.TreeSet;
@CommandInfo (name = "modules", usageParameters = "[list|enable|disable]", aliases = {"module"})
@@ -47,9 +48,39 @@ public class ModulesCommand extends Command
@Override
protected void run() throws CommandException
{
- final Collection modules = UHCReloaded.get().getModules();
+ final Set modules = new TreeSet<>((module1, module2) -> {
+ if (module1.equals(module2)) return 0;
+
+ if (module1.isEnabled() != module2.isEnabled()) return module1.isEnabled() ? -1 : 1;
+
+ if (module1.getWhen() != module2.getWhen())
+ return Integer.compare(module1.getWhen().ordinal(), module2.getWhen().ordinal());
+
+ if (module1.isInternal() != module2.isInternal()) return module1.isInternal() ? -1 : 1;
+
+ return module1.getName().compareTo(module2.getName());
+ });
+
+ modules.addAll(UHCReloaded.get().getModules());
success(I.tn("{0} module registered", "{0} modules registered", modules.size()));
- modules.forEach(module -> info(I.t("- {0} ({1} - {2})", module.getName(), module.isEnabled() ? "enabled" : "disabled", module.getWhen())));
+ modules.forEach(module -> {
+ if (module.isEnabled())
+ {
+ info(I.t(
+ "{green} • {white}{0} (enabled - {1})",
+ module.getName(),
+ module.getWhen()
+ ));
+ }
+ else
+ {
+ info(I.t(
+ "{red} • {white}{0} (disabled - {1})",
+ module.getName(),
+ module.getWhen()
+ ));
+ }
+ });
}
}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java
index 186eb04..06beaa2 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java
@@ -35,11 +35,15 @@
import fr.zcraft.zlib.components.configuration.ConfigurationValueHandler;
import fr.zcraft.zlib.components.configuration.ConfigurationValueHandlers;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
import java.util.Objects;
public class TimeDelta
{
+ private static final NumberFormat formatter = new DecimalFormat("00");
+
private final long seconds;
static
@@ -113,6 +117,23 @@ public long getSeconds()
return seconds;
}
+ @Override
+ public String toString()
+ {
+ final long secondsLeft = seconds % 60;
+ final long minutesLeft = (seconds % 3600) / 60;
+ final long hoursLeft = (long) Math.floor(seconds / 3600.0);
+
+ if (hoursLeft != 0)
+ {
+ return formatter.format(hoursLeft) + ":" + formatter.format(minutesLeft) + ":" + formatter.format(secondsLeft);
+ }
+ else
+ {
+ return formatter.format(minutesLeft) + ":" + formatter.format(secondsLeft);
+ }
+ }
+
@Override
public boolean equals(Object o)
{
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java
index 03d7f6e..7dce0ce 100644
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java
+++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java
@@ -32,28 +32,7 @@
package eu.carrade.amaury.UHCReloaded.old.commands.commands;
import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHAboutCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHBorderCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHFeedAllCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHFeedCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHFinishCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHFreezeCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHGenerateWallsCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHHealAllCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHHealCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHInfosCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHKillCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHLoadPlayersCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHResurrectCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHRulesCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHShiftCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHSpawnsCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHSpectatorsCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHStartCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTPBackCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTPCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTPSpawnCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTeamCommand;
+import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.*;
import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
@@ -75,10 +54,7 @@ public UHRootCommand(UHCReloaded plugin)
registerSubCommand(new UHStartCommand(p));
registerSubCommand(new UHShiftCommand(p));
registerSubCommand(new UHSpawnsCommand(p));
- registerSubCommand(new UHTeamCommand(p));
- registerSubCommand(new UHBorderCommand(p));
registerSubCommand(new UHSpectatorsCommand(p));
- registerSubCommand(new UHGenerateWallsCommand(p));
// Bugs
registerSubCommand(new UHHealCommand(p));
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHBorderCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHBorderCommand.java
deleted file mode 100644
index 5386e47..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHBorderCommand.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border.UHBorderCheckCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border.UHBorderGetCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border.UHBorderSetCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border.UHBorderWarningCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.Collections;
-import java.util.List;
-
-
-/**
- * This command manages borders (gets current, checks if players are out, sets a new size, warns players
- * about the future size).
- *
- * Usage: /uh border (doc)
- * Usage: /uh border
- */
-@Command (name = "border")
-public class UHBorderCommand extends AbstractCommand
-{
- public UHBorderCommand(UHCReloaded p)
- {
- registerSubCommand(new UHBorderGetCommand(p));
- registerSubCommand(new UHBorderSetCommand(p));
- registerSubCommand(new UHBorderWarningCommand(p));
- registerSubCommand(new UHBorderCheckCommand(p));
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this);
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- return null;
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return Collections.singletonList(I.t("{aqua}------ Border commands ------"));
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh border {ci}: manages borders. Execute /uh border for details."));
- }
-
- @Override
- public String getCategory()
- {
- return Category.GAME.getTitle();
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java
deleted file mode 100644
index ea42728..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.World;
-import org.bukkit.command.BlockCommandSender;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * This command generates the walls around the map.
- *
- * Usage: /uh generatewalls
- */
-@Command (name = "generatewalls")
-public class UHGenerateWallsCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHGenerateWallsCommand(UHCReloaded plugin)
- {
- p = plugin;
- }
-
- /**
- * Runs the command.
- *
- * @param sender The sender of the command.
- * @param args The arguments passed to the command.
- *
- * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed.
- */
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- sender.sendMessage(I.t("{cst}Generating the walls..."));
-
- final World world;
-
- if (sender instanceof Player)
- {
- world = ((Player) sender).getWorld();
- }
- else if (sender instanceof BlockCommandSender)
- {
- world = ((BlockCommandSender) sender).getBlock().getWorld();
- }
- else
- {
- world = p.getServer().getWorlds().get(0);
- sender.sendMessage(I.t("{ci}From the console, generating the walls of the default world, {0}", world.getName()));
- }
-
-// try
-// {
-// p.getBorderManager().generateWalls(world);
-// }
-// catch (CannotGenerateWallsException e)
-// {
-// sender.sendMessage(I.t("{ce}Unable to generate the wall: see logs for details. The blocks set in the config are probably invalid."));
-// return;
-//
-// }
-// catch (Exception e)
-// {
-// sender.sendMessage(I.t("{ce}An error occurred, see console for details."));
-// e.printStackTrace();
-// return;
-// }
-
- sender.sendMessage(I.t("{cst}Generation done."));
- }
-
- /**
- * Tab-completes this command.
- *
- * @param sender The sender.
- * @param args The arguments passed to the command.
- *
- * @return A list of suggestions.
- */
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- return null;
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh generatewalls {ci}: generates the walls according to the configuration."));
- }
-
- @Override
- public String getCategory()
- {
- return Category.GAME.getTitle();
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTeamCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTeamCommand.java
deleted file mode 100644
index 1d7d766..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTeamCommand.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamAddCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamBannerCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamBannerResetCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamGUICommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamJoinCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamLeaveCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamListCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamRemoveCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamResetCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamSpyCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * This command is used to manage the teams.
- *
- * Usage: /uh team (for the doc).
- * Usage: /uh team (see doc for details).
- */
-@Command (name = "team")
-public class UHTeamCommand extends AbstractCommand
-{
- public UHTeamCommand(UHCReloaded plugin)
- {
- registerSubCommand(new UHTeamAddCommand(plugin));
- registerSubCommand(new UHTeamRemoveCommand(plugin));
- registerSubCommand(new UHTeamJoinCommand(plugin));
- registerSubCommand(new UHTeamLeaveCommand(plugin));
- registerSubCommand(new UHTeamBannerCommand());
- registerSubCommand(new UHTeamBannerResetCommand());
- registerSubCommand(new UHTeamListCommand(plugin));
- registerSubCommand(new UHTeamSpyCommand(plugin));
- registerSubCommand(new UHTeamResetCommand(plugin));
- registerSubCommand(new UHTeamGUICommand(plugin));
- }
-
- /**
- * This will be executed if this command is called without argument,
- * or if there isn't any sub-command executor registered.
- *
- * @param sender The sender.
- * @param args The arguments passed to the command.
- */
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this);
- }
-
- /**
- * The result of this method will be added to the tab-complete suggestions for this command.
- *
- * @param sender The sender.
- * @param args The arguments.
- *
- * @return The suggestions to add.
- */
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- return null;
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return Arrays.asList(
- I.t("{aqua}------ Team commands ------"),
- I.t("{cc}/join [player] {ci}: adds “player” (or the sender) inside the given team. Without arguments, displays the chat-based team selector."),
- I.t("{cc}/leave [player] {ci}: removes “player” (or the sender) from his team.")
- );
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh team {ci}: manages the teams. Execute /uh team for details."));
- }
-
- @Override
- public String getCategory()
- {
- return Category.GAME.getTitle();
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java
deleted file mode 100644
index 51b7bdd..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.Collections;
-import java.util.List;
-
-@Command (name = "check")
-public class UHBorderCheckCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHBorderCheckCommand(UHCReloaded p)
- {
- this.p = p;
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- // /uh border check
- if (args.length == 0)
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
- }
- // /uh border check >
- else
- {
- try
- {
-// p.getBorderManager().sendCheckMessage(sender, Integer.valueOf(args[0]));
- }
- catch (NumberFormatException e)
- {
- sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0]));
- }
- }
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- return null;
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh border check {ci}: returns a list of the players outside the given border size."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java
deleted file mode 100644
index 66cab42..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.Collections;
-import java.util.List;
-
-@Command (name = "get")
-public class UHBorderGetCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHBorderGetCommand(UHCReloaded p)
- {
- this.p = p;
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
-// if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR)
-// {
-// sender.sendMessage(I.tn("{ci}The current diameter of the map is {0} block.", "{ci}The current diameter of the map is {0} blocks.", p.getBorderManager().getCurrentBorderDiameter()));
-// }
-// else
-// {
-// sender.sendMessage(I.t("{ci}The current map size is {0}×{0}.", p.getBorderManager().getCurrentBorderDiameter()));
-// }
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- return null;
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh border get{ci}: returns the current size of the map."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java
deleted file mode 100644
index ec83ece..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.Collections;
-import java.util.List;
-
-@Command (name = "set")
-public class UHBorderSetCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHBorderSetCommand(UHCReloaded p)
- {
- this.p = p;
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
-// // /uh border set
-// if (args.length == 0)
-// {
-// throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
-// }
-//
-// // /uh border set >
-// else if (args.length == 1)
-// {
-// try
-// {
-// final int newDiameter = Integer.valueOf(args[0]);
-//
-// // Some players are outside
-// if (p.getBorderManager().getPlayersOutside(newDiameter).size() != 0)
-// {
-// sender.sendMessage(I.t("{ce}Some players are outside the future border, so this operation was cancelled."));
-// sender.sendMessage(I.t("{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to this point.", args[0]));
-//
-// if (!p.getWorldBorderIntegration().isWBIntegrationEnabled())
-// {
-// sender.sendMessage(I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!"));
-// }
-//
-// p.getBorderManager().sendCheckMessage(sender, newDiameter);
-// }
-// else
-// {
-// p.getBorderManager().setCurrentBorderDiameter(newDiameter);
-//
-// if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR)
-// {
-// p.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter));
-// }
-// else
-// {
-// p.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter));
-// }
-// }
-// }
-// catch (NumberFormatException e)
-// {
-// sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0]));
-// }
-// }
-//
-// // /uh border set > force
-// else if (args.length == 2 && args[1].equalsIgnoreCase("force"))
-// {
-// try
-// {
-// Integer newDiameter = Integer.valueOf(args[0]);
-//
-// p.getBorderManager().setCurrentBorderDiameter(newDiameter);
-//
-// if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR)
-// {
-// p.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter));
-// }
-// else
-// {
-// p.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter));
-// }
-// }
-// catch (NumberFormatException e)
-// {
-// sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0]));
-// }
-// }
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- if (args.length == 2)
- {
- return CommandUtils.getAutocompleteSuggestions(args[1], Collections.singletonList("force"));
- }
-
- else return null;
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh border set [force]{ci}: changes the size of the map. If force is not given, the operation will be canceled if there is a player outside the border."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java
deleted file mode 100644
index 807e3d7..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.UHConfig;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-
-@Command (name = "warning")
-public class UHBorderWarningCommand extends AbstractCommand
-{
- private final Integer WARNING_INTERVAL;
-
- private final UHCReloaded p;
-
-
- public UHBorderWarningCommand(UHCReloaded p)
- {
- this.p = p;
-
- WARNING_INTERVAL = UHConfig.MAP.BORDER.WARNING_INTERVAL.get();
- }
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- if (args.length == 0)
- { // /uh border warning
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
- }
- else if (args[0].equalsIgnoreCase("cancel"))
- { // /uh border warning cancel
- // p.getBorderManager().cancelWarning();
- sender.sendMessage(I.t("{cs}Warning canceled."));
- }
- else
- { // /uh border warning >
- try
- {
- int warnDiameter = Integer.parseInt(args[0]);
- int warnTime = 0;
-
- // /uh border warning > >
- if (args.length >= 4)
- {
- warnTime = Integer.parseInt(args[1]);
- }
-
- // p.getBorderManager().setWarningSize(warnDiameter, warnTime, sender);
- sender.sendMessage(I.tn("{cs}Future size saved. All players outside this future border will be warned every {0} second.", "{cs}Future size saved. All players outside this future border will be warned every {0} seconds.", WARNING_INTERVAL));
-
- }
- catch (NumberFormatException e)
- {
- sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0]));
- }
- }
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- if (args.length == 1)
- {
- return CommandUtils.getAutocompleteSuggestions(args[0], Collections.singletonList("cancel"));
- }
-
- else return null;
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Arrays.asList(I.t("{cc}/uh border warning [minutesBeforeReduction]{ci}: warns all players outside the given future diameter. It's just a notice, nothing else."), I.t("{cc}/uh border warning cancel{ci}: cancels a previously-set warning."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamAddCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamAddCommand.java
deleted file mode 100644
index b00023a..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamAddCommand.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor;
-import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-
-@Command (name = "add")
-public class UHTeamAddCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHTeamAddCommand(UHCReloaded plugin)
- {
- p = plugin;
- }
-
- /**
- * Runs the command.
- *
- * @param sender The sender of the command.
- * @param args The arguments passed to the command.
- *
- * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed.
- */
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- // /uh team add
- if (args.length == 1)
- {
-
- TeamColor color = TeamColor.fromString(args[0]);
- UHTeam team;
-
- if (color == null)
- {
- sender.sendMessage(I.t("{ce}Unable to add the team, check the color name. Tip: use Tab to autocomplete."));
- }
- else
- {
- try
- {
- team = p.getTeamManager().addTeam(color);
- }
- catch (IllegalArgumentException e)
- {
- sender.sendMessage(I.t("{ce}This team already exists."));
- return;
- }
-
- sender.sendMessage(I.t("{cs}Team {0}{cs} added.", team.getDisplayName()));
- }
-
- }
- else if (args.length >= 2)
- { // /uh team add
-
- TeamColor color = TeamColor.fromString(args[0]);
- UHTeam team;
-
- if (color == null)
- {
- sender.sendMessage(I.t("{ce}Unable to add the team, check the color name. Tip: use Tab to autocomplete."));
- }
- else
- {
- String name = UHUtils.getStringFromCommandArguments(args, 1);
-
- try
- {
- team = p.getTeamManager().addTeam(color, name);
- }
- catch (IllegalArgumentException e)
- {
- sender.sendMessage(I.t("{ce}This team already exists."));
- return;
- }
-
- sender.sendMessage(I.t("{cs}Team {0}{cs} added.", team.getDisplayName()));
- }
-
- }
- else
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
- }
- }
-
- /**
- * Tab-completes this command.
- *
- * @param sender The sender.
- * @param args The arguments passed to the command.
- *
- * @return A list of suggestions.
- */
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- if (args.length == 1)
- {
- List colors = Arrays.asList("aqua", "black", "blue", "darkaqua",
- "darkblue", "darkgray", "darkgreen", "darkpurple", "darkred",
- "gold", "gray", "green", "lightpurple", "red", "white", "yellow", "?");
-
- return CommandUtils.getAutocompleteSuggestions(args[0], colors);
- }
-
- return null;
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh team add [] {ci}: adds a team with the provided color."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerCommand.java
deleted file mode 100644
index f8ce689..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerCommand.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.Material;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-
-@Command (name = "banner")
-public class UHTeamBannerCommand extends AbstractCommand
-{
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- if (!(sender instanceof Player))
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER, this);
-
- final UHTeam team;
-
- if (args.length >= 1)
- {
- String name = UHUtils.getStringFromCommandArguments(args, 0);
- team = UHCReloaded.get().getTeamManager().getTeam(name);
- }
- else
- {
- team = UHCReloaded.get().getTeamManager().getTeamForPlayer((Player) sender);
- }
-
- if (team == null)
- {
- sender.sendMessage(I.t("{ce}Either this team does not exists, or you are not in a team."));
- }
- else if (((Player) sender).getItemInHand().getType() != Material.BANNER)
- {
- sender.sendMessage(I.t("{ce}You must run this command with a banner in your main hand."));
- }
- else
- {
- team.setBanner(((Player) sender).getItemInHand());
- sender.sendMessage(I.t("{cs}The banner of the team {0}{cs} was successfully updated.", team.getDisplayName()));
- }
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- ArrayList teamNames = new ArrayList<>();
-
- for (UHTeam team : UHCReloaded.get().getTeamManager().getTeams())
- {
- teamNames.add(team.getName());
- }
-
- return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), teamNames, args.length - 1);
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh team banner [team name ...] {ci}: updates the team's banner using the banner in the sender hand. If the team name is not provided, uses the sender's team."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerResetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerResetCommand.java
deleted file mode 100644
index 80bfaae..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerResetCommand.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.bukkit.inventory.ItemStack;
-
-
-@Command (name = "bannerreset")
-public class UHTeamBannerResetCommand extends AbstractCommand
-{
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- UHTeam team = null;
-
- if (args.length >= 1)
- {
- String name = UHUtils.getStringFromCommandArguments(args, 0);
- team = UHCReloaded.get().getTeamManager().getTeam(name);
- }
- else if (sender instanceof Player)
- {
- team = UHCReloaded.get().getTeamManager().getTeamForPlayer((Player) sender);
- }
- else
- {
- /// Error message of /uh team bannerreset from the console without name
- sender.sendMessage(I.t("{ce}From the console, you must provide a team name."));
- }
-
-
- if (team == null)
- {
- sender.sendMessage(I.t("{ce}Either this team does not exists, or you are not in a team."));
- }
- else
- {
- team.setBanner((ItemStack) null);
- sender.sendMessage(I.t("{cs}The banner of the team {0}{cs} was successfully reset to the default one.", team.getDisplayName()));
- }
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- ArrayList teamNames = new ArrayList<>();
-
- for (UHTeam team : UHCReloaded.get().getTeamManager().getTeams())
- {
- teamNames.add(team.getName());
- }
-
- return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), teamNames, args.length - 1);
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh team bannerreset [team name ...] {ci}: resets the banner of the team to the default. If the team name is not provided, uses the sender's team."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamGUICommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamGUICommand.java
deleted file mode 100644
index 3016b6d..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamGUICommand.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.teams.TeamsSelectorGUI;
-import fr.zcraft.zlib.components.gui.Gui;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-import java.util.Collections;
-import java.util.List;
-
-
-@Command (name = "gui", noPermission = true, inheritPermission = false)
-public class UHTeamGUICommand extends AbstractCommand
-{
- public UHTeamGUICommand(UHCReloaded plugin) {}
-
-
- @Override
- public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- if (!(sender instanceof Player))
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER, this);
- }
-
- Gui.open((Player) sender, new TeamsSelectorGUI());
- }
-
- @Override
- public List tabComplete(CommandSender sender, String[] args)
- {
- return null;
- }
-
- @Override
- public List help(CommandSender sender)
- {
- return null;
- }
-
- @Override
- public List onListHelp(CommandSender sender)
- {
- return Collections.singletonList(I.t("{cc}/uh team gui {ci}: opens a GUI to join and manage the teams."));
- }
-}
diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamJoinCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamJoinCommand.java
deleted file mode 100644
index e37737d..0000000
--- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamJoinCommand.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright or © or Copr. Amaury Carrade (2014 - 2016)
- *
- * http://amaury.carrade.eu
- *
- * This software is governed by the CeCILL-B license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-B
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-B license and that you accept its terms.
- */
-package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team;
-
-import eu.carrade.amaury.UHCReloaded.UHCReloaded;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException;
-import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils;
-import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader;
-import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam;
-import eu.carrade.amaury.UHCReloaded.utils.UHUtils;
-import fr.zcraft.zlib.components.i18n.I;
-import org.bukkit.Bukkit;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-
-/**
- * This class is used for both /uh team join and /join commands.
- *
- * @see {@link eu.carrade.amaury.UHCReloaded.old.commands.commands.JoinCommand}.
- */
-@Command (name = "join")
-public class UHTeamJoinCommand extends AbstractCommand
-{
- private UHCReloaded p;
-
- public UHTeamJoinCommand(UHCReloaded plugin)
- {
- p = plugin;
- }
-
-
- /**
- * Runs the command.
- *
- * @param sender The sender of the command.
- * @param args The arguments passed to the command.
- *
- * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed.
- */
- @Override
- public void run(final CommandSender sender, String[] args) throws CannotExecuteCommandException
- {
- if (args.length == 0)
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this);
-
- UHTeam team;
-
- String targetName = "";
- Boolean self = null;
-
- // /... join ?
- team = p.getTeamManager().getTeam(UHUtils.getStringFromCommandArguments(args, 0));
- if (team != null)
- {
- if (sender instanceof Player)
- {
- targetName = sender.getName();
- self = true;
- }
- else
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER);
- }
- }
-
- // /... join ?
- else if (args.length >= 2)
- {
- team = p.getTeamManager().getTeam(UHUtils.getStringFromCommandArguments(args, 1));
- if (team != null)
- {
- targetName = args[0];
- self = false;
- }
- }
-
- if (team == null)
- {
- sender.sendMessage(I.t("{ce}This team does not exists."));
- }
- else if (sender.hasPermission("uh.team.join")
- || (self && sender.hasPermission("uh.player.join.self"))
- || (!self && sender.hasPermission("uh.player.join.others")))
- {
- final UHTeam finalTeam = team;
- OfflinePlayersLoader.loadPlayer(targetName, player -> {
- if (player == null)
- {
- sender.sendMessage(I.t("{ce}Unable to retrieve the player {0}."));
-
- if (!Bukkit.getOnlineMode())
- sender.sendMessage(I.t("{ce}In offline mode, you cannot add players if they never came to this server."));
-
- return;
- }
-
- finalTeam.addPlayer(player);
-
- if (!sender.equals(player))
- {
- sender.sendMessage(I.t("{cs}The player {0} was successfully added to the team {1}", player.getName(), finalTeam.getName()));
- }
- });
- }
- else
- {
- throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NOT_ALLOWED, this);
- }
- }
-
- /**
- * Tab-completes this command.
- *
- * @param sender The sender.
- * @param args The arguments passed to the command.
- *
- * @return A list of suggestions.
- */
- @Override
- public List