mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-10-31 09:33:43 +01:00 
			
		
		
		
	Merge pull request #2560 from IntellectualSites/we
"Use WorldEdit classes" because actually descriptive commitmessages are dumb, right?
This commit is contained in:
		| @@ -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.SingleWorldListener; | ||||
| 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.uuid.DefaultUUIDWrapper; | ||||
| 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.HybridUtils; | ||||
| 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.PlotArea; | ||||
| 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.SinglePlotAreaManager; | ||||
| 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.uuid.UUIDWrapper; | ||||
| 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 lombok.Getter; | ||||
| 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.entity.Entity; | ||||
| 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; | ||||
|     @Getter private String pluginName; | ||||
|     @Getter private SingleWorldListener singleWorldListener; | ||||
| @@ -796,12 +829,9 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain | ||||
|         return names; | ||||
|     } | ||||
|  | ||||
|     @Override public BlockRegistry<Material> getBlockRegistry() { | ||||
|         return this.blockRegistry; | ||||
|     @Override public Actor getConsole() { | ||||
|         @NotNull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); | ||||
|         WorldEditPlugin wePlugin = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")); | ||||
|         return wePlugin.wrapCommandSender(console); | ||||
|     } | ||||
|  | ||||
|     @Override public LegacyMappings getLegacyMappings() { | ||||
|         return this.legacyMappings; | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -19,8 +19,18 @@ import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.io.StringWriter; | ||||
| import java.lang.reflect.*; | ||||
| import java.util.*; | ||||
| 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.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; | ||||
|  | ||||
| /** | ||||
|   | ||||
| @@ -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.PlotPlayer; | ||||
| 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.google.common.collect.Sets; | ||||
|  | ||||
| @@ -24,8 +28,12 @@ import java.io.File; | ||||
| import java.io.IOException; | ||||
| import java.nio.charset.StandardCharsets; | ||||
| 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.UUID; | ||||
|  | ||||
| @CommandDeclaration(command = "uuidconvert", permission = "plots.admin", | ||||
|     description = "Debug UUID conversion", usage = "/plot uuidconvert <lower|offline|online>", | ||||
|   | ||||
| @@ -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.generator.GeneratorWrapper; | ||||
| 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.PlotArea; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.worlds.SingleWorldGenerator; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.MainUtil; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; | ||||
| import com.sk89q.worldedit.math.BlockVector2; | ||||
| import org.bukkit.World; | ||||
| import org.bukkit.block.Biome; | ||||
| import org.bukkit.generator.BlockPopulator; | ||||
| @@ -41,7 +41,7 @@ public class BukkitPlotGenerator extends ChunkGenerator | ||||
|         this.plotGenerator = generator; | ||||
|         this.platformGenerator = this; | ||||
|         this.populators = new ArrayList<>(); | ||||
|         this.populators.add(new PlotBlockPopulator(this.plotGenerator)); | ||||
|         this.populators.add(new BlockStatePopulator(this.plotGenerator)); | ||||
|         this.full = true; | ||||
|         MainUtil.initCache(); | ||||
|     } | ||||
| @@ -145,7 +145,7 @@ public class BukkitPlotGenerator extends ChunkGenerator | ||||
|             if (this.platformGenerator != this) { | ||||
|                 return this.platformGenerator.generateChunkData(world, random, x, z, biome); | ||||
|             } else { | ||||
|                 generate(new ChunkLoc(x, z), world, result); | ||||
|                 generate(BlockVector2.at(x, z), world, result); | ||||
|             } | ||||
|         } catch (Throwable e) { | ||||
|             e.printStackTrace(); | ||||
| @@ -154,7 +154,7 @@ public class BukkitPlotGenerator extends ChunkGenerator | ||||
|         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 | ||||
|         if (!this.loaded) { | ||||
|             String name = world.getName(); | ||||
|   | ||||
| @@ -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.Location; | ||||
| 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.PlotManager; | ||||
| 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 lombok.RequiredArgsConstructor; | ||||
| import org.bukkit.World; | ||||
| @@ -46,7 +45,7 @@ import java.util.Random; | ||||
|             for (short x = 0; x < 16; x++) { | ||||
|                 for (short z = 0; z < 16; z++) { | ||||
|                     blockBuckets[0][(z << 4) | x] = | ||||
|                         BlockBucket.withSingle(PlotBlock.get("bedrock")); | ||||
|                         BlockBucket.withSingle(BlockUtil.get("bedrock")); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull; | ||||
|  | ||||
| import java.util.Random; | ||||
|  | ||||
| @RequiredArgsConstructor final class PlotBlockPopulator extends BlockPopulator { | ||||
| @RequiredArgsConstructor final class BlockStatePopulator extends BlockPopulator { | ||||
|  | ||||
|     private final IndependentPlotGenerator plotGenerator; | ||||
|     private LocalBlockQueue queue; | ||||
|   | ||||
| @@ -1,7 +1,6 @@ | ||||
| package com.github.intellectualsites.plotsquared.bukkit.listeners; | ||||
|  | ||||
| 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.object.Location; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.Plot; | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| package com.github.intellectualsites.plotsquared.bukkit.listeners; | ||||
|  | ||||
| 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.util.BukkitUtil; | ||||
| 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.listener.PlayerBlockEventType; | ||||
| import com.github.intellectualsites.plotsquared.plot.listener.PlotListener; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.*; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.*; | ||||
| 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.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 org.bukkit.Bukkit; | ||||
| import org.bukkit.ChatColor; | ||||
| @@ -20,21 +39,83 @@ import org.bukkit.Material; | ||||
| import org.bukkit.World; | ||||
| import org.bukkit.block.Block; | ||||
| import org.bukkit.block.BlockFace; | ||||
| import org.bukkit.block.BlockState; | ||||
| import org.bukkit.block.data.BlockData; | ||||
| 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.EventHandler; | ||||
| import org.bukkit.event.EventPriority; | ||||
| import org.bukkit.event.Listener; | ||||
| import org.bukkit.event.block.*; | ||||
| import org.bukkit.event.entity.*; | ||||
| import org.bukkit.event.block.Action; | ||||
| 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.HangingPlaceEvent; | ||||
| import org.bukkit.event.inventory.InventoryClickEvent; | ||||
| 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.VehicleDestroyEvent; | ||||
| import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; | ||||
| @@ -53,8 +134,16 @@ import org.bukkit.projectiles.ProjectileSource; | ||||
| import org.bukkit.util.Vector; | ||||
|  | ||||
| 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.Objects; | ||||
| import java.util.Optional; | ||||
| import java.util.Set; | ||||
| import java.util.UUID; | ||||
| import java.util.function.Supplier; | ||||
| import java.util.regex.Pattern; | ||||
|  | ||||
| /** | ||||
| @@ -1016,10 +1105,10 @@ import java.util.regex.Pattern; | ||||
|                 return; | ||||
|             } | ||||
|             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(); | ||||
|                 if (destroy.isPresent() && destroy.get() | ||||
|                     .contains(PlotBlock.get(block.getType().name()))) { | ||||
|                     .contains(BukkitAdapter.asBlockType(block.getType()))) { | ||||
|                     return; | ||||
|                 } | ||||
|                 if (Permissions | ||||
| @@ -1301,10 +1390,10 @@ import java.util.regex.Pattern; | ||||
|             } | ||||
|             PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); | ||||
|             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(); | ||||
|                 if (destroy.isPresent() && destroy.get() | ||||
|                     .contains(PlotBlock.get(block.getType().name())) || Permissions | ||||
|                     .contains(BukkitBlockUtil.get(block)) || Permissions | ||||
|                     .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) { | ||||
|                     return; | ||||
|                 } | ||||
| @@ -1536,7 +1625,7 @@ import java.util.regex.Pattern; | ||||
|         if (!PlotSquared.get().hasPlotArea(event.getWorld().getName())) { | ||||
|             return; | ||||
|         } | ||||
|         List<BlockState> blocks = event.getBlocks(); | ||||
|         List<org.bukkit.block.BlockState> blocks = event.getBlocks(); | ||||
|         if (blocks.isEmpty()) { | ||||
|             return; | ||||
|         } | ||||
| @@ -1650,7 +1739,7 @@ import java.util.regex.Pattern; | ||||
|             } | ||||
|         } | ||||
|         Block block = player.getTargetBlock(null, 7); | ||||
|         BlockState state = block.getState(); | ||||
|         org.bukkit.block.BlockState state = block.getState(); | ||||
|         if (state == null) { | ||||
|             return; | ||||
|         } | ||||
| @@ -1829,9 +1918,10 @@ import java.util.regex.Pattern; | ||||
|                 Block block = player.getTargetBlockExact(5, FluidCollisionMode.SOURCE_ONLY); | ||||
|                 if (block != null && block.getType() != Material.AIR) { | ||||
|                     Location location = BukkitUtil.getLocation(block.getLocation()); | ||||
|                     Material finalType = type; | ||||
|                     if (!EventUtil.manager | ||||
|                         .checkPlayerBlockEvent(pp, PlayerBlockEventType.SPAWN_MOB, location, | ||||
|                             new BukkitLazyBlock(PlotBlock.get(type.toString())), true)) { | ||||
|                         .checkPlayerBlockEvent(pp, PlayerBlockEventType.SPAWN_MOB, location, () -> BukkitAdapter.asBlockType( | ||||
|                             finalType).getDefaultState(), true)) { | ||||
|                         event.setCancelled(true); | ||||
|                         event.setUseItemInHand(Event.Result.DENY); | ||||
|                     } | ||||
| @@ -1849,14 +1939,14 @@ import java.util.regex.Pattern; | ||||
|             return; | ||||
|         } | ||||
|         PlayerBlockEventType eventType = null; | ||||
|         BukkitLazyBlock lb; | ||||
|         Supplier<BlockState> lb; | ||||
|         Location location; | ||||
|         Action action = event.getAction(); | ||||
|         switch (action) { | ||||
|             case PHYSICAL: { | ||||
|                 eventType = PlayerBlockEventType.TRIGGER_PHYSICAL; | ||||
|                 Block block = event.getClickedBlock(); | ||||
|                 lb = new BukkitLazyBlock(block); | ||||
|                 lb = BukkitBlockUtil.supply(block); | ||||
|                 location = BukkitUtil.getLocation(block.getLocation()); | ||||
|                 break; | ||||
|             } | ||||
| @@ -2025,7 +2115,7 @@ import java.util.regex.Pattern; | ||||
|                             eventType = PlayerBlockEventType.INTERACT_BLOCK; | ||||
|                         } | ||||
|                 } | ||||
|                 lb = new BukkitLazyBlock(PlotBlock.get(block.getType().toString())); | ||||
|                 lb = BukkitBlockUtil.supply(block); | ||||
|                 if (eventType != null && (eventType != PlayerBlockEventType.INTERACT_BLOCK | ||||
|                     || !player.isSneaking())) { | ||||
|                     break; | ||||
| @@ -2044,7 +2134,7 @@ import java.util.regex.Pattern; | ||||
|                     type = offType; | ||||
|                 } | ||||
|                 // 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()) { | ||||
|                     location = BukkitUtil | ||||
|                         .getLocation(block.getRelative(event.getBlockFace()).getLocation()); | ||||
| @@ -2127,7 +2217,7 @@ import java.util.regex.Pattern; | ||||
|                 Block block = event.getClickedBlock(); | ||||
|                 location = BukkitUtil.getLocation(block.getLocation()); | ||||
|                 eventType = PlayerBlockEventType.BREAK_BLOCK; | ||||
|                 lb = new BukkitLazyBlock(block); | ||||
|                 lb = BukkitBlockUtil.supply(block); | ||||
|                 break; | ||||
|             default: | ||||
|                 return; | ||||
| @@ -2386,7 +2476,7 @@ import java.util.regex.Pattern; | ||||
|                 Captions.PERMISSION_ADMIN_BUILD_UNOWNED); | ||||
|             event.setCancelled(true); | ||||
|         } 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; | ||||
|             } | ||||
|             if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { | ||||
| @@ -2446,9 +2536,9 @@ import java.util.regex.Pattern; | ||||
|                 Captions.PERMISSION_ADMIN_BUILD_UNOWNED); | ||||
|             event.setCancelled(true); | ||||
|         } 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(); | ||||
|             if (use.isPresent() && use.get().contains(PlotBlock.get(block.getType().name()))) { | ||||
|             if (use.isPresent() && use.get().contains(BukkitBlockUtil.get(block))) { | ||||
|                 return; | ||||
|             } | ||||
|             if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { | ||||
| @@ -3004,10 +3094,10 @@ import java.util.regex.Pattern; | ||||
|                     return; | ||||
|                 } | ||||
|             } 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) { | ||||
|                     Block block = event.getBlock(); | ||||
|                     if (place.contains(PlotBlock.get(block.getType().name()))) { | ||||
|                     if (place.contains(BukkitBlockUtil.get(block))) { | ||||
|                         return; | ||||
|                     } | ||||
|                 } | ||||
|   | ||||
| @@ -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(); | ||||
|     } | ||||
| } | ||||
| @@ -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; | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
| @@ -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.config.Captions; | ||||
| 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.util.EconHandler; | ||||
| 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.StringMan; | ||||
| 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 org.bukkit.GameMode; | ||||
| import org.bukkit.Material; | ||||
| import org.bukkit.Sound; | ||||
| import org.bukkit.WeatherType; | ||||
| import org.bukkit.entity.Player; | ||||
| @@ -55,6 +57,10 @@ public class BukkitPlayer extends PlotPlayer { | ||||
|         super.populatePersistentMetaMap(); | ||||
|     } | ||||
|  | ||||
|     @Override public Actor toActor() { | ||||
|         return BukkitAdapter.adapt(player); | ||||
|     } | ||||
|  | ||||
|     @NotNull @Override public Location getLocation() { | ||||
|         final Location location = super.getLocation(); | ||||
|         return location == null ? BukkitUtil.getLocation(this.player) : location; | ||||
| @@ -277,8 +283,8 @@ public class BukkitPlayer extends PlotPlayer { | ||||
|         this.player.setAllowFlight(fly); | ||||
|     } | ||||
|  | ||||
|     @Override public void playMusic(@NotNull final Location location, @NotNull final PlotBlock id) { | ||||
|         if (PlotBlock.isEverything(id) || id.isAir()) { | ||||
|     @Override public void playMusic(@NotNull final Location location, @NotNull final ItemType id) { | ||||
|         if (id.getBlockType().getMaterial().isAir()) { | ||||
|             // Let's just stop all the discs because why not? | ||||
|             for (final Sound sound : Arrays.stream(Sound.values()) | ||||
|                 .filter(sound -> sound.name().contains("DISC")).collect(Collectors.toList())) { | ||||
| @@ -288,7 +294,7 @@ public class BukkitPlayer extends PlotPlayer { | ||||
|         } else { | ||||
|             // this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, id.to(Material.class)); | ||||
|             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); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package com.github.intellectualsites.plotsquared.bukkit.object.entity; | ||||
|  | ||||
|  | ||||
| class EntityBaseStats { | ||||
|  | ||||
|     EntityWrapper passenger; | ||||
|   | ||||
| @@ -8,7 +8,23 @@ import org.bukkit.Rotation; | ||||
| import org.bukkit.TreeSpecies; | ||||
| import org.bukkit.World; | ||||
| 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.InventoryHolder; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|   | ||||
| @@ -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.plot.PlotSquared; | ||||
| 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.World; | ||||
| import org.bukkit.block.Block; | ||||
| import org.bukkit.block.BlockState; | ||||
| import org.bukkit.block.Container; | ||||
| import org.bukkit.block.Sign; | ||||
| import org.bukkit.enchantments.Enchantment; | ||||
| @@ -23,10 +27,10 @@ import java.util.Map.Entry; | ||||
|  | ||||
| public class StateWrapper { | ||||
|  | ||||
|     public BlockState state = null; | ||||
|     public org.bukkit.block.BlockState state = null; | ||||
|     public CompoundTag tag = null; | ||||
|  | ||||
|     public StateWrapper(BlockState state) { | ||||
|     public StateWrapper(org.bukkit.block.BlockState state) { | ||||
|         this.state = state; | ||||
|     } | ||||
|  | ||||
| @@ -151,7 +155,7 @@ public class StateWrapper { | ||||
|         if (block == null) { | ||||
|             return false; | ||||
|         } | ||||
|         BlockState state = block.getState(); | ||||
|         org.bukkit.block.BlockState state = block.getState(); | ||||
|         switch (tileid) { | ||||
|             case "chest": | ||||
|             case "beacon": | ||||
|   | ||||
| @@ -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()); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -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.generator.AugmentedUtils; | ||||
| 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.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.LocalBlockQueue; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; | ||||
| import com.sk89q.worldedit.bukkit.BukkitWorld; | ||||
| import com.sk89q.worldedit.math.BlockVector2; | ||||
| import com.sk89q.worldedit.math.BlockVector3; | ||||
| import com.sk89q.worldedit.world.block.BaseBlock; | ||||
| import io.papermc.lib.PaperLib; | ||||
| @@ -25,30 +33,27 @@ import org.bukkit.entity.Creature; | ||||
| import org.bukkit.entity.Entity; | ||||
| 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.Set; | ||||
| import java.util.concurrent.CompletableFuture; | ||||
|  | ||||
| public class BukkitChunkManager extends ChunkManager { | ||||
|  | ||||
|     public static boolean isIn(RegionWrapper region, int x, int z) { | ||||
|         return x >= region.minX && x <= region.maxX && z >= region.minZ && z <= region.maxZ; | ||||
|     } | ||||
|  | ||||
|     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 boolean isIn(CuboidRegion region, int x, int z) { | ||||
|         return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX() && z >= region.getMinimumPoint().getZ() && z <= region.getMaximumPoint().getZ(); | ||||
|     } | ||||
|  | ||||
|     public static ContentMap swapChunk(World world1, World world2, Chunk pos1, Chunk pos2, | ||||
|         RegionWrapper r1, RegionWrapper r2) { | ||||
|         CuboidRegion r1, CuboidRegion r2) { | ||||
|         ContentMap map = new ContentMap(); | ||||
|         int relX = r2.minX - r1.minX; | ||||
|         int relZ = r2.minZ - r1.minZ; | ||||
|         int relX = r2.getMinimumPoint().getX() - r1.getMinimumPoint().getX(); | ||||
|         int relZ = r2.getMinimumPoint().getZ() - r1.getMinimumPoint().getZ(); | ||||
|  | ||||
|         map.saveEntitiesIn(pos1, r1, 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 queue2 = GlobalBlockQueue.IMP.getNewQueue(worldName2, false); | ||||
|  | ||||
|         for (int x = Math.max(r1.minX, sx); x <= Math.min(r1.maxX, sx + 15); x++) { | ||||
|             for (int z = Math.max(r1.minZ, sz); z <= Math.min(r1.maxZ, sz + 15); z++) { | ||||
|         for (int x = Math.max(r1.getMinimumPoint().getX(), sx); x <= Math.min(r1.getMaximumPoint().getX(), sx + 15); x++) { | ||||
|             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++) { | ||||
|                     Block block1 = world1.getBlockAt(x, y, z); | ||||
|                     BaseBlock baseBlock1 = bukkitWorld1.getFullBlock(BlockVector3.at(x, y, z)); | ||||
| @@ -104,10 +109,10 @@ public class BukkitChunkManager extends ChunkManager { | ||||
|         return map; | ||||
|     } | ||||
|  | ||||
|     @Override public Set<ChunkLoc> getChunkChunks(String world) { | ||||
|         Set<ChunkLoc> chunks = super.getChunkChunks(world); | ||||
|     @Override public Set<BlockVector2> getChunkChunks(String world) { | ||||
|         Set<BlockVector2> chunks = super.getChunkChunks(world); | ||||
|         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); | ||||
|         } | ||||
|         return chunks; | ||||
| @@ -194,8 +199,8 @@ public class BukkitChunkManager extends ChunkManager { | ||||
|         final int relX = newPos.getX() - pos1.getX(); | ||||
|         final int relZ = newPos.getZ() - pos1.getZ(); | ||||
|  | ||||
|         final RegionWrapper region = | ||||
|             new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); | ||||
|         final CuboidRegion region = | ||||
|             RegionUtil.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); | ||||
|         final World oldWorld = Bukkit.getWorld(pos1.getWorld()); | ||||
|         final BukkitWorld oldBukkitWorld = new BukkitWorld(oldWorld); | ||||
|         final World newWorld = Bukkit.getWorld(newPos.getWorld()); | ||||
| @@ -210,10 +215,10 @@ public class BukkitChunkManager extends ChunkManager { | ||||
|                 int bz = value[3]; | ||||
|                 int tx = value[4]; | ||||
|                 int tz = value[5]; | ||||
|                 ChunkLoc loc = new ChunkLoc(value[0], value[1]); | ||||
|                 int cxx = loc.x << 4; | ||||
|                 int czz = loc.z << 4; | ||||
|                 PaperLib.getChunkAtAsync(oldWorld, loc.x, loc.z) | ||||
|                 BlockVector2 loc = BlockVector2.at(value[0], value[1]); | ||||
|                 int cxx = loc.getX() << 4; | ||||
|                 int czz = loc.getZ() << 4; | ||||
|                 PaperLib.getChunkAtAsync(oldWorld, loc.getX(), loc.getZ()) | ||||
|                     .thenAccept(chunk1 -> map.saveEntitiesIn(chunk1, region)).thenRun(() -> { | ||||
|                     for (int x = bx & 15; x <= (tx & 15); x++) { | ||||
|                         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 tcz = p2z >> 4; | ||||
|  | ||||
|         final List<ChunkLoc> chunks = new ArrayList<>(); | ||||
|         final List<BlockVector2> chunks = new ArrayList<>(); | ||||
|  | ||||
|         for (int x = bcx; x <= tcx; x++) { | ||||
|             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); | ||||
| @@ -269,9 +274,9 @@ public class BukkitChunkManager extends ChunkManager { | ||||
|             @Override public void run() { | ||||
|                 long start = System.currentTimeMillis(); | ||||
|                 while (!chunks.isEmpty() && System.currentTimeMillis() - start < 5) { | ||||
|                     final ChunkLoc chunk = chunks.remove(0); | ||||
|                     int x = chunk.x; | ||||
|                     int z = chunk.z; | ||||
|                     final BlockVector2 chunk = chunks.remove(0); | ||||
|                     int x = chunk.getX(); | ||||
|                     int z = chunk.getZ(); | ||||
|                     int xxb = x << 4; | ||||
|                     int zzb = z << 4; | ||||
|                     int xxt = xxb + 15; | ||||
| @@ -284,7 +289,7 @@ public class BukkitChunkManager extends ChunkManager { | ||||
|                     if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z | ||||
|                         && PlotSquared.imp().getServerVersion()[1] == 13) { | ||||
|                         AugmentedUtils | ||||
|                             .bypass(ignoreAugment, () -> queue.regenChunkSafe(chunk.x, chunk.z)); | ||||
|                             .bypass(ignoreAugment, () -> queue.regenChunkSafe(chunk.getX(), chunk.getZ())); | ||||
|                         continue; | ||||
|                     } | ||||
|                     boolean checkX1 = false; | ||||
| @@ -346,8 +351,8 @@ public class BukkitChunkManager extends ChunkManager { | ||||
|                     if (checkX2 && checkZ2) { | ||||
|                         map.saveRegion(bukkitWorldObj, xxt2, xxt, zzt2, zzt); // | ||||
|                     } | ||||
|                     RegionWrapper currentPlotClear = | ||||
|                         new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); | ||||
|                     CuboidRegion currentPlotClear = | ||||
|                         RegionUtil.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); | ||||
|                     map.saveEntitiesOut(chunkObj, currentPlotClear); | ||||
|                     AugmentedUtils.bypass(ignoreAugment, | ||||
|                         () -> setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() { | ||||
| @@ -365,7 +370,7 @@ public class BukkitChunkManager extends ChunkManager { | ||||
|                                                 if (id != null) { | ||||
|                                                     value.setBlock(x1, y, z1, id); | ||||
|                                                 } 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); | ||||
| @@ -393,17 +398,17 @@ public class BukkitChunkManager extends ChunkManager { | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override public CompletableFuture loadChunk(String world, ChunkLoc chunkLoc, boolean force) { | ||||
|         return PaperLib.getChunkAtAsync(BukkitUtil.getWorld(world),chunkLoc.x, chunkLoc.z, force); | ||||
|     @Override public CompletableFuture loadChunk(String world, BlockVector2 chunkLoc, boolean force) { | ||||
|         return PaperLib.getChunkAtAsync(BukkitUtil.getWorld(world),chunkLoc.getX(), chunkLoc.getZ(), force); | ||||
|     } | ||||
|  | ||||
|     @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())) { | ||||
|             TaskManager.runTask( | ||||
|                 () -> BukkitUtil.getWorld(world).unloadChunk(chunkLoc.x, chunkLoc.z, save)); | ||||
|                 () -> BukkitUtil.getWorld(world).unloadChunk(chunkLoc.getX(), chunkLoc.getZ(), save)); | ||||
|         } 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, | ||||
|         final Runnable whenDone) { | ||||
|         RegionWrapper region1 = | ||||
|             new RegionWrapper(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ()); | ||||
|         RegionWrapper region2 = | ||||
|             new RegionWrapper(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ()); | ||||
|         CuboidRegion region1 = | ||||
|             RegionUtil.createRegion(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ()); | ||||
|         CuboidRegion region2 = | ||||
|             RegionUtil.createRegion(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ()); | ||||
|         final World world1 = Bukkit.getWorld(bot1.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()) { | ||||
|                 Location location = BukkitUtil.getLocation(entity); | ||||
|                 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); | ||||
|         } | ||||
|  | ||||
|         void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ, | ||||
|         void saveEntitiesIn(Chunk chunk, CuboidRegion region, int offsetX, int offsetZ, | ||||
|             boolean delete) { | ||||
|             for (Entity entity : chunk.getEntities()) { | ||||
|                 Location location = BukkitUtil.getLocation(entity); | ||||
|   | ||||
| @@ -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.object.ConsolePlayer; | ||||
| 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 java.util.ArrayList; | ||||
|   | ||||
| @@ -1,6 +1,22 @@ | ||||
| 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.plot.flag.Flag; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.Location; | ||||
|   | ||||
| @@ -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.generator.HybridPlotWorld; | ||||
| 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.MainUtil; | ||||
| 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.LocalBlockQueue; | ||||
| 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.BlockState; | ||||
| import com.sk89q.worldedit.world.block.BlockType; | ||||
| import com.sk89q.worldedit.world.block.BlockTypes; | ||||
| import org.bukkit.Bukkit; | ||||
| import org.bukkit.Material; | ||||
| import org.bukkit.World; | ||||
| @@ -22,15 +30,16 @@ import org.bukkit.block.data.Directional; | ||||
| import org.bukkit.generator.ChunkGenerator; | ||||
|  | ||||
| import java.util.HashSet; | ||||
| import java.util.Set; | ||||
|  | ||||
| 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) { | ||||
|         // int diff, int variety, int vertices, int rotation, int height_sd | ||||
|         /* | ||||
|          * 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 | ||||
|          * | ||||
|          * vertices: store air map and compare with neighbours | ||||
| @@ -47,8 +56,8 @@ public class BukkitHybridUtils extends HybridUtils { | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             final Location bot = new Location(world, region.minX, region.minY, region.minZ); | ||||
|             final Location top = new Location(world, region.maxX, region.maxY, region.maxZ); | ||||
|             final Location bot = new Location(world, region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ()); | ||||
|             final Location top = new Location(world, region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ()); | ||||
|  | ||||
|             final int bx = bot.getX(); | ||||
|             final int bz = bot.getZ(); | ||||
| @@ -65,8 +74,8 @@ public class BukkitHybridUtils extends HybridUtils { | ||||
|             System.gc(); | ||||
|             System.gc(); | ||||
|             final BlockBucket[][][] oldBlocks = new BlockBucket[256][width][length]; | ||||
|             final PlotBlock[][][] newBlocks = new PlotBlock[256][width][length]; | ||||
|             final BlockBucket airBucket = BlockBucket.withSingle(StringPlotBlock.EVERYTHING); | ||||
|             final BlockState[][][] newBlocks = new BlockState[256][width][length]; | ||||
|             final BlockBucket airBucket = BlockBucket.withSingle(BlockTypes.AIR.getDefaultState()); | ||||
|  | ||||
|             PlotArea area = PlotSquared.get().getPlotArea(world, null); | ||||
|  | ||||
| @@ -122,7 +131,7 @@ public class BukkitHybridUtils extends HybridUtils { | ||||
|                         for (int y = 0; y < blocks.length; y++) { | ||||
|                             if (blocks[y] != null) { | ||||
|                                 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; | ||||
|                 for (int x = 0; x < width; x++) { | ||||
|                     for (int z = 0; z < length; z++) { | ||||
|                         HashSet<PlotBlock> types = new HashSet<>(); | ||||
|                         Set<BlockType> types = new HashSet<>(); | ||||
|                         for (int y = 0; y < 256; y++) { | ||||
|                             BlockBucket old = oldBlocks[y][x][z]; | ||||
|                             try { | ||||
|                                 if (old == null) { | ||||
|                                     old = airBucket; | ||||
|                                 } | ||||
|                                 PlotBlock now = newBlocks[y][x][z]; | ||||
|                                 BlockState now = newBlocks[y][x][z]; | ||||
|                                 if (!old.getBlocks().contains(now)) { | ||||
|                                     changes[i]++; | ||||
|                                 } | ||||
|                                 if (now.isAir()) { | ||||
|                                 if (now.getBlockType().getMaterial().isAir()) { | ||||
|                                     air[i]++; | ||||
|                                 } else { | ||||
|                                     // check vertices | ||||
|                                     // modifications_adjacent | ||||
|                                     if (x > 0 && z > 0 && y > 0 && x < width - 1 && z < length - 1 | ||||
|                                         && y < 255) { | ||||
|                                         if (newBlocks[y - 1][x][z].isAir()) { | ||||
|                                         if (newBlocks[y - 1][x][z].getBlockType().getMaterial().isAir()) { | ||||
|                                             faces[i]++; | ||||
|                                         } | ||||
|                                         if (newBlocks[y][x - 1][z].isAir()) { | ||||
|                                         if (newBlocks[y][x - 1][z].getBlockType().getMaterial().isAir()) { | ||||
|                                             faces[i]++; | ||||
|                                         } | ||||
|                                         if (newBlocks[y][x][z - 1].isAir()) { | ||||
|                                         if (newBlocks[y][x][z - 1].getBlockType().getMaterial().isAir()) { | ||||
|                                             faces[i]++; | ||||
|                                         } | ||||
|                                         if (newBlocks[y + 1][x][z].isAir()) { | ||||
|                                         if (newBlocks[y + 1][x][z].getBlockType().getMaterial().isAir()) { | ||||
|                                             faces[i]++; | ||||
|                                         } | ||||
|                                         if (newBlocks[y][x + 1][z].isAir()) { | ||||
|                                         if (newBlocks[y][x + 1][z].getBlockType().getMaterial().isAir()) { | ||||
|                                             faces[i]++; | ||||
|                                         } | ||||
|                                         if (newBlocks[y][x][z + 1].isAir()) { | ||||
|                                         if (newBlocks[y][x][z + 1].getBlockType().getMaterial().isAir()) { | ||||
|                                             faces[i]++; | ||||
|                                         } | ||||
|                                     } | ||||
|  | ||||
|                                     Material material = now.to(Material.class); | ||||
|                                     Material material = BukkitAdapter.adapt(now.getBlockType()); | ||||
|                                     if (material != null) { | ||||
|                                         BlockData blockData = material.createBlockData(); | ||||
|                                         if (blockData instanceof Directional) { | ||||
| @@ -224,7 +233,7 @@ public class BukkitHybridUtils extends HybridUtils { | ||||
|                                             data[i]++; | ||||
|                                         } | ||||
|                                     } | ||||
|                                     types.add(now); | ||||
|                                     types.add(now.getBlockType()); | ||||
|                                 } | ||||
|                             } catch (NullPointerException e) { | ||||
|                                 e.printStackTrace(); | ||||
| @@ -297,7 +306,7 @@ public class BukkitHybridUtils extends HybridUtils { | ||||
|                         for (int z = minZ; z <= maxZ; z++) { | ||||
|                             int zz = cbz + z; | ||||
|                             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 zr = zb + z; | ||||
|                                 newBlocks[y][xr][zr] = block; | ||||
|   | ||||
| @@ -56,7 +56,7 @@ public class BukkitInventoryUtil extends InventoryUtil { | ||||
|     if (item == 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; | ||||
|     if (item.name != null) { | ||||
|       meta = stack.getItemMeta(); | ||||
|   | ||||
| @@ -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; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -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.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.util.MainUtil; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.TaskManager; | ||||
| 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.regions.CuboidRegion; | ||||
| import com.sk89q.worldedit.world.block.BaseBlock; | ||||
|  | ||||
| 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; | ||||
|  | ||||
| /** | ||||
| @@ -22,7 +35,7 @@ import java.util.stream.IntStream; | ||||
|  */ | ||||
| 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) { | ||||
|         // async | ||||
|         TaskManager.runTaskAsync(new Runnable() { | ||||
| @@ -61,7 +74,7 @@ public class BukkitSchematicHandler extends SchematicHandler { | ||||
|                 List<CompoundTag> tileEntities = new ArrayList<>(); | ||||
|                 ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length); | ||||
|                 // Queue | ||||
|                 final ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions); | ||||
|                 final ArrayDeque<CuboidRegion> queue = new ArrayDeque<>(regions); | ||||
|                 TaskManager.runTask(new Runnable() { | ||||
|                     @Override public void run() { | ||||
|                         if (queue.isEmpty()) { | ||||
| @@ -82,9 +95,9 @@ public class BukkitSchematicHandler extends SchematicHandler { | ||||
|                             return; | ||||
|                         } | ||||
|                         final Runnable regionTask = this; | ||||
|                         RegionWrapper region = queue.poll(); | ||||
|                         Location pos1 = new Location(world, region.minX, region.minY, region.minZ); | ||||
|                         Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ); | ||||
|                         CuboidRegion region = queue.poll(); | ||||
|                         Location pos1 = new Location(world, region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ()); | ||||
|                         Location pos2 = new Location(world, region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ()); | ||||
|                         final int p1x = pos1.getX(); | ||||
|                         final int sy = pos1.getY(); | ||||
|                         final int p1z = pos1.getZ(); | ||||
|   | ||||
| @@ -3,6 +3,8 @@ package com.github.intellectualsites.plotsquared.bukkit.util; | ||||
| import com.github.intellectualsites.plotsquared.bukkit.BukkitMain; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.TaskManager; | ||||
| import org.bukkit.Bukkit; | ||||
| import org.bukkit.scheduler.BukkitTask; | ||||
| import org.jetbrains.annotations.NotNull; | ||||
|  | ||||
| public class BukkitTaskManager extends TaskManager { | ||||
|  | ||||
| @@ -26,7 +28,7 @@ public class BukkitTaskManager extends TaskManager { | ||||
|     @Override public void taskAsync(Runnable runnable) { | ||||
|         if (this.bukkitMain.isEnabled()) { | ||||
|             this.bukkitMain.getServer().getScheduler() | ||||
|                 .runTaskAsynchronously(this.bukkitMain, runnable).getTaskId(); | ||||
|                 .runTaskAsynchronously(this.bukkitMain, runnable); | ||||
|         } else { | ||||
|             runnable.run(); | ||||
|         } | ||||
|   | ||||
| @@ -3,7 +3,11 @@ package com.github.intellectualsites.plotsquared.bukkit.util; | ||||
| import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer; | ||||
| import com.github.intellectualsites.plotsquared.plot.PlotSquared; | ||||
| 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.util.MainUtil; | ||||
| 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.UUIDHandler; | ||||
| 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.world.block.BlockState; | ||||
| import lombok.NonNull; | ||||
| import org.bukkit.Bukkit; | ||||
| import org.bukkit.Material; | ||||
| @@ -20,7 +27,6 @@ import org.bukkit.World; | ||||
| import org.bukkit.block.Biome; | ||||
| import org.bukkit.block.Block; | ||||
| import org.bukkit.block.BlockFace; | ||||
| import org.bukkit.block.BlockState; | ||||
| import org.bukkit.block.Sign; | ||||
| import org.bukkit.block.data.Directional; | ||||
| import org.bukkit.block.data.type.WallSign; | ||||
| @@ -36,7 +42,6 @@ import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.HashSet; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
| import java.util.Set; | ||||
|  | ||||
| @SuppressWarnings({"unused", "WeakerAccess"}) public class BukkitUtil extends WorldUtil { | ||||
| @@ -258,23 +263,11 @@ import java.util.Set; | ||||
|             location.getPitch()); | ||||
|     } | ||||
|  | ||||
|     public static BukkitLegacyMappings getBukkitLegacyMappings() { | ||||
|         return (BukkitLegacyMappings) PlotSquared.imp().getLegacyMappings(); | ||||
|     public static Material getMaterial(@NonNull final BlockState plotBlock) { | ||||
|         return BukkitAdapter.adapt(plotBlock.getBlockType()); | ||||
|     } | ||||
|  | ||||
|     public static Material getMaterial(@NonNull final PlotBlock plotBlock) { | ||||
|         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) { | ||||
|     @Override public boolean isBlockSame(BlockState block1, BlockState block2) { | ||||
|         if (block1.equals(block2)) { | ||||
|             return true; | ||||
|         } | ||||
| @@ -377,7 +370,7 @@ import java.util.Set; | ||||
|             sign.setFacing(facing); | ||||
|             block.setBlockData(sign, false); | ||||
|         } | ||||
|         final BlockState blockstate = block.getState(); | ||||
|         final org.bukkit.block.BlockState blockstate = block.getState(); | ||||
|         if (blockstate instanceof Sign) { | ||||
|             final Sign sign = (Sign) blockstate; | ||||
|             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) { | ||||
|         final World world = getWorld(worldName); | ||||
|         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) { | ||||
|             InventoryHolder holder = (InventoryHolder) state; | ||||
|             Inventory inv = holder.getInventory(); | ||||
|             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(items.types[i].to(Material.class), items.amount[i]); | ||||
|                 ItemStack item = new ItemStack(BukkitAdapter.adapt(items.types[i]), items.amount[i]); | ||||
|                 inv.addItem(item); | ||||
|             } | ||||
|             state.update(true); | ||||
| @@ -420,33 +413,11 @@ import java.util.Set; | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override public boolean isBlockSolid(@NonNull final PlotBlock block) { | ||||
|         try { | ||||
|             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 boolean isBlockSolid(@NonNull final BlockState block) { | ||||
|         return block.getBlockType().getMaterial().isSolid(); | ||||
|     } | ||||
|  | ||||
|     @Override public String getClosestMatchingName(@NonNull final PlotBlock block) { | ||||
|     @Override public String getClosestMatchingName(@NonNull final BlockState block) { | ||||
|         try { | ||||
|             return getMaterial(block).name(); | ||||
|         } catch (Exception ignored) { | ||||
| @@ -455,21 +426,18 @@ import java.util.Set; | ||||
|     } | ||||
|  | ||||
|     @Override @Nullable | ||||
|     public StringComparison<PlotBlock>.ComparisonResult getClosestBlock(String name) { | ||||
|         final PlotBlock plotBlock = BukkitUtil.getBukkitLegacyMappings().fromAny(name); | ||||
|         if (plotBlock != null) { | ||||
|             return new StringComparison<PlotBlock>().new ComparisonResult(1, plotBlock); | ||||
|         } | ||||
|         return BukkitUtil.getBukkitLegacyMappings().getClosestsMatch(name); | ||||
|     public StringComparison<BlockState>.ComparisonResult getClosestBlock(String name) { | ||||
|         BlockState state = BlockUtil.get(name); | ||||
|         return new StringComparison<BlockState>().new ComparisonResult(1, state); | ||||
|     } | ||||
|  | ||||
|     @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) { | ||||
|         final World world = getWorld(worldName); | ||||
|         final Biome biome = Biome.valueOf(biomeString.toUpperCase()); | ||||
|         for (int x = region.minX; x <= region.maxX; x++) { | ||||
|             for (int z = region.minZ; z <= region.maxZ; z++) { | ||||
|         for (int x = region.getMinimumPoint().getX(); x <= region.getMaximumPoint().getX(); x++) { | ||||
|             for (int z = region.getMinimumPoint().getZ(); z <= region.getMaximumPoint().getZ(); z++) { | ||||
|                 world.setBiome(x, z, biome); | ||||
|             } | ||||
|         } | ||||
| @@ -479,10 +447,10 @@ import java.util.Set; | ||||
|         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 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() { | ||||
|   | ||||
| @@ -10,12 +10,24 @@ import org.json.simple.JSONArray; | ||||
| import org.json.simple.JSONObject; | ||||
|  | ||||
| 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.Method; | ||||
| import java.net.URL; | ||||
| 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.logging.Level; | ||||
| 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'}); | ||||
|             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 | ||||
|  | ||||
|             if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) { | ||||
|                 throw new IllegalStateException("bStats Metrics class has not been relocated correctly!"); | ||||
|             } | ||||
|   | ||||
| @@ -13,9 +13,28 @@ import org.bukkit.Material; | ||||
| import org.bukkit.Server; | ||||
| import org.bukkit.inventory.ItemStack; | ||||
|  | ||||
| import java.io.*; | ||||
| import java.lang.reflect.*; | ||||
| import java.util.*; | ||||
| import java.io.BufferedInputStream; | ||||
| import java.io.DataInput; | ||||
| 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.zip.GZIPInputStream; | ||||
| import java.util.zip.GZIPOutputStream; | ||||
|   | ||||
| @@ -9,7 +9,13 @@ import java.lang.reflect.Constructor; | ||||
| import java.lang.reflect.Method; | ||||
| 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 { | ||||
|  | ||||
|   | ||||
| @@ -2,7 +2,6 @@ package com.github.intellectualsites.plotsquared.bukkit.util; | ||||
|  | ||||
| import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer; | ||||
| 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.Plot; | ||||
| 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.TaskManager; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; | ||||
| import com.sk89q.worldedit.math.BlockVector2; | ||||
| import io.papermc.lib.PaperLib; | ||||
| import org.bukkit.Bukkit; | ||||
| 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); | ||||
|         ArrayList<Chunk> chunks = new ArrayList<>(); | ||||
|         for (ChunkLoc loc : chunkLocations) { | ||||
|             if (myWorld.isChunkLoaded(loc.x, loc.z)) { | ||||
|                 PaperLib.getChunkAtAsync(myWorld, loc.x, loc.z).thenAccept(chunks::add); | ||||
|         for (BlockVector2 loc : chunkLocations) { | ||||
|             if (myWorld.isChunkLoaded(loc.getX(), loc.getZ())) { | ||||
|                 PaperLib.getChunkAtAsync(myWorld, loc.getX(), loc.getZ()).thenAccept(chunks::add); | ||||
|             } | ||||
|         } | ||||
|         sendChunk(chunks); | ||||
|   | ||||
| @@ -1,15 +1,15 @@ | ||||
| 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.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.block.BasicLocalBlockQueue; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil; | ||||
| import com.sk89q.jnbt.CompoundTag; | ||||
| import com.sk89q.worldedit.bukkit.BukkitAdapter; | ||||
| import com.sk89q.worldedit.world.block.BaseBlock; | ||||
| import com.sk89q.worldedit.world.block.BlockState; | ||||
| import io.papermc.lib.PaperLib; | ||||
| import lombok.NonNull; | ||||
| import org.bukkit.Bukkit; | ||||
| @@ -19,7 +19,6 @@ import org.bukkit.block.Biome; | ||||
| import org.bukkit.block.Block; | ||||
| import org.bukkit.block.data.BlockData; | ||||
|  | ||||
| import java.util.Locale; | ||||
| import java.util.concurrent.ExecutionException; | ||||
|  | ||||
| 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()); | ||||
|         if (worldObj != null) { | ||||
|             Block block = worldObj.getBlockAt(x, y, z); | ||||
|             return PlotBlock.get(block.getType().toString()); | ||||
|             return BukkitBlockUtil.get(block); | ||||
|         } 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); | ||||
|  | ||||
|                                 Block existing = chunk.getBlock(x, y, z); | ||||
|                                 if (equals(PlotBlock.get(block), existing) && existing | ||||
|                                 if (BukkitBlockUtil.get(existing).equals(block) && existing | ||||
|                                     .getBlockData().matches(blockData)) { | ||||
|                                     continue; | ||||
|                                 } | ||||
| @@ -116,38 +115,13 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue { | ||||
|             }); | ||||
|     } | ||||
|  | ||||
|     private void setMaterial(@NonNull final PlotBlock plotBlock, @NonNull final Block block) { | ||||
|         final Material material; | ||||
|         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())); | ||||
|             } | ||||
|         } | ||||
|     private void setMaterial(@NonNull final BlockState plotBlock, @NonNull final Block block) { | ||||
|         Material material = BukkitAdapter.adapt(plotBlock.getBlockType()); | ||||
|         block.setType(material, false); | ||||
|     } | ||||
|  | ||||
|     private boolean equals(@NonNull final PlotBlock plotBlock, @NonNull final Block block) { | ||||
|         if (plotBlock instanceof StringPlotBlock) { | ||||
|             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()); | ||||
|     private boolean equals(@NonNull final BlockState plotBlock, @NonNull final Block block) { | ||||
|         return plotBlock.equals(BukkitBlockUtil.get(block)); | ||||
|     } | ||||
|  | ||||
|     public void setBiomes(LocalChunk lc) { | ||||
|   | ||||
| @@ -1,17 +1,18 @@ | ||||
| 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.plot.object.ChunkWrapper; | ||||
| 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.world.BlockUtil; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; | ||||
| import com.sk89q.worldedit.bukkit.BukkitAdapter; | ||||
| import com.sk89q.worldedit.world.block.BaseBlock; | ||||
| import com.sk89q.worldedit.world.block.BlockState; | ||||
| import lombok.Getter; | ||||
| import lombok.Setter; | ||||
| import org.bukkit.Chunk; | ||||
| import org.bukkit.Material; | ||||
| import org.bukkit.World; | ||||
| import org.bukkit.block.Biome; | ||||
| import org.bukkit.generator.ChunkGenerator.BiomeGrid; | ||||
| @@ -22,7 +23,7 @@ import java.util.Arrays; | ||||
| public class GenChunk extends ScopedLocalBlockQueue { | ||||
|  | ||||
|     public final Biome[] biomes; | ||||
|     public PlotBlock[][] result; | ||||
|     public BlockState[][] result; | ||||
|     public BiomeGrid biomeGrid; | ||||
|     public Chunk chunk; | ||||
|     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 | ||||
|             && pos2.getZ() == 15) { | ||||
|             for (int y = pos1.getY(); y <= pos2.getY(); y++) { | ||||
|                 int layer = y >> 4; | ||||
|                 PlotBlock[] data = result[layer]; | ||||
|                 BlockState[] data = result[layer]; | ||||
|                 if (data == null) { | ||||
|                     result[layer] = data = new PlotBlock[4096]; | ||||
|                     result[layer] = data = new BlockState[4096]; | ||||
|                 } | ||||
|                 int start = y << 8; | ||||
|                 int end = start + 256; | ||||
| @@ -88,8 +89,7 @@ public class GenChunk extends ScopedLocalBlockQueue { | ||||
|         int maxX = Math.max(pos1.getX(), pos2.getX()); | ||||
|         int maxY = Math.max(pos1.getY(), pos2.getY()); | ||||
|         int maxZ = Math.max(pos1.getZ(), pos2.getZ()); | ||||
|         chunkData | ||||
|             .setRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1, block.to(Material.class)); | ||||
|         chunkData.setRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1, BukkitAdapter.adapt(block)); | ||||
|     } | ||||
|  | ||||
|     @Override public boolean setBiome(int x, int z, String biome) { | ||||
| @@ -104,21 +104,21 @@ public class GenChunk extends ScopedLocalBlockQueue { | ||||
|         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) { | ||||
|             this.chunkData.setBlock(x, y, z, id.to(Material.class)); | ||||
|             this.chunkData.setBlock(x, y, z, BukkitAdapter.adapt(id)); | ||||
|             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); | ||||
|         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]; | ||||
|         PlotBlock[] v = this.result[i]; | ||||
|         BlockState[] v = this.result[i]; | ||||
|         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]; | ||||
|         v[j] = id; | ||||
| @@ -130,18 +130,18 @@ public class GenChunk extends ScopedLocalBlockQueue { | ||||
|             return true; | ||||
|         } | ||||
|         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; | ||||
|     } | ||||
|  | ||||
|     @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]; | ||||
|         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) { | ||||
|             return PlotBlock.get(""); | ||||
|             return BlockUtil.get(""); | ||||
|         } | ||||
|         int j = MainUtil.CACHE_J[y][x][z]; | ||||
|         return array[j]; | ||||
| @@ -171,9 +171,9 @@ public class GenChunk extends ScopedLocalBlockQueue { | ||||
|         GenChunk toReturn = new GenChunk(); | ||||
|         if (this.result != null) { | ||||
|             for (int i = 0; i < this.result.length; i++) { | ||||
|                 PlotBlock[] matrix = this.result[i]; | ||||
|                 BlockState[] matrix = this.result[i]; | ||||
|                 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); | ||||
|                 } | ||||
|             } | ||||
|   | ||||
| @@ -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.block.GlobalBlockQueue; | ||||
| import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper; | ||||
| import com.sk89q.worldedit.extension.platform.Actor; | ||||
| import lombok.NoArgsConstructor; | ||||
|  | ||||
| import java.util.Collections; | ||||
|   | ||||
| @@ -19,7 +19,15 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan; | ||||
| import java.io.IOException; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| 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; | ||||
|  | ||||
| public abstract class Command { | ||||
|   | ||||
| @@ -1,6 +1,11 @@ | ||||
| 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. | ||||
|   | ||||
| @@ -4,7 +4,16 @@ import com.github.intellectualsites.plotsquared.configuration.Configuration; | ||||
| import com.github.intellectualsites.plotsquared.configuration.InvalidConfigurationException; | ||||
| 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.util.stream.Collectors; | ||||
|  | ||||
|   | ||||
| @@ -7,8 +7,15 @@ import java.lang.reflect.Field; | ||||
| import java.lang.reflect.InvocationTargetException; | ||||
| import java.lang.reflect.Method; | ||||
| 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.ResourceBundle; | ||||
| import java.util.Set; | ||||
| import java.util.stream.IntStream; | ||||
|  | ||||
| /** | ||||
| @@ -554,7 +561,9 @@ public class JSONObject { | ||||
|                 return new JSONObject((Map<String, Object>) object); | ||||
|             } | ||||
|             Package objectPackage = object.getClass().getPackage(); | ||||
|  | ||||
|             String objectPackageName = objectPackage != null ? objectPackage.getName() : ""; | ||||
|  | ||||
|             if (objectPackageName.startsWith("java.") || objectPackageName.startsWith("javax.") || ( | ||||
|                 object.getClass().getClassLoader() == null)) { | ||||
|                 return object.toString(); | ||||
|   | ||||
| @@ -1,6 +1,11 @@ | ||||
| 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 | ||||
|   | ||||
| @@ -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.IndependentPlotGenerator; | ||||
| 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.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.sk89q.worldedit.extension.platform.Actor; | ||||
| import org.jetbrains.annotations.NotNull; | ||||
|  | ||||
| import java.io.File; | ||||
| @@ -237,8 +246,5 @@ public interface IPlotMain extends ILogger { | ||||
|  | ||||
|     List<String> getPluginIds(); | ||||
|  | ||||
|     BlockRegistry<?> getBlockRegistry(); | ||||
|  | ||||
|     LegacyMappings getLegacyMappings(); | ||||
|  | ||||
|     Actor getConsole(); | ||||
| } | ||||
|   | ||||
| @@ -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.listener.WESubscriber; | ||||
| 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.PlotAreaManager; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea; | ||||
| 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.expiry.ExpireManager; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpiryTask; | ||||
| @@ -35,15 +61,37 @@ import lombok.NonNull; | ||||
| import lombok.Setter; | ||||
| 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.URISyntaxException; | ||||
| import java.net.URL; | ||||
| import java.net.URLConnection; | ||||
| import java.nio.file.Files; | ||||
| 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.Objects; | ||||
| import java.util.Properties; | ||||
| import java.util.Set; | ||||
| import java.util.UUID; | ||||
| import java.util.function.Consumer; | ||||
| import java.util.regex.Pattern; | ||||
| import java.util.stream.Collectors; | ||||
| @@ -105,7 +153,7 @@ import java.util.zip.ZipInputStream; | ||||
|         // | ||||
|         // Register configuration serializable classes | ||||
|         // | ||||
|         ConfigurationSerialization.registerClass(PlotBlock.class, "PlotBlock"); | ||||
| //        ConfigurationSerialization.registerClass(BlockState.class, "BlockState"); | ||||
|         ConfigurationSerialization.registerClass(BlockBucket.class, "BlockBucket"); | ||||
|  | ||||
|         try { | ||||
| @@ -1272,7 +1320,7 @@ import java.util.zip.ZipInputStream; | ||||
|                 .filter(validArgument -> args.toLowerCase(Locale.ENGLISH).contains(validArgument)) | ||||
|                 .count(); | ||||
|  | ||||
|             String[] split = args.toLowerCase(Locale.ENGLISH).split(","); | ||||
|             String[] split = args.toLowerCase(Locale.ENGLISH).split(",(?![^\\(\\[]*[\\]\\)])"); | ||||
|  | ||||
|             if (split.length > expected) { | ||||
|                 // This means we have multi-block block buckets | ||||
| @@ -1960,7 +2008,7 @@ import java.util.zip.ZipInputStream; | ||||
|         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 Set<PlotArea> set = new HashSet<>(); | ||||
|         Collections.addAll(set, areas); | ||||
|   | ||||
| @@ -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.generator.AugmentedUtils; | ||||
| import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.*; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.*; | ||||
| 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.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.util.ArrayList; | ||||
| @@ -83,7 +100,7 @@ import java.util.Set; | ||||
|                                     area.ROAD_WIDTH / 2; | ||||
|                                 final int offsetX = bx - (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 = | ||||
|                                     PlotSquared.get().getPlotAreas(area.worldname, region); | ||||
|                                 if (!areas.isEmpty()) { | ||||
| @@ -120,10 +137,10 @@ import java.util.Set; | ||||
|                                         player.teleport(WorldUtil.IMP.getSpawn(world)); | ||||
|                                         if (area.TERRAIN != 3) { | ||||
|                                             ChunkManager.largeRegionTask(world, region, | ||||
|                                                 new RunnableVal<ChunkLoc>() { | ||||
|                                                     @Override public void run(ChunkLoc value) { | ||||
|                                                 new RunnableVal<BlockVector2>() { | ||||
|                                                     @Override public void run(BlockVector2 value) { | ||||
|                                                         AugmentedUtils | ||||
|                                                             .generate(world, value.x, value.z, | ||||
|                                                             .generate(world, value.getX(), value.getZ(), | ||||
|                                                                 null); | ||||
|                                                     } | ||||
|                                                 }, null); | ||||
| @@ -415,9 +432,9 @@ import java.util.Set; | ||||
|                     return false; | ||||
|                 } | ||||
|                 ChunkManager | ||||
|                     .largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<ChunkLoc>() { | ||||
|                         @Override public void run(ChunkLoc value) { | ||||
|                             AugmentedUtils.generate(area.worldname, value.x, value.z, null); | ||||
|                     .largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<BlockVector2>() { | ||||
|                         @Override public void run(BlockVector2 value) { | ||||
|                             AugmentedUtils.generate(area.worldname, value.getX(), value.getZ(), null); | ||||
|                         } | ||||
|                     }, () -> player.sendMessage("Regen complete")); | ||||
|                 return true; | ||||
| @@ -444,10 +461,10 @@ import java.util.Set; | ||||
|                 if (area.TYPE != 2) { | ||||
|                     center = WorldUtil.IMP.getSpawn(area.worldname); | ||||
|                 } else { | ||||
|                     RegionWrapper region = area.getRegion(); | ||||
|                     CuboidRegion region = area.getRegion(); | ||||
|                     center = | ||||
|                         new Location(area.worldname, region.minX + (region.maxX - region.minX) / 2, | ||||
|                             0, region.minZ + (region.maxZ - region.minZ) / 2); | ||||
|                         new Location(area.worldname, region.getMinimumPoint().getX() + (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2, | ||||
|                             0, region.getMinimumPoint().getZ() + (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2); | ||||
|                     center.setY(1 + WorldUtil.IMP | ||||
|                         .getHighestBlock(area.worldname, center.getX(), center.getZ())); | ||||
|                 } | ||||
|   | ||||
| @@ -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.Settings; | ||||
| 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.EconHandler; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.MainUtil; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.Permissions; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.TaskManager; | ||||
|  | ||||
| import org.jetbrains.annotations.Nullable; | ||||
|  | ||||
| import java.util.Set; | ||||
|  | ||||
| @CommandDeclaration(command = "auto", permission = "plots.auto", | ||||
|   | ||||
| @@ -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.Settings; | ||||
| 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.EconHandler; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.Permissions; | ||||
|   | ||||
| @@ -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.Settings; | ||||
| 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.Permissions; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; | ||||
|   | ||||
| @@ -4,12 +4,19 @@ import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; | ||||
| import com.github.intellectualsites.plotsquared.plot.PlotSquared; | ||||
| import com.github.intellectualsites.plotsquared.plot.config.Captions; | ||||
| 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.MainUtil; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; | ||||
| import com.google.common.collect.BiMap; | ||||
| import com.sk89q.worldedit.math.BlockVector2; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Map; | ||||
| @@ -55,7 +62,7 @@ public class DebugClaimTest extends SubCommand { | ||||
|                 continue; | ||||
|             } | ||||
|             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(() -> { | ||||
|                 String[] lines = WorldUtil.IMP.getSign(location); | ||||
|                 if (lines != null) { | ||||
|   | ||||
| @@ -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.generator.HybridUtils; | ||||
| import com.github.intellectualsites.plotsquared.plot.listener.WEManager; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.*; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.*; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer; | ||||
| 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.expiry.ExpireManager; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis; | ||||
| import com.google.common.io.Files; | ||||
| import com.sk89q.worldedit.world.block.BlockState; | ||||
|  | ||||
| import javax.script.Bindings; | ||||
| import javax.script.ScriptContext; | ||||
| @@ -103,7 +124,7 @@ import java.util.concurrent.CompletableFuture; | ||||
|  | ||||
|         // Classes | ||||
|         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("PlotId", PlotId.class); | ||||
|         this.scope.put("Runnable", Runnable.class); | ||||
|   | ||||
| @@ -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.Settings; | ||||
| 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.FlagManager; | ||||
| import com.github.intellectualsites.plotsquared.plot.flag.Flags; | ||||
| import com.github.intellectualsites.plotsquared.plot.flag.IntegerFlag; | ||||
| 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.Plot; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.MainUtil; | ||||
| 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.StringComparison; | ||||
| 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", | ||||
|     "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) { | ||||
|             } | ||||
|         } else if (flag instanceof PlotBlockListFlag) { | ||||
|             final PlotBlockListFlag blockListFlag = (PlotBlockListFlag) flag; | ||||
|             final HashSet<PlotBlock> parsedBlocks = blockListFlag.parseValue(value); | ||||
|             for (final PlotBlock block : parsedBlocks) { | ||||
|         } else if (flag instanceof BlockStateListFlag) { | ||||
|             final BlockStateListFlag blockListFlag = (BlockStateListFlag) flag; | ||||
|             Set<BlockType> parsedBlocks = blockListFlag.parseValue(value); | ||||
|             for (final BlockType block : parsedBlocks) { | ||||
|                 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); | ||||
|                 if (!result) { | ||||
|                     MainUtil.sendMessage(player, Captions.NO_PERMISSION, | ||||
|   | ||||
| @@ -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.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", | ||||
|     usage = "/plot like [next|purge]", category = CommandCategory.INFO, | ||||
|   | ||||
| @@ -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.Rating; | ||||
| 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 java.util.ArrayList; | ||||
|   | ||||
| @@ -5,7 +5,14 @@ import com.github.intellectualsites.plotsquared.commands.CommandCaller; | ||||
| import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; | ||||
| import com.github.intellectualsites.plotsquared.plot.config.Captions; | ||||
| 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.EconHandler; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.Permissions; | ||||
|   | ||||
| @@ -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.PlotItemStack; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; | ||||
| import com.sk89q.worldedit.world.item.ItemTypes; | ||||
|  | ||||
| import java.util.Arrays; | ||||
| import java.util.Collection; | ||||
| @@ -39,11 +40,11 @@ import java.util.Locale; | ||||
|                 if (item == null) { | ||||
|                     return true; | ||||
|                 } | ||||
|                 if (item.getPlotBlock().equalsAny(7, "bedrock")) { | ||||
|                 if (item.getType() == ItemTypes.BEDROCK) { | ||||
|                     plot.removeFlag(Flags.MUSIC); | ||||
|                     Captions.FLAG_REMOVED.send(player); | ||||
|                 } 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); | ||||
|                 } else { | ||||
|                     Captions.FLAG_NOT_ADDED.send(player); | ||||
|   | ||||
| @@ -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.database.DBFunc; | ||||
| import com.github.intellectualsites.plotsquared.plot.flag.Flags; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.*; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.*; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.Plot; | ||||
| 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.HashMap; | ||||
|   | ||||
| @@ -43,7 +43,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil; | ||||
|             MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD); | ||||
|             return false; | ||||
|         } | ||||
|         //Set<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name); | ||||
|         //Set<BlockVector2> chunks = ChunkManager.manager.getChunkChunks(name); | ||||
|         MainUtil | ||||
|             .sendMessage(player, "&cIf no schematic is set, the following will not do anything"); | ||||
|         MainUtil.sendMessage(player, | ||||
|   | ||||
| @@ -3,7 +3,11 @@ package com.github.intellectualsites.plotsquared.plot.commands; | ||||
| import com.github.intellectualsites.plotsquared.commands.Command; | ||||
| import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; | ||||
| 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.block.LocalBlockQueue; | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,11 @@ package com.github.intellectualsites.plotsquared.plot.commands; | ||||
| import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; | ||||
| import com.github.intellectualsites.plotsquared.plot.PlotSquared; | ||||
| 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.Permissions; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; | ||||
|   | ||||
| @@ -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.object.BlockBucket; | ||||
| 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.PlotPlayer; | ||||
| 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.WorldUtil; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; | ||||
| import com.sk89q.worldedit.world.block.BlockState; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| @@ -60,7 +60,7 @@ import java.util.stream.IntStream; | ||||
|                                 Captions.PERMISSION_SET_COMPONENT.f(component)); | ||||
|                             return false; | ||||
|                         } | ||||
|                         // PlotBlock[] blocks; | ||||
|                         // BlockState[] blocks; | ||||
|                         BlockBucket bucket; | ||||
|                         try { | ||||
|                             if (args.length < 2) { | ||||
| @@ -73,7 +73,7 @@ import java.util.stream.IntStream; | ||||
|                             } catch (final UnknownBlockException unknownBlockException) { | ||||
|                                 final String unknownBlock = unknownBlockException.getUnknownValue(); | ||||
|                                 Captions.NOT_VALID_BLOCK.send(player, unknownBlock); | ||||
|                                 StringComparison<PlotBlock>.ComparisonResult match = | ||||
|                                 StringComparison<BlockState>.ComparisonResult match = | ||||
|                                     WorldUtil.IMP.getClosestBlock(unknownBlock); | ||||
|                                 if (match != null) { | ||||
|                                     final String found = | ||||
| @@ -87,8 +87,8 @@ import java.util.stream.IntStream; | ||||
|                             } | ||||
|  | ||||
|                             if (!allowUnsafe) { | ||||
|                                 for (final PlotBlock block : bucket.getBlocks()) { | ||||
|                                     if (!block.isAir() && !WorldUtil.IMP.isBlockSolid(block)) { | ||||
|                                 for (final BlockState block : bucket.getBlocks()) { | ||||
|                                     if (!block.getBlockType().getMaterial().isAir() && !WorldUtil.IMP.isBlockSolid(block)) { | ||||
|                                         Captions.NOT_ALLOWED_BLOCK.send(player, block.toString()); | ||||
|                                         return false; | ||||
|                                     } | ||||
|   | ||||
| @@ -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.StringMan; | ||||
| 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 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.UUID; | ||||
|  | ||||
| @CommandDeclaration(command = "setup", permission = "plots.admin.command.setup", | ||||
|     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()); | ||||
|                 } | ||||
|                 if (valid) { | ||||
|                     sendMessage(player, Captions.SETUP_VALID_ARG, step.getConstant(), args[0]); | ||||
|                     step.setValue(args[0]); | ||||
|                     Object value = step.getValue(); | ||||
|                     sendMessage(player, Captions.SETUP_VALID_ARG, step.getConstant(), value); | ||||
|                     object.setup_index++; | ||||
|                     if (object.setup_index == object.step.length) { | ||||
|                         onCommand(player, args); | ||||
|   | ||||
| @@ -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.ConfigurationNode; | ||||
| 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.SetupUtils; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.TaskManager; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; | ||||
| 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.zip.ZipEntry; | ||||
| import java.util.zip.ZipInputStream; | ||||
|   | ||||
| @@ -3,7 +3,13 @@ package com.github.intellectualsites.plotsquared.plot.commands; | ||||
| import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; | ||||
| import com.github.intellectualsites.plotsquared.plot.PlotSquared; | ||||
| 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.MainUtil; | ||||
| 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.LocalBlockQueue; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; | ||||
| import com.sk89q.worldedit.math.BlockVector2; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.io.IOException; | ||||
| @@ -31,7 +38,7 @@ import java.util.Set; | ||||
|     public static ArrayList<Plot> expired = null; | ||||
|     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) { | ||||
|         if (Trim.TASK) { | ||||
|             return false; | ||||
| @@ -71,7 +78,7 @@ import java.util.Set; | ||||
|                     String[] split = name.split("\\."); | ||||
|                     int x = Integer.parseInt(split[1]); | ||||
|                     int z = Integer.parseInt(split[2]); | ||||
|                     ChunkLoc loc = new ChunkLoc(x, z); | ||||
|                     BlockVector2 loc = BlockVector2.at(x, z); | ||||
|                     empty.add(loc); | ||||
|                 } catch (NumberFormatException ignored) { | ||||
|                     PlotSquared.debug("INVALID MCA: " + name); | ||||
| @@ -90,7 +97,7 @@ import java.util.Set; | ||||
|      * @return | ||||
|      */ | ||||
|     public static boolean getTrimRegions(String world, | ||||
|         final RunnableVal2<Set<ChunkLoc>, Set<ChunkLoc>> result) { | ||||
|         final RunnableVal2<Set<BlockVector2>, Set<BlockVector2>> result) { | ||||
|         if (result == null) { | ||||
|             return false; | ||||
|         } | ||||
| @@ -114,7 +121,7 @@ import java.util.Set; | ||||
|                 int ccz2 = pos2.getZ() >> 9; | ||||
|                 for (int x = ccx1; x <= ccx2; x++) { | ||||
|                     for (int z = ccz1; z <= ccz2; z++) { | ||||
|                         ChunkLoc loc = new ChunkLoc(x, z); | ||||
|                         BlockVector2 loc = BlockVector2.at(x, z); | ||||
|                         if (result.value1.remove(loc)) { | ||||
|                             result.value2.add(loc); | ||||
|                         } | ||||
| @@ -141,8 +148,8 @@ import java.util.Set; | ||||
|         } | ||||
|         Trim.TASK = true; | ||||
|         final boolean regen = args.length == 2 && Boolean.parseBoolean(args[1]); | ||||
|         getTrimRegions(world, new RunnableVal2<Set<ChunkLoc>, Set<ChunkLoc>>() { | ||||
|             @Override public void run(Set<ChunkLoc> viable, final Set<ChunkLoc> nonViable) { | ||||
|         getTrimRegions(world, new RunnableVal2<Set<BlockVector2>, Set<BlockVector2>>() { | ||||
|             @Override public void run(Set<BlockVector2> viable, final Set<BlockVector2> nonViable) { | ||||
|                 Runnable regenTask; | ||||
|                 if (regen) { | ||||
|                     PlotSquared.log("Starting regen task:"); | ||||
| @@ -155,43 +162,43 @@ import java.util.Set; | ||||
|                                 player.sendMessage("Trim done!"); | ||||
|                                 return; | ||||
|                             } | ||||
|                             Iterator<ChunkLoc> iterator = nonViable.iterator(); | ||||
|                             ChunkLoc mcr = iterator.next(); | ||||
|                             Iterator<BlockVector2> iterator = nonViable.iterator(); | ||||
|                             BlockVector2 mcr = iterator.next(); | ||||
|                             iterator.remove(); | ||||
|                             int cbx = mcr.x << 5; | ||||
|                             int cbz = mcr.z << 5; | ||||
|                             int cbx = mcr.getX() << 5; | ||||
|                             int cbz = mcr.getZ() << 5; | ||||
|                             // get all 1024 chunks | ||||
|                             HashSet<ChunkLoc> chunks = new HashSet<>(); | ||||
|                             HashSet<BlockVector2> chunks = new HashSet<>(); | ||||
|                             for (int x = cbx; x < cbx + 32; x++) { | ||||
|                                 for (int z = cbz; z < cbz + 32; z++) { | ||||
|                                     ChunkLoc loc = new ChunkLoc(x, z); | ||||
|                                     BlockVector2 loc = BlockVector2.at(x, z); | ||||
|                                     chunks.add(loc); | ||||
|                                 } | ||||
|                             } | ||||
|                             int bx = cbx << 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)) { | ||||
|                                 Location bot = plot.getBottomAbs(); | ||||
|                                 Location top = plot.getExtendedTopAbs(); | ||||
|                                 RegionWrapper plotReg = | ||||
|                                     new RegionWrapper(bot.getX(), top.getX(), bot.getZ(), | ||||
|                                 CuboidRegion plotReg = | ||||
|                                     RegionUtil.createRegion(bot.getX(), top.getX(), bot.getZ(), | ||||
|                                         top.getZ()); | ||||
|                                 if (!region.intersects(plotReg)) { | ||||
|                                 if (!RegionUtil.intersects(region, plotReg)) { | ||||
|                                     continue; | ||||
|                                 } | ||||
|                                 for (int x = plotReg.minX >> 4; x <= plotReg.maxX >> 4; x++) { | ||||
|                                     for (int z = plotReg.minZ >> 4; z <= plotReg.maxZ >> 4; z++) { | ||||
|                                         ChunkLoc loc = new ChunkLoc(x, z); | ||||
|                                 for (int x = plotReg.getMinimumPoint().getX() >> 4; x <= plotReg.getMaximumPoint().getX() >> 4; x++) { | ||||
|                                     for (int z = plotReg.getMinimumPoint().getZ() >> 4; z <= plotReg.getMaximumPoint().getZ() >> 4; z++) { | ||||
|                                         BlockVector2 loc = BlockVector2.at(x, z); | ||||
|                                         chunks.remove(loc); | ||||
|                                     } | ||||
|                                 } | ||||
|                             } | ||||
|                             final LocalBlockQueue queue = | ||||
|                                 GlobalBlockQueue.IMP.getNewQueue(world, false); | ||||
|                             TaskManager.objectTask(chunks, new RunnableVal<ChunkLoc>() { | ||||
|                                 @Override public void run(ChunkLoc value) { | ||||
|                                     queue.regenChunk(value.x, value.z); | ||||
|                             TaskManager.objectTask(chunks, new RunnableVal<BlockVector2>() { | ||||
|                                 @Override public void run(BlockVector2 value) { | ||||
|                                     queue.regenChunk(value.getX(), value.getZ()); | ||||
|                                 } | ||||
|                             }, this); | ||||
|                         } | ||||
|   | ||||
| @@ -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.Settings; | ||||
| 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.MathMan; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.Permissions; | ||||
| 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; | ||||
|  | ||||
| @CommandDeclaration(command = "visit", permission = "plots.visit", | ||||
|   | ||||
| @@ -14,7 +14,11 @@ import java.lang.annotation.Target; | ||||
| import java.lang.invoke.MethodHandles; | ||||
| import java.lang.reflect.Field; | ||||
| 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 { | ||||
|  | ||||
| @@ -361,12 +365,8 @@ public class Config { | ||||
|      * @throws NoSuchFieldException | ||||
|      * @throws IllegalAccessException | ||||
|      */ | ||||
|     private static void setAccessible(Field field) | ||||
|         throws NoSuchFieldException, IllegalAccessException { | ||||
|     private static void setAccessible(Field field) { | ||||
|         field.setAccessible(true); | ||||
|         Field modifiersField = Field.class.getDeclaredField("modifiers"); | ||||
|         modifiersField.setAccessible(true); | ||||
|         modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -1,12 +1,18 @@ | ||||
| package com.github.intellectualsites.plotsquared.plot.config; | ||||
|  | ||||
| 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.StringMan; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; | ||||
| import com.sk89q.worldedit.world.block.BlockState; | ||||
| import lombok.Getter; | ||||
| import lombok.NonNull; | ||||
|  | ||||
| import java.util.Arrays; | ||||
| import java.util.regex.Matcher; | ||||
| import java.util.regex.Pattern; | ||||
|  | ||||
| /** | ||||
|  * Main Configuration Utility | ||||
|  */ | ||||
| @@ -57,30 +63,28 @@ public class Configuration { | ||||
|  | ||||
|     public static final 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) { | ||||
|                 if (string == null || string.isEmpty()) { | ||||
|                     return new BlockBucket(); | ||||
|                 } | ||||
|                 final BlockBucket blockBucket = new BlockBucket(); | ||||
|                 final String[] parts = string.split(","); | ||||
|                 final String[] parts = string.split(",(?![^\\(\\[]*[\\]\\)])"); | ||||
|                 for (final String part : parts) { | ||||
|                     String block; | ||||
|                     int chance = -1; | ||||
|  | ||||
|                     if (part.contains(":")) { | ||||
|                         final String[] innerParts = part.split(":"); | ||||
|                         if (innerParts.length > 1) { | ||||
|                             chance = Integer.parseInt(innerParts[1]); | ||||
|                         } | ||||
|                         block = innerParts[0]; | ||||
|                     } else { | ||||
|                         block = part; | ||||
|                     } | ||||
|                     final StringComparison<PlotBlock>.ComparisonResult value = | ||||
|                     Matcher matcher = pattern.matcher(part); | ||||
|                     matcher.find(); | ||||
|                     String namespace = matcher.group("namespace"); | ||||
|                     String block = matcher.group("block"); | ||||
|                     String chanceStr = matcher.group("chance"); | ||||
|                     if (namespace == null) namespace = "minecraft"; | ||||
|                     int chance = chanceStr == null ? -1 : Integer.parseInt(chanceStr); | ||||
|                     final StringComparison<BlockState>.ComparisonResult value = | ||||
|                         WorldUtil.IMP.getClosestBlock(block); | ||||
|                     if (value == null) { | ||||
|                         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)) { | ||||
|                         throw new UnsafeBlockException(value.best); | ||||
|                     } | ||||
| @@ -95,26 +99,24 @@ public class Configuration { | ||||
|                     if (string == null || string.isEmpty()) { | ||||
|                         return false; | ||||
|                     } | ||||
|                     final String[] parts = string.split(","); | ||||
|                     final String[] parts = string.split(",(?![^\\(\\[]*[\\]\\)])"); | ||||
|                     for (final String part : parts) { | ||||
|                         String block; | ||||
|                         if (part.contains(":")) { | ||||
|                             final String[] innerParts = part.split(":"); | ||||
|                             if (innerParts.length > 1) { | ||||
|                                 final int chance = Integer.parseInt(innerParts[1]); | ||||
|                                 if (chance < 1 || chance > 100) { | ||||
|                         Matcher matcher = pattern.matcher(part); | ||||
|                         matcher.find(); | ||||
|                         String namespace = matcher.group("namespace"); | ||||
|                         String block = matcher.group("block"); | ||||
|                         String chanceStr = matcher.group("chance"); | ||||
|                         if (namespace == null) namespace = "minecraft"; | ||||
|                         int chance = chanceStr == null ? -1 : Integer.parseInt(chanceStr); | ||||
|  | ||||
|                         if ((chance != -1 && (chance < 1 || chance > 100)) || block == null) { | ||||
|                             return false; | ||||
|                         } | ||||
|                             } | ||||
|                             block = innerParts[0]; | ||||
|                         } else { | ||||
|                             block = part; | ||||
|                         } | ||||
|                         StringComparison<PlotBlock>.ComparisonResult value = | ||||
|                         StringComparison<BlockState>.ComparisonResult value = | ||||
|                             WorldUtil.IMP.getClosestBlock(block); | ||||
|                         if (value == null || value.match > 1) { | ||||
|                             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)) { | ||||
|                             throw new UnsafeBlockException(value.best); | ||||
|                         } | ||||
| @@ -162,9 +164,9 @@ public class Configuration { | ||||
|  | ||||
|     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)); | ||||
|             this.unsafeBlock = unsafeBlock; | ||||
|         } | ||||
|   | ||||
| @@ -1,8 +1,8 @@ | ||||
| package com.github.intellectualsites.plotsquared.plot.config; | ||||
|  | ||||
| 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.sk89q.worldedit.world.block.BlockState; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| @@ -66,7 +66,7 @@ public class ConfigurationNode { | ||||
|         if (this.value instanceof BlockBucket) { | ||||
|             return this.value.toString(); | ||||
|         } | ||||
|         if (this.value instanceof PlotBlock) { | ||||
|         if (this.value instanceof BlockState) { | ||||
|             return this.value.toString(); | ||||
|         } | ||||
|         return this.value; | ||||
|   | ||||
| @@ -16,10 +16,10 @@ public class Settings extends Config { | ||||
|  | ||||
|     @Comment("These first 7 aren't configurable") // This is a comment | ||||
|     @Final // Indicates that this value isn't configurable | ||||
|     public static final String ISSUES = "https://github.com/IntellectualSites/PlotSquared/issues"; | ||||
|     @Final public static final String SUGGESTION = | ||||
|     public static String ISSUES = "https://github.com/IntellectualSites/PlotSquared/issues"; | ||||
|     @Final public static String SUGGESTION = | ||||
|         "https://github.com/IntellectualSites/PlotSquaredSuggestions"; | ||||
|     @Final public static final String WIKI = | ||||
|     @Final public static String WIKI = | ||||
|         "https://github.com/IntellectualSites/PlotSquared/wiki"; | ||||
|     @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 | ||||
|   | ||||
| @@ -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.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 | ||||
|   | ||||
| @@ -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.flag.Flag; | ||||
| 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.util.MainUtil; | ||||
| 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 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.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.Queue; | ||||
| import java.util.Set; | ||||
| import java.util.UUID; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.concurrent.ConcurrentLinkedQueue; | ||||
| import java.util.concurrent.atomic.AtomicInteger; | ||||
| @@ -857,10 +878,10 @@ import java.util.concurrent.atomic.AtomicInteger; | ||||
|                 statement.setInt(i * 10 + 9, hash); | ||||
|                 BlockLoc loc = pair.settings.getPosition(); | ||||
|                 String position; | ||||
|                 if (loc.y == 0) { | ||||
|                 if (loc.getY() == 0) { | ||||
|                     position = "DEFAULT"; | ||||
|                 } else { | ||||
|                     position = loc.x + "," + loc.y + ',' + loc.z; | ||||
|                     position = loc.getX() + "," + loc.getY() + ',' + loc.getZ(); | ||||
|                 } | ||||
|                 statement.setString(i * 10 + 10, position); | ||||
|             } | ||||
| @@ -898,10 +919,10 @@ import java.util.concurrent.atomic.AtomicInteger; | ||||
|                 stmt.setInt(i * 10 + 9, n); | ||||
|                 BlockLoc loc = pair.settings.getPosition(); | ||||
|                 String position; | ||||
|                 if (loc.y == 0) { | ||||
|                 if (loc.getY() == 0) { | ||||
|                     position = "DEFAULT"; | ||||
|                 } else { | ||||
|                     position = loc.x + "," + loc.y + ',' + loc.z; | ||||
|                     position = loc.getX() + "," + loc.getY() + ',' + loc.getZ(); | ||||
|                 } | ||||
|                 stmt.setString(i * 10 + 10, position); | ||||
|             } | ||||
|   | ||||
| @@ -4,7 +4,11 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared; | ||||
|  | ||||
| import java.io.File; | ||||
| 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. | ||||
|   | ||||
| @@ -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()); | ||||
|     } | ||||
| } | ||||
| @@ -10,7 +10,12 @@ import com.github.intellectualsites.plotsquared.plot.util.EventUtil; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.Permissions; | ||||
| 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; | ||||
|  | ||||
| /** | ||||
|   | ||||
| @@ -58,9 +58,9 @@ public final class Flags { | ||||
|     public static final BooleanFlag BLOCK_IGNITION = new BooleanFlag("block-ignition"); | ||||
|     public static final BooleanFlag SOIL_DRY = new BooleanFlag("soil-dry"); | ||||
|     public static final StringListFlag BLOCKED_CMDS = new StringListFlag("blocked-cmds"); | ||||
|     public static final PlotBlockListFlag USE = new PlotBlockListFlag("use"); | ||||
|     public static final PlotBlockListFlag BREAK = new PlotBlockListFlag("break"); | ||||
|     public static final PlotBlockListFlag PLACE = new PlotBlockListFlag("place"); | ||||
|     public static final BlockStateListFlag USE = new BlockStateListFlag("use"); | ||||
|     public static final BlockStateListFlag BREAK = new BlockStateListFlag("break"); | ||||
|     public static final BlockStateListFlag PLACE = new BlockStateListFlag("place"); | ||||
|     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_PLACE = new BooleanFlag("vehicle-place"); | ||||
|   | ||||
| @@ -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(); | ||||
|     } | ||||
| } | ||||
| @@ -1,6 +1,5 @@ | ||||
| package com.github.intellectualsites.plotsquared.plot.flag; | ||||
|  | ||||
|  | ||||
| import com.github.intellectualsites.plotsquared.plot.config.Captions; | ||||
|  | ||||
| public class StringFlag extends Flag<String> { | ||||
|   | ||||
| @@ -3,14 +3,15 @@ package com.github.intellectualsites.plotsquared.plot.generator; | ||||
| import com.github.intellectualsites.plotsquared.plot.PlotSquared; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.Location; | ||||
| 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.RegionWrapper; | ||||
| import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil; | ||||
| import com.sk89q.worldedit.regions.CuboidRegion; | ||||
| 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.LocalBlockQueue; | ||||
| 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 java.util.Set; | ||||
| @@ -33,7 +34,7 @@ public class AugmentedUtils { | ||||
|  | ||||
|         final int blockX = chunkX << 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); | ||||
|         if (areas.isEmpty()) { | ||||
|             return false; | ||||
| @@ -59,12 +60,12 @@ public class AugmentedUtils { | ||||
|             int tzz; | ||||
|             // gen | ||||
|             if (area.TYPE == 2) { | ||||
|                 bxx = Math.max(0, area.getRegion().minX - blockX); | ||||
|                 bzz = Math.max(0, area.getRegion().minZ - blockZ); | ||||
|                 txx = Math.min(15, area.getRegion().maxX - blockX); | ||||
|                 tzz = Math.min(15, area.getRegion().maxZ - blockZ); | ||||
|                 bxx = Math.max(0, area.getRegion().getMinimumPoint().getX() - blockX); | ||||
|                 bzz = Math.max(0, area.getRegion().getMinimumPoint().getZ() - blockZ); | ||||
|                 txx = Math.min(15, area.getRegion().getMaximumPoint().getX() - blockX); | ||||
|                 tzz = Math.min(15, area.getRegion().getMaximumPoint().getZ() - blockZ); | ||||
|                 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)) { | ||||
|                             return super.setBlock(x, y, z, id); | ||||
|                         } | ||||
| @@ -84,7 +85,7 @@ public class AugmentedUtils { | ||||
|                 primaryMask = queue; | ||||
|             } | ||||
|             LocalBlockQueue secondaryMask; | ||||
|             PlotBlock air = StringPlotBlock.EVERYTHING; | ||||
|             BlockState air = BlockTypes.AIR.getDefaultState(); | ||||
|             if (area.TERRAIN == 2) { | ||||
|                 PlotManager manager = area.getPlotManager(); | ||||
|                 final boolean[][] canPlace = new boolean[16][16]; | ||||
| @@ -108,7 +109,7 @@ public class AugmentedUtils { | ||||
|                 } | ||||
|                 toReturn = true; | ||||
|                 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]) { | ||||
|                             return super.setBlock(x, y, z, id); | ||||
|                         } | ||||
|   | ||||
| @@ -1,8 +1,14 @@ | ||||
| package com.github.intellectualsites.plotsquared.plot.generator; | ||||
|  | ||||
| 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.world.BlockUtil; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; | ||||
| 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) { | ||||
|         setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING); | ||||
|         if (!classicPlotWorld.WALL_BLOCK.isAir() || !classicPlotWorld.WALL_BLOCK.equals(classicPlotWorld.CLAIMED_WALL_BLOCK)) { | ||||
|             setWall(plot.getId(), classicPlotWorld.WALL_BLOCK); | ||||
|         } | ||||
|         return GlobalBlockQueue.IMP.addEmptyTask(whenDone); | ||||
|     } | ||||
|  | ||||
| @@ -53,11 +61,11 @@ public class ClassicPlotManager extends SquarePlotManager { | ||||
|         Plot plot = classicPlotWorld.getPlotAbs(plotId); | ||||
|         LocalBlockQueue queue = classicPlotWorld.getQueue(false); | ||||
|         if (plot.isBasePlot()) { | ||||
|             for (RegionWrapper region : plot.getRegions()) { | ||||
|             for (CuboidRegion region : plot.getRegions()) { | ||||
|                 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 = | ||||
|                     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); | ||||
|             } | ||||
|         } | ||||
| @@ -71,9 +79,9 @@ public class ClassicPlotManager extends SquarePlotManager { | ||||
|         } | ||||
|         LocalBlockQueue queue = classicPlotWorld.getQueue(false); | ||||
|         int maxY = getWorldHeight(); | ||||
|         for (RegionWrapper region : plot.getRegions()) { | ||||
|             Location pos1 = new Location(classicPlotWorld.worldname, region.minX, 1, region.minZ); | ||||
|             Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ); | ||||
|         for (CuboidRegion region : plot.getRegions()) { | ||||
|             Location pos1 = new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), 1, region.getMinimumPoint().getZ()); | ||||
|             Location pos2 = new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), maxY, region.getMaximumPoint().getZ()); | ||||
|             queue.setCuboid(pos1, pos2, blocks); | ||||
|         } | ||||
|         return queue.enqueue(); | ||||
| @@ -86,10 +94,10 @@ public class ClassicPlotManager extends SquarePlotManager { | ||||
|         } | ||||
|         LocalBlockQueue queue = classicPlotWorld.getQueue(false); | ||||
|         int maxY = getWorldHeight(); | ||||
|         for (RegionWrapper region : plot.getRegions()) { | ||||
|         for (CuboidRegion region : plot.getRegions()) { | ||||
|             Location pos1 = | ||||
|                 new Location(classicPlotWorld.worldname, region.minX, classicPlotWorld.PLOT_HEIGHT + 1, region.minZ); | ||||
|             Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ); | ||||
|                 new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), classicPlotWorld.PLOT_HEIGHT + 1, region.getMinimumPoint().getZ()); | ||||
|             Location pos2 = new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), maxY, region.getMaximumPoint().getZ()); | ||||
|             queue.setCuboid(pos1, pos2, blocks); | ||||
|         } | ||||
|         return queue.enqueue(); | ||||
| @@ -101,10 +109,10 @@ public class ClassicPlotManager extends SquarePlotManager { | ||||
|             return false; | ||||
|         } | ||||
|         LocalBlockQueue queue = classicPlotWorld.getQueue(false); | ||||
|         for (RegionWrapper region : plot.getRegions()) { | ||||
|             Location pos1 = new Location(classicPlotWorld.worldname, region.minX, 1, region.minZ); | ||||
|         for (CuboidRegion region : plot.getRegions()) { | ||||
|             Location pos1 = new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), 1, region.getMinimumPoint().getZ()); | ||||
|             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); | ||||
|         } | ||||
|         return queue.enqueue(); | ||||
| @@ -167,9 +175,9 @@ public class ClassicPlotManager extends SquarePlotManager { | ||||
|             } | ||||
|         } | ||||
|         if (plot.isBasePlot()) { | ||||
|             for (RegionWrapper region : plot.getRegions()) { | ||||
|                 Location pos1 = new Location(classicPlotWorld.worldname, region.minX, maxY, region.minZ); | ||||
|                 Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ); | ||||
|             for (CuboidRegion region : plot.getRegions()) { | ||||
|                 Location pos1 = new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), maxY, region.getMinimumPoint().getZ()); | ||||
|                 Location pos2 = new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), maxY, region.getMaximumPoint().getZ()); | ||||
|                 queue.setCuboid(pos1, pos2, blocks); | ||||
|             } | ||||
|         } | ||||
| @@ -278,9 +286,9 @@ public class ClassicPlotManager extends SquarePlotManager { | ||||
|         queue.setCuboid( | ||||
|             new Location(classicPlotWorld.worldname, sx, Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 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), | ||||
|             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), | ||||
|             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), | ||||
| @@ -306,9 +314,9 @@ public class ClassicPlotManager extends SquarePlotManager { | ||||
|             new Location(classicPlotWorld.worldname, sx + 1, Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, | ||||
|                 sz), | ||||
|             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), | ||||
|             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), | ||||
|             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), | ||||
| @@ -331,10 +339,10 @@ public class ClassicPlotManager extends SquarePlotManager { | ||||
|         LocalBlockQueue queue = classicPlotWorld.getQueue(false); | ||||
|         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), | ||||
|             PlotBlock.get((short) 0, (byte) 0)); | ||||
|             BlockUtil.get((short) 0, (byte) 0)); | ||||
|         queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 0, sz + 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), | ||||
|             new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK); | ||||
|         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, | ||||
|                 sz), | ||||
|             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), | ||||
|             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), | ||||
| @@ -372,7 +380,7 @@ public class ClassicPlotManager extends SquarePlotManager { | ||||
|             new Location(classicPlotWorld.worldname, sx, Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, | ||||
|                 sz), | ||||
|             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), | ||||
|             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), | ||||
| @@ -389,7 +397,7 @@ public class ClassicPlotManager extends SquarePlotManager { | ||||
|         LocalBlockQueue queue = classicPlotWorld.getQueue(false); | ||||
|         queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT + 1, sz), | ||||
|             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), | ||||
|             new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK); | ||||
|         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. | ||||
|      */ | ||||
|     @Override public boolean finishPlotMerge(List<PlotId> plotIds) { | ||||
|         final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK; | ||||
|         boolean success = true; | ||||
|         final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK; | ||||
|         if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) { | ||||
|             for (PlotId plotId : plotIds) { | ||||
|             success &= setWall(plotId, block); | ||||
|                 setWall(plotId, claim); | ||||
|             } | ||||
|         } | ||||
|         if (Settings.General.MERGE_REPLACE_WALL) { | ||||
|             final BlockBucket wallBlock = classicPlotWorld.WALL_FILLING; | ||||
|             for (PlotId id : plotIds) { | ||||
|                 success &= setWallFilling(id, wallBlock); | ||||
|                 setWallFilling(id, wallBlock); | ||||
|             } | ||||
|         } | ||||
|         return success; | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override public boolean finishPlotUnlink(List<PlotId> plotIds) { | ||||
|         final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK; | ||||
|         boolean success = true; | ||||
|         final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK; | ||||
|         if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) { | ||||
|             for (PlotId id : plotIds) { | ||||
|             success &= setWall(id, block); | ||||
|         } | ||||
|         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); | ||||
|                 setWall(id, claim); | ||||
|             } | ||||
|         } | ||||
|         return success; | ||||
|         return true; // return false if unlink has been denied | ||||
|     } | ||||
|  | ||||
|     @Override public boolean startPlotMerge(List<PlotId> plotIds) { | ||||
| @@ -453,8 +446,11 @@ public class ClassicPlotManager extends SquarePlotManager { | ||||
|  | ||||
|     @Override public boolean claimPlot(Plot plot) { | ||||
|         final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK; | ||||
|         if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) { | ||||
|             return setWall(plot.getId(), claim); | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override public String[] getPlotComponents(PlotId plotId) { | ||||
|         return new String[] {"main", "floor", "air", "all", "border", "wall", "outline", "middle"}; | ||||
|   | ||||
| @@ -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.Settings; | ||||
| 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.util.world.BlockUtil; | ||||
| import org.jetbrains.annotations.NotNull; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| import java.lang.reflect.Field; | ||||
| import java.util.Locale; | ||||
|  | ||||
| @@ -19,18 +18,18 @@ import java.util.Locale; | ||||
|     public int ROAD_HEIGHT = 62; | ||||
|     public int PLOT_HEIGHT = 62; | ||||
|     public int WALL_HEIGHT = 62; | ||||
|     public BlockBucket MAIN_BLOCK = BlockBucket.withSingle(PlotBlock.get("stone")); | ||||
|     // new PlotBlock[] {PlotBlock.get("stone")}; | ||||
|     public BlockBucket TOP_BLOCK = BlockBucket.withSingle(PlotBlock.get("grass_block")); | ||||
|     //new PlotBlock[] {PlotBlock.get("grass")}; | ||||
|     public BlockBucket WALL_BLOCK = BlockBucket.withSingle(PlotBlock.get("stone_slab")); | ||||
|     // PlotBlock.get((short) 44, (byte) 0); | ||||
|     public BlockBucket CLAIMED_WALL_BLOCK = BlockBucket.withSingle(PlotBlock.get("sandstone_slab")); | ||||
|     // PlotBlock.get((short) 44, (byte) 1); | ||||
|     public BlockBucket WALL_FILLING = BlockBucket.withSingle(PlotBlock.get("stone")); | ||||
|     //PlotBlock.get((short) 1, (byte) 0); | ||||
|     public BlockBucket ROAD_BLOCK = BlockBucket.withSingle(PlotBlock.get("quartz_block")); | ||||
|     // PlotBlock.get((short) 155, (byte) 0); | ||||
|     public BlockBucket MAIN_BLOCK = BlockBucket.withSingle(BlockUtil.get("stone")); | ||||
|     // new BlockState[] {BlockUtil.get("stone")}; | ||||
|     public BlockBucket TOP_BLOCK = BlockBucket.withSingle(BlockUtil.get("grass_block")); | ||||
|     //new BlockState[] {BlockUtil.get("grass")}; | ||||
|     public BlockBucket WALL_BLOCK = BlockBucket.withSingle(BlockUtil.get("stone_slab")); | ||||
|     // BlockUtil.get((short) 44, (byte) 0); | ||||
|     public BlockBucket CLAIMED_WALL_BLOCK = BlockBucket.withSingle(BlockUtil.get("sandstone_slab")); | ||||
|     // BlockUtil.get((short) 44, (byte) 1); | ||||
|     public BlockBucket WALL_FILLING = BlockBucket.withSingle(BlockUtil.get("stone")); | ||||
|     //BlockUtil.get((short) 1, (byte) 0); | ||||
|     public BlockBucket ROAD_BLOCK = BlockBucket.withSingle(BlockUtil.get("quartz_block")); | ||||
|     // BlockUtil.get((short) 155, (byte) 0); | ||||
|     public boolean PLOT_BEDROCK = true; | ||||
|  | ||||
|     public ClassicPlotWorld(String worldName, String id, | ||||
|   | ||||
| @@ -2,8 +2,12 @@ package com.github.intellectualsites.plotsquared.plot.generator; | ||||
|  | ||||
| import com.github.intellectualsites.plotsquared.plot.PlotSquared; | ||||
| 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.world.BlockUtil; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; | ||||
| 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 z = 0; z < 16; z++) { | ||||
|                     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) { | ||||
|             for (short x = 0; x < 16; x++) { | ||||
|                 for (short z = 0; z < 16; z++) { | ||||
|                     result.setBlock(x, 0, z, PlotBlock.get("bedrock")); | ||||
|                     result.setBlock(x, 0, z, BlockUtil.get("bedrock")); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -3,14 +3,21 @@ package com.github.intellectualsites.plotsquared.plot.generator; | ||||
| import com.github.intellectualsites.plotsquared.plot.PlotSquared; | ||||
| import com.github.intellectualsites.plotsquared.plot.commands.Template; | ||||
| 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.MainUtil; | ||||
| 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.LocalBlockQueue; | ||||
| import com.google.common.collect.Sets; | ||||
| import com.sk89q.worldedit.world.block.BaseBlock; | ||||
| import com.sk89q.worldedit.world.block.BlockState; | ||||
| import com.sk89q.worldedit.world.block.BlockTypes; | ||||
|  | ||||
| import java.io.File; | ||||
| @@ -168,13 +175,13 @@ public class HybridPlotManager extends ClassicPlotManager { | ||||
|         // The component blocks | ||||
|         final BlockBucket plotfloor = hybridPlotWorld.TOP_BLOCK; | ||||
|         final BlockBucket filling = hybridPlotWorld.MAIN_BLOCK; | ||||
|         final PlotBlock bedrock; | ||||
|         final BlockState bedrock; | ||||
|         if (hybridPlotWorld.PLOT_BEDROCK) { | ||||
|             bedrock = PlotBlock.get((short) 7, (byte) 0); | ||||
|             bedrock = BlockUtil.get((short) 7, (byte) 0); | ||||
|         } 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 LocalBlockQueue queue = hybridPlotWorld.getQueue(false); | ||||
|         ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() { | ||||
|   | ||||
| @@ -14,7 +14,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MathMan; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; | ||||
| import com.sk89q.jnbt.CompoundTag; | ||||
| 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.internal.helper.MCDirections; | ||||
| import com.sk89q.worldedit.math.BlockVector3; | ||||
| @@ -178,7 +178,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { | ||||
|  | ||||
|         if (schematic3 != null) { | ||||
|             this.PLOT_SCHEMATIC = true; | ||||
|             BlockArrayClipboard blockArrayClipboard3 = schematic3.getClipboard(); | ||||
|             Clipboard blockArrayClipboard3 = schematic3.getClipboard(); | ||||
|  | ||||
|             BlockVector3 d3 = blockArrayClipboard3.getDimensions(); | ||||
|             short w3 = (short) d3.getX(); | ||||
| @@ -252,9 +252,9 @@ public class HybridPlotWorld extends ClassicPlotWorld { | ||||
|         } | ||||
|         this.ROAD_SCHEMATIC_ENABLED = true; | ||||
|         // 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(); | ||||
|         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(); | ||||
|         short w2 = (short) d2.getX(); | ||||
|         short l2 = (short) d2.getZ(); | ||||
|   | ||||
| @@ -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.Flags; | ||||
| 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.MathMan; | ||||
| 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.expiry.PlotAnalysis; | ||||
| import com.sk89q.jnbt.CompoundTag; | ||||
| import com.sk89q.worldedit.math.BlockVector2; | ||||
| import com.sk89q.worldedit.world.block.BaseBlock; | ||||
| import com.sk89q.worldedit.world.block.BlockState; | ||||
|  | ||||
| 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.AtomicInteger; | ||||
|  | ||||
| public abstract class HybridUtils { | ||||
|  | ||||
|     public static HybridUtils manager; | ||||
|     public static Set<ChunkLoc> regions; | ||||
|     public static Set<ChunkLoc> chunks = new HashSet<>(); | ||||
|     public static Set<BlockVector2> regions; | ||||
|     public static Set<BlockVector2> chunks = new HashSet<>(); | ||||
|     public static PlotArea area; | ||||
|     public static boolean UPDATE = false; | ||||
|  | ||||
|     public abstract void analyzeRegion(String world, RegionWrapper region, | ||||
|     public abstract void analyzeRegion(String world, CuboidRegion region, | ||||
|         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<>(); | ||||
|         Runnable run = new Runnable() { | ||||
|             @Override public void run() { | ||||
| @@ -82,7 +98,7 @@ public abstract class HybridUtils { | ||||
|                     TaskManager.runTask(whenDone); | ||||
|                     return; | ||||
|                 } | ||||
|                 RegionWrapper region = zones.poll(); | ||||
|                 CuboidRegion region = zones.poll(); | ||||
|                 final Runnable task = this; | ||||
|                 analyzeRegion(origin.getWorldName(), region, new RunnableVal<PlotAnalysis>() { | ||||
|                     @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, | ||||
|         PlotBlock[] blocks) { | ||||
|         BlockState[] blocks) { | ||||
|         int count = 0; | ||||
|         for (int y = y1; y <= y2; y++) { | ||||
|             for (int x = x1; x <= x2; x++) { | ||||
|                 for (int z = z1; z <= z2; z++) { | ||||
|                     PlotBlock block = queue.getBlock(x, y, z); | ||||
|                     BlockState block = queue.getBlock(x, y, z); | ||||
|                     boolean same = | ||||
|                         Arrays.stream(blocks).anyMatch(p -> WorldUtil.IMP.isBlockSame(block, p)); | ||||
|                     if (!same) { | ||||
| @@ -113,13 +129,13 @@ public abstract class HybridUtils { | ||||
|         return count; | ||||
|     } | ||||
|  | ||||
|     public final ArrayList<ChunkLoc> getChunks(ChunkLoc region) { | ||||
|         ArrayList<ChunkLoc> chunks = new ArrayList<>(); | ||||
|         int sx = region.x << 5; | ||||
|         int sz = region.z << 5; | ||||
|     public final ArrayList<BlockVector2> getChunks(BlockVector2 region) { | ||||
|         ArrayList<BlockVector2> chunks = new ArrayList<>(); | ||||
|         int sx = region.getX() << 5; | ||||
|         int sz = region.getZ() << 5; | ||||
|         for (int x = sx; x < sx + 32; x++) { | ||||
|             for (int z = sz; z < sz + 32; z++) { | ||||
|                 chunks.add(new ChunkLoc(x, z)); | ||||
|                 chunks.add(BlockVector2.at(x, z)); | ||||
|             } | ||||
|         } | ||||
|         return chunks; | ||||
| @@ -130,7 +146,7 @@ public abstract class HybridUtils { | ||||
|             return false; | ||||
|         } | ||||
|         HybridUtils.UPDATE = true; | ||||
|         Set<ChunkLoc> regions = ChunkManager.manager.getChunkChunks(area.worldname); | ||||
|         Set<BlockVector2> regions = ChunkManager.manager.getChunkChunks(area.worldname); | ||||
|         return scheduleRoadUpdate(area, regions, extend); | ||||
|     } | ||||
|  | ||||
| @@ -139,12 +155,12 @@ public abstract class HybridUtils { | ||||
|             return false; | ||||
|         } | ||||
|         HybridUtils.UPDATE = true; | ||||
|         Set<ChunkLoc> regions = new HashSet<>(); | ||||
|         regions.add(ChunkManager.getChunkChunk(plot.getCenter())); | ||||
|         Set<BlockVector2> regions = new HashSet<>(); | ||||
|         regions.add(ChunkManager.getRegion(plot.getCenter())); | ||||
|         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) { | ||||
|         HybridUtils.regions = regions; | ||||
|         HybridUtils.area = area; | ||||
| @@ -153,9 +169,9 @@ public abstract class HybridUtils { | ||||
|         TaskManager.runTask(new Runnable() { | ||||
|             @Override public void run() { | ||||
|                 if (!UPDATE) { | ||||
|                     Iterator<ChunkLoc> iter = chunks.iterator(); | ||||
|                     Iterator<BlockVector2> iter = chunks.iterator(); | ||||
|                     while (iter.hasNext()) { | ||||
|                         ChunkLoc chunk = iter.next(); | ||||
|                         BlockVector2 chunk = iter.next(); | ||||
|                         iter.remove(); | ||||
|                         boolean regenedRoad = regenerateRoad(area, chunk, extend); | ||||
|                         if (!regenedRoad) { | ||||
| @@ -183,10 +199,10 @@ public abstract class HybridUtils { | ||||
|                         try { | ||||
|                             if (chunks.size() < 1024) { | ||||
|                                 if (!HybridUtils.regions.isEmpty()) { | ||||
|                                     Iterator<ChunkLoc> iterator = HybridUtils.regions.iterator(); | ||||
|                                     ChunkLoc loc = iterator.next(); | ||||
|                                     Iterator<BlockVector2> iterator = HybridUtils.regions.iterator(); | ||||
|                                     BlockVector2 loc = iterator.next(); | ||||
|                                     iterator.remove(); | ||||
|                                     PlotSquared.debug("Updating .mcr: " + loc.x + ", " + loc.z | ||||
|                                     PlotSquared.debug("Updating .mcr: " + loc.getX() + ", " + loc.getZ() | ||||
|                                         + " (approx 1024 chunks)"); | ||||
|                                     PlotSquared | ||||
|                                         .debug(" - Remaining: " + HybridUtils.regions.size()); | ||||
| @@ -198,10 +214,10 @@ public abstract class HybridUtils { | ||||
|                                 TaskManager.IMP.sync(new RunnableVal<Object>() { | ||||
|                                     @Override public void run(Object value) { | ||||
|                                         long start = System.currentTimeMillis(); | ||||
|                                         Iterator<ChunkLoc> iterator = chunks.iterator(); | ||||
|                                         Iterator<BlockVector2> iterator = chunks.iterator(); | ||||
|                                         while (System.currentTimeMillis() - start < 20 && !chunks | ||||
|                                             .isEmpty()) { | ||||
|                                             final ChunkLoc chunk = iterator.next(); | ||||
|                                             final BlockVector2 chunk = iterator.next(); | ||||
|                                             iterator.remove(); | ||||
|                                             boolean regenedRoads = | ||||
|                                                 regenerateRoad(area, chunk, extend); | ||||
| @@ -214,18 +230,18 @@ public abstract class HybridUtils { | ||||
|                             } | ||||
|                         } catch (Exception e) { | ||||
|                             e.printStackTrace(); | ||||
|                             Iterator<ChunkLoc> iterator = HybridUtils.regions.iterator(); | ||||
|                             ChunkLoc loc = iterator.next(); | ||||
|                             Iterator<BlockVector2> iterator = HybridUtils.regions.iterator(); | ||||
|                             BlockVector2 loc = iterator.next(); | ||||
|                             iterator.remove(); | ||||
|                             PlotSquared.debug( | ||||
|                                 "[ERROR] Could not update '" + area.worldname + "/region/r." + loc.x | ||||
|                                     + "." + loc.z + ".mca' (Corrupt chunk?)"); | ||||
|                             int sx = loc.x << 5; | ||||
|                             int sz = loc.z << 5; | ||||
|                                 "[ERROR] Could not update '" + area.worldname + "/region/r." + loc.getX() | ||||
|                                     + "." + loc.getZ() + ".mca' (Corrupt chunk?)"); | ||||
|                             int sx = loc.getX() << 5; | ||||
|                             int sz = loc.getZ() << 5; | ||||
|                             for (int x = sx; x < sx + 32; x++) { | ||||
|                                 for (int z = sz; z < sz + 32; z++) { | ||||
|                                     ChunkManager.manager | ||||
|                                         .unloadChunk(area.worldname, new ChunkLoc(x, z), true); | ||||
|                                         .unloadChunk(area.worldname, BlockVector2.at(x, z), true); | ||||
|                                 } | ||||
|                             } | ||||
|                             PlotSquared.debug(" - Potentially skipping 1024 chunks"); | ||||
| @@ -256,10 +272,10 @@ public abstract class HybridUtils { | ||||
|         int tz = sz - 1; | ||||
|         int ty = get_ey(plotManager, queue, sx, ex, bz, tz, sy); | ||||
|  | ||||
|         Set<RegionWrapper> sideRoad = | ||||
|             new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ey, sz, ez))); | ||||
|         final Set<RegionWrapper> intersection = | ||||
|             new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ty, bz, tz))); | ||||
|         Set<CuboidRegion> sideRoad = | ||||
|             new HashSet<>(Collections.singletonList(RegionUtil.createRegion(sx, ex, sy, ey, sz, ez))); | ||||
|         final Set<CuboidRegion> intersection = | ||||
|             new HashSet<>(Collections.singletonList(RegionUtil.createRegion(sx, ex, sy, ty, bz, tz))); | ||||
|  | ||||
|         final String dir = | ||||
|             "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 y = sy; y <= pm.getWorldHeight(); y++) { | ||||
|                     if (y > ey) { | ||||
|                         PlotBlock block = queue.getBlock(x, y, z); | ||||
|                         if (!block.isAir()) { | ||||
|                         BlockState block = queue.getBlock(x, y, z); | ||||
|                         if (!block.getBlockType().getMaterial().isAir()) { | ||||
|                             ey = y; | ||||
|                         } | ||||
|                     } | ||||
| @@ -303,9 +319,9 @@ public abstract class HybridUtils { | ||||
|         return ey; | ||||
|     } | ||||
|  | ||||
|     public boolean regenerateRoad(final PlotArea area, final ChunkLoc chunk, int extend) { | ||||
|         int x = chunk.x << 4; | ||||
|         int z = chunk.z << 4; | ||||
|     public boolean regenerateRoad(final PlotArea area, final BlockVector2 chunk, int extend) { | ||||
|         int x = chunk.getX() << 4; | ||||
|         int z = chunk.getZ() << 4; | ||||
|         int ex = x + 15; | ||||
|         int ez = z + 15; | ||||
|         HybridPlotWorld plotWorld = (HybridPlotWorld) area; | ||||
|   | ||||
| @@ -1,7 +1,10 @@ | ||||
| package com.github.intellectualsites.plotsquared.plot.generator; | ||||
|  | ||||
| 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; | ||||
|  | ||||
| /** | ||||
|   | ||||
| @@ -1,13 +1,19 @@ | ||||
| package com.github.intellectualsites.plotsquared.plot.generator; | ||||
|  | ||||
| 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.MainUtil; | ||||
|  | ||||
| import java.util.Arrays; | ||||
| import java.util.HashSet; | ||||
| import java.util.Iterator; | ||||
| import java.util.Set; | ||||
|  | ||||
| /** | ||||
|  * A plot manager with a square grid layout, with square shaped plots. | ||||
| @@ -23,20 +29,20 @@ public abstract class SquarePlotManager extends GridPlotManager { | ||||
|  | ||||
|     @Override | ||||
|     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() { | ||||
|             @Override public void run() { | ||||
|                 if (regions.isEmpty()) { | ||||
|                     whenDone.run(); | ||||
|                     return; | ||||
|                 } | ||||
|                 Iterator<RegionWrapper> iterator = regions.iterator(); | ||||
|                 RegionWrapper region = iterator.next(); | ||||
|                 Iterator<CuboidRegion> iterator = regions.iterator(); | ||||
|                 CuboidRegion region = iterator.next(); | ||||
|                 iterator.remove(); | ||||
|                 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 = | ||||
|                     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); | ||||
|             } | ||||
|         }; | ||||
|   | ||||
| @@ -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.Plot; | ||||
| 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.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.sk89q.worldedit.world.item.ItemType; | ||||
| import com.sk89q.worldedit.world.item.ItemTypes; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| @@ -135,21 +146,21 @@ public class PlotListener { | ||||
|                 Optional<String> musicFlag = plot.getFlag(Flags.MUSIC); | ||||
|                 if (musicFlag.isPresent()) { | ||||
|                     final String id = musicFlag.get(); | ||||
|                     final PlotBlock block = PlotBlock.get(id); | ||||
|                     final String rawId = block.getRawId().toString(); | ||||
|                     if (rawId.contains("disc") || PlotBlock.isEverything(block) || block.isAir()) { | ||||
|                     final ItemType item = ItemUtil.get(id); | ||||
|                     final String rawId = item.getId(); | ||||
|                     if (rawId.contains("disc") || item == ItemTypes.AIR) { | ||||
|                         Location location = player.getLocation(); | ||||
|                         Location lastLocation = player.getMeta("music"); | ||||
|                         if (lastLocation != null) { | ||||
|                             player.playMusic(lastLocation, PlotBlock.get("air")); | ||||
|                             if (PlotBlock.isEverything(block) || block.isAir()) { | ||||
|                             player.playMusic(lastLocation, ItemTypes.AIR); | ||||
|                             if (item == ItemTypes.AIR) { | ||||
|                                 player.deleteMeta("music"); | ||||
|                             } | ||||
|                         } | ||||
|                         if (!(PlotBlock.isEverything(block) || block.isAir())) { | ||||
|                         if (!(item == ItemTypes.AIR)) { | ||||
|                             try { | ||||
|                                 player.setMeta("music", location); | ||||
|                                 player.playMusic(location, block); | ||||
|                                 player.playMusic(location, item); | ||||
|                             } catch (Exception ignored) { | ||||
|                             } | ||||
|                         } | ||||
| @@ -158,7 +169,7 @@ public class PlotListener { | ||||
|                     Location lastLoc = player.getMeta("music"); | ||||
|                     if (lastLoc != null) { | ||||
|                         player.deleteMeta("music"); | ||||
|                         player.playMusic(lastLoc, PlotBlock.get("air")); | ||||
|                         player.playMusic(lastLoc, ItemTypes.AIR); | ||||
|                     } | ||||
|                 } | ||||
|                 CommentManager.sendTitle(player, plot); | ||||
| @@ -266,7 +277,7 @@ public class PlotListener { | ||||
|             Location lastLoc = player.getMeta("music"); | ||||
|             if (lastLoc != null) { | ||||
|                 player.deleteMeta("music"); | ||||
|                 player.playMusic(lastLoc, PlotBlock.get("air")); | ||||
|                 player.playMusic(lastLoc, ItemTypes.AIR); | ||||
|             } | ||||
|         } | ||||
|         return true; | ||||
|   | ||||
| @@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.listener; | ||||
| 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.object.RegionWrapper; | ||||
| import com.sk89q.worldedit.regions.CuboidRegion; | ||||
| import com.sk89q.worldedit.WorldEditException; | ||||
| import com.sk89q.worldedit.entity.BaseEntity; | ||||
| import com.sk89q.worldedit.entity.Entity; | ||||
| @@ -20,10 +20,11 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; | ||||
|  | ||||
| import java.lang.reflect.Field; | ||||
| import java.util.HashSet; | ||||
| import java.util.Set; | ||||
|  | ||||
| public class ProcessedWEExtent extends AbstractDelegateExtent { | ||||
|  | ||||
|     private final HashSet<RegionWrapper> mask; | ||||
|     private final Set<CuboidRegion> mask; | ||||
|     private final String world; | ||||
|     private final int max; | ||||
|     int BScount = 0; | ||||
| @@ -33,7 +34,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { | ||||
|     private int count; | ||||
|     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) { | ||||
|         super(child); | ||||
|         this.mask = mask; | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| 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.entity.BaseEntity; | ||||
| 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 java.util.HashSet; | ||||
| import java.util.Set; | ||||
|  | ||||
| public class WEExtent extends AbstractDelegateExtent { | ||||
|  | ||||
|     public static BlockState AIRSTATE = BlockTypes.AIR.getDefaultState(); | ||||
|     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); | ||||
|         this.mask = mask; | ||||
|     } | ||||
|   | ||||
| @@ -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.PlotArea; | ||||
| 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.Set; | ||||
| import java.util.UUID; | ||||
|  | ||||
| public class WEManager { | ||||
|  | ||||
|     public static boolean maskContains(HashSet<RegionWrapper> mask, int x, int y, int z) { | ||||
|         for (RegionWrapper region : mask) { | ||||
|             if (region.isIn(x, y, z)) { | ||||
|     public static boolean maskContains(Set<CuboidRegion> mask, int x, int y, int z) { | ||||
|         for (CuboidRegion region : mask) { | ||||
|             if (RegionUtil.contains(region, x, y, z)) { | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     public static boolean maskContains(HashSet<RegionWrapper> mask, int x, int z) { | ||||
|         for (RegionWrapper region : mask) { | ||||
|             if (region.isIn(x, z)) { | ||||
|     public static boolean maskContains(Set<CuboidRegion> mask, int x, int z) { | ||||
|         for (CuboidRegion region : mask) { | ||||
|             if (RegionUtil.contains(region, x, z)) { | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         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) { | ||||
|         int x = Math.toIntExact(Math.round(dx >= 0 ? dx - 0.5 : dx + 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)); | ||||
|         for (RegionWrapper region : mask) { | ||||
|             if (region.isIn(x, y, z)) { | ||||
|         for (CuboidRegion region : mask) { | ||||
|             if (RegionUtil.contains(region, x, y, z)) { | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         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 z = Math.toIntExact(Math.round(dz >= 0 ? dz - 0.5 : dz + 0.5)); | ||||
|         for (RegionWrapper region : mask) { | ||||
|             if (region.isIn(x, z)) { | ||||
|         for (CuboidRegion region : mask) { | ||||
|             if (RegionUtil.contains(region, x, z)) { | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     public static HashSet<RegionWrapper> getMask(PlotPlayer player) { | ||||
|         HashSet<RegionWrapper> regions = new HashSet<>(); | ||||
|     public static HashSet<CuboidRegion> getMask(PlotPlayer player) { | ||||
|         HashSet<CuboidRegion> regions = new HashSet<>(); | ||||
|         UUID uuid = player.getUUID(); | ||||
|         Location location = player.getLocation(); | ||||
|         String world = location.getWorld(); | ||||
|         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)); | ||||
|             return regions; | ||||
|         } | ||||
| @@ -78,10 +81,10 @@ public class WEManager { | ||||
|         if (plot != null && (!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot)) && ( | ||||
|             (allowMember && plot.isAdded(uuid)) || (!allowMember && (plot.isOwner(uuid)) || plot | ||||
|                 .getTrusted().contains(uuid))) && !(Flags.NO_WORLDEDIT.isTrue(plot))) { | ||||
|             for (RegionWrapper region : plot.getRegions()) { | ||||
|                 RegionWrapper copy = | ||||
|                     new RegionWrapper(region.minX, region.maxX, area.MIN_BUILD_HEIGHT, | ||||
|                         area.MAX_BUILD_HEIGHT, region.minZ, region.maxZ); | ||||
|             for (CuboidRegion region : plot.getRegions()) { | ||||
|                 BlockVector3 pos1 = region.getMinimumPoint().withY(area.MIN_BUILD_HEIGHT); | ||||
|                 BlockVector3 pos2 = region.getMaximumPoint().withY(area.MAX_BUILD_HEIGHT); | ||||
|                 CuboidRegion copy = new CuboidRegion(pos1, pos2); | ||||
|                 regions.add(copy); | ||||
|             } | ||||
|             player.setMeta("WorldEditRegionPlot", plot); | ||||
| @@ -89,12 +92,12 @@ public class WEManager { | ||||
|         return regions; | ||||
|     } | ||||
|  | ||||
|     public static boolean intersects(RegionWrapper region1, RegionWrapper region2) { | ||||
|         return region1.intersects(region2); | ||||
|     public static boolean intersects(CuboidRegion region1, CuboidRegion region2) { | ||||
|         return RegionUtil.intersects(region1, region2); | ||||
|     } | ||||
|  | ||||
|     public static boolean regionContains(RegionWrapper selection, HashSet<RegionWrapper> mask) { | ||||
|         for (RegionWrapper region : mask) { | ||||
|     public static boolean regionContains(CuboidRegion selection, HashSet<CuboidRegion> mask) { | ||||
|         for (CuboidRegion region : mask) { | ||||
|             if (intersects(region, selection)) { | ||||
|                 return true; | ||||
|             } | ||||
|   | ||||
| @@ -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.object.Plot; | ||||
| 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.Permissions; | ||||
| import com.sk89q.worldedit.WorldEdit; | ||||
| @@ -19,6 +19,7 @@ import com.sk89q.worldedit.util.eventbus.Subscribe; | ||||
| import com.sk89q.worldedit.world.World; | ||||
|  | ||||
| import java.util.HashSet; | ||||
| import java.util.Set; | ||||
|  | ||||
| public class WESubscriber { | ||||
|  | ||||
| @@ -37,7 +38,7 @@ public class WESubscriber { | ||||
|         if (actor != null && actor.isPlayer()) { | ||||
|             String name = actor.getName(); | ||||
|             PlotPlayer plotPlayer = PlotPlayer.wrap(name); | ||||
|             HashSet<RegionWrapper> mask; | ||||
|             Set<CuboidRegion> mask; | ||||
|             if (plotPlayer == null) { | ||||
|                 Player player = (Player) actor; | ||||
|                 Location location = player.getLocation(); | ||||
|   | ||||
| @@ -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.object.collection.RandomCollection; | ||||
| 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.Getter; | ||||
| import lombok.NonNull; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| 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.Random; | ||||
|  | ||||
| /** | ||||
|  * A block bucket is a container of block types, where each block | ||||
|  * has a specified chance of being randomly picked | ||||
|  */ | ||||
| @EqualsAndHashCode @SuppressWarnings({"unused", "WeakerAccess"}) public final class BlockBucket | ||||
|     implements Iterable<PlotBlock>, ConfigurationSerializable { | ||||
| @EqualsAndHashCode(of={"blocks"}) @SuppressWarnings({"unused", "WeakerAccess"}) public final class BlockBucket | ||||
|     implements Iterable<BlockState>, ConfigurationSerializable { | ||||
|  | ||||
|     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 boolean compiled, singleItem; | ||||
|     private PlotBlock head; | ||||
|     private BlockState head; | ||||
|  | ||||
|     private RandomCollection<PlotBlock> randomBlocks; | ||||
|     private PlotBlock single; | ||||
|     private RandomCollection<BlockState> randomBlocks; | ||||
|     private BlockState single; | ||||
|  | ||||
|     public BlockBucket() { | ||||
|         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(); | ||||
|         blockBucket.addBlock(block, 100); | ||||
|         return blockBucket; | ||||
| @@ -47,15 +55,15 @@ import java.util.Map.Entry; | ||||
|         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); | ||||
|     } | ||||
|  | ||||
|     public void addBlock(@NonNull final PlotBlock block, final int chance) { | ||||
|     public void addBlock(@NonNull final BlockState block, final int 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) | ||||
|             chance = 1; | ||||
|         this.blocks.put(block, chance); | ||||
| @@ -75,7 +83,7 @@ import java.util.Map.Entry; | ||||
|      * @return Immutable collection containing all blocks that can | ||||
|      * be found in the bucket | ||||
|      */ | ||||
|     public Collection<PlotBlock> getBlocks() { | ||||
|     public Collection<BlockState> getBlocks() { | ||||
|         if (!isCompiled()) { | ||||
|             this.compile(); | ||||
|         } | ||||
| @@ -88,7 +96,7 @@ import java.util.Map.Entry; | ||||
|      * @param count Number of 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)); | ||||
|     } | ||||
|  | ||||
| @@ -98,8 +106,8 @@ import java.util.Map.Entry; | ||||
|      * @param count Number of blocks | ||||
|      * @return Immutable collection containing randomly selected blocks | ||||
|      */ | ||||
|     public PlotBlock[] getBlockArray(final int count) { | ||||
|         final PlotBlock[] blocks = new PlotBlock[count]; | ||||
|     public BlockState[] getBlockArray(final int count) { | ||||
|         final BlockState[] blocks = new BlockState[count]; | ||||
|         if (this.singleItem) { | ||||
|             Arrays.fill(blocks, 0, count, getBlock()); | ||||
|         } 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; | ||||
|     } | ||||
|  | ||||
| @@ -149,7 +157,7 @@ import java.util.Map.Entry; | ||||
|      * | ||||
|      * @return Randomly picked block (cased on specified rates) | ||||
|      */ | ||||
|     public PlotBlock getBlock() { | ||||
|     public BlockState getBlock() { | ||||
|         if (!isCompiled()) { | ||||
|             this.compile(); | ||||
|         } | ||||
| @@ -159,19 +167,22 @@ import java.util.Map.Entry; | ||||
|         if (randomBlocks != null) { | ||||
|             return randomBlocks.next(); | ||||
|         } | ||||
|         return StringPlotBlock.EVERYTHING; | ||||
|         return BlockTypes.AIR.getDefaultState(); | ||||
|     } | ||||
|  | ||||
|     @Override public String toString() { | ||||
|         if (!isCompiled()) { | ||||
|             compile(); | ||||
|         } | ||||
|         if (blocks.size() == 1) { | ||||
|             return blocks.entrySet().iterator().next().getKey().toString(); | ||||
|         } | ||||
|         final StringBuilder builder = new StringBuilder(); | ||||
|         Iterator<Entry<PlotBlock, Double>> iterator = blocks.entrySet().iterator(); | ||||
|         Iterator<Entry<BlockState, Double>> iterator = blocks.entrySet().iterator(); | ||||
|         while (iterator.hasNext()) { | ||||
|             Entry<PlotBlock, Double> entry = iterator.next(); | ||||
|             PlotBlock block = entry.getKey(); | ||||
|             builder.append(block.getRawId()); | ||||
|             Entry<BlockState, Double> entry = iterator.next(); | ||||
|             BlockState block = entry.getKey(); | ||||
|             builder.append(block); | ||||
|             Double weight = entry.getValue(); | ||||
|             if (weight != 1) { | ||||
|                 builder.append(":").append(weight.intValue()); | ||||
| @@ -183,6 +194,11 @@ import java.util.Map.Entry; | ||||
|         return builder.toString(); | ||||
|     } | ||||
|  | ||||
|     public boolean isAir() { | ||||
|         compile(); | ||||
|         return blocks.isEmpty() || (single != null && single.getBlockType().getMaterial().isAir()); | ||||
|     } | ||||
|  | ||||
|     @Override public Map<String, Object> serialize() { | ||||
|         if (!isCompiled()) { | ||||
|             compile(); | ||||
| @@ -190,7 +206,6 @@ import java.util.Map.Entry; | ||||
|         return ImmutableMap.of("blocks", this.toString()); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     @Getter @EqualsAndHashCode @RequiredArgsConstructor private final static class Range { | ||||
|  | ||||
|         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() { | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         @Override public PlotBlock next() { | ||||
|         @Override public BlockState next() { | ||||
|             return getBlock(); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -2,12 +2,12 @@ package com.github.intellectualsites.plotsquared.plot.object; | ||||
|  | ||||
| public class BlockLoc { | ||||
|  | ||||
|     public final int x; | ||||
|     public final int y; | ||||
|     public final int z; | ||||
|     private final int x; | ||||
|     private final int y; | ||||
|     private final int z; | ||||
|  | ||||
|     public final float yaw; | ||||
|     public final float pitch; | ||||
|     private final float yaw; | ||||
|     private final float pitch; | ||||
|  | ||||
|     public BlockLoc(int x, int y, int z, float yaw, float pitch) { | ||||
|         this.x = x; | ||||
| @@ -27,10 +27,6 @@ public class BlockLoc { | ||||
|  | ||||
|         float yaw; | ||||
|         float pitch; | ||||
|         if (parts.length == 3) { | ||||
|             yaw = 0f; | ||||
|             pitch = 0f; | ||||
|         } | ||||
|         if (parts.length == 5) { | ||||
|             yaw = Float.parseFloat(parts[3]); | ||||
|             pitch = Float.parseFloat(parts[4]); | ||||
| @@ -47,9 +43,9 @@ public class BlockLoc { | ||||
|     @Override public int hashCode() { | ||||
|         int prime = 31; | ||||
|         int result = 1; | ||||
|         result = prime * result + this.x; | ||||
|         result = prime * result + this.y; | ||||
|         result = prime * result + this.z; | ||||
|         result = prime * result + this.getX(); | ||||
|         result = prime * result + this.getY(); | ||||
|         result = prime * result + this.getZ(); | ||||
|         return result; | ||||
|     } | ||||
|  | ||||
| @@ -58,20 +54,42 @@ public class BlockLoc { | ||||
|             return true; | ||||
|         } | ||||
|         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()) { | ||||
|             return false; | ||||
|         } | ||||
|         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() { | ||||
|         if (this.x == 0 && this.y == 0 && this.z == 0) { | ||||
|         if (this.getX() == 0 && this.getY() == 0 && this.getZ() == 0) { | ||||
|             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; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -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; | ||||
|     } | ||||
| } | ||||
| @@ -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.util.PlotGameMode; | ||||
| 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 java.util.UUID; | ||||
| @@ -17,9 +21,9 @@ public class ConsolePlayer extends PlotPlayer { | ||||
|         PlotArea area = PlotSquared.get().getFirstPlotArea(); | ||||
|         Location location; | ||||
|         if (area != null) { | ||||
|             RegionWrapper region = area.getRegion(); | ||||
|             location = new Location(area.worldname, region.minX + region.maxX / 2, 0, | ||||
|                 region.minZ + region.maxZ / 2); | ||||
|             CuboidRegion region = area.getRegion(); | ||||
|             location = new Location(area.worldname, region.getMinimumPoint().getX() + region.getMaximumPoint().getX() / 2, 0, | ||||
|                 region.getMinimumPoint().getZ() + region.getMaximumPoint().getZ() / 2); | ||||
|         } else { | ||||
|             location = new Location("world", 0, 0, 0); | ||||
|         } | ||||
| @@ -34,6 +38,10 @@ public class ConsolePlayer extends PlotPlayer { | ||||
|         return instance; | ||||
|     } | ||||
|  | ||||
|     @Override public Actor toActor() { | ||||
|         return PlotSquared.get().IMP.getConsole(); | ||||
|     } | ||||
|  | ||||
|     @Override public boolean canTeleport(@NotNull Location location) { | ||||
|         return true; | ||||
|     } | ||||
| @@ -120,7 +128,7 @@ public class ConsolePlayer extends PlotPlayer { | ||||
|     @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) { | ||||
|   | ||||
| @@ -1,10 +1,12 @@ | ||||
| package com.github.intellectualsites.plotsquared.plot.object; | ||||
|  | ||||
| import com.sk89q.worldedit.world.block.BlockState; | ||||
|  | ||||
| public abstract class LazyBlock { | ||||
|  | ||||
|     public abstract StringPlotBlock getPlotBlock(); | ||||
|     public abstract BlockState getBlockState(); | ||||
|  | ||||
|     public String getId() { | ||||
|         return getPlotBlock().getItemId(); | ||||
|         return getBlockState().toString(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.object; | ||||
|  | ||||
| import com.github.intellectualsites.plotsquared.plot.PlotSquared; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.MathMan; | ||||
| import com.sk89q.worldedit.math.BlockVector2; | ||||
| import com.sk89q.worldedit.math.BlockVector3; | ||||
| import lombok.Getter; | ||||
| import lombok.Setter; | ||||
| @@ -26,10 +27,6 @@ public class Location implements Cloneable, Comparable<Location> { | ||||
|         this.blockVector3 = BlockVector3.at(x, y, z); | ||||
|     } | ||||
|  | ||||
|     public Location() { | ||||
|         this.world = ""; | ||||
|     } | ||||
|  | ||||
|     public Location(String world, int x, int y, int z) { | ||||
|         this(world, x, y, z, 0f, 0f); | ||||
|     } | ||||
| @@ -127,8 +124,8 @@ public class Location implements Cloneable, Comparable<Location> { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public ChunkLoc getChunkLoc() { | ||||
|         return new ChunkLoc(this.x >> 4, this.z >> 4); | ||||
|     public BlockVector2 getBlockVector2() { | ||||
|         return BlockVector2.at(this.x >> 4, this.z >> 4); | ||||
|     } | ||||
|  | ||||
|     public Location add(int x, int y, int z) { | ||||
|   | ||||
| @@ -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.object.comment.PlotComment; | ||||
| 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.LocalBlockQueue; | ||||
| 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.Sets; | ||||
| 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.Nullable; | ||||
|  | ||||
| @@ -30,8 +43,18 @@ import java.awt.geom.Rectangle2D; | ||||
| import java.io.File; | ||||
| import java.net.URL; | ||||
| 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.Optional; | ||||
| import java.util.Set; | ||||
| import java.util.UUID; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| @@ -45,13 +68,13 @@ import java.util.stream.Collectors; | ||||
|  */ | ||||
| public class Plot { | ||||
|  | ||||
|     private static final int MAX_HEIGHT = 256; | ||||
|     public static final int MAX_HEIGHT = 256; | ||||
|  | ||||
|     /** | ||||
|      * @deprecated raw access is deprecated | ||||
|      */ | ||||
|     @Deprecated private static HashSet<Plot> connected_cache; | ||||
|     private static HashSet<RegionWrapper> regions_cache; | ||||
|     @Deprecated private static Set<Plot> connected_cache; | ||||
|     private static Set<CuboidRegion> regions_cache; | ||||
|  | ||||
|     @NotNull private final PlotId id; | ||||
|  | ||||
| @@ -844,7 +867,7 @@ public class Plot { | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
|         final HashSet<RegionWrapper> regions = this.getRegions(); | ||||
|         final Set<CuboidRegion> regions = this.getRegions(); | ||||
|         final Set<Plot> plots = this.getConnectedPlots(); | ||||
|         final ArrayDeque<Plot> queue = new ArrayDeque<>(plots); | ||||
|         if (isDelete) { | ||||
| @@ -856,8 +879,8 @@ public class Plot { | ||||
|             @Override public void run() { | ||||
|                 if (queue.isEmpty()) { | ||||
|                     Runnable run = () -> { | ||||
|                         for (RegionWrapper region : regions) { | ||||
|                             Location[] corners = region.getCorners(getWorldName()); | ||||
|                         for (CuboidRegion region : regions) { | ||||
|                             Location[] corners = MainUtil.getCorners(getWorldName(), region); | ||||
|                             ChunkManager.manager.clearAllEntities(corners[0], corners[1]); | ||||
|                         } | ||||
|                         TaskManager.runTask(whenDone); | ||||
| @@ -899,7 +922,7 @@ public class Plot { | ||||
|      * @param whenDone The task to run when finished, or null | ||||
|      */ | ||||
|     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; | ||||
|         if (area instanceof SquarePlotWorld) { | ||||
|             extendBiome = (((SquarePlotWorld) area).ROAD_WIDTH > 0) ? 1 : 0; | ||||
| @@ -913,14 +936,14 @@ public class Plot { | ||||
|                     TaskManager.runTask(whenDone); | ||||
|                     return; | ||||
|                 } | ||||
|                 RegionWrapper region = regions.poll(); | ||||
|                 Location pos1 = new Location(getWorldName(), region.minX - extendBiome, region.minY, | ||||
|                     region.minZ - extendBiome); | ||||
|                 Location pos2 = new Location(getWorldName(), region.maxX + extendBiome, region.maxY, | ||||
|                     region.maxZ + extendBiome); | ||||
|                 CuboidRegion region = regions.poll(); | ||||
|                 Location pos1 = new Location(getWorldName(), region.getMinimumPoint().getX() - extendBiome, region.getMinimumPoint().getY(), | ||||
|                     region.getMinimumPoint().getZ() - extendBiome); | ||||
|                 Location pos2 = new Location(getWorldName(), region.getMaximumPoint().getX() + extendBiome, region.getMaximumPoint().getY(), | ||||
|                     region.getMaximumPoint().getZ() + extendBiome); | ||||
|                 ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() { | ||||
|                     @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); | ||||
|                         MainUtil.setBiome(getWorldName(), value[2], value[3], value[4], value[5], | ||||
|                             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) | ||||
|      * | ||||
|      * @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) { | ||||
|         if (!this.hasOwner()) { | ||||
| @@ -1233,9 +1256,9 @@ public class Plot { | ||||
|     } | ||||
|  | ||||
|     public Location getSide() { | ||||
|         RegionWrapper largest = getLargestRegion(); | ||||
|         int x = (largest.maxX >> 1) - (largest.minX >> 1) + largest.minX; | ||||
|         int z = largest.minZ - 1; | ||||
|         CuboidRegion largest = getLargestRegion(); | ||||
|         int x = (largest.getMaximumPoint().getX() >> 1) - (largest.getMinimumPoint().getX() >> 1) + largest.getMinimumPoint().getX(); | ||||
|         int z = largest.getMinimumPoint().getZ() - 1; | ||||
|         PlotManager manager = getManager(); | ||||
|         int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), x, z) : 62; | ||||
|         if (area.ALLOW_SIGNS && (y <= 0 || y >= 255)) { | ||||
| @@ -1251,17 +1274,18 @@ public class Plot { | ||||
|      */ | ||||
|     public Location getHome() { | ||||
|         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); | ||||
|         } else { | ||||
|             Location bottom = this.getBottomAbs(); | ||||
|             Location location = | ||||
|                 new Location(bottom.getWorld(), bottom.getX() + home.x, bottom.getY() + home.y, | ||||
|                     bottom.getZ() + home.z, home.yaw, home.pitch); | ||||
|                 new Location(bottom.getWorld(), bottom.getX() + home.getX(), bottom.getY() + home | ||||
|                     .getY(), | ||||
|                     bottom.getZ() + home.getZ(), home.getYaw(), home.getPitch()); | ||||
|             if (!isLoaded()) { | ||||
|                 return location; | ||||
|             } | ||||
|             if (!WorldUtil.IMP.getBlock(location).isAir()) { | ||||
|             if (!WorldUtil.IMP.getBlock(location).getBlockType().getMaterial().isAir()) { | ||||
|                 location.setY(Math.max(1 + WorldUtil.IMP | ||||
|                         .getHighestBlock(this.getWorldName(), location.getX(), location.getZ()), | ||||
|                     bottom.getY())); | ||||
| @@ -1306,9 +1330,9 @@ public class Plot { | ||||
|             int z; | ||||
|             if (loc.getX() == Integer.MAX_VALUE && loc.getZ() == Integer.MAX_VALUE) { | ||||
|                 // center | ||||
|                 RegionWrapper largest = plot.getLargestRegion(); | ||||
|                 x = (largest.maxX >> 1) - (largest.minX >> 1) + largest.minX; | ||||
|                 z = (largest.maxZ >> 1) - (largest.minZ >> 1) + largest.minZ; | ||||
|                 CuboidRegion largest = plot.getLargestRegion(); | ||||
|                 x = (largest.getMaximumPoint().getX() >> 1) - (largest.getMinimumPoint().getX() >> 1) + largest.getMinimumPoint().getX(); | ||||
|                 z = (largest.getMaximumPoint().getZ() >> 1) - (largest.getMinimumPoint().getZ() >> 1) + largest.getMinimumPoint().getZ(); | ||||
|             } else { | ||||
|                 // specific | ||||
|                 Location bot = plot.getBottomAbs(); | ||||
| @@ -1326,9 +1350,9 @@ public class Plot { | ||||
|  | ||||
|     public double getVolume() { | ||||
|         double count = 0; | ||||
|         for (RegionWrapper region : getRegions()) { | ||||
|         for (CuboidRegion region : getRegions()) { | ||||
|             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; | ||||
|         } | ||||
|         return count; | ||||
| @@ -1413,11 +1437,11 @@ public class Plot { | ||||
|      */ | ||||
|     public void refreshChunks() { | ||||
|         LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false); | ||||
|         HashSet<ChunkLoc> chunks = new HashSet<>(); | ||||
|         for (RegionWrapper region : Plot.this.getRegions()) { | ||||
|             for (int x = region.minX >> 4; x <= region.maxX >> 4; x++) { | ||||
|                 for (int z = region.minZ >> 4; z <= region.maxZ >> 4; z++) { | ||||
|                     if (chunks.add(new ChunkLoc(x, z))) { | ||||
|         HashSet<BlockVector2> chunks = new HashSet<>(); | ||||
|         for (CuboidRegion region : Plot.this.getRegions()) { | ||||
|             for (int x = region.getMinimumPoint().getX() >> 4; x <= region.getMaximumPoint().getX() >> 4; x++) { | ||||
|                 for (int z = region.getMinimumPoint().getZ() >> 4; z <= region.getMaximumPoint().getZ() >> 4; z++) { | ||||
|                     if (chunks.add(BlockVector2.at(x, z))) { | ||||
|                         queue.refreshChunk(x, z); | ||||
|                     } | ||||
|                 } | ||||
| @@ -1435,7 +1459,7 @@ public class Plot { | ||||
|         } | ||||
|         Location location = manager.getSignLoc(this); | ||||
|         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(); | ||||
|     } | ||||
|  | ||||
| @@ -2142,7 +2166,7 @@ public class Plot { | ||||
|             String[] lines = TaskManager.IMP.sync(new RunnableVal<String[]>() { | ||||
|                 @Override public void run(String[] value) { | ||||
|                     ChunkManager.manager | ||||
|                         .loadChunk(location.getWorld(), location.getChunkLoc(), false); | ||||
|                         .loadChunk(location.getWorld(), location.getBlockVector2(), false); | ||||
|                     this.value = WorldUtil.IMP.getSign(location); | ||||
|                 } | ||||
|             }); | ||||
| @@ -2571,7 +2595,7 @@ public class Plot { | ||||
|      * | ||||
|      * @return | ||||
|      */ | ||||
|     @NotNull public HashSet<RegionWrapper> getRegions() { | ||||
|     @NotNull public Set<CuboidRegion> getRegions() { | ||||
|         if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) { | ||||
|             return regions_cache; | ||||
|         } | ||||
| @@ -2579,14 +2603,13 @@ public class Plot { | ||||
|             Location pos1 = this.getBottomAbs(); | ||||
|             Location pos2 = this.getTopAbs(); | ||||
|             connected_cache = Sets.newHashSet(this); | ||||
|             regions_cache = Sets.newHashSet( | ||||
|                 new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(), | ||||
|                     pos2.getZ())); | ||||
|             CuboidRegion rg = new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3()); | ||||
|             regions_cache = Collections.singleton(rg); | ||||
|             return regions_cache; | ||||
|         } | ||||
|         Set<Plot> plots = this.getConnectedPlots(); | ||||
|         HashSet<RegionWrapper> regions = regions_cache = new HashSet<>(); | ||||
|         HashSet<PlotId> visited = new HashSet<>(); | ||||
|         Set<CuboidRegion> regions = regions_cache = new HashSet<>(); | ||||
|         Set<PlotId> visited = new HashSet<>(); | ||||
|         for (Plot current : plots) { | ||||
|             if (visited.contains(current.getId())) { | ||||
|                 continue; | ||||
| @@ -2663,12 +2686,14 @@ public class Plot { | ||||
|                     Location toploc = plot.getExtendedTopAbs(); | ||||
|                     Location botabs = plot.getBottomAbs(); | ||||
|                     Location topabs = plot.getTopAbs(); | ||||
|                     regions.add(new RegionWrapper(botabs.getX(), topabs.getX(), topabs.getZ() + 1, | ||||
|                         toploc.getZ())); | ||||
|                     BlockVector3 pos1 = BlockVector3.at(botabs.getX(), 0, topabs.getZ() + 1); | ||||
|                     BlockVector3 pos2 = BlockVector3.at(topabs.getX(), Plot.MAX_HEIGHT - 1, toploc.getZ()); | ||||
|                     regions.add(new CuboidRegion(pos1, pos2)); | ||||
|                     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( | ||||
|                             new RegionWrapper(topabs.getX() + 1, toploc.getX(), topabs.getZ() + 1, | ||||
|                                 toploc.getZ())); | ||||
|                             new CuboidRegion(pos1, pos2)); | ||||
|                         // intersection | ||||
|                     } | ||||
|                 } | ||||
| @@ -2681,18 +2706,22 @@ public class Plot { | ||||
|                     Location toploc = plot.getExtendedTopAbs(); | ||||
|                     Location botabs = plot.getBottomAbs(); | ||||
|                     Location topabs = plot.getTopAbs(); | ||||
|                     regions.add(new RegionWrapper(topabs.getX() + 1, toploc.getX(), botabs.getZ(), | ||||
|                         topabs.getZ())); | ||||
|                     BlockVector3 pos1 = BlockVector3.at(topabs.getX() + 1, 0, botabs.getZ()); | ||||
|                     BlockVector3 pos2 = BlockVector3.at(toploc.getX(), Plot.MAX_HEIGHT - 1, topabs.getZ()); | ||||
|                     regions.add(new CuboidRegion(pos1, pos2)); | ||||
|                     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( | ||||
|                             new RegionWrapper(topabs.getX() + 1, toploc.getX(), topabs.getZ() + 1, | ||||
|                                 toploc.getZ())); | ||||
|                             new CuboidRegion(pos1, pos2)); | ||||
|                         // 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( | ||||
|                 new RegionWrapper(gbotabs.getX(), gtopabs.getX(), gbotabs.getZ(), gtopabs.getZ())); | ||||
|                 new CuboidRegion(pos1, pos2)); | ||||
|         } | ||||
|         return regions; | ||||
|     } | ||||
| @@ -2702,13 +2731,13 @@ public class Plot { | ||||
|      * | ||||
|      * @return | ||||
|      */ | ||||
|     public RegionWrapper getLargestRegion() { | ||||
|         HashSet<RegionWrapper> regions = this.getRegions(); | ||||
|         RegionWrapper max = null; | ||||
|     public CuboidRegion getLargestRegion() { | ||||
|         Set<CuboidRegion> regions = this.getRegions(); | ||||
|         CuboidRegion max = null; | ||||
|         double area = Double.NEGATIVE_INFINITY; | ||||
|         for (RegionWrapper region : regions) { | ||||
|         for (CuboidRegion region : regions) { | ||||
|             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) { | ||||
|                 max = region; | ||||
|                 area = current; | ||||
| @@ -2737,9 +2766,9 @@ public class Plot { | ||||
|      */ | ||||
|     public List<Location> getAllCorners() { | ||||
|         Area area = new Area(); | ||||
|         for (RegionWrapper region : this.getRegions()) { | ||||
|             Rectangle2D rect = new Rectangle2D.Double(region.minX - 0.6, region.minZ - 0.6, | ||||
|                 region.maxX - region.minX + 1.2, region.maxZ - region.minZ + 1.2); | ||||
|         for (CuboidRegion region : this.getRegions()) { | ||||
|             Rectangle2D rect = new Rectangle2D.Double(region.getMinimumPoint().getX() - 0.6, region.getMinimumPoint().getZ() - 0.6, | ||||
|                 region.getMaximumPoint().getX() - region.getMinimumPoint().getX() + 1.2, region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + 1.2); | ||||
|             Area rectArea = new Area(rect); | ||||
|             area.add(rectArea); | ||||
|         } | ||||
| @@ -2954,7 +2983,7 @@ public class Plot { | ||||
|         } | ||||
|         // world border | ||||
|         destination.updateWorldBorder(); | ||||
|         final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(this.getRegions()); | ||||
|         final ArrayDeque<CuboidRegion> regions = new ArrayDeque<>(this.getRegions()); | ||||
|         // move / swap data | ||||
|         final PlotArea originArea = getArea(); | ||||
|         for (Plot plot : plots) { | ||||
| @@ -2969,8 +2998,8 @@ public class Plot { | ||||
|                         TaskManager.runTask(whenDone); | ||||
|                         return; | ||||
|                     } | ||||
|                     RegionWrapper region = regions.poll(); | ||||
|                     Location[] corners = region.getCorners(getWorldName()); | ||||
|                     CuboidRegion region = regions.poll(); | ||||
|                     Location[] corners = MainUtil.getCorners(getWorldName(), region); | ||||
|                     Location pos1 = corners[0]; | ||||
|                     Location pos2 = corners[1]; | ||||
|                     Location pos3 = pos1.clone().add(offsetX, 0, offsetZ); | ||||
| @@ -2997,8 +3026,8 @@ public class Plot { | ||||
|                         return; | ||||
|                     } | ||||
|                     final Runnable task = this; | ||||
|                     RegionWrapper region = regions.poll(); | ||||
|                     Location[] corners = region.getCorners(getWorldName()); | ||||
|                     CuboidRegion region = regions.poll(); | ||||
|                     Location[] corners = MainUtil.getCorners(getWorldName(), region); | ||||
|                     final Location pos1 = corners[0]; | ||||
|                     final Location pos2 = corners[1]; | ||||
|                     Location newPos = pos1.clone().add(offsetX, 0, offsetZ); | ||||
| @@ -3071,7 +3100,7 @@ public class Plot { | ||||
|             } | ||||
|         } | ||||
|         // copy terrain | ||||
|         final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(this.getRegions()); | ||||
|         final ArrayDeque<CuboidRegion> regions = new ArrayDeque<>(this.getRegions()); | ||||
|         Runnable run = new Runnable() { | ||||
|             @Override public void run() { | ||||
|                 if (regions.isEmpty()) { | ||||
| @@ -3082,8 +3111,8 @@ public class Plot { | ||||
|                     TaskManager.runTask(whenDone); | ||||
|                     return; | ||||
|                 } | ||||
|                 RegionWrapper region = regions.poll(); | ||||
|                 Location[] corners = region.getCorners(getWorldName()); | ||||
|                 CuboidRegion region = regions.poll(); | ||||
|                 Location[] corners = MainUtil.getCorners(getWorldName(), region); | ||||
|                 Location pos1 = corners[0]; | ||||
|                 Location pos2 = corners[1]; | ||||
|                 Location newPos = pos1.clone().add(offsetX, 0, offsetZ); | ||||
|   | ||||
| @@ -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.block.GlobalBlockQueue; | ||||
| 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.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.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.Set; | ||||
| import java.util.UUID; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.function.Consumer; | ||||
|  | ||||
| @@ -71,7 +83,7 @@ public abstract class PlotArea { | ||||
|     public int MIN_BUILD_HEIGHT = 1; | ||||
|     public PlotGameMode GAMEMODE = PlotGameMode.CREATIVE; | ||||
|     private int hash; | ||||
|     private RegionWrapper region; | ||||
|     private CuboidRegion region; | ||||
|     private ConcurrentHashMap<String, Object> meta; | ||||
|     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. | ||||
|      * | ||||
|      * @return RegionWrapper | ||||
|      * @return CuboidRegion | ||||
|      */ | ||||
|     public RegionWrapper getRegion() { | ||||
|     public CuboidRegion getRegion() { | ||||
|         this.region = getRegionAbs(); | ||||
|         if (this.region == null) { | ||||
|             return new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, | ||||
|                 Integer.MAX_VALUE); | ||||
|             return new CuboidRegion(BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE), | ||||
|                 BlockVector3.at(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)); | ||||
|         } | ||||
|         return this.region; | ||||
|     } | ||||
| @@ -137,15 +149,16 @@ public abstract class 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.min != null) { | ||||
|                 Location bot = getPlotManager().getPlotBottomLocAbs(this.min); | ||||
|                 Location top = getPlotManager().getPlotTopLocAbs(this.max); | ||||
|                 this.region = new RegionWrapper(bot.getX() - 1, top.getX() + 1, bot.getZ() - 1, | ||||
|                     top.getZ() + 1); | ||||
|                 BlockVector3 pos1 = bot.getBlockVector3().subtract(BlockVector3.ONE); | ||||
|                 BlockVector3 pos2 = top.getBlockVector3().add(BlockVector3.ONE); | ||||
|                 this.region = new CuboidRegion(pos1, pos2); | ||||
|             } | ||||
|         } | ||||
|         return this.region; | ||||
| @@ -489,7 +502,7 @@ public abstract class PlotArea { | ||||
|     } | ||||
|  | ||||
|     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) { | ||||
| @@ -499,7 +512,7 @@ public abstract class PlotArea { | ||||
|  | ||||
|     public boolean contains(@NotNull final Location location) { | ||||
|         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) { | ||||
| @@ -932,9 +945,10 @@ public abstract class PlotArea { | ||||
|     public void addCluster(@Nullable final PlotCluster plotCluster) { | ||||
|         if (this.clusters == null) { | ||||
|             this.clusters = new QuadMap<PlotCluster>(Integer.MAX_VALUE, 0, 0, 62) { | ||||
|                 @Override public RegionWrapper getRegion(PlotCluster value) { | ||||
|                     return new RegionWrapper(value.getP1().x, value.getP2().x, value.getP1().y, | ||||
|                         value.getP2().y); | ||||
|                 @Override public CuboidRegion getRegion(PlotCluster value) { | ||||
|                     BlockVector2 pos1 = BlockVector2.at(value.getP1().x, value.getP1().y); | ||||
|                     BlockVector2 pos2 = BlockVector2.at(value.getP2().x, value.getP2().y); | ||||
|                     return new CuboidRegion(pos1.toBlockVector3(), pos2.toBlockVector3(Plot.MAX_HEIGHT - 1)); | ||||
|                 } | ||||
|             }; | ||||
|         } | ||||
|   | ||||
| @@ -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(); | ||||
|  | ||||
| } | ||||
| @@ -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.util.MainUtil; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil; | ||||
| import com.sk89q.worldedit.regions.CuboidRegion; | ||||
|  | ||||
| import java.util.HashSet; | ||||
| import java.util.UUID; | ||||
| @@ -15,7 +17,7 @@ public class PlotCluster { | ||||
|     public int temp; | ||||
|     private PlotId pos1; | ||||
|     private PlotId pos2; | ||||
|     private RegionWrapper region; | ||||
|     private CuboidRegion region; | ||||
|  | ||||
|     public PlotCluster(PlotArea area, PlotId pos1, PlotId pos2, UUID owner) { | ||||
|         this.area = area; | ||||
| @@ -56,10 +58,10 @@ public class PlotCluster { | ||||
|     } | ||||
|  | ||||
|     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; | ||||
|     } | ||||
|  | ||||
| @@ -126,7 +128,7 @@ public class PlotCluster { | ||||
|     public Location getHome() { | ||||
|         BlockLoc home = this.settings.getPosition(); | ||||
|         Location toReturn; | ||||
|         if (home.y == 0) { | ||||
|         if (home.getY() == 0) { | ||||
|             // default pos | ||||
|             Plot center = getCenterPlot(); | ||||
|             toReturn = center.getHome(); | ||||
| @@ -136,7 +138,7 @@ public class PlotCluster { | ||||
|                 toReturn.setY(location.getY()); | ||||
|             } | ||||
|         } 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()); | ||||
|         if (max > toReturn.getY()) { | ||||
|   | ||||
| @@ -25,6 +25,14 @@ public class PlotId { | ||||
|         this.y = y; | ||||
|     } | ||||
|  | ||||
|     public int getX() { | ||||
|         return x; | ||||
|     } | ||||
|  | ||||
|     public int getY() { | ||||
|         return y; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get a Plot Id based on a string | ||||
|      * | ||||
| @@ -40,7 +48,7 @@ public class PlotId { | ||||
|     } | ||||
|  | ||||
|     @Nullable public static PlotId fromStringOrNull(@NotNull String string) { | ||||
|         String[] parts = string.split("[;|,]"); | ||||
|         String[] parts = string.split("[;,.]"); | ||||
|         if (parts.length < 2) { | ||||
|             return null; | ||||
|         } | ||||
|   | ||||
| @@ -1,7 +1,9 @@ | ||||
| package com.github.intellectualsites.plotsquared.plot.object; | ||||
|  | ||||
| import com.github.intellectualsites.plotsquared.plot.util.StringComparison; | ||||
| import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; | ||||
| import com.sk89q.worldedit.world.block.BlockState; | ||||
| import com.sk89q.worldedit.world.item.ItemType; | ||||
| import com.sk89q.worldedit.world.item.ItemTypes; | ||||
| import com.sk89q.worldedit.world.registry.LegacyMapper; | ||||
| import lombok.Getter; | ||||
|  | ||||
| public class PlotItemStack { | ||||
| @@ -9,7 +11,7 @@ public class PlotItemStack { | ||||
|     public final int amount; | ||||
|     public final String name; | ||||
|     public final String[] lore; | ||||
|     @Getter private final PlotBlock plotBlock; | ||||
|     @Getter private final ItemType type; | ||||
|  | ||||
|     /** | ||||
|      * @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, | ||||
|         final String name, final String... lore) { | ||||
|  | ||||
|         this.amount = amount; | ||||
|         this.name = name; | ||||
|         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, | ||||
|         final String... lore) { | ||||
|         StringComparison<PlotBlock>.ComparisonResult match = WorldUtil.IMP.getClosestBlock(id); | ||||
|         this.plotBlock = match.best; | ||||
|         this.type = ItemTypes.get(id); | ||||
|         this.amount = amount; | ||||
|         this.name = name; | ||||
|         this.lore = lore; | ||||
|     } | ||||
|  | ||||
|     public BlockState getBlockState() { | ||||
|         return type.getBlockType().getDefaultState(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -90,6 +90,21 @@ public abstract class PlotManager { | ||||
|         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; | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -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.SinglePlotArea; | ||||
| 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.google.common.base.Preconditions; | ||||
| import com.sk89q.worldedit.extension.platform.Actor; | ||||
| import com.sk89q.worldedit.world.item.ItemType; | ||||
| import lombok.NonNull; | ||||
| import org.jetbrains.annotations.NotNull; | ||||
|  | ||||
| @@ -79,6 +87,8 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { | ||||
|         return UUIDHandler.getPlayer(name); | ||||
|     } | ||||
|  | ||||
|     public abstract Actor toActor(); | ||||
|  | ||||
|     /** | ||||
|      * 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 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. | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user
	 Alexander Söderberg
					Alexander Söderberg