Refactor switch statements to use enhanced -> syntax and update dependencies to include cosmos-api.
This commit is contained in:
parent
fc7860145f
commit
eb30750134
|
|
@ -3,10 +3,10 @@ plugins {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
// compileOnly("com.alttd:Galaxy-API:1.21-R0.1-SNAPSHOT") {
|
||||
// exclude("net.kyori")
|
||||
// }
|
||||
compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
|
||||
// Cosmos
|
||||
compileOnly("com.alttd.cosmos:cosmos-api:1.21.7-R0.1-SNAPSHOT") {
|
||||
isChanging = true
|
||||
}
|
||||
compileOnly("org.spongepowered:configurate-yaml:4.2.0") // Configurate
|
||||
compileOnly("net.luckperms:api:5.5") // Luckperms
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class PluginMessage implements PluginMessageListener {
|
|||
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
|
||||
String subChannel = in.readUTF();
|
||||
switch (subChannel) {
|
||||
case "privatemessagein": {
|
||||
case "privatemessagein" -> {
|
||||
UUID uuid = UUID.fromString(in.readUTF());
|
||||
String target = in.readUTF();
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
|
|
@ -49,14 +49,15 @@ public class PluginMessage implements PluginMessageListener {
|
|||
ChatUser chatUser = ChatUserManager.getChatUser(uuid);
|
||||
if (isTargetNotIgnored(chatUser, targetuuid)) {
|
||||
player.sendMessage(GsonComponentSerializer.gson().deserialize(message));
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 1); // todo load this from config
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1,
|
||||
1); // todo load this from config
|
||||
ChatUser user = ChatUserManager.getChatUser(uuid);
|
||||
if (!user.getReplyContinueTarget().equalsIgnoreCase(target)) {
|
||||
user.setReplyTarget(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
case "privatemessageout": {
|
||||
case "privatemessageout" -> {
|
||||
UUID uuid = UUID.fromString(in.readUTF());
|
||||
String target = in.readUTF();
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
|
|
@ -72,9 +73,8 @@ public class PluginMessage implements PluginMessageListener {
|
|||
// ChatUser user = ChatUserManager.getChatUser(uuid);
|
||||
// user.setReplyTarget(target);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "globalchat": {
|
||||
case "globalchat" -> {
|
||||
if (!ChatPlugin.getInstance().serverGlobalChatEnabled() || ChatPlugin.getInstance().serverMuted()) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -88,31 +88,27 @@ public class PluginMessage implements PluginMessageListener {
|
|||
p.sendMessage(GsonComponentSerializer.gson().deserialize(message));
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "ignore": {
|
||||
case "ignore" -> {
|
||||
ChatUser chatUser = ChatUserManager.getChatUser(UUID.fromString(in.readUTF()));
|
||||
UUID targetUUID = UUID.fromString(in.readUTF());
|
||||
|
||||
if (!chatUser.getIgnoredPlayers().contains(targetUUID)) {
|
||||
chatUser.addIgnoredPlayers(targetUUID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "unignore": {
|
||||
case "unignore" -> {
|
||||
ChatUser chatUser = ChatUserManager.getChatUser(UUID.fromString(in.readUTF()));
|
||||
chatUser.removeIgnoredPlayers(UUID.fromString(in.readUTF()));
|
||||
break;
|
||||
}
|
||||
case "chatchannel": {
|
||||
case "chatchannel" -> {
|
||||
if (ChatPlugin.getInstance().serverMuted()) {
|
||||
break;
|
||||
}
|
||||
|
||||
chatChannel(in);
|
||||
break;
|
||||
}
|
||||
case "tmppartyupdate": {
|
||||
case "tmppartyupdate" -> {
|
||||
int id = Integer.parseInt(in.readUTF());
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
|
|
@ -120,9 +116,8 @@ public class PluginMessage implements PluginMessageListener {
|
|||
Queries.loadPartyUsers(id);
|
||||
}
|
||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||
break;
|
||||
}
|
||||
case "partylogin": {
|
||||
case "partylogin" -> {
|
||||
int id = Integer.parseInt(in.readUTF());
|
||||
Party party = PartyManager.getParty(id);
|
||||
if (party == null) {
|
||||
|
|
@ -135,18 +130,19 @@ public class PluginMessage implements PluginMessageListener {
|
|||
public void run() {
|
||||
PartyUser user = party.getPartyUser(uuid);
|
||||
if (user != null) {
|
||||
ComponentLike component = Utility.parseMiniMessage("<dark_aqua>* " + user.getPlayerName() + " logged in to Altitude.");
|
||||
ComponentLike component = Utility.parseMiniMessage(
|
||||
"<dark_aqua>* " + user.getPlayerName() + " logged in to Altitude.");
|
||||
|
||||
Bukkit.getOnlinePlayers().stream()
|
||||
.filter(p -> party.getPartyUsersUuid().contains(p.getUniqueId()))
|
||||
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers().contains(uuid))
|
||||
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers()
|
||||
.contains(uuid))
|
||||
.forEach(p -> p.sendMessage(component));
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||
break;
|
||||
}
|
||||
case "partylogout": {
|
||||
case "partylogout" -> {
|
||||
int id = Integer.parseInt(in.readUTF());
|
||||
Party party = PartyManager.getParty(id);
|
||||
if (party == null) {
|
||||
|
|
@ -159,21 +155,20 @@ public class PluginMessage implements PluginMessageListener {
|
|||
public void run() {
|
||||
PartyUser user = party.getPartyUser(uuid);
|
||||
if (user != null) {
|
||||
ComponentLike component = Utility.parseMiniMessage("<dark_aqua>* " + user.getPlayerName() + " logged out of Altitude.");
|
||||
ComponentLike component = Utility.parseMiniMessage(
|
||||
"<dark_aqua>* " + user.getPlayerName() + " logged out of Altitude.");
|
||||
|
||||
Bukkit.getOnlinePlayers().stream()
|
||||
.filter(p -> party.getPartyUsersUuid().contains(p.getUniqueId()))
|
||||
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers().contains(uuid))
|
||||
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers()
|
||||
.contains(uuid))
|
||||
.forEach(p -> p.sendMessage(component));
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||
break;
|
||||
}
|
||||
case "reloadconfig":
|
||||
ChatPlugin.getInstance().reloadConfig();
|
||||
break;
|
||||
case "chatpunishments":
|
||||
case "reloadconfig" -> ChatPlugin.getInstance().reloadConfig();
|
||||
case "chatpunishments" -> {
|
||||
UUID uuid = UUID.fromString(in.readUTF());
|
||||
boolean mute = in.readBoolean();
|
||||
ChatUser user = ChatUserManager.getChatUser(uuid);
|
||||
|
|
@ -181,9 +176,9 @@ public class PluginMessage implements PluginMessageListener {
|
|||
return;
|
||||
}
|
||||
user.setMuted(mute);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +215,8 @@ public class PluginMessage implements PluginMessageListener {
|
|||
public void run() {
|
||||
Bukkit.getOnlinePlayers().stream()
|
||||
.filter(p -> p.hasPermission(finalChatChannel.getPermission()))
|
||||
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers().contains(finalUuid))
|
||||
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers()
|
||||
.contains(finalUuid))
|
||||
.forEach(p -> p.sendMessage(finalComponent));
|
||||
}
|
||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user