12
1

Merge pull request 'MultiSchemTypes' (#403) from MultiSchemTypes into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #403
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
YoyoNow 2023-12-05 15:21:22 +01:00
Commit ad7a42a685
5 geänderte Dateien mit 54 neuen und 47 gelöschten Zeilen

Datei anzeigen

@ -61,6 +61,8 @@ 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
# The schematic types that are also allowed to be chosen in this arena
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

Datei anzeigen

@ -83,6 +83,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 +182,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(i), 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, type.name()), (ClickType click) -> {
p.closeInventory();
schemDialog(p, type, false, true);
});
}
if (SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.toDB()).isEmpty() && !Config.test()) {
inv.setItem(row * 9, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_NO_PRIVATE", p, type.name()), (ClickType click)->{});
return;
}
inv.setItem(row * 9, SWItem.getMaterial("CAULDRON_ITEM"), msg.parse("SCHEM_PRIVATE", p, type.name()), (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,16 @@ 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 (Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)) {
if(Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)){ return false;
return 1000;
} }
if (redTeam.getLeader() == null || blueTeam.getLeader() == null) {
return false;
if(redTeam.getLeader() == null || blueTeam.getLeader() == null){
return 1000;
} }
return redTeam.isPublicsOnly() || blueTeam.isPublicsOnly();
return Math.min(redTeam.getSchemRank(), blueTeam.getSchemRank());
} }
} }

Datei anzeigen

@ -91,7 +91,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<>();
@ -114,7 +114,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;
@ -162,8 +162,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(){
@ -358,11 +358,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));