SteamWar/FightSystem
Archiviert
13
1

Changing to SchematicNodes #305

Zusammengeführt
Lixfel hat 6 Commits von fightnodes nach master 2021-12-27 16:32:19 +01:00 zusammengeführt
13 geänderte Dateien mit 44 neuen und 56 gelöschten Zeilen

Datei anzeigen

@ -41,7 +41,7 @@ import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
@ -122,7 +122,7 @@ public class WorldeditWrapper14 implements WorldeditWrapper.IWorldeditWrapper {
}
@Override
public void saveSchem(Schematic schem, Region region, int minY) throws WorldEditException {
public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
BlockVector3 min = BlockVector3.at(region.getMinX(), minY, region.getMinZ());
CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(BlockVector3.ONE));

Datei anzeigen

@ -38,7 +38,7 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
@ -121,7 +121,7 @@ public class WorldeditWrapper8 implements WorldeditWrapper.IWorldeditWrapper {
}
@Override
public void saveSchem(Schematic schem, Region region, int minY) throws WorldEditException {
public void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector min = new Vector(region.getMinX(), minY, region.getMinZ());
CuboidRegion cuboidRegion = new CuboidRegion(w, min, new Vector(region.getMaxX(), region.getMaxY(), region.getMaxZ()).subtract(Vector.ONE));

Datei anzeigen

@ -33,7 +33,7 @@ import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.winconditions.*;
import de.steamwar.message.Message;
import de.steamwar.sql.EventFight;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -140,9 +140,9 @@ public class FightSystem extends JavaPlugin {
if(Config.mode == ArenaMode.EVENT) {
setPreSchemState();
}else if(Config.mode == ArenaMode.CHECK){
Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.CheckSchemID));
Fight.getBlueTeam().setSchem(SchematicNode.getSchematicNode(Config.CheckSchemID));
}else if(Config.mode == ArenaMode.PREPARE) {
Fight.getUnrotated().setSchem(Schematic.getSchemFromDB(Config.PrepareSchemID));
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID));
}else if(Config.mode == ArenaMode.REPLAY) {
FightWorld.forceLoad();
FileSource.startReplay();

Datei anzeigen

@ -27,13 +27,10 @@ import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.Kit;
import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.inventory.*;
import de.steamwar.message.Message;
import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
@ -173,7 +170,7 @@ public class GUI {
});
if(Fight.getMaxRank() == 0){
inv.setItem(0, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_PRIVATE_FORBIDDEN", p, Config.GameName), (ClickType click)->{});
}else if(Schematic.getSchemsOfType(p.getUniqueId(), Config.SchematicType).isEmpty() && !Config.test()){
}else if(SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB()).isEmpty() && !Config.test()){
inv.setItem(0, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_NO_PRIVATE", p, Config.GameName), (ClickType click)->{});
}else{
inv.setItem(0, SWItem.getMaterial("CAULDRON_ITEM"), msg.parse("SCHEM_PRIVATE", p, Config.GameName), (ClickType click) -> {
@ -186,25 +183,15 @@ public class GUI {
}
private static void schemDialog(Player p, boolean publicSchems){
List<SWListInv.SWListEntry<Schematic>> schems;
if(publicSchems)
schems = SWListInv.getSchemList(Config.SchematicType, 0);
else if(Config.test())
schems = SWListInv.getSchemList(null, SteamwarUser.get(p.getUniqueId()).getId());
else{
schems = SWListInv.getSchemList(Config.SchematicType, SteamwarUser.get(p.getUniqueId()).getId());
schems.removeIf(schem -> schem.getObject().getRank() > Fight.getMaxRank());
}
SWListInv<Schematic> inv = new SWListInv<>(p, msg.parse("SCHEM_TITLE", p, Config.GameName), schems, (ClickType click, Schematic s) -> {
SchematicSelector selector = new SchematicSelector(p, Config.test()?SchematicSelector.selectSchematic():SchematicSelector.selectSchematicTypeWithRank(Config.SchematicType, Fight.getMaxRank()), node -> {
FightTeam fightTeam = Fight.getPlayerTeam(p);
if(fightTeam == null)
return;
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
fightTeam.pasteSchem(s);
fightTeam.pasteSchem(node);
p.closeInventory();
});
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open();
selector.setPublicMode(publicSchems?SchematicSelector.PublicMode.PUBLIC_ONLY:SchematicSelector.PublicMode.PRIVATE_ONLY);
selector.open();
}
}

Datei anzeigen

@ -25,7 +25,7 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
@ -67,7 +67,7 @@ public class LockschemCommand implements CommandExecutor {
return false;
}
Schematic.getSchemFromDB(fightTeam.getSchematic()).setSchemType(SchematicType.Normal);
SchematicNode.getSchematicNode(fightTeam.getSchematic()).setSchemtype(SchematicType.Normal);
FightSystem.getMessage().sendPrefixless("LOCKSCHEM_LOCKED", player, ChatMessageType.ACTION_BAR);
fightTeam.broadcastSystem("LOCKSCHEM_LOCKED_BY", player.getName());
return false;

Datei anzeigen

@ -31,7 +31,7 @@ import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.ColorConverter;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.utils.WorldeditWrapper;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.event.HandlerList;
@ -67,13 +67,13 @@ public class FightSchematic extends StateDependent {
return schematic;
}
public void setSchematic(Schematic schem) {
schematic = schem.getSchemID();
public void setSchematic(SchematicNode schem) {
schematic = schem.getId();
try {
clipboard = schem.load();
} catch (IOException e) {
team.broadcastSystem("SCHEMATIC_UNLOADABLE");
Bukkit.getLogger().log(Level.SEVERE, e, () -> "Couldn't load Schematic " + schem.getSchemName());
Bukkit.getLogger().log(Level.SEVERE, e, () -> "Couldn't load Schematic " + schem.getName());
}
}
@ -93,7 +93,7 @@ public class FightSchematic extends StateDependent {
return;
if(clipboard == null){
List<Schematic> publics = Schematic.getSchemsOfType(0, Config.SchematicType);
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.SchematicType.toDB());
if(publics.isEmpty())
return;

Datei anzeigen

@ -32,7 +32,8 @@ import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.*;
import de.steamwar.inventory.SWItem;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
@ -281,7 +282,7 @@ public class FightTeam {
if(!silent)
FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getPlayer().getName());
Optional<Integer> maxRank = Schematic.getSchemsOfType(leader.getPlayer().getUniqueId(), Config.SchematicType).stream().map(Schematic::getRank).max(Integer::compare);
Optional<Integer> maxRank = SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(leader.getPlayer().getUniqueId()).getId(), Config.SchematicType.toDB()).stream().map(SchematicNode::getRank).max(Integer::compare);
if(Config.RanksEnabled)
schemRank = maxRank.orElse(1);
else
@ -320,7 +321,7 @@ public class FightTeam {
return ready;
}
public void pasteSchem(Schematic schematic){
public void pasteSchem(SchematicNode schematic){
setSchem(schematic);
testPasteAction();
}
@ -342,9 +343,9 @@ public class FightTeam {
schematic.pasteTeamName();
}
public void setSchem(Schematic schematic){
public void setSchem(SchematicNode schematic){
this.schematic.setSchematic(schematic);
broadcast("SCHEMATIC_CHOSEN", Config.GameName, schematic.getSchemName());
broadcast("SCHEMATIC_CHOSEN", Config.GameName, schematic.getName());
}
public void setReady(boolean ready) {

Datei anzeigen

@ -24,7 +24,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import org.bukkit.Bukkit;
@ -50,8 +50,8 @@ public class Check implements Listener {
if(allowedToCheck(user))
return;
Schematic schem = Schematic.getSchemFromDB(Config.CheckSchemID);
if(user.getId() == schem.getSchemOwner())
SchematicNode schem = SchematicNode.getSchematicNode(Config.CheckSchemID);
if(user.getId() == schem.getOwner())
return;
FightSystem.getMessage().send("CHECK_JOIN_DENIED", player);

Datei anzeigen

@ -30,7 +30,7 @@ import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.utils.WorldeditWrapper;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
@ -49,9 +49,9 @@ public class PrepareSchem implements Listener {
Region region = Fight.getUnrotated().getExtendRegion();
int minY = Fight.getUnrotated().getSchemRegion().getMinY();
Schematic schem;
SchematicNode schem;
try{
schem = Schematic.getSchemFromDB(Config.PrepareSchemID);
schem = SchematicNode.getSchematicNode(Config.PrepareSchemID);
}catch(SecurityException e){
FightSystem.getMessage().broadcast("PREPARE_SCHEM_DELETED");
Bukkit.shutdown();
@ -78,7 +78,7 @@ public class PrepareSchem implements Listener {
throw new SecurityException("Could not save schem", e);
}
schem.setSchemType(Config.SchematicType.checkType());
schem.setSchemtype(Config.SchematicType.checkType());
FightSystem.getMessage().broadcast("PREPARE_SENT_IN");
Bukkit.shutdown();
}

Datei anzeigen

@ -32,7 +32,7 @@ import de.steamwar.fightsystem.fight.FreezeWorld;
import de.steamwar.fightsystem.listener.FightScoreboard;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.utils.*;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.Team;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
@ -374,12 +374,12 @@ public class PacketProcessor {
private void pasteSchem(FightTeam team) throws IOException {
int schemId = source.readInt();
execSync(() -> team.pasteSchem(Schematic.getSchemFromDB(schemId)));
execSync(() -> team.pasteSchem(SchematicNode.getSchematicNode(schemId)));
}
private void pasteEmbeddedSchem(FightTeam team) throws IOException {
int schemId = source.readInt();
Clipboard clipboard = Schematic.clipboardFromStream(source, Core.getVersion() > 12);
Clipboard clipboard = SchematicNode.clipboardFromStream(source, Core.getVersion() > 12);
execSync(() -> team.pasteSchem(schemId, clipboard));
}

Datei anzeigen

@ -29,7 +29,7 @@ import de.steamwar.fightsystem.utils.BlockIdWrapper;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -275,7 +275,7 @@ public interface Recorder {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try{
copy(Schematic.getSchemFromDB(schemId).schemData(), buffer);
copy(SchematicNode.getSchematicNode(schemId).schemData(), buffer);
}catch (EOFException e) {
Bukkit.getLogger().log(Level.INFO, "EOFException ignored");
} catch (IOException e) {

Datei anzeigen

@ -31,7 +31,7 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.winconditions.Wincondition;
import de.steamwar.sql.Elo;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
@ -91,12 +91,12 @@ public class FightStatistics {
Integer blueSchem;
Integer redSchem;
try{
blueSchem = Schematic.getSchemFromDB(Fight.getBlueTeam().getSchematic()).getSchemID();
blueSchem = SchematicNode.getSchematicNode(Fight.getBlueTeam().getSchematic()).getId();
}catch(SecurityException e){
blueSchem = null;
}
try{
redSchem = Schematic.getSchemFromDB(Fight.getRedTeam().getSchematic()).getSchemID();
redSchem = SchematicNode.getSchematicNode(Fight.getRedTeam().getSchematic()).getId();
}catch(SecurityException e){
redSchem = null;
}

Datei anzeigen

@ -24,7 +24,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.transform.AffineTransform;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.util.Vector;
@ -42,6 +42,6 @@ public class WorldeditWrapper {
void pasteClipboard(Clipboard clipboard, Location position, Vector offset, AffineTransform aT);
Vector getDimensions(Clipboard clipboard);
Clipboard loadChar(String charName) throws IOException;
void saveSchem(Schematic schem, Region region, int minY) throws WorldEditException;
void saveSchem(SchematicNode schem, Region region, int minY) throws WorldEditException;
}
}