This commit is contained in:
parent
e55bd1c676
commit
b267985be1
3 changed files with 29 additions and 13 deletions
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
package eu.m724.tweaks;
|
package eu.m724.tweaks;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
@ -23,4 +27,12 @@ public class Language {
|
||||||
public static String getString(String key) {
|
public static String getString(String key) {
|
||||||
return INSTANCE.resourceBundle.getString(key);
|
return INSTANCE.resourceBundle.getString(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BaseComponent getComponent(String key, ChatColor color) {
|
||||||
|
return new ComponentBuilder(getString(key)).color(color).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BaseComponent getComponent(String key, ChatColor color, Object... format) {
|
||||||
|
return new ComponentBuilder(getString(key).formatted(format)).color(color).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
package eu.m724.tweaks.chat;
|
package eu.m724.tweaks.chat;
|
||||||
|
|
||||||
|
import eu.m724.tweaks.Language;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
|
@ -45,36 +46,31 @@ public class ChatCommands implements CommandExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean authenticated = false;
|
boolean authenticated = false;
|
||||||
BaseComponent[] component = null;
|
BaseComponent component = null;
|
||||||
ChatRoom newRoom = manager.getById(id);
|
ChatRoom newRoom = manager.getById(id);
|
||||||
if (newRoom != null) {
|
if (newRoom != null) {
|
||||||
if (newRoom.password != null) {
|
if (newRoom.password != null) {
|
||||||
if (newRoom.password.equals(password)) {
|
if (newRoom.password.equals(password)) {
|
||||||
authenticated = true;
|
authenticated = true;
|
||||||
} else if (password == null) {
|
} else if (password == null) {
|
||||||
component = new ComponentBuilder("This room is password protected").color(ChatColor.RED)
|
component = Language.getComponent("chatPasswordProtected", ChatColor.RED);
|
||||||
.create();
|
|
||||||
} else {
|
} else {
|
||||||
component = new ComponentBuilder("Invalid password").color(ChatColor.RED)
|
component = Language.getComponent("chatWrongPassword", ChatColor.RED);
|
||||||
.create();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
authenticated = true;
|
authenticated = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
component = new ComponentBuilder("No room named ").color(ChatColor.RED)
|
component = Language.getComponent("chatNoSuchRoom", ChatColor.RED, id);
|
||||||
.append(id).color(ChatColor.AQUA)
|
|
||||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(chatRoom.getInfoComponent())))
|
|
||||||
.create();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authenticated) {
|
if (authenticated) {
|
||||||
manager.setPlayerChatRoom(newRoom, player);
|
manager.setPlayerChatRoom(newRoom, player);
|
||||||
component = new ComponentBuilder("Joined chat room: ").color(ChatColor.GOLD)
|
component = new ComponentBuilder(Language.getComponent("chatJoined", ChatColor.GOLD))
|
||||||
.append(newRoom.id).color(newRoom.color)
|
.append(newRoom.id).color(newRoom.color)
|
||||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(newRoom.getInfoComponent())))
|
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(newRoom.getInfoComponent())))
|
||||||
.append("\nThere are %d other players".formatted(newRoom.players.size())).color(ChatColor.GOLD)
|
.append(Language.getComponent("chatPlayers", ChatColor.GOLD, newRoom.players.size()))
|
||||||
.create();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
player.spigot().sendMessage(component);
|
player.spigot().sendMessage(component);
|
||||||
|
|
|
@ -12,4 +12,12 @@ updatesNotChecked = Not checked yet
|
||||||
# %s is time as HH:mm
|
# %s is time as HH:mm
|
||||||
updatesNoUpdates = No available updates. Last checked: %s
|
updatesNoUpdates = No available updates. Last checked: %s
|
||||||
# %s is update title
|
# %s is update title
|
||||||
updatesClickToOpen = Click to open on SpigotMC "%s"
|
updatesClickToOpen = Click to open on SpigotMC "%s"
|
||||||
|
|
||||||
|
# Used in /chat
|
||||||
|
chatPasswordProtected = This room is password protected
|
||||||
|
chatWrongPassword = Wrong password
|
||||||
|
chatNoSuchRoom = No room named %s
|
||||||
|
# Room name is added at end
|
||||||
|
chatJoined = Joined chat room:
|
||||||
|
chatPlayers = %d other players are here
|
Loading…
Reference in a new issue