1.13 shizzle

This commit is contained in:
sauilitired 2018-12-17 20:57:21 +01:00
parent 820710721e
commit fb7bcef05f
40 changed files with 1487 additions and 2332 deletions

View File

@ -1,5 +1,5 @@
repositories { repositories {
maven { url "https://hub.spigotmc.org/nexus/content/groups/public/" } maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "http://nexus.hc.to/content/repositories/pub_releases" } maven { url "http://nexus.hc.to/content/repositories/pub_releases" }
mavenLocal() mavenLocal()
@ -7,7 +7,7 @@ repositories {
dependencies { dependencies {
compile project(':Core') compile project(':Core')
compile 'org.spigotmc:spigot-api:1.12.1-R0.1-SNAPSHOT' compile 'org.spigotmc:spigot-api:1.13-R0.1-SNAPSHOT'
compile("net.milkbowl.vault:VaultAPI:1.6") { compile("net.milkbowl.vault:VaultAPI:1.6") {
exclude module: 'bukkit' exclude module: 'bukkit'
} }

View File

@ -1,14 +1,46 @@
package com.github.intellectualsites.plotsquared.bukkit; package com.github.intellectualsites.plotsquared.bukkit;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
import com.github.intellectualsites.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector; import com.github.intellectualsites.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
import com.github.intellectualsites.plotsquared.bukkit.database.plotme.LikePlotMeConverter; import com.github.intellectualsites.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
import com.github.intellectualsites.plotsquared.bukkit.database.plotme.PlotMeConnector_017; import com.github.intellectualsites.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
import com.github.intellectualsites.plotsquared.bukkit.generator.BukkitPlotGenerator; import com.github.intellectualsites.plotsquared.bukkit.generator.BukkitPlotGenerator;
import com.github.intellectualsites.plotsquared.bukkit.listeners.*; import com.github.intellectualsites.plotsquared.bukkit.listeners.ChunkListener;
import com.github.intellectualsites.plotsquared.bukkit.listeners.EntityPortal_1_7_9;
import com.github.intellectualsites.plotsquared.bukkit.listeners.EntitySpawnListener;
import com.github.intellectualsites.plotsquared.bukkit.listeners.PlayerEvents;
import com.github.intellectualsites.plotsquared.bukkit.listeners.PlayerEvents183;
import com.github.intellectualsites.plotsquared.bukkit.listeners.PlayerEvents_1_8;
import com.github.intellectualsites.plotsquared.bukkit.listeners.PlayerEvents_1_9;
import com.github.intellectualsites.plotsquared.bukkit.listeners.PlotPlusListener;
import com.github.intellectualsites.plotsquared.bukkit.listeners.PlotPlusListener_1_12;
import com.github.intellectualsites.plotsquared.bukkit.listeners.PlotPlusListener_Legacy;
import com.github.intellectualsites.plotsquared.bukkit.listeners.SingleWorldListener;
import com.github.intellectualsites.plotsquared.bukkit.listeners.WorldEvents;
import com.github.intellectualsites.plotsquared.bukkit.titles.DefaultTitle_111; import com.github.intellectualsites.plotsquared.bukkit.titles.DefaultTitle_111;
import com.github.intellectualsites.plotsquared.bukkit.util.*; import com.github.intellectualsites.plotsquared.bukkit.util.BukkitChatManager;
import com.github.intellectualsites.plotsquared.bukkit.util.block.*; import com.github.intellectualsites.plotsquared.bukkit.util.BukkitChunkManager;
import com.github.intellectualsites.plotsquared.bukkit.uuid.*; 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.BukkitVersion;
import com.github.intellectualsites.plotsquared.bukkit.util.LegacyMappings;
import com.github.intellectualsites.plotsquared.bukkit.util.Metrics;
import com.github.intellectualsites.plotsquared.bukkit.util.SendChunk;
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;
import com.github.intellectualsites.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.github.intellectualsites.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.github.intellectualsites.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection; import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
import com.github.intellectualsites.plotsquared.plot.IPlotMain; import com.github.intellectualsites.plotsquared.plot.IPlotMain;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
@ -19,20 +51,55 @@ import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.generator.HybridGen; import com.github.intellectualsites.plotsquared.plot.generator.HybridGen;
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils; import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator; import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.object.*; 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.object.SetupObject;
import com.github.intellectualsites.plotsquared.plot.object.chat.PlainChatManager; import com.github.intellectualsites.plotsquared.plot.object.chat.PlainChatManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager; import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea; import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager; import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SingleWorldGenerator; import com.github.intellectualsites.plotsquared.plot.object.worlds.SingleWorldGenerator;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.AbstractTitle;
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.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider; import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper; import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nullable;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -45,15 +112,6 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import javax.annotation.Nullable;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@Getter private static WorldEdit worldEdit; @Getter private static WorldEdit worldEdit;
@ -138,6 +196,9 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
} }
this.pluginName = getDescription().getName(); this.pluginName = getDescription().getName();
getServer().getName(); getServer().getName();
LegacyMappings.initialize();
new PlotSquared(this, "Bukkit"); new PlotSquared(this, "Bukkit");
if (Settings.Enabled_Components.METRICS) { if (Settings.Enabled_Components.METRICS) {
new Metrics(this).start(); new Metrics(this).start();
@ -646,19 +707,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
SendChunk.class + " does not support " + StringMan.getString(getServerVersion())); SendChunk.class + " does not support " + StringMan.getString(getServerVersion()));
MainUtil.canSendChunk = false; MainUtil.canSendChunk = false;
} }
if (PlotSquared.get().checkVersion(getServerVersion(), BukkitVersion.v1_13_0)) { return QueueProvider.of(BukkitLocalQueue.class, BukkitLocalQueue.class);
return QueueProvider.of(BukkitLocalQueue.class, BukkitLocalQueue.class);
}
if (PlotSquared.get().checkVersion(getServerVersion(), BukkitVersion.v1_9_0)) {
return QueueProvider.of(BukkitLocalQueue_1_9.class, BukkitLocalQueue.class);
}
if (PlotSquared.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_3)) {
return QueueProvider.of(BukkitLocalQueue_1_8_3.class, BukkitLocalQueue.class);
}
if (PlotSquared.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_0)) {
return QueueProvider.of(BukkitLocalQueue_1_8.class, BukkitLocalQueue.class);
}
return QueueProvider.of(BukkitLocalQueue_1_7.class, BukkitLocalQueue.class);
} }
@Override public WorldUtil initWorldUtil() { @Override public WorldUtil initWorldUtil() {

View File

@ -5,6 +5,7 @@ import com.github.intellectualsites.plotsquared.bukkit.object.BukkitLazyBlock;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer; import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil; import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitVersion; import com.github.intellectualsites.plotsquared.bukkit.util.BukkitVersion;
import com.github.intellectualsites.plotsquared.bukkit.util.LegacyMappings;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.C; import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
@ -230,21 +231,21 @@ public class PlayerEvents extends PlotListener implements Listener {
Block block = event.getBlock(); Block block = event.getBlock();
switch (block.getType()) { switch (block.getType()) {
case OBSERVER: case OBSERVER:
case REDSTONE_LAMP_OFF: case LEGACY_REDSTONE_LAMP_OFF:
case REDSTONE_WIRE: case REDSTONE_WIRE:
case REDSTONE_LAMP_ON: case LEGACY_REDSTONE_LAMP_ON:
case PISTON_BASE: case LEGACY_PISTON_BASE:
case PISTON_STICKY_BASE: case LEGACY_PISTON_STICKY_BASE:
case IRON_DOOR_BLOCK: case LEGACY_IRON_DOOR_BLOCK:
case LEVER: case LEVER:
case WOODEN_DOOR: case LEGACY_WOODEN_DOOR:
case FENCE_GATE: case LEGACY_FENCE_GATE:
case WOOD_BUTTON: case LEGACY_WOOD_BUTTON:
case STONE_BUTTON: case STONE_BUTTON:
case IRON_PLATE: case LEGACY_IRON_PLATE:
case WOOD_PLATE: case LEGACY_WOOD_PLATE:
case STONE_PLATE: case LEGACY_STONE_PLATE:
case GOLD_PLATE: case LEGACY_GOLD_PLATE:
case SPRUCE_DOOR: case SPRUCE_DOOR:
case BIRCH_DOOR: case BIRCH_DOOR:
case JUNGLE_DOOR: case JUNGLE_DOOR:
@ -312,8 +313,8 @@ public class PlayerEvents extends PlotListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPhysicsEvent(BlockPhysicsEvent event) { public void onPhysicsEvent(BlockPhysicsEvent event) {
switch (event.getChangedType()) { switch (event.getChangedType()) {
case REDSTONE_COMPARATOR_OFF: case LEGACY_REDSTONE_COMPARATOR_OFF:
case REDSTONE_COMPARATOR_ON: { case LEGACY_REDSTONE_COMPARATOR_ON: {
Block block = event.getBlock(); Block block = event.getBlock();
Location loc = BukkitUtil.getLocation(block.getLocation()); Location loc = BukkitUtil.getLocation(block.getLocation());
PlotArea area = loc.getPlotArea(); PlotArea area = loc.getPlotArea();
@ -352,8 +353,8 @@ public class PlayerEvents extends PlotListener implements Listener {
if (Settings.Redstone.DETECT_INVALID_EDGE_PISTONS) { if (Settings.Redstone.DETECT_INVALID_EDGE_PISTONS) {
Block block = event.getBlock(); Block block = event.getBlock();
switch (block.getType()) { switch (block.getType()) {
case PISTON_BASE: case LEGACY_PISTON_BASE:
case PISTON_STICKY_BASE: case LEGACY_PISTON_STICKY_BASE:
Location loc = BukkitUtil.getLocation(block.getLocation()); Location loc = BukkitUtil.getLocation(block.getLocation());
PlotArea area = loc.getPlotArea(); PlotArea area = loc.getPlotArea();
if (area == null) { if (area == null) {
@ -919,7 +920,7 @@ public class PlayerEvents extends PlotListener implements Listener {
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK); Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock(); Block block = event.getBlock();
if (destroy.isPresent() && destroy.get() if (destroy.isPresent() && destroy.get()
.contains(PlotBlock.get((short) block.getTypeId(), block.getData()))) { .contains(PlotBlock.get(block.getType().name()))) {
return; return;
} }
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) { if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
@ -943,8 +944,8 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) { if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
if (player.getItemInHand().getTypeId() == PlotSquared.get().worldedit if (player.getInventory().getItemInMainHand().getType() == LegacyMappings.fromLegacyId(PlotSquared.get().worldedit
.getConfiguration().wandItem) { .getConfiguration().wandItem).getMaterial()) {
return; return;
} }
} }
@ -1118,7 +1119,7 @@ public class PlayerEvents extends PlotListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
break; break;
case MYCEL: case LEGACY_MYCEL:
if (Flags.MYCEL_GROW.isFalse(plot)) { if (Flags.MYCEL_GROW.isFalse(plot)) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -1202,7 +1203,7 @@ public class PlayerEvents extends PlotListener implements Listener {
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK); Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock(); Block block = event.getBlock();
if (destroy.isPresent() && destroy.get() if (destroy.isPresent() && destroy.get()
.contains(PlotBlock.get((short) block.getTypeId(), block.getData())) .contains(PlotBlock.get(block.getType().name()))
|| Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) { || Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return; return;
} }
@ -1242,7 +1243,7 @@ public class PlayerEvents extends PlotListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
break; break;
case SOIL: case LEGACY_SOIL:
if (Flags.SOIL_DRY.isFalse(plot)) { if (Flags.SOIL_DRY.isFalse(plot)) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -1273,9 +1274,7 @@ public class PlayerEvents extends PlotListener implements Listener {
if (Flags.LIQUID_FLOW.isFalse(plot)) { if (Flags.LIQUID_FLOW.isFalse(plot)) {
switch (to.getType()) { switch (to.getType()) {
case WATER: case WATER:
case STATIONARY_WATER:
case LAVA: case LAVA:
case STATIONARY_LAVA:
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -1356,7 +1355,7 @@ public class PlayerEvents extends PlotListener implements Listener {
this.pistonBlocks = false; this.pistonBlocks = false;
} }
} }
if (!this.pistonBlocks && block.getType() != Material.PISTON_BASE) { if (!this.pistonBlocks && block.getType() != Material.LEGACY_PISTON_BASE) {
BlockFace dir = event.getDirection(); BlockFace dir = event.getDirection();
location = BukkitUtil.getLocation(block.getLocation() location = BukkitUtil.getLocation(block.getLocation()
.add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2)); .add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
@ -1397,7 +1396,7 @@ public class PlayerEvents extends PlotListener implements Listener {
this.pistonBlocks = false; this.pistonBlocks = false;
} }
} }
if (!this.pistonBlocks && block.getType() != Material.PISTON_BASE) { if (!this.pistonBlocks && block.getType() != Material.LEGACY_PISTON_BASE) {
location = BukkitUtil.getLocation( location = BukkitUtil.getLocation(
block.getLocation().add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2)); block.getLocation().add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
if (!area.contains(location)) { if (!area.contains(location)) {
@ -1521,48 +1520,47 @@ public class PlayerEvents extends PlotListener implements Listener {
case IRON_DOOR: case IRON_DOOR:
case JUNGLE_DOOR: case JUNGLE_DOOR:
case SPRUCE_DOOR: case SPRUCE_DOOR:
case TRAP_DOOR: case LEGACY_TRAP_DOOR:
case IRON_TRAPDOOR: case IRON_TRAPDOOR:
case WOOD_DOOR: case LEGACY_WOOD_DOOR:
case WOODEN_DOOR: case LEGACY_WOODEN_DOOR:
case TRAPPED_CHEST: case TRAPPED_CHEST:
case ENDER_CHEST: case ENDER_CHEST:
case CHEST: case CHEST:
case ACACIA_FENCE_GATE: case ACACIA_FENCE_GATE:
case BIRCH_FENCE_GATE: case BIRCH_FENCE_GATE:
case DARK_OAK_FENCE_GATE: case DARK_OAK_FENCE_GATE:
case FENCE_GATE: case LEGACY_FENCE_GATE:
case JUNGLE_FENCE_GATE: case JUNGLE_FENCE_GATE:
case SPRUCE_FENCE_GATE: case SPRUCE_FENCE_GATE:
case LEVER: case LEVER:
case DIODE: case LEGACY_DIODE:
case DIODE_BLOCK_OFF: case LEGACY_DIODE_BLOCK_OFF:
case DIODE_BLOCK_ON: case LEGACY_DIODE_BLOCK_ON:
case COMMAND: case COMMAND_BLOCK:
case REDSTONE_COMPARATOR: case LEGACY_REDSTONE_COMPARATOR:
case REDSTONE_COMPARATOR_OFF: case LEGACY_REDSTONE_COMPARATOR_OFF:
case REDSTONE_COMPARATOR_ON: case LEGACY_REDSTONE_COMPARATOR_ON:
case REDSTONE_ORE: case REDSTONE_ORE:
case WOOD_BUTTON: case LEGACY_WOOD_BUTTON:
case STONE_BUTTON: case STONE_BUTTON:
case BEACON: case BEACON:
case BED_BLOCK: case LEGACY_BED_BLOCK:
case SIGN: case SIGN:
case WALL_SIGN: case WALL_SIGN:
case SIGN_POST: case LEGACY_ENCHANTMENT_TABLE:
case ENCHANTMENT_TABLE:
case BREWING_STAND: case BREWING_STAND:
case STANDING_BANNER: case LEGACY_STANDING_BANNER:
case BURNING_FURNACE: case LEGACY_BURNING_FURNACE:
case FURNACE: case FURNACE:
case CAKE_BLOCK: case CAKE:
case DISPENSER: case DISPENSER:
case DROPPER: case DROPPER:
case HOPPER: case HOPPER:
case NOTE_BLOCK: case NOTE_BLOCK:
case JUKEBOX: case JUKEBOX:
case WORKBENCH: case CRAFTING_TABLE:
case SILVER_SHULKER_BOX: case LEGACY_SILVER_SHULKER_BOX:
case BLACK_SHULKER_BOX: case BLACK_SHULKER_BOX:
case BLUE_SHULKER_BOX: case BLUE_SHULKER_BOX:
case RED_SHULKER_BOX: case RED_SHULKER_BOX:
@ -1578,8 +1576,8 @@ public class PlayerEvents extends PlotListener implements Listener {
case LIME_SHULKER_BOX: case LIME_SHULKER_BOX:
case LIGHT_BLUE_SHULKER_BOX: case LIGHT_BLUE_SHULKER_BOX:
case MAGENTA_SHULKER_BOX: case MAGENTA_SHULKER_BOX:
case COMMAND_REPEATING: case LEGACY_COMMAND_REPEATING:
case COMMAND_CHAIN: case LEGACY_COMMAND_CHAIN:
eventType = PlayerBlockEventType.INTERACT_BLOCK; eventType = PlayerBlockEventType.INTERACT_BLOCK;
break; break;
@ -1592,7 +1590,7 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
break; break;
} }
lb = new BukkitLazyBlock(blockId, block); lb = new BukkitLazyBlock(PlotBlock.get(block.getType().toString()));
ItemStack hand = player.getItemInHand(); ItemStack hand = player.getItemInHand();
if (eventType != null && (eventType != PlayerBlockEventType.INTERACT_BLOCK if (eventType != null && (eventType != PlayerBlockEventType.INTERACT_BLOCK
|| !player.isSneaking())) { || !player.isSneaking())) {
@ -1608,15 +1606,14 @@ public class PlayerEvents extends PlotListener implements Listener {
location = BukkitUtil location = BukkitUtil
.getLocation(block.getRelative(event.getBlockFace()).getLocation()); .getLocation(block.getRelative(event.getBlockFace()).getLocation());
eventType = PlayerBlockEventType.PLACE_BLOCK; eventType = PlayerBlockEventType.PLACE_BLOCK;
lb = new BukkitLazyBlock(id, block);
break; break;
} }
Material handType = hand.getType(); Material handType = hand.getType();
lb = new BukkitLazyBlock(PlotBlock.get((short) handType.getId(), (byte) 0)); lb = new BukkitLazyBlock(PlotBlock.get(handType.toString()));
switch (handType) { switch (handType) {
case FIREWORK: case LEGACY_FIREWORK:
case MONSTER_EGG: case LEGACY_MONSTER_EGG:
case MONSTER_EGGS: case LEGACY_MONSTER_EGGS:
eventType = PlayerBlockEventType.SPAWN_MOB; eventType = PlayerBlockEventType.SPAWN_MOB;
break; break;
case ARMOR_STAND: case ARMOR_STAND:
@ -1625,40 +1622,40 @@ public class PlayerEvents extends PlotListener implements Listener {
eventType = PlayerBlockEventType.PLACE_MISC; eventType = PlayerBlockEventType.PLACE_MISC;
break; break;
case WRITTEN_BOOK: case WRITTEN_BOOK:
case BOOK_AND_QUILL: case LEGACY_BOOK_AND_QUILL:
case BOOK: case BOOK:
eventType = PlayerBlockEventType.READ; eventType = PlayerBlockEventType.READ;
break; break;
case APPLE: case APPLE:
case BAKED_POTATO: case BAKED_POTATO:
case MUSHROOM_SOUP: case LEGACY_MUSHROOM_SOUP:
case BREAD: case BREAD:
case CARROT: case CARROT:
case CARROT_ITEM: case LEGACY_CARROT_ITEM:
case COOKIE: case COOKIE:
case GRILLED_PORK: case LEGACY_GRILLED_PORK:
case POISONOUS_POTATO: case POISONOUS_POTATO:
case MUTTON: case MUTTON:
case PORK: case LEGACY_PORK:
case POTATO: case POTATO:
case POTATO_ITEM: case LEGACY_POTATO_ITEM:
case POTION: case POTION:
case PUMPKIN_PIE: case PUMPKIN_PIE:
case RABBIT: case RABBIT:
case RABBIT_FOOT: case RABBIT_FOOT:
case RABBIT_STEW: case RABBIT_STEW:
case RAW_BEEF: case LEGACY_RAW_BEEF:
case RAW_FISH: case LEGACY_RAW_FISH:
case RAW_CHICKEN: case LEGACY_RAW_CHICKEN:
eventType = PlayerBlockEventType.EAT; eventType = PlayerBlockEventType.EAT;
break; break;
case MINECART: case MINECART:
case STORAGE_MINECART: case LEGACY_STORAGE_MINECART:
case POWERED_MINECART: case LEGACY_POWERED_MINECART:
case HOPPER_MINECART: case HOPPER_MINECART:
case EXPLOSIVE_MINECART: case LEGACY_EXPLOSIVE_MINECART:
case COMMAND_MINECART: case LEGACY_COMMAND_MINECART:
case BOAT: case LEGACY_BOAT:
eventType = PlayerBlockEventType.PLACE_VEHICLE; eventType = PlayerBlockEventType.PLACE_VEHICLE;
break; break;
case PAINTING: case PAINTING:
@ -1683,8 +1680,8 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) { if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
if (player.getItemInHand().getTypeId() == PlotSquared.get().worldedit if (player.getInventory().getItemInMainHand().getType() == LegacyMappings.fromLegacyId(PlotSquared.get().worldedit
.getConfiguration().wandItem) { .getConfiguration().wandItem).getMaterial()) {
return; return;
} }
} }
@ -1996,7 +1993,7 @@ public class PlayerEvents extends PlotListener implements Listener {
Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE); Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE);
Block block = event.getBlockClicked(); Block block = event.getBlockClicked();
if (use.isPresent() && use.get() if (use.isPresent() && use.get()
.contains(PlotBlock.get(block.getTypeId(), block.getData()))) { .contains(PlotBlock.get(block.getType().name()))) {
return; return;
} }
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) { if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) {
@ -2520,7 +2517,7 @@ public class PlayerEvents extends PlotListener implements Listener {
Set<PlotBlock> place = plot.getFlag(Flags.PLACE, null); Set<PlotBlock> place = plot.getFlag(Flags.PLACE, null);
if (place != null) { if (place != null) {
Block block = event.getBlock(); Block block = event.getBlock();
if (place.contains(PlotBlock.get((short) block.getTypeId(), block.getData()))) { if (place.contains(PlotBlock.get(block.getType().name()))) {
return; return;
} }
} }

View File

@ -73,8 +73,8 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
} }
if (!"[(+NBT)]".equals(newLore) || (current.equals(newItem) && newLore.equals(oldLore))) { if (!"[(+NBT)]".equals(newLore) || (current.equals(newItem) && newLore.equals(oldLore))) {
switch (newItem.getType()) { switch (newItem.getType()) {
case BANNER: case LEGACY_BANNER:
case SKULL_ITEM: case PLAYER_HEAD:
if (newMeta != null) if (newMeta != null)
break; break;
default: default:
@ -92,12 +92,12 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
Material itemType = newItem.getType(); Material itemType = newItem.getType();
if (stateType != itemType) { if (stateType != itemType) {
switch (stateType) { switch (stateType) {
case STANDING_BANNER: case LEGACY_STANDING_BANNER:
case WALL_BANNER: case LEGACY_WALL_BANNER:
if (itemType == Material.BANNER) if (itemType == Material.LEGACY_BANNER)
break; break;
case SKULL: case LEGACY_SKULL:
if (itemType == Material.SKULL_ITEM) if (itemType == Material.LEGACY_SKULL_ITEM)
break; break;
default: default:
return; return;

View File

@ -2,135 +2,24 @@ package com.github.intellectualsites.plotsquared.bukkit.object;
import com.github.intellectualsites.plotsquared.plot.object.LazyBlock; import com.github.intellectualsites.plotsquared.plot.object.LazyBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
import org.bukkit.block.Block; import org.bukkit.block.Block;
public class BukkitLazyBlock extends LazyBlock { public class BukkitLazyBlock extends LazyBlock {
private int id; private StringPlotBlock pb;
private Block block;
private PlotBlock pb;
public BukkitLazyBlock(int id, Block block) { public BukkitLazyBlock(Block block) {
this.id = id; this.pb = (StringPlotBlock) PlotBlock.get(block.getType().toString());
this.block = block;
} }
public BukkitLazyBlock(PlotBlock pb) { public BukkitLazyBlock(StringPlotBlock pb) {
this.id = pb.id;
this.pb = pb; this.pb = pb;
} }
public BukkitLazyBlock(Block block) { public StringPlotBlock getPlotBlock() {
this.block = block;
}
@Override public PlotBlock getPlotBlock() {
if (this.pb != null) {
return this.pb;
}
if (this.id == 0) {
this.id = this.block.getTypeId();
}
byte data;
switch (this.id) {
case 0:
case 2:
case 4:
case 13:
case 14:
case 15:
case 20:
case 21:
case 22:
case 24:
case 25:
case 30:
case 32:
case 37:
case 39:
case 40:
case 41:
case 42:
case 45:
case 46:
case 47:
case 48:
case 49:
case 51:
case 52:
case 54:
case 55:
case 56:
case 57:
case 58:
case 60:
case 61:
case 62:
case 7:
case 8:
case 9:
case 10:
case 11:
case 73:
case 74:
case 78:
case 79:
case 80:
case 81:
case 82:
case 83:
case 84:
case 85:
case 87:
case 88:
case 101:
case 102:
case 103:
case 110:
case 112:
case 113:
case 117:
case 121:
case 122:
case 123:
case 124:
case 129:
case 133:
case 138:
case 137:
case 140:
case 165:
case 166:
case 169:
case 170:
case 172:
case 173:
case 174:
case 176:
case 177:
case 181:
case 182:
case 188:
case 189:
case 190:
case 191:
case 192:
data = 0;
break;
default:
data = this.block.getData();
break;
}
this.pb = PlotBlock.get((short) this.id, data);
return this.pb; return this.pb;
} }
@Override public int getId() {
if (this.id == 0) {
this.id = this.block.getTypeId();
}
return this.id;
}
} }

View File

@ -13,6 +13,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlock
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.*; import org.bukkit.block.*;
import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.Pattern;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -58,29 +59,35 @@ public class BukkitChunkManager extends ChunkManager {
map.saveBlocks(world1, 256, sx, sz, relX, relZ, false); map.saveBlocks(world1, 256, sx, sz, relX, relZ, false);
for (int y = 0; y < 256; y++) { for (int y = 0; y < 256; y++) {
Block block1 = world1.getBlockAt(x, y, z); Block block1 = world1.getBlockAt(x, y, z);
int id1 = block1.getTypeId(); // int id1 = block1.getTypeId();
byte data1 = block1.getData(); Material id1 = block1.getType();
BlockData data1 = block1.getBlockData();
// byte data1 = block1.getData();
int xx = x + relX; int xx = x + relX;
int zz = z + relZ; int zz = z + relZ;
Block block2 = world2.getBlockAt(xx, y, zz); Block block2 = world2.getBlockAt(xx, y, zz);
int id2 = block2.getTypeId(); // int id2 = block2.getTypeId();
byte data2 = block2.getData(); Material id2 = block2.getType();
if (id1 == 0) { BlockData data2 = block2.getBlockData();
if (id2 != 0) { // byte data2 = block2.getData();
queue1.setBlock(x, y, z, (short) id2, data2); if (id1 == Material.AIR) {
if (id2 != Material.AIR) {
queue1.setBlock(x, y, z, id2.name());
queue2.setBlock(xx, y, zz, (short) 0, (byte) 0); queue2.setBlock(xx, y, zz, (short) 0, (byte) 0);
} }
} else if (id2 == 0) { } else if (id2 == Material.AIR) {
queue1.setBlock(x, y, z, (short) 0, (byte) 0); queue1.setBlock(x, y, z, (short) 0, (byte) 0);
queue2.setBlock(xx, y, zz, (short) id1, data1); queue2.setBlock(xx, y, zz, id1.name());
} else if (id1 == id2) { } else if (id1 == id2) {
if (data1 != data2) { if (data1 != data2) {
block1.setData(data2); block1.setBlockData(data2);
block2.setData(data1); block2.setBlockData(data1);
} }
} else { } else {
queue1.setBlock(x, y, z, (short) id2, data2); queue1.setBlock(x, y, z, id2.name());
queue2.setBlock(xx, y, zz, (short) id1, data1); queue2.setBlock(xx, y, zz, id1.name());
// queue1.setBlock(x, y, z, (short) id2, data2);
// queue2.setBlock(xx, y, zz, (short) id1, data1);
} }
} }
} }
@ -1092,7 +1099,7 @@ public class BukkitChunkManager extends ChunkManager {
if (storeNormal) { if (storeNormal) {
int typeId = id.getId(); int typeId = id.getId();
if (typeId == 0) { if (typeId == 0) {
ids[y] = PlotBlock.EVERYTHING; ids[y] = StringPlotBlock.EVERYTHING;
} else { } else {
ids[y] = PlotBlock.get((short) typeId, block.getData()); ids[y] = PlotBlock.get((short) typeId, block.getData());
} }
@ -1131,7 +1138,7 @@ public class BukkitChunkManager extends ChunkManager {
this.brewingStandContents.put(bl, invBre); this.brewingStandContents.put(bl, invBre);
break; break;
case FURNACE: case FURNACE:
case BURNING_FURNACE: case LEGACY_BURNING_FURNACE:
Furnace furnace = (Furnace) inventoryHolder; Furnace furnace = (Furnace) inventoryHolder;
short burn = furnace.getBurnTime(); short burn = furnace.getBurnTime();
short cook = furnace.getCookTime(); short cook = furnace.getCookTime();

View File

@ -7,6 +7,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.InventoryUtil; import com.github.intellectualsites.plotsquared.plot.util.InventoryUtil;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.InventoryView;
@ -23,7 +24,7 @@ public class BukkitInventoryUtil extends InventoryUtil {
if (item == null) { if (item == null) {
return null; return null;
} }
ItemStack stack = new ItemStack(item.id, item.amount, item.data); ItemStack stack = new ItemStack(BukkitUtil.getMaterial(item.getPlotBlock()), item.amount);
ItemMeta meta = null; ItemMeta meta = null;
if (item.name != null) { if (item.name != null) {
meta = stack.getItemMeta(); meta = stack.getItemMeta();
@ -82,7 +83,8 @@ public class BukkitInventoryUtil extends InventoryUtil {
if (item == null) { if (item == null) {
return null; return null;
} }
int id = item.getTypeId(); // int id = item.getTypeId();
Material id = item.getType();
short data = item.getDurability(); short data = item.getDurability();
int amount = item.getAmount(); int amount = item.getAmount();
String name = null; String name = null;
@ -97,7 +99,7 @@ public class BukkitInventoryUtil extends InventoryUtil {
lore = itemLore.toArray(new String[itemLore.size()]); lore = itemLore.toArray(new String[itemLore.size()]);
} }
} }
return new PlotItemStack(id, data, amount, name, lore); return new PlotItemStack(id.name(), amount, name, lore);
} }
@Override public PlotItemStack[] getItems(PlotPlayer player) { @Override public PlotItemStack[] getItems(PlotPlayer player) {

View File

@ -140,7 +140,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
int rx = x - bx; int rx = x - bx;
int index = i2 + rx; int index = i2 + rx;
Block block = worldObj.getBlockAt(x, y, z); Block block = worldObj.getBlockAt(x, y, z);
int id = block.getTypeId(); int id = LegacyMappings.fromNewName(block.getType().name()).getNumericalId();
switch (id) { switch (id) {
case 0: case 0:
case 2: case 2:

View File

@ -60,6 +60,14 @@ import java.util.*;
return getLocation(location).getPlot(); return getLocation(location).getPlot();
} }
@Override public boolean isBlockSame(PlotBlock block1, PlotBlock block2) {
if (block1.equals(block2)) {
return true;
}
Material mat1 = getMaterial(block1), mat2 = getMaterial(block2);
return mat1 == mat2;
}
/** /**
* Get a plot based on the player location. * Get a plot based on the player location.
* *
@ -248,7 +256,7 @@ import java.util.*;
final Block block = world.getBlockAt(x, y, z); final Block block = world.getBlockAt(x, y, z);
// block.setType(Material.AIR); // block.setType(Material.AIR);
final Material type = block.getType(); final Material type = block.getType();
if (type != Material.SIGN && type != Material.SIGN_POST) { if (type != Material.SIGN && type != Material.WALL_SIGN) {
int data = 2; int data = 2;
if (world.getBlockAt(x, y, z + 1).getType().isSolid()) if (world.getBlockAt(x, y, z + 1).getType().isSolid())
data = 2; data = 2;
@ -258,7 +266,9 @@ import java.util.*;
data = 3; data = 3;
else if (world.getBlockAt(x - 1, y, z).getType().isSolid()) else if (world.getBlockAt(x - 1, y, z).getType().isSolid())
data = 5; data = 5;
block.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) data, false); block.setType(Material.WALL_SIGN, false);
final Sign sign = (Sign) block.getBlockData();
sign.setRawData((byte) data);
} }
final BlockState blockstate = block.getState(); final BlockState blockstate = block.getState();
if (blockstate instanceof Sign) { if (blockstate instanceof Sign) {
@ -322,8 +332,6 @@ import java.util.*;
switch (type) { switch (type) {
case WATER: case WATER:
case LAVA: case LAVA:
case STATIONARY_LAVA:
case STATIONARY_WATER:
return y; return y;
} }
air++; air++;
@ -363,7 +371,7 @@ import java.util.*;
InventoryHolder holder = (InventoryHolder) state; InventoryHolder holder = (InventoryHolder) state;
Inventory inv = holder.getInventory(); Inventory inv = holder.getInventory();
for (int i = 0; i < items.id.length; i++) { for (int i = 0; i < items.id.length; i++) {
ItemStack item = new ItemStack(items.id[i], items.amount[i], items.data[i]); ItemStack item = new ItemStack(LegacyMappings.fromLegacyId(items.id[i]).getMaterial(), items.amount[i], items.data[i]);
inv.addItem(item); inv.addItem(item);
} }
state.update(true); state.update(true);
@ -372,9 +380,18 @@ import java.util.*;
return false; return false;
} }
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 LegacyMappings.fromLegacyId(legacyPlotBlock.getId()).getMaterial();
}
}
@Override public boolean isBlockSolid(@NonNull final PlotBlock block) { @Override public boolean isBlockSolid(@NonNull final PlotBlock block) {
try { try {
final Material material = Material.getMaterial(block.id); final Material material = getMaterial(block);
if (material.isBlock() && material.isSolid() && !material.hasGravity()) { if (material.isBlock() && material.isSolid() && !material.hasGravity()) {
Class<? extends MaterialData> data = material.getData(); Class<? extends MaterialData> data = material.getData();
if (data.equals(MaterialData.class) && !material.isTransparent() && material if (data.equals(MaterialData.class) && !material.isTransparent() && material
@ -383,7 +400,7 @@ import java.util.*;
.equals(WoodenStep.class)) { .equals(WoodenStep.class)) {
switch (material) { switch (material) {
case NOTE_BLOCK: case NOTE_BLOCK:
case MOB_SPAWNER: case SPAWNER:
return false; return false;
default: default:
return true; return true;
@ -398,7 +415,7 @@ import java.util.*;
@Override public String getClosestMatchingName(@NonNull final PlotBlock block) { @Override public String getClosestMatchingName(@NonNull final PlotBlock block) {
try { try {
return Material.getMaterial(block.id).name(); return getMaterial(block).name();
} catch (Exception ignored) { } catch (Exception ignored) {
return null; return null;
} }
@ -408,8 +425,8 @@ import java.util.*;
public StringComparison<PlotBlock>.ComparisonResult getClosestBlock(String name) { public StringComparison<PlotBlock>.ComparisonResult getClosestBlock(String name) {
try { try {
final Material material = Material.valueOf(name.toUpperCase()); final Material material = Material.valueOf(name.toUpperCase());
return new StringComparison<PlotBlock>().new ComparisonResult(0, return new StringComparison<PlotBlock>().new ComparisonResult(1,
PlotBlock.get((short) material.getId(), (byte) 0)); PlotBlock.get(name));
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
} }
try { try {
@ -457,9 +474,9 @@ import java.util.*;
final World world = getWorld(location.getWorld()); final World world = getWorld(location.getWorld());
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ()); final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
if (block == null) { if (block == null) {
return PlotBlock.EVERYTHING; return StringPlotBlock.EVERYTHING;
} }
return PlotBlock.get((short) block.getTypeId(), block.getData()); return PlotBlock.get(block.getType().name());
} }
@Override public String getMainWorld() { @Override public String getMainWorld() {

View File

@ -0,0 +1,905 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import lombok.*;
import org.bukkit.Material;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* Borrowed from https://github.com/Phoenix616/IDConverter/blob/master/mappings/src/main/java/de/themoep/idconverter/IdMappings.java
* Original License:
*
* Minecraft ID mappings
* Copyright (C) 2017 Max Lee (https://github.com/Phoenix616)
*
* 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.
*
* 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.
*
* 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 class 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", "chisled_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"),
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"),
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"),
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_coblestone"),
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_crcked_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", "ironbars"),
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", "zombe_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<Integer, LegacyBlock> NUMERICAL_MAP = new HashMap<>();
private static final Map<IdDataPair, LegacyBlock> NUMERICAL_AND_DATA_MAP = new HashMap<>();
private static final Map<String, LegacyBlock> LEGACY_NAME_MAP = new HashMap<>();
private static final Map<String, LegacyBlock> NEW_NAME_MAP = new HashMap<>();
public static void initialize() {
for (final LegacyBlock legacyBlock : BLOCKS) {
NUMERICAL_MAP.put(legacyBlock.getNumericalId(), legacyBlock);
if (legacyBlock.getDataValue() != 0) {
NUMERICAL_AND_DATA_MAP.put(new IdDataPair(legacyBlock.getNumericalId(), legacyBlock.getDataValue()), legacyBlock);
}
LEGACY_NAME_MAP.put(legacyBlock.getLegacyName(), legacyBlock);
NEW_NAME_MAP.put(legacyBlock.getNewName(), legacyBlock);
Material material;
try {
material = Material.valueOf(legacyBlock.getNewName());
} catch (final Exception e)
{
material = Material.getMaterial(legacyBlock.getLegacyName(), true);
}
legacyBlock.material = material;
}
}
public static LegacyBlock fromLegacyId(final int id) {
return NUMERICAL_MAP.get(id);
}
public static LegacyBlock fromIdAndData(final int id, final int data) {
if (data == 0) {
return fromLegacyId(id);
}
return NUMERICAL_AND_DATA_MAP.get(new IdDataPair(id, data));
}
public static LegacyBlock fromLegacyName(final String id) {
return LEGACY_NAME_MAP.get(id);
}
public static LegacyBlock fromNewName(final String id) {
return NEW_NAME_MAP.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, @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);
}
}
}

View File

@ -1,17 +1,23 @@
package com.github.intellectualsites.plotsquared.bukkit.util.block; package com.github.intellectualsites.plotsquared.bukkit.util.block;
import com.github.intellectualsites.plotsquared.bukkit.util.LegacyMappings;
import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.block.BasicLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.BasicLocalBlockQueue;
import lombok.NonNull;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Locale;
public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> { public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
@ -38,11 +44,12 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
if (block == null) { if (block == null) {
return PlotBlock.get(0, 0); return PlotBlock.get(0, 0);
} }
int id = block.getTypeId(); // int id = block.getTypeId();
if (id == 0) { // if (id == 0) {
return PlotBlock.get(0, 0); // return PlotBlock.get(0, 0);
} // }
return PlotBlock.get(id, block.getData()); // return PlotBlock.get(id, block.getData());
return PlotBlock.get(block.getType().toString());
} }
@Override public void refreshChunk(int x, int z) { @Override public void refreshChunk(int x, int z) {
@ -86,22 +93,48 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
int y = MainUtil.y_loc[layer][j]; int y = MainUtil.y_loc[layer][j];
int z = MainUtil.z_loc[layer][j]; int z = MainUtil.z_loc[layer][j];
Block existing = chunk.getBlock(x, y, z); Block existing = chunk.getBlock(x, y, z);
int existingId = existing.getTypeId(); // int existingId = existing.getTypeId();
if (existingId == block.id) { // if (existingId == block.id) {
if (existingId == 0) { // if (existingId == 0) {
continue; // continue;
} // }
if (existing.getData() == block.data) { // if (existing.getData() == block.data) {
continue; // continue;
} // }
//}
if (equals(block, existing)) {
continue;
} }
existing.setTypeIdAndData(block.id, block.data, false); setMaterial(block, existing);
} }
} }
} }
} }
} }
private void setMaterial(@NonNull final PlotBlock plotBlock, @NonNull final Block block) {
if (plotBlock instanceof StringPlotBlock) {
final Material material = Material.getMaterial(((StringPlotBlock) plotBlock).getItemId().toLowerCase(
Locale.ENGLISH));
if (material == null) {
throw new IllegalStateException(String.format("Could not find material that matches %s", block.toString()));
}
block.setType(material, false);
} else {
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock;
block.setType(LegacyMappings.fromIdAndData(legacyPlotBlock.getId(), legacyPlotBlock.getData()).getMaterial());
// block.setTypeIdAndData(legacyPlotBlock.getId(), legacyPlotBlock.getData(), 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 LegacyMappings.fromLegacyId(((LegacyPlotBlock) plotBlock).id).getMaterial() == block.getType() && (legacyPlotBlock.id == 0 || legacyPlotBlock.data == block.getData());
}
public void setBiomes(LocalChunk<T> lc) { public void setBiomes(LocalChunk<T> lc) {
if (lc.biomes != null) { if (lc.biomes != null) {
World worldObj = Bukkit.getWorld(getWorld()); World worldObj = Bukkit.getWorld(getWorld());

View File

@ -1,129 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util.block;
import com.github.intellectualsites.plotsquared.bukkit.util.SendChunk;
import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import java.util.*;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
public class BukkitLocalQueue_1_7 extends BukkitLocalQueue<PlotBlock[]> {
private final ReflectionUtils.RefClass classBlock = getRefClass("{nms}.Block");
private final ReflectionUtils.RefClass classChunk = getRefClass("{nms}.Chunk");
private final ReflectionUtils.RefClass classWorld = getRefClass("{nms}.World");
private final ReflectionUtils.RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
private final ReflectionUtils.RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
private final ReflectionUtils.RefMethod methodGetHandle;
private final ReflectionUtils.RefMethod methodGetHandleChunk;
private final ReflectionUtils.RefMethod methodGetChunkAt;
private final ReflectionUtils.RefMethod methodA;
private final ReflectionUtils.RefMethod methodGetById;
private final ReflectionUtils.RefMethod methodInitLighting;
private final SendChunk sendChunk;
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
public BukkitLocalQueue_1_7(String world)
throws NoSuchMethodException, ClassNotFoundException, NoSuchFieldException {
super(world);
this.methodGetHandle = this.classCraftWorld.getMethod("getHandle");
this.methodGetChunkAt = this.classWorld.getMethod("getChunkAt", int.class, int.class);
this.methodA = this.classChunk
.getMethod("a", int.class, int.class, int.class, this.classBlock, int.class);
this.methodGetById = this.classBlock.getMethod("getById", int.class);
this.methodGetHandleChunk = this.classCraftChunk.getMethod("getHandle");
this.methodInitLighting = this.classChunk.getMethod("initLighting");
this.sendChunk = new SendChunk();
TaskManager.runTaskRepeat(new Runnable() {
@Override public void run() {
if (BukkitLocalQueue_1_7.this.toUpdate.isEmpty()) {
return;
}
int count = 0;
ArrayList<Chunk> chunks = new ArrayList<>();
Iterator<Map.Entry<ChunkWrapper, Chunk>> i =
BukkitLocalQueue_1_7.this.toUpdate.entrySet().iterator();
while (i.hasNext() && (count < 128)) {
chunks.add(i.next().getValue());
i.remove();
count++;
}
if (count == 0) {
return;
}
update(chunks);
}
}, 1);
MainUtil.initCache();
}
public void update(Collection<Chunk> chunks) {
if (chunks.isEmpty()) {
return;
}
if (!MainUtil.canSendChunk) {
for (Chunk chunk : chunks) {
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
chunk.unload(true, false);
chunk.load();
}
return;
}
try {
this.sendChunk.sendChunk(chunks);
} catch (Throwable e) {
e.printStackTrace();
MainUtil.canSendChunk = false;
}
}
@Override public void fixChunkLighting(int x, int z) {
Object c = this.methodGetHandleChunk.of(getChunk(x, z)).call();
this.methodInitLighting.of(c).call();
}
@Override public void setBlocks(LocalChunk<PlotBlock[]> lc) {
Chunk chunk = getChunk(lc.getX(), lc.getZ());
chunk.load(true);
World world = chunk.getWorld();
ChunkWrapper wrapper = new ChunkWrapper(getWorld(), lc.getX(), lc.getZ());
if (!this.toUpdate.containsKey(wrapper)) {
this.toUpdate.put(wrapper, chunk);
}
Object w = this.methodGetHandle.of(world).call();
Object c = this.methodGetChunkAt.of(w).call(lc.getX(), lc.getZ());
for (int i = 0; i < lc.blocks.length; i++) {
PlotBlock[] result2 = lc.blocks[i];
if (result2 == null) {
continue;
}
for (int j = 0; j < 4096; j++) {
int x = MainUtil.x_loc[i][j];
int y = MainUtil.y_loc[i][j];
int z = MainUtil.z_loc[i][j];
PlotBlock newBlock = result2[j];
if (newBlock != null) {
if (newBlock.id == -1) {
chunk.getBlock(x, y, z).setData(newBlock.data, false);
continue;
}
Object block = this.methodGetById.call(newBlock.id);
this.methodA.of(c).call(x, y, z, block, newBlock.data);
}
}
}
fixChunkLighting(lc.getX(), lc.getZ());
}
@Override public void refreshChunk(int x, int z) {
update(Arrays.asList(Bukkit.getWorld(getWorld()).getChunkAt(x, z)));
}
}

View File

@ -1,341 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util.block;
import com.github.intellectualsites.plotsquared.bukkit.util.SendChunk;
import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.RefClass;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.RefMethod;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Block;
import java.util.*;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
public class BukkitLocalQueue_1_8 extends BukkitLocalQueue<PlotBlock[]> {
private final ReflectionUtils.RefMethod methodInitLighting;
private final ReflectionUtils.RefClass classBlock = getRefClass("{nms}.Block");
private final ReflectionUtils.RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
private final ReflectionUtils.RefClass classIBlockData = getRefClass("{nms}.IBlockData");
private final ReflectionUtils.RefClass classChunk = getRefClass("{nms}.Chunk");
private final ReflectionUtils.RefClass classWorld = getRefClass("{nms}.World");
private final ReflectionUtils.RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
private final ReflectionUtils.RefMethod methodGetHandle;
private final ReflectionUtils.RefMethod methodGetChunkAt;
private final ReflectionUtils.RefMethod methodA;
private final ReflectionUtils.RefMethod methodGetByCombinedId;
private final ReflectionUtils.RefConstructor constructorBlockPosition;
private final SendChunk sendChunk;
private final RefMethod methodGetHandleChunk;
public BukkitLocalQueue_1_8(String world)
throws NoSuchMethodException, ClassNotFoundException, NoSuchFieldException {
super(world);
this.methodInitLighting = this.classChunk.getMethod("initLighting");
this.constructorBlockPosition =
this.classBlockPosition.getConstructor(int.class, int.class, int.class);
this.methodGetByCombinedId = this.classBlock.getMethod("getByCombinedId", int.class);
this.methodGetHandle = this.classCraftWorld.getMethod("getHandle");
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
this.methodGetChunkAt = this.classWorld.getMethod("getChunkAt", int.class, int.class);
this.methodA =
this.classChunk.getMethod("a", this.classBlockPosition, this.classIBlockData);
this.sendChunk = new SendChunk();
TaskManager.runTaskRepeat(new Runnable() {
@Override public void run() {
if (BukkitLocalQueue_1_8.this.toUpdate.isEmpty()) {
return;
}
int count = 0;
ArrayList<Chunk> chunks = new ArrayList<>();
Iterator<Map.Entry<ChunkWrapper, Chunk>> i =
BukkitLocalQueue_1_8.this.toUpdate.entrySet().iterator();
while (i.hasNext() && count < 128) {
chunks.add(i.next().getValue());
i.remove();
count++;
}
if (count == 0) {
return;
}
update(chunks);
}
}, 1);
MainUtil.initCache();
}
@Override public void fixChunkLighting(int x, int z) {
Object c = this.methodGetHandleChunk.of(getChunk(x, z)).call();
this.methodInitLighting.of(c).call();
}
@Override public void setBlocks(LocalChunk<PlotBlock[]> lc) {
Chunk chunk = getChunk(lc.getX(), lc.getZ());
chunk.load(true);
World world = chunk.getWorld();
ChunkWrapper wrapper = new ChunkWrapper(getWorld(), lc.getX(), lc.getZ());
if (!this.toUpdate.containsKey(wrapper)) {
this.toUpdate.put(wrapper, chunk);
}
Object w = this.methodGetHandle.of(world).call();
Object c = this.methodGetChunkAt.of(w).call(lc.getX(), lc.getZ());
for (int i = 0; i < lc.blocks.length; i++) {
PlotBlock[] result2 = lc.blocks[i];
if (result2 == null) {
continue;
}
for (int j = 0; j < 4096; j++) {
int x = MainUtil.x_loc[i][j];
int y = MainUtil.y_loc[i][j];
int z = MainUtil.z_loc[i][j];
PlotBlock newBlock = result2[j];
if (newBlock == null)
continue;
if (newBlock.id == -1) {
chunk.getBlock(x, y, z).setData(newBlock.data, false);
continue;
}
// Start blockstate workaround //
switch (newBlock.id) {
case 54:
case 130:
case 142:
case 132:
case 27:
case 137:
case 52:
case 154:
case 84:
case 25:
case 144:
case 138:
case 176:
case 177:
case 119:
case 63:
case 68:
case 323:
case 117:
case 116:
case 28:
case 66:
case 157:
case 61:
case 62:
case 140:
case 146:
case 149:
case 150:
case 158:
case 23:
case 123:
case 124:
case 29:
case 33:
case 151:
case 178:
Block block = world.getBlockAt(x, y, z);
if (block.getData() == newBlock.data) {
if (block.getTypeId() != newBlock.id) {
block.setTypeId(newBlock.id, false);
}
} else {
if (block.getTypeId() == newBlock.id) {
block.setData(newBlock.data, false);
} else {
block.setTypeIdAndData(newBlock.id, newBlock.data, false);
}
}
continue;
}
// Start data value shortcut
Block block = world.getBlockAt(x, y, z);
int currentId = block.getTypeId();
if (currentId == newBlock.id) {
switch (newBlock.id) {
case 0:
case 2:
case 4:
case 13:
case 14:
case 15:
case 20:
case 21:
case 22:
case 25:
case 30:
case 32:
case 37:
case 39:
case 40:
case 41:
case 42:
case 45:
case 46:
case 47:
case 48:
case 49:
case 51:
case 52:
case 54:
case 55:
case 56:
case 57:
case 58:
case 60:
case 61:
case 62:
case 7:
case 8:
case 9:
case 10:
case 11:
case 73:
case 74:
case 78:
case 79:
case 80:
case 81:
case 82:
case 83:
case 84:
case 85:
case 87:
case 88:
case 101:
case 102:
case 103:
case 110:
case 112:
case 113:
case 117:
case 121:
case 122:
case 123:
case 124:
case 129:
case 133:
case 138:
case 137:
case 140:
case 165:
case 166:
case 169:
case 170:
case 172:
case 173:
case 174:
case 176:
case 177:
case 181:
case 182:
case 188:
case 189:
case 190:
case 191:
case 192:
continue;
}
if (block.getData() == newBlock.data) {
return;
}
block.setData(newBlock.data, false);
return;
}
// blockstate
switch (currentId) {
case 54:
case 130:
case 132:
case 142:
case 27:
case 137:
case 52:
case 154:
case 84:
case 25:
case 144:
case 138:
case 176:
case 177:
case 63:
case 68:
case 323:
case 117:
case 119:
case 116:
case 28:
case 66:
case 157:
case 61:
case 62:
case 140:
case 146:
case 149:
case 150:
case 158:
case 23:
case 123:
case 124:
case 29:
case 33:
case 151:
case 178:
if (block.getData() == newBlock.data) {
block.setTypeId(newBlock.id, false);
} else {
block.setTypeIdAndData(newBlock.id, newBlock.data, false);
}
continue;
}
// End blockstate workaround //
// check sign
Object pos = null;
try {
pos = this.constructorBlockPosition.create(x, y, z);
} catch (ReflectiveOperationException e) {
e.printStackTrace();
}
Object combined =
this.methodGetByCombinedId.call(newBlock.id + (newBlock.data << 12));
this.methodA.of(c).call(pos, combined);
}
}
fixChunkLighting(lc.getX(), lc.getZ());
}
public void update(Collection<Chunk> chunks) {
if (chunks.isEmpty()) {
return;
}
if (!MainUtil.canSendChunk) {
for (Chunk chunk : chunks) {
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
chunk.unload(true, false);
chunk.load();
}
return;
}
try {
this.sendChunk.sendChunk(chunks);
} catch (Throwable e) {
e.printStackTrace();
MainUtil.canSendChunk = false;
}
}
@Override public void refreshChunk(int x, int z) {
update(Arrays.asList(Bukkit.getWorld(getWorld()).getChunkAt(x, z)));
}
}

View File

@ -1,530 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util.block;
import com.github.intellectualsites.plotsquared.bukkit.util.SendChunk;
import com.github.intellectualsites.plotsquared.plot.object.ChunkLoc;
import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper;
import com.github.intellectualsites.plotsquared.plot.object.PseudoRandom;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.block.BasicLocalBlockQueue;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
public class BukkitLocalQueue_1_8_3 extends BukkitLocalQueue<char[]> {
private final SendChunk sendChunk;
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
private final ReflectionUtils.RefMethod methodGetHandleChunk;
private final ReflectionUtils.RefMethod methodGetHandleWorld;
private final ReflectionUtils.RefMethod methodInitLighting;
private final ReflectionUtils.RefConstructor classBlockPositionConstructor;
private final ReflectionUtils.RefConstructor classChunkSectionConstructor;
private final ReflectionUtils.RefMethod methodX;
private final ReflectionUtils.RefMethod methodAreNeighborsLoaded;
private final ReflectionUtils.RefField fieldSections;
private final ReflectionUtils.RefField fieldWorld;
private final ReflectionUtils.RefMethod methodGetIdArray;
private final ReflectionUtils.RefMethod methodGetWorld;
private final ReflectionUtils.RefField tileEntityListTick;
public BukkitLocalQueue_1_8_3(String world)
throws NoSuchMethodException, ClassNotFoundException, NoSuchFieldException {
super(world);
ReflectionUtils.RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
ReflectionUtils.RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
ReflectionUtils.RefClass classChunk = getRefClass("{nms}.Chunk");
this.methodInitLighting = classChunk.getMethod("initLighting");
ReflectionUtils.RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
this.classBlockPositionConstructor =
classBlockPosition.getConstructor(int.class, int.class, int.class);
ReflectionUtils.RefClass classWorld = getRefClass("{nms}.World");
this.methodX = classWorld.getMethod("x", classBlockPosition.getRealClass());
this.fieldSections = classChunk.getField("sections");
this.fieldWorld = classChunk.getField("world");
ReflectionUtils.RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
this.methodGetIdArray = classChunkSection.getMethod("getIdArray");
this.methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class);
this.classChunkSectionConstructor =
classChunkSection.getConstructor(int.class, boolean.class, char[].class);
this.tileEntityListTick = classWorld.getField("tileEntityList");
this.methodGetHandleWorld = classCraftWorld.getMethod("getHandle");
this.methodGetWorld = classChunk.getMethod("getWorld");
this.sendChunk = new SendChunk();
TaskManager.runTaskRepeat(new Runnable() {
@Override public void run() {
if (BukkitLocalQueue_1_8_3.this.toUpdate.isEmpty()) {
return;
}
int count = 0;
ArrayList<Chunk> chunks = new ArrayList<>();
Iterator<Map.Entry<ChunkWrapper, Chunk>> i =
BukkitLocalQueue_1_8_3.this.toUpdate.entrySet().iterator();
while (i.hasNext() && count < 128) {
chunks.add(i.next().getValue());
i.remove();
count++;
}
if (count == 0) {
return;
}
update(chunks);
}
}, 1);
MainUtil.initCache();
}
@Override public LocalChunk<char[]> getLocalChunk(int x, int z) {
return new CharLocalChunk_1_8_3(this, x, z);
}
@Override public void setBlocks(LocalChunk<char[]> lc) {
CharLocalChunk_1_8_3 fs = (CharLocalChunk_1_8_3) lc;
Chunk chunk = getChunk(lc.getX(), lc.getZ());
chunk.load(true);
World world = chunk.getWorld();
ChunkWrapper wrapper = new ChunkWrapper(getWorld(), lc.getX(), lc.getZ());
if (!this.toUpdate.containsKey(wrapper)) {
this.toUpdate.put(wrapper, chunk);
}
try {
boolean flag = world.getEnvironment() == World.Environment.NORMAL;
// Sections
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
Object c = getHandle.invoke(chunk);
Object w = this.methodGetWorld.of(c).call();
Class<?> clazz = c.getClass();
Field sections1 = clazz.getDeclaredField("sections");
sections1.setAccessible(true);
Field tileEntities = clazz.getDeclaredField("tileEntities");
Field entitySlices = clazz.getDeclaredField("entitySlices");
Object[] sections = (Object[]) sections1.get(c);
Map<?, ?> tiles = (Map<?, ?>) tileEntities.get(c);
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
Method getX = null;
Method getY = null;
Method getZ = null;
// Trim tiles
boolean removed = false;
Set<Map.Entry<?, ?>> entrySet = (Set<Map.Entry<?, ?>>) (Set<?>) tiles.entrySet();
Iterator<Map.Entry<?, ?>> iterator = entrySet.iterator();
while (iterator.hasNext()) {
Map.Entry<?, ?> tile = iterator.next();
Object pos = tile.getKey();
if (getX == null) {
Class<? extends Object> clazz2 = pos.getClass().getSuperclass();
getX = clazz2.getDeclaredMethod("getX");
getY = clazz2.getDeclaredMethod("getY");
getZ = clazz2.getDeclaredMethod("getZ");
}
int lx = (int) getX.invoke(pos) & 15;
int ly = (int) getY.invoke(pos);
int lz = (int) getZ.invoke(pos) & 15;
int j = MainUtil.CACHE_I[ly][lx][lz];
int k = MainUtil.CACHE_J[ly][lx][lz];
char[] array = fs.getIdArray(j);
if (array == null) {
continue;
}
if (array[k] != 0) {
removed = true;
iterator.remove();
}
}
if (removed) {
((Collection) this.tileEntityListTick.of(w).get()).clear();
}
// Trim entities
for (int i = 0; i < 16; i++) {
if ((entities[i] != null) && (fs.getCount(i) >= 4096)) {
entities[i].clear();
}
}
// Efficiently merge sections
for (int j = 0; j < sections.length; j++) {
if (fs.getCount(j) == 0) {
continue;
}
char[] newArray = fs.getIdArray(j);
if (newArray == null) {
continue;
}
Object section = sections[j];
if ((section == null) || (fs.getCount(j) >= 4096)) {
section = sections[j] = newChunkSection(j << 4, flag, newArray);
continue;
}
char[] currentArray = getIdArray(section);
boolean fill = true;
for (int k = 0; k < newArray.length; k++) {
char n = newArray[k];
switch (n) {
case 0:
fill = false;
continue;
case 1:
fill = false;
currentArray[k] = 0;
continue;
default:
currentArray[k] = n;
continue;
}
}
if (fill) {
fs.setCount(j, Short.MAX_VALUE);
}
}
// Clear
} catch (IllegalArgumentException | SecurityException | ReflectiveOperationException e) {
e.printStackTrace();
}
fixLighting(chunk, fs, true);
}
public Object newChunkSection(int i, boolean flag, char[] ids)
throws ReflectiveOperationException {
return this.classChunkSectionConstructor.create(i, flag, ids);
}
public char[] getIdArray(Object obj) {
return (char[]) this.methodGetIdArray.of(obj).call();
}
@Override public void fixChunkLighting(int x, int z) {
Object c = this.methodGetHandleChunk.of(getChunk(x, z)).call();
this.methodInitLighting.of(c).call();
}
public boolean fixLighting(Chunk chunk, CharLocalChunk_1_8_3 bc, boolean fixAll) {
try {
if (!chunk.isLoaded()) {
chunk.load(false);
} else {
chunk.unload(true, false);
chunk.load(false);
}
// Initialize lighting
Object c = this.methodGetHandleChunk.of(chunk).call();
if (fixAll && !(boolean) this.methodAreNeighborsLoaded.of(c).call(1)) {
World world = chunk.getWorld();
ChunkWrapper wrapper = new ChunkWrapper(getWorld(), chunk.getX(), chunk.getZ());
for (int x = wrapper.x - 1; x <= wrapper.x + 1; x++) {
for (int z = wrapper.z - 1; z <= wrapper.z + 1; z++) {
if (x != 0 && z != 0) {
Chunk other = world.getChunkAt(x, z);
while (!other.isLoaded()) {
other.load(true);
}
ChunkManager.manager.loadChunk(wrapper.world, new ChunkLoc(x, z), true);
}
}
}
/*
if (!(boolean) methodAreNeighborsLoaded.of(c).call(1)) {
return false;
}
*/
}
this.methodInitLighting.of(c).call();
if (bc.getTotalRelight() == 0 && !fixAll) {
return true;
}
Object[] sections = (Object[]) this.fieldSections.of(c).get();
Object w = this.fieldWorld.of(c).get();
int X = chunk.getX() << 4;
int Z = chunk.getZ() << 4;
ReflectionUtils.RefMethod.RefExecutor relight = this.methodX.of(w);
for (int j = 0; j < sections.length; j++) {
Object section = sections[j];
if (section == null) {
continue;
}
if ((bc.getRelight(j) == 0 && !fixAll) || bc.getCount(j) == 0 || (
bc.getCount(j) >= 4096 && bc.getAir(j) == 0)) {
continue;
}
char[] array = getIdArray(section);
int l = PseudoRandom.random.random(2);
for (int k = 0; k < array.length; k++) {
int i = array[k];
if (i < 16) {
continue;
}
short id = (short) (i >> 4);
switch (id) { // Lighting
default:
if (!fixAll) {
continue;
}
if ((k & 1) == l) {
l = 1 - l;
continue;
}
case 10:
case 11:
case 39:
case 40:
case 50:
case 51:
case 62:
case 74:
case 76:
case 89:
case 122:
case 124:
case 130:
case 138:
case 169:
int x = MainUtil.x_loc[j][k];
int y = MainUtil.y_loc[j][k];
int z = MainUtil.z_loc[j][k];
if (isSurrounded(sections, x, y, z)) {
continue;
}
Object pos = this.classBlockPositionConstructor.create(X + x, y, Z + z);
relight.call(pos);
}
}
}
return true;
} catch (Throwable e) {
e.printStackTrace();
}
return false;
}
public boolean isSurrounded(Object[] sections, int x, int y, int z) {
return isSolid(getId(sections, x, y + 1, z)) && isSolid(getId(sections, x + 1, y - 1, z))
&& isSolid(getId(sections, x - 1, y, z)) && isSolid(getId(sections, x, y, z + 1))
&& isSolid(getId(sections, x, y, z - 1));
}
public boolean isSolid(int i) {
return i != 0 && Material.getMaterial(i).isOccluding();
}
public int getId(Object[] sections, int x, int y, int z) {
if (x < 0 || x > 15 || z < 0 || z > 15) {
return 1;
}
if (y < 0 || y > 255) {
return 1;
}
int i = MainUtil.CACHE_I[y][x][z];
Object section = sections[i];
if (section == null) {
return 0;
}
char[] array = getIdArray(section);
int j = MainUtil.CACHE_J[y][x][z];
return array[j] >> 4;
}
public void update(Collection<Chunk> chunks) {
if (chunks.isEmpty()) {
return;
}
if (!MainUtil.canSendChunk) {
for (Chunk chunk : chunks) {
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
chunk.unload(true, false);
chunk.load();
}
return;
}
try {
this.sendChunk.sendChunk(chunks);
} catch (Throwable e) {
e.printStackTrace();
MainUtil.canSendChunk = false;
}
}
@Override public void refreshChunk(int x, int z) {
update(Arrays.asList(Bukkit.getWorld(getWorld()).getChunkAt(x, z)));
}
public class CharLocalChunk_1_8_3 extends CharLocalChunk {
public short[] count;
public short[] air;
public short[] relight;
public CharLocalChunk_1_8_3(BasicLocalBlockQueue parent, int x, int z) {
super(parent, x, z);
this.count = new short[16];
this.air = new short[16];
this.relight = new short[16];
}
@Override public void setBlock(int x, int y, int z, int id, int data) {
int i = MainUtil.CACHE_I[y][x][z];
int j = MainUtil.CACHE_J[y][x][z];
char[] vs = this.blocks[i];
if (vs == null) {
vs = this.blocks[i] = new char[4096];
this.count[i]++;
} else if (vs[j] == 0) {
this.count[i]++;
}
switch (id) {
case 0:
this.air[i]++;
vs[j] = (char) 1;
return;
case 10:
case 11:
case 39:
case 40:
case 51:
case 74:
case 89:
case 122:
case 124:
case 138:
case 169:
this.relight[i]++;
case 2:
case 4:
case 13:
case 14:
case 15:
case 20:
case 21:
case 22:
case 30:
case 32:
case 37:
case 41:
case 42:
case 45:
case 46:
case 47:
case 48:
case 49:
case 55:
case 56:
case 57:
case 58:
case 60:
case 7:
case 8:
case 9:
case 73:
case 78:
case 79:
case 80:
case 81:
case 82:
case 83:
case 85:
case 87:
case 88:
case 101:
case 102:
case 103:
case 110:
case 112:
case 113:
case 121:
case 129:
case 133:
case 165:
case 166:
case 170:
case 172:
case 173:
case 174:
case 181:
case 182:
case 188:
case 189:
case 190:
case 191:
case 192:
vs[j] = (char) (id << 4);
return;
case 130:
case 76:
case 62:
this.relight[i]++;
case 54:
case 146:
case 61:
case 65:
case 68:
case 50:
if (data < 2) {
data = 2;
}
default:
vs[j] = (char) ((id << 4) + data);
return;
}
}
public char[] getIdArray(int i) {
return this.blocks[i];
}
public int getCount(int i) {
return this.count[i];
}
public int getAir(int i) {
return this.air[i];
}
public void setCount(int i, short value) {
this.count[i] = value;
}
public int getRelight(int i) {
return this.relight[i];
}
public int getTotalCount() {
int total = 0;
for (int i = 0; i < 16; i++) {
total += this.count[i];
}
return total;
}
public int getTotalRelight() {
if (getTotalCount() == 0) {
Arrays.fill(this.count, (short) 1);
Arrays.fill(this.relight, Short.MAX_VALUE);
return Short.MAX_VALUE;
}
int total = 0;
for (int i = 0; i < 16; i++) {
total += this.relight[i];
}
return total;
}
}
}

View File

@ -1,494 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util.block;
import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper;
import com.github.intellectualsites.plotsquared.plot.object.PseudoRandom;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils;
import com.github.intellectualsites.plotsquared.plot.util.block.BasicLocalBlockQueue;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
public class BukkitLocalQueue_1_9 extends BukkitLocalQueue<char[]> {
private final Object air;
// private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
private final ReflectionUtils.RefMethod methodGetHandleChunk;
private final ReflectionUtils.RefMethod methodInitLighting;
private final ReflectionUtils.RefConstructor classBlockPositionConstructor;
private final ReflectionUtils.RefConstructor classChunkSectionConstructor;
private final ReflectionUtils.RefMethod methodW;
private final ReflectionUtils.RefMethod methodAreNeighborsLoaded;
private final ReflectionUtils.RefField fieldSections;
private final ReflectionUtils.RefField fieldWorld;
private final ReflectionUtils.RefMethod methodGetBlocks;
private final ReflectionUtils.RefMethod methodGetType;
private final ReflectionUtils.RefMethod methodSetType;
private final ReflectionUtils.RefMethod methodGetCombinedId;
private final ReflectionUtils.RefMethod methodGetByCombinedId;
private final ReflectionUtils.RefMethod methodGetWorld;
private final ReflectionUtils.RefField tileEntityListTick;
public BukkitLocalQueue_1_9(String world)
throws NoSuchMethodException, ClassNotFoundException, NoSuchFieldException {
super(world);
ReflectionUtils.RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
ReflectionUtils.RefClass classChunk = getRefClass("{nms}.Chunk");
this.methodInitLighting = classChunk.getMethod("initLighting");
ReflectionUtils.RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
this.classBlockPositionConstructor =
classBlockPosition.getConstructor(int.class, int.class, int.class);
ReflectionUtils.RefClass classWorld = getRefClass("{nms}.World");
this.tileEntityListTick = classWorld.getField("tileEntityListTick");
this.methodGetWorld = classChunk.getMethod("getWorld");
this.methodW = classWorld.getMethod("w", classBlockPosition.getRealClass());
this.fieldSections = classChunk.getField("sections");
this.fieldWorld = classChunk.getField("world");
ReflectionUtils.RefClass classBlock = getRefClass("{nms}.Block");
ReflectionUtils.RefClass classIBlockData = getRefClass("{nms}.IBlockData");
this.methodGetCombinedId =
classBlock.getMethod("getCombinedId", classIBlockData.getRealClass());
this.methodGetByCombinedId = classBlock.getMethod("getByCombinedId", int.class);
ReflectionUtils.RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
this.methodGetBlocks = classChunkSection.getMethod("getBlocks");
this.methodGetType =
classChunkSection.getMethod("getType", int.class, int.class, int.class);
this.methodSetType = classChunkSection
.getMethod("setType", int.class, int.class, int.class, classIBlockData.getRealClass());
this.methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class);
this.classChunkSectionConstructor =
classChunkSection.getConstructor(int.class, boolean.class, char[].class);
this.air = this.methodGetByCombinedId.call(0);
MainUtil.initCache();
}
@Override public LocalChunk<char[]> getLocalChunk(int x, int z) {
return new CharLocalChunk_1_8_3(this, x, z);
}
@Override public void setBlocks(LocalChunk lc) {
CharLocalChunk_1_8_3 fs = (CharLocalChunk_1_8_3) lc;
Chunk chunk = getChunk(lc.getX(), lc.getZ());
chunk.load(true);
World world = chunk.getWorld();
try {
boolean flag = world.getEnvironment() == World.Environment.NORMAL;
// Sections
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
Object c = getHandle.invoke(chunk);
Object w = this.methodGetWorld.of(c).call();
Class<? extends Object> clazz = c.getClass();
Field sf = clazz.getDeclaredField("sections");
sf.setAccessible(true);
Field tf = clazz.getDeclaredField("tileEntities");
Field entitySlices = clazz.getDeclaredField("entitySlices");
Object[] sections = (Object[]) sf.get(c);
Map<?, ?> tiles = (Map<?, ?>) tf.get(c);
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
Method xm = null;
Method ym = null;
Method zm = null;
// Trim tiles
Collection tickList = ((Collection) this.tileEntityListTick.of(w).get());
Set<Map.Entry<?, ?>> entrySet = (Set<Map.Entry<?, ?>>) (Set<?>) tiles.entrySet();
Iterator<Map.Entry<?, ?>> iterator = entrySet.iterator();
while (iterator.hasNext()) {
Map.Entry<?, ?> tile = iterator.next();
Object pos = tile.getKey();
if (xm == null) {
Class<?> clazz2 = pos.getClass().getSuperclass();
xm = clazz2.getDeclaredMethod("getX");
ym = clazz2.getDeclaredMethod("getY");
zm = clazz2.getDeclaredMethod("getZ");
}
int lx = (int) xm.invoke(pos) & 15;
int ly = (int) ym.invoke(pos);
int lz = (int) zm.invoke(pos) & 15;
int j = MainUtil.CACHE_I[ly][lx][lz];
int k = MainUtil.CACHE_J[ly][lx][lz];
char[] array = fs.getIdArray(j);
if (array == null) {
continue;
}
if (array[k] != 0) {
tickList.remove(tile.getValue());
iterator.remove();
}
}
// Trim entities
for (int i = 0; i < 16; i++) {
if (entities[i] != null && fs.getCount(i) >= 4096) {
entities[i].clear();
}
}
// Efficiently merge sections
for (int j = 0; j < sections.length; j++) {
if (fs.getCount(j) == 0) {
continue;
}
char[] newArray = fs.getIdArray(j);
if (newArray == null) {
continue;
}
Object section = sections[j];
if (section == null || fs.getCount(j) >= 4096) {
section = sections[j] = newChunkSection(j << 4, flag, fs.getIdArray(j));
continue;
}
Object currentArray = getBlocks(section);
ReflectionUtils.RefMethod.RefExecutor setType = this.methodSetType.of(section);
boolean fill = true;
for (int k = 0; k < newArray.length; k++) {
char n = newArray[k];
switch (n) {
case 0:
fill = false;
continue;
case 1: {
fill = false;
int x = MainUtil.x_loc[j][k];
int y = MainUtil.y_loc[j][k];
int z = MainUtil.z_loc[j][k];
setType.call(x, y & 15, z, this.air);
continue;
}
default:
int x = MainUtil.x_loc[j][k];
int y = MainUtil.y_loc[j][k];
int z = MainUtil.z_loc[j][k];
int id = n >> 4;
int data = n & 15;
Object iBlock =
this.methodGetByCombinedId.call((int) (id & 0xFFF) + (data << 12));
setType.call(x, y & 15, z, iBlock);
}
}
if (fill) {
fs.setCount(j, Short.MAX_VALUE);
}
}
// Clear
} catch (IllegalArgumentException | SecurityException | ReflectiveOperationException e) {
e.printStackTrace();
}
fixLighting(chunk, fs, true);
refreshChunk(fs.getX(), fs.getZ());
}
public Object newChunkSection(int i, boolean flag, char[] ids)
throws ReflectiveOperationException {
return this.classChunkSectionConstructor.create(i, flag, ids);
}
public Object getBlocks(Object obj) {
return this.methodGetBlocks.of(obj).call();
}
@Override public void fixChunkLighting(int x, int z) {
Object c = this.methodGetHandleChunk.of(getChunk(x, z)).call();
this.methodInitLighting.of(c).call();
}
public boolean fixLighting(Chunk chunk, CharLocalChunk_1_8_3 bc, boolean fixAll) {
try {
if (!chunk.isLoaded()) {
chunk.load(false);
} else {
chunk.unload(true, false);
chunk.load(false);
}
// Initialize lighting
Object c = this.methodGetHandleChunk.of(chunk).call();
ChunkWrapper wrapper = new ChunkWrapper(getWorld(), bc.getX(), bc.getZ());
Object[] result = disableLighting(chunk);
enableLighting(result);
this.methodInitLighting.of(c).call();
if (bc.getTotalRelight() != 0 || fixAll) {
Object[] sections = (Object[]) this.fieldSections.of(c).get();
Object w = this.fieldWorld.of(c).get();
int X = chunk.getX() << 4;
int Z = chunk.getZ() << 4;
ReflectionUtils.RefMethod.RefExecutor relight = this.methodW.of(w);
for (int j = 0; j < sections.length; j++) {
Object section = sections[j];
if (section == null) {
continue;
}
if (bc.getRelight(j) == 0 && !fixAll || bc.getCount(j) == 0
|| bc.getCount(j) >= 4096 && bc.getAir(j) == 0) {
continue;
}
char[] array = bc.getIdArray(j);
if (array != null) {
int l = PseudoRandom.random.random(2);
for (int k = 0; k < array.length; k++) {
int i = array[k];
if (i < 16) {
continue;
}
short id = (short) (i >> 4);
switch (id) { // Lighting
default:
if (!fixAll) {
continue;
}
if ((k & 1) == l) {
l = 1 - l;
continue;
}
case 10:
case 11:
case 39:
case 40:
case 50:
case 51:
case 62:
case 74:
case 76:
case 89:
case 122:
case 124:
case 130:
case 138:
case 169:
int x = MainUtil.x_loc[j][k];
int y = MainUtil.y_loc[j][k];
int z = MainUtil.z_loc[j][k];
if (isSurrounded(bc.blocks, x, y, z)) {
continue;
}
Object pos =
this.classBlockPositionConstructor.create(X + x, y, Z + z);
relight.call(pos);
}
}
}
}
}
resetLighting(result);
return true;
} catch (Throwable e) {
e.printStackTrace();
}
return false;
}
@Override public void refreshChunk(int x, int z) {
getBukkitWorld().refreshChunk(x, z);
}
public boolean isSurrounded(char[][] sections, int x, int y, int z) {
return isSolid(getId(sections, x, y + 1, z)) && isSolid(getId(sections, x + 1, y - 1, z))
&& isSolid(getId(sections, x - 1, y, z)) && isSolid(getId(sections, x, y, z + 1))
&& isSolid(getId(sections, x, y, z - 1));
}
public boolean isSolid(int i) {
if (i != 0) {
Material material = Material.getMaterial(i);
return material != null && Material.getMaterial(i).isOccluding();
}
return false;
}
public int getId(char[] section, int x, int y, int z) {
if (section == null) {
return 0;
}
int j = MainUtil.CACHE_J[y][x][z];
return section[j] >> 4;
}
public int getId(char[][] sections, int x, int y, int z) {
if (x < 0 || x > 15 || z < 0 || z > 15) {
return 1;
}
if (y < 0 || y > 255) {
return 1;
}
int i = MainUtil.CACHE_I[y][x][z];
char[] section = sections[i];
if (section == null) {
return 0;
}
return getId(section, x, y, z);
}
public class CharLocalChunk_1_8_3 extends CharLocalChunk {
public short[] count;
public short[] air;
public short[] relight;
public CharLocalChunk_1_8_3(BasicLocalBlockQueue parent, int x, int z) {
super(parent, x, z);
this.count = new short[16];
this.air = new short[16];
this.relight = new short[16];
}
@Override public void setBlock(int x, int y, int z, int id, int data) {
int i = MainUtil.CACHE_I[y][x][z];
int j = MainUtil.CACHE_J[y][x][z];
char[] vs = this.blocks[i];
if (vs == null) {
vs = this.blocks[i] = new char[4096];
this.count[i]++;
} else if (vs[j] == 0) {
this.count[i]++;
}
switch (id) {
case 0:
this.air[i]++;
vs[j] = (char) 1;
return;
case 10:
case 11:
case 39:
case 40:
case 51:
case 74:
case 89:
case 122:
case 124:
case 138:
case 169:
this.relight[i]++;
case 2:
case 4:
case 13:
case 14:
case 15:
case 20:
case 21:
case 22:
case 30:
case 32:
case 37:
case 41:
case 42:
case 45:
case 46:
case 47:
case 48:
case 49:
case 55:
case 56:
case 57:
case 58:
case 60:
case 7:
case 8:
case 9:
case 73:
case 78:
case 79:
case 80:
case 81:
case 82:
case 83:
case 85:
case 87:
case 88:
case 101:
case 102:
case 103:
case 110:
case 112:
case 113:
case 121:
case 129:
case 133:
case 165:
case 166:
case 170:
case 172:
case 173:
case 174:
case 181:
case 182:
case 188:
case 189:
case 190:
case 191:
case 192:
vs[j] = (char) (id << 4);
return;
case 130:
case 76:
case 62:
this.relight[i]++;
case 54:
case 146:
case 61:
case 65:
case 68:
case 50:
if (data < 2) {
data = 2;
}
default:
vs[j] = (char) ((id << 4) + data);
return;
}
}
public char[] getIdArray(int i) {
return this.blocks[i];
}
public int getCount(int i) {
return this.count[i];
}
public int getAir(int i) {
return this.air[i];
}
public void setCount(int i, short value) {
this.count[i] = value;
}
public int getRelight(int i) {
return this.relight[i];
}
public int getTotalCount() {
int total = 0;
for (int i = 0; i < 16; i++) {
total += this.count[i];
}
return total;
}
public int getTotalRelight() {
if (getTotalCount() == 0) {
Arrays.fill(this.count, (short) 1);
Arrays.fill(this.relight, Short.MAX_VALUE);
return Short.MAX_VALUE;
}
int total = 0;
for (int i = 0; i < 16; i++) {
total += this.relight[i];
}
return total;
}
}
}

View File

@ -1,5 +1,6 @@
name: ${name} name: ${name}
main: com.github.intellectualsites.plotsquared.bukkit.BukkitMain main: com.github.intellectualsites.plotsquared.bukkit.BukkitMain
api-version: 1.13
version: ${version} version: ${version}
load: STARTUP load: STARTUP
description: > description: >

View File

@ -1,53 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.C;
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.BO3Handler;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
@CommandDeclaration(command = "bo3", aliases = {
"bo2"}, description = "Mark a plot as done", permission = "plots.bo3", category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE)
public class BO3 extends SubCommand {
public void noArgs(PlotPlayer player) {
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot bo3 export [category] [alias] [-r]");
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot bo3 import <file>");
}
@Override public boolean onCommand(PlotPlayer player, String[] args) {
Location loc = player.getLocation();
Plot plot = loc.getPlotAbs();
if (plot == null || !plot.hasOwner()) {
return !sendMessage(player, C.NOT_IN_PLOT);
}
if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_BO3)) {
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
return false;
}
if (args.length == 0) {
noArgs(player);
return false;
}
switch (args[0].toLowerCase()) {
case "output":
case "save":
case "export":
return BO3Handler.saveBO3(player, plot);
case "paste":
case "load":
case "import":
case "input":
// TODO NOT IMPLEMENTED YET
MainUtil.sendMessage(player, "NOT IMPLEMENTED YET!!!");
return false;
default:
noArgs(player);
return false;
}
}
}

View File

@ -65,27 +65,6 @@ public class Download extends SubCommand {
}); });
} }
}); });
} else if (args.length == 1 && StringMan
.isEqualIgnoreCaseToAny(args[0], "bo3", "bo2", "b03", "b02")) {
if (!Permissions.hasPermission(player, C.PERMISSION_DOWNLOAD_BO3)) {
C.NO_PERMISSION.send(player, C.PERMISSION_DOWNLOAD_BO3);
return false;
}
if (plot.getVolume() > 128d * 128d * 256) {
C.SCHEMATIC_TOO_LARGE.send(player);
return false;
}
plot.addRunning();
BO3Handler.upload(plot, null, null, new RunnableVal<URL>() {
@Override public void run(URL url) {
plot.removeRunning();
if (url == null) {
MainUtil.sendMessage(player, C.GENERATING_LINK_FAILED);
return;
}
MainUtil.sendMessage(player, url.toString());
}
});
} else if (args.length == 1 && StringMan } else if (args.length == 1 && StringMan
.isEqualIgnoreCaseToAny(args[0], "mcr", "world", "mca")) { .isEqualIgnoreCaseToAny(args[0], "mcr", "world", "mca")) {
if (!Permissions.hasPermission(player, C.PERMISSION_DOWNLOAD_WORLD)) { if (!Permissions.hasPermission(player, C.PERMISSION_DOWNLOAD_WORLD)) {

View File

@ -88,7 +88,6 @@ import java.util.Arrays;
new Trim(); new Trim();
new Done(); new Done();
new Continue(); new Continue();
new BO3();
new Middle(); new Middle();
new Grant(); new Grant();
// Set commands // Set commands

View File

@ -25,11 +25,10 @@ public class Music extends SubCommand {
if (item == null) { if (item == null) {
return true; return true;
} }
int id = item.id == 7 ? 0 : item.id; if (item.getPlotBlock().equalsAny(7, "bedrock")) {
if (id == 0) {
plot.removeFlag(Flags.MUSIC); plot.removeFlag(Flags.MUSIC);
} else { } else {
plot.setFlag(Flags.MUSIC, id); plot.setFlag(Flags.MUSIC, item.getPlotBlock().getRawId());
} }
return false; return false;
} }

View File

@ -77,7 +77,7 @@ public class Set extends SubCommand {
} }
} }
return false; return false;
} else if (!allowUnsafe && (block.id != 0 && !WorldUtil.IMP } else if (!allowUnsafe && (!block.isAir() && !WorldUtil.IMP
.isBlockSolid(block))) { .isBlockSolid(block))) {
MainUtil MainUtil
.sendMessage(player, C.NOT_ALLOWED_BLOCK, block.toString()); .sendMessage(player, C.NOT_ALLOWED_BLOCK, block.toString());
@ -86,7 +86,7 @@ public class Set extends SubCommand {
} }
if (!allowUnsafe) { if (!allowUnsafe) {
for (PlotBlock block : blocks) { for (PlotBlock block : blocks) {
if (block.id != 0 && !WorldUtil.IMP.isBlockSolid(block)) { if (!block.isAir() && !WorldUtil.IMP.isBlockSolid(block)) {
MainUtil.sendMessage(player, C.NOT_ALLOWED_BLOCK, MainUtil.sendMessage(player, C.NOT_ALLOWED_BLOCK,
block.toString()); block.toString());
return false; return false;

View File

@ -46,7 +46,7 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) { @Override public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea; ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
setWallFilling(dpw, plot.getId(), new PlotBlock[] {dpw.WALL_FILLING}); setWallFilling(dpw, plot.getId(), new PlotBlock[] {dpw.WALL_FILLING});
if (dpw.WALL_BLOCK.id != 0 || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) { if (!dpw.WALL_BLOCK.isAir() || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) {
setWall(dpw, plot.getId(), new PlotBlock[] {dpw.WALL_BLOCK}); setWall(dpw, plot.getId(), new PlotBlock[] {dpw.WALL_BLOCK});
} }
GlobalBlockQueue.IMP.addTask(whenDone); GlobalBlockQueue.IMP.addTask(whenDone);
@ -431,7 +431,7 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override public boolean finishPlotMerge(PlotArea plotArea, ArrayList<PlotId> plotIds) { @Override public boolean finishPlotMerge(PlotArea plotArea, ArrayList<PlotId> plotIds) {
PlotBlock block = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK; PlotBlock block = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK;
PlotBlock unclaim = ((ClassicPlotWorld) plotArea).WALL_BLOCK; PlotBlock unclaim = ((ClassicPlotWorld) plotArea).WALL_BLOCK;
if (block.id != 0 || !block.equals(unclaim)) { if (!block.isAir() || !block.equals(unclaim)) {
for (PlotId id : plotIds) { for (PlotId id : plotIds) {
setWall(plotArea, id, new PlotBlock[] {block}); setWall(plotArea, id, new PlotBlock[] {block});
} }
@ -443,7 +443,7 @@ public class ClassicPlotManager extends SquarePlotManager {
PlotBlock block = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK; PlotBlock block = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK;
PlotBlock unclaim = ((ClassicPlotWorld) plotArea).WALL_BLOCK; PlotBlock unclaim = ((ClassicPlotWorld) plotArea).WALL_BLOCK;
for (PlotId id : plotIds) { for (PlotId id : plotIds) {
if (block.id != 0 || !block.equals(unclaim)) { if (block.isAir() || !block.equals(unclaim)) {
setWall(plotArea, id, new PlotBlock[] {block}); setWall(plotArea, id, new PlotBlock[] {block});
} }
} }
@ -461,7 +461,7 @@ public class ClassicPlotManager extends SquarePlotManager {
@Override public boolean claimPlot(PlotArea plotArea, Plot plot) { @Override public boolean claimPlot(PlotArea plotArea, Plot plot) {
PlotBlock unclaim = ((ClassicPlotWorld) plotArea).WALL_BLOCK; PlotBlock unclaim = ((ClassicPlotWorld) plotArea).WALL_BLOCK;
PlotBlock claim = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK; PlotBlock claim = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK;
if (claim.id != 0 || !claim.equals(unclaim)) { if (!claim.isAir() || !claim.equals(unclaim)) {
setWall(plotArea, plot.getId(), new PlotBlock[] {claim}); setWall(plotArea, plot.getId(), new PlotBlock[] {claim});
} }
return true; return true;

View File

@ -12,8 +12,8 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
public int ROAD_HEIGHT = 64; public int ROAD_HEIGHT = 64;
public int PLOT_HEIGHT = 64; public int PLOT_HEIGHT = 64;
public int WALL_HEIGHT = 64; public int WALL_HEIGHT = 64;
public PlotBlock[] MAIN_BLOCK = new PlotBlock[] {PlotBlock.get((short) 1, (byte) 0)}; public PlotBlock[] MAIN_BLOCK = new PlotBlock[] {PlotBlock.get("stone")};
public PlotBlock[] TOP_BLOCK = new PlotBlock[] {PlotBlock.get((short) 2, (byte) 0)}; public PlotBlock[] TOP_BLOCK = new PlotBlock[] {PlotBlock.get("grass")};
public PlotBlock WALL_BLOCK = PlotBlock.get((short) 44, (byte) 0); public PlotBlock WALL_BLOCK = PlotBlock.get((short) 44, (byte) 0);
public PlotBlock CLAIMED_WALL_BLOCK = PlotBlock.get((short) 44, (byte) 1); public PlotBlock CLAIMED_WALL_BLOCK = PlotBlock.get((short) 44, (byte) 1);
public PlotBlock WALL_FILLING = PlotBlock.get((short) 1, (byte) 0); public PlotBlock WALL_FILLING = PlotBlock.get((short) 1, (byte) 0);
@ -45,12 +45,14 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
new ConfigurationNode("wall.block", this.WALL_BLOCK, "Top wall block", new ConfigurationNode("wall.block", this.WALL_BLOCK, "Top wall block",
Configuration.BLOCK), Configuration.BLOCK),
new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK, new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK,
"Wall block (claimed)", Configuration.BLOCK), "Wall block (claimed)",
Configuration.BLOCK),
new ConfigurationNode("road.width", this.ROAD_WIDTH, "Road width", new ConfigurationNode("road.width", this.ROAD_WIDTH, "Road width",
Configuration.INTEGER), Configuration.INTEGER),
new ConfigurationNode("road.height", this.ROAD_HEIGHT, "Road height", new ConfigurationNode("road.height", this.ROAD_HEIGHT, "Road height",
Configuration.INTEGER), Configuration.INTEGER),
new ConfigurationNode("road.block", this.ROAD_BLOCK, "Road block", Configuration.BLOCK), new ConfigurationNode("road.block", this.ROAD_BLOCK, "Road block",
Configuration.BLOCK),
new ConfigurationNode("wall.filling", this.WALL_FILLING, "Wall filling block", new ConfigurationNode("wall.filling", this.WALL_FILLING, "Wall filling block",
Configuration.BLOCK), Configuration.BLOCK),
new ConfigurationNode("wall.height", this.WALL_HEIGHT, "Wall height", new ConfigurationNode("wall.height", this.WALL_HEIGHT, "Wall height",

View File

@ -277,7 +277,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
} }
this.ROAD_SCHEMATIC_ENABLED = true; this.ROAD_SCHEMATIC_ENABLED = true;
// Do not populate road if using schematic population // Do not populate road if using schematic population
this.ROAD_BLOCK = PlotBlock.get(this.ROAD_BLOCK.id, (byte) 0); this.ROAD_BLOCK = PlotBlock.getEmptyData(this.ROAD_BLOCK); // PlotBlock.get(this.ROAD_BLOCK.id, (byte) 0);
short[] ids1 = schematic1.getIds(); short[] ids1 = schematic1.getIds();
byte[] datas1 = schematic1.getDatas(); byte[] datas1 = schematic1.getDatas();

View File

@ -6,10 +6,7 @@ import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.*;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis; import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
@ -100,7 +97,7 @@ public abstract class HybridUtils {
PlotBlock block = queue.getBlock(x, y, z); PlotBlock block = queue.getBlock(x, y, z);
boolean same = false; boolean same = false;
for (PlotBlock p : blocks) { for (PlotBlock p : blocks) {
if (block.id == p.id) { if (WorldUtil.IMP.isBlockSame(block, p)) {
same = true; same = true;
break; break;
} }
@ -333,7 +330,7 @@ public abstract class HybridUtils {
for (int y = sy; y <= pm.getWorldHeight(); y++) { for (int y = sy; y <= pm.getWorldHeight(); y++) {
if (y > ey) { if (y > ey) {
PlotBlock block = queue.getBlock(x, y, z); PlotBlock block = queue.getBlock(x, y, z);
if (block.id != 0) { if (!block.isAir()) {
ey = y; ey = y;
} }
} }

View File

@ -1,75 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.object;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import java.io.File;
public class BO3 {
private final ChunkLoc chunk;
private final String world;
private final StringBuilder blocks;
private final StringBuilder children;
private final String name;
public BO3(String name, String world, ChunkLoc loc) {
this.world = world;
this.name = name;
this.chunk = loc;
this.blocks = new StringBuilder();
this.children = new StringBuilder();
}
public void addChild(BO3 child) {
ChunkLoc childloc = child.getLoc();
this.children.append("Branch(").append(childloc.x - this.chunk.x).append(",0,")
.append(childloc.z - this.chunk.z).append(',').append(this.name).append('_')
.append(childloc.x).append('_').append(childloc.z).append(",NORTH,100)\n");
}
public ChunkLoc getLoc() {
return this.chunk;
}
public String getWorld() {
return this.world;
}
public String getName() {
return this.name;
}
public void addBlock(int x, int y, int z, PlotBlock block) {
if (block.data == 0) {
// Block(-3,1,-2,AIR)
this.blocks.append("Block(").append(x).append(',').append(y).append(',').append(z)
.append(',').append(block.id).append(")\n");
} else {
this.blocks.append("Block(").append(x).append(',').append(y).append(',').append(z)
.append(',').append(block.id).append(':').append(block.data).append(")\n");
}
}
public String getBlocks() {
return this.blocks.toString();
}
public String getChildren() {
return this.children.toString();
}
public File getFile() {
return MainUtil.getFile(PlotSquared.get().IMP.getDirectory(),
Settings.Paths.BO3 + File.separator + getWorld() + File.separator + getFilename());
}
public String getFilename() {
if (this.chunk.x == 0 && this.chunk.z == 0) {
return this.name + ".bo3";
} else {
return this.name + ("_" + this.chunk.x + '_' + this.chunk.z) + ".bo3";
}
}
}

View File

@ -2,9 +2,9 @@ package com.github.intellectualsites.plotsquared.plot.object;
public abstract class LazyBlock { public abstract class LazyBlock {
public abstract PlotBlock getPlotBlock(); public abstract StringPlotBlock getPlotBlock();
public int getId() { public String getId() {
return getPlotBlock().id; return getPlotBlock().getItemId();
} }
} }

View File

@ -0,0 +1,62 @@
package com.github.intellectualsites.plotsquared.plot.object;
import lombok.Getter;
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);
}
}
@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 boolean isAir() {
return this.id == 0;
}
@Override public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
LegacyPlotBlock other = (LegacyPlotBlock) obj;
return (this.id == other.id) && ((this.data == other.data) || (this.data == -1) || (
other.data == -1));
}
@Override public int hashCode() {
return this.id;
}
@Override public String toString() {
if (this.data == -1) {
return this.id + "";
}
return this.id + ":" + this.data;
}
}

View File

@ -1203,7 +1203,7 @@ public class Plot {
bot.getZ() + home.z, home.yaw, home.pitch); bot.getZ() + home.z, home.yaw, home.pitch);
if (!isLoaded()) if (!isLoaded())
return loc; return loc;
if (WorldUtil.IMP.getBlock(loc).id != 0) { if (!WorldUtil.IMP.getBlock(loc).isAir()) {
loc.setY(Math.max( loc.setY(Math.max(
1 + WorldUtil.IMP.getHighestBlock(this.getWorldName(), loc.getX(), loc.getZ()), 1 + WorldUtil.IMP.getHighestBlock(this.getWorldName(), loc.getX(), loc.getZ()),
bot.getY())); bot.getY()));
@ -1848,22 +1848,6 @@ public class Plot {
}); });
} }
/**
* Export the plot as a BO3 object<br>
* - bedrock, floor and main block are ignored in their respective sections
* - air is ignored
* - The center is considered to be on top of the plot in the center
*
* @param whenDone value will be false if exporting fails
*/
public void exportBO3(RunnableVal<Boolean> whenDone) {
boolean result = BO3Handler.saveBO3(this);
if (whenDone != null) {
whenDone.value = result;
}
TaskManager.runTask(whenDone);
}
/** /**
* Upload the plot as a schematic to the configured web interface. * Upload the plot as a schematic to the configured web interface.
* *
@ -1889,18 +1873,6 @@ public class Plot {
WorldUtil.IMP.upload(this, null, null, whenDone); WorldUtil.IMP.upload(this, null, null, whenDone);
} }
/**
* Upload this plot as a BO3<br>
* - May not work on non default generator<br>
* - BO3 includes flags/ignores plot main/floor block<br>
*
* @param whenDone
* @see BO3Handler
*/
public void uploadBO3(RunnableVal<URL> whenDone) {
BO3Handler.upload(this, null, null, whenDone);
}
@Override public boolean equals(Object obj) { @Override public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;

View File

@ -1,26 +1,26 @@
package com.github.intellectualsites.plotsquared.plot.object; package com.github.intellectualsites.plotsquared.plot.object;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import lombok.NonNull;
public class PlotBlock { import java.util.Collection;
public static final PlotBlock EVERYTHING = new PlotBlock((short) 0, (byte) 0); public abstract class PlotBlock {
private static final PlotBlock[] CACHE = new PlotBlock[65535];
static { public static boolean isEverything(@NonNull final PlotBlock block) {
for (int i = 0; i < 65535; i++) { return block.equals(LegacyPlotBlock.EVERYTHING) || block.equals(StringPlotBlock.EVERYTHING);
short id = (short) (i >> 4);
byte data = (byte) (i & 15);
CACHE[i] = new PlotBlock(id, data);
}
} }
public final short id; public static boolean containsEverything(@NonNull final Collection<PlotBlock> blocks) {
public final byte data; for (final PlotBlock block : blocks) {
if (isEverything(block)) {
return true;
}
}
return false;
}
public PlotBlock(short id, byte data) { protected PlotBlock() {
this.id = id;
this.data = data;
} }
public static PlotBlock get(char combinedId) { public static PlotBlock get(char combinedId) {
@ -34,35 +34,43 @@ public class PlotBlock {
} }
} }
public abstract boolean isAir();
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) { public static PlotBlock get(int id, int data) {
return Settings.Enabled_Components.BLOCK_CACHE && data > 0 ? return Settings.Enabled_Components.BLOCK_CACHE && data > 0 ?
CACHE[(id << 4) + data] : LegacyPlotBlock.CACHE[(id << 4) + data] :
new PlotBlock((short) id, (byte) data); new LegacyPlotBlock((short) id, (byte) data);
} }
@Override public boolean equals(Object obj) { public static PlotBlock getEmptyData(@NonNull final PlotBlock plotBlock) {
if (this == obj) { if (plotBlock instanceof StringPlotBlock) {
return true; return plotBlock;
} }
if (obj == null) { return get(((LegacyPlotBlock) plotBlock).getId(), (byte) 0);
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
PlotBlock other = (PlotBlock) obj;
return (this.id == other.id) && ((this.data == other.data) || (this.data == -1) || (
other.data == -1));
} }
@Override public int hashCode() { public final boolean equalsAny(final int id, @NonNull final String stringId) {
return this.id; if (this instanceof StringPlotBlock) {
final StringPlotBlock stringPlotBlock = (StringPlotBlock) this;
return stringPlotBlock.idEquals(stringId);
}
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) this;
return legacyPlotBlock.id == id;
} }
@Override public String toString() { @Override public abstract boolean equals(Object obj);
if (this.data == -1) {
return this.id + ""; @Override public abstract int hashCode();
}
return this.id + ":" + this.data; @Override public abstract String toString();
}
public abstract Object getRawId();
} }

View File

@ -2,10 +2,13 @@ package com.github.intellectualsites.plotsquared.plot.object;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison; import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import lombok.Getter;
public class PlotItemStack { public class PlotItemStack {
public final int id; // public final int id;
public final short data; // public final short data;
@Getter
private final PlotBlock plotBlock;
public final int amount; public final int amount;
public final String name; public final String name;
public final String[] lore; public final String[] lore;
@ -13,19 +16,16 @@ public class PlotItemStack {
@Deprecated @Deprecated
public PlotItemStack(final int id, final short data, final int amount, final String name, public PlotItemStack(final int id, final short data, final int amount, final String name,
final String... lore) { final String... lore) {
this.id = id;
this.data = data;
this.amount = amount; this.amount = amount;
this.name = name; this.name = name;
this.lore = lore; this.lore = lore;
this.plotBlock = PlotBlock.get(id, data);
} }
public PlotItemStack(final String id, final int amount, final String name, public PlotItemStack(final String id, final int amount, final String name,
final String... lore) { final String... lore) {
StringComparison<PlotBlock>.ComparisonResult match = WorldUtil.IMP.getClosestBlock(id); StringComparison<PlotBlock>.ComparisonResult match = WorldUtil.IMP.getClosestBlock(id);
final PlotBlock block = match.best; this.plotBlock = match.best;
this.id = block.id;
data = block.data;
this.amount = amount; this.amount = amount;
this.name = name; this.name = name;
this.lore = lore; this.lore = lore;

View File

@ -0,0 +1,91 @@
package com.github.intellectualsites.plotsquared.plot.object;
import lombok.Getter;
import lombok.NonNull;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class StringPlotBlock extends PlotBlock {
public static final PlotBlock EVERYTHING = new StringPlotBlock("");
private static final Map<String, StringPlotBlock> STRING_PLOT_BLOCK_CACHE = new HashMap<>();
public static StringPlotBlock getOrAdd(@NonNull final String itemId) {
// final String id = itemId.toLowerCase(Locale.ENGLISH);
StringPlotBlock plotBlock = STRING_PLOT_BLOCK_CACHE.get(itemId);
if (plotBlock == null) {
plotBlock = new StringPlotBlock(itemId);
STRING_PLOT_BLOCK_CACHE.put(itemId, plotBlock);
}
return plotBlock;
}
@Getter
private final String nameSpace;
@Getter
private final String itemId;
private boolean isForeign = false;
public StringPlotBlock(@NonNull final String nameSpace, @NonNull final String itemId) {
this.nameSpace = nameSpace.toLowerCase(Locale.ENGLISH);
this.itemId = itemId.toLowerCase(Locale.ENGLISH);
this.determineForeign();
}
public StringPlotBlock(@NonNull final String itemId) {
if (itemId.contains(":")) {
final String[] parts = itemId.split(":");
if (parts.length < 2) {
throw new IllegalArgumentException(String.format("Cannot parse \"%s\"", itemId));
}
this.nameSpace = parts[0].toLowerCase(Locale.ENGLISH);
this.itemId = parts[1].toLowerCase(Locale.ENGLISH);
} else {
this.nameSpace = "minecraft";
this.itemId = itemId.toLowerCase(Locale.ENGLISH);
}
this.determineForeign();
}
private void determineForeign() {
this.isForeign = !this.nameSpace.equals("minecraft");
}
@Override public String toString() {
return this.isForeign ? String.format("%s:%s", nameSpace, itemId) : itemId;
}
@Override public boolean isAir() {
return this.itemId.isEmpty() || this.itemId.equalsIgnoreCase("air");
}
@Override public int hashCode() {
return this.toString().hashCode();
}
public boolean idEquals(@NonNull final String id) {
return id.equalsIgnoreCase(this.itemId);
}
@Override public Object getRawId() {
return this.getItemId();
}
@Override public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
StringPlotBlock other = (StringPlotBlock) obj;
return other.nameSpace.equals(this.nameSpace) && other.itemId.equals(this.itemId);
}
}

View File

@ -1,297 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.util;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.generator.ClassicPlotWorld;
import com.github.intellectualsites.plotsquared.plot.object.*;
import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.util.*;
import java.util.Map.Entry;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class BO3Handler {
/**
* @param plot
* @return if successfully exported
* @see #saveBO3(PlotPlayer, Plot, RunnableVal)
*/
public static boolean saveBO3(Plot plot) {
return saveBO3(null, plot);
}
public static boolean saveBO3(PlotPlayer player, final Plot plot) {
return saveBO3(player, plot, new RunnableVal<BO3>() {
@Override public void run(BO3 bo3) {
save(plot, bo3);
}
});
}
public static boolean contains(PlotBlock[] blocks, PlotBlock block) {
for (PlotBlock item : blocks) {
if (item.equals(block)) {
return true;
}
}
return false;
}
/**
* Save a plot as a BO3 file.
* - Use null for the player object if no player is applicable
*
* @param player
* @param plot
* @return
*/
public static boolean saveBO3(PlotPlayer player, Plot plot, RunnableVal<BO3> saveTask) {
if (saveTask == null) {
throw new IllegalArgumentException("Save task cannot be null!");
}
PlotArea plotworld = plot.getArea();
if (!(plotworld instanceof ClassicPlotWorld) || plotworld.TYPE != 0) {
MainUtil.sendMessage(player, "BO3 exporting only supports type 0 classic generation.");
return false;
}
String alias = plot.toString();
Location[] corners = plot.getCorners();
Location bot = corners[0];
Location top = corners[1];
ClassicPlotWorld cpw = (ClassicPlotWorld) plotworld;
int height = cpw.PLOT_HEIGHT;
int cx = MathMan.average(bot.getX(), top.getX());
int cz = MathMan.average(bot.getZ(), top.getZ());
HashMap<ChunkLoc, BO3> map = new HashMap<>();
HashSet<RegionWrapper> regions = plot.getRegions();
ArrayList<ChunkLoc> chunks = new ArrayList<>();
for (RegionWrapper region : regions) {
for (int x = region.minX >> 4; x <= region.maxX >> 4; x++) {
for (int z = region.minZ >> 4; z <= region.maxZ >> 4; z++) {
chunks.add(new ChunkLoc(x, z));
}
}
}
for (ChunkLoc loc : chunks) {
ChunkManager.manager.loadChunk(plot.getWorldName(), loc, false);
}
boolean content = false;
for (RegionWrapper region : regions) {
Location pos1 =
new Location(plotworld.worldname, region.minX, region.minY, region.minZ);
Location pos2 =
new Location(plotworld.worldname, region.maxX, region.maxY, region.maxZ);
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
int X = x + 7 - cx >> 4;
int xx = (x - cx) % 16;
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
int Z = z + 7 - cz >> 4;
int zz = (z - cz) % 16;
ChunkLoc loc = new ChunkLoc(X, Z);
BO3 bo3 = map.get(loc);
for (int y = 1; y < height; y++) {
PlotBlock block =
WorldUtil.IMP.getBlock(new Location(plot.getWorldName(), x, y, z));
if (!contains(cpw.MAIN_BLOCK, block)) {
if (bo3 == null) {
bo3 = new BO3(alias, plotworld.worldname, loc);
map.put(loc, bo3);
content = true;
}
bo3.addBlock(xx, y - height - 1, zz, block);
}
}
PlotBlock floor =
WorldUtil.IMP.getBlock(new Location(plot.getWorldName(), x, height, z));
if (!contains(cpw.TOP_BLOCK, floor)) {
if (bo3 == null) {
bo3 = new BO3(alias, plotworld.worldname, loc);
map.put(loc, bo3);
content = true;
}
bo3.addBlock(xx, -1, zz, floor);
}
for (int y = height + 1; y < 256; y++) {
PlotBlock block =
WorldUtil.IMP.getBlock(new Location(plot.getWorldName(), x, y, z));
if (block.id != 0) {
if (bo3 == null) {
bo3 = new BO3(alias, plotworld.worldname, loc);
map.put(loc, bo3);
content = true;
}
bo3.addBlock(xx, y - height - 1, zz, block);
}
}
}
}
}
if (!content) {
MainUtil.sendMessage(player, "No content found!");
return false;
}
for (Entry<ChunkLoc, BO3> entry : map.entrySet()) {
ChunkLoc chunk = entry.getKey();
BO3 bo3 = entry.getValue();
if (chunk.x == 0 && chunk.z == 0) {
continue;
}
int x = chunk.x;
int z = chunk.z;
if (Math.abs(chunk.x) > Math.abs(chunk.z)) {
x += chunk.x > 0 ? -1 : 1;
} else {
z += chunk.z > 0 ? -1 : 1;
}
ChunkLoc parentLoc = new ChunkLoc(x, z);
if (!map.containsKey(parentLoc)) {
parentLoc = null;
for (Entry<ChunkLoc, BO3> entry2 : map.entrySet()) {
ChunkLoc other = entry2.getKey();
if (other.x == chunk.x - 1 && other.z == chunk.z
|| other.z == chunk.z - 1 && other.x == chunk.x) {
parentLoc = other;
}
}
if (parentLoc == null) {
MainUtil.sendMessage(player,
"Exporting BO3 cancelled due to detached chunk: " + chunk
+ " - Make sure you only have one object per plot");
return false;
}
}
map.get(parentLoc).addChild(bo3);
}
for (Entry<ChunkLoc, BO3> entry : map.entrySet()) {
saveTask.run(entry.getValue());
}
MainUtil.sendMessage(player, "BO3 exporting was successful!");
return true;
}
public static void upload(final Plot plot, UUID uuid, String file, RunnableVal<URL> whenDone) {
if (plot == null) {
throw new IllegalArgumentException("Arguments may not be null!");
}
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (final ZipOutputStream zos = new ZipOutputStream(baos)) {
saveBO3(null, plot, new RunnableVal<BO3>() {
@Override public void run(BO3 bo3) {
try {
ZipEntry ze = new ZipEntry(bo3.getFilename());
zos.putNextEntry(ze);
write(zos, plot, bo3);
zos.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
});
} catch (IOException e) {
e.printStackTrace();
whenDone.run();
return;
}
MainUtil.upload(uuid, file, "zip", new RunnableVal<OutputStream>() {
@Override public void run(OutputStream output) {
try {
output.write(baos.toByteArray());
baos.flush();
baos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}, whenDone);
}
public static void write(OutputStream stream, Plot plot, BO3 bo3) throws IOException {
File base = getBaseFile(bo3.getWorld());
List<String> lines = Files.readAllLines(base.toPath(), StandardCharsets.UTF_8);
for (int i = 0; i < lines.size(); i++) {
String line = lines.get(i).trim();
String result = StringMan
.replaceAll(line, "%owner%", MainUtil.getName(plot.owner), "%alias%",
plot.toString(), "%blocks%", bo3.getBlocks(), "%branches%", bo3.getChildren(),
"%flags%", StringMan.join(FlagManager.getPlotFlags(plot).values(), ","));
if (!StringMan.isEqual(result, line)) {
lines.set(i, result);
}
}
stream.write(StringMan.join(lines, System.getProperty("line.separator")).getBytes());
}
public static boolean save(Plot plot, BO3 bo3) {
try {
File bo3File = bo3.getFile();
File parent = bo3File.getParentFile();
if (parent != null) {
parent.mkdirs();
}
bo3File.createNewFile();
bo3File.getParentFile().mkdirs();
try (FileOutputStream fos = new FileOutputStream(bo3File)) {
write(fos, plot, bo3);
}
} catch (IOException e) {
e.printStackTrace();
return false;
}
File base = getBaseFile(plot.getWorldName());
try {
List<String> lines = Files.readAllLines(base.toPath(), StandardCharsets.UTF_8);
for (int i = 0; i < lines.size(); i++) {
String line = lines.get(i).trim();
String result = StringMan
.replaceAll(line, "%owner%", MainUtil.getName(plot.owner), "%alias%",
plot.toString(), "%blocks%", bo3.getBlocks(), "%branches%",
bo3.getChildren(), "%flags%",
StringMan.join(FlagManager.getPlotFlags(plot).values(), ","));
if (!StringMan.isEqual(result, line)) {
lines.set(i, result);
}
}
File bo3File;
if (bo3.getLoc().x == 0 && bo3.getLoc().z == 0) {
bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + ".bo3");
} else {
bo3File = MainUtil.getFile(base.getParentFile(),
bo3.getName() + '_' + bo3.getLoc().x + '_' + bo3.getLoc().z + ".bo3");
}
bo3File.createNewFile();
Files.write(bo3File.toPath(),
StringMan.join(lines, System.getProperty("line.separator")).getBytes(),
StandardOpenOption.WRITE);
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
public static File getBaseFile(String category) {
File base = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(),
Settings.Paths.BO3 + File.separator + category + File.separator + "base.yml");
if (!base.exists()) {
PlotSquared.get().copyFile("base.yml", Settings.Paths.BO3 + File.separator + category);
}
return base;
}
}

View File

@ -134,16 +134,14 @@ public abstract class EventUtil {
Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE); Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE);
if (use.isPresent()) { if (use.isPresent()) {
HashSet<PlotBlock> value = use.get(); HashSet<PlotBlock> value = use.get();
if (value.contains(PlotBlock.EVERYTHING) || value if (PlotBlock.containsEverything(value) || value.contains(block.getPlotBlock())) {
.contains(block.getPlotBlock())) {
return true; return true;
} }
} }
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK); Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
if (destroy.isPresent()) { if (destroy.isPresent()) {
HashSet<PlotBlock> value = destroy.get(); HashSet<PlotBlock> value = destroy.get();
if (value.contains(PlotBlock.EVERYTHING) || value if (PlotBlock.containsEverything(value) || value.contains(block.getPlotBlock())) {
.contains(block.getPlotBlock())) {
return true; return true;
} }
} }
@ -220,7 +218,7 @@ public abstract class EventUtil {
} else { } else {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value if (value == null || !PlotBlock.containsEverything(value) && !value
.contains(block.getPlotBlock())) { .contains(block.getPlotBlock())) {
return Permissions return Permissions
.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false) || !( .hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false) || !(
@ -245,7 +243,7 @@ public abstract class EventUtil {
} else { } else {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value if (value == null || !PlotBlock.containsEverything(value) && !value
.contains(block.getPlotBlock())) { .contains(block.getPlotBlock())) {
if (Permissions if (Permissions
.hasPermission(player, C.PERMISSION_ADMIN_BUILD_OTHER.s(), false)) { .hasPermission(player, C.PERMISSION_ADMIN_BUILD_OTHER.s(), false)) {
@ -275,7 +273,7 @@ public abstract class EventUtil {
} else { } else {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value if (value == null || !PlotBlock.containsEverything(value) && !value
.contains(block.getPlotBlock())) { .contains(block.getPlotBlock())) {
if (Permissions if (Permissions
.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) { .hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
@ -305,7 +303,7 @@ public abstract class EventUtil {
} else { } else {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value if (value == null || !PlotBlock.containsEverything(value) && !value
.contains(block.getPlotBlock())) { .contains(block.getPlotBlock())) {
if (Permissions if (Permissions
.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) { .hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
@ -336,7 +334,7 @@ public abstract class EventUtil {
} else { } else {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value if (value == null || !PlotBlock.containsEverything(value) && !value
.contains(block.getPlotBlock())) { .contains(block.getPlotBlock())) {
if (Permissions if (Permissions
.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) { .hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
@ -367,7 +365,7 @@ public abstract class EventUtil {
} else { } else {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value if (value == null || !PlotBlock.containsEverything(value) && !value
.contains(block.getPlotBlock())) { .contains(block.getPlotBlock())) {
if (Permissions if (Permissions
.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) { .hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
@ -398,7 +396,7 @@ public abstract class EventUtil {
} else { } else {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value if (value == null || !PlotBlock.containsEverything(value) && !value
.contains(block.getPlotBlock())) { .contains(block.getPlotBlock())) {
if (Permissions if (Permissions
.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) { .hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
@ -431,7 +429,7 @@ public abstract class EventUtil {
} else { } else {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value if (value == null || !PlotBlock.containsEverything(value) && !value
.contains(block.getPlotBlock())) { .contains(block.getPlotBlock())) {
if (Permissions if (Permissions
.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) { .hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
@ -463,7 +461,7 @@ public abstract class EventUtil {
} else { } else {
value = null; value = null;
} }
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value if (value == null || !PlotBlock.containsEverything(value) && !value
.contains(block.getPlotBlock())) { .contains(block.getPlotBlock())) {
if (Permissions if (Permissions
.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) { .hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {

View File

@ -142,4 +142,6 @@ public abstract class WorldUtil {
} }
return null; return null;
} }
public abstract boolean isBlockSame(PlotBlock block1, PlotBlock block2);
} }

View File

@ -5,6 +5,7 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import lombok.NonNull;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ConcurrentLinkedDeque;
@ -84,6 +85,33 @@ public abstract class BasicLocalBlockQueue<T> extends LocalBlockQueue {
this.modified = modified; this.modified = modified;
} }
@Override public boolean setBlock(int x, int y, int z, String id) {
if ((y > 255) || (y < 0)) {
return false;
}
int cx = x >> 4;
int cz = z >> 4;
if (cx != lastX || cz != lastZ) {
lastX = cx;
lastZ = cz;
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL;
lastWrappedChunk = this.blocks.get(pair);
if (lastWrappedChunk == null) {
lastWrappedChunk = this.getLocalChunk(x >> 4, z >> 4);
lastWrappedChunk.setBlock(x & 15, y, z & 15, id);
LocalChunk previous = this.blocks.put(pair, lastWrappedChunk);
if (previous == null) {
chunks.add(lastWrappedChunk);
return true;
}
this.blocks.put(pair, previous);
lastWrappedChunk = previous;
}
}
lastWrappedChunk.setBlock(x & 15, y, z & 15, id);
return true;
}
@Override public final boolean setBlock(int x, int y, int z, int id, int data) { @Override public final boolean setBlock(int x, int y, int z, int id, int data) {
if ((y > 255) || (y < 0)) { if ((y > 255) || (y < 0)) {
return false; return false;
@ -211,6 +239,18 @@ public abstract class BasicLocalBlockQueue<T> extends LocalBlockQueue {
} }
} }
public void fillCuboid(int x1, int x2, int y1, int y2, int z1, int z2, String id) {
for (int x = x1; x <= x2; x++) {
for (int y = y1; y <= y2; y++) {
for (int z = z1; z <= z2; z++) {
setBlock(x, y, z, id);
}
}
}
}
public abstract void setBlock(final int x, final int y, final int z, final String id);
public abstract void setBlock(final int x, final int y, final int z, final int id, public abstract void setBlock(final int x, final int y, final int z, final int id,
final int data); final int data);
@ -241,20 +281,28 @@ public abstract class BasicLocalBlockQueue<T> extends LocalBlockQueue {
blocks = new PlotBlock[16][]; blocks = new PlotBlock[16][];
} }
public void setBlock(final int x, final int y, final int z, final int id, final int data) { @Override public void setBlock(final int x, final int y, final int z, @NonNull final String id) {
PlotBlock block = PlotBlock.get(id, data); final PlotBlock block = PlotBlock.get(id);
int i = MainUtil.CACHE_I[y][x][z]; this.setInternal(x, y, z, block);
int j = MainUtil.CACHE_J[y][x][z]; }
private void setInternal(final int x, final int y, final int z, final PlotBlock plotBlock) {
final int i = MainUtil.CACHE_I[y][x][z];
final int j = MainUtil.CACHE_J[y][x][z];
PlotBlock[] array = blocks[i]; PlotBlock[] array = blocks[i];
if (array == null) { if (array == null) {
array = (blocks[i] = new PlotBlock[4096]); array = (blocks[i] = new PlotBlock[4096]);
} }
array[j] = block; array[j] = plotBlock;
}
public void setBlock(final int x, final int y, final int z, final int id, final int data) {
final PlotBlock block = PlotBlock.get(id, data);
this.setInternal(x, y, z, block);
} }
} }
/* public class CharLocalChunk extends LocalChunk<char[]> {
public class CharLocalChunk extends LocalChunk<char[]> {
public CharLocalChunk(BasicLocalBlockQueue parent, int x, int z) { public CharLocalChunk(BasicLocalBlockQueue parent, int x, int z) {
super(parent, x, z); super(parent, x, z);
@ -271,5 +319,5 @@ public abstract class BasicLocalBlockQueue<T> extends LocalBlockQueue {
} }
array[j] = (char) ((block.id << 4) + block.data); array[j] = (char) ((block.id << 4) + block.data);
} }
} } */
} }

View File

@ -57,6 +57,10 @@ public class DelegateLocalBlockQueue extends LocalBlockQueue {
} }
} }
@Override public boolean setBlock(int x, int y, int z, String id) {
return parent.setBlock(x, y, z, id);
}
@Override public boolean setBlock(int x, int y, int z, int id, int data) { @Override public boolean setBlock(int x, int y, int z, int id, int data) {
return parent.setBlock(x, y, z, id, data); return parent.setBlock(x, y, z, id, data);
} }

View File

@ -6,6 +6,7 @@ import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import lombok.NonNull;
import java.util.Map; import java.util.Map;
@ -43,8 +44,16 @@ public abstract class LocalBlockQueue {
return setBlock(x, y, z, id, 0); return setBlock(x, y, z, id, 0);
} }
public final boolean setBlock(int x, int y, int z, PlotBlock block) { public abstract boolean setBlock(final int x, final int y, final int z, final String id);
return setBlock(x, y, z, block.id, block.data);
public final boolean setBlock(int x, int y, int z, @NonNull final PlotBlock block) {
if (block instanceof LegacyPlotBlock) {
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) block;
return this.setBlock(x, y, z, legacyPlotBlock.id, legacyPlotBlock.data);
} else {
final StringPlotBlock stringPlotBlock = (StringPlotBlock) block;
return this.setBlock(x, y, z, stringPlotBlock.getItemId());
}
} }
public boolean setTile(int x, int y, int z, CompoundTag tag) { public boolean setTile(int x, int y, int z, CompoundTag tag) {

View File

@ -44,6 +44,11 @@ public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue {
} }
} }
@Override public boolean setBlock(int x, int y, int z, String id) {
return x >= 0 && x <= dx && y >= 0 && y <= dy && z >= 0 && z <= dz &&
super.setBlock(x + minX, y + minY, z + minZ, id);
}
@Override public boolean setBlock(int x, int y, int z, int id, int data) { @Override public boolean setBlock(int x, int y, int z, int id, int data) {
return x >= 0 && x <= dx && y >= 0 && y <= dy && z >= 0 && z <= dz && super return x >= 0 && x <= dx && y >= 0 && y <= dy && z >= 0 && z <= dz && super
.setBlock(x + minX, y + minY, z + minZ, id, data); .setBlock(x + minX, y + minY, z + minZ, id, data);

View File

@ -70,7 +70,6 @@ subprojects {
} }
repositories { repositories {
mavenCentral() mavenCentral()
maven { url "http://empcraft.com/maven2" }
maven { url "http://maven.sk89q.com/repo/" } maven { url "http://maven.sk89q.com/repo/" }
maven { url "http://repo.maven.apache.org/maven2" } maven { url "http://repo.maven.apache.org/maven2" }
} }