🚧 Add koth events

This commit is contained in:
Maxlego08 2024-02-22 14:31:23 +01:00
parent 1fd765fa0e
commit 252de85ee7
20 changed files with 1042 additions and 123 deletions

View File

@ -1,9 +1,11 @@
package fr.maxlego08.koth; package fr.maxlego08.koth;
import fr.maxlego08.koth.api.Koth;
import fr.maxlego08.koth.board.Board; import fr.maxlego08.koth.board.Board;
import fr.maxlego08.koth.board.ColorBoard; import fr.maxlego08.koth.board.ColorBoard;
import fr.maxlego08.koth.board.EmptyBoard; import fr.maxlego08.koth.board.EmptyBoard;
import fr.maxlego08.koth.listener.ListenerAdapter; import fr.maxlego08.koth.listener.ListenerAdapter;
import fr.maxlego08.koth.save.Config;
import fr.maxlego08.koth.zcore.enums.Message; import fr.maxlego08.koth.zcore.enums.Message;
import fr.maxlego08.koth.zcore.utils.nms.NMSUtils; import fr.maxlego08.koth.zcore.utils.nms.NMSUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -12,11 +14,13 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Shulker; import org.bukkit.entity.Shulker;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import java.util.List;
import java.util.Optional; import java.util.Optional;
public class KothListener extends ListenerAdapter { public class KothListener extends ListenerAdapter {
@ -24,6 +28,7 @@ public class KothListener extends ListenerAdapter {
private final KothPlugin plugin; private final KothPlugin plugin;
private final KothManager manager; private final KothManager manager;
private final Board board = NMSUtils.isHexColor() ? new ColorBoard() : new EmptyBoard(); private final Board board = NMSUtils.isHexColor() ? new ColorBoard() : new EmptyBoard();
private long playerMoveEventCooldown = 0;
public KothListener(KothPlugin plugin, KothManager manager) { public KothListener(KothPlugin plugin, KothManager manager) {
this.plugin = plugin; this.plugin = plugin;
@ -83,4 +88,15 @@ public class KothListener extends ListenerAdapter {
} }
} }
} }
@Override
protected void onMove(PlayerMoveEvent event, Player player) {
if (System.currentTimeMillis() > this.playerMoveEventCooldown) {
this.playerMoveEventCooldown = System.currentTimeMillis() + Config.playerMoveEventCooldown;
List<Koth> koths = this.manager.getActiveKoths();
koths.forEach(koth -> koth.playerMove(player, this.manager.getKothTeam()));
}
}
} }

View File

