Added a way to check if an APartType has an event

Activate APartType without event when activated in the gui
This commit is contained in:
Teriuihi 2022-01-13 23:16:57 +01:00
parent 0140e5f293
commit cc60244fd0
2 changed files with 17 additions and 8 deletions

View File

@ -2,6 +2,7 @@ package com.alttd.gui.actions;
import com.alttd.database.Queries; import com.alttd.database.Queries;
import com.alttd.gui.GUIAction; import com.alttd.gui.GUIAction;
import com.alttd.objects.APartType;
import com.alttd.objects.ParticleSet; import com.alttd.objects.ParticleSet;
import com.alttd.storage.PlayerSettings; import com.alttd.storage.PlayerSettings;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -38,6 +39,8 @@ public class ActivateParticleSet implements GUIAction {
playerSettings.addParticle(particleSet.getAPartType(), particleSet); playerSettings.addParticle(particleSet.getAPartType(), particleSet);
else else
playerSettings.removeParticle(particleSet.getAPartType()); playerSettings.removeParticle(particleSet.getAPartType());
if (enable && !particleSet.getAPartType().hasEvent())
particleSet.run(player, playerSettings);
} }
private boolean updateItem(@NotNull ItemStack itemStack, Player player) { private boolean updateItem(@NotNull ItemStack itemStack, Player player) {

View File

@ -4,18 +4,19 @@ import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public enum APartType { //TODO add description? public enum APartType { //TODO add description?
HEAD("HEAD", "Head", Material.PLAYER_HEAD, null), HEAD("HEAD", "Head", Material.PLAYER_HEAD, null, false),
TRAIL("TRAIL", "Trail", Material.GOLD_INGOT, null), TRAIL("TRAIL", "Trail", Material.GOLD_INGOT, null, false),
BREAK_PLACE_BLOCK("BREAK_PLACE_BLOCK", "Break/place block", Material.GRASS_BLOCK, null), BREAK_PLACE_BLOCK("BREAK_PLACE_BLOCK", "Break/place block", Material.GRASS_BLOCK, null, true),
DEATH("DEATH", "Death", Material.SKELETON_SKULL, null), DEATH("DEATH", "Death", Material.SKELETON_SKULL, null, true),
ATTACK_CLOSE("ATTACK_CQC", "Attack CQC", Material.DIAMOND_SWORD, null), ATTACK("KILL", "Kill", Material.DIAMOND_SWORD, null, true),
ATTACK_RANGE("ATTACK_RANGED", "Attack ranged", Material.BOW, null), CLICK_BLOCK("CLICK_BLOCK", "Right click block", Material.DIAMOND_BLOCK, null, true),
TELEPORT_ARRIVE("TELEPORT", "Teleport", Material.DRAGON_EGG, null); TELEPORT_ARRIVE("TELEPORT", "Teleport", Material.DRAGON_EGG, null, true);
private final String name; private final String name;
private final String displayName; private final String displayName;
private final Material material; private final Material material;
private ItemStack itemStack; private ItemStack itemStack;
private final boolean event;
public String getName() { public String getName() {
return name; return name;
@ -37,11 +38,16 @@ public enum APartType { //TODO add description?
this.itemStack = itemStack; this.itemStack = itemStack;
} }
APartType(String name, String displayName, Material material, ItemStack itemStack) { public boolean hasEvent() {
return event;
}
APartType(String name, String displayName, Material material, ItemStack itemStack, boolean event) {
this.name = name; this.name = name;
this.displayName = displayName; this.displayName = displayName;
this.material = material; this.material = material;
this.itemStack = itemStack; this.itemStack = itemStack;
this.event = event;
} }
} }