mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-03 06:37:47 +01:00
Small cleanup
This commit is contained in:
parent
57b20fa97d
commit
f54fc0636e
@ -7,10 +7,8 @@ public interface Edition {
|
||||
/**
|
||||
* Processes the player input.
|
||||
*
|
||||
* @param input
|
||||
* Current player input
|
||||
* @return If the edition process should be closed, or false if it should
|
||||
* continue listening to player input
|
||||
* @param input Current player input
|
||||
* @return False if it should continue listening to player input
|
||||
*/
|
||||
boolean processInput(String input);
|
||||
|
||||
@ -23,8 +21,7 @@ public interface Edition {
|
||||
/**
|
||||
* Called when edition is opened.
|
||||
*
|
||||
* @param message
|
||||
* Message which should be sent to the player
|
||||
* @param message Message which should be sent to the player
|
||||
*/
|
||||
void enable(String... message);
|
||||
|
||||
@ -32,6 +29,5 @@ public interface Edition {
|
||||
* @return If the previously opened GUI should be opened right after edition
|
||||
* ends or if it should be ignored
|
||||
*/
|
||||
@Deprecated
|
||||
boolean shouldGoBack();
|
||||
}
|
||||
|
@ -4,19 +4,13 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.edition.process.AnvilGUI;
|
||||
import net.Indyuce.mmoitems.api.edition.process.ChatEdition;
|
||||
import net.Indyuce.mmoitems.api.edition.input.AnvilGUI;
|
||||
import net.Indyuce.mmoitems.api.edition.input.ChatEdition;
|
||||
import net.Indyuce.mmoitems.gui.ItemBrowser;
|
||||
import net.Indyuce.mmoitems.gui.PluginInventory;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class NewItemEdition implements Edition {
|
||||
|
||||
/*
|
||||
* saves the data about the edited data so the plugin can edit the
|
||||
* corresponding stat. some stats have complex chat formats, so the object
|
||||
* array allow to save more complex edition info
|
||||
*/
|
||||
private final ItemBrowser inv;
|
||||
|
||||
public NewItemEdition(ItemBrowser inv) {
|
||||
|
@ -3,8 +3,8 @@ package net.Indyuce.mmoitems.api.edition;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.edition.process.AnvilGUI;
|
||||
import net.Indyuce.mmoitems.api.edition.process.ChatEdition;
|
||||
import net.Indyuce.mmoitems.api.edition.input.AnvilGUI;
|
||||
import net.Indyuce.mmoitems.api.edition.input.ChatEdition;
|
||||
import net.Indyuce.mmoitems.comp.parse.StringInputParser;
|
||||
import net.Indyuce.mmoitems.gui.PluginInventory;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.Indyuce.mmoitems.api.edition.process;
|
||||
package net.Indyuce.mmoitems.api.edition.input;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -15,12 +15,17 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.edition.Edition;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class AnvilGUI extends EditionProcess implements Listener {
|
||||
public class AnvilGUI extends PlayerInputHandler implements Listener {
|
||||
private final int containerId;
|
||||
private final Inventory inventory;
|
||||
|
||||
private boolean open;
|
||||
|
||||
/**
|
||||
* Allows to retrieve player input using an anvil GUI
|
||||
*
|
||||
* @param edition Data being edited
|
||||
*/
|
||||
public AnvilGUI(Edition edition) {
|
||||
super(edition);
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.Indyuce.mmoitems.api.edition.process;
|
||||
package net.Indyuce.mmoitems.api.edition.input;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -11,7 +11,13 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.edition.Edition;
|
||||
|
||||
public class ChatEdition extends EditionProcess implements Listener {
|
||||
public class ChatEdition extends PlayerInputHandler implements Listener {
|
||||
|
||||
/**
|
||||
* Allows to retrieve player input using chat messages
|
||||
*
|
||||
* @param edition The type of data being edited
|
||||
*/
|
||||
public ChatEdition(Edition edition) {
|
||||
super(edition);
|
||||
|
@ -1,14 +1,14 @@
|
||||
package net.Indyuce.mmoitems.api.edition.process;
|
||||
package net.Indyuce.mmoitems.api.edition.input;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.api.edition.Edition;
|
||||
|
||||
public abstract class EditionProcess {
|
||||
public abstract class PlayerInputHandler {
|
||||
|
||||
/*
|
||||
* saves the last inventory opened. it saves the item data, and the last
|
||||
* opened page. allows for a much easier access to this data
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@ -17,7 +17,7 @@ public abstract class EditionProcess {
|
||||
*
|
||||
* @param edition The edition object
|
||||
*/
|
||||
public EditionProcess(Edition edition) {
|
||||
public PlayerInputHandler(Edition edition) {
|
||||
this.edition = edition;
|
||||
}
|
||||
|
||||
@ -30,15 +30,14 @@ public abstract class EditionProcess {
|
||||
* opens the previously opened GUI if needed. This method is protected
|
||||
* because it should only be ran by edition process classes
|
||||
*
|
||||
* @param input
|
||||
* Player input
|
||||
* @param input Player input
|
||||
*/
|
||||
protected void registerInput(String input) {
|
||||
if (!edition.processInput(input))
|
||||
return;
|
||||
|
||||
// if (edition.shouldGoBack())
|
||||
// edition.getInventory().open();
|
||||
if (edition.shouldGoBack())
|
||||
edition.getInventory().open();
|
||||
close();
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ public enum CraftingType {
|
||||
private final Material material;
|
||||
private final int[] mustBeHigher;
|
||||
|
||||
CraftingType(int slot, String lore, VersionMaterial material, int... mustBeHigher) {
|
||||
private CraftingType(int slot, String lore, VersionMaterial material, int... mustBeHigher) {
|
||||
this(slot, lore, material.toMaterial(), mustBeHigher);
|
||||
}
|
||||
|
||||
CraftingType(int slot, String lore, Material material, int... mustBeHigher) {
|
||||
private CraftingType(int slot, String lore, Material material, int... mustBeHigher) {
|
||||
this.slot = slot;
|
||||
this.lore = lore;
|
||||
this.material = material;
|
||||
@ -49,7 +49,7 @@ public enum CraftingType {
|
||||
}
|
||||
|
||||
public boolean shouldAdd() {
|
||||
return mustBeHigher.length < 1 || MMOLib.plugin.getVersion().isStrictlyHigher(mustBeHigher);
|
||||
return mustBeHigher.length == 0 || MMOLib.plugin.getVersion().isStrictlyHigher(mustBeHigher);
|
||||
}
|
||||
|
||||
public static CraftingType getBySlot(int slot) {
|
||||
|
Loading…
Reference in New Issue
Block a user