Merge branch 'develop' of https://github.com/BentoBoxWorld/BentoBox.git into develop

This commit is contained in:
tastybento 2019-09-29 16:31:51 -07:00
commit d2502a6289
11 changed files with 166 additions and 7 deletions

View File

@ -38,8 +38,12 @@ public class AdminDeathsRemoveCommand extends CompositeCommand {
} else if (!NumberUtils.isNumber(args.get(1)) || Integer.valueOf(args.get(1)) < 0) { } else if (!NumberUtils.isNumber(args.get(1)) || Integer.valueOf(args.get(1)) < 0) {
user.sendMessage("general.errors.must-be-positive-number", TextVariables.NUMBER, args.get(1)); user.sendMessage("general.errors.must-be-positive-number", TextVariables.NUMBER, args.get(1));
} else { } else {
getPlayers().setDeaths(getWorld(), target, getPlayers().getDeaths(getWorld(), target) - Integer.valueOf(args.get(1))); // Make sure it cannot go under 0.
user.sendMessage("commands.admin.deaths.remove.success", TextVariables.NAME, args.get(0), TextVariables.NUMBER, args.get(1)); int newDeaths = Math.max(getPlayers().getDeaths(getWorld(), target) - Integer.valueOf(args.get(1)), 0);
getPlayers().setDeaths(getWorld(), target, newDeaths);
user.sendMessage("commands.admin.deaths.remove.success",
TextVariables.NAME, args.get(0), TextVariables.NUMBER, args.get(1),
"[total]", String.valueOf(newDeaths));
return true; return true;
} }

View File

@ -0,0 +1,50 @@
package world.bentobox.bentobox.api.commands.admin.resets;
import org.apache.commons.lang.math.NumberUtils;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import java.util.List;
import java.util.UUID;
/**
* @author Poslovitch
* @since 1.8.0
*/
public class AdminResetsAddCommand extends CompositeCommand {
public AdminResetsAddCommand(AdminResetsCommand parent) {
super(parent, "add");
}
@Override
public void setup() {
setDescription("commands.admin.resets.add.description");
setParametersHelp("commands.admin.resets.add.parameters");
}
@Override
public boolean execute(User user, String label, @NonNull List<String> args) {
if (args.size() != 2) {
showHelp(this, user);
return false;
}
UUID target = getPlayers().getUUID(args.get(0));
if (target == null) {
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
} else if (!NumberUtils.isNumber(args.get(1)) || Integer.valueOf(args.get(1)) < 0) {
user.sendMessage("general.errors.must-be-positive-number", TextVariables.NUMBER, args.get(1));
} else {
getPlayers().setResets(getWorld(), target, getPlayers().getResets(getWorld(), target) + Integer.valueOf(args.get(1)));
user.sendMessage("commands.admin.resets.add.success",
TextVariables.NAME, args.get(0), TextVariables.NUMBER, args.get(1),
"[total]", String.valueOf(getPlayers().getResets(getWorld(), target)));
return true;
}
return false;
}
}

View File

@ -18,6 +18,8 @@ public class AdminResetsCommand extends CompositeCommand {
new AdminResetsSetCommand(this); new AdminResetsSetCommand(this);
new AdminResetsResetCommand(this); new AdminResetsResetCommand(this);
new AdminResetsAddCommand(this);
new AdminResetsRemoveCommand(this);
} }
@Override @Override

View File

@ -0,0 +1,52 @@
package world.bentobox.bentobox.api.commands.admin.resets;
import org.apache.commons.lang.math.NumberUtils;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import java.util.List;
import java.util.UUID;
/**
* @author Poslovitch
* @since 1.8.0
*/
public class AdminResetsRemoveCommand extends CompositeCommand {
public AdminResetsRemoveCommand(AdminResetsCommand parent) {
super(parent, "remove");
}
@Override
public void setup() {
setDescription("commands.admin.resets.remove.description");
setParametersHelp("commands.admin.resets.remove.parameters");
}
@Override
public boolean execute(User user, String label, @NonNull List<String> args) {
if (args.size() != 2) {
showHelp(this, user);
return false;
}
UUID target = getPlayers().getUUID(args.get(0));
if (target == null) {
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
} else if (!NumberUtils.isNumber(args.get(1)) || Integer.valueOf(args.get(1)) < 0) {
user.sendMessage("general.errors.must-be-positive-number", TextVariables.NUMBER, args.get(1));
} else {
// Make sure it cannot go under 0.
int newResets = Math.max(getPlayers().getResets(getWorld(), target) - Integer.valueOf(args.get(1)), 0);
getPlayers().setResets(getWorld(), target, newResets);
user.sendMessage("commands.admin.resets.remove.success",
TextVariables.NAME, args.get(0), TextVariables.NUMBER, args.get(1),
"[total]", String.valueOf(newResets));
return true;
}
return false;
}
}

View File

@ -39,7 +39,7 @@ public class AdminResetsResetCommand extends ConfirmableCommand {
getIWM().setResetEpoch(getWorld()); getIWM().setResetEpoch(getWorld());
// Reset all current players // Reset all current players
Bukkit.getOnlinePlayers().stream().map(Player::getUniqueId).filter(getPlayers()::isKnown).forEach(u -> getPlayers().setResets(getWorld(), u, 0)); Bukkit.getOnlinePlayers().stream().map(Player::getUniqueId).filter(getPlayers()::isKnown).forEach(u -> getPlayers().setResets(getWorld(), u, 0));
user.sendMessage("general.success"); user.sendMessage("commands.admin.resets.reset.success-everyone");
}); });
return true; return true;
} else { } else {
@ -50,7 +50,7 @@ public class AdminResetsResetCommand extends ConfirmableCommand {
return false; return false;
} else { } else {
getPlayers().setResets(getWorld(), target, 0); getPlayers().setResets(getWorld(), target, 0);
user.sendMessage("general.success"); user.sendMessage("commands.admin.resets.reset.success", TextVariables.NAME, args.get(0));
return true; return true;
} }
} }