@ -1,6 +1,7 @@
package fr.maxlego08.koth; package fr.maxlego08.koth;
import fr.maxlego08.koth.api.Koth; import fr.maxlego08.koth.api.Koth;
import fr.maxlego08.koth.api.KothStatus;
import fr.maxlego08.koth.api.KothTeam; import fr.maxlego08.koth.api.KothTeam;
import fr.maxlego08.koth.api.KothType; import fr.maxlego08.koth.api.KothType;
import fr.maxlego08.koth.api.events.KothCreateEvent; import fr.maxlego08.koth.api.events.KothCreateEvent;
@ -28,10 +29,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
public class KothManager extends ZUtils implements Savable { public class KothManager extends ZUtils implements Savable {
private final Loader<Koth> kothLoader = new KothLoader(); private final Loader<Koth> kothLoader;
private final List<Koth> koths = new ArrayList<>(); private final List<Koth> koths = new ArrayList<>();
private final Map<UUID, Selection> selections = new HashMap<>(); private final Map<UUID, Selection> selections = new HashMap<>();
private final KothPlugin plugin; private final KothPlugin plugin;
@ -40,6 +42,7 @@ public class KothManager extends ZUtils implements Savable {
public KothManager(KothPlugin plugin) { public KothManager(KothPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
this.kothLoader = new KothLoader(plugin);
this.folder = new File(plugin.getDataFolder(), "koths"); this.folder = new File(plugin.getDataFolder(), "koths");
if (!this.folder.exists()) this.folder.mkdir(); if (!this.folder.exists()) this.folder.mkdir();
@ -121,7 +124,7 @@ public class KothManager extends ZUtils implements Savable {
} }
String fileName = name.replace(" ", "_"); String fileName = name.replace(" ", "_");
Koth koth = new ZKoth(fileName, kothType, name, capture, minLocation, maxLocation); Koth koth = new ZKoth(this.plugin, fileName, kothType, name, capture, minLocation, maxLocation);
KothCreateEvent event = new KothCreateEvent(koth); KothCreateEvent event = new KothCreateEvent(koth);
event.call(); event.call();
@ -144,4 +147,12 @@ public class KothManager extends ZUtils implements Savable {
public KothTeam getKothTeam() { public KothTeam getKothTeam() {
return kothTeam; return kothTeam;
} }
public List<Koth> getActiveKoths() {
return koths.stream().filter(koth -> koth.getStatus() == KothStatus.START).collect(Collectors.toList());
}
public List<Koth> getEnableKoths() {
return koths.stream().filter(koth -> koth.getStatus() == KothStatus.COOLDOWN).collect(Collectors.toList());
}
} }

View File

@ -5,6 +5,7 @@ import fr.maxlego08.koth.command.commands.CommandKoth;
import fr.maxlego08.koth.hook.ScoreboardPlugin; import fr.maxlego08.koth.hook.ScoreboardPlugin;
import fr.maxlego08.koth.hook.scoreboard.DefaultHook; import fr.maxlego08.koth.hook.scoreboard.DefaultHook;
import fr.maxlego08.koth.placeholder.LocalPlaceholder; import fr.maxlego08.koth.placeholder.LocalPlaceholder;
import fr.maxlego08.koth.save.Config;
import fr.maxlego08.koth.save.MessageLoader; import fr.maxlego08.koth.save.MessageLoader;
import fr.maxlego08.koth.storage.StorageManager; import fr.maxlego08.koth.storage.StorageManager;
import fr.maxlego08.koth.zcore.ZPlugin; import fr.maxlego08.koth.zcore.ZPlugin;
@ -42,6 +43,7 @@ public class KothPlugin extends ZPlugin {
this.addListener(new KothListener(this, this.kothManager)); this.addListener(new KothListener(this, this.kothManager));
Config.getInstance().load(this);
this.loadFiles(); this.loadFiles();
for (ScoreboardPlugin value : ScoreboardPlugin.values()) { for (ScoreboardPlugin value : ScoreboardPlugin.values()) {

View File

@ -1,28 +1,69 @@
package fr.maxlego08.koth; package fr.maxlego08.koth;
import fr.maxlego08.koth.api.Koth; import fr.maxlego08.koth.api.Koth;
import fr.maxlego08.koth.api.KothStatus;
import fr.maxlego08.koth.api.KothTeam;
import fr.maxlego08.koth.api.KothType; import fr.maxlego08.koth.api.KothType;
import fr.maxlego08.koth.api.events.KothCapEvent;
import fr.maxlego08.koth.api.events.KothCatchEvent;
import fr.maxlego08.koth.api.events.KothLooseEvent;
import fr.maxlego08.koth.api.events.KothSpawnEvent;
import fr.maxlego08.koth.api.events.KothStartEvent;
import fr.maxlego08.koth.api.events.KothStopEvent;
import fr.maxlego08.koth.api.events.KothWinEvent;
import fr.maxlego08.koth.api.utils.ScoreboardConfiguration; import fr.maxlego08.koth.api.utils.ScoreboardConfiguration;
import fr.maxlego08.koth.hook.teams.NoneHook;
import fr.maxlego08.koth.save.Config;
import fr.maxlego08.koth.zcore.enums.Message;
import fr.maxlego08.koth.zcore.utils.Cuboid; import fr.maxlego08.koth.zcore.utils.Cuboid;
import fr.maxlego08.koth.zcore.utils.ZUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
public class ZKoth implements Koth { public class ZKoth extends ZUtils implements Koth {
private final KothPlugin plugin;
private final String fileName; private final String fileName;
private final KothType kothType; private final KothType kothType;
private final ScoreboardConfiguration cooldownScoreboard; private final ScoreboardConfiguration cooldownScoreboard;
private final ScoreboardConfiguration startScoreboard; private final ScoreboardConfiguration startScoreboard;
private final int cooldownStart;
private final int stopAfterSeconds;
private final Map<UUID, Integer> playersValues = new HashMap<>();
private final boolean enableStartCapMessage;
private final boolean enableLooseCapMessage;
private final boolean enableEverySecondsCapMessage;
private String name; private String name;
private int captureSeconds; private int captureSeconds;
private Location minLocation; private Location minLocation;
private Location maxLocation; private Location maxLocation;
private List<String> startCommands = new ArrayList<>(); private List<String> startCommands = new ArrayList<>();
private List<String> endCommands = new ArrayList<>(); private List<String> endCommands = new ArrayList<>();
private KothStatus kothStatus = KothStatus.STOP;
private KothTeam kothTeam = new NoneHook();
private Player currentPlayer;
private AtomicInteger remainingSeconds;
private TimerTask timerTask;
private TimerTask timerTaskStop;
public ZKoth(String fileName, KothType kothType, String name, int captureSeconds, Location minLocation, Location maxLocation, List<String> startCommands, List<String> endCommands, ScoreboardConfiguration cooldownScoreboard, ScoreboardConfiguration startScoreboard) { public ZKoth(KothPlugin plugin, String fileName, KothType kothType, String name, int captureSeconds, Location minLocation, Location maxLocation,
List<String> startCommands, List<String> endCommands, ScoreboardConfiguration cooldownScoreboard, ScoreboardConfiguration startScoreboard,
int cooldownStart, int stopAfterSeconds, boolean enableStartCapMessage, boolean enableLooseCapMessage, boolean enableEverySecondsCapMessage) {
this.plugin = plugin;
this.fileName = fileName; this.fileName = fileName;
this.kothType = kothType; this.kothType = kothType;
this.name = name; this.name = name;
@ -33,9 +74,15 @@ public class ZKoth implements Koth {
this.endCommands = endCommands; this.endCommands = endCommands;
this.startScoreboard = startScoreboard; this.startScoreboard = startScoreboard;
this.cooldownScoreboard = cooldownScoreboard; this.cooldownScoreboard = cooldownScoreboard;
this.cooldownStart = cooldownStart;
this.stopAfterSeconds = stopAfterSeconds;
this.enableStartCapMessage = enableStartCapMessage;
this.enableLooseCapMessage = enableLooseCapMessage;
this.enableEverySecondsCapMessage = enableEverySecondsCapMessage;
} }
public ZKoth(String fileName, KothType kothType, String name, int captureSeconds, Location minLocation, Location maxLocation) { public ZKoth(KothPlugin plugin, String fileName, KothType kothType, String name, int captureSeconds, Location minLocation, Location maxLocation) {
this.plugin = plugin;
this.fileName = fileName; this.fileName = fileName;
this.kothType = kothType; this.kothType = kothType;
this.name = name; this.name = name;
@ -44,6 +91,11 @@ public class ZKoth implements Koth {
this.maxLocation = maxLocation; this.maxLocation = maxLocation;
this.startScoreboard = new ScoreboardConfiguration(); this.startScoreboard = new ScoreboardConfiguration();
this.cooldownScoreboard = new ScoreboardConfiguration(); this.cooldownScoreboard = new ScoreboardConfiguration();
this.cooldownStart = 300;
this.stopAfterSeconds = 3600;
this.enableStartCapMessage = true;
this.enableLooseCapMessage = true;
this.enableEverySecondsCapMessage = false;
} }
@Override @Override
@ -81,6 +133,26 @@ public class ZKoth implements Koth {
return new Cuboid(this.maxLocation, this.minLocation); return new Cuboid(this.maxLocation, this.minLocation);
} }
@Override
public boolean isEnableStartCapMessage() {
return this.enableStartCapMessage;
}
@Override
public boolean isEnableLooseCapMessage() {
return this.enableLooseCapMessage;
}
@Override
public boolean isEnableEverySecondsCapMessage() {
return this.enableEverySecondsCapMessage;
}
@Override
public int getStopAfterSeconds() {
return this.stopAfterSeconds;
}
@Override @Override
public Location getCenter() { public Location getCenter() {
Cuboid cuboid = getCuboid(); Cuboid cuboid = getCuboid();
@ -122,4 +194,417 @@ public class ZKoth implements Koth {
public ScoreboardConfiguration getStartScoreboard() { public ScoreboardConfiguration getStartScoreboard() {
return this.startScoreboard; return this.startScoreboard;
} }
@Override
public KothStatus getStatus() {
return this.kothStatus;
}
@Override
public void spawn(CommandSender sender, boolean now) {
if (this.minLocation == null || this.maxLocation == null) {
message(sender, Message.SPAWN_ERROR);
} else if (this.kothStatus == KothStatus.COOLDOWN) {
message(sender, Message.SPAWN_COOLDOWN);
} else if (this.kothStatus == KothStatus.START) {
message(sender, Message.SPAWN_ALREADY);
} else {
if (now) spawnNow();
else spawn();
}
}
@Override
public void spawn(boolean now) {
if (this.minLocation == null || this.maxLocation == null || this.kothStatus != KothStatus.STOP) return;
if (now) spawnNow();
else spawn();
}
@Override
public void stop(CommandSender sender) {
if (this.kothStatus != KothStatus.START) {
message(sender, Message.EVENT_DISABLE);
return;
}
KothStopEvent event = new KothStopEvent(this);
event.call();
if (event.isCancelled()) return;
broadcast(Message.EVENT_STOP);
if (this.timerTask != null) {
this.timerTask.cancel();
}
this.kothStatus = KothStatus.STOP;
this.currentPlayer = null;
this.timerTask = null;
this.remainingSeconds = null;
this.playersValues.clear();
// this.resetBlocks();
if (this.timerTaskStop != null) this.timerTaskStop.cancel();
// this.plugin.getHologram().end(this);
}
private void spawn() {
this.resetData();
this.kothStatus = KothStatus.COOLDOWN;
this.remainingSeconds = new AtomicInteger(this.cooldownStart);
KothStartEvent event = new KothStartEvent(this);
event.call();
if (event.isCancelled()) return;
this.timerTask = scheduleFix(this.plugin, 0, Config.enableDebug ? 10 : 1000, (task, isCancelled) -> {
if (!isCancelled) {
task.cancel();
return;
}
if (this.kothStatus != KothStatus.COOLDOWN) {
task.cancel();
return;
}
int currentRemainingSeconds = this.remainingSeconds.get();
if (Config.displayMessageCooldown.contains(currentRemainingSeconds)) {
broadcast(Message.EVENT_COOLDOWN);
}
if (currentRemainingSeconds <= 0) {
this.timerTask.cancel();
this.spawnNow();
return;
}
this.remainingSeconds.decrementAndGet();
});
}
private void spawnNow() {
this.resetData();
this.kothStatus = KothStatus.START;
KothSpawnEvent event = new KothSpawnEvent(this);
event.call();
if (event.isCancelled()) return;
this.remainingSeconds = new AtomicInteger(this.captureSeconds);
this.broadcast(Message.EVENT_START);
// this.changeBlocks(Config.noOneCapturingMaterial, true);
/*if (this.kothType == KothType.POINT_COUNT) {
this.startschedule();
}*/
Koth koth = this;
Timer timer = new Timer();
this.timerTaskStop = new TimerTask() {
@Override
public void run() {
// plugin.getHologram().end(koth);
Bukkit.getScheduler().runTask(plugin, () -> {
stop(Bukkit.getConsoleSender());
});
}
};
timer.schedule(this.timerTaskStop, this.stopAfterSeconds * 1000L);
// this.plugin.getHologram().start(this);
/*if (Config.discordWebhookConfig != null) {
Config.discordWebhookConfig.send(this.plugin, this);
}*/
this.startCommands.forEach(command -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), replaceKothInformations(command)));
}
private void resetData() {
this.playersValues.clear();
this.currentPlayer = null;
}
@Override
public void playerMove(Player player, KothTeam kothTeam) {
if (this.kothStatus != KothStatus.START) return;
this.kothTeam = kothTeam;
Cuboid cuboid = this.getCuboid();
if (this.currentPlayer == null && cuboid.contains(player.getLocation())) {
this.currentPlayer = player;
this.startCap(player);
// this.plugin.getHologram().update(this);
} else if (this.currentPlayer != null && !cuboid.contains(this.currentPlayer.getLocation())) {
KothLooseEvent event = new KothLooseEvent(this.currentPlayer, this);
event.call();
if (event.isCancelled()) return;
// this.plugin.getHologram().update(this);
broadcast(Message.EVENT_LOOSE);
if (this.timerTask != null) {
this.timerTask.cancel();
}
// this.changeBlocks(Config.noOneCapturingMaterial, true);
this.remainingSeconds = new AtomicInteger(this.captureSeconds);
this.timerTask = null;
this.currentPlayer = null;
}
}
@Override
public int getCooldownStart() {
return this.cooldownStart;
}
private void startCap(Player player) {
if (this.currentPlayer == null)
return;
KothCatchEvent event = new KothCatchEvent(this, player, this.captureSeconds);
event.call();
if (event.isCancelled()) {
this.currentPlayer = null;
return;
}
if (enableStartCapMessage) {
broadcast(Message.EVENT_CATCH);
}
int captureSeconds = event.getCaptureSeconds();
captureSeconds = captureSeconds < 0 ? 30 : captureSeconds;
this.remainingSeconds = new AtomicInteger(captureSeconds);
Cuboid cuboid = getCuboid();
// this.changeBlocks(Config.onePersonneCapturingMaterial, false);
// this.plugin.getHologram().update(this);
scheduleFix(this.plugin, 0, 1000, (task, isCancelled) -> {
this.timerTask = task;
if (!isCancelled) {
task.cancel();
return;
}
if (this.kothStatus != KothStatus.START) {
task.cancel();
return;
}
int currentRemainingSeconds = this.remainingSeconds.get();
if (this.currentPlayer != null) {
if (!this.currentPlayer.isValid() || !this.currentPlayer.isOnline()
|| !cuboid.contains(this.currentPlayer.getLocation())) {
this.currentPlayer = null;
// this.plugin.getHologram().update(this);
}
}
if (this.currentPlayer == null) {
KothLooseEvent kothLooseEvent = new KothLooseEvent(null, this);
kothLooseEvent.call();
if (kothLooseEvent.isCancelled()) {
return;
}
if (this.timerTask != null) {
this.timerTask.cancel();
}
// this.changeBlocks(Config.noOneCapturingMaterial, true);
this.timerTask = null;
this.currentPlayer = null;
this.remainingSeconds = new AtomicInteger(this.captureSeconds);
if (enableLooseCapMessage) {
broadcast(Message.EVENT_LOOSE);
}
// this.plugin.getHologram().update(this);
return;
}
if (Config.displayMessageKothCap.contains(currentRemainingSeconds)) {
broadcast(Message.EVENT_TIMER);
} else if (enableEverySecondsCapMessage) {
broadcast(Message.EVENT_EVERYSECONDS);
}
if (this.hasWin()) {
this.endKoth(task, cuboid, player);
} else {
KothCapEvent capEvent = new KothCapEvent(this, player, this.remainingSeconds.get(), this.kothTeam.getFactionTag(player));
capEvent.callEvent();
switch (this.kothType) {
case CAPTURE:
default:
this.remainingSeconds.decrementAndGet();
break;
case SCORE:
// case TIMER:
this.playersValues.put(this.currentPlayer.getUniqueId(), this.getValue(this.currentPlayer) + 1);
break;
}
// this.plugin.getHologram().update(this);
}
});
}
public void endKoth(TimerTask task, Cuboid cuboid, Player player) {
KothWinEvent kothWinEvent = new KothWinEvent(this, this.currentPlayer);
kothWinEvent.call();
if (kothWinEvent.isCancelled()) return;
// this.plugin.getHologram().end(this);
task.cancel();
broadcast(Message.EVENT_WIN);
/* Gestion des loots */
this.endCommands.forEach(command -> {
if (command.contains("%online-player%")) {
for (Player cPlayer : this.kothTeam.getOnlinePlayer(player)) {
String finaleCommand = replaceMessage(command);
finaleCommand = finaleCommand.replace("%online-player%", cPlayer.getName());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), papi(finaleCommand, cPlayer));
}
} else {
command = replaceMessage(command);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), papi(command, player));
}
});
Location center = cuboid.getCenter();
World world = center.getWorld();
while (center.getBlock().getRelative(BlockFace.DOWN).getType().equals(Material.AIR)) {
center = center.getBlock().getRelative(BlockFace.DOWN).getLocation();
}
/*if (this.itemStacks.size() != 0) {
switch (this.type) {
case CHEST:
location.getBlock().setType(Material.CHEST);
Chest chest = (Chest) location.getBlock().getState();
this.getItemStacks().forEach(itemStack -> chest.getInventory().addItem(itemStack));
Bukkit.getScheduler().runTaskLater(ZPlugin.z(), () -> {
location.getBlock().setType(Material.AIR);
}, 20 * Config.removeChestSec);
break;
case DROP:
location.add(0.5, 0.3, 0.5);
this.getItemStacks().forEach(itemStack -> {
Item item = world.dropItem(location, itemStack);
Vector vector = item.getVelocity();
vector.setZ(0);
vector.setY(0.5);
vector.setX(0);
item.setVelocity(vector);
});
break;
case INVENTORY:
this.getItemStacks().forEach(itemStack -> give(this.currentPlayer, itemStack));
break;
case NONE:
break;
default:
break;
}
}*/
this.kothStatus = KothStatus.STOP;
this.currentPlayer = null;
this.timerTask = null;
this.remainingSeconds = null;
this.playersValues.clear();
// this.resetBlocks();
if (this.timerTaskStop != null)
this.timerTaskStop.cancel();
}
public int getValue(Player player) {
return player == null ? 0 : this.playersValues.getOrDefault(player.getUniqueId(), 0);
}
public boolean hasWin() {
switch (this.kothType) {
case CAPTURE:
return this.remainingSeconds != null && this.remainingSeconds.get() <= 0;
case SCORE:
return this.currentPlayer != null && this.getValue(this.currentPlayer) >= this.captureSeconds;
/*case TIMER:
return this.currentPlayer == null ? false : this.getValue(this.currentPlayer) >= this.maxSecondsCap;*/
default:
return false;
}
}
private String replaceMessage(String string) {
string = string.replace("%playerName%", this.currentPlayer != null ? this.currentPlayer.getName() : Config.noPlayer);
return replaceKothInformations(string);
}
private String replaceKothInformations(String string) {
Location centerLocation = getCenter();
string = string.replace("%name%", this.name);
string = string.replace("%world%", centerLocation.getWorld().getName());
string = string.replace("%minX%", String.valueOf(minLocation.getBlockX()));
string = string.replace("%minY%", String.valueOf(minLocation.getBlockY()));
string = string.replace("%minZ%", String.valueOf(minLocation.getBlockZ()));
string = string.replace("%maxX%", String.valueOf(maxLocation.getBlockX()));
string = string.replace("%maxY%", String.valueOf(maxLocation.getBlockY()));
string = string.replace("%maxZ%", String.valueOf(maxLocation.getBlockZ()));
string = string.replace("%centerX%", String.valueOf(centerLocation.getBlockX()));
string = string.replace("%centerY%", String.valueOf(centerLocation.getBlockY()));
string = string.replace("%centerZ%", String.valueOf(centerLocation.getBlockZ()));
return string;
}
} }

View File

@ -1,8 +1,11 @@
package fr.maxlego08.koth.api; package fr.maxlego08.koth.api;
import fr.maxlego08.koth.KothPlugin;
import fr.maxlego08.koth.api.utils.ScoreboardConfiguration; import fr.maxlego08.koth.api.utils.ScoreboardConfiguration;
import fr.maxlego08.koth.zcore.utils.Cuboid; import fr.maxlego08.koth.zcore.utils.Cuboid;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.List; import java.util.List;
@ -37,4 +40,23 @@ public interface Koth {
ScoreboardConfiguration getCooldownScoreboard(); ScoreboardConfiguration getCooldownScoreboard();
ScoreboardConfiguration getStartScoreboard(); ScoreboardConfiguration getStartScoreboard();
KothStatus getStatus();
void spawn(CommandSender sender, boolean now);
void spawn(boolean now);
void stop(CommandSender sender);
void playerMove(Player player, KothTeam kothTeam);
int getCooldownStart();
int getStopAfterSeconds();
boolean isEnableStartCapMessage();
boolean isEnableLooseCapMessage();
boolean isEnableEverySecondsCapMessage();
} }

View File

@ -0,0 +1,9 @@
package fr.maxlego08.koth.api;
public enum KothStatus {
COOLDOWN,
START,
STOP,
}

View File

@ -0,0 +1,50 @@
package fr.maxlego08.koth.api.events;
import fr.maxlego08.koth.api.Koth;
import org.bukkit.entity.Player;
public class KothCapEvent extends KothEvent {
private final Koth koth;
private final Player player;
private final int timer;
private final String teamName;
public KothCapEvent(Koth koth, Player player, int timer, String teamName) {
super();
this.koth = koth;
this.player = player;
this.timer = timer;
this.teamName = teamName;
}
/**
* @return the koth
*/
public Koth getKoth() {
return koth;
}
/**
* @return the player
*/
public Player getPlayer() {
return player;
}
/**
* @return the timer
*/
public int getTimer() {
return timer;
}
/**
* @return the factionName
*/
public String getTeamName() {
return teamName;
}
}

View File

@ -0,0 +1,47 @@
package fr.maxlego08.koth.api.events;
import fr.maxlego08.koth.api.Koth;
import org.bukkit.entity.Player;
public class KothCatchEvent extends CancelledKothEvent {
private final Koth koth;
private final Player player;
private int captureSeconds;
public KothCatchEvent(Koth koth, Player player, int captureSeconds) {
super();
this.koth = koth;
this.player = player;
this.captureSeconds = captureSeconds;
}
/**
* @return the koth
*/
public Koth getKoth() {
return koth;
}
/**
* @return the player
*/
public Player getPlayer() {
return player;
}
/**
* @return the captureSeconds
*/
public int getCaptureSeconds() {
return captureSeconds;
}
/**
* @param captureSeconds the captureSeconds to set
*/
public void setCaptureSeconds(int captureSeconds) {
this.captureSeconds = captureSeconds;
}
}

View File

@ -0,0 +1,36 @@
package fr.maxlego08.koth.api.events;
import fr.maxlego08.koth.api.Koth;
import org.bukkit.entity.Player;
public class KothLooseEvent extends CancelledKothEvent {
private final Player player;
private final Koth koth;
/**
* @param player
* @param koth
*/
public KothLooseEvent(Player player, Koth koth) {
super();
this.player = player;
this.koth = koth;
}
/**
* @return the player
*/
public Player getPlayer() {
return player;
}
/**
* @return the koth
*/
public Koth getKoth() {
return koth;
}
}

View File

@ -0,0 +1,21 @@
package fr.maxlego08.koth.api.events;
import fr.maxlego08.koth.api.Koth;
public class KothSpawnEvent extends CancelledKothEvent {
private final Koth koth;
public KothSpawnEvent(Koth koth) {
super();
this.koth = koth;
}
/**
* @return the koth
*/
public Koth getKoth() {
return koth;
}
}

View File

@ -0,0 +1,22 @@
package fr.maxlego08.koth.api.events;
import fr.maxlego08.koth.api.Koth;
public class KothStartEvent extends CancelledKothEvent {
private final Koth koth;
public KothStartEvent(Koth koth) {
super();
this.koth = koth;
}
/**
* @return the koth
*/
public Koth getKoth() {
return koth;
}
}

View File

@ -0,0 +1,21 @@
package fr.maxlego08.koth.api.events;
import fr.maxlego08.koth.api.Koth;
public class KothStopEvent extends CancelledKothEvent {
private final Koth koth;
public KothStopEvent(Koth koth) {
super();
this.koth = koth;
}
/**
* @return the koth
*/
public Koth getKoth() {
return koth;
}
}

View File

@ -0,0 +1,32 @@
package fr.maxlego08.koth.api.events;
import fr.maxlego08.koth.api.Koth;
import org.bukkit.entity.Player;
public class KothWinEvent extends CancelledKothEvent {
private final Koth koth;
private final Player player;
public KothWinEvent(Koth koth, Player player) {
super();
this.koth = koth;
this.player = player;
}
/**
* @return the koth
*/
public Koth getKoth() {
return koth;
}
/**
* @return the player
*/
public Player getPlayer() {
return player;
}
}

View File

@ -2,6 +2,7 @@ package fr.maxlego08.koth.command.commands;
import fr.maxlego08.koth.KothPlugin; import fr.maxlego08.koth.KothPlugin;
import fr.maxlego08.koth.command.VCommand; import fr.maxlego08.koth.command.VCommand;
import fr.maxlego08.koth.save.Config;
import fr.maxlego08.koth.zcore.enums.Message; import fr.maxlego08.koth.zcore.enums.Message;
import fr.maxlego08.koth.zcore.enums.Permission; import fr.maxlego08.koth.zcore.enums.Permission;
import fr.maxlego08.koth.zcore.utils.commands.CommandType; import fr.maxlego08.koth.zcore.utils.commands.CommandType;
@ -20,6 +21,7 @@ public class CommandKothReload extends VCommand {
protected CommandType perform(KothPlugin plugin) { protected CommandType perform(KothPlugin plugin) {
plugin.reloadConfig(); plugin.reloadConfig();
Config.getInstance().load(plugin);
plugin.reloadFiles(); plugin.reloadFiles();
message(sender, Message.RELOAD); message(sender, Message.RELOAD);

View File

@ -1,5 +1,6 @@
package fr.maxlego08.koth.listener; package fr.maxlego08.koth.listener;
import fr.maxlego08.koth.KothPlugin;
import fr.maxlego08.koth.zcore.utils.ZUtils; import fr.maxlego08.koth.zcore.utils.ZUtils;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,141 +22,135 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import fr.maxlego08.koth.KothPlugin;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class AdapterListener extends ZUtils implements Listener { public class AdapterListener extends ZUtils implements Listener {
private final KothPlugin plugin; private final KothPlugin plugin;
public AdapterListener(KothPlugin plugin) { public AdapterListener(KothPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler @EventHandler
public void onConnect(PlayerJoinEvent event) { public void onConnect(PlayerJoinEvent event) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onConnect(event, event.getPlayer())); this.plugin.getListenerAdapters().forEach(adapter -> adapter.onConnect(event, event.getPlayer()));
} }
@EventHandler @EventHandler
public void onQuit(PlayerQuitEvent event) { public void onQuit(PlayerQuitEvent event) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onQuit(event, event.getPlayer())); this.plugin.getListenerAdapters().forEach(adapter -> adapter.onQuit(event, event.getPlayer()));
} }
/*
* @EventHandler public void onMove(PlayerMoveEvent event) {
* this.plugin.getListenerAdapters().forEach(adapter ->
* adapter.onMove(event, event.getPlayer())); if
* (event.getFrom().getBlockX() >> 1 == event.getTo().getBlockX() >> 1 &&
* event.getFrom().getBlockZ() >> 1 == event.getTo().getBlockZ() >> 1 &&
* event.getFrom().getWorld() == event.getTo().getWorld()) return;
* this.plugin.getListenerAdapters().forEach(adapter ->
* adapter.onPlayerWalk(event, event.getPlayer(), 1)); }
*/
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent event) { public void onMove(PlayerMoveEvent event) {
this.plugin.getListenerAdapters() this.plugin.getListenerAdapters().forEach(adapter -> adapter.onMove(event, event.getPlayer()));
.forEach(adapter -> adapter.onInventoryClick(event, (Player) event.getWhoClicked())); }
}
@EventHandler @EventHandler
public void onBlockBreak(BlockBreakEvent event) { public void onInventoryClick(InventoryClickEvent event) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onBlockBreak(event, event.getPlayer())); this.plugin.getListenerAdapters()
} .forEach(adapter -> adapter.onInventoryClick(event, (Player) event.getWhoClicked()));
}
@EventHandler @EventHandler
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockBreak(BlockBreakEvent event) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onBlockPlace(event, event.getPlayer())); this.plugin.getListenerAdapters().forEach(adapter -> adapter.onBlockBreak(event, event.getPlayer()));
} }
@EventHandler @EventHandler
public void onEntityDeath(EntityDeathEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onEntityDeath(event, event.getEntity())); this.plugin.getListenerAdapters().forEach(adapter -> adapter.onBlockPlace(event, event.getPlayer()));
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler
public void onInteract(PlayerInteractEvent event) { public void onEntityDeath(EntityDeathEvent event) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onInteract(event, event.getPlayer())); this.plugin.getListenerAdapters().forEach(adapter -> adapter.onEntityDeath(event, event.getEntity()));
} }
@EventHandler @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerTalk(AsyncPlayerChatEvent event) { public void onInteract(PlayerInteractEvent event) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onPlayerTalk(event, event.getMessage())); this.plugin.getListenerAdapters().forEach(adapter -> adapter.onInteract(event, event.getPlayer()));
} }
@EventHandler @EventHandler
public void onCraftItem(CraftItemEvent event) { public void onPlayerTalk(AsyncPlayerChatEvent event) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onCraftItem(event)); this.plugin.getListenerAdapters().forEach(adapter -> adapter.onPlayerTalk(event, event.getMessage()));
} }
@EventHandler @EventHandler
public void onDrag(InventoryDragEvent event) { public void onCraftItem(CraftItemEvent event) {
this.plugin.getListenerAdapters() this.plugin.getListenerAdapters().forEach(adapter -> adapter.onCraftItem(event));
.forEach(adapter -> adapter.onInventoryDrag(event, (Player) event.getWhoClicked())); }
}
@EventHandler @EventHandler
public void onClose(InventoryCloseEvent event) { public void onDrag(InventoryDragEvent event) {
this.plugin.getListenerAdapters() this.plugin.getListenerAdapters()
.forEach(adapter -> adapter.onInventoryClose(event, (Player) event.getPlayer())); .forEach(adapter -> adapter.onInventoryDrag(event, (Player) event.getWhoClicked()));
} }
@EventHandler @EventHandler
public void onCommand(PlayerCommandPreprocessEvent event) { public void onClose(InventoryCloseEvent event) {
this.plugin.getListenerAdapters() this.plugin.getListenerAdapters()
.forEach(adapter -> adapter.onCommand(event, event.getPlayer(), event.getMessage())); .forEach(adapter -> adapter.onInventoryClose(event, (Player) event.getPlayer()));
} }
@EventHandler @EventHandler
public void onGamemodeChange(PlayerGameModeChangeEvent event) { public void onCommand(PlayerCommandPreprocessEvent event) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onGamemodeChange(event, event.getPlayer())); this.plugin.getListenerAdapters()
} .forEach(adapter -> adapter.onCommand(event, event.getPlayer(), event.getMessage()));
}
/* @EventHandler
* @EventHandler public void onDrop(PlayerDropItemEvent event) { public void onGamemodeChange(PlayerGameModeChangeEvent event) {
* this.plugin.getListenerAdapters().forEach(adapter -> this.plugin.getListenerAdapters().forEach(adapter -> adapter.onGamemodeChange(event, event.getPlayer()));
* adapter.onDrop(event, event.getPlayer())); if (!Config.useItemFallEvent) }
* return; Item item = event.getItemDrop(); AtomicBoolean hasSendEvent = new
* AtomicBoolean(false); scheduleFix(100, (task, isActive) -> { if
* (!isActive) return; this.plugin.getListenerAdapters().forEach(adapter ->
* adapter.onItemMove(event, event.getPlayer(), item, item.getLocation(),
* item.getLocation().getBlock())); if (item.isOnGround() &&
* !hasSendEvent.get()) { task.cancel(); hasSendEvent.set(true);
* this.plugin.getListenerAdapters().forEach( adapter ->
* adapter.onItemisOnGround(event, event.getPlayer(), item,
* item.getLocation())); } }); }
*/
@EventHandler /*
public void onPick(PlayerPickupItemEvent event) { * @EventHandler public void onDrop(PlayerDropItemEvent event) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onPickUp(event, event.getPlayer())); * this.plugin.getListenerAdapters().forEach(adapter ->
} * adapter.onDrop(event, event.getPlayer())); if (!Config.useItemFallEvent)
* return; Item item = event.getItemDrop(); AtomicBoolean hasSendEvent = new
* AtomicBoolean(false); scheduleFix(100, (task, isActive) -> { if
* (!isActive) return; this.plugin.getListenerAdapters().forEach(adapter ->
* adapter.onItemMove(event, event.getPlayer(), item, item.getLocation(),
* item.getLocation().getBlock())); if (item.isOnGround() &&
* !hasSendEvent.get()) { task.cancel(); hasSendEvent.set(true);
* this.plugin.getListenerAdapters().forEach( adapter ->
* adapter.onItemisOnGround(event, event.getPlayer(), item,
* item.getLocation())); } }); }
*/
@EventHandler @EventHandler
public void onMobSpawn(CreatureSpawnEvent event) { public void onPick(PlayerPickupItemEvent event) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onMobSpawn(event)); this.plugin.getListenerAdapters().forEach(adapter -> adapter.onPickUp(event, event.getPlayer()));
} }
@EventHandler @EventHandler
public void onDamage(EntityDamageByEntityEvent event) { public void onMobSpawn(CreatureSpawnEvent event) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onMobSpawn(event));
}
if (event.getEntity() instanceof LivingEntity && event.getDamager() instanceof LivingEntity) { @EventHandler
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onDamageByEntity(event, event.getCause(), public void onDamage(EntityDamageByEntityEvent event) {
event.getDamage(), (LivingEntity) event.getDamager(), (LivingEntity) event.getEntity()));
}
if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) { if (event.getEntity() instanceof LivingEntity && event.getDamager() instanceof LivingEntity) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onPlayerDamagaByPlayer(event, event.getCause(), this.plugin.getListenerAdapters().forEach(adapter -> adapter.onDamageByEntity(event, event.getCause(),
event.getDamage(), (Player) event.getDamager(), (Player) event.getEntity())); event.getDamage(), (LivingEntity) event.getDamager(), (LivingEntity) event.getEntity()));
} }
if (event.getEntity() instanceof Player && event.getDamager() instanceof Projectile) { if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onPlayerDamagaByArrow(event, event.getCause(), this.plugin.getListenerAdapters().forEach(adapter -> adapter.onPlayerDamagaByPlayer(event, event.getCause(),
event.getDamage(), (Projectile) event.getDamager(), (Player) event.getEntity())); event.getDamage(), (Player) event.getDamager(), (Player) event.getEntity()));
} }
}
if (event.getEntity() instanceof Player && event.getDamager() instanceof Projectile) {
this.plugin.getListenerAdapters().forEach(adapter -> adapter.onPlayerDamagaByArrow(event, event.getCause(),
event.getDamage(), (Projectile) event.getDamager(), (Player) event.getEntity()));
}
}
} }

