Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public boolean execute(CommandSender sender, String commandLabel, String[] args)
Map<Enchantment, Integer> enchantments = item.getEnchantments();
boolean conflicts = false;

if (!force && !enchantments.isEmpty()) { // TODO: Improve this to use a "hasEnchantments" call
if (!force && !item.hasEnchantments()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fine to keep this like how it was before.

I don't think a hasEnchantments method was added in newer API.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!force && !item.hasEnchantments()) {
if (!force && !enchantments.isEmpty()) {

for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
Enchantment enchant = entry.getKey();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ public static double getDouble(CommandSender sender, String input) {
public static double getDouble(CommandSender sender, String input, double min, double max) {
double result = getDouble(sender, input);

// TODO: This should throw an exception instead.
if (result < min) {
result = min;
throw new NumberFormatException(String.format("Number must be at least %s", min));
} else if (result > max) {
result = max;
throw new NumberFormatException(String.format("Number must be at most %s", max));
}

return result;
Expand Down
11 changes: 11 additions & 0 deletions WindSpigot-API/src/main/java/org/bukkit/inventory/ItemStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,17 @@ public Map<Enchantment, Integer> getEnchantments() {
return meta == null ? ImmutableMap.<Enchantment, Integer>of() : meta.getEnchants();
}

// WindSpigot start

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this, same reason as above

/**
* Checks if this ItemStack has any enchantments.
*
* @return True if this has any enchantments
*/
public boolean hasEnchantments() {
return !getEnchantments().isEmpty();
}
// WindSpigot stop

Comment on lines +407 to +417

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// WindSpigot start
/**
* Checks if this ItemStack has any enchantments.
*
* @return True if this has any enchantments
*/
public boolean hasEnchantments() {
return !getEnchantments().isEmpty();
}
// WindSpigot stop

/**
* Adds the specified enchantments to this item stack.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,22 @@ private void initCmds() {
PingCommand pingCommand = new PingCommand("ping");
commandMap.register(pingCommand.getName(), "", pingCommand);
}



// NachoSpigot commands
// TODO: add configuration for all of these
SetMaxSlotCommand setMaxSlotCommand = new SetMaxSlotCommand("sms"); // [Nacho-0021] Add setMaxPlayers within Bukkit.getServer() and SetMaxSlot Command
commandMap.register(setMaxSlotCommand.getName(), "ns", setMaxSlotCommand);
if (WindSpigotConfig.setMaxSlotCommand) {
SetMaxSlotCommand setMaxSlotCommand = new SetMaxSlotCommand("sms"); // [Nacho-0021] Add setMaxPlayers within Bukkit.getServer() and SetMaxSlot Command
commandMap.register(setMaxSlotCommand.getName(), "ns", setMaxSlotCommand);
}

SpawnMobCommand spawnMobCommand = new SpawnMobCommand("spawnmob");
commandMap.register(spawnMobCommand.getName(), "ns", spawnMobCommand);
if (WindSpigotConfig.spawnMobCommand) {
SpawnMobCommand spawnMobCommand = new SpawnMobCommand("spawnmob");
commandMap.register(spawnMobCommand.getName(), "ns", spawnMobCommand);
}

KnockbackCommand knockbackCommand = new KnockbackCommand("kb");
commandMap.register(knockbackCommand.getName(), "ns", knockbackCommand);
if (WindSpigotConfig.knockbackCommand) {
KnockbackCommand knockbackCommand = new KnockbackCommand("kb");
commandMap.register(knockbackCommand.getName(), "ns", knockbackCommand);
}
}

private void initStatistics() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ static void loadComments() {

// NachoSpigot stuff
c.addComment("settings.save-empty-scoreboard-teams", "Toggles whether or not the server should save empty scoreboard teams");
c.addComment("settings.command.setmaxslot", "Enables the /setmaxslot command");
c.addComment("settings.command.spawnmob", "Enables the /spawnmob command");
c.addComment("settings.command.knockback", "Enables the /knockback command");
c.addComment("settings.command.version", "Enables the /version command");
c.addComment("settings.command.plugins", "Enables the /plugins command");
c.addComment("settings.command.reload", "Enables the /reload command (It is recommended to not use /reload)");
Expand Down Expand Up @@ -438,11 +441,17 @@ private static void saveEmptyScoreboardTeams() {
saveEmptyScoreboardTeams = getBoolean("settings.save-empty-scoreboard-teams", false);
}

public static boolean setMaxSlotCommand;
public static boolean spawnMobCommand;
public static boolean knockbackCommand;
public static boolean enableVersionCommand;
public static boolean enablePluginsCommand;
public static boolean enableReloadCommand;

private static void commands() {
setMaxSlotCommand = getBoolean("settings.command.setmaxslot", true);
spawnMobCommand = getBoolean("settings.command.spawnmob", true);
knockbackCommand = getBoolean("settings.command.knockback", true);
enableVersionCommand = getBoolean("settings.command.version", true);
enablePluginsCommand = getBoolean("settings.command.plugins", true);
enableReloadCommand = getBoolean("settings.command.reload", false);
Expand Down
Loading