mirror of
https://github.com/Auxilor/Reforges.git
synced 2026-01-03 14:22:19 +00:00
Saving in case i lose this
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.willfp.reforges;
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.Prerequisite;
|
||||
import com.willfp.eco.core.command.impl.PluginCommand;
|
||||
import com.willfp.eco.core.display.DisplayModule;
|
||||
import com.willfp.eco.core.items.Items;
|
||||
@@ -11,6 +12,7 @@ import com.willfp.reforges.config.TargetYml;
|
||||
import com.willfp.reforges.display.ReforgesDisplay;
|
||||
import com.willfp.reforges.effects.Effect;
|
||||
import com.willfp.reforges.effects.Effects;
|
||||
import com.willfp.reforges.paper.PaperHandler;
|
||||
import com.willfp.reforges.reforges.Reforges;
|
||||
import com.willfp.reforges.reforges.util.ReforgeArgParser;
|
||||
import com.willfp.reforges.reforges.util.WatcherTriggers;
|
||||
@@ -18,6 +20,7 @@ import com.willfp.reforges.util.AntiPlaceListener;
|
||||
import com.willfp.reforges.util.DiscoverRecipeListener;
|
||||
import com.willfp.reforges.vault.EconomyHandler;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -44,6 +47,13 @@ public class ReforgesPlugin extends EcoPlugin {
|
||||
@Getter
|
||||
private final ReforgesJson reforgesJson;
|
||||
|
||||
/**
|
||||
* Paper handler.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private PaperHandler paperHandler;
|
||||
|
||||
/**
|
||||
* Internal constructor called by bukkit on plugin load.
|
||||
*/
|
||||
@@ -52,6 +62,17 @@ public class ReforgesPlugin extends EcoPlugin {
|
||||
this.targetYml = new TargetYml(this);
|
||||
this.reforgesJson = new ReforgesJson(this);
|
||||
instance = this;
|
||||
|
||||
/*
|
||||
I still use the spigot api for most things and don't want to suppress deprecation warnings
|
||||
every 2 seconds, so I'm moving all paper related things off to their own module.
|
||||
*/
|
||||
if (Prerequisite.HAS_PAPER.isMet()) {
|
||||
try {
|
||||
Class.forName("com.willfp.reforges.paper.PaperLoader");
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.willfp.reforges.effects;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.willfp.reforges.effects.effects.EffectAttackSpeedMultiplier;
|
||||
import com.willfp.reforges.effects.effects.EffectCritMultiplier;
|
||||
import com.willfp.reforges.effects.effects.EffectDamageMultiplier;
|
||||
import com.willfp.reforges.effects.effects.EffectIncomingDamageMultiplier;
|
||||
@@ -21,7 +22,7 @@ public class Effects {
|
||||
/**
|
||||
* All registered effects.
|
||||
*/
|
||||
private static final BiMap<String, Effect> BY_NAME = HashBiMap.create();
|
||||
private static final BiMap<String, Effect> BY_ID = HashBiMap.create();
|
||||
|
||||
public static final Effect DAMAGE_MULTIPLIER = new EffectDamageMultiplier();
|
||||
public static final Effect CRIT_MULTIPLIER = new EffectCritMultiplier();
|
||||
@@ -29,16 +30,17 @@ public class Effects {
|
||||
public static final Effect KNOCKBACK_MULTIPLIER = new EffectKnockbackMultiplier();
|
||||
public static final Effect REWARD_BLOCK_BREAK = new EffectRewardBlockBreak();
|
||||
public static final Effect INCOMING_DAMAGE_MULTIPLIER = new EffectIncomingDamageMultiplier();
|
||||
public static final Effect ATTACK_SPEED_MULTIPLIER = new EffectAttackSpeedMultiplier();
|
||||
|
||||
/**
|
||||
* Get effect matching name.
|
||||
* Get effect matching id.
|
||||
*
|
||||
* @param name The name to query.
|
||||
* @param id The id to query.
|
||||
* @return The matching effect, or null if not found.
|
||||
*/
|
||||
@Nullable
|
||||
public static Effect getByName(@NotNull final String name) {
|
||||
return BY_NAME.get(name);
|
||||
public static Effect getByID(@NotNull final String id) {
|
||||
return BY_ID.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +49,7 @@ public class Effects {
|
||||
* @return The effects.
|
||||
*/
|
||||
public static List<Effect> values() {
|
||||
return ImmutableList.copyOf(BY_NAME.values());
|
||||
return ImmutableList.copyOf(BY_ID.values());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +58,7 @@ public class Effects {
|
||||
* @param effect The effect to add.
|
||||
*/
|
||||
public static void addNewEffect(@NotNull final Effect effect) {
|
||||
BY_NAME.remove(effect.getName());
|
||||
BY_NAME.put(effect.getName(), effect);
|
||||
BY_ID.remove(effect.getId());
|
||||
BY_ID.put(effect.getId(), effect);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginDependent;
|
||||
import com.willfp.eco.core.gui.menu.Menu;
|
||||
import com.willfp.eco.core.gui.slot.Slot;
|
||||
import com.willfp.reforges.reforges.Reforge;
|
||||
import com.willfp.reforges.reforges.meta.ReforgeTarget;
|
||||
import com.willfp.reforges.vault.EconomyHandler;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ReforgeUtils {
|
||||
List<Reforge> applicable = new ArrayList<>();
|
||||
|
||||
for (Reforge reforge : Reforges.values()) {
|
||||
if (Arrays.asList(reforge.getTargets()).contains(target) && !reforge.isRequiresStone()) {
|
||||
if (Arrays.asList(reforge.getTargets()).contains(target) && !reforge.getRequiresStone()) {
|
||||
applicable.add(reforge);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.willfp.eco.core.fast.FastItemStack
|
||||
import com.willfp.eco.util.SkullUtils
|
||||
import com.willfp.reforges.reforges.meta.ReforgeTarget
|
||||
import com.willfp.reforges.reforges.util.ReforgeUtils
|
||||
import org.apache.commons.lang.WordUtils
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.inventory.meta.SkullMeta
|
||||
@@ -61,27 +60,17 @@ class ReforgesDisplay(plugin: EcoPlugin) : DisplayModule(plugin, DisplayPriority
|
||||
val addLore: MutableList<String> = ArrayList()
|
||||
addLore.add(" ")
|
||||
addLore.add(reforge.name)
|
||||
val description = mutableListOf(
|
||||
*WordUtils.wrap(
|
||||
reforge.description,
|
||||
plugin.configYml.getInt("reforge.line-wrap"),
|
||||
"\n",
|
||||
false
|
||||
).split("\\r?\\n").toTypedArray()
|
||||
)
|
||||
description.replaceAll { s: String ->
|
||||
plugin.langYml.getString("description-color") + s.replace(
|
||||
"%description%",
|
||||
reforge.description
|
||||
)
|
||||
}
|
||||
description.replaceAll { s: String ->
|
||||
s.replace(
|
||||
"§r",
|
||||
plugin.langYml.getString("description-color")
|
||||
)
|
||||
}
|
||||
addLore.addAll(description)
|
||||
addLore.addAll(reforge.description)
|
||||
addLore.replaceAll { "${Display.PREFIX}$it" }
|
||||
lore.addAll(addLore)
|
||||
}
|
||||
if (plugin.configYml.getBool("reforge.display-in-name")) {
|
||||
val
|
||||
|
||||
val addLore: MutableList<String> = ArrayList()
|
||||
addLore.add(" ")
|
||||
addLore.add(reforge.name)
|
||||
addLore.addAll(reforge.description)
|
||||
addLore.replaceAll { "${Display.PREFIX}$it" }
|
||||
lore.addAll(addLore)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.willfp.reforges.effects.effects
|
||||
|
||||
import com.willfp.eco.core.config.interfaces.JSONConfig
|
||||
import com.willfp.reforges.effects.Effect
|
||||
import org.bukkit.attribute.Attribute
|
||||
import org.bukkit.attribute.AttributeModifier
|
||||
import org.bukkit.inventory.meta.ItemMeta
|
||||
|
||||
class EffectAttackSpeedMultiplier : Effect("attack_speed_multiplier") {
|
||||
override fun handleApplication(
|
||||
meta: ItemMeta,
|
||||
config: JSONConfig
|
||||
) {
|
||||
meta.addAttributeModifier(
|
||||
Attribute.GENERIC_ATTACK_SPEED,
|
||||
AttributeModifier(
|
||||
this.uuid,
|
||||
this.id,
|
||||
config.getDouble("multiplier") - 1,
|
||||
AttributeModifier.Operation.MULTIPLY_SCALAR_1
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun handleRemoval(meta: ItemMeta) {
|
||||
meta.removeAttributeModifier(
|
||||
Attribute.GENERIC_ATTACK_SPEED,
|
||||
AttributeModifier(
|
||||
this.uuid,
|
||||
this.id,
|
||||
0.0,
|
||||
AttributeModifier.Operation.MULTIPLY_SCALAR_1
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.willfp.reforges.paper
|
||||
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
interface PaperHandler {
|
||||
fun getDisplayName(itemStack: ItemStack): String
|
||||
}
|
||||
@@ -22,12 +22,12 @@ class Reforge(
|
||||
|
||||
val name = config.getString("name")
|
||||
|
||||
val description = config.getString("description")
|
||||
val description: List<String> = config.getStrings("description")
|
||||
|
||||
val targets = config.getStrings("targets").map { ReforgeTarget.getByName(it) }.toSet()
|
||||
|
||||
val effects = config.getSubsections("effects").map {
|
||||
val effect = Effects.getByName(it.getString("id")) ?: return@map null
|
||||
val effect = Effects.getByID(it.getString("id")) ?: return@map null
|
||||
ConfiguredEffect(effect, it)
|
||||
}.filterNotNull().toSet()
|
||||
|
||||
|
||||
@@ -122,8 +122,6 @@ reforge:
|
||||
|
||||
cost-exponent: 1.15 # (Reforges done ^ cost exponent) * cost
|
||||
|
||||
line-wrap: 32
|
||||
|
||||
show-reforgable: true
|
||||
reforgable-suffix:
|
||||
- ""
|
||||
|
||||
@@ -15,6 +15,4 @@ messages:
|
||||
|
||||
menu:
|
||||
title: "Reforge Item"
|
||||
close: "&cClose"
|
||||
|
||||
description-color: "&7&o"
|
||||
close: "&cClose"
|
||||
@@ -3,7 +3,10 @@
|
||||
{
|
||||
"id": "dynamic",
|
||||
"name": "<gradient:#AAFFA9>Dynamic</gradient:#11FFBD>",
|
||||
"description": "Deal &a5%&r more damage and &a10%&r more critical damage",
|
||||
"description": [
|
||||
"&a+5% &fDamage",
|
||||
"&a+10% &fCrit Damage"
|
||||
],
|
||||
"targets": [
|
||||
"melee"
|
||||
],
|
||||
@@ -15,11 +18,9 @@
|
||||
"air",
|
||||
"ecoitems:blank_reforge_stone ? air",
|
||||
"air",
|
||||
|
||||
"iron_block",
|
||||
"daylight_sensor",
|
||||
"iron_block",
|
||||
|
||||
"air",
|
||||
"phantom_membrane",
|
||||
"air"
|
||||
@@ -36,7 +37,6 @@
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user