mirror of
https://github.com/craftaro/EpicSpawners.git
synced 2025-01-08 11:37:51 +08:00
Redid the Spawner Editor.
This commit is contained in:
parent
87afa61ea9
commit
6eebf8d623
@ -541,6 +541,10 @@ public interface SpawnerData {
|
||||
*/
|
||||
void setParticleEffectBoostedOnly(boolean boostedOnly);
|
||||
|
||||
boolean isCustom();
|
||||
|
||||
void setCustom(boolean custom);
|
||||
|
||||
/**
|
||||
* Add spawner condiction.
|
||||
*
|
||||
|
@ -355,6 +355,8 @@ public interface SpawnerDataBuilder {
|
||||
*/
|
||||
SpawnerDataBuilder spawnEffectParticle(ParticleType particle);
|
||||
|
||||
SpawnerDataBuilder isCustom(boolean custom);
|
||||
|
||||
/**
|
||||
* Set the particle type to be used when entities have been
|
||||
* spawned from this spawner
|
||||
|
@ -25,7 +25,6 @@ import com.songoda.epicspawners.player.PlayerActionManager;
|
||||
import com.songoda.epicspawners.player.PlayerData;
|
||||
import com.songoda.epicspawners.spawners.SpawnManager;
|
||||
import com.songoda.epicspawners.spawners.condition.*;
|
||||
import com.songoda.epicspawners.spawners.editor.SpawnerEditor;
|
||||
import com.songoda.epicspawners.spawners.spawner.ESpawner;
|
||||
import com.songoda.epicspawners.spawners.spawner.ESpawnerManager;
|
||||
import com.songoda.epicspawners.spawners.spawner.ESpawnerStack;
|
||||
@ -68,7 +67,6 @@ public class EpicSpawnersPlugin extends JavaPlugin implements EpicSpawners {
|
||||
private static EpicSpawnersPlugin INSTANCE;
|
||||
private References references;
|
||||
|
||||
private ChatListeners chatListeners;
|
||||
|
||||
private ConfigWrapper spawnerFile = new ConfigWrapper(this, "", "spawners.yml");
|
||||
|
||||
@ -88,7 +86,6 @@ public class EpicSpawnersPlugin extends JavaPlugin implements EpicSpawners {
|
||||
private SpawnerParticleTask particleTask;
|
||||
private SpawnerSpawnTask spawnerCustomSpawnTask;
|
||||
|
||||
private SpawnerEditor spawnerEditor;
|
||||
private Heads heads;
|
||||
private Locale locale;
|
||||
|
||||
@ -145,19 +142,16 @@ public class EpicSpawnersPlugin extends JavaPlugin implements EpicSpawners {
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.blacklistHandler = new BlacklistHandler();
|
||||
this.playerActionManager = new PlayerActionManager();
|
||||
this.chatListeners = new ChatListeners(this);
|
||||
|
||||
this.loadSpawnersFromFile();
|
||||
this.checkStorage();
|
||||
|
||||
this.spawnerEditor = new SpawnerEditor(this);
|
||||
this.appearanceHandler = new AppearanceHandler();
|
||||
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
|
||||
// Event registration
|
||||
pluginManager.registerEvents(new BlockListeners(this), this);
|
||||
pluginManager.registerEvents(chatListeners, this);
|
||||
pluginManager.registerEvents(new EntityListeners(this), this);
|
||||
pluginManager.registerEvents(new InteractListeners(this), this);
|
||||
pluginManager.registerEvents(new InventoryListeners(this), this);
|
||||
@ -331,6 +325,12 @@ public class EpicSpawnersPlugin extends JavaPlugin implements EpicSpawners {
|
||||
.particleDensity(ParticleDensity.valueOf(currentSection.getString("Particle-Amount", "NORMAL")))
|
||||
.particleEffectBoostedOnly(currentSection.getBoolean("Particle-Effect-Boosted-Only"));
|
||||
|
||||
if (currentSection.contains("custom")) {
|
||||
dataBuilder.isCustom(currentSection.getBoolean("custom"));
|
||||
} else {
|
||||
dataBuilder.isCustom(key.toLowerCase().contains("custom"));
|
||||
}
|
||||
|
||||
if (currentSection.contains("Display-Name")) {
|
||||
dataBuilder.displayName(currentSection.getString("Display-Name"));
|
||||
}
|
||||
@ -431,6 +431,7 @@ public class EpicSpawnersPlugin extends JavaPlugin implements EpicSpawners {
|
||||
currentSection.set("items", spawnerData.getItems());
|
||||
currentSection.set("command", spawnerData.getCommands());
|
||||
|
||||
currentSection.set("custom", spawnerData.isCustom());
|
||||
currentSection.set("Spawn-Block", String.join(", ", getStrings(spawnerData.getSpawnBlocksList())));
|
||||
currentSection.set("Allowed", spawnerData.isActive());
|
||||
currentSection.set("Spawn-On-Fire", spawnerData.isSpawnOnFire());
|
||||
@ -632,6 +633,7 @@ public class EpicSpawnersPlugin extends JavaPlugin implements EpicSpawners {
|
||||
}
|
||||
}
|
||||
|
||||
spawnerConfig.addDefault("Entities." + type + ".custom", false);
|
||||
spawnerConfig.addDefault("Entities." + type + ".Spawn-Block", spawnBlock);
|
||||
spawnerConfig.addDefault("Entities." + type + ".Allowed", true);
|
||||
spawnerConfig.addDefault("Entities." + type + ".Spawn-On-Fire", false);
|
||||
@ -711,10 +713,6 @@ public class EpicSpawnersPlugin extends JavaPlugin implements EpicSpawners {
|
||||
return appearanceHandler;
|
||||
}
|
||||
|
||||
public SpawnerEditor getSpawnerEditor() {
|
||||
return spawnerEditor;
|
||||
}
|
||||
|
||||
public BlacklistHandler getBlacklistHandler() {
|
||||
return blacklistHandler;
|
||||
}
|
||||
@ -726,15 +724,6 @@ public class EpicSpawnersPlugin extends JavaPlugin implements EpicSpawners {
|
||||
public Heads getHeads() {
|
||||
return heads;
|
||||
}
|
||||
|
||||
public References getReferences() {
|
||||
return references;
|
||||
}
|
||||
|
||||
public ChatListeners getChatListeners() {
|
||||
return chatListeners;
|
||||
}
|
||||
|
||||
public HookManager getHookManager() {
|
||||
return hookManager;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.songoda.epicspawners.command.commands;
|
||||
|
||||
import com.songoda.epicspawners.EpicSpawnersPlugin;
|
||||
import com.songoda.epicspawners.command.AbstractCommand;
|
||||
import com.songoda.epicspawners.gui.GUIEditorSelector;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -15,7 +16,7 @@ public class CommandEditor extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(EpicSpawnersPlugin instance, CommandSender sender, String... args) {
|
||||
instance.getSpawnerEditor().openSpawnerSelector((Player) sender, 1);
|
||||
new GUIEditorSelector(instance, (Player)sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,268 @@
|
||||
package com.songoda.epicspawners.gui;
|
||||
|
||||
import com.songoda.epicspawners.EpicSpawnersPlugin;
|
||||
import com.songoda.epicspawners.References;
|
||||
import com.songoda.epicspawners.api.spawner.SpawnerData;
|
||||
import com.songoda.epicspawners.utils.AbstractChatConfirm;
|
||||
import com.songoda.epicspawners.utils.Debugger;
|
||||
import com.songoda.epicspawners.utils.Methods;
|
||||
import com.songoda.epicspawners.utils.gui.AbstractAnvilGUI;
|
||||
import com.songoda.epicspawners.utils.gui.AbstractGUI;
|
||||
import com.songoda.epicspawners.utils.gui.Range;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GUIEditorEdit extends AbstractGUI {
|
||||
|
||||
private final EpicSpawnersPlugin plugin;
|
||||
private final EditType editType;
|
||||
|
||||
private final AbstractGUI back;
|
||||
private SpawnerData spawnerData;
|
||||
|
||||
public GUIEditorEdit(EpicSpawnersPlugin plugin, AbstractGUI abstractGUI, SpawnerData spawnerData, EditType editType, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.back = abstractGUI;
|
||||
this.editType = editType;
|
||||
this.spawnerData = spawnerData;
|
||||
|
||||
init(Methods.compileName(spawnerData, 1, false) + "&8 " + editType.getName() + " &8Settings.", 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
int num = 0;
|
||||
while (num != 54) {
|
||||
inventory.setItem(num, Methods.getGlass());
|
||||
num++;
|
||||
}
|
||||
|
||||
num = 10;
|
||||
int spot = 0;
|
||||
while (num != 26) {
|
||||
if (num == 17)
|
||||
num = num + 2;
|
||||
|
||||
if (spawnerData.getEntityDroppedItems().size() >= spot + 1 && editType == EditType.DROPS) {
|
||||
inventory.setItem(num, spawnerData.getEntityDroppedItems().get(spot));
|
||||
} else if (spawnerData.getItems().size() >= spot + 1 && editType == EditType.ITEM) {
|
||||
inventory.setItem(num, spawnerData.getItems().get(spot));
|
||||
} else if (spawnerData.getBlocks().size() >= spot + 1 && editType == EditType.BLOCK) {
|
||||
inventory.setItem(num, new ItemStack(spawnerData.getBlocks().get(spot)));
|
||||
} else if (spawnerData.getEntities().size() >= spot + 1 && editType == EditType.ENTITY && spawnerData.getEntities().get(spot) != EntityType.GIANT) {
|
||||
ItemStack it = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
|
||||
ItemStack item = plugin.getHeads().addTexture(it,
|
||||
plugin.getSpawnerManager().getSpawnerData(spawnerData.getEntities().get(spot)));
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(Methods.formatText("&e" + Methods.getTypeFromString(spawnerData.getEntities().get(spot).name())));
|
||||
item.setItemMeta(meta);
|
||||
inventory.setItem(num, item);
|
||||
|
||||
} else if (spawnerData.getCommands().size() >= spot + 1 && editType == EditType.COMMAND) {
|
||||
ItemStack parseStack = new ItemStack(Material.PAPER, 1);
|
||||
ItemMeta meta = parseStack.getItemMeta();
|
||||
meta.setDisplayName(Methods.formatText("&a/" + spawnerData.getCommands().get(spot)));
|
||||
parseStack.setItemMeta(meta);
|
||||
inventory.setItem(num, parseStack);
|
||||
} else {
|
||||
inventory.setItem(num, new ItemStack(Material.AIR));
|
||||
}
|
||||
spot++;
|
||||
num++;
|
||||
}
|
||||
|
||||
inventory.setItem(1, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(7, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(8, Methods.getBackgroundGlass(true));
|
||||
|
||||
inventory.setItem(9, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(17, Methods.getBackgroundGlass(true));
|
||||
|
||||
inventory.setItem(36, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(37, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(38, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(42, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(43, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(44, Methods.getBackgroundGlass(false));
|
||||
|
||||
inventory.setItem(45, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(46, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(47, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(51, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(52, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(53, Methods.getBackgroundGlass(true));
|
||||
|
||||
createButton(0, Methods.addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3),
|
||||
"http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"),
|
||||
plugin.getLocale().getMessage("general.nametag.back"));
|
||||
|
||||
|
||||
if (editType != EditType.ITEM && editType != EditType.BLOCK && editType != EditType.DROPS) {
|
||||
ItemStack add;
|
||||
String addName;
|
||||
if (editType == EditType.COMMAND) {
|
||||
add = new ItemStack(Material.PAPER);
|
||||
addName = "&6Add Command";
|
||||
} else {
|
||||
add = new ItemStack(Material.SHEEP_SPAWN_EGG);
|
||||
addName = "&6Add entity";
|
||||
}
|
||||
|
||||
createButton(39, add, addName);
|
||||
}
|
||||
|
||||
createButton(editType != EditType.ITEM ? 41 : 49, Material.REDSTONE, "&aSave");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
addDraggable(new Range(10, 25, null, true), true);
|
||||
addDraggable(new Range(17, 17, null, true), false);
|
||||
addDraggable(new Range(27, 27, null, true), false);
|
||||
|
||||
registerClickable(editType != EditType.ITEM ? 41 : 49, ((player1, inventory1, cursor, slot, type) ->
|
||||
save(player, getItems(player))));
|
||||
|
||||
|
||||
if (editType == EditType.COMMAND) {
|
||||
registerClickable(39, (player, inventory, cursor, slot, type) -> {
|
||||
player.sendMessage(Methods.formatText("&7Please Type a command. Example: &6eco give @p 1000&7."));
|
||||
player.sendMessage(Methods.formatText("&7You can use @X @Y and @Z for random X Y and Z coordinates around the spawner."));
|
||||
player.sendMessage(Methods.formatText("&7@n will execute the command for the person who originally placed the spawner."));
|
||||
player.sendMessage(Methods.formatText("&7If you're getting command output try &6/gamerule sendCommandFeedback false&7."));
|
||||
player.sendMessage(Methods.formatText("&7do not include a &a/"));
|
||||
AbstractChatConfirm abstractChatConfirm = new AbstractChatConfirm(player, event -> {
|
||||
List<String> commands = new ArrayList<>(spawnerData.getCommands());
|
||||
commands.add(event.getMessage());
|
||||
spawnerData.setCommands(commands);
|
||||
constructGUI();
|
||||
});
|
||||
|
||||
abstractChatConfirm.setOnClose(() ->
|
||||
init(inventory.getTitle(), inventory.getSize()));
|
||||
});
|
||||
} else {
|
||||
registerClickable(39, (player, inventory, cursor, slot, type) -> {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
try {
|
||||
EntityType eType = EntityType.valueOf(event.getName().toUpperCase());
|
||||
List<EntityType> entities = new ArrayList<>(spawnerData.getEntities());
|
||||
entities.add(eType);
|
||||
spawnerData.setEntities(entities);
|
||||
constructGUI();
|
||||
} catch (Exception ex) {
|
||||
player.sendMessage("That is not a correct EntityType. Please try again..");
|
||||
}
|
||||
});
|
||||
|
||||
gui.setOnClose((player1, inventory1) -> init(inventory.getTitle(), inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Entity: Ex. IRON_GOLEM");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
});
|
||||
}
|
||||
|
||||
registerClickable(0, (player, inventory, cursor, slot, type) -> {
|
||||
back.init(back.getInventory().getTitle(), back.getInventory().getSize());
|
||||
back.constructGUI();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
|
||||
private List<ItemStack> getItems(Player p) {
|
||||
try {
|
||||
ItemStack[] items2 = p.getOpenInventory().getTopInventory().getContents();
|
||||
//items2 = Arrays.copyOf(items2, items2.length - 9);
|
||||
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
|
||||
int num = 0;
|
||||
for (ItemStack item : items2) {
|
||||
if (num >= 10 && num <= 25 && num != 17 && num != 18 && item != null) {
|
||||
items.add(items2[num]);
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return items;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void save(Player p, List<ItemStack> items) {
|
||||
try {
|
||||
if (editType == EditType.ITEM) {
|
||||
spawnerData.setItems(items);
|
||||
} else if (editType == EditType.DROPS) {
|
||||
spawnerData.setEntityDroppedItems(items);
|
||||
} else if (editType == EditType.BLOCK) {
|
||||
List<Material> list = new ArrayList<>();
|
||||
for (ItemStack item : items) {
|
||||
Material material = item.getType();
|
||||
list.add(material);
|
||||
}
|
||||
spawnerData.setBlocks(list);
|
||||
} else if (editType == EditType.ENTITY) {
|
||||
List<EntityType> list = new ArrayList<>();
|
||||
for (ItemStack item : items) {
|
||||
EntityType entityType = EntityType.valueOf(ChatColor.stripColor(item.getItemMeta().getDisplayName()).toUpperCase().replace(" ", "_"));
|
||||
list.add(entityType);
|
||||
}
|
||||
spawnerData.setEntities(list);
|
||||
} else if (editType == EditType.COMMAND) {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (ItemStack item : items) {
|
||||
String name = ChatColor.stripColor(item.getItemMeta().getDisplayName()).substring(1);
|
||||
list.add(name);
|
||||
}
|
||||
spawnerData.setCommands(list);
|
||||
}
|
||||
p.sendMessage(Methods.formatText(References.getPrefix() + "&7Spawner Saved."));
|
||||
spawnerData.reloadSpawnMethods();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public enum EditType {
|
||||
ENTITY("Entity"),
|
||||
ITEM("Item"),
|
||||
COMMAND("Command"),
|
||||
BLOCK("Block"),
|
||||
DROPS("Drops");
|
||||
|
||||
private final String name;
|
||||
|
||||
EditType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,287 @@
|
||||
package com.songoda.epicspawners.gui;
|
||||
|
||||
import com.songoda.epicspawners.EpicSpawnersPlugin;
|
||||
import com.songoda.epicspawners.api.spawner.SpawnerData;
|
||||
import com.songoda.epicspawners.utils.Methods;
|
||||
import com.songoda.epicspawners.utils.gui.AbstractAnvilGUI;
|
||||
import com.songoda.epicspawners.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class GUIEditorGeneral extends AbstractGUI {
|
||||
|
||||
private final EpicSpawnersPlugin plugin;
|
||||
private final AbstractGUI back;
|
||||
private SpawnerData spawnerData;
|
||||
|
||||
public GUIEditorGeneral(EpicSpawnersPlugin plugin, AbstractGUI abstractGUI, SpawnerData spawnerData, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.back = abstractGUI;
|
||||
this.spawnerData = spawnerData;
|
||||
|
||||
init(Methods.compileName(spawnerData, 1, false) + " &8Settings.", 45);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
int num = 0;
|
||||
while (num != 45) {
|
||||
inventory.setItem(num, Methods.getGlass());
|
||||
num++;
|
||||
}
|
||||
|
||||
createButton(0, Methods.addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3),
|
||||
"http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"),
|
||||
plugin.getLocale().getMessage("general.nametag.back"));
|
||||
|
||||
inventory.setItem(1, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(2, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(9, Methods.getBackgroundGlass(true));
|
||||
|
||||
inventory.setItem(6, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(7, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(8, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(17, Methods.getBackgroundGlass(true));
|
||||
|
||||
inventory.setItem(27, Methods.getBackgroundGlass(true));
|
||||
|
||||
inventory.setItem(35, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(36, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(37, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(38, Methods.getBackgroundGlass(false));
|
||||
|
||||
inventory.setItem(42, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(43, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(44, Methods.getBackgroundGlass(true));
|
||||
|
||||
createButton(19, Material.SUNFLOWER, "&6&lShop Price",
|
||||
"&7Currently: &a" + spawnerData.getShopPrice(),
|
||||
"&7This is the price of the",
|
||||
"&7spawner in the shop.");
|
||||
|
||||
createButton(20, Material.DIAMOND, "&6&lIn Shop",
|
||||
"&7Currently: &a" + spawnerData.isInShop(),
|
||||
"&7If this is true this spawner",
|
||||
"&7will show up in the shop GUI.");
|
||||
|
||||
createButton(22, Material.FIRE_CHARGE, "&c&lSpawn On Fire",
|
||||
"&7Currently: &a" + spawnerData.isSpawnOnFire(),
|
||||
"&7If this is true this spawner",
|
||||
"&7will spawn entities on fire.");
|
||||
|
||||
createButton(13, Material.HOPPER, "&5&lUpgradable",
|
||||
"&7Currently: &a" + spawnerData.isUpgradeable(),
|
||||
"&7Setting this to true will define",
|
||||
"&7upgradable.");
|
||||
|
||||
createButton(24, Material.SUNFLOWER, "&6&lCustom Economy cost",
|
||||
"&7Currently: &a" + spawnerData.getUpgradeCostEconomy(),
|
||||
"&7This is the custom economy cost",
|
||||
"&7to upgrade this spawner.");
|
||||
|
||||
createButton(25, Material.EXPERIENCE_BOTTLE, "&5&lCustom Experience cost",
|
||||
"&7Currently: &a" + spawnerData.getUpgradeCostExperience(),
|
||||
"&7This is the custom XP cost",
|
||||
"&7to upgrade this spawner.");
|
||||
|
||||
createButton(30, Material.EXPERIENCE_BOTTLE, "&5&lCustom Goal",
|
||||
"&7Currently: &a" + spawnerData.getKillGoal(),
|
||||
"&7If this is set to anything",
|
||||
"&7but 0 the default kill goal",
|
||||
"&7will be adjusted for this spawner.");
|
||||
|
||||
createButton(32, Material.DIAMOND, "&b&lPickup Cost",
|
||||
"&7Currently: &a" + spawnerData.getPickupCost(),
|
||||
"&7Setting this to anything but 0",
|
||||
"&7will allow you to charge players",
|
||||
"&7for breaking this type of spawner.");
|
||||
|
||||
createButton(40, Material.CLOCK, "&6&lTick Rate",
|
||||
"&7Currently: &a" + spawnerData.getTickRate(),
|
||||
"&7This is the default tick rate",
|
||||
"&7that your spawner will use",
|
||||
"&7to create its delay with.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(13, (player, inventory, cursor, slot, type) -> {
|
||||
if (spawnerData.isUpgradeable())
|
||||
spawnerData.setUpgradeable(false);
|
||||
else
|
||||
spawnerData.setUpgradeable(true);
|
||||
constructGUI();
|
||||
});
|
||||
|
||||
registerClickable(20, (player, inventory, cursor, slot, type) -> {
|
||||
if (spawnerData.isInShop())
|
||||
spawnerData.setInShop(false);
|
||||
else
|
||||
spawnerData.setInShop(true);
|
||||
constructGUI();
|
||||
});
|
||||
|
||||
registerClickable(22, (player, inventory, cursor, slot, type) -> {
|
||||
if (spawnerData.isSpawnOnFire())
|
||||
spawnerData.setSpawnOnFire(false);
|
||||
else
|
||||
spawnerData.setSpawnOnFire(true);
|
||||
constructGUI();
|
||||
});
|
||||
|
||||
registerClickable(19, (player, inventory, cursor, slot, type) -> {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
if (Methods.isNumeric(event.getName())) {
|
||||
spawnerData.setShopPrice(Double.parseDouble(event.getName()));
|
||||
} else {
|
||||
player.sendMessage(Methods.formatText("&CYou must enter a number."));
|
||||
}
|
||||
});
|
||||
|
||||
gui.setOnClose((player1, inventory1) -> init(inventory.getTitle(), inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Goal: Ex. 19.99");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
|
||||
player.sendMessage(Methods.formatText("&7Enter a sale price for &6" + Methods.getTypeFromString(spawnerData.getIdentifyingName()) + "&7."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &619.99&7."));
|
||||
});
|
||||
|
||||
registerClickable(24, (player, inventory, cursor, slot, type) -> {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
if (Methods.isNumeric(event.getName())) {
|
||||
spawnerData.setUpgradeCostEconomy(Double.parseDouble(event.getName()));
|
||||
} else {
|
||||
player.sendMessage(Methods.formatText("&CYou must enter a number."));
|
||||
}
|
||||
});
|
||||
|
||||
gui.setOnClose((player1, inventory1) -> init(inventory.getTitle(), inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Goal: Ex. 19.99");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
|
||||
player.sendMessage(Methods.formatText("&7Enter a custom eco cost for " + Methods.getTypeFromString(spawnerData.getIdentifyingName()) + "&7."));
|
||||
player.sendMessage(Methods.formatText("&7Use &60 &7to use the default cost."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &619.99&7."));
|
||||
});
|
||||
|
||||
registerClickable(25, (player, inventory, cursor, slot, type) -> {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
if (Methods.isInt(event.getName())) {
|
||||
spawnerData.setUpgradeCostExperience(Integer.parseInt(event.getName()));
|
||||
} else {
|
||||
player.sendMessage(Methods.formatText("&CYou must enter a number."));
|
||||
}
|
||||
});
|
||||
|
||||
gui.setOnClose((player1, inventory1) -> init(inventory.getTitle(), inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Goal: Ex. 25");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
|
||||
player.sendMessage(Methods.formatText("&7Enter a custom xp cost for " + Methods.getTypeFromString(spawnerData.getIdentifyingName()) + "&7."));
|
||||
player.sendMessage(Methods.formatText("&7Use &60 &7to use the default cost."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &625&7."));
|
||||
});
|
||||
|
||||
registerClickable(30, (player, inventory, cursor, slot, type) -> {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
if (Methods.isInt(event.getName())) {
|
||||
spawnerData.setKillGoal(Integer.parseInt(event.getName()));
|
||||
} else {
|
||||
player.sendMessage(Methods.formatText("&CYou must enter a number."));
|
||||
}
|
||||
});
|
||||
|
||||
gui.setOnClose((player1, inventory1) -> init(inventory.getTitle(), inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Goal: Ex. 5");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
|
||||
player.sendMessage(Methods.formatText("&7Enter a custom goal for " + Methods.getTypeFromString(spawnerData.getIdentifyingName()) + "&7."));
|
||||
player.sendMessage(Methods.formatText("&7Use &60 &7to use the default price."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &35&6."));
|
||||
});
|
||||
|
||||
registerClickable(32, (player, inventory, cursor, slot, type) -> {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
if (Methods.isNumeric(event.getName())) {
|
||||
spawnerData.setPickupCost(Double.parseDouble(event.getName()));
|
||||
} else {
|
||||
player.sendMessage(Methods.formatText("&CYou must enter a number."));
|
||||
}
|
||||
});
|
||||
|
||||
gui.setOnClose((player1, inventory1) -> init(inventory.getTitle(), inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Cost: Ex. 719.99");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
|
||||
player.sendMessage(Methods.formatText("&7Enter a pickup cost for " + Methods.getTypeFromString(spawnerData.getIdentifyingName()) + "&7."));
|
||||
player.sendMessage(Methods.formatText("&7Use &60 &7to disable."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &719.99&6."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &625&7."));
|
||||
});
|
||||
|
||||
registerClickable(40, (player, inventory, cursor, slot, type) -> {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event ->
|
||||
spawnerData.setTickRate(event.getName().trim()));
|
||||
|
||||
gui.setOnClose((player1, inventory1) -> init(inventory.getTitle(), inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Rate: Ex. 800:200");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
|
||||
player.sendMessage(Methods.formatText("&7Enter a tick rate min and max for " + Methods.getTypeFromString(spawnerData.getIdentifyingName()) + "&7."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &3800:200&6."));
|
||||
});
|
||||
|
||||
registerClickable(0, (player, inventory, cursor, slot, type) -> {
|
||||
back.init(back.getInventory().getTitle(), back.getInventory().getSize());
|
||||
back.constructGUI();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,232 @@
|
||||
package com.songoda.epicspawners.gui;
|
||||
|
||||
import com.songoda.epicspawners.EpicSpawnersPlugin;
|
||||
import com.songoda.epicspawners.References;
|
||||
import com.songoda.epicspawners.api.spawner.SpawnerData;
|
||||
import com.songoda.epicspawners.spawners.spawner.ESpawnerData;
|
||||
import com.songoda.epicspawners.utils.Methods;
|
||||
import com.songoda.epicspawners.utils.gui.AbstractAnvilGUI;
|
||||
import com.songoda.epicspawners.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GUIEditorOverview extends AbstractGUI {
|
||||
|
||||
private final EpicSpawnersPlugin plugin;
|
||||
private final AbstractGUI back;
|
||||
private SpawnerData spawnerData;
|
||||
|
||||
public GUIEditorOverview(EpicSpawnersPlugin plugin, AbstractGUI abstractGUI, SpawnerData spawnerData, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.back = abstractGUI;
|
||||
this.spawnerData = spawnerData;
|
||||
|
||||
if (spawnerData == null) {
|
||||
String type;
|
||||
for (int i = 1; true; i++) {
|
||||
String temp = "Custom " + i;
|
||||
if (!plugin.getSpawnerManager().isSpawnerData(temp)) {
|
||||
type = temp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.spawnerData = new ESpawnerData(0, type, new ArrayList<>(), new ArrayList<>(),
|
||||
new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
|
||||
((ESpawnerData) this.spawnerData).addDefaultConditions();
|
||||
this.spawnerData.setCustom(true);
|
||||
plugin.getSpawnerManager().addSpawnerData(type, this.spawnerData);
|
||||
}
|
||||
|
||||
init("&8Editing: " + Methods.compileName(this.spawnerData, 1, false) + "&8.", 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
int num = 0;
|
||||
while (num != 54) {
|
||||
inventory.setItem(num, Methods.getGlass());
|
||||
num++;
|
||||
}
|
||||
|
||||
inventory.setItem(0, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(1, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(2, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(3, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(4, Methods.getBackgroundGlass(true));
|
||||
|
||||
inventory.setItem(9, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(13, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(14, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(15, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(16, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(17, Methods.getBackgroundGlass(true));
|
||||
|
||||
inventory.setItem(18, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(22, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(26, Methods.getBackgroundGlass(true));
|
||||
|
||||
inventory.setItem(27, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(31, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(35, Methods.getBackgroundGlass(false));
|
||||
|
||||
inventory.setItem(36, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(37, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(38, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(39, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(40, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(44, Methods.getBackgroundGlass(false));
|
||||
|
||||
inventory.setItem(49, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(50, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(51, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(52, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(53, Methods.getBackgroundGlass(false));
|
||||
|
||||
createButton(8, Methods.addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3),
|
||||
"http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"),
|
||||
plugin.getLocale().getMessage("general.nametag.back"));
|
||||
|
||||
ItemStack it = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
|
||||
|
||||
ItemStack item = plugin.getHeads().addTexture(it, spawnerData);
|
||||
if (spawnerData.getDisplayItem() != null && spawnerData.getDisplayItem() != Material.AIR) {
|
||||
item.setType(spawnerData.getDisplayItem());
|
||||
}
|
||||
|
||||
ItemMeta itemmeta = item.getItemMeta();
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(Methods.formatText("&7Left-Click to &9Change Spawner Name&7."));
|
||||
lore.add(Methods.formatText("&7Right-Click to &bChange Spawner Display Item&7."));
|
||||
lore.add(Methods.formatText("&6-----------------------------"));
|
||||
|
||||
lore.add(Methods.formatText("&6Display Name: &7" + spawnerData.getDisplayName() + "&7."));
|
||||
if (spawnerData.getDisplayItem() != null) {
|
||||
lore.add(Methods.formatText("&6Display Item: &7" + spawnerData.getDisplayItem().name() + "&7."));
|
||||
} else {
|
||||
if (!spawnerData.isCustom()) {
|
||||
lore.add(Methods.formatText("&6Display Item: &7Unavailable&7."));
|
||||
} else {
|
||||
lore.add(Methods.formatText("&6Display Item: &7Dirt&7."));
|
||||
}
|
||||
}
|
||||
lore.add(Methods.formatText("&6Config Name: &7" + spawnerData.getIdentifyingName() + "&7."));
|
||||
itemmeta.setLore(lore);
|
||||
itemmeta.setDisplayName(Methods.compileName(spawnerData, 1, false));
|
||||
item.setItemMeta(itemmeta);
|
||||
inventory.setItem(11, item);
|
||||
|
||||
lore = new ArrayList<>();
|
||||
if (spawnerData.isCustom()) lore.add(Methods.formatText("&7Right-Click to: &cDestroy Spawner"));
|
||||
lore.add(Methods.formatText("&6---------------------------"));
|
||||
lore.add(Methods.formatText(spawnerData.isActive() ? "&6Currently:&a Enabled." : "&6Currently:&c Disabled."));
|
||||
|
||||
createButton(29, Material.TNT, "&7Left-Click to: &cDisable Spawner", lore);
|
||||
|
||||
createButton(23, Material.LEVER, "&9&lGeneral Settings");
|
||||
createButton(24, Material.BONE, "&e&lDrop Settings");
|
||||
|
||||
createButton(25, plugin.getHeads().addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3), plugin.getSpawnerManager().getSpawnerData("omni")), "&a&lEntity Settings");
|
||||
|
||||
createButton(41, Material.CHEST, "&5&lItem Settings");
|
||||
createButton(32, Material.GOLD_BLOCK, "&c&lBlock Settings");
|
||||
createButton(34, Material.FIREWORK_ROCKET, "&b&lParticle Settings");
|
||||
createButton(43, Material.PAPER, "&6&lCommand Settings");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
|
||||
registerClickable(29, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (type == ClickType.LEFT || !spawnerData.isCustom()) {
|
||||
if (spawnerData.isActive())
|
||||
spawnerData.setActive(false);
|
||||
else
|
||||
spawnerData.setActive(true);
|
||||
constructGUI();
|
||||
} else if (type == ClickType.RIGHT) {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
if (event.getName().equalsIgnoreCase("yes")) {
|
||||
player.sendMessage(Methods.formatText("&6" + spawnerData.getIdentifyingName() + " Spawner &7 has been destroyed successfully"));
|
||||
plugin.getSpawnerManager().removeSpawnerData(spawnerData.getIdentifyingName());
|
||||
}
|
||||
});
|
||||
|
||||
gui.setOnClose((player, inventory) -> {
|
||||
back.init(back.getInventory().getTitle(), back.getInventory().getSize());
|
||||
back.constructGUI();
|
||||
});
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Are you sure? (Yes/No)");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}
|
||||
}));
|
||||
|
||||
registerClickable(23, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIEditorGeneral(plugin, this, spawnerData, player)));
|
||||
|
||||
registerClickable(41, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIEditorEdit(plugin, this, spawnerData, GUIEditorEdit.EditType.ITEM, player)));
|
||||
|
||||
registerClickable(43, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIEditorEdit(plugin, this, spawnerData, GUIEditorEdit.EditType.COMMAND, player)));
|
||||
|
||||
registerClickable(24, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIEditorEdit(plugin, this, spawnerData, GUIEditorEdit.EditType.DROPS, player)));
|
||||
|
||||
registerClickable(25, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIEditorEdit(plugin, this, spawnerData, GUIEditorEdit.EditType.ENTITY, player)));
|
||||
|
||||
registerClickable(32, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIEditorEdit(plugin, this, spawnerData, GUIEditorEdit.EditType.BLOCK, player)));
|
||||
|
||||
registerClickable(34, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIEditorParticle(plugin, this, spawnerData, player)));
|
||||
|
||||
registerClickable(8, (player, inventory, cursor, slot, type) -> {
|
||||
back.init(back.getInventory().getTitle(), back.getInventory().getSize());
|
||||
back.constructGUI();
|
||||
});
|
||||
|
||||
registerClickable(11, (player, inventory, cursor, slot, type) -> {
|
||||
if (type == ClickType.RIGHT) {
|
||||
spawnerData.setDisplayItem(Material.valueOf(player.getInventory().getItemInHand().getType().toString()));
|
||||
player.sendMessage(Methods.formatText(References.getPrefix() + "&7Display Item for &6" + spawnerData.getIdentifyingName() + " &7set to &6" + player.getInventory().getItemInHand().getType().toString() + "&7."));
|
||||
constructGUI();
|
||||
} else if (type == ClickType.LEFT) {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event ->
|
||||
spawnerData.setDisplayName(event.getName()));
|
||||
|
||||
gui.setOnClose((player1, inventory1) -> init("&8Editing: " + Methods.compileName(spawnerData, 1, false) + "&8.", inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Enter a display name.");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
package com.songoda.epicspawners.gui;
|
||||
|
||||
import com.songoda.epicspawners.EpicSpawnersPlugin;
|
||||
import com.songoda.epicspawners.api.particles.ParticleDensity;
|
||||
import com.songoda.epicspawners.api.particles.ParticleEffect;
|
||||
import com.songoda.epicspawners.api.particles.ParticleType;
|
||||
import com.songoda.epicspawners.api.spawner.SpawnerData;
|
||||
import com.songoda.epicspawners.utils.Methods;
|
||||
import com.songoda.epicspawners.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class GUIEditorParticle extends AbstractGUI {
|
||||
|
||||
private final EpicSpawnersPlugin plugin;
|
||||
private final AbstractGUI back;
|
||||
private SpawnerData spawnerData;
|
||||
|
||||
public GUIEditorParticle(EpicSpawnersPlugin plugin, AbstractGUI abstractGUI, SpawnerData spawnerData, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.back = abstractGUI;
|
||||
this.spawnerData = spawnerData;
|
||||
|
||||
init(Methods.compileName(spawnerData, 1, false) + " &8Particle &8Settings.", 45);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
int num = 0;
|
||||
while (num != 45) {
|
||||
inventory.setItem(num, Methods.getGlass());
|
||||
num++;
|
||||
}
|
||||
|
||||
createButton(0, Methods.addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3),
|
||||
"http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"),
|
||||
plugin.getLocale().getMessage("general.nametag.back"));
|
||||
|
||||
inventory.setItem(1, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(2, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(9, Methods.getBackgroundGlass(true));
|
||||
|
||||
inventory.setItem(6, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(7, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(8, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(17, Methods.getBackgroundGlass(true));
|
||||
|
||||
inventory.setItem(27, Methods.getBackgroundGlass(true));
|
||||
|
||||
inventory.setItem(35, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(36, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(37, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(38, Methods.getBackgroundGlass(false));
|
||||
|
||||
inventory.setItem(42, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(43, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(44, Methods.getBackgroundGlass(true));
|
||||
|
||||
createButton(20, Material.ENDER_PEARL, "&5&lParticle Types",
|
||||
"&7Entity Spawn Particle: &a" + spawnerData.getEntitySpawnParticle().name(),
|
||||
"&cLeft-Click to change.",
|
||||
"&7Spawner Spawn Particle: &a" + spawnerData.getSpawnerSpawnParticle().name(),
|
||||
"&cMiddle-Click to change.",
|
||||
"&7Effect Particle: &a" + spawnerData.getSpawnEffectParticle().name(),
|
||||
"&cRight-Click to change.");
|
||||
|
||||
createButton(22, Material.FIREWORK_ROCKET, "&6&lSpawner Effect",
|
||||
"&7Particle Effect: &a" + spawnerData.getParticleEffect().name(),
|
||||
"&cLeft-Click to change.",
|
||||
"&7Particle Effect For Boosted Only: &a" + spawnerData.isParticleEffectBoostedOnly(),
|
||||
"&cRight-Click to change.");
|
||||
|
||||
createButton(24, Material.COMPARATOR, "&6&lPerformance",
|
||||
"&7Currently: &a" + spawnerData.getParticleDensity().name() + " &cClick to change.");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
|
||||
registerClickable(20, (player, inventory, cursor, slot, type) -> {
|
||||
ParticleType currentParticleType;
|
||||
if (type == ClickType.LEFT) {
|
||||
currentParticleType = spawnerData.getEntitySpawnParticle();
|
||||
} else if (type == ClickType.RIGHT) {
|
||||
currentParticleType = spawnerData.getSpawnEffectParticle();
|
||||
} else {
|
||||
currentParticleType = spawnerData.getSpawnerSpawnParticle();
|
||||
}
|
||||
|
||||
boolean next = false;
|
||||
for (ParticleType particleType : ParticleType.values()) {
|
||||
if (currentParticleType == particleType) {
|
||||
next = true;
|
||||
} else if (next) {
|
||||
currentParticleType = particleType;
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
if (next) {
|
||||
currentParticleType = ParticleType.values()[0];
|
||||
}
|
||||
|
||||
|
||||
if (type == ClickType.LEFT) {
|
||||
spawnerData.setEntitySpawnParticle(currentParticleType);
|
||||
} else if (type == ClickType.RIGHT) {
|
||||
spawnerData.setSpawnEffectParticle(currentParticleType);
|
||||
} else {
|
||||
spawnerData.setSpawnerSpawnParticle(currentParticleType);
|
||||
}
|
||||
|
||||
constructGUI();
|
||||
});
|
||||
|
||||
registerClickable(22, (player, inventory, cursor, slot, type) -> {
|
||||
ParticleEffect currentParticleEffect = spawnerData.getParticleEffect();
|
||||
|
||||
if (type == ClickType.LEFT) {
|
||||
boolean next = false;
|
||||
for (ParticleEffect particleEffect : ParticleEffect.values()) {
|
||||
if (currentParticleEffect == particleEffect) {
|
||||
next = true;
|
||||
} else if (next) {
|
||||
currentParticleEffect = particleEffect;
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
if (next) {
|
||||
currentParticleEffect = ParticleEffect.values()[0];
|
||||
}
|
||||
spawnerData.setParticleEffect(currentParticleEffect);
|
||||
} else if (type == ClickType.RIGHT) {
|
||||
if (!spawnerData.isParticleEffectBoostedOnly())
|
||||
spawnerData.setParticleEffectBoostedOnly(true);
|
||||
else
|
||||
spawnerData.setParticleEffectBoostedOnly(false);
|
||||
}
|
||||
|
||||
constructGUI();
|
||||
});
|
||||
|
||||
|
||||
registerClickable(24, (player, inventory, cursor, slot, type) -> {
|
||||
ParticleDensity currentParticleDensity = spawnerData.getParticleDensity();
|
||||
|
||||
boolean next = false;
|
||||
for (ParticleDensity particleDensity : ParticleDensity.values()) {
|
||||
if (currentParticleDensity == particleDensity) {
|
||||
next = true;
|
||||
} else if (next) {
|
||||
currentParticleDensity = particleDensity;
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
if (next) {
|
||||
currentParticleDensity = ParticleDensity.values()[0];
|
||||
}
|
||||
spawnerData.setParticleDensity(currentParticleDensity);
|
||||
|
||||
constructGUI();
|
||||
});
|
||||
|
||||
registerClickable(0, (player, inventory, cursor, slot, type) -> {
|
||||
back.init(back.getInventory().getTitle(), back.getInventory().getSize());
|
||||
back.constructGUI();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,167 @@
|
||||
package com.songoda.epicspawners.gui;
|
||||
|
||||
import com.songoda.epicspawners.EpicSpawnersPlugin;
|
||||
import com.songoda.epicspawners.api.spawner.SpawnerData;
|
||||
import com.songoda.epicspawners.utils.Methods;
|
||||
import com.songoda.epicspawners.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GUIEditorSelector extends AbstractGUI {
|
||||
|
||||
private final EpicSpawnersPlugin plugin;
|
||||
private List<SpawnerData> entities;
|
||||
private int page = 1;
|
||||
private int max = 0;
|
||||
private int totalAmount = 0;
|
||||
private int slots = 0;
|
||||
|
||||
public GUIEditorSelector(EpicSpawnersPlugin plugin, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
setUp();
|
||||
}
|
||||
|
||||
private void setUp() {
|
||||
int show = 0;
|
||||
int start = (page - 1) * 32;
|
||||
entities = new ArrayList<>();
|
||||
totalAmount = 0;
|
||||
for (SpawnerData spawnerData : plugin.getSpawnerManager().getAllSpawnerData()) {
|
||||
if (totalAmount >= start && !spawnerData.getIdentifyingName().equalsIgnoreCase("omni")) {
|
||||
if (show <= 31) {
|
||||
entities.add(spawnerData);
|
||||
show++;
|
||||
}
|
||||
}
|
||||
totalAmount++;
|
||||
}
|
||||
|
||||
int size = entities.size();
|
||||
if (size == 24 || size == 25) size = 26;
|
||||
slots = 54;
|
||||
if (size <= 7) {
|
||||
slots = 27;
|
||||
} else if (size <= 15) {
|
||||
slots = 36;
|
||||
} else if (size <= 25) {
|
||||
slots = 45;
|
||||
}
|
||||
|
||||
init("Spawner Editor", slots);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
max = (int) Math.ceil((double) totalAmount / (double) 32);
|
||||
|
||||
createButton(8, Material.OAK_DOOR, plugin.getLocale().getMessage("general.nametag.exit"));
|
||||
|
||||
int place = 10;
|
||||
|
||||
for (SpawnerData spawnerData : entities) {
|
||||
if (place == 17 || place == (slots - 18)) place++;
|
||||
|
||||
ItemStack icon = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
|
||||
ItemStack item = plugin.getHeads().addTexture(icon, spawnerData);
|
||||
if (spawnerData.getDisplayItem() != null && spawnerData.getDisplayItem() != Material.AIR) {
|
||||
item.setType(spawnerData.getDisplayItem());
|
||||
}
|
||||
|
||||
String name = Methods.compileName(spawnerData, 1, false);
|
||||
|
||||
createButton(place, icon, Methods.convertToInvisibleString(spawnerData.getIdentifyingName() + ":") + name,
|
||||
"&7Click to &a&lEdit&7.");
|
||||
|
||||
registerClickable(place, ((player1, inventory1, cursor, slot, type) -> {
|
||||
new GUIEditorOverview(plugin, this, spawnerData, player);
|
||||
|
||||
}));
|
||||
|
||||
place++;
|
||||
}
|
||||
|
||||
ItemStack glass = Methods.getGlass();
|
||||
for (int i = 0; i < 8; i++) {
|
||||
inventory.setItem(i, glass);
|
||||
}
|
||||
|
||||
for (int i = slots - 9; i < slots; i++) {
|
||||
inventory.setItem(i, glass);
|
||||
}
|
||||
|
||||
ItemStack glassType2 = Methods.getBackgroundGlass(true), glassType3 = Methods.getBackgroundGlass(false);
|
||||
inventory.setItem(0, glassType2);
|
||||
inventory.setItem(1, glassType2);
|
||||
inventory.setItem(9, glassType2);
|
||||
|
||||
inventory.setItem(7, glassType2);
|
||||
inventory.setItem(17, glassType2);
|
||||
|
||||
inventory.setItem(slots - 18, glassType2);
|
||||
inventory.setItem(slots - 9, glassType2);
|
||||
inventory.setItem(slots - 8, glassType2);
|
||||
|
||||
inventory.setItem(slots - 10, glassType2);
|
||||
inventory.setItem(slots - 2, glassType2);
|
||||
inventory.setItem(slots - 1, glassType2);
|
||||
|
||||
inventory.setItem(2, glassType3);
|
||||
inventory.setItem(6, glassType3);
|
||||
inventory.setItem(slots - 7, glassType3);
|
||||
inventory.setItem(slots - 3, glassType3);
|
||||
|
||||
if (page != 1) {
|
||||
createButton(slots - 8, Methods.addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3),
|
||||
"http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"),
|
||||
plugin.getLocale().getMessage("general.nametag.back"));
|
||||
}
|
||||
|
||||
if (page != max) {
|
||||
createButton(slots - 2, Methods.addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3),
|
||||
"http://textures.minecraft.net/texture/1b6f1a25b6bc199946472aedb370522584ff6f4e83221e5946bd2e41b5ca13b"),
|
||||
plugin.getLocale().getMessage("general.nametag.next"));
|
||||
}
|
||||
|
||||
|
||||
createButton(slots - 4, Material.PAPER, "&9&lNew Spawner");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, (player, inventory, cursor, slot, type) -> player.closeInventory());
|
||||
|
||||
registerClickable(slots - 4, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIEditorOverview(plugin, this, null, player)));
|
||||
|
||||
registerClickable(slots - 8, (player, inventory, cursor, slot, type) -> {
|
||||
if (page == 1) return;
|
||||
page--;
|
||||
setUp();
|
||||
constructGUI();
|
||||
});
|
||||
|
||||
registerClickable(slots - 2, (player, inventory, cursor, slot, type) -> {
|
||||
if (page == max) return;
|
||||
page++;
|
||||
setUp();
|
||||
constructGUI();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ public class GUIShopItem extends AbstractGUI {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
public void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
@ -48,7 +48,7 @@ public class GUISpawnerBoost extends AbstractGUI {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
public void constructGUI() {
|
||||
if (!player.hasPermission("epicspawners.canboost")) return;
|
||||
|
||||
int num = 0;
|
||||
|
@ -69,7 +69,7 @@ public class GUISpawnerConvert extends AbstractGUI {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
public void constructGUI() {
|
||||
inventory.clear();
|
||||
max = (int) Math.ceil((double) totalAmount / (double) 32);
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class GUISpawnerOverview extends AbstractGUI {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
public void constructGUI() {
|
||||
int showAmt = spawner.getSpawnerDataCount();
|
||||
if (showAmt > 64)
|
||||
showAmt = 1;
|
||||
|
@ -64,7 +64,7 @@ public class GUISpawnerShop extends AbstractGUI {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
public void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
@ -43,7 +43,7 @@ public class GUISpawnerStats extends AbstractGUI {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
public void constructGUI() {
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
inventory.setItem(i, Methods.getGlass());
|
||||
|
@ -1,127 +0,0 @@
|
||||
package com.songoda.epicspawners.listeners;
|
||||
|
||||
import com.songoda.epicspawners.EpicSpawnersPlugin;
|
||||
import com.songoda.epicspawners.References;
|
||||
import com.songoda.epicspawners.api.spawner.SpawnerData;
|
||||
import com.songoda.epicspawners.spawners.editor.EditingMenu;
|
||||
import com.songoda.epicspawners.utils.Debugger;
|
||||
import com.songoda.epicspawners.utils.Methods;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/25/2017.
|
||||
*/
|
||||
public class ChatListeners implements Listener {
|
||||
|
||||
private HashMap<UUID, EditingType> inEditor = new HashMap<>();
|
||||
private EpicSpawnersPlugin instance;
|
||||
|
||||
public ChatListeners(EpicSpawnersPlugin instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void chatListeners(AsyncPlayerChatEvent e) {
|
||||
try {
|
||||
if (!inEditor.containsKey(e.getPlayer().getUniqueId())) return;
|
||||
|
||||
Player player = e.getPlayer();
|
||||
|
||||
switch (inEditor.get(player.getUniqueId())) {
|
||||
case DESTROY:
|
||||
instance.getSpawnerEditor().destroyFinal(player, e.getMessage());
|
||||
break;
|
||||
case NAME:
|
||||
instance.getSpawnerEditor().saveSpawnerName(player, e.getMessage());
|
||||
break;
|
||||
case ADD_ENTITY:
|
||||
try {
|
||||
EntityType.valueOf(e.getMessage().toUpperCase());
|
||||
instance.getSpawnerEditor().addEntity(player, e.getMessage().toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
player.sendMessage("That is not a correct EntityType. Please try again..");
|
||||
}
|
||||
break;
|
||||
case SHOP_PRICE:
|
||||
SpawnerData spawnerData = instance.getSpawnerEditor().getEditingData(player).getSpawnerEditing();
|
||||
if (Methods.isInt(e.getMessage())) {
|
||||
spawnerData.setShopPrice(Double.parseDouble(e.getMessage()));
|
||||
} else {
|
||||
player.sendMessage(Methods.formatText("&CYou must enter a number."));
|
||||
}
|
||||
instance.getSpawnerEditor().basicSettings(player);
|
||||
break;
|
||||
case TICK_RATE:
|
||||
instance.getSpawnerEditor().getEditingData(player).getSpawnerEditing().setTickRate(e.getMessage().trim());
|
||||
instance.getSpawnerEditor().basicSettings(player);
|
||||
break;
|
||||
case CUSTOM_ECO_COST:
|
||||
if (Methods.isInt(e.getMessage())) {
|
||||
instance.getSpawnerEditor().getEditingData(player).getSpawnerEditing().setUpgradeCostEconomy(Double.parseDouble(e.getMessage()));
|
||||
} else {
|
||||
player.sendMessage(Methods.formatText("&CYou must enter a number."));
|
||||
}
|
||||
instance.getSpawnerEditor().basicSettings(player);
|
||||
break;
|
||||
case CUSTOM_XP_COST:
|
||||
if (Methods.isInt(e.getMessage())) {
|
||||
instance.getSpawnerEditor().getEditingData(player).getSpawnerEditing().setUpgradeCostExperience(Integer.parseInt(e.getMessage()));
|
||||
} else {
|
||||
player.sendMessage(Methods.formatText("&CYou must enter a number."));
|
||||
}
|
||||
instance.getSpawnerEditor().basicSettings(player);
|
||||
break;
|
||||
case COMMAND:
|
||||
String msg = e.getMessage();
|
||||
player.sendMessage(Methods.formatText(References.getPrefix() + "&8Command &5" + msg + "&8 saved to your inventory."));
|
||||
instance.getSpawnerEditor().addCommand(player, e.getMessage());
|
||||
break;
|
||||
case CUSTOM_GOAL:
|
||||
if (Methods.isInt(e.getMessage())) {
|
||||
instance.getSpawnerEditor().getEditingData(player).getSpawnerEditing().setKillGoal(Integer.parseInt(e.getMessage()));
|
||||
} else {
|
||||
player.sendMessage(Methods.formatText("&CYou must enter a number."));
|
||||
}
|
||||
instance.getSpawnerEditor().basicSettings(player);
|
||||
break;
|
||||
case PICKUP_COST:
|
||||
if (Methods.isInt(e.getMessage())) {
|
||||
instance.getSpawnerEditor().getEditingData(player).getSpawnerEditing().setPickupCost(Double.parseDouble(e.getMessage()));
|
||||
} else {
|
||||
player.sendMessage(Methods.formatText("&CYou must enter a number."));
|
||||
}
|
||||
instance.getSpawnerEditor().basicSettings(player);
|
||||
break;
|
||||
case SPAWN_LIMIT:
|
||||
//SpawnerData spawnerData = instance.getSpawnerEditor().getType(instance.getSpawnerEditor().getEditingData(player).getSpawnerSlot());
|
||||
if (Methods.isInt(e.getMessage())) { //ToDo: Make this work.
|
||||
//instance.spawnerFile.getConfig().set("Entities." + Methods.getTypeFromString(instance.getSpawnerEditor().getType(instance.editing.get(player))) + ".commandSpawnLimit", Double.parseDouble(e.getMessage()));
|
||||
instance.getSpawnerEditor().editor(player, EditingMenu.COMMAND);
|
||||
} else {
|
||||
player.sendMessage(Methods.formatText("&CYou must enter a number."));
|
||||
}
|
||||
instance.getSpawnerEditor().basicSettings(player);
|
||||
break;
|
||||
}
|
||||
inEditor.remove(player.getUniqueId());
|
||||
e.setCancelled(true);
|
||||
|
||||
|
||||
} catch (Exception ex) {
|
||||
Debugger.runReport(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void addToEditor(Player player, EditingType type) {
|
||||
inEditor.put(player.getUniqueId(), type);
|
||||
}
|
||||
|
||||
public enum EditingType {DESTROY, NAME, ADD_ENTITY, SHOP_PRICE, TICK_RATE, CUSTOM_ECO_COST, CUSTOM_XP_COST, COMMAND, CUSTOM_GOAL, PICKUP_COST, SPAWN_LIMIT}
|
||||
}
|
@ -1,21 +1,12 @@
|
||||
package com.songoda.epicspawners.listeners;
|
||||
|
||||
import com.songoda.epicspawners.EpicSpawnersPlugin;
|
||||
import com.songoda.epicspawners.References;
|
||||
import com.songoda.epicspawners.api.particles.ParticleDensity;
|
||||
import com.songoda.epicspawners.api.particles.ParticleEffect;
|
||||
import com.songoda.epicspawners.api.particles.ParticleType;
|
||||
import com.songoda.epicspawners.api.spawner.SpawnerData;
|
||||
import com.songoda.epicspawners.gui.GUISpawnerShop;
|
||||
import com.songoda.epicspawners.player.MenuType;
|
||||
import com.songoda.epicspawners.player.PlayerData;
|
||||
import com.songoda.epicspawners.spawners.editor.EditingData;
|
||||
import com.songoda.epicspawners.spawners.editor.EditingMenu;
|
||||
import com.songoda.epicspawners.utils.Debugger;
|
||||
import com.songoda.epicspawners.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -41,219 +32,7 @@ public class InventoryListeners implements Listener {
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
try {
|
||||
if (event.getInventory() == null || event.getCurrentItem() == null) return;
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
PlayerData playerData = instance.getPlayerActionManager().getPlayerAction(player);
|
||||
|
||||
if (instance.getSpawnerEditor().getEditingData(player).getMenu() != EditingMenu.NOT_IN) {
|
||||
|
||||
if (event.getRawSlot() >= event.getView().getTopInventory().getSize()) return;
|
||||
|
||||
EditingData editingData = instance.getSpawnerEditor().getEditingData(player);
|
||||
EditingMenu editingMenu = editingData.getMenu();
|
||||
if (editingMenu == EditingMenu.OVERVIEW) {
|
||||
event.setCancelled(true);
|
||||
if (event.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("general.nametag.back")))
|
||||
instance.getSpawnerEditor().openSpawnerSelector(player, playerData.getCurrentPage());
|
||||
else if (event.getSlot() == 11) {
|
||||
if (!event.getClick().isLeftClick() && !event.getClick().isRightClick()) {
|
||||
SpawnerData spawnerData = editingData.getSpawnerEditing();
|
||||
spawnerData.setDisplayItem(Material.valueOf(player.getInventory().getItemInHand().getType().toString()));
|
||||
player.sendMessage(Methods.formatText(References.getPrefix() + "&7Display Item for &6" + spawnerData.getIdentifyingName() + " &7set to &6" + player.getInventory().getItemInHand().getType().toString() + "&7."));
|
||||
instance.getSpawnerEditor().overview(player, editingData.getSpawnerEditing());
|
||||
} else if (event.getClick().isLeftClick()) {
|
||||
instance.getSpawnerEditor().editSpawnerName(player);
|
||||
}
|
||||
} else if (event.getSlot() == 24)
|
||||
instance.getSpawnerEditor().editor(player, EditingMenu.DROPS);
|
||||
else if (event.getSlot() == 25)
|
||||
instance.getSpawnerEditor().editor(player, EditingMenu.ENTITY);
|
||||
else if (event.getSlot() == 32)
|
||||
instance.getSpawnerEditor().editor(player, EditingMenu.BLOCK);
|
||||
else if (event.getSlot() == 34)
|
||||
instance.getSpawnerEditor().particleEditor(player);
|
||||
else if (event.getSlot() == 29) {
|
||||
boolean right = event.isRightClick();
|
||||
for (final EntityType val : EntityType.values()) {
|
||||
if (val.isSpawnable() && val.isAlive()) {
|
||||
if (val.name().equals(Methods.restoreType(editingData.getSpawnerEditing().getIdentifyingName()))) {
|
||||
right = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!right) {
|
||||
SpawnerData spawnerData = editingData.getSpawnerEditing();
|
||||
if (spawnerData.isActive())
|
||||
spawnerData.setActive(false);
|
||||
else
|
||||
spawnerData.setActive(true);
|
||||
instance.getSpawnerEditor().overview(player, editingData.getSpawnerEditing());
|
||||
} else {
|
||||
instance.getSpawnerEditor().destroy(player);
|
||||
}
|
||||
} else if (event.getSlot() == 23) {
|
||||
instance.getSpawnerEditor().basicSettings(player);
|
||||
} else if (event.getSlot() == 41)
|
||||
instance.getSpawnerEditor().editor(player, EditingMenu.ITEM);
|
||||
else if (event.getSlot() == 43)
|
||||
instance.getSpawnerEditor().editor(player, EditingMenu.COMMAND);
|
||||
} else if (editingMenu == EditingMenu.PARTICLE) {
|
||||
SpawnerData spawnerData = editingData.getSpawnerEditing();
|
||||
event.setCancelled(true);
|
||||
|
||||
if (event.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("general.nametag.back")))
|
||||
instance.getSpawnerEditor().overview(player, editingData.getSpawnerEditing());
|
||||
else if (event.getSlot() == 20) {
|
||||
ParticleType currentParticleType;
|
||||
if (event.isLeftClick()) {
|
||||
currentParticleType = spawnerData.getEntitySpawnParticle();
|
||||
} else if (event.isRightClick()) {
|
||||
currentParticleType = spawnerData.getSpawnEffectParticle();
|
||||
} else {
|
||||
currentParticleType = spawnerData.getSpawnerSpawnParticle();
|
||||
}
|
||||
|
||||
boolean next = false;
|
||||
for (ParticleType particleType : ParticleType.values()) {
|
||||
if (currentParticleType == particleType) {
|
||||
next = true;
|
||||
} else if (next) {
|
||||
currentParticleType = particleType;
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
if (next) {
|
||||
currentParticleType = ParticleType.values()[0];
|
||||
}
|
||||
|
||||
|
||||
if (event.isLeftClick()) {
|
||||
spawnerData.setEntitySpawnParticle(currentParticleType);
|
||||
} else if (event.isRightClick()) {
|
||||
spawnerData.setSpawnEffectParticle(currentParticleType);
|
||||
} else {
|
||||
spawnerData.setSpawnerSpawnParticle(currentParticleType);
|
||||
}
|
||||
|
||||
instance.getSpawnerEditor().particleEditor(player);
|
||||
} else if (event.getSlot() == 22) {
|
||||
ParticleEffect currentParticleEffect = spawnerData.getParticleEffect();
|
||||
|
||||
if (event.isLeftClick()) {
|
||||
boolean next = false;
|
||||
for (ParticleEffect particleEffect : ParticleEffect.values()) {
|
||||
if (currentParticleEffect == particleEffect) {
|
||||
next = true;
|
||||
} else if (next) {
|
||||
currentParticleEffect = particleEffect;
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
if (next) {
|
||||
currentParticleEffect = ParticleEffect.values()[0];
|
||||
}
|
||||
spawnerData.setParticleEffect(currentParticleEffect);
|
||||
} else if (event.isRightClick()) {
|
||||
if (!spawnerData.isParticleEffectBoostedOnly())
|
||||
spawnerData.setParticleEffectBoostedOnly(true);
|
||||
else
|
||||
spawnerData.setParticleEffectBoostedOnly(false);
|
||||
}
|
||||
|
||||
instance.getSpawnerEditor().particleEditor(player);
|
||||
} else if (event.getSlot() == 24) {
|
||||
ParticleDensity currentParticleDensity = spawnerData.getParticleDensity();
|
||||
|
||||
boolean next = false;
|
||||
for (ParticleDensity particleDensity : ParticleDensity.values()) {
|
||||
if (currentParticleDensity == particleDensity) {
|
||||
next = true;
|
||||
} else if (next) {
|
||||
currentParticleDensity = particleDensity;
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
if (next) {
|
||||
currentParticleDensity = ParticleDensity.values()[0];
|
||||
}
|
||||
spawnerData.setParticleDensity(currentParticleDensity);
|
||||
|
||||
instance.getSpawnerEditor().particleEditor(player);
|
||||
}
|
||||
|
||||
} else if (editingMenu == EditingMenu.GENERAL) {
|
||||
if (event.getInventory().equals(player.getOpenInventory().getTopInventory())) {
|
||||
SpawnerData spawnerData = editingData.getSpawnerEditing();
|
||||
if (event.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("general.nametag.back")))
|
||||
instance.getSpawnerEditor().overview(player, editingData.getSpawnerEditing());
|
||||
else if (event.getSlot() == 13) {
|
||||
if (spawnerData.isUpgradeable())
|
||||
spawnerData.setUpgradeable(false);
|
||||
else
|
||||
spawnerData.setUpgradeable(true);
|
||||
instance.getSpawnerEditor().basicSettings(player);
|
||||
} else if (event.getSlot() == 19) {
|
||||
instance.getSpawnerEditor().alterSetting(player, ChatListeners.EditingType.SHOP_PRICE);
|
||||
} else if (event.getSlot() == 20) {
|
||||
if (spawnerData.isInShop())
|
||||
spawnerData.setInShop(false);
|
||||
else
|
||||
spawnerData.setInShop(true);
|
||||
instance.getSpawnerEditor().basicSettings(player);
|
||||
} else if (event.getSlot() == 22) {
|
||||
if (spawnerData.isSpawnOnFire())
|
||||
spawnerData.setSpawnOnFire(false);
|
||||
else
|
||||
spawnerData.setSpawnOnFire(true);
|
||||
instance.getSpawnerEditor().basicSettings(player);
|
||||
} else if (event.getSlot() == 24) {
|
||||
instance.getSpawnerEditor().alterSetting(player, ChatListeners.EditingType.CUSTOM_ECO_COST);
|
||||
} else if (event.getSlot() == 25) {
|
||||
instance.getSpawnerEditor().alterSetting(player, ChatListeners.EditingType.CUSTOM_XP_COST);
|
||||
} else if (event.getSlot() == 30) {
|
||||
instance.getSpawnerEditor().alterSetting(player, ChatListeners.EditingType.CUSTOM_GOAL);
|
||||
} else if (event.getSlot() == 32) {
|
||||
instance.getSpawnerEditor().alterSetting(player, ChatListeners.EditingType.PICKUP_COST);
|
||||
} else if (event.getSlot() == 40) {
|
||||
instance.getSpawnerEditor().alterSetting(player, ChatListeners.EditingType.TICK_RATE);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (editingMenu != EditingMenu.SPAWNER_SELECTOR) {
|
||||
if (event.getInventory().equals(player.getOpenInventory().getTopInventory())) {
|
||||
if ((event.getSlot() < 10 || event.getSlot() > 25) || event.getSlot() == 17 || event.getSlot() == 18) {
|
||||
event.setCancelled(true);
|
||||
if (event.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("general.nametag.back")))
|
||||
instance.getSpawnerEditor().overview(player, editingData.getSpawnerEditing());
|
||||
else if (event.getCurrentItem().getItemMeta().getDisplayName().equals(Methods.formatText("&6Add Command")))
|
||||
instance.getSpawnerEditor().createCommand(player);
|
||||
else if (event.getCurrentItem().getItemMeta().getDisplayName().equals(Methods.formatText("&6Add entity")))
|
||||
instance.getSpawnerEditor().addEntityInit(player);
|
||||
else if (event.getCurrentItem().getItemMeta().getDisplayName().equals(Methods.formatText("&aSave")))
|
||||
instance.getSpawnerEditor().save(player, instance.getSpawnerEditor().getItems(player));
|
||||
else if (event.getSlot() == 49)
|
||||
instance.getSpawnerEditor().editSpawnLimit(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (event.getInventory().getTitle().equals("Spawner Editor")) {
|
||||
event.setCancelled(true);
|
||||
int page = playerData.getCurrentPage();
|
||||
if (event.getSlot() == 8) {
|
||||
player.closeInventory();
|
||||
} else if (event.getCurrentItem().getItemMeta().getDisplayName().equals(Methods.formatText("&9&lNew Spawner"))) {
|
||||
instance.getSpawnerEditor().getEditingData(player).setNewId(instance.getSpawnerManager().getAllSpawnerData().size() - 1);
|
||||
instance.getSpawnerEditor().overview(player, null);
|
||||
} else if (event.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("general.nametag.back"))) {
|
||||
if (page != 1) {
|
||||
instance.getSpawnerEditor().openSpawnerSelector(player, page - 1);
|
||||
}
|
||||
} else if (event.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("general.nametag.next"))) {
|
||||
instance.getSpawnerEditor().openSpawnerSelector(player, page + 1);
|
||||
} else if (!event.getCurrentItem().getType().name().contains("GLASS_PANE")) {
|
||||
//if (e.getClick().isLeftClick())
|
||||
instance.getSpawnerEditor().overview(player, instance.getSpawnerEditor().getType(event.getCurrentItem().getItemMeta().getDisplayName()));
|
||||
}
|
||||
}
|
||||
if (event.getSlot() != 64537) {
|
||||
if (event.getInventory().getType() == InventoryType.ANVIL) {
|
||||
if (event.getAction() != InventoryAction.NOTHING) {
|
||||
@ -266,32 +45,8 @@ public class InventoryListeners implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
Debugger.runReport(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onClose(InventoryCloseEvent event) {
|
||||
try {
|
||||
final Player p = (Player) event.getPlayer();
|
||||
|
||||
PlayerData playerData = instance.getPlayerActionManager().getPlayerAction(p);
|
||||
|
||||
|
||||
if (playerData.getInMenu() == MenuType.SHOP) {
|
||||
Bukkit.getScheduler().runTaskLater(instance, () -> {
|
||||
if (!p.getOpenInventory().getTopInventory().getType().equals(InventoryType.CHEST))
|
||||
p.closeInventory();
|
||||
}, 1L);
|
||||
}
|
||||
|
||||
playerData.setInMenu(MenuType.NOT_IN);
|
||||
|
||||
instance.getSpawnerEditor().getEditingData(p).setMenu(EditingMenu.NOT_IN);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,23 +10,12 @@ public class PlayerData {
|
||||
|
||||
private final UUID playerUUID;
|
||||
|
||||
private MenuType inMenu = MenuType.NOT_IN;
|
||||
private Map<EntityType, Integer> entityKills = new EnumMap<>(EntityType.class);
|
||||
|
||||
private int currentPage = 0;
|
||||
|
||||
PlayerData(UUID playerUUID) {
|
||||
this.playerUUID = playerUUID;
|
||||
}
|
||||
|
||||
public MenuType getInMenu() {
|
||||
return inMenu;
|
||||
}
|
||||
|
||||
public void setInMenu(MenuType inMenu) {
|
||||
this.inMenu = inMenu;
|
||||
}
|
||||
|
||||
public OfflinePlayer getPlayer() {
|
||||
return Bukkit.getOfflinePlayer(playerUUID);
|
||||
}
|
||||
@ -48,14 +37,6 @@ public class PlayerData {
|
||||
this.entityKills = entityKills;
|
||||
}
|
||||
|
||||
public int getCurrentPage() {
|
||||
return currentPage;
|
||||
}
|
||||
|
||||
public void setCurrentPage(int currentPage) {
|
||||
this.currentPage = currentPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * (playerUUID == null ? 0 : playerUUID.hashCode());
|
||||
|
@ -1,44 +0,0 @@
|
||||
package com.songoda.epicspawners.spawners.editor;
|
||||
|
||||
import com.songoda.epicspawners.api.spawner.SpawnerData;
|
||||
|
||||
public class EditingData {
|
||||
|
||||
private EditingMenu menu = EditingMenu.NOT_IN;
|
||||
private int newId = -1;
|
||||
private SpawnerData spawnerEditing = null;
|
||||
|
||||
private String newSpawnerName = null;
|
||||
|
||||
public EditingMenu getMenu() {
|
||||
return menu;
|
||||
}
|
||||
|
||||
public void setMenu(EditingMenu menu) {
|
||||
this.menu = menu;
|
||||
}
|
||||
|
||||
public SpawnerData getSpawnerEditing() {
|
||||
return spawnerEditing;
|
||||
}
|
||||
|
||||
public void setSpawnerEditing(SpawnerData spawnerEditing) {
|
||||
this.spawnerEditing = spawnerEditing;
|
||||
}
|
||||
|
||||
public int getNewId() {
|
||||
return newId;
|
||||
}
|
||||
|
||||
public void setNewId(int newId) {
|
||||
this.newId = newId;
|
||||
}
|
||||
|
||||
public String getNewSpawnerName() {
|
||||
return newSpawnerName;
|
||||
}
|
||||
|
||||
public void setNewSpawnerName(String newSpawnerName) {
|
||||
this.newSpawnerName = newSpawnerName;
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.songoda.epicspawners.spawners.editor;
|
||||
|
||||
public enum EditingMenu {
|
||||
|
||||
NOT_IN,
|
||||
SPAWNER_SELECTOR,
|
||||
OVERVIEW,
|
||||
GENERAL,
|
||||
ENTITY, ITEM, COMMAND, BLOCK,
|
||||
DROPS, PARTICLE
|
||||
|
||||
}
|
@ -1,785 +0,0 @@
|
||||
package com.songoda.epicspawners.spawners.editor;
|
||||
|
||||
import com.songoda.epicspawners.EpicSpawnersPlugin;
|
||||
import com.songoda.epicspawners.References;
|
||||
import com.songoda.epicspawners.api.spawner.SpawnerData;
|
||||
import com.songoda.epicspawners.listeners.ChatListeners;
|
||||
import com.songoda.epicspawners.player.PlayerData;
|
||||
import com.songoda.epicspawners.spawners.spawner.ESpawnerData;
|
||||
import com.songoda.epicspawners.utils.Debugger;
|
||||
import com.songoda.epicspawners.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SpawnerEditor {
|
||||
|
||||
private final EpicSpawnersPlugin instance;
|
||||
|
||||
private final Map<UUID, EditingData> userEditingData = new HashMap<>();
|
||||
|
||||
public SpawnerEditor(EpicSpawnersPlugin instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public void openSpawnerSelector(Player player, int page) {
|
||||
try {
|
||||
this.userEditingData.remove(player.getUniqueId());
|
||||
EditingData editingData = new EditingData();
|
||||
editingData.setMenu(EditingMenu.SPAWNER_SELECTOR);
|
||||
editingData.setNewSpawnerName(null);
|
||||
|
||||
PlayerData playerData = instance.getPlayerActionManager().getPlayerAction(player);
|
||||
|
||||
playerData.setCurrentPage(page);
|
||||
|
||||
List<SpawnerData> entities = new ArrayList<>();
|
||||
|
||||
int num = 0, show = 0;
|
||||
int start = (page - 1) * 32;
|
||||
|
||||
for (SpawnerData spawnerData : instance.getSpawnerManager().getAllSpawnerData()) {
|
||||
if (num >= start && !spawnerData.getIdentifyingName().equalsIgnoreCase("omni")) {
|
||||
if (show <= 32) {
|
||||
entities.add(spawnerData);
|
||||
show++;
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
|
||||
int max = (int) Math.ceil((double) num / (double) 32);
|
||||
int amt = entities.size();
|
||||
if (amt == 24 || amt == 25) amt = 26;
|
||||
Inventory inventory = Bukkit.createInventory(null, 54, "Spawner Editor");
|
||||
int max2 = 54;
|
||||
if (amt <= 7) {
|
||||
inventory = Bukkit.createInventory(null, 27, "Spawner Editor");
|
||||
max2 = 27;
|
||||
} else if (amt <= 15) {
|
||||
inventory = Bukkit.createInventory(null, 36, "Spawner Editor");
|
||||
max2 = 36;
|
||||
} else if (amt <= 25) {
|
||||
inventory = Bukkit.createInventory(null, 45, "Spawner Editor");
|
||||
max2 = 45;
|
||||
}
|
||||
|
||||
inventory.setItem(8, Methods.createButton(Material.OAK_DOOR, instance.getLocale().getMessage("general.nametag.exit")));
|
||||
|
||||
ItemStack next = Methods.createButton(Methods.addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3), "http://textures.minecraft.net/texture/1b6f1a25b6bc199946472aedb370522584ff6f4e83221e5946bd2e41b5ca13b"), instance.getLocale().getMessage("general.nametag.next"));
|
||||
|
||||
ItemStack back = Methods.createButton(Methods.addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3), "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"), instance.getLocale().getMessage("general.nametag.back"));
|
||||
|
||||
|
||||
int max22 = max2;
|
||||
int place = 10;
|
||||
|
||||
for (SpawnerData spawnerData : entities) {
|
||||
if (place == 17 || place == (max22 - 18)) place++;
|
||||
|
||||
ItemStack icon = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
|
||||
ItemStack item = instance.getHeads().addTexture(icon, spawnerData);
|
||||
if (spawnerData.getDisplayItem() != null && spawnerData.getDisplayItem() != Material.AIR) {
|
||||
item.setType(spawnerData.getDisplayItem());
|
||||
}
|
||||
|
||||
String name = Methods.compileName(spawnerData, 1, false);
|
||||
inventory.setItem(place, Methods.createButton(icon, Methods.convertToInvisibleString(spawnerData.getIdentifyingName() + ":") + name,
|
||||
"&7Click to &a&lEdit&7."));
|
||||
|
||||
place++;
|
||||
}
|
||||
|
||||
ItemStack glass = Methods.getGlass();
|
||||
for (int i = 0; i < 8; i++) {
|
||||
inventory.setItem(i, glass);
|
||||
}
|
||||
|
||||
for (int i = max22 - 9; i < max22; i++) {
|
||||
inventory.setItem(i, glass);
|
||||
}
|
||||
|
||||
ItemStack glassType2 = Methods.getBackgroundGlass(true), glassType3 = Methods.getBackgroundGlass(false);
|
||||
inventory.setItem(0, glassType2);
|
||||
inventory.setItem(1, glassType2);
|
||||
inventory.setItem(9, glassType2);
|
||||
|
||||
inventory.setItem(7, glassType2);
|
||||
inventory.setItem(17, glassType2);
|
||||
|
||||
inventory.setItem(max22 - 18, glassType2);
|
||||
inventory.setItem(max22 - 9, glassType2);
|
||||
inventory.setItem(max22 - 8, glassType2);
|
||||
|
||||
inventory.setItem(max22 - 10, glassType2);
|
||||
inventory.setItem(max22 - 2, glassType2);
|
||||
inventory.setItem(max22 - 1, glassType2);
|
||||
|
||||
inventory.setItem(2, glassType3);
|
||||
inventory.setItem(6, glassType3);
|
||||
inventory.setItem(max22 - 7, glassType3);
|
||||
inventory.setItem(max22 - 3, glassType3);
|
||||
|
||||
if (page != 1) {
|
||||
inventory.setItem(max22 - 8, back);
|
||||
}
|
||||
|
||||
if (page != max) {
|
||||
inventory.setItem(max22 - 2, next);
|
||||
}
|
||||
|
||||
|
||||
inventory.setItem(max22 - 4, Methods.createButton(Material.PAPER, "&9&lNew Spawner"));
|
||||
|
||||
player.openInventory(inventory);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void overview(Player player, SpawnerData spawnerData) {
|
||||
try {
|
||||
EditingData editingData = getEditingData(player);
|
||||
|
||||
int csp = 1;
|
||||
for (SpawnerData spawnerData2 : instance.getSpawnerManager().getAllSpawnerData()) {
|
||||
if (spawnerData2.getIdentifyingName().toLowerCase().contains("custom"))
|
||||
csp++;
|
||||
}
|
||||
String type = "Custom " + (editingData.getNewSpawnerName() != null ? editingData.getNewSpawnerName() : csp);
|
||||
|
||||
if (spawnerData != null)
|
||||
type = spawnerData.getIdentifyingName();
|
||||
else
|
||||
editingData.setNewSpawnerName(type);
|
||||
|
||||
String name;
|
||||
|
||||
if (!instance.getSpawnerManager().isSpawnerData(type.toLowerCase())) {
|
||||
spawnerData = new ESpawnerData(0, type, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
|
||||
((ESpawnerData) spawnerData).addDefaultConditions();
|
||||
instance.getSpawnerManager().addSpawnerData(type, spawnerData);
|
||||
}
|
||||
spawnerData = instance.getSpawnerManager().getSpawnerData(type);
|
||||
|
||||
name = Methods.compileName(spawnerData, 1, false);
|
||||
Inventory i = Bukkit.createInventory(null, 54, Methods.formatText("&8Editing: " + name + "&8."));
|
||||
|
||||
int num = 0;
|
||||
while (num != 54) {
|
||||
i.setItem(num, Methods.getGlass());
|
||||
num++;
|
||||
}
|
||||
|
||||
i.setItem(0, Methods.getBackgroundGlass(false));
|
||||
i.setItem(1, Methods.getBackgroundGlass(false));
|
||||
i.setItem(2, Methods.getBackgroundGlass(false));
|
||||
i.setItem(3, Methods.getBackgroundGlass(true));
|
||||
i.setItem(4, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(9, Methods.getBackgroundGlass(false));
|
||||
i.setItem(13, Methods.getBackgroundGlass(true));
|
||||
i.setItem(14, Methods.getBackgroundGlass(false));
|
||||
i.setItem(15, Methods.getBackgroundGlass(true));
|
||||
i.setItem(16, Methods.getBackgroundGlass(true));
|
||||
i.setItem(17, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(18, Methods.getBackgroundGlass(false));
|
||||
i.setItem(22, Methods.getBackgroundGlass(false));
|
||||
i.setItem(26, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(27, Methods.getBackgroundGlass(true));
|
||||
i.setItem(31, Methods.getBackgroundGlass(false));
|
||||
i.setItem(35, Methods.getBackgroundGlass(false));
|
||||
|
||||
i.setItem(36, Methods.getBackgroundGlass(true));
|
||||
i.setItem(37, Methods.getBackgroundGlass(true));
|
||||
i.setItem(38, Methods.getBackgroundGlass(false));
|
||||
i.setItem(39, Methods.getBackgroundGlass(true));
|
||||
i.setItem(40, Methods.getBackgroundGlass(true));
|
||||
i.setItem(44, Methods.getBackgroundGlass(false));
|
||||
|
||||
i.setItem(49, Methods.getBackgroundGlass(true));
|
||||
i.setItem(50, Methods.getBackgroundGlass(true));
|
||||
i.setItem(51, Methods.getBackgroundGlass(false));
|
||||
i.setItem(52, Methods.getBackgroundGlass(false));
|
||||
i.setItem(53, Methods.getBackgroundGlass(false));
|
||||
|
||||
i.setItem(8, Methods.createButton(Methods.addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3), "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"), instance.getLocale().getMessage("general.nametag.back")));
|
||||
|
||||
ItemStack it = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
|
||||
|
||||
ItemStack item = instance.getHeads().addTexture(it, spawnerData);
|
||||
if (spawnerData.getDisplayItem() != null && spawnerData.getDisplayItem() != Material.AIR) {
|
||||
item.setType(spawnerData.getDisplayItem());
|
||||
}
|
||||
|
||||
ItemMeta itemmeta = item.getItemMeta();
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(Methods.formatText("&7Left-Click to &9Change Spawner Name&7."));
|
||||
lore.add(Methods.formatText("&7Middle-Click to &bChange Spawner Display Item&7."));
|
||||
if (instance.getConfig().getBoolean("settings.beta-features"))
|
||||
lore.add(Methods.formatText("&7Right-Click to &9Change Spawner Head&7."));
|
||||
lore.add(Methods.formatText("&6-----------------------------"));
|
||||
|
||||
lore.add(Methods.formatText("&6Display Name: &7" + spawnerData.getDisplayName() + "&7."));
|
||||
if (spawnerData.getDisplayItem() != null) {
|
||||
lore.add(Methods.formatText("&6Display Item: &7" + spawnerData.getDisplayItem().name() + "&7."));
|
||||
} else {
|
||||
if (!name.contains("Custom")) {
|
||||
lore.add(Methods.formatText("&6Display Item: &7Unavailable&7."));
|
||||
} else {
|
||||
lore.add(Methods.formatText("&6Display Item: &7Dirt&7."));
|
||||
}
|
||||
}
|
||||
lore.add(Methods.formatText("&6Config Name: &7" + type + "&7."));
|
||||
itemmeta.setLore(lore);
|
||||
itemmeta.setDisplayName(name);
|
||||
item.setItemMeta(itemmeta);
|
||||
i.setItem(11, item);
|
||||
|
||||
boolean dont = false;
|
||||
for (final EntityType val : EntityType.values()) {
|
||||
if (val.isSpawnable() && val.isAlive()) {
|
||||
if (val.name().equals(Methods.restoreType(type))) {
|
||||
dont = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lore = new ArrayList<>();
|
||||
if (!dont) lore.add(Methods.formatText("&7Right-Click to: &cDestroy Spawner"));
|
||||
lore.add(Methods.formatText("&6---------------------------"));
|
||||
lore.add(Methods.formatText(spawnerData.isActive() ? "&6Currently:&a Enabled." : "&6Currently:&c Disabled."));
|
||||
|
||||
i.setItem(29, Methods.createButton(Material.TNT, "&7Left-Click to: &cDisable Spawner", lore));
|
||||
|
||||
i.setItem(23, Methods.createButton(Material.LEVER, "&9&lGeneral Settings"));
|
||||
i.setItem(24, Methods.createButton(Material.BONE, "&e&lDrop Settings"));
|
||||
|
||||
i.setItem(25, Methods.createButton(instance.getHeads().addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3), instance.getSpawnerManager().getSpawnerData("omni")), "&a&lEntity Settings"));
|
||||
|
||||
i.setItem(41, Methods.createButton(Material.CHEST, "&5&lItem Settings"));
|
||||
i.setItem(32, Methods.createButton(Material.GOLD_BLOCK, "&c&lBlock Settings"));
|
||||
i.setItem(34, Methods.createButton(Material.FIREWORK_ROCKET, "&b&lParticle Settings"));
|
||||
i.setItem(43, Methods.createButton(Material.PAPER, "&6&lCommand Settings"));
|
||||
|
||||
player.openInventory(i);
|
||||
editingData.setMenu(EditingMenu.OVERVIEW);
|
||||
editingData.setSpawnerEditing(spawnerData);
|
||||
editingData.setNewId(-1);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public SpawnerData getType(String name) {
|
||||
SpawnerData type = instance.getSpawnerManager().getSpawnerData("pig");
|
||||
try {
|
||||
name = name.replace(String.valueOf(ChatColor.COLOR_CHAR), "").split(":")[0];
|
||||
return instance.getSpawnerManager().getSpawnerData(name);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public void particleEditor(Player player) {
|
||||
EditingData editingData = userEditingData.get(player.getUniqueId());
|
||||
SpawnerData spawnerData = editingData.getSpawnerEditing();
|
||||
|
||||
String name = Methods.compileName(spawnerData, 1, false);
|
||||
Inventory i = Bukkit.createInventory(null, 45, Methods.formatText(name + " &8Particle &8Settings."));
|
||||
|
||||
int num = 0;
|
||||
while (num != 45) {
|
||||
i.setItem(num, Methods.getGlass());
|
||||
num++;
|
||||
}
|
||||
|
||||
i.setItem(0, Methods.createButton(Methods.addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3), "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"), instance.getLocale().getMessage("general.nametag.back")));
|
||||
|
||||
i.setItem(1, Methods.getBackgroundGlass(true));
|
||||
i.setItem(2, Methods.getBackgroundGlass(false));
|
||||
i.setItem(9, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(6, Methods.getBackgroundGlass(false));
|
||||
i.setItem(7, Methods.getBackgroundGlass(true));
|
||||
i.setItem(8, Methods.getBackgroundGlass(true));
|
||||
i.setItem(17, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(27, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(35, Methods.getBackgroundGlass(true));
|
||||
i.setItem(36, Methods.getBackgroundGlass(true));
|
||||
i.setItem(37, Methods.getBackgroundGlass(true));
|
||||
i.setItem(38, Methods.getBackgroundGlass(false));
|
||||
|
||||
i.setItem(42, Methods.getBackgroundGlass(false));
|
||||
i.setItem(43, Methods.getBackgroundGlass(true));
|
||||
i.setItem(44, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(20, Methods.createButton(Material.ENDER_PEARL, "&5&lParticle Types",
|
||||
"&7Entity Spawn Particle: &a" + spawnerData.getEntitySpawnParticle().name(),
|
||||
"&cLeft-Click to change.",
|
||||
"&7Spawner Spawn Particle: &a" + spawnerData.getSpawnerSpawnParticle().name(),
|
||||
"&cMiddle-Click to change.",
|
||||
"&7Effect Particle: &a" + spawnerData.getSpawnEffectParticle().name(),
|
||||
"&cRight-Click to change."));
|
||||
|
||||
i.setItem(22, Methods.createButton(Material.FIREWORK_ROCKET, "&6&lSpawner Effect",
|
||||
"&7Particle Effect: &a" + spawnerData.getParticleEffect().name(),
|
||||
"&cLeft-Click to change.",
|
||||
"&7Particle Effect For Boosted Only: &a" + spawnerData.isParticleEffectBoostedOnly(),
|
||||
"&cRight-Click to change."));
|
||||
|
||||
i.setItem(24, Methods.createButton(Material.COMPARATOR, "&6&lPerformance",
|
||||
"&7Currently: &a" + spawnerData.getParticleDensity().name() + " &cClick to change."));
|
||||
|
||||
player.openInventory(i);
|
||||
editingData.setMenu(EditingMenu.PARTICLE);
|
||||
}
|
||||
|
||||
public void editor(Player player, EditingMenu editingMenu) {
|
||||
try {
|
||||
EditingData editingData = userEditingData.get(player.getUniqueId());
|
||||
SpawnerData spawnerData = editingData.getSpawnerEditing();
|
||||
|
||||
String name = Methods.compileName(spawnerData, 1, false);
|
||||
Inventory i = Bukkit.createInventory(null, 54, Methods.formatText(name + "&8 " + editingMenu + " &8Settings."));
|
||||
|
||||
int num = 0;
|
||||
while (num != 54) {
|
||||
i.setItem(num, Methods.getGlass());
|
||||
num++;
|
||||
}
|
||||
|
||||
num = 10;
|
||||
int spot = 0;
|
||||
while (num != 26) {
|
||||
if (num == 17)
|
||||
num = num + 2;
|
||||
|
||||
if (spawnerData.getEntityDroppedItems().size() >= spot + 1 && editingMenu == EditingMenu.DROPS) {
|
||||
i.setItem(num, spawnerData.getEntityDroppedItems().get(spot));
|
||||
} else if (spawnerData.getItems().size() >= spot + 1 && editingMenu == EditingMenu.ITEM) {
|
||||
i.setItem(num, spawnerData.getItems().get(spot));
|
||||
} else if (spawnerData.getBlocks().size() >= spot + 1 && editingMenu == EditingMenu.BLOCK) {
|
||||
i.setItem(num, new ItemStack(spawnerData.getBlocks().get(spot)));
|
||||
} else if (spawnerData.getEntities().size() >= spot + 1 && editingMenu == EditingMenu.ENTITY && spawnerData.getEntities().get(spot) != EntityType.GIANT) {
|
||||
ItemStack it = new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3);
|
||||
ItemStack item = instance.getHeads().addTexture(it,
|
||||
instance.getSpawnerManager().getSpawnerData(spawnerData.getEntities().get(spot)));
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(Methods.formatText("&e" + Methods.getTypeFromString(spawnerData.getEntities().get(spot).name())));
|
||||
item.setItemMeta(meta);
|
||||
i.setItem(num, item);
|
||||
|
||||
} else if (spawnerData.getCommands().size() >= spot + 1 && editingMenu == EditingMenu.COMMAND) {
|
||||
ItemStack parseStack = new ItemStack(Material.PAPER, 1);
|
||||
ItemMeta meta = parseStack.getItemMeta();
|
||||
meta.setDisplayName(Methods.formatText("&a/" + spawnerData.getCommands().get(spot)));
|
||||
parseStack.setItemMeta(meta);
|
||||
i.setItem(num, parseStack);
|
||||
} else {
|
||||
i.setItem(num, new ItemStack(Material.AIR));
|
||||
}
|
||||
spot++;
|
||||
num++;
|
||||
}
|
||||
|
||||
i.setItem(1, Methods.getBackgroundGlass(true));
|
||||
i.setItem(7, Methods.getBackgroundGlass(true));
|
||||
i.setItem(8, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(9, Methods.getBackgroundGlass(true));
|
||||
i.setItem(17, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(36, Methods.getBackgroundGlass(false));
|
||||
i.setItem(37, Methods.getBackgroundGlass(false));
|
||||
i.setItem(38, Methods.getBackgroundGlass(false));
|
||||
i.setItem(42, Methods.getBackgroundGlass(false));
|
||||
i.setItem(43, Methods.getBackgroundGlass(false));
|
||||
i.setItem(44, Methods.getBackgroundGlass(false));
|
||||
|
||||
i.setItem(45, Methods.getBackgroundGlass(true));
|
||||
i.setItem(46, Methods.getBackgroundGlass(true));
|
||||
i.setItem(47, Methods.getBackgroundGlass(false));
|
||||
i.setItem(51, Methods.getBackgroundGlass(false));
|
||||
i.setItem(52, Methods.getBackgroundGlass(true));
|
||||
i.setItem(53, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(0, Methods.createButton(Methods.addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3), "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"), instance.getLocale().getMessage("general.nametag.back")));
|
||||
|
||||
if (editingMenu == EditingMenu.COMMAND) {
|
||||
i.setItem(49, Methods.createButton(Material.CLOCK, "&bSpawn Limit",
|
||||
"",
|
||||
"&7This is the spawn limit for entities you spawn",
|
||||
"&7from this spawner. Set to &60 &7to disable this."));
|
||||
}
|
||||
|
||||
if (editingMenu != EditingMenu.ITEM && editingMenu != EditingMenu.BLOCK && editingMenu != EditingMenu.DROPS) {
|
||||
ItemStack add;
|
||||
String addName;
|
||||
if (editingMenu == EditingMenu.COMMAND) {
|
||||
add = new ItemStack(Material.PAPER);
|
||||
addName = "&6Add Command";
|
||||
} else {
|
||||
add = new ItemStack(Material.SHEEP_SPAWN_EGG);
|
||||
addName = "&6Add entity";
|
||||
}
|
||||
|
||||
i.setItem(39, Methods.createButton(add, addName));
|
||||
}
|
||||
|
||||
i.setItem(editingMenu != EditingMenu.ITEM ? 41 : 49, Methods.createButton(Material.REDSTONE, "&aSave"));
|
||||
|
||||
player.openInventory(i);
|
||||
editingData.setMenu(editingMenu);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void basicSettings(Player player) {
|
||||
try {
|
||||
EditingData editingData = userEditingData.get(player.getUniqueId());
|
||||
SpawnerData spawnerData = editingData.getSpawnerEditing();
|
||||
String name = Methods.compileName(spawnerData, 1, false);
|
||||
Inventory i = Bukkit.createInventory(null, 45, Methods.formatText(name + " &8Settings."));
|
||||
int num = 0;
|
||||
while (num != 45) {
|
||||
i.setItem(num, Methods.getGlass());
|
||||
num++;
|
||||
}
|
||||
|
||||
i.setItem(0, Methods.createButton(Methods.addTexture(new ItemStack(Material.PLAYER_HEAD, 1, (byte) 3), "http://textures.minecraft.net/texture/3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"), instance.getLocale().getMessage("general.nametag.back")));
|
||||
|
||||
i.setItem(1, Methods.getBackgroundGlass(true));
|
||||
i.setItem(2, Methods.getBackgroundGlass(false));
|
||||
i.setItem(9, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(6, Methods.getBackgroundGlass(false));
|
||||
i.setItem(7, Methods.getBackgroundGlass(true));
|
||||
i.setItem(8, Methods.getBackgroundGlass(true));
|
||||
i.setItem(17, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(27, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(35, Methods.getBackgroundGlass(true));
|
||||
i.setItem(36, Methods.getBackgroundGlass(true));
|
||||
i.setItem(37, Methods.getBackgroundGlass(true));
|
||||
i.setItem(38, Methods.getBackgroundGlass(false));
|
||||
|
||||
i.setItem(42, Methods.getBackgroundGlass(false));
|
||||
i.setItem(43, Methods.getBackgroundGlass(true));
|
||||
i.setItem(44, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(19, Methods.createButton(Material.SUNFLOWER, "&6&lShop Price",
|
||||
"&7Currently: &a" + spawnerData.getShopPrice(),
|
||||
"&7This is the price of the",
|
||||
"&7spawner in the shop."));
|
||||
|
||||
i.setItem(20, Methods.createButton(Material.DIAMOND, "&6&lIn Shop",
|
||||
"&7Currently: &a" + spawnerData.isInShop(),
|
||||
"&7If this is true this spawner",
|
||||
"&7will show up in the shop GUI."));
|
||||
|
||||
i.setItem(22, Methods.createButton(Material.FIRE_CHARGE, "&c&lSpawn On Fire",
|
||||
"&7Currently: &a" + spawnerData.isSpawnOnFire(),
|
||||
"&7If this is true this spawner",
|
||||
"&7will spawn entities on fire."));
|
||||
|
||||
i.setItem(13, Methods.createButton(Material.HOPPER, "&5&lUpgradable",
|
||||
"&7Currently: &a" + spawnerData.isUpgradeable(),
|
||||
"&7Setting this to true will define",
|
||||
"&7upgradable."));
|
||||
|
||||
i.setItem(24, Methods.createButton(Material.SUNFLOWER, "&6&lCustom Economy cost",
|
||||
"&7Currently: &a" + spawnerData.getUpgradeCostEconomy(),
|
||||
"&7This is the custom economy cost",
|
||||
"&7to upgrade this spawner."));
|
||||
|
||||
i.setItem(25, Methods.createButton(Material.EXPERIENCE_BOTTLE, "&5&lCustom Experience cost",
|
||||
"&7Currently: &a" + spawnerData.getUpgradeCostExperience(),
|
||||
"&7This is the custom XP cost",
|
||||
"&7to upgrade this spawner."));
|
||||
|
||||
i.setItem(30, Methods.createButton(Material.EXPERIENCE_BOTTLE, "&5&lCustom Goal",
|
||||
"&7Currently: &a" + spawnerData.getKillGoal(),
|
||||
"&7If this is set to anything",
|
||||
"&7but 0 the default kill goal",
|
||||
"&7will be adjusted for this spawner."));
|
||||
|
||||
i.setItem(32, Methods.createButton(Material.DIAMOND, "&b&lPickup Cost",
|
||||
"&7Currently: &a" + spawnerData.getPickupCost(),
|
||||
"&7Setting this to anything but 0",
|
||||
"&7will allow you to charge players",
|
||||
"&7for breaking this type of spawner."));
|
||||
|
||||
i.setItem(40, Methods.createButton(Material.CLOCK, "&6&lTick Rate",
|
||||
"&7Currently: &a" + spawnerData.getTickRate(),
|
||||
"&7This is the default tick rate",
|
||||
"&7that your spawner will use",
|
||||
"&7to create its delay with."));
|
||||
|
||||
player.openInventory(i);
|
||||
editingData.setMenu(EditingMenu.GENERAL);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void alterSetting(Player player, ChatListeners.EditingType type) {
|
||||
try {
|
||||
EditingData editingData = userEditingData.get(player.getUniqueId());
|
||||
SpawnerData entity = editingData.getSpawnerEditing();
|
||||
player.sendMessage("");
|
||||
switch (type) {
|
||||
case SHOP_PRICE:
|
||||
player.sendMessage(Methods.formatText("&7Enter a sale price for &6" + Methods.getTypeFromString(entity.getIdentifyingName()) + "&7."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &619.99&7."));
|
||||
break;
|
||||
case CUSTOM_ECO_COST:
|
||||
player.sendMessage(Methods.formatText("&7Enter a custom eco cost for " + Methods.getTypeFromString(entity.getIdentifyingName()) + "&7."));
|
||||
player.sendMessage(Methods.formatText("&7Use &60 &7to use the default cost."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &619.99&7."));
|
||||
break;
|
||||
case CUSTOM_XP_COST:
|
||||
player.sendMessage(Methods.formatText("&7Enter a custom xp cost for " + Methods.getTypeFromString(entity.getIdentifyingName()) + "&7."));
|
||||
player.sendMessage(Methods.formatText("&7Use &60 &7to use the default cost."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &625&7."));
|
||||
break;
|
||||
case PICKUP_COST:
|
||||
player.sendMessage(Methods.formatText("&7Enter a pickup cost for " + Methods.getTypeFromString(entity.getIdentifyingName()) + "&7."));
|
||||
player.sendMessage(Methods.formatText("&7Use &60 &7to disable."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &719.99&6."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &625&7."));
|
||||
break;
|
||||
case CUSTOM_GOAL:
|
||||
player.sendMessage(Methods.formatText("&7Enter a custom goal for " + Methods.getTypeFromString(entity.getIdentifyingName()) + "&7."));
|
||||
player.sendMessage(Methods.formatText("&7Use &60 &7to use the default price."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &35&6."));
|
||||
break;
|
||||
case TICK_RATE:
|
||||
player.sendMessage(Methods.formatText("&7Enter a tick rate min and max for " + Methods.getTypeFromString(entity.getIdentifyingName()) + "&7."));
|
||||
player.sendMessage(Methods.formatText("&7Example: &3800:200&6."));
|
||||
break;
|
||||
}
|
||||
player.sendMessage("");
|
||||
instance.getChatListeners().addToEditor(player, type);
|
||||
player.closeInventory();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<ItemStack> getItems(Player p) {
|
||||
try {
|
||||
ItemStack[] items2 = p.getOpenInventory().getTopInventory().getContents();
|
||||
//items2 = Arrays.copyOf(items2, items2.length - 9);
|
||||
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
|
||||
int num = 0;
|
||||
for (ItemStack item : items2) {
|
||||
if (num >= 10 && num <= 25 && num != 17 && num != 18 && item != null) {
|
||||
items.add(items2[num]);
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return items;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void save(Player p, List<ItemStack> items) {
|
||||
try {
|
||||
EditingData editingData = userEditingData.get(p.getUniqueId());
|
||||
SpawnerData spawnerData = editingData.getSpawnerEditing();
|
||||
if (editingData.getMenu() == EditingMenu.ITEM) {
|
||||
spawnerData.setItems(items);
|
||||
} else if (editingData.getMenu() == EditingMenu.DROPS) {
|
||||
spawnerData.setEntityDroppedItems(items);
|
||||
} else if (editingData.getMenu() == EditingMenu.BLOCK) {
|
||||
List<Material> list = new ArrayList<>();
|
||||
for (ItemStack item : items) {
|
||||
Material material = item.getType();
|
||||
list.add(material);
|
||||
}
|
||||
|
||||
spawnerData.setBlocks(list);
|
||||
} else if (editingData.getMenu() == EditingMenu.ENTITY) {
|
||||
List<EntityType> list = new ArrayList<>();
|
||||
for (ItemStack item : items) {
|
||||
EntityType entityType = EntityType.valueOf(ChatColor.stripColor(item.getItemMeta().getDisplayName()).toUpperCase().replace(" ", "_"));
|
||||
list.add(entityType);
|
||||
}
|
||||
spawnerData.setEntities(list);
|
||||
} else if (editingData.getMenu() == EditingMenu.COMMAND) {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (ItemStack item : items) {
|
||||
String name = ChatColor.stripColor(item.getItemMeta().getDisplayName()).substring(1);
|
||||
list.add(name);
|
||||
}
|
||||
spawnerData.setCommands(list);
|
||||
}
|
||||
p.sendMessage(Methods.formatText(References.getPrefix() + "&7Spawner Saved."));
|
||||
spawnerData.reloadSpawnMethods();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addEntityInit(Player p) {
|
||||
try {
|
||||
p.sendMessage("");
|
||||
StringBuilder list = new StringBuilder();
|
||||
for (final EntityType value : EntityType.values()) {
|
||||
if (value.isSpawnable() && value.isAlive()) {
|
||||
list.append(value.toString()).append("&7, &6");
|
||||
}
|
||||
}
|
||||
p.sendMessage(Methods.formatText("&6" + list));
|
||||
p.sendMessage("Enter an entity Type.");
|
||||
p.sendMessage("");
|
||||
instance.getChatListeners().addToEditor(p, ChatListeners.EditingType.ADD_ENTITY);
|
||||
p.closeInventory();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy(Player p) {
|
||||
try {
|
||||
EditingData editingData = userEditingData.get(p.getUniqueId());
|
||||
p.sendMessage("");
|
||||
p.sendMessage(Methods.formatText("&cAre you sure you want to destroy &6" + editingData.getSpawnerEditing().getIdentifyingName() + "&7."));
|
||||
p.sendMessage(Methods.formatText("&7Type &l&6CONFIRM &7to continue. Otherwise Type anything else to cancel."));
|
||||
p.sendMessage("");
|
||||
instance.getChatListeners().addToEditor(p, ChatListeners.EditingType.DESTROY);
|
||||
p.closeInventory();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyFinal(Player p, String msg) {
|
||||
try {
|
||||
EditingData editingData = userEditingData.get(p.getUniqueId());
|
||||
|
||||
if (msg.toLowerCase().equals("confirm")) {
|
||||
p.sendMessage(Methods.formatText("&6" + editingData.getSpawnerEditing().getIdentifyingName() + " Spawner &7 has been destroyed successfully"));
|
||||
instance.getSpawnerManager().removeSpawnerData(editingData.getSpawnerEditing().getIdentifyingName());
|
||||
openSpawnerSelector(p, 1);
|
||||
} else {
|
||||
p.sendMessage(Methods.formatText("&7Action canceled..."));
|
||||
overview(p, editingData.getSpawnerEditing());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void editSpawnLimit(Player p) {
|
||||
try {
|
||||
EditingData editingData = userEditingData.get(p.getUniqueId());
|
||||
if (editingData.getMenu() == EditingMenu.COMMAND) {
|
||||
SpawnerData spawnerData = editingData.getSpawnerEditing();
|
||||
|
||||
p.sendMessage("");
|
||||
p.sendMessage(Methods.formatText("&7Enter a spawn limit for &6" + Methods.getTypeFromString(spawnerData.getIdentifyingName()) + "&7."));
|
||||
p.sendMessage("");
|
||||
instance.getChatListeners().addToEditor(p, ChatListeners.EditingType.SPAWN_LIMIT);
|
||||
p.closeInventory();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void createCommand(Player p) {
|
||||
try {
|
||||
p.sendMessage("");
|
||||
p.sendMessage(Methods.formatText("&7Please Type a command. Example: &6eco give @p 1000&7."));
|
||||
p.sendMessage(Methods.formatText("&7You can use @X @Y and @Z for random X Y and Z coordinates around the spawner."));
|
||||
p.sendMessage(Methods.formatText("&7@n will execute the command for the person who originally placed the spawner."));
|
||||
p.sendMessage(Methods.formatText("&7If you're getting command output try &6/gamerule sendCommandFeedback false&7."));
|
||||
p.sendMessage(Methods.formatText("&7do not include a &a/"));
|
||||
p.sendMessage("");
|
||||
|
||||
instance.getChatListeners().addToEditor(p, ChatListeners.EditingType.COMMAND);
|
||||
p.closeInventory();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void addCommand(Player p, String cmd) {
|
||||
try {
|
||||
EditingData editingData = userEditingData.get(p.getUniqueId());
|
||||
SpawnerData spawnerData = editingData.getSpawnerEditing();
|
||||
List<String> commands = new ArrayList<>(spawnerData.getCommands());
|
||||
commands.add(cmd);
|
||||
spawnerData.setCommands(commands);
|
||||
|
||||
editor(p, EditingMenu.COMMAND);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void editSpawnerName(Player p) {
|
||||
try {
|
||||
EditingData editingData = userEditingData.get(p.getUniqueId());
|
||||
SpawnerData spawnerData = editingData.getSpawnerEditing();
|
||||
|
||||
p.sendMessage("");
|
||||
p.sendMessage(Methods.formatText("&7Enter a display name for &6" + Methods.getTypeFromString(spawnerData.getIdentifyingName()) + "&7."));
|
||||
p.sendMessage("");
|
||||
instance.getChatListeners().addToEditor(p, ChatListeners.EditingType.NAME);
|
||||
p.closeInventory();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveSpawnerName(Player p, String name) {
|
||||
try {
|
||||
EditingData editingData = userEditingData.get(p.getUniqueId());
|
||||
SpawnerData spawnerData = editingData.getSpawnerEditing();
|
||||
spawnerData.setDisplayName(name);
|
||||
overview(p, spawnerData);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void addEntity(Player p, String ent) {
|
||||
try {
|
||||
EditingData editingData = userEditingData.get(p.getUniqueId());
|
||||
SpawnerData spawnerData = editingData.getSpawnerEditing();
|
||||
List<EntityType> entities = new ArrayList<>(spawnerData.getEntities());
|
||||
entities.add(EntityType.valueOf(ent));
|
||||
spawnerData.setEntities(entities);
|
||||
editor(p, EditingMenu.ENTITY);
|
||||
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public EditingData getEditingData(Player player) {
|
||||
return userEditingData.computeIfAbsent(player.getUniqueId(), uuid -> new EditingData());
|
||||
}
|
||||
}
|
@ -22,6 +22,9 @@ public class ESpawnerData implements SpawnerData {
|
||||
|
||||
private final String name;
|
||||
private int uuid;
|
||||
|
||||
private boolean custom = false;
|
||||
|
||||
private double pickupCost = 0.0;
|
||||
private List<Material> spawnBlocks = Collections.singletonList(Material.DIRT);
|
||||
private boolean active = true, inShop = true;
|
||||
@ -101,7 +104,6 @@ public class ESpawnerData implements SpawnerData {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
@ -409,6 +411,16 @@ public class ESpawnerData implements SpawnerData {
|
||||
this.particleEffectBoostedOnly = particleEffectBoostedOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCustom() {
|
||||
return custom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom(boolean custom) {
|
||||
this.custom = custom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCondition(SpawnCondition spawnCondition) {
|
||||
spawnConditions.add(spawnCondition);
|
||||
|
@ -70,7 +70,7 @@ public class ESpawnerManager implements SpawnerManager {
|
||||
|
||||
@Override
|
||||
public boolean isSpawnerData(String type) {
|
||||
return spawners.containsKey(type);
|
||||
return spawners.containsKey(type.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,99 @@
|
||||
package com.songoda.epicspawners.utils;
|
||||
|
||||
import com.songoda.epicspawners.EpicSpawnersPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AbstractChatConfirm implements Listener {
|
||||
|
||||
private static final List<UUID> registered = new ArrayList<>();
|
||||
|
||||
private final Player player;
|
||||
private final ChatConfirmHandler handler;
|
||||
|
||||
private OnClose onClose = null;
|
||||
private Listener listener;
|
||||
|
||||
public AbstractChatConfirm(Player player, ChatConfirmHandler hander) {
|
||||
this.player = player;
|
||||
this.handler = hander;
|
||||
player.closeInventory();
|
||||
initializeListeners(EpicSpawnersPlugin.getInstance());
|
||||
registered.add(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static boolean isRegistered(Player player) {
|
||||
return registered.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static boolean unregister(Player player) {
|
||||
return registered.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void initializeListeners(JavaPlugin plugin) {
|
||||
|
||||
this.listener = new Listener() {
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!AbstractChatConfirm.isRegistered(player)) return;
|
||||
|
||||
AbstractChatConfirm.unregister(player);
|
||||
event.setCancelled(true);
|
||||
|
||||
ChatConfirmEvent chatConfirmEvent = new ChatConfirmEvent(player, event.getMessage());
|
||||
|
||||
handler.onChat(chatConfirmEvent);
|
||||
|
||||
if (onClose != null) {
|
||||
onClose.onClose();
|
||||
}
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(listener, EpicSpawnersPlugin.getInstance());
|
||||
}
|
||||
|
||||
public void setOnClose(OnClose onClose) {
|
||||
this.onClose = onClose;
|
||||
}
|
||||
|
||||
public interface ChatConfirmHandler {
|
||||
void onChat(ChatConfirmEvent event);
|
||||
}
|
||||
|
||||
public interface OnClose {
|
||||
void onClose();
|
||||
}
|
||||
|
||||
public class ChatConfirmEvent {
|
||||
|
||||
private final Player player;
|
||||
private final String message;
|
||||
|
||||
public ChatConfirmEvent(Player player, String message) {
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -241,6 +241,12 @@ public final class ESpawnerDataBuilder implements SpawnerDataBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpawnerDataBuilder isCustom(boolean custom) {
|
||||
this.spawnerData.setCustom(custom);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpawnerDataBuilder entitySpawnParticle(ParticleType particle) {
|
||||
this.spawnerData.setEntitySpawnParticle(particle);
|
||||
|
@ -40,26 +40,6 @@ public class Methods {
|
||||
player.setItemInHand(result > 0 ? item : null);
|
||||
}
|
||||
|
||||
public static ItemStack createButton(ItemStack item, String name, String... lore) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(formatText(name));
|
||||
if (lore != null && lore.length != 0) {
|
||||
List<String> newLore = new ArrayList<>();
|
||||
for (String line : lore) newLore.add(formatText(line));
|
||||
meta.setLore(newLore);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack createButton(Material material, String name, String... lore) {
|
||||
return createButton(new ItemStack(material), name, lore);
|
||||
}
|
||||
|
||||
public static ItemStack createButton(Material material, String name, ArrayList<String> lore) {
|
||||
return createButton(material, name, lore.toArray(new String[0]));
|
||||
}
|
||||
|
||||
public static String getBoostCost(int time, int amount) {
|
||||
StringBuilder cost = new StringBuilder("&6&l");
|
||||
String[] parts = EpicSpawnersPlugin.getInstance().getConfig().getString("Spawner Boosting.Item Charged For A Boost").split(":");
|
||||
@ -293,6 +273,19 @@ public class Methods {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the provided string is a valid number (int, double, float, or otherwise).
|
||||
*
|
||||
* @param s The string to check.
|
||||
* @return <code>true</code> if the string is numeric, otherwise <code>false</code>
|
||||
*/
|
||||
public static boolean isNumeric(String s) {
|
||||
if (s == null || s.equals(""))
|
||||
return false;
|
||||
return s.matches("[-+]?\\d*\\.?\\d+");
|
||||
}
|
||||
|
||||
|
||||
public static void removeFromInventory(Inventory inventory, ItemStack item) {
|
||||
int amt = item.getAmount();
|
||||
ItemStack[] items = inventory.getContents();
|
||||
|
@ -127,7 +127,7 @@ public abstract class AbstractGUI implements Listener {
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
|
||||
protected abstract void constructGUI();
|
||||
public abstract void constructGUI();
|
||||
|
||||
protected void addDraggable(Range range, boolean option) {
|
||||
this.draggableRanges.put(range, option);
|
||||
|
Loading…
Reference in New Issue
Block a user