mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-12-01 13:23:56 +01:00
Finished mega plots (unlink now removes roads)
This commit is contained in:
parent
c4635be66b
commit
e1cfde520e
@ -27,7 +27,7 @@ import java.util.*;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PlotHelper {
|
public class PlotHelper {
|
||||||
static boolean canSetFast;
|
static boolean canSetFast = false;
|
||||||
static long state;
|
static long state;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -693,6 +693,8 @@ public class PlotHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setCuboid(World world, Location pos1, Location pos2, short[] id_l, short[] d_l) {
|
public static void setCuboid(World world, Location pos1, Location pos2, short[] id_l, short[] d_l) {
|
||||||
|
System.out.print("S "+pos1.getBlockX()+" | "+pos1.getBlockY()+" | "+pos1.getBlockZ());
|
||||||
|
System.out.print("E "+pos2.getBlockX()+" | "+pos2.getBlockY()+" | "+pos2.getBlockZ());
|
||||||
if (!canSetFast) {
|
if (!canSetFast) {
|
||||||
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||||
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
|
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
|
||||||
@ -725,7 +727,6 @@ public class PlotHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -26,6 +27,7 @@ import com.intellectualcrafters.plot.PlotMain;
|
|||||||
import com.intellectualcrafters.plot.PlotWorld;
|
import com.intellectualcrafters.plot.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.SetBlockFast;
|
import com.intellectualcrafters.plot.SetBlockFast;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -103,7 +105,16 @@ public class Merge extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(plr, "PLOTS HAVE BEEN MERGED");
|
|
||||||
|
PlotMergeEvent event = new PlotMergeEvent(world, plot, plots);
|
||||||
|
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
PlayerFunctions.sendMessage(plr, "&cMerge has been cancelled");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PlayerFunctions.sendMessage(plr, "&cPlots have been merged");
|
||||||
return mergePlot(world, plr, PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,bot.y), new PlotId(top.x,top.y)), plots, direction, direction2);
|
return mergePlot(world, plr, PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,bot.y), new PlotId(top.x,top.y)), plots, direction, direction2);
|
||||||
}
|
}
|
||||||
public static boolean mergePlot(World world, Player player, ArrayList<PlotId> currentMegaPlots, ArrayList<PlotId> toMerge, int dir1, int dir2) {
|
public static boolean mergePlot(World world, Player player, ArrayList<PlotId> currentMegaPlots, ArrayList<PlotId> toMerge, int dir1, int dir2) {
|
||||||
|
@ -24,6 +24,7 @@ import com.intellectualcrafters.plot.PlotId;
|
|||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
import com.intellectualcrafters.plot.PlotSettings;
|
import com.intellectualcrafters.plot.PlotSettings;
|
||||||
import com.intellectualcrafters.plot.PlotWorld;
|
import com.intellectualcrafters.plot.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.SetBlockFast;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
||||||
import com.intellectualcrafters.plot.events.PlotUnlinkEvent;
|
import com.intellectualcrafters.plot.events.PlotUnlinkEvent;
|
||||||
@ -120,20 +121,31 @@ public class Unlink extends SubCommand {
|
|||||||
PlotId id = new PlotId(x,y);
|
PlotId id = new PlotId(x,y);
|
||||||
|
|
||||||
if (lx) {
|
if (lx) {
|
||||||
|
System.out.print("LX "+id);
|
||||||
setRoadX(world, id);
|
setRoadX(world, id);
|
||||||
|
|
||||||
if (ly&&lx) {
|
if (ly) {
|
||||||
|
System.out.print("LXY "+id);
|
||||||
setRoadXY(world, id);
|
setRoadXY(world, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ly) {
|
if (ly) {
|
||||||
|
System.out.print("LY "+id);
|
||||||
setRoadY(world, id);
|
setRoadY(world, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
SetBlockFast.update(plr);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
PlayerFunctions.sendMessage(plr, "&cPLOT UNLINKING IS NOT FINISHED (as you can see by the lack of roads appearing)");
|
PlayerFunctions.sendMessage(plr, "&cPLOT UNLINKING IS NOT FINISHED (as you can see by the lack of roads appearing)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -148,16 +160,18 @@ public class Unlink extends SubCommand {
|
|||||||
|
|
||||||
int sx = pos2.getBlockX()+1;
|
int sx = pos2.getBlockX()+1;
|
||||||
int ex = sx + pathsize - 1;
|
int ex = sx + pathsize - 1;
|
||||||
int sz = pos1.getBlockZ();
|
int sz = pos1.getBlockZ()-1;
|
||||||
int ez = pos2.getBlockZ()+1;
|
int ez = pos2.getBlockZ()+2;
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w,sx,1,sz), new Location(w,sx+1,wallheight,sz+1), new short[] {wf_id}, new short[] {wf_v});
|
PlotHelper.setSimpleCuboid(w, new Location(w,sx,Math.min(wallheight, roadheight)+1,sz+1), new Location(w,ex+1,257+1,ez), (short) 0);
|
||||||
PlotHelper.setCuboid(w, new Location(w,sx,wallheight+1,sz), new Location(w,sx+1,wallheight+2,sz+1), new short[] {w_id}, new short[] {w_v});
|
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w,ex,1,ez), new Location(w,ex+1,wallheight,ez+1), new short[] {wf_id}, new short[] {wf_v});
|
PlotHelper.setCuboid(w, new Location(w,sx,1,sz+1), new Location(w,sx+1,wallheight+1,ez), new short[] {wf_id}, new short[] {wf_v});
|
||||||
PlotHelper.setCuboid(w, new Location(w,ex,wallheight+1,ez), new Location(w,ex+1,wallheight+2,ez+1), new short[] {w_id}, new short[] {w_v});
|
PlotHelper.setCuboid(w, new Location(w,sx,wallheight+1,sz+1), new Location(w,sx+1,wallheight+2,ez), new short[] {w_id}, new short[] {w_v});
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w,sx+1,1,sz+1), new Location(w,ex,roadheight,ex), new short[] {wf_id}, new short[] {wf_v});
|
PlotHelper.setCuboid(w, new Location(w,ex,1,sz+1), new Location(w,ex+1,wallheight+1,ez), new short[] {w_id}, new short[] {w_v});
|
||||||
|
PlotHelper.setCuboid(w, new Location(w,ex,wallheight+1,sz+1), new Location(w,ex+1,wallheight+2,ez), new short[] {wf_id}, new short[] {wf_v});
|
||||||
|
|
||||||
|
PlotHelper.setCuboid(w, new Location(w,sx+1,1,sz+1), new Location(w,ex,roadheight+1,ez), new short[] {f1_id}, new short[] {f1_v});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Setting the road with the greatest Y value
|
* Setting the road with the greatest Y value
|
||||||
@ -170,16 +184,18 @@ public class Unlink extends SubCommand {
|
|||||||
|
|
||||||
int sz = pos2.getBlockX()+1;
|
int sz = pos2.getBlockX()+1;
|
||||||
int ez = sz + pathsize - 1;
|
int ez = sz + pathsize - 1;
|
||||||
int sx = pos1.getBlockZ();
|
int sx = pos1.getBlockZ()-1;
|
||||||
int ex = pos2.getBlockZ()+1;
|
int ex = pos2.getBlockZ()+2;
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w,sx,1,sz), new Location(w,sx+1,wallheight,sz+1), new short[] {wf_id}, new short[] {wf_v});
|
PlotHelper.setSimpleCuboid(w, new Location(w,sx,Math.min(wallheight, roadheight)+1,sz+1), new Location(w,ex+1,257+1,ez), (short) 0);
|
||||||
PlotHelper.setCuboid(w, new Location(w,sx,wallheight+1,sz), new Location(w,sx+1,wallheight+2,sz+1), new short[] {w_id}, new short[] {w_v});
|
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w,ex,1,ez), new Location(w,ex+1,wallheight,ez+1), new short[] {wf_id}, new short[] {wf_v});
|
PlotHelper.setCuboid(w, new Location(w,sx,1,sz+1), new Location(w,sx+1,wallheight+1,ez), new short[] {wf_id}, new short[] {wf_v});
|
||||||
PlotHelper.setCuboid(w, new Location(w,ex,wallheight+1,ez), new Location(w,ex+1,wallheight+2,ez+1), new short[] {w_id}, new short[] {w_v});
|
PlotHelper.setCuboid(w, new Location(w,sx,wallheight+1,sz+1), new Location(w,sx+1,wallheight+2,ez), new short[] {w_id}, new short[] {w_v});
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w,sx+1,1,sz+1), new Location(w,ex,roadheight,ex), new short[] {wf_id}, new short[] {wf_v});
|
PlotHelper.setCuboid(w, new Location(w,ex,1,sz+1), new Location(w,ex+1,wallheight+1,ez), new short[] {wf_id}, new short[] {wf_v});
|
||||||
|
PlotHelper.setCuboid(w, new Location(w,ex,wallheight+1,sz+1), new Location(w,ex+1,wallheight+2,ez), new short[] {w_id}, new short[] {w_v});
|
||||||
|
|
||||||
|
PlotHelper.setCuboid(w, new Location(w,sx+1,1,sz+1), new Location(w,ex,roadheight+1,ez), new short[] {f1_id}, new short[] {f1_v});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Setting the intersection with the greatest X and Y value
|
* Setting the intersection with the greatest X and Y value
|
||||||
@ -194,6 +210,8 @@ public class Unlink extends SubCommand {
|
|||||||
int sz = pos2.getBlockZ()+2;
|
int sz = pos2.getBlockZ()+2;
|
||||||
int ez = sz + pathsize - 1;
|
int ez = sz + pathsize - 1;
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w,sx+1,1,sz+1), new Location(w,ex,roadheight,ex), new short[] {wf_id}, new short[] {wf_v});
|
PlotHelper.setSimpleCuboid(w, new Location(w,sx,roadheight+1,sz+1), new Location(w,ex+1,257+1,ez), (short) 0);
|
||||||
|
|
||||||
|
PlotHelper.setCuboid(w, new Location(w,sx+1,1,sz+1), new Location(w,ex,roadheight+1,ez), new short[] {f1_id}, new short[] {f1_v});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,9 @@ public class PlotMeConverter {
|
|||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
HashMap<String, Plot> plots = PlotManager.getPlots(world);
|
HashMap<String, Plot> plots = PlotManager.getPlots(world);
|
||||||
if (plots!=null) {
|
if (plots!=null) {
|
||||||
|
|
||||||
|
// TODO generate configuration based on PlotMe config
|
||||||
|
|
||||||
PlotMain.sendConsoleSenderMessage("Converting " + plots.size() + " plots for '" + world.toString() + "'...");
|
PlotMain.sendConsoleSenderMessage("Converting " + plots.size() + " plots for '" + world.toString() + "'...");
|
||||||
for (Plot plot : plots.values()) {
|
for (Plot plot : plots.values()) {
|
||||||
PlayerList denied = null;
|
PlayerList denied = null;
|
||||||
@ -77,6 +80,9 @@ public class PlotMeConverter {
|
|||||||
stream.println(eR3040bl230);
|
stream.println(eR3040bl230);
|
||||||
PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1]));
|
PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1]));
|
||||||
com.intellectualcrafters.plot.Plot pl = new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] {false, false, false, false} );
|
com.intellectualcrafters.plot.Plot pl = new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] {false, false, false, false} );
|
||||||
|
|
||||||
|
// TODO createPlot doesn't add helpers / denied users
|
||||||
|
|
||||||
DBFunc.createPlot(pl);
|
DBFunc.createPlot(pl);
|
||||||
DBFunc.createPlotSettings(DBFunc.getId(world.getName(), pl.id), pl);
|
DBFunc.createPlotSettings(DBFunc.getId(world.getName(), pl.id), pl);
|
||||||
}
|
}
|
||||||
@ -84,6 +90,10 @@ public class PlotMeConverter {
|
|||||||
}
|
}
|
||||||
stream.close();
|
stream.close();
|
||||||
PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has finished");
|
PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has finished");
|
||||||
|
|
||||||
|
// TODO disable PlotMe -> Unload all plot worlds, change the generator, restart the server automatically
|
||||||
|
// Possibly use multiverse / multiworld if it's to difficult modifying a world's generator while the server is running
|
||||||
|
|
||||||
Bukkit.getPluginManager().disablePlugin(PlotMeConverter.this.plugin);
|
Bukkit.getPluginManager().disablePlugin(PlotMeConverter.this.plugin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -9,8 +9,10 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.events;
|
package com.intellectualcrafters.plot.events;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -18,6 +20,7 @@ import org.bukkit.event.HandlerList;
|
|||||||
import org.bukkit.event.player.PlayerEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Citymonstret on 2014-08-09.
|
* Created by Citymonstret on 2014-08-09.
|
||||||
@ -26,24 +29,37 @@ public class PlotMergeEvent extends Event implements Cancellable {
|
|||||||
private static HandlerList handlers = new HandlerList();
|
private static HandlerList handlers = new HandlerList();
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
private Set<Plot> plots;
|
private ArrayList<PlotId> plots;
|
||||||
|
private Plot plot;
|
||||||
|
private World world;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlotMergeEvent: Called when a plot is merged
|
* PlotMergeEvent: Called when plots are merged
|
||||||
* @param player
|
* @param player
|
||||||
* @param plot
|
* @param plot
|
||||||
*/
|
*/
|
||||||
public PlotMergeEvent(Set<Plot> plots) {
|
public PlotMergeEvent(World world, Plot plot, ArrayList<PlotId> plots) {
|
||||||
this.plots = plots;
|
this.plots = plots;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the plots involved
|
* Get the plots being added;
|
||||||
* @return Plot
|
* @return Plot
|
||||||
*/
|
*/
|
||||||
public Set<Plot> getPlost() {
|
public ArrayList<PlotId> getPlots() {
|
||||||
return this.plots;
|
return this.plots;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Get the main plot
|
||||||
|
* @return Plot
|
||||||
|
*/
|
||||||
|
public Plot getPlot() {
|
||||||
|
return this.plot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public World getWorld() {
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
|
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* 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 = PlayerClaimPlotEvent.java
|
||||||
|
* >> Generated by: Citymonstret at 2014-08-09 15:21
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.intellectualcrafters.plot.events;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Citymonstret on 2014-08-09.
|
||||||
|
*/
|
||||||
|
public class PlotUnlinkEvent extends Event implements Cancellable {
|
||||||
|
private static HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
private ArrayList<PlotId> plots;
|
||||||
|
private World world;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a mega-plot is unlinked.
|
||||||
|
* @param world
|
||||||
|
* @param plots
|
||||||
|
*/
|
||||||
|
public PlotUnlinkEvent(World world, ArrayList<PlotId> plots) {
|
||||||
|
this.plots = plots;
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the plots involved
|
||||||
|
* @return PlotId
|
||||||
|
*/
|
||||||
|
public ArrayList<PlotId> getPlots() {
|
||||||
|
return this.plots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public World getWorld() {
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return this.cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean b) {
|
||||||
|
this.cancelled = b;
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,11 @@ import org.bukkit.event.Listener;
|
|||||||
*/
|
*/
|
||||||
public class WorldGuardListener implements Listener {
|
public class WorldGuardListener implements Listener {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO recreate WG region when a plot is merged
|
||||||
|
* - It should use the region of the main plot, and delete the other ones.
|
||||||
|
*/
|
||||||
|
|
||||||
private PlotMain plugin;
|
private PlotMain plugin;
|
||||||
|
|
||||||
public WorldGuardListener(PlotMain plugin) {
|
public WorldGuardListener(PlotMain plugin) {
|
||||||
|
Loading…
Reference in New Issue
Block a user