SteamWar/FightSystem
Archiviert
13
1

MultiSchemTypes #403

Zusammengeführt
YoyoNow hat 4 Commits von MultiSchemTypes nach master 2023-12-05 15:21:23 +01:00 zusammengeführt
5 geänderte Dateien mit 53 neuen und 53 gelöschten Zeilen
Nur Änderungen aus Commit b3ad960973 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -61,6 +61,7 @@ Schematic:
z: 0 z: 0
# The schematic type that can be chosen in this arena # The schematic type that can be chosen in this arena
Type: Normal # defaults to Normal if missing Type: Normal # defaults to Normal if missing
SubTypes: [] # defaults to empty List
# Shortcut of the schematic type # Shortcut of the schematic type
Shortcut: "" # defaults to "" if missing Shortcut: "" # defaults to "" if missing
# Spigot (1.8) material for GUIs # Spigot (1.8) material for GUIs
@ -73,7 +74,7 @@ Schematic:
PasteAligned: false # defaults to false if missing PasteAligned: false # defaults to false if missing
# If only public schematics are allowed # If only public schematics are allowed
OnlyPublicSchematics: false # defaults to false if missing OnlyPublicSchematics: false # defaults to false if missing
# If the public only force should be completely disabled # If the public only force should be completely disabled # TODO: I think this value is now obsolete!
IgnorePublicOnly: false # defaults to false if missing IgnorePublicOnly: false # defaults to false if missing
# If obsidian and bedrock should be replaced during PRE_RUNNING # If obsidian and bedrock should be replaced during PRE_RUNNING
ReplaceObsidianBedrock: false # defaults to false if missing ReplaceObsidianBedrock: false # defaults to false if missing

Datei anzeigen

@ -21,10 +21,7 @@ package de.steamwar.fightsystem;
import de.steamwar.fightsystem.utils.Region; import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.winconditions.Winconditions; import de.steamwar.fightsystem.winconditions.Winconditions;
import de.steamwar.sql.Event; import de.steamwar.sql.*;
import de.steamwar.sql.EventFight;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.Team;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -83,6 +80,7 @@ public class Config {
public static final boolean OnlyPublicSchematics; public static final boolean OnlyPublicSchematics;
public static final boolean IgnorePublicOnly; public static final boolean IgnorePublicOnly;
public static final de.steamwar.sql.SchematicType SchematicType; public static final de.steamwar.sql.SchematicType SchematicType;
public static final List<de.steamwar.sql.SchematicType> SubTypes;
public static final boolean RedRotate; public static final boolean RedRotate;
public static final boolean BlueRotate; public static final boolean BlueRotate;
public static final boolean PasteAligned; public static final boolean PasteAligned;
@ -181,6 +179,7 @@ public class Config {
int schemsizeZ = config.getInt("Schematic.Size.z"); int schemsizeZ = config.getInt("Schematic.Size.z");
RanksEnabled = !config.getStringList("Ranks").isEmpty(); RanksEnabled = !config.getStringList("Ranks").isEmpty();
SchematicType = de.steamwar.sql.SchematicType.fromDB(Objects.requireNonNull(config.getString("Schematic.Type", "normal"))); SchematicType = de.steamwar.sql.SchematicType.fromDB(Objects.requireNonNull(config.getString("Schematic.Type", "normal")));
SubTypes = config.getStringList("Schematic.SubTypes").stream().map(de.steamwar.sql.SchematicType::fromDB).collect(Collectors.toList());
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly", false); IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly", false);
boolean rotate = config.getBoolean("Schematic.Rotate", true); boolean rotate = config.getBoolean("Schematic.Rotate", true);
PasteAligned = config.getBoolean("Schematic.PasteAligned", false); PasteAligned = config.getBoolean("Schematic.PasteAligned", false);

Datei anzeigen

@ -29,6 +29,7 @@ import de.steamwar.inventory.*;
import de.steamwar.message.Message; import de.steamwar.message.Message;
import de.steamwar.sql.PersonalKit; import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -167,36 +168,47 @@ public class GUI {
return; return;
} }
SWInventory inv = new SWInventory(p, 9, msg.parse("SCHEM_TITLE", p, Config.GameName)); int invSize = (Config.SubTypes.size() + 1) * 9;
inv.setItem(8, Material.REDSTONE, msg.parse("SCHEM_PUBLIC", p, Config.GameName), (ClickType click) -> { SWInventory inv = new SWInventory(p, invSize, msg.parse("SCHEM_TITLE", p, Config.GameName));
p.closeInventory(); setupSchemTypeRow(p, inv, Config.SchematicType, 0);
schemDialog(p, true, false); for (int i = 0; i < Config.SubTypes.size(); i++) {
}); setupSchemTypeRow(p, inv, Config.SubTypes.get(0), i + 1);
if(Fight.getMaxRank() == 0){
inv.setItem(0, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_PRIVATE_FORBIDDEN", p, Config.GameName), (ClickType click)->{});
}else {
if (Config.SchematicType.checkType() != null && !SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.checkType().toDB()).isEmpty()) {
inv.setItem(4, Material.ANVIL, msg.parse("SCHEM_UNCHECKED", p, Config.GameName), (ClickType click) -> {
p.closeInventory();
schemDialog(p, false, true);
});
}
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) -> {
p.closeInventory();
schemDialog(p, false, false);
});
}
} }
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open(); inv.open();
} }
private static void schemDialog(Player p, boolean publicSchems, boolean unchecked){ private static void setupSchemTypeRow(Player p, SWInventory inv, SchematicType type, int row) {
SchematicSelector selector = new SchematicSelector(p, Config.test()?SchematicSelector.selectSchematic():SchematicSelector.selectSchematicTypeWithRank(unchecked ? Config.SchematicType.checkType() : Config.SchematicType, Fight.getMaxRank()), node -> { inv.setItem(row * 9 + 8, Material.REDSTONE, msg.parse("SCHEM_PUBLIC", p, type.name()), (ClickType click) -> {
p.closeInventory();
schemDialog(p, type, true, false);
});
if (Fight.publicOnly()) {
inv.setItem(row * 9, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_PRIVATE_FORBIDDEN", p, type.name()), (ClickType click)->{});
return;
}
if (type.checkType() != null && type.checkType() != type && !SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.checkType().toDB()).isEmpty()) {
inv.setItem(row * 9 + 4, Material.ANVIL, msg.parse("SCHEM_UNCHECKED", p, Config.GameName), (ClickType click) -> {
p.closeInventory();
schemDialog(p, type, false, true);
});
}
if (SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB()).isEmpty() && !Config.test()) {
inv.setItem(row * 9, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_NO_PRIVATE", p, Config.GameName), (ClickType click)->{});
return;
}
inv.setItem(row * 9, SWItem.getMaterial("CAULDRON_ITEM"), msg.parse("SCHEM_PRIVATE", p, Config.GameName), (ClickType click) -> {
p.closeInventory();
schemDialog(p, type, false, false);
});
}
private static void schemDialog(Player p, SchematicType type, boolean publicSchems, boolean unchecked){
SchematicSelector selector = new SchematicSelector(p, Config.test() ? SchematicSelector.selectSchematic() : SchematicSelector.selectSchematicType(unchecked ? type.checkType() : type), node -> {
FightTeam fightTeam = Fight.getPlayerTeam(p); FightTeam fightTeam = Fight.getPlayerTeam(p);
if(fightTeam == null) if(fightTeam == null)
return; return;

Datei anzeigen

@ -139,21 +139,13 @@ public class Fight {
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), enable ? GameMode.CREATIVE : GameMode.SPECTATOR)); TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), enable ? GameMode.CREATIVE : GameMode.SPECTATOR));
} }
public static int getMaxRank(){ public static boolean publicOnly() {
/* MaxRank of 0 is Pubonly*/ if (Config.OnlyPublicSchematics) {
if(Config.OnlyPublicSchematics){ return true;
return 0;
} }
if (redTeam.isPublicsOnly() || blueTeam.isPublicsOnly()) {
if(Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)){ return true;
return 1000;
} }
return false;
if(redTeam.getLeader() == null || blueTeam.getLeader() == null){
return 1000;
}
return Math.min(redTeam.getSchemRank(), blueTeam.getSchemRank());
} }
} }

