12
1
Fork 0

Add MultiSchemType selection for GUI.preSchemDialog
SteamWarCI Build successful Details

Dieser Commit ist enthalten in:
yoyosource 2023-12-01 16:14:37 +01:00
Ursprung ad5a2d4a08
Commit b3ad960973
5 geänderte Dateien mit 53 neuen und 53 gelöschten Zeilen

Datei anzeigen

@ -61,6 +61,7 @@ Schematic:
z: 0
# The schematic type that can be chosen in this arena
Type: Normal # defaults to Normal if missing
SubTypes: [] # defaults to empty List
# Shortcut of the schematic type
Shortcut: "" # defaults to "" if missing
# Spigot (1.8) material for GUIs
@ -73,7 +74,7 @@ Schematic:
PasteAligned: false # defaults to false if missing
# If only public schematics are allowed
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
# If obsidian and bedrock should be replaced during PRE_RUNNING
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.winconditions.Winconditions;
import de.steamwar.sql.Event;
import de.steamwar.sql.EventFight;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.Team;
import de.steamwar.sql.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -83,6 +80,7 @@ public class Config {
public static final boolean OnlyPublicSchematics;
public static final boolean IgnorePublicOnly;
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 BlueRotate;
public static final boolean PasteAligned;
@ -181,6 +179,7 @@ public class Config {
int schemsizeZ = config.getInt("Schematic.Size.z");
RanksEnabled = !config.getStringList("Ranks").isEmpty();
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);
boolean rotate = config.getBoolean("Schematic.Rotate", true);
PasteAligned = config.getBoolean("Schematic.PasteAligned", false);

Datei anzeigen

@ -29,6 +29,7 @@ import de.steamwar.inventory.*;
import de.steamwar.message.Message;
import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
@ -167,36 +168,47 @@ public class GUI {
return;
}
SWInventory inv = new SWInventory(p, 9, msg.parse("SCHEM_TITLE", p, Config.GameName));
inv.setItem(8, Material.REDSTONE, msg.parse("SCHEM_PUBLIC", p, Config.GameName), (ClickType click) -> {
p.closeInventory();
schemDialog(p, true, false);
});
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);
});
}
int invSize = (Config.SubTypes.size() + 1) * 9;
SWInventory inv = new SWInventory(p, invSize, msg.parse("SCHEM_TITLE", p, Config.GameName));
setupSchemTypeRow(p, inv, Config.SchematicType, 0);
for (int i = 0; i < Config.SubTypes.size(); i++) {
setupSchemTypeRow(p, inv, Config.SubTypes.get(0), i + 1);
}
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open();
}
private static void schemDialog(Player p, boolean publicSchems, boolean unchecked){
SchematicSelector selector = new SchematicSelector(p, Config.test()?SchematicSelector.selectSchematic():SchematicSelector.selectSchematicTypeWithRank(unchecked ? Config.SchematicType.checkType() : Config.SchematicType, Fight.getMaxRank()), node -> {
private static void setupSchemTypeRow(Player p, SWInventory inv, SchematicType type, int row) {
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);
if(fightTeam == null)
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));
}
public static int getMaxRank(){
/* MaxRank of 0 is Pubonly*/
if(Config.OnlyPublicSchematics){
return 0;
public static boolean publicOnly() {
if (Config.OnlyPublicSchematics) {
return true;
}
if(Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)){
return 1000;
if (redTeam.isPublicsOnly() || blueTeam.isPublicsOnly()) {
return true;
}
if(redTeam.getLeader() == null || blueTeam.getLeader() == null){
return 1000;
}
return Math.min(redTeam.getSchemRank(), blueTeam.getSchemRank());
return false;
}
}

Datei anzeigen

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