mirror of
https://github.com/Auxilor/EcoArmor.git
synced 2025-12-29 11:59:13 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -13,9 +13,7 @@ import com.willfp.ecoarmor.display.ArmorDisplay;
|
||||
import com.willfp.ecoarmor.effects.Effect;
|
||||
import com.willfp.ecoarmor.effects.Effects;
|
||||
import com.willfp.ecoarmor.effects.util.EffectWatcher;
|
||||
import com.willfp.ecoarmor.sets.ArmorSet;
|
||||
import com.willfp.ecoarmor.sets.ArmorSets;
|
||||
import com.willfp.ecoarmor.sets.meta.ArmorSlot;
|
||||
import com.willfp.ecoarmor.sets.util.EffectiveDurabilityListener;
|
||||
import com.willfp.ecoarmor.sets.util.PreventSkullPlaceListener;
|
||||
import com.willfp.ecoarmor.upgrades.Tiers;
|
||||
@@ -23,7 +21,6 @@ import com.willfp.ecoarmor.upgrades.listeners.AdvancementShardListener;
|
||||
import com.willfp.ecoarmor.upgrades.listeners.CrystalListener;
|
||||
import com.willfp.ecoarmor.util.DiscoverRecipeListener;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -63,6 +60,7 @@ public class EcoArmorPlugin extends EcoPlugin {
|
||||
|
||||
Effects.values().stream().filter(Effect::isEnabled).forEach(effect -> this.getEventManager().registerListener(effect));
|
||||
Conditions.values().forEach(condition -> this.getEventManager().registerListener(condition));
|
||||
this.getScheduler().runTimer((Runnable) Conditions.HAS_PERMISSION, 100, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.willfp.ecoarmor.conditions.conditions.ConditionBelowHealthPercent;
|
||||
import com.willfp.ecoarmor.conditions.conditions.ConditionBelowHungerPercent;
|
||||
import com.willfp.ecoarmor.conditions.conditions.ConditionBelowXPLevel;
|
||||
import com.willfp.ecoarmor.conditions.conditions.ConditionBelowY;
|
||||
import com.willfp.ecoarmor.conditions.conditions.ConditionHasPermission;
|
||||
import com.willfp.ecoarmor.conditions.conditions.ConditionInBiome;
|
||||
import com.willfp.ecoarmor.conditions.conditions.ConditionInWater;
|
||||
import com.willfp.ecoarmor.conditions.conditions.ConditionInWorld;
|
||||
@@ -38,6 +39,7 @@ public class Conditions {
|
||||
public static final Condition<?> ABOVE_HUNGER_PERCENT = new ConditionAboveHungerPercent();
|
||||
public static final Condition<?> BELOW_HUNGER_PERCENT = new ConditionBelowHungerPercent();
|
||||
public static final Condition<?> IN_BIOME = new ConditionInBiome();
|
||||
public static final Condition<?> HAS_PERMISSION = new ConditionHasPermission();
|
||||
|
||||
/**
|
||||
* Get condition matching name.s
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.willfp.ecoarmor.conditions.conditions;
|
||||
|
||||
import com.willfp.ecoarmor.conditions.Condition;
|
||||
import com.willfp.ecoarmor.sets.ArmorSet;
|
||||
import com.willfp.ecoarmor.sets.util.ArmorUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ConditionHasPermission extends Condition<String> implements Runnable {
|
||||
public ConditionHasPermission() {
|
||||
super("has-permission", String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
ArmorSet set = ArmorUtils.getSetOnPlayer(player);
|
||||
|
||||
if (set == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String value = set.getConditionValue(this);
|
||||
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
evaluateEffects(player, value, set);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConditionMet(@NotNull final Player player,
|
||||
@NotNull final String value) {
|
||||
return player.hasPermission(value);
|
||||
}
|
||||
}
|
||||
@@ -35,17 +35,17 @@ public class ArmorDisplay extends DisplayModule {
|
||||
return;
|
||||
}
|
||||
|
||||
ArmorSet set = ArmorUtils.getSetOnItem(itemStack);
|
||||
ArmorSet set = ArmorUtils.getSetOnItem(meta);
|
||||
|
||||
if (set == null) {
|
||||
Tier crystalTier = ArmorUtils.getCrystalTier(itemStack);
|
||||
Tier crystalTier = ArmorUtils.getCrystalTier(meta);
|
||||
|
||||
if (crystalTier != null) {
|
||||
meta.setLore(crystalTier.getCrystal().getItemMeta().getLore());
|
||||
itemStack.setItemMeta(meta);
|
||||
}
|
||||
|
||||
ArmorSet shardSet = ArmorUtils.getShardSet(itemStack);
|
||||
ArmorSet shardSet = ArmorUtils.getShardSet(meta);
|
||||
|
||||
if (shardSet != null) {
|
||||
itemStack.setItemMeta(shardSet.getAdvancementShardItem().getItemMeta());
|
||||
@@ -61,7 +61,7 @@ public class ArmorDisplay extends DisplayModule {
|
||||
|
||||
ItemStack slotStack;
|
||||
|
||||
if (ArmorUtils.isAdvanced(itemStack)) {
|
||||
if (ArmorUtils.isAdvanced(meta)) {
|
||||
slotStack = set.getAdvancedItemStack(slot);
|
||||
} else {
|
||||
slotStack = set.getItemStack(slot);
|
||||
@@ -69,7 +69,7 @@ public class ArmorDisplay extends DisplayModule {
|
||||
ItemMeta slotMeta = slotStack.getItemMeta();
|
||||
assert slotMeta != null;
|
||||
|
||||
Tier tier = ArmorUtils.getTier(itemStack);
|
||||
Tier tier = ArmorUtils.getTier(meta);
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ public class Flight extends Effect<Boolean> {
|
||||
|
||||
@Override
|
||||
protected void onDisable(@NotNull final Player player) {
|
||||
if (player.hasPermission("ecoarmor.noflydisable")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE) {
|
||||
player.setAllowFlight(false);
|
||||
}
|
||||
|
||||
@@ -358,7 +358,22 @@ public class ArmorSet {
|
||||
@NotNull final Config slotConfig,
|
||||
@NotNull final ItemStack out) {
|
||||
if (slotConfig.getBool("craftable")) {
|
||||
ShapedCraftingRecipe.Builder builder = ShapedCraftingRecipe.builder(PLUGIN, this.getName() + "_" + slot.name().toLowerCase()).setOutput(out);
|
||||
ItemStack formattedOut = out.clone();
|
||||
ItemMeta meta = formattedOut.getItemMeta();
|
||||
assert meta != null;
|
||||
assert meta.getLore() != null;
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
for (String s : meta.getLore()) {
|
||||
s = s.replace("%tier%", Tiers.DEFAULT.getDisplayName());
|
||||
lore.add(s);
|
||||
}
|
||||
|
||||
meta.setLore(lore);
|
||||
formattedOut.setItemMeta(meta);
|
||||
|
||||
ShapedCraftingRecipe.Builder builder = ShapedCraftingRecipe.builder(PLUGIN, this.getName() + "_" + slot.name().toLowerCase()).setOutput(formattedOut);
|
||||
|
||||
List<String> recipeStrings = slotConfig.getStrings("recipe");
|
||||
|
||||
|
||||
@@ -56,29 +56,24 @@ public enum ArmorSlot {
|
||||
}
|
||||
|
||||
Material material = itemStack.getType();
|
||||
String name = material.name().toLowerCase();
|
||||
String[] split = material.name().toLowerCase().split("_");
|
||||
String name = split[split.length - 1];
|
||||
|
||||
if (name.endsWith("helmet") || name.endsWith("head")) {
|
||||
return HELMET;
|
||||
switch (name) {
|
||||
case "helmet":
|
||||
case "head":
|
||||
return HELMET;
|
||||
case "chestplate":
|
||||
return CHESTPLATE;
|
||||
case "elytra":
|
||||
return ELYTRA;
|
||||
case "leggings":
|
||||
return LEGGINGS;
|
||||
case "boots":
|
||||
return BOOTS;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
if (name.endsWith("chestplate")) {
|
||||
return CHESTPLATE;
|
||||
}
|
||||
|
||||
if (name.endsWith("elytra")) {
|
||||
return ELYTRA;
|
||||
}
|
||||
|
||||
if (name.endsWith("leggings")) {
|
||||
return LEGGINGS;
|
||||
}
|
||||
|
||||
if (name.endsWith("boots")) {
|
||||
return BOOTS;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -45,6 +46,17 @@ public class ArmorUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
return getSetOnItem(meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get armor set on an item.
|
||||
*
|
||||
* @param meta The itemStack to check.
|
||||
* @return The set, or null if no set is found.
|
||||
*/
|
||||
@Nullable
|
||||
public ArmorSet getSetOnItem(@NotNull final ItemMeta meta) {
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
String setName = container.get(PLUGIN.getNamespacedKeyFactory().create("set"), PersistentDataType.STRING);
|
||||
|
||||
@@ -133,6 +145,17 @@ public class ArmorUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
return getCrystalTier(meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tier on upgrade crystal.
|
||||
*
|
||||
* @param meta The item to check.
|
||||
* @return The found tier, or null.
|
||||
*/
|
||||
@Nullable
|
||||
public static Tier getCrystalTier(@NotNull final ItemMeta meta) {
|
||||
if (meta.getPersistentDataContainer().has(PLUGIN.getNamespacedKeyFactory().create("upgrade_crystal"), PersistentDataType.STRING)) {
|
||||
return Tiers.getByName(meta.getPersistentDataContainer().get(PLUGIN.getNamespacedKeyFactory().create("upgrade_crystal"), PersistentDataType.STRING));
|
||||
}
|
||||
@@ -154,7 +177,25 @@ public class ArmorUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (getSetOnItem(itemStack) == null) {
|
||||
Tier tier = getTier(meta);
|
||||
|
||||
if (getSetOnItem(meta) != null && tier == null) {
|
||||
setTier(itemStack, Tiers.DEFAULT);
|
||||
return Tiers.DEFAULT;
|
||||
} else {
|
||||
return tier;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tier on item.
|
||||
*
|
||||
* @param meta The item to check.
|
||||
* @return The found tier, or null if not found.
|
||||
*/
|
||||
@Nullable
|
||||
public static Tier getTier(@NotNull final ItemMeta meta) {
|
||||
if (getSetOnItem(meta) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -162,8 +203,7 @@ public class ArmorUtils {
|
||||
return Tiers.getByName(meta.getPersistentDataContainer().get(PLUGIN.getNamespacedKeyFactory().create("tier"), PersistentDataType.STRING));
|
||||
}
|
||||
|
||||
setTier(itemStack, Tiers.DEFAULT);
|
||||
return getTier(itemStack);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,6 +330,16 @@ public class ArmorUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isAdvanced(meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if item is advanced.
|
||||
*
|
||||
* @param meta The item to check.
|
||||
* @return If advanced.
|
||||
*/
|
||||
public static boolean isAdvanced(@NotNull final ItemMeta meta) {
|
||||
if (meta.getPersistentDataContainer().has(PLUGIN.getNamespacedKeyFactory().create("advanced"), PersistentDataType.INTEGER)) {
|
||||
return meta.getPersistentDataContainer().get(PLUGIN.getNamespacedKeyFactory().create("advanced"), PersistentDataType.INTEGER) == 1;
|
||||
}
|
||||
@@ -334,6 +384,17 @@ public class ArmorUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
return getShardSet(meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the set from a shard.
|
||||
*
|
||||
* @param meta The item to check.
|
||||
* @return The set, or null if not a shard.
|
||||
*/
|
||||
@Nullable
|
||||
public static ArmorSet getShardSet(@NotNull final ItemMeta meta) {
|
||||
String shardSet = meta.getPersistentDataContainer().get(PLUGIN.getNamespacedKeyFactory().create("advancement-shard"), PersistentDataType.STRING);
|
||||
|
||||
if (shardSet == null) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.willfp.eco.core.PluginDependent;
|
||||
import com.willfp.ecoarmor.sets.ArmorSet;
|
||||
import com.willfp.ecoarmor.sets.ArmorSets;
|
||||
import com.willfp.ecoarmor.sets.util.ArmorUtils;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -32,6 +33,10 @@ public class AdvancementShardListener extends PluginDependent implements Listene
|
||||
*/
|
||||
@EventHandler
|
||||
public void onDrag(@NotNull final InventoryClickEvent event) {
|
||||
if (event.getWhoClicked().getGameMode() == GameMode.CREATIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack current = event.getCurrentItem();
|
||||
ItemStack cursor = event.getCursor();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginDependent;
|
||||
import com.willfp.ecoarmor.sets.util.ArmorUtils;
|
||||
import com.willfp.ecoarmor.upgrades.Tier;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -31,6 +32,10 @@ public class CrystalListener extends PluginDependent implements Listener {
|
||||
*/
|
||||
@EventHandler
|
||||
public void onDrag(@NotNull final InventoryClickEvent event) {
|
||||
if (event.getWhoClicked().getGameMode() == GameMode.CREATIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack current = event.getCurrentItem();
|
||||
ItemStack cursor = event.getCursor();
|
||||
|
||||
@@ -52,9 +57,7 @@ public class CrystalListener extends PluginDependent implements Listener {
|
||||
boolean allowed = false;
|
||||
List<Tier> prereq = crystalTier.getRequiredTiersForApplication();
|
||||
|
||||
if (prereq.isEmpty()) {
|
||||
allowed = true;
|
||||
} else if (prereq.contains(previousTier)) {
|
||||
if (prereq.isEmpty() || prereq.contains(previousTier)) {
|
||||
allowed = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ permissions:
|
||||
children:
|
||||
ecoarmor.reload: true
|
||||
ecoarmor.give: true
|
||||
ecoarmor.noflydisable: true
|
||||
|
||||
ecoarmor.reload:
|
||||
description: Allows reloading the config
|
||||
@@ -44,3 +45,6 @@ permissions:
|
||||
ecoarmor.give:
|
||||
description: Allows the use of /eagive
|
||||
default: op
|
||||
ecoarmor.noflydisable:
|
||||
description: Prevents losing fly.
|
||||
default: op
|
||||
|
||||
@@ -21,6 +21,8 @@ crystal-lore:
|
||||
- "&8Drop this onto an armor piece"
|
||||
- "&8to set its tier to:"
|
||||
- "/ab&lCOBALT"
|
||||
- ""
|
||||
- "&8&oRequires the armor to already have Iron tier"
|
||||
properties:
|
||||
helmet:
|
||||
armor: 3
|
||||
|
||||
@@ -21,6 +21,8 @@ crystal-lore:
|
||||
- "&8Drop this onto an armor piece"
|
||||
- "&8to set its tier to:"
|
||||
- "&b&lDIAMOND"
|
||||
- ""
|
||||
- "&8&oRequires the armor to already have Iron tier"
|
||||
properties:
|
||||
helmet:
|
||||
armor: 3
|
||||
|
||||
@@ -21,6 +21,8 @@ crystal-lore:
|
||||
- "&8Drop this onto an armor piece"
|
||||
- "&8to set its tier to:"
|
||||
- "&6&k!!&r <GRADIENT:f79d00>&lEXOTIC</GRADIENT:64f38c>&r &6&k!!&r"
|
||||
- ""
|
||||
- "&8&oRequires the armor to already have Netherite tier"
|
||||
properties:
|
||||
helmet:
|
||||
armor: 3
|
||||
|
||||
@@ -21,6 +21,8 @@ crystal-lore:
|
||||
- "&8Drop this onto an armor piece"
|
||||
- "&8to set its tier to:"
|
||||
- "&7&lIRON"
|
||||
- ""
|
||||
- "&8&oRequires the armor to already have default tier"
|
||||
properties:
|
||||
helmet:
|
||||
armor: 2
|
||||
|
||||
@@ -21,6 +21,8 @@ crystal-lore:
|
||||
- "&8Drop this onto an armor piece"
|
||||
- "&8to set its tier to:"
|
||||
- "&d&k!!&r <GRADIENT:f953c6>&lMANYULLYN</GRADIENT:b91d73>&r &d&k!!&r"
|
||||
- ""
|
||||
- "&8&oRequires the armor to already have Netherite tier"
|
||||
properties:
|
||||
helmet:
|
||||
armor: 3
|
||||
|
||||
@@ -21,6 +21,8 @@ crystal-lore:
|
||||
- "&8Drop this onto an armor piece"
|
||||
- "&8to set its tier to:"
|
||||
- "&c&lNETHERITE"
|
||||
- ""
|
||||
- "&8&oRequires the armor to already have Diamond tier"
|
||||
properties:
|
||||
helmet:
|
||||
armor: 3
|
||||
|
||||
@@ -21,6 +21,8 @@ crystal-lore:
|
||||
- "&8Drop this onto an armor piece"
|
||||
- "&8to set its tier to:"
|
||||
- "&b&k!!&r <GRADIENT:c7f1ff>&lOSMIUM</GRADIENT:5c92ff>&r &b&k!!"
|
||||
- ""
|
||||
- "&8&oRequires the armor to already have Cobalt tier"
|
||||
properties:
|
||||
helmet:
|
||||
armor: 3
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version = 4.1.1
|
||||
version = 4.2.3
|
||||
plugin-name = EcoArmor
|
||||
Reference in New Issue
Block a user