Merge pull request #2560 from IntellectualSites/we

"Use WorldEdit classes" because actually descriptive commitmessages are dumb, right?
This commit is contained in:
Alexander Söderberg 2019-11-10 15:56:41 +01:00 committed by GitHub
commit be93e6efdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
160 changed files with 2141 additions and 2776 deletions

View File

@ -7,7 +7,19 @@ import com.github.intellectualsites.plotsquared.bukkit.listeners.PlayerEvents;
import com.github.intellectualsites.plotsquared.bukkit.listeners.PlotPlusListener; import com.github.intellectualsites.plotsquared.bukkit.listeners.PlotPlusListener;
import com.github.intellectualsites.plotsquared.bukkit.listeners.SingleWorldListener; import com.github.intellectualsites.plotsquared.bukkit.listeners.SingleWorldListener;
import com.github.intellectualsites.plotsquared.bukkit.listeners.WorldEvents; import com.github.intellectualsites.plotsquared.bukkit.listeners.WorldEvents;
import com.github.intellectualsites.plotsquared.bukkit.util.*; import com.github.intellectualsites.plotsquared.bukkit.util.BukkitChatManager;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitChunkManager;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitCommand;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitEconHandler;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitEventUtil;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitHybridUtils;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitInventoryUtil;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitSchematicHandler;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitSetupUtils;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitTaskManager;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.bukkit.util.Metrics;
import com.github.intellectualsites.plotsquared.bukkit.util.SetGenCB;
import com.github.intellectualsites.plotsquared.bukkit.util.block.BukkitLocalQueue; import com.github.intellectualsites.plotsquared.bukkit.util.block.BukkitLocalQueue;
import com.github.intellectualsites.plotsquared.bukkit.uuid.DefaultUUIDWrapper; import com.github.intellectualsites.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
import com.github.intellectualsites.plotsquared.bukkit.uuid.FileUUIDHandler; import com.github.intellectualsites.plotsquared.bukkit.uuid.FileUUIDHandler;
@ -24,7 +36,6 @@ import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.generator.HybridGen; import com.github.intellectualsites.plotsquared.plot.generator.HybridGen;
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils; import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator; import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.object.BlockRegistry;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
@ -35,14 +46,39 @@ import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManag
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea; import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager; import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SingleWorldGenerator; import com.github.intellectualsites.plotsquared.plot.object.worlds.SingleWorldGenerator;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.ChatManager;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.ConsoleColors;
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.InventoryUtil;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandlerImplementation;
import com.github.intellectualsites.plotsquared.plot.util.UpdateUtility;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider; import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper; import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitCommandSender;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extension.platform.Actor;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -77,9 +113,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
} }
} }
private final LegacyMappings legacyMappings = new BukkitLegacyMappings();
private final BlockRegistry<Material> blockRegistry =
new BukkitBlockRegistry(Material.values());
private int[] version; private int[] version;
@Getter private String pluginName; @Getter private String pluginName;
@Getter private SingleWorldListener singleWorldListener; @Getter private SingleWorldListener singleWorldListener;
@ -796,12 +829,9 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
return names; return names;
} }
@Override public BlockRegistry<Material> getBlockRegistry() { @Override public Actor getConsole() {
return this.blockRegistry; @NotNull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
WorldEditPlugin wePlugin = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
return wePlugin.wrapCommandSender(console);
} }
@Override public LegacyMappings getLegacyMappings() {
return this.legacyMappings;
}
} }

View File

