📝 Add koth save for loot

This commit is contained in:
Maxlego08 2024-02-22 19:58:18 +01:00
parent 09e5f4ee19
commit 301de953c0
5 changed files with 22 additions and 11 deletions

View File

@ -127,6 +127,8 @@ public class KothListener extends ListenerAdapter {
itemStacks.removeIf(itemStack -> itemStack == null || itemStack.getType() == Material.AIR);
koth.setItemStacks(itemStacks);
message(player, Message.LOOT_CHANGE, "%name%", koth.getName());
manager.saveKoth(koth);
}
}
}

View File

@ -526,12 +526,6 @@ public class ZKoth extends ZUtils implements Koth {
}
if (Config.displayMessageKothCap.contains(currentRemainingSeconds)) {
broadcast(Message.EVENT_TIMER);
} else if (enableEverySecondsCapMessage) {
broadcast(Message.EVENT_EVERYSECONDS);
}
if (this.hasWin()) {
this.endKoth(task, cuboid, player);
@ -541,6 +535,14 @@ public class ZKoth extends ZUtils implements Koth {
KothCapEvent capEvent = new KothCapEvent(this, player, this.remainingSeconds.get(), this.kothTeam.getFactionTag(player));
capEvent.callEvent();
if (Config.displayMessageKothCap.contains(currentRemainingSeconds)) {
broadcast(Message.EVENT_TIMER);
} else if (enableEverySecondsCapMessage) {
broadcast(Message.EVENT_EVERYSECONDS);
}
this.plugin.getKothHologram().update(this);
switch (this.kothType) {
case CAPTURE:
default:
@ -551,8 +553,6 @@ public class ZKoth extends ZUtils implements Koth {
this.playersValues.put(this.currentPlayer.getUniqueId(), this.getValue(this.currentPlayer) + 1);
break;
}
this.plugin.getKothHologram().update(this);
}
});
}
@ -773,4 +773,9 @@ public class ZKoth extends ZUtils implements Koth {
Collections.shuffle(itemStacks, new Random());
return itemStacks.stream().limit(this.randomItemStacks).collect(Collectors.toList());
}
@Override
public int getRandomItemStack() {
return this.randomItemStacks;
}
}

View File

@ -1,6 +1,5 @@
package fr.maxlego08.koth.api;
import fr.maxlego08.koth.KothPlugin;
import fr.maxlego08.koth.api.discord.DiscordWebhookConfig;
import fr.maxlego08.koth.api.utils.HologramConfig;
import fr.maxlego08.koth.api.utils.ScoreboardConfiguration;
@ -76,9 +75,12 @@ public interface Koth {
DiscordWebhookConfig getDiscordWebhookConfig();
List<ItemStack> getItemStacks();
void setItemStacks(List<ItemStack> itemStacks);
KothLootType getLootType();
List<ItemStack> getRandomItemStacks();
int getRandomItemStack();
}

View File

@ -66,9 +66,10 @@ public class KothLoader extends ZUtils implements Loader<Koth> {
}
List<ItemStack> itemStacks = configuration.getStringList("loot.items").stream().map(ItemStackUtils::deserializeItemStack).collect(Collectors.toList());
int randomItemStacks = configuration.getInt("loot.random", 0);
return new ZKoth(this.plugin, fileName, kothType, name, captureSeconds, minLocation, maxLocation, startCommands, endCommands, cooldownScoreboard,
startScoreboard, cooldownStart, stopAfterSeconds, enableStartCapMessage, enableLooseCapMessage, enableEverySecondsCapMessage, hologramConfig, itemStacks, kothLootType, discordWebhookConfig);
startScoreboard, cooldownStart, stopAfterSeconds, enableStartCapMessage, enableLooseCapMessage, enableEverySecondsCapMessage, hologramConfig, itemStacks, kothLootType, discordWebhookConfig, randomItemStacks);
}
@Override
@ -91,6 +92,7 @@ public class KothLoader extends ZUtils implements Loader<Koth> {
hologramConfigLoader.save(koth.getHologramConfig(), configuration, "hologram.");
configuration.set("loot.type", koth.getLootType().name());
configuration.set("loot.random", koth.getRandomItemStack());
List<String> items = koth.getItemStacks().stream().map(ItemStackUtils::serializeItemStack).collect(Collectors.toList());
configuration.set("loot.items", items);

View File

@ -135,7 +135,7 @@ webhook:
loot:
# Takes 10 items from the list of items, to put all the items you must put -1
randomItemStacks: 3
random: 3
# Available type :
# DROP
# CHEST