mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 18:24:43 +02:00
Hows this?
This commit is contained in:
@ -44,57 +44,44 @@ category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.claim",
|
||||
usage = "/plot claim")
|
||||
public class Claim extends SubCommand
|
||||
{
|
||||
|
||||
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final boolean auto)
|
||||
{
|
||||
public class Claim extends SubCommand {
|
||||
|
||||
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final boolean auto) {
|
||||
return claimPlot(player, plot, teleport, "", auto);
|
||||
}
|
||||
|
||||
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final String schematic, final boolean auto)
|
||||
{
|
||||
if (plot.hasOwner() || plot.getSettings().isMerged()) { return false; }
|
||||
|
||||
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) {
|
||||
if (plot.hasOwner() || plot.getSettings().isMerged()) {
|
||||
return false;
|
||||
}
|
||||
final boolean result = EventUtil.manager.callClaim(player, plot, false);
|
||||
if (result)
|
||||
{
|
||||
if (result) {
|
||||
MainUtil.createPlot(player.getUUID(), plot);
|
||||
MainUtil.setSign(player.getName(), plot);
|
||||
MainUtil.sendMessage(player, C.CLAIMED);
|
||||
final Location loc = player.getLocation();
|
||||
if (teleport)
|
||||
{
|
||||
if (teleport) {
|
||||
MainUtil.teleportPlayer(player, loc, plot);
|
||||
}
|
||||
final String world = plot.world;
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
final Plot plot2 = PS.get().getPlot(world, plot.id);
|
||||
if (plotworld.SCHEMATIC_ON_CLAIM)
|
||||
{
|
||||
if (plotworld.SCHEMATIC_ON_CLAIM) {
|
||||
Schematic sch;
|
||||
if (schematic.equals(""))
|
||||
{
|
||||
if (schematic.equals("")) {
|
||||
sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sch = SchematicHandler.manager.getSchematic(schematic);
|
||||
if (sch == null)
|
||||
{
|
||||
if (sch == null) {
|
||||
sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE);
|
||||
}
|
||||
}
|
||||
SchematicHandler.manager.paste(sch, plot2, 0, 0, new RunnableVal<Boolean>()
|
||||
{
|
||||
SchematicHandler.manager.paste(sch, plot2, 0, 0, new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
public void run() {
|
||||
if (value) {
|
||||
MainUtil.sendMessage(player, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.SCHEMATIC_PASTE_FAILED);
|
||||
}
|
||||
}
|
||||
@ -104,40 +91,45 @@ public class Claim extends SubCommand
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args)
|
||||
{
|
||||
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
|
||||
String schematic = "";
|
||||
if (args.length >= 1)
|
||||
{
|
||||
if (args.length >= 1) {
|
||||
schematic = args[0];
|
||||
}
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); }
|
||||
if (plot == null) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final int currentPlots = Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(loc.getWorld(), plr);
|
||||
if (currentPlots >= MainUtil.getAllowedPlots(plr)) { return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); }
|
||||
if (!MainUtil.canClaim(plr, plot)) { return sendMessage(plr, C.PLOT_IS_CLAIMED); }
|
||||
if (currentPlots >= MainUtil.getAllowedPlots(plr)) {
|
||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
if (!MainUtil.canClaim(plr, plot)) {
|
||||
return sendMessage(plr, C.PLOT_IS_CLAIMED);
|
||||
}
|
||||
final PlotWorld world = PS.get().getPlotWorld(plot.world);
|
||||
if ((EconHandler.manager != null) && world.USE_ECONOMY)
|
||||
{
|
||||
if ((EconHandler.manager != null) && world.USE_ECONOMY) {
|
||||
final double cost = world.PLOT_PRICE;
|
||||
if (cost > 0d)
|
||||
{
|
||||
if (EconHandler.manager.getMoney(plr) < cost) { return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost); }
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(plr, cost);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
if (!schematic.equals(""))
|
||||
{
|
||||
if (world.SCHEMATIC_CLAIM_SPECIFY)
|
||||
{
|
||||
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) { return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); }
|
||||
if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !Permissions.hasPermission(plr, "plots.admin.command.schematic")) { return sendMessage(plr,
|
||||
C.NO_SCHEMATIC_PERMISSION, schematic); }
|
||||
if (!schematic.equals("")) {
|
||||
if (world.SCHEMATIC_CLAIM_SPECIFY) {
|
||||
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||
return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
}
|
||||
if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !Permissions.hasPermission(plr, "plots.admin.command.schematic")) {
|
||||
return sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
|
||||
}
|
||||
}
|
||||
}
|
||||
return claimPlot(plr, plot, false, schematic, false) || sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||
|
Reference in New Issue
Block a user