@ -19,8 +19,18 @@ import org.bukkit.inventory.ItemStack;
import java.io.IOException; import java.io.IOException;
import java.io.StringWriter; import java.io.StringWriter;
import java.lang.reflect.*; import java.lang.reflect.Constructor;
import java.util.*; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
/** /**

View File

@ -16,7 +16,11 @@ import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper; import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper; import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -24,8 +28,12 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID;
@CommandDeclaration(command = "uuidconvert", permission = "plots.admin", @CommandDeclaration(command = "uuidconvert", permission = "plots.admin",
description = "Debug UUID conversion", usage = "/plot uuidconvert <lower|offline|online>", description = "Debug UUID conversion", usage = "/plot uuidconvert <lower|offline|online>",

View File

@ -5,13 +5,13 @@ import com.github.intellectualsites.plotsquared.bukkit.util.block.GenChunk;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper; import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator; import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.object.ChunkLoc;
import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper; import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SingleWorldGenerator; import com.github.intellectualsites.plotsquared.plot.object.worlds.SingleWorldGenerator;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import com.sk89q.worldedit.math.BlockVector2;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
@ -41,7 +41,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
this.plotGenerator = generator; this.plotGenerator = generator;
this.platformGenerator = this; this.platformGenerator = this;
this.populators = new ArrayList<>(); this.populators = new ArrayList<>();
this.populators.add(new PlotBlockPopulator(this.plotGenerator)); this.populators.add(new BlockStatePopulator(this.plotGenerator));
this.full = true; this.full = true;
MainUtil.initCache(); MainUtil.initCache();
} }
@ -145,7 +145,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
if (this.platformGenerator != this) { if (this.platformGenerator != this) {
return this.platformGenerator.generateChunkData(world, random, x, z, biome); return this.platformGenerator.generateChunkData(world, random, x, z, biome);
} else { } else {
generate(new ChunkLoc(x, z), world, result); generate(BlockVector2.at(x, z), world, result);
} }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
@ -154,7 +154,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
return result.getChunkData(); return result.getChunkData();
} }
private void generate(ChunkLoc loc, World world, ScopedLocalBlockQueue result) { private void generate(BlockVector2 loc, World world, ScopedLocalBlockQueue result) {
// Load if improperly loaded // Load if improperly loaded
if (!this.loaded) { if (!this.loaded) {
String name = world.getName(); String name = world.getName();

View File

@ -7,10 +7,9 @@ import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGe
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.bukkit.World; import org.bukkit.World;
@ -46,7 +45,7 @@ import java.util.Random;
for (short x = 0; x < 16; x++) { for (short x = 0; x < 16; x++) {
for (short z = 0; z < 16; z++) { for (short z = 0; z < 16; z++) {
blockBuckets[0][(z << 4) | x] = blockBuckets[0][(z << 4) | x] =
BlockBucket.withSingle(PlotBlock.get("bedrock")); BlockBucket.withSingle(BlockUtil.get("bedrock"));
} }
} }
} }

View File

@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.Random; import java.util.Random;
@RequiredArgsConstructor final class PlotBlockPopulator extends BlockPopulator { @RequiredArgsConstructor final class BlockStatePopulator extends BlockPopulator {
private final IndependentPlotGenerator plotGenerator; private final IndependentPlotGenerator plotGenerator;
private LocalBlockQueue queue; private LocalBlockQueue queue;

View File

@ -1,7 +1,6 @@
package com.github.intellectualsites.plotsquared.bukkit.listeners; package com.github.intellectualsites.plotsquared.bukkit.listeners;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;

View File

@ -1,7 +1,7 @@
package com.github.intellectualsites.plotsquared.bukkit.listeners; package com.github.intellectualsites.plotsquared.bukkit.listeners;
import com.github.intellectualsites.plotsquared.bukkit.BukkitMain; import com.github.intellectualsites.plotsquared.bukkit.BukkitMain;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitLazyBlock; import com.github.intellectualsites.plotsquared.bukkit.object.BukkitBlockUtil;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer; import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil; import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
@ -10,8 +10,27 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType; import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType;
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener; import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotHandler;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotInventory;
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
import com.github.intellectualsites.plotsquared.plot.util.EntityUtil;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.RegExUtil;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.UpdateUtility;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -20,21 +39,83 @@ import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
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.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import org.bukkit.entity.*; import org.bukkit.entity.Ageable;
import org.bukkit.entity.Animals;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Creature;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.entity.Vehicle;
import org.bukkit.entity.Villager;
import org.bukkit.entity.WaterMob;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.*; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.*; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.EntityBlockFormEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.LingeringPotionSplashEvent;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.vehicle.VehicleCreateEvent; import org.bukkit.event.vehicle.VehicleCreateEvent;
import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.event.vehicle.VehicleDestroyEvent;
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
@ -53,8 +134,16 @@ import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.*; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.function.Supplier;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
@ -1016,10 +1105,10 @@ import java.util.regex.Pattern;
return; return;
} }
if (!plot.isAdded(plotPlayer.getUUID())) { if (!plot.isAdded(plotPlayer.getUUID())) {
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK); Optional<Set<BlockType>> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock(); Block block = event.getBlock();
if (destroy.isPresent() && destroy.get() if (destroy.isPresent() && destroy.get()
.contains(PlotBlock.get(block.getType().name()))) { .contains(BukkitAdapter.asBlockType(block.getType()))) {
return; return;
} }
if (Permissions if (Permissions
@ -1301,10 +1390,10 @@ import java.util.regex.Pattern;
} }
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (!plot.isAdded(plotPlayer.getUUID())) { if (!plot.isAdded(plotPlayer.getUUID())) {
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK); Optional<Set<BlockType>> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock(); Block block = event.getBlock();
if (destroy.isPresent() && destroy.get() if (destroy.isPresent() && destroy.get()
.contains(PlotBlock.get(block.getType().name())) || Permissions .contains(BukkitBlockUtil.get(block)) || Permissions
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) { .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
return; return;
} }
@ -1536,7 +1625,7 @@ import java.util.regex.Pattern;
if (!PlotSquared.get().hasPlotArea(event.getWorld().getName())) { if (!PlotSquared.get().hasPlotArea(event.getWorld().getName())) {
return; return;
} }
List<BlockState> blocks = event.getBlocks(); List<org.bukkit.block.BlockState> blocks = event.getBlocks();
if (blocks.isEmpty()) { if (blocks.isEmpty()) {
return; return;
} }
@ -1650,7 +1739,7 @@ import java.util.regex.Pattern;
} }
} }
Block block = player.getTargetBlock(null, 7); Block block = player.getTargetBlock(null, 7);
BlockState state = block.getState(); org.bukkit.block.BlockState state = block.getState();
if (state == null) { if (state == null) {
return; return;
} }
@ -1829,9 +1918,10 @@ import java.util.regex.Pattern;
Block block = player.getTargetBlockExact(5, FluidCollisionMode.SOURCE_ONLY); Block block = player.getTargetBlockExact(5, FluidCollisionMode.SOURCE_ONLY);
if (block != null && block.getType() != Material.AIR) { if (block != null && block.getType() != Material.AIR) {
Location location = BukkitUtil.getLocation(block.getLocation()); Location location = BukkitUtil.getLocation(block.getLocation());
Material finalType = type;
if (!EventUtil.manager if (!EventUtil.manager
.checkPlayerBlockEvent(pp, PlayerBlockEventType.SPAWN_MOB, location, .checkPlayerBlockEvent(pp, PlayerBlockEventType.SPAWN_MOB, location, () -> BukkitAdapter.asBlockType(
new BukkitLazyBlock(PlotBlock.get(type.toString())), true)) { finalType).getDefaultState(), true)) {
event.setCancelled(true); event.setCancelled(true);
event.setUseItemInHand(Event.Result.DENY); event.setUseItemInHand(Event.Result.DENY);
} }
@ -1849,14 +1939,14 @@ import java.util.regex.Pattern;
return; return;
} }
PlayerBlockEventType eventType = null; PlayerBlockEventType eventType = null;
BukkitLazyBlock lb; Supplier<BlockState> lb;
Location location; Location location;
Action action = event.getAction(); Action action = event.getAction();
switch (action) { switch (action) {
case PHYSICAL: { case PHYSICAL: {
eventType = PlayerBlockEventType.TRIGGER_PHYSICAL; eventType = PlayerBlockEventType.TRIGGER_PHYSICAL;
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
lb = new BukkitLazyBlock(block); lb = BukkitBlockUtil.supply(block);
location = BukkitUtil.getLocation(block.getLocation()); location = BukkitUtil.getLocation(block.getLocation());
break; break;
} }
@ -2025,7 +2115,7 @@ import java.util.regex.Pattern;
eventType = PlayerBlockEventType.INTERACT_BLOCK; eventType = PlayerBlockEventType.INTERACT_BLOCK;
} }
} }
lb = new BukkitLazyBlock(PlotBlock.get(block.getType().toString())); lb = BukkitBlockUtil.supply(block);
if (eventType != null && (eventType != PlayerBlockEventType.INTERACT_BLOCK if (eventType != null && (eventType != PlayerBlockEventType.INTERACT_BLOCK
|| !player.isSneaking())) { || !player.isSneaking())) {
break; break;
@ -2044,7 +2134,7 @@ import java.util.regex.Pattern;
type = offType; type = offType;
} }
// in the following, lb needs to have the material of the item in hand i.e. type // in the following, lb needs to have the material of the item in hand i.e. type
lb = new BukkitLazyBlock(PlotBlock.get(type.toString())); lb = BukkitBlockUtil.supply(type);
if (type.isBlock()) { if (type.isBlock()) {
location = BukkitUtil location = BukkitUtil
.getLocation(block.getRelative(event.getBlockFace()).getLocation()); .getLocation(block.getRelative(event.getBlockFace()).getLocation());
@ -2127,7 +2217,7 @@ import java.util.regex.Pattern;
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
location = BukkitUtil.getLocation(block.getLocation()); location = BukkitUtil.getLocation(block.getLocation());
eventType = PlayerBlockEventType.BREAK_BLOCK; eventType = PlayerBlockEventType.BREAK_BLOCK;
lb = new BukkitLazyBlock(block); lb = BukkitBlockUtil.supply(block);
break; break;
default: default:
return; return;
@ -2386,7 +2476,7 @@ import java.util.regex.Pattern;
Captions.PERMISSION_ADMIN_BUILD_UNOWNED); Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
if (Flags.USE.contains(plot, PlotBlock.get(event.getBucket().name()))) { if (Flags.USE.contains(plot, BukkitBlockUtil.get(block))) {
return; return;
} }
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
@ -2446,9 +2536,9 @@ import java.util.regex.Pattern;
Captions.PERMISSION_ADMIN_BUILD_UNOWNED); Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
} else if (!plot.isAdded(plotPlayer.getUUID())) { } else if (!plot.isAdded(plotPlayer.getUUID())) {
Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE); Optional<Set<BlockType>> use = plot.getFlag(Flags.USE);
Block block = event.getBlockClicked(); Block block = event.getBlockClicked();
if (use.isPresent() && use.get().contains(PlotBlock.get(block.getType().name()))) { if (use.isPresent() && use.get().contains(BukkitBlockUtil.get(block))) {
return; return;
} }
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
@ -3004,10 +3094,10 @@ import java.util.regex.Pattern;
return; return;
} }
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
Set<PlotBlock> place = plot.getFlag(Flags.PLACE, null); Set<BlockType> place = plot.getFlag(Flags.PLACE, null);
if (place != null) { if (place != null) {
Block block = event.getBlock(); Block block = event.getBlock();
if (place.contains(PlotBlock.get(block.getType().name()))) { if (place.contains(BukkitBlockUtil.get(block))) {
return; return;
} }
} }

View File

@ -0,0 +1,26 @@
package com.github.intellectualsites.plotsquared.bukkit.object;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockState;
import org.bukkit.Material;
import org.bukkit.block.Block;
import java.util.function.Supplier;
public class BukkitBlockUtil {
public static Supplier<BlockState> supply(Block block) {
return () -> BukkitAdapter.asBlockType(block.getType()).getDefaultState();
}
public static Supplier<BlockState> supply(Material type) {
return () -> BukkitAdapter.asBlockType(type).getDefaultState();
}
public static BlockState get(Block block) {
return get(block.getType());
}
public static BlockState get(Material material) {
return BukkitAdapter.asBlockType(material).getDefaultState();
}
}

View File

@ -1,25 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.object;
import com.github.intellectualsites.plotsquared.plot.object.LazyBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
import org.bukkit.block.Block;
public class BukkitLazyBlock extends LazyBlock {
private StringPlotBlock pb;
public BukkitLazyBlock(Block block) {
this.pb = (StringPlotBlock) PlotBlock.get(block.getType().toString());
}
public BukkitLazyBlock(StringPlotBlock pb) {
this.pb = pb;
}
public StringPlotBlock getPlotBlock() {
return this.pb;
}
}

View File

@ -4,7 +4,6 @@ import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.EconHandler; import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
@ -12,9 +11,12 @@ import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather; import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.world.item.ItemType;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.WeatherType; import org.bukkit.WeatherType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -55,6 +57,10 @@ public class BukkitPlayer extends PlotPlayer {
super.populatePersistentMetaMap(); super.populatePersistentMetaMap();
} }
@Override public Actor toActor() {
return BukkitAdapter.adapt(player);
}
@NotNull @Override public Location getLocation() { @NotNull @Override public Location getLocation() {
final Location location = super.getLocation(); final Location location = super.getLocation();
return location == null ? BukkitUtil.getLocation(this.player) : location; return location == null ? BukkitUtil.getLocation(this.player) : location;
@ -277,8 +283,8 @@ public class BukkitPlayer extends PlotPlayer {
this.player.setAllowFlight(fly); this.player.setAllowFlight(fly);
} }
@Override public void playMusic(@NotNull final Location location, @NotNull final PlotBlock id) { @Override public void playMusic(@NotNull final Location location, @NotNull final ItemType id) {
if (PlotBlock.isEverything(id) || id.isAir()) { if (id.getBlockType().getMaterial().isAir()) {
// Let's just stop all the discs because why not? // Let's just stop all the discs because why not?
for (final Sound sound : Arrays.stream(Sound.values()) for (final Sound sound : Arrays.stream(Sound.values())
.filter(sound -> sound.name().contains("DISC")).collect(Collectors.toList())) { .filter(sound -> sound.name().contains("DISC")).collect(Collectors.toList())) {
@ -288,7 +294,7 @@ public class BukkitPlayer extends PlotPlayer {
} else { } else {
// this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, id.to(Material.class)); // this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, id.to(Material.class));
this.player.playSound(BukkitUtil.getLocation(location), this.player.playSound(BukkitUtil.getLocation(location),
Sound.valueOf(id.to(Material.class).name()), Float.MAX_VALUE, 1f); Sound.valueOf(BukkitAdapter.adapt(id).name()), Float.MAX_VALUE, 1f);
} }
} }

View File

@ -1,6 +1,5 @@
package com.github.intellectualsites.plotsquared.bukkit.object.entity; package com.github.intellectualsites.plotsquared.bukkit.object.entity;
class EntityBaseStats { class EntityBaseStats {
EntityWrapper passenger; EntityWrapper passenger;

View File

@ -8,7 +8,23 @@ import org.bukkit.Rotation;
import org.bukkit.TreeSpecies; import org.bukkit.TreeSpecies;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.*; import org.bukkit.entity.AbstractHorse;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Bat;
import org.bukkit.entity.Boat;
import org.bukkit.entity.ChestedHorse;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.IronGolem;
import org.bukkit.entity.Item;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Painting;
import org.bukkit.entity.Rabbit;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Tameable;
import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@ -3,11 +3,15 @@ package com.github.intellectualsites.plotsquared.bukkit.object.schematic;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil; import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.sk89q.jnbt.*; import com.sk89q.jnbt.ByteTag;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.ShortTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Container; import org.bukkit.block.Container;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -23,10 +27,10 @@ import java.util.Map.Entry;
public class StateWrapper { public class StateWrapper {
public BlockState state = null; public org.bukkit.block.BlockState state = null;
public CompoundTag tag = null; public CompoundTag tag = null;
public StateWrapper(BlockState state) { public StateWrapper(org.bukkit.block.BlockState state) {
this.state = state; this.state = state;
} }
@ -151,7 +155,7 @@ public class StateWrapper {
if (block == null) { if (block == null) {
return false; return false;
} }
BlockState state = block.getState(); org.bukkit.block.BlockState state = block.getState();
switch (tileid) { switch (tileid) {
case "chest": case "chest":
case "beacon": case "beacon":

View File

@ -1,18 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.plot.object.BlockRegistry;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import lombok.NonNull;
import org.bukkit.Material;
public class BukkitBlockRegistry extends BlockRegistry<Material> {
public BukkitBlockRegistry(final Material... preInitializedItems) {
super(Material.class, preInitializedItems);
}
@Override public PlotBlock getPlotBlock(@NonNull final Material item) {
return PlotBlock.get(item.name());
}
}

View File

@ -5,13 +5,21 @@ import com.github.intellectualsites.plotsquared.bukkit.object.entity.Replicating
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.generator.AugmentedUtils; import com.github.intellectualsites.plotsquared.plot.generator.AugmentedUtils;
import com.github.intellectualsites.plotsquared.plot.listener.WEExtent; import com.github.intellectualsites.plotsquared.plot.listener.WEExtent;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotLoc;
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
@ -25,30 +33,27 @@ import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.*; import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class BukkitChunkManager extends ChunkManager { public class BukkitChunkManager extends ChunkManager {
public static boolean isIn(RegionWrapper region, int x, int z) { public static boolean isIn(CuboidRegion region, int x, int z) {
return x >= region.minX && x <= region.maxX && z >= region.minZ && z <= region.maxZ; return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX() && z >= region.getMinimumPoint().getZ() && z <= region.getMaximumPoint().getZ();
}
private static byte getOrdinal(Object[] list, Object value) {
for (byte i = 0; i < list.length; i++) {
if (list[i].equals(value)) {
return i;
}
}
return 0;
} }
public static ContentMap swapChunk(World world1, World world2, Chunk pos1, Chunk pos2, public static ContentMap swapChunk(World world1, World world2, Chunk pos1, Chunk pos2,
RegionWrapper r1, RegionWrapper r2) { CuboidRegion r1, CuboidRegion r2) {
ContentMap map = new ContentMap(); ContentMap map = new ContentMap();
int relX = r2.minX - r1.minX; int relX = r2.getMinimumPoint().getX() - r1.getMinimumPoint().getX();
int relZ = r2.minZ - r1.minZ; int relZ = r2.getMinimumPoint().getZ() - r1.getMinimumPoint().getZ();
map.saveEntitiesIn(pos1, r1, relX, relZ, true); map.saveEntitiesIn(pos1, r1, relX, relZ, true);
map.saveEntitiesIn(pos2, r2, -relX, -relZ, true); map.saveEntitiesIn(pos2, r2, -relX, -relZ, true);
@ -65,8 +70,8 @@ public class BukkitChunkManager extends ChunkManager {
LocalBlockQueue queue1 = GlobalBlockQueue.IMP.getNewQueue(worldName1, false); LocalBlockQueue queue1 = GlobalBlockQueue.IMP.getNewQueue(worldName1, false);
LocalBlockQueue queue2 = GlobalBlockQueue.IMP.getNewQueue(worldName2, false); LocalBlockQueue queue2 = GlobalBlockQueue.IMP.getNewQueue(worldName2, false);
for (int x = Math.max(r1.minX, sx); x <= Math.min(r1.maxX, sx + 15); x++) { for (int x = Math.max(r1.getMinimumPoint().getX(), sx); x <= Math.min(r1.getMaximumPoint().getX(), sx + 15); x++) {
for (int z = Math.max(r1.minZ, sz); z <= Math.min(r1.maxZ, sz + 15); z++) { for (int z = Math.max(r1.getMinimumPoint().getZ(), sz); z <= Math.min(r1.getMaximumPoint().getZ(), sz + 15); z++) {
for (int y = 0; y < 256; y++) { for (int y = 0; y < 256; y++) {
Block block1 = world1.getBlockAt(x, y, z); Block block1 = world1.getBlockAt(x, y, z);
BaseBlock baseBlock1 = bukkitWorld1.getFullBlock(BlockVector3.at(x, y, z)); BaseBlock baseBlock1 = bukkitWorld1.getFullBlock(BlockVector3.at(x, y, z));
@ -104,10 +109,10 @@ public class BukkitChunkManager extends ChunkManager {
return map; return map;
} }
@Override public Set<ChunkLoc> getChunkChunks(String world) { @Override public Set<BlockVector2> getChunkChunks(String world) {
Set<ChunkLoc> chunks = super.getChunkChunks(world); Set<BlockVector2> chunks = super.getChunkChunks(world);
for (Chunk chunk : Bukkit.getWorld(world).getLoadedChunks()) { for (Chunk chunk : Bukkit.getWorld(world).getLoadedChunks()) {
ChunkLoc loc = new ChunkLoc(chunk.getX() >> 5, chunk.getZ() >> 5); BlockVector2 loc = BlockVector2.at(chunk.getX() >> 5, chunk.getZ() >> 5);
chunks.add(loc); chunks.add(loc);
} }
return chunks; return chunks;
@ -194,8 +199,8 @@ public class BukkitChunkManager extends ChunkManager {
final int relX = newPos.getX() - pos1.getX(); final int relX = newPos.getX() - pos1.getX();
final int relZ = newPos.getZ() - pos1.getZ(); final int relZ = newPos.getZ() - pos1.getZ();
final RegionWrapper region = final CuboidRegion region =
new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); RegionUtil.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
final World oldWorld = Bukkit.getWorld(pos1.getWorld()); final World oldWorld = Bukkit.getWorld(pos1.getWorld());
final BukkitWorld oldBukkitWorld = new BukkitWorld(oldWorld); final BukkitWorld oldBukkitWorld = new BukkitWorld(oldWorld);
final World newWorld = Bukkit.getWorld(newPos.getWorld()); final World newWorld = Bukkit.getWorld(newPos.getWorld());
@ -210,10 +215,10 @@ public class BukkitChunkManager extends ChunkManager {
int bz = value[3]; int bz = value[3];
int tx = value[4]; int tx = value[4];
int tz = value[5]; int tz = value[5];
ChunkLoc loc = new ChunkLoc(value[0], value[1]); BlockVector2 loc = BlockVector2.at(value[0], value[1]);
int cxx = loc.x << 4; int cxx = loc.getX() << 4;
int czz = loc.z << 4; int czz = loc.getZ() << 4;
PaperLib.getChunkAtAsync(oldWorld, loc.x, loc.z) PaperLib.getChunkAtAsync(oldWorld, loc.getX(), loc.getZ())
.thenAccept(chunk1 -> map.saveEntitiesIn(chunk1, region)).thenRun(() -> { .thenAccept(chunk1 -> map.saveEntitiesIn(chunk1, region)).thenRun(() -> {
for (int x = bx & 15; x <= (tx & 15); x++) { for (int x = bx & 15; x <= (tx & 15); x++) {
for (int z = bz & 15; z <= (tz & 15); z++) { for (int z = bz & 15; z <= (tz & 15); z++) {
@ -256,11 +261,11 @@ public class BukkitChunkManager extends ChunkManager {
final int tcx = p2x >> 4; final int tcx = p2x >> 4;
final int tcz = p2z >> 4; final int tcz = p2z >> 4;
final List<ChunkLoc> chunks = new ArrayList<>(); final List<BlockVector2> chunks = new ArrayList<>();
for (int x = bcx; x <= tcx; x++) { for (int x = bcx; x <= tcx; x++) {
for (int z = bcz; z <= tcz; z++) { for (int z = bcz; z <= tcz; z++) {
chunks.add(new ChunkLoc(x, z)); chunks.add(BlockVector2.at(x, z));
} }
} }
final World worldObj = Bukkit.getWorld(world); final World worldObj = Bukkit.getWorld(world);
@ -269,9 +274,9 @@ public class BukkitChunkManager extends ChunkManager {
@Override public void run() { @Override public void run() {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
while (!chunks.isEmpty() && System.currentTimeMillis() - start < 5) { while (!chunks.isEmpty() && System.currentTimeMillis() - start < 5) {
final ChunkLoc chunk = chunks.remove(0); final BlockVector2 chunk = chunks.remove(0);
int x = chunk.x; int x = chunk.getX();
int z = chunk.z; int z = chunk.getZ();
int xxb = x << 4; int xxb = x << 4;
int zzb = z << 4; int zzb = z << 4;
int xxt = xxb + 15; int xxt = xxb + 15;
@ -284,7 +289,7 @@ public class BukkitChunkManager extends ChunkManager {
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z
&& PlotSquared.imp().getServerVersion()[1] == 13) { && PlotSquared.imp().getServerVersion()[1] == 13) {
AugmentedUtils AugmentedUtils
.bypass(ignoreAugment, () -> queue.regenChunkSafe(chunk.x, chunk.z)); .bypass(ignoreAugment, () -> queue.regenChunkSafe(chunk.getX(), chunk.getZ()));
continue; continue;
} }
boolean checkX1 = false; boolean checkX1 = false;
@ -346,8 +351,8 @@ public class BukkitChunkManager extends ChunkManager {
if (checkX2 && checkZ2) { if (checkX2 && checkZ2) {
map.saveRegion(bukkitWorldObj, xxt2, xxt, zzt2, zzt); // map.saveRegion(bukkitWorldObj, xxt2, xxt, zzt2, zzt); //
} }
RegionWrapper currentPlotClear = CuboidRegion currentPlotClear =
new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); RegionUtil.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
map.saveEntitiesOut(chunkObj, currentPlotClear); map.saveEntitiesOut(chunkObj, currentPlotClear);
AugmentedUtils.bypass(ignoreAugment, AugmentedUtils.bypass(ignoreAugment,
() -> setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() { () -> setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() {
@ -365,7 +370,7 @@ public class BukkitChunkManager extends ChunkManager {
if (id != null) { if (id != null) {
value.setBlock(x1, y, z1, id); value.setBlock(x1, y, z1, id);
} else { } else {
value.setBlock(x1, y, z1, PlotBlock.get("air")); value.setBlock(x1, y, z1, BlockUtil.get("air"));
} }
} }
for (int y = Math.min(128, ids.length); for (int y = Math.min(128, ids.length);
@ -393,17 +398,17 @@ public class BukkitChunkManager extends ChunkManager {
return true; return true;
} }
@Override public CompletableFuture loadChunk(String world, ChunkLoc chunkLoc, boolean force) { @Override public CompletableFuture loadChunk(String world, BlockVector2 chunkLoc, boolean force) {
return PaperLib.getChunkAtAsync(BukkitUtil.getWorld(world),chunkLoc.x, chunkLoc.z, force); return PaperLib.getChunkAtAsync(BukkitUtil.getWorld(world),chunkLoc.getX(), chunkLoc.getZ(), force);
} }
@Override @Override
public void unloadChunk(final String world, final ChunkLoc chunkLoc, final boolean save) { public void unloadChunk(final String world, final BlockVector2 chunkLoc, final boolean save) {
if (!PlotSquared.get().isMainThread(Thread.currentThread())) { if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
TaskManager.runTask( TaskManager.runTask(
() -> BukkitUtil.getWorld(world).unloadChunk(chunkLoc.x, chunkLoc.z, save)); () -> BukkitUtil.getWorld(world).unloadChunk(chunkLoc.getX(), chunkLoc.getZ(), save));
} else { } else {
BukkitUtil.getWorld(world).unloadChunk(chunkLoc.x, chunkLoc.z, save); BukkitUtil.getWorld(world).unloadChunk(chunkLoc.getX(), chunkLoc.getZ(), save);
} }
} }
@ -430,10 +435,10 @@ public class BukkitChunkManager extends ChunkManager {
@Override public void swap(Location bot1, Location top1, Location bot2, Location top2, @Override public void swap(Location bot1, Location top1, Location bot2, Location top2,
final Runnable whenDone) { final Runnable whenDone) {
RegionWrapper region1 = CuboidRegion region1 =
new RegionWrapper(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ()); RegionUtil.createRegion(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
RegionWrapper region2 = CuboidRegion region2 =
new RegionWrapper(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ()); RegionUtil.createRegion(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ());
final World world1 = Bukkit.getWorld(bot1.getWorld()); final World world1 = Bukkit.getWorld(bot1.getWorld());
World world2 = Bukkit.getWorld(bot2.getWorld()); World world2 = Bukkit.getWorld(bot2.getWorld());
@ -618,7 +623,7 @@ public class BukkitChunkManager extends ChunkManager {
} }
} }
void saveEntitiesOut(Chunk chunk, RegionWrapper region) { void saveEntitiesOut(Chunk chunk, CuboidRegion region) {
for (Entity entity : chunk.getEntities()) { for (Entity entity : chunk.getEntities()) {
Location location = BukkitUtil.getLocation(entity); Location location = BukkitUtil.getLocation(entity);
int x = location.getX(); int x = location.getX();
@ -635,11 +640,11 @@ public class BukkitChunkManager extends ChunkManager {
} }
} }
void saveEntitiesIn(Chunk chunk, RegionWrapper region) { void saveEntitiesIn(Chunk chunk, CuboidRegion region) {
saveEntitiesIn(chunk, region, 0, 0, false); saveEntitiesIn(chunk, region, 0, 0, false);
} }
void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ, void saveEntitiesIn(Chunk chunk, CuboidRegion region, int offsetX, int offsetZ,
boolean delete) { boolean delete) {
for (Entity entity : chunk.getEntities()) { for (Entity entity : chunk.getEntities()) {
Location location = BukkitUtil.getLocation(entity); Location location = BukkitUtil.getLocation(entity);

View File

@ -4,7 +4,13 @@ import com.github.intellectualsites.plotsquared.bukkit.commands.DebugUUID;
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand; import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer; import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import org.bukkit.command.*; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.ProxiedCommandSender;
import org.bukkit.command.RemoteConsoleCommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,6 +1,22 @@
package com.github.intellectualsites.plotsquared.bukkit.util; package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.events.*; import com.github.intellectualsites.plotsquared.bukkit.events.PlayerClaimPlotEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerLeavePlotEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerPlotDeniedEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerPlotHelperEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerPlotTrustedEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerTeleportToPlotEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotAutoMergeEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotChangeOwnerEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotClearEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotComponentSetEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotDeleteEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotFlagAddEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotFlagRemoveEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotMergeEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotRateEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlotUnlinkEvent;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer; import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;

View File

@ -5,7 +5,11 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld; import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld;
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils; import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
@ -13,7 +17,11 @@ import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis; import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
@ -22,15 +30,16 @@ import org.bukkit.block.data.Directional;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
public class BukkitHybridUtils extends HybridUtils { public class BukkitHybridUtils extends HybridUtils {
@Override public void analyzeRegion(final String world, final RegionWrapper region, @Override public void analyzeRegion(final String world, final CuboidRegion region,
final RunnableVal<PlotAnalysis> whenDone) { final RunnableVal<PlotAnalysis> whenDone) {
// int diff, int variety, int vertices, int rotation, int height_sd // int diff, int variety, int vertices, int rotation, int height_sd
/* /*
* diff: compare to base by looping through all blocks * diff: compare to base by looping through all blocks
* variety: add to HashSet for each PlotBlock * variety: add to HashSet for each BlockState
* height_sd: loop over all blocks and get top block * height_sd: loop over all blocks and get top block
* *
* vertices: store air map and compare with neighbours * vertices: store air map and compare with neighbours
@ -47,8 +56,8 @@ public class BukkitHybridUtils extends HybridUtils {
return; return;
} }
final Location bot = new Location(world, region.minX, region.minY, region.minZ); final Location bot = new Location(world, region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
final Location top = new Location(world, region.maxX, region.maxY, region.maxZ); final Location top = new Location(world, region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
final int bx = bot.getX(); final int bx = bot.getX();
final int bz = bot.getZ(); final int bz = bot.getZ();
@ -65,8 +74,8 @@ public class BukkitHybridUtils extends HybridUtils {
System.gc(); System.gc();
System.gc(); System.gc();
final BlockBucket[][][] oldBlocks = new BlockBucket[256][width][length]; final BlockBucket[][][] oldBlocks = new BlockBucket[256][width][length];
final PlotBlock[][][] newBlocks = new PlotBlock[256][width][length]; final BlockState[][][] newBlocks = new BlockState[256][width][length];
final BlockBucket airBucket = BlockBucket.withSingle(StringPlotBlock.EVERYTHING); final BlockBucket airBucket = BlockBucket.withSingle(BlockTypes.AIR.getDefaultState());
PlotArea area = PlotSquared.get().getPlotArea(world, null); PlotArea area = PlotSquared.get().getPlotArea(world, null);
@ -122,7 +131,7 @@ public class BukkitHybridUtils extends HybridUtils {
for (int y = 0; y < blocks.length; y++) { for (int y = 0; y < blocks.length; y++) {
if (blocks[y] != null) { if (blocks[y] != null) {
result[(minY + y) >> 4][(((minY + y) & 0xF) << 8) | (z << 4) | x] = result[(minY + y) >> 4][(((minY + y) & 0xF) << 8) | (z << 4) | x] =
BlockBucket.withSingle(PlotBlock.get(blocks[y])); BlockBucket.withSingle(blocks[y].toImmutableState());
} }
} }
} }
@ -177,45 +186,45 @@ public class BukkitHybridUtils extends HybridUtils {
int i = 0; int i = 0;
for (int x = 0; x < width; x++) { for (int x = 0; x < width; x++) {
for (int z = 0; z < length; z++) { for (int z = 0; z < length; z++) {
HashSet<PlotBlock> types = new HashSet<>(); Set<BlockType> types = new HashSet<>();
for (int y = 0; y < 256; y++) { for (int y = 0; y < 256; y++) {
BlockBucket old = oldBlocks[y][x][z]; BlockBucket old = oldBlocks[y][x][z];
try { try {
if (old == null) { if (old == null) {
old = airBucket; old = airBucket;
} }
PlotBlock now = newBlocks[y][x][z]; BlockState now = newBlocks[y][x][z];
if (!old.getBlocks().contains(now)) { if (!old.getBlocks().contains(now)) {
changes[i]++; changes[i]++;
} }
if (now.isAir()) { if (now.getBlockType().getMaterial().isAir()) {
air[i]++; air[i]++;
} else { } else {
// check vertices // check vertices
// modifications_adjacent // modifications_adjacent
if (x > 0 && z > 0 && y > 0 && x < width - 1 && z < length - 1 if (x > 0 && z > 0 && y > 0 && x < width - 1 && z < length - 1
&& y < 255) { && y < 255) {
if (newBlocks[y - 1][x][z].isAir()) { if (newBlocks[y - 1][x][z].getBlockType().getMaterial().isAir()) {
faces[i]++; faces[i]++;
} }
if (newBlocks[y][x - 1][z].isAir()) { if (newBlocks[y][x - 1][z].getBlockType().getMaterial().isAir()) {
faces[i]++; faces[i]++;
} }
if (newBlocks[y][x][z - 1].isAir()) { if (newBlocks[y][x][z - 1].getBlockType().getMaterial().isAir()) {
faces[i]++; faces[i]++;
} }
if (newBlocks[y + 1][x][z].isAir()) { if (newBlocks[y + 1][x][z].getBlockType().getMaterial().isAir()) {
faces[i]++; faces[i]++;
} }
if (newBlocks[y][x + 1][z].isAir()) { if (newBlocks[y][x + 1][z].getBlockType().getMaterial().isAir()) {
faces[i]++; faces[i]++;
} }
if (newBlocks[y][x][z + 1].isAir()) { if (newBlocks[y][x][z + 1].getBlockType().getMaterial().isAir()) {
faces[i]++; faces[i]++;
} }
} }
Material material = now.to(Material.class); Material material = BukkitAdapter.adapt(now.getBlockType());
if (material != null) { if (material != null) {
BlockData blockData = material.createBlockData(); BlockData blockData = material.createBlockData();
if (blockData instanceof Directional) { if (blockData instanceof Directional) {
@ -224,7 +233,7 @@ public class BukkitHybridUtils extends HybridUtils {
data[i]++; data[i]++;
} }
} }
types.add(now); types.add(now.getBlockType());
} }
} catch (NullPointerException e) { } catch (NullPointerException e) {
e.printStackTrace(); e.printStackTrace();
@ -297,7 +306,7 @@ public class BukkitHybridUtils extends HybridUtils {
for (int z = minZ; z <= maxZ; z++) { for (int z = minZ; z <= maxZ; z++) {
int zz = cbz + z; int zz = cbz + z;
for (int y = 0; y < 256; y++) { for (int y = 0; y < 256; y++) {
PlotBlock block = queue.getBlock(xx, y, zz); BlockState block = queue.getBlock(xx, y, zz);
int xr = xb + x; int xr = xb + x;
int zr = zb + z; int zr = zb + z;
newBlocks[y][xr][zr] = block; newBlocks[y][xr][zr] = block;

View File

@ -56,7 +56,7 @@ public class BukkitInventoryUtil extends InventoryUtil {
if (item == null) { if (item == null) {
return null; return null;
} }
ItemStack stack = new ItemStack(BukkitUtil.getMaterial(item.getPlotBlock()), item.amount); ItemStack stack = new ItemStack(BukkitUtil.getMaterial(item.getBlockState()), item.amount);
ItemMeta meta = null; ItemMeta meta = null;
if (item.name != null) { if (item.name != null) {
meta = stack.getItemMeta(); meta = stack.getItemMeta();

View File

@ -1,865 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.LegacyMappings;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import java.util.*;
import java.util.stream.Collectors;
/**
* Borrowed from https://github.com/Phoenix616/IDConverter/blob/master/mappings/src/main/java/de/themoep/idconverter/IdMappings.java
* Original License:
* <p>
* Minecraft ID mappings Copyright (C) 2017 Max Lee (https://github.com/Phoenix616)
* <p>
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License along with this program. If
* not, see <http://www.gnu.org/licenses/>.
*/
public final class BukkitLegacyMappings extends LegacyMappings {
private static final LegacyBlock[] BLOCKS =
new LegacyBlock[] {new LegacyBlock(0, "air"), new LegacyBlock(1, "stone"),
new LegacyBlock(1, 1, "stone", "granite"),
new LegacyBlock(1, 2, "stone", "polished_granite"),
new LegacyBlock(1, 3, "stone", "diorite"),
new LegacyBlock(1, 4, "stone", "polished_diorite"),
new LegacyBlock(1, 5, "stone", "andesite"),
new LegacyBlock(1, 6, "stone", "polished_andesite"),
new LegacyBlock(2, "grass", "grass_block"), new LegacyBlock(3, "dirt"),
new LegacyBlock(3, 1, "dirt", "coarse_dirt"), new LegacyBlock(3, 2, "dirt", "podzol"),
new LegacyBlock(4, "cobblestone"), new LegacyBlock(5, "wood", "oak_planks"),
new LegacyBlock(5, 1, "wood", "spruce_planks"),
new LegacyBlock(5, 2, "wood", "birch_planks"),
new LegacyBlock(5, 3, "wood", "jungle_planks"),
new LegacyBlock(5, 4, "wood", "acacia_planks"),
new LegacyBlock(5, 5, "wood", "dark_oak_planks"),
new LegacyBlock(6, "sapling", "oak_sapling"),
new LegacyBlock(6, 1, "sapling", "spruce_sapling"),
new LegacyBlock(6, 2, "sapling", "birch_sapling"),
new LegacyBlock(6, 3, "sapling", "jungle_sapling"),
new LegacyBlock(6, 4, "sapling", "acacia_sapling"),
new LegacyBlock(6, 5, "sapling", "dark_oak_sapling"), new LegacyBlock(7, "bedrock"),
new LegacyBlock(8, "water", "flowing_water"),
new LegacyBlock(9, "stationary_water", "water"),
new LegacyBlock(10, "lava", "flowing_lava"),
new LegacyBlock(11, "stationary_lava", "lava"), new LegacyBlock(12, "sand"),
new LegacyBlock(12, 1, "sand", "red_sand"), new LegacyBlock(13, "gravel"),
new LegacyBlock(14, "gold_ore"), new LegacyBlock(15, "iron_ore"),
new LegacyBlock(16, "coal_ore"), new LegacyBlock(17, "log", "oak_log"),
new LegacyBlock(17, 1, "log", "oak_log"), new LegacyBlock(17, 2, "log", "spruce_log"),
new LegacyBlock(17, 3, "log", "birch_log"), new LegacyBlock(17, 4, "log", "jungle_log"),
new LegacyBlock(17, 5, "log", "oak_bark"), new LegacyBlock(17, 6, "log", "spruce_bark"),
new LegacyBlock(17, 7, "log", "birch_bark"),
new LegacyBlock(17, 8, "log", "jungle_bark"),
new LegacyBlock(18, "leaves", "oak_leaves"),
new LegacyBlock(18, 1, "leaves", "spruce_leaves"),
new LegacyBlock(18, 2, "leaves", "birch_leaves"),
new LegacyBlock(18, 3, "leaves", "jungle_leaves"), new LegacyBlock(19, "sponge"),
new LegacyBlock(19, 1, "sponge", "wet_sponge"), new LegacyBlock(20, "glass"),
new LegacyBlock(21, "lapis_ore"), new LegacyBlock(22, "lapis_block"),
new LegacyBlock(23, "dispenser"), new LegacyBlock(24, "sandstone"),
new LegacyBlock(24, 1, "sandstone", "chiseled_sandstone"),
new LegacyBlock(24, 2, "sandstone", "cut_sandstone"), new LegacyBlock(25, "note_block"),
new LegacyBlock(26, "bed_block"), new LegacyBlock(27, "powered_rail"),
new LegacyBlock(28, "detector_rail"),
new LegacyBlock(29, "piston_sticky_base", "sticky_piston"),
new LegacyBlock(30, "web", "cobweb"), new LegacyBlock(31, "long_grass", "dead_bush"),
new LegacyBlock(31, 1, "long_grass", "grass"),
new LegacyBlock(31, 2, "long_grass", "fern"), new LegacyBlock(32, "dead_bush"),
new LegacyBlock(33, "piston_base", "piston"),
new LegacyBlock(34, "piston_extension", "piston_head"),
new LegacyBlock(35, "wool", "white_wool"),
new LegacyBlock(35, 1, "wool", "orange_wool"),
new LegacyBlock(35, 2, "wool", "magenta_wool"),
new LegacyBlock(35, 3, "wool", "light_blue_wool"),
new LegacyBlock(35, 4, "wool", "yellow_wool"),
new LegacyBlock(35, 5, "wool", "lime_wool"),
new LegacyBlock(35, 6, "wool", "pink_wool"),
new LegacyBlock(35, 7, "wool", "gray_wool"),
new LegacyBlock(35, 8, "wool", "light_gray_wool"),
new LegacyBlock(35, 9, "wool", "cyan_wool"),
new LegacyBlock(35, 10, "wool", "purple_wool"),
new LegacyBlock(35, 11, "wool", "blue_wool"),
new LegacyBlock(35, 12, "wool", "brown_wool"),
new LegacyBlock(35, 13, "wool", "green_wool"),
new LegacyBlock(35, 14, "wool", "red_wool"),
new LegacyBlock(35, 15, "wool", "black_wool"),
new LegacyBlock(36, "piston_moving_piece", "moving_piston"),
new LegacyBlock(37, "yellow_flower", "dandelion"),
new LegacyBlock(38, "red_rose", "poppy"),
new LegacyBlock(38, 1, "red_rose", "blue_orchid"),
new LegacyBlock(38, 2, "red_rose", "allium"),
new LegacyBlock(38, 3, "red_rose", "azure_bluet"),
new LegacyBlock(38, 4, "red_rose", "red_tulip"),
new LegacyBlock(38, 5, "red_rose", "orange_tulip"),
new LegacyBlock(38, 6, "red_rose", "white_tulip"),
new LegacyBlock(38, 7, "red_rose", "pink_tulip"),
new LegacyBlock(38, 8, "red_rose", "oxeye_daisy"),
new LegacyBlock(39, "brown_mushroom"), new LegacyBlock(40, "red_mushroom"),
new LegacyBlock(41, "gold_block"), new LegacyBlock(42, "iron_block"),
new LegacyBlock(43, "double_step"),
new LegacyBlock(43, 6, "double_step", "smooth_quartz"),
new LegacyBlock(43, 8, "double_step", "smooth_stone"),
new LegacyBlock(43, 9, "double_step", "smooth_sandstone"),
new LegacyBlock(44, "step", "stone_slab", "smooth_stone_slab"),
new LegacyBlock(44, 1, "step", "sandstone_slab"),
new LegacyBlock(44, 2, "step", "petrified_oak_slab"),
new LegacyBlock(44, 3, "step", "cobblestone_slab"),
new LegacyBlock(44, 4, "step", "brick_slab"),
new LegacyBlock(44, 5, "step", "stone_brick_slab"),
new LegacyBlock(44, 6, "step", "nether_brick_slab"),
new LegacyBlock(44, 7, "step", "quartz_slab"), new LegacyBlock(45, "brick", "bricks"),
new LegacyBlock(46, "tnt"), new LegacyBlock(47, "bookshelf"),
new LegacyBlock(48, "mossy_cobblestone"), new LegacyBlock(49, "obsidian"),
new LegacyBlock(50, "torch"), new LegacyBlock(50, 1, "torch", "wall_torch"),
new LegacyBlock(50, 2, "torch", "wall_torch"),
new LegacyBlock(50, 3, "torch", "wall_torch"),
new LegacyBlock(50, 4, "torch", "wall_torch"), new LegacyBlock(50, 5, "torch"),
new LegacyBlock(51, "fire"), new LegacyBlock(52, "mob_spawner"),
new LegacyBlock(53, "wood_stairs", "oak_stairs"), new LegacyBlock(54, "chest", "chest"),
new LegacyBlock(55, "redstone_wire"), new LegacyBlock(56, "diamond_ore"),
new LegacyBlock(57, "diamond_block"),
new LegacyBlock(58, "workbench", "crafting_table"),
new LegacyBlock(59, "crops", "wheat"), new LegacyBlock(60, "soil", "farmland"),
new LegacyBlock(61, "furnace"), new LegacyBlock(62, "burning_furnace"),
new LegacyBlock(63, "sign_post", "sign", "oak_sign"),
new LegacyBlock(64, "wooden_door", "oak_door"), new LegacyBlock(65, "ladder"),
new LegacyBlock(66, "rails", "rail"), new LegacyBlock(67, "cobblestone_stairs"),
new LegacyBlock(68, "wall_sign", "wall_sign", "oak_wall_sign"),
new LegacyBlock(69, "lever"),
new LegacyBlock(70, "stone_plate", "stone_pressure_plate"),
new LegacyBlock(71, "iron_door_block", "iron_door"),
new LegacyBlock(72, "wood_plate", "oak_pressure_plate"),
new LegacyBlock(73, "redstone_ore"), new LegacyBlock(74, "glowing_redstone_ore"),
new LegacyBlock(75, "redstone_torch_off"),
new LegacyBlock(76, "redstone_torch_on", "redstone_torch"),
new LegacyBlock(76, 1, "redstone_torch_on", "redstone_wall_torch"),
new LegacyBlock(76, 2, "redstone_torch_on", "redstone_wall_torch"),
new LegacyBlock(76, 3, "redstone_torch_on", "redstone_wall_torch"),
new LegacyBlock(76, 4, "redstone_torch_on", "redstone_wall_torch"),
new LegacyBlock(76, 5, "redstone_torch_on", "redstone_torch"),
new LegacyBlock(77, "stone_button"), new LegacyBlock(78, "snow"),
new LegacyBlock(79, "ice"), new LegacyBlock(80, "snow_block"),
new LegacyBlock(81, "cactus"), new LegacyBlock(82, "clay"),
new LegacyBlock(83, "sugar_cane_block", "sugar_cane"), new LegacyBlock(84, "jukebox"),
new LegacyBlock(85, "fence", "oak_fence"),
new LegacyBlock(86, "pumpkin", "carved_pumpkin"), new LegacyBlock(87, "netherrack"),
new LegacyBlock(88, "soul_sand"), new LegacyBlock(89, "glowstone"),
new LegacyBlock(90, "portal"), new LegacyBlock(91, "jack_o_lantern"),
new LegacyBlock(92, "cake_block", "cake"), new LegacyBlock(93, "diode_block_off"),
new LegacyBlock(94, "diode_block_on", "repeater"),
new LegacyBlock(95, "stained_glass", "white_stained_glass"),
new LegacyBlock(95, 1, "stained_glass", "orange_stained_glass"),
new LegacyBlock(95, 2, "stained_glass", "magenta_stained_glass"),
new LegacyBlock(95, 3, "stained_glass", "light_blue_stained_glass"),
new LegacyBlock(95, 4, "stained_glass", "yellow_stained_glass"),
new LegacyBlock(95, 5, "stained_glass", "lime_stained_glass"),
new LegacyBlock(95, 6, "stained_glass", "pink_stained_glass"),
new LegacyBlock(95, 7, "stained_glass", "gray_stained_glass"),
new LegacyBlock(95, 8, "stained_glass", "light_gray_stained_glass"),
new LegacyBlock(95, 9, "stained_glass", "cyan_stained_glass"),
new LegacyBlock(95, 10, "stained_glass", "purple_stained_glass"),
new LegacyBlock(95, 11, "stained_glass", "blue_stained_glass"),
new LegacyBlock(95, 12, "stained_glass", "brown_stained_glass"),
new LegacyBlock(95, 13, "stained_glass", "green_stained_glass"),
new LegacyBlock(95, 14, "stained_glass", "red_stained_glass"),
new LegacyBlock(95, 15, "stained_glass", "black_stained_glass"),
new LegacyBlock(96, "trap_door", "oak_trapdoor"),
new LegacyBlock(97, "monster_eggs", "infested_stone"),
new LegacyBlock(97, 1, "monster_eggs", "infested_cobblestone"),
new LegacyBlock(97, 2, "monster_eggs", "infested_stone_bricks"),
new LegacyBlock(97, 3, "monster_eggs", "infested_mossy_stone_bricks"),
new LegacyBlock(97, 4, "monster_eggs", "infested_cracked_stone_bricks"),
new LegacyBlock(97, 5, "monster_eggs", "infested_chiseled_stone_bricks"),
new LegacyBlock(98, "smooth_brick", "stone_bricks"),
new LegacyBlock(98, 1, "smooth_brick", "mossy_stone_bricks"),
new LegacyBlock(98, 2, "smooth_brick", "cracked_stone_bricks"),
new LegacyBlock(98, 3, "smooth_brick", "chiseled_bricks"),
new LegacyBlock(99, "huge_mushroom_1", "brown_mushroom_block"),
new LegacyBlock(99, 1, "huge_mushroom_1"), new LegacyBlock(99, 2, "huge_mushroom_1"),
new LegacyBlock(99, 3, "huge_mushroom_1"), new LegacyBlock(99, 4, "huge_mushroom_1"),
new LegacyBlock(99, 5, "huge_mushroom_1"), new LegacyBlock(99, 6, "huge_mushroom_1"),
new LegacyBlock(99, 7, "huge_mushroom_1"), new LegacyBlock(99, 8, "huge_mushroom_1"),
new LegacyBlock(99, 9, "huge_mushroom_1"),
new LegacyBlock(99, 10, "huge_mushroom_1", "mushroom_stem"),
new LegacyBlock(99, 14, "huge_mushroom_1"), new LegacyBlock(99, 15, "huge_mushroom_1"),
new LegacyBlock(100, "huge_mushroom_2", "red_mushroom_block"),
new LegacyBlock(100, 1, "huge_mushroom_2"), new LegacyBlock(100, 2, "huge_mushroom_2"),
new LegacyBlock(100, 3, "huge_mushroom_2"), new LegacyBlock(100, 4, "huge_mushroom_2"),
new LegacyBlock(100, 5, "huge_mushroom_2"), new LegacyBlock(100, 6, "huge_mushroom_2"),
new LegacyBlock(100, 7, "huge_mushroom_2"), new LegacyBlock(100, 8, "huge_mushroom_2"),
new LegacyBlock(100, 9, "huge_mushroom_2"),
new LegacyBlock(100, 10, "huge_mushroom_2", "mushroom_stem"),
new LegacyBlock(100, 14, "huge_mushroom_2"),
new LegacyBlock(100, 15, "huge_mushroom_2"),
new LegacyBlock(101, "iron_fence", "iron_bars"),
new LegacyBlock(102, "thin_glass", "glass_pane"), new LegacyBlock(103, "melon_block"),
new LegacyBlock(104, "pumpkin_stem"), new LegacyBlock(105, "melon_stem"),
new LegacyBlock(106, "vine"), new LegacyBlock(107, "fence_gate", "oak_fence_gate"),
new LegacyBlock(108, "brick_stairs"),
new LegacyBlock(109, "smooth_stairs", "stone_brick_stairs"),
new LegacyBlock(110, "mycel", "mycelium"),
new LegacyBlock(111, "water_lily", "lily_pad"),
new LegacyBlock(112, "nether_brick", "nether_bricks"),
new LegacyBlock(113, "nether_fence", "nether_brick_fence"),
new LegacyBlock(114, "nether_brick_stairs"),
new LegacyBlock(115, "nether_warts", "nether_wart"),
new LegacyBlock(116, "enchantment_table", "enchanting_table"),
new LegacyBlock(117, "brewing_stand"), new LegacyBlock(118, "cauldron"),
new LegacyBlock(119, "ender_portal", "end_portal"),
new LegacyBlock(120, "ender_portal_frame", "end_portal_frame"),
new LegacyBlock(121, "ender_stone", "end_stone"), new LegacyBlock(122, "dragon_egg"),
new LegacyBlock(123, "redstone_lamp_off"),
new LegacyBlock(124, "redstone_lamp_on", "redstone_lamp"),
new LegacyBlock(125, "wood_double_step"), new LegacyBlock(125, 1, "wood_double_step"),
new LegacyBlock(125, 2, "wood_double_step"),
new LegacyBlock(125, 3, "wood_double_step"),
new LegacyBlock(125, 4, "wood_double_step"),
new LegacyBlock(125, 5, "wood_double_step"),
new LegacyBlock(126, "wood_step", "oak_slab"),
new LegacyBlock(126, 1, "wood_step", "spruce_slab"),
new LegacyBlock(126, 2, "wood_step", "birch_slab"),
new LegacyBlock(126, 3, "wood_step", "jungle_slab"),
new LegacyBlock(126, 4, "wood_step", "acacia_slab"),
new LegacyBlock(126, 5, "wood_step", "dark_oak_slab"), new LegacyBlock(127, "cocoa"),
new LegacyBlock(128, "sandstone_stairs"), new LegacyBlock(129, "emerald_ore"),
new LegacyBlock(130, "ender_chest"), new LegacyBlock(131, "tripwire_hook"),
new LegacyBlock(132, "tripwire"), new LegacyBlock(133, "emerald_block"),
new LegacyBlock(134, "spruce_wood_stairs", "spruce_stairs"),
new LegacyBlock(135, "birch_wood_stairs", "birch_stairs"),
new LegacyBlock(136, "jungle_wood_stairs", "jungle_stairs"),
new LegacyBlock(137, "command", "command_block"), new LegacyBlock(138, "beacon"),
new LegacyBlock(139, "cobble_wall", "cobblestone_wall"),
new LegacyBlock(139, 1, "cobble_wall", "mossy_cobblestone_wall"),
new LegacyBlock(140, "flower_pot"), new LegacyBlock(141, "carrot", "carrots"),
new LegacyBlock(142, "potato", "potatoes"),
new LegacyBlock(143, "wood_button", "oak_button"),
new LegacyBlock(144, "skull", "skeleton_skull"),
new LegacyBlock(144, 1, "skull", "skeleton_wall_skull"),
new LegacyBlock(144, 2, "skull", "skeleton_wall_skull"),
new LegacyBlock(144, 3, "skull", "skeleton_wall_skull"),
new LegacyBlock(144, 4, "skull", "skeleton_wall_skull"),
new LegacyBlock(144, 5, "skull", "skeleton_wall_skull"), new LegacyBlock(145, "anvil"),
new LegacyBlock(145, 1, "anvil", "chipped_anvil"),
new LegacyBlock(145, 2, "anvil", "damaged_anvil"),
new LegacyBlock(146, "trapped_chest"),
new LegacyBlock(147, "gold_plate", "light_weighted_pressure_plate"),
new LegacyBlock(148, "iron_plate", "heavy_weighted_pressure_plate"),
new LegacyBlock(149, "redstone_comparator_off"),
new LegacyBlock(150, "redstone_comparator_on", "comparator"),
new LegacyBlock(151, "daylight_detector"), new LegacyBlock(152, "redstone_block"),
new LegacyBlock(153, "quartz_ore", "nether_quartz_ore"), new LegacyBlock(154, "hopper"),
new LegacyBlock(155, "quartz_block"), new LegacyBlock(156, "quartz_stairs"),
new LegacyBlock(157, "activator_rail"), new LegacyBlock(158, "dropper"),
new LegacyBlock(159, "stained_clay", "white_terracotta"),
new LegacyBlock(159, 1, "stained_clay", "orange_terracotta"),
new LegacyBlock(159, 2, "stained_clay", "magenta_terracotta"),
new LegacyBlock(159, 3, "stained_clay", "light_blue_terracotta"),
new LegacyBlock(159, 4, "stained_clay", "yellow_terracotta"),
new LegacyBlock(159, 5, "stained_clay", "lime_terracotta"),
new LegacyBlock(159, 6, "stained_clay", "pink_terracotta"),
new LegacyBlock(159, 7, "stained_clay", "gray_terracotta"),
new LegacyBlock(159, 8, "stained_clay", "light_gray_terracotta"),
new LegacyBlock(159, 9, "stained_clay", "cyan_terracotta"),
new LegacyBlock(159, 10, "stained_clay", "purple_terracotta"),
new LegacyBlock(159, 11, "stained_clay", "blue_terracotta"),
new LegacyBlock(159, 12, "stained_clay", "brown_terracotta"),
new LegacyBlock(159, 13, "stained_clay", "green_terracotta"),
new LegacyBlock(159, 14, "stained_clay", "red_terracotta"),
new LegacyBlock(159, 15, "stained_clay", "black_terracotta"),
new LegacyBlock(160, "stained_glass_pane", "white_stained_glass_pane"),
new LegacyBlock(160, 1, "stained_glass_pane", "orange_stained_glass_pane"),
new LegacyBlock(160, 2, "stained_glass_pane", "magenta_stained_glass_pane"),
new LegacyBlock(160, 3, "stained_glass_pane", "light_blue_stained_glass_pane"),
new LegacyBlock(160, 4, "stained_glass_pane", "yellow_stained_glass_pane"),
new LegacyBlock(160, 5, "stained_glass_pane", "lime_stained_glass_pane"),
new LegacyBlock(160, 6, "stained_glass_pane", "pink_stained_glass_pane"),
new LegacyBlock(160, 7, "stained_glass_pane", "gray_stained_glass_pane"),
new LegacyBlock(160, 8, "stained_glass_pane", "light_gray_stained_glass_pane"),
new LegacyBlock(160, 9, "stained_glass_pane", "cyan_stained_glass_pane"),
new LegacyBlock(160, 10, "stained_glass_pane", "purple_stained_glass_pane"),
new LegacyBlock(160, 11, "stained_glass_pane", "blue_stained_glass_pane"),
new LegacyBlock(160, 12, "stained_glass_pane", "brown_stained_glass_pane"),
new LegacyBlock(160, 13, "stained_glass_pane", "green_stained_glass_pane"),
new LegacyBlock(160, 14, "stained_glass_pane", "red_stained_glass_pane"),
new LegacyBlock(160, 15, "stained_glass_pane", "black_stained_glass_pane"),
new LegacyBlock(161, "leaves_2", "acacia_leaves"),
new LegacyBlock(161, 1, "leaves_2", "dark_oak_leaves"),
new LegacyBlock(162, "log_2", "acacia_log"),
new LegacyBlock(162, 1, "log_2", "spruce_log"),
new LegacyBlock(162, 2, "log_2", "birch_log"),
new LegacyBlock(162, 3, "log_2", "jungle_log"),
new LegacyBlock(163, "acacia_stairs", "acacia_stairs"),
new LegacyBlock(164, "dark_oak_stairs", "dark_oak_stairs"),
new LegacyBlock(165, "slime_block", "slime_block"),
new LegacyBlock(166, "barrier", "barrier"),
new LegacyBlock(167, "iron_trapdoor", "iron_trapdoor"),
new LegacyBlock(168, "prismarine"),
new LegacyBlock(168, 1, "prismarine", "prismarine_bricks"),
new LegacyBlock(168, 2, "prismarine", "dark_prismarine"),
new LegacyBlock(169, "sea_lantern"), new LegacyBlock(170, "hay_block"),
new LegacyBlock(171, "carpet", "white_carpet"),
new LegacyBlock(171, 1, "carpet", "orange_carpet"),
new LegacyBlock(171, 2, "carpet", "magenta_carpet"),
new LegacyBlock(171, 3, "carpet", "light_blue_carpet"),
new LegacyBlock(171, 4, "carpet", "yellow_carpet"),
new LegacyBlock(171, 5, "carpet", "lime_carpet"),
new LegacyBlock(171, 6, "carpet", "pink_carpet"),
new LegacyBlock(171, 7, "carpet", "gray_carpet"),
new LegacyBlock(171, 8, "carpet", "light_gray_carpet"),
new LegacyBlock(171, 9, "carpet", "cyan_carpet"),
new LegacyBlock(171, 10, "carpet", "purple_carpet"),
new LegacyBlock(171, 11, "carpet", "blue_carpet"),
new LegacyBlock(171, 12, "carpet", "brown_carpet"),
new LegacyBlock(171, 13, "carpet", "green_carpet"),
new LegacyBlock(171, 14, "carpet", "red_carpet"),
new LegacyBlock(171, 15, "carpet", "black_carpet"),
new LegacyBlock(172, "hard_clay", "terracotta"), new LegacyBlock(173, "coal_block"),
new LegacyBlock(174, "packed_ice"), new LegacyBlock(175, "double_plant", "sunflower"),
new LegacyBlock(175, 1, "double_plant", "lilac"),
new LegacyBlock(175, 2, "double_plant", "tall_grass"),
new LegacyBlock(175, 3, "double_plant", "large_fern"),
new LegacyBlock(175, 4, "double_plant", "rose_bush"),
new LegacyBlock(175, 5, "double_plant", "peony"),
new LegacyBlock(176, "standing_banner"), new LegacyBlock(177, "wall_banner"),
new LegacyBlock(178, "daylight_detector_inverted"),
new LegacyBlock(179, "red_sandstone", "red_sandstone"),
new LegacyBlock(179, 1, "red_sandstone", "chiseled_red_sandstone"),
new LegacyBlock(179, 2, "red_sandstone", "cut_red_sandstone"),
new LegacyBlock(180, "red_sandstone_stairs"),
new LegacyBlock(181, "double_stone_slab2"),
new LegacyBlock(181, 8, "double_stone_slab2", "smooth_red_sandstone"),
new LegacyBlock(182, "stone_slab2", "red_sandstone_slab"),
new LegacyBlock(183, "spruce_fence_gate"), new LegacyBlock(184, "birch_fence_gate"),
new LegacyBlock(185, "jungle_fence_gate"), new LegacyBlock(186, "dark_oak_fence_gate"),
new LegacyBlock(187, "acacia_fence_gate"), new LegacyBlock(188, "spruce_fence"),
new LegacyBlock(189, "birch_fence"), new LegacyBlock(190, "jungle_fence"),
new LegacyBlock(191, "dark_oak_fence"), new LegacyBlock(192, "acacia_fence"),
new LegacyBlock(193, "spruce_door"), new LegacyBlock(194, "birch_door"),
new LegacyBlock(195, "jungle_door"), new LegacyBlock(196, "acacia_door"),
new LegacyBlock(197, "dark_oak_door"), new LegacyBlock(198, "end_rod"),
new LegacyBlock(199, "chorus_plant"), new LegacyBlock(200, "chorus_flower"),
new LegacyBlock(201, "purpur_block"), new LegacyBlock(202, "purpur_pillar"),
new LegacyBlock(203, "purpur_stairs"), new LegacyBlock(204, "purpur_double_slab"),
new LegacyBlock(205, "purpur_slab"),
new LegacyBlock(206, "end_bricks", "end_stone_bricks"),
new LegacyBlock(207, "beetroot_block", "beetroots"), new LegacyBlock(208, "grass_path"),
new LegacyBlock(209, "end_gateway"),
new LegacyBlock(210, "command_repeating", "repeating_command_block"),
new LegacyBlock(211, "command_chain", "chain_command_block"),
new LegacyBlock(212, "frosted_ice"), new LegacyBlock(213, "magma", "magma_block"),
new LegacyBlock(214, "nether_wart_block"),
new LegacyBlock(215, "red_nether_brick", "red_nether_bricks"),
new LegacyBlock(216, "bone_block"), new LegacyBlock(217, "structure_void"),
new LegacyBlock(218, "observer"), new LegacyBlock(219, "white_shulker_box"),
new LegacyBlock(220, "orange_shulker_box"), new LegacyBlock(221, "magenta_shulker_box"),
new LegacyBlock(222, "light_blue_shulker_box"),
new LegacyBlock(223, "yellow_shulker_box"), new LegacyBlock(224, "lime_shulker_box"),
new LegacyBlock(225, "pink_shulker_box"), new LegacyBlock(226, "gray_shulker_box"),
new LegacyBlock(227, "silver_shulker_box", "light_gray_shulker_box"),
new LegacyBlock(228, "cyan_shulker_box"), new LegacyBlock(229, "purple_shulker_box"),
new LegacyBlock(230, "blue_shulker_box"), new LegacyBlock(231, "brown_shulker_box"),
new LegacyBlock(232, "green_shulker_box"), new LegacyBlock(233, "red_shulker_box"),
new LegacyBlock(234, "black_shulker_box"),
new LegacyBlock(235, "white_glazed_terracotta"),
new LegacyBlock(236, "orange_glazed_terracotta"),
new LegacyBlock(237, "magenta_glazed_terracotta"),
new LegacyBlock(238, "light_blue_glazed_terracotta"),
new LegacyBlock(239, "yellow_glazed_terracotta"),
new LegacyBlock(240, "lime_glazed_terracotta"),
new LegacyBlock(241, "pink_glazed_terracotta"),
new LegacyBlock(242, "gray_glazed_terracotta"),
new LegacyBlock(243, "silver_glazed_terracotta", "light_gray_glazed_terracotta"),
new LegacyBlock(244, "cyan_glazed_terracotta"),
new LegacyBlock(245, "purple_glazed_terracotta"),
new LegacyBlock(246, "blue_glazed_terracotta"),
new LegacyBlock(247, "brown_glazed_terracotta"),
new LegacyBlock(248, "green_glazed_terracotta"),
new LegacyBlock(249, "red_glazed_terracotta"),
new LegacyBlock(250, "black_glazed_terracotta"),
new LegacyBlock(251, "concrete", "white_concrete"),
new LegacyBlock(251, 1, "concrete", "orange_concrete"),
new LegacyBlock(251, 2, "concrete", "magenta_concrete"),
new LegacyBlock(251, 3, "concrete", "light_blue_concrete"),
new LegacyBlock(251, 4, "concrete", "yellow_concrete"),
new LegacyBlock(251, 5, "concrete", "lime_concrete"),
new LegacyBlock(251, 6, "concrete", "pink_concrete"),
new LegacyBlock(251, 7, "concrete", "gray_concrete"),
new LegacyBlock(251, 8, "concrete", "light_gray_concrete"),
new LegacyBlock(251, 9, "concrete", "cyan_concrete"),
new LegacyBlock(251, 10, "concrete", "purple_concrete"),
new LegacyBlock(251, 11, "concrete", "blue_concrete"),
new LegacyBlock(251, 12, "concrete", "brown_concrete"),
new LegacyBlock(251, 13, "concrete", "green_concrete"),
new LegacyBlock(251, 14, "concrete", "red_concrete"),
new LegacyBlock(251, 15, "concrete", "black_concrete"),
new LegacyBlock(252, "concrete_powder", "white_concrete_powder"),
new LegacyBlock(252, 1, "concrete_powder", "orange_concrete_powder"),
new LegacyBlock(252, 2, "concrete_powder", "magenta_concrete_powder"),
new LegacyBlock(252, 3, "concrete_powder", "light_blue_concrete_powder"),
new LegacyBlock(252, 4, "concrete_powder", "yellow_concrete_powder"),
new LegacyBlock(252, 5, "concrete_powder", "lime_concrete_powder"),
new LegacyBlock(252, 6, "concrete_powder", "pink_concrete_powder"),
new LegacyBlock(252, 7, "concrete_powder", "gray_concrete_powder"),
new LegacyBlock(252, 8, "concrete_powder", "light_gray_concrete_powder"),
new LegacyBlock(252, 9, "concrete_powder", "cyan_concrete_powder"),
new LegacyBlock(252, 10, "concrete_powder", "purple_concrete_powder"),
new LegacyBlock(252, 11, "concrete_powder", "blue_concrete_powder"),
new LegacyBlock(252, 12, "concrete_powder", "brown_concrete_powder"),
new LegacyBlock(252, 13, "concrete_powder", "green_concrete_powder"),
new LegacyBlock(252, 14, "concrete_powder", "red_concrete_powder"),
new LegacyBlock(252, 15, "concrete_powder", "black_concrete_powder"),
new LegacyBlock(255, "structure_block"),
new LegacyBlock(256, "iron_spade", "iron_shovel"), new LegacyBlock(257, "iron_pickaxe"),
new LegacyBlock(258, "iron_axe"), new LegacyBlock(259, "flint_and_steel"),
new LegacyBlock(260, "apple"), new LegacyBlock(261, "bow"),
new LegacyBlock(262, "arrow"), new LegacyBlock(263, "coal"),
new LegacyBlock(263, 1, "coal", "charcoal"), new LegacyBlock(264, "diamond"),
new LegacyBlock(265, "iron_ingot"), new LegacyBlock(266, "gold_ingot"),
new LegacyBlock(267, "iron_sword"), new LegacyBlock(268, "wood_sword", "wooden_sword"),
new LegacyBlock(269, "wood_spade", "wooden_shovel"),
new LegacyBlock(270, "wood_pickaxe", "wooden_pickaxe"),
new LegacyBlock(271, "wood_axe", "wooden_axe"), new LegacyBlock(272, "stone_sword"),
new LegacyBlock(273, "stone_spade", "stone_shovel"),
new LegacyBlock(274, "stone_pickaxe"), new LegacyBlock(275, "stone_axe"),
new LegacyBlock(276, "diamond_sword"),
new LegacyBlock(277, "diamond_spade", "diamond_shovel"),
new LegacyBlock(278, "diamond_pickaxe"), new LegacyBlock(279, "diamond_axe"),
new LegacyBlock(280, "stick"), new LegacyBlock(281, "bowl"),
new LegacyBlock(282, "mushroom_soup", "mushroom_stew"),
new LegacyBlock(283, "gold_sword", "golden_sword"),
new LegacyBlock(284, "gold_spade", "golden_shovel"),
new LegacyBlock(285, "gold_pickaxe", "golden_pickaxe"),
new LegacyBlock(286, "gold_axe", "golden_axe"), new LegacyBlock(287, "string"),
new LegacyBlock(288, "feather"), new LegacyBlock(289, "sulphur", "gunpowder"),
new LegacyBlock(290, "wood_hoe", "wooden_hoe"), new LegacyBlock(291, "stone_hoe"),
new LegacyBlock(292, "iron_hoe"), new LegacyBlock(293, "diamond_hoe"),
new LegacyBlock(294, "gold_hoe", "golden_hoe"),
new LegacyBlock(295, "seeds", "wheat_seeds"), new LegacyBlock(296, "wheat"),
new LegacyBlock(297, "bread"), new LegacyBlock(298, "leather_helmet"),
new LegacyBlock(299, "leather_chestplate"), new LegacyBlock(300, "leather_leggings"),
new LegacyBlock(301, "leather_boots"), new LegacyBlock(302, "chainmail_helmet"),
new LegacyBlock(303, "chainmail_chestplate"),
new LegacyBlock(304, "chainmail_leggings"), new LegacyBlock(305, "chainmail_boots"),
new LegacyBlock(306, "iron_helmet"), new LegacyBlock(307, "iron_chestplate"),
new LegacyBlock(308, "iron_leggings"), new LegacyBlock(309, "iron_boots"),
new LegacyBlock(310, "diamond_helmet"), new LegacyBlock(311, "diamond_chestplate"),
new LegacyBlock(312, "diamond_leggings"), new LegacyBlock(313, "diamond_boots"),
new LegacyBlock(314, "gold_helmet", "golden_helmet"),
new LegacyBlock(315, "gold_chestplate", "golden_chestplate"),
new LegacyBlock(316, "gold_leggings", "golden_leggings"),
new LegacyBlock(317, "gold_boots", "golden_boots"), new LegacyBlock(318, "flint"),
new LegacyBlock(319, "pork", "porkchop"),
new LegacyBlock(320, "grilled_pork", "cooked_porkchop"),
new LegacyBlock(321, "painting"), new LegacyBlock(322, "golden_apple", "golden_apple"),
new LegacyBlock(322, 1, "golden_apple", "enchanted_golden_apple"),
new LegacyBlock(323, "sign"), new LegacyBlock(324, "wood_door", "oak_door"),
new LegacyBlock(325, "bucket"), new LegacyBlock(326, "water_bucket"),
new LegacyBlock(327, "lava_bucket"), new LegacyBlock(328, "minecart"),
new LegacyBlock(329, "saddle"), new LegacyBlock(330, "iron_door"),
new LegacyBlock(331, "redstone"), new LegacyBlock(332, "snow_ball", "snowball"),
new LegacyBlock(333, "boat", "oak_boat"), new LegacyBlock(334, "leather"),
new LegacyBlock(335, "milk_bucket"), new LegacyBlock(336, "clay_brick", "brick"),
new LegacyBlock(337, "clay_ball"), new LegacyBlock(338, "sugar_cane"),
new LegacyBlock(339, "paper"), new LegacyBlock(340, "book"),
new LegacyBlock(341, "slime_ball"),
new LegacyBlock(342, "storage_minecart", "chest_minecart"),
new LegacyBlock(343, "powered_minecart", "furnace_minecart"),
new LegacyBlock(344, "egg"), new LegacyBlock(345, "compass"),
new LegacyBlock(346, "fishing_rod"), new LegacyBlock(347, "watch", "clock"),
new LegacyBlock(348, "glowstone_dust"), new LegacyBlock(349, "raw_fish", "cod"),
new LegacyBlock(349, 1, "raw_fish", "salmon"),
new LegacyBlock(349, 2, "raw_fish", "tropical_fish"),
new LegacyBlock(349, 3, "raw_fish", "pufferfish"),
new LegacyBlock(350, "cooked_fish", "cooked_cod"),
new LegacyBlock(350, 1, "cooked_fish", "cooked_salmon"),
new LegacyBlock(351, "ink_sack", "ink_sac"),
new LegacyBlock(351, 1, "ink_sack", "rose_red"),
new LegacyBlock(351, 2, "ink_sack", "cactus_green"),
new LegacyBlock(351, 3, "ink_sack", "cocoa_beans"),
new LegacyBlock(351, 4, "ink_sack", "lapis_lazuli"),
new LegacyBlock(351, 5, "ink_sack", "purple_dye"),
new LegacyBlock(351, 6, "ink_sack", "cyan_dye"),
new LegacyBlock(351, 7, "ink_sack", "light_gray_dye"),
new LegacyBlock(351, 8, "ink_sack", "gray_dye"),
new LegacyBlock(351, 9, "ink_sack", "pink_dye"),
new LegacyBlock(351, 10, "ink_sack", "lime_dye"),
new LegacyBlock(351, 11, "ink_sack", "dandelion_yellow"),
new LegacyBlock(351, 12, "ink_sack", "light_blue_dye"),
new LegacyBlock(351, 13, "ink_sack", "magenta_dye"),
new LegacyBlock(351, 14, "ink_sack", "orange_dye"),
new LegacyBlock(351, 15, "ink_sack", "bone_meal"), new LegacyBlock(352, "bone"),
new LegacyBlock(353, "sugar", "sugar"), new LegacyBlock(354, "cake", "cake"),
new LegacyBlock(355, "bed", "white_bed"), new LegacyBlock(355, 1, "bed", "orange_bed"),
new LegacyBlock(355, 2, "bed", "magenta_bed"),
new LegacyBlock(355, 3, "bed", "light_blue_bed"),
new LegacyBlock(355, 4, "bed", "yellow_bed"),
new LegacyBlock(355, 5, "bed", "lime_bed"), new LegacyBlock(355, 6, "bed", "pink_bed"),
new LegacyBlock(355, 7, "bed", "gray_bed"),
new LegacyBlock(355, 8, "bed", "light_gray_bed"),
new LegacyBlock(355, 9, "bed", "cyan_bed"),
new LegacyBlock(355, 10, "bed", "purple_bed"),
new LegacyBlock(355, 11, "bed", "blue_bed"),
new LegacyBlock(355, 12, "bed", "brown_bed"),
new LegacyBlock(355, 13, "bed", "green_bed"),
new LegacyBlock(355, 14, "bed", "red_bed"),
new LegacyBlock(355, 15, "bed", "black_bed"), new LegacyBlock(356, "diode", "repeater"),
new LegacyBlock(357, "cookie", "cookie"), new LegacyBlock(358, "map"),
new LegacyBlock(359, "shears"), new LegacyBlock(360, "melon", "melon"),
new LegacyBlock(361, "pumpkin_seeds", "pumpkin_seeds"),
new LegacyBlock(362, "melon_seeds", "melon_seeds"),
new LegacyBlock(363, "raw_beef", "beef"), new LegacyBlock(364, "cooked_beef"),
new LegacyBlock(365, "raw_chicken", "chicken"), new LegacyBlock(366, "cooked_chicken"),
new LegacyBlock(367, "rotten_flesh"), new LegacyBlock(368, "ender_pearl"),
new LegacyBlock(369, "blaze_rod"), new LegacyBlock(370, "ghast_tear"),
new LegacyBlock(371, "gold_nugget"),
new LegacyBlock(372, "nether_stalk", "nether_wart"),
new LegacyBlock(373, "potion", "potion"), new LegacyBlock(374, "glass_bottle"),
new LegacyBlock(375, "spider_eye"), new LegacyBlock(376, "fermented_spider_eye"),
new LegacyBlock(377, "blaze_powder"), new LegacyBlock(378, "magma_cream"),
new LegacyBlock(379, "brewing_stand_item", "brewing_stand"),
new LegacyBlock(380, "cauldron_item", "cauldron"),
new LegacyBlock(381, "eye_of_ender", "ender_eye"),
new LegacyBlock(382, "speckled_melon"), new LegacyBlock(383, "monster_egg"),
new LegacyBlock(383, 4, "monster_egg", "elder_guardian_spawn_egg"),
new LegacyBlock(383, 5, "monster_egg", "wither_skeleton_spawn_egg"),
new LegacyBlock(383, 6, "monster_egg", "stray_spawn_egg"),
new LegacyBlock(383, 23, "monster_egg", "husk_spawn_egg"),
new LegacyBlock(383, 27, "monster_egg", "zombie_villager_spawn_egg"),
new LegacyBlock(383, 28, "monster_egg", "skeleton_horse_spawn_egg"),
new LegacyBlock(383, 29, "monster_egg", "zombie_horse_spawn_egg"),
new LegacyBlock(383, 31, "monster_egg", "donkey_spawn_egg"),
new LegacyBlock(383, 32, "monster_egg", "mule_spawn_egg"),
new LegacyBlock(383, 34, "monster_egg", "evocation_illager_spawn_egg"),
new LegacyBlock(383, 35, "monster_egg", "vex_spawn_egg"),
new LegacyBlock(383, 36, "monster_egg", "vindication_illager_spawn_egg"),
new LegacyBlock(383, 50, "monster_egg", "creeper_spawn_egg"),
new LegacyBlock(383, 51, "monster_egg", "skeleton_spawn_egg"),
new LegacyBlock(383, 52, "monster_egg", "spider_spawn_egg"),
new LegacyBlock(383, 54, "monster_egg", "zombie_spawn_egg"),
new LegacyBlock(383, 55, "monster_egg", "slime_spawn_egg"),
new LegacyBlock(383, 56, "monster_egg", "ghast_spawn_egg"),
new LegacyBlock(383, 57, "monster_egg", "zombie_pigman_spawn_egg"),
new LegacyBlock(383, 58, "monster_egg", "enderman_spawn_egg"),
new LegacyBlock(383, 59, "monster_egg", "cave_spider_spawn_egg"),
new LegacyBlock(383, 60, "monster_egg", "silverfish_spawn_egg"),
new LegacyBlock(383, 61, "monster_egg", "blaze_spawn_egg"),
new LegacyBlock(383, 62, "monster_egg", "magma_cube_spawn_egg"),
new LegacyBlock(383, 65, "monster_egg", "bat_spawn_egg"),
new LegacyBlock(383, 66, "monster_egg", "witch_spawn_egg"),
new LegacyBlock(383, 67, "monster_egg", "endermite_spawn_egg"),
new LegacyBlock(383, 68, "monster_egg", "guardian_spawn_egg"),
new LegacyBlock(383, 69, "monster_egg", "shulker_spawn_egg"),
new LegacyBlock(383, 90, "monster_egg", "pig_spawn_egg"),
new LegacyBlock(383, 91, "monster_egg", "sheep_spawn_egg"),
new LegacyBlock(383, 92, "monster_egg", "cow_spawn_egg"),
new LegacyBlock(383, 93, "monster_egg", "chicken_spawn_egg"),
new LegacyBlock(383, 94, "monster_egg", "squid_spawn_egg"),
new LegacyBlock(383, 95, "monster_egg", "wolf_spawn_egg"),
new LegacyBlock(383, 96, "monster_egg", "mooshroom_spawn_egg"),
new LegacyBlock(383, 98, "monster_egg", "ocelot_spawn_egg"),
new LegacyBlock(383, 100, "monster_egg", "horse_spawn_egg"),
new LegacyBlock(383, 101, "monster_egg", "rabbit_spawn_egg"),
new LegacyBlock(383, 102, "monster_egg", "polar_bear_spawn_egg"),
new LegacyBlock(383, 103, "monster_egg", "llama_spawn_egg"),
new LegacyBlock(383, 120, "monster_egg", "villager_spawn_egg"),
new LegacyBlock(384, "exp_bottle", "experience_bottle"),
new LegacyBlock(385, "fireball", "fire_charge"),
new LegacyBlock(386, "book_and_quill", "writable_book"),
new LegacyBlock(387, "written_book"), new LegacyBlock(388, "emerald"),
new LegacyBlock(389, "item_frame"),
new LegacyBlock(390, "flower_pot_item", "flower_pot"),
new LegacyBlock(391, "carrot_item", "carrot"),
new LegacyBlock(392, "potato_item", "potato"), new LegacyBlock(393, "baked_potato"),
new LegacyBlock(394, "poisonous_potato"), new LegacyBlock(395, "empty_map", "map"),
new LegacyBlock(396, "golden_carrot"),
new LegacyBlock(397, "skull_item", "skeleton_skull"),
new LegacyBlock(397, 1, "skull_item", "wither_skeleton_skull"),
new LegacyBlock(397, 2, "skull_item", "zombie_head"),
new LegacyBlock(397, 3, "skull_item", "player_head"),
new LegacyBlock(397, 4, "skull_item", "creeper_head"),
new LegacyBlock(397, 5, "skull_item", "dragon_head"),
new LegacyBlock(398, "carrot_stick"), new LegacyBlock(399, "nether_star"),
new LegacyBlock(400, "pumpkin_pie"),
new LegacyBlock(401, "firework", "firework_rocket"),
new LegacyBlock(402, "firework_charge", "firework_star"),
new LegacyBlock(403, "enchanted_book"),
new LegacyBlock(404, "redstone_comparator", "comparator"),
new LegacyBlock(405, "nether_brick_item", "nether_brick"),
new LegacyBlock(406, "quartz"),
new LegacyBlock(407, "explosive_minecart", "tnt_minecart"),
new LegacyBlock(408, "hopper_minecart"), new LegacyBlock(409, "prismarine_shard"),
new LegacyBlock(410, "prismarine_crystals"), new LegacyBlock(411, "rabbit"),
new LegacyBlock(412, "cooked_rabbit"), new LegacyBlock(413, "rabbit_stew"),
new LegacyBlock(414, "rabbit_foot"), new LegacyBlock(415, "rabbit_hide"),
new LegacyBlock(416, "armor_stand"),
new LegacyBlock(417, "iron_barding", "iron_horse_armor"),
new LegacyBlock(418, "gold_barding", "gold_horse_armor"),
new LegacyBlock(419, "diamond_barding", "diamond_horse_armor"),
new LegacyBlock(420, "leash", "lead"), new LegacyBlock(421, "name_tag"),
new LegacyBlock(422, "command_minecart", "command_block_minecart"),
new LegacyBlock(423, "mutton"), new LegacyBlock(424, "cooked_mutton"),
new LegacyBlock(425, "banner", "white_banner"),
new LegacyBlock(425, 1, "banner", "orange_banner"),
new LegacyBlock(425, 2, "banner", "magenta_banner"),
new LegacyBlock(425, 3, "banner", "light_blue_banner"),
new LegacyBlock(425, 4, "banner", "yellow_banner"),
new LegacyBlock(425, 5, "banner", "lime_banner"),
new LegacyBlock(425, 6, "banner", "pink_banner"),
new LegacyBlock(425, 7, "banner", "gray_banner"),
new LegacyBlock(425, 8, "banner", "light_gray_banner"),
new LegacyBlock(425, 9, "banner", "cyan_banner"),
new LegacyBlock(425, 10, "banner", "purple_banner"),
new LegacyBlock(425, 11, "banner", "blue_banner"),
new LegacyBlock(425, 12, "banner", "brown_banner"),
new LegacyBlock(425, 13, "banner", "green_banner"),
new LegacyBlock(425, 14, "banner", "red_banner"),
new LegacyBlock(425, 15, "banner", "black_banner"), new LegacyBlock(426, "end_crystal"),
new LegacyBlock(427, "spruce_door_item", "spruce_door"),
new LegacyBlock(428, "birch_door_item", "birch_door"),
new LegacyBlock(429, "jungle_door_item", "jungle_door"),
new LegacyBlock(430, "acacia_door_item", "acacia_door"),
new LegacyBlock(431, "dark_oak_door_item", "dark_oak_door"),
new LegacyBlock(432, "chorus_fruit"), new LegacyBlock(433, "chorus_fruit_popped"),
new LegacyBlock(434, "beetroot"), new LegacyBlock(435, "beetroot_seeds"),
new LegacyBlock(436, "beetroot_soup"),
new LegacyBlock(437, "dragons_breath", "dragon_breath"),
new LegacyBlock(438, "splash_potion"), new LegacyBlock(439, "spectral_arrow"),
new LegacyBlock(440, "tipped_arrow"), new LegacyBlock(441, "lingering_potion"),
new LegacyBlock(442, "shield"), new LegacyBlock(443, "elytra"),
new LegacyBlock(444, "boat_spruce", "spruce_boat"),
new LegacyBlock(445, "boat_birch", "birch_boat"),
new LegacyBlock(446, "boat_jungle", "jungle_boat"),
new LegacyBlock(447, "boat_acacia", "acacia_boat"),
new LegacyBlock(448, "boat_dark_oak", "dark_oak_boat"),
new LegacyBlock(449, "totem", "totem_of_undying"),
new LegacyBlock(450, "shulker_shell"), new LegacyBlock(452, "iron_nugget"),
new LegacyBlock(453, "knowledge_book"),
new LegacyBlock(2256, "gold_record", "music_disc_13"),
new LegacyBlock(2257, "green_record", "music_disc_cat"),
new LegacyBlock(2258, "record_3", "music_disc_blocks"),
new LegacyBlock(2259, "record_4", "music_disc_chirp"),
new LegacyBlock(2260, "record_5", "music_disc_far"),
new LegacyBlock(2261, "record_6", "music_disc_mall"),
new LegacyBlock(2262, "record_7", "music_disc_mellohi"),
new LegacyBlock(2263, "record_8", "music_disc_stal"),
new LegacyBlock(2264, "record_9", "music_disc_strad"),
new LegacyBlock(2265, "record_10", "music_disc_ward"),
new LegacyBlock(2266, "record_11", "music_disc_11"),
new LegacyBlock(2267, "record_12", "music_disc_wait")};
private static final Map<IdDataPair, PlotBlock> LEGACY_ID_AND_DATA_TO_STRING_PLOT_BLOCK =
new HashMap<>();
private static final Map<String, PlotBlock> NEW_STRING_TO_LEGACY_PLOT_BLOCK = new HashMap<>();
private static final Map<String, PlotBlock> OLD_STRING_TO_STRING_PLOT_BLOCK = new HashMap<>();
@SuppressWarnings("deprecation") public BukkitLegacyMappings() {
this.addAll(Arrays.asList(BLOCKS));
// Make sure to add new blocks as well
final List<LegacyBlock> missing = new ArrayList<>();
for (final Material material : Material.values()) {
final String materialName = material.name().toLowerCase(Locale.ENGLISH);
if (NEW_STRING_TO_LEGACY_PLOT_BLOCK.get(materialName) == null) {
try {
final LegacyBlock missingBlock =
new LegacyBlock(material.getId(), materialName, materialName);
missing.add(missingBlock);
} catch (Exception ignored) {
}
}
}
addAll(missing);
}
private void addAll(@NonNull final Collection<LegacyBlock> blocks) {
for (final LegacyBlock legacyBlock : blocks) {
LEGACY_ID_AND_DATA_TO_STRING_PLOT_BLOCK
.put(new IdDataPair(legacyBlock.getNumericalId(), legacyBlock.getDataValue()),
legacyBlock.toStringPlotBlock());
NEW_STRING_TO_LEGACY_PLOT_BLOCK
.put(legacyBlock.getNewName(), legacyBlock.toLegacyPlotBlock());
OLD_STRING_TO_STRING_PLOT_BLOCK
.put(legacyBlock.getLegacyName(), legacyBlock.toStringPlotBlock());
Material material;
try {
material = Material.valueOf(legacyBlock.getNewName());
} catch (final Exception e) {
try {
material = Material.getMaterial(legacyBlock.getLegacyName(), true);
} catch (NoSuchMethodError error) {
PlotSquared.log("You can't use this version of PlotSquared on a server "
+ "less than Minecraft 1.13.2");
Bukkit.shutdown();
break;
}
}
legacyBlock.material = material;
}
}
public Collection<PlotBlock> getPlotBlocks() {
return Arrays.stream(BLOCKS).map(block -> PlotBlock.get(block.getNewName()))
.collect(Collectors.toList());
}
public StringComparison<PlotBlock>.ComparisonResult getClosestsMatch(
@NonNull final String string) {
final StringComparison<PlotBlock> comparison =
new StringComparison<>(string, getPlotBlocks());
return comparison.getBestMatchAdvanced();
}
/**
* Try to find a legacy plot block by any means possible. Strategy: - Check if the name contains
* a namespace, if so, strip it - Check if there's a (new) material matching the name - Check if
* there's a legacy material matching the name - Check if there's a numerical ID matching the
* name - Return null if everything else fails
*
* @param string String ID
* @return LegacyBlock if found, else null
*/
public PlotBlock fromAny(@NonNull final String string) {
if (string.isEmpty()) {
return StringPlotBlock.EVERYTHING;
}
String workingString = string;
String[] parts = null;
IdDataPair idDataPair = null;
if (string.contains(":")) {
parts = string.split(":");
if (parts.length > 1) {
if (parts[0].equalsIgnoreCase("minecraft")) {
workingString = parts[1];
} else {
if (parts[0].matches("^\\d+$")) {
idDataPair =
new IdDataPair(Integer.parseInt(parts[0]), Integer.parseInt(parts[0]));
} else {
workingString = parts[0];
}
}
}
} else if (string.matches("^\\d+$")) {
idDataPair = new IdDataPair(Integer.parseInt(string), 0);
}
PlotBlock plotBlock;
if (Material.matchMaterial(workingString) != null) {
return PlotBlock.get(workingString);
} else if (NEW_STRING_TO_LEGACY_PLOT_BLOCK.containsKey(workingString.toLowerCase())) {
return PlotBlock.get(workingString);
} else if ((plotBlock = fromLegacyToString(idDataPair)) != null) {
return plotBlock;
} else if ((plotBlock = fromLegacyToString(workingString)) != null) {
return plotBlock;
} else {
try {
if (parts != null && parts.length > 1) {
final int id = Integer.parseInt(parts[0]);
final int data = Integer.parseInt(parts[1]);
return fromLegacyToString(id, data);
} else {
return fromLegacyToString(Integer.parseInt(workingString), 0);
}
} catch (final Throwable exception) {
return null;
}
}
}
public PlotBlock fromLegacyToString(final int id, final int data) {
return LEGACY_ID_AND_DATA_TO_STRING_PLOT_BLOCK.get(new IdDataPair(id, data));
}
public PlotBlock fromLegacyToString(IdDataPair idDataPair) {
if (idDataPair == null) {
return null;
}
return LEGACY_ID_AND_DATA_TO_STRING_PLOT_BLOCK.get(idDataPair);
}
public PlotBlock fromLegacyToString(final String id) {
return OLD_STRING_TO_STRING_PLOT_BLOCK.get(id);
}
public PlotBlock fromStringToLegacy(final String id) {
return NEW_STRING_TO_LEGACY_PLOT_BLOCK.get(id.toLowerCase(Locale.ENGLISH));
}
@Getter @EqualsAndHashCode @ToString @RequiredArgsConstructor
private static final class IdDataPair {
private final int id;
private final int data;
}
@Getter @RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public static final class LegacyBlock {
private final int numericalId;
private final int dataValue;
private final String legacyName;
private final String newName;
private Material material;
LegacyBlock(final int numericalId, final int dataValue, @NonNull final String legacyName) {
this(numericalId, dataValue, legacyName, legacyName);
}
LegacyBlock(final int numericalId, final int dataValue, @NonNull final String legacyName,
@NonNull final String newName, @NonNull final String new14Name) {
this(numericalId, dataValue, legacyName,
PlotSquared.get().IMP.getServerVersion()[1] == 13 ? newName : new14Name);
}
LegacyBlock(final int numericalId, @NonNull final String legacyName,
@NonNull final String newName, @NonNull final String new14Name) {
this(numericalId, 0, legacyName,
Bukkit.getBukkitVersion().split("-")[0].split("\\.")[1].equals("13") ?
newName :
new14Name);
}
LegacyBlock(final int numericalId, @NonNull final String legacyName,
@NonNull final String newName) {
this(numericalId, 0, legacyName, newName);
}
LegacyBlock(final int numericalId, @NonNull final String legacyName) {
this(numericalId, legacyName, legacyName);
}
PlotBlock toStringPlotBlock() {
return StringPlotBlock.get(newName);
}
PlotBlock toLegacyPlotBlock() {
return LegacyPlotBlock.get(numericalId, dataValue);
}
@Override public String toString() {
return this.newName;
}
}
}

