mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-22 04:37:42 +01:00
The following changes were made:
(1) Allows to put items in item frames even if they have DisableInteractions stat — this stat allows to put items in armor stands, but it blocked Item Frames for some reason? (2) MMOItemEditionEvent now fired when a player edits a MMOItem in the GUI /mi browse (3) Allows RANGE stat to be put in gemstones, so gems that increase musket or magic wand range can be made. (4) Turned "MORE IS BETTER" to "false" in cost stats, like stamina cost or mana cost, to better reflect the effect of upgrades that edit these stats.
This commit is contained in:
parent
0994e6b0c3
commit
919c88a28b
@ -69,9 +69,9 @@ public class ItemStats {
|
||||
PARRY_RATING = new DoubleStat("PARRY_RATING", Material.BUCKET, "Parry Rating", new String[]{"The chance to parry an attack.", "Parrying negates the damage", "and knocks the attacker back."}, new String[]{"!miscellaneous", "!block", "all"}),
|
||||
PARRY_COOLDOWN_REDUCTION = new DoubleStat("PARRY_COOLDOWN_REDUCTION", Material.BUCKET, "Parry Cooldown Reduction", new String[]{"Reduces the parrying cooldown (%)."}, new String[]{"!miscellaneous", "!block", "all"}),
|
||||
COOLDOWN_REDUCTION = new DoubleStat("COOLDOWN_REDUCTION", Material.BOOK, "Cooldown Reduction", new String[]{"Reduces cooldowns of item and player skills (%)."}),
|
||||
RANGE = new DoubleStat("RANGE", Material.STICK, "Range", new String[]{"The range of your item attacks."}, new String[]{"staff", "whip", "wand", "musket"}),
|
||||
RANGE = new DoubleStat("RANGE", Material.STICK, "Range", new String[]{"The range of your item attacks."}, new String[]{"staff", "whip", "wand", "musket", "gem_stone", "bow"}),
|
||||
MANA_COST = new ManaCost(),
|
||||
STAMINA_COST = new DoubleStat("STAMINA_COST", VersionMaterial.LIGHT_GRAY_DYE.toMaterial(), "Stamina Cost", new String[]{"Stamina spent by your weapon to be used."}, new String[]{"piercing", "slashing", "blunt", "range"}),
|
||||
STAMINA_COST = new DoubleStat("STAMINA_COST", VersionMaterial.LIGHT_GRAY_DYE.toMaterial(), "Stamina Cost", new String[]{"Stamina spent by your weapon to be used."}, new String[]{"piercing", "slashing", "blunt", "range"}, false),
|
||||
ARROW_VELOCITY = new DoubleStat("ARROW_VELOCITY", Material.ARROW, "Arrow Velocity", new String[]{"Determines how far your", "weapon can shoot.", "Default: 1.0"}, new String[]{"gem_stone", "bow", "crossbow"}),
|
||||
ARROW_POTION_EFFECTS = new ArrowPotionEffects(),
|
||||
PVE_DAMAGE = new DoubleStat("PVE_DAMAGE", VersionMaterial.PORKCHOP.toMaterial(), "PvE Damage", new String[]{"Additional damage against", "non human entities in %."}, new String[]{"piercing", "slashing", "blunt", "catalyst", "range", "tool", "armor", "gem_stone", "accessory"}),
|
||||
|
@ -2,6 +2,10 @@ package net.Indyuce.mmoitems.api.edition.input;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.edition.Edition;
|
||||
import net.Indyuce.mmoitems.api.edition.StatEdition;
|
||||
import net.Indyuce.mmoitems.api.event.MMOItemEditionEvent;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -9,6 +13,8 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ChatEdition extends PlayerInputHandler implements Listener {
|
||||
|
||||
@ -31,6 +37,22 @@ public class ChatEdition extends PlayerInputHandler implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void a(AsyncPlayerChatEvent event) {
|
||||
if (getPlayer() != null && event.getPlayer().equals(getPlayer())) {
|
||||
@Nullable RandomStatData legacy;
|
||||
if (getEdition() instanceof StatEdition && getEdition().getInventory() instanceof EditionInventory) { legacy = ((EditionInventory) getEdition().getInventory()).getEdited().getBaseItemData().get(((StatEdition) getEdition()).getStat()); } else { legacy = null; }
|
||||
|
||||
// Send it to sync
|
||||
ChatEdition capitalQuestion = this;
|
||||
(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// Send it to sync
|
||||
MMOItemEditionEvent ent = new MMOItemEditionEvent(event.getPlayer(), capitalQuestion, event.getMessage(), legacy);
|
||||
Bukkit.getServer().getPluginManager().callEvent(ent);
|
||||
}
|
||||
}).runTask(MMOItems.plugin);
|
||||
|
||||
// Actually perform edition
|
||||
event.setCancelled(true);
|
||||
registerInput(event.getMessage());
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.api.edition.input;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.api.edition.Edition;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class PlayerInputHandler {
|
||||
|
||||
@ -10,14 +11,15 @@ public abstract class PlayerInputHandler {
|
||||
* Saves the last inventory opened, the item data, and the last opened page;
|
||||
* allows for a much easier access to this data
|
||||
*/
|
||||
private final Edition edition;
|
||||
@NotNull private final Edition edition;
|
||||
@NotNull public Edition getEdition() { return edition; }
|
||||
|
||||
/**
|
||||
* Abstract class which lists all possible ways to retrieve player input
|
||||
*
|
||||
* @param edition The edition object
|
||||
*/
|
||||
public PlayerInputHandler(Edition edition) {
|
||||
public PlayerInputHandler(@NotNull Edition edition) {
|
||||
this.edition = edition;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,52 @@
|
||||
package net.Indyuce.mmoitems.api.event;
|
||||
|
||||
import net.Indyuce.mmoitems.api.edition.input.ChatEdition;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Sent when a MMOItem is edited, by a player, using `/mi browse` GUI
|
||||
*/
|
||||
public class MMOItemEditionEvent extends PlayerEvent {
|
||||
|
||||
/**
|
||||
* @return What of MMOItem is being edited
|
||||
*/
|
||||
@NotNull public ChatEdition getEditionInformation() { return editionInformation; }
|
||||
@NotNull final ChatEdition editionInformation;
|
||||
|
||||
/**
|
||||
* @return Message (I guess)
|
||||
*/
|
||||
@NotNull public String getEditionMessage() { return editionMessage; }
|
||||
@NotNull final String editionMessage;
|
||||
|
||||
/**
|
||||
* @return Old value
|
||||
*/
|
||||
@Nullable public RandomStatData getLegacyValue() { return legacyValue; }
|
||||
@Nullable final RandomStatData legacyValue;
|
||||
|
||||
/**
|
||||
* @param who Player doing edition of MMOItems
|
||||
* @param editionInformation What MMOItem is being edited
|
||||
*/
|
||||
public MMOItemEditionEvent(@NotNull Player who, @NotNull ChatEdition editionInformation, @NotNull String editionMessage, @Nullable RandomStatData legacyValue) {
|
||||
super(who);
|
||||
this.editionInformation = editionInformation;
|
||||
this.editionMessage = editionMessage;
|
||||
this.legacyValue = legacyValue;
|
||||
}
|
||||
|
||||
//region Event Standard
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@NotNull
|
||||
@Override public HandlerList getHandlers() { return handlers; }
|
||||
public static HandlerList getHandlerList() { return handlers; }
|
||||
//endregion
|
||||
}
|
@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ManaCost extends DoubleStat implements ItemRestriction, PlayerConsumable {
|
||||
|
||||
public ManaCost() {
|
||||
super("MANA_COST", VersionMaterial.LAPIS_LAZULI.toMaterial(), "Mana Cost", new String[]{"Mana spent by your weapon to be used."}, new String[]{"piercing", "slashing", "blunt", "range"});
|
||||
super("MANA_COST", VersionMaterial.LAPIS_LAZULI.toMaterial(), "Mana Cost", new String[]{"Mana spent by your weapon to be used."}, new String[]{"piercing", "slashing", "blunt", "range"}, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.interaction.util.DurabilityItem;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
@ -112,6 +113,9 @@ public class DisableInteractions implements Listener {
|
||||
if (event.getRightClicked() instanceof ArmorStand)
|
||||
return;
|
||||
|
||||
if (event.getRightClicked() instanceof ItemFrame)
|
||||
return;
|
||||
|
||||
NBTItem item = NBTItem.get(event.getHand() == EquipmentSlot.OFF_HAND ? event.getPlayer().getInventory().getItemInOffHand()
|
||||
: event.getPlayer().getInventory().getItemInMainHand());
|
||||
if (item.getBoolean("MMOITEMS_DISABLE_INTERACTION"))
|
||||
|
Loading…
Reference in New Issue
Block a user