Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
54b34bbfae
Commit
d0dab38d55
@ -178,12 +178,11 @@ public final class ScriptExecutor {
|
|||||||
|
|
||||||
Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command);
|
Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command);
|
||||||
if (!strings[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + strings[0])) {
|
if (!strings[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + strings[0])) {
|
||||||
EditSession editSession = WorldEditUtils.getEditSession(player.getWorld());
|
EditSession editSession = WorldEditUtils.getEditSession(player);
|
||||||
WorldEditUtils.addToPlayer(player, editSession);
|
|
||||||
Actor actor = BukkitAdapter.adapt(player);
|
Actor actor = BukkitAdapter.adapt(player);
|
||||||
WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().handleCommandOnCurrentThread(new CommandEvent(actor, command, editSession));
|
WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().handleCommandOnCurrentThread(new CommandEvent(actor, command, editSession));
|
||||||
editSession.close();
|
editSession.flushSession();
|
||||||
WorldEdit.getInstance().flushBlockBag(actor, editSession);
|
WorldEditUtils.addToPlayer(player, editSession);
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getServer().dispatchCommand(player, command);
|
Bukkit.getServer().dispatchCommand(player, command);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ class MenuCommand implements CustomCommand, MenuScript {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(CustomScript.MenuCommand menuCommand) {
|
public boolean equals(MenuCommand menuCommand) {
|
||||||
if (menuCommand.args.length != args.length) {
|
if (menuCommand.args.length != args.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class Laufbau {
|
|||||||
|
|
||||||
filteringTracesState = new FilteringTracesState(world, this::inRegion);
|
filteringTracesState = new FilteringTracesState(world, this::inRegion);
|
||||||
|
|
||||||
editSession = WorldEditUtils.getEditSession(world);
|
editSession = WorldEditUtils.getEditSession(player);
|
||||||
|
|
||||||
elements = BlockBoundingBox.elements.stream().filter(blockBoundingBox -> {
|
elements = BlockBoundingBox.elements.stream().filter(blockBoundingBox -> {
|
||||||
return !LaufbauUtils.isDeactivated(player, blockBoundingBox);
|
return !LaufbauUtils.isDeactivated(player, blockBoundingBox);
|
||||||
|
@ -54,7 +54,7 @@ public class LaufbauCommand extends SWCommand {
|
|||||||
while (true) {
|
while (true) {
|
||||||
if (!laufbau.hasNext()) {
|
if (!laufbau.hasNext()) {
|
||||||
BauSystem.MESSAGE.send("LAUFBAU_DONE", player);
|
BauSystem.MESSAGE.send("LAUFBAU_DONE", player);
|
||||||
laufbau.getEditSession().close();
|
laufbau.getEditSession().flushSession();
|
||||||
WorldEditUtils.addToPlayer(player, laufbau.getEditSession());
|
WorldEditUtils.addToPlayer(player, laufbau.getEditSession());
|
||||||
cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
|
@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.slaves.panzern;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import de.steamwar.bausystem.linkage.LinkageUtils;
|
import de.steamwar.bausystem.linkage.LinkageUtils;
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||||
@ -32,6 +33,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -50,12 +52,11 @@ public class Panzern {
|
|||||||
|
|
||||||
private Set<Location> current = new LinkedHashSet<>();
|
private Set<Location> current = new LinkedHashSet<>();
|
||||||
private Set<Vector> emptyBlocks = new HashSet<>();
|
private Set<Vector> emptyBlocks = new HashSet<>();
|
||||||
|
private Set<Vector> doneBlocks = new HashSet<>();
|
||||||
|
|
||||||
private World world;
|
private World world;
|
||||||
private Location pos1;
|
private Location pos1;
|
||||||
private Location pos2;
|
private Location pos2;
|
||||||
private Material blockMaterial;
|
|
||||||
private Material slabMaterial;
|
|
||||||
|
|
||||||
private BaseBlock blockType;
|
private BaseBlock blockType;
|
||||||
private BaseBlock slabType;
|
private BaseBlock slabType;
|
||||||
@ -66,7 +67,7 @@ public class Panzern {
|
|||||||
@Getter
|
@Getter
|
||||||
private EditSession editSession;
|
private EditSession editSession;
|
||||||
|
|
||||||
public Panzern(Location pos1, Location pos2, Location possibleSource, Material blockMaterial, Material slabMaterial) {
|
public Panzern(Player player, Location pos1, Location pos2, Location possibleSource, Material blockMaterial, Material slabMaterial) {
|
||||||
this.world = pos1.getWorld();
|
this.world = pos1.getWorld();
|
||||||
this.pos1 = new Location(world, Math.min(pos1.getBlockX(), pos2.getBlockX()), Math.min(pos1.getBlockY(), pos2.getBlockY()), Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
this.pos1 = new Location(world, Math.min(pos1.getBlockX(), pos2.getBlockX()), Math.min(pos1.getBlockY(), pos2.getBlockY()), Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||||
this.pos2 = new Location(world, Math.max(pos1.getBlockX(), pos2.getBlockX()), Math.max(pos1.getBlockY(), pos2.getBlockY()), Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
this.pos2 = new Location(world, Math.max(pos1.getBlockX(), pos2.getBlockX()), Math.max(pos1.getBlockY(), pos2.getBlockY()), Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||||
@ -76,13 +77,11 @@ public class Panzern {
|
|||||||
current.add(this.pos1);
|
current.add(this.pos1);
|
||||||
current.add(this.pos2);
|
current.add(this.pos2);
|
||||||
}
|
}
|
||||||
this.blockMaterial = blockMaterial;
|
|
||||||
this.slabMaterial = slabMaterial;
|
|
||||||
|
|
||||||
blockType = BlockTypes.get("minecraft:" + blockMaterial.name().toLowerCase()).getDefaultState().toBaseBlock();
|
blockType = BlockTypes.get("minecraft:" + blockMaterial.name().toLowerCase()).getDefaultState().toBaseBlock();
|
||||||
slabType = BlockTypes.get("minecraft:" + slabMaterial.name().toLowerCase()).getDefaultState().toBaseBlock();
|
slabType = BlockTypes.get("minecraft:" + slabMaterial.name().toLowerCase()).getDefaultState().toBaseBlock();
|
||||||
|
|
||||||
editSession = WorldEditUtils.getEditSession(world);
|
editSession = WorldEditUtils.getEditSession(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
@ -140,9 +139,15 @@ public class Panzern {
|
|||||||
emptyBlocks.add(currentBlock.getLocation().toVector());
|
emptyBlocks.add(currentBlock.getLocation().toVector());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
doneBlocks.add(currentBlock.getLocation().toVector());
|
||||||
|
|
||||||
adjacent.forEach((blockFace, temp) -> {
|
adjacent.forEach((blockFace, temp) -> {
|
||||||
if (temp.getType().isAir() && !emptyBlocks.contains(temp.getLocation().toVector())) {
|
if (doneBlocks.contains(temp.getLocation().toVector())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BlockState blockState = editSession.getBlock(BukkitAdapter.asBlockVector(temp.getLocation()));
|
||||||
|
boolean isAir = blockState.getBlockType() == BlockTypes.AIR;
|
||||||
|
if (isAir && !emptyBlocks.contains(temp.getLocation().toVector())) {
|
||||||
current.add(temp.getLocation());
|
current.add(temp.getLocation());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -59,7 +59,7 @@ public class PanzernCommand extends SWCommand {
|
|||||||
BauSystem.MESSAGE.send("PANZERN_NO_WORLDEDIT", player);
|
BauSystem.MESSAGE.send("PANZERN_NO_WORLDEDIT", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Panzern panzern = new Panzern(selection.getKey(), selection.getValue(), player.getLocation(), blockMaterial, slabMaterial);
|
Panzern panzern = new Panzern(player, selection.getKey(), selection.getValue(), player.getLocation(), blockMaterial, slabMaterial);
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -69,7 +69,7 @@ public class PanzernCommand extends SWCommand {
|
|||||||
while (true) {
|
while (true) {
|
||||||
if (!panzern.hasNext()) {
|
if (!panzern.hasNext()) {
|
||||||
BauSystem.MESSAGE.send("PANZERN_DONE", player);
|
BauSystem.MESSAGE.send("PANZERN_DONE", player);
|
||||||
panzern.getEditSession().close();
|
panzern.getEditSession().flushSession();
|
||||||
WorldEditUtils.addToPlayer(player, panzern.getEditSession());
|
WorldEditUtils.addToPlayer(player, panzern.getEditSession());
|
||||||
cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.bausystem.features.worldedit;
|
package de.steamwar.bausystem.features.worldedit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
@ -36,7 +35,6 @@ import de.steamwar.command.TypeMapper;
|
|||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -69,15 +67,13 @@ public class ColorReplaceCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
World world = player.getWorld();
|
|
||||||
|
|
||||||
Map<String, String> replacements = new HashMap<>();
|
Map<String, String> replacements = new HashMap<>();
|
||||||
for (String type : types) {
|
for (String type : types) {
|
||||||
replacements.put("minecraft:" + from.getValue().name().toLowerCase() + "_" + type.toLowerCase(), "minecraft:" + to.name().toLowerCase() + "_" + type.toLowerCase());
|
replacements.put("minecraft:" + from.getValue().name().toLowerCase() + "_" + type.toLowerCase(), "minecraft:" + to.name().toLowerCase() + "_" + type.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
Region region = WorldEditUtils.getRegion(player);
|
Region region = WorldEditUtils.getRegion(player);
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(BukkitAdapter.adapt(world), -1, BukkitAdapter.adapt(player));
|
EditSession editSession = WorldEditUtils.getEditSession(player);
|
||||||
|
|
||||||
SpecialReplace specialReplace = new SpecialReplace(editSession, replacements, from.getKey());
|
SpecialReplace specialReplace = new SpecialReplace(editSession, replacements, from.getKey());
|
||||||
int affected = editSession.replaceBlocks(region, specialReplace, specialReplace);
|
int affected = editSession.replaceBlocks(region, specialReplace, specialReplace);
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.bausystem.features.worldedit;
|
package de.steamwar.bausystem.features.worldedit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
@ -37,7 +36,6 @@ import de.steamwar.linkage.MinVersion;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.data.type.Fence;
|
import org.bukkit.block.data.type.Fence;
|
||||||
import org.bukkit.block.data.type.Wall;
|
import org.bukkit.block.data.type.Wall;
|
||||||
@ -73,10 +71,8 @@ public class TypeReplaceCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
World world = player.getWorld();
|
|
||||||
|
|
||||||
Region region = WorldEditUtils.getRegion(player);
|
Region region = WorldEditUtils.getRegion(player);
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(BukkitAdapter.adapt(world), -1, BukkitAdapter.adapt(player));
|
EditSession editSession = WorldEditUtils.getEditSession(player);
|
||||||
|
|
||||||
SpecialReplace specialReplace = new SpecialReplace(editSession, to.replacements(from.getValue()), from.getKey(), (oldBlockData, newBlockData) -> {
|
SpecialReplace specialReplace = new SpecialReplace(editSession, to.replacements(from.getValue()), from.getKey(), (oldBlockData, newBlockData) -> {
|
||||||
if (newBlockData instanceof Fence && oldBlockData instanceof Wall) {
|
if (newBlockData instanceof Fence && oldBlockData instanceof Wall) {
|
||||||
|
@ -40,8 +40,8 @@ import org.bukkit.entity.Player;
|
|||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class WorldEditUtils {
|
public class WorldEditUtils {
|
||||||
|
|
||||||
public EditSession getEditSession(World world) {
|
public EditSession getEditSession(Player player) {
|
||||||
return WorldEdit.getInstance().getEditSessionFactory().getEditSession(BukkitAdapter.adapt(world), Integer.MAX_VALUE);
|
return WorldEdit.getInstance().getEditSessionFactory().getEditSession(BukkitAdapter.adapt(player.getWorld()), -1, BukkitAdapter.adapt(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToPlayer(Player player, EditSession editSession) {
|
public void addToPlayer(Player player, EditSession editSession) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren