forked from SteamWar/SteamWar
Enable a Dirt Block (Schem owner -1 and Name like GameMode) to be selected for any ServerTeam member
This commit is contained in:
@@ -76,6 +76,7 @@ KITSEARCH_TITLE=Search for kit
|
||||
|
||||
SCHEM_NO_ENEMY=§cNo schematic selection without an opponent
|
||||
SCHEM_TITLE={0} selection
|
||||
SCHEM_DIRT=§eDirt Block
|
||||
SCHEM_PUBLIC=§ePublic {0}
|
||||
SCHEM_UNCHECKED=§eUnchecked {0}
|
||||
SCHEM_PRIVATE=§ePrivate {0}
|
||||
|
||||
@@ -70,6 +70,7 @@ KITSEARCH_TITLE=Nach Kit suchen
|
||||
|
||||
SCHEM_NO_ENEMY=§cKeine Schematicwahl ohne Gegner
|
||||
SCHEM_TITLE={0}-Auswahl
|
||||
SCHEM_DIRT=§eErdblock
|
||||
SCHEM_PUBLIC=§eÖffentliches {0}
|
||||
SCHEM_UNCHECKED=§eUngeprüftes {0}
|
||||
SCHEM_PRIVATE=§ePrivates {0}
|
||||
|
||||
@@ -24,15 +24,14 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.ai.AIManager;
|
||||
import de.steamwar.fightsystem.fight.*;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||
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 de.steamwar.sql.*;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -40,7 +39,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUI {
|
||||
@@ -206,6 +208,16 @@ public class GUI {
|
||||
for (int i = 0; i < Config.SubTypes.size(); i++) {
|
||||
setupSchemTypeRow(p, inv, Config.SubTypes.get(i), i + 1);
|
||||
}
|
||||
if (!Config.test() && SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.TEAM)) {
|
||||
SchematicNode node = SchematicNode.getSchematicNode(-1, Config.GameName, (Integer) null);
|
||||
if (node != null) {
|
||||
inv.setItem(2, new SWItem(SWItem.getMaterial(node.getItem()), msg.parse("SCHEM_DIRT", p), click -> {
|
||||
schemSelect(p, node, fightTeam -> {
|
||||
fightTeam.setIgnoreWinconditions(true);
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
@@ -241,14 +253,21 @@ public class GUI {
|
||||
|
||||
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;
|
||||
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||
fightTeam.pasteSchem(node);
|
||||
p.closeInventory();
|
||||
schemSelect(p, node, fightTeam -> {
|
||||
fightTeam.setIgnoreWinconditions(false);
|
||||
});
|
||||
});
|
||||
selector.setPublicMode(publicSchems?SchematicSelector.PublicMode.PUBLIC_ONLY:SchematicSelector.PublicMode.PRIVATE_ONLY);
|
||||
selector.open();
|
||||
}
|
||||
|
||||
private static void schemSelect(Player p, SchematicNode node, Consumer<FightTeam> fightTeamConsumer) {
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
||||
if(fightTeam == null)
|
||||
return;
|
||||
fightTeamConsumer.accept(fightTeam);
|
||||
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||
fightTeam.pasteSchem(node);
|
||||
p.closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@@ -100,6 +101,10 @@ public class FightTeam {
|
||||
@Getter
|
||||
private boolean publicsOnly;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean ignoreWinconditions;
|
||||
|
||||
private final Map<UUID, FightPlayer> players = new HashMap<>();
|
||||
|
||||
@Getter
|
||||
@@ -385,7 +390,7 @@ public class FightTeam {
|
||||
}
|
||||
|
||||
public void pasteSchem(SchematicNode schematic){
|
||||
if(schematic.getSchemtype().check()) {
|
||||
if(schematic.getSchemtype().check() || schematic.getSchemtype().writeable()) {
|
||||
FightStatistics.unrank();
|
||||
FightSystem.getMessage().broadcast("SCHEMATIC_UNCHECKED", getColoredName());
|
||||
}
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ public class WinconditionBlocks extends Wincondition implements PrintableWincond
|
||||
|
||||
private void check() {
|
||||
blocks.removeIf(block -> !isOfType.test(block));
|
||||
if(blocks.isEmpty())
|
||||
if(blocks.isEmpty() && !team.isIgnoreWinconditions())
|
||||
win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName());
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -42,6 +42,8 @@ public class WinconditionCaptainDead extends Wincondition implements Listener {
|
||||
return;
|
||||
|
||||
FightTeam team = leader.getTeam();
|
||||
if (team.isIgnoreWinconditions())
|
||||
return;
|
||||
win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + leader.getEntity().getName());
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -40,6 +40,8 @@ public class WinconditionPercent extends Wincondition implements PrintableWincon
|
||||
private final Map<FightTeam, TeamPercent> teamMap = new HashMap<>();
|
||||
|
||||
protected Consumer<FightTeam> checkWin = team -> {
|
||||
if (team.isIgnoreWinconditions())
|
||||
return;
|
||||
if (getPercent(team) >= Config.PercentWin) {
|
||||
win(Fight.getOpposite(team), "WIN_PERCENT", team.getColoredName());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user