View File

@ -23,7 +23,7 @@ public class AdminResetsSetCommand extends CompositeCommand {
@Override @Override
public boolean execute(User user, String label, List<String> args) { public boolean execute(User user, String label, List<String> args) {
if (args.isEmpty() || args.size() != 2) { if (args.size() != 2) {
showHelp(this, user); showHelp(this, user);
return false; return false;
} }
@ -31,11 +31,12 @@ public class AdminResetsSetCommand extends CompositeCommand {
UUID target = getPlayers().getUUID(args.get(0)); UUID target = getPlayers().getUUID(args.get(0));
if (target == null) { if (target == null) {
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0)); user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
} else if (!NumberUtils.isNumber(args.get(1)) || Integer.valueOf(args.get(1)) < 0) { } else if (!NumberUtils.isNumber(args.get(1)) || Integer.valueOf(args.get(1)) <= 0) {
user.sendMessage("general.errors.must-be-positive-number", TextVariables.NUMBER, args.get(1)); user.sendMessage("general.errors.must-be-positive-number", TextVariables.NUMBER, args.get(1));
} else { } else {
getPlayers().setResets(getWorld(), target, Integer.valueOf(args.get(1))); getPlayers().setResets(getWorld(), target, Integer.valueOf(args.get(1)));
user.sendMessage("general.success"); user.sendMessage("commands.admin.resets.set.success",
TextVariables.NAME, args.get(0), TextVariables.NUMBER, args.get(1));
return true; return true;
} }

View File

@ -14,6 +14,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Banner;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
@ -288,6 +289,12 @@ public class BlueprintClipboard {
cs.setSpawnRange(spawner.getSpawnRange()); cs.setSpawnRange(spawner.getSpawnRange());
b.setCreatureSpawner(cs); b.setCreatureSpawner(cs);
} }
// Banners
if (blockState instanceof Banner) {
b.setBannerPatterns(((Banner) blockState).getPatterns());
}
this.bpBlocks.put(pos, b); this.bpBlocks.put(pos, b);
return true; return true;
} }

View File

@ -11,6 +11,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Banner;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -246,6 +247,12 @@ public class BlueprintPaster {
spawner.setSpawnRange(s.getSpawnRange()); spawner.setSpawnRange(s.getSpawnRange());
bs.update(true, false); bs.update(true, false);
} }
// Banners
if (bs instanceof Banner) {
Banner banner = (Banner) bs;
banner.setPatterns(bpBlock.getBannerPatterns());
banner.update(true, false);
}
} }
/** /**

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.block.banner.Pattern;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
@ -22,6 +23,11 @@ public class BlueprintBlock {
private Map<Integer, ItemStack> inventory; private Map<Integer, ItemStack> inventory;
@Expose @Expose
private BlueprintCreatureSpawner creatureSpawner; private BlueprintCreatureSpawner creatureSpawner;
/**
* @since 1.8.0
*/
@Expose
private List<Pattern> bannerPatterns;
public BlueprintBlock(String blockData) { public BlueprintBlock(String blockData) {
this.blockData = blockData; this.blockData = blockData;
@ -82,4 +88,20 @@ public class BlueprintBlock {
public void setCreatureSpawner(BlueprintCreatureSpawner creatureSpawner) { public void setCreatureSpawner(BlueprintCreatureSpawner creatureSpawner) {
this.creatureSpawner = creatureSpawner; this.creatureSpawner = creatureSpawner;
} }
/**
* @return list of the banner patterns
* @since 1.8.0
*/
public List<Pattern> getBannerPatterns() {
return bannerPatterns;
}
/**
* @param bannerPatterns the banner Patterns to set
* @since 1.8.0
*/
public void setBannerPatterns(List<Pattern> bannerPatterns) {
this.bannerPatterns = bannerPatterns;
}
} }

View File

@ -41,6 +41,9 @@ public class BlueprintEntity {
@Expose @Expose
private Style style; private Style style;
/**
* @since 1.8.0
*/
public void configureEntity(Entity e) { public void configureEntity(Entity e) {
if (e instanceof Colorable) { if (e instanceof Colorable) {
((Colorable) e).setColor(color); ((Colorable) e).setColor(color);

View File

@ -54,9 +54,20 @@ commands:
set: set:
description: "sets the resets of this player" description: "sets the resets of this player"
parameters: "<player> <resets>" parameters: "<player> <resets>"
success: "&aSuccessfully set &b[name]&a's resets to &b[number]&a."
reset: reset:
description: "resets the resets of this player to 0" description: "resets the resets of this player to 0"
parameters: "<player>" parameters: "<player>"
success-everyone: "&aSuccessfully reset &beveryone&a's resets to &b0&a."
success: "&aSuccessfully reset &b[name]&a's resets to &b0&a."
add:
description: "adds resets to the player"
parameters: "<player> <resets>"
success: "&aSuccessfully added &b[number] &aresets to &b[name], increasing the total to &b[total]&a resets."
remove:
description: "removes resets to the player"
parameters: "<player> <resets>"
success: "&aSuccessfully removed &b[number] &aresets to &b[name], decreasing the total to &b[total]&a resets."
purge: purge:
parameters: "[days]" parameters: "[days]"
description: "purge islands abandoned for more than [days]" description: "purge islands abandoned for more than [days]"