forked from SteamWar/SteamWar
Merge branch 'main' into world-system
# Conflicts: # VelocityCore/src/de/steamwar/velocitycore/ServerStarter.java # VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java # VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java
This commit is contained in:
@@ -29,6 +29,7 @@ import java.util.function.Consumer;
|
||||
@Getter
|
||||
public class Bauserver extends Subserver {
|
||||
private static final Map<UUID, Bauserver> servers = new HashMap<>();
|
||||
|
||||
public static Bauserver get(UUID owner) {
|
||||
synchronized (servers) {
|
||||
return servers.get(owner);
|
||||
@@ -37,11 +38,11 @@ public class Bauserver extends Subserver {
|
||||
|
||||
private final UUID owner;
|
||||
|
||||
public Bauserver(String serverName, UUID owner, int port, ProcessBuilder processBuilder, Runnable shutdownCallback){
|
||||
public Bauserver(String serverName, UUID owner, int port, ProcessBuilder processBuilder, Runnable shutdownCallback) {
|
||||
this(serverName, owner, port, processBuilder, shutdownCallback, null);
|
||||
}
|
||||
|
||||
public Bauserver(String serverName, UUID owner, int port, ProcessBuilder processBuilder, Runnable shutdownCallback, Consumer<Exception> failureCallback){
|
||||
public Bauserver(String serverName, UUID owner, int port, ProcessBuilder processBuilder, Runnable shutdownCallback, Consumer<Exception> failureCallback) {
|
||||
super(serverName, port, processBuilder, shutdownCallback, failureCallback);
|
||||
this.owner = owner;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.function.Consumer;
|
||||
public class Builderserver extends Subserver {
|
||||
|
||||
private static final Map<String, Builderserver> servers = new HashMap<>();
|
||||
|
||||
public static Builderserver get(String map) {
|
||||
synchronized (servers) {
|
||||
return servers.get(map);
|
||||
@@ -36,11 +37,12 @@ public class Builderserver extends Subserver {
|
||||
}
|
||||
|
||||
private final String map;
|
||||
public Builderserver(String serverName, String map, int port, ProcessBuilder processBuilder, Runnable shutdownCallback){
|
||||
|
||||
public Builderserver(String serverName, String map, int port, ProcessBuilder processBuilder, Runnable shutdownCallback) {
|
||||
this(serverName, map, port, processBuilder, shutdownCallback, null);
|
||||
}
|
||||
|
||||
public Builderserver(String serverName, String map, int port, ProcessBuilder processBuilder, Runnable shutdownCallback, Consumer<Exception> failureCallback){
|
||||
public Builderserver(String serverName, String map, int port, ProcessBuilder processBuilder, Runnable shutdownCallback, Consumer<Exception> failureCallback) {
|
||||
super(serverName, port, processBuilder, shutdownCallback, failureCallback);
|
||||
this.map = map;
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ public class Persistent {
|
||||
|
||||
broadcast("§eNetwork update is starting§8.");
|
||||
try {
|
||||
if(container != null && plugin != null) {
|
||||
if (container != null && plugin != null) {
|
||||
System.out.println("Proxy Shutdown Event");
|
||||
plugin.onProxyShutdown(new ProxyShutdownEvent());
|
||||
System.out.println("Unloading of Container");
|
||||
@@ -193,28 +193,30 @@ public class Persistent {
|
||||
PluginClassLoader classLoader = ((PluginClassLoader) plugin.getClass().getClassLoader());
|
||||
|
||||
CommandManager commandManager = proxy.getCommandManager();
|
||||
for(String alias : commandManager.getAliases()) {
|
||||
for (String alias : commandManager.getAliases()) {
|
||||
CommandMeta meta = commandManager.getCommandMeta(alias);
|
||||
if(meta != null && meta.getPlugin() == plugin)
|
||||
if (meta != null && meta.getPlugin() == plugin) {
|
||||
commandManager.unregister(meta);
|
||||
}
|
||||
}
|
||||
|
||||
proxy.getEventManager().unregisterListeners(plugin);
|
||||
proxy.getScheduler().tasksByPlugin(plugin).forEach(ScheduledTask::cancel);
|
||||
|
||||
container.getExecutorService().shutdown();
|
||||
if(!container.getExecutorService().awaitTermination(100, TimeUnit.MILLISECONDS))
|
||||
if (!container.getExecutorService().awaitTermination(100, TimeUnit.MILLISECONDS)) {
|
||||
logger.log(Level.WARNING, "ExecutorService termination took longer than 100ms, continuing.");
|
||||
}
|
||||
|
||||
for(Thread thread : Thread.getAllStackTraces().keySet()) {
|
||||
if(thread.getClass().getClassLoader() != classLoader)
|
||||
continue;
|
||||
for (Thread thread : Thread.getAllStackTraces().keySet()) {
|
||||
if (thread.getClass().getClassLoader() != classLoader) continue;
|
||||
|
||||
thread.interrupt();
|
||||
thread.join(100);
|
||||
|
||||
if (thread.isAlive())
|
||||
if (thread.isAlive()) {
|
||||
logger.log(Level.WARNING, "Could not stop thread %s of plugin %s. Still running".formatted(thread.getName(), container.getDescription().getId()));
|
||||
}
|
||||
}
|
||||
|
||||
//TODO close all log handlers
|
||||
|
||||
@@ -24,5 +24,7 @@ import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||
|
||||
public interface ReloadablePlugin {
|
||||
void onProxyInitialization(ProxyInitializeEvent event);
|
||||
default void onProxyShutdown(ProxyShutdownEvent event) {}
|
||||
|
||||
default void onProxyShutdown(ProxyShutdownEvent event) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,7 @@ public class Subserver {
|
||||
public static Subserver getSubserver(Player p) {
|
||||
synchronized (serverList) {
|
||||
for (int i = serverList.size() - 1; i >= 0; i--) {
|
||||
if (serverList.get(i).onServer(p))
|
||||
return serverList.get(i);
|
||||
if (serverList.get(i).onServer(p)) return serverList.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -142,8 +141,9 @@ public class Subserver {
|
||||
public void stop() {
|
||||
try {
|
||||
long pid = process.pid();
|
||||
if (checkpoint)
|
||||
if (checkpoint) {
|
||||
pid = process.children().findAny().map(ProcessHandle::pid).orElse(pid);
|
||||
}
|
||||
|
||||
Runtime.getRuntime().exec(new String[]{"kill", "-SIGUSR1", Long.toString(pid)});
|
||||
} catch (IOException e) {
|
||||
@@ -156,8 +156,7 @@ public class Subserver {
|
||||
process.destroyForcibly();
|
||||
}
|
||||
|
||||
if(thread.isAlive())
|
||||
thread.join();
|
||||
if (thread.isAlive()) thread.join();
|
||||
} catch (InterruptedException e) {
|
||||
logger.log(Level.SEVERE, "Subserver stop interrupted!", e);
|
||||
Thread.currentThread().interrupt();
|
||||
@@ -171,11 +170,13 @@ public class Subserver {
|
||||
private void fatalError(Exception e) {
|
||||
logger.log(Level.SEVERE, e, () -> serverName + " did not run correctly!");
|
||||
|
||||
for (Player cached : cachedPlayers)
|
||||
for (Player cached : cachedPlayers) {
|
||||
cached.sendMessage(PREFIX.append(Component.text("Unexpected error during server startup.").color(NamedTextColor.RED)));
|
||||
}
|
||||
if (registeredServer != null) {
|
||||
for (Player player : registeredServer.getPlayersConnected())
|
||||
for (Player player : registeredServer.getPlayersConnected()) {
|
||||
player.sendMessage(PREFIX.append(Component.text("Lost connection to server.").color(NamedTextColor.RED)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,8 +187,9 @@ public class Subserver {
|
||||
started = test.test(line);
|
||||
}
|
||||
|
||||
if (line == null)
|
||||
if (line == null) {
|
||||
throw new IOException(serverName + " did not start correctly!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,18 +227,18 @@ public class Subserver {
|
||||
} else {
|
||||
sendProgress(0);
|
||||
start(process.getInputStream(), line -> {
|
||||
if (line.contains("Loading libraries, please wait"))
|
||||
if (line.contains("Loading libraries, please wait")) {
|
||||
sendProgress(2);
|
||||
else if (line.contains("Starting Minecraft server on"))
|
||||
} else if (line.contains("Starting Minecraft server on")) {
|
||||
sendProgress(5);
|
||||
else if (line.contains("Preparing start region"))
|
||||
} else if (line.contains("Preparing start region")) {
|
||||
sendProgress(8);
|
||||
}
|
||||
return line.contains("Done (");
|
||||
});
|
||||
}
|
||||
|
||||
if (!started)
|
||||
return;
|
||||
if (!started) return;
|
||||
|
||||
sendProgress(10);
|
||||
for (Player cachedPlayer : cachedPlayers) {
|
||||
@@ -253,8 +255,7 @@ public class Subserver {
|
||||
} finally {
|
||||
unregister();
|
||||
shutdownCallback.run();
|
||||
if (ex != null)
|
||||
failureCallback.accept(ex);
|
||||
if (ex != null) failureCallback.accept(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +266,8 @@ public class Subserver {
|
||||
|
||||
private void sendProgress(int progress) {
|
||||
Component tc = generateBar(progress);
|
||||
for (Player cached : cachedPlayers)
|
||||
for (Player cached : cachedPlayers) {
|
||||
cached.sendActionBar(tc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
# SteamWar GDPR report
|
||||
|
||||
## Copyright notice
|
||||
|
||||
The provided build worlds contain the world design of SteamWar contributors and is subject to their copyright.
|
||||
The build worlds are therefore provided for personal use only.
|
||||
|
||||
## Categories of personal data processed
|
||||
|
||||
- IP address
|
||||
- Minecraft account
|
||||
- E-Mail address (if using a website account)
|
||||
|
||||
## Processing purposes of personal data and person-related data
|
||||
- Provision of SteamWar user functionality (Minecraft account, IP address, BuildWorlds, BuildInventories, BuildMembers, Elo, IgnoredPlayers, SchematicMembers, SchematicChecksessions, Schematics, PersonalKits, UserData, UserConfigs)
|
||||
|
||||
- Provision of SteamWar user functionality (Minecraft account, IP address, BuildWorlds, BuildInventories, BuildMembers,
|
||||
Elo, IgnoredPlayers, SchematicMembers, SchematicChecksessions, Schematics, PersonalKits, UserData, UserConfigs)
|
||||
- Manual analysis and punishment of player misbehaviour (BannedIPs, log files, Punishments)
|
||||
- Statistical analysis (Sessions, Fights, SchematicChecksessions)
|
||||
- Historical data storage (Fights)
|
||||
@@ -18,12 +22,14 @@ The build worlds are therefore provided for personal use only.
|
||||
- Provision of the SteamWar website functionality (IP address, E-Mail address)
|
||||
|
||||
## Data Accessors
|
||||
|
||||
- SteamWar software
|
||||
- SteamWar Administration
|
||||
- SteamWar Development
|
||||
- SteamWar Moderation (limited to Punishments and SchematicChecksessions)
|
||||
|
||||
## Storage duration
|
||||
|
||||
- Data for provision of functionality is stored until user triggered deletion
|
||||
- Log file storage duration is targeted at one month, but might differ due to technical reasons
|
||||
- Historical and statistical data deletion is not intended
|
||||
|
||||
@@ -84,8 +84,7 @@ public class SWCommand extends AbstractSWCommand<Chatter> {
|
||||
@Override
|
||||
public List<String> suggest(Invocation invocation) {
|
||||
String[] args = invocation.arguments();
|
||||
if(args.length == 0)
|
||||
args = new String[]{""};
|
||||
if (args.length == 0) args = new String[]{""};
|
||||
|
||||
return SWCommand.this.tabComplete(Chatter.of(invocation.source()), invocation.alias(), args);
|
||||
}
|
||||
@@ -99,8 +98,7 @@ public class SWCommand extends AbstractSWCommand<Chatter> {
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
if (command == null)
|
||||
return;
|
||||
if (command == null) return;
|
||||
|
||||
VelocityCore.getProxy().getCommandManager().unregister(name);
|
||||
DiscordBot.getCommands().remove(name);
|
||||
@@ -108,8 +106,7 @@ public class SWCommand extends AbstractSWCommand<Chatter> {
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
if (command == null)
|
||||
return;
|
||||
if (command == null) return;
|
||||
|
||||
VelocityCore.getProxy().getCommandManager().register(VelocityCore.getProxy().getCommandManager().metaBuilder(name).aliases(aliases).plugin(VelocityCore.get()).build(), command);
|
||||
DiscordBot.getCommands().put(name, this);
|
||||
@@ -163,7 +160,8 @@ public class SWCommand extends AbstractSWCommand<Chatter> {
|
||||
}
|
||||
if (args.length == 0 || atomicInteger.get() == commandList.size()) {
|
||||
commandList.forEach(subCommand -> {
|
||||
if (subCommand.validator == null || subCommand.validator.validate(sender, sender, (s, args1) -> {})) {
|
||||
if (subCommand.validator == null || subCommand.validator.validate(sender, sender, (s, args1) -> {
|
||||
})) {
|
||||
send(sender, subCommand);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -21,12 +21,12 @@ package de.steamwar.command;
|
||||
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.velocitycore.ServerVersion;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.commands.TypeMappers;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.velocitycore.ServerVersion;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.commands.TypeMappers;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -21,4 +21,5 @@ package de.steamwar.command;
|
||||
|
||||
import de.steamwar.messages.Chatter;
|
||||
|
||||
public interface TypeValidator<T> extends AbstractValidator<Chatter, T> {}
|
||||
public interface TypeValidator<T> extends AbstractValidator<Chatter, T> {
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -77,27 +77,34 @@ public interface Chatter {
|
||||
SteamwarUser user();
|
||||
|
||||
Locale getLocale();
|
||||
|
||||
boolean chatShown();
|
||||
|
||||
void sendMessage(Component msg);
|
||||
|
||||
Player getPlayer();
|
||||
|
||||
default <T> T withPlayerOrOffline(Function<Player, T> withPlayer, Supplier<T> withOffline) {
|
||||
Player player = getPlayer();
|
||||
if(player == null)
|
||||
if (player == null) {
|
||||
return withOffline.get();
|
||||
else
|
||||
} else {
|
||||
return withPlayer.apply(player);
|
||||
}
|
||||
}
|
||||
|
||||
default void withPlayerOrOffline(Consumer<Player> withPlayer, Runnable withOffline) {
|
||||
Player player = getPlayer();
|
||||
if(player == null) {
|
||||
if (player == null) {
|
||||
withOffline.run();
|
||||
} else {
|
||||
withPlayer.accept(player);
|
||||
}
|
||||
}
|
||||
|
||||
default void withPlayer(Consumer<Player> function) {
|
||||
withPlayerOrOffline(function, () -> {});
|
||||
withPlayerOrOffline(function, () -> {
|
||||
});
|
||||
}
|
||||
|
||||
default void system(String format, Object... params) {
|
||||
@@ -122,10 +129,12 @@ public interface Chatter {
|
||||
|
||||
default void send(boolean prefixed, Message onHover, ClickEvent onClick, Message message) {
|
||||
Component msg = parse(prefixed, message);
|
||||
if(onHover != null)
|
||||
if (onHover != null) {
|
||||
msg = msg.hoverEvent(HoverEvent.showText(parse(false, onHover)));
|
||||
if(onClick != null)
|
||||
}
|
||||
if (onClick != null) {
|
||||
msg = msg.clickEvent(onClick);
|
||||
}
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
@@ -161,24 +170,25 @@ public interface Chatter {
|
||||
Locale locale = getLocale();
|
||||
ResourceBundle resourceBundle = SteamwarResourceBundle.getResourceBundle(locale);
|
||||
String pattern = "";
|
||||
if(prefixed)
|
||||
if (prefixed) {
|
||||
pattern = resourceBundle.getObject("PREFIX") + " ";
|
||||
pattern += (String)resourceBundle.getObject(message.format());
|
||||
}
|
||||
pattern += (String) resourceBundle.getObject(message.format());
|
||||
|
||||
MessageFormat format = new MessageFormat(pattern, locale);
|
||||
Object[] params = message.params();
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
if(params[i] instanceof Message msg) {
|
||||
if (params[i] instanceof Message msg) {
|
||||
params[i] = parseToLegacy(msg);
|
||||
} else if(params[i] instanceof Date date) {
|
||||
} else if (params[i] instanceof Date date) {
|
||||
params[i] = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale).format(date);
|
||||
} else if(params[i] instanceof SteamwarUser user) {
|
||||
} else if (params[i] instanceof SteamwarUser user) {
|
||||
params[i] = user.getUserName();
|
||||
} else if(params[i] instanceof Player player) {
|
||||
} else if (params[i] instanceof Player player) {
|
||||
params[i] = player.getUsername();
|
||||
} else if(params[i] instanceof Chatter chatter) {
|
||||
} else if (params[i] instanceof Chatter chatter) {
|
||||
params[i] = chatter.user().getUserName();
|
||||
} else if(params[i] instanceof Function func) {
|
||||
} else if (params[i] instanceof Function func) {
|
||||
params[i] = func.apply(this);
|
||||
}
|
||||
}
|
||||
@@ -194,8 +204,7 @@ public interface Chatter {
|
||||
}
|
||||
|
||||
static Chatter of(CommandSource sender) {
|
||||
if(sender instanceof Player player)
|
||||
return of(player);
|
||||
if (sender instanceof Player player) return of(player);
|
||||
|
||||
//Console
|
||||
return new PlayerlessChatter() {
|
||||
@@ -226,8 +235,7 @@ public interface Chatter {
|
||||
|
||||
static Chatter of(UUID uuid, boolean playerlessChatShown) {
|
||||
Player player = VelocityCore.getProxy().getPlayer(uuid).orElse(null);
|
||||
if(player != null)
|
||||
return Chatter.of(player);
|
||||
if (player != null) return Chatter.of(player);
|
||||
|
||||
return new PlayerlessChatter() {
|
||||
@Override
|
||||
|
||||
@@ -47,8 +47,9 @@ public class ChatterGroup extends Chatter.PlayerlessChatter {
|
||||
|
||||
@Override
|
||||
public void send(boolean prefixed, Message onHover, ClickEvent onClick, Message message) {
|
||||
for(Chatter sender : chatters)
|
||||
for (Chatter sender : chatters) {
|
||||
sender.send(prefixed, onHover, onClick, message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,4 +19,5 @@
|
||||
|
||||
package de.steamwar.messages;
|
||||
|
||||
public record Message(String format, Object... params) { }
|
||||
public record Message(String format, Object... params) {
|
||||
}
|
||||
@@ -46,8 +46,7 @@ public class PlayerChatter implements Chatter {
|
||||
|
||||
@Override
|
||||
public boolean chatShown() {
|
||||
if(!player.hasSentPlayerSettings())
|
||||
return false;
|
||||
if (!player.hasSentPlayerSettings()) return false;
|
||||
|
||||
return player.getPlayerSettings().getChatMode() == PlayerSettings.ChatMode.SHOWN;
|
||||
}
|
||||
|
||||
@@ -30,14 +30,13 @@ public class SteamwarResourceBundle extends PropertyResourceBundle {
|
||||
private static final Map<String, ResourceBundle> bundles = new HashMap<>();
|
||||
|
||||
public static ResourceBundle getResourceBundle(Locale locale) {
|
||||
return getResourceBundle(locale.toString(), getResourceBundle(locale.getLanguage(), getResourceBundle( "", null)));
|
||||
return getResourceBundle(locale.toString(), getResourceBundle(locale.getLanguage(), getResourceBundle("", null)));
|
||||
}
|
||||
|
||||
private static synchronized ResourceBundle getResourceBundle(String locale, ResourceBundle parent) {
|
||||
return bundles.computeIfAbsent(locale, locale1 -> {
|
||||
InputStream inputStream = Message.class.getResourceAsStream(BASE_PATH + ("".equals(locale) ? "" : "_" + locale) + ".properties");
|
||||
if(inputStream == null)
|
||||
return parent;
|
||||
if (inputStream == null) return parent;
|
||||
try {
|
||||
return new SteamwarResourceBundle(inputStream, parent);
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package de.steamwar.sql;
|
||||
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.sql.internal.SQLConfig;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ public class SQLWrapperImpl implements SQLWrapper<String> {
|
||||
@Override
|
||||
public void additionalExceptionMetadata(StringBuilder builder) {
|
||||
builder.append("\nServers: ");
|
||||
for(RegisteredServer server : VelocityCore.getProxy().getAllServers()) {
|
||||
for (RegisteredServer server : VelocityCore.getProxy().getAllServers()) {
|
||||
builder.append(server.getServerInfo().getName()).append("(");
|
||||
for(Player player : server.getPlayersConnected()) {
|
||||
for (Player player : server.getPlayersConnected()) {
|
||||
builder.append(player.getUsername()).append(" ");
|
||||
}
|
||||
builder.append(") ");
|
||||
|
||||
@@ -50,8 +50,7 @@ public class ArenaMode {
|
||||
allModes.clear();
|
||||
|
||||
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||
if(!folder.exists())
|
||||
return;
|
||||
if (!folder.exists()) return;
|
||||
|
||||
GameModeConfig.init();
|
||||
SchematicType.init();
|
||||
@@ -71,24 +70,25 @@ public class ArenaMode {
|
||||
}
|
||||
}
|
||||
|
||||
public static GameModeConfig<String, String> getByChat(String name){
|
||||
public static GameModeConfig<String, String> getByChat(String name) {
|
||||
return byChat.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
public static GameModeConfig<String, String> getByInternal(String name){
|
||||
public static GameModeConfig<String, String> getByInternal(String name) {
|
||||
return byInternal.get(name);
|
||||
}
|
||||
|
||||
public static List<String> getAllChatNames(boolean historic) {
|
||||
List<String> chatNames = new LinkedList<>();
|
||||
for(GameModeConfig<String, String> mode : byInternal.values()){
|
||||
if(mode.isActive() && historic == mode.Server.Historic)
|
||||
for (GameModeConfig<String, String> mode : byInternal.values()) {
|
||||
if (mode.isActive() && historic == mode.Server.Historic) {
|
||||
chatNames.addAll(mode.Server.ChatNames);
|
||||
}
|
||||
}
|
||||
return chatNames;
|
||||
}
|
||||
|
||||
public static GameModeConfig<String, String> getBySchemType(SchematicType schemType){
|
||||
public static GameModeConfig<String, String> getBySchemType(SchematicType schemType) {
|
||||
return bySchemType.get(schemType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,15 +34,16 @@ public class Broadcaster {
|
||||
private int lastBroadCast = 0;
|
||||
|
||||
public Broadcaster() {
|
||||
if(!broadcasts.isEmpty())
|
||||
if (!broadcasts.isEmpty()) {
|
||||
VelocityCore.schedule(this::broadcast).repeat(10, TimeUnit.MINUTES).schedule();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcast() {
|
||||
if(!VelocityCore.getProxy().getAllPlayers().isEmpty())
|
||||
if (!VelocityCore.getProxy().getAllPlayers().isEmpty()) {
|
||||
Chatter.broadcast().system("PLAIN_STRING", broadcasts.get(lastBroadCast++));
|
||||
}
|
||||
|
||||
if(lastBroadCast == broadcasts.size())
|
||||
lastBroadCast = 0;
|
||||
if (lastBroadCast == broadcasts.size()) lastBroadCast = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ public class Config {
|
||||
Yaml yaml = new Yaml(constructor, representer);
|
||||
yaml.setBeanAccess(BeanAccess.FIELD);
|
||||
|
||||
try{
|
||||
try {
|
||||
return yaml.load(new FileInputStream(file));
|
||||
}catch(IOException e){
|
||||
} catch (IOException e) {
|
||||
VelocityCore.getProxy().shutdown();
|
||||
throw new SecurityException("Could not load config", e);
|
||||
}
|
||||
|
||||
@@ -53,21 +53,20 @@ public class ErrorLogger extends AbstractAppender {
|
||||
|
||||
@Override
|
||||
public void append(LogEvent event) {
|
||||
if(event.getLevel().intLevel() > Level.WARN.intLevel())
|
||||
return;
|
||||
if (event.getLevel().intLevel() > Level.WARN.intLevel()) return;
|
||||
|
||||
String message = event.getMessage().getFormattedMessage();
|
||||
for(String reason : filteredMessages)
|
||||
if(message.contains(reason))
|
||||
return;
|
||||
for (String reason : filteredMessages) {
|
||||
if (message.contains(reason)) return;
|
||||
}
|
||||
|
||||
ByteArrayOutputStream stacktraceOutput = new ByteArrayOutputStream();
|
||||
if(event.getThrown() != null)
|
||||
if (event.getThrown() != null)
|
||||
event.getThrown().printStackTrace(new PrintStream(stacktraceOutput));
|
||||
String stacktrace = stacktraceOutput.toString();
|
||||
for(String reason : filteredStacktraces)
|
||||
if (stacktrace.contains(reason))
|
||||
return;
|
||||
for (String reason : filteredStacktraces) {
|
||||
if (stacktrace.contains(reason)) return;
|
||||
}
|
||||
|
||||
SWException.log(message, stacktrace);
|
||||
}
|
||||
|
||||
@@ -63,13 +63,13 @@ public class EventStarter {
|
||||
Queue<EventFight> fights = EventFight.getFights();
|
||||
|
||||
EventFight next;
|
||||
while((next = nextFight(fights)) != null){
|
||||
while ((next = nextFight(fights)) != null) {
|
||||
Team blue = Team.byId(next.getTeamBlue());
|
||||
Team red = Team.byId(next.getTeamRed());
|
||||
|
||||
//Don't start EventServer if not the event bungee
|
||||
String command;
|
||||
if(VelocityCore.get().getConfig().isEventmode() || next.getSpectatePort() == null) {
|
||||
if (VelocityCore.get().getConfig().isEventmode() || next.getSpectatePort() == null) {
|
||||
ServerStarter starter = new ServerStarter().event(next);
|
||||
|
||||
starter.callback(subserver -> {
|
||||
@@ -95,13 +95,11 @@ public class EventStarter {
|
||||
EventFight.clearActiveFightsCache();
|
||||
}
|
||||
|
||||
private EventFight nextFight(Queue<EventFight> fights){
|
||||
private EventFight nextFight(Queue<EventFight> fights) {
|
||||
EventFight next = fights.peek();
|
||||
if(next == null)
|
||||
return null;
|
||||
if (next == null) return null;
|
||||
|
||||
if(!next.getStartTime().before(new Timestamp(System.currentTimeMillis())))
|
||||
return null;
|
||||
if (!next.getStartTime().before(new Timestamp(System.currentTimeMillis()))) return null;
|
||||
|
||||
return fights.poll();
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ public abstract class Node {
|
||||
"-XX:+EnableDynamicAgentLoading", "-Dlog4j.configurationFile=log4j2.xml"
|
||||
);
|
||||
private static final Set<String> JAVA_8 = new HashSet<>();
|
||||
|
||||
static {
|
||||
JAVA_8.add("paper-1.8.8.jar");
|
||||
JAVA_8.add("paper-1.10.2.jar");
|
||||
@@ -52,9 +53,8 @@ public abstract class Node {
|
||||
private static final List<Node> nodes = new ArrayList<>();
|
||||
|
||||
public static Node getNode() {
|
||||
for(Node node : nodes) {
|
||||
if(node.belowLoadLimit)
|
||||
return node;
|
||||
for (Node node : nodes) {
|
||||
if (node.belowLoadLimit) return node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -66,6 +66,7 @@ public abstract class Node {
|
||||
public abstract ProcessBuilder startServer(String serverJar, File directory, String worldDir, String levelName, int port, String... dParams);
|
||||
|
||||
protected abstract ProcessBuilder prepareExecution(String... command);
|
||||
|
||||
protected abstract void calcLoadLimit();
|
||||
|
||||
protected final String hostname;
|
||||
@@ -91,17 +92,19 @@ public abstract class Node {
|
||||
public boolean belowLoadLimit() {
|
||||
return belowLoadLimit;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
protected void constructServerstart(File directory, List<String> cmd, String serverJar, String worldDir, String levelName, int port, String... dParams) {
|
||||
if (JAVA_8.contains(serverJar))
|
||||
if (JAVA_8.contains(serverJar)) {
|
||||
cmd.add("/usr/lib/jvm/openj9-8/bin/java");
|
||||
else
|
||||
} else {
|
||||
cmd.add("/usr/lib/jvm/openj9-21/bin/java");
|
||||
}
|
||||
|
||||
for(String param : dParams){
|
||||
for (String param : dParams) {
|
||||
cmd.add("-D" + param);
|
||||
}
|
||||
cmd.add("-Xshareclasses:nonfatal,name=" + directory.getName());
|
||||
@@ -126,7 +129,7 @@ public abstract class Node {
|
||||
|
||||
protected void calcLoadLimit(BufferedReader meminfo) throws IOException {
|
||||
String line = meminfo.readLine();
|
||||
while(!line.startsWith("MemAvailable")) {
|
||||
while (!line.startsWith("MemAvailable")) {
|
||||
line = meminfo.readLine();
|
||||
}
|
||||
|
||||
@@ -200,14 +203,16 @@ public abstract class Node {
|
||||
protected void calcLoadLimit() {
|
||||
try {
|
||||
Process process = prepareExecution("cat /proc/meminfo").start();
|
||||
if(!process.waitFor(1, TimeUnit.SECONDS))
|
||||
if (!process.waitFor(1, TimeUnit.SECONDS)) {
|
||||
throw new IOException(hostname + " timeout");
|
||||
}
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
|
||||
calcLoadLimit(reader);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if(belowLoadLimit)
|
||||
if (belowLoadLimit) {
|
||||
VelocityCore.getLogger().log(Level.SEVERE, "Could read remote load", e);
|
||||
}
|
||||
belowLoadLimit = false;
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
|
||||
@@ -22,7 +22,6 @@ package de.steamwar.velocitycore;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.velocity.platform.VelocityViaConfig;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.persistent.Arenaserver;
|
||||
import de.steamwar.persistent.Bauserver;
|
||||
@@ -50,7 +49,7 @@ public class ServerStarter {
|
||||
|
||||
private static final String TMP_DATA = System.getProperty("user.home") + "/";
|
||||
private static final String EVENT_PATH = TMP_DATA + "event/";
|
||||
public static final String TEMP_WORLD_PATH = TMP_DATA + "arenaserver/";
|
||||
public static final String TEMP_WORLD_PATH = TMP_DATA + "arenaserver/";
|
||||
|
||||
public static final String WORLDS_BASE_PATH = SteamwarWorld.WORLD_STORAGE + "/";
|
||||
public static final String LEGACY_WORLDS_BASE_PATH = "/worlds/userworlds";
|
||||
@@ -64,15 +63,18 @@ public class ServerStarter {
|
||||
private Portrange portrange = BAU_PORTS;
|
||||
private Function<Integer, String> serverNameProvider = port -> node.getName() + port;
|
||||
private BooleanSupplier startCondition = () -> true;
|
||||
private Runnable worldSetup = () -> {};
|
||||
private Runnable worldSetup = () -> {
|
||||
};
|
||||
private String worldName = null;
|
||||
private Runnable worldCleanup = () -> {};
|
||||
private Runnable worldCleanup = () -> {
|
||||
};
|
||||
private boolean allowMerge = false;
|
||||
private String fightMap = null;
|
||||
private String gameMode = null;
|
||||
private boolean checkpoint = false;
|
||||
private ServerConstructor constructor = (serverName, port, builder, shutdownCallback, failureCallback) -> new Arenaserver(serverName, gameMode, fightMap, allowMerge, port, builder, shutdownCallback);
|
||||
private Consumer<Subserver> callback = subserver -> {};
|
||||
private Consumer<Subserver> callback = subserver -> {
|
||||
};
|
||||
private Object responsible = new Object();
|
||||
|
||||
private final Set<Player> playersToSend = new HashSet<>();
|
||||
@@ -89,7 +91,7 @@ public class ServerStarter {
|
||||
arguments.put("config", mode.configFile.getName());
|
||||
tempWorld(SERVER_PATH + mode.Server.Folder + "/arenas/" + map);
|
||||
startCondition = () -> {
|
||||
if(playersToSend.stream().anyMatch(player -> Subserver.isArena(Subserver.getSubserver(player)))) {
|
||||
if (playersToSend.stream().anyMatch(player -> Subserver.isArena(Subserver.getSubserver(player)))) {
|
||||
playersToSend.forEach(player -> Chatter.of(player).system("FIGHT_IN_ARENA"));
|
||||
return false;
|
||||
}
|
||||
@@ -103,7 +105,8 @@ public class ServerStarter {
|
||||
arena(ArenaMode.getByInternal(eventFight.getSpielmodus()), eventFight.getMap());
|
||||
node = VelocityCore.local;
|
||||
worldDir = EVENT_PATH;
|
||||
worldCleanup = () -> {};
|
||||
worldCleanup = () -> {
|
||||
};
|
||||
arguments.put("fightID", String.valueOf(eventFight.getFightID()));
|
||||
fightMap = eventFight.getMap();
|
||||
gameMode = eventFight.getSpielmodus();
|
||||
@@ -163,9 +166,10 @@ public class ServerStarter {
|
||||
// Send players to existing server
|
||||
startCondition = () -> {
|
||||
Bauserver subserver = Bauserver.get(owner);
|
||||
if(subserver != null) {
|
||||
for(Player p : playersToSend)
|
||||
if (subserver != null) {
|
||||
for (Player p : playersToSend) {
|
||||
SubserverSystem.sendPlayer(subserver, p);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
boolean atLeastOneSupervisor = playersToSend.stream().anyMatch(player -> {
|
||||
@@ -195,12 +199,10 @@ public class ServerStarter {
|
||||
|
||||
// Stop existing build server
|
||||
startCondition = () -> {
|
||||
if(startingBau(owner))
|
||||
return false;
|
||||
if (startingBau(owner)) return false;
|
||||
|
||||
Bauserver subserver = Bauserver.get(owner.getUniqueId());
|
||||
if(subserver != null && subserver.isStarted())
|
||||
subserver.stop();
|
||||
if (subserver != null && subserver.isStarted()) subserver.stop();
|
||||
|
||||
return !startingBau(owner);
|
||||
};
|
||||
@@ -225,14 +227,15 @@ public class ServerStarter {
|
||||
startCondition = () -> {
|
||||
Builderserver subserver = Builderserver.get(worldName);
|
||||
if (subserver != null) {
|
||||
for(Player p : playersToSend)
|
||||
for (Player p : playersToSend) {
|
||||
SubserverSystem.sendPlayer(subserver, p);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
if(generator != null) {
|
||||
if (generator != null) {
|
||||
worldSetup = () -> {
|
||||
File leveldat = new File(world.setupAndGetStoragePath(), "level.dat");
|
||||
try {
|
||||
@@ -251,8 +254,9 @@ public class ServerStarter {
|
||||
public ServerStarter send(Player player) {
|
||||
playersToSend.add(player);
|
||||
|
||||
if(!(responsible instanceof Player))
|
||||
if (!(responsible instanceof Player)) {
|
||||
responsible = player;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -265,35 +269,37 @@ public class ServerStarter {
|
||||
public void start() {
|
||||
VelocityCore.schedule(() -> {
|
||||
synchronized (responsible) {
|
||||
if(!startCondition.getAsBoolean())
|
||||
return;
|
||||
if (!startCondition.getAsBoolean()) return;
|
||||
|
||||
int port = portrange.freePort();
|
||||
String serverName = serverNameProvider.apply(port);
|
||||
arguments.put("serverName", serverName);
|
||||
|
||||
if(node == null) {
|
||||
if (node == null) {
|
||||
node = Node.getNode();
|
||||
if(node == null) {
|
||||
for (Player p : playersToSend)
|
||||
if (node == null) {
|
||||
for (Player p : playersToSend) {
|
||||
Chatter.of(p).system("SERVER_START_OVERLOAD");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(worldName == null)
|
||||
if (worldName == null) {
|
||||
worldName = serverToWorldName(serverName);
|
||||
}
|
||||
|
||||
worldSetup.run();
|
||||
arguments.put("logPath", worldName);
|
||||
|
||||
File checkpointDir = new File("/tmp/" + System.getProperty("user.name") + ".checkpoints/" + directory.getName() + "/" + worldName);
|
||||
if(checkpoint)
|
||||
if (checkpoint) {
|
||||
arguments.put("checkpoint", checkpointDir.getPath());
|
||||
}
|
||||
|
||||
((VelocityViaConfig) Via.getConfig()).getVelocityServerProtocols().put(serverName, version.getProtocolVersion().getProtocol());
|
||||
if(checkpoint && checkpointDir.exists()) {
|
||||
try(DataOutputStream out = new DataOutputStream(Files.newOutputStream(new File(checkpointDir, "port").toPath()))) {
|
||||
if (checkpoint && checkpointDir.exists()) {
|
||||
try (DataOutputStream out = new DataOutputStream(Files.newOutputStream(new File(checkpointDir, "port").toPath()))) {
|
||||
out.writeInt(port);
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException(e);
|
||||
@@ -316,15 +322,16 @@ public class ServerStarter {
|
||||
}
|
||||
|
||||
private void postStart(Subserver subserver) {
|
||||
for(Player p : playersToSend)
|
||||
for (Player p : playersToSend) {
|
||||
SubserverSystem.sendPlayer(subserver, p);
|
||||
}
|
||||
|
||||
callback.accept(subserver);
|
||||
}
|
||||
|
||||
private static boolean startingBau(Player p) {
|
||||
Bauserver subserver = Bauserver.get(p.getUniqueId());
|
||||
if(subserver != null && !subserver.isStarted()) {
|
||||
if (subserver != null && !subserver.isStarted()) {
|
||||
Chatter.of(p).system("BAU_START_ALREADY");
|
||||
return true;
|
||||
}
|
||||
@@ -377,9 +384,7 @@ public class ServerStarter {
|
||||
|
||||
private void increment() {
|
||||
current++;
|
||||
|
||||
if(current == end)
|
||||
current = start;
|
||||
if (current == end) current = start;
|
||||
}
|
||||
|
||||
private synchronized int freePort() {
|
||||
@@ -389,7 +394,7 @@ public class ServerStarter {
|
||||
usedPorts = Subserver.getServerList().stream().map(server -> server.getServer().getAddress().getPort()).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
while(usedPorts.contains(current)) {
|
||||
while (usedPorts.contains(current)) {
|
||||
increment();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ package de.steamwar.velocitycore;
|
||||
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -93,8 +92,9 @@ public enum ServerVersion {
|
||||
private static final Map<Integer, ServerVersion> versionMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
for(ServerVersion version : values())
|
||||
for (ServerVersion version : values()) {
|
||||
versionMap.put(version.getVersionSuffix(), version);
|
||||
}
|
||||
}
|
||||
|
||||
public static ServerVersion get(int version) {
|
||||
|
||||
@@ -20,27 +20,28 @@
|
||||
package de.steamwar.velocitycore;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.velocitycore.network.NetworkSender;
|
||||
import de.steamwar.velocitycore.network.handlers.FightInfoHandler;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.Message;
|
||||
import de.steamwar.network.packets.server.StartingServerPacket;
|
||||
import de.steamwar.persistent.Subserver;
|
||||
import de.steamwar.sql.IgnoreSystem;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.velocitycore.network.NetworkSender;
|
||||
import de.steamwar.velocitycore.network.handlers.FightInfoHandler;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SubserverSystem {
|
||||
private SubserverSystem(){}
|
||||
private SubserverSystem() {
|
||||
}
|
||||
|
||||
public static void deleteFolder(Node node, String worldName) {
|
||||
node.execute("rm", "-r", worldName);
|
||||
}
|
||||
|
||||
public static void sendDeniedMessage(Chatter p, UUID owner) {
|
||||
if(IgnoreSystem.isIgnored(owner, p.user().getUUID())){
|
||||
if (IgnoreSystem.isIgnored(owner, p.user().getUUID())) {
|
||||
p.system("SERVER_IGNORED");
|
||||
return;
|
||||
}
|
||||
@@ -52,7 +53,8 @@ public class SubserverSystem {
|
||||
|
||||
public static void sendPlayer(Subserver subserver, Player player) {
|
||||
subserver.sendPlayer(player);
|
||||
if(!subserver.isStarted() && FightInfoHandler.onLobby(player))
|
||||
if (!subserver.isStarted() && FightInfoHandler.onLobby(player)) {
|
||||
NetworkSender.send(player, new StartingServerPacket(SteamwarUser.get(player.getUniqueId()).getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,13 +62,14 @@ import java.util.logging.Logger;
|
||||
@Plugin(
|
||||
id = "velocitycore",
|
||||
name = "VelocityCore",
|
||||
dependencies = { @Dependency(id = "persistentvelocitycore"), @Dependency(id = "depencendiesvelocitycore") }
|
||||
dependencies = {@Dependency(id = "persistentvelocitycore"), @Dependency(id = "depencendiesvelocitycore")}
|
||||
)
|
||||
public class VelocityCore implements ReloadablePlugin {
|
||||
|
||||
public static boolean MAIN_SERVER;
|
||||
|
||||
private static VelocityCore instance;
|
||||
|
||||
public static VelocityCore get() {
|
||||
return instance;
|
||||
}
|
||||
@@ -135,7 +136,7 @@ public class VelocityCore implements ReloadablePlugin {
|
||||
initStaticServers();
|
||||
|
||||
local = new Node.LocalNode();
|
||||
if(MAIN_SERVER) {
|
||||
if (MAIN_SERVER) {
|
||||
//new Node.RemoteNode("lx");
|
||||
}
|
||||
|
||||
@@ -205,8 +206,9 @@ public class VelocityCore implements ReloadablePlugin {
|
||||
bot.getJda().getHttpClient().connectionPool().evictAll();
|
||||
bot.getJda().getHttpClient().dispatcher().executorService().shutdown();
|
||||
try {
|
||||
if(!bot.getJda().awaitShutdown(1, TimeUnit.SECONDS))
|
||||
if (!bot.getJda().awaitShutdown(1, TimeUnit.SECONDS)) {
|
||||
logger.log(Level.SEVERE, "Could not await discord bot shutdown");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
@@ -228,12 +230,13 @@ public class VelocityCore implements ReloadablePlugin {
|
||||
|
||||
private void initStaticServers() {
|
||||
for (Map.Entry<String, Config.Server> entry : config.getServers().entrySet()) {
|
||||
Config.Server server = entry.getValue();
|
||||
Config.Server server = entry.getValue();
|
||||
List<String> cmds = server.getCommands();
|
||||
String cmd = cmds.remove(0);
|
||||
|
||||
if(server.getSpectatePort() != 0)
|
||||
if (server.getSpectatePort() != 0) {
|
||||
EventStarter.addSpectateServer(server.getSpectatePort(), cmd);
|
||||
}
|
||||
|
||||
new ServerSwitchCommand(cmd, entry.getKey(), server.getSpectatePort() != 0, cmds.toArray(new String[0]));
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.velocitycore.discord.DiscordBot;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import de.steamwar.velocitycore.discord.DiscordBot;
|
||||
|
||||
@Linked
|
||||
public class AlertCommand extends SWCommand {
|
||||
@@ -42,7 +42,8 @@ public class AlertCommand extends SWCommand {
|
||||
String s = String.join(" ", message);
|
||||
Chatter.broadcast().system("ALERT", s.replace('&', '§'));
|
||||
|
||||
if ("-discord".equals(sendToDiscord))
|
||||
if ("-discord".equals(sendToDiscord)) {
|
||||
DiscordBot.withBot(bot -> bot.getAnnouncementChannel().send(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.data.BauLockState;
|
||||
import de.steamwar.linkage.EventMode;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
@@ -33,6 +33,7 @@ import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||
import de.steamwar.persistent.Bauserver;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarWorld;
|
||||
import de.steamwar.velocitycore.*;
|
||||
@@ -40,7 +41,6 @@ import de.steamwar.velocitycore.inventory.SWInventory;
|
||||
import de.steamwar.velocitycore.inventory.SWItem;
|
||||
import de.steamwar.velocitycore.network.NetworkSender;
|
||||
import de.steamwar.velocitycore.util.BauLock;
|
||||
import de.steamwar.data.BauLockState;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
@@ -160,8 +160,9 @@ public class BauCommand extends SWCommand {
|
||||
setter.accept(target);
|
||||
|
||||
Bauserver bauserver = Bauserver.get(owner.user().getUUID());
|
||||
if(bauserver != null)
|
||||
if (bauserver != null) {
|
||||
bauserver.getRegisteredServer().getPlayersConnected().stream().findAny().ifPresent(player -> NetworkSender.send(player, new BaumemberUpdatePacket()));
|
||||
}
|
||||
|
||||
Chatter.of(user.getUUID()).system("BAU_MEMBER_SET_TARGET", owner, new Message(permName));
|
||||
owner.system("BAU_MEMBER_SET", new Message(permName));
|
||||
@@ -176,12 +177,14 @@ public class BauCommand extends SWCommand {
|
||||
Bauserver bauserver = Bauserver.get(owner.user().getUUID());
|
||||
Chatter member = Chatter.of(user.getUUID());
|
||||
member.withPlayer(player -> {
|
||||
if (bauserver != null && bauserver.getRegisteredServer().getPlayersConnected().contains(player))
|
||||
if (bauserver != null && bauserver.getRegisteredServer().getPlayersConnected().contains(player)) {
|
||||
player.createConnectionRequest(VelocityCore.get().getConfig().lobbyserver()).fireAndForget();
|
||||
}
|
||||
});
|
||||
|
||||
if(bauserver != null)
|
||||
if (bauserver != null) {
|
||||
bauserver.getRegisteredServer().getPlayersConnected().stream().findAny().ifPresent(player -> NetworkSender.send(player, new BaumemberUpdatePacket()));
|
||||
}
|
||||
|
||||
member.system("BAU_DELMEMBER_DELETED_TARGET", owner);
|
||||
owner.system("BAU_DELMEMBER_DELETED");
|
||||
@@ -210,8 +213,9 @@ public class BauCommand extends SWCommand {
|
||||
VelocityCore.schedule(() -> {
|
||||
sender.system("BAU_STOPPING");
|
||||
Bauserver subserver = Bauserver.get(sender.user().getUUID());
|
||||
if(subserver != null)
|
||||
if (subserver != null) {
|
||||
subserver.stop();
|
||||
}
|
||||
|
||||
sender.system("BAU_STOPPED");
|
||||
}).schedule();
|
||||
@@ -221,13 +225,14 @@ public class BauCommand extends SWCommand {
|
||||
@Register("delete")
|
||||
public void delete(PlayerChatter sender, ServerVersion version) {
|
||||
SWInventory inventory = new SWInventory(sender, 9, new Message("BAU_DELETE_GUI_NAME"));
|
||||
inventory.addItem(0, new SWItem(new Message("BAU_DELETE_GUI_DELETE"), 10), click -> {
|
||||
inventory.addItem(0, new SWItem("LIME_DYE", new Message("BAU_DELETE_GUI_DELETE")), click -> {
|
||||
SteamwarWorld world = SteamwarWorld.getBauWorld(sender.user(), version.getVersionSuffix());
|
||||
|
||||
VelocityCore.schedule(() -> {
|
||||
Bauserver subserver = Bauserver.get(sender.user().getUUID());
|
||||
if(subserver != null)
|
||||
if (subserver != null) {
|
||||
subserver.stop();
|
||||
}
|
||||
|
||||
if(world != null) {
|
||||
world.markDeleted();
|
||||
@@ -241,7 +246,7 @@ public class BauCommand extends SWCommand {
|
||||
|
||||
inventory.close();
|
||||
});
|
||||
inventory.addItem(8, new SWItem(new Message("BAU_DELETE_GUI_CANCEL"), 1), click -> inventory.close());
|
||||
inventory.addItem(8, new SWItem("RED_DYE", new Message("BAU_DELETE_GUI_CANCEL")), click -> inventory.close());
|
||||
inventory.open();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,15 @@ import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
import de.steamwar.velocitycore.ServerStarter;
|
||||
import de.steamwar.velocitycore.ServerVersion;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -60,7 +66,7 @@ public class BuilderCloudCommand extends SWCommand {
|
||||
|
||||
@Register(description = "BUILDERCLOUD_USAGE")
|
||||
public void start(PlayerChatter sender, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map) {
|
||||
if(!mapExists(version, map)) {
|
||||
if (!mapExists(version, map)) {
|
||||
sender.system("BUILDERCLOUD_UNKNOWN_MAP");
|
||||
return;
|
||||
}
|
||||
@@ -71,12 +77,12 @@ public class BuilderCloudCommand extends SWCommand {
|
||||
@Register(value = "rename", description = "BUILDERCLOUD_RENAME_USAGE")
|
||||
public void rename(Chatter sender, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String oldName, String newName) {
|
||||
SteamwarWorld oldMap = builderWorld(version, oldName);
|
||||
if(oldMap == null) {
|
||||
if (oldMap == null) {
|
||||
sender.system("BUILDERCLOUD_UNKNOWN_MAP");
|
||||
return;
|
||||
}
|
||||
|
||||
if(mapExists(version, newName)) {
|
||||
if (mapExists(version, newName)) {
|
||||
sender.system("BUILDERCLOUD_EXISTING_MAP");
|
||||
return;
|
||||
}
|
||||
@@ -89,7 +95,7 @@ public class BuilderCloudCommand extends SWCommand {
|
||||
@Register(value = "deploy", description = "BUILDERCLOUD_DEPLOY_USAGE")
|
||||
public void deploy(Chatter sender, @Mapper("nonHistoricArenaMode") GameModeConfig<String, String> arenaMode, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map) {
|
||||
SteamwarWorld builderWorld = builderWorld(version, map);
|
||||
if(builderWorld == null) {
|
||||
if (builderWorld == null) {
|
||||
sender.system("BUILDERCLOUD_UNKNOWN_MAP");
|
||||
return;
|
||||
}
|
||||
@@ -114,8 +120,9 @@ public class BuilderCloudCommand extends SWCommand {
|
||||
@Override
|
||||
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||
ServerVersion version = getVersion(previousArguments, 1);
|
||||
if(version == null)
|
||||
if (version == null)
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Set<String> maps = new LinkedHashSet<>();
|
||||
SteamwarWorld.getBuilderWorlds(version.getVersionSuffix()).stream()
|
||||
@@ -141,17 +148,16 @@ public class BuilderCloudCommand extends SWCommand {
|
||||
return new TypeMapper<File>() {
|
||||
@Override
|
||||
public File map(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||
if(s.isEmpty())
|
||||
return null;
|
||||
if (s.isEmpty()) return null;
|
||||
|
||||
File folder = getLegacyWorldFolder(previousArguments, 2);
|
||||
|
||||
if(folder == null)
|
||||
throw new SecurityException();
|
||||
if (folder == null) throw new SecurityException();
|
||||
|
||||
File generator = new File(folder, s + ".dat");
|
||||
if(!generator.exists() || !generator.isFile())
|
||||
if (!generator.exists() || !generator.isFile()) {
|
||||
throw new SecurityException();
|
||||
}
|
||||
|
||||
return generator;
|
||||
}
|
||||
@@ -161,8 +167,9 @@ public class BuilderCloudCommand extends SWCommand {
|
||||
File folder = getLegacyWorldFolder(previousArguments, 2);
|
||||
|
||||
String[] files;
|
||||
if(folder == null || (files = folder.list()) == null)
|
||||
if (folder == null || (files = folder.list()) == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Arrays.stream(files).filter(file -> new File(folder, file).isFile()).filter(file -> file.endsWith(".dat")).map(file -> file.substring(0, file.length() - 4)).toList();
|
||||
}
|
||||
@@ -191,14 +198,16 @@ public class BuilderCloudCommand extends SWCommand {
|
||||
|
||||
private File getLegacyWorldFolder(PreviousArguments previousArguments, int offset) {
|
||||
ServerVersion v = getVersion(previousArguments, offset);
|
||||
if(v == null)
|
||||
if (v == null) {
|
||||
return null;
|
||||
}
|
||||
return new File(v.getWorldFolder(ServerStarter.LEGACY_BUILDER_BASE_PATH));
|
||||
}
|
||||
|
||||
private ServerVersion getVersion(PreviousArguments previousArguments, int offset) {
|
||||
if(previousArguments.userArgs.length < offset)
|
||||
if (previousArguments.userArgs.length < offset) {
|
||||
return null;
|
||||
}
|
||||
return ServerVersion.get(previousArguments.userArgs[previousArguments.userArgs.length - offset]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,15 +22,14 @@ package de.steamwar.velocitycore.commands;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.linkage.EventMode;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.Message;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.persistent.Subserver;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.sql.IgnoreSystem;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.velocitycore.ServerStarter;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
||||
@@ -50,15 +49,15 @@ public class ChallengeCommand extends SWCommand {
|
||||
public void challenge(@Validator("arenaPlayer") PlayerChatter sender, @Validator("target") Player target, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull GameModeConfig<String, String> arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
FightCommand.createArena(sender, "/challenge " + target.getUsername() + " ", false, arenaMode, map, false, (chatter, mode, m) -> {
|
||||
Player p = sender.getPlayer();
|
||||
if(challenges.containsKey(target) && challenges.get(target).contains(p)){
|
||||
if (challenges.containsKey(target) && challenges.get(target).contains(p)) {
|
||||
challenges.remove(target);
|
||||
challenges.remove(p);
|
||||
|
||||
new ServerStarter().arena(mode, map).blueLeader(sender.getPlayer()).redLeader(target).callback(
|
||||
arena -> Chatter.broadcast().system("CHALLENGE_BROADCAST", new Message("CHALLENGE_BROADCAST_HOVER"), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.GameName, p, target)
|
||||
).start();
|
||||
}else{
|
||||
if(!challenges.containsKey(p)){
|
||||
} else {
|
||||
if (!challenges.containsKey(p)) {
|
||||
challenges.put(p, new LinkedList<>());
|
||||
}
|
||||
|
||||
@@ -96,7 +95,7 @@ public class ChallengeCommand extends SWCommand {
|
||||
};
|
||||
}
|
||||
|
||||
public static void remove(Player player){
|
||||
public static void remove(Player player) {
|
||||
challenges.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class CheckCommand extends SWCommand {
|
||||
private static final Map<UUID, CheckSession> currentCheckers = new HashMap<>();
|
||||
private static final Map<Integer, CheckSession> currentSchems = new HashMap<>();
|
||||
|
||||
public static boolean isChecking(Player player){
|
||||
public static boolean isChecking(Player player) {
|
||||
return currentCheckers.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
@@ -77,8 +77,7 @@ public class CheckCommand extends SWCommand {
|
||||
|
||||
public static void sendReminder(Chatter chatter) {
|
||||
List<SchematicNode> schematics = getSchemsToCheck();
|
||||
if(schematics.size() == currentCheckers.size())
|
||||
return;
|
||||
if (schematics.size() == currentCheckers.size()) return;
|
||||
|
||||
chatter.system("CHECK_REMINDER", new Message("CHECK_REMINDER_HOVER"), ClickEvent.runCommand("/check list"), schematics.size() - currentCheckers.size());
|
||||
}
|
||||
@@ -123,7 +122,7 @@ public class CheckCommand extends SWCommand {
|
||||
|
||||
@Register(value = "schematic", noTabComplete = true)
|
||||
public void schematic(PlayerChatter sender, String schemID) {
|
||||
if(isChecking(sender.getPlayer())){
|
||||
if (isChecking(sender.getPlayer())) {
|
||||
sender.system("CHECK_SCHEMATIC_ALREADY_CHECKING");
|
||||
return;
|
||||
}
|
||||
@@ -134,10 +133,10 @@ public class CheckCommand extends SWCommand {
|
||||
sender.system("CHECK_SCHEMATIC_EVENT");
|
||||
return;
|
||||
}
|
||||
if(!schem.getSchemtype().check()){
|
||||
if (!schem.getSchemtype().check()) {
|
||||
VelocityCore.getLogger().log(Level.SEVERE, () -> sender.user().getUserName() + " tried to check an uncheckable schematic!");
|
||||
return;
|
||||
}else if(schem.getOwner() == sender.user().getId() && !sender.user().hasPerm(UserPerm.ADMINISTRATION)) {
|
||||
} else if (schem.getOwner() == sender.user().getId() && !sender.user().hasPerm(UserPerm.ADMINISTRATION)) {
|
||||
sender.system("CHECK_SCHEMATIC_OWN");
|
||||
return;
|
||||
}
|
||||
@@ -167,8 +166,7 @@ public class CheckCommand extends SWCommand {
|
||||
}
|
||||
|
||||
public static void abort(Player player) {
|
||||
if(notChecking(player))
|
||||
return;
|
||||
if (notChecking(player)) return;
|
||||
|
||||
Chatter.of(player).system("CHECK_ABORT");
|
||||
currentCheckers.get(player.getUniqueId()).abort();
|
||||
@@ -176,8 +174,7 @@ public class CheckCommand extends SWCommand {
|
||||
|
||||
@Register(value = "next", description = "CHECK_HELP_NEXT")
|
||||
public void next(PlayerChatter sender) {
|
||||
if(notChecking(sender.getPlayer()))
|
||||
return;
|
||||
if (notChecking(sender.getPlayer())) return;
|
||||
|
||||
currentCheckers.get(sender.getPlayer().getUniqueId()).next();
|
||||
}
|
||||
@@ -189,26 +186,25 @@ public class CheckCommand extends SWCommand {
|
||||
|
||||
@Register(value = "decline", description = "CHECK_HELP_DECLINE")
|
||||
public void decline(PlayerChatter sender) {
|
||||
if(notChecking(sender.getPlayer()))
|
||||
return;
|
||||
if (notChecking(sender.getPlayer())) return;
|
||||
|
||||
currentCheckers.get(sender.getPlayer().getUniqueId()).markDeclined();
|
||||
}
|
||||
|
||||
@Register(value = "decline", description = "CHECK_HELP_DECLINE")
|
||||
public void decline(PlayerChatter sender, String... message) {
|
||||
if(notChecking(sender.getPlayer()))
|
||||
return;
|
||||
if (notChecking(sender.getPlayer())) return;
|
||||
|
||||
currentCheckers.get(sender.getPlayer().getUniqueId()).decline(String.join(" ", message));
|
||||
}
|
||||
|
||||
public static List<SchematicNode> getSchemsToCheck(){
|
||||
public static List<SchematicNode> getSchemsToCheck() {
|
||||
List<SchematicNode> schematicList = new ArrayList<>();
|
||||
|
||||
for (SchematicType type : SchematicType.values()) {
|
||||
if (type.check())
|
||||
if (type.check()) {
|
||||
schematicList.addAll(SchematicNode.getAllSchematicsOfType(type));
|
||||
}
|
||||
}
|
||||
return schematicList;
|
||||
}
|
||||
@@ -218,15 +214,15 @@ public class CheckCommand extends SWCommand {
|
||||
return currentSchems.get(schematic.getId()).checker.user().getUserName();
|
||||
}
|
||||
|
||||
private static boolean notChecking(Player player){
|
||||
if(!isChecking(player)){
|
||||
private static boolean notChecking(Player player) {
|
||||
if (!isChecking(player)) {
|
||||
Chatter.of(player).system("CHECK_NOT_CHECKING");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class CheckSession{
|
||||
private static class CheckSession {
|
||||
private final PlayerChatter checker;
|
||||
private final SchematicNode schematic;
|
||||
private final Timestamp startTime;
|
||||
@@ -234,7 +230,7 @@ public class CheckCommand extends SWCommand {
|
||||
private String currentQuestion;
|
||||
private final List<String> declinedQuestions = new ArrayList<>();
|
||||
|
||||
private CheckSession(PlayerChatter checker, SchematicNode schematic){
|
||||
private CheckSession(PlayerChatter checker, SchematicNode schematic) {
|
||||
this.checker = checker;
|
||||
this.schematic = schematic;
|
||||
this.startTime = Timestamp.from(Instant.now());
|
||||
@@ -245,14 +241,15 @@ 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.previousChecks(schematic)) {
|
||||
checker.prefixless("CHECK_SCHEMATIC_PREVIOUS", previous.getEndTime(), SteamwarUser.byId(previous.getValidator()).getUserName(), previous.getDeclineReason());
|
||||
}
|
||||
next();
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void next() {
|
||||
if(!checkList.hasNext()){
|
||||
if (!checkList.hasNext()) {
|
||||
if (declinedQuestions.isEmpty()) {
|
||||
accept();
|
||||
} else {
|
||||
@@ -293,7 +290,7 @@ public class CheckCommand extends SWCommand {
|
||||
next();
|
||||
}
|
||||
|
||||
private void accept(){
|
||||
private void accept() {
|
||||
// TODO: This Code is only for the WGS and because YoyoNow is not available this can be removed or changed after the WGS!
|
||||
if (schematic.getSchemtype().toDB().equals("cwargearseason26")) {
|
||||
int userId = schematic.getOwner();
|
||||
@@ -359,7 +356,7 @@ public class CheckCommand extends SWCommand {
|
||||
});
|
||||
}
|
||||
|
||||
private void decline(String reason){
|
||||
private void decline(String reason) {
|
||||
concludeCheckSession(reason, SchematicType.Normal, () -> {
|
||||
Chatter owner = Chatter.of(SteamwarUser.byId(schematic.getOwner()).getUUID());
|
||||
owner.withPlayerOrOffline(
|
||||
@@ -377,14 +374,14 @@ public class CheckCommand extends SWCommand {
|
||||
DiscordBot.withBot(bot -> bot.getChecklistChannel().system(message));
|
||||
}
|
||||
|
||||
private void abort(){
|
||||
private void abort() {
|
||||
concludeCheckSession("Prüfvorgang abgebrochen", null, () -> true);
|
||||
}
|
||||
|
||||
private void concludeCheckSession(String reason, SchematicType type, BooleanSupplier sendMessageIsOnline) {
|
||||
if(SchematicNode.getSchematicNode(schematic.getId()) != null) {
|
||||
if (SchematicNode.getSchematicNode(schematic.getId()) != null) {
|
||||
CheckedSchematic.create(schematic, checker.user().getId(), startTime, Timestamp.from(Instant.now()), reason, sendMessageIsOnline.getAsBoolean());
|
||||
if(type != null) {
|
||||
if (type != null) {
|
||||
schematic.setSchemtype(type);
|
||||
if (type == SchematicType.Normal) {
|
||||
schematic.setPrepared(false);
|
||||
@@ -395,8 +392,7 @@ public class CheckCommand extends SWCommand {
|
||||
remove();
|
||||
VelocityCore.schedule(() -> {
|
||||
Bauserver subserver = Bauserver.get(checker.user().getUUID());
|
||||
if(subserver != null)
|
||||
subserver.stop();
|
||||
if (subserver != null) subserver.stop();
|
||||
}).schedule();
|
||||
}
|
||||
|
||||
|
||||
@@ -77,8 +77,7 @@ public class DevCommand extends SWCommand {
|
||||
|
||||
@Register(value = "reloadmodes")
|
||||
public void reloadModes(Chatter sender) {
|
||||
if(!sender.user().hasPerm(UserPerm.ADMINISTRATION))
|
||||
return;
|
||||
if (!sender.user().hasPerm(UserPerm.ADMINISTRATION)) return;
|
||||
|
||||
try {
|
||||
ArenaMode.init();
|
||||
@@ -148,8 +147,7 @@ public class DevCommand extends SWCommand {
|
||||
String name = "Dev " + user.getUserName();
|
||||
((VelocityViaConfig) Via.getConfig()).getVelocityServerProtocols().put(name, ServerVersion.get(devServerVersions.get(username)).getProtocolVersion().getProtocol());
|
||||
|
||||
if (devServers.containsKey(username))
|
||||
return;
|
||||
if (devServers.containsKey(username)) return;
|
||||
devServers.put(user.getUserName().toLowerCase(), VelocityCore.getProxy().registerServer(new ServerInfo(name, new InetSocketAddress("127.0.0.1", value))));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -55,8 +55,7 @@ public class EventCommand extends SWCommand {
|
||||
sender.system("EVENT_NO_CURRENT");
|
||||
|
||||
List<Event> coming = Event.getComing();
|
||||
if (coming.isEmpty())
|
||||
return;
|
||||
if (coming.isEmpty()) return;
|
||||
|
||||
sender.system("EVENT_COMING");
|
||||
|
||||
@@ -65,16 +64,19 @@ public class EventCommand extends SWCommand {
|
||||
for (Event e : coming) {
|
||||
sender.prefixless("EVENT_COMING_EVENT", e.getStart().toLocalDateTime().format(format), e.getEnd().toLocalDateTime().format(format), e.getEventName());
|
||||
|
||||
if (now.isBefore(e.getDeadline().toInstant()))
|
||||
if (now.isBefore(e.getDeadline().toInstant())) {
|
||||
sender.prefixless("EVENT_COMING_DEADLINE", e.getDeadline());
|
||||
}
|
||||
|
||||
SchematicType schemType = e.getSchematicType();
|
||||
if (schemType != null && schemType.getDeadline() != null && now.isBefore(schemType.getDeadline().toInstant()))
|
||||
if (schemType != null && schemType.getDeadline() != null && now.isBefore(schemType.getDeadline().toInstant())) {
|
||||
sender.prefixless("EVENT_COMING_SCHEM_DEADLINE", schemType.getDeadline());
|
||||
}
|
||||
|
||||
Set<Team> teams = TeamTeilnahme.getTeams(e.getEventID());
|
||||
if (!teams.isEmpty())
|
||||
if (!teams.isEmpty()) {
|
||||
sender.prefixless("EVENT_COMING_TEAMS", teams.stream().map(team -> sender.parseToLegacy("EVENT_COMING_TEAM", team.getTeamColor(), team.getTeamKuerzel())).collect(Collectors.joining(" ")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +152,9 @@ public class EventCommand extends SWCommand {
|
||||
@ClassMapper(value = Team.class, local = true)
|
||||
public TypeMapper<Team> eventTeams() {
|
||||
return eventTeam(eventFight -> {
|
||||
if (eventFight.getStartTime().after(new Timestamp(System.currentTimeMillis()))) return Collections.emptyList();
|
||||
if (eventFight.getStartTime().after(new Timestamp(System.currentTimeMillis()))) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return List.of(eventFight.getTeamBlue(), eventFight.getTeamRed());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class EventRescheduleCommand extends SWCommand {
|
||||
@Register
|
||||
public void reschedule(Chatter sender, @Mapper("BLUE_TEAM") Team teamBlue, @Mapper("RED_TEAM") Team teamRed) {
|
||||
Event event = Event.get();
|
||||
if(event == null){
|
||||
if (event == null) {
|
||||
sender.system("EVENTRESCHEDULE_UNKNOWN_TEAM");
|
||||
return;
|
||||
}
|
||||
@@ -51,12 +51,11 @@ public class EventRescheduleCommand extends SWCommand {
|
||||
List<EventFight> fights = EventFight.getEvent(event.getEventID());
|
||||
ListIterator<EventFight> it = fights.listIterator(fights.size());
|
||||
Timestamp now = Timestamp.from(new Date().toInstant());
|
||||
while(it.hasPrevious()){
|
||||
while (it.hasPrevious()) {
|
||||
EventFight fight = it.previous();
|
||||
if(fight.getStartTime().after(now))
|
||||
continue;
|
||||
if (fight.getStartTime().after(now)) continue;
|
||||
|
||||
if(fight.getTeamBlue() == teamBlue.getTeamId() && fight.getTeamRed() == teamRed.getTeamId()){
|
||||
if (fight.getTeamBlue() == teamBlue.getTeamId() && fight.getTeamRed() == teamRed.getTeamId()) {
|
||||
sender.system("EVENTRESCHEDULE_STARTING");
|
||||
fight.reschedule();
|
||||
EventFight.loadAllComingFights();
|
||||
|
||||
@@ -21,7 +21,6 @@ package de.steamwar.velocitycore.commands;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.linkage.EventMode;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
@@ -29,7 +28,7 @@ import de.steamwar.messages.Message;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.persistent.Arenaserver;
|
||||
import de.steamwar.persistent.Subserver;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
import de.steamwar.velocitycore.ServerStarter;
|
||||
import de.steamwar.velocitycore.inventory.SWInventory;
|
||||
@@ -48,11 +47,10 @@ public class FightCommand extends SWCommand {
|
||||
super("fight", "f");
|
||||
}
|
||||
|
||||
private static void getModes(Chatter sender, String precommand, boolean historic){
|
||||
private static void getModes(Chatter sender, String precommand, boolean historic) {
|
||||
Component start = Component.empty();
|
||||
for(GameModeConfig<String, String> mode : ArenaMode.getAllModes()){
|
||||
if (!mode.isActive() || mode.Server.Historic != historic)
|
||||
continue;
|
||||
for (GameModeConfig<String, String> mode : ArenaMode.getAllModes()) {
|
||||
if (!mode.isActive() || mode.Server.Historic != historic) continue;
|
||||
|
||||
String command = precommand + mode.getChatName();
|
||||
start = start.append(Component
|
||||
@@ -72,8 +70,9 @@ public class FightCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (map == null)
|
||||
if (map == null) {
|
||||
map = arenaMode.getRandomMap();
|
||||
}
|
||||
|
||||
if (!allowMerging) {
|
||||
callback.run(sender, arenaMode, map);
|
||||
@@ -86,7 +85,7 @@ public class FightCommand extends SWCommand {
|
||||
Arenaserver mergable = null;
|
||||
synchronized (Subserver.getServerList()) {
|
||||
for (Subserver subserver : Subserver.getServerList()) {
|
||||
if(subserver instanceof Arenaserver arenaserver &&
|
||||
if (subserver instanceof Arenaserver arenaserver &&
|
||||
(mode.configFile.getName().replace(".yml", "").equals(arenaserver.getMode()) && arenaserver.isAllowMerge() && arenaserver.getRegisteredServer().getPlayersConnected().size() == 1)) {
|
||||
mergable = arenaserver;
|
||||
break;
|
||||
@@ -94,22 +93,23 @@ public class FightCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if(mergable == null) {
|
||||
if (mergable == null) {
|
||||
declineMerge.run(sender, mode, map);
|
||||
return;
|
||||
}
|
||||
|
||||
SWInventory inventory = new SWInventory(sender, 9, new Message("FIGHT_MERGE_TITLE"));
|
||||
inventory.addItem(0, new SWItem(new Message("FIGHT_MERGE_DECLINE"), 1), click -> {
|
||||
inventory.addItem(0, new SWItem("RED_DYE", new Message("FIGHT_MERGE_DECLINE")), click -> {
|
||||
inventory.close();
|
||||
declineMerge.run(sender, mode, map);
|
||||
});
|
||||
Arenaserver finalMergable = mergable;
|
||||
SWItem item = new SWItem(new Message("FIGHT_MERGE_INFO", mode.GameName, finalMergable.getMap()), 11);
|
||||
SWItem item = new SWItem("YELLOW_DYE", new Message("FIGHT_MERGE_INFO", mode.GameName, finalMergable.getMap()));
|
||||
item.addLore(new Message("FIGHT_MERGE_INFO_LORE_1", finalMergable.getRegisteredServer().getPlayersConnected().toArray(new Player[1])[0].getUsername()));
|
||||
inventory.addItem(4, item, click -> {});
|
||||
inventory.addItem(8, new SWItem(new Message("FIGHT_MERGE_ACCEPT"), 10), click -> {
|
||||
if(Subserver.getServerList().contains(finalMergable)) {
|
||||
inventory.addItem(4, item, click -> {
|
||||
});
|
||||
inventory.addItem(8, new SWItem("LIME_DYE", new Message("FIGHT_MERGE_ACCEPT")), click -> {
|
||||
if (Subserver.getServerList().contains(finalMergable)) {
|
||||
finalMergable.sendPlayer(sender.getPlayer());
|
||||
} else {
|
||||
sender.system("FIGHT_MERGE_OFFLINE");
|
||||
|
||||
@@ -136,14 +136,14 @@ public class GDPRQuery extends SWCommand {
|
||||
OutputStreamWriter writer = new OutputStreamWriter(stream);
|
||||
int columns = rs.getMetaData().getColumnCount();
|
||||
|
||||
for(int i = 1; i <= columns; i++) {
|
||||
for (int i = 1; i <= columns; i++) {
|
||||
writer.write(rs.getMetaData().getColumnLabel(i));
|
||||
writer.write(";");
|
||||
}
|
||||
writer.write("\n");
|
||||
|
||||
while(rs.next()) {
|
||||
for(int i = 1; i <= columns; i++) {
|
||||
while (rs.next()) {
|
||||
for (int i = 1; i <= columns; i++) {
|
||||
try {
|
||||
writer.write(rs.getString(i));
|
||||
} catch (NullPointerException e) {
|
||||
@@ -163,13 +163,13 @@ public class GDPRQuery extends SWCommand {
|
||||
|
||||
private void personalKits(SteamwarUser user, ZipOutputStream out) {
|
||||
personalKitData.select(rs -> {
|
||||
while(rs.next()) {
|
||||
while (rs.next()) {
|
||||
try {
|
||||
String path = "PersonalKit/" + rs.getString("GameMode") + "/" + rs.getString("Name");
|
||||
try(InputStream data = rs.getBinaryStream("Inventory")) {
|
||||
try (InputStream data = rs.getBinaryStream("Inventory")) {
|
||||
copy(data, out, path + ".Inventory.yml");
|
||||
}
|
||||
try(InputStream data = rs.getBinaryStream("Armor")) {
|
||||
try (InputStream data = rs.getBinaryStream("Armor")) {
|
||||
copy(data, out, path + ".Armor.yml");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@@ -182,10 +182,10 @@ public class GDPRQuery extends SWCommand {
|
||||
|
||||
private void schematics(SteamwarUser user, ZipOutputStream out) {
|
||||
schematicData.select(rs -> {
|
||||
while(rs.next()) {
|
||||
while (rs.next()) {
|
||||
String name = (rs.getString("ParentNode") != null ? rs.getString("ParentNode") : "") + ":" + rs.getString("NodeName");
|
||||
boolean format = rs.getBoolean("NodeFormat");
|
||||
try(InputStream data = rs.getBinaryStream("NodeData")) {
|
||||
try (InputStream data = rs.getBinaryStream("NodeData")) {
|
||||
copy(data, out, "Schematics/" + name + (format ? ".schem" : ".schematic"));
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not export Schematic", e);
|
||||
@@ -197,9 +197,9 @@ public class GDPRQuery extends SWCommand {
|
||||
|
||||
private void userConfig(SteamwarUser user, ZipOutputStream out) {
|
||||
userConfig.select(rs -> {
|
||||
while(rs.next()) {
|
||||
while (rs.next()) {
|
||||
String name = rs.getString("Config");
|
||||
try(InputStream data = rs.getBinaryStream("Value")) {
|
||||
try (InputStream data = rs.getBinaryStream("Value")) {
|
||||
copy(data, out, name + ".yapion");
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not export UserConfig", e);
|
||||
@@ -211,7 +211,7 @@ public class GDPRQuery extends SWCommand {
|
||||
|
||||
private void copyLogs(SteamwarUser user, ZipOutputStream out, File log, String outFile) throws IOException {
|
||||
if (log.isDirectory()) {
|
||||
for(File logfile : log.listFiles()) {
|
||||
for (File logfile : log.listFiles()) {
|
||||
copyLogs(user, out, logfile, outFile + "/" + logfile.getName().replace(".gz", ""));
|
||||
}
|
||||
} else {
|
||||
@@ -222,26 +222,26 @@ public class GDPRQuery extends SWCommand {
|
||||
|
||||
private void copyBauwelt(SteamwarUser user, ZipOutputStream out, String inDir, String outDir) throws IOException {
|
||||
File world = new File(inDir);
|
||||
if(!world.exists())
|
||||
return;
|
||||
if (!world.exists()) return;
|
||||
|
||||
copy(new File(world, "level.dat"), out, outDir + "/level.dat");
|
||||
|
||||
File region = new File(world, "region");
|
||||
for(File regionfile : region.listFiles()) {
|
||||
for (File regionfile : region.listFiles()) {
|
||||
copy(regionfile, out, outDir + "/region/" + regionfile.getName());
|
||||
}
|
||||
|
||||
File poi = new File(world, "poi");
|
||||
if(poi.exists()) {
|
||||
for(File regionfile : poi.listFiles()) {
|
||||
if (poi.exists()) {
|
||||
for (File regionfile : poi.listFiles()) {
|
||||
copy(regionfile, out, outDir + "/poi/" + regionfile.getName());
|
||||
}
|
||||
}
|
||||
|
||||
File playerdata = new File(world, "playerdata/" + user.getUUID().toString() + ".dat");
|
||||
if(playerdata.exists())
|
||||
if (playerdata.exists()) {
|
||||
copy(playerdata, out, outDir + "/playerdata/" + user.getUUID().toString() + ".dat");
|
||||
}
|
||||
}
|
||||
|
||||
private void copyLegacyBauwelt(SteamwarUser user, ZipOutputStream out, ServerVersion version) throws IOException {
|
||||
@@ -261,17 +261,16 @@ public class GDPRQuery extends SWCommand {
|
||||
String path = "playerdata/" + user.getUUID().toString() + ".dat";
|
||||
|
||||
int i = 0;
|
||||
for(File world : worlds.listFiles()) {
|
||||
for (File world : worlds.listFiles()) {
|
||||
File playerdata = new File(world, path);
|
||||
if(!playerdata.exists())
|
||||
continue;
|
||||
if (!playerdata.exists()) continue;
|
||||
|
||||
copy(playerdata, out, outDir + "/" + (i++) + "/" + user.getUUID().toString() + ".dat");
|
||||
}
|
||||
}
|
||||
|
||||
private void copy(File file, ZipOutputStream out, String path) throws IOException {
|
||||
try(FileInputStream in = new FileInputStream(file)) {
|
||||
try (FileInputStream in = new FileInputStream(file)) {
|
||||
copy(in, out, path);
|
||||
}
|
||||
}
|
||||
@@ -280,8 +279,8 @@ public class GDPRQuery extends SWCommand {
|
||||
boolean initialized = false;
|
||||
|
||||
int bytes;
|
||||
for(byte[] buf = new byte[8192]; (bytes = in.read(buf)) > 0; ) {
|
||||
if(!initialized) {
|
||||
for (byte[] buf = new byte[8192]; (bytes = in.read(buf)) > 0; ) {
|
||||
if (!initialized) {
|
||||
ZipEntry entry = new ZipEntry(path);
|
||||
out.putNextEntry(entry);
|
||||
initialized = true;
|
||||
@@ -290,7 +289,7 @@ public class GDPRQuery extends SWCommand {
|
||||
out.write(buf, 0, bytes);
|
||||
}
|
||||
|
||||
if(initialized) {
|
||||
if (initialized) {
|
||||
out.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,25 +48,25 @@ public class HelpCommand extends SWCommand {
|
||||
"HELP_LOCAL", "/local");
|
||||
}
|
||||
|
||||
@Register({"build","world"})
|
||||
@Register({"build", "world"})
|
||||
public void buildWorld(Chatter sender) {
|
||||
printPage(sender, "HELP_BAU_GROUP_WORLD_TITLE", "HELP_TNT", "HELP_FIRE", "HELP_FREEZE", "HELP_TPSLIMIT", "HELP_PROTECT", "HELP_RESET");
|
||||
}
|
||||
|
||||
@Register({"build","player"})
|
||||
@Register({"build", "player"})
|
||||
public void buildPlayer(Chatter sender) {
|
||||
printPage(sender, "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER");
|
||||
}
|
||||
|
||||
@Register({"build","worldedit"})
|
||||
@Register({"build","we"})
|
||||
@Register({"build","world-edit"})
|
||||
@Register({"build","edit"})
|
||||
@Register({"build", "worldedit"})
|
||||
@Register({"build", "we"})
|
||||
@Register({"build", "world-edit"})
|
||||
@Register({"build", "edit"})
|
||||
public void buildWorldedit(Chatter sender) {
|
||||
printPage(sender, "HELP_BAU_GROUP_WE_TITLE", "HELP_WE_POS1", "HELP_WE_POS2", "HELP_WE_COPY", "HELP_WE_PASTE", "HELP_WE_FLOPY", "HELP_WE_FLOPYP", "HELP_WE_ROTATE_90", "HELP_WE_ROTATE_180", "HELP_WE_ROTATE_N90");
|
||||
}
|
||||
|
||||
@Register({"build","other"})
|
||||
@Register({"build", "other"})
|
||||
public void buildOther(Chatter sender) {
|
||||
printPage(sender, "HELP_BAU_GROUP_OTHER_TITLE", "HELP_TESTBLOCK", "HELP_SKULL", "HELP_BAUINFO");
|
||||
sender.prefixless("HELP_SCHEMSUBMIT", new Message("HELP_SCHEMSUBMIT_HOVER"), ClickEvent.openUrl("https://www.youtube.com/watch?v=9QrQ3UBWveE"));
|
||||
@@ -83,9 +83,9 @@ public class HelpCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register("buildserver")
|
||||
@Register({"build","admin"})
|
||||
@Register({"build","owner"})
|
||||
@Register({"build","bauwelt"})
|
||||
@Register({"build", "admin"})
|
||||
@Register({"build", "owner"})
|
||||
@Register({"build", "bauwelt"})
|
||||
public void sendBauHelp(Chatter sender) {
|
||||
printPage(sender, ClickEvent::suggestCommand,
|
||||
"HELP_BAU_TP", "/build tp ",
|
||||
@@ -102,10 +102,10 @@ public class HelpCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private static void printPage(Chatter sender, Function<String, ClickEvent> action, String... args) {
|
||||
for(int i = 0; i < args.length; i += 2) {
|
||||
for (int i = 0; i < args.length; i += 2) {
|
||||
String message = args[i];
|
||||
String hoverMessage = message + "_HOVER";
|
||||
String command = args[i+1];
|
||||
String command = args[i + 1];
|
||||
|
||||
sender.system(message, new Message(hoverMessage), action.apply(command));
|
||||
}
|
||||
|
||||
@@ -20,13 +20,12 @@
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.linkage.EventMode;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.Message;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.velocitycore.ServerStarter;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
||||
|
||||
@@ -36,11 +36,11 @@ public class IgnoreCommand extends SWCommand {
|
||||
public void genericCommand(Chatter player, @ErrorMessage("UNKNOWN_PLAYER") SteamwarUser target) {
|
||||
SteamwarUser user = player.user();
|
||||
|
||||
if(target.equals(user)){
|
||||
if (target.equals(user)) {
|
||||
player.system("IGNORE_YOURSELF");
|
||||
return;
|
||||
}
|
||||
if(IgnoreSystem.isIgnored(user, target)){
|
||||
if (IgnoreSystem.isIgnored(user, target)) {
|
||||
player.system("IGNORE_ALREADY");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,12 +40,11 @@ public class ListCommand extends SWCommand {
|
||||
super("list");
|
||||
}
|
||||
|
||||
public static synchronized SortedMap<String, List<Player>> getCustomTablist(){
|
||||
public static synchronized SortedMap<String, List<Player>> getCustomTablist() {
|
||||
SortedMap<String, List<Player>> playerMap = new TreeMap<>();
|
||||
for (Player player : VelocityCore.getProxy().getAllPlayers()) {
|
||||
ServerConnection pserver = player.getCurrentServer().orElse(null);
|
||||
if (pserver == null)
|
||||
continue;
|
||||
if (pserver == null) continue;
|
||||
|
||||
if (Subserver.isBuild(Subserver.getSubserver(pserver.getServerInfo()))) {
|
||||
playerMap.computeIfAbsent("Bau", s -> new ArrayList<>()).add(player);
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.velocitycore.listeners.ChatListener;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.velocitycore.listeners.ChatListener;
|
||||
|
||||
@Linked
|
||||
public class LocalCommand extends SWCommand {
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.velocitycore.inventory.SWInventory;
|
||||
import de.steamwar.velocitycore.inventory.SWItem;
|
||||
import de.steamwar.velocitycore.inventory.SWListInv;
|
||||
import de.steamwar.velocitycore.inventory.SWStreamInv;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.Message;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import de.steamwar.velocitycore.inventory.SWInventory;
|
||||
import de.steamwar.velocitycore.inventory.SWItem;
|
||||
import de.steamwar.velocitycore.inventory.SWListInv;
|
||||
import de.steamwar.velocitycore.inventory.SWStreamInv;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -58,7 +58,7 @@ public class ModCommand extends SWCommand {
|
||||
openGui(player);
|
||||
}), page -> {
|
||||
Mod.ModType filtertype = playerFilterType.get(player.user().getUUID());
|
||||
return Mod.getAllModsFiltered(page,45, filtertype).stream().map(mod -> new SWListInv.SWListEntry<>(new SWItem("NAME_TAG", new Message("PLAIN_STRING", mod.getModName())).addLore(new Message("PLAIN_STRING", mod.getPlatform().name())), mod)).toList();
|
||||
return Mod.getAllModsFiltered(page, 45, filtertype).stream().map(mod -> new SWListInv.SWListEntry<>(new SWItem("NAME_TAG", new Message("PLAIN_STRING", mod.getModName())).addLore(new Message("PLAIN_STRING", mod.getPlatform().name())), mod)).toList();
|
||||
});
|
||||
|
||||
swStreamInv.addItem(52, new SWItem("NAME_TAG", new Message("MOD_TITLE_FILTER")), click -> {
|
||||
@@ -72,11 +72,11 @@ public class ModCommand extends SWCommand {
|
||||
private void openTypeGUI(PlayerChatter player, String title, Consumer<Mod.ModType> function) {
|
||||
SWInventory inv = new SWInventory(player, 9, new Message(title));
|
||||
|
||||
inv.addItem(1, new SWItem(new Message("MOD_UNCLASSIFIED"), 8), click -> function.accept(Mod.ModType.UNKLASSIFIED));
|
||||
inv.addItem(2, new SWItem(new Message("MOD_ALLOWED"), 2), click -> function.accept(Mod.ModType.GREEN));
|
||||
inv.addItem(3, new SWItem(new Message("MOD_FORBIDDEN"), 11), click -> function.accept(Mod.ModType.YELLOW));
|
||||
inv.addItem(4, new SWItem(new Message("MOD_AUTOBAN"), 1), click -> function.accept(Mod.ModType.RED));
|
||||
inv.addItem(5, new SWItem(new Message("MOD_YT"), 13), click -> function.accept(Mod.ModType.YOUTUBER_ONLY));
|
||||
inv.addItem(1, new SWItem("GRAY_DYE", new Message("MOD_UNCLASSIFIED")), click -> function.accept(Mod.ModType.UNKLASSIFIED));
|
||||
inv.addItem(2, new SWItem("GREEN_DYE", new Message("MOD_ALLOWED")), click -> function.accept(Mod.ModType.GREEN));
|
||||
inv.addItem(3, new SWItem("YELLOW_DYE", new Message("MOD_FORBIDDEN")), click -> function.accept(Mod.ModType.YELLOW));
|
||||
inv.addItem(4, new SWItem("RED_DYE", new Message("MOD_AUTOBAN")), click -> function.accept(Mod.ModType.RED));
|
||||
inv.addItem(5, new SWItem("MAGENTA_DYE", new Message("MOD_YT")), click -> function.accept(Mod.ModType.YOUTUBER_ONLY));
|
||||
|
||||
inv.addItem(8, new SWItem("ARROW", new Message("MOD_ITEM_BACK")), click -> {
|
||||
inv.close();
|
||||
@@ -86,10 +86,10 @@ public class ModCommand extends SWCommand {
|
||||
inv.open();
|
||||
}
|
||||
|
||||
@Register(value = {"set"},description = "MOD_COMMAND_SET_USAGE")
|
||||
@Register(value = {"set"}, description = "MOD_COMMAND_SET_USAGE")
|
||||
public void set(Chatter sender, String modName, Mod.Platform platform, Mod.ModType newModType) {
|
||||
Mod mod = Mod.get(modName, platform);
|
||||
if(mod == null) {
|
||||
if (mod == null) {
|
||||
sender.system("MOD_COMMAND_NOT_FOUND_IN_DATABASE", modName, platform.name());
|
||||
return;
|
||||
}
|
||||
@@ -98,10 +98,10 @@ public class ModCommand extends SWCommand {
|
||||
sender.system("MOD_CHANGED_TYPE", modName, platform.name(), newModType.name());
|
||||
}
|
||||
|
||||
@Register(value = {"get"},description = "MOD_COMMAND_GET_USAGE")
|
||||
@Register(value = {"get"}, description = "MOD_COMMAND_GET_USAGE")
|
||||
public void get(Chatter sender, String modName, Mod.Platform platform) {
|
||||
Mod mod = Mod.get(modName, platform);
|
||||
if(mod == null) {
|
||||
if (mod == null) {
|
||||
sender.system("MOD_COMMAND_NOT_FOUND_IN_DATABASE", modName, platform.name());
|
||||
return;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class ModCommand extends SWCommand {
|
||||
@Register(value = {"next"})
|
||||
public void next(Chatter sender) {
|
||||
Mod mod = Mod.findFirstMod();
|
||||
if(mod == null) {
|
||||
if (mod == null) {
|
||||
sender.system("MOD_NO_MORE_UNCLASSIFIED_MODS");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class MsgCommand extends SWCommand {
|
||||
}
|
||||
|
||||
public static void msg(PlayerChatter sender, Player target, String[] args) {
|
||||
if(target == null || VelocityCore.getProxy().getPlayer(target.getUniqueId()).orElse(null) == null) {
|
||||
if (target == null || VelocityCore.getProxy().getPlayer(target.getUniqueId()).orElse(null) == null) {
|
||||
sender.system("MSG_OFFLINE");
|
||||
return;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class MsgCommand extends SWCommand {
|
||||
lastChats.put(target, sender.getPlayer());
|
||||
}
|
||||
|
||||
public static void remove(Player player){
|
||||
public static void remove(Player player) {
|
||||
lastChats.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import de.steamwar.messages.Message;
|
||||
import de.steamwar.sql.BannedUserIPs;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.listeners.IPSanitizer;
|
||||
|
||||
@@ -61,7 +60,8 @@ public class PunishmentCommand {
|
||||
return null;
|
||||
}
|
||||
|
||||
return SteamwarUser.getOrCreate(uuid, name, u -> {});
|
||||
return SteamwarUser.getOrCreate(uuid, name, u -> {
|
||||
});
|
||||
}
|
||||
|
||||
private static UUID getUUIDofOfflinePlayer(String playerName) {
|
||||
@@ -115,8 +115,7 @@ public class PunishmentCommand {
|
||||
public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) {
|
||||
new PunishCommand(command, punishmentType);
|
||||
|
||||
if (punishmentType.getUnpunishmentMessage() == null)
|
||||
return;
|
||||
if (punishmentType.getUnpunishmentMessage() == null) return;
|
||||
|
||||
new UnpunishCommand("un" + command, punishmentType);
|
||||
}
|
||||
@@ -188,29 +187,25 @@ public class PunishmentCommand {
|
||||
|
||||
private SteamwarUser unsafeUser(Chatter sender, String arg) {
|
||||
SteamwarUser target = getOrCreateOfflinePlayer(arg);
|
||||
if(target == null)
|
||||
sender.system("UNKNOWN_PLAYER");
|
||||
if (target == null) sender.system("UNKNOWN_PLAYER");
|
||||
return target;
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Chatter sender, @Mapper("toPunish") String toPunish, String date, @ErrorMessage(allowEAs = false, value = "PUNISHMENT_USAGE_REASON") String... message) {
|
||||
SteamwarUser punisher = sender.user();
|
||||
if (!punisher.hasPerm(punishmentType.getUserPerm()))
|
||||
return;
|
||||
if (!punisher.hasPerm(punishmentType.getUserPerm())) return;
|
||||
|
||||
SteamwarUser target = unsafeUser(sender, toPunish);
|
||||
if (target == null)
|
||||
return;
|
||||
if (target == null) return;
|
||||
|
||||
Timestamp banTime = parseTime(sender, date);
|
||||
if (banTime == null)
|
||||
return;
|
||||
if (banTime == null) return;
|
||||
|
||||
boolean isPerma = date.equalsIgnoreCase("perma");
|
||||
String msg = String.join(" ", message);
|
||||
target.punish(punishmentType, banTime, msg, punisher.getId(), isPerma);
|
||||
if(punishmentType == Punishment.PunishmentType.Ban)
|
||||
if (punishmentType == Punishment.PunishmentType.Ban)
|
||||
ban(target, banTime, msg, punisher, isPerma);
|
||||
Chatter.serverteam().system(punishmentType.getTeamMessage(), target, sender, new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
|
||||
}
|
||||
@@ -254,8 +249,7 @@ public class PunishmentCommand {
|
||||
@Register
|
||||
public void genericCommand(Chatter sender, @ErrorMessage("UNKNOWN_PLAYER") SteamwarUser target) {
|
||||
SteamwarUser punisher = sender.user();
|
||||
if (!punisher.hasPerm(punishmentType.getUserPerm()))
|
||||
return;
|
||||
if (!punisher.hasPerm(punishmentType.getUserPerm())) return;
|
||||
|
||||
if (!target.isPunished(punishmentType)) {
|
||||
sender.system(punishmentType.getUsageNotPunished());
|
||||
@@ -263,8 +257,9 @@ public class PunishmentCommand {
|
||||
}
|
||||
|
||||
target.punish(punishmentType, Timestamp.from(new Date().toInstant()), command, sender.user().getId(), false);
|
||||
if(punishmentType == Punishment.PunishmentType.Ban)
|
||||
if (punishmentType == Punishment.PunishmentType.Ban) {
|
||||
BannedUserIPs.unbanIPs(target.getId());
|
||||
}
|
||||
|
||||
sender.system(punishmentType.getUnpunishmentMessage(), target.getUserName());
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.linkage.EventMode;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Message;
|
||||
@@ -44,7 +43,7 @@ public class ReplayCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(PlayerChatter sender, int replayId, @StaticValue(value = {"", "-a"}, allowISE=true) @OptionalValue("") boolean isAdmin, @OptionalValue("") String optionalMap) {
|
||||
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) {
|
||||
@@ -57,8 +56,7 @@ public class ReplayCommand extends SWCommand {
|
||||
|
||||
@Register
|
||||
public void genericCommand(PlayerChatter sender, @OptionalValue("") String optionalMap) {
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
return;
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) return;
|
||||
|
||||
new SWStreamInv<>(sender, new Message("REPLAY_TITLE"), (click, fight) -> {
|
||||
startReplay(sender, click.isShiftClick(), optionalMap, fight);
|
||||
@@ -66,8 +64,7 @@ public class ReplayCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private void startReplay(PlayerChatter sender, boolean isAdmin, String optionalMap, Fight fight) {
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
return;
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) return;
|
||||
|
||||
GameModeConfig<String, String> mode = ArenaMode.getBySchemType(fight.getSchemType());
|
||||
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(sender.getPlayer());
|
||||
@@ -81,7 +78,7 @@ public class ReplayCommand extends SWCommand {
|
||||
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()) {
|
||||
} else if (!fight.replayAllowed()) {
|
||||
sender.system("REPLAY_UNAVAILABLE");
|
||||
} else {
|
||||
starter.arena(mode, map).start();
|
||||
@@ -97,12 +94,14 @@ public class ReplayCommand extends SWCommand {
|
||||
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())));
|
||||
if(!fight.replayAllowed())
|
||||
if (!fight.replayAllowed()) {
|
||||
lore.add(new Message("REPLAY_UNAVAILABLE"));
|
||||
}
|
||||
item.setLore(lore);
|
||||
|
||||
if(fight.replayAllowed())
|
||||
if (fight.replayAllowed()) {
|
||||
item.setEnchanted(true);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ public class RulesCommand extends SWCommand {
|
||||
public void genericCommand(Chatter sender) {
|
||||
sender.system("REGELN_RULES");
|
||||
|
||||
for(String ruleset : Arrays.asList("REGELN_AS", "REGELN_MWG", "REGELN_WG", "REGELN_WS", "REGELN_QG", "REGELN_CONDUCT"))
|
||||
for (String ruleset : Arrays.asList("REGELN_AS", "REGELN_MWG", "REGELN_WG", "REGELN_WS", "REGELN_QG", "REGELN_CONDUCT")) {
|
||||
sender.prefixless(ruleset, new Message("URL_FORMAT", sender.parseToPlain(ruleset + "_URL")), ClickEvent.openUrl(sender.parseToPlain(ruleset + "_URL")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,16 @@
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
|
||||
public class ServerSwitchCommand extends SWCommand {
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.velocitycore.listeners.ChatListener;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import de.steamwar.velocitycore.listeners.ChatListener;
|
||||
|
||||
@Linked
|
||||
public class ServerTeamchatCommand extends SWCommand {
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.velocitycore.Node;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import de.steamwar.velocitycore.Node;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -43,8 +43,7 @@ public class StatCommand extends SWCommand {
|
||||
try {
|
||||
Process process = new ProcessBuilder("ps", "x").start();
|
||||
new BufferedReader(new InputStreamReader(process.getInputStream())).lines().forEach(s -> {
|
||||
if (!s.contains("--port"))
|
||||
return;
|
||||
if (!s.contains("--port")) return;
|
||||
serverCount.compute(
|
||||
s.contains("ssh -L") ? s.substring(s.indexOf("ssh -L") + 6).split(" ")[2] : "sw",
|
||||
(server, count) -> (count != null ? count : 0) + 1
|
||||
|
||||
@@ -56,32 +56,35 @@ public class TeamCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register(noTabComplete = true)
|
||||
public void help(Chatter sender, String... args){
|
||||
public void help(Chatter sender, String... args) {
|
||||
helpMessages(sender, "TEAM_HELP_HEADER", "TEAM_HELP_LIST", "TEAM_HELP_INFO");
|
||||
|
||||
SteamwarUser user = sender.user();
|
||||
if(user.getTeam() == 0) {
|
||||
if (user.getTeam() == 0) {
|
||||
helpMessages(sender, "TEAM_HELP_CREATE", "TEAM_HELP_JOIN");
|
||||
}else{
|
||||
} else {
|
||||
helpMessages(sender, "TEAM_HELP_CHAT", "TEAM_HELP_EVENT", "TEAM_HELP_LEAVE");
|
||||
|
||||
if(user.isLeader())
|
||||
if (user.isLeader()) {
|
||||
helpMessages(sender, "TEAM_HELP_INVITE", "TEAM_HELP_REMOVE", "TEAM_HELP_KUERZEL", "TEAM_HELP_NAME", "TEAM_HELP_COLOR", "TEAM_HELP_LEADER", "TEAM_HELP_STEP_BACK", "TEAM_HELP_SERVER");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void helpMessages(Chatter sender, String... messages) {
|
||||
for(String message : messages)
|
||||
for (String message : messages) {
|
||||
sender.system(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Register(value = "create", description = "TEAM_CREATE_USAGE")
|
||||
public void create(@Validator("isNotInTeam") Chatter sender, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGTH") String name){
|
||||
public void create(@Validator("isNotInTeam") Chatter sender, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGTH") String name) {
|
||||
SteamwarUser user = sender.user();
|
||||
Team team = Team.byId(user.getTeam());
|
||||
|
||||
if(checkTeamKuerzel(sender, team, kuerzel) || checkTeamName(sender, team, name))
|
||||
if (checkTeamKuerzel(sender, team, kuerzel) || checkTeamName(sender, team, name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Team.create(kuerzel, name);
|
||||
user.setTeam(Team.get(kuerzel).getTeamId());
|
||||
@@ -90,13 +93,12 @@ public class TeamCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register("join")
|
||||
public void join(@Validator("isNotInTeam") Chatter sender, String... args){
|
||||
public void join(@Validator("isNotInTeam") Chatter sender, String... args) {
|
||||
SteamwarUser user = sender.user();
|
||||
|
||||
if(notDuringEvent(sender))
|
||||
return;
|
||||
if (notDuringEvent(sender)) return;
|
||||
|
||||
if(!teamInvitations.containsKey(user.getId())){
|
||||
if (!teamInvitations.containsKey(user.getId())) {
|
||||
sender.system("TEAM_JOIN_NO_INVITE");
|
||||
return;
|
||||
}
|
||||
@@ -104,13 +106,13 @@ public class TeamCommand extends SWCommand {
|
||||
List<Integer> invs = teamInvitations.get(user.getId());
|
||||
Integer t = null;
|
||||
|
||||
if(invs.size() == 1){
|
||||
if (invs.size() == 1) {
|
||||
t = invs.get(0);
|
||||
}else{
|
||||
if(args.length != 1){
|
||||
} else {
|
||||
if (args.length != 1) {
|
||||
sender.system("TEAM_JOIN_USAGE");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int inv : invs){
|
||||
for (int inv : invs) {
|
||||
Team team = Team.byId(inv);
|
||||
sb.append(team.getTeamName()).append(" ");
|
||||
}
|
||||
@@ -118,15 +120,15 @@ public class TeamCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
for(int inv : invs){
|
||||
for (int inv : invs) {
|
||||
Team team = Team.byId(inv);
|
||||
if(team.getTeamKuerzel().equalsIgnoreCase(args[0]) || team.getTeamName().equalsIgnoreCase(args[0])){
|
||||
if (team.getTeamKuerzel().equalsIgnoreCase(args[0]) || team.getTeamName().equalsIgnoreCase(args[0])) {
|
||||
t = inv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(t == null){
|
||||
if (t == null) {
|
||||
sender.system("TEAM_JOIN_NOT_BY_TEAM");
|
||||
return;
|
||||
}
|
||||
@@ -142,7 +144,7 @@ public class TeamCommand extends SWCommand {
|
||||
SteamwarUser user = sender.user();
|
||||
Team team = Team.byId(user.getTeam());
|
||||
|
||||
if(noRemainingLeaders(team, user)){
|
||||
if (noRemainingLeaders(team, user)) {
|
||||
sender.system("TEAM_OTHER_LEADER_REQUIRED");
|
||||
return;
|
||||
}
|
||||
@@ -157,15 +159,14 @@ public class TeamCommand extends SWCommand {
|
||||
Team team = Team.byId(user.getTeam());
|
||||
|
||||
int teamSize = team.size();
|
||||
if(teamSize > 1 && user.isLeader() && noRemainingLeaders(team, user)) {
|
||||
if (teamSize > 1 && user.isLeader() && noRemainingLeaders(team, user)) {
|
||||
sender.system("TEAM_OTHER_LEADER_REQUIRED");
|
||||
return;
|
||||
}
|
||||
|
||||
user.setTeam(0);
|
||||
|
||||
if(teamSize == 1)
|
||||
team.disband(user);
|
||||
if (teamSize == 1) team.disband(user);
|
||||
|
||||
sender.system("TEAM_LEAVE_LEFT");
|
||||
}
|
||||
@@ -176,19 +177,18 @@ public class TeamCommand extends SWCommand {
|
||||
|
||||
|
||||
@Register(value = "invite", description = "TEAM_INVITE_USAGE")
|
||||
public void invite(@Validator("isLeader") Chatter sender, @ErrorMessage("TEAM_INVITE_NO_PLAYER") SteamwarUser target){
|
||||
public void invite(@Validator("isLeader") Chatter sender, @ErrorMessage("TEAM_INVITE_NO_PLAYER") SteamwarUser target) {
|
||||
Team team = Team.byId(sender.user().getTeam());
|
||||
|
||||
if(notDuringEvent(sender))
|
||||
return;
|
||||
if (notDuringEvent(sender)) return;
|
||||
|
||||
if(target.getTeam() != 0){
|
||||
if (target.getTeam() != 0) {
|
||||
sender.system("TEAM_INVITE_IN_TEAM");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Integer> invitations = teamInvitations.computeIfAbsent(target.getId(), id -> new ArrayList<>());
|
||||
if(invitations.contains(team.getTeamId())){
|
||||
if (invitations.contains(team.getTeamId())) {
|
||||
sender.system("TEAM_INVITE_ALREADY_INVITED");
|
||||
return;
|
||||
}
|
||||
@@ -199,7 +199,7 @@ public class TeamCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register(value = "remove", description = "TEAM_REMOVE_USAGE")
|
||||
public void remove(@Validator("isLeader") Chatter sender, @ErrorMessage("TEAM_REMOVE_NOT_PLAYER") @Mapper("memberList") SteamwarUser target){
|
||||
public void remove(@Validator("isLeader") Chatter sender, @ErrorMessage("TEAM_REMOVE_NOT_PLAYER") @Mapper("memberList") SteamwarUser target) {
|
||||
Team team = Team.byId(sender.user().getTeam());
|
||||
|
||||
if (target.isLeader()) {
|
||||
@@ -208,12 +208,12 @@ public class TeamCommand extends SWCommand {
|
||||
}
|
||||
|
||||
List<Integer> invitations = teamInvitations.get(target.getId());
|
||||
if(invitations != null) {
|
||||
if (invitations != null) {
|
||||
sender.system(invitations.remove((Integer) team.getTeamId()) ? "TEAM_REMOVE_INVITE" : "TEAM_REMOVE_NO_INVITE");
|
||||
return;
|
||||
}
|
||||
|
||||
if(target.getTeam() != team.getTeamId()) {
|
||||
if (target.getTeam() != team.getTeamId()) {
|
||||
sender.system("TEAM_REMOVE_NOT_IN_TEAM");
|
||||
return;
|
||||
}
|
||||
@@ -243,37 +243,32 @@ public class TeamCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register(value = "changekurzel", description = "TEAM_KUERZEL_USAGE")
|
||||
public void changekuerzel(@Validator("isLeader") Chatter sender, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel){
|
||||
public void changekuerzel(@Validator("isLeader") Chatter sender, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel) {
|
||||
Team team = Team.byId(sender.user().getTeam());
|
||||
|
||||
if(notDuringEvent(sender))
|
||||
return;
|
||||
if (notDuringEvent(sender)) return;
|
||||
|
||||
if(checkTeamKuerzel(sender, team, kuerzel))
|
||||
return;
|
||||
if (checkTeamKuerzel(sender, team, kuerzel)) return;
|
||||
|
||||
team.setTeamKuerzel(kuerzel);
|
||||
sender.system("TEAM_KUERZEL_CHANGED");
|
||||
}
|
||||
|
||||
@Register(value = "changename", description = "TEAM_NAME_USAGE")
|
||||
public void changename(@Validator("isLeader") Chatter sender, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGTH") String name){
|
||||
public void changename(@Validator("isLeader") Chatter sender, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGTH") String name) {
|
||||
Team team = Team.byId(sender.user().getTeam());
|
||||
|
||||
if(notDuringEvent(sender))
|
||||
return;
|
||||
if (notDuringEvent(sender)) return;
|
||||
|
||||
if(checkTeamName(sender, team, name))
|
||||
return;
|
||||
if (checkTeamName(sender, team, name)) return;
|
||||
|
||||
team.setTeamName(name);
|
||||
sender.system("TEAM_NAME_CHANGED");
|
||||
}
|
||||
|
||||
@Register(value = "promote", description = "TEAM_LEADER_USAGE")
|
||||
public void promote(@Validator("isLeader") Chatter sender, @ErrorMessage("TEAM_LEADER_NOT_USER") @Mapper("memberList") SteamwarUser target){
|
||||
if(notDuringEvent(sender))
|
||||
return;
|
||||
public void promote(@Validator("isLeader") Chatter sender, @ErrorMessage("TEAM_LEADER_NOT_USER") @Mapper("memberList") SteamwarUser target) {
|
||||
if (notDuringEvent(sender)) return;
|
||||
|
||||
if (target.getTeam() != sender.user().getTeam()) {
|
||||
sender.system("TEAM_LEADER_NOT_MEMBER");
|
||||
@@ -285,23 +280,24 @@ public class TeamCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register("info")
|
||||
public void info(@Validator("isInTeam") Chatter sender){
|
||||
public void info(@Validator("isInTeam") Chatter sender) {
|
||||
info(sender, Team.byId(sender.user().getTeam()));
|
||||
}
|
||||
|
||||
@Register(value = "info", description = "TEAM_INFO_USAGE")
|
||||
public void info(Chatter sender, @ErrorMessage("UNKNOWN_TEAM") Team team){
|
||||
public void info(Chatter sender, @ErrorMessage("UNKNOWN_TEAM") Team team) {
|
||||
List<SteamwarUser> users = team.getMembers().stream().map(SteamwarUser::byId).toList();
|
||||
|
||||
sender.system("TEAM_INFO_TEAM", team.getTeamName(), team.getTeamColor(), team.getTeamKuerzel());
|
||||
sender.prefixless("TEAM_INFO_LEADER", users.stream().filter(SteamwarUser::isLeader).count(), getMemberList(users, true));
|
||||
|
||||
String members = getMemberList(users, false);
|
||||
if(!members.isEmpty())
|
||||
if (!members.isEmpty()) {
|
||||
sender.prefixless("TEAM_INFO_MEMBER", users.stream().filter(u -> !u.isLeader()).count(), members);
|
||||
}
|
||||
|
||||
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
|
||||
if(!events.isEmpty()){
|
||||
if (!events.isEmpty()) {
|
||||
sender.prefixless("TEAM_INFO_EVENTS", events.size(), events.stream().map(event -> {
|
||||
Integer placement = TeamTeilnahme.getPlacement(team, event);
|
||||
if (placement != null) {
|
||||
@@ -349,19 +345,19 @@ public class TeamCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register("list")
|
||||
public void list(Chatter sender, @Min(intValue = 1) @OptionalValue("1") @ErrorMessage("TEAM_LIST_NOT_PAGE") int page){
|
||||
public void list(Chatter sender, @Min(intValue = 1) @OptionalValue("1") @ErrorMessage("TEAM_LIST_NOT_PAGE") int page) {
|
||||
final int TEAMS_PER_PAGE = 10;
|
||||
|
||||
List<Team> all = Team.getAll();
|
||||
final int lastPage = ((all.size() - 1) / 10) + 1;
|
||||
if(page < 1 || page > lastPage){
|
||||
if (page < 1 || page > lastPage) {
|
||||
sender.system("TEAM_LIST_UNKNOWN_PAGE");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.system("TEAM_LIST_HEADER", page, lastPage);
|
||||
|
||||
for(int i = (page-1) * TEAMS_PER_PAGE; i < (page-1) * TEAMS_PER_PAGE + TEAMS_PER_PAGE && i < all.size(); i++){
|
||||
for (int i = (page - 1) * TEAMS_PER_PAGE; i < (page - 1) * TEAMS_PER_PAGE + TEAMS_PER_PAGE && i < all.size(); i++) {
|
||||
Team tm = all.get(i);
|
||||
|
||||
sender.prefixless("TEAM_LIST_TEAM", new Message("TEAM_LIST_TEAM_HOVER"),
|
||||
@@ -371,17 +367,19 @@ public class TeamCommand extends SWCommand {
|
||||
Component beforePage = Component
|
||||
.text("«« ")
|
||||
.color(page > 1 ? NamedTextColor.YELLOW : NamedTextColor.DARK_GRAY);
|
||||
if(page > 1)
|
||||
if (page > 1) {
|
||||
beforePage = beforePage
|
||||
.hoverEvent(HoverEvent.showText(sender.parse("TEAM_LIST_PREV")))
|
||||
.clickEvent(ClickEvent.runCommand("/team list " + (page - 1)));
|
||||
}
|
||||
|
||||
Component nextPage = sender.parse("TEAM_LIST_PAGE")
|
||||
.color(page > 1 ? NamedTextColor.YELLOW : NamedTextColor.DARK_GRAY);
|
||||
if(page < lastPage)
|
||||
if (page < lastPage) {
|
||||
nextPage = nextPage
|
||||
.hoverEvent(HoverEvent.showText(sender.parse("TEAM_LIST_NEXT")))
|
||||
.clickEvent(ClickEvent.runCommand("/team list " + (page + 1)));
|
||||
}
|
||||
|
||||
sender.sendMessage(beforePage.append(nextPage));
|
||||
}
|
||||
@@ -392,30 +390,30 @@ public class TeamCommand extends SWCommand {
|
||||
|
||||
sender.system("TEAM_EVENT_USAGE");
|
||||
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
|
||||
if(!events.isEmpty()){
|
||||
if (!events.isEmpty()) {
|
||||
sender.system("TEAM_EVENT_HEADER");
|
||||
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(sender.parseToPlain("EVENT_DATE_FORMAT"));
|
||||
for(Event e : events)
|
||||
for (Event e : events) {
|
||||
sender.prefixless("TEAM_EVENT_EVENT", e.getStart().toLocalDateTime().format(dateFormat), e.getEventName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Register("event")
|
||||
public void event(@Validator("isLeader") Chatter sender, Event event){
|
||||
public void event(@Validator("isLeader") Chatter sender, Event event) {
|
||||
Team team = Team.byId(sender.user().getTeam());
|
||||
|
||||
if(notDuringEvent(sender))
|
||||
return;
|
||||
if (notDuringEvent(sender)) return;
|
||||
|
||||
if(Instant.now().isAfter(event.getDeadline().toInstant())){
|
||||
if (Instant.now().isAfter(event.getDeadline().toInstant())) {
|
||||
sender.system("TEAM_EVENT_OVER");
|
||||
return;
|
||||
}
|
||||
|
||||
if(TeamTeilnahme.nimmtTeil(team.getTeamId(), event.getEventID())){
|
||||
if (TeamTeilnahme.nimmtTeil(team.getTeamId(), event.getEventID())) {
|
||||
TeamTeilnahme.notTeilnehmen(team.getTeamId(), event.getEventID());
|
||||
sender.system("TEAM_EVENT_LEFT");
|
||||
}else{
|
||||
} else {
|
||||
TeamTeilnahme.teilnehmen(team.getTeamId(), event.getEventID());
|
||||
sender.system("TEAM_EVENT_JOINED", event.getEventName());
|
||||
sender.prefixless("TEAM_EVENT_HOW_TO_LEAVE");
|
||||
@@ -424,25 +422,25 @@ public class TeamCommand extends SWCommand {
|
||||
DiscordBot.withBot(bot -> bot.getEventChannel().update());
|
||||
}
|
||||
|
||||
private static final Map<String, Integer> COLOR_CODES = new HashMap<>();
|
||||
private static final Map<String, String> COLOR_CODES = new HashMap<>();
|
||||
|
||||
static {
|
||||
COLOR_CODES.put("4", 1);
|
||||
COLOR_CODES.put("c", 15);
|
||||
COLOR_CODES.put("6", 14);
|
||||
COLOR_CODES.put("e", 11);
|
||||
COLOR_CODES.put("2", 2);
|
||||
COLOR_CODES.put("a", 10);
|
||||
COLOR_CODES.put("b", 12);
|
||||
COLOR_CODES.put("3", 6);
|
||||
COLOR_CODES.put("1", 4);
|
||||
COLOR_CODES.put("9", 6);
|
||||
COLOR_CODES.put("d", 9);
|
||||
COLOR_CODES.put("5", 5);
|
||||
COLOR_CODES.put("f", 15);
|
||||
COLOR_CODES.put("7", 7);
|
||||
COLOR_CODES.put("8", 8);
|
||||
COLOR_CODES.put("0", 16);
|
||||
COLOR_CODES.put("4", "RED_DYE");
|
||||
COLOR_CODES.put("c", "WHITE_DYE");
|
||||
COLOR_CODES.put("6", "ORANGE_DYE");
|
||||
COLOR_CODES.put("e", "YELLOW_DYE");
|
||||
COLOR_CODES.put("2", "GREEN_DYE");
|
||||
COLOR_CODES.put("a", "LIME_DYE");
|
||||
COLOR_CODES.put("b", "LIGHT_BLUE_DYE");
|
||||
COLOR_CODES.put("3", "CYAN_DYE");
|
||||
COLOR_CODES.put("1", "LAPIS_LAZULI");
|
||||
COLOR_CODES.put("9", "CYAN_DYE");
|
||||
COLOR_CODES.put("d", "PINK_DYE");
|
||||
COLOR_CODES.put("5", "PURPLE_DYE");
|
||||
COLOR_CODES.put("f", "WHITE_DYE");
|
||||
COLOR_CODES.put("7", "LIGHT_GRAY_DYE");
|
||||
COLOR_CODES.put("8", "GRAY_DYE");
|
||||
COLOR_CODES.put("0", "BLACK_DYE");
|
||||
}
|
||||
|
||||
@Register("color")
|
||||
@@ -450,10 +448,10 @@ public class TeamCommand extends SWCommand {
|
||||
public void changeColor(@Validator("isLeader") PlayerChatter sender) {
|
||||
Team team = Team.byId(sender.user().getTeam());
|
||||
|
||||
if(notDuringEvent(sender))
|
||||
return;
|
||||
if (notDuringEvent(sender)) return;
|
||||
|
||||
SWListInv<String> inv = new SWListInv<>(sender, new Message("TEAM_COLOR_TITLE"), COLOR_CODES.entrySet().stream().map(entry -> new SWListInv.SWListEntry<>(new SWItem(new Message("PLAIN_STRING", "§" + entry.getKey() + team.getTeamKuerzel()), entry.getValue()), entry.getKey())).toList(), (click, element) -> {});
|
||||
SWListInv<String> inv = new SWListInv<>(sender, new Message("TEAM_COLOR_TITLE"), COLOR_CODES.entrySet().stream().map(entry -> new SWListInv.SWListEntry<>(new SWItem(entry.getValue(), new Message("PLAIN_STRING", "§" + entry.getKey() + team.getTeamKuerzel())), entry.getKey())).toList(), (click, element) -> {
|
||||
});
|
||||
inv.setCallback((click, element) -> {
|
||||
inv.close();
|
||||
team.setTeamColor(element);
|
||||
@@ -546,26 +544,26 @@ public class TeamCommand extends SWCommand {
|
||||
};
|
||||
}
|
||||
|
||||
private boolean checkTeamName(Chatter sender, Team team, String arg){
|
||||
private boolean checkTeamName(Chatter sender, Team team, String arg) {
|
||||
Team t = Team.get(arg);
|
||||
if(t != null && t.getTeamId() != team.getTeamId()){
|
||||
if (t != null && t.getTeamId() != team.getTeamId()) {
|
||||
sender.system("TEAM_NAME_TAKEN");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkTeamKuerzel(Chatter sender, Team team, String arg){
|
||||
private boolean checkTeamKuerzel(Chatter sender, Team team, String arg) {
|
||||
Team t = Team.get(arg);
|
||||
if(t != null && (team == null || t.getTeamId() != team.getTeamId())){
|
||||
if (t != null && (team == null || t.getTeamId() != team.getTeamId())) {
|
||||
sender.system("TEAM_KUERZEL_TAKEN");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean notDuringEvent(Chatter sender){
|
||||
if(Event.get() != null){
|
||||
private boolean notDuringEvent(Chatter sender) {
|
||||
if (Event.get() != null) {
|
||||
sender.system("TEAM_NOT_IN_EVENT");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.velocitycore.listeners.ChatListener;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.ChatterGroup;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.velocitycore.listeners.ChatListener;
|
||||
|
||||
@Linked
|
||||
public class TeamchatCommand extends SWCommand {
|
||||
@@ -37,7 +37,7 @@ public class TeamchatCommand extends SWCommand {
|
||||
public void genericCommand(Chatter sender, @ErrorMessage(value = "TC_USAGE", allowEAs = false) String... args) {
|
||||
SteamwarUser user = sender.user();
|
||||
|
||||
if(user.getTeam() == 0){
|
||||
if (user.getTeam() == 0) {
|
||||
sender.system("TC_NO_TEAM");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,18 +22,20 @@ package de.steamwar.velocitycore.commands;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.velocitycore.*;
|
||||
import de.steamwar.velocitycore.util.BauLock;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.persistent.Bauserver;
|
||||
import de.steamwar.persistent.Storage;
|
||||
import de.steamwar.persistent.Subserver;
|
||||
import de.steamwar.sql.*;
|
||||
import de.steamwar.velocitycore.EventStarter;
|
||||
import de.steamwar.velocitycore.SubserverSystem;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.util.BauLock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -43,7 +45,7 @@ import java.util.List;
|
||||
@Linked
|
||||
public class TpCommand extends SWCommand {
|
||||
|
||||
public TpCommand(){
|
||||
public TpCommand() {
|
||||
super("join", "tp", "teleport");
|
||||
}
|
||||
|
||||
@@ -101,21 +103,22 @@ public class TpCommand extends SWCommand {
|
||||
}
|
||||
|
||||
public static void teleport(PlayerChatter sender, RegisteredServer server) {
|
||||
if(CheckCommand.isChecking(sender.getPlayer())){
|
||||
if (CheckCommand.isChecking(sender.getPlayer())) {
|
||||
sender.system("CHECK_CHECKING");
|
||||
return;
|
||||
}
|
||||
|
||||
Subserver subserver = Subserver.getSubserver(server.getServerInfo());
|
||||
if(subserver == null) {
|
||||
if (subserver == null) {
|
||||
sender.getPlayer().createConnectionRequest(server).fireAndForget();
|
||||
return;
|
||||
}
|
||||
|
||||
if(Subserver.isArena(subserver)) {
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
if (Subserver.isArena(subserver)) {
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) {
|
||||
return;
|
||||
} else if(Subserver.isBuild(subserver)) {
|
||||
}
|
||||
} else if (Subserver.isBuild(subserver)) {
|
||||
Bauserver bauserver = (Bauserver) subserver;
|
||||
Player checker = VelocityCore.getProxy().getPlayer(bauserver.getOwner()).orElse(null);
|
||||
if (checker != null && CheckCommand.isChecking(checker)) {
|
||||
@@ -132,8 +135,8 @@ public class TpCommand extends SWCommand {
|
||||
sender.system("JOIN_PLAYER_BLOCK");
|
||||
return;
|
||||
}
|
||||
} else if(Subserver.isBuilder(subserver)) {
|
||||
if(!sender.user().hasPerm(UserPerm.BUILD)) {
|
||||
} else if (Subserver.isBuilder(subserver)) {
|
||||
if (!sender.user().hasPerm(UserPerm.BUILD)) {
|
||||
sender.system("JOIN_PLAYER_BLOCK");
|
||||
return;
|
||||
}
|
||||
@@ -147,16 +150,18 @@ public class TpCommand extends SWCommand {
|
||||
|
||||
//Get target player server
|
||||
Player target = VelocityCore.getProxy().getPlayer(arg).orElse(null);
|
||||
if(target != null)
|
||||
if (target != null) {
|
||||
server = target.getCurrentServer().map(ServerConnection::getServer).orElse(server);
|
||||
}
|
||||
|
||||
//Get target team event arena
|
||||
if(server == null){
|
||||
if (server == null) {
|
||||
Team team = Team.get(arg);
|
||||
if(team != null){
|
||||
if (team != null) {
|
||||
Subserver eventArena = EventStarter.getEventServer().get(team.getTeamId());
|
||||
if(eventArena != null && Subserver.getServerList().contains(eventArena))
|
||||
if (eventArena != null && Subserver.getServerList().contains(eventArena)) {
|
||||
server = eventArena.getRegisteredServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,10 @@ import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.velocitycore.ArenaMode;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class UnIgnoreCommand extends SWCommand {
|
||||
public void genericCommand(Chatter sender, @ErrorMessage("UNIGNORE_NOT_PLAYER") SteamwarUser target) {
|
||||
SteamwarUser user = sender.user();
|
||||
|
||||
if(!IgnoreSystem.isIgnored(user, target)){
|
||||
if (!IgnoreSystem.isIgnored(user, target)) {
|
||||
sender.system("UNIGNORE_NOT_IGNORED");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.discord.util.AuthManager;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
|
||||
import java.util.Base64;
|
||||
@@ -46,14 +46,14 @@ public class VerifyCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if(bytes.length != 16) {
|
||||
if (bytes.length != 16) {
|
||||
sender.system("VERIFY_INVALID");
|
||||
return;
|
||||
}
|
||||
|
||||
User user = AuthManager.connectAuth(sender.user(), code);
|
||||
if(user != null) {
|
||||
VelocityCore.getLogger().log(Level.INFO,"%s Verified with Discorduser: %s".formatted(sender.user().getUserName(), user.getIdLong()));
|
||||
if (user != null) {
|
||||
VelocityCore.getLogger().log(Level.INFO, "%s Verified with Discorduser: %s".formatted(sender.user().getUserName(), user.getIdLong()));
|
||||
sender.system("VERIFY_SUCCESS", user.getAsTag());
|
||||
} else {
|
||||
sender.system("VERIFY_INVALID");
|
||||
|
||||
@@ -36,7 +36,7 @@ public class WebpasswordCommand extends SWCommand {
|
||||
|
||||
@Register(description = "WEB_USAGE")
|
||||
public void genericCommand(Chatter sender, String password) {
|
||||
if(password.length() < 8) {
|
||||
if (password.length() < 8) {
|
||||
sender.system("WEB_PASSWORD_LENGTH");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class WhoisCommand extends SWCommand {
|
||||
|
||||
@Register(description = "WHOIS_USAGE")
|
||||
public void whois(Chatter sender, long id, WhoisParameterTypes... parameters) {
|
||||
if(!sender.user().hasPerm(UserPerm.ADMINISTRATION) && !sender.user().hasPerm(UserPerm.PREFIX_DEVELOPER)) {
|
||||
if (!sender.user().hasPerm(UserPerm.ADMINISTRATION) && !sender.user().hasPerm(UserPerm.PREFIX_DEVELOPER)) {
|
||||
sender.system("UNKNOWN_PLAYER");
|
||||
return;
|
||||
}
|
||||
@@ -69,15 +69,15 @@ public class WhoisCommand extends SWCommand {
|
||||
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());
|
||||
|
||||
if (!sender.user().hasPerm(UserPerm.TEAM))
|
||||
return;
|
||||
if (!sender.user().hasPerm(UserPerm.TEAM)) return;
|
||||
|
||||
sender.system("WHOIS_STREAMING", !StreamingCommand.isNotStreaming(user));
|
||||
if (sender.user().hasPerm(UserPerm.MODERATION) || sender.user().hasPerm(UserPerm.PREFIX_DEVELOPER)) {
|
||||
sender.system("WHOIS_ID", user.getId());
|
||||
sender.system("WHOIS_UUID", new Message("WHOIS_UUID_HOVER"), ClickEvent.copyToClipboard(user.getUUID().toString()), user.getUUID().toString());
|
||||
if (user.getDiscordId() != null)
|
||||
if (user.getDiscordId() != null) {
|
||||
sender.system("WHOIS_DISCORD_ID", user.getDiscordId());
|
||||
}
|
||||
|
||||
sender.system("WHOIS_PERMS", user.perms().stream().map(Enum::name).collect(Collectors.joining(", ")));
|
||||
}
|
||||
@@ -85,25 +85,28 @@ public class WhoisCommand extends SWCommand {
|
||||
Player target = VelocityCore.getProxy().getPlayer(user.getUUID()).orElse(null);
|
||||
Timestamp firstJoin = user.getFirstjoin();
|
||||
double onlineTime = user.getOnlinetime();
|
||||
if(firstJoin == null && target != null) {
|
||||
if (firstJoin == null && target != null) {
|
||||
firstJoin = Storage.sessions.get(target);
|
||||
}
|
||||
Timestamp lastOnline = user.getLastOnline();
|
||||
|
||||
if(firstJoin != null)
|
||||
if (firstJoin != null) {
|
||||
sender.system("WHOIS_JOINED_FIRST", firstJoin.toString());
|
||||
if (lastOnline != null)
|
||||
}
|
||||
if (lastOnline != null) {
|
||||
sender.system("WHOIS_LAST_ONLINE", lastOnline.toString());
|
||||
}
|
||||
sender.system("WHOIS_HOURS_PLAYED", new DecimalFormat("###.##").format(onlineTime / 3600d));
|
||||
|
||||
if(target != null) {
|
||||
if (target != null) {
|
||||
sender.system("WHOIS_CURRENT_PLAYED", new DecimalFormat("####.##").format((Instant.now().getEpochSecond() - Storage.sessions.get(target).toInstant().getEpochSecond()) / 60d));
|
||||
sender.system("WHOIS_CURRENT_SERVER", target.getCurrentServer().orElseThrow().getServerInfo().getName());
|
||||
sender.system("WHOIS_CURRENT_PROTOCOL", target.getProtocolVersion().getMostRecentSupportedVersion());
|
||||
|
||||
List<Mod> mods = ModUtils.getPlayerModMap().get(user.getUUID());
|
||||
if(mods == null)
|
||||
if (mods == null) {
|
||||
mods = Collections.emptyList();
|
||||
}
|
||||
|
||||
sender.system("WHOIS_PLATFORM", mods.isEmpty() ? "Vanilla" : mods.get(0).getPlatform().toString());
|
||||
|
||||
@@ -137,10 +140,11 @@ public class WhoisCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private Message duration(Chatter sender, Timestamp timestamp, boolean perma) {
|
||||
if(perma)
|
||||
if (perma) {
|
||||
return new Message("PUNISHMENT_PERMA");
|
||||
else
|
||||
return new Message("PLAIN_STRING", timestamp.toLocalDateTime().format(DateTimeFormatter.ofPattern(sender.parseToPlain("TIMEFORMAT"))));
|
||||
} else {
|
||||
return new Message("PLAIN_STRING", timestamp.toLocalDateTime().format(DateTimeFormatter.ofPattern(sender.parseToPlain("TIMEFORMAT"))));
|
||||
}
|
||||
}
|
||||
|
||||
@ClassMapper(value = WhoisParameterTypes.class, local = true)
|
||||
|
||||
@@ -70,8 +70,7 @@ public class DiscordBot {
|
||||
private final OptionData commandArgument = new OptionData(OptionType.STRING, ARGUMENT_NAME, "Command arguments", false);
|
||||
|
||||
public static void withBot(Consumer<DiscordBot> consumer) {
|
||||
if (instance != null)
|
||||
consumer.accept(instance);
|
||||
if (instance != null) consumer.accept(instance);
|
||||
}
|
||||
|
||||
public static Guild getGuild() {
|
||||
@@ -143,8 +142,9 @@ public class DiscordBot {
|
||||
ActionRow.of(Button.link("https://steamwar.de", "Website"), Button.link("https://steamwar.de/youtube", "YouTube")),
|
||||
ActionRow.of(Button.primary("auth", Emoji.fromUnicode("U+2705")).withLabel("Minecraft verknüpfen"))
|
||||
), event -> {
|
||||
if (event.getComponentId().equals("auth"))
|
||||
if (event.getComponentId().equals("auth")) {
|
||||
event.reply("Gebe innerhalb der nächsten 10 Minuten ``/verify " + AuthManager.createDiscordAuthToken(event.getUser()) + "`` auf dem Minecraft Server ein").setEphemeral(true).queue();
|
||||
}
|
||||
});
|
||||
|
||||
List<ActionRow> actionRows = new ArrayList<>();
|
||||
|
||||
@@ -36,8 +36,7 @@ public class DiscordConfig {
|
||||
|
||||
public static DiscordConfig load() {
|
||||
File file = new File(System.getProperty("user.home"), "discord.yml");
|
||||
if(!file.exists() || VelocityCore.get().getConfig().isEventmode())
|
||||
return null;
|
||||
if (!file.exists() || VelocityCore.get().getConfig().isEventmode()) return null;
|
||||
|
||||
return Config.load(DiscordConfig.class, file, description -> description.addPropertyParameters("roles", String.class, DiscordRole.class));
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public enum DiscordTicketType {
|
||||
private final String url;
|
||||
|
||||
public Button toButton() {
|
||||
if(style == ButtonStyle.LINK) {
|
||||
if (style == ButtonStyle.LINK) {
|
||||
return Button.link(url, label).withEmoji(Emoji.fromUnicode(emoji));
|
||||
}
|
||||
return Button.of(style, name().toLowerCase(), Emoji.fromUnicode(emoji)).withLabel(label);
|
||||
|
||||
@@ -35,15 +35,15 @@ public class ChecklistChannel extends DiscordChannel {
|
||||
}
|
||||
|
||||
public void update() {
|
||||
List<SchematicNode> schems = CheckCommand.getSchemsToCheck();
|
||||
List<SchematicNode> schems = CheckCommand.getSchemsToCheck();
|
||||
|
||||
lastSchematics.removeIf(id -> schems.stream().noneMatch(schem -> schem.getId() == id));
|
||||
schems.removeIf(schem -> lastSchematics.contains(schem.getId()));
|
||||
lastSchematics.removeIf(id -> schems.stream().noneMatch(schem -> schem.getId() == id));
|
||||
schems.removeIf(schem -> lastSchematics.contains(schem.getId()));
|
||||
|
||||
for(SchematicNode schem : schems) {
|
||||
String waitTime = "<t:" + (schem.getLastUpdate().getTime() / 1000) + ":R>";
|
||||
system("CHECK_LIST_TO_CHECK", waitTime, schem.getSchemtype().getKuerzel(), SteamwarUser.byId(schem.getOwner()).getUserName(), schem.getName());
|
||||
lastSchematics.add(schem.getId());
|
||||
}
|
||||
for (SchematicNode schem : schems) {
|
||||
String waitTime = "<t:" + (schem.getLastUpdate().getTime() / 1000) + ":R>";
|
||||
system("CHECK_LIST_TO_CHECK", waitTime, schem.getSchemtype().getKuerzel(), SteamwarUser.byId(schem.getOwner()).getUserName(), schem.getName());
|
||||
lastSchematics.add(schem.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,8 @@ public class CouncilChannel extends StaticMessageChannel {
|
||||
});
|
||||
|
||||
return messageCreateBuilder;
|
||||
}, event -> {});
|
||||
}, event -> {
|
||||
});
|
||||
|
||||
channels.add(this);
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
package de.steamwar.velocitycore.discord.channels;
|
||||
|
||||
import de.steamwar.velocitycore.listeners.ChatListener;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.ChatterGroup;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.velocitycore.listeners.ChatListener;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -42,8 +42,7 @@ import java.util.stream.Collectors;
|
||||
public class EventChannel {
|
||||
|
||||
public MessageCreateBuilder get() {
|
||||
if (Event.get() == null)
|
||||
return updateComing();
|
||||
if (Event.get() == null) return updateComing();
|
||||
|
||||
return updateCurrent();
|
||||
}
|
||||
@@ -73,7 +72,7 @@ public class EventChannel {
|
||||
st.append("\nAngemeldete Teams: ").append(teilname);
|
||||
}
|
||||
embedBuilder.addField(event.getEventName(), st.toString(), false);
|
||||
if(event.getDeadline().after(Timestamp.from(Instant.now()))) {
|
||||
if (event.getDeadline().after(Timestamp.from(Instant.now()))) {
|
||||
menuBuilder.addOption(event.getEventName(), event.getEventID() + "", "An " + event.getEventName() + " teilnehmen", Emoji.fromUnicode("U+1F4DD"));
|
||||
}
|
||||
});
|
||||
@@ -81,7 +80,7 @@ public class EventChannel {
|
||||
MessageCreateBuilder messageBuilder = new MessageCreateBuilder()
|
||||
.setEmbeds(embedBuilder.build());
|
||||
|
||||
if(events.stream().anyMatch(event -> event.getDeadline().after(Timestamp.from(Instant.now())))) {
|
||||
if (events.stream().anyMatch(event -> event.getDeadline().after(Timestamp.from(Instant.now())))) {
|
||||
messageBuilder.setComponents(ActionRow.of(menuBuilder.build()));
|
||||
}
|
||||
return messageBuilder;
|
||||
@@ -105,7 +104,7 @@ public class EventChannel {
|
||||
|
||||
StringBuilder st = new StringBuilder();
|
||||
st.append("Fightbeginn: <t:").append(eventFight.getStartTime().getTime() / 1000).append(":R>");
|
||||
if(now.isAfter(eventFight.getStartTime().toInstant().plus(35, ChronoUnit.MINUTES))) {
|
||||
if (now.isAfter(eventFight.getStartTime().toInstant().plus(35, ChronoUnit.MINUTES))) {
|
||||
st.append("\n");
|
||||
if (eventFight.getErgebnis() == 1) {
|
||||
st.append("Sieg ").append(teamBlue.getTeamKuerzel());
|
||||
|
||||
@@ -48,15 +48,16 @@ public class InteractionReply extends DiscordChannel {
|
||||
|
||||
@Override
|
||||
public void sendMessage(Component msg) {
|
||||
if(!replied) {
|
||||
if (!replied) {
|
||||
messages.add(PlainTextComponentSerializer.plainText().serialize(msg));
|
||||
return;
|
||||
}
|
||||
|
||||
if(interaction.getHook().isExpired())
|
||||
if (interaction.getHook().isExpired()) {
|
||||
super.sendMessage(msg);
|
||||
else
|
||||
} else {
|
||||
interaction.getHook().sendMessage(PlainTextComponentSerializer.plainText().serialize(msg)).queue();
|
||||
}
|
||||
}
|
||||
|
||||
public void submit() {
|
||||
|
||||
+2
-2
@@ -28,7 +28,6 @@ import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||
import net.dv8tion.jda.api.utils.messages.MessageEditData;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -45,7 +44,8 @@ public class StaticMessageChannel extends DiscordChannel {
|
||||
private final Consumer<GenericComponentInteractionCreateEvent> interaction;
|
||||
|
||||
public StaticMessageChannel(String channel, Supplier<MessageCreateBuilder> supplier) {
|
||||
this(channel, supplier, event -> {});
|
||||
this(channel, supplier, event -> {
|
||||
});
|
||||
}
|
||||
|
||||
public StaticMessageChannel(String channel, Supplier<MessageCreateBuilder> supplier, Consumer<GenericComponentInteractionCreateEvent> interaction) {
|
||||
|
||||
@@ -46,46 +46,43 @@ public class ChannelListener extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
public void onMessageReceived(@NotNull MessageReceivedEvent event) {
|
||||
if(event.getAuthor().isBot())
|
||||
return;
|
||||
if (event.getAuthor().isBot()) return;
|
||||
|
||||
DiscordChannel channel = channels.get(event.getChannel());
|
||||
if(channel != null)
|
||||
channel.received(event);
|
||||
if (channel != null) channel.received(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) {
|
||||
if(event.getType() != InteractionType.COMPONENT)
|
||||
return;
|
||||
if (event.getType() != InteractionType.COMPONENT) return;
|
||||
|
||||
DiscordChannel channel = channels.get(event.getChannel());
|
||||
if(channel != null) {
|
||||
if (channel != null) {
|
||||
channel.received(event);
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.getChannelType() == ChannelType.PRIVATE && event.getComponentId().equals("tada"))
|
||||
if (event.getChannelType() == ChannelType.PRIVATE && event.getComponentId().equals("tada")) {
|
||||
event.reply(":tada:").queue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) {
|
||||
if (event.getGuild().getIdLong() == 1241489896909180998L) return;
|
||||
InteractionReply.reply(event, sender -> {
|
||||
if(sender.user().getDiscordId() == null)
|
||||
return;
|
||||
if (sender.user().getDiscordId() == null) return;
|
||||
|
||||
OptionMapping option = event.getOption(DiscordBot.ARGUMENT_NAME);
|
||||
String args = "";
|
||||
if(option != null)
|
||||
if (option != null) {
|
||||
args = option.getAsString();
|
||||
}
|
||||
|
||||
VelocityCore.getLogger().log(Level.INFO, "%s -> executed Discord command /%s %s".formatted(sender.user().getUserName(), event.getName(), args));
|
||||
SWCommand command = DiscordBot.getCommands().get(event.getName());
|
||||
UserPerm permission = command.getPermission();
|
||||
if(permission != null && !sender.user().perms().contains(permission))
|
||||
return;
|
||||
if (permission != null && !sender.user().perms().contains(permission)) return;
|
||||
|
||||
command.execute(sender, args.isEmpty() ? new String[0] : args.split(" "));
|
||||
});
|
||||
|
||||
+13
-10
@@ -19,19 +19,22 @@
|
||||
|
||||
package de.steamwar.velocitycore.discord.listeners;
|
||||
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.discord.channels.DiscordChannel;
|
||||
import de.steamwar.sql.NodeData;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.discord.channels.DiscordChannel;
|
||||
import dev.dewy.nbt.Nbt;
|
||||
import dev.dewy.nbt.tags.collection.CompoundTag;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -49,17 +52,16 @@ public class DiscordSchemUpload extends ListenerAdapter {
|
||||
if (event.isFromGuild()) return;
|
||||
|
||||
Message message = event.getMessage();
|
||||
if(message.getAttachments().isEmpty())
|
||||
return;
|
||||
if (message.getAttachments().isEmpty()) return;
|
||||
|
||||
DiscordChannel sender = new DiscordChannel(event.getAuthor());
|
||||
SteamwarUser user = sender.user();
|
||||
if(user.getId() == 0) {
|
||||
if (user.getId() == 0) {
|
||||
sender.system("DC_UNLINKED");
|
||||
return;
|
||||
}
|
||||
|
||||
if(user.isPunished(Punishment.PunishmentType.NoSchemReceiving)) {
|
||||
if (user.isPunished(Punishment.PunishmentType.NoSchemReceiving)) {
|
||||
sender.system("DC_SCHEMUPLOAD_NOPERM");
|
||||
return;
|
||||
}
|
||||
@@ -67,20 +69,21 @@ public class DiscordSchemUpload extends ListenerAdapter {
|
||||
for (Message.Attachment attachment : message.getAttachments()) {
|
||||
String fileName = attachment.getFileName();
|
||||
int dot = fileName.lastIndexOf('.');
|
||||
if(dot == -1 || !SCHEM_FILE_ENDINGS.contains(fileName.substring(dot).toLowerCase())) {
|
||||
if (dot == -1 || !SCHEM_FILE_ENDINGS.contains(fileName.substring(dot).toLowerCase())) {
|
||||
sender.system("DC_SCHEMUPLOAD_IGNORED", attachment.getFileName());
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = fileName.substring(0, dot);
|
||||
if(SchematicNode.invalidSchemName(new String[] {name})) {
|
||||
if (SchematicNode.invalidSchemName(new String[]{name})) {
|
||||
sender.system("DC_SCHEMUPLOAD_INVCHAR", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
SchematicNode node = SchematicNode.getSchematicNode(user.getId(), name, (Integer) null);
|
||||
if(node == null)
|
||||
if (node == null) {
|
||||
node = SchematicNode.createSchematic(user.getId(), name, null);
|
||||
}
|
||||
|
||||
try (InputStream in = attachment.getProxy().download().get()) {
|
||||
byte[] bytes = in.readAllBytes();
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
|
||||
package de.steamwar.velocitycore.discord.listeners;
|
||||
|
||||
import de.steamwar.sql.Event;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.discord.DiscordBot;
|
||||
import de.steamwar.velocitycore.discord.channels.InteractionReply;
|
||||
import de.steamwar.sql.Event;
|
||||
import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -33,10 +33,9 @@ public class DiscordTeamEvent extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
public void onStringSelectInteraction(@NotNull StringSelectInteractionEvent event) {
|
||||
if(!event.getChannel().getId().equals(eventsChannel))
|
||||
return;
|
||||
if (!event.getChannel().getId().equals(eventsChannel)) return;
|
||||
|
||||
if(event.getSelectedOptions().isEmpty()) {
|
||||
if (event.getSelectedOptions().isEmpty()) {
|
||||
event.deferReply(true).queue();
|
||||
return;
|
||||
}
|
||||
@@ -50,13 +49,13 @@ public class DiscordTeamEvent extends ListenerAdapter {
|
||||
return;
|
||||
}
|
||||
|
||||
if(reply.user().getId() == 0) {
|
||||
if (reply.user().getId() == 0) {
|
||||
reply.system("DC_UNLINKED");
|
||||
return;
|
||||
}
|
||||
|
||||
Event tournament = Event.byId(eventId);
|
||||
if(tournament == null){
|
||||
if (tournament == null) {
|
||||
reply.system("UNKNOWN_EVENT");
|
||||
return;
|
||||
}
|
||||
|
||||
+18
-18
@@ -86,7 +86,7 @@ public class DiscordTicketHandler extends ListenerAdapter {
|
||||
@Override
|
||||
public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) {
|
||||
MessageChannel messageChannel = event.getChannel();
|
||||
if(messageChannel instanceof TextChannel channel && channel.getParentCategoryIdLong() != 0 && channel.getParentCategoryId().equals(TICKET_CATEGORY) && event.getComponentId().startsWith("close-")) {
|
||||
if (messageChannel instanceof TextChannel channel && channel.getParentCategoryIdLong() != 0 && channel.getParentCategoryId().equals(TICKET_CATEGORY) && event.getComponentId().startsWith("close-")) {
|
||||
LinkedList<StringBuilder> messages = channel.getIterableHistory().reverse().complete().stream()
|
||||
.filter(message -> !message.getAuthor().isSystem() && !message.getAuthor().isBot())
|
||||
.map(message -> {
|
||||
@@ -96,7 +96,7 @@ public class DiscordTicketHandler extends ListenerAdapter {
|
||||
.append(message.getContentRaw())
|
||||
.append("\n");
|
||||
|
||||
if(!message.getAttachments().isEmpty()) {
|
||||
if (!message.getAttachments().isEmpty()) {
|
||||
message.getAttachments().forEach(attachment -> stringBuilder.append(attachment.getUrl()));
|
||||
stringBuilder.append("\n");
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class DiscordTicketHandler extends ListenerAdapter {
|
||||
.setTitle(event.getChannel().getName());
|
||||
|
||||
User user;
|
||||
if(channel.getTopic() != null && !channel.getTopic().isEmpty()) {
|
||||
if (channel.getTopic() != null && !channel.getTopic().isEmpty()) {
|
||||
user = event.getJDA().retrieveUserById(channel.getTopic()).complete();
|
||||
embedBuilder.setAuthor(user.getName(), null, user.getAvatarUrl());
|
||||
} else {
|
||||
@@ -122,12 +122,12 @@ public class DiscordTicketHandler extends ListenerAdapter {
|
||||
|
||||
TextChannel logChannel = event.getGuild().getTextChannelById(TICKET_LOG);
|
||||
SplitUtil.split(
|
||||
messages.stream()
|
||||
.map(StringBuilder::toString).collect(Collectors.joining()),
|
||||
2000,
|
||||
SplitUtil.Strategy.NEWLINE,
|
||||
SplitUtil.Strategy.ANYWHERE
|
||||
).stream().map(message -> new MessageCreateBuilder().setEmbeds(embedBuilder.setDescription(message).build()))
|
||||
messages.stream()
|
||||
.map(StringBuilder::toString).collect(Collectors.joining()),
|
||||
2000,
|
||||
SplitUtil.Strategy.NEWLINE,
|
||||
SplitUtil.Strategy.ANYWHERE
|
||||
).stream().map(message -> new MessageCreateBuilder().setEmbeds(embedBuilder.setDescription(message).build()))
|
||||
.forEach(builder -> {
|
||||
MessageCreateData createData = builder.build();
|
||||
logChannel.sendMessage(createData).queue();
|
||||
@@ -144,22 +144,22 @@ public class DiscordTicketHandler extends ListenerAdapter {
|
||||
@Override
|
||||
public void onMessageReceived(@NotNull MessageReceivedEvent event) {
|
||||
MessageChannel channel = event.getChannel();
|
||||
if(
|
||||
if (
|
||||
channel instanceof TextChannel textChannel &&
|
||||
textChannel.getParentCategoryIdLong() != 0 &&
|
||||
textChannel.getParentCategoryId().equals(TICKET_CATEGORY) &&
|
||||
!channel.getId().equals(TICKET_CHANNEL) &&
|
||||
!channel.getId().equals(TICKET_LOG)
|
||||
textChannel.getParentCategoryIdLong() != 0 &&
|
||||
textChannel.getParentCategoryId().equals(TICKET_CATEGORY) &&
|
||||
!channel.getId().equals(TICKET_CHANNEL) &&
|
||||
!channel.getId().equals(TICKET_LOG)
|
||||
) {
|
||||
if(event.getAuthor().isBot())
|
||||
return;
|
||||
if (event.getAuthor().isBot()) return;
|
||||
|
||||
ChatterGroup receivers = new ChatterGroup(Chatter.allStream().filter(player -> player.user().hasPerm(UserPerm.TICKET_LOG)));
|
||||
try {
|
||||
SteamwarUser user = SteamwarUser.get(Long.parseLong(textChannel.getTopic()));
|
||||
if(user != null && !user.perms().contains(UserPerm.TEAM))
|
||||
if (user != null && !user.perms().contains(UserPerm.TEAM)) {
|
||||
receivers = new ChatterGroup(receivers, Chatter.of(user));
|
||||
} catch(NumberFormatException e) {
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
//ignored
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
package de.steamwar.velocitycore.discord.util;
|
||||
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.discord.channels.DiscordChannel;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
@@ -57,8 +57,7 @@ public class AuthManager {
|
||||
|
||||
public User connectAuth(SteamwarUser user, String code) {
|
||||
User dcUser = TOKENS.remove(code);
|
||||
if(dcUser == null)
|
||||
return null;
|
||||
if (dcUser == null) return null;
|
||||
|
||||
user.setDiscordId(dcUser.getIdLong());
|
||||
|
||||
|
||||
@@ -40,12 +40,10 @@ public class DiscordAlert {
|
||||
public static void send(Chatter player, Color color, Message title, Message description, boolean success) {
|
||||
DiscordBot.withBot(bot -> {
|
||||
Long discordId = player.user().getDiscordId();
|
||||
if(discordId == null)
|
||||
return;
|
||||
if (discordId == null) return;
|
||||
|
||||
User user = DiscordBot.getInstance().getJda().retrieveUserById(discordId).complete();
|
||||
if(user == null)
|
||||
return;
|
||||
if (user == null) return;
|
||||
|
||||
MessageCreateBuilder builder = new MessageCreateBuilder()
|
||||
.setEmbeds(new EmbedBuilder()
|
||||
@@ -55,8 +53,9 @@ public class DiscordAlert {
|
||||
.setDescription(player.parseToPlain(description))
|
||||
.setTimestamp(Instant.now())
|
||||
.build());
|
||||
if(success)
|
||||
if (success) {
|
||||
builder.setComponents(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389"))));
|
||||
}
|
||||
|
||||
new DiscordChannel(user).send(builder);
|
||||
});
|
||||
|
||||
@@ -19,14 +19,16 @@
|
||||
|
||||
package de.steamwar.velocitycore.discord.util;
|
||||
|
||||
import de.steamwar.velocitycore.discord.DiscordBot;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import de.steamwar.velocitycore.discord.DiscordBot;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.exceptions.ErrorResponseException;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -36,8 +38,7 @@ public class DiscordRanks {
|
||||
private final Map<UserPerm.Prefix, String> prefixToPermName = UserPerm.prefixes.entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, entry -> entry.getKey().name().toLowerCase()));
|
||||
|
||||
public void update(SteamwarUser user) {
|
||||
if (user.getDiscordId() == null)
|
||||
return;
|
||||
if (user.getDiscordId() == null) return;
|
||||
|
||||
Set<String> swRoles = new HashSet<>(DiscordBot.getInstance().getConfig().getRanks().values());
|
||||
|
||||
@@ -49,11 +50,13 @@ public class DiscordRanks {
|
||||
.filter(role -> !role.getId().equals(prefixRole))
|
||||
.forEach(role -> guild.removeRoleFromMember(member, role).queue());
|
||||
|
||||
if (prefixRole != null && member.getRoles().stream().noneMatch(role -> role.getId().equals(prefixRole)))
|
||||
if (prefixRole != null && member.getRoles().stream().noneMatch(role -> role.getId().equals(prefixRole))) {
|
||||
guild.addRoleToMember(member, guild.getRoleById(prefixRole)).queue();
|
||||
}
|
||||
}, e -> {
|
||||
if(e instanceof ErrorResponseException err && err.getErrorCode() == 10007)
|
||||
if (e instanceof ErrorResponseException err && err.getErrorCode() == 10007) {
|
||||
user.setDiscordId(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ public class SWAnvilInv {
|
||||
openInv.get(packet.getPlayerId()).callback.accept(packet.getText());
|
||||
break;
|
||||
}
|
||||
} catch (NullPointerException ignored) { }
|
||||
} catch (NullPointerException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private final Player player;
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
|
||||
package de.steamwar.velocitycore.inventory;
|
||||
|
||||
import de.steamwar.messages.Message;
|
||||
import de.steamwar.velocitycore.network.NetworkSender;
|
||||
import de.steamwar.velocitycore.network.handlers.InventoryCallbackHandler;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.Message;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.network.packets.server.CloseInventoryPacket;
|
||||
import de.steamwar.network.packets.server.InventoryPacket;
|
||||
import de.steamwar.velocitycore.network.NetworkSender;
|
||||
import de.steamwar.velocitycore.network.handlers.InventoryCallbackHandler;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -69,17 +69,16 @@ public class SWInventory {
|
||||
}
|
||||
|
||||
public void handleCallback(InvCallback.ClickType type, int pos) {
|
||||
if(processingClick.compareAndSet(false, true)) {
|
||||
if (processingClick.compareAndSet(false, true)) {
|
||||
itemMap.get(pos).getCallback().clicked(type);
|
||||
processingClick.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleClose() {
|
||||
if(processingClick.compareAndSet(false, true)) {
|
||||
if (processingClick.compareAndSet(false, true)) {
|
||||
InventoryCallbackHandler.inventoryHashMap.remove(player.user().getId(), this);
|
||||
if(close != null)
|
||||
close.clicked(null);
|
||||
if (close != null) close.clicked(null);
|
||||
processingClick.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ package de.steamwar.velocitycore.inventory;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import de.steamwar.messages.Message;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.Message;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -41,7 +41,6 @@ public class SWItem {
|
||||
private List<Message> lore = new ArrayList<>();
|
||||
@Getter
|
||||
private InvCallback callback;
|
||||
private int color = 0;
|
||||
private int customModelData = 0;
|
||||
|
||||
public SWItem(String material, Message title) {
|
||||
@@ -49,11 +48,6 @@ public class SWItem {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public SWItem(Message title, int color) {
|
||||
this.title = title;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public static SWItem getSkull(String skullOwner) {
|
||||
SWItem item = new SWItem("SKULL", new Message("PLAIN_STRING", skullOwner));
|
||||
item.setSkullOwner(skullOwner);
|
||||
@@ -75,15 +69,16 @@ public class SWItem {
|
||||
object.addProperty("material", material);
|
||||
object.addProperty("position", position);
|
||||
object.addProperty("title", player.parseToLegacy(title));
|
||||
if(skullOwner != null)
|
||||
if (skullOwner != null) {
|
||||
object.addProperty("skullOwner", skullOwner);
|
||||
if(enchanted)
|
||||
}
|
||||
if (enchanted) {
|
||||
object.addProperty("enchanted", true);
|
||||
if(hideAttributes)
|
||||
}
|
||||
if (hideAttributes) {
|
||||
object.addProperty("hideAttributes", true);
|
||||
if(color != 0)
|
||||
object.addProperty("color", color);
|
||||
if(lore != null) {
|
||||
}
|
||||
if (lore != null) {
|
||||
JsonArray array = new JsonArray();
|
||||
for (Message lores : lore) {
|
||||
array.add(player.parseToLegacy(lores));
|
||||
|
||||
@@ -33,38 +33,42 @@ public class SWListInv<T> extends SWInventory {
|
||||
private final List<SWListEntry<T>> elements;
|
||||
private int page;
|
||||
|
||||
public SWListInv(PlayerChatter p, Message t, List<SWListEntry<T>> l, ListCallback<T> c){
|
||||
super(p, (l.size()>45) ? 54 : (l.size() + 9-l.size()%9), t);
|
||||
public SWListInv(PlayerChatter p, Message t, List<SWListEntry<T>> l, ListCallback<T> c) {
|
||||
super(p, (l.size() > 45) ? 54 : (l.size() + 9 - l.size() % 9), t);
|
||||
callback = c;
|
||||
elements = l;
|
||||
page = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(){
|
||||
if(elements.size() > 54){
|
||||
if(page != 0)
|
||||
addItem(45, new SWItem(new Message("INV_PAGE_BACK", "e"), 10), (InvCallback.ClickType click) -> {
|
||||
public void open() {
|
||||
if (elements.size() > 54) {
|
||||
if (page != 0) {
|
||||
addItem(45, new SWItem("LIME_DYE", new Message("INV_PAGE_BACK", "e")), (InvCallback.ClickType click) -> {
|
||||
page--;
|
||||
open();
|
||||
});
|
||||
else
|
||||
addItem(45, new SWItem(new Message("INV_PAGE_BACK", "7"), 8), (InvCallback.ClickType click) -> {});
|
||||
if(page < elements.size()/45)
|
||||
addItem(53, new SWItem(new Message("INV_PAGE_NEXT", "e"), 10), (InvCallback.ClickType click) -> {
|
||||
} else {
|
||||
addItem(45, new SWItem("GRAY_DYE", new Message("INV_PAGE_BACK", "7")), (InvCallback.ClickType click) -> {
|
||||
});
|
||||
}
|
||||
if (page < elements.size() / 45) {
|
||||
addItem(53, new SWItem("LIME_DYE", new Message("INV_PAGE_NEXT", "e")), (InvCallback.ClickType click) -> {
|
||||
page++;
|
||||
open();
|
||||
});
|
||||
else
|
||||
addItem(53, new SWItem(new Message("INV_PAGE_NEXT", "7"), 8), (InvCallback.ClickType click) -> {});
|
||||
} else {
|
||||
addItem(53, new SWItem("GRAY_DYE", new Message("INV_PAGE_NEXT", "7")), (InvCallback.ClickType click) -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
int ipageLimit = elements.size() - page*45;
|
||||
if(ipageLimit > 45 && elements.size() > 54){
|
||||
int ipageLimit = elements.size() - page * 45;
|
||||
if (ipageLimit > 45 && elements.size() > 54) {
|
||||
ipageLimit = 45;
|
||||
}
|
||||
int i = page*45;
|
||||
for(int ipage=0; ipage < ipageLimit; ipage++ ){
|
||||
int i = page * 45;
|
||||
for (int ipage = 0; ipage < ipageLimit; ipage++) {
|
||||
SWItem e = elements.get(i).getItem();
|
||||
|
||||
final int pos = i;
|
||||
@@ -75,7 +79,7 @@ public class SWListInv<T> extends SWInventory {
|
||||
super.open();
|
||||
}
|
||||
|
||||
public interface ListCallback<T>{
|
||||
public interface ListCallback<T> {
|
||||
void clicked(InvCallback.ClickType click, T element);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,26 +38,30 @@ public class SWStreamInv<T> extends SWInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(){
|
||||
public void open() {
|
||||
List<SWListInv.SWListEntry<T>> entries = constructor.apply(page);
|
||||
|
||||
if(page != 0)
|
||||
addItem(45, new SWItem(new Message("INV_PAGE_BACK", "e"), 10), (InvCallback.ClickType click) -> {
|
||||
if (page != 0) {
|
||||
addItem(45, new SWItem("LIME_DYE", new Message("INV_PAGE_BACK", "e")), (InvCallback.ClickType click) -> {
|
||||
page--;
|
||||
open();
|
||||
});
|
||||
else
|
||||
addItem(45, new SWItem(new Message("INV_PAGE_BACK", "7"), 8), (InvCallback.ClickType click) -> {});
|
||||
} else {
|
||||
addItem(45, new SWItem("GRAY_DYE", new Message("INV_PAGE_BACK", "7")), (InvCallback.ClickType click) -> {
|
||||
});
|
||||
}
|
||||
|
||||
if(entries.size() == 45)
|
||||
addItem(53, new SWItem(new Message("INV_PAGE_NEXT", "e"), 10), (InvCallback.ClickType click) -> {
|
||||
if (entries.size() == 45) {
|
||||
addItem(53, new SWItem("LIME_DYE", new Message("INV_PAGE_NEXT", "e")), (InvCallback.ClickType click) -> {
|
||||
page++;
|
||||
open();
|
||||
});
|
||||
else
|
||||
addItem(53, new SWItem(new Message("INV_PAGE_NEXT", "7"), 8), (InvCallback.ClickType click) -> {});
|
||||
} else {
|
||||
addItem(53, new SWItem("GRAY_DYE", new Message("INV_PAGE_NEXT", "7")), (InvCallback.ClickType click) -> {
|
||||
});
|
||||
}
|
||||
|
||||
for(int i = 0; i < entries.size(); i++) {
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
SWListInv.SWListEntry<T> item = entries.get(i);
|
||||
addItem(i, item.getItem());
|
||||
setCallback(i, (InvCallback.ClickType click) -> {
|
||||
|
||||
@@ -54,19 +54,20 @@ public class BanListener extends BasicListener {
|
||||
}
|
||||
|
||||
List<BannedUserIPs> ips = BannedUserIPs.get(ip);
|
||||
if(!ips.isEmpty()){
|
||||
if (!ips.isEmpty()) {
|
||||
Timestamp highestBan = ips.get(0).getTimestamp();
|
||||
boolean perma = false;
|
||||
for(BannedUserIPs banned : ips) {
|
||||
for (BannedUserIPs banned : ips) {
|
||||
SteamwarUser bannedUser = SteamwarUser.byId(banned.getUserID());
|
||||
if (bannedUser.isPunished(Punishment.PunishmentType.Ban)) {
|
||||
Punishment ban = bannedUser.getPunishment(Punishment.PunishmentType.Ban);
|
||||
if(ban.isPerma()) {
|
||||
if (ban.isPerma()) {
|
||||
perma = true;
|
||||
break;
|
||||
}
|
||||
if(ban.getEndTime().after(highestBan))
|
||||
if (ban.getEndTime().after(highestBan)) {
|
||||
highestBan = ban.getEndTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
ClickEvent clickEvent = ClickEvent.runCommand("/ban " + user.getUserName() + " "
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.ChatterGroup;
|
||||
@@ -64,14 +63,15 @@ public class ChatListener extends BasicListener {
|
||||
@Subscribe(order = PostOrder.FIRST)
|
||||
public void fixCommands(CommandExecuteEvent e) {
|
||||
String command = e.getCommand();
|
||||
if(command.startsWith("7")) {
|
||||
if (command.startsWith("7")) {
|
||||
command = "/" + command.substring(1);
|
||||
|
||||
CommandExecuteEvent.CommandResult result = e.getResult();
|
||||
if(result.isForwardToServer())
|
||||
if (result.isForwardToServer()) {
|
||||
result = CommandExecuteEvent.CommandResult.forwardToServer(command);
|
||||
else if(result.isAllowed())
|
||||
} else if (result.isAllowed()) {
|
||||
result = CommandExecuteEvent.CommandResult.command(command);
|
||||
}
|
||||
|
||||
e.setResult(result);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class ChatListener extends BasicListener {
|
||||
String command = e.getCommand();
|
||||
int space = command.indexOf(' ');
|
||||
String cmd = space != -1 ? command.substring(0, space) : command;
|
||||
if(VelocityCore.getProxy().getCommandManager().hasCommand(cmd)) {
|
||||
if (VelocityCore.getProxy().getCommandManager().hasCommand(cmd)) {
|
||||
CommandSource source = e.getCommandSource();
|
||||
String name;
|
||||
SteamwarUser user = null;
|
||||
@@ -129,16 +129,17 @@ public class ChatListener extends BasicListener {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (message.contains("jndi:ldap")) {
|
||||
PunishmentCommand.ban(user, Punishment.PERMA_TIME, "Versuchte Exploit-Ausnutzung", SteamwarUser.byId(-1), true);
|
||||
VelocityCore.getLogger().log(Level.SEVERE, "%s %s wurde automatisch wegen jndi:ldap gebannt.".formatted(user.getUserName(), user.getId()));
|
||||
VelocityCore.getLogger().log(Level.SEVERE, "%s %s wurde automatisch wegen jndi:ldap gebannt.".formatted(user.getUserName(), user.getId()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (isMistypedCommand(player, message))
|
||||
if (isMistypedCommand(player, message)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Subserver subserver = Subserver.getSubserver(player);
|
||||
String serverName = AuditLog.SERVER_NAME_VELOCITY;
|
||||
if(Subserver.isArena(subserver) && subserver.getServer() == player.getCurrentServer().orElseThrow().getServerInfo()) {
|
||||
if (Subserver.isArena(subserver) && subserver.getServer() == player.getCurrentServer().orElseThrow().getServerInfo()) {
|
||||
serverName = subserver.getServer().getName();
|
||||
localChat(Chatter.of(player), message);
|
||||
} else if (message.startsWith("+")) {
|
||||
@@ -156,13 +157,13 @@ public class ChatListener extends BasicListener {
|
||||
private static boolean isMistypedCommand(Player player, String message) {
|
||||
String command = message.substring(1);
|
||||
boolean isCommand = message.startsWith("7") && command.matches("^[7/]?[A-Za-z]+");
|
||||
if(isCommand && Boolean.FALSE.equals(VelocityCore.getProxy().getCommandManager().executeAsync(player, command).join())) {
|
||||
if(command.startsWith("7"))
|
||||
if (isCommand && Boolean.FALSE.equals(VelocityCore.getProxy().getCommandManager().executeAsync(player, command).join())) {
|
||||
if (command.startsWith("7")) {
|
||||
command = "/" + command.substring(1);
|
||||
}
|
||||
message = "/" + command;
|
||||
|
||||
if(filteredCommand(Chatter.of(player), message))
|
||||
return true;
|
||||
if (filteredCommand(Chatter.of(player), message)) return true;
|
||||
|
||||
player.spoofChatInput(message);
|
||||
}
|
||||
@@ -173,20 +174,18 @@ public class ChatListener extends BasicListener {
|
||||
public static void sendChat(Chatter sender, ChatterGroup receivers, String format, Chatter msgReceiver, String message) {
|
||||
SteamwarUser user = sender.user();
|
||||
final String coloredMessage = user.hasPerm(UserPerm.COLOR_CHAT) ? message.replace('&', '§') : message;
|
||||
if(chatFilter(sender, coloredMessage))
|
||||
return;
|
||||
if (chatFilter(sender, coloredMessage)) return;
|
||||
|
||||
boolean noReceiver = true;
|
||||
for(Chatter player : receivers.getChatters()) {
|
||||
if(player.chatShown()) {
|
||||
for (Chatter player : receivers.getChatters()) {
|
||||
if (player.chatShown()) {
|
||||
chatToReciever(player, msgReceiver, user, format, coloredMessage);
|
||||
if(sender.user().getId() != player.user().getId())
|
||||
noReceiver = false;
|
||||
if (sender.user().getId() != player.user().getId()) noReceiver = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(format.equals("CHAT_GLOBAL")) {
|
||||
if (format.equals("CHAT_GLOBAL")) {
|
||||
DiscordBot.withBot(bot -> chatToReciever(bot.getIngameChat(), msgReceiver, user, format, coloredMessage));
|
||||
} else if (format.equals("CHAT_SERVERTEAM")) {
|
||||
DiscordBot.withBot(bot -> chatToReciever(bot.getServerTeamChat(), msgReceiver, user, "CHAT_GLOBAL", coloredMessage));
|
||||
@@ -196,46 +195,46 @@ public class ChatListener extends BasicListener {
|
||||
}
|
||||
|
||||
public static void localChat(PlayerChatter sender, String message) {
|
||||
if(message.isEmpty()){
|
||||
if (message.isEmpty()) {
|
||||
sender.system("CHAT_BC_USAGE");
|
||||
return;
|
||||
}
|
||||
|
||||
if(ChatListener.filteredCommand(sender, message))
|
||||
return;
|
||||
if (ChatListener.filteredCommand(sender, message)) return;
|
||||
|
||||
if(!message.startsWith("/") && chatFilter(sender, message))
|
||||
return;
|
||||
if (!message.startsWith("/") && chatFilter(sender, message)) return;
|
||||
|
||||
sender.getPlayer().spoofChatInput(message);
|
||||
}
|
||||
|
||||
private static boolean chatFilter(Chatter sender, String message) {
|
||||
if(!sender.chatShown()) {
|
||||
if (!sender.chatShown()) {
|
||||
sender.system("CHAT_RECEIVE");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(message.replace("§[a-f0-9klmno]", "").trim().isEmpty()) {
|
||||
if (message.replace("§[a-f0-9klmno]", "").trim().isEmpty()) {
|
||||
sender.system("CHAT_EMPTY");
|
||||
return true;
|
||||
}
|
||||
|
||||
SteamwarUser user = sender.user();
|
||||
if(!user.hasPerm(UserPerm.TEAM) && (message.contains("http:") || message.contains("https:") || message.contains("www."))){
|
||||
if (!user.hasPerm(UserPerm.TEAM) && (message.contains("http:") || message.contains("https:") || message.contains("www."))) {
|
||||
sender.system("CHAT_NO_LINKS");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
|
||||
return true;
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) return true;
|
||||
|
||||
if (message.contains("LIXFEL"))
|
||||
if (message.contains("LIXFEL")) {
|
||||
specialAlert(sender, "Lixfel", "CHAT_LIXFEL_", 3, 6, 11, 12, 15);
|
||||
if (message.contains("YOYONOW"))
|
||||
}
|
||||
if (message.contains("YOYONOW")) {
|
||||
specialAlert(sender, "YoyoNow", "CHAT_YOYONOW_", 3, 6, 11, 12);
|
||||
if (message.contains("CHAOSCAOT"))
|
||||
}
|
||||
if (message.contains("CHAOSCAOT")) {
|
||||
specialAlert(sender, "Chaoscaot", "CHAT_CHAOSCAOT_", 3, 6, 11, 12, 15, 17);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -256,7 +255,7 @@ public class ChatListener extends BasicListener {
|
||||
|
||||
private static boolean filteredCommand(Chatter sender, String message) {
|
||||
String command = message.split(" ", 2)[0];
|
||||
if(command.startsWith("/") && command.contains(":")) {
|
||||
if (command.startsWith("/") && command.contains(":")) {
|
||||
sender.system("UNKNOWN_COMMAND");
|
||||
return true;
|
||||
}
|
||||
@@ -265,19 +264,18 @@ public class ChatListener extends BasicListener {
|
||||
|
||||
private static void specialAlert(Chatter sender, String name, String baseMessage, int... delay) {
|
||||
sender.system("CHAT_LIXFEL_ACTION_BAR");
|
||||
for(int i = 0; i < delay.length; i++) {
|
||||
for (int i = 0; i < delay.length; i++) {
|
||||
int finalI = i;
|
||||
VelocityCore.schedule( () -> sender.prefixless("CHAT_MSG", name, sender.user(), new Message(baseMessage + (finalI+1)))).delay(delay[i], TimeUnit.SECONDS).schedule();
|
||||
VelocityCore.schedule(() -> sender.prefixless("CHAT_MSG", name, sender.user(), new Message(baseMessage + (finalI + 1)))).delay(delay[i], TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
}
|
||||
|
||||
private static String highlightMentions(String message, String returnColor, Chatter player) {
|
||||
if(!message.contains("@"))
|
||||
return message;
|
||||
if (!message.contains("@")) return message;
|
||||
|
||||
String mark = "@" + player.user().getUserName();
|
||||
return Arrays.stream(message.split(" ")).map(cur -> {
|
||||
if(cur.equalsIgnoreCase(mark) && player.getPlayer() != null) {
|
||||
if (cur.equalsIgnoreCase(mark) && player.getPlayer() != null) {
|
||||
NetworkSender.send(player.getPlayer(), new PingPacket(player.user().getId()));
|
||||
return "§e" + cur + returnColor;
|
||||
}
|
||||
@@ -286,15 +284,16 @@ public class ChatListener extends BasicListener {
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onTabCompleteResponseEvent(TabCompleteEvent e){
|
||||
public void onTabCompleteResponseEvent(TabCompleteEvent e) {
|
||||
List<String> suggestions = e.getSuggestions();
|
||||
int i = 0;
|
||||
while (i < suggestions.size()) {
|
||||
String suggestion = suggestions.get(i);
|
||||
if(suggestion.startsWith("/") && suggestion.contains(":"))
|
||||
if (suggestion.startsWith("/") && suggestion.contains(":")) {
|
||||
suggestions.remove(i);
|
||||
else
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,33 +39,37 @@ import java.util.List;
|
||||
public class CheckListener extends BasicListener {
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerJoin(PostLoginEvent e){
|
||||
public void onPlayerJoin(PostLoginEvent e) {
|
||||
Chatter sender = Chatter.of(e.getPlayer());
|
||||
|
||||
List<SchematicNode> uncheckedSchematics = new ArrayList<>();
|
||||
for(SchematicType type : SchematicType.values()){
|
||||
if(type.check())
|
||||
for (SchematicType type : SchematicType.values()) {
|
||||
if (type.check()) {
|
||||
uncheckedSchematics.addAll(SchematicNode.getAllSchematicsOfType(sender.user().getId(), type.toDB()));
|
||||
}
|
||||
}
|
||||
|
||||
if(!uncheckedSchematics.isEmpty())
|
||||
if (!uncheckedSchematics.isEmpty()) {
|
||||
sender.system("CHECK_UNCHECKED", uncheckedSchematics.size());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onServerSwitch(ServerConnectedEvent e){
|
||||
Player player = e.getPlayer();
|
||||
if(CheckCommand.isChecking(player)){
|
||||
Subserver server = Subserver.getSubserver(e.getServer().getServerInfo());
|
||||
if(!Subserver.isBuild(server) || ((Bauserver)server).getOwner() != player.getUniqueId())
|
||||
CheckCommand.abort(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerDisconnect(DisconnectEvent e){
|
||||
public void onServerSwitch(ServerConnectedEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if(CheckCommand.isChecking(player))
|
||||
if (CheckCommand.isChecking(player)) {
|
||||
Subserver server = Subserver.getSubserver(e.getServer().getServerInfo());
|
||||
if (!Subserver.isBuild(server) || ((Bauserver) server).getOwner() != player.getUniqueId()) {
|
||||
CheckCommand.abort(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerDisconnect(DisconnectEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if (CheckCommand.isChecking(player)) {
|
||||
CheckCommand.abort(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ConnectionListener extends BasicListener {
|
||||
|
||||
private static final Set<UUID> newPlayers = new HashSet<>();
|
||||
|
||||
public static void newPlayer(UUID player){
|
||||
public static void newPlayer(UUID player) {
|
||||
newPlayers.add(player);
|
||||
}
|
||||
|
||||
@@ -60,16 +60,18 @@ public class ConnectionListener extends BasicListener {
|
||||
@Subscribe
|
||||
public void onPermissionSetup(PermissionsSetupEvent event) {
|
||||
event.setProvider(subject -> {
|
||||
if(!(subject instanceof Player player))
|
||||
if (!(subject instanceof Player player)) {
|
||||
return perm -> Tristate.TRUE;
|
||||
}
|
||||
|
||||
Set<UserPerm> perms = SteamwarUser.getOrCreate(player.getUniqueId(), player.getUsername(), ConnectionListener::newPlayer).perms();
|
||||
if(perms.contains(UserPerm.ADMINISTRATION))
|
||||
if (perms.contains(UserPerm.ADMINISTRATION)) {
|
||||
return perm -> Tristate.TRUE;
|
||||
else if(perms.contains(UserPerm.TEAM))
|
||||
} else if (perms.contains(UserPerm.TEAM)) {
|
||||
return perm -> Tristate.fromBoolean(TEAM_PERMISSIONS.contains(perm));
|
||||
else
|
||||
} else {
|
||||
return perm -> Tristate.FALSE;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -79,18 +81,17 @@ public class ConnectionListener extends BasicListener {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Chatter chatter = Chatter.of(player);
|
||||
|
||||
if(user.hasPerm(UserPerm.CHECK))
|
||||
CheckCommand.sendReminder(chatter);
|
||||
if (user.hasPerm(UserPerm.CHECK)) CheckCommand.sendReminder(chatter);
|
||||
|
||||
for(Subserver subserver : Subserver.getServerList()) {
|
||||
if(Subserver.isArena(subserver)) {
|
||||
for (Subserver subserver : Subserver.getServerList()) {
|
||||
if (Subserver.isArena(subserver)) {
|
||||
chatter.system("JOIN_ARENA", new Message("JOIN_ARENA_HOVER"), ClickEvent.runCommand("/arena " + subserver.getServer().getName()), subserver.getServer().getName());
|
||||
}
|
||||
}
|
||||
|
||||
for (CheckedSchematic checkedSchematic : CheckedSchematic.getUnseen(user)) {
|
||||
SchematicType type = SchematicType.fromDB(checkedSchematic.getNodeType());
|
||||
if(type == null) continue;
|
||||
if (type == null) continue;
|
||||
if (checkedSchematic.getDeclineReason().equals("freigegeben")) {
|
||||
chatter.system("CHECK_ACCEPTED", type.name(), checkedSchematic.getSchemName());
|
||||
} else {
|
||||
@@ -100,7 +101,7 @@ public class ConnectionListener extends BasicListener {
|
||||
checkedSchematic.setSeen(true);
|
||||
}
|
||||
|
||||
if(newPlayers.contains(player.getUniqueId())){
|
||||
if (newPlayers.contains(player.getUniqueId())) {
|
||||
Chatter.broadcast().system("JOIN_FIRST", player);
|
||||
newPlayers.remove(player.getUniqueId());
|
||||
}
|
||||
@@ -124,7 +125,7 @@ public class ConnectionListener extends BasicListener {
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onDisconnect(DisconnectEvent e){
|
||||
public void onDisconnect(DisconnectEvent e) {
|
||||
ChallengeCommand.remove(e.getPlayer());
|
||||
MsgCommand.remove(e.getPlayer());
|
||||
ModUtils.getPlayerModMap().remove(e.getPlayer().getUniqueId());
|
||||
|
||||
@@ -36,10 +36,8 @@ public class CookieEvents extends BasicListener {
|
||||
@Subscribe
|
||||
public void handleCookies(CookieReceiveEvent e) {
|
||||
System.out.println(e.getOriginalKey() + " " + e.getOriginalData());
|
||||
if (!e.getOriginalKey().namespace().equals(EventModeListener.EVENT_TO_SPECTATE_KEY.namespace()))
|
||||
return;
|
||||
if (!e.getOriginalKey().value().equals(EventModeListener.EVENT_TO_SPECTATE_KEY.value()))
|
||||
return;
|
||||
if (!e.getOriginalKey().namespace().equals(EventModeListener.EVENT_TO_SPECTATE_KEY.namespace())) return;
|
||||
if (!e.getOriginalKey().value().equals(EventModeListener.EVENT_TO_SPECTATE_KEY.value())) return;
|
||||
e.setResult(CookieReceiveEvent.ForwardResult.handled());
|
||||
Player player = e.getPlayer();
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
|
||||
@@ -74,8 +74,7 @@ public class EventModeListener extends BasicListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Referee.get(event.getEventID()).contains(user.getId()))
|
||||
return;
|
||||
if (Referee.get(event.getEventID()).contains(user.getId())) return;
|
||||
|
||||
if (player.getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_20_5)) {
|
||||
sender.system("EVENTMODE_KICK");
|
||||
@@ -94,8 +93,7 @@ public class EventModeListener extends BasicListener {
|
||||
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Event event = Event.get();
|
||||
if (event != null && Referee.get(event.getEventID()).contains(user.getId()))
|
||||
return;
|
||||
if (event != null && Referee.get(event.getEventID()).contains(user.getId())) return;
|
||||
|
||||
List<EventFight> activeFights = EventFight.getActiveFights();
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class IPSanitizer extends BasicListener {
|
||||
private static final Map<UUID, InetAddress> trueAddress = new HashMap<>(); // Will likely slightly leak over time
|
||||
|
||||
public static InetAddress getTrueAddress(Player player) {
|
||||
return trueAddress.getOrDefault(player.getUniqueId(), ((InetSocketAddress) ((ConnectedPlayer)player).getConnection().getChannel().remoteAddress()).getAddress());
|
||||
return trueAddress.getOrDefault(player.getUniqueId(), ((InetSocketAddress) ((ConnectedPlayer) player).getConnection().getChannel().remoteAddress()).getAddress());
|
||||
}
|
||||
|
||||
private static final Reflection.Field<MinecraftConnection, SocketAddress> remoteAddress = new Reflection.Field<>(MinecraftConnection.class, "remoteAddress");
|
||||
|
||||
@@ -90,7 +90,8 @@ public class PluginMessage extends BasicListener {
|
||||
|
||||
private static final Parser UNKNOWN = event -> VelocityCore.getLogger().log(Level.WARNING, () -> "Undefined PluginMessage on channel " + event.getIdentifier() + " from " + event.getSource() + " received.\n" + new String(event.getData()) + "\n" + Arrays.toString(event.getData()));
|
||||
private static final Parser PASS_THROUGH = event -> event.setResult(PluginMessageEvent.ForwardResult.forward());
|
||||
private static final Parser DROP = event -> {};
|
||||
private static final Parser DROP = event -> {
|
||||
};
|
||||
|
||||
private final Lunar lunar = new Lunar();
|
||||
private final Badlion badlion = new Badlion();
|
||||
@@ -105,7 +106,7 @@ public class PluginMessage extends BasicListener {
|
||||
|
||||
knownBrands.addAll(Arrays.asList("vanilla", "badlion", "fabric", "quilt", "forge", "optifine", "Geyser", "labymod", "Feather Fabric"));
|
||||
|
||||
for(String channel : Arrays.asList(
|
||||
for (String channel : Arrays.asList(
|
||||
"fabric:container/open", "fabric:registry/sync/direct", "fabric:registry/sync",
|
||||
"fabric-screen-handler-api-v1:open_screen", "fabric:attachment_sync_v1",
|
||||
|
||||
@@ -346,12 +347,13 @@ public class PluginMessage extends BasicListener {
|
||||
"imm_ptl:remote_cts", //https://www.curseforge.com/minecraft/mc-mods/immersive-portals-mod
|
||||
"distant_horizons:message", "tcdcommons:cpn"
|
||||
))
|
||||
channelRegisterHandlers.put(channel, player -> {});
|
||||
channelRegisterHandlers.put(channel, player -> {
|
||||
});
|
||||
|
||||
//channelRegisterHandlers.put(Lunar.CHANNEL, lunar::sendRestrictions);
|
||||
channelRegisterHandlers.put(Feather.CHANNEL, new Feather()::sendRestrictions);
|
||||
channelRegisterHandlers.put("openboatutils:settings", player -> send(player, "openboatutils:settings", new byte[] { 0, 0 })); //https://github.com/o7Moon/OpenBoatUtils/wiki/Packets (Reset packet)
|
||||
channelRegisterHandlers.put("itemswapper:disable", player -> send(player, "itemswapper:disable", new byte[]{ 0 })); //https://github.com/tr7zw/ItemSwapper/blob/main/src/main/java/dev/tr7zw/itemswapper/packets/DisableModPayload.java
|
||||
channelRegisterHandlers.put("openboatutils:settings", player -> send(player, "openboatutils:settings", new byte[]{0, 0})); //https://github.com/o7Moon/OpenBoatUtils/wiki/Packets (Reset packet)
|
||||
channelRegisterHandlers.put("itemswapper:disable", player -> send(player, "itemswapper:disable", new byte[]{0})); //https://github.com/tr7zw/ItemSwapper/blob/main/src/main/java/dev/tr7zw/itemswapper/packets/DisableModPayload.java
|
||||
channelRegisterHandlers.put("xaerominimap:main", player -> player.sendMessage(Component.text("§n§o§m§i§n§i§m§a§p"))); //https://www.curseforge.com/minecraft/mc-mods/xaeros-minimap
|
||||
channelRegisterHandlers.put("xaeroworldmap:main", player -> player.sendMessage(Component.text("§n§o§m§i§n§i§m§a§p"))); //https://www.curseforge.com/minecraft/mc-mods/xaeros-minimap
|
||||
channelRegisterHandlers.put("litemoretica:init_easy_place", player -> Chatter.disconnect(player).prefixless("MOD_YELLOW_SING", "litematica")); //https://github.com/Earthcomputer/litemoretica/tree/master
|
||||
@@ -361,7 +363,7 @@ public class PluginMessage extends BasicListener {
|
||||
channelRegisterHandlers.put("inventoryessentials:hello", player -> Chatter.disconnect(player).prefixless("MOD_YELLOW_SING", "InventoryEssentials")); //https://github.com/TwelveIterationMods/InventoryEssentials
|
||||
channelRegisterHandlers.put(Controlify.CHANNEL, new Controlify()::onRegister);
|
||||
|
||||
for(String channel : Arrays.asList(
|
||||
for (String channel : Arrays.asList(
|
||||
"worldinfo:world_id", // JourneyMap and VoxelMap
|
||||
"journeymap:version", "journeymap:admin_req", "journeymap:mp_options_req", "journeymap:waypoint",
|
||||
"journeymap:player_loc", "journeymap:admin_save", "journeymap:teleport_req", "journeymap:common",
|
||||
@@ -374,7 +376,7 @@ public class PluginMessage extends BasicListener {
|
||||
Chatter.disconnect(player).prefixless("MOD_YELLOW_SING", "norisk client");
|
||||
});
|
||||
|
||||
for(String channel : Arrays.asList(
|
||||
for (String channel : Arrays.asList(
|
||||
"flashback:remote_food_data",
|
||||
"flashback:remote_set_slot",
|
||||
"flashback:force_client_tick",
|
||||
@@ -393,8 +395,10 @@ public class PluginMessage extends BasicListener {
|
||||
}
|
||||
});
|
||||
|
||||
for(String channel : Arrays.asList("bedrockify:cauldron_particles", "bedrockify:eat-particles")) //https://github.com/juancarloscp52/BedrockIfy (Bedrock features on Java, banned for reach-around block placement)
|
||||
for (String channel : Arrays.asList("bedrockify:cauldron_particles", "bedrockify:eat-particles")) {
|
||||
//https://github.com/juancarloscp52/BedrockIfy (Bedrock features on Java, banned for reach-around block placement)
|
||||
channelRegisterHandlers.put(channel, player -> Chatter.disconnect(player).prefixless("MOD_YELLOW_SING", "bedrockify"));
|
||||
}
|
||||
|
||||
registerBiDirPassthrough("WECUI", "worldedit:cui", "worldedit:internal", "minecraft:wecui");
|
||||
|
||||
@@ -407,7 +411,7 @@ public class PluginMessage extends BasicListener {
|
||||
"axiom:register_world"
|
||||
);
|
||||
registerBiDirPassthrough("axiom:handle_big_payload", "axiom:set_editor_views", "axiom:update_available_dispatch_sends");
|
||||
for(String channel : Arrays.asList(
|
||||
for (String channel : Arrays.asList(
|
||||
"axiom:hello", "axiom:set_gamemode", "axiom:set_fly_speed", "axiom:set_world_time",
|
||||
"axiom:set_world_property", "axiom:set_block", "axiom:set_hotbar_slot", "axiom:switch_active_hotbar",
|
||||
"axiom:teleport", "axiom:request_chunk_data", "axiom:spawn_entity", "axiom:response_entity_data",
|
||||
@@ -415,11 +419,12 @@ public class PluginMessage extends BasicListener {
|
||||
"axiom:allowed_gamemodes", "axiom:ignore_display_entities", "axiom:add_server_heightmap", "axiom:set_no_physical_trigger",
|
||||
"axiom:request_blueprint", "axiom:request_entity_data", "axiom:upload_blueprint"
|
||||
)) {
|
||||
channelRegisterHandlers.put(channel, player -> {});
|
||||
channelRegisterHandlers.put(channel, player -> {
|
||||
});
|
||||
registerPassthroughToServer(channel);
|
||||
}
|
||||
|
||||
for(String channel : Arrays.asList(
|
||||
for (String channel : Arrays.asList(
|
||||
"floodgate:skin",
|
||||
"watut:nbt", "watut:nbt_server", //https://github.com/Corosauce/WATUT
|
||||
"bclib:hello_server",
|
||||
@@ -429,11 +434,12 @@ public class PluginMessage extends BasicListener {
|
||||
"hyevent:location", "hyevent:register", // Hypixel mods (I could not find which sadly)
|
||||
"hypixel:hello", "hypixel:party_info", "hypixel:ping", "hypixel:player_info", "hypixel:register", "hypixel:party_info", "hypixel:player_info", "hypixel:ping" // Hypixel mods (I could not find which sadly)
|
||||
)) {
|
||||
channelRegisterHandlers.put(channel, player -> {});
|
||||
channelRegisterHandlers.put(channel, player -> {
|
||||
});
|
||||
register(channel, false, directional(UNKNOWN, DROP));
|
||||
}
|
||||
|
||||
for(String channel : Arrays.asList(
|
||||
for (String channel : Arrays.asList(
|
||||
"UNREGISTER", "minecraft:unregister", // used by carpet and servux
|
||||
"WDL|REQUEST", "wdl:request",
|
||||
"minecraft:intave", //undocumented, byte stringlength, clientconfig, byte length, json {"legacySneakHeight":false,"legacyOldRange":false,"legacyOldSlowdown":false}
|
||||
@@ -493,7 +499,7 @@ public class PluginMessage extends BasicListener {
|
||||
public void onClientChannelRegister(PlayerChannelRegisterEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
for(ChannelIdentifier channel : event.getChannels()) {
|
||||
for (ChannelIdentifier channel : event.getChannels()) {
|
||||
channelRegisterHandlers.getOrDefault(channel.getId(), p -> VelocityCore.getLogger().log(Level.WARNING, () -> p.getUsername() + " registered unknown channel " + channel)).accept(player);
|
||||
}
|
||||
}
|
||||
@@ -516,33 +522,38 @@ public class PluginMessage extends BasicListener {
|
||||
String brand = event.getBrand();
|
||||
|
||||
VelocityCore.getLogger().log(knownBrands.contains(brand) ? Level.INFO : Level.WARNING, () -> player.getUsername() + " joins with brand: " + brand);
|
||||
if(brand.equals("badlion"))
|
||||
if (brand.equals("badlion")) {
|
||||
badlion.sendRestrictions(player);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerPassthroughToClient(String... channels) {
|
||||
for(String channel : channels) {
|
||||
channelRegisterHandlers.put(channel, player -> {});
|
||||
for (String channel : channels) {
|
||||
channelRegisterHandlers.put(channel, player -> {
|
||||
});
|
||||
register(channel, false, directional(PASS_THROUGH, UNKNOWN));
|
||||
}
|
||||
}
|
||||
|
||||
private void registerPassthroughToServer(String... channels) {
|
||||
for(String channel : channels)
|
||||
for (String channel : channels) {
|
||||
register(channel, false, directional(UNKNOWN, PASS_THROUGH));
|
||||
}
|
||||
}
|
||||
|
||||
private void registerBiDirPassthrough(String... channels) {
|
||||
for(String channel : channels) {
|
||||
channelRegisterHandlers.put(channel, player -> {});
|
||||
for (String channel : channels) {
|
||||
channelRegisterHandlers.put(channel, player -> {
|
||||
});
|
||||
register(channel, false, PASS_THROUGH);
|
||||
}
|
||||
}
|
||||
|
||||
private void register(String channel, boolean clientSideRegister, Parser handler) {
|
||||
handlers.put(channel, handler);
|
||||
if(clientSideRegister)
|
||||
if (clientSideRegister) {
|
||||
VelocityCore.getProxy().getChannelRegistrar().register(channel.indexOf(':') != -1 ? MinecraftChannelIdentifier.from(channel) : new LegacyChannelIdentifier(channel));
|
||||
}
|
||||
}
|
||||
|
||||
private void serverRegistersChannel(PluginMessageEvent event) {
|
||||
@@ -562,10 +573,11 @@ public class PluginMessage extends BasicListener {
|
||||
|
||||
private Parser directional(Parser fromServer, Parser fromPlayer) {
|
||||
return event -> {
|
||||
if(event.getSource() instanceof Player)
|
||||
if (event.getSource() instanceof Player) {
|
||||
fromPlayer.handle(event);
|
||||
else
|
||||
} else {
|
||||
fromServer.handle(event);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.AuditLog;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.sql.Session;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
@@ -37,16 +37,16 @@ import static de.steamwar.persistent.Storage.sessions;
|
||||
public class SessionManager extends BasicListener {
|
||||
|
||||
@Subscribe
|
||||
public void onPostLogin(PostLoginEvent event){
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
sessions.put(event.getPlayer(), Timestamp.from(Instant.now()));
|
||||
AuditLog.createJoin(AuditLog.SERVER_NAME_VELOCITY, null, SteamwarUser.get(event.getPlayer().getUniqueId()));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onDisconnect(DisconnectEvent e){
|
||||
public void onDisconnect(DisconnectEvent e) {
|
||||
AuditLog.createLeave(AuditLog.SERVER_NAME_VELOCITY, null, SteamwarUser.get(e.getPlayer().getUniqueId()));
|
||||
Timestamp timestamp = sessions.remove(e.getPlayer());
|
||||
if(timestamp != null) {
|
||||
if (timestamp != null) {
|
||||
VelocityCore.schedule(() -> Session.insertSession(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), timestamp)).schedule();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.player.PlayerSettingsChangedEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.network.NetworkSender;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
||||
|
||||
@Linked
|
||||
public class SettingsChangedListener extends BasicListener {
|
||||
|
||||
@@ -100,7 +100,7 @@ public class TexturePackSystem extends BasicListener {
|
||||
|
||||
for (int i = 0; i < len; i += 2) {
|
||||
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
|
||||
+ Character.digit(s.charAt(i+1), 16));
|
||||
+ Character.digit(s.charAt(i + 1), 16));
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
@@ -56,11 +56,9 @@ public class VersionAnnouncer extends BasicListener {
|
||||
}).delay(Duration.of(100, ChronoUnit.MILLIS)).schedule();
|
||||
}
|
||||
|
||||
if(playerVersion == serverVersion)
|
||||
return;
|
||||
if (playerVersion == serverVersion) return;
|
||||
|
||||
if(!Subserver.isBuild(Subserver.getSubserver(server)))
|
||||
return;
|
||||
if (!Subserver.isBuild(Subserver.getSubserver(server))) return;
|
||||
|
||||
player.sendActionBar(Chatter.of(player).parse("SERVER_VERSION", ProtocolVersion.getProtocolVersion(serverVersion).getMostRecentSupportedVersion()));
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@ public class Alpine {
|
||||
public static final String HANDSHAKE = "ac:handshake";
|
||||
public static final String PLAY = "ac:play";
|
||||
|
||||
private final byte[] magicHandshakeResponse = new byte[] {0x3A, 0x3D}; //https://github.com/alpine-client/alpine-client-api/blob/master/src/main/java/com/alpineclient/plugin/listener/plugin/HandshakeListener.java#L19
|
||||
private final byte[] magicHandshakeResponse = new byte[]{0x3A, 0x3D}; //https://github.com/alpine-client/alpine-client-api/blob/master/src/main/java/com/alpineclient/plugin/listener/plugin/HandshakeListener.java#L19
|
||||
private final byte[] modulesPacket;
|
||||
|
||||
public Alpine() {
|
||||
//https://github.com/alpine-client/alpine-client-api/blob/master/MODULES.md
|
||||
String[] disabledModules = new String[] {
|
||||
String[] disabledModules = new String[]{
|
||||
"armor_status", "cannon_playback", "cannon_view", "clear_water", "explosion_boxes", "fullbright",
|
||||
"hit_color", "inventory_tweaks", "low_hp_tint", "minimap", "perspective_mod", "potion_status",
|
||||
"reach_display", "schematica", "tnt_timer", "toggle_sneak_sprint"
|
||||
|
||||
@@ -32,8 +32,9 @@ public class Controlify {
|
||||
public static final String CHANNEL = "controlify:server_policy";
|
||||
|
||||
private final byte[][] packets;
|
||||
|
||||
public Controlify() {
|
||||
packets = new byte[][] {
|
||||
packets = new byte[][]{
|
||||
restrict("reachAround"),
|
||||
restrict("disableFlyDrifting")
|
||||
};
|
||||
@@ -47,7 +48,8 @@ public class Controlify {
|
||||
}
|
||||
|
||||
public void onRegister(Player player) {
|
||||
for(byte[] packet : packets)
|
||||
for (byte[] packet : packets) {
|
||||
player.sendPluginMessage(MinecraftChannelIdentifier.from(CHANNEL), packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.listeners.BasicListener;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.listeners.BasicListener;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -53,15 +53,16 @@ public class FML extends BasicListener {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
synchronized (unlocked) {
|
||||
if(unlocked.contains(player.getUniqueId())){
|
||||
if (unlocked.contains(player.getUniqueId())) {
|
||||
unlocked.remove(player.getUniqueId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//if(isFML(player, "\0FML\0"))
|
||||
if(player.getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_13))
|
||||
if (player.getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_13)) {
|
||||
player.sendPluginMessage(new LegacyChannelIdentifier(CHANNEL), helloPacket);
|
||||
}
|
||||
}
|
||||
|
||||
public void handlePluginMessage(PluginMessageEvent event) {
|
||||
@@ -72,7 +73,7 @@ public class FML extends BasicListener {
|
||||
int numMods = ProtocolUtils.readVarInt(buf);
|
||||
|
||||
List<Mod> mods = new ArrayList<>();
|
||||
for(int i = 0; i < numMods; i++) {
|
||||
for (int i = 0; i < numMods; i++) {
|
||||
String name = ProtocolUtils.readString(buf);
|
||||
ProtocolUtils.readString(buf); // version
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.proxy.connection.client.LoginInboundConnection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.listeners.BasicListener;
|
||||
import de.steamwar.velocitycore.listeners.PluginMessage;
|
||||
import de.steamwar.sql.Mod;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -78,12 +78,11 @@ public class FML2 extends BasicListener {
|
||||
boolean fml2 = isFML(connection, "\0FML2\0");
|
||||
boolean fml3 = isFML(connection, "\0FML3\0");
|
||||
boolean forge = isFML(connection, "\0FORGE");
|
||||
if(!fml2 && !fml3 && !forge)
|
||||
return;
|
||||
if (!fml2 && !fml3 && !forge) return;
|
||||
|
||||
FML2LoginHandler handler = new FML2LoginHandler(connection, event.getUniqueId(), forge);
|
||||
|
||||
if(forge) {
|
||||
if (forge) {
|
||||
connection.sendLoginPluginMessage(MinecraftChannelIdentifier.from("forge:login"), forgeModListPacket, handler);
|
||||
} else {
|
||||
connection.sendLoginPluginMessage(MinecraftChannelIdentifier.from("fml:loginwrapper"), fml3 ? fml3ModListPacket : fml2ModListPacket, handler);
|
||||
@@ -98,8 +97,8 @@ public class FML2 extends BasicListener {
|
||||
packet.writeByte(1); // Mod list packet
|
||||
ProtocolUtils.writeVarInt(packet, 0); // Mod amount
|
||||
|
||||
if(fml3) {
|
||||
ProtocolUtils.writeVarInt(packet,1); // Channel amount
|
||||
if (fml3) {
|
||||
ProtocolUtils.writeVarInt(packet, 1); // Channel amount
|
||||
ProtocolUtils.writeString(packet, "forge:tier_sorting");
|
||||
ProtocolUtils.writeString(packet, "1.0");
|
||||
} else {
|
||||
@@ -107,8 +106,9 @@ public class FML2 extends BasicListener {
|
||||
}
|
||||
|
||||
ProtocolUtils.writeVarInt(packet, 0); // Registries amount
|
||||
if(fml3)
|
||||
if (fml3) {
|
||||
ProtocolUtils.writeVarInt(packet, 0); // DataPacks amount
|
||||
}
|
||||
|
||||
ProtocolUtils.writeVarInt(buf, packet.readableBytes());
|
||||
buf.writeBytes(packet);
|
||||
@@ -129,28 +129,28 @@ public class FML2 extends BasicListener {
|
||||
|
||||
@Override
|
||||
public void onMessageResponse(byte[] data) {
|
||||
if(data == null) {
|
||||
if (data == null) {
|
||||
abort(null, "Not FML2/3 client");
|
||||
return;
|
||||
}
|
||||
|
||||
ByteBuf buf = Unpooled.wrappedBuffer(data);
|
||||
if(forge && buf.readByte() != 0) {
|
||||
if (forge && buf.readByte() != 0) {
|
||||
abort(data, "Not FORGE login wrapper");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!ProtocolUtils.readString(buf).equals(forge ? "forge:handshake" : "fml:handshake")) {
|
||||
if (!ProtocolUtils.readString(buf).equals(forge ? "forge:handshake" : "fml:handshake")) {
|
||||
abort(data, "Not FML2/3/FORGE handshake response");
|
||||
return;
|
||||
}
|
||||
|
||||
if(ProtocolUtils.readVarInt(buf) != buf.readableBytes()) {
|
||||
if (ProtocolUtils.readVarInt(buf) != buf.readableBytes()) {
|
||||
abort(data, "FML2/3/FORGE packet size mismatch");
|
||||
return;
|
||||
}
|
||||
|
||||
if(ProtocolUtils.readVarInt(buf) != (forge ? /* Mod Versions */ 1 : /* Mod List Reply */ 2)) {
|
||||
if (ProtocolUtils.readVarInt(buf) != (forge ? /* Mod Versions */ 1 : /* Mod List Reply */ 2)) {
|
||||
abort(data, "Not FML2/3/FORGE mod list reply");
|
||||
return;
|
||||
}
|
||||
@@ -158,10 +158,10 @@ public class FML2 extends BasicListener {
|
||||
List<Mod> mods = new ArrayList<>();
|
||||
|
||||
int modCount = ProtocolUtils.readVarInt(buf);
|
||||
for(int i = 0; i < modCount; i++) {
|
||||
for (int i = 0; i < modCount; i++) {
|
||||
mods.add(Mod.getOrCreate(ProtocolUtils.readString(buf), Mod.Platform.FORGE));
|
||||
|
||||
if(forge) {
|
||||
if (forge) {
|
||||
ProtocolUtils.readString(buf); // Human readable name
|
||||
ProtocolUtils.readString(buf); // Version
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.persistent.Storage;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.listeners.BasicListener;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.sql.SWException;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.listeners.BasicListener;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class FabricModSender extends BasicListener {
|
||||
}).repeat(1, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
|
||||
public void handlePluginMessage(PluginMessageEvent e){
|
||||
public void handlePluginMessage(PluginMessageEvent e) {
|
||||
Player player = (Player) e.getSource();
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
|
||||
@@ -88,25 +88,24 @@ public class FabricModSender extends BasicListener {
|
||||
List<Mod> mods = new ArrayList<>();
|
||||
|
||||
ByteBuf buf = Unpooled.wrappedBuffer(e.getData());
|
||||
String data = ProtocolUtils.readString(buf, 1024*1024);
|
||||
if(buf.readableBytes() > 0) {
|
||||
String data = ProtocolUtils.readString(buf, 1024 * 1024);
|
||||
if (buf.readableBytes() > 0) {
|
||||
logMessage(user, "Invalid message length", Arrays.toString(e.getData()));
|
||||
return;
|
||||
}
|
||||
|
||||
JsonArray array = JsonParser.parseString(data).getAsJsonArray();
|
||||
|
||||
for(JsonElement mod : array) {
|
||||
for (JsonElement mod : array) {
|
||||
mods.add(Mod.getOrCreate(mod.getAsString(), Mod.Platform.FABRIC));
|
||||
}
|
||||
|
||||
if(!neededModsContained(neededFabricMods, mods) && !neededModsContained(neededQuiltMods, mods)) {
|
||||
if (!neededModsContained(neededFabricMods, mods) && !neededModsContained(neededQuiltMods, mods)) {
|
||||
logMessage(user, "Needed mods are not contained", data);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!ModUtils.handleMods(player,mods))
|
||||
return;
|
||||
if (!ModUtils.handleMods(player, mods)) return;
|
||||
|
||||
if (!Storage.fabricCheckedPlayers.containsKey(player)) {
|
||||
Storage.fabricCheckedPlayers.put(player, data.hashCode());
|
||||
|
||||
@@ -30,6 +30,7 @@ public class Feather {
|
||||
public static final String CHANNEL = "feather:client";
|
||||
|
||||
private final byte[] packet;
|
||||
|
||||
public Feather() {
|
||||
JsonArray array = new JsonArray();
|
||||
array.add("clearWater");
|
||||
|
||||
@@ -37,16 +37,17 @@ import java.util.logging.Level;
|
||||
public class Hostname extends BasicListener {
|
||||
|
||||
private static final Reflection.Field<LoginInboundConnection, InitialInboundConnection> delegate = new Reflection.Field<>(LoginInboundConnection.class, "delegate");
|
||||
|
||||
public static InitialInboundConnection getInitialInboundConnection(LoginInboundConnection loginInboundConnection) {
|
||||
return delegate.get(loginInboundConnection);
|
||||
}
|
||||
|
||||
private static final Reflection.Field<InitialInboundConnection, HandshakePacket> handshake = new Reflection.Field<>(InitialInboundConnection.class, "handshake");
|
||||
|
||||
public static String getExtraHandshakeData(LoginInboundConnection loginInboundConnection) {
|
||||
HandshakePacket handshakePacket = handshake.get(getInitialInboundConnection(loginInboundConnection));
|
||||
int i = handshakePacket.getServerAddress().indexOf('\0');
|
||||
if(i == -1)
|
||||
return "";
|
||||
if (i == -1) return "";
|
||||
|
||||
return handshakePacket.getServerAddress().substring(i);
|
||||
}
|
||||
@@ -77,11 +78,13 @@ public class Hostname extends BasicListener {
|
||||
@Subscribe
|
||||
public void onHandshake(ConnectionHandshakeEvent event) {
|
||||
String hostname = event.getConnection().getVirtualHost().orElseThrow().getHostName().toLowerCase();
|
||||
if (!knownHostnames.contains(hostname) && !hostname.endsWith(".steamwar.de"))
|
||||
if (!knownHostnames.contains(hostname) && !hostname.endsWith(".steamwar.de")) {
|
||||
VelocityCore.getLogger().log(Level.WARNING, () -> event.getConnection().getRemoteAddress() + " connected with unknown hostname " + hostname);
|
||||
}
|
||||
|
||||
String extraData = getExtraHandshakeData((LoginInboundConnection) event.getConnection());
|
||||
if (!knownExtraData.contains(extraData))
|
||||
if (!knownExtraData.contains(extraData)) {
|
||||
VelocityCore.getLogger().log(Level.WARNING, () -> event.getConnection().getRemoteAddress() + " connected with unknown extra data " + extraData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ import com.google.gson.JsonParser;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.listeners.PluginMessage;
|
||||
import de.steamwar.sql.Mod;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -41,6 +41,7 @@ public class LabyMod {
|
||||
// https://dl.labymod.net/addons.json
|
||||
|
||||
private final byte[] gameInfoPacket;
|
||||
|
||||
public LabyMod() {
|
||||
gameInfoPacket = PluginMessage.genBufPacket(buf -> {
|
||||
ProtocolUtils.writeString(buf, "discord_rpc");
|
||||
@@ -60,20 +61,19 @@ public class LabyMod {
|
||||
|
||||
ByteBuf buf = Unpooled.wrappedBuffer(event.getData());
|
||||
String purpose = ProtocolUtils.readString(buf);
|
||||
if(!"INFO".equals(purpose))
|
||||
return;
|
||||
if (!"INFO".equals(purpose)) return;
|
||||
|
||||
JsonObject message = JsonParser.parseString(ProtocolUtils.readString(buf)).getAsJsonObject();
|
||||
List<Mod> mods = new LinkedList<>();
|
||||
|
||||
if(message.has("addons")) {
|
||||
for(JsonElement element : message.getAsJsonArray("addons")) {
|
||||
if (message.has("addons")) {
|
||||
for (JsonElement element : message.getAsJsonArray("addons")) {
|
||||
JsonObject addon = element.getAsJsonObject();
|
||||
mods.add(Mod.getOrCreate(addon.get("name").getAsString(), Mod.Platform.LABYMOD));
|
||||
}
|
||||
}
|
||||
|
||||
if(message.has("mods")) {
|
||||
if (message.has("mods")) {
|
||||
VelocityCore.getLogger().log(Level.WARNING, () -> "LabyMod External Mods for debugging: " + message.getAsJsonArray("mods"));
|
||||
//for(JsonElement element : message.getAsJsonArray("mods")) {
|
||||
// JsonObject addon = element.getAsJsonObject();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user