mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 06:28:53 +00:00
Add channel registry and remove custom channels
This commit is contained in:
1 parent
bbeaa3bb85
commit
dceb47e160
19 files changed
+200
-565
No files matched your search
@@ -23,7 +23,6 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public final class SimpleChat extends JavaPlugin {
|
public final class SimpleChat extends JavaPlugin {
|
||||||
|
|
||||||
private ArrayList<ChatChannel> channels = new ArrayList<>();
|
|
||||||
private ArrayList<Pattern> itemPatterns = new ArrayList<>();
|
private ArrayList<Pattern> itemPatterns = new ArrayList<>();
|
||||||
|
|
||||||
private Permission permission;
|
private Permission permission;
|
||||||
@@ -128,34 +127,6 @@ public final class SimpleChat extends JavaPlugin {
|
|||||||
return BungeeCordComponentSerializer.get().deserialize(MineDown.parse(input, placeholders));
|
return BungeeCordComponentSerializer.get().deserialize(MineDown.parse(input, placeholders));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatChannel getDefaultChannel() {
|
|
||||||
for (ChatChannel channel : channels) {
|
|
||||||
if (channel.isDefault()) {
|
|
||||||
return channel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return channels.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatChannel getChannel(String name) {
|
|
||||||
if (name == null) {
|
|
||||||
return getDefaultChannel();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ChatChannel chatChannel : channels) {
|
|
||||||
if (chatChannel.getName().equalsIgnoreCase(name)) {
|
|
||||||
return chatChannel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return getDefaultChannel();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ChatChannel> getChannels() {
|
|
||||||
return channels;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Permission getPermission() {
|
public Permission getPermission() {
|
||||||
return permission;
|
return permission;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package net.draycia.simplechat.channels;
|
||||||
|
|
||||||
|
import co.aikar.commands.CommandManager;
|
||||||
|
import net.draycia.simplechat.SimpleChat;
|
||||||
|
import net.draycia.simplechat.commands.AliasedChannelCommand;
|
||||||
|
import net.draycia.simplechat.util.Registry;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ChannelRegistry implements Registry<ChatChannel> {
|
||||||
|
|
||||||
|
private Map<String, ChatChannel> registry = new HashMap<>();
|
||||||
|
private SimpleChat simpleChat;
|
||||||
|
|
||||||
|
public ChannelRegistry(SimpleChat simpleChat) {
|
||||||
|
this.simpleChat = simpleChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean register(@NotNull String key, @NotNull ChatChannel value) {
|
||||||
|
boolean registerSuccessful = registry.putIfAbsent(key, value) == null;
|
||||||
|
|
||||||
|
if (registerSuccessful) {
|
||||||
|
CommandManager commandManager = simpleChat.getCommandManager().getCommandManager();
|
||||||
|
|
||||||
|
commandManager.getCommandReplacements().addReplacement("channelName", value.getAliases());
|
||||||
|
commandManager.registerCommand(new AliasedChannelCommand(simpleChat, value));
|
||||||
|
|
||||||
|
if (value instanceof Listener) {
|
||||||
|
Bukkit.getPluginManager().registerEvents((Listener)value, simpleChat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return registerSuccessful;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public Collection<ChatChannel> values() {
|
||||||
|
return registry.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public ChatChannel get(String key) {
|
||||||
|
return registry.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -39,6 +39,8 @@ public abstract class ChatChannel {
|
|||||||
|
|
||||||
public abstract String getKey();
|
public abstract String getKey();
|
||||||
|
|
||||||
|
public abstract String getAliases();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The distance other players must be within to the sender to see messages in this channel.
|
* @return The distance other players must be within to the sender to see messages in this channel.
|
||||||
*/
|
*/
|
||||||
@@ -67,33 +69,7 @@ public abstract class ChatChannel {
|
|||||||
|
|
||||||
public abstract String getToggleOtherOffMessage();
|
public abstract String getToggleOtherOffMessage();
|
||||||
|
|
||||||
/**
|
public abstract String getCannotUseMessage();
|
||||||
* @return If this channel is Towny's town chat.
|
|
||||||
*/
|
|
||||||
public boolean isTownChat() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return If this channel is Towny's nation chat.
|
|
||||||
*/
|
|
||||||
public boolean isNationChat() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return If this channel is a Towny alliance chat.
|
|
||||||
*/
|
|
||||||
public boolean isAllianceChat() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return If this channel is mcMMO's party chat.
|
|
||||||
*/
|
|
||||||
public boolean isPartyChat() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract boolean firstMatchingGroup();
|
public abstract boolean firstMatchingGroup();
|
||||||
|
|
||||||
|
|||||||
-50
@@ -1,50 +0,0 @@
|
|||||||
package net.draycia.simplechat.channels.impls;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
public class AllianceChatChannel extends NationChatChannel implements Listener {
|
|
||||||
|
|
||||||
public AllianceChatChannel(String name, SimpleChat simpleChat) {
|
|
||||||
super(name, simpleChat);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerSee(ChatUser sender, ChatUser target, boolean checkSpying) {
|
|
||||||
if (checkSpying && target.asPlayer().hasPermission("simplechat.spy." + getName())) {
|
|
||||||
if (target.getChannelSettings(this).isSpying()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (super.canPlayerSee(sender, target, false) && sender != null) {
|
|
||||||
try {
|
|
||||||
Resident resident = TownyAPI.getInstance().getDataSource().getResident(target.asPlayer().getName());
|
|
||||||
Resident targetResident = TownyAPI.getInstance().getDataSource().getResident(sender.asPlayer().getName());
|
|
||||||
|
|
||||||
if (resident.isAlliedWith(targetResident)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAllianceChat() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isNationChat() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-125
@@ -1,125 +0,0 @@
|
|||||||
package net.draycia.simplechat.channels.impls;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
|
||||||
import com.palmergames.bukkit.towny.event.NationRemoveTownEvent;
|
|
||||||
import com.palmergames.bukkit.towny.event.TownRemoveResidentEvent;
|
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
|
||||||
import com.palmergames.bukkit.towny.object.Nation;
|
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
public class NationChatChannel extends SimpleChatChannel implements Listener {
|
|
||||||
|
|
||||||
public NationChatChannel(String name, SimpleChat simpleChat) {
|
|
||||||
super(name, simpleChat);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String processPlaceholders(ChatUser user, String input) {
|
|
||||||
return input.replace("<nation>", getNation(user));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getNation(ChatUser user) {
|
|
||||||
try {
|
|
||||||
Resident resident = TownyAPI.getInstance().getDataSource().getResident(user.asPlayer().getName());
|
|
||||||
|
|
||||||
if (resident.hasNation()) {
|
|
||||||
return resident.getTown().getNation().getFormattedName();
|
|
||||||
}
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerSee(ChatUser sender, ChatUser target, boolean checkSpying) {
|
|
||||||
if (checkSpying && target.asPlayer().hasPermission("simplechat.spy." + getName())) {
|
|
||||||
if (target.getChannelSettings(this).isSpying()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (super.canPlayerSee(sender, target, false) && sender != null) {
|
|
||||||
try {
|
|
||||||
Resident resident = TownyAPI.getInstance().getDataSource().getResident(sender.asPlayer().getName());
|
|
||||||
|
|
||||||
if (resident.hasNation()) {
|
|
||||||
Nation nation = resident.getTown().getNation();
|
|
||||||
|
|
||||||
if (nation.hasResident(target.asPlayer().getName())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerUse(ChatUser user) {
|
|
||||||
return super.canPlayerUse(user) && isInNation(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInNation(ChatUser user) {
|
|
||||||
try {
|
|
||||||
return TownyAPI.getInstance().getDataSource().getResident(user.asPlayer().getName()).hasNation();
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onResidentRemove(TownRemoveResidentEvent event) {
|
|
||||||
String name = event.getResident().getName();
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(Bukkit.getOfflinePlayer(name));
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isAllianceChat()) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onNationRemoveTown(NationRemoveTownEvent event) {
|
|
||||||
for (Resident resident : event.getTown().getResidents()) {
|
|
||||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(resident.getName());
|
|
||||||
|
|
||||||
if (!offlinePlayer.isOnline()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(offlinePlayer);
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isAllianceChat()) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(event.getPlayer());
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isAllianceChat() && !isInNation(user)) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isNationChat() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-82
@@ -1,82 +0,0 @@
|
|||||||
package net.draycia.simplechat.channels.impls;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.api.PartyAPI;
|
|
||||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
public class PartyChatChannel extends SimpleChatChannel implements Listener {
|
|
||||||
|
|
||||||
public PartyChatChannel(String name, SimpleChat simpleChat) {
|
|
||||||
super(name, simpleChat);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String processPlaceholders(ChatUser user, String input) {
|
|
||||||
String partyName = PartyAPI.getPartyName(user.asPlayer());
|
|
||||||
|
|
||||||
if (partyName == null) {
|
|
||||||
partyName = "NotLoaded";
|
|
||||||
}
|
|
||||||
|
|
||||||
return input.replace("<party>", partyName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerSee(ChatUser sender, ChatUser target, boolean checkSpying) {
|
|
||||||
if (checkSpying && target.asPlayer().hasPermission("simplechat.spy." + getName())) {
|
|
||||||
if (target.getChannelSettings(this).isSpying()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (super.canPlayerSee(sender, target, false) && sender != null) {
|
|
||||||
return PartyAPI.inSameParty(sender.asPlayer(), target.asPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerUse(ChatUser user) {
|
|
||||||
return super.canPlayerUse(user) && isInParty(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
private McMMOPartyChangeEvent.EventReason LEFT = McMMOPartyChangeEvent.EventReason.LEFT_PARTY;
|
|
||||||
private McMMOPartyChangeEvent.EventReason KICKED = McMMOPartyChangeEvent.EventReason.KICKED_FROM_PARTY;
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPartyLeave(McMMOPartyChangeEvent event) {
|
|
||||||
if (event.getReason() != LEFT && event.getReason() != KICKED) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(event.getPlayer());
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isPartyChat()) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(event.getPlayer());
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isPartyChat() && !isInParty(user)) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInParty(ChatUser user) {
|
|
||||||
return PartyAPI.inParty(user.asPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPartyChat() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+17
-13
@@ -89,19 +89,7 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
|
|
||||||
TextColor userColor = chatUser.getChannelSettings(this).getColor();
|
TextColor userColor = chatUser.getChannelSettings(this).getColor();
|
||||||
|
|
||||||
String prefix;
|
String prefix = processPlaceholders(user, simpleChat.getConfig().getString("spy-prefix"));
|
||||||
|
|
||||||
if (isNationChat()) {
|
|
||||||
prefix = simpleChat.getConfig().getString("spy-prefix-nation");
|
|
||||||
} else if (isTownChat()) {
|
|
||||||
prefix = simpleChat.getConfig().getString("spy-prefix-town");
|
|
||||||
} else if (isPartyChat()) {
|
|
||||||
prefix = simpleChat.getConfig().getString("spy-prefix-mcmmo");
|
|
||||||
} else {
|
|
||||||
prefix = simpleChat.getConfig().getString("spy-prefix");
|
|
||||||
}
|
|
||||||
|
|
||||||
prefix = processPlaceholders(user, prefix);
|
|
||||||
|
|
||||||
if (userColor == null) {
|
if (userColor == null) {
|
||||||
if (isUserSpying(user, chatUser)) {
|
if (isUserSpying(user, chatUser)) {
|
||||||
@@ -338,6 +326,11 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
return (String) getSetting("toggle-other-off");
|
return (String) getSetting("toggle-other-off");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCannotUseMessage() {
|
||||||
|
return (String) getSetting("cannot-use-channel");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldForwardFormatting() {
|
public boolean shouldForwardFormatting() {
|
||||||
return (Boolean) getSetting("forward-format");
|
return (Boolean) getSetting("forward-format");
|
||||||
@@ -380,4 +373,15 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAliases() {
|
||||||
|
String aliases = (String)getSetting("aliases");
|
||||||
|
|
||||||
|
if (aliases == null) {
|
||||||
|
return getKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
-109
@@ -1,109 +0,0 @@
|
|||||||
package net.draycia.simplechat.channels.impls;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
|
||||||
import com.palmergames.bukkit.towny.event.TownRemoveResidentEvent;
|
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
public class TownChatChannel extends SimpleChatChannel implements Listener {
|
|
||||||
|
|
||||||
public TownChatChannel(String name, SimpleChat simpleChat) {
|
|
||||||
super(name, simpleChat);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String processPlaceholders(ChatUser user, String input) {
|
|
||||||
return input.replace("<town>", getTown(user));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTown(ChatUser user) {
|
|
||||||
try {
|
|
||||||
Resident resident = TownyAPI.getInstance().getDataSource().getResident(user.asPlayer().getName());
|
|
||||||
|
|
||||||
if (resident.hasTown()) {
|
|
||||||
return resident.getTown().getFormattedName();
|
|
||||||
}
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerSee(ChatUser sender, ChatUser target, boolean checkSpying) {
|
|
||||||
if (checkSpying && target.asPlayer().hasPermission("simplechat.spy." + getName())) {
|
|
||||||
if (target.getChannelSettings(this).isSpying()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (super.canPlayerSee(sender, target, false) && sender != null) {
|
|
||||||
try {
|
|
||||||
Resident resident = TownyAPI.getInstance().getDataSource().getResident(target.asPlayer().getName());
|
|
||||||
|
|
||||||
if (resident.hasTown()) {
|
|
||||||
return resident.getTown().hasResident(sender.asPlayer().getName());
|
|
||||||
}
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayerUse(ChatUser user) {
|
|
||||||
if (super.canPlayerUse(user)) {
|
|
||||||
try {
|
|
||||||
return TownyAPI.getInstance().getDataSource().getResident(user.asPlayer().getName()).hasTown();
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInTown(ChatUser user) {
|
|
||||||
try {
|
|
||||||
return TownyAPI.getInstance().getDataSource().getResident(user.asPlayer().getName()).hasTown();
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onResidentRemove(TownRemoveResidentEvent event) {
|
|
||||||
String name = event.getResident().getName();
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(Bukkit.getOfflinePlayer(name));
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isTownChat()) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
ChatUser user = getSimpleChat().getUserService().wrap(event.getPlayer());
|
|
||||||
|
|
||||||
if (user.getSelectedChannel().isTownChat() && !isInTown(user)) {
|
|
||||||
user.clearSelectedChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isTownChat() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+1
-15
@@ -5,10 +5,6 @@ import co.aikar.commands.ConditionFailedException;
|
|||||||
import co.aikar.commands.annotation.*;
|
import co.aikar.commands.annotation.*;
|
||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.channels.impls.AllianceChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.NationChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.PartyChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.TownChatChannel;
|
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -30,17 +26,7 @@ public class AliasedChannelCommand extends BaseCommand {
|
|||||||
ChatUser user = simpleChat.getUserService().wrap(player);
|
ChatUser user = simpleChat.getUserService().wrap(player);
|
||||||
|
|
||||||
if (!chatChannel.canPlayerUse(user)) {
|
if (!chatChannel.canPlayerUse(user)) {
|
||||||
if (chatChannel.isTownChat() && !((TownChatChannel)chatChannel).isInTown(user)) {
|
throw new ConditionFailedException(chatChannel.getCannotUseMessage());
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.town-cannot-use"));
|
|
||||||
} else if (chatChannel.isNationChat() && !((NationChatChannel)chatChannel).isInNation(user)) {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.nation-cannot-use"));
|
|
||||||
} else if (chatChannel.isAllianceChat() && !((AllianceChatChannel)chatChannel).isInNation(user)) {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("alliance-cannot-use"));
|
|
||||||
} else if (chatChannel.isPartyChat() && !((PartyChatChannel)chatChannel).isInParty(user)) {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("party-cannot-use"));
|
|
||||||
} else {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("cannot-use-channel"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args == null || args.length == 0) {
|
if (args == null || args.length == 0) {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ public class ChatReloadCommand extends BaseCommand {
|
|||||||
@Default
|
@Default
|
||||||
public void baseCommand(CommandSender sender) {
|
public void baseCommand(CommandSender sender) {
|
||||||
simpleChat.reloadConfig();
|
simpleChat.reloadConfig();
|
||||||
simpleChat.getChannelManager().reloadChannels();
|
|
||||||
simpleChat.reloadPatterns();
|
simpleChat.reloadPatterns();
|
||||||
|
|
||||||
Component message = simpleChat.processMessage(simpleChat.getConfig().getString("language.reloaded"),
|
Component message = simpleChat.processMessage(simpleChat.getConfig().getString("language.reloaded"),
|
||||||
|
|||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package net.draycia.simplechat.events;
|
||||||
|
|
||||||
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
|
import net.draycia.simplechat.util.Registry;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ChannelRegisterEvent extends Event {
|
||||||
|
|
||||||
|
/** Bukkit event stuff **/
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Relevant stuff **/
|
||||||
|
private List<ChatChannel> registeredChannels;
|
||||||
|
private Registry<ChatChannel> registry;
|
||||||
|
|
||||||
|
public ChannelRegisterEvent(List<ChatChannel> registeredChannels, Registry<ChatChannel> registry) {
|
||||||
|
this.registeredChannels = registeredChannels;
|
||||||
|
this.registry = registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(ChatChannel chatChannel) {
|
||||||
|
registry.register(chatChannel.getKey(), chatChannel);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+39
-81
@@ -1,24 +1,28 @@
|
|||||||
package net.draycia.simplechat.managers;
|
package net.draycia.simplechat.managers;
|
||||||
|
|
||||||
import co.aikar.commands.CommandManager;
|
|
||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
|
import net.draycia.simplechat.channels.ChannelRegistry;
|
||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.channels.impls.*;
|
import net.draycia.simplechat.channels.impls.*;
|
||||||
import net.draycia.simplechat.commands.AliasedChannelCommand;
|
import net.draycia.simplechat.events.ChannelRegisterEvent;
|
||||||
|
import net.draycia.simplechat.util.Registry;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ChannelManager {
|
public class ChannelManager {
|
||||||
|
|
||||||
|
private ChannelRegistry registry;
|
||||||
|
private String defaultChannelKey = null;
|
||||||
|
|
||||||
public ChannelManager(SimpleChat simpleChat) {
|
public ChannelManager(SimpleChat simpleChat) {
|
||||||
boolean hasTownChat = false;
|
registry = new ChannelRegistry(simpleChat);
|
||||||
boolean hasNationChat = false;
|
List<ChatChannel> channels = new ArrayList<>();
|
||||||
boolean hasAllianceChat = false;
|
|
||||||
boolean hasPartyChat = false;
|
|
||||||
|
|
||||||
for (String key : simpleChat.getConfig().getConfigurationSection("channels").getKeys(false)) {
|
for (String key : simpleChat.getConfig().getConfigurationSection("channels").getKeys(false)) {
|
||||||
ChatChannel channel;
|
ChatChannel channel = new SimpleChatChannel(key, simpleChat);
|
||||||
|
|
||||||
ConfigurationSection section = simpleChat.getConfig().getConfigurationSection("channels").getConfigurationSection(key);
|
ConfigurationSection section = simpleChat.getConfig().getConfigurationSection("channels").getConfigurationSection(key);
|
||||||
|
|
||||||
@@ -30,87 +34,41 @@ public class ChannelManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String type = section.getString("type");
|
channels.add(channel);
|
||||||
|
|
||||||
if (type == null) {
|
if (channel.isDefault()) {
|
||||||
type = "normal";
|
defaultChannelKey = channel.getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type.toLowerCase()) {
|
|
||||||
case "towny":
|
|
||||||
channel = new TownChatChannel(key, simpleChat);
|
|
||||||
hasTownChat = true;
|
|
||||||
break;
|
|
||||||
case "nation":
|
|
||||||
channel = new NationChatChannel(key, simpleChat);
|
|
||||||
hasNationChat = true;
|
|
||||||
break;
|
|
||||||
case "alliance":
|
|
||||||
channel = new AllianceChatChannel(key, simpleChat);
|
|
||||||
hasAllianceChat = true;
|
|
||||||
break;
|
|
||||||
case "party":
|
|
||||||
channel = new PartyChatChannel(key, simpleChat);
|
|
||||||
hasPartyChat = true;
|
|
||||||
break;
|
|
||||||
case "normal":
|
|
||||||
channel = new SimpleChatChannel(key, simpleChat);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
simpleChat.getLogger().warning("Invalid channel type for channel [" + key + "]. Skipping channel.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channel.isTownChat() || channel.isNationChat() || channel.isAllianceChat()) {
|
|
||||||
if (!Bukkit.getPluginManager().isPluginEnabled("Towny")) {
|
|
||||||
simpleChat.getLogger().warning("Towny related channel with key [" + key + "] found, but Towny isn't installed. Skipping channel.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channel.isPartyChat()) {
|
|
||||||
if (!Bukkit.getPluginManager().isPluginEnabled("mcMMO")) {
|
|
||||||
simpleChat.getLogger().warning("mcMMO related channel with key [" + key + "] found, but mcMMO isn't installed. Skipping channel.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
simpleChat.getChannels().add(channel);
|
|
||||||
|
|
||||||
CommandManager commandManager = simpleChat.getCommandManager().getCommandManager();
|
|
||||||
|
|
||||||
String commandName = section.contains("aliases") ? section.getString("aliases") : key;
|
|
||||||
|
|
||||||
commandManager.getCommandReplacements().addReplacement("channelName", commandName);
|
|
||||||
commandManager.registerCommand(new AliasedChannelCommand(simpleChat, channel));
|
|
||||||
|
|
||||||
if (channel instanceof Listener) {
|
|
||||||
Bukkit.getPluginManager().registerEvents((Listener)channel, simpleChat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean townyInstalled = Bukkit.getPluginManager().isPluginEnabled("Towny");
|
Bukkit.getPluginManager().callEvent(new ChannelRegisterEvent(channels, getRegistry()));
|
||||||
boolean mcmmoInstalled = Bukkit.getPluginManager().isPluginEnabled("mcMMO");
|
|
||||||
|
|
||||||
if (!hasTownChat && townyInstalled) {
|
|
||||||
simpleChat.getLogger().info("Towny installed but no Town channel is setup!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasNationChat && townyInstalled) {
|
|
||||||
simpleChat.getLogger().info("Towny installed but no Nation channel is setup!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasAllianceChat && townyInstalled) {
|
|
||||||
simpleChat.getLogger().info("Towny installed but no Alliance channel is setup!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasPartyChat && mcmmoInstalled) {
|
|
||||||
simpleChat.getLogger().info("mcMMO installed but no Party channel is setup!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadChannels() {
|
public Registry<ChatChannel> getRegistry() {
|
||||||
|
return registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatChannel getDefaultChannel() {
|
||||||
|
if (defaultChannelKey != null) {
|
||||||
|
return registry.get(defaultChannelKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatChannel getChannelOrDefault(String key) {
|
||||||
|
if (key == null) {
|
||||||
|
return getDefaultChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatChannel channel = registry.get(key);
|
||||||
|
|
||||||
|
if (channel == null) {
|
||||||
|
return getDefaultChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,6 @@ package net.draycia.simplechat.managers;
|
|||||||
import co.aikar.commands.*;
|
import co.aikar.commands.*;
|
||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.channels.impls.AllianceChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.NationChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.PartyChatChannel;
|
|
||||||
import net.draycia.simplechat.channels.impls.TownChatChannel;
|
|
||||||
import net.draycia.simplechat.commands.*;
|
import net.draycia.simplechat.commands.*;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -30,7 +26,7 @@ public class CommandManager {
|
|||||||
|
|
||||||
ArrayList<String> completions = new ArrayList<>();
|
ArrayList<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
for (ChatChannel chatChannel : simpleChat.getChannels()) {
|
for (ChatChannel chatChannel : simpleChat.getChannelManager().getRegistry().values()) {
|
||||||
if (chatChannel.canPlayerUse(user)) {
|
if (chatChannel.canPlayerUse(user)) {
|
||||||
completions.add(chatChannel.getName());
|
completions.add(chatChannel.getName());
|
||||||
}
|
}
|
||||||
@@ -42,7 +38,7 @@ public class CommandManager {
|
|||||||
commandManager.getCommandCompletions().registerCompletion("channel", (context) -> {
|
commandManager.getCommandCompletions().registerCompletion("channel", (context) -> {
|
||||||
ArrayList<String> completions = new ArrayList<>();
|
ArrayList<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
for (ChatChannel chatChannel : simpleChat.getChannels()) {
|
for (ChatChannel chatChannel : simpleChat.getChannelManager().getRegistry().values()) {
|
||||||
completions.add(chatChannel.getName());
|
completions.add(chatChannel.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +48,7 @@ public class CommandManager {
|
|||||||
commandManager.getCommandContexts().registerContext(ChatChannel.class, (context) -> {
|
commandManager.getCommandContexts().registerContext(ChatChannel.class, (context) -> {
|
||||||
String name = context.popFirstArg();
|
String name = context.popFirstArg();
|
||||||
|
|
||||||
for (ChatChannel chatChannel : simpleChat.getChannels()) {
|
for (ChatChannel chatChannel : simpleChat.getChannelManager().getRegistry().values()) {
|
||||||
if (chatChannel.getName().equalsIgnoreCase(name)) {
|
if (chatChannel.getName().equalsIgnoreCase(name)) {
|
||||||
return chatChannel;
|
return chatChannel;
|
||||||
}
|
}
|
||||||
@@ -73,17 +69,7 @@ public class CommandManager {
|
|||||||
ChatUser user = simpleChat.getUserService().wrap(context.getIssuer().getPlayer());
|
ChatUser user = simpleChat.getUserService().wrap(context.getIssuer().getPlayer());
|
||||||
|
|
||||||
if (!value.canPlayerUse(user)) {
|
if (!value.canPlayerUse(user)) {
|
||||||
if (value.isTownChat() && !((TownChatChannel)value).isInTown(user)) {
|
throw new ConditionFailedException(value.getCannotUseMessage());
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.town-cannot-use"));
|
|
||||||
} else if (value.isNationChat() && !((NationChatChannel)value).isInNation(user)) {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.nation-cannot-use"));
|
|
||||||
} else if (value.isAllianceChat() && !((AllianceChatChannel)value).isInNation(user)) {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.alliance-cannot-use"));
|
|
||||||
} else if (value.isPartyChat() && !((PartyChatChannel)value).isInParty(user)) {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.party-cannot-use"));
|
|
||||||
} else {
|
|
||||||
throw new ConditionFailedException(simpleChat.getConfig().getString("language.cannot-use-channel"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -57,7 +57,7 @@ public class PluginMessageManager implements PluginMessageListener {
|
|||||||
private void onMessageReceived(ByteArrayDataInput in) {
|
private void onMessageReceived(ByteArrayDataInput in) {
|
||||||
String chatChannelName = in.readUTF();
|
String chatChannelName = in.readUTF();
|
||||||
|
|
||||||
ChatChannel chatChannel = simpleChat.getChannel(chatChannelName);
|
ChatChannel chatChannel = simpleChat.getChannelManager().getRegistry().get(chatChannelName);
|
||||||
|
|
||||||
if (chatChannel == null) {
|
if (chatChannel == null) {
|
||||||
return;
|
return;
|
||||||
@@ -84,7 +84,7 @@ public class PluginMessageManager implements PluginMessageListener {
|
|||||||
public void onComponentReceived(ByteArrayDataInput in) {
|
public void onComponentReceived(ByteArrayDataInput in) {
|
||||||
String chatChannelName = in.readUTF();
|
String chatChannelName = in.readUTF();
|
||||||
|
|
||||||
ChatChannel chatChannel = simpleChat.getChannel(chatChannelName);
|
ChatChannel chatChannel = simpleChat.getChannelManager().getRegistry().get(chatChannelName);
|
||||||
|
|
||||||
if (chatChannel == null) {
|
if (chatChannel == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
+2
-2
@@ -118,13 +118,13 @@ public class MySQLUserService extends UserService {
|
|||||||
List<DbRow> channelSettings = database.getResults("SELECT * from sc_channel_settings WHERE uuid = ?;", uuid.toString());
|
List<DbRow> channelSettings = database.getResults("SELECT * from sc_channel_settings WHERE uuid = ?;", uuid.toString());
|
||||||
List<DbRow> ignoredUsers = database.getResults("SELECT * from sc_ignored_users WHERE uuid = ?;", uuid.toString());
|
List<DbRow> ignoredUsers = database.getResults("SELECT * from sc_ignored_users WHERE uuid = ?;", uuid.toString());
|
||||||
|
|
||||||
user.setSelectedChannel(simpleChat.getChannel(users.getString("channel")));
|
user.setSelectedChannel(simpleChat.getChannelManager().getRegistry().get(users.getString("channel")));
|
||||||
user.setMuted(users.<Boolean>get("muted"));
|
user.setMuted(users.<Boolean>get("muted"));
|
||||||
user.setShadowMuted(users.<Boolean>get("shadowmuted"));
|
user.setShadowMuted(users.<Boolean>get("shadowmuted"));
|
||||||
user.setSpyingWhispers(users.<Boolean>get("spyingwhispers"));
|
user.setSpyingWhispers(users.<Boolean>get("spyingwhispers"));
|
||||||
|
|
||||||
for (DbRow channelSetting : channelSettings) {
|
for (DbRow channelSetting : channelSettings) {
|
||||||
ChatChannel chatChannel = simpleChat.getChannel(channelSetting.getString("channel"));
|
ChatChannel chatChannel = simpleChat.getChannelManager().getRegistry().get(channelSetting.getString("channel"));
|
||||||
UserChannelSettings settings = user.getChannelSettings(chatChannel);
|
UserChannelSettings settings = user.getChannelSettings(chatChannel);
|
||||||
|
|
||||||
settings.setSpying(channelSetting.<Boolean>get("spying"));
|
settings.setSpying(channelSetting.<Boolean>get("spying"));
|
||||||
|
|||||||
+2
-2
@@ -70,7 +70,7 @@ public class SimpleChatUser implements ChatUser, ForwardingAudience {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChatChannel getSelectedChannel() {
|
public ChatChannel getSelectedChannel() {
|
||||||
return selectedChannel == null ? simpleChat.getDefaultChannel() : simpleChat.getChannel(selectedChannel);
|
return simpleChat.getChannelManager().getChannelOrDefault(selectedChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -83,7 +83,7 @@ public class SimpleChatUser implements ChatUser, ForwardingAudience {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearSelectedChannel() {
|
public void clearSelectedChannel() {
|
||||||
setSelectedChannel(simpleChat.getDefaultChannel());
|
setSelectedChannel(simpleChat.getChannelManager().getDefaultChannel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
Simple channel based chat plugin for Spigot
|
Simple channel based chat plugin for Spigot
|
||||||
Copyright (C) 2020 Alexander Söderberg
|
Copyright (C) 2020 Alexander Söderberg
|
||||||
|
Copyright (C) 2020 Josua Parks (Draycia)
|
||||||
|
|
||||||
|
Modifications made to work with Kyori/Adventure
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package net.draycia.simplechat.util;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public interface Registry<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the specified key and value to the registry
|
||||||
|
* @param key The entry's key
|
||||||
|
* @param value The value to insert
|
||||||
|
* @return If successfully registered
|
||||||
|
*/
|
||||||
|
boolean register(@NotNull String key, @NotNull T value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the list of registered values
|
||||||
|
* @return The list of registered values
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
Collection<T> values();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains an entry associated with the specified key
|
||||||
|
* @param key The key for the entry
|
||||||
|
* @return The entry associated with the key
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
T get(String key);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ default:
|
|||||||
toggle-off-message: '<gray>You can no longer see <color><channel> <gray>chat!'
|
toggle-off-message: '<gray>You can no longer see <color><channel> <gray>chat!'
|
||||||
toggle-other-on: '<gray><player> can now see <color><channel> <gray>chat!'
|
toggle-other-on: '<gray><player> can now see <color><channel> <gray>chat!'
|
||||||
toggle-other-off: '<gray><player> can no longer see <color><channel> <gray>chat!'
|
toggle-other-off: '<gray><player> can no longer see <color><channel> <gray>chat!'
|
||||||
|
cannot-use-channel: "You cannot use that channel!"
|
||||||
formats:
|
formats:
|
||||||
# Placeholders: <username>, <displayname>, <channel>, <server>, <message>, <primaryrole>, <color>
|
# Placeholders: <username>, <displayname>, <channel>, <server>, <message>, <primaryrole>, <color>
|
||||||
# Also supports PlaceholderAPI
|
# Also supports PlaceholderAPI
|
||||||
@@ -31,8 +32,6 @@ default:
|
|||||||
should-bungee: true
|
should-bungee: true
|
||||||
# Determines if this channel should use the highest matching vault group found for formatting
|
# Determines if this channel should use the highest matching vault group found for formatting
|
||||||
first-matching-group: false
|
first-matching-group: false
|
||||||
# Towny, Nation, Alliance, Party, Normal
|
|
||||||
type: 'normal'
|
|
||||||
|
|
||||||
channels:
|
channels:
|
||||||
global:
|
global:
|
||||||
@@ -78,13 +77,6 @@ language:
|
|||||||
spy-whispers-on: '<gray>You are now spying on whispers!'
|
spy-whispers-on: '<gray>You are now spying on whispers!'
|
||||||
spy-whispers-off: '<gray>You are no longer spying on whispers!'
|
spy-whispers-off: '<gray>You are no longer spying on whispers!'
|
||||||
|
|
||||||
# The following messages are not MiniMessage or PAPI compatible
|
|
||||||
cannot-use-channel: "You cannot use that channel!"
|
|
||||||
town-cannot-use: 'You are not in a town!'
|
|
||||||
nation-cannot-use: 'You are not in a nation!'
|
|
||||||
alliance-cannot-use: 'You do not have any alliances!'
|
|
||||||
party-cannot-use: 'You are not in a party!'
|
|
||||||
|
|
||||||
# Used for <server> placeholder in channel formats
|
# Used for <server> placeholder in channel formats
|
||||||
server-name: 'Server'
|
server-name: 'Server'
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user