Datei anzeigen

@ -90,7 +90,7 @@ public class FightTeam {
private UUID designatedLeader; private UUID designatedLeader;
private FightPlayer leader; private FightPlayer leader;
private int schemRank; private boolean publicsOnly;
private final Map<UUID, FightPlayer> players = new HashMap<>(); private final Map<UUID, FightPlayer> players = new HashMap<>();
@ -113,7 +113,7 @@ public class FightTeam {
this.spawn = spawn; this.spawn = spawn;
this.schemRegion = schemRegion; this.schemRegion = schemRegion;
this.extendRegion = extendRegion; this.extendRegion = extendRegion;
this.schemRank = 0; this.publicsOnly = false;
this.ready = false; this.ready = false;
this.skip = false; this.skip = false;
this.blue = blue; this.blue = blue;
@ -161,8 +161,8 @@ public class FightTeam {
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId())); return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
} }
public int getSchemRank() { public boolean isPublicsOnly() {
return schemRank; return publicsOnly;
} }
public void teleportToSpawn(){ public void teleportToSpawn(){
@ -357,11 +357,7 @@ public class FightTeam {
if(!silent) if(!silent)
FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getEntity().getName()); FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getEntity().getName());
Optional<Integer> maxRank = SchematicNode.getAllAccessibleSchematicsOfType(leader.getUser().getId(), Config.SchematicType.toDB()).stream().map(SchematicNode::getRank).max(Integer::compare); publicsOnly = SchematicNode.getAllAccessibleSchematicsOfType(leader.getUser().getId(), Config.SchematicType.toDB()).isEmpty();
if(Config.RanksEnabled)
schemRank = maxRank.orElse(1);
else
schemRank = maxRank.isPresent() ? 1 : 0;
if(!Config.PersonalKits) if(!Config.PersonalKits)
leader.setKit(Kit.getKitByName(Config.LeaderDefault)); leader.setKit(Kit.getKitByName(Config.LeaderDefault));