View File

@ -1,5 +1,6 @@
package fr.maxlego08.koth.loader; package fr.maxlego08.koth.loader;
import fr.maxlego08.koth.KothPlugin;
import fr.maxlego08.koth.ZKoth; import fr.maxlego08.koth.ZKoth;
import fr.maxlego08.koth.api.Koth; import fr.maxlego08.koth.api.Koth;
import fr.maxlego08.koth.api.KothType; import fr.maxlego08.koth.api.KothType;
@ -14,9 +15,14 @@ import java.util.List;
public class KothLoader extends ZUtils implements Loader<Koth> { public class KothLoader extends ZUtils implements Loader<Koth> {
private final KothPlugin plugin;
private final Loader<Location> locationLoader = new LocationLoader(); private final Loader<Location> locationLoader = new LocationLoader();
private final Loader<ScoreboardConfiguration> scoreboardLoaderLoader = new ScoreboardLoader(); private final Loader<ScoreboardConfiguration> scoreboardLoaderLoader = new ScoreboardLoader();
public KothLoader(KothPlugin plugin) {
this.plugin = plugin;
}
@Override @Override
public Koth load(YamlConfiguration configuration, String path, File file) { public Koth load(YamlConfiguration configuration, String path, File file) {
@ -24,6 +30,11 @@ public class KothLoader extends ZUtils implements Loader<Koth> {
KothType kothType = KothType.valueOf(configuration.getString("type", KothType.CAPTURE.name()).toUpperCase()); KothType kothType = KothType.valueOf(configuration.getString("type", KothType.CAPTURE.name()).toUpperCase());
String name = configuration.getString("name"); String name = configuration.getString("name");
int captureSeconds = configuration.getInt("capture"); int captureSeconds = configuration.getInt("capture");
int cooldownStart = configuration.getInt("cooldownStart");
int stopAfterSeconds = configuration.getInt("stopAfterSeconds");
boolean enableStartCapMessage = configuration.getBoolean("enableStartCapMessage", true);
boolean enableLooseCapMessage = configuration.getBoolean("enableLooseCapMessage", true);
boolean enableEverySecondsCapMessage = configuration.getBoolean("enableEverySecondsCapMessage", false);
List<String> startCommands = configuration.getStringList("startCommands"); List<String> startCommands = configuration.getStringList("startCommands");
List<String> endCommands = configuration.getStringList("endCommands"); List<String> endCommands = configuration.getStringList("endCommands");
Location minLocation = locationLoader.load(configuration, "minLocation.", file); Location minLocation = locationLoader.load(configuration, "minLocation.", file);
@ -31,7 +42,8 @@ public class KothLoader extends ZUtils implements Loader<Koth> {
ScoreboardConfiguration cooldownScoreboard = scoreboardLoaderLoader.load(configuration, "scoreboard.cooldown.", file); ScoreboardConfiguration cooldownScoreboard = scoreboardLoaderLoader.load(configuration, "scoreboard.cooldown.", file);
ScoreboardConfiguration startScoreboard = scoreboardLoaderLoader.load(configuration, "scoreboard.start.", file); ScoreboardConfiguration startScoreboard = scoreboardLoaderLoader.load(configuration, "scoreboard.start.", file);
return new ZKoth(fileName, kothType, name, captureSeconds, minLocation, manLocation, startCommands, endCommands, cooldownScoreboard, startScoreboard); return new ZKoth(this.plugin, fileName, kothType, name, captureSeconds, minLocation, manLocation, startCommands, endCommands, cooldownScoreboard,
startScoreboard, cooldownStart, stopAfterSeconds, enableStartCapMessage, enableLooseCapMessage, enableEverySecondsCapMessage);
} }
@Override @Override
@ -40,8 +52,13 @@ public class KothLoader extends ZUtils implements Loader<Koth> {
configuration.set("type", koth.getKothType().name()); configuration.set("type", koth.getKothType().name());
configuration.set("name", koth.getName()); configuration.set("name", koth.getName());
configuration.set("capture", koth.getCaptureSeconds()); configuration.set("capture", koth.getCaptureSeconds());
configuration.set("cooldownStart", koth.getCooldownStart());
configuration.set("stopAfterSeconds", koth.getStopAfterSeconds());
configuration.set("startCommands", koth.getStartCommands()); configuration.set("startCommands", koth.getStartCommands());
configuration.set("endCommands", koth.getEndCommands()); configuration.set("endCommands", koth.getEndCommands());
configuration.set("enableStartCapMessage", koth.isEnableStartCapMessage());
configuration.set("enableLooseCapMessage", koth.isEnableLooseCapMessage());
configuration.set("enableEverySecondsCapMessage", koth.isEnableEverySecondsCapMessage());
locationLoader.save(koth.getMinLocation(), configuration, "minLocation."); locationLoader.save(koth.getMinLocation(), configuration, "minLocation.");
locationLoader.save(koth.getMaxLocation(), configuration, "manLocation."); locationLoader.save(koth.getMaxLocation(), configuration, "manLocation.");
scoreboardLoaderLoader.save(koth.getCooldownScoreboard(), configuration, "scoreboard.cooldown."); scoreboardLoaderLoader.save(koth.getCooldownScoreboard(), configuration, "scoreboard.cooldown.");

View File

@ -1,14 +1,23 @@
package fr.maxlego08.koth.save; package fr.maxlego08.koth.save;
import fr.maxlego08.koth.KothPlugin;
import fr.maxlego08.koth.zcore.utils.storage.Persist; import fr.maxlego08.koth.zcore.utils.storage.Persist;
import fr.maxlego08.koth.zcore.utils.storage.Savable; import fr.maxlego08.koth.zcore.utils.storage.Savable;
import org.bukkit.configuration.file.YamlConfiguration;
public class Config implements Savable { import java.util.Arrays;
import java.util.List;
public class Config {
public static boolean enableDebug = true; public static boolean enableDebug = true;
public static boolean enableDebugTime = false; public static boolean enableDebugTime = false;
public static long playerMoveEventCooldown = 50;
/** public static List<Integer> displayMessageCooldown = Arrays.asList(300, 120, 60, 30, 10, 5, 4, 3, 2, 1);
public static List<Integer> displayMessageKothCap = Arrays.asList(300, 120, 60, 30, 10, 5, 4, 3, 2, 1);
public static String noPlayer = "X";
/**
* static Singleton instance. * static Singleton instance.
*/ */
private static volatile Config instance; private static volatile Config instance;
@ -35,12 +44,17 @@ public class Config implements Savable {
return instance; return instance;
} }
public void save(Persist persist) { public void load(KothPlugin plugin) {
persist.save(getInstance());
}
public void load(Persist persist) { YamlConfiguration configuration = (YamlConfiguration) plugin.getConfig();
persist.loadOrSaveDefault(getInstance(), Config.class);
enableDebug = configuration.getBoolean("enableDebug", false);
enableDebugTime = configuration.getBoolean("enableDebugTime", false);
playerMoveEventCooldown = configuration.getInt("playerMoveEventCooldown", 50);
displayMessageCooldown = configuration.getIntegerList("displayMessageCooldown");
displayMessageKothCap = configuration.getIntegerList("displayMessageKothCap");
noPlayer = configuration.getString("noPlayer", "X");
} }
} }

View File

@ -70,6 +70,53 @@ public enum Message {
KOTH_SIZE("§cYour koth is too small, you can't create one that small. Then you will come on discord for support when the problem comes from you."), KOTH_SIZE("§cYour koth is too small, you can't create one that small. Then you will come on discord for support when the problem comes from you."),
DOESNT_EXIST("§cThe koth §f%name% §cdoesnt exists."), DOESNT_EXIST("§cThe koth §f%name% §cdoesnt exists."),
EVENT_START(MessageType.CENTER,
"§8§m-+------------------------------+-",
"",
"§fThe koth §b%name% §has just appeared!",
"§fCoordinate§8: §7%x%, %y%, %z%.",
"",
"§8§m-+------------------------------+-"
),
EVENT_WIN(MessageType.CENTER,
"§8§m-+------------------------------+-",
"",
"§d%player% §fof faction §7%faction% §fhas just captured",
"§fthe koth, and §nwins§f the event!",
"",
"§8§m-+------------------------------+-"
),
EVENT_COOLDOWN(MessageType.CENTER,
"§8§m-+------------------------------+-",
"",
"§fThe koth §n%name%§f will appear in §d%capture%",
"§fCoordinate§8: §7%x%, %y%, %z%.",
"",
"§8§m-+------------------------------+-"
),
EVENT_STOP(MessageType.CENTER,
"§8§m-+------------------------------+-",
"",
"§fkoth §n%name%§f has just been stopped.",
"",
"§8§m-+------------------------------+-"),
SPAWN_ERROR("§cImpossible to spawn the koth, positions is wrong. You have to do §b/zkoth move §8<§aname§8>§c."),
SPAWN_COOLDOWN("§cThe countdown to the appearance of the koth is already underway"),
SPAWN_ALREADY("§cThe koth is running."),
EVENT_FACION("No faction"),
EVENT_PLAYER("Person"),
EVENT_DISABLE("§cThe event is not enable."),
EVENT_CATCH(MessageType.ACTION, "§d%player% §fjust started capturing the koth §n%name%§f. §8(§7%x%, %y%, %z%§8)"),
EVENT_LOOSE(MessageType.ACTION, "§d%player% §fjust loose koth §n%name%§f. §8(§7%x%, %y%, %z%§8)"),
EVENT_TIMER(MessageType.ACTION, "§fAnother §b%capture% §fbefore §d%player% §fwins the koth §n%name%§e. §8(§7%x%, %y%, %z%§8)"),
EVENT_EVERYSECONDS(MessageType.ACTION, "§d%player% §7- §8[§f%classicProgress%§8] §7- §b%classicPercent%§f%"),
; ;

View File

@ -23,3 +23,41 @@
# - TitleManager # - TitleManager
# #
######################################################################################################### #########################################################################################################
# Displays more information in the console, if you have a problem please enable this option and send errors to support.
enableDebug: false
# Enables time debugs, is used to measure plugin performance
enableDebugTime: false
# Number of milliseconds between each PlayerMoveEvent action
# Allows to cooldown the player not to overload the plugin
playerMoveEventCooldown: 50
# Display a message during koth cooldown
displayMessageCooldown:
- 300
- 120
- 60
- 30
- 10
- 5
- 4
- 3
- 2
- 1
# Display a message during koth cap
displayMessageKothCap:
- 300
- 120
- 60
- 30
- 10
- 5
- 4
- 3
- 2
- 1
noPlayer: 'X'

View File

@ -4,8 +4,40 @@ name: test
type: CAPTURE type: CAPTURE
capture: 30 capture: 30
cooldownStart: 300
stopAfterSeconds: 3600
enableStartCapMessage: true
enableLooseCapMessage: true
# Available placeholders:
# - %name% - Koth name
# - %world% - World name
# - %minX% - Min location X
# - %minY% - Min location Y
# - %minZ% - Min location Z
# - %maxX% - Max location X
# - %maxY% - Max location Y
# - %maxZ% - Max location Z
# - %centerX% - Center location X
# - %centerY% - Center location Y
# - %centerZ% - Center location Z
startCommands: [] startCommands: []
# Available placeholders:
# - %name% - Koth name
# - %world% - World name
# - %minX% - Min location X
# - %minY% - Min location Y
# - %minZ% - Min location Z
# - %maxX% - Max location X
# - %maxY% - Max location Y
# - %maxZ% - Max location Z
# - %centerX% - Center location X
# - %centerY% - Center location Y
# - %centerZ% - Center location Z
# - %playerName% - Current player name
endCommands: [] endCommands: []
minLocation: minLocation: