mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Fixes to merge methods
- Merged automatically added to DB - Started work on commands - Fixed getCurrentPlot not working for roads
This commit is contained in:
parent
5d0f377d3b
commit
eb7106eb76
@ -53,7 +53,7 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Permission
|
* Permission
|
||||||
*/
|
*/
|
||||||
NO_PERMISSION("&cYou don't have the permissions required to use this command."), NO_PLOT_PERMS("&cYou don't have the permissions to do that in this plot"), CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."), YOU_BE_DENIED("&cYou are not allowed to enter this plot"),
|
NO_PERMISSION("&cYou don't have the permissions required to use this command."), NO_PLOT_PERMS("&cYou don't have the permissions to do that in this plot"), CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."), YOU_BE_DENIED("&cYou are not allowed to enter this plot"), NO_PERM_MERGE("&cYou must be the owner of all plots taking place in the merge."),
|
||||||
/*
|
/*
|
||||||
* Commands
|
* Commands
|
||||||
*/
|
*/
|
||||||
|
@ -58,8 +58,25 @@ public class PlayerFunctions {
|
|||||||
|
|
||||||
public static Set<PlotId> getPlotSelectionIds(World world, PlotId pos1, PlotId pos2) {
|
public static Set<PlotId> getPlotSelectionIds(World world, PlotId pos1, PlotId pos2) {
|
||||||
Set<PlotId> myplots = new HashSet<PlotId>();
|
Set<PlotId> myplots = new HashSet<PlotId>();
|
||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
int sx, ex, sy, ey;
|
||||||
for (int y = pos1.y; x <= pos2.y; x++) {
|
if (pos1.x > pos2.x) {
|
||||||
|
sx = pos2.x;
|
||||||
|
ex = pos1.x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sx = pos1.x;
|
||||||
|
ex = pos2.x;
|
||||||
|
}
|
||||||
|
if (pos1.y > pos2.y) {
|
||||||
|
sy = pos2.y;
|
||||||
|
ey = pos1.y;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sy = pos1.y;
|
||||||
|
ey = pos2.y;
|
||||||
|
}
|
||||||
|
for (int x = sx; x <= ex; x++) {
|
||||||
|
for (int y = sy; x <= ey; x++) {
|
||||||
myplots.add(new PlotId(x,y));
|
myplots.add(new PlotId(x,y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,20 +139,43 @@ public class PlayerFunctions {
|
|||||||
|
|
||||||
int end = pathWidthLower+plotworld.PLOT_WIDTH;
|
int end = pathWidthLower+plotworld.PLOT_WIDTH;
|
||||||
|
|
||||||
if (rx<=pathWidthLower) {
|
boolean northSouth = rz<=pathWidthLower || rz>pathWidthLower+plotworld.PLOT_WIDTH;
|
||||||
// System.out.print("WEST");
|
boolean eastWest = rx<=pathWidthLower || rx>end;
|
||||||
|
|
||||||
|
if (northSouth && eastWest) {
|
||||||
|
// This means you are in the intersection
|
||||||
|
PlotId id = getPlot(loc.add(plotworld.ROAD_WIDTH, 0, plotworld.ROAD_WIDTH));
|
||||||
|
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||||
|
if (plot==null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (plot.settings.getMerged(0) && plot.settings.getMerged(3)) {
|
||||||
|
return getBottomPlot(loc.getWorld(), plot).id;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (rx>end) {
|
if (northSouth) {
|
||||||
// System.out.print("EAST");
|
// You are on a road running West to East (yeah, I named the var poorly)
|
||||||
|
PlotId id = getPlot(loc.add(0, 0, plotworld.ROAD_WIDTH));
|
||||||
|
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||||
|
if (plot==null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (plot.settings.getMerged(0)) {
|
||||||
|
return getBottomPlot(loc.getWorld(), plot).id;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (rz<=pathWidthLower) {
|
if (eastWest) {
|
||||||
// System.out.print("NORTH");
|
// This is the road separating an Eastern and Western plot
|
||||||
return null;
|
PlotId id = getPlot(loc.add(plotworld.ROAD_WIDTH, 0, 0));
|
||||||
}
|
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||||
if (rz>pathWidthLower+plotworld.PLOT_WIDTH) {
|
if (plot==null) {
|
||||||
// System.out.print("SOUTH");
|
return null;
|
||||||
|
}
|
||||||
|
if (plot.settings.getMerged(3)) {
|
||||||
|
return getBottomPlot(loc.getWorld(), plot).id;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
PlotId id = new PlotId(dx+1,dz+1);
|
PlotId id = new PlotId(dx+1,dz+1);
|
||||||
|
@ -27,6 +27,10 @@ public enum Command {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
CLAIM("claim", "c"),
|
CLAIM("claim", "c"),
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
MERGE("merge", "m"),
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) IntellectualCrafters - 2014.
|
||||||
|
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||||
|
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||||
|
*
|
||||||
|
* >> File = Merge.java
|
||||||
|
* >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.C;
|
||||||
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Citymonstret
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Merge extends SubCommand {
|
||||||
|
|
||||||
|
public Merge() {
|
||||||
|
super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(Player plr, String... args) {
|
||||||
|
if (!PlayerFunctions.isInPlot(plr)) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
|
if (!plot.hasOwner()) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!plot.getOwner().equals(plr.getUniqueId())) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// get the plots involved
|
||||||
|
|
||||||
|
// C.NO_PERM_MERGE;
|
||||||
|
|
||||||
|
// for each plot check if you are the owner
|
||||||
|
|
||||||
|
// execute the merge
|
||||||
|
|
||||||
|
// add methods to get plots relative to your current plot
|
||||||
|
// getNorthernPlot | getEasternPlot | getSouthernPlot | getWesternPlot
|
||||||
|
// return mergePlot(plr, plot, false);
|
||||||
|
|
||||||
|
// merge the plots
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean mergePlot(Player player, Plot plot, java.util.Set<Plot> plots) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -223,7 +223,13 @@ public class DBFunc {
|
|||||||
statement.addBatch("UPDATE `plot` SET\n" + " `plot_id_x` = IF(" + " LOCATE(';', `plot_id`) > 0," + " SUBSTRING(`plot_id`, 1, LOCATE(';', `plot_id`) - 1)," + " `plot_id`" + " )," + " `plot_id_z` = IF(" + " LOCATE(';', `plot_id`) > 0," + " SUBSTRING(`plot_id`, LOCATE(';', `plot_id`) + 1)," + " NULL" + " )");
|
statement.addBatch("UPDATE `plot` SET\n" + " `plot_id_x` = IF(" + " LOCATE(';', `plot_id`) > 0," + " SUBSTRING(`plot_id`, 1, LOCATE(';', `plot_id`) - 1)," + " `plot_id`" + " )," + " `plot_id_z` = IF(" + " LOCATE(';', `plot_id`) > 0," + " SUBSTRING(`plot_id`, LOCATE(';', `plot_id`) + 1)," + " NULL" + " )");
|
||||||
statement.addBatch("ALTER TABLE `plot` DROP `plot_id`");
|
statement.addBatch("ALTER TABLE `plot` DROP `plot_id`");
|
||||||
statement.addBatch("ALTER IGNORE TABLE `plot_settings` ADD `flags` VARCHAR(512) DEFAULT NULL");
|
statement.addBatch("ALTER IGNORE TABLE `plot_settings` ADD `flags` VARCHAR(512) DEFAULT NULL");
|
||||||
statement.addBatch("ALTER IGNORE TABLE `plot_settings` ADD `merged` int(11) DEFAULT 0");
|
statement.executeBatch();
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
rs = data.getColumns(null, null, "plot_settings", "merged");
|
||||||
|
if (!rs.next()) {
|
||||||
|
Statement statement = connection.createStatement();
|
||||||
|
statement.addBatch("ALTER IGNORE TABLE `plot_settings` ADD `merged` int(11) DEFAULT NULL");
|
||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
statement.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user