12
1

Refactoring 1.14 support to vanilla WorldEdit compatibility

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2019-12-27 11:06:09 +01:00
Ursprung 692cd609bc
Commit 27808e35e0
2 geänderte Dateien mit 30 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -33,6 +33,12 @@
<version>1.14</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.15</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_API</artifactId>
@ -40,9 +46,8 @@
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FAWE</artifactId>
<version>1.14</version>
<scope>provided</scope>
<artifactId>FightSystem_12</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -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<BaseBlock> WOOL_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_wool")));
private static final Set<BaseBlock> CLAY_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_terracotta")));
private static final Set<BaseBlock> GLASS_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_stained_glass")));
private static final Set<BaseBlock> GLASS_PANE_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_stained_glass_pane")));
private static final Set<BaseBlock> CONCRETE_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_concrete")));
private static final Set<BaseBlock> CONCRETE_POWDER_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_concrete_powder")));
private static final Set<BaseBlock> WOOL_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock());
private static final Set<BaseBlock> CLAY_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock());
private static final Set<BaseBlock> GLASS_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock());
private static final Set<BaseBlock> GLASS_PANE_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock());
private static final Set<BaseBlock> CONCRETE_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock());
private static final Set<BaseBlock> 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;
}
}