View File

@ -2,19 +2,32 @@ package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.object.schematic.StateWrapper; import com.github.intellectualsites.plotsquared.bukkit.object.schematic.StateWrapper;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.sk89q.jnbt.*; import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntArrayTag;
import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.ShortTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.util.*; import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.IntStream; import java.util.stream.IntStream;
/** /**
@ -22,7 +35,7 @@ import java.util.stream.IntStream;
*/ */
public class BukkitSchematicHandler extends SchematicHandler { public class BukkitSchematicHandler extends SchematicHandler {
@Override public void getCompoundTag(final String world, final Set<RegionWrapper> regions, @Override public void getCompoundTag(final String world, final Set<CuboidRegion> regions,
final RunnableVal<CompoundTag> whenDone) { final RunnableVal<CompoundTag> whenDone) {
// async // async
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@ -61,7 +74,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
List<CompoundTag> tileEntities = new ArrayList<>(); List<CompoundTag> tileEntities = new ArrayList<>();
ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length); ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length);
// Queue // Queue
final ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions); final ArrayDeque<CuboidRegion> queue = new ArrayDeque<>(regions);
TaskManager.runTask(new Runnable() { TaskManager.runTask(new Runnable() {
@Override public void run() { @Override public void run() {
if (queue.isEmpty()) { if (queue.isEmpty()) {
@ -82,9 +95,9 @@ public class BukkitSchematicHandler extends SchematicHandler {
return; return;
} }
final Runnable regionTask = this; final Runnable regionTask = this;
RegionWrapper region = queue.poll(); CuboidRegion region = queue.poll();
Location pos1 = new Location(world, region.minX, region.minY, region.minZ); Location pos1 = new Location(world, region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ); Location pos2 = new Location(world, region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
final int p1x = pos1.getX(); final int p1x = pos1.getX();
final int sy = pos1.getY(); final int sy = pos1.getY();
final int p1z = pos1.getZ(); final int p1z = pos1.getZ();

View File

@ -3,6 +3,8 @@ package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.BukkitMain; import com.github.intellectualsites.plotsquared.bukkit.BukkitMain;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
public class BukkitTaskManager extends TaskManager { public class BukkitTaskManager extends TaskManager {
@ -26,7 +28,7 @@ public class BukkitTaskManager extends TaskManager {
@Override public void taskAsync(Runnable runnable) { @Override public void taskAsync(Runnable runnable) {
if (this.bukkitMain.isEnabled()) { if (this.bukkitMain.isEnabled()) {
this.bukkitMain.getServer().getScheduler() this.bukkitMain.getServer().getScheduler()
.runTaskAsynchronously(this.bukkitMain, runnable).getTaskId(); .runTaskAsynchronously(this.bukkitMain, runnable);
} else { } else {
runnable.run(); runnable.run();
} }

View File

@ -3,7 +3,11 @@ package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer; import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem; import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
@ -11,7 +15,10 @@ import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.world.block.BlockState;
import lombok.NonNull; import lombok.NonNull;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
@ -20,7 +27,6 @@ import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
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.Sign; import org.bukkit.block.Sign;
import org.bukkit.block.data.Directional; import org.bukkit.block.data.Directional;
import org.bukkit.block.data.type.WallSign; import org.bukkit.block.data.type.WallSign;
@ -36,7 +42,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Set; import java.util.Set;
@SuppressWarnings({"unused", "WeakerAccess"}) public class BukkitUtil extends WorldUtil { @SuppressWarnings({"unused", "WeakerAccess"}) public class BukkitUtil extends WorldUtil {
@ -258,23 +263,11 @@ import java.util.Set;
location.getPitch()); location.getPitch());
} }
public static BukkitLegacyMappings getBukkitLegacyMappings() { public static Material getMaterial(@NonNull final BlockState plotBlock) {
return (BukkitLegacyMappings) PlotSquared.imp().getLegacyMappings(); return BukkitAdapter.adapt(plotBlock.getBlockType());
} }
public static Material getMaterial(@NonNull final PlotBlock plotBlock) { @Override public boolean isBlockSame(BlockState block1, BlockState block2) {
if (plotBlock instanceof StringPlotBlock) {
return Material
.getMaterial(((StringPlotBlock) plotBlock).getItemId().toUpperCase(Locale.ENGLISH));
} else {
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock;
return getBukkitLegacyMappings()
.fromLegacyToString(legacyPlotBlock.getId(), legacyPlotBlock.getData())
.to(Material.class);
}
}
@Override public boolean isBlockSame(PlotBlock block1, PlotBlock block2) {
if (block1.equals(block2)) { if (block1.equals(block2)) {
return true; return true;
} }
@ -377,7 +370,7 @@ import java.util.Set;
sign.setFacing(facing); sign.setFacing(facing);
block.setBlockData(sign, false); block.setBlockData(sign, false);
} }
final BlockState blockstate = block.getState(); final org.bukkit.block.BlockState blockstate = block.getState();
if (blockstate instanceof Sign) { if (blockstate instanceof Sign) {
final Sign sign = (Sign) blockstate; final Sign sign = (Sign) blockstate;
for (int i = 0; i < lines.length; i++) { for (int i = 0; i < lines.length; i++) {
@ -405,13 +398,13 @@ import java.util.Set;
public boolean addItems(@NonNull final String worldName, @NonNull final PlotItem items) { public boolean addItems(@NonNull final String worldName, @NonNull final PlotItem items) {
final World world = getWorld(worldName); final World world = getWorld(worldName);
final Block block = world.getBlockAt(items.x, items.y, items.z); final Block block = world.getBlockAt(items.x, items.y, items.z);
final BlockState state = block.getState(); final org.bukkit.block.BlockState state = block.getState();
if (state instanceof InventoryHolder) { if (state instanceof InventoryHolder) {
InventoryHolder holder = (InventoryHolder) state; InventoryHolder holder = (InventoryHolder) state;
Inventory inv = holder.getInventory(); Inventory inv = holder.getInventory();
for (int i = 0; i < items.types.length; i++) { for (int i = 0; i < items.types.length; i++) {
// ItemStack item = new ItemStack(LegacyMappings.fromLegacyId(items.id[i]).getMaterial(), items.amount[i], items.data[i]); // ItemStack item = new ItemStack(LegacyMappings.fromLegacyId(items.id[i]).getMaterial(), items.amount[i], items.data[i]);
ItemStack item = new ItemStack(items.types[i].to(Material.class), items.amount[i]); ItemStack item = new ItemStack(BukkitAdapter.adapt(items.types[i]), items.amount[i]);
inv.addItem(item); inv.addItem(item);
} }
state.update(true); state.update(true);
@ -420,33 +413,11 @@ import java.util.Set;
return false; return false;
} }
@Override public boolean isBlockSolid(@NonNull final PlotBlock block) { @Override public boolean isBlockSolid(@NonNull final BlockState block) {
try { return block.getBlockType().getMaterial().isSolid();
Material material = getMaterial(block);
if (material.isLegacy()) {
material = getBukkitLegacyMappings().fromLegacyToString(material.name())
.to(Material.class);
}
if (material.isBlock() && material.isSolid() && !material.hasGravity()) {
String name = material.name().toLowerCase(Locale.ENGLISH);
if (material.isOccluding() || name.contains("stairs") || name.contains("slab")
|| name.contains("wool")) {
switch (material) {
case NOTE_BLOCK:
case SPAWNER:
return false;
default:
return true;
}
}
}
return false;
} catch (Exception ignored) {
return false;
}
} }
@Override public String getClosestMatchingName(@NonNull final PlotBlock block) { @Override public String getClosestMatchingName(@NonNull final BlockState block) {
try { try {
return getMaterial(block).name(); return getMaterial(block).name();
} catch (Exception ignored) { } catch (Exception ignored) {
@ -455,21 +426,18 @@ import java.util.Set;
} }
@Override @Nullable @Override @Nullable
public StringComparison<PlotBlock>.ComparisonResult getClosestBlock(String name) { public StringComparison<BlockState>.ComparisonResult getClosestBlock(String name) {
final PlotBlock plotBlock = BukkitUtil.getBukkitLegacyMappings().fromAny(name); BlockState state = BlockUtil.get(name);
if (plotBlock != null) { return new StringComparison<BlockState>().new ComparisonResult(1, state);
return new StringComparison<PlotBlock>().new ComparisonResult(1, plotBlock);
}
return BukkitUtil.getBukkitLegacyMappings().getClosestsMatch(name);
} }
@Override @Override
public void setBiomes(@NonNull final String worldName, @NonNull final RegionWrapper region, public void setBiomes(@NonNull final String worldName, @NonNull final CuboidRegion region,
@NonNull final String biomeString) { @NonNull final String biomeString) {
final World world = getWorld(worldName); final World world = getWorld(worldName);
final Biome biome = Biome.valueOf(biomeString.toUpperCase()); final Biome biome = Biome.valueOf(biomeString.toUpperCase());
for (int x = region.minX; x <= region.maxX; x++) { for (int x = region.getMinimumPoint().getX(); x <= region.getMaximumPoint().getX(); x++) {
for (int z = region.minZ; z <= region.maxZ; z++) { for (int z = region.getMinimumPoint().getZ(); z <= region.getMaximumPoint().getZ(); z++) {
world.setBiome(x, z, biome); world.setBiome(x, z, biome);
} }
} }
@ -479,10 +447,10 @@ import java.util.Set;
return new BukkitWorld(Bukkit.getWorld(world)); return new BukkitWorld(Bukkit.getWorld(world));
} }
@Override public PlotBlock getBlock(@NonNull final Location location) { @Override public BlockState getBlock(@NonNull final Location location) {
final World world = getWorld(location.getWorld()); final World world = getWorld(location.getWorld());
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ()); final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
return PlotBlock.get(block.getType().name()); return BlockUtil.get(block.getType().name());
} }
@Override public String getMainWorld() { @Override public String getMainWorld() {

View File

@ -10,12 +10,24 @@ import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import java.io.*; import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
@ -36,6 +48,7 @@ public class Metrics {
new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'}); new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'});
final String examplePackage = new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'}); final String examplePackage = new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
// We want to make sure nobody just copy & pastes the example and use the wrong package names // We want to make sure nobody just copy & pastes the example and use the wrong package names
if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) { if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) {
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!"); throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
} }

View File

@ -13,9 +13,28 @@ import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.io.*; import java.io.BufferedInputStream;
import java.lang.reflect.*; import java.io.DataInput;
import java.util.*; import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.AbstractList;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;

View File

@ -9,7 +9,13 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.UUID; import java.util.UUID;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.*; import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.callConstructor;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.callMethod;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getCbClass;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getNmsClass;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getUtilClass;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.makeConstructor;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.makeMethod;
public class OfflinePlayerUtil { public class OfflinePlayerUtil {

View File

@ -2,7 +2,6 @@ package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer; import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.ChunkLoc;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@ -12,6 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.RefFie
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.RefMethod; import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.RefMethod;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.sk89q.worldedit.math.BlockVector2;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
@ -129,12 +129,12 @@ public class SendChunk {
} }
} }
public void sendChunk(String worldName, Collection<ChunkLoc> chunkLocations) { public void sendChunk(String worldName, Collection<BlockVector2> chunkLocations) {
World myWorld = Bukkit.getWorld(worldName); World myWorld = Bukkit.getWorld(worldName);
ArrayList<Chunk> chunks = new ArrayList<>(); ArrayList<Chunk> chunks = new ArrayList<>();
for (ChunkLoc loc : chunkLocations) { for (BlockVector2 loc : chunkLocations) {
if (myWorld.isChunkLoaded(loc.x, loc.z)) { if (myWorld.isChunkLoaded(loc.getX(), loc.getZ())) {
PaperLib.getChunkAtAsync(myWorld, loc.x, loc.z).thenAccept(chunks::add); PaperLib.getChunkAtAsync(myWorld, loc.getX(), loc.getZ()).thenAccept(chunks::add);
} }
} }
sendChunk(chunks); sendChunk(chunks);

View File

@ -1,15 +1,15 @@
package com.github.intellectualsites.plotsquared.bukkit.util.block; package com.github.intellectualsites.plotsquared.bukkit.util.block;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitBlockUtil;
import com.github.intellectualsites.plotsquared.bukkit.object.schematic.StateWrapper; import com.github.intellectualsites.plotsquared.bukkit.object.schematic.StateWrapper;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.BasicLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.BasicLocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import lombok.NonNull; import lombok.NonNull;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -19,7 +19,6 @@ import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import java.util.Locale;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
public class BukkitLocalQueue extends BasicLocalBlockQueue { public class BukkitLocalQueue extends BasicLocalBlockQueue {
@ -38,13 +37,13 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
} }
@Override public PlotBlock getBlock(int x, int y, int z) { @Override public BlockState getBlock(int x, int y, int z) {
World worldObj = Bukkit.getWorld(getWorld()); World worldObj = Bukkit.getWorld(getWorld());
if (worldObj != null) { if (worldObj != null) {
Block block = worldObj.getBlockAt(x, y, z); Block block = worldObj.getBlockAt(x, y, z);
return PlotBlock.get(block.getType().toString()); return BukkitBlockUtil.get(block);
} else { } else {
return PlotBlock.get(0, 0); return BlockUtil.get(0, 0);
} }
} }
@ -95,7 +94,7 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
BlockData blockData = BukkitAdapter.adapt(block); BlockData blockData = BukkitAdapter.adapt(block);
Block existing = chunk.getBlock(x, y, z); Block existing = chunk.getBlock(x, y, z);
if (equals(PlotBlock.get(block), existing) && existing if (BukkitBlockUtil.get(existing).equals(block) && existing
.getBlockData().matches(blockData)) { .getBlockData().matches(blockData)) {
continue; continue;
} }
@ -116,38 +115,13 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
}); });
} }
private void setMaterial(@NonNull final PlotBlock plotBlock, @NonNull final Block block) { private void setMaterial(@NonNull final BlockState plotBlock, @NonNull final Block block) {
final Material material; Material material = BukkitAdapter.adapt(plotBlock.getBlockType());
if (plotBlock instanceof StringPlotBlock) {
material = Material
.getMaterial(((StringPlotBlock) plotBlock).getItemId().toUpperCase(Locale.ENGLISH));
if (material == null) {
throw new IllegalStateException(String
.format("Could not find material that matches %s",
((StringPlotBlock) plotBlock).getItemId()));
}
} else {
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock;
material = PlotSquared.get().IMP.getLegacyMappings()
.fromLegacyToString(legacyPlotBlock.getId(), legacyPlotBlock.getData())
.to(Material.class);
if (material == null) {
throw new IllegalStateException(String
.format("Could not find material that matches %s", legacyPlotBlock.toString()));
}
}
block.setType(material, false); block.setType(material, false);
} }
private boolean equals(@NonNull final PlotBlock plotBlock, @NonNull final Block block) { private boolean equals(@NonNull final BlockState plotBlock, @NonNull final Block block) {
if (plotBlock instanceof StringPlotBlock) { return plotBlock.equals(BukkitBlockUtil.get(block));
return ((StringPlotBlock) plotBlock).idEquals(block.getType().name());
}
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock;
return Material.getMaterial(PlotSquared.get().IMP.getLegacyMappings()
.fromLegacyToString(((LegacyPlotBlock) plotBlock).id,
((LegacyPlotBlock) plotBlock).data).toString()) == block.getType() && (
legacyPlotBlock.id == 0 || legacyPlotBlock.data == block.getData());
} }
public void setBiomes(LocalChunk lc) { public void setBiomes(LocalChunk lc) {

View File

@ -1,17 +1,18 @@
package com.github.intellectualsites.plotsquared.bukkit.util.block; package com.github.intellectualsites.plotsquared.bukkit.util.block;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitBlockUtil;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil; import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper; import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator.BiomeGrid; import org.bukkit.generator.ChunkGenerator.BiomeGrid;
@ -22,7 +23,7 @@ import java.util.Arrays;
public class GenChunk extends ScopedLocalBlockQueue { public class GenChunk extends ScopedLocalBlockQueue {
public final Biome[] biomes; public final Biome[] biomes;
public PlotBlock[][] result; public BlockState[][] result;
public BiomeGrid biomeGrid; public BiomeGrid biomeGrid;
public Chunk chunk; public Chunk chunk;
public String world; public String world;
@ -68,14 +69,14 @@ public class GenChunk extends ScopedLocalBlockQueue {
} }
} }
@Override public void setCuboid(Location pos1, Location pos2, PlotBlock block) { @Override public void setCuboid(Location pos1, Location pos2, BlockState block) {
if (result != null && pos1.getX() == 0 && pos1.getZ() == 0 && pos2.getX() == 15 if (result != null && pos1.getX() == 0 && pos1.getZ() == 0 && pos2.getX() == 15
&& pos2.getZ() == 15) { && pos2.getZ() == 15) {
for (int y = pos1.getY(); y <= pos2.getY(); y++) { for (int y = pos1.getY(); y <= pos2.getY(); y++) {
int layer = y >> 4; int layer = y >> 4;
PlotBlock[] data = result[layer]; BlockState[] data = result[layer];
if (data == null) { if (data == null) {
result[layer] = data = new PlotBlock[4096]; result[layer] = data = new BlockState[4096];
} }
int start = y << 8; int start = y << 8;
int end = start + 256; int end = start + 256;
@ -88,8 +89,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
int maxX = Math.max(pos1.getX(), pos2.getX()); int maxX = Math.max(pos1.getX(), pos2.getX());
int maxY = Math.max(pos1.getY(), pos2.getY()); int maxY = Math.max(pos1.getY(), pos2.getY());
int maxZ = Math.max(pos1.getZ(), pos2.getZ()); int maxZ = Math.max(pos1.getZ(), pos2.getZ());
chunkData chunkData.setRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1, BukkitAdapter.adapt(block));
.setRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1, block.to(Material.class));
} }
@Override public boolean setBiome(int x, int z, String biome) { @Override public boolean setBiome(int x, int z, String biome) {
@ -104,21 +104,21 @@ public class GenChunk extends ScopedLocalBlockQueue {
return false; return false;
} }
@Override public boolean setBlock(int x, int y, int z, PlotBlock id) { @Override public boolean setBlock(int x, int y, int z, BlockState id) {
if (this.result == null) { if (this.result == null) {
this.chunkData.setBlock(x, y, z, id.to(Material.class)); this.chunkData.setBlock(x, y, z, BukkitAdapter.adapt(id));
return true; return true;
} }
this.chunkData.setBlock(x, y, z, id.to(Material.class)); this.chunkData.setBlock(x, y, z, BukkitAdapter.adapt(id));
this.storeCache(x, y, z, id); this.storeCache(x, y, z, id);
return true; return true;
} }
private void storeCache(final int x, final int y, final int z, final PlotBlock id) { private void storeCache(final int x, final int y, final int z, final BlockState id) {
int i = MainUtil.CACHE_I[y][x][z]; int i = MainUtil.CACHE_I[y][x][z];
PlotBlock[] v = this.result[i]; BlockState[] v = this.result[i];
if (v == null) { if (v == null) {
this.result[i] = v = new PlotBlock[4096]; this.result[i] = v = new BlockState[4096];
} }
int j = MainUtil.CACHE_J[y][x][z]; int j = MainUtil.CACHE_J[y][x][z];
v[j] = id; v[j] = id;
@ -130,18 +130,18 @@ public class GenChunk extends ScopedLocalBlockQueue {
return true; return true;
} }
this.chunkData.setBlock(x, y, z, BukkitAdapter.adapt(id)); this.chunkData.setBlock(x, y, z, BukkitAdapter.adapt(id));
this.storeCache(x, y, z, PlotBlock.get(id.getBlockType().getId())); this.storeCache(x, y, z, BlockUtil.get(id.getBlockType().getId()));
return true; return true;
} }
@Override public PlotBlock getBlock(int x, int y, int z) { @Override public BlockState getBlock(int x, int y, int z) {
int i = MainUtil.CACHE_I[y][x][z]; int i = MainUtil.CACHE_I[y][x][z];
if (result == null) { if (result == null) {
return PlotBlock.get(chunkData.getType(x, y, z)); return BukkitBlockUtil.get(chunkData.getType(x, y, z));
} }
PlotBlock[] array = result[i]; BlockState[] array = result[i];
if (array == null) { if (array == null) {
return PlotBlock.get(""); return BlockUtil.get("");
} }
int j = MainUtil.CACHE_J[y][x][z]; int j = MainUtil.CACHE_J[y][x][z];
return array[j]; return array[j];
@ -171,9 +171,9 @@ public class GenChunk extends ScopedLocalBlockQueue {
GenChunk toReturn = new GenChunk(); GenChunk toReturn = new GenChunk();
if (this.result != null) { if (this.result != null) {
for (int i = 0; i < this.result.length; i++) { for (int i = 0; i < this.result.length; i++) {
PlotBlock[] matrix = this.result[i]; BlockState[] matrix = this.result[i];
if (matrix != null) { if (matrix != null) {
toReturn.result[i] = new PlotBlock[matrix.length]; toReturn.result[i] = new BlockState[matrix.length];
System.arraycopy(matrix, 0, toReturn.result[i], 0, matrix.length); System.arraycopy(matrix, 0, toReturn.result[i], 0, matrix.length);
} }
} }

View File

@ -14,6 +14,7 @@ import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper; import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import com.sk89q.worldedit.extension.platform.Actor;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.Collections; import java.util.Collections;

View File

@ -19,7 +19,15 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public abstract class Command { public abstract class Command {

View File

@ -1,6 +1,11 @@
package com.github.intellectualsites.plotsquared.configuration; package com.github.intellectualsites.plotsquared.configuration;
import java.util.*; import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/** /**
* A type of {@link ConfigurationSection} that is stored in memory. * A type of {@link ConfigurationSection} that is stored in memory.

View File

@ -4,7 +4,16 @@ import com.github.intellectualsites.plotsquared.configuration.Configuration;
import com.github.intellectualsites.plotsquared.configuration.InvalidConfigurationException; import com.github.intellectualsites.plotsquared.configuration.InvalidConfigurationException;
import com.github.intellectualsites.plotsquared.configuration.MemoryConfiguration; import com.github.intellectualsites.plotsquared.configuration.MemoryConfiguration;
import java.io.*; import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors; import java.util.stream.Collectors;

View File

@ -7,8 +7,15 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.*; import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.stream.IntStream; import java.util.stream.IntStream;
/** /**
@ -554,7 +561,9 @@ public class JSONObject {
return new JSONObject((Map<String, Object>) object); return new JSONObject((Map<String, Object>) object);
} }
Package objectPackage = object.getClass().getPackage(); Package objectPackage = object.getClass().getPackage();
String objectPackageName = objectPackage != null ? objectPackage.getName() : ""; String objectPackageName = objectPackage != null ? objectPackage.getName() : "";
if (objectPackageName.startsWith("java.") || objectPackageName.startsWith("javax.") || ( if (objectPackageName.startsWith("java.") || objectPackageName.startsWith("javax.") || (
object.getClass().getClassLoader() == null)) { object.getClass().getClassLoader() == null)) {
return object.toString(); return object.toString();

View File

@ -1,6 +1,11 @@
package com.github.intellectualsites.plotsquared.json; package com.github.intellectualsites.plotsquared.json;
import java.io.*; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
/** /**
* A JSONTokener takes a source string and extracts characters and tokens from it. It is used by the JSONObject and * A JSONTokener takes a source string and extracts characters and tokens from it. It is used by the JSONObject and

View File

@ -4,10 +4,19 @@ import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils; import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator; import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.logger.ILogger; import com.github.intellectualsites.plotsquared.plot.logger.ILogger;
import com.github.intellectualsites.plotsquared.plot.object.BlockRegistry;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.ChatManager;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.InventoryUtil;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandlerImplementation;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider; import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
import com.sk89q.worldedit.extension.platform.Actor;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
@ -237,8 +246,5 @@ public interface IPlotMain extends ILogger {
List<String> getPluginIds(); List<String> getPluginIds();
BlockRegistry<?> getBlockRegistry(); Actor getConsole();
LegacyMappings getLegacyMappings();
} }

View File

@ -20,12 +20,38 @@ import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator; import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.listener.WESubscriber; import com.github.intellectualsites.plotsquared.plot.listener.WESubscriber;
import com.github.intellectualsites.plotsquared.plot.logger.ILogger; import com.github.intellectualsites.plotsquared.plot.logger.ILogger;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotCluster;
import com.github.intellectualsites.plotsquared.plot.object.PlotFilter;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
import com.github.intellectualsites.plotsquared.plot.object.worlds.DefaultPlotAreaManager; import com.github.intellectualsites.plotsquared.plot.object.worlds.DefaultPlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager; import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea; import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager; import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.ChatManager;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.CommentManager;
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.InventoryUtil;
import com.github.intellectualsites.plotsquared.plot.util.LegacyConverter;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.UpdateUtility;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpiryTask; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpiryTask;
@ -35,15 +61,37 @@ import lombok.NonNull;
import lombok.Setter; import lombok.Setter;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.io.*; import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.file.Files; import java.nio.file.Files;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.*; import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects;
import java.util.Properties;
import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -105,7 +153,7 @@ import java.util.zip.ZipInputStream;
// //
// Register configuration serializable classes // Register configuration serializable classes
// //
ConfigurationSerialization.registerClass(PlotBlock.class, "PlotBlock"); // ConfigurationSerialization.registerClass(BlockState.class, "BlockState");
ConfigurationSerialization.registerClass(BlockBucket.class, "BlockBucket"); ConfigurationSerialization.registerClass(BlockBucket.class, "BlockBucket");
try { try {
@ -1272,7 +1320,7 @@ import java.util.zip.ZipInputStream;
.filter(validArgument -> args.toLowerCase(Locale.ENGLISH).contains(validArgument)) .filter(validArgument -> args.toLowerCase(Locale.ENGLISH).contains(validArgument))
.count(); .count();
String[] split = args.toLowerCase(Locale.ENGLISH).split(","); String[] split = args.toLowerCase(Locale.ENGLISH).split(",(?![^\\(\\[]*[\\]\\)])");
if (split.length > expected) { if (split.length > expected) {
// This means we have multi-block block buckets // This means we have multi-block block buckets
@ -1960,7 +2008,7 @@ import java.util.zip.ZipInputStream;
return Collections.unmodifiableSet(result); return Collections.unmodifiableSet(result);
} }
public Set<PlotArea> getPlotAreas(final String world, final RegionWrapper region) { public Set<PlotArea> getPlotAreas(final String world, final CuboidRegion region) {
final PlotArea[] areas = plotAreaManager.getPlotAreas(world, region); final PlotArea[] areas = plotAreaManager.getPlotAreas(world, region);
final Set<PlotArea> set = new HashSet<>(); final Set<PlotArea> set = new HashSet<>();
Collections.addAll(set, areas); Collections.addAll(set, areas);

View File

@ -7,8 +7,25 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Configuration; import com.github.intellectualsites.plotsquared.plot.config.Configuration;
import com.github.intellectualsites.plotsquared.plot.generator.AugmentedUtils; import com.github.intellectualsites.plotsquared.plot.generator.AugmentedUtils;
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld; import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.sk89q.worldedit.math.BlockVector2;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -83,7 +100,7 @@ import java.util.Set;
area.ROAD_WIDTH / 2; area.ROAD_WIDTH / 2;
final int offsetX = bx - (area.ROAD_WIDTH == 0 ? 0 : lower); final int offsetX = bx - (area.ROAD_WIDTH == 0 ? 0 : lower);
final int offsetZ = bz - (area.ROAD_WIDTH == 0 ? 0 : lower); final int offsetZ = bz - (area.ROAD_WIDTH == 0 ? 0 : lower);
final RegionWrapper region = new RegionWrapper(bx, tx, bz, tz); final CuboidRegion region = RegionUtil.createRegion(bx, tx, bz, tz);
Set<PlotArea> areas = Set<PlotArea> areas =
PlotSquared.get().getPlotAreas(area.worldname, region); PlotSquared.get().getPlotAreas(area.worldname, region);
if (!areas.isEmpty()) { if (!areas.isEmpty()) {
@ -120,10 +137,10 @@ import java.util.Set;
player.teleport(WorldUtil.IMP.getSpawn(world)); player.teleport(WorldUtil.IMP.getSpawn(world));
if (area.TERRAIN != 3) { if (area.TERRAIN != 3) {
ChunkManager.largeRegionTask(world, region, ChunkManager.largeRegionTask(world, region,
new RunnableVal<ChunkLoc>() { new RunnableVal<BlockVector2>() {
@Override public void run(ChunkLoc value) { @Override public void run(BlockVector2 value) {
AugmentedUtils AugmentedUtils
.generate(world, value.x, value.z, .generate(world, value.getX(), value.getZ(),
null); null);
} }
}, null); }, null);
@ -415,9 +432,9 @@ import java.util.Set;
return false; return false;
} }
ChunkManager ChunkManager
.largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<ChunkLoc>() { .largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<BlockVector2>() {
@Override public void run(ChunkLoc value) { @Override public void run(BlockVector2 value) {
AugmentedUtils.generate(area.worldname, value.x, value.z, null); AugmentedUtils.generate(area.worldname, value.getX(), value.getZ(), null);
} }
}, () -> player.sendMessage("Regen complete")); }, () -> player.sendMessage("Regen complete"));
return true; return true;
@ -444,10 +461,10 @@ import java.util.Set;
if (area.TYPE != 2) { if (area.TYPE != 2) {
center = WorldUtil.IMP.getSpawn(area.worldname); center = WorldUtil.IMP.getSpawn(area.worldname);
} else { } else {
RegionWrapper region = area.getRegion(); CuboidRegion region = area.getRegion();
center = center =
new Location(area.worldname, region.minX + (region.maxX - region.minX) / 2, new Location(area.worldname, region.getMinimumPoint().getX() + (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2,
0, region.minZ + (region.maxZ - region.minZ) / 2); 0, region.getMinimumPoint().getZ() + (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
center.setY(1 + WorldUtil.IMP center.setY(1 + WorldUtil.IMP
.getHighestBlock(area.worldname, center.getX(), center.getZ())); .getHighestBlock(area.worldname, center.getX(), center.getZ()));
} }

View File

@ -5,14 +5,20 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Direction;
import com.github.intellectualsites.plotsquared.plot.object.Expression;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ByteArrayUtilities; import com.github.intellectualsites.plotsquared.plot.util.ByteArrayUtilities;
import com.github.intellectualsites.plotsquared.plot.util.EconHandler; import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Set; import java.util.Set;
@CommandDeclaration(command = "auto", permission = "plots.auto", @CommandDeclaration(command = "auto", permission = "plots.auto",

View File

@ -4,7 +4,13 @@ import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Direction;
import com.github.intellectualsites.plotsquared.plot.object.Expression;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ByteArrayUtilities; import com.github.intellectualsites.plotsquared.plot.util.ByteArrayUtilities;
import com.github.intellectualsites.plotsquared.plot.util.EconHandler; import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;

View File

@ -5,7 +5,13 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.BlockLoc;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotCluster;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;

View File

@ -4,12 +4,19 @@ import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.sk89q.worldedit.math.BlockVector2;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map; import java.util.Map;
@ -55,7 +62,7 @@ public class DebugClaimTest extends SubCommand {
continue; continue;
} }
Location location = manager.getSignLoc(plot); Location location = manager.getSignLoc(plot);
ChunkLoc chunk = new ChunkLoc(location.getX() >> 4, location.getZ() >> 4); BlockVector2 chunk = BlockVector2.at(location.getX() >> 4, location.getZ() >> 4);
ChunkManager.manager.loadChunk(area.worldname, chunk, false).thenRun(() -> { ChunkManager.manager.loadChunk(area.worldname, chunk, false).thenRun(() -> {
String[] lines = WorldUtil.IMP.getSign(location); String[] lines = WorldUtil.IMP.getSign(location);
if (lines != null) { if (lines != null) {

View File

@ -10,12 +10,33 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils; import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.listener.WEManager; import com.github.intellectualsites.plotsquared.plot.listener.WEManager;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis; import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.sk89q.worldedit.world.block.BlockState;
import javax.script.Bindings; import javax.script.Bindings;
import javax.script.ScriptContext; import javax.script.ScriptContext;
@ -103,7 +124,7 @@ import java.util.concurrent.CompletableFuture;
// Classes // Classes
this.scope.put("Location", Location.class); this.scope.put("Location", Location.class);
this.scope.put("PlotBlock", PlotBlock.class); this.scope.put("BlockState", BlockState.class);
this.scope.put("Plot", Plot.class); this.scope.put("Plot", Plot.class);
this.scope.put("PlotId", PlotId.class); this.scope.put("PlotId", PlotId.class);
this.scope.put("Runnable", Runnable.class); this.scope.put("Runnable", Runnable.class);

View File

@ -5,15 +5,14 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.BlockStateListFlag;
import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flag.IntegerFlag; import com.github.intellectualsites.plotsquared.plot.flag.IntegerFlag;
import com.github.intellectualsites.plotsquared.plot.flag.ListFlag; import com.github.intellectualsites.plotsquared.plot.flag.ListFlag;
import com.github.intellectualsites.plotsquared.plot.flag.PlotBlockListFlag;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
@ -21,8 +20,18 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather; import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison; import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@CommandDeclaration(command = "setflag", aliases = {"f", "flag", @CommandDeclaration(command = "setflag", aliases = {"f", "flag",
"setflag"}, usage = "/plot flag <set|remove|add|list|info> <flag> <value>", description = "Set plot flags", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, permission = "plots.flag") "setflag"}, usage = "/plot flag <set|remove|add|list|info> <flag> <value>", description = "Set plot flags", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, permission = "plots.flag")
@ -52,12 +61,12 @@ public class FlagCmd extends SubCommand {
} catch (NumberFormatException ignore) { } catch (NumberFormatException ignore) {
} }
} else if (flag instanceof PlotBlockListFlag) { } else if (flag instanceof BlockStateListFlag) {
final PlotBlockListFlag blockListFlag = (PlotBlockListFlag) flag; final BlockStateListFlag blockListFlag = (BlockStateListFlag) flag;
final HashSet<PlotBlock> parsedBlocks = blockListFlag.parseValue(value); Set<BlockType> parsedBlocks = blockListFlag.parseValue(value);
for (final PlotBlock block : parsedBlocks) { for (final BlockType block : parsedBlocks) {
final String permission = Captions.PERMISSION_SET_FLAG_KEY_VALUE final String permission = Captions.PERMISSION_SET_FLAG_KEY_VALUE
.f(key.toLowerCase(), block.getRawId().toString().toLowerCase()); .f(key.toLowerCase(), block.toString().toLowerCase());
final boolean result = Permissions.hasPermission(player, permission); final boolean result = Permissions.hasPermission(player, permission);
if (!result) { if (!result) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION,

View File

@ -14,7 +14,11 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import java.util.*; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
@CommandDeclaration(command = "like", permission = "plots.like", description = "Like the plot", @CommandDeclaration(command = "like", permission = "plots.like", description = "Like the plot",
usage = "/plot like [next|purge]", category = CommandCategory.INFO, usage = "/plot like [next|purge]", category = CommandCategory.INFO,

View File

@ -11,7 +11,13 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.Rating; import com.github.intellectualsites.plotsquared.plot.object.Rating;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -5,7 +5,14 @@ import com.github.intellectualsites.plotsquared.commands.CommandCaller;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer;
import com.github.intellectualsites.plotsquared.plot.object.Expression;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm; import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm;
import com.github.intellectualsites.plotsquared.plot.util.EconHandler; import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;

View File

@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotInventory; import com.github.intellectualsites.plotsquared.plot.object.PlotInventory;
import com.github.intellectualsites.plotsquared.plot.object.PlotItemStack; import com.github.intellectualsites.plotsquared.plot.object.PlotItemStack;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.sk89q.worldedit.world.item.ItemTypes;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -39,11 +40,11 @@ import java.util.Locale;
if (item == null) { if (item == null) {
return true; return true;
} }
if (item.getPlotBlock().equalsAny(7, "bedrock")) { if (item.getType() == ItemTypes.BEDROCK) {
plot.removeFlag(Flags.MUSIC); plot.removeFlag(Flags.MUSIC);
Captions.FLAG_REMOVED.send(player); Captions.FLAG_REMOVED.send(player);
} else if (item.name.toLowerCase(Locale.ENGLISH).contains("disc")) { } else if (item.name.toLowerCase(Locale.ENGLISH).contains("disc")) {
plot.setFlag(Flags.MUSIC, item.getPlotBlock().getRawId()); plot.setFlag(Flags.MUSIC, item);
Captions.FLAG_ADDED.send(player); Captions.FLAG_ADDED.send(player);
} else { } else {
Captions.FLAG_NOT_ADDED.send(player); Captions.FLAG_NOT_ADDED.send(player);

View File

@ -7,8 +7,16 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.object.PlotInventory;
import com.github.intellectualsites.plotsquared.plot.object.PlotItemStack;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.Rating;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;

View File

@ -43,7 +43,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD); MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD);
return false; return false;
} }
//Set<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name); //Set<BlockVector2> chunks = ChunkManager.manager.getChunkChunks(name);
MainUtil MainUtil
.sendMessage(player, "&cIf no schematic is set, the following will not do anything"); .sendMessage(player, "&cIf no schematic is set, the following will not do anything");
MainUtil.sendMessage(player, MainUtil.sendMessage(player,

View File

@ -3,7 +3,11 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.Command; import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;

View File

@ -3,7 +3,11 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;

View File

@ -10,7 +10,6 @@ import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager; import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@ -19,6 +18,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.sk89q.worldedit.world.block.BlockState;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -60,7 +60,7 @@ import java.util.stream.IntStream;
Captions.PERMISSION_SET_COMPONENT.f(component)); Captions.PERMISSION_SET_COMPONENT.f(component));
return false; return false;
} }
// PlotBlock[] blocks; // BlockState[] blocks;
BlockBucket bucket; BlockBucket bucket;
try { try {
if (args.length < 2) { if (args.length < 2) {
@ -73,7 +73,7 @@ import java.util.stream.IntStream;
} catch (final UnknownBlockException unknownBlockException) { } catch (final UnknownBlockException unknownBlockException) {
final String unknownBlock = unknownBlockException.getUnknownValue(); final String unknownBlock = unknownBlockException.getUnknownValue();
Captions.NOT_VALID_BLOCK.send(player, unknownBlock); Captions.NOT_VALID_BLOCK.send(player, unknownBlock);
StringComparison<PlotBlock>.ComparisonResult match = StringComparison<BlockState>.ComparisonResult match =
WorldUtil.IMP.getClosestBlock(unknownBlock); WorldUtil.IMP.getClosestBlock(unknownBlock);
if (match != null) { if (match != null) {
final String found = final String found =
@ -87,8 +87,8 @@ import java.util.stream.IntStream;
} }
if (!allowUnsafe) { if (!allowUnsafe) {
for (final PlotBlock block : bucket.getBlocks()) { for (final BlockState block : bucket.getBlocks()) {
if (!block.isAir() && !WorldUtil.IMP.isBlockSolid(block)) { if (!block.getBlockType().getMaterial().isAir() && !WorldUtil.IMP.isBlockSolid(block)) {
Captions.NOT_ALLOWED_BLOCK.send(player, block.toString()); Captions.NOT_ALLOWED_BLOCK.send(player, block.toString());
return false; return false;
} }

View File

@ -15,11 +15,23 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils; import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import lombok.*; import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID;
@CommandDeclaration(command = "setup", permission = "plots.admin.command.setup", @CommandDeclaration(command = "setup", permission = "plots.admin.command.setup",
description = "Setup wizard for plot worlds", usage = "/plot setup", aliases = {"create"}, description = "Setup wizard for plot worlds", usage = "/plot setup", aliases = {"create"},
@ -264,8 +276,9 @@ import java.util.Map.Entry;
Captions.NOT_ALLOWED_BLOCK.send(player, e.getUnsafeBlock().toString()); Captions.NOT_ALLOWED_BLOCK.send(player, e.getUnsafeBlock().toString());
} }
if (valid) { if (valid) {
sendMessage(player, Captions.SETUP_VALID_ARG, step.getConstant(), args[0]);
step.setValue(args[0]); step.setValue(args[0]);
Object value = step.getValue();
sendMessage(player, Captions.SETUP_VALID_ARG, step.getConstant(), value);
object.setup_index++; object.setup_index++;
if (object.setup_index == object.step.length) { if (object.setup_index == object.step.length) {
onCommand(player, args); onCommand(player, args);

View File

@ -8,14 +8,21 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode; import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.FileBytes;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils; import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import java.io.*; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Set; import java.util.Set;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;

View File

@ -3,7 +3,13 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
@ -11,6 +17,7 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import com.sk89q.worldedit.math.BlockVector2;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -31,7 +38,7 @@ import java.util.Set;
public static ArrayList<Plot> expired = null; public static ArrayList<Plot> expired = null;
private static volatile boolean TASK = false; private static volatile boolean TASK = false;
public static boolean getBulkRegions(final ArrayList<ChunkLoc> empty, final String world, public static boolean getBulkRegions(final ArrayList<BlockVector2> empty, final String world,
final Runnable whenDone) { final Runnable whenDone) {
if (Trim.TASK) { if (Trim.TASK) {
return false; return false;
@ -71,7 +78,7 @@ import java.util.Set;
String[] split = name.split("\\."); String[] split = name.split("\\.");
int x = Integer.parseInt(split[1]); int x = Integer.parseInt(split[1]);
int z = Integer.parseInt(split[2]); int z = Integer.parseInt(split[2]);
ChunkLoc loc = new ChunkLoc(x, z); BlockVector2 loc = BlockVector2.at(x, z);
empty.add(loc); empty.add(loc);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
PlotSquared.debug("INVALID MCA: " + name); PlotSquared.debug("INVALID MCA: " + name);
@ -90,7 +97,7 @@ import java.util.Set;
* @return * @return
*/ */
public static boolean getTrimRegions(String world, public static boolean getTrimRegions(String world,
final RunnableVal2<Set<ChunkLoc>, Set<ChunkLoc>> result) { final RunnableVal2<Set<BlockVector2>, Set<BlockVector2>> result) {
if (result == null) { if (result == null) {
return false; return false;
} }
@ -114,7 +121,7 @@ import java.util.Set;
int ccz2 = pos2.getZ() >> 9; int ccz2 = pos2.getZ() >> 9;
for (int x = ccx1; x <= ccx2; x++) { for (int x = ccx1; x <= ccx2; x++) {
for (int z = ccz1; z <= ccz2; z++) { for (int z = ccz1; z <= ccz2; z++) {
ChunkLoc loc = new ChunkLoc(x, z); BlockVector2 loc = BlockVector2.at(x, z);
if (result.value1.remove(loc)) { if (result.value1.remove(loc)) {
result.value2.add(loc); result.value2.add(loc);
} }
@ -141,8 +148,8 @@ import java.util.Set;
} }
Trim.TASK = true; Trim.TASK = true;
final boolean regen = args.length == 2 && Boolean.parseBoolean(args[1]); final boolean regen = args.length == 2 && Boolean.parseBoolean(args[1]);
getTrimRegions(world, new RunnableVal2<Set<ChunkLoc>, Set<ChunkLoc>>() { getTrimRegions(world, new RunnableVal2<Set<BlockVector2>, Set<BlockVector2>>() {
@Override public void run(Set<ChunkLoc> viable, final Set<ChunkLoc> nonViable) { @Override public void run(Set<BlockVector2> viable, final Set<BlockVector2> nonViable) {
Runnable regenTask; Runnable regenTask;
if (regen) { if (regen) {
PlotSquared.log("Starting regen task:"); PlotSquared.log("Starting regen task:");
@ -155,43 +162,43 @@ import java.util.Set;
player.sendMessage("Trim done!"); player.sendMessage("Trim done!");
return; return;
} }
Iterator<ChunkLoc> iterator = nonViable.iterator(); Iterator<BlockVector2> iterator = nonViable.iterator();
ChunkLoc mcr = iterator.next(); BlockVector2 mcr = iterator.next();
iterator.remove(); iterator.remove();
int cbx = mcr.x << 5; int cbx = mcr.getX() << 5;
int cbz = mcr.z << 5; int cbz = mcr.getZ() << 5;
// get all 1024 chunks // get all 1024 chunks
HashSet<ChunkLoc> chunks = new HashSet<>(); HashSet<BlockVector2> chunks = new HashSet<>();
for (int x = cbx; x < cbx + 32; x++) { for (int x = cbx; x < cbx + 32; x++) {
for (int z = cbz; z < cbz + 32; z++) { for (int z = cbz; z < cbz + 32; z++) {
ChunkLoc loc = new ChunkLoc(x, z); BlockVector2 loc = BlockVector2.at(x, z);
chunks.add(loc); chunks.add(loc);
} }
} }
int bx = cbx << 4; int bx = cbx << 4;
int bz = cbz << 4; int bz = cbz << 4;
RegionWrapper region = new RegionWrapper(bx, bx + 511, bz, bz + 511); CuboidRegion region = RegionUtil.createRegion(bx, bx + 511, bz, bz + 511);
for (Plot plot : PlotSquared.get().getPlots(world)) { for (Plot plot : PlotSquared.get().getPlots(world)) {
Location bot = plot.getBottomAbs(); Location bot = plot.getBottomAbs();
Location top = plot.getExtendedTopAbs(); Location top = plot.getExtendedTopAbs();
RegionWrapper plotReg = CuboidRegion plotReg =
new RegionWrapper(bot.getX(), top.getX(), bot.getZ(), RegionUtil.createRegion(bot.getX(), top.getX(), bot.getZ(),
top.getZ()); top.getZ());
if (!region.intersects(plotReg)) { if (!RegionUtil.intersects(region, plotReg)) {
continue; continue;
} }
for (int x = plotReg.minX >> 4; x <= plotReg.maxX >> 4; x++) { for (int x = plotReg.getMinimumPoint().getX() >> 4; x <= plotReg.getMaximumPoint().getX() >> 4; x++) {
for (int z = plotReg.minZ >> 4; z <= plotReg.maxZ >> 4; z++) { for (int z = plotReg.getMinimumPoint().getZ() >> 4; z <= plotReg.getMaximumPoint().getZ() >> 4; z++) {
ChunkLoc loc = new ChunkLoc(x, z); BlockVector2 loc = BlockVector2.at(x, z);
chunks.remove(loc); chunks.remove(loc);
} }
} }
} }
final LocalBlockQueue queue = final LocalBlockQueue queue =
GlobalBlockQueue.IMP.getNewQueue(world, false); GlobalBlockQueue.IMP.getNewQueue(world, false);
TaskManager.objectTask(chunks, new RunnableVal<ChunkLoc>() { TaskManager.objectTask(chunks, new RunnableVal<BlockVector2>() {
@Override public void run(ChunkLoc value) { @Override public void run(BlockVector2 value) {
queue.regenChunk(value.x, value.z); queue.regenChunk(value.getX(), value.getZ());
} }
}, this); }, this);
} }

View File

@ -6,13 +6,21 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import java.util.*; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "visit", permission = "plots.visit", @CommandDeclaration(command = "visit", permission = "plots.visit",

View File

@ -14,7 +14,11 @@ import java.lang.annotation.Target;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.*; import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Config { public class Config {
@ -361,12 +365,8 @@ public class Config {
* @throws NoSuchFieldException * @throws NoSuchFieldException
* @throws IllegalAccessException * @throws IllegalAccessException
*/ */
private static void setAccessible(Field field) private static void setAccessible(Field field) {
throws NoSuchFieldException, IllegalAccessException {
field.setAccessible(true); field.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
} }
/** /**

View File

@ -1,12 +1,18 @@
package com.github.intellectualsites.plotsquared.plot.config; package com.github.intellectualsites.plotsquared.plot.config;
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison; import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.sk89q.worldedit.world.block.BlockState;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* Main Configuration Utility * Main Configuration Utility
*/ */
@ -57,30 +63,28 @@ public class Configuration {
public static final SettingValue<BlockBucket> BLOCK_BUCKET = public static final SettingValue<BlockBucket> BLOCK_BUCKET =
new SettingValue<BlockBucket>("BLOCK_BUCKET") { new SettingValue<BlockBucket>("BLOCK_BUCKET") {
private Pattern pattern = Pattern.compile("((?<namespace>[A-Za-z_]+):)?(?<block>([A-Za-z_]+(\\[?[\\S\\s]+\\])?))(:(?<chance>[0-9]{1,3}))?");
@Override public BlockBucket parseString(final String string) { @Override public BlockBucket parseString(final String string) {
if (string == null || string.isEmpty()) { if (string == null || string.isEmpty()) {
return new BlockBucket(); return new BlockBucket();
} }
final BlockBucket blockBucket = new BlockBucket(); final BlockBucket blockBucket = new BlockBucket();
final String[] parts = string.split(","); final String[] parts = string.split(",(?![^\\(\\[]*[\\]\\)])");
for (final String part : parts) { for (final String part : parts) {
String block; Matcher matcher = pattern.matcher(part);
int chance = -1; matcher.find();
String namespace = matcher.group("namespace");
if (part.contains(":")) { String block = matcher.group("block");
final String[] innerParts = part.split(":"); String chanceStr = matcher.group("chance");
if (innerParts.length > 1) { if (namespace == null) namespace = "minecraft";
chance = Integer.parseInt(innerParts[1]); int chance = chanceStr == null ? -1 : Integer.parseInt(chanceStr);
} final StringComparison<BlockState>.ComparisonResult value =
block = innerParts[0];
} else {
block = part;
}
final StringComparison<PlotBlock>.ComparisonResult value =
WorldUtil.IMP.getClosestBlock(block); WorldUtil.IMP.getClosestBlock(block);
if (value == null) { if (value == null) {
throw new UnknownBlockException(block); throw new UnknownBlockException(block);
} else if (Settings.Enabled_Components.PREVENT_UNSAFE && !value.best.isAir() } else if (Settings.Enabled_Components.PREVENT_UNSAFE && !value.best.getBlockType().getMaterial().isAir()
&& !WorldUtil.IMP.isBlockSolid(value.best)) { && !WorldUtil.IMP.isBlockSolid(value.best)) {
throw new UnsafeBlockException(value.best); throw new UnsafeBlockException(value.best);
} }
@ -95,26 +99,24 @@ public class Configuration {
if (string == null || string.isEmpty()) { if (string == null || string.isEmpty()) {
return false; return false;
} }
final String[] parts = string.split(","); final String[] parts = string.split(",(?![^\\(\\[]*[\\]\\)])");
for (final String part : parts) { for (final String part : parts) {
String block; Matcher matcher = pattern.matcher(part);
if (part.contains(":")) { matcher.find();
final String[] innerParts = part.split(":"); String namespace = matcher.group("namespace");
if (innerParts.length > 1) { String block = matcher.group("block");
final int chance = Integer.parseInt(innerParts[1]); String chanceStr = matcher.group("chance");
if (chance < 1 || chance > 100) { if (namespace == null) namespace = "minecraft";
return false; int chance = chanceStr == null ? -1 : Integer.parseInt(chanceStr);
}
} if ((chance != -1 && (chance < 1 || chance > 100)) || block == null) {
block = innerParts[0]; return false;
} else {
block = part;
} }
StringComparison<PlotBlock>.ComparisonResult value = StringComparison<BlockState>.ComparisonResult value =
WorldUtil.IMP.getClosestBlock(block); WorldUtil.IMP.getClosestBlock(block);
if (value == null || value.match > 1) { if (value == null || value.match > 1) {
return false; return false;
} else if (Settings.Enabled_Components.PREVENT_UNSAFE && !value.best.isAir() } else if (Settings.Enabled_Components.PREVENT_UNSAFE && !value.best.getBlockType().getMaterial().isAir()
&& !WorldUtil.IMP.isBlockSolid(value.best)) { && !WorldUtil.IMP.isBlockSolid(value.best)) {
throw new UnsafeBlockException(value.best); throw new UnsafeBlockException(value.best);
} }
@ -162,9 +164,9 @@ public class Configuration {
public static final class UnsafeBlockException extends IllegalArgumentException { public static final class UnsafeBlockException extends IllegalArgumentException {
@Getter private final PlotBlock unsafeBlock; @Getter private final BlockState unsafeBlock;
UnsafeBlockException(@NonNull final PlotBlock unsafeBlock) { UnsafeBlockException(@NonNull final BlockState unsafeBlock) {
super(String.format("%s is not a valid block", unsafeBlock)); super(String.format("%s is not a valid block", unsafeBlock));
this.unsafeBlock = unsafeBlock; this.unsafeBlock = unsafeBlock;
} }

View File

@ -1,8 +1,8 @@
package com.github.intellectualsites.plotsquared.plot.config; package com.github.intellectualsites.plotsquared.plot.config;
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.sk89q.worldedit.world.block.BlockState;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -66,7 +66,7 @@ public class ConfigurationNode {
if (this.value instanceof BlockBucket) { if (this.value instanceof BlockBucket) {
return this.value.toString(); return this.value.toString();
} }
if (this.value instanceof PlotBlock) { if (this.value instanceof BlockState) {
return this.value.toString(); return this.value.toString();
} }
return this.value; return this.value;

View File

@ -16,10 +16,10 @@ public class Settings extends Config {
@Comment("These first 7 aren't configurable") // This is a comment @Comment("These first 7 aren't configurable") // This is a comment
@Final // Indicates that this value isn't configurable @Final // Indicates that this value isn't configurable
public static final String ISSUES = "https://github.com/IntellectualSites/PlotSquared/issues"; public static String ISSUES = "https://github.com/IntellectualSites/PlotSquared/issues";
@Final public static final String SUGGESTION = @Final public static String SUGGESTION =
"https://github.com/IntellectualSites/PlotSquaredSuggestions"; "https://github.com/IntellectualSites/PlotSquaredSuggestions";
@Final public static final String WIKI = @Final public static String WIKI =
"https://github.com/IntellectualSites/PlotSquared/wiki"; "https://github.com/IntellectualSites/PlotSquared/wiki";
@Final public static String DATE; // These values are set from P2 before loading @Final public static String DATE; // These values are set from P2 before loading
@Final public static String BUILD; // These values are set from P2 before loading @Final public static String BUILD; // These values are set from P2 before loading

View File

@ -3,7 +3,11 @@ package com.github.intellectualsites.plotsquared.plot.database;
import com.github.intellectualsites.plotsquared.plot.config.Storage; import com.github.intellectualsites.plotsquared.plot.config.Storage;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.sql.*; import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/** /**
* Connects to and uses a MySQL database * Connects to and uses a MySQL database

View File

@ -6,7 +6,13 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.config.Storage; import com.github.intellectualsites.plotsquared.plot.config.Storage;
import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.BlockLoc;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotCluster;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotSettings;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment; import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
@ -14,11 +20,26 @@ import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.sql.*; import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -857,10 +878,10 @@ import java.util.concurrent.atomic.AtomicInteger;
statement.setInt(i * 10 + 9, hash); statement.setInt(i * 10 + 9, hash);
BlockLoc loc = pair.settings.getPosition(); BlockLoc loc = pair.settings.getPosition();
String position; String position;
if (loc.y == 0) { if (loc.getY() == 0) {
position = "DEFAULT"; position = "DEFAULT";
} else { } else {
position = loc.x + "," + loc.y + ',' + loc.z; position = loc.getX() + "," + loc.getY() + ',' + loc.getZ();
} }
statement.setString(i * 10 + 10, position); statement.setString(i * 10 + 10, position);
} }
@ -898,10 +919,10 @@ import java.util.concurrent.atomic.AtomicInteger;
stmt.setInt(i * 10 + 9, n); stmt.setInt(i * 10 + 9, n);
BlockLoc loc = pair.settings.getPosition(); BlockLoc loc = pair.settings.getPosition();
String position; String position;
if (loc.y == 0) { if (loc.getY() == 0) {
position = "DEFAULT"; position = "DEFAULT";
} else { } else {
position = loc.x + "," + loc.y + ',' + loc.z; position = loc.getX() + "," + loc.getY() + ',' + loc.getZ();
} }
stmt.setString(i * 10 + 10, position); stmt.setString(i * 10 + 10, position);
} }

View File

@ -4,7 +4,11 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.sql.*; import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/** /**
* Connects to and uses a SQLite database. * Connects to and uses a SQLite database.

View File

@ -0,0 +1,35 @@
package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
public class BlockStateListFlag extends ListFlag<Set<BlockType>> {
public BlockStateListFlag(String name) {
super(Captions.FLAG_CATEGORY_BLOCK_LIST, name);
}
@Override public String valueToString(Object value) {
return StringMan.join((Set<BlockType>) value, ",");
}
@Override public Set<BlockType> parseValue(final String value) {
return Arrays.stream(BlockUtil.parse(value)).map(BlockState::getBlockType).collect(Collectors.toSet());
}
@Override public String getValueDescription() {
return Captions.FLAG_ERROR_PLOTBLOCKLIST.getTranslated();
}
public boolean contains(Plot plot, BlockState value) {
return contains(plot, value.getBlockType());
}
}

View File

@ -10,7 +10,12 @@ import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import java.util.*; import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**

View File

@ -58,9 +58,9 @@ public final class Flags {
public static final BooleanFlag BLOCK_IGNITION = new BooleanFlag("block-ignition"); public static final BooleanFlag BLOCK_IGNITION = new BooleanFlag("block-ignition");
public static final BooleanFlag SOIL_DRY = new BooleanFlag("soil-dry"); public static final BooleanFlag SOIL_DRY = new BooleanFlag("soil-dry");
public static final StringListFlag BLOCKED_CMDS = new StringListFlag("blocked-cmds"); public static final StringListFlag BLOCKED_CMDS = new StringListFlag("blocked-cmds");
public static final PlotBlockListFlag USE = new PlotBlockListFlag("use"); public static final BlockStateListFlag USE = new BlockStateListFlag("use");
public static final PlotBlockListFlag BREAK = new PlotBlockListFlag("break"); public static final BlockStateListFlag BREAK = new BlockStateListFlag("break");
public static final PlotBlockListFlag PLACE = new PlotBlockListFlag("place"); public static final BlockStateListFlag PLACE = new BlockStateListFlag("place");
public static final BooleanFlag DEVICE_INTERACT = new BooleanFlag("device-interact"); public static final BooleanFlag DEVICE_INTERACT = new BooleanFlag("device-interact");
public static final BooleanFlag VEHICLE_BREAK = new BooleanFlag("vehicle-break"); public static final BooleanFlag VEHICLE_BREAK = new BooleanFlag("vehicle-break");
public static final BooleanFlag VEHICLE_PLACE = new BooleanFlag("vehicle-place"); public static final BooleanFlag VEHICLE_PLACE = new BooleanFlag("vehicle-place");

View File

@ -1,34 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.LegacyMappings;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
public class PlotBlockListFlag extends ListFlag<HashSet<PlotBlock>> {
public PlotBlockListFlag(String name) {
super(Captions.FLAG_CATEGORY_BLOCK_LIST, name);
}
@Override public String valueToString(Object value) {
return StringMan.join((HashSet<PlotBlock>) value, ",");
}
@Override public HashSet<PlotBlock> parseValue(final String value) {
final LegacyMappings legacyMappings = PlotSquared.get().IMP.getLegacyMappings();
return Arrays.stream(value.split(",")).map(legacyMappings::fromAny).filter(Objects::nonNull)
.collect(Collectors.toCollection(HashSet::new));
}
@Override public String getValueDescription() {
return Captions.FLAG_ERROR_PLOTBLOCKLIST.getTranslated();
}
}

View File

@ -1,6 +1,5 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
public class StringFlag extends Flag<String> { public class StringFlag extends Flag<String> {

View File

@ -3,14 +3,15 @@ package com.github.intellectualsites.plotsquared.plot.generator;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager; import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.util.block.DelegateLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.DelegateLocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Set; import java.util.Set;
@ -33,7 +34,7 @@ public class AugmentedUtils {
final int blockX = chunkX << 4; final int blockX = chunkX << 4;
final int blockZ = chunkZ << 4; final int blockZ = chunkZ << 4;
RegionWrapper region = new RegionWrapper(blockX, blockX + 15, blockZ, blockZ + 15); CuboidRegion region = RegionUtil.createRegion(blockX, blockX + 15, blockZ, blockZ + 15);
Set<PlotArea> areas = PlotSquared.get().getPlotAreas(world, region); Set<PlotArea> areas = PlotSquared.get().getPlotAreas(world, region);
if (areas.isEmpty()) { if (areas.isEmpty()) {
return false; return false;
@ -59,12 +60,12 @@ public class AugmentedUtils {
int tzz; int tzz;
// gen // gen
if (area.TYPE == 2) { if (area.TYPE == 2) {
bxx = Math.max(0, area.getRegion().minX - blockX); bxx = Math.max(0, area.getRegion().getMinimumPoint().getX() - blockX);
bzz = Math.max(0, area.getRegion().minZ - blockZ); bzz = Math.max(0, area.getRegion().getMinimumPoint().getZ() - blockZ);
txx = Math.min(15, area.getRegion().maxX - blockX); txx = Math.min(15, area.getRegion().getMaximumPoint().getX() - blockX);
tzz = Math.min(15, area.getRegion().maxZ - blockZ); tzz = Math.min(15, area.getRegion().getMaximumPoint().getZ() - blockZ);
primaryMask = new DelegateLocalBlockQueue(queue) { primaryMask = new DelegateLocalBlockQueue(queue) {
@Override public boolean setBlock(int x, int y, int z, PlotBlock id) { @Override public boolean setBlock(int x, int y, int z, BlockState id) {
if (area.contains(x, z)) { if (area.contains(x, z)) {
return super.setBlock(x, y, z, id); return super.setBlock(x, y, z, id);
} }
@ -84,7 +85,7 @@ public class AugmentedUtils {
primaryMask = queue; primaryMask = queue;
} }
LocalBlockQueue secondaryMask; LocalBlockQueue secondaryMask;
PlotBlock air = StringPlotBlock.EVERYTHING; BlockState air = BlockTypes.AIR.getDefaultState();
if (area.TERRAIN == 2) { if (area.TERRAIN == 2) {
PlotManager manager = area.getPlotManager(); PlotManager manager = area.getPlotManager();
final boolean[][] canPlace = new boolean[16][16]; final boolean[][] canPlace = new boolean[16][16];
@ -108,7 +109,7 @@ public class AugmentedUtils {
} }
toReturn = true; toReturn = true;
secondaryMask = new DelegateLocalBlockQueue(primaryMask) { secondaryMask = new DelegateLocalBlockQueue(primaryMask) {
@Override public boolean setBlock(int x, int y, int z, PlotBlock id) { @Override public boolean setBlock(int x, int y, int z, BlockState id) {
if (canPlace[x - blockX][z - blockZ]) { if (canPlace[x - blockX][z - blockZ]) {
return super.setBlock(x, y, z, id); return super.setBlock(x, y, z, id);
} }

View File

@ -1,8 +1,14 @@
package com.github.intellectualsites.plotsquared.plot.generator; package com.github.intellectualsites.plotsquared.plot.generator;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.Direction;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
@ -45,7 +51,9 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override public boolean unClaimPlot(Plot plot, Runnable whenDone) { @Override public boolean unClaimPlot(Plot plot, Runnable whenDone) {
setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING); setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING);
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK); if (!classicPlotWorld.WALL_BLOCK.isAir() || !classicPlotWorld.WALL_BLOCK.equals(classicPlotWorld.CLAIMED_WALL_BLOCK)) {
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK);
}
return GlobalBlockQueue.IMP.addEmptyTask(whenDone); return GlobalBlockQueue.IMP.addEmptyTask(whenDone);
} }
@ -53,11 +61,11 @@ public class ClassicPlotManager extends SquarePlotManager {
Plot plot = classicPlotWorld.getPlotAbs(plotId); Plot plot = classicPlotWorld.getPlotAbs(plotId);
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
for (RegionWrapper region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = Location pos1 =
new Location(classicPlotWorld.worldname, region.minX, classicPlotWorld.PLOT_HEIGHT, region.minZ); new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), classicPlotWorld.PLOT_HEIGHT, region.getMinimumPoint().getZ());
Location pos2 = Location pos2 =
new Location(classicPlotWorld.worldname, region.maxX, classicPlotWorld.PLOT_HEIGHT, region.maxZ); new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), classicPlotWorld.PLOT_HEIGHT, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
} }
@ -71,9 +79,9 @@ public class ClassicPlotManager extends SquarePlotManager {
} }
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
int maxY = getWorldHeight(); int maxY = getWorldHeight();
for (RegionWrapper region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = new Location(classicPlotWorld.worldname, region.minX, 1, region.minZ); Location pos1 = new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), 1, region.getMinimumPoint().getZ());
Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ); Location pos2 = new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), maxY, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
return queue.enqueue(); return queue.enqueue();
@ -86,10 +94,10 @@ public class ClassicPlotManager extends SquarePlotManager {
} }
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
int maxY = getWorldHeight(); int maxY = getWorldHeight();
for (RegionWrapper region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = Location pos1 =
new Location(classicPlotWorld.worldname, region.minX, classicPlotWorld.PLOT_HEIGHT + 1, region.minZ); new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), classicPlotWorld.PLOT_HEIGHT + 1, region.getMinimumPoint().getZ());
Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ); Location pos2 = new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), maxY, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
return queue.enqueue(); return queue.enqueue();
@ -101,10 +109,10 @@ public class ClassicPlotManager extends SquarePlotManager {
return false; return false;
} }
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
for (RegionWrapper region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = new Location(classicPlotWorld.worldname, region.minX, 1, region.minZ); Location pos1 = new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), 1, region.getMinimumPoint().getZ());
Location pos2 = Location pos2 =
new Location(classicPlotWorld.worldname, region.maxX, classicPlotWorld.PLOT_HEIGHT - 1, region.maxZ); new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), classicPlotWorld.PLOT_HEIGHT - 1, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
return queue.enqueue(); return queue.enqueue();
@ -167,9 +175,9 @@ public class ClassicPlotManager extends SquarePlotManager {
} }
} }
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
for (RegionWrapper region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = new Location(classicPlotWorld.worldname, region.minX, maxY, region.minZ); Location pos1 = new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), maxY, region.getMinimumPoint().getZ());
Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ); Location pos2 = new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), maxY, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
} }
@ -278,9 +286,9 @@ public class ClassicPlotManager extends SquarePlotManager {
queue.setCuboid( queue.setCuboid(
new Location(classicPlotWorld.worldname, sx, Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, new Location(classicPlotWorld.worldname, sx, Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1,
sz + 1), new Location(classicPlotWorld.worldname, ex, maxY, ez - 1), sz + 1), new Location(classicPlotWorld.worldname, ex, maxY, ez - 1),
PlotBlock.get((short) 0, (byte) 0)); BlockUtil.get((short) 0, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 0, sz + 1), queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 0, sz + 1),
new Location(classicPlotWorld.worldname, ex, 0, ez - 1), PlotBlock.get((short) 7, (byte) 0)); new Location(classicPlotWorld.worldname, ex, 0, ez - 1), BlockUtil.get((short) 7, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz + 1),
new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT, ez - 1), classicPlotWorld.WALL_FILLING); new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT, ez - 1), classicPlotWorld.WALL_FILLING);
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT + 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT + 1, sz + 1),
@ -306,9 +314,9 @@ public class ClassicPlotManager extends SquarePlotManager {
new Location(classicPlotWorld.worldname, sx + 1, Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, new Location(classicPlotWorld.worldname, sx + 1, Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1,
sz), sz),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.getPlotManager().getWorldHeight(), new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.getPlotManager().getWorldHeight(),
ez), PlotBlock.get((short) 0, (byte) 0)); ez), BlockUtil.get((short) 0, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 0, sz), queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 0, sz),
new Location(classicPlotWorld.worldname, ex - 1, 0, ez), PlotBlock.get((short) 7, (byte) 0)); new Location(classicPlotWorld.worldname, ex - 1, 0, ez), BlockUtil.get((short) 7, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz), queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT, sz), classicPlotWorld.WALL_FILLING); new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT, sz), classicPlotWorld.WALL_FILLING);
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.WALL_HEIGHT + 1, sz), queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.WALL_HEIGHT + 1, sz),
@ -331,10 +339,10 @@ public class ClassicPlotManager extends SquarePlotManager {
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.ROAD_HEIGHT + 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.ROAD_HEIGHT + 1, sz + 1),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.getPlotManager().getWorldHeight(), ez - 1), new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.getPlotManager().getWorldHeight(), ez - 1),
PlotBlock.get((short) 0, (byte) 0)); BlockUtil.get((short) 0, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 0, sz + 1), queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 0, sz + 1),
new Location(classicPlotWorld.worldname, ex - 1, 0, ez - 1), new Location(classicPlotWorld.worldname, ex - 1, 0, ez - 1),
PlotBlock.get((short) 7, (byte) 0)); BlockUtil.get((short) 7, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK); new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK);
return queue.enqueue(); return queue.enqueue();
@ -352,7 +360,7 @@ public class ClassicPlotManager extends SquarePlotManager {
new Location(classicPlotWorld.worldname, sx, Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, new Location(classicPlotWorld.worldname, sx, Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1,
sz), sz),
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez), new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
PlotBlock.get((short) 0, (byte) 0)); BlockUtil.get((short) 0, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz + 1), queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz + 1),
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT - 1, ez - 1), classicPlotWorld.MAIN_BLOCK); new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT - 1, ez - 1), classicPlotWorld.MAIN_BLOCK);
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.PLOT_HEIGHT, sz + 1), queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.PLOT_HEIGHT, sz + 1),
@ -372,7 +380,7 @@ public class ClassicPlotManager extends SquarePlotManager {
new Location(classicPlotWorld.worldname, sx, Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, new Location(classicPlotWorld.worldname, sx, Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1,
sz), sz),
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez), new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
PlotBlock.get((short) 0, (byte) 0)); BlockUtil.get((short) 0, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz), queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz),
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK); new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK);
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.PLOT_HEIGHT, sz), queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.PLOT_HEIGHT, sz),
@ -389,7 +397,7 @@ public class ClassicPlotManager extends SquarePlotManager {
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT + 1, sz), queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT + 1, sz),
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez), new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
PlotBlock.get((short) 0, (byte) 0)); BlockUtil.get((short) 0, (byte) 0));
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz), queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz),
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK); new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK);
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT, sz), queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT, sz),
@ -403,44 +411,29 @@ public class ClassicPlotManager extends SquarePlotManager {
* @return false if part of the merge failed, otherwise true if successful. * @return false if part of the merge failed, otherwise true if successful.
*/ */
@Override public boolean finishPlotMerge(List<PlotId> plotIds) { @Override public boolean finishPlotMerge(List<PlotId> plotIds) {
final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK; final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
boolean success = true; if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
for (PlotId plotId : plotIds) { for (PlotId plotId : plotIds) {
success &= setWall(plotId, block); setWall(plotId, claim);
}
} }
if (Settings.General.MERGE_REPLACE_WALL) { if (Settings.General.MERGE_REPLACE_WALL) {
final BlockBucket wallBlock = classicPlotWorld.WALL_FILLING; final BlockBucket wallBlock = classicPlotWorld.WALL_FILLING;
for (PlotId id : plotIds) { for (PlotId id : plotIds) {
success &= setWallFilling(id, wallBlock); setWallFilling(id, wallBlock);
} }
} }
return success; return true;
} }
@Override public boolean finishPlotUnlink(List<PlotId> plotIds) { @Override public boolean finishPlotUnlink(List<PlotId> plotIds) {
final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK; final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
boolean success = true; if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
for (PlotId id : plotIds) { for (PlotId id : plotIds) {
success &= setWall(id, block); setWall(id, claim);
}
return success;
}
/**
* Sets all the blocks along all the plot walls to their correct state (claimed or unclaimed).
*
* @return true if the wall blocks were successfully set
*/
@Override public boolean regenerateAllPlotWalls() {
boolean success = true;
for (Plot plot : classicPlotWorld.getPlots()) {
if (plot.hasOwner()) {
success &= setWall(plot.getId(), classicPlotWorld.CLAIMED_WALL_BLOCK);
} else {
success &= setWall(plot.getId(), classicPlotWorld.WALL_BLOCK);
} }
} }
return success; return true; // return false if unlink has been denied
} }
@Override public boolean startPlotMerge(List<PlotId> plotIds) { @Override public boolean startPlotMerge(List<PlotId> plotIds) {
@ -453,7 +446,10 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override public boolean claimPlot(Plot plot) { @Override public boolean claimPlot(Plot plot) {
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK; final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
return setWall(plot.getId(), claim); if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
return setWall(plot.getId(), claim);
}
return true;
} }
@Override public String[] getPlotComponents(PlotId plotId) { @Override public String[] getPlotComponents(PlotId plotId) {

View File

@ -6,11 +6,10 @@ import com.github.intellectualsites.plotsquared.plot.config.Configuration;
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode; import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Locale; import java.util.Locale;
@ -19,18 +18,18 @@ import java.util.Locale;
public int ROAD_HEIGHT = 62; public int ROAD_HEIGHT = 62;
public int PLOT_HEIGHT = 62; public int PLOT_HEIGHT = 62;
public int WALL_HEIGHT = 62; public int WALL_HEIGHT = 62;
public BlockBucket MAIN_BLOCK = BlockBucket.withSingle(PlotBlock.get("stone")); public BlockBucket MAIN_BLOCK = BlockBucket.withSingle(BlockUtil.get("stone"));
// new PlotBlock[] {PlotBlock.get("stone")}; // new BlockState[] {BlockUtil.get("stone")};
public BlockBucket TOP_BLOCK = BlockBucket.withSingle(PlotBlock.get("grass_block")); public BlockBucket TOP_BLOCK = BlockBucket.withSingle(BlockUtil.get("grass_block"));
//new PlotBlock[] {PlotBlock.get("grass")}; //new BlockState[] {BlockUtil.get("grass")};
public BlockBucket WALL_BLOCK = BlockBucket.withSingle(PlotBlock.get("stone_slab")); public BlockBucket WALL_BLOCK = BlockBucket.withSingle(BlockUtil.get("stone_slab"));
// PlotBlock.get((short) 44, (byte) 0); // BlockUtil.get((short) 44, (byte) 0);
public BlockBucket CLAIMED_WALL_BLOCK = BlockBucket.withSingle(PlotBlock.get("sandstone_slab")); public BlockBucket CLAIMED_WALL_BLOCK = BlockBucket.withSingle(BlockUtil.get("sandstone_slab"));
// PlotBlock.get((short) 44, (byte) 1); // BlockUtil.get((short) 44, (byte) 1);
public BlockBucket WALL_FILLING = BlockBucket.withSingle(PlotBlock.get("stone")); public BlockBucket WALL_FILLING = BlockBucket.withSingle(BlockUtil.get("stone"));
//PlotBlock.get((short) 1, (byte) 0); //BlockUtil.get((short) 1, (byte) 0);
public BlockBucket ROAD_BLOCK = BlockBucket.withSingle(PlotBlock.get("quartz_block")); public BlockBucket ROAD_BLOCK = BlockBucket.withSingle(BlockUtil.get("quartz_block"));
// PlotBlock.get((short) 155, (byte) 0); // BlockUtil.get((short) 155, (byte) 0);
public boolean PLOT_BEDROCK = true; public boolean PLOT_BEDROCK = true;
public ClassicPlotWorld(String worldName, String id, public ClassicPlotWorld(String worldName, String id,

View File

@ -2,8 +2,12 @@ package com.github.intellectualsites.plotsquared.plot.generator;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
@ -39,7 +43,7 @@ public class HybridGen extends IndependentPlotGenerator {
for (short x = 0; x < 16; x++) { for (short x = 0; x < 16; x++) {
for (short z = 0; z < 16; z++) { for (short z = 0; z < 16; z++) {
blockBuckets[0][(z << 4) | x] = blockBuckets[0][(z << 4) | x] =
BlockBucket.withSingle(PlotBlock.get("bedrock")); BlockBucket.withSingle(BlockUtil.get("bedrock"));
} }
} }
} }
@ -70,7 +74,7 @@ public class HybridGen extends IndependentPlotGenerator {
if (hpw.PLOT_BEDROCK) { if (hpw.PLOT_BEDROCK) {
for (short x = 0; x < 16; x++) { for (short x = 0; x < 16; x++) {
for (short z = 0; z < 16; z++) { for (short z = 0; z < 16; z++) {
result.setBlock(x, 0, z, PlotBlock.get("bedrock")); result.setBlock(x, 0, z, BlockUtil.get("bedrock"));
} }
} }
} }

View File

@ -3,14 +3,21 @@ package com.github.intellectualsites.plotsquared.plot.generator;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.commands.Template; import com.github.intellectualsites.plotsquared.plot.commands.Template;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.FileBytes;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.io.File; import java.io.File;
@ -168,13 +175,13 @@ public class HybridPlotManager extends ClassicPlotManager {
// The component blocks // The component blocks
final BlockBucket plotfloor = hybridPlotWorld.TOP_BLOCK; final BlockBucket plotfloor = hybridPlotWorld.TOP_BLOCK;
final BlockBucket filling = hybridPlotWorld.MAIN_BLOCK; final BlockBucket filling = hybridPlotWorld.MAIN_BLOCK;
final PlotBlock bedrock; final BlockState bedrock;
if (hybridPlotWorld.PLOT_BEDROCK) { if (hybridPlotWorld.PLOT_BEDROCK) {
bedrock = PlotBlock.get((short) 7, (byte) 0); bedrock = BlockUtil.get((short) 7, (byte) 0);
} else { } else {
bedrock = PlotBlock.get((short) 0, (byte) 0); bedrock = BlockUtil.get((short) 0, (byte) 0);
} }
final PlotBlock air = PlotBlock.get((short) 0, (byte) 0); final BlockState air = BlockUtil.get((short) 0, (byte) 0);
final String biome = hybridPlotWorld.PLOT_BIOME; final String biome = hybridPlotWorld.PLOT_BIOME;
final LocalBlockQueue queue = hybridPlotWorld.getQueue(false); final LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() { ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {

View File

@ -14,7 +14,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.CompoundTagBuilder; import com.sk89q.jnbt.CompoundTagBuilder;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.transform.BlockTransformExtent; import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
import com.sk89q.worldedit.internal.helper.MCDirections; import com.sk89q.worldedit.internal.helper.MCDirections;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -178,7 +178,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
if (schematic3 != null) { if (schematic3 != null) {
this.PLOT_SCHEMATIC = true; this.PLOT_SCHEMATIC = true;
BlockArrayClipboard blockArrayClipboard3 = schematic3.getClipboard(); Clipboard blockArrayClipboard3 = schematic3.getClipboard();
BlockVector3 d3 = blockArrayClipboard3.getDimensions(); BlockVector3 d3 = blockArrayClipboard3.getDimensions();
short w3 = (short) d3.getX(); short w3 = (short) d3.getX();
@ -252,9 +252,9 @@ public class HybridPlotWorld extends ClassicPlotWorld {
} }
this.ROAD_SCHEMATIC_ENABLED = true; this.ROAD_SCHEMATIC_ENABLED = true;
// Do not populate road if using schematic population // Do not populate road if using schematic population
// TODO: What? this.ROAD_BLOCK = BlockBucket.empty(); // PlotBlock.getEmptyData(this.ROAD_BLOCK); // PlotBlock.get(this.ROAD_BLOCK.id, (byte) 0); // TODO: What? this.ROAD_BLOCK = BlockBucket.empty(); // BlockState.getEmptyData(this.ROAD_BLOCK); // BlockUtil.get(this.ROAD_BLOCK.id, (byte) 0);
BlockArrayClipboard blockArrayClipboard1 = schematic1.getClipboard(); Clipboard blockArrayClipboard1 = schematic1.getClipboard();
BlockVector3 d1 = blockArrayClipboard1.getDimensions(); BlockVector3 d1 = blockArrayClipboard1.getDimensions();
short w1 = (short) d1.getX(); short w1 = (short) d1.getX();
@ -277,7 +277,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
} }
} }
BlockArrayClipboard blockArrayClipboard2 = schematic2.getClipboard(); Clipboard blockArrayClipboard2 = schematic2.getClipboard();
BlockVector3 d2 = blockArrayClipboard2.getDimensions(); BlockVector3 d2 = blockArrayClipboard2.getDimensions();
short w2 = (short) d2.getX(); short w2 = (short) d2.getX();
short l2 = (short) d2.getZ(); short l2 = (short) d2.getZ();

View File

@ -5,7 +5,14 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.listener.WEExtent; import com.github.intellectualsites.plotsquared.plot.listener.WEExtent;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
@ -15,26 +22,35 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis; import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import java.io.File; import java.io.File;
import java.util.*; import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public abstract class HybridUtils { public abstract class HybridUtils {
public static HybridUtils manager; public static HybridUtils manager;
public static Set<ChunkLoc> regions; public static Set<BlockVector2> regions;
public static Set<ChunkLoc> chunks = new HashSet<>(); public static Set<BlockVector2> chunks = new HashSet<>();
public static PlotArea area; public static PlotArea area;
public static boolean UPDATE = false; public static boolean UPDATE = false;
public abstract void analyzeRegion(String world, RegionWrapper region, public abstract void analyzeRegion(String world, CuboidRegion region,
RunnableVal<PlotAnalysis> whenDone); RunnableVal<PlotAnalysis> whenDone);
public void analyzePlot(final Plot origin, final RunnableVal<PlotAnalysis> whenDone) { public void analyzePlot(final Plot origin, final RunnableVal<PlotAnalysis> whenDone) {
final ArrayDeque<RegionWrapper> zones = new ArrayDeque<>(origin.getRegions()); final ArrayDeque<CuboidRegion> zones = new ArrayDeque<>(origin.getRegions());
final ArrayList<PlotAnalysis> analysis = new ArrayList<>(); final ArrayList<PlotAnalysis> analysis = new ArrayList<>();
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override public void run() { @Override public void run() {
@ -82,7 +98,7 @@ public abstract class HybridUtils {
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
} }
RegionWrapper region = zones.poll(); CuboidRegion region = zones.poll();
final Runnable task = this; final Runnable task = this;
analyzeRegion(origin.getWorldName(), region, new RunnableVal<PlotAnalysis>() { analyzeRegion(origin.getWorldName(), region, new RunnableVal<PlotAnalysis>() {
@Override public void run(PlotAnalysis value) { @Override public void run(PlotAnalysis value) {
@ -96,12 +112,12 @@ public abstract class HybridUtils {
} }
public int checkModified(LocalBlockQueue queue, int x1, int x2, int y1, int y2, int z1, int z2, public int checkModified(LocalBlockQueue queue, int x1, int x2, int y1, int y2, int z1, int z2,
PlotBlock[] blocks) { BlockState[] blocks) {
int count = 0; int count = 0;
for (int y = y1; y <= y2; y++) { for (int y = y1; y <= y2; y++) {
for (int x = x1; x <= x2; x++) { for (int x = x1; x <= x2; x++) {
for (int z = z1; z <= z2; z++) { for (int z = z1; z <= z2; z++) {
PlotBlock block = queue.getBlock(x, y, z); BlockState block = queue.getBlock(x, y, z);
boolean same = boolean same =
Arrays.stream(blocks).anyMatch(p -> WorldUtil.IMP.isBlockSame(block, p)); Arrays.stream(blocks).anyMatch(p -> WorldUtil.IMP.isBlockSame(block, p));
if (!same) { if (!same) {
@ -113,13 +129,13 @@ public abstract class HybridUtils {
return count; return count;
} }
public final ArrayList<ChunkLoc> getChunks(ChunkLoc region) { public final ArrayList<BlockVector2> getChunks(BlockVector2 region) {
ArrayList<ChunkLoc> chunks = new ArrayList<>(); ArrayList<BlockVector2> chunks = new ArrayList<>();
int sx = region.x << 5; int sx = region.getX() << 5;
int sz = region.z << 5; int sz = region.getZ() << 5;
for (int x = sx; x < sx + 32; x++) { for (int x = sx; x < sx + 32; x++) {
for (int z = sz; z < sz + 32; z++) { for (int z = sz; z < sz + 32; z++) {
chunks.add(new ChunkLoc(x, z)); chunks.add(BlockVector2.at(x, z));
} }
} }
return chunks; return chunks;
@ -130,7 +146,7 @@ public abstract class HybridUtils {
return false; return false;
} }
HybridUtils.UPDATE = true; HybridUtils.UPDATE = true;
Set<ChunkLoc> regions = ChunkManager.manager.getChunkChunks(area.worldname); Set<BlockVector2> regions = ChunkManager.manager.getChunkChunks(area.worldname);
return scheduleRoadUpdate(area, regions, extend); return scheduleRoadUpdate(area, regions, extend);
} }
@ -139,12 +155,12 @@ public abstract class HybridUtils {
return false; return false;
} }
HybridUtils.UPDATE = true; HybridUtils.UPDATE = true;
Set<ChunkLoc> regions = new HashSet<>(); Set<BlockVector2> regions = new HashSet<>();
regions.add(ChunkManager.getChunkChunk(plot.getCenter())); regions.add(ChunkManager.getRegion(plot.getCenter()));
return scheduleRoadUpdate(plot.getArea(), regions, extend); return scheduleRoadUpdate(plot.getArea(), regions, extend);
} }
public boolean scheduleRoadUpdate(final PlotArea area, Set<ChunkLoc> regions, public boolean scheduleRoadUpdate(final PlotArea area, Set<BlockVector2> regions,
final int extend) { final int extend) {
HybridUtils.regions = regions; HybridUtils.regions = regions;
HybridUtils.area = area; HybridUtils.area = area;
@ -153,9 +169,9 @@ public abstract class HybridUtils {
TaskManager.runTask(new Runnable() { TaskManager.runTask(new Runnable() {
@Override public void run() { @Override public void run() {
if (!UPDATE) { if (!UPDATE) {
Iterator<ChunkLoc> iter = chunks.iterator(); Iterator<BlockVector2> iter = chunks.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
ChunkLoc chunk = iter.next(); BlockVector2 chunk = iter.next();
iter.remove(); iter.remove();
boolean regenedRoad = regenerateRoad(area, chunk, extend); boolean regenedRoad = regenerateRoad(area, chunk, extend);
if (!regenedRoad) { if (!regenedRoad) {
@ -183,10 +199,10 @@ public abstract class HybridUtils {
try { try {
if (chunks.size() < 1024) { if (chunks.size() < 1024) {
if (!HybridUtils.regions.isEmpty()) { if (!HybridUtils.regions.isEmpty()) {
Iterator<ChunkLoc> iterator = HybridUtils.regions.iterator(); Iterator<BlockVector2> iterator = HybridUtils.regions.iterator();
ChunkLoc loc = iterator.next(); BlockVector2 loc = iterator.next();
iterator.remove(); iterator.remove();
PlotSquared.debug("Updating .mcr: " + loc.x + ", " + loc.z PlotSquared.debug("Updating .mcr: " + loc.getX() + ", " + loc.getZ()
+ " (approx 1024 chunks)"); + " (approx 1024 chunks)");
PlotSquared PlotSquared
.debug(" - Remaining: " + HybridUtils.regions.size()); .debug(" - Remaining: " + HybridUtils.regions.size());
@ -198,10 +214,10 @@ public abstract class HybridUtils {
TaskManager.IMP.sync(new RunnableVal<Object>() { TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override public void run(Object value) { @Override public void run(Object value) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Iterator<ChunkLoc> iterator = chunks.iterator(); Iterator<BlockVector2> iterator = chunks.iterator();
while (System.currentTimeMillis() - start < 20 && !chunks while (System.currentTimeMillis() - start < 20 && !chunks
.isEmpty()) { .isEmpty()) {
final ChunkLoc chunk = iterator.next(); final BlockVector2 chunk = iterator.next();
iterator.remove(); iterator.remove();
boolean regenedRoads = boolean regenedRoads =
regenerateRoad(area, chunk, extend); regenerateRoad(area, chunk, extend);
@ -214,18 +230,18 @@ public abstract class HybridUtils {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Iterator<ChunkLoc> iterator = HybridUtils.regions.iterator(); Iterator<BlockVector2> iterator = HybridUtils.regions.iterator();
ChunkLoc loc = iterator.next(); BlockVector2 loc = iterator.next();
iterator.remove(); iterator.remove();
PlotSquared.debug( PlotSquared.debug(
"[ERROR] Could not update '" + area.worldname + "/region/r." + loc.x "[ERROR] Could not update '" + area.worldname + "/region/r." + loc.getX()
+ "." + loc.z + ".mca' (Corrupt chunk?)"); + "." + loc.getZ() + ".mca' (Corrupt chunk?)");
int sx = loc.x << 5; int sx = loc.getX() << 5;
int sz = loc.z << 5; int sz = loc.getZ() << 5;
for (int x = sx; x < sx + 32; x++) { for (int x = sx; x < sx + 32; x++) {
for (int z = sz; z < sz + 32; z++) { for (int z = sz; z < sz + 32; z++) {
ChunkManager.manager ChunkManager.manager
.unloadChunk(area.worldname, new ChunkLoc(x, z), true); .unloadChunk(area.worldname, BlockVector2.at(x, z), true);
} }
} }
PlotSquared.debug(" - Potentially skipping 1024 chunks"); PlotSquared.debug(" - Potentially skipping 1024 chunks");
@ -256,10 +272,10 @@ public abstract class HybridUtils {
int tz = sz - 1; int tz = sz - 1;
int ty = get_ey(plotManager, queue, sx, ex, bz, tz, sy); int ty = get_ey(plotManager, queue, sx, ex, bz, tz, sy);
Set<RegionWrapper> sideRoad = Set<CuboidRegion> sideRoad =
new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ey, sz, ez))); new HashSet<>(Collections.singletonList(RegionUtil.createRegion(sx, ex, sy, ey, sz, ez)));
final Set<RegionWrapper> intersection = final Set<CuboidRegion> intersection =
new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ty, bz, tz))); new HashSet<>(Collections.singletonList(RegionUtil.createRegion(sx, ex, sy, ty, bz, tz)));
final String dir = final String dir =
"schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.getArea() "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.getArea()
@ -292,8 +308,8 @@ public abstract class HybridUtils {
for (int z = sz; z <= ez; z++) { for (int z = sz; z <= ez; z++) {
for (int y = sy; y <= pm.getWorldHeight(); y++) { for (int y = sy; y <= pm.getWorldHeight(); y++) {
if (y > ey) { if (y > ey) {
PlotBlock block = queue.getBlock(x, y, z); BlockState block = queue.getBlock(x, y, z);
if (!block.isAir()) { if (!block.getBlockType().getMaterial().isAir()) {
ey = y; ey = y;
} }
} }
@ -303,9 +319,9 @@ public abstract class HybridUtils {
return ey; return ey;
} }
public boolean regenerateRoad(final PlotArea area, final ChunkLoc chunk, int extend) { public boolean regenerateRoad(final PlotArea area, final BlockVector2 chunk, int extend) {
int x = chunk.x << 4; int x = chunk.getX() << 4;
int z = chunk.z << 4; int z = chunk.getZ() << 4;
int ex = x + 15; int ex = x + 15;
int ez = z + 15; int ez = z + 15;
HybridPlotWorld plotWorld = (HybridPlotWorld) area; HybridPlotWorld plotWorld = (HybridPlotWorld) area;

View File

@ -1,7 +1,10 @@
package com.github.intellectualsites.plotsquared.plot.generator; package com.github.intellectualsites.plotsquared.plot.generator;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
/** /**

View File

@ -1,13 +1,19 @@
package com.github.intellectualsites.plotsquared.plot.generator; package com.github.intellectualsites.plotsquared.plot.generator;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.Direction;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set;
/** /**
* A plot manager with a square grid layout, with square shaped plots. * A plot manager with a square grid layout, with square shaped plots.
@ -23,20 +29,20 @@ public abstract class SquarePlotManager extends GridPlotManager {
@Override @Override
public boolean clearPlot(final Plot plot, final Runnable whenDone) { public boolean clearPlot(final Plot plot, final Runnable whenDone) {
final HashSet<RegionWrapper> regions = plot.getRegions(); final Set<CuboidRegion> regions = plot.getRegions();
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override public void run() { @Override public void run() {
if (regions.isEmpty()) { if (regions.isEmpty()) {
whenDone.run(); whenDone.run();
return; return;
} }
Iterator<RegionWrapper> iterator = regions.iterator(); Iterator<CuboidRegion> iterator = regions.iterator();
RegionWrapper region = iterator.next(); CuboidRegion region = iterator.next();
iterator.remove(); iterator.remove();
Location pos1 = Location pos1 =
new Location(plot.getWorldName(), region.minX, region.minY, region.minZ); new Location(plot.getWorldName(), region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
Location pos2 = Location pos2 =
new Location(plot.getWorldName(), region.maxX, region.maxY, region.maxZ); new Location(plot.getWorldName(), region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
ChunkManager.manager.regenerateRegion(pos1, pos2, false, this); ChunkManager.manager.regenerateRegion(pos1, pos2, false, this);
} }
}; };

View File

@ -8,11 +8,22 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.ByteArrayUtilities;
import com.github.intellectualsites.plotsquared.plot.util.CommentManager;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.world.ItemUtil;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -135,21 +146,21 @@ public class PlotListener {
Optional<String> musicFlag = plot.getFlag(Flags.MUSIC); Optional<String> musicFlag = plot.getFlag(Flags.MUSIC);
if (musicFlag.isPresent()) { if (musicFlag.isPresent()) {
final String id = musicFlag.get(); final String id = musicFlag.get();
final PlotBlock block = PlotBlock.get(id); final ItemType item = ItemUtil.get(id);
final String rawId = block.getRawId().toString(); final String rawId = item.getId();
if (rawId.contains("disc") || PlotBlock.isEverything(block) || block.isAir()) { if (rawId.contains("disc") || item == ItemTypes.AIR) {
Location location = player.getLocation(); Location location = player.getLocation();
Location lastLocation = player.getMeta("music"); Location lastLocation = player.getMeta("music");
if (lastLocation != null) { if (lastLocation != null) {
player.playMusic(lastLocation, PlotBlock.get("air")); player.playMusic(lastLocation, ItemTypes.AIR);
if (PlotBlock.isEverything(block) || block.isAir()) { if (item == ItemTypes.AIR) {
player.deleteMeta("music"); player.deleteMeta("music");
} }
} }
if (!(PlotBlock.isEverything(block) || block.isAir())) { if (!(item == ItemTypes.AIR)) {
try { try {
player.setMeta("music", location); player.setMeta("music", location);
player.playMusic(location, block); player.playMusic(location, item);
} catch (Exception ignored) { } catch (Exception ignored) {
} }
} }
@ -158,7 +169,7 @@ public class PlotListener {
Location lastLoc = player.getMeta("music"); Location lastLoc = player.getMeta("music");
if (lastLoc != null) { if (lastLoc != null) {
player.deleteMeta("music"); player.deleteMeta("music");
player.playMusic(lastLoc, PlotBlock.get("air")); player.playMusic(lastLoc, ItemTypes.AIR);
} }
} }
CommentManager.sendTitle(player, plot); CommentManager.sendTitle(player, plot);
@ -266,7 +277,7 @@ public class PlotListener {
Location lastLoc = player.getMeta("music"); Location lastLoc = player.getMeta("music");
if (lastLoc != null) { if (lastLoc != null) {
player.deleteMeta("music"); player.deleteMeta("music");
player.playMusic(lastLoc, PlotBlock.get("air")); player.playMusic(lastLoc, ItemTypes.AIR);
} }
} }
return true; return true;

View File

@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.listener;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
@ -20,10 +20,11 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
public class ProcessedWEExtent extends AbstractDelegateExtent { public class ProcessedWEExtent extends AbstractDelegateExtent {
private final HashSet<RegionWrapper> mask; private final Set<CuboidRegion> mask;
private final String world; private final String world;
private final int max; private final int max;
int BScount = 0; int BScount = 0;
@ -33,7 +34,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
private int count; private int count;
private Extent parent; private Extent parent;
public ProcessedWEExtent(String world, HashSet<RegionWrapper> mask, int max, Extent child, public ProcessedWEExtent(String world, Set<CuboidRegion> mask, int max, Extent child,
Extent parent) { Extent parent) {
super(child); super(child);
this.mask = mask; this.mask = mask;

View File

@ -1,6 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.listener; package com.github.intellectualsites.plotsquared.plot.listener;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
@ -16,14 +16,15 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
public class WEExtent extends AbstractDelegateExtent { public class WEExtent extends AbstractDelegateExtent {
public static BlockState AIRSTATE = BlockTypes.AIR.getDefaultState(); public static BlockState AIRSTATE = BlockTypes.AIR.getDefaultState();
public static BaseBlock AIRBASE = BlockTypes.AIR.getDefaultState().toBaseBlock(); public static BaseBlock AIRBASE = BlockTypes.AIR.getDefaultState().toBaseBlock();
private final HashSet<RegionWrapper> mask; private final Set<CuboidRegion> mask;
public WEExtent(HashSet<RegionWrapper> mask, Extent extent) { public WEExtent(Set<CuboidRegion> mask, Extent extent) {
super(extent); super(extent);
this.mask = mask; this.mask = mask;
} }

View File

@ -7,62 +7,65 @@ import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
public class WEManager { public class WEManager {
public static boolean maskContains(HashSet<RegionWrapper> mask, int x, int y, int z) { public static boolean maskContains(Set<CuboidRegion> mask, int x, int y, int z) {
for (RegionWrapper region : mask) { for (CuboidRegion region : mask) {
if (region.isIn(x, y, z)) { if (RegionUtil.contains(region, x, y, z)) {
return true; return true;
} }
} }
return false; return false;
} }
public static boolean maskContains(HashSet<RegionWrapper> mask, int x, int z) { public static boolean maskContains(Set<CuboidRegion> mask, int x, int z) {
for (RegionWrapper region : mask) { for (CuboidRegion region : mask) {
if (region.isIn(x, z)) { if (RegionUtil.contains(region, x, z)) {
return true; return true;
} }
} }
return false; return false;
} }
public static boolean maskContains(HashSet<RegionWrapper> mask, double dx, double dy, public static boolean maskContains(Set<CuboidRegion> mask, double dx, double dy,
double dz) { double dz) {
int x = Math.toIntExact(Math.round(dx >= 0 ? dx - 0.5 : dx + 0.5)); int x = Math.toIntExact(Math.round(dx >= 0 ? dx - 0.5 : dx + 0.5));
int y = Math.toIntExact(Math.round(dy - 0.5)); int y = Math.toIntExact(Math.round(dy - 0.5));
int z = Math.toIntExact(Math.round(dz >= 0 ? dz - 0.5 : dz + 0.5)); int z = Math.toIntExact(Math.round(dz >= 0 ? dz - 0.5 : dz + 0.5));
for (RegionWrapper region : mask) { for (CuboidRegion region : mask) {
if (region.isIn(x, y, z)) { if (RegionUtil.contains(region, x, y, z)) {
return true; return true;
} }
} }
return false; return false;
} }
public static boolean maskContains(HashSet<RegionWrapper> mask, double dx, double dz) { public static boolean maskContains(Set<CuboidRegion> mask, double dx, double dz) {
int x = Math.toIntExact(Math.round(dx >= 0 ? dx - 0.5 : dx + 0.5)); int x = Math.toIntExact(Math.round(dx >= 0 ? dx - 0.5 : dx + 0.5));
int z = Math.toIntExact(Math.round(dz >= 0 ? dz - 0.5 : dz + 0.5)); int z = Math.toIntExact(Math.round(dz >= 0 ? dz - 0.5 : dz + 0.5));
for (RegionWrapper region : mask) { for (CuboidRegion region : mask) {
if (region.isIn(x, z)) { if (RegionUtil.contains(region, x, z)) {
return true; return true;
} }
} }
return false; return false;
} }
public static HashSet<RegionWrapper> getMask(PlotPlayer player) { public static HashSet<CuboidRegion> getMask(PlotPlayer player) {
HashSet<RegionWrapper> regions = new HashSet<>(); HashSet<CuboidRegion> regions = new HashSet<>();
UUID uuid = player.getUUID(); UUID uuid = player.getUUID();
Location location = player.getLocation(); Location location = player.getLocation();
String world = location.getWorld(); String world = location.getWorld();
if (!PlotSquared.get().hasPlotArea(world)) { if (!PlotSquared.get().hasPlotArea(world)) {
regions.add(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, regions.add(RegionUtil.createRegion(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE,
Integer.MAX_VALUE)); Integer.MAX_VALUE));
return regions; return regions;
} }
@ -78,10 +81,10 @@ public class WEManager {
if (plot != null && (!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot)) && ( if (plot != null && (!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot)) && (
(allowMember && plot.isAdded(uuid)) || (!allowMember && (plot.isOwner(uuid)) || plot (allowMember && plot.isAdded(uuid)) || (!allowMember && (plot.isOwner(uuid)) || plot
.getTrusted().contains(uuid))) && !(Flags.NO_WORLDEDIT.isTrue(plot))) { .getTrusted().contains(uuid))) && !(Flags.NO_WORLDEDIT.isTrue(plot))) {
for (RegionWrapper region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
RegionWrapper copy = BlockVector3 pos1 = region.getMinimumPoint().withY(area.MIN_BUILD_HEIGHT);
new RegionWrapper(region.minX, region.maxX, area.MIN_BUILD_HEIGHT, BlockVector3 pos2 = region.getMaximumPoint().withY(area.MAX_BUILD_HEIGHT);
area.MAX_BUILD_HEIGHT, region.minZ, region.maxZ); CuboidRegion copy = new CuboidRegion(pos1, pos2);
regions.add(copy); regions.add(copy);
} }
player.setMeta("WorldEditRegionPlot", plot); player.setMeta("WorldEditRegionPlot", plot);
@ -89,12 +92,12 @@ public class WEManager {
return regions; return regions;
} }
public static boolean intersects(RegionWrapper region1, RegionWrapper region2) { public static boolean intersects(CuboidRegion region1, CuboidRegion region2) {
return region1.intersects(region2); return RegionUtil.intersects(region1, region2);
} }
public static boolean regionContains(RegionWrapper selection, HashSet<RegionWrapper> mask) { public static boolean regionContains(CuboidRegion selection, HashSet<CuboidRegion> mask) {
for (RegionWrapper region : mask) { for (CuboidRegion region : mask) {
if (intersects(region, selection)) { if (intersects(region, selection)) {
return true; return true;
} }

View File

@ -5,7 +5,7 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -19,6 +19,7 @@ import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
public class WESubscriber { public class WESubscriber {
@ -37,7 +38,7 @@ public class WESubscriber {
if (actor != null && actor.isPlayer()) { if (actor != null && actor.isPlayer()) {
String name = actor.getName(); String name = actor.getName();
PlotPlayer plotPlayer = PlotPlayer.wrap(name); PlotPlayer plotPlayer = PlotPlayer.wrap(name);
HashSet<RegionWrapper> mask; Set<CuboidRegion> mask;
if (plotPlayer == null) { if (plotPlayer == null) {
Player player = (Player) actor; Player player = (Player) actor;
Location location = player.getLocation(); Location location = player.getLocation();

View File

@ -4,37 +4,45 @@ import com.github.intellectualsites.plotsquared.configuration.serialization.Conf
import com.github.intellectualsites.plotsquared.plot.config.Configuration; import com.github.intellectualsites.plotsquared.plot.config.Configuration;
import com.github.intellectualsites.plotsquared.plot.object.collection.RandomCollection; import com.github.intellectualsites.plotsquared.plot.object.collection.RandomCollection;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.*; import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Random;
/** /**
* A block bucket is a container of block types, where each block * A block bucket is a container of block types, where each block
* has a specified chance of being randomly picked * has a specified chance of being randomly picked
*/ */
@EqualsAndHashCode @SuppressWarnings({"unused", "WeakerAccess"}) public final class BlockBucket @EqualsAndHashCode(of={"blocks"}) @SuppressWarnings({"unused", "WeakerAccess"}) public final class BlockBucket
implements Iterable<PlotBlock>, ConfigurationSerializable { implements Iterable<BlockState>, ConfigurationSerializable {
private final Random random = new Random(); private final Random random = new Random();
private final Map<PlotBlock, Double> blocks; private final Map<BlockState, Double> blocks;
private final BucketIterator bucketIterator = new BucketIterator(); private final BucketIterator bucketIterator = new BucketIterator();
private boolean compiled, singleItem; private boolean compiled, singleItem;
private PlotBlock head; private BlockState head;
private RandomCollection<PlotBlock> randomBlocks; private RandomCollection<BlockState> randomBlocks;
private PlotBlock single; private BlockState single;
public BlockBucket() { public BlockBucket() {
this.blocks = new HashMap<>(); this.blocks = new HashMap<>();
} }
public static BlockBucket withSingle(@NonNull final PlotBlock block) { public static BlockBucket withSingle(@NonNull final BlockState block) {
final BlockBucket blockBucket = new BlockBucket(); final BlockBucket blockBucket = new BlockBucket();
blockBucket.addBlock(block, 100); blockBucket.addBlock(block, 100);
return blockBucket; return blockBucket;
@ -47,15 +55,15 @@ import java.util.Map.Entry;
return Configuration.BLOCK_BUCKET.parseString(map.get("blocks").toString()); return Configuration.BLOCK_BUCKET.parseString(map.get("blocks").toString());
} }
public void addBlock(@NonNull final PlotBlock block) { public void addBlock(@NonNull final BlockState block) {
this.addBlock(block, -1); this.addBlock(block, -1);
} }
public void addBlock(@NonNull final PlotBlock block, final int chance) { public void addBlock(@NonNull final BlockState block, final int chance) {
addBlock(block, (double) chance); addBlock(block, (double) chance);
} }
private void addBlock(@NonNull final PlotBlock block, double chance) { private void addBlock(@NonNull final BlockState block, double chance) {
if (chance == -1) if (chance == -1)
chance = 1; chance = 1;
this.blocks.put(block, chance); this.blocks.put(block, chance);
@ -75,7 +83,7 @@ import java.util.Map.Entry;
* @return Immutable collection containing all blocks that can * @return Immutable collection containing all blocks that can
* be found in the bucket * be found in the bucket
*/ */
public Collection<PlotBlock> getBlocks() { public Collection<BlockState> getBlocks() {
if (!isCompiled()) { if (!isCompiled()) {
this.compile(); this.compile();
} }
@ -88,7 +96,7 @@ import java.util.Map.Entry;
* @param count Number of blocks * @param count Number of blocks
* @return Immutable collection containing randomly selected blocks * @return Immutable collection containing randomly selected blocks
*/ */
public Collection<PlotBlock> getBlocks(final int count) { public Collection<BlockState> getBlocks(final int count) {
return Arrays.asList(getBlockArray(count)); return Arrays.asList(getBlockArray(count));
} }
@ -98,8 +106,8 @@ import java.util.Map.Entry;
* @param count Number of blocks * @param count Number of blocks
* @return Immutable collection containing randomly selected blocks * @return Immutable collection containing randomly selected blocks
*/ */
public PlotBlock[] getBlockArray(final int count) { public BlockState[] getBlockArray(final int count) {
final PlotBlock[] blocks = new PlotBlock[count]; final BlockState[] blocks = new BlockState[count];
if (this.singleItem) { if (this.singleItem) {
Arrays.fill(blocks, 0, count, getBlock()); Arrays.fill(blocks, 0, count, getBlock());
} else { } else {
@ -136,7 +144,7 @@ import java.util.Map.Entry;
} }
} }
@NotNull @Override public Iterator<PlotBlock> iterator() { @NotNull @Override public Iterator<BlockState> iterator() {
return this.bucketIterator; return this.bucketIterator;
} }
@ -149,7 +157,7 @@ import java.util.Map.Entry;
* *
* @return Randomly picked block (cased on specified rates) * @return Randomly picked block (cased on specified rates)
*/ */
public PlotBlock getBlock() { public BlockState getBlock() {
if (!isCompiled()) { if (!isCompiled()) {
this.compile(); this.compile();
} }
@ -159,19 +167,22 @@ import java.util.Map.Entry;
if (randomBlocks != null) { if (randomBlocks != null) {
return randomBlocks.next(); return randomBlocks.next();
} }
return StringPlotBlock.EVERYTHING; return BlockTypes.AIR.getDefaultState();
} }
@Override public String toString() { @Override public String toString() {
if (!isCompiled()) { if (!isCompiled()) {
compile(); compile();
} }
if (blocks.size() == 1) {
return blocks.entrySet().iterator().next().getKey().toString();
}
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
Iterator<Entry<PlotBlock, Double>> iterator = blocks.entrySet().iterator(); Iterator<Entry<BlockState, Double>> iterator = blocks.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Entry<PlotBlock, Double> entry = iterator.next(); Entry<BlockState, Double> entry = iterator.next();
PlotBlock block = entry.getKey(); BlockState block = entry.getKey();
builder.append(block.getRawId()); builder.append(block);
Double weight = entry.getValue(); Double weight = entry.getValue();
if (weight != 1) { if (weight != 1) {
builder.append(":").append(weight.intValue()); builder.append(":").append(weight.intValue());
@ -183,6 +194,11 @@ import java.util.Map.Entry;
return builder.toString(); return builder.toString();
} }
public boolean isAir() {
compile();
return blocks.isEmpty() || (single != null && single.getBlockType().getMaterial().isAir());
}
@Override public Map<String, Object> serialize() { @Override public Map<String, Object> serialize() {
if (!isCompiled()) { if (!isCompiled()) {
compile(); compile();
@ -190,7 +206,6 @@ import java.util.Map.Entry;
return ImmutableMap.of("blocks", this.toString()); return ImmutableMap.of("blocks", this.toString());
} }
@Getter @EqualsAndHashCode @RequiredArgsConstructor private final static class Range { @Getter @EqualsAndHashCode @RequiredArgsConstructor private final static class Range {
private final int min; private final int min;
@ -207,13 +222,13 @@ import java.util.Map.Entry;
} }
private final class BucketIterator implements Iterator<PlotBlock> { private final class BucketIterator implements Iterator<BlockState> {
@Override public boolean hasNext() { @Override public boolean hasNext() {
return true; return true;
} }
@Override public PlotBlock next() { @Override public BlockState next() {
return getBlock(); return getBlock();
} }
} }

View File

@ -2,12 +2,12 @@ package com.github.intellectualsites.plotsquared.plot.object;
public class BlockLoc { public class BlockLoc {
public final int x; private final int x;
public final int y; private final int y;
public final int z; private final int z;
public final float yaw; private final float yaw;
public final float pitch; private final float pitch;
public BlockLoc(int x, int y, int z, float yaw, float pitch) { public BlockLoc(int x, int y, int z, float yaw, float pitch) {
this.x = x; this.x = x;
@ -27,10 +27,6 @@ public class BlockLoc {
float yaw; float yaw;
float pitch; float pitch;
if (parts.length == 3) {
yaw = 0f;
pitch = 0f;
}
if (parts.length == 5) { if (parts.length == 5) {
yaw = Float.parseFloat(parts[3]); yaw = Float.parseFloat(parts[3]);
pitch = Float.parseFloat(parts[4]); pitch = Float.parseFloat(parts[4]);
@ -47,9 +43,9 @@ public class BlockLoc {
@Override public int hashCode() { @Override public int hashCode() {
int prime = 31; int prime = 31;
int result = 1; int result = 1;
result = prime * result + this.x; result = prime * result + this.getX();
result = prime * result + this.y; result = prime * result + this.getY();
result = prime * result + this.z; result = prime * result + this.getZ();
return result; return result;
} }
@ -58,20 +54,42 @@ public class BlockLoc {
return true; return true;
} }
if (obj == null) { if (obj == null) {
return this.x == 0 && this.y == 0 && this.z == 0; return this.getX() == 0 && this.getY() == 0 && this.getZ() == 0;
} }
if (getClass() != obj.getClass()) { if (getClass() != obj.getClass()) {
return false; return false;
} }
BlockLoc other = (BlockLoc) obj; BlockLoc other = (BlockLoc) obj;
return this.x == other.x && this.y == other.y && this.z == other.z; return this.getX() == other.getX() && this.getY() == other.getY() && this.getZ() == other
.getZ();
} }
@Override public String toString() { @Override public String toString() {
if (this.x == 0 && this.y == 0 && this.z == 0) { if (this.getX() == 0 && this.getY() == 0 && this.getZ() == 0) {
return ""; return "";
} }
return this.x + "," + this.y + ',' + this.z + ',' + this.yaw + ',' + this.pitch; return this.getX() + "," + this.getY() + ',' + this.getZ() + ',' + this.getYaw()
+ ',' + this.getPitch();
} }
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getZ() {
return z;
}
public float getYaw() {
return yaw;
}
public float getPitch() {
return pitch;
}
} }

View File

@ -1,34 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.object;
import lombok.Getter;
import lombok.NonNull;
import java.util.HashMap;
import java.util.Map;
public abstract class BlockRegistry<T> {
@Getter private final Class<T> type;
private final Map<PlotBlock, T> map = new HashMap<>();
public BlockRegistry(@NonNull final Class<T> type, final T... preInitializedItems) {
this.type = type;
for (final T preInitializedItem : preInitializedItems) {
this.addMapping(getPlotBlock(preInitializedItem), preInitializedItem);
}
}
public final void addMapping(@NonNull final PlotBlock plotBlock, @NonNull final T t) {
if (map.containsKey(plotBlock)) {
return;
}
this.map.put(plotBlock, t);
}
public abstract PlotBlock getPlotBlock(final T item);
public final T getItem(final PlotBlock plotBlock) {
return this.map.get(plotBlock);
}
}

View File

@ -1,50 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.object;
public class ChunkLoc {
public int x;
public int z;
public ChunkLoc(int x, int z) {
this.x = x;
this.z = z;
}
public static long getChunkLong(int x, int z) {
return (long) x & 0xffffffffL | ((long) z & 0xffffffffL) << 32;
}
public long toLong() {
return getChunkLong(this.x,this.z);
}
public static int getX(long chunkLong) {
return (int)(chunkLong & 0xffffffffL);
}
public static int getZ(long chunkLong) {
return (int)(chunkLong >>> 32 & 0xffffffffL);
}
@Override public int hashCode() {
return (x << 16) | (z & 0xFFFF);
}
@Override public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
ChunkLoc other = (ChunkLoc) obj;
return (this.x == other.x) && (this.z == other.z);
}
@Override public String toString() {
return this.x + "," + this.z;
}
}

View File

@ -5,6 +5,10 @@ import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode; import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather; import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.item.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.UUID; import java.util.UUID;
@ -17,9 +21,9 @@ public class ConsolePlayer extends PlotPlayer {
PlotArea area = PlotSquared.get().getFirstPlotArea(); PlotArea area = PlotSquared.get().getFirstPlotArea();
Location location; Location location;
if (area != null) { if (area != null) {
RegionWrapper region = area.getRegion(); CuboidRegion region = area.getRegion();
location = new Location(area.worldname, region.minX + region.maxX / 2, 0, location = new Location(area.worldname, region.getMinimumPoint().getX() + region.getMaximumPoint().getX() / 2, 0,
region.minZ + region.maxZ / 2); region.getMinimumPoint().getZ() + region.getMaximumPoint().getZ() / 2);
} else { } else {
location = new Location("world", 0, 0, 0); location = new Location("world", 0, 0, 0);
} }
@ -34,6 +38,10 @@ public class ConsolePlayer extends PlotPlayer {
return instance; return instance;
} }
@Override public Actor toActor() {
return PlotSquared.get().IMP.getConsole();
}
@Override public boolean canTeleport(@NotNull Location location) { @Override public boolean canTeleport(@NotNull Location location) {
return true; return true;
} }
@ -120,7 +128,7 @@ public class ConsolePlayer extends PlotPlayer {
@Override public void setFlight(boolean fly) { @Override public void setFlight(boolean fly) {
} }
@Override public void playMusic(@NotNull Location location, @NotNull PlotBlock id) { @Override public void playMusic(@NotNull Location location, @NotNull ItemType id) {
} }
@Override public void kick(String message) { @Override public void kick(String message) {

View File

@ -1,10 +1,12 @@
package com.github.intellectualsites.plotsquared.plot.object; package com.github.intellectualsites.plotsquared.plot.object;
import com.sk89q.worldedit.world.block.BlockState;
public abstract class LazyBlock { public abstract class LazyBlock {
public abstract StringPlotBlock getPlotBlock(); public abstract BlockState getBlockState();
public String getId() { public String getId() {
return getPlotBlock().getItemId(); return getBlockState().toString();
} }
} }

View File

@ -1,72 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.object;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import lombok.Getter;
import lombok.Setter;
public class LegacyPlotBlock extends PlotBlock {
public static final PlotBlock EVERYTHING = new LegacyPlotBlock((short) 0, (byte) 0);
public static final PlotBlock[] CACHE = new PlotBlock[65535];
static {
for (int i = 0; i < 65535; i++) {
short id = (short) (i >> 4);
byte data = (byte) (i & 15);
CACHE[i] = new LegacyPlotBlock(id, data);
}
}
@Setter private BaseBlock baseBlock = null;
@Getter public final short id;
@Getter public final byte data;
public LegacyPlotBlock(short id, byte data) {
this.id = id;
this.data = data;
}
@Override public Object getRawId() {
return this.id;
}
@Override public BaseBlock getBaseBlock() {
if (baseBlock == null) {
baseBlock = LegacyMapper.getInstance().getBlockFromLegacy(id, data).toBaseBlock();
}
return baseBlock;
}
@Override public boolean isAir() {
return this.id == 0;
}
@Override public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
LegacyPlotBlock other = (LegacyPlotBlock) obj;
return (this.id == other.id) && ((this.data == other.data) || (this.data == -1) || (
other.data == -1));
}
@Override public int hashCode() {
return this.id;
}
@Override public String toString() {
if (this.data == -1) {
return this.id + "";
}
return this.id + ":" + this.data;
}
}

View File

@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.object;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -26,10 +27,6 @@ public class Location implements Cloneable, Comparable<Location> {
this.blockVector3 = BlockVector3.at(x, y, z); this.blockVector3 = BlockVector3.at(x, y, z);
} }
public Location() {
this.world = "";
}
public Location(String world, int x, int y, int z) { public Location(String world, int x, int y, int z) {
this(world, x, y, z, 0f, 0f); this(world, x, y, z, 0f, 0f);
} }
@ -127,8 +124,8 @@ public class Location implements Cloneable, Comparable<Location> {
} }
} }
public ChunkLoc getChunkLoc() { public BlockVector2 getBlockVector2() {
return new ChunkLoc(this.x >> 4, this.z >> 4); return BlockVector2.at(this.x >> 4, this.z >> 4);
} }
public Location add(int x, int y, int z) { public Location add(int x, int y, int z) {

View File

@ -12,7 +12,17 @@ import com.github.intellectualsites.plotsquared.plot.generator.SquarePlotWorld;
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener; import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment; import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic; import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
@ -21,6 +31,9 @@ import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -30,8 +43,18 @@ import java.awt.geom.Rectangle2D;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -45,13 +68,13 @@ import java.util.stream.Collectors;
*/ */
public class Plot { public class Plot {
private static final int MAX_HEIGHT = 256; public static final int MAX_HEIGHT = 256;
/** /**
* @deprecated raw access is deprecated * @deprecated raw access is deprecated
*/ */
@Deprecated private static HashSet<Plot> connected_cache; @Deprecated private static Set<Plot> connected_cache;
private static HashSet<RegionWrapper> regions_cache; private static Set<CuboidRegion> regions_cache;
@NotNull private final PlotId id; @NotNull private final PlotId id;
@ -844,7 +867,7 @@ public class Plot {
return false; return false;
} }
} }
final HashSet<RegionWrapper> regions = this.getRegions(); final Set<CuboidRegion> regions = this.getRegions();
final Set<Plot> plots = this.getConnectedPlots(); final Set<Plot> plots = this.getConnectedPlots();
final ArrayDeque<Plot> queue = new ArrayDeque<>(plots); final ArrayDeque<Plot> queue = new ArrayDeque<>(plots);
if (isDelete) { if (isDelete) {
@ -856,8 +879,8 @@ public class Plot {
@Override public void run() { @Override public void run() {
if (queue.isEmpty()) { if (queue.isEmpty()) {
Runnable run = () -> { Runnable run = () -> {
for (RegionWrapper region : regions) { for (CuboidRegion region : regions) {
Location[] corners = region.getCorners(getWorldName()); Location[] corners = MainUtil.getCorners(getWorldName(), region);
ChunkManager.manager.clearAllEntities(corners[0], corners[1]); ChunkManager.manager.clearAllEntities(corners[0], corners[1]);
} }
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
@ -899,7 +922,7 @@ public class Plot {
* @param whenDone The task to run when finished, or null * @param whenDone The task to run when finished, or null
*/ */
public void setBiome(final String biome, final Runnable whenDone) { public void setBiome(final String biome, final Runnable whenDone) {
final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(this.getRegions()); final ArrayDeque<CuboidRegion> regions = new ArrayDeque<>(this.getRegions());
final int extendBiome; final int extendBiome;
if (area instanceof SquarePlotWorld) { if (area instanceof SquarePlotWorld) {
extendBiome = (((SquarePlotWorld) area).ROAD_WIDTH > 0) ? 1 : 0; extendBiome = (((SquarePlotWorld) area).ROAD_WIDTH > 0) ? 1 : 0;
@ -913,14 +936,14 @@ public class Plot {
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
} }
RegionWrapper region = regions.poll(); CuboidRegion region = regions.poll();
Location pos1 = new Location(getWorldName(), region.minX - extendBiome, region.minY, Location pos1 = new Location(getWorldName(), region.getMinimumPoint().getX() - extendBiome, region.getMinimumPoint().getY(),
region.minZ - extendBiome); region.getMinimumPoint().getZ() - extendBiome);
Location pos2 = new Location(getWorldName(), region.maxX + extendBiome, region.maxY, Location pos2 = new Location(getWorldName(), region.getMaximumPoint().getX() + extendBiome, region.getMaximumPoint().getY(),
region.maxZ + extendBiome); region.getMaximumPoint().getZ() + extendBiome);
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() { ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
@Override public void run(int[] value) { @Override public void run(int[] value) {
ChunkLoc loc = new ChunkLoc(value[0], value[1]); BlockVector2 loc = BlockVector2.at(value[0], value[1]);
ChunkManager.manager.loadChunk(getWorldName(), loc, false); ChunkManager.manager.loadChunk(getWorldName(), loc, false);
MainUtil.setBiome(getWorldName(), value[2], value[3], value[4], value[5], MainUtil.setBiome(getWorldName(), value[2], value[3], value[4], value[5],
biome); biome);
@ -1093,7 +1116,7 @@ public class Plot {
* Delete a plot (use null for the runnable if you don't need to be notified on completion) * Delete a plot (use null for the runnable if you don't need to be notified on completion)
* *
* @see PlotSquared#removePlot(Plot, boolean) * @see PlotSquared#removePlot(Plot, boolean)
* @see #clear(Runnable) to simply clear a plot * @see #clear(boolean, boolean, Runnable) to simply clear a plot
*/ */
public boolean deletePlot(final Runnable whenDone) { public boolean deletePlot(final Runnable whenDone) {
if (!this.hasOwner()) { if (!this.hasOwner()) {
@ -1233,9 +1256,9 @@ public class Plot {
} }
public Location getSide() { public Location getSide() {
RegionWrapper largest = getLargestRegion(); CuboidRegion largest = getLargestRegion();
int x = (largest.maxX >> 1) - (largest.minX >> 1) + largest.minX; int x = (largest.getMaximumPoint().getX() >> 1) - (largest.getMinimumPoint().getX() >> 1) + largest.getMinimumPoint().getX();
int z = largest.minZ - 1; int z = largest.getMinimumPoint().getZ() - 1;
PlotManager manager = getManager(); PlotManager manager = getManager();
int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), x, z) : 62; int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), x, z) : 62;
if (area.ALLOW_SIGNS && (y <= 0 || y >= 255)) { if (area.ALLOW_SIGNS && (y <= 0 || y >= 255)) {
@ -1251,17 +1274,18 @@ public class Plot {
*/ */
public Location getHome() { public Location getHome() {
BlockLoc home = this.getPosition(); BlockLoc home = this.getPosition();
if (home == null || home.x == 0 && home.z == 0) { if (home == null || home.getX() == 0 && home.getZ() == 0) {
return this.getDefaultHome(true); return this.getDefaultHome(true);
} else { } else {
Location bottom = this.getBottomAbs(); Location bottom = this.getBottomAbs();
Location location = Location location =
new Location(bottom.getWorld(), bottom.getX() + home.x, bottom.getY() + home.y, new Location(bottom.getWorld(), bottom.getX() + home.getX(), bottom.getY() + home
bottom.getZ() + home.z, home.yaw, home.pitch); .getY(),
bottom.getZ() + home.getZ(), home.getYaw(), home.getPitch());
if (!isLoaded()) { if (!isLoaded()) {
return location; return location;
} }
if (!WorldUtil.IMP.getBlock(location).isAir()) { if (!WorldUtil.IMP.getBlock(location).getBlockType().getMaterial().isAir()) {
location.setY(Math.max(1 + WorldUtil.IMP location.setY(Math.max(1 + WorldUtil.IMP
.getHighestBlock(this.getWorldName(), location.getX(), location.getZ()), .getHighestBlock(this.getWorldName(), location.getX(), location.getZ()),
bottom.getY())); bottom.getY()));
@ -1306,9 +1330,9 @@ public class Plot {
int z; int z;
if (loc.getX() == Integer.MAX_VALUE && loc.getZ() == Integer.MAX_VALUE) { if (loc.getX() == Integer.MAX_VALUE && loc.getZ() == Integer.MAX_VALUE) {
// center // center
RegionWrapper largest = plot.getLargestRegion(); CuboidRegion largest = plot.getLargestRegion();
x = (largest.maxX >> 1) - (largest.minX >> 1) + largest.minX; x = (largest.getMaximumPoint().getX() >> 1) - (largest.getMinimumPoint().getX() >> 1) + largest.getMinimumPoint().getX();
z = (largest.maxZ >> 1) - (largest.minZ >> 1) + largest.minZ; z = (largest.getMaximumPoint().getZ() >> 1) - (largest.getMinimumPoint().getZ() >> 1) + largest.getMinimumPoint().getZ();
} else { } else {
// specific // specific
Location bot = plot.getBottomAbs(); Location bot = plot.getBottomAbs();
@ -1326,9 +1350,9 @@ public class Plot {
public double getVolume() { public double getVolume() {
double count = 0; double count = 0;
for (RegionWrapper region : getRegions()) { for (CuboidRegion region : getRegions()) {
count += count +=
(region.maxX - (double) region.minX + 1) * (region.maxZ - (double) region.minZ + 1) (region.getMaximumPoint().getX() - (double) region.getMinimumPoint().getX() + 1) * (region.getMaximumPoint().getZ() - (double) region.getMinimumPoint().getZ() + 1)
* MAX_HEIGHT; * MAX_HEIGHT;
} }
return count; return count;
@ -1413,11 +1437,11 @@ public class Plot {
*/ */
public void refreshChunks() { public void refreshChunks() {
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false); LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false);
HashSet<ChunkLoc> chunks = new HashSet<>(); HashSet<BlockVector2> chunks = new HashSet<>();
for (RegionWrapper region : Plot.this.getRegions()) { for (CuboidRegion region : Plot.this.getRegions()) {
for (int x = region.minX >> 4; x <= region.maxX >> 4; x++) { for (int x = region.getMinimumPoint().getX() >> 4; x <= region.getMaximumPoint().getX() >> 4; x++) {
for (int z = region.minZ >> 4; z <= region.maxZ >> 4; z++) { for (int z = region.getMinimumPoint().getZ() >> 4; z <= region.getMaximumPoint().getZ() >> 4; z++) {
if (chunks.add(new ChunkLoc(x, z))) { if (chunks.add(BlockVector2.at(x, z))) {
queue.refreshChunk(x, z); queue.refreshChunk(x, z);
} }
} }
@ -1435,7 +1459,7 @@ public class Plot {
} }
Location location = manager.getSignLoc(this); Location location = manager.getSignLoc(this);
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false); LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false);
queue.setBlock(location.getX(), location.getY(), location.getZ(), PlotBlock.get("air")); queue.setBlock(location.getX(), location.getY(), location.getZ(), BlockUtil.get("air"));
queue.flush(); queue.flush();
} }
@ -2142,7 +2166,7 @@ public class Plot {
String[] lines = TaskManager.IMP.sync(new RunnableVal<String[]>() { String[] lines = TaskManager.IMP.sync(new RunnableVal<String[]>() {
@Override public void run(String[] value) { @Override public void run(String[] value) {
ChunkManager.manager ChunkManager.manager
.loadChunk(location.getWorld(), location.getChunkLoc(), false); .loadChunk(location.getWorld(), location.getBlockVector2(), false);
this.value = WorldUtil.IMP.getSign(location); this.value = WorldUtil.IMP.getSign(location);
} }
}); });
@ -2571,7 +2595,7 @@ public class Plot {
* *
* @return * @return
*/ */
@NotNull public HashSet<RegionWrapper> getRegions() { @NotNull public Set<CuboidRegion> getRegions() {
if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) { if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) {
return regions_cache; return regions_cache;
} }
@ -2579,14 +2603,13 @@ public class Plot {
Location pos1 = this.getBottomAbs(); Location pos1 = this.getBottomAbs();
Location pos2 = this.getTopAbs(); Location pos2 = this.getTopAbs();
connected_cache = Sets.newHashSet(this); connected_cache = Sets.newHashSet(this);
regions_cache = Sets.newHashSet( CuboidRegion rg = new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3());
new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(), regions_cache = Collections.singleton(rg);
pos2.getZ()));
return regions_cache; return regions_cache;
} }
Set<Plot> plots = this.getConnectedPlots(); Set<Plot> plots = this.getConnectedPlots();
HashSet<RegionWrapper> regions = regions_cache = new HashSet<>(); Set<CuboidRegion> regions = regions_cache = new HashSet<>();
HashSet<PlotId> visited = new HashSet<>(); Set<PlotId> visited = new HashSet<>();
for (Plot current : plots) { for (Plot current : plots) {
if (visited.contains(current.getId())) { if (visited.contains(current.getId())) {
continue; continue;
@ -2663,12 +2686,14 @@ public class Plot {
Location toploc = plot.getExtendedTopAbs(); Location toploc = plot.getExtendedTopAbs();
Location botabs = plot.getBottomAbs(); Location botabs = plot.getBottomAbs();
Location topabs = plot.getTopAbs(); Location topabs = plot.getTopAbs();
regions.add(new RegionWrapper(botabs.getX(), topabs.getX(), topabs.getZ() + 1, BlockVector3 pos1 = BlockVector3.at(botabs.getX(), 0, topabs.getZ() + 1);
toploc.getZ())); BlockVector3 pos2 = BlockVector3.at(topabs.getX(), Plot.MAX_HEIGHT - 1, toploc.getZ());
regions.add(new CuboidRegion(pos1, pos2));
if (plot.getMerged(Direction.SOUTHEAST)) { if (plot.getMerged(Direction.SOUTHEAST)) {
pos1 = BlockVector3.at(topabs.getX() + 1, 0, topabs.getZ() + 1);
pos2 = BlockVector3.at(toploc.getX(), Plot.MAX_HEIGHT - 1, toploc.getZ());
regions.add( regions.add(
new RegionWrapper(topabs.getX() + 1, toploc.getX(), topabs.getZ() + 1, new CuboidRegion(pos1, pos2));
toploc.getZ()));
// intersection // intersection
} }
} }
@ -2681,18 +2706,22 @@ public class Plot {
Location toploc = plot.getExtendedTopAbs(); Location toploc = plot.getExtendedTopAbs();
Location botabs = plot.getBottomAbs(); Location botabs = plot.getBottomAbs();
Location topabs = plot.getTopAbs(); Location topabs = plot.getTopAbs();
regions.add(new RegionWrapper(topabs.getX() + 1, toploc.getX(), botabs.getZ(), BlockVector3 pos1 = BlockVector3.at(topabs.getX() + 1, 0, botabs.getZ());
topabs.getZ())); BlockVector3 pos2 = BlockVector3.at(toploc.getX(), Plot.MAX_HEIGHT - 1, topabs.getZ());
regions.add(new CuboidRegion(pos1, pos2));
if (plot.getMerged(Direction.SOUTHEAST)) { if (plot.getMerged(Direction.SOUTHEAST)) {
pos1 = BlockVector3.at(topabs.getX() + 1, 0, topabs.getZ() + 1);
pos2 = BlockVector3.at(toploc.getX(), Plot.MAX_HEIGHT - 1, toploc.getZ());
regions.add( regions.add(
new RegionWrapper(topabs.getX() + 1, toploc.getX(), topabs.getZ() + 1, new CuboidRegion(pos1, pos2));
toploc.getZ()));
// intersection // intersection
} }
} }
} }
BlockVector3 pos1 = BlockVector3.at(gbotabs.getX() + 1, 0, gbotabs.getZ());
BlockVector3 pos2 = BlockVector3.at(gtopabs.getX(), Plot.MAX_HEIGHT - 1, gtopabs.getZ());
regions.add( regions.add(
new RegionWrapper(gbotabs.getX(), gtopabs.getX(), gbotabs.getZ(), gtopabs.getZ())); new CuboidRegion(pos1, pos2));
} }
return regions; return regions;
} }
@ -2702,13 +2731,13 @@ public class Plot {
* *
* @return * @return
*/ */
public RegionWrapper getLargestRegion() { public CuboidRegion getLargestRegion() {
HashSet<RegionWrapper> regions = this.getRegions(); Set<CuboidRegion> regions = this.getRegions();
RegionWrapper max = null; CuboidRegion max = null;
double area = Double.NEGATIVE_INFINITY; double area = Double.NEGATIVE_INFINITY;
for (RegionWrapper region : regions) { for (CuboidRegion region : regions) {
double current = double current =
(region.maxX - (double) region.minX + 1) * (region.maxZ - (double) region.minZ + 1); (region.getMaximumPoint().getX() - (double) region.getMinimumPoint().getX() + 1) * (region.getMaximumPoint().getZ() - (double) region.getMinimumPoint().getZ() + 1);
if (current > area) { if (current > area) {
max = region; max = region;
area = current; area = current;
@ -2737,9 +2766,9 @@ public class Plot {
*/ */
public List<Location> getAllCorners() { public List<Location> getAllCorners() {
Area area = new Area(); Area area = new Area();
for (RegionWrapper region : this.getRegions()) { for (CuboidRegion region : this.getRegions()) {
Rectangle2D rect = new Rectangle2D.Double(region.minX - 0.6, region.minZ - 0.6, Rectangle2D rect = new Rectangle2D.Double(region.getMinimumPoint().getX() - 0.6, region.getMinimumPoint().getZ() - 0.6,
region.maxX - region.minX + 1.2, region.maxZ - region.minZ + 1.2); region.getMaximumPoint().getX() - region.getMinimumPoint().getX() + 1.2, region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + 1.2);
Area rectArea = new Area(rect); Area rectArea = new Area(rect);
area.add(rectArea); area.add(rectArea);
} }
@ -2954,7 +2983,7 @@ public class Plot {
} }
// world border // world border
destination.updateWorldBorder(); destination.updateWorldBorder();
final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(this.getRegions()); final ArrayDeque<CuboidRegion> regions = new ArrayDeque<>(this.getRegions());
// move / swap data // move / swap data
final PlotArea originArea = getArea(); final PlotArea originArea = getArea();
for (Plot plot : plots) { for (Plot plot : plots) {
@ -2969,8 +2998,8 @@ public class Plot {
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
} }
RegionWrapper region = regions.poll(); CuboidRegion region = regions.poll();
Location[] corners = region.getCorners(getWorldName()); Location[] corners = MainUtil.getCorners(getWorldName(), region);
Location pos1 = corners[0]; Location pos1 = corners[0];
Location pos2 = corners[1]; Location pos2 = corners[1];
Location pos3 = pos1.clone().add(offsetX, 0, offsetZ); Location pos3 = pos1.clone().add(offsetX, 0, offsetZ);
@ -2997,8 +3026,8 @@ public class Plot {
return; return;
} }
final Runnable task = this; final Runnable task = this;
RegionWrapper region = regions.poll(); CuboidRegion region = regions.poll();
Location[] corners = region.getCorners(getWorldName()); Location[] corners = MainUtil.getCorners(getWorldName(), region);
final Location pos1 = corners[0]; final Location pos1 = corners[0];
final Location pos2 = corners[1]; final Location pos2 = corners[1];
Location newPos = pos1.clone().add(offsetX, 0, offsetZ); Location newPos = pos1.clone().add(offsetX, 0, offsetZ);
@ -3071,7 +3100,7 @@ public class Plot {
} }
} }
// copy terrain // copy terrain
final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(this.getRegions()); final ArrayDeque<CuboidRegion> regions = new ArrayDeque<>(this.getRegions());
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override public void run() { @Override public void run() {
if (regions.isEmpty()) { if (regions.isEmpty()) {
@ -3082,8 +3111,8 @@ public class Plot {
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
} }
RegionWrapper region = regions.poll(); CuboidRegion region = regions.poll();
Location[] corners = region.getCorners(getWorldName()); Location[] corners = MainUtil.getCorners(getWorldName(), region);
Location pos1 = corners[0]; Location pos1 = corners[0];
Location pos2 = corners[1]; Location pos2 = corners[1];
Location newPos = pos1.clone().add(offsetX, 0, offsetZ); Location newPos = pos1.clone().add(offsetX, 0, offsetZ);

View File

@ -19,13 +19,25 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap; import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.*; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -71,7 +83,7 @@ public abstract class PlotArea {
public int MIN_BUILD_HEIGHT = 1; public int MIN_BUILD_HEIGHT = 1;
public PlotGameMode GAMEMODE = PlotGameMode.CREATIVE; public PlotGameMode GAMEMODE = PlotGameMode.CREATIVE;
private int hash; private int hash;
private RegionWrapper region; private CuboidRegion region;
private ConcurrentHashMap<String, Object> meta; private ConcurrentHashMap<String, Object> meta;
private QuadMap<PlotCluster> clusters; private QuadMap<PlotCluster> clusters;
@ -120,16 +132,16 @@ public abstract class PlotArea {
} }
/** /**
* Returns the region for this PlotArea or a RegionWrapper encompassing * Returns the region for this PlotArea or a CuboidRegion encompassing
* the whole world if none exists. * the whole world if none exists.
* *
* @return RegionWrapper * @return CuboidRegion
*/ */
public RegionWrapper getRegion() { public CuboidRegion getRegion() {
this.region = getRegionAbs(); this.region = getRegionAbs();
if (this.region == null) { if (this.region == null) {
return new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, return new CuboidRegion(BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE),
Integer.MAX_VALUE); BlockVector3.at(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE));
} }
return this.region; return this.region;
} }
@ -137,15 +149,16 @@ public abstract class PlotArea {
/** /**
* Returns the region for this PlotArea. * Returns the region for this PlotArea.
* *
* @return RegionWrapper or null if no applicable region * @return CuboidRegion or null if no applicable region
*/ */
private RegionWrapper getRegionAbs() { private CuboidRegion getRegionAbs() {
if (this.region == null) { if (this.region == null) {
if (this.min != null) { if (this.min != null) {
Location bot = getPlotManager().getPlotBottomLocAbs(this.min); Location bot = getPlotManager().getPlotBottomLocAbs(this.min);
Location top = getPlotManager().getPlotTopLocAbs(this.max); Location top = getPlotManager().getPlotTopLocAbs(this.max);
this.region = new RegionWrapper(bot.getX() - 1, top.getX() + 1, bot.getZ() - 1, BlockVector3 pos1 = bot.getBlockVector3().subtract(BlockVector3.ONE);
top.getZ() + 1); BlockVector3 pos2 = top.getBlockVector3().add(BlockVector3.ONE);
this.region = new CuboidRegion(pos1, pos2);
} }
} }
return this.region; return this.region;
@ -489,7 +502,7 @@ public abstract class PlotArea {
} }
public boolean contains(final int x, final int z) { public boolean contains(final int x, final int z) {
return this.TYPE != 2 || getRegionAbs().isIn(x, z); return this.TYPE != 2 || RegionUtil.contains(getRegionAbs(), x, z);
} }
public boolean contains(@NotNull final PlotId id) { public boolean contains(@NotNull final PlotId id) {
@ -499,7 +512,7 @@ public abstract class PlotArea {
public boolean contains(@NotNull final Location location) { public boolean contains(@NotNull final Location location) {
return StringMan.isEqual(location.getWorld(), this.worldname) && (getRegionAbs() == null return StringMan.isEqual(location.getWorld(), this.worldname) && (getRegionAbs() == null
|| this.region.isIn(location.getX(), location.getZ())); || this.region.contains(location.getBlockVector3()));
} }
@NotNull Set<Plot> getPlotsAbs(final UUID uuid) { @NotNull Set<Plot> getPlotsAbs(final UUID uuid) {
@ -932,9 +945,10 @@ public abstract class PlotArea {
public void addCluster(@Nullable final PlotCluster plotCluster) { public void addCluster(@Nullable final PlotCluster plotCluster) {
if (this.clusters == null) { if (this.clusters == null) {
this.clusters = new QuadMap<PlotCluster>(Integer.MAX_VALUE, 0, 0, 62) { this.clusters = new QuadMap<PlotCluster>(Integer.MAX_VALUE, 0, 0, 62) {
@Override public RegionWrapper getRegion(PlotCluster value) { @Override public CuboidRegion getRegion(PlotCluster value) {
return new RegionWrapper(value.getP1().x, value.getP2().x, value.getP1().y, BlockVector2 pos1 = BlockVector2.at(value.getP1().x, value.getP1().y);
value.getP2().y); BlockVector2 pos2 = BlockVector2.at(value.getP2().x, value.getP2().y);
return new CuboidRegion(pos1.toBlockVector3(), pos2.toBlockVector3(Plot.MAX_HEIGHT - 1));
} }
}; };
} }

View File

@ -1,138 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.object;
import com.github.intellectualsites.plotsquared.configuration.serialization.ConfigurationSerializable;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.google.common.collect.ImmutableMap;
import com.sk89q.worldedit.world.block.BaseBlock;
import lombok.NonNull;
import java.util.Collection;
import java.util.Map;
public abstract class PlotBlock implements ConfigurationSerializable {
private static Class<?> conversionType;
private static BlockRegistry blockRegistry;
protected PlotBlock() {
}
public static boolean isEverything(@NonNull final PlotBlock block) {
return block.equals(LegacyPlotBlock.EVERYTHING) || block.equals(StringPlotBlock.EVERYTHING);
}
public static boolean containsEverything(@NonNull final Collection<PlotBlock> blocks) {
for (final PlotBlock block : blocks) {
if (isEverything(block)) {
return true;
}
}
return false;
}
public static PlotBlock get(char combinedId) {
switch (combinedId) {
case 0:
return null;
case 1:
return get(0, 0);
default:
return get(combinedId >> 4, combinedId & 15);
}
}
public static PlotBlock deserialize(@NonNull final Map<String, Object> map) {
if (map.containsKey("material")) {
final Object object = map.get("material");
return get(object.toString());
}
return null;
}
public static StringPlotBlock get(@NonNull final String itemId) {
if (Settings.Enabled_Components.BLOCK_CACHE) {
return StringPlotBlock.getOrAdd(itemId);
}
return new StringPlotBlock(itemId);
}
public static PlotBlock get(int id, int data) {
return Settings.Enabled_Components.BLOCK_CACHE && data > 0 ?
LegacyPlotBlock.CACHE[(id << 4) + data] :
new LegacyPlotBlock((short) id, (byte) data);
}
public static PlotBlock getEmptyData(@NonNull final PlotBlock plotBlock) {
if (plotBlock instanceof StringPlotBlock) {
return plotBlock;
}
return get(((LegacyPlotBlock) plotBlock).getId(), (byte) 0);
}
public static PlotBlock get(@NonNull final BaseBlock baseBlock) {
StringPlotBlock plotBlock = get(baseBlock.getBlockType().getId());
plotBlock.setBaseBlock(baseBlock);
return plotBlock;
}
public static PlotBlock get(@NonNull final Object type) {
if (blockRegistry == null) {
blockRegistry = PlotSquared.imp().getBlockRegistry();
if (blockRegistry == null) {
throw new UnsupportedOperationException(
"The PlotSquared implementation has not registered a custom block registry."
+ " This method can't be used.");
}
conversionType = blockRegistry.getType();
}
if (!type.getClass().equals(conversionType)) {
throw new UnsupportedOperationException(
"The PlotSquared implementation has not registered a block registry for this object type");
}
return blockRegistry.getPlotBlock(type);
}
@Override public Map<String, Object> serialize() {
return ImmutableMap.of("material", this.getRawId());
}
public <T> T to(@NonNull final Class<T> clazz) {
if (blockRegistry == null) {
blockRegistry = PlotSquared.imp().getBlockRegistry();
if (blockRegistry == null) {
throw new UnsupportedOperationException(
"The PlotSquared implementation has not registered a custom block registry."
+ " This method can't be used.");
}
conversionType = blockRegistry.getType();
}
if (!clazz.equals(conversionType)) {
throw new UnsupportedOperationException(
"The PlotSquared implementation has not registered a block registry for this object type");
}
return clazz.cast(blockRegistry.getItem(this));
}
public abstract boolean isAir();
public final boolean equalsAny(final int id, @NonNull final String stringId) {
if (this instanceof StringPlotBlock) {
final StringPlotBlock stringPlotBlock = (StringPlotBlock) this;
return stringPlotBlock.idEquals(stringId);
}
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) this;
return legacyPlotBlock.id == id;
}
@Override public abstract boolean equals(Object obj);
@Override public abstract int hashCode();
@Override public abstract String toString();
public abstract Object getRawId();
public abstract BaseBlock getBaseBlock();
}

View File

@ -2,6 +2,8 @@ package com.github.intellectualsites.plotsquared.plot.object;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
import java.util.HashSet; import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
@ -15,7 +17,7 @@ public class PlotCluster {
public int temp; public int temp;
private PlotId pos1; private PlotId pos1;
private PlotId pos2; private PlotId pos2;
private RegionWrapper region; private CuboidRegion region;
public PlotCluster(PlotArea area, PlotId pos1, PlotId pos2, UUID owner) { public PlotCluster(PlotArea area, PlotId pos1, PlotId pos2, UUID owner) {
this.area = area; this.area = area;
@ -56,10 +58,10 @@ public class PlotCluster {
} }
private void setRegion() { private void setRegion() {
this.region = new RegionWrapper(this.pos1.x, this.pos2.x, this.pos1.y, this.pos2.y); this.region = RegionUtil.createRegion(this.pos1.x, this.pos2.x, this.pos1.y, this.pos2.y);
} }
public RegionWrapper getRegion() { public CuboidRegion getRegion() {
return this.region; return this.region;
} }
@ -126,7 +128,7 @@ public class PlotCluster {
public Location getHome() { public Location getHome() {
BlockLoc home = this.settings.getPosition(); BlockLoc home = this.settings.getPosition();
Location toReturn; Location toReturn;
if (home.y == 0) { if (home.getY() == 0) {
// default pos // default pos
Plot center = getCenterPlot(); Plot center = getCenterPlot();
toReturn = center.getHome(); toReturn = center.getHome();
@ -136,7 +138,7 @@ public class PlotCluster {
toReturn.setY(location.getY()); toReturn.setY(location.getY());
} }
} else { } else {
toReturn = getClusterBottom().add(home.x, home.y, home.z); toReturn = getClusterBottom().add(home.getX(), home.getY(), home.getZ());
} }
int max = MainUtil.getHeighestBlock(this.area.worldname, toReturn.getX(), toReturn.getZ()); int max = MainUtil.getHeighestBlock(this.area.worldname, toReturn.getX(), toReturn.getZ());
if (max > toReturn.getY()) { if (max > toReturn.getY()) {

View File

@ -25,6 +25,14 @@ public class PlotId {
this.y = y; this.y = y;
} }
public int getX() {
return x;
}
public int getY() {
return y;
}
/** /**
* Get a Plot Id based on a string * Get a Plot Id based on a string
* *
@ -40,7 +48,7 @@ public class PlotId {
} }
@Nullable public static PlotId fromStringOrNull(@NotNull String string) { @Nullable public static PlotId fromStringOrNull(@NotNull String string) {
String[] parts = string.split("[;|,]"); String[] parts = string.split("[;,.]");
if (parts.length < 2) { if (parts.length < 2) {
return null; return null;
} }

View File

@ -1,7 +1,9 @@
package com.github.intellectualsites.plotsquared.plot.object; package com.github.intellectualsites.plotsquared.plot.object;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison; import com.sk89q.worldedit.world.block.BlockState;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import lombok.Getter; import lombok.Getter;
public class PlotItemStack { public class PlotItemStack {
@ -9,7 +11,7 @@ public class PlotItemStack {
public final int amount; public final int amount;
public final String name; public final String name;
public final String[] lore; public final String[] lore;
@Getter private final PlotBlock plotBlock; @Getter private final ItemType type;
/** /**
* @param id Legacy numerical item ID * @param id Legacy numerical item ID
@ -21,10 +23,11 @@ public class PlotItemStack {
*/ */
@Deprecated public PlotItemStack(final int id, final short data, final int amount, @Deprecated public PlotItemStack(final int id, final short data, final int amount,
final String name, final String... lore) { final String name, final String... lore) {
this.amount = amount; this.amount = amount;
this.name = name; this.name = name;
this.lore = lore; this.lore = lore;
this.plotBlock = PlotBlock.get(id, data); this.type = LegacyMapper.getInstance().getItemFromLegacy(id, data);
} }
/** /**
@ -35,10 +38,13 @@ public class PlotItemStack {
*/ */
public PlotItemStack(final String id, final int amount, final String name, public PlotItemStack(final String id, final int amount, final String name,
final String... lore) { final String... lore) {
StringComparison<PlotBlock>.ComparisonResult match = WorldUtil.IMP.getClosestBlock(id); this.type = ItemTypes.get(id);
this.plotBlock = match.best;
this.amount = amount; this.amount = amount;
this.name = name; this.name = name;
this.lore = lore; this.lore = lore;
} }
public BlockState getBlockState() {
return type.getBlockType().getDefaultState();
}
} }

View File

@ -90,6 +90,21 @@ public abstract class PlotManager {
return 255; return 255;
} }
public abstract boolean regenerateAllPlotWalls(); /**
* Sets all the blocks along all the plot walls to their correct state (claimed or unclaimed).
*
* @return true if the wall blocks were successfully set
*/
public boolean regenerateAllPlotWalls() {
boolean success = true;
for (Plot plot : plotArea.getPlots()) {
if (plot.hasOwner()) {
success &= claimPlot(plot);
} else {
success &= unClaimPlot(plot, null);
}
}
return success;
}
} }

View File

@ -10,9 +10,17 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager; import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea; import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager; import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.world.item.ItemType;
import lombok.NonNull; import lombok.NonNull;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -79,6 +87,8 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
return UUIDHandler.getPlayer(name); return UUIDHandler.getPlayer(name);
} }
public abstract Actor toActor();
/** /**
* Set some session only metadata for this player. * Set some session only metadata for this player.
* *
@ -464,7 +474,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
* @param location where to play the music * @param location where to play the music
* @param id the record item id * @param id the record item id
*/ */
public abstract void playMusic(@NotNull Location location, @NotNull PlotBlock id); public abstract void playMusic(@NotNull Location location, @NotNull ItemType id);
/** /**
* Check if this player is banned. * Check if this player is banned.

Some files were not shown because too many files have changed in this diff Show More