mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Various:
- Empty StringPlotBlocks are air - Update signs to 1.13 - Fix getting material in BukktiLocalQueue#setMaterial
This commit is contained in:
parent
442473368d
commit
1543ac50cd
3 changed files with 32 additions and 22 deletions
|
@ -12,10 +12,10 @@ import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.*;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.block.data.Rotatable;
|
||||||
|
import org.bukkit.block.data.type.WallSign;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
@ -275,18 +275,17 @@ import java.util.*;
|
||||||
// block.setType(Material.AIR);
|
// block.setType(Material.AIR);
|
||||||
final Material type = block.getType();
|
final Material type = block.getType();
|
||||||
if (type != Material.SIGN && type != Material.WALL_SIGN) {
|
if (type != Material.SIGN && type != Material.WALL_SIGN) {
|
||||||
int data = 2;
|
BlockFace facing = BlockFace.EAST;
|
||||||
if (world.getBlockAt(x, y, z + 1).getType().isSolid())
|
if (world.getBlockAt(x, y, z + 1).getType().isSolid())
|
||||||
data = 2;
|
facing = BlockFace.NORTH;
|
||||||
else if (world.getBlockAt(x + 1, y, z).getType().isSolid())
|
else if (world.getBlockAt(x + 1, y, z).getType().isSolid())
|
||||||
data = 4;
|
facing = BlockFace.WEST;
|
||||||
else if (world.getBlockAt(x, y, z - 1).getType().isSolid())
|
else if (world.getBlockAt(x, y, z - 1).getType().isSolid())
|
||||||
data = 3;
|
facing = BlockFace.SOUTH;
|
||||||
else if (world.getBlockAt(x - 1, y, z).getType().isSolid())
|
|
||||||
data = 5;
|
|
||||||
block.setType(Material.WALL_SIGN, false);
|
block.setType(Material.WALL_SIGN, false);
|
||||||
final Sign sign = (Sign) block.getBlockData();
|
final WallSign sign = (WallSign) block.getBlockData();
|
||||||
sign.setRawData((byte) data);
|
sign.setFacing(facing);
|
||||||
|
block.setBlockData(sign, false);
|
||||||
}
|
}
|
||||||
final BlockState blockstate = block.getState();
|
final BlockState blockstate = block.getState();
|
||||||
if (blockstate instanceof Sign) {
|
if (blockstate instanceof Sign) {
|
||||||
|
@ -403,7 +402,7 @@ import java.util.*;
|
||||||
try {
|
try {
|
||||||
final Material material = getMaterial(block);
|
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<?> data = material.data;
|
||||||
if (data.equals(MaterialData.class) && !material.isTransparent() && material
|
if (data.equals(MaterialData.class) && !material.isTransparent() && material
|
||||||
.isOccluding() || data.equals(Tree.class) || data.equals(Sandstone.class)
|
.isOccluding() || data.equals(Tree.class) || data.equals(Sandstone.class)
|
||||||
|| data.equals(Wool.class) || data.equals(Step.class) || data
|
|| data.equals(Wool.class) || data.equals(Step.class) || data
|
||||||
|
@ -419,6 +418,7 @@ import java.util.*;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
|
ignored.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,21 +113,27 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMaterial(@NonNull final PlotBlock plotBlock, @NonNull final Block block) {
|
private void setMaterial(@NonNull final PlotBlock plotBlock, @NonNull final Block block) {
|
||||||
|
final Material material;
|
||||||
if (plotBlock instanceof StringPlotBlock) {
|
if (plotBlock instanceof StringPlotBlock) {
|
||||||
final Material material = Material
|
material = Material
|
||||||
.getMaterial(((StringPlotBlock) plotBlock).getItemId().toLowerCase(Locale.ENGLISH));
|
.getMaterial(((StringPlotBlock) plotBlock).getItemId().toUpperCase(Locale.ENGLISH));
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(String
|
||||||
String.format("Could not find material that matches %s", block.toString()));
|
.format("Could not find material that matches %s",
|
||||||
|
((StringPlotBlock) plotBlock).getItemId()));
|
||||||
}
|
}
|
||||||
block.setType(material, false);
|
|
||||||
} else {
|
} else {
|
||||||
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock;
|
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock;
|
||||||
block.setType(Material.getMaterial(PlotSquared.get().IMP.getLegacyMappings()
|
material = PlotSquared.get().IMP.getLegacyMappings()
|
||||||
.fromLegacyToString(legacyPlotBlock.getId(), legacyPlotBlock.getData())
|
.fromLegacyToString(legacyPlotBlock.getId()).to(Material.class);
|
||||||
.toString()));
|
if (material == null) {
|
||||||
// block.setTypeIdAndData(legacyPlotBlock.getId(), legacyPlotBlock.getData(), false);
|
throw new IllegalStateException(String
|
||||||
|
.format("Could not find material that matches %s",
|
||||||
|
PlotSquared.get().IMP.getLegacyMappings()
|
||||||
|
.fromLegacyToString(legacyPlotBlock.getId())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
block.setType(material, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean equals(@NonNull final PlotBlock plotBlock, @NonNull final Block block) {
|
private boolean equals(@NonNull final PlotBlock plotBlock, @NonNull final Block block) {
|
||||||
|
|
|
@ -34,7 +34,11 @@ public class StringPlotBlock extends PlotBlock {
|
||||||
this.itemId = parts[1].toLowerCase(Locale.ENGLISH);
|
this.itemId = parts[1].toLowerCase(Locale.ENGLISH);
|
||||||
} else {
|
} else {
|
||||||
this.nameSpace = "minecraft";
|
this.nameSpace = "minecraft";
|
||||||
this.itemId = itemId.toLowerCase(Locale.ENGLISH);
|
if (itemId.isEmpty()) {
|
||||||
|
this.itemId = "air";
|
||||||
|
} else {
|
||||||
|
this.itemId = itemId.toLowerCase(Locale.ENGLISH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.determineForeign();
|
this.determineForeign();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue