1.0.0-SNAPSHOT-U52

+ Finished Boss GiveEgg Cmd
+ Added more messages
This commit is contained in:
AMinecraftDev 2018-11-16 00:28:17 +08:00
parent 4fe07e8bc5
commit 77975dd912
5 changed files with 79 additions and 4 deletions

View File

@ -1,7 +1,16 @@
package com.songoda.epicbosses.commands.boss;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.managers.BossEntityManager;
import com.songoda.epicbosses.managers.files.BossesFileManager;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.NumberUtils;
import com.songoda.epicbosses.utils.Permission;
import com.songoda.epicbosses.utils.command.SubCommand;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
/**
* @author Charles Cullen
@ -10,12 +19,68 @@ import org.bukkit.command.CommandSender;
*/
public class BossGiveEggCmd extends SubCommand {
public BossGiveEggCmd() {
private BossEntityManager bossEntityManager;
private BossesFileManager bossesFileManager;
public BossGiveEggCmd(BossesFileManager bossesFileManager, BossEntityManager bossEntityManager) {
super("give", "giveegg");
this.bossesFileManager = bossesFileManager;
this.bossEntityManager = bossEntityManager;
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!Permission.give.hasPermission(sender)) {
Message.Boss_GiveEgg_NoPermission.msg(sender);
return;
}
if(args.length < 3) {
Message.Boss_GiveEgg_InvalidArgs.msg(sender);
return;
}
int amount = 1;
if(args.length == 4) {
String amountInput = args[3];
if(NumberUtils.get().isInt(amountInput)) {
amount = Integer.valueOf(amountInput);
} else {
Message.General_NotNumber.msg(sender);
return;
}
}
String playerInput = args[2];
Player player = Bukkit.getPlayer(playerInput);
if(player == null) {
Message.General_NotOnline.msg(sender, playerInput);
return;
}
String bossInput = args[1];
BossEntity bossEntity = this.bossesFileManager.getBossEntity(bossInput);
if(bossEntity == null) {
Message.Boss_GiveEgg_InvalidBoss.msg(sender);
return;
}
ItemStack spawnItem = this.bossEntityManager.getSpawnItem(bossEntity);
if(spawnItem == null) {
Message.Boss_GiveEgg_NotSet.msg(sender);
return;
}
spawnItem.setAmount(amount);
player.getInventory().addItem(spawnItem);
Message.Boss_GiveEgg_Given.msg(sender, player.getName(), amount, bossInput);
Message.Boss_GiveEgg_Received.msg(player, amount, bossInput);
}
}

View File

@ -33,7 +33,7 @@ public class BossCommandManager implements ILoadable {
this.commandService.registerSubCommand(new BossDebugCmd(this.customBosses.getDebugManager()));
this.commandService.registerSubCommand(new BossDropTableCmd(this.customBosses.getBossPanelManager()));
this.commandService.registerSubCommand(new BossEditCmd(this.customBosses.getBossPanelManager()));
this.commandService.registerSubCommand(new BossGiveEggCmd());
this.commandService.registerSubCommand(new BossGiveEggCmd(this.customBosses.getBossesFileManager(), this.customBosses.getBossEntityManager()));
this.commandService.registerSubCommand(new BossHelpCmd());
this.commandService.registerSubCommand(new BossInfoCmd(this.customBosses.getBossesFileManager(), this.customBosses.getBossEntityManager()));
this.commandService.registerSubCommand(new BossItemsCmd(this.customBosses.getBossPanelManager()));

View File

@ -17,7 +17,9 @@ public enum Message {
General_LocationFormat("{world}, {x}, {y}, {z}"),
General_MustBePlayer("&c&l(!) &cYou must be a player to use this command."),
General_NotOnline("&c&l(!) &cThe specified player, {0}, is not online or a valid player."),
General_CannotSpawn("&c&l(!) &cYou cannot spawn a boss at this location! &c&l(!)"),
General_NotNumber("&c&l(!) &cThe number you have provided is not a proper number."),
General_Disarmed("&4&l(!) &f&lYOU HAVE BEEN DISARMED! CHECK THE GROUND AROUND YOU FOR YOUR ITEM!"),
Boss_Create_EntityTypeNotFound("&c&l(!) &cThe specified entity type {0} was not found. If you think this is an error please contact &fAMinecraftDev&c."),
@ -37,6 +39,13 @@ public enum Message {
Boss_Edit_ItemStackHolderNull("&c&l(!) &cThe itemstack name that is provided for the spawn item doesn't exist or wasn't found."),
Boss_Edit_CannotSpawn("&c&l(!) &cYou cannot spawn this boss while editing is enabled. If you think this is a mistake please contact an administrator to disable the editing of the boss."),
Boss_GiveEgg_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_GiveEgg_InvalidArgs("&c&l(!) &cYou must use &n/boss giveegg [name] [player] (amount)&c to give an egg."),
Boss_GiveEgg_InvalidBoss("&c&l(!) &cThe specified boss is not a valid type."),
Boss_GiveEgg_NotSet("&c&l(!) &cThe spawn item for the {0} boss has not been set yet."),
Boss_GiveEgg_Given("&b&lEpicBosses &8» &7You have given {0} {1}x {2}'s boss spawn item."),
Boss_GiveEgg_Received("&b&lEpicBosses &8» &7You have received {0}x {1} boss spawn item(s)."),
Boss_Help_Page1(
"&8&m----*--------&3&l[ &b&lBoss Help &7(Page 1/3) &3&l]&8&m--------*----\n" +
"&b/boss help (page) &8» &7Displays boss commands.\n" +
@ -62,7 +71,7 @@ public enum Message {
Boss_Help_Page3(
"&8&m----*--------&3&l[ &b&lBoss Help &7(Page 3/3) &3&l]&8&m--------*----\n" +
"&b/boss debug &8» &7Used to toggle the debug aspect of the plugin.\n" +
"&b/boss giveegg [name] [player] &8» &7Used to be given a spawn item of the boss.\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\n" +

View File

@ -13,6 +13,7 @@ public enum Permission {
admin("boss.admin"),
create("boss.create"),
debug("boss.debug"),
give("boss.give"),
reload("boss.reload"),
nearby("boss.nearby");

View File

@ -19,7 +19,7 @@
</modules>
<properties>
<plugin.version>1.0.0-SNAPSHOT-U51</plugin.version>
<plugin.version>1.0.0-SNAPSHOT-U52</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>