mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-24 03:12:45 +00:00
Refactored out public static instances that are not constants.
This commit is contained in:
parent
c1f94dc4d0
commit
b057239a81
@ -7,7 +7,6 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -15,13 +14,10 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandMap;
|
|
||||||
import org.bukkit.command.SimpleCommandMap;
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
@ -56,7 +52,6 @@ import mineverse.Aust1n46.chat.listeners.SignListener;
|
|||||||
import mineverse.Aust1n46.chat.localization.Localization;
|
import mineverse.Aust1n46.chat.localization.Localization;
|
||||||
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
import mineverse.Aust1n46.chat.versions.V1_8;
|
|
||||||
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
||||||
import net.milkbowl.vault.chat.Chat;
|
import net.milkbowl.vault.chat.Chat;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
@ -66,49 +61,33 @@ import net.milkbowl.vault.permission.Permission;
|
|||||||
* @author Aust1n46
|
* @author Aust1n46
|
||||||
*/
|
*/
|
||||||
public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
||||||
public static String[] playerlist;
|
|
||||||
public static String playerlist_server;
|
|
||||||
public boolean ircListen;
|
|
||||||
public static ChatMessage lastChatMessage;
|
|
||||||
public static String lastJson;
|
|
||||||
public static Method messageMethod;
|
|
||||||
public static Field posField;
|
|
||||||
public static Class<?> chatMessageType;
|
|
||||||
private static Field commandMap;
|
|
||||||
private static Field knownCommands;
|
|
||||||
|
|
||||||
// Misc --------------------------------
|
|
||||||
public boolean quickchat = true;
|
|
||||||
private static final Logger log = Logger.getLogger("Minecraft");
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static Set<MineverseChatPlayer> players = new HashSet<MineverseChatPlayer>();
|
|
||||||
@Deprecated
|
|
||||||
public static Set<MineverseChatPlayer> onlinePlayers = new HashSet<MineverseChatPlayer>();
|
|
||||||
|
|
||||||
public static List<String> networkPlayerNames = new ArrayList<String>();
|
|
||||||
|
|
||||||
// Plugin Messaging Channel
|
// Plugin Messaging Channel
|
||||||
public static final String PLUGIN_MESSAGING_CHANNEL = "venturechat:data";
|
public static final String PLUGIN_MESSAGING_CHANNEL = "venturechat:data";
|
||||||
|
|
||||||
// Event constants
|
// Event constants
|
||||||
public static final boolean ASYNC = true;
|
public static final boolean ASYNC = true;
|
||||||
public static final boolean SYNC = false;
|
public static final boolean SYNC = false;
|
||||||
|
|
||||||
// Vault --------------------------------
|
|
||||||
public static Permission permission = null;
|
|
||||||
public static Chat chat = null;
|
|
||||||
private static CommandMap cmap;
|
|
||||||
|
|
||||||
public static final int LINE_LENGTH = 40;
|
|
||||||
|
|
||||||
private LogLevels curLogLevel;
|
public static final int LINE_LENGTH = 40;
|
||||||
|
|
||||||
// DiscordSRV backwards compatibility
|
// DiscordSRV backwards compatibility
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static ChatChannelInfo ccInfo;
|
public static ChatChannelInfo ccInfo;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static Set<MineverseChatPlayer> players = new HashSet<MineverseChatPlayer>();
|
||||||
|
@Deprecated
|
||||||
|
public static Set<MineverseChatPlayer> onlinePlayers = new HashSet<MineverseChatPlayer>();
|
||||||
|
|
||||||
|
// Vault
|
||||||
|
private static Permission permission = null;
|
||||||
|
private static Chat chat = null;
|
||||||
|
|
||||||
public static void main(String[] args) {}
|
// NMS
|
||||||
|
private static Field posField;
|
||||||
|
private static Class<?> chatMessageType;
|
||||||
|
private static Field commandMap;
|
||||||
|
private static Field knownCommands;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -130,12 +109,9 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
saveResource("example_config_always_up_to_date!.yml", true);
|
saveResource("example_config_always_up_to_date!.yml", true);
|
||||||
}
|
}
|
||||||
catch(Exception ex) {
|
catch(Exception ex) {
|
||||||
log.severe(String.format("[" + String.format("VentureChat") + "]" + " - Could not load configuration!\n " + ex, getDescription().getName()));
|
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&c - Could not load configuration! Something unexpected went wrong!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setLogLevel(this.getConfig().getString("loglevel", "INFO").toUpperCase());
|
|
||||||
ChatChannel.initialize();
|
|
||||||
|
|
||||||
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Checking for Vault..."));
|
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Checking for Vault..."));
|
||||||
// Set up Vault
|
// Set up Vault
|
||||||
if(!this.setupPermissions()) {
|
if(!this.setupPermissions()) {
|
||||||
@ -186,17 +162,9 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
this.loadNMS();
|
this.loadNMS();
|
||||||
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Attaching to Executors"));
|
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Attaching to Executors"));
|
||||||
|
|
||||||
try {
|
//if(commandMapObj == null) {
|
||||||
// if(VersionHandler.is1_7_9()) cmap = V1_7_9.v1_7_9();
|
//this.quickchat = false;
|
||||||
// if(VersionHandler.is1_7_10()) cmap = V1_7_10.v1_7_10();
|
|
||||||
if(VersionHandler.is1_8()) cmap = V1_8.v1_8();
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
this.quickchat = false;
|
|
||||||
if(cmap == null) {
|
|
||||||
this.quickchat = false;
|
|
||||||
// log.info(String.format("[" + String.format("VentureChat" + "]" +
|
// log.info(String.format("[" + String.format("VentureChat" + "]" +
|
||||||
// " - Unrecognized server version, Quickchat commands not
|
// " - Unrecognized server version, Quickchat commands not
|
||||||
// registering",
|
// registering",
|
||||||
@ -204,8 +172,10 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
// log.info(String.format("[" + String.format("VentureChat" + "]" +
|
// log.info(String.format("[" + String.format("VentureChat" + "]" +
|
||||||
// " - Unrecognized server version, Alias commands not registering",
|
// " - Unrecognized server version, Alias commands not registering",
|
||||||
// getDescription().getName())));
|
// getDescription().getName())));
|
||||||
}
|
//}
|
||||||
else {
|
//else {
|
||||||
|
//this.quickchat = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't run this code right now for(ChatChannel c :
|
* Don't run this code right now for(ChatChannel c :
|
||||||
* ccInfo.getChannelsInfo()) { CCommand cmd = new
|
* ccInfo.getChannelsInfo()) { CCommand cmd = new
|
||||||
@ -219,7 +189,9 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
* FormatStringAll("&8[&eVentureChat&8]&e - Registering Quickchat commands"
|
* FormatStringAll("&8[&eVentureChat&8]&e - Registering Quickchat commands"
|
||||||
* ));
|
* ));
|
||||||
*/
|
*/
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
ChatChannel.initialize(false);
|
||||||
|
|
||||||
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Establishing BungeeCord"));
|
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Establishing BungeeCord"));
|
||||||
Bukkit.getMessenger().registerOutgoingPluginChannel(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL);
|
Bukkit.getMessenger().registerOutgoingPluginChannel(this, MineverseChat.PLUGIN_MESSAGING_CHANNEL);
|
||||||
@ -320,10 +292,6 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommandMap getCommandMap() {
|
|
||||||
return cmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MineverseChat getInstance() {
|
public static MineverseChat getInstance() {
|
||||||
return getPlugin(MineverseChat.class);
|
return getPlugin(MineverseChat.class);
|
||||||
|
|
||||||
@ -341,11 +309,19 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
private void registerPacketListeners() {
|
private void registerPacketListeners() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketListener());
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Field getPosField() {
|
||||||
|
return posField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Class<?> getChatMessageType() {
|
||||||
|
return chatMessageType;
|
||||||
|
}
|
||||||
|
|
||||||
private void loadNMS() {
|
private void loadNMS() {
|
||||||
try {
|
try {
|
||||||
MineverseChat.posField = MinecraftReflection.getMinecraftClass("PacketPlayOutChat").getDeclaredField("b");
|
posField = MinecraftReflection.getMinecraftClass("PacketPlayOutChat").getDeclaredField("b");
|
||||||
MineverseChat.posField.setAccessible(true);
|
posField.setAccessible(true);
|
||||||
|
|
||||||
|
|
||||||
//MineverseChat.messageMethod = MinecraftReflection.getMinecraftClass("ChatBaseComponent").getDeclaredMethod("getString");
|
//MineverseChat.messageMethod = MinecraftReflection.getMinecraftClass("ChatBaseComponent").getDeclaredMethod("getString");
|
||||||
@ -356,7 +332,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
if(!VersionHandler.is1_7_10() && !VersionHandler.is1_8() && !VersionHandler.is1_9() && !VersionHandler.is1_10() && !VersionHandler.is1_11()) {
|
if(!VersionHandler.is1_7_10() && !VersionHandler.is1_8() && !VersionHandler.is1_9() && !VersionHandler.is1_10() && !VersionHandler.is1_11()) {
|
||||||
try {
|
try {
|
||||||
MineverseChat.chatMessageType = getNMSClass("ChatMessageType");
|
chatMessageType = getNMSClass("ChatMessageType");
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -393,20 +369,13 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
return(chat != null);
|
return(chat != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLogLevel(String loglevel) {
|
public static Chat getVaultChat() {
|
||||||
if(LogLevels.valueOf(loglevel) != null) {
|
return chat;
|
||||||
curLogLevel = LogLevels.valueOf(loglevel);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
curLogLevel = LogLevels.INFO;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logme(LogLevels level, String location, String logline) {
|
public static Permission getVaultPermission() {
|
||||||
if(level.ordinal() >= curLogLevel.ordinal()) {
|
return permission;
|
||||||
log.log(Level.INFO, "[VentureChat]: {0}:{1} : {2}", new Object[] { level.toString(), location, logline });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void synchronize(MineverseChatPlayer mcp, boolean changes) {
|
public void synchronize(MineverseChatPlayer mcp, boolean changes) {
|
||||||
@ -614,10 +583,10 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(subchannel.equals("PlayerNames")) {
|
if(subchannel.equals("PlayerNames")) {
|
||||||
networkPlayerNames.clear();
|
MineverseChatAPI.clearNetworkPlayerNames();
|
||||||
int playerCount = msgin.readInt();
|
int playerCount = msgin.readInt();
|
||||||
for(int a = 0; a < playerCount; a ++) {
|
for(int a = 0; a < playerCount; a ++) {
|
||||||
networkPlayerNames.add(msgin.readUTF());
|
MineverseChatAPI.addNetworkPlayerName(msgin.readUTF());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(subchannel.equals("Chwho")) {
|
if(subchannel.equals("Chwho")) {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package mineverse.Aust1n46.chat.api;
|
package mineverse.Aust1n46.chat.api;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -18,9 +20,22 @@ public final class MineverseChatAPI {
|
|||||||
private static HashMap<UUID, MineverseChatPlayer> playerMap = new HashMap<UUID, MineverseChatPlayer>();
|
private static HashMap<UUID, MineverseChatPlayer> playerMap = new HashMap<UUID, MineverseChatPlayer>();
|
||||||
private static HashMap<String, UUID> namesMap = new HashMap<String, UUID>();
|
private static HashMap<String, UUID> namesMap = new HashMap<String, UUID>();
|
||||||
private static HashMap<UUID, MineverseChatPlayer> onlinePlayerMap = new HashMap<UUID, MineverseChatPlayer>();
|
private static HashMap<UUID, MineverseChatPlayer> onlinePlayerMap = new HashMap<UUID, MineverseChatPlayer>();
|
||||||
|
private static List<String> networkPlayerNames = new ArrayList<String>();
|
||||||
|
|
||||||
private static HashMap<UUID, SynchronizedMineverseChatPlayer> bungeePlayerMap = new HashMap<UUID, SynchronizedMineverseChatPlayer>();
|
private static HashMap<UUID, SynchronizedMineverseChatPlayer> bungeePlayerMap = new HashMap<UUID, SynchronizedMineverseChatPlayer>();
|
||||||
|
|
||||||
|
public static List<String> getNetworkPlayerNames() {
|
||||||
|
return networkPlayerNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearNetworkPlayerNames() {
|
||||||
|
networkPlayerNames.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addNetworkPlayerName(String name) {
|
||||||
|
networkPlayerNames.add(name);
|
||||||
|
}
|
||||||
|
|
||||||
public static void addSynchronizedMineverseChatPlayerToMap(SynchronizedMineverseChatPlayer smcp) {
|
public static void addSynchronizedMineverseChatPlayerToMap(SynchronizedMineverseChatPlayer smcp) {
|
||||||
bungeePlayerMap.put(smcp.getUUID(), smcp);
|
bungeePlayerMap.put(smcp.getUUID(), smcp);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ public class ChatChannel {
|
|||||||
|
|
||||||
private static MineverseChat plugin = MineverseChat.getInstance();
|
private static MineverseChat plugin = MineverseChat.getInstance();
|
||||||
private static ChatChannel defaultChatChannel;
|
private static ChatChannel defaultChatChannel;
|
||||||
|
private static boolean aliasesRegisteredAsCommands;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private static ChatChannel[] channels;
|
private static ChatChannel[] channels;
|
||||||
@ -48,7 +49,8 @@ public class ChatChannel {
|
|||||||
/**
|
/**
|
||||||
* Read chat channels from config file and initialize channel array.
|
* Read chat channels from config file and initialize channel array.
|
||||||
*/
|
*/
|
||||||
public static void initialize() {
|
public static void initialize(boolean aliasesRegisteredAsCommands) {
|
||||||
|
ChatChannel.aliasesRegisteredAsCommands = aliasesRegisteredAsCommands;
|
||||||
ConfigurationSection cs = plugin.getConfig().getConfigurationSection("channels");
|
ConfigurationSection cs = plugin.getConfig().getConfigurationSection("channels");
|
||||||
int len = (cs.getKeys(false)).size();
|
int len = (cs.getKeys(false)).size();
|
||||||
channels = new ChatChannel[len];
|
channels = new ChatChannel[len];
|
||||||
@ -79,6 +81,10 @@ public class ChatChannel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean areAliasesRegisteredAsCommands() {
|
||||||
|
return aliasesRegisteredAsCommands;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get array of chat channels.
|
* Get array of chat channels.
|
||||||
|
@ -99,10 +99,10 @@ public class IgnoreCommandExecutor implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(plugin.getConfig().getBoolean("bungeecordmessaging", true)) {
|
if(plugin.getConfig().getBoolean("bungeecordmessaging", true)) {
|
||||||
List<String> completions = new ArrayList<>();
|
List<String> completions = new ArrayList<>();
|
||||||
StringUtil.copyPartialMatches(args[args.length - 1], MineverseChat.networkPlayerNames, completions);
|
StringUtil.copyPartialMatches(args[args.length - 1], MineverseChatAPI.getNetworkPlayerNames(), completions);
|
||||||
Collections.sort(completions);
|
Collections.sort(completions);
|
||||||
return completions;
|
return completions;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ public class MessageCommandExecutor implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(plugin.getConfig().getBoolean("bungeecordmessaging", true)) {
|
if(plugin.getConfig().getBoolean("bungeecordmessaging", true)) {
|
||||||
List<String> completions = new ArrayList<>();
|
List<String> completions = new ArrayList<>();
|
||||||
StringUtil.copyPartialMatches(args[args.length - 1], MineverseChat.networkPlayerNames, completions);
|
StringUtil.copyPartialMatches(args[args.length - 1], MineverseChatAPI.getNetworkPlayerNames(), completions);
|
||||||
Collections.sort(completions);
|
Collections.sort(completions);
|
||||||
return completions;
|
return completions;
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ public class Mute implements VentureCommand {
|
|||||||
if(ChatChannel.isChannel(args[0])) {
|
if(ChatChannel.isChannel(args[0])) {
|
||||||
ChatChannel chatChannelObj = ChatChannel.getChannel(args[0]);
|
ChatChannel chatChannelObj = ChatChannel.getChannel(args[0]);
|
||||||
if(chatChannelObj.getBungee()) {
|
if(chatChannelObj.getBungee()) {
|
||||||
StringUtil.copyPartialMatches(args[1], MineverseChat.networkPlayerNames, completions);
|
StringUtil.copyPartialMatches(args[1], MineverseChatAPI.getNetworkPlayerNames(), completions);
|
||||||
Collections.sort(completions);
|
Collections.sort(completions);
|
||||||
return completions;
|
return completions;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class Unmute implements VentureCommand {
|
|||||||
if(ChatChannel.isChannel(args[0])) {
|
if(ChatChannel.isChannel(args[0])) {
|
||||||
ChatChannel chatChannelObj = ChatChannel.getChannel(args[0]);
|
ChatChannel chatChannelObj = ChatChannel.getChannel(args[0]);
|
||||||
if(chatChannelObj.getBungee()) {
|
if(chatChannelObj.getBungee()) {
|
||||||
StringUtil.copyPartialMatches(args[1], MineverseChat.networkPlayerNames, completions);
|
StringUtil.copyPartialMatches(args[1], MineverseChatAPI.getNetworkPlayerNames(), completions);
|
||||||
Collections.sort(completions);
|
Collections.sort(completions);
|
||||||
return completions;
|
return completions;
|
||||||
}
|
}
|
||||||
|
@ -492,7 +492,7 @@ public class ChatListener implements Listener {
|
|||||||
int hash = message.hashCode();
|
int hash = message.hashCode();
|
||||||
|
|
||||||
//Create VentureChatEvent
|
//Create VentureChatEvent
|
||||||
VentureChatEvent ventureChatEvent = new VentureChatEvent(mcp, mcp.getName(), mcp.getNickname(), MineverseChat.permission.getPrimaryGroup(mcp.getPlayer()), eventChannel, recipients, recipientCount, format, chat, globalJSON, hash, bungee);
|
VentureChatEvent ventureChatEvent = new VentureChatEvent(mcp, mcp.getName(), mcp.getNickname(), MineverseChat.getVaultPermission().getPrimaryGroup(mcp.getPlayer()), eventChannel, recipients, recipientCount, format, chat, globalJSON, hash, bungee);
|
||||||
//Fire event and wait for other plugin listeners to act on it
|
//Fire event and wait for other plugin listeners to act on it
|
||||||
Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent);
|
Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent);
|
||||||
//Call method to send the processed chat
|
//Call method to send the processed chat
|
||||||
@ -548,7 +548,7 @@ public class ChatListener implements Listener {
|
|||||||
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
||||||
System.out.println(out.size() + " bytes size with json");
|
System.out.println(out.size() + " bytes size with json");
|
||||||
}
|
}
|
||||||
out.writeUTF(MineverseChat.permission.getPrimaryGroup(mcp.getPlayer()));
|
out.writeUTF(MineverseChat.getVaultPermission().getPrimaryGroup(mcp.getPlayer()));
|
||||||
out.writeUTF(mcp.getNickname());
|
out.writeUTF(mcp.getNickname());
|
||||||
mcp.getPlayer().sendPluginMessage(plugin, MineverseChat.PLUGIN_MESSAGING_CHANNEL, byteOutStream.toByteArray());
|
mcp.getPlayer().sendPluginMessage(plugin, MineverseChat.PLUGIN_MESSAGING_CHANNEL, byteOutStream.toByteArray());
|
||||||
out.close();
|
out.close();
|
||||||
|
@ -126,7 +126,7 @@ public class CommandListener implements CommandExecutor, Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!plugin.quickchat) {
|
if(!ChatChannel.areAliasesRegisteredAsCommands()) {
|
||||||
for(ChatChannel channel : ChatChannel.getChatChannels()) {
|
for(ChatChannel channel : ChatChannel.getChatChannels()) {
|
||||||
if(!channel.hasPermission() || mcp.getPlayer().hasPermission(channel.getPermission())) {
|
if(!channel.hasPermission() || mcp.getPlayer().hasPermission(channel.getPermission())) {
|
||||||
if(message.equals("/" + channel.getAlias())) {
|
if(message.equals("/" + channel.getAlias())) {
|
||||||
|
@ -7,6 +7,8 @@ import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
|||||||
import mineverse.Aust1n46.chat.utilities.Format;
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.ListenerPriority;
|
import com.comphenix.protocol.events.ListenerPriority;
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
@ -39,23 +41,24 @@ public class PacketListener extends PacketAdapter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(MineverseChat.posField == null) {
|
Field posField = MineverseChat.getPosField();
|
||||||
|
if(posField == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(VersionHandler.is1_7_2() || VersionHandler.is1_7_10() || VersionHandler.is1_7_9()) {
|
if(VersionHandler.is1_7_2() || VersionHandler.is1_7_10() || VersionHandler.is1_7_9()) {
|
||||||
if(!(((boolean) MineverseChat.posField.get(packet.getHandle())))) {
|
if(!(((boolean) posField.get(packet.getHandle())))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(VersionHandler.is1_8() || VersionHandler.is1_9() || VersionHandler.is1_10() || VersionHandler.is1_11()){
|
else if(VersionHandler.is1_8() || VersionHandler.is1_9() || VersionHandler.is1_10() || VersionHandler.is1_11()){
|
||||||
if(((Byte) MineverseChat.posField.get(packet.getHandle())).intValue() > 1) {
|
if(((Byte) posField.get(packet.getHandle())).intValue() > 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(((Object) MineverseChat.posField.get(packet.getHandle())) == MineverseChat.chatMessageType.getEnumConstants()[2]) {
|
if(((Object) posField.get(packet.getHandle())) == MineverseChat.getChatMessageType().getEnumConstants()[2]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,4 +75,4 @@ public class PacketListener extends PacketAdapter {
|
|||||||
int hash = message.hashCode();
|
int hash = message.hashCode();
|
||||||
mcp.addMessage(new ChatMessage(chat, message, coloredMessage, hash));
|
mcp.addMessage(new ChatMessage(chat, message, coloredMessage, hash));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,8 @@ public class Format {
|
|||||||
String prefix = "";
|
String prefix = "";
|
||||||
String suffix = "";
|
String suffix = "";
|
||||||
try {
|
try {
|
||||||
prefix = FormatStringAll(MineverseChat.chat.getPlayerPrefix(sender.getPlayer()));
|
prefix = FormatStringAll(MineverseChat.getVaultChat().getPlayerPrefix(sender.getPlayer()));
|
||||||
suffix = FormatStringAll(MineverseChat.chat.getPlayerSuffix(sender.getPlayer()));
|
suffix = FormatStringAll(MineverseChat.getVaultChat().getPlayerSuffix(sender.getPlayer()));
|
||||||
// Don't apply JSON if the prefix or suffix is just a color code
|
// Don't apply JSON if the prefix or suffix is just a color code
|
||||||
if (suffix.isEmpty() || (suffix.length() == 2 && suffix.substring(1).matches("[0-9a-fA-F]"))) {
|
if (suffix.isEmpty() || (suffix.length() == 2 && suffix.substring(1).matches("[0-9a-fA-F]"))) {
|
||||||
suffix = "venturechat_no_suffix_code";
|
suffix = "venturechat_no_suffix_code";
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
package mineverse.Aust1n46.chat.versions;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandMap;
|
|
||||||
//import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
|
|
||||||
|
|
||||||
//This class returns the CommandMap for Minecraft version 1.7.10
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public class V1_7_10 {
|
|
||||||
/*public static CommandMap v1_7_10() {
|
|
||||||
CommandMap cmap = null;
|
|
||||||
try {
|
|
||||||
if(Bukkit.getServer() instanceof CraftServer) {
|
|
||||||
final Field f = CraftServer.class.getDeclaredField("commandMap");
|
|
||||||
f.setAccessible(true);
|
|
||||||
cmap = (CommandMap) f.get(Bukkit.getServer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return cmap;
|
|
||||||
}*/
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package mineverse.Aust1n46.chat.versions;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandMap;
|
|
||||||
//import org.bukkit.craftbukkit.v1_7_R3.CraftServer;
|
|
||||||
|
|
||||||
//This class returns the CommandMap for Minecraft version 1.7.9
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public class V1_7_9 {
|
|
||||||
/*public static CommandMap v1_7_9() {
|
|
||||||
CommandMap cmap = null;
|
|
||||||
try {
|
|
||||||
if(Bukkit.getServer() instanceof CraftServer) {
|
|
||||||
final Field f = CraftServer.class.getDeclaredField("commandMap");
|
|
||||||
f.setAccessible(true);
|
|
||||||
cmap = (CommandMap) f.get(Bukkit.getServer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return cmap;
|
|
||||||
}*/
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
package mineverse.Aust1n46.chat.versions;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandMap;
|
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
|
|
||||||
|
|
||||||
//This class returns the CommandMap for Minecraft version 1.8
|
|
||||||
public class V1_8 {
|
|
||||||
public static CommandMap v1_8() {
|
|
||||||
CommandMap cmap = null;
|
|
||||||
try {
|
|
||||||
if(Bukkit.getServer() instanceof CraftServer) {
|
|
||||||
final Field f = CraftServer.class.getDeclaredField("commandMap");
|
|
||||||
f.setAccessible(true);
|
|
||||||
cmap = (CommandMap) f.get(Bukkit.getServer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return cmap;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user