mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
Abstracted away ValueUpdatableGui.
This commit is contained in:
parent
fc033460b4
commit
502aa64f50
8 changed files with 42 additions and 27 deletions
|
|
@ -1,20 +1,11 @@
|
|||
package xyz.alexcrea.cuanvil.gui;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||
|
||||
public abstract class ValueUpdatableGui extends ChestGui {
|
||||
public interface ValueUpdatableGui {
|
||||
|
||||
public ValueUpdatableGui(int rows, @NotNull String title, @NotNull Plugin plugin) {
|
||||
super(rows, title, plugin);
|
||||
}
|
||||
void updateGuiValues();
|
||||
|
||||
public ValueUpdatableGui(int rows, @NotNull TextHolder title, @NotNull Plugin plugin) {
|
||||
super(rows, title, plugin);
|
||||
}
|
||||
|
||||
public abstract void updateGuiValues();
|
||||
Gui getConnectedGui();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||
import com.github.stefvanschie.inventoryframework.pane.Orientable;
|
||||
import com.github.stefvanschie.inventoryframework.pane.OutlinePane;
|
||||
import io.delilaheve.CustomAnvil;
|
||||
|
|
@ -17,7 +19,7 @@ import java.util.List;
|
|||
*
|
||||
* @param <T> Type of the factory of the type of setting the gui should edit.
|
||||
*/
|
||||
public abstract class AbstractEnchantConfigGui<T extends AbstractSettingGui.SettingGuiFactory> extends ValueUpdatableGui {
|
||||
public abstract class AbstractEnchantConfigGui<T extends AbstractSettingGui.SettingGuiFactory> extends ChestGui implements ValueUpdatableGui {
|
||||
|
||||
/**
|
||||
* Constructor for a gui displaying available enchantment to edit a enchantment setting.
|
||||
|
|
@ -78,7 +80,10 @@ public abstract class AbstractEnchantConfigGui<T extends AbstractSettingGui.Sett
|
|||
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gui getConnectedGui() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract T getFactoryFromEnchant(WrappedEnchantment enchant);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||
import com.github.stefvanschie.inventoryframework.pane.PatternPane;
|
||||
import com.github.stefvanschie.inventoryframework.pane.util.Pattern;
|
||||
import io.delilaheve.CustomAnvil;
|
||||
|
|
@ -27,7 +29,7 @@ import java.util.Collections;
|
|||
/**
|
||||
* Global config to edit basic basic settings.
|
||||
*/
|
||||
public class BasicConfigGui extends ValueUpdatableGui {
|
||||
public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
|
||||
|
||||
private static BasicConfigGui INSTANCE;
|
||||
|
||||
|
|
@ -253,4 +255,9 @@ public class BasicConfigGui extends ValueUpdatableGui {
|
|||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gui getConnectedGui() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ import java.util.Locale;
|
|||
*/
|
||||
public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSettingsGui.EnchantCostSettingFactory> {
|
||||
|
||||
private final static String SECTION_NAME = "enchant_values";
|
||||
private static final String SECTION_NAME = "enchant_values";
|
||||
|
||||
public final static EnchantCostConfigGui INSTANCE = new EnchantCostConfigGui();
|
||||
public static final EnchantCostConfigGui INSTANCE = new EnchantCostConfigGui();
|
||||
|
||||
static {
|
||||
INSTANCE.init();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package xyz.alexcrea.cuanvil.gui.config.list;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||
import com.github.stefvanschie.inventoryframework.pane.Orientable;
|
||||
import com.github.stefvanschie.inventoryframework.pane.OutlinePane;
|
||||
import com.github.stefvanschie.inventoryframework.pane.Pane;
|
||||
|
|
@ -23,13 +25,13 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class ElementListConfigGui< T > extends ValueUpdatableGui {
|
||||
public abstract class ElementListConfigGui< T > extends ChestGui implements ValueUpdatableGui {
|
||||
|
||||
private final String namePrefix;
|
||||
|
||||
protected PatternPane backgroundPane;
|
||||
|
||||
public ElementListConfigGui(@NotNull String title) {
|
||||
protected ElementListConfigGui(@NotNull String title) {
|
||||
super(6, title, CustomAnvil.instance);
|
||||
this.namePrefix = title;
|
||||
|
||||
|
|
@ -304,4 +306,9 @@ public abstract class ElementListConfigGui< T > extends ValueUpdatableGui {
|
|||
reloadValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gui getConnectedGui() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
package xyz.alexcrea.cuanvil.gui.config.list.elements;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||
import io.delilaheve.CustomAnvil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
||||
|
||||
public abstract class MappedToListSubSettingGui extends ValueUpdatableGui implements ElementMappedToListGui {
|
||||
public abstract class MappedToListSubSettingGui extends ChestGui implements ValueUpdatableGui, ElementMappedToListGui {
|
||||
|
||||
private final GuiItem item;
|
||||
public MappedToListSubSettingGui(
|
||||
protected MappedToListSubSettingGui(
|
||||
GuiItem item,
|
||||
int rows,
|
||||
@NotNull String title) {
|
||||
|
|
@ -27,5 +28,9 @@ public abstract class MappedToListSubSettingGui extends ValueUpdatableGui implem
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gui getConnectedGui() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
|||
*/
|
||||
public abstract class AbstractSettingGui extends ChestGui {
|
||||
|
||||
protected final static String CLICK_LORE = "\u00A77Click Here to change the value";
|
||||
protected static final String CLICK_LORE = "\u00A77Click Here to change the value";
|
||||
|
||||
private PatternPane pane;
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ public abstract class AbstractSettingGui extends ChestGui {
|
|||
* @param title Title of this gui.
|
||||
* @param parent Parent gui to go back when completed.
|
||||
*/
|
||||
public AbstractSettingGui(int rows, @NotNull TextHolder title, ValueUpdatableGui parent) {
|
||||
protected AbstractSettingGui(int rows, @NotNull TextHolder title, ValueUpdatableGui parent) {
|
||||
super(rows, title, CustomAnvil.instance);
|
||||
initBase(parent);
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ public abstract class AbstractSettingGui extends ChestGui {
|
|||
* @param title Title of this gui.
|
||||
* @param parent Parent gui to go back when completed.
|
||||
*/
|
||||
public AbstractSettingGui(int rows, @NotNull String title, ValueUpdatableGui parent) {
|
||||
protected AbstractSettingGui(int rows, @NotNull String title, ValueUpdatableGui parent) {
|
||||
this(rows, StringHolder.of(title), parent);
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ public abstract class AbstractSettingGui extends ChestGui {
|
|||
pane = new PatternPane(0, 0, pattern.getLength(), pattern.getHeight(), pattern);
|
||||
addPane(pane);
|
||||
|
||||
GuiGlobalItems.addBackItem(pane, parent);
|
||||
GuiGlobalItems.addBackItem(pane, parent.getConnectedGui());
|
||||
GuiGlobalItems.addBackgroundItem(pane);
|
||||
|
||||
saveItem = GuiGlobalItems.saveItem(this, parent);
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ public class GuiGlobalActions {
|
|||
// Update gui for those who have it open.
|
||||
goal.updateGuiValues();
|
||||
// Then show
|
||||
goal.show(player);
|
||||
goal.getConnectedGui().show(player);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue