geforkt von SteamWar/BungeeCore
Merge pull request 'Fix some SonarLint Issues and Modernize Java' (#517) from modernize into velocity
Reviewed-on: SteamWar/BungeeCore#517 Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
286f06f866
@ -50,11 +50,6 @@ public class Bauserver extends Subserver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void register() {
|
|
||||||
super.register();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void unregister() {
|
protected void unregister() {
|
||||||
synchronized (servers) {
|
synchronized (servers) {
|
||||||
|
@ -49,11 +49,6 @@ public class Builderserver extends Subserver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void register() {
|
|
||||||
super.register();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void unregister() {
|
protected void unregister() {
|
||||||
synchronized (servers) {
|
synchronized (servers) {
|
||||||
|
@ -116,11 +116,6 @@ public class Subserver {
|
|||||||
this.thread.start();
|
this.thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public boolean hasStarted() {
|
|
||||||
return started;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendPlayer(Player p) {
|
public void sendPlayer(Player p) {
|
||||||
if (!started) {
|
if (!started) {
|
||||||
p.sendActionBar(generateBar(0));
|
p.sendActionBar(generateBar(0));
|
||||||
|
@ -170,7 +170,7 @@ public abstract class Node {
|
|||||||
|
|
||||||
public RemoteNode(String hostname) {
|
public RemoteNode(String hostname) {
|
||||||
super(hostname);
|
super(hostname);
|
||||||
VelocityCore.getLogger().log(Level.INFO, "Added node " + hostname);
|
VelocityCore.getLogger().log(Level.INFO, "Added node {0}", hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -276,8 +276,8 @@ public class ServerStarter {
|
|||||||
arguments.put("checkpoint", checkpointDir.getPath());
|
arguments.put("checkpoint", checkpointDir.getPath());
|
||||||
|
|
||||||
if(checkpoint && checkpointDir.exists()) {
|
if(checkpoint && checkpointDir.exists()) {
|
||||||
try {
|
try(DataOutputStream out = new DataOutputStream(Files.newOutputStream(new File(checkpointDir, "port").toPath()))) {
|
||||||
new DataOutputStream(Files.newOutputStream(new File(checkpointDir, "port").toPath())).writeInt(port);
|
out.writeInt(port);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new SecurityException(e);
|
throw new SecurityException(e);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class ArenaCommand extends SWCommand {
|
|||||||
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
List<Subserver> subserverList = Subserver.getServerList();
|
List<Subserver> subserverList = Subserver.getServerList();
|
||||||
synchronized (subserverList) {
|
synchronized (subserverList) {
|
||||||
return subserverList.stream().filter(subserver -> subserver.getType() == Servertype.ARENA).map(subserver -> subserver.getServer().getName()).collect(Collectors.toList());
|
return subserverList.stream().filter(subserver -> subserver.getType() == Servertype.ARENA).map(subserver -> subserver.getServer().getName()).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -183,7 +183,7 @@ public class BauCommand extends SWCommand {
|
|||||||
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
return BauweltMember.getMembers(sender.user().getId()).stream()
|
return BauweltMember.getMembers(sender.user().getId()).stream()
|
||||||
.map(bauweltMember -> SteamwarUser.get(bauweltMember.getMemberID()).getUserName())
|
.map(bauweltMember -> SteamwarUser.get(bauweltMember.getMemberID()).getUserName())
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
if(folder == null || (files = folder.list()) == null)
|
if(folder == null || (files = folder.list()) == null)
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
||||||
return Arrays.stream(files).filter(file -> new File(folder, file).isDirectory()).filter(file -> s.startsWith(".") || !file.startsWith(".")).collect(Collectors.toList());
|
return Arrays.stream(files).filter(file -> new File(folder, file).isDirectory()).filter(file -> s.startsWith(".") || !file.startsWith(".")).toList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
if(folder == null || (files = folder.list()) == null)
|
if(folder == null || (files = folder.list()) == null)
|
||||||
return Collections.emptyList();
|
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)).collect(Collectors.toList());
|
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();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,8 @@ public class CheckCommand extends SWCommand {
|
|||||||
for (SchematicNode schematic : schematicList) {
|
for (SchematicNode schematic : schematicList) {
|
||||||
CheckSession current = currentSchems.get(schematic.getId());
|
CheckSession current = currentSchems.get(schematic.getId());
|
||||||
long waitedMillis = Timestamp.from(Instant.now()).getTime() - schematic.getLastUpdate().getTime();
|
long waitedMillis = Timestamp.from(Instant.now()).getTime() - schematic.getLastUpdate().getTime();
|
||||||
String color = waitedMillis > 14400000 ? (waitedMillis > 86400000 ? "c" : "e") : "a";
|
String ce = waitedMillis > 86400000 ? "c" : "e";
|
||||||
|
String color = waitedMillis > 14400000 ? ce : "a";
|
||||||
long hours = waitedMillis / 3600000;
|
long hours = waitedMillis / 3600000;
|
||||||
long minutes = (waitedMillis - hours * 3600000) / 60000;
|
long minutes = (waitedMillis - hours * 3600000) / 60000;
|
||||||
Message waitTime = new Message("CHECK_LIST_WAIT", color, hours, (minutes < 10) ? "0" + minutes : minutes);
|
Message waitTime = new Message("CHECK_LIST_WAIT", color, hours, (minutes < 10) ? "0" + minutes : minutes);
|
||||||
|
@ -51,7 +51,7 @@ public class DevCommand extends SWCommand {
|
|||||||
sender.system("DEV_NO_SERVER");
|
sender.system("DEV_NO_SERVER");
|
||||||
return;
|
return;
|
||||||
} else if (devServers.size() == 1) {
|
} else if (devServers.size() == 1) {
|
||||||
sender.getPlayer().createConnectionRequest(devServers.values().stream().findAny().get()).fireAndForget();
|
devServers.values().stream().findAny().ifPresent(server -> sender.getPlayer().createConnectionRequest(server).fireAndForget());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ import de.steamwar.messages.Chatter;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -38,8 +39,8 @@ public class ListCommand extends SWCommand {
|
|||||||
super("list");
|
super("list");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized TreeMap<String, List<Player>> getCustomTablist(){
|
public static synchronized SortedMap<String, List<Player>> getCustomTablist(){
|
||||||
TreeMap<String, List<Player>> playerMap = new TreeMap<>();
|
SortedMap<String, List<Player>> playerMap = new TreeMap<>();
|
||||||
for (Player player : VelocityCore.getProxy().getAllPlayers()) {
|
for (Player player : VelocityCore.getProxy().getAllPlayers()) {
|
||||||
ServerConnection pserver = player.getCurrentServer().orElse(null);
|
ServerConnection pserver = player.getCurrentServer().orElse(null);
|
||||||
if (pserver == null)
|
if (pserver == null)
|
||||||
@ -58,8 +59,8 @@ public class ListCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void list(Chatter sender) {
|
public void list(Chatter sender) {
|
||||||
TreeMap<String, List<Player>> playerMap = getCustomTablist();
|
SortedMap<String, List<Player>> playerMap = getCustomTablist();
|
||||||
for (String server : playerMap.navigableKeySet()) {
|
for (String server : playerMap.keySet()) {
|
||||||
String serverName = server;
|
String serverName = server;
|
||||||
if (server.equals("Bau")) {
|
if (server.equals("Bau")) {
|
||||||
serverName = sender.parseToLegacy("TABLIST_BAU");
|
serverName = sender.parseToLegacy("TABLIST_BAU");
|
||||||
|
@ -57,7 +57,7 @@ public class ModCommand extends SWCommand {
|
|||||||
openGui(player);
|
openGui(player);
|
||||||
}), page -> {
|
}), page -> {
|
||||||
Mod.ModType filtertype = playerFilterType.get(player.user().getUUID());
|
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)).collect(Collectors.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 -> {
|
swStreamInv.addItem(52, new SWItem("NAME_TAG", new Message("MOD_TITLE_FILTER")), click -> {
|
||||||
|
@ -36,7 +36,7 @@ public class PlaytimeCommand extends SWCommand {
|
|||||||
SteamwarUser user = sender.user();
|
SteamwarUser user = sender.user();
|
||||||
NumberFormat format = NumberFormat.getNumberInstance(user.getLocale());
|
NumberFormat format = NumberFormat.getNumberInstance(user.getLocale());
|
||||||
format.setMaximumFractionDigits(2);
|
format.setMaximumFractionDigits(2);
|
||||||
String formattedText = format.format((user.getOnlinetime() / (double) 3600));
|
String formattedText = format.format((user.getOnlinetime() / 3600d));
|
||||||
|
|
||||||
sender.system("HOURS_PLAYED", formattedText);
|
sender.system("HOURS_PLAYED", formattedText);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class PunishmentCommand {
|
|||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
// ignore, player does not exist
|
// ignore, player does not exist
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
VelocityCore.getLogger().log(Level.SEVERE, "Could not get offline player UUID " + playerName, e);
|
VelocityCore.getLogger().log(Level.SEVERE, "Could not get offline player UUID {0}".formatted(playerName), e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class ReplayCommand extends SWCommand {
|
|||||||
} else {
|
} else {
|
||||||
starter.arena(mode, map).start();
|
starter.arena(mode, map).start();
|
||||||
}
|
}
|
||||||
}, page -> Fight.getPage(page, 45).stream().map(fight -> new SWListInv.SWListEntry<>(getFightItem(fight), fight)).collect(Collectors.toList())).open();
|
}, page -> Fight.getPage(page, 45).stream().map(fight -> new SWListInv.SWListEntry<>(getFightItem(fight), fight)).toList()).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SWItem getFightItem(Fight fight) {
|
private SWItem getFightItem(Fight fight) {
|
||||||
|
@ -236,7 +236,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
return Team.get(sender.user().getTeam()).getMembers().stream()
|
return Team.get(sender.user().getTeam()).getMembers().stream()
|
||||||
.map(SteamwarUser::get)
|
.map(SteamwarUser::get)
|
||||||
.map(SteamwarUser::getUserName)
|
.map(SteamwarUser::getUserName)
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register(value = "info", description = "TEAM_INFO_USAGE")
|
@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::get).collect(Collectors.toList());
|
List<SteamwarUser> users = team.getMembers().stream().map(SteamwarUser::get).toList();
|
||||||
|
|
||||||
sender.system("TEAM_INFO_TEAM", team.getTeamName(), team.getTeamColor(), team.getTeamKuerzel());
|
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));
|
sender.prefixless("TEAM_INFO_LEADER", users.stream().filter(SteamwarUser::isLeader).count(), getMemberList(users, true));
|
||||||
@ -484,7 +484,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
if(notDuringEvent(sender))
|
if(notDuringEvent(sender))
|
||||||
return;
|
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())).collect(Collectors.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(new Message("PLAIN_STRING", "§" + entry.getKey() + team.getTeamKuerzel()), entry.getValue()), entry.getKey())).toList(), (click, element) -> {});
|
||||||
inv.setCallback((click, element) -> {
|
inv.setCallback((click, element) -> {
|
||||||
inv.close();
|
inv.close();
|
||||||
team.setTeamColor(element);
|
team.setTeamColor(element);
|
||||||
@ -512,7 +512,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
return Event.getComing().stream().map(Event::getEventName).collect(Collectors.toList());
|
return Event.getComing().stream().map(Event::getEventName).toList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -568,7 +568,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
return Team.getAll().stream()
|
return Team.getAll().stream()
|
||||||
.flatMap(team -> Stream.of(team.getTeamName(), team.getTeamKuerzel()))
|
.flatMap(team -> Stream.of(team.getTeamName(), team.getTeamKuerzel()))
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ public class TutorialCommand extends SWCommand {
|
|||||||
|
|
||||||
new ServerStarter().tutorial(sender.getPlayer(), tutorial).start();
|
new ServerStarter().tutorial(sender.getPlayer(), tutorial).start();
|
||||||
},
|
},
|
||||||
page -> (own ? Tutorial.getOwn(user.getId(), page, 45) : Tutorial.getPage(page, 45, released)).stream().map(tutorial -> new SWListInv.SWListEntry<>(getTutorialItem(tutorial, own), tutorial)).collect(Collectors.toList())
|
page -> (own ? Tutorial.getOwn(user.getId(), page, 45) : Tutorial.getPage(page, 45, released)).stream().map(tutorial -> new SWListInv.SWListEntry<>(getTutorialItem(tutorial, own), tutorial)).toList()
|
||||||
).open();
|
).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ public class TutorialCommand extends SWCommand {
|
|||||||
private void rate(PlayerChatter sender, Tutorial tutorial) {
|
private void rate(PlayerChatter sender, Tutorial tutorial) {
|
||||||
int[] rates = new int[]{1, 2, 3, 4, 5};
|
int[] rates = new int[]{1, 2, 3, 4, 5};
|
||||||
|
|
||||||
new SWListInv<>(sender, new Message("TUTORIAL_RATE_TITLE"), Arrays.stream(rates).mapToObj(rate -> new SWListInv.SWListEntry<>(new SWItem("NETHER_STAR", new Message("TUTORIAL_RATE", rate)), rate)).collect(Collectors.toList()), (click, rate) -> {
|
new SWListInv<>(sender, new Message("TUTORIAL_RATE_TITLE"), Arrays.stream(rates).mapToObj(rate -> new SWListInv.SWListEntry<>(new SWItem("NETHER_STAR", new Message("TUTORIAL_RATE", rate)), rate)).toList(), (click, rate) -> {
|
||||||
tutorial.rate(sender.user().getId(), rate);
|
tutorial.rate(sender.user().getId(), rate);
|
||||||
SWInventory.close(sender);
|
SWInventory.close(sender);
|
||||||
}).open();
|
}).open();
|
||||||
|
@ -51,7 +51,7 @@ public class VerifyCommand extends SWCommand {
|
|||||||
|
|
||||||
User user = AuthManager.connectAuth(sender.user(), code);
|
User user = AuthManager.connectAuth(sender.user(), code);
|
||||||
if(user != null) {
|
if(user != null) {
|
||||||
VelocityCore.getLogger().log(Level.INFO, sender.user().getUserName() + " Verified with Discorduser: " + user.getIdLong());
|
VelocityCore.getLogger().log(Level.INFO, "{0} Verified with Discorduser: {1}".formatted(sender.user().getUserName(), user.getIdLong()));
|
||||||
sender.system("VERIFY_SUCCESS", user.getAsTag());
|
sender.system("VERIFY_SUCCESS", user.getAsTag());
|
||||||
} else {
|
} else {
|
||||||
sender.system("VERIFY_INVALID");
|
sender.system("VERIFY_INVALID");
|
||||||
|
@ -72,11 +72,11 @@ public class DiscordBot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private volatile DiscordChannel announcementChannel;
|
private DiscordChannel announcementChannel;
|
||||||
@Getter
|
@Getter
|
||||||
private volatile DiscordChatRoom ingameChat;
|
private DiscordChatRoom ingameChat;
|
||||||
@Getter
|
@Getter
|
||||||
private volatile DiscordChatRoom serverTeamChat;
|
private DiscordChatRoom serverTeamChat;
|
||||||
@Getter
|
@Getter
|
||||||
private StaticMessageChannel eventChannel;
|
private StaticMessageChannel eventChannel;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class DiscordSchemUpload extends ListenerAdapter {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
} catch (ExecutionException | IOException e) {
|
} catch (ExecutionException | IOException e) {
|
||||||
VelocityCore.getLogger().log(Level.SEVERE, "Could not upload schem \"" + name + "\" for user \"" + user.getUserName() + "\"", e);
|
VelocityCore.getLogger().log(Level.SEVERE, "Could not upload schem \"{0}\" for user \"{1}\"".formatted(name, user.getUserName()), e);
|
||||||
sender.system("DC_SCHEMUPLOAD_ERROR", name);
|
sender.system("DC_SCHEMUPLOAD_ERROR", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class AuthManager {
|
|||||||
String code = Base64.getEncoder().encodeToString(randBytes);
|
String code = Base64.getEncoder().encodeToString(randBytes);
|
||||||
|
|
||||||
TOKENS.put(code, user);
|
TOKENS.put(code, user);
|
||||||
VelocityCore.getLogger().log(Level.INFO, "Created Discord Auth-Token: " + code + " for: " + user.getAsTag());
|
VelocityCore.getLogger().log(Level.INFO, "Created Discord Auth-Token: {0} for: {1}".formatted(code, user.getAsTag()));
|
||||||
VelocityCore.schedule(() -> TOKENS.remove(code)).delay(10, TimeUnit.MINUTES).schedule();
|
VelocityCore.schedule(() -> TOKENS.remove(code)).delay(10, TimeUnit.MINUTES).schedule();
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class DiscordRanks {
|
|||||||
if (member.getRoles().stream().noneMatch(role -> role.getId().equals(prefixRole)))
|
if (member.getRoles().stream().noneMatch(role -> role.getId().equals(prefixRole)))
|
||||||
guild.addRoleToMember(member, guild.getRoleById(prefixRole)).queue();
|
guild.addRoleToMember(member, guild.getRoleById(prefixRole)).queue();
|
||||||
}, e -> {
|
}, e -> {
|
||||||
if(e instanceof ErrorResponseException && ((ErrorResponseException) e).getErrorCode() == 10007)
|
if(e instanceof ErrorResponseException err && err.getErrorCode() == 10007)
|
||||||
user.setDiscordId(null);
|
user.setDiscordId(null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class ChatListener extends BasicListener {
|
public class ChatListener extends BasicListener {
|
||||||
|
|
||||||
private static final List<String> rankedModes = ArenaMode.getAllModes().stream().filter(ArenaMode::isRanked).map(ArenaMode::getSchemType).collect(Collectors.toList());
|
private static final List<String> rankedModes = ArenaMode.getAllModes().stream().filter(ArenaMode::isRanked).map(ArenaMode::getSchemType).toList();
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onChatEvent(PlayerChatEvent e) {
|
public void onChatEvent(PlayerChatEvent e) {
|
||||||
@ -58,7 +58,7 @@ public class ChatListener extends BasicListener {
|
|||||||
if (message.contains("jndi:ldap")) {
|
if (message.contains("jndi:ldap")) {
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
PunishmentCommand.ban(user, Punishment.PERMA_TIME, "Versuchte Exploit-Ausnutzung", SteamwarUser.get(-1), true);
|
PunishmentCommand.ban(user, Punishment.PERMA_TIME, "Versuchte Exploit-Ausnutzung", SteamwarUser.get(-1), true);
|
||||||
VelocityCore.getLogger().log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen jndi:ldap gebannt.");
|
VelocityCore.getLogger().log(Level.SEVERE, "{0} {1} wurde automatisch wegen jndi:ldap gebannt.".formatted(user.getUserName(), user.getId()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ public class ChatListener extends BasicListener {
|
|||||||
private static boolean isCommand(Player player, String message) {
|
private static boolean isCommand(Player player, String message) {
|
||||||
String command = message.substring(1);
|
String command = message.substring(1);
|
||||||
boolean isCommand = message.startsWith("/") || (message.startsWith("7") && command.split(" ", 2)[0].matches("[7/]?[A-Za-z]+"));
|
boolean isCommand = message.startsWith("/") || (message.startsWith("7") && command.split(" ", 2)[0].matches("[7/]?[A-Za-z]+"));
|
||||||
if(isCommand && !VelocityCore.getProxy().getCommandManager().executeImmediatelyAsync(player, command).join()) {
|
if(isCommand && Boolean.FALSE.equals(VelocityCore.getProxy().getCommandManager().executeImmediatelyAsync(player, command).join())) {
|
||||||
if(command.startsWith("7"))
|
if(command.startsWith("7"))
|
||||||
command = "/" + command.substring(1);
|
command = "/" + command.substring(1);
|
||||||
message = "/" + command;
|
message = "/" + command;
|
||||||
|
@ -46,7 +46,7 @@ public class IPSanitizer extends BasicListener {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void loginEvent(PreLoginEvent e) {
|
public void loginEvent(PreLoginEvent e) {
|
||||||
VelocityCore.getLogger().log(Level.INFO, e.getConnection().getRemoteAddress() + " has logged in with user name " + e.getUsername());
|
VelocityCore.getLogger().log(Level.INFO, "{0} has logged in with user name {1}".formatted(e.getConnection().getRemoteAddress(), e.getUsername()));
|
||||||
remoteAddress.set(Hostname.getInitialInboundConnection((LoginInboundConnection) e.getConnection()).getConnection(), sanitized);
|
remoteAddress.set(Hostname.getInitialInboundConnection((LoginInboundConnection) e.getConnection()).getConnection(), sanitized);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,11 +75,11 @@ public class LabyMod {
|
|||||||
|
|
||||||
if(message.has("mods")) {
|
if(message.has("mods")) {
|
||||||
VelocityCore.getLogger().log(Level.WARNING, () -> "LabyMod External Mods for debugging: " + message.getAsJsonArray("mods"));
|
VelocityCore.getLogger().log(Level.WARNING, () -> "LabyMod External Mods for debugging: " + message.getAsJsonArray("mods"));
|
||||||
for(JsonElement element : message.getAsJsonArray("mods")) {
|
//for(JsonElement element : message.getAsJsonArray("mods")) {
|
||||||
JsonObject addon = element.getAsJsonObject();
|
// JsonObject addon = element.getAsJsonObject();
|
||||||
//TODO observe: FORGE and FABRIC mods available, do they always and with .jar? (would equal new mod platform)
|
// //TODO observe: FORGE and FABRIC mods available, do they always and with .jar? (would equal new mod platform)
|
||||||
//mods.add(Mod.getOrCreate(addon.get("name").getAsString().replace(".jar", ""), Mod.Platform.FORGE));
|
// //mods.add(Mod.getOrCreate(addon.get("name").getAsString().replace(".jar", ""), Mod.Platform.FORGE));
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
ModUtils.handleMods(player, mods);
|
ModUtils.handleMods(player, mods);
|
||||||
|
@ -82,8 +82,7 @@ public class Lunar {
|
|||||||
|
|
||||||
for(ModMessage mod : handshake.getInstalledModsList()) {
|
for(ModMessage mod : handshake.getInstalledModsList()) {
|
||||||
switch(mod.getType()) {
|
switch(mod.getType()) {
|
||||||
case TYPE_FABRIC_INTERNAL:
|
case TYPE_FABRIC_INTERNAL, TYPE_FORGE_INTERNAL:
|
||||||
case TYPE_FORGE_INTERNAL:
|
|
||||||
// Controlled with ModSettings
|
// Controlled with ModSettings
|
||||||
break;
|
break;
|
||||||
case TYPE_FABRIC_EXTERNAL:
|
case TYPE_FABRIC_EXTERNAL:
|
||||||
@ -92,8 +91,6 @@ public class Lunar {
|
|||||||
case TYPE_FORGE_EXTERNAL:
|
case TYPE_FORGE_EXTERNAL:
|
||||||
mods.add(Mod.getOrCreate(mod.getName(), Mod.Platform.FORGE));
|
mods.add(Mod.getOrCreate(mod.getName(), Mod.Platform.FORGE));
|
||||||
break;
|
break;
|
||||||
case TYPE_UNSPECIFIED:
|
|
||||||
case UNRECOGNIZED:
|
|
||||||
default:
|
default:
|
||||||
VelocityCore.getLogger().log(Level.INFO, () -> player.getUsername() + " uses Lunar mod with unknown type " + mod);
|
VelocityCore.getLogger().log(Level.INFO, () -> player.getUsername() + " uses Lunar mod with unknown type " + mod);
|
||||||
break;
|
break;
|
||||||
|
@ -54,7 +54,7 @@ public class ModUtils {
|
|||||||
Chatter sender = Chatter.of(uuid);
|
Chatter sender = Chatter.of(uuid);
|
||||||
SteamwarUser user = sender.user();
|
SteamwarUser user = sender.user();
|
||||||
playerModMap.put(uuid,new ArrayList<>(mods));
|
playerModMap.put(uuid,new ArrayList<>(mods));
|
||||||
VelocityCore.getLogger().log(Level.INFO, user.getUserName() + " declares mods: " + mods.stream().map(mod -> mod.getPlatform() + ":" + mod.getModName()).collect(Collectors.joining(" ")));
|
VelocityCore.getLogger().log(Level.INFO, "{0} declares mods: {1}".formatted(user.getUserName(), mods.stream().map(mod -> mod.getPlatform() + ":" + mod.getModName()).collect(Collectors.joining(" "))));
|
||||||
|
|
||||||
ModType max = ModType.YELLOW;
|
ModType max = ModType.YELLOW;
|
||||||
Iterator<Mod> it = mods.iterator();
|
Iterator<Mod> it = mods.iterator();
|
||||||
@ -83,7 +83,7 @@ public class ModUtils {
|
|||||||
|
|
||||||
if(max == ModType.RED) {
|
if(max == ModType.RED) {
|
||||||
PunishmentCommand.ban(user, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, SteamwarUser.get(-1), false);
|
PunishmentCommand.ban(user, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, SteamwarUser.get(-1), false);
|
||||||
VelocityCore.getLogger().log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + modList + " gebannt.");
|
VelocityCore.getLogger().log(Level.SEVERE, "{0} {1} wurde automatisch wegen der Mods {2} gebannt.".formatted(user.getUserName(), user.getId(), modList));
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect.accept(LegacyComponentSerializer.legacySection().deserialize(message));
|
disconnect.accept(LegacyComponentSerializer.legacySection().deserialize(message));
|
||||||
|
@ -34,7 +34,7 @@ public class NetworkSender {
|
|||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static void send(Player player, NetworkPacket packet) {
|
public static void send(Player player, NetworkPacket packet) {
|
||||||
player.getCurrentServer().map(server -> server.sendPluginMessage(swBridge, packet.serialize()));
|
player.getCurrentServer().ifPresent(server -> server.sendPluginMessage(swBridge, packet.serialize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void send(RegisteredServer server, NetworkPacket packet) {
|
public static void send(RegisteredServer server, NetworkPacket packet) {
|
||||||
|
@ -21,12 +21,5 @@ package de.steamwar.bungeecore.network;
|
|||||||
|
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import de.steamwar.network.packets.MetaInfos;
|
import de.steamwar.network.packets.MetaInfos;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
public record ServerMetaInfo(ServerConnection sender) implements MetaInfos {}
|
||||||
@AllArgsConstructor
|
|
||||||
public class ServerMetaInfo implements MetaInfos {
|
|
||||||
|
|
||||||
private final ServerConnection sender;
|
|
||||||
}
|
|
||||||
|
@ -173,17 +173,7 @@ public class EloPlayerHandler extends PacketHandler {
|
|||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String finalOldEmblem = (oldEmblem.isEmpty() ? "/" : oldEmblem).trim();
|
IntFunction<String> getRankup = getEmblemTransition(oldEmblem, newEmblem, arrowColor);
|
||||||
String finalNewEmblem = (newEmblem.isEmpty() ? "/" : newEmblem).trim();
|
|
||||||
|
|
||||||
IntFunction<String> getRankup = i -> {
|
|
||||||
if (oldEmblem.equals(newEmblem)) return "§8" + finalOldEmblem;
|
|
||||||
if (i < 8) return "§8" + finalOldEmblem;
|
|
||||||
if (i < 16) return "§8" + finalOldEmblem + arrowColor + " >";
|
|
||||||
if (i < 24) return "§8" + finalOldEmblem + arrowColor + " >>";
|
|
||||||
if (i < 32) return "§8" + finalOldEmblem + arrowColor + " >>>";
|
|
||||||
return "§8" + finalOldEmblem + arrowColor + " >>> §8" + finalNewEmblem;
|
|
||||||
};
|
|
||||||
|
|
||||||
String color = ((eloGain > 0) ? "§a+" : (eloGain == 0 ? "§7" : "§c"));
|
String color = ((eloGain > 0) ? "§a+" : (eloGain == 0 ? "§7" : "§c"));
|
||||||
|
|
||||||
@ -199,6 +189,20 @@ public class EloPlayerHandler extends PacketHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IntFunction<String> getEmblemTransition(String oldEmblem, String newEmblem, String arrowColor) {
|
||||||
|
String finalOldEmblem = (oldEmblem.isEmpty() ? "/" : oldEmblem).trim();
|
||||||
|
String finalNewEmblem = (newEmblem.isEmpty() ? "/" : newEmblem).trim();
|
||||||
|
|
||||||
|
return i -> {
|
||||||
|
if (oldEmblem.equals(newEmblem)) return "§8" + finalOldEmblem;
|
||||||
|
if (i < 8) return "§8" + finalOldEmblem;
|
||||||
|
if (i < 16) return "§8" + finalOldEmblem + arrowColor + " >";
|
||||||
|
if (i < 24) return "§8" + finalOldEmblem + arrowColor + " >>";
|
||||||
|
if (i < 32) return "§8" + finalOldEmblem + arrowColor + " >>>";
|
||||||
|
return "§8" + finalOldEmblem + arrowColor + " >>> §8" + finalNewEmblem;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private Player player(int userId) {
|
private Player player(int userId) {
|
||||||
return VelocityCore.getProxy().getPlayer(SteamwarUser.get(userId).getUUID()).orElse(null);
|
return VelocityCore.getProxy().getPlayer(SteamwarUser.get(userId).getUUID()).orElse(null);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class FightInfoHandler extends PacketHandler {
|
|||||||
|
|
||||||
@Handler
|
@Handler
|
||||||
public void handle(FightInfoPacket packet) {
|
public void handle(FightInfoPacket packet) {
|
||||||
RegisteredServer server = ((ServerMetaInfo) packet.getMetaInfos()).getSender().getServer();
|
RegisteredServer server = ((ServerMetaInfo) packet.getMetaInfos()).sender().getServer();
|
||||||
|
|
||||||
FightInfoPacket lobbyPacket = packet.withServerName(server.getServerInfo().getName());
|
FightInfoPacket lobbyPacket = packet.withServerName(server.getServerInfo().getName());
|
||||||
|
|
||||||
|
@ -27,6 +27,6 @@ public class ImALobbyHandler extends PacketHandler {
|
|||||||
|
|
||||||
@Handler
|
@Handler
|
||||||
public void handle(ImALobbyPacket packet) {
|
public void handle(ImALobbyPacket packet) {
|
||||||
FightInfoHandler.addLobby(((ServerMetaInfo) packet.getMetaInfos()).getSender().getServer());
|
FightInfoHandler.addLobby(((ServerMetaInfo) packet.getMetaInfos()).sender().getServer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class InventoryCallbackHandler extends PacketHandler {
|
|||||||
if(!inventoryHashMap.containsKey(owner.getId())) {
|
if(!inventoryHashMap.containsKey(owner.getId())) {
|
||||||
Chatter.of(owner).system("UPDATE_INTERRUPTION");
|
Chatter.of(owner).system("UPDATE_INTERRUPTION");
|
||||||
if(type == InventoryCallbackPacket.CallbackType.CLICK) {
|
if(type == InventoryCallbackPacket.CallbackType.CLICK) {
|
||||||
NetworkSender.send((Player) ((ServerMetaInfo) packet.getMetaInfos()).getSender(), new CloseInventoryPacket(owner.getId()));
|
NetworkSender.send((Player) ((ServerMetaInfo) packet.getMetaInfos()).sender(), new CloseInventoryPacket(owner.getId()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ public class Tablist extends ChannelInboundHandlerAdapter {
|
|||||||
sendTabPacket(current, null);
|
sendTabPacket(current, null);
|
||||||
current.clear();
|
current.clear();
|
||||||
synchronized (directTabItems) {
|
synchronized (directTabItems) {
|
||||||
sendNpcPacket(npcs.stream().map(npc -> directTabItems.get(npc).getProfile().getName()).collect(Collectors.toList()), true);
|
sendNpcPacket(npcs.stream().map(npc -> directTabItems.get(npc).getProfile().getName()).toList(), true);
|
||||||
npcs.clear();
|
npcs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class TablistBuild implements TablistPart {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
servers.add(server);
|
servers.add(server);
|
||||||
players.put(server, server.getPlayersConnected().stream().sorted(((p1, p2) -> p1.getUsername().compareToIgnoreCase(p2.getUsername()))).map(Item::new).collect(Collectors.toList()));
|
players.put(server, server.getPlayersConnected().stream().sorted(((p1, p2) -> p1.getUsername().compareToIgnoreCase(p2.getUsername()))).map(Item::new).toList());
|
||||||
}
|
}
|
||||||
servers.sort((s1, s2) -> s1.getServerInfo().getName().compareToIgnoreCase(s2.getServerInfo().getName()));
|
servers.sort((s1, s2) -> s1.getServerInfo().getName().compareToIgnoreCase(s2.getServerInfo().getName()));
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class TablistServer implements TablistPart {
|
|||||||
private final List<Item> players;
|
private final List<Item> players;
|
||||||
|
|
||||||
public TablistServer(RegisteredServer server) {
|
public TablistServer(RegisteredServer server) {
|
||||||
this(server, server.getPlayersConnected().stream().sorted((p1, p2) -> p1.getUsername().compareToIgnoreCase(p2.getUsername())).map(TablistPart.Item::new).collect(Collectors.toList()));
|
this(server, server.getPlayersConnected().stream().sorted((p1, p2) -> p1.getUsername().compareToIgnoreCase(p2.getUsername())).map(TablistPart.Item::new).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TablistServer(RegisteredServer server, FightInfoPacket info) {
|
public TablistServer(RegisteredServer server, FightInfoPacket info) {
|
||||||
|
@ -177,7 +177,7 @@ public class SWCommand extends AbstractSWCommand<Chatter> {
|
|||||||
chatter.prefixless(s, new Message("PLAIN_STRING", hover), ClickEvent.suggestCommand("/" + name + " " + String.join(" ", subCommand.subCommand)));
|
chatter.prefixless(s, new Message("PLAIN_STRING", hover), ClickEvent.suggestCommand("/" + name + " " + String.join(" ", subCommand.subCommand)));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
VelocityCore.getLogger().log(Level.WARNING, "Failed to send description of registered method '" + subCommand.method + "' with description '" + Arrays.toString(subCommand.description) + "'", e);
|
VelocityCore.getLogger().log(Level.WARNING, "Failed to send description of registered method '{0}' with description '{1}'".formatted(subCommand.method, Arrays.toString(subCommand.description)), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,23 +158,23 @@ public interface Chatter {
|
|||||||
String pattern = "";
|
String pattern = "";
|
||||||
if(prefixed)
|
if(prefixed)
|
||||||
pattern = resourceBundle.getObject("PREFIX") + " ";
|
pattern = resourceBundle.getObject("PREFIX") + " ";
|
||||||
pattern += (String)resourceBundle.getObject(message.getFormat());
|
pattern += (String)resourceBundle.getObject(message.format());
|
||||||
|
|
||||||
MessageFormat format = new MessageFormat(pattern, locale);
|
MessageFormat format = new MessageFormat(pattern, locale);
|
||||||
Object[] params = message.getParams();
|
Object[] params = message.params();
|
||||||
for (int i = 0; i < params.length; i++) {
|
for (int i = 0; i < params.length; i++) {
|
||||||
if(params[i] instanceof Message) {
|
if(params[i] instanceof Message msg) {
|
||||||
params[i] = parseToLegacy((Message) params[i]);
|
params[i] = parseToLegacy(msg);
|
||||||
} else if(params[i] instanceof Date) {
|
} else if(params[i] instanceof Date date) {
|
||||||
params[i] = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale).format((Date) params[i]);
|
params[i] = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale).format(date);
|
||||||
} else if(params[i] instanceof SteamwarUser) {
|
} else if(params[i] instanceof SteamwarUser user) {
|
||||||
params[i] = ((SteamwarUser) params[i]).getUserName();
|
params[i] = user.getUserName();
|
||||||
} else if(params[i] instanceof Player) {
|
} else if(params[i] instanceof Player player) {
|
||||||
params[i] = ((Player) params[i]).getUsername();
|
params[i] = player.getUsername();
|
||||||
} else if(params[i] instanceof Chatter) {
|
} else if(params[i] instanceof Chatter chatter) {
|
||||||
params[i] = ((Chatter) params[i]).user().getUserName();
|
params[i] = chatter.user().getUserName();
|
||||||
} else if(params[i] instanceof Function) {
|
} else if(params[i] instanceof Function func) {
|
||||||
params[i] = ((Function) params[i]).apply(this);
|
params[i] = func.apply(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return LegacyComponentSerializer.legacySection().deserialize(format.format(params));
|
return LegacyComponentSerializer.legacySection().deserialize(format.format(params));
|
||||||
|
@ -19,16 +19,4 @@
|
|||||||
|
|
||||||
package de.steamwar.messages;
|
package de.steamwar.messages;
|
||||||
|
|
||||||
import lombok.Getter;
|
public record Message(String format, Object... params) { }
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class Message {
|
|
||||||
|
|
||||||
private final String format;
|
|
||||||
private final Object[] params;
|
|
||||||
|
|
||||||
public Message(String format, Object... params) {
|
|
||||||
this.format = format;
|
|
||||||
this.params = params;
|
|
||||||
}
|
|
||||||
}
|
|
In neuem Issue referenzieren
Einen Benutzer sperren