forked from SteamWar/SteamWar
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d801e473c | ||
|
|
e17ba8bdcb | ||
|
|
a21760003e | ||
|
|
9ba8a83a3b |
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.data;
|
||||
|
||||
public class SyncCommands {
|
||||
public static final String RELOAD_PLAYER = "reload_player";
|
||||
public static final String RELOAD_EVENT = "reload_event";
|
||||
}
|
||||
@@ -35,8 +35,7 @@ import java.util.stream.Collectors;
|
||||
public class Fight {
|
||||
|
||||
private static final Table<Fight> table = new Table<>(Fight.class);
|
||||
private static final SelectStatement<Fight> getPage = new SelectStatement<>(table, "SELECT f.*, (b.NodeId IS NULL OR b.Config & 2) AND (r.NodeId IS NULL OR r.Config & 2) AS ReplayAllowed FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId ORDER BY FightID DESC LIMIT ?, ?");
|
||||
private static final SelectStatement<Fight> getById = new SelectStatement<>(table, "SELECT f.*, (b.NodeId IS NULL OR b.Config & 2) AND (r.NodeId IS NULL OR r.Config & 2) AS ReplayAllowed FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId WHERE FightId = ?");
|
||||
private static final SelectStatement<Fight> getPage = new SelectStatement<>(table, "SELECT f.*, (b.NodeId IS NULL OR b.AllowReplay) AND (r.NodeId IS NULL OR r.AllowReplay) AS ReplayAllowed FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId ORDER BY FightID DESC LIMIT ?, ?");
|
||||
private static final Statement insert = table.insertFields(true, "GameMode", "Server", "StartTime", "Duration", "BlueLeader", "RedLeader", "BlueSchem", "RedSchem", "Win", "WinCondition");
|
||||
private static final Statement updateReplayAvailable = table.update(Table.PRIMARY, "ReplayAvailable");
|
||||
|
||||
@@ -52,10 +51,6 @@ public class Fight {
|
||||
return fights;
|
||||
}
|
||||
|
||||
public static Fight getById(int fightID) {
|
||||
return getById.select(fightID);
|
||||
}
|
||||
|
||||
public static int create(String gamemode, String server, Timestamp starttime, int duration, int blueleader, int redleader, Integer blueschem, Integer redschem, int win, String wincondition){
|
||||
return insert.insertGetKey(gamemode, server, starttime, duration, blueleader, redleader, blueschem, redschem, win, wincondition);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class NodeData {
|
||||
@Field(keys = {Table.PRIMARY})
|
||||
private final int nodeId;
|
||||
|
||||
@Field(keys = {Table.PRIMARY})
|
||||
@Field
|
||||
private Timestamp createdAt;
|
||||
|
||||
@Field
|
||||
|
||||
@@ -466,6 +466,16 @@ public class SchematicNode {
|
||||
setConfig(ConfigFlags.IS_PREPARED, prepared);
|
||||
}
|
||||
|
||||
public boolean isInvestigation() {
|
||||
return getConfig(ConfigFlags.INVESTIGATION);
|
||||
}
|
||||
|
||||
public void setInvestigation(boolean investigation) {
|
||||
if (isDir())
|
||||
throw new SecurityException("Is Directory");
|
||||
setConfig(ConfigFlags.INVESTIGATION, investigation);
|
||||
}
|
||||
|
||||
public boolean getConfig(ConfigFlags flag) {
|
||||
return (config & (1 << flag.ordinal())) != 0;
|
||||
}
|
||||
@@ -629,6 +639,7 @@ public class SchematicNode {
|
||||
public static enum ConfigFlags {
|
||||
REPLACE_COLOR,
|
||||
ALLOW_REPLAY,
|
||||
IS_PREPARED
|
||||
IS_PREPARED,
|
||||
INVESTIGATION,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,13 +54,13 @@ public enum UserPerm {
|
||||
emptyPrefix = new Prefix("§7", "");
|
||||
p.put(PREFIX_NONE, emptyPrefix);
|
||||
p.put(PREFIX_YOUTUBER, new Prefix("§7", "YT"));
|
||||
p.put(PREFIX_GUIDE, new Prefix("§x§e§7§6§2§e§d", "Guide")); // E762ED
|
||||
p.put(PREFIX_GUIDE, new Prefix("§x§E§5§F§F§8§4", "Guide")); // E5FF84
|
||||
|
||||
p.put(PREFIX_SUPPORTER, new Prefix("§x§6§0§9§5§F§B", "Sup")); // 6095FB
|
||||
p.put(PREFIX_MODERATOR, new Prefix("§x§F§F§A§2§5§C", "Mod")); // FFA25C
|
||||
p.put(PREFIX_BUILDER, new Prefix("§x§6§0§F§F§6§A", "Arch")); // 60FF6A
|
||||
p.put(PREFIX_DEVELOPER, new Prefix("§x§0§B§B§C§B§3", "Dev")); // 0BBCB3
|
||||
p.put(PREFIX_ADMIN, new Prefix("§x§F§F§2§B§2§4", "Admin")); // FF2B24
|
||||
p.put(PREFIX_SUPPORTER, new Prefix("§x§6§0§9§5§F§F", "Sup")); // 6095FF
|
||||
p.put(PREFIX_MODERATOR, new Prefix("§x§F§F§A§2§5§0", "Mod")); // FFA250
|
||||
p.put(PREFIX_BUILDER, new Prefix("§x§6§0§F§F§6§9", "Arch")); // 60FF69
|
||||
p.put(PREFIX_DEVELOPER, new Prefix("§x§0§B§B§C§B§9", "Dev")); // 0BBCB9
|
||||
p.put(PREFIX_ADMIN, new Prefix("§x§F§F§2§B§2§B", "Admin")); // FF2B2B
|
||||
prefixes = Collections.unmodifiableMap(p);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ public class GUI {
|
||||
}).setCustomModelData(CMDs.Schematic.BACK));
|
||||
|
||||
if(node.getOwner() == user.getId()){
|
||||
if(!node.isDir() && node.getSchemtype().writeable()){
|
||||
if(!node.isDir() && node.getSchemtype().writeable() && !node.isInvestigation()){
|
||||
CheckedSchematic.getLastDeclinedOfNode(node.getId()).stream().findFirst().ifPresent(checkedSchematic ->
|
||||
inv.setItem(1, SWItem.getDye(10), (byte) 10, SchematicSystem.MESSAGE.parse("GUI_INFO_STATUS", player, node.getSchemtype().name()), Collections.singletonList(SchematicSystem.MESSAGE.parse("GUI_INFO_STATUS_LORE", player, checkedSchematic.getDeclineReason().replaceAll("&", "§"))), false, click -> {}));
|
||||
}
|
||||
|
||||
+3
-1
@@ -251,7 +251,9 @@ public class SchematicCommandUtils {
|
||||
}
|
||||
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_FORMAT", player, node.getFileEnding());
|
||||
CheckedSchematic.getLastDeclinedOfNode(node.getId()).stream().findFirst().ifPresent(checkedSchematic -> SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_STATUS", player, checkedSchematic.getEndTime(), checkedSchematic.getDeclineReason()));
|
||||
if (!node.isInvestigation()) {
|
||||
CheckedSchematic.getLastDeclinedOfNode(node.getId()).stream().findFirst().ifPresent(checkedSchematic -> SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_STATUS", player, checkedSchematic.getEndTime(), checkedSchematic.getDeclineReason()));
|
||||
}
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_TYPE", player, SchematicSystem.MESSAGE.parse("UTIL_INFO_TYPE_DIR", player));
|
||||
}
|
||||
|
||||
@@ -319,6 +319,7 @@ CHECK_LIST_CHECKING_HOVER=§eTo the reviewer
|
||||
CHECK_SCHEMATIC_ALREADY_CHECKING=§cYou are already reviewing a schematic!
|
||||
CHECK_SCHEMATIC_OWN=§cYou cannot review your own schematics.
|
||||
CHECK_SCHEMATIC_OWN_TEAM=§cYou cannot review your team schematics.
|
||||
CHECK_SCHEMATIC_INVESTIGATION_PENDING=§cThis schematic is currently under investigation
|
||||
CHECK_SCHEMATIC_PREVIOUS=§7{0} from {1}§8: §e{2}
|
||||
CHECK_INVALID_RANK=§cUnknown schematic rank.
|
||||
CHECK_ABORT=§aThe test operation was canceled!
|
||||
@@ -397,7 +398,7 @@ REPLAY_WINNER=§e§l{0} §7+§e{1}
|
||||
REPLAY_SOLO_LOSER=§e{0}
|
||||
REPLAY_LOSER=§e{0} §7+§e{1}
|
||||
REPLAY_TIME=§7{0}
|
||||
REPLAY_SERVER=§7{0} #{1}
|
||||
REPLAY_SERVER=§7{0}
|
||||
|
||||
#TutorialCommand
|
||||
TUTORIAL_TITLE=Tutorials
|
||||
|
||||
@@ -301,6 +301,7 @@ CHECK_LIST_CHECKING_HOVER=§eZum Prüfer
|
||||
CHECK_SCHEMATIC_ALREADY_CHECKING=§cDu prüfst schon eine Schematic!
|
||||
CHECK_SCHEMATIC_OWN=§cDu kannst nicht deine eigenen Schematics prüfen.
|
||||
CHECK_SCHEMATIC_OWN_TEAM=§cDu kannst nicht Schematics deines Teams prüfen.
|
||||
CHECK_SCHEMATIC_INVESTIGATION_PENDING=§cDiese Schematic wird grade untersucht!
|
||||
CHECK_SCHEMATIC_PREVIOUS=§7{0} von {1}§8: §e{2}
|
||||
CHECK_INVALID_RANK=§cUnbekannter Schematicrang.
|
||||
CHECK_ABORT=§aDer Prüfvorgang wurde abgebrochen!
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.velocitycore;
|
||||
|
||||
import de.steamwar.data.SyncCommands;
|
||||
import de.steamwar.sql.Event;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
|
||||
public class BackendSync implements Runnable {
|
||||
private static final Path syncPath = new File("/run/sync").toPath();
|
||||
private final Thread thread;
|
||||
private final WatchService watchService;
|
||||
|
||||
public BackendSync() {
|
||||
try {
|
||||
watchService
|
||||
= FileSystems.getDefault().newWatchService();
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not create watch service", e);
|
||||
}
|
||||
|
||||
|
||||
thread = new Thread(this, "BackendSync");
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
try {
|
||||
watchService.close();
|
||||
thread.join();
|
||||
} catch (IOException | InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCommand(String name) {
|
||||
try {
|
||||
String[] parts = name.split("\\.");
|
||||
|
||||
switch (parts[0]) {
|
||||
case SyncCommands.RELOAD_EVENT -> EventFight.loadAllComingFights();
|
||||
case SyncCommands.RELOAD_PLAYER -> SteamwarUser.invalidate(Integer.parseInt(parts[1]));
|
||||
default -> VelocityCore.getLogger().warning("Unknown command: " + name);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
VelocityCore.getLogger().throwing(this.getClass().getName(), "handleCommand", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
syncPath.register(watchService,
|
||||
java.nio.file.StandardWatchEventKinds.ENTRY_CREATE);
|
||||
|
||||
WatchKey key;
|
||||
while ((key = watchService.take()) != null) {
|
||||
for (WatchEvent<?> event : key.pollEvents()) {
|
||||
String command = event.context().toString();
|
||||
handleCommand(command);
|
||||
|
||||
if (!VelocityCore.get().getConfig().isEventmode()) {
|
||||
Path path = syncPath.resolve((Path) event.context());
|
||||
Files.delete(path);
|
||||
}
|
||||
}
|
||||
key.reset();
|
||||
}
|
||||
} catch (InterruptedException | ClosedWatchServiceException ignored) {
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (Exception e) {
|
||||
VelocityCore.getLogger().throwing(this.getClass().getName(), "run", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,6 @@ public class VelocityCore implements ReloadablePlugin {
|
||||
private Config config;
|
||||
private ErrorLogger errorLogger;
|
||||
private TablistManager tablistManager;
|
||||
private BackendSync backendSync;
|
||||
|
||||
@Getter
|
||||
private TeamCommand teamCommand;
|
||||
@@ -148,8 +147,6 @@ public class VelocityCore implements ReloadablePlugin {
|
||||
new ReplayMod();
|
||||
new FML2();
|
||||
|
||||
backendSync = new BackendSync();
|
||||
|
||||
new ConnectionListener();
|
||||
new ChatListener();
|
||||
new BanListener();
|
||||
@@ -271,8 +268,6 @@ public class VelocityCore implements ReloadablePlugin {
|
||||
logger.log(Level.SEVERE, "Could not shutdown discord bot", e);
|
||||
}
|
||||
|
||||
backendSync.stop();
|
||||
|
||||
if(tablistManager != null)
|
||||
tablistManager.disable();
|
||||
errorLogger.unregister();
|
||||
|
||||
@@ -99,11 +99,13 @@ public class CheckCommand extends SWCommand {
|
||||
for (SchematicNode schematic : schematicList) {
|
||||
CheckSession current = currentSchems.get(schematic.getId());
|
||||
if (current == null) {
|
||||
boolean isInvestigation = schematic.isInvestigation();
|
||||
|
||||
sender.prefixless("CHECK_LIST_TO_CHECK",
|
||||
new Message("CHECK_LIST_TO_CHECK_HOVER"),
|
||||
ClickEvent.runCommand("/check schematic " + schematic.getId()),
|
||||
isInvestigation ? new Message("PLAIN_STRING", CheckedSchematic.getLastDeclinedOfNode(schematic.getId()).stream().map(CheckedSchematic::getDeclineReason).findFirst().orElse("")) : new Message("CHECK_LIST_TO_CHECK_HOVER"),
|
||||
isInvestigation ? ClickEvent.suggestCommand("") : ClickEvent.runCommand("/check schematic " + schematic.getId()),
|
||||
getWaitTime(schematic),
|
||||
schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName());
|
||||
schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), (isInvestigation ? "§c" : "") + schematic.getName());
|
||||
} else {
|
||||
sender.prefixless("CHECK_LIST_CHECKING",
|
||||
new Message("CHECK_LIST_CHECKING_HOVER"),
|
||||
@@ -130,6 +132,10 @@ public class CheckCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if(schem.isInvestigation() && !sender.user().hasPerm(UserPerm.MODERATION)) {
|
||||
sender.system("CHECK_SCHEMATIC_INVESTIGATION_PENDING");
|
||||
}
|
||||
|
||||
int playerTeam = sender.user().hasPerm(UserPerm.MODERATION) ? 0 : sender.user().getTeam();
|
||||
if (playerTeam != 0 && SteamwarUser.get(schem.getOwner()).getTeam() == playerTeam) {
|
||||
sender.system("CHECK_SCHEMATIC_OWN_TEAM");
|
||||
@@ -181,6 +187,22 @@ public class CheckCommand extends SWCommand {
|
||||
currentCheckers.get(sender.getPlayer().getUniqueId()).decline(String.join(" ", message));
|
||||
}
|
||||
|
||||
@Register(value = "block")
|
||||
public void investigate(PlayerChatter sender, String... message) {
|
||||
if(notChecking(sender.getPlayer()))
|
||||
return;
|
||||
|
||||
currentCheckers.get(sender.getPlayer().getUniqueId()).investigate(String.join(" ", message));
|
||||
}
|
||||
|
||||
@Register(value = "unblock")
|
||||
public void uninvestigate(PlayerChatter sender) {
|
||||
if(notChecking(sender.getPlayer()))
|
||||
return;
|
||||
|
||||
currentCheckers.get(sender.getPlayer().getUniqueId()).unblock();
|
||||
}
|
||||
|
||||
public static List<SchematicNode> getSchemsToCheck(){
|
||||
List<SchematicNode> schematicList = new ArrayList<>();
|
||||
|
||||
@@ -223,7 +245,7 @@ public class CheckCommand extends SWCommand {
|
||||
currentCheckers.put(checker.user().getUUID(), this);
|
||||
currentSchems.put(schematic.getId(), this);
|
||||
|
||||
for(CheckedSchematic previous : CheckedSchematic.previousChecks(schematic))
|
||||
for(CheckedSchematic previous : CheckedSchematic.getLastDeclinedOfNode(schematic.getId()))
|
||||
checker.prefixless("CHECK_SCHEMATIC_PREVIOUS", previous.getEndTime(), SteamwarUser.get(previous.getValidator()).getUserName(), previous.getDeclineReason());
|
||||
next();
|
||||
}).start();
|
||||
@@ -309,7 +331,9 @@ public class CheckCommand extends SWCommand {
|
||||
private void concludeCheckSession(String reason, SchematicType type, BooleanSupplier sendMessageIsOnline) {
|
||||
if(SchematicNode.getSchematicNode(schematic.getId()) != null) {
|
||||
CheckedSchematic.create(schematic, checker.user().getId(), startTime, Timestamp.from(Instant.now()), reason, sendMessageIsOnline.getAsBoolean());
|
||||
|
||||
if(type != null) {
|
||||
schematic.setInvestigation(false);
|
||||
schematic.setSchemtype(type);
|
||||
if (type == SchematicType.Normal) {
|
||||
schematic.setPrepared(false);
|
||||
@@ -329,5 +353,15 @@ public class CheckCommand extends SWCommand {
|
||||
currentCheckers.remove(checker.user().getUUID());
|
||||
currentSchems.remove(schematic.getId());
|
||||
}
|
||||
|
||||
public void investigate(String reason) {
|
||||
schematic.setInvestigation(true);
|
||||
concludeCheckSession(reason, null, () -> true);
|
||||
}
|
||||
|
||||
public void unblock() {
|
||||
schematic.setInvestigation(false);
|
||||
CheckedSchematic.create(schematic, checker.user().getId(), startTime, Timestamp.from(Instant.now()), "", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,51 +38,31 @@ public class ReplayCommand extends SWCommand {
|
||||
super("replay");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(PlayerChatter sender, int replayId, @StaticValue(value = {"", "-a"}, allowISE=true) @OptionalValue("") boolean isAdmin, @OptionalValue("") String optionalMap) {
|
||||
Fight fight = Fight.getById(replayId);
|
||||
|
||||
if (fight == null) {
|
||||
sender.system("REPLAY_UNAVAILABLE");
|
||||
return;
|
||||
}
|
||||
|
||||
startReplay(sender, isAdmin, optionalMap, fight);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(PlayerChatter sender, @OptionalValue("") String optionalMap) {
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
return;
|
||||
|
||||
new SWStreamInv<>(sender, new Message("REPLAY_TITLE"), (click, fight) -> {
|
||||
startReplay(sender, click.isShiftClick(), optionalMap, fight);
|
||||
ArenaMode mode = ArenaMode.getBySchemType(fight.getSchemType());
|
||||
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(sender.getPlayer());
|
||||
|
||||
String map = mode.getRandomMap();
|
||||
if (!optionalMap.equals("")) {
|
||||
String tMap = mode.hasMap(optionalMap);
|
||||
if (tMap != null) map = tMap;
|
||||
}
|
||||
|
||||
if (sender.user().hasPerm(UserPerm.MODERATION) && click.isShiftClick() && fight.replayExists()) {
|
||||
starter.test(mode, map, sender.getPlayer()).start();
|
||||
} else if(!fight.replayAllowed()) {
|
||||
sender.system("REPLAY_UNAVAILABLE");
|
||||
} else {
|
||||
starter.arena(mode, map).start();
|
||||
}
|
||||
}, page -> Fight.getPage(page, 45).stream().map(fight -> new SWListInv.SWListEntry<>(getFightItem(fight), fight)).toList()).open();
|
||||
}
|
||||
|
||||
private void startReplay(PlayerChatter sender, boolean isAdmin, String optionalMap, Fight fight) {
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
return;
|
||||
|
||||
ArenaMode mode = ArenaMode.getBySchemType(fight.getSchemType());
|
||||
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(sender.getPlayer());
|
||||
|
||||
String map = mode.getRandomMap();
|
||||
if (!optionalMap.isEmpty()) {
|
||||
String tMap = mode.hasMap(optionalMap);
|
||||
if (tMap != null) map = tMap;
|
||||
}
|
||||
|
||||
if (sender.user().hasPerm(UserPerm.MODERATION) && isAdmin && fight.replayExists()) {
|
||||
System.out.println("Starting admin replay");
|
||||
starter.test(mode, map, sender.getPlayer()).start();
|
||||
} else if(!fight.replayAllowed()) {
|
||||
sender.system("REPLAY_UNAVAILABLE");
|
||||
} else {
|
||||
starter.arena(mode, map).start();
|
||||
}
|
||||
}
|
||||
|
||||
private SWItem getFightItem(Fight fight) {
|
||||
SchematicType type = fight.getSchemType();
|
||||
SWItem item = new SWItem(type != null ? type.getMaterial() : "BARRIER", parseLeader(fight.getBlueLeader(), fight.getBluePlayers().size(), fight.getWin() == 1));
|
||||
@@ -91,7 +71,7 @@ public class ReplayCommand extends SWCommand {
|
||||
lore.add(parseLeader(fight.getRedLeader(), fight.getRedPlayers().size(), fight.getWin() == 2));
|
||||
lore.add(new Message("REPLAY_TIME", fight.getStartTime()));
|
||||
lore.add(new Message("SPACER"));
|
||||
lore.add(new Message("REPLAY_SERVER", fight.getServer(), Integer.toString(fight.getFightID())));
|
||||
lore.add(new Message("REPLAY_SERVER", fight.getServer()));
|
||||
if(!fight.replayAllowed())
|
||||
lore.add(new Message("REPLAY_UNAVAILABLE"));
|
||||
item.setLore(lore);
|
||||
|
||||
@@ -333,7 +333,7 @@ public class TeamCommand extends SWCommand {
|
||||
Team tm = all.get(i);
|
||||
|
||||
sender.prefixless("TEAM_LIST_TEAM", new Message("TEAM_LIST_TEAM_HOVER"),
|
||||
ClickEvent.runCommand("/team info " + tm.getTeamName()), tm.getTeamColor(), tm.getTeamKuerzel(), tm.getTeamName());
|
||||
ClickEvent.runCommand("/team info " + tm.getTeamKuerzel()), tm.getTeamColor(), tm.getTeamKuerzel(), tm.getTeamName());
|
||||
}
|
||||
|
||||
Component beforePage = Component
|
||||
|
||||
@@ -66,7 +66,7 @@ public class WhoisCommand extends SWCommand {
|
||||
|
||||
sender.system("WHOIS_USERNAME", user.getUserName());
|
||||
sender.system("WHOIS_PREFIX", user.prefix().getColorCode() + user.prefix().getChatPrefix());
|
||||
sender.system("WHOIS_TEAM", new Message("WHOIS_TEAM_HOVER", team.getTeamName()), ClickEvent.runCommand("/team info " + team.getTeamName()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName());
|
||||
sender.system("WHOIS_TEAM", new Message("WHOIS_TEAM_HOVER", team.getTeamName()), ClickEvent.runCommand("/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName());
|
||||
|
||||
if (!sender.user().hasPerm(UserPerm.TEAM))
|
||||
return;
|
||||
|
||||
@@ -338,8 +338,7 @@ public class PluginMessage extends BasicListener {
|
||||
"frozenlib:moving_restriction_sound_packet", "frozenlib:remove_entity_screen_shakes_packet",
|
||||
"frozenlib:remove_screen_shakes_packet", "frozenlib:screen_shake_entity_packet",
|
||||
"frozenlib:screen_shake_packet", "frozenlib:spotting_icon_packet", "frozenlib:wind_disturbance_packet",
|
||||
"frozenlib:spotting_icon_remove_packet", "frozenlib:starting_moving_restriction_looping_sound_packet",
|
||||
"imm_ptl:remote_cts" //https://www.curseforge.com/minecraft/mc-mods/immersive-portals-mod
|
||||
"frozenlib:spotting_icon_remove_packet", "frozenlib:starting_moving_restriction_looping_sound_packet"
|
||||
))
|
||||
channelRegisterHandlers.put(channel, player -> {});
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.data
|
||||
|
||||
import de.steamwar.sql.SteamwarUser
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
|
||||
object VelocitySync {
|
||||
private const val SYNC_PATH = "/run/sync"
|
||||
private val SYNC_FILE = File(SYNC_PATH)
|
||||
private val isWindows = System.getProperty("os.name").lowercase().contains("win")
|
||||
private val lastSendMap = mutableMapOf<String, Long>()
|
||||
|
||||
private fun sendCommand(command: String, vararg args: String) {
|
||||
if (isWindows) { return }
|
||||
|
||||
val name = command + if (args.isNotEmpty()) "." + args.joinToString(".") else ""
|
||||
|
||||
if (lastSendMap[name] != null || lastSendMap[name]!! > System.currentTimeMillis() - 1000) {
|
||||
return
|
||||
}
|
||||
|
||||
lastSendMap[name] = System.currentTimeMillis()
|
||||
|
||||
Files.createFile(File(SYNC_FILE, name).toPath())
|
||||
}
|
||||
|
||||
fun reloadEvent() = sendCommand(SyncCommands.RELOAD_EVENT)
|
||||
|
||||
fun reloadPlayer(user: SteamwarUser) = sendCommand(SyncCommands.RELOAD_PLAYER, user.id.toString())
|
||||
}
|
||||
@@ -20,7 +20,6 @@
|
||||
package de.steamwar.routes
|
||||
|
||||
import de.steamwar.ResponseError
|
||||
import de.steamwar.data.VelocitySync
|
||||
import de.steamwar.sql.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.server.application.*
|
||||
@@ -113,7 +112,6 @@ fun Route.configureEventFightRoutes() {
|
||||
if (fight.group != null) {
|
||||
eventFight.setGroup(fight.group)
|
||||
}
|
||||
VelocitySync.reloadEvent()
|
||||
call.respond(HttpStatusCode.Created, ResponseEventFight(eventFight))
|
||||
}
|
||||
route("/{fight}") {
|
||||
@@ -145,13 +143,11 @@ fun Route.configureEventFightRoutes() {
|
||||
}
|
||||
|
||||
fight.update(start, spielmodus, map, teamBlue, teamRed, spectatePort)
|
||||
VelocitySync.reloadEvent()
|
||||
call.respond(HttpStatusCode.OK, ResponseEventFight(fight))
|
||||
}
|
||||
delete {
|
||||
val fight = call.receiveFight() ?: return@delete
|
||||
fight.delete()
|
||||
VelocitySync.reloadEvent()
|
||||
call.respond(HttpStatusCode.OK)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.routes
|
||||
|
||||
import de.steamwar.data.VelocitySync
|
||||
import de.steamwar.plugins.SWPermissionCheck
|
||||
import de.steamwar.plugins.getUser
|
||||
import de.steamwar.sql.SteamwarUser
|
||||
@@ -87,8 +86,6 @@ fun Route.configureUserPerms() {
|
||||
}
|
||||
|
||||
UserPerm.addPerm(user, UserPerm.entries.find { it == prefix }!!)
|
||||
|
||||
VelocitySync.reloadPlayer(user)
|
||||
call.respond(HttpStatusCode.Accepted)
|
||||
}
|
||||
put("/{perm}") {
|
||||
@@ -99,8 +96,6 @@ fun Route.configureUserPerms() {
|
||||
call.respond(HttpStatusCode.Accepted)
|
||||
return@put
|
||||
}
|
||||
|
||||
VelocitySync.reloadPlayer(user)
|
||||
call.respond(HttpStatusCode.NoContent)
|
||||
}
|
||||
delete("/{perm}") {
|
||||
@@ -111,8 +106,6 @@ fun Route.configureUserPerms() {
|
||||
call.respond(HttpStatusCode.Accepted)
|
||||
return@delete
|
||||
}
|
||||
|
||||
VelocitySync.reloadPlayer(user)
|
||||
call.respond(HttpStatusCode.NoContent)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user