UltimateStacker/UltimateStacker-Plugin/src/main/java/com.craftaro.ultimatestacker/gui/GUIConvertWhat.java

68 lines
2.4 KiB
Java
Raw Normal View History

2023-05-25 19:20:03 +02:00
package com.craftaro.ultimatestacker.gui;
import com.craftaro.core.gui.Gui;
import com.craftaro.core.gui.GuiUtils;
2024-01-07 12:16:27 +01:00
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.core.utils.TextUtils;
2024-01-07 12:16:27 +01:00
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.ultimatestacker.convert.Convert;
2019-09-03 22:38:00 +02:00
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
2019-09-03 22:38:00 +02:00
public class GUIConvertWhat extends Gui {
2020-09-01 20:54:43 +02:00
private Convert convertFrom;
private boolean entities = true;
private boolean spawners = true;
2019-09-03 22:38:00 +02:00
public GUIConvertWhat(Convert convertFrom, Gui returnTo) {
super(returnTo);
this.setRows(1);
this.setTitle("What Do You Want To Convert?");
this.convertFrom = convertFrom;
2019-09-03 22:38:00 +02:00
if (convertFrom.canEntities()) {
2023-06-29 11:18:18 +02:00
this.setButton(0, GuiUtils.createButtonItem(XMaterial.STONE,
2019-09-03 22:38:00 +02:00
ChatColor.GRAY + "Stacked Entities",
entities ? ChatColor.GREEN + "Yes" : ChatColor.RED + "No"),
(event) -> toggleEntities());
}
if (convertFrom.canSpawners()) {
2023-06-29 11:18:18 +02:00
this.setButton(1, GuiUtils.createButtonItem(XMaterial.STONE,
2019-09-03 22:38:00 +02:00
ChatColor.GRAY + "Stacked Spawners",
spawners ? ChatColor.GREEN + "Yes" : ChatColor.RED + "No"),
(event) -> toggleSpawners());
}
2023-06-29 11:18:18 +02:00
this.setButton(8, GuiUtils.createButtonItem(XMaterial.GREEN_WOOL, ChatColor.GREEN + "Run"),
2019-09-03 22:38:00 +02:00
(event) -> run(event.player));
2019-09-03 22:38:00 +02:00
}
2020-09-01 20:54:43 +02:00
private void toggleEntities() {
2019-09-03 22:38:00 +02:00
entities = !entities;
this.updateItem(0, ChatColor.GRAY + "Stacked Entities", entities ? ChatColor.GREEN + "Yes" : ChatColor.RED + "No");
}
2020-09-01 20:54:43 +02:00
private void toggleSpawners() {
2019-09-03 22:38:00 +02:00
spawners = !spawners;
this.updateItem(1, ChatColor.GRAY + "Stacked Spawners", spawners ? ChatColor.GREEN + "Yes" : ChatColor.RED + "No");
}
2020-09-01 20:54:43 +02:00
private void run(Player player) {
2019-09-03 22:38:00 +02:00
if (entities) {
convertFrom.convertEntities();
//UltimateStacker.getInstance().getEntityStackManager().tryAndLoadColdEntities();
2019-09-03 22:38:00 +02:00
}
if (spawners) {
convertFrom.convertSpawners();
}
2019-09-03 22:38:00 +02:00
convertFrom.disablePlugin();
exit();
2021-03-05 15:09:00 +01:00
player.sendMessage(TextUtils.formatText("&7Data converted successfully. Remove &6" + convertFrom.getName() + " &7and restart your server to continue."));
}
}