mirror of
https://github.com/songoda/EpicBosses.git
synced 2024-12-24 00:47:35 +01:00
1.0.0-SNAPSHOT-U69 (hehe..)
+ Finished work on the create table command + Added a method to BossAPI to create a table
This commit is contained in:
parent
2b352d0d3a
commit
8a97059dc1
@ -1,6 +1,12 @@
|
||||
package com.songoda.epicbosses.api;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.droptable.DropTable;
|
||||
import com.songoda.epicbosses.droptable.elements.DropTableElement;
|
||||
import com.songoda.epicbosses.droptable.elements.GiveTableElement;
|
||||
import com.songoda.epicbosses.droptable.elements.SprayTableElement;
|
||||
import com.songoda.epicbosses.entity.BossEntity;
|
||||
import com.songoda.epicbosses.entity.MinionEntity;
|
||||
import com.songoda.epicbosses.entity.elements.*;
|
||||
@ -16,6 +22,7 @@ import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.custom.Minions;
|
||||
import com.songoda.epicbosses.skills.elements.CustomMinionSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import com.songoda.epicbosses.utils.BossesGson;
|
||||
import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.EntityFinder;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
@ -26,6 +33,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -157,6 +165,39 @@ public class BossAPI {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static DropTable createBaseDropTable(String name, String dropType) {
|
||||
if(PLUGIN.getDropTableFileManager().getDropTable(name) != null) {
|
||||
Debug.DROPTABLE_NAME_EXISTS.debug(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
String jsonString;
|
||||
|
||||
if(dropType.equalsIgnoreCase("SPRAY")) {
|
||||
SprayTableElement sprayTableElement = new SprayTableElement(new HashMap<>(), false, 100, 10);
|
||||
|
||||
jsonString = BossesGson.get().toJson(sprayTableElement);
|
||||
} else if(dropType.equalsIgnoreCase("GIVE")) {
|
||||
GiveTableElement giveTableElement = new GiveTableElement(new HashMap<>());
|
||||
|
||||
jsonString = BossesGson.get().toJson(giveTableElement);
|
||||
} else if(dropType.equalsIgnoreCase("DROP")) {
|
||||
DropTableElement dropTableElement = new DropTableElement(new HashMap<>(), false, 10);
|
||||
|
||||
jsonString = BossesGson.get().toJson(dropTableElement);
|
||||
} else {
|
||||
Debug.DROP_TABLE_FAILED_TO_GET_TYPE.debug(dropType);
|
||||
return null;
|
||||
}
|
||||
|
||||
DropTable dropTable = new DropTable(dropType, jsonParser.parse(jsonString).getAsJsonObject());
|
||||
|
||||
PLUGIN.getDropTableFileManager().saveDropTable(name, dropTable);
|
||||
|
||||
return dropTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to create a base BossEntity model which
|
||||
* can be used to fine tune and then once the main
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.droptable.DropTable;
|
||||
import com.songoda.epicbosses.managers.BossDropTableManager;
|
||||
import com.songoda.epicbosses.managers.files.DropTableFileManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
@ -53,10 +55,17 @@ public class BossNewCmd extends SubCommand {
|
||||
}
|
||||
|
||||
if(!validType) {
|
||||
Message.Boss_New_InvalidType.msg(sender);
|
||||
Message.Boss_New_InvalidDropTableType.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
DropTable dropTable = BossAPI.createBaseDropTable(nameInput, typeInput);
|
||||
|
||||
if(dropTable == null) {
|
||||
Message.Boss_New_SomethingWentWrong.msg(sender, "DropTable");
|
||||
} else {
|
||||
Message.Boss_New_DropTable.msg(sender, nameInput, typeInput);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public class BossCommandManager implements ILoadable {
|
||||
this.commandService.registerSubCommand(new BossListCmd(this.customBosses.getBossPanelManager()));
|
||||
this.commandService.registerSubCommand(new BossMenuCmd(this.customBosses.getBossPanelManager()));
|
||||
this.commandService.registerSubCommand(new BossNearbyCmd(this.customBosses));
|
||||
this.commandService.registerSubCommand(new BossNewCmd(this.customBosses));
|
||||
this.commandService.registerSubCommand(new BossReloadCmd(this.customBosses, this.customBosses.getBossEntityManager()));
|
||||
this.commandService.registerSubCommand(new BossShopCmd(this.customBosses));
|
||||
this.commandService.registerSubCommand(new BossSkillsCmd(this.customBosses.getBossPanelManager()));
|
||||
|
@ -42,6 +42,13 @@ public class DropTableFileManager implements ILoadable, ISavable, IReloadable {
|
||||
this.dropTableFileHandler.saveFile(this.dropTableMap);
|
||||
}
|
||||
|
||||
public void saveDropTable(String name, DropTable dropTable) {
|
||||
if(this.dropTableMap.containsKey(name)) return;
|
||||
|
||||
this.dropTableMap.put(name, dropTable);
|
||||
save();
|
||||
}
|
||||
|
||||
public DropTable getDropTable(String name) {
|
||||
return this.dropTableMap.getOrDefault(name, null);
|
||||
}
|
||||
|
@ -91,7 +91,10 @@ public class DropsEditorPanel extends VariablePanelHandler<BossEntity> {
|
||||
|
||||
fillPanel(panel, bossEntity);
|
||||
counter.getSlotsWith("Selected").forEach(slot -> panel.setOnClick(slot, event -> {/* TODO: GO TO EDIT PANEL FOR DROP TABLE */}));
|
||||
counter.getSlotsWith("CreateDropTable").forEach(slot -> panel.setOnClick(slot, event -> {/* TODO: CREATE NEW DROP TABLE COMMAND */}));
|
||||
counter.getSlotsWith("CreateDropTable").forEach(slot -> panel.setOnClick(slot, event -> {
|
||||
player.closeInventory();
|
||||
Message.Boss_New_CreateArgumentsDropTable.msg(event.getWhoClicked());
|
||||
}));
|
||||
|
||||
panel.openFor(player);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ public enum Debug {
|
||||
MAX_HEALTH("You cannot set the max health higher than {0}. You can adjust your max health in the spigot.yml file and restart your server to increase this."),
|
||||
MECHANIC_APPLICATION_FAILED("Some mechanics have failed to be applied. It got stuck at {0} mechanic."),
|
||||
BOSS_NAME_EXISTS("A boss was attempted to be created with the name {0} but there is already a boss with that name."),
|
||||
DROPTABLE_NAME_EXISTS("A droptable was attempted to be created with the name {0} but there is already a drop table with that name."),
|
||||
MINION_NAME_EXISTS("A minion was attempted to be created with the name {0} but there is already a minion with that name."),
|
||||
BOSS_CONTAINER_SAVE("The BossEntity map was saved in, {0} succeeded, and {1} failed. Listed below are the saved data which already existed in the container: \n{2}"),
|
||||
MINION_CONTAINER_SAVE("The MinionEntity map was saved in, {0} succeeded, and {1} failed. Listed below are the saved data which already existed in the container: \n{2}"),
|
||||
@ -45,6 +46,7 @@ public enum Debug {
|
||||
|
||||
DROP_TABLE_FAILED_INVALID_NUMBER("The specified position ({0}) on the drop table is not a valid number."),
|
||||
DROP_TABLE_FAILED_TO_GET_ITEM("The drop table failed to get the specific item for the list."),
|
||||
DROP_TABLE_FAILED_TO_GET_TYPE("The drop table that was attempted to be made with type {0} failed as it's not a valid drop table type."),
|
||||
|
||||
MECHANIC_TYPE_NOT_STORED("This mechanic type is not stored, therefore will not be applied. Valid mechanic types are IOptionalMechanic and IPrimaryMechanic."),
|
||||
|
||||
|
@ -76,7 +76,7 @@ public enum Message {
|
||||
"&b/boss debug &8» &7Used to toggle the debug aspect of the plugin.\n" +
|
||||
"&b/boss giveegg [name] [player] (amount) &8» &7Used to be given a spawn item of the boss.\n" +
|
||||
"&b/boss list &8» &7Shows all the list of current boss entities.\n" +
|
||||
"&b\n" +
|
||||
"&b/boss new [droptable/skill] [name] [type] &8» &7Used to create new drop tables and skills.\n" +
|
||||
"&b\n" +
|
||||
"&7\n" +
|
||||
"&8&m----*-----------------------------------*----"),
|
||||
@ -112,8 +112,11 @@ public enum Message {
|
||||
|
||||
Boss_New_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_New_InvalidArgs("&c&l(!) &cInvalid arguments! You must use &n/boss new droptable [name] (type)&c or &n/boss new skill [name]&c!"),
|
||||
Boss_New_CreateArgumentsDropTable("&b&lEpicBosses &8» &7Create a new droptable with the command &f/boss new droptable [name] [type]&7."),
|
||||
Boss_New_DropTableAlreadyExists("&c&l(!) &cThe specified DropTable name already exists. Please try another name."),
|
||||
Boss_New_InvalidType("&c&l(!) &cThe specified DropTable type is invalid. Please use &fGive, Drop, Spray&c."),
|
||||
Boss_New_InvalidDropTableType("&c&l(!) &cThe specified DropTable type is invalid. Please use &fGive, Drop, Spray&c."),
|
||||
Boss_New_DropTable("&b&lEpicBosses &8» &7You have created a new drop table with the name &f{0}&7 and type &f{1}&7."),
|
||||
Boss_New_SomethingWentWrong("&c&l(!) &cSomething went wrong while trying to create a new &f{0}&c."),
|
||||
|
||||
Boss_Reload_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Reload_Successful("&b&lEpicBosses &8» &7All boss data has been reloaded. The process took &f{0}ms&7."),
|
||||
|
Loading…
Reference in New Issue
Block a user