SteamWar/FightSystem
Archiviert
13
1

Schematic pasting refactoring #286

Manuell gemergt
Lixfel hat 5 Commits von weRefactoring nach master 2021-09-11 17:57:23 +02:00 zusammengeführt
6 geänderte Dateien mit 28 neuen und 18 gelöschten Zeilen
Nur Änderungen aus Commit 0556b9de9a werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -33,6 +33,7 @@ import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder;
@ -103,9 +104,9 @@ public class WorldeditWrapper14 implements WorldeditWrapper.IWorldeditWrapper {
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(position.getWorld()), -1);
ClipboardHolder ch = new ClipboardHolder(clipboard);
ch.setTransform(aT);
Operations.completeBlindly(ch.createPaste(e).to(BukkitAdapter.asBlockVector(position).add(
aT.apply(BlockVector3.at(offset.getBlockX(), offset.getBlockY(), offset.getBlockZ()).add(clipboard.getOrigin()).subtract(clipboard.getMinimumPoint()).toVector3()).toBlockPoint()
)).build());
Operations.completeBlindly(ch.createPaste(e).to(BukkitAdapter.asVector(position).add(
aT.apply(Vector3.at(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin().toVector3()).subtract(clipboard.getMinimumPoint().toVector3()))
).toBlockPoint()).build());
e.flushSession();
}

Datei anzeigen

@ -103,9 +103,9 @@ public class WorldeditWrapper8 implements WorldeditWrapper.IWorldeditWrapper {
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
ch.setTransform(aT);
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(new Vector(position.getBlockX(), position.getBlockY(), position.getBlockZ()).add(
aT.apply(new Vector(offset.getBlockX(), offset.getBlockY(), offset.getBlockZ()).add(clipboard.getOrigin()).subtract(clipboard.getMinimumPoint())).toBlockPoint()
)).build());
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(new Vector(position.getX(), position.getY(), position.getZ()).add(
aT.apply(new Vector(offset.getX(), offset.getY(), offset.getZ()).add(clipboard.getOrigin()).subtract(clipboard.getMinimumPoint()))
).toBlockPoint()).build());
e.flushQueue();
}

Datei anzeigen

@ -61,9 +61,9 @@ public class Config {
public static final Location TeamRedSpawn;
public static final Location SpecSpawn;
private static final int BlueToRedX;
public static final int BlueToRedX;
private static final int BlueToRedY;
private static final int BlueToRedZ;
public static final int BlueToRedZ;
public static final int PreperationArea;
public static final int WaterDepth;
@ -132,14 +132,15 @@ public class Config {
public static final int ReplayID;
static{
if(!new File(FightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) {
String configFile = System.getProperty("config", "config.yml");
if(!new File(FightSystem.getPlugin().getDataFolder(), configFile).exists()) {
FightSystem.getPlugin().saveDefaultConfig();
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
Bukkit.shutdown();
}
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(FightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")));
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(FightSystem.getPlugin().getDataFolder(), configFile));
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), config.getString("Arenaconfig", "config.yml"));
File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
if(!worldConfigFile.exists()) {
Bukkit.getLogger().log(Level.SEVERE, "Weltconfig fehlt!");
Bukkit.shutdown();
@ -173,7 +174,7 @@ public class Config {
GroundWalkable = config.getBoolean("Arena.GroundWalkable");
RanksEnabled = config.getBoolean("Schematic.RanksEnabled");
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
SchematicType = de.steamwar.sql.SchematicType.fromDB(Objects.requireNonNull(config.getString("Schematic.SchematicType")));
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly");
boolean rotate = config.getBoolean("Schematic.Rotate");
PasteAligned = config.getBoolean("Schematic.PasteAligned");

Datei anzeigen

@ -132,9 +132,9 @@ public class FightSchematic extends StateDependent {
clipboard,
new Location(Bukkit.getWorlds().get(0), region.centerX(), region.getMinY(), region.centerZ()),
new Vector(
-dims.getBlockX()/2,
-(Config.PasteAligned && Config.BlueToRedX != 0 ? region.getSizeX() : dims.getBlockX())/2.0,
Config.WaterDepth != 0 ? Config.WaterDepth - WorldeditWrapper.impl.getWaterDepth(clipboard) : 0,
-dims.getBlockZ()/2
-(Config.PasteAligned && Config.BlueToRedZ != 0 ? region.getSizeZ() : dims.getBlockZ())/2.0
),
new AffineTransform().rotateY(rotate ? 180 : 0)
);

Datei anzeigen

@ -71,6 +71,10 @@ public class Region {
return maxZ;
}
public int getSizeX() {
return maxX - minX;
}
public int getSizeZ() {
return maxZ - minZ;
}
@ -120,12 +124,12 @@ public class Region {
return (maxX - minX) * (maxY - minY) * (maxZ - minZ);
}
public int centerX() {
return (maxX - minX) / 2 + minX;
public double centerX() {
return (maxX - minX) / 2.0 + minX;
}
public int centerZ() {
return (maxZ - minZ) / 2 + minZ;
public double centerZ() {
return (maxZ - minZ) / 2.0 + minZ;
}
public boolean in2dRegion(Location location){

Datei anzeigen

@ -23,13 +23,17 @@ public enum Winconditions {
TIMEOUT,
HEART_RATIO_TIMEOUT,
PERCENT_TIMEOUT,
ALL_DEAD,
CAPTAIN_DEAD,
PERCENT_SYSTEM,
RELATIVE_PERCENT,
POINTS,
TIME_TECH_KO,
WATER_TECH_KO,
PUMPKIN_TECH_KO,
HELLS_BELLS
}