SteamWar/FightSystem
Archiviert
13
1

Schematic Pasting

Dieser Commit ist enthalten in:
lixfel 2019-04-12 12:57:49 +02:00
Ursprung 209f1ba88a
Commit eab9235eef
4 geänderte Dateien mit 50 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,7 @@ Schematic:
OnlyPublicSchematics: boolean OnlyPublicSchematics: boolean
Directory: /home/netuser/schematics/ Directory: /home/netuser/schematics/
SchematicType: airship SchematicType: airship
Rotate: boolean
Output: Output:
TeamRedName: Team1 TeamRedName: Team1
TeamRedPrefix: §c TeamRedPrefix: §c

Datei anzeigen

@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
public class Fight { public class Fight {
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix); public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedPaste, Config.TeamRedRotate);
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix); public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBluePaste, Config.TeamBlueRotate);
public static FightTeam getPlayerTeam(Player player) { public static FightTeam getPlayerTeam(Player player) {

Datei anzeigen

@ -2,6 +2,7 @@ package me.yaruma.fightsystem.fight;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import de.warking.hunjy.MySQL.Schematic; import de.warking.hunjy.MySQL.Schematic;
@ -10,6 +11,7 @@ import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.utils.Config; import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.ItemBuilder; import me.yaruma.fightsystem.utils.ItemBuilder;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -24,16 +26,22 @@ public class FightTeam {
private final ArrayList<FightPlayer> players; private final ArrayList<FightPlayer> players;
private boolean ready; private boolean ready;
private final ArrayList<Player> invited; private final ArrayList<Player> invited;
private String name; private final String name;
private String prefix; private final String prefix;
private Schematic schematic; private Schematic schematic;
private final Location spawn;
private final Vector paste;
private final boolean rotate;
public FightTeam(String Name, String Prefix) { public FightTeam(String Name, String Prefix, Location Spawn, Vector Paste, boolean Rotate) {
players = new ArrayList<>(); players = new ArrayList<>();
invited = new ArrayList<>(); invited = new ArrayList<>();
spawn = Spawn;
paste = Paste;
name = Name; name = Name;
prefix = Prefix; prefix = Prefix;
ready = false; ready = false;
rotate = Rotate;
} }
public FightPlayer getFightPlayer(Player player) { public FightPlayer getFightPlayer(Player player) {
@ -95,9 +103,10 @@ public class FightTeam {
public void setLeader(FightPlayer leader) { public void setLeader(FightPlayer leader) {
this.leader = leader; this.leader = leader;
if(!this.players.contains(leader)) if(!this.players.contains(leader)){
this.players.add(leader); this.players.add(leader);
} }
}
public ArrayList<FightPlayer> getPlayers() { public ArrayList<FightPlayer> getPlayers() {
return players; return players;
@ -108,7 +117,7 @@ public class FightTeam {
} }
private void pasteSchematic(){ private void pasteSchematic(){
File file = new File(Config.SchematicDirectory + WarkingUser.get(schematic.getSchemOwner()) + "/" + schematic.getSchemName() + ".schematic"); File file = new File(Config.SchematicDirectory + WarkingUser.get(schematic.getSchemOwner()).getUUID().toString() + "/" + schematic.getSchemName() + ".schematic");
com.boydti.fawe.object.schematic.Schematic schem; com.boydti.fawe.object.schematic.Schematic schem;
try { try {
schem = FaweAPI.load(file); schem = FaweAPI.load(file);
@ -116,13 +125,13 @@ public class FightTeam {
e.printStackTrace(); e.printStackTrace();
return; return;
} }
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = schem.getClipboard().getDimensions();
Vector v = paste.subtract(dimensions.getX()/2, 0, dimensions.getZ()/2).subtract(schem.getClipboard().getRegion().getMinimumPoint()).add(schem.getClipboard().getOrigin());
AffineTransform aT = new AffineTransform(); AffineTransform aT = new AffineTransform();
World w = (World) Bukkit.getWorlds().get(0); if(rotate){
Vector v = schem.getClipboard().getDimensions().divide(-2); aT.rotateY(180);
if(this == Fight.getBlueTeam()) }
v = v.add(Config.TeamBluePasteX, Config.TeamBluePasteY, Config.TeamBluePasteZ);
else
v = v.add(Config.TeamRedPasteX, Config.TeamRedPasteY, Config.TeamRedPasteZ);
schem.paste(w, v, false, true, aT).flushQueue(); schem.paste(w, v, false, true, aT).flushQueue();
} }

Datei anzeigen

@ -1,5 +1,6 @@
package me.yaruma.fightsystem.utils; package me.yaruma.fightsystem.utils;
import com.sk89q.worldedit.Vector;
import de.warking.hunjy.MySQL.SchematicType; import de.warking.hunjy.MySQL.SchematicType;
import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.FightSystem;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -33,6 +34,8 @@ public class Config {
public static boolean OnlyPublicSchematics; public static boolean OnlyPublicSchematics;
public static String SchematicDirectory; public static String SchematicDirectory;
public static SchematicType SchematicType; public static SchematicType SchematicType;
public static boolean TeamRedRotate;
public static boolean TeamBlueRotate;
public static String TeamRedName; public static String TeamRedName;
public static String TeamRedPrefix; public static String TeamRedPrefix;
@ -69,6 +72,8 @@ public class Config {
public static int TeamRedPasteX; public static int TeamRedPasteX;
public static int TeamRedPasteY; public static int TeamRedPasteY;
public static int TeamRedPasteZ; public static int TeamRedPasteZ;
public static Vector TeamBluePaste;
public static Vector TeamRedPaste;
public static int ArenaMinX; public static int ArenaMinX;
public static int ArenaMinZ; public static int ArenaMinZ;
@ -105,6 +110,7 @@ public class Config {
OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics"); OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics");
SchematicDirectory = config.getString("Schematic.Directory"); SchematicDirectory = config.getString("Schematic.Directory");
SchematicType = de.warking.hunjy.MySQL.SchematicType.valueOf(config.getString("Schematic.SchematicType")); SchematicType = de.warking.hunjy.MySQL.SchematicType.valueOf(config.getString("Schematic.SchematicType"));
boolean Rotate = config.getBoolean("Schematic.Rotate");
TeamRedName = config.getString("Output.TeamRedName"); TeamRedName = config.getString("Output.TeamRedName");
TeamRedPrefix = config.getString("Output.TeamRedPrefix"); TeamRedPrefix = config.getString("Output.TeamRedPrefix");
@ -148,31 +154,49 @@ public class Config {
TeamBluePasteY = TeamBlueCornerY; TeamBluePasteY = TeamBlueCornerY;
TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ/2; TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ/2;
TeamBluePaste = new Vector(TeamBlueCornerX + SchemsizeX/2, TeamBlueCornerY, TeamBlueCornerZ + SchemsizeZ/2);
TeamRedPaste = new Vector(TeamRedCornerX + SchemsizeX/2, TeamRedCornerY, TeamRedCornerZ + SchemsizeZ/2);
TeamRedPasteX = TeamBluePasteX + TeamBluetoReddistanceX; TeamRedPasteX = TeamBluePasteX + TeamBluetoReddistanceX;
TeamRedPasteY = TeamBluePasteY + TeamBluetoReddistanceY; TeamRedPasteY = TeamBluePasteY + TeamBluetoReddistanceY;
TeamRedPasteZ = TeamBluePasteZ + TeamBluetoReddistanceZ; TeamRedPasteZ = TeamBluePasteZ + TeamBluetoReddistanceZ;
World world = Bukkit.getWorlds().get(0); World world = Bukkit.getWorlds().get(0);
TeamBlueSpawn = new Location(world, TeamBluePasteX, TeamBluePasteY + SchemsizeY, TeamBluePasteZ); TeamBlueSpawn = new Location(world, TeamBluePasteX + 0.5, TeamBluePasteY + SchemsizeY, TeamBluePasteZ + 0.5);
TeamRedSpawn = new Location(world, TeamRedPasteX, TeamRedPasteY + SchemsizeY, TeamRedPasteZ); TeamRedSpawn = new Location(world, TeamRedPasteX + 0.5, TeamRedPasteY + SchemsizeY, TeamRedPasteZ + 0.5);
SpecSpawn = new Location(world, SpecSpawn = new Location(world,
TeamBluePasteX + TeamBluetoReddistanceX/2, TeamBluePasteX + TeamBluetoReddistanceX/2,
TeamBluePasteY + TeamBluetoReddistanceY/2, TeamBluePasteY + TeamBluetoReddistanceY/2 + SchemsizeY/2,
TeamBluePasteZ + TeamBluetoReddistanceZ/2); TeamBluePasteZ + TeamBluetoReddistanceZ/2);
if(TeamBluetoReddistanceX > 0){ if(TeamBluetoReddistanceX > 0){
ArenaMinX = TeamBlueCornerX - Schem2BorderX; ArenaMinX = TeamBlueCornerX - Schem2BorderX;
ArenaMaxX = TeamRedCornerX + SchemsizeX + Schem2BorderX; ArenaMaxX = TeamRedCornerX + SchemsizeX + Schem2BorderX;
TeamRedRotate = true;
TeamBlueRotate = false;
}else{ }else{
ArenaMinX = TeamRedCornerX - Schem2BorderX; ArenaMinX = TeamRedCornerX - Schem2BorderX;
ArenaMaxX = TeamBlueCornerX + SchemsizeX + Schem2BorderX; ArenaMaxX = TeamBlueCornerX + SchemsizeX + Schem2BorderX;
TeamRedRotate = false;
TeamBlueRotate = true;
} }
if(TeamBluetoReddistanceZ > 0){ if(TeamBluetoReddistanceZ > 0){
ArenaMinZ = TeamBlueCornerZ - Schem2BorderZ; ArenaMinZ = TeamBlueCornerZ - Schem2BorderZ;
ArenaMaxZ = TeamRedCornerZ + SchemsizeZ + Schem2BorderZ; ArenaMaxZ = TeamRedCornerZ + SchemsizeZ + Schem2BorderZ;
TeamRedRotate = true;
TeamBlueRotate = false;
}else{ }else{
ArenaMinZ = TeamRedCornerZ - Schem2BorderZ; ArenaMinZ = TeamRedCornerZ - Schem2BorderZ;
ArenaMaxZ = TeamBlueCornerZ + SchemsizeZ + Schem2BorderZ; ArenaMaxZ = TeamBlueCornerZ + SchemsizeZ + Schem2BorderZ;
if(TeamBluetoReddistanceZ != 0){
TeamRedRotate = false;
TeamBlueRotate = true;
}
}
if(!Rotate){
TeamRedRotate = false;
TeamBlueRotate = false;
} }
} }
} }