mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Working on flag system
This commit is contained in:
parent
6b988f616a
commit
277018df63
@ -168,11 +168,6 @@ import org.bukkit.entity.Player;
|
||||
br = true;
|
||||
final PlotWorld pw = PlotMain.getWorldSettings(world);
|
||||
final Plot plot2 = PlotMain.getPlots(world).get(plot.id);
|
||||
if ((pw.DEFAULT_FLAGS != null) && (pw.DEFAULT_FLAGS.size() > 0)) {
|
||||
final Flag[] flags = FlagManager.parseFlags(pw.DEFAULT_FLAGS);
|
||||
plot2.settings.setFlags(flags);
|
||||
DBFunc.setFlags(plot2.world, plot2, flags);
|
||||
}
|
||||
}
|
||||
Auto.lastPlot = getNextPlot(Auto.lastPlot, 1);
|
||||
}
|
||||
@ -204,11 +199,6 @@ import org.bukkit.entity.Player;
|
||||
br = true;
|
||||
final PlotWorld pw = PlotMain.getWorldSettings(world);
|
||||
final Plot plot2 = PlotMain.getPlots(world).get(start);
|
||||
if ((pw.DEFAULT_FLAGS != null) && (pw.DEFAULT_FLAGS.size() > 0)) {
|
||||
final Flag[] flags = FlagManager.parseFlags(pw.DEFAULT_FLAGS);
|
||||
plot2.settings.setFlags(flags);
|
||||
DBFunc.setFlags(plot2.world, plot2, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,11 +79,6 @@ public class Claim extends SubCommand {
|
||||
}
|
||||
SchematicHandler.paste(player.getLocation(), sch, plot2, 0, 0);
|
||||
}
|
||||
if ((world.DEFAULT_FLAGS != null) && (world.DEFAULT_FLAGS.size() > 0)) {
|
||||
final Flag[] flags = FlagManager.parseFlags(world.DEFAULT_FLAGS);
|
||||
plot2.settings.setFlags(flags);
|
||||
DBFunc.setFlags(plot.world, plot2, flags);
|
||||
}
|
||||
if (world instanceof HybridPlotWorld) {
|
||||
final HybridPlotWorld pW = (HybridPlotWorld) world;
|
||||
if (pW.CLAIMED_WALL_BLOCK != pW.WALL_BLOCK) {
|
||||
|
@ -67,7 +67,6 @@ public class DebugClaimTest extends SubCommand {
|
||||
if (teleport) {
|
||||
PlotMain.teleportPlayer(player, player.getLocation(), plot);
|
||||
}
|
||||
plot.settings.setFlags(FlagManager.parseFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS));
|
||||
}
|
||||
return event.isCancelled();
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ import java.util.UUID;
|
||||
|
||||
String owner = "none";
|
||||
if (plot.owner != null) {
|
||||
owner = UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner).getName();
|
||||
owner = UUIDHandler.getName(plot.owner);
|
||||
}
|
||||
if (owner == null) {
|
||||
owner = plot.owner.toString();
|
||||
@ -225,10 +225,6 @@ import java.util.UUID;
|
||||
if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) {
|
||||
return "everyone";
|
||||
}
|
||||
/*
|
||||
* OfflinePlayer plr = Bukkit.getOfflinePlayer(uuid); if (plr.getName()
|
||||
* == null) { return "unknown"; } return plr.getName();
|
||||
*/
|
||||
String name = UUIDHandler.getName(uuid);
|
||||
if (name == null) {
|
||||
return "unknown";
|
||||
|
@ -142,13 +142,9 @@ public class Set extends SubCommand {
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
}
|
||||
final java.util.Set<Flag> newflags = plot.settings.getFlags();
|
||||
final Flag oldFlag = plot.settings.getFlag(args[1].toLowerCase());
|
||||
if (oldFlag != null) {
|
||||
newflags.remove(oldFlag);
|
||||
}
|
||||
plot.settings.setFlags(newflags.toArray(new Flag[newflags.size()]));
|
||||
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[newflags.size()]));
|
||||
final java.util.Set<Flag> newflags = FlagManager.removeFlag(plot.settings.getFlags(), args[1].toLowerCase());
|
||||
plot.settings.setFlags(newflags);
|
||||
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags);
|
||||
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
|
||||
PlotListener.plotEntry(plr, plot);
|
||||
return true;
|
||||
@ -175,8 +171,7 @@ public class Set extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
plot.settings.addFlag(flag);
|
||||
final java.util.Set<Flag> flags = plot.settings.getFlags();
|
||||
DBFunc.setFlags(plr.getWorld().getName(), plot, flags.toArray(new Flag[flags.size()]));
|
||||
DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags());
|
||||
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
|
||||
PlotListener.plotEntry(plr, plot);
|
||||
return true;
|
||||
|
@ -109,7 +109,7 @@ public enum C {
|
||||
/*
|
||||
* Title Stuff
|
||||
*/
|
||||
TITLE_ENTERED_PLOT("You entered plot %s"),
|
||||
TITLE_ENTERED_PLOT("You entered plot %world%;%x%;%z%"),
|
||||
TITLE_ENTERED_PLOT_COLOR("GOLD"),
|
||||
TITLE_ENTERED_PLOT_SUB("Owned by %s"),
|
||||
TITLE_ENTERED_PLOT_SUB_COLOR("RED"),
|
||||
|
@ -25,12 +25,14 @@ import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotComment;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -130,7 +132,7 @@ public interface AbstractDB {
|
||||
* @param plot Plot Object
|
||||
* @param flags flags to set (flag[])
|
||||
*/
|
||||
public void setFlags(final String world, final Plot plot, final Flag[] flags);
|
||||
public void setFlags(final String world, final Plot plot, final Set<Flag> flags);
|
||||
|
||||
/**
|
||||
* Set the plot alias
|
||||
|
@ -25,11 +25,13 @@ import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotComment;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -156,7 +158,7 @@ public class DBFunc {
|
||||
dbManager.setMerged(world, plot, merged);
|
||||
}
|
||||
|
||||
public static void setFlags(final String world, final Plot plot, final Flag[] flags) {
|
||||
public static void setFlags(final String world, final Plot plot, final Set<Flag> flags) {
|
||||
dbManager.setFlags(world, plot, flags);
|
||||
}
|
||||
|
||||
|
@ -659,7 +659,7 @@ public class SQLManager implements AbstractDB {
|
||||
} else {
|
||||
flags_string = myflags.split(",");
|
||||
}
|
||||
final ArrayList<Flag> flags = new ArrayList<Flag>();
|
||||
final Set<Flag> flags = new HashSet<Flag>();
|
||||
boolean exception = false;
|
||||
for (final String element : flags_string) {
|
||||
if (element.contains(":")) {
|
||||
@ -677,7 +677,7 @@ public class SQLManager implements AbstractDB {
|
||||
PlotMain.sendConsoleSenderMessage("&cPlot " + id + " had an invalid flag. A fix has been attempted.");
|
||||
setFlags(id, flags.toArray(new Flag[0]));
|
||||
}
|
||||
plot.settings.setFlags(flags.toArray(new Flag[0]));
|
||||
plot.settings.setFlags(flags);
|
||||
} else {
|
||||
PlotMain.sendConsoleSenderMessage("&cPLOT " + id + " in plot_settings does not exist. Please create the plot or remove this entry.");
|
||||
}
|
||||
@ -730,7 +730,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlags(final String world, final Plot plot, final Flag[] flags) {
|
||||
public void setFlags(final String world, final Plot plot, final Set<Flag> flags) {
|
||||
plot.settings.setFlags(flags);
|
||||
final StringBuilder flag_string = new StringBuilder();
|
||||
int i = 0;
|
||||
|
@ -22,9 +22,11 @@
|
||||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -65,15 +67,15 @@ import java.util.Set;
|
||||
return f;
|
||||
}
|
||||
|
||||
public static Flag[] removeFlag(final Set<Flag> flags, final String r) {
|
||||
final Flag[] flagArray = new Flag[flags.size() - 1];
|
||||
public static Set<Flag> removeFlag(final Set<Flag> flags, final String r) {
|
||||
final HashSet<Flag> newflags = new HashSet<>();
|
||||
int index = 0;
|
||||
for (final Flag flag : flags) {
|
||||
if (!flag.getKey().equals(r)) {
|
||||
flagArray[index++] = flag;
|
||||
if (!flag.getKey().equalsIgnoreCase(r)) {
|
||||
newflags.add(flag);
|
||||
}
|
||||
}
|
||||
return flagArray;
|
||||
return newflags;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,7 @@ package com.intellectualcrafters.plot.listeners;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
|
||||
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
@ -188,13 +189,14 @@ import java.util.UUID;
|
||||
player.setPlayerTime(time, true);
|
||||
} catch (final Exception e) {
|
||||
plot.settings.setFlags(FlagManager.removeFlag(plot.settings.getFlags(), "time"));
|
||||
DBFunc.setFlags(plot.world, plot, plot.settings.getFlags());
|
||||
}
|
||||
}
|
||||
if (plot.settings.getFlag("weather") != null) {
|
||||
player.setPlayerWeather(getWeatherType(plot.settings.getFlag("weather").getValue()));
|
||||
}
|
||||
if ((booleanFlag(plot, "titles") || Settings.TITLES) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) {
|
||||
final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", plot.getDisplayName());
|
||||
final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%y%", plot.id.y + "").replaceAll("%world%", plot.world + "");
|
||||
final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner));
|
||||
final ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s());
|
||||
final ChatColor sTitleSubColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s());
|
||||
|
@ -26,12 +26,15 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -108,7 +111,7 @@ import java.util.UUID;
|
||||
this.settings.setAlias("");
|
||||
this.settings.setPosition(PlotHomePosition.DEFAULT);
|
||||
this.delete = false;
|
||||
this.settings.setFlags(new Flag[0]);
|
||||
this.settings.setFlags(new HashSet<Flag>());
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@ -131,7 +134,7 @@ import java.util.UUID;
|
||||
this.settings.setAlias("");
|
||||
this.settings.setPosition(PlotHomePosition.DEFAULT);
|
||||
this.delete = false;
|
||||
this.settings.setFlags(new Flag[0]);
|
||||
this.settings.setFlags(new HashSet<Flag>());
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@ -149,7 +152,7 @@ import java.util.UUID;
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("unused")
|
||||
public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final PlotHomePosition position, final Flag[] flags, final String world, final boolean[] merged) {
|
||||
public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final PlotHomePosition position, final Set<Flag> flags, final String world, final boolean[] merged) {
|
||||
this.id = id;
|
||||
this.settings = new PlotSettings(this);
|
||||
this.owner = owner;
|
||||
@ -164,7 +167,7 @@ import java.util.UUID;
|
||||
if (flags != null) {
|
||||
this.settings.setFlags(flags);
|
||||
} else {
|
||||
this.settings.setFlags(new Flag[0]);
|
||||
this.settings.setFlags(new HashSet<Flag>());
|
||||
}
|
||||
this.world = world;
|
||||
}
|
||||
@ -178,7 +181,7 @@ import java.util.UUID;
|
||||
* @param denied
|
||||
* @param merged
|
||||
*/
|
||||
public Plot(final PlotId id, final UUID owner, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final PlotHomePosition position, final Flag[] flags, final String world, final boolean[] merged) {
|
||||
public Plot(final PlotId id, final UUID owner, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final PlotHomePosition position, final Set<Flag> flags, final String world, final boolean[] merged) {
|
||||
this.id = id;
|
||||
this.settings = new PlotSettings(this);
|
||||
this.owner = owner;
|
||||
@ -193,7 +196,7 @@ import java.util.UUID;
|
||||
if (flags != null) {
|
||||
this.settings.setFlags(flags);
|
||||
} else {
|
||||
this.settings.setFlags(new Flag[0]);
|
||||
this.settings.setFlags(new HashSet<Flag>());
|
||||
}
|
||||
this.world = world;
|
||||
}
|
||||
@ -268,7 +271,7 @@ import java.util.UUID;
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
final Plot p = (Plot) super.clone();
|
||||
if (!p.equals(this) || (p != this)) {
|
||||
return new Plot(this.id, this.owner, this.helpers, this.trusted, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.getFlags().toArray(new Flag[this.settings.getFlags().size()]), getWorld().getName(), this.settings.getMerged());
|
||||
return new Plot(this.id, this.owner, this.helpers, this.trusted, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.getFlags(), getWorld().getName(), this.settings.getMerged());
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@ -305,11 +308,11 @@ import java.util.UUID;
|
||||
*
|
||||
* @return alias if set, else id
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
public String toString() {
|
||||
if (this.settings.getAlias().length() > 1) {
|
||||
return this.settings.getAlias();
|
||||
}
|
||||
return this.getId().x + ";" + this.getId().y;
|
||||
return this.world + ";" + this.getId().x + ";" + this.getId().y;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,8 +135,8 @@ import java.util.Set;
|
||||
*
|
||||
* @param flags Flag Array
|
||||
*/
|
||||
public void setFlags(@NotNull final Flag[] flags) {
|
||||
this.flags = new HashSet<>(Arrays.asList(flags));
|
||||
public void setFlags(@NotNull final Set<Flag> flags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,6 +152,7 @@ import java.util.Set;
|
||||
return myflag;
|
||||
}
|
||||
}
|
||||
// FIXME: return default flag
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,9 @@ package com.intellectualcrafters.plot.object;
|
||||
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -45,7 +48,6 @@ public abstract class PlotWorld {
|
||||
public final static boolean SCHEMATIC_ON_CLAIM_DEFAULT = false;
|
||||
public final static String SCHEMATIC_FILE_DEFAULT = "null";
|
||||
public final static List<String> SCHEMATICS_DEFAULT = null;
|
||||
public final static List<String> DEFAULT_FLAGS_DEFAULT = Arrays.asList();
|
||||
public final static boolean USE_ECONOMY_DEFAULT = false;
|
||||
public final static double PLOT_PRICE_DEFAULT = 100;
|
||||
public final static double MERGE_PRICE_DEFAULT = 100;
|
||||
@ -272,7 +274,7 @@ public abstract class PlotWorld {
|
||||
public boolean SCHEMATIC_ON_CLAIM;
|
||||
public String SCHEMATIC_FILE;
|
||||
public List<String> SCHEMATICS;
|
||||
public List<String> DEFAULT_FLAGS;
|
||||
public Flag[] DEFAULT_FLAGS;
|
||||
public boolean USE_ECONOMY;
|
||||
public double PLOT_PRICE;
|
||||
public double MERGE_PRICE;
|
||||
@ -305,9 +307,12 @@ public abstract class PlotWorld {
|
||||
this.MERGE_PRICE = config.getDouble("economy.prices.merge");
|
||||
this.SELL_PRICE = config.getDouble("economy.prices.sell");
|
||||
this.PLOT_CHAT = config.getBoolean("chat.enabled");
|
||||
this.DEFAULT_FLAGS = config.getStringList("flags.default");
|
||||
if (this.DEFAULT_FLAGS == null) {
|
||||
this.DEFAULT_FLAGS = new ArrayList<>();
|
||||
List<String> flags = config.getStringList("flags.default");
|
||||
if (flags == null) {
|
||||
this.DEFAULT_FLAGS = new Flag[] {};
|
||||
}
|
||||
else {
|
||||
this.DEFAULT_FLAGS = FlagManager.parseFlags(flags);
|
||||
}
|
||||
this.PVP = config.getBoolean("event.pvp");
|
||||
this.PVE = config.getBoolean("event.pve");
|
||||
|
@ -24,9 +24,12 @@ package com.intellectualcrafters.plot.util;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||
import com.intellectualcrafters.plot.listeners.PlotListener;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
@ -1051,6 +1054,71 @@ import java.util.UUID;
|
||||
final PlotManager manager = PlotMain.getPlotManager(world);
|
||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
||||
}
|
||||
|
||||
public static boolean checkModified(Plot plot, int requiredChanges) {
|
||||
World world = Bukkit.getWorld(plot.world);
|
||||
Location bottom = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
Location top = PlotHelper.getPlotTopLoc(world, plot.id);
|
||||
|
||||
int botx = bottom.getBlockX();
|
||||
int boty = bottom.getBlockY();
|
||||
int botz = bottom.getBlockZ();
|
||||
|
||||
int topx = top.getBlockX();
|
||||
int topy = top.getBlockY();
|
||||
int topz = top.getBlockZ();
|
||||
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) PlotMain.getWorldSettings(world);
|
||||
|
||||
PlotBlock[] air = new PlotBlock[] {new PlotBlock((short) 0, (byte) 0)};
|
||||
|
||||
int changes = checkModified(requiredChanges, world, botx, topx, hpw.PLOT_HEIGHT, hpw.PLOT_HEIGHT, botz, topz, hpw.TOP_BLOCK);
|
||||
if (changes == -1) {
|
||||
return true;
|
||||
}
|
||||
requiredChanges -= changes;
|
||||
changes = checkModified(requiredChanges, world, botx, topx, hpw.PLOT_HEIGHT + 1, hpw.PLOT_HEIGHT + 1, botz, topz, air);
|
||||
if (changes == -1) {
|
||||
return true;
|
||||
}
|
||||
requiredChanges -= changes;
|
||||
changes = checkModified(requiredChanges, world, botx, topx, hpw.PLOT_HEIGHT + 2, world.getMaxHeight(), botz, topz, air);
|
||||
if (changes == -1) {
|
||||
return true;
|
||||
}
|
||||
requiredChanges -= changes;
|
||||
changes = checkModified(requiredChanges, world, botx, topx, 1, hpw.PLOT_HEIGHT, botz, topz, hpw.MAIN_BLOCK);
|
||||
if (changes == -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int checkModified(int threshhold, World world, int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks) {
|
||||
int count = 0;
|
||||
for (int y = y1; y <= y2; y++) {
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
for (int z = z1; z <= z2; z++) {
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
int id = block.getTypeId();
|
||||
boolean same = false;
|
||||
for (PlotBlock p : blocks) {
|
||||
if (id == p.id) {
|
||||
same = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!same) {
|
||||
count++;
|
||||
if (count > threshhold) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the plot from the main class
|
||||
|
Loading…
Reference in New Issue
Block a user