From 27808e35e0bcace964907e0cd7986eef578f4cef Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 27 Dec 2019 11:06:09 +0100 Subject: [PATCH] Refactoring 1.14 support to vanilla WorldEdit compatibility Signed-off-by: Lixfel --- FightSystem_14/pom.xml | 11 ++++-- .../fightsystem/fight/FightTeam_14.java | 39 +++++++++++-------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/FightSystem_14/pom.xml b/FightSystem_14/pom.xml index f6d65f0..d29cb36 100644 --- a/FightSystem_14/pom.xml +++ b/FightSystem_14/pom.xml @@ -33,6 +33,12 @@ 1.14 provided + + steamwar + WorldEdit + 1.15 + provided + steamwar FightSystem_API @@ -40,9 +46,8 @@ steamwar - FAWE - 1.14 - provided + FightSystem_12 + 1.0 \ No newline at end of file diff --git a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java b/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java index d5c18ee..a5eef37 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java +++ b/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java @@ -1,6 +1,7 @@ package de.steamwar.fightsystem.fight; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -11,7 +12,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockTypes; import de.steamwar.fightsystem.Config; import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.Schematic; @@ -22,33 +23,37 @@ import org.bukkit.scoreboard.Team; import java.io.IOException; import java.util.Collections; +import java.util.Objects; import java.util.Set; class FightTeam_14 { private FightTeam_14(){} - private static final Set WOOL_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_wool"))); - private static final Set CLAY_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_terracotta"))); - private static final Set GLASS_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_stained_glass"))); - private static final Set GLASS_PANE_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_stained_glass_pane"))); - private static final Set CONCRETE_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_concrete"))); - private static final Set CONCRETE_POWDER_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_concrete_powder"))); + private static final Set WOOL_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock()); + private static final Set CLAY_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock()); + private static final Set GLASS_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock()); + private static final Set GLASS_PANE_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock()); + private static final Set CONCRETE_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock()); + private static final Set CONCRETE_POWDER_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock()); static void setTeamColor(Team team, ChatColor color){ - team.setColor(color); - team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); + FightTeam_10.setTeamColor(team, color); } static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ BlockVector3 corner3 = BlockVector3.at(cornerX, cornerY, cornerZ); BlockVector3 schemsize3 = BlockVector3.at(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ); CuboidRegion region = new CuboidRegion(corner3, corner3.add(schemsize3)); - e.replaceBlocks(region, WOOL_SET, new BaseBlock(BlockState.get(c.name().toLowerCase() + "_wool"))); - e.replaceBlocks(region, CLAY_SET, new BaseBlock(BlockState.get(c.name().toLowerCase() + "_terracotta"))); - e.replaceBlocks(region, GLASS_SET, new BaseBlock(BlockState.get(c.name().toLowerCase() + "_stained_glass"))); - e.replaceBlocks(region, GLASS_PANE_SET, new BaseBlock(BlockState.get(c.name().toLowerCase() + "_stained_glass_pane"))); - e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(BlockState.get(c.name().toLowerCase() + "_concrete"))); - e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(BlockState.get(c.name().toLowerCase() + "_concrete_powder"))); + try { + e.replaceBlocks(region, WOOL_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock()); + e.replaceBlocks(region, CLAY_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_terracotta")).getDefaultState().toBaseBlock()); + e.replaceBlocks(region, GLASS_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_stained_glass")).getDefaultState().toBaseBlock()); + e.replaceBlocks(region, GLASS_PANE_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_stained_glass_pane")).getDefaultState().toBaseBlock()); + e.replaceBlocks(region, CONCRETE_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_concrete")).getDefaultState().toBaseBlock()); + e.replaceBlocks(region, CONCRETE_POWDER_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_concrete_powder")).getDefaultState().toBaseBlock()); + } catch (MaxChangedBlocksException ex) { + //ignored + } } static EditSession pasteSchematic(Schematic schematic, int pX, int pY, int pZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException { @@ -70,7 +75,7 @@ class FightTeam_14 { if(Config.AlignWater){ BlockVector3 it = clipboard.getMinimumPoint(); int depth = 0; - while(!clipboard.getBlock(it).getMaterial().isAir()){ + while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){ depth++; it = it.add(0, 1, 0); } @@ -81,7 +86,7 @@ class FightTeam_14 { ClipboardHolder ch = new ClipboardHolder(clipboard); ch.setTransform(aT); Operations.completeBlindly(ch.createPaste(e).to(v).build()); - e.flushQueue(); + e.flushSession(); return e; } }