mirror of
https://github.com/ryandw11/UltraChat.git
synced 2025-01-03 06:38:05 +01:00
Reformatted Code
- Renamed several internal variables. - Improved the internal code. - Improved the Javadocs. - Improved the API. - Fixed Help command bug. - Fixed sjoin bug. - The console can now use the /chat command. - Fixed the Range chat. - Reimplemented permission based chat coloring. - Reimplemented permission based chat formatting. - Removed unused config options. - Removed unused Classes. - Added more default config options to the chatcolor.yml.
This commit is contained in:
parent
62df20ae69
commit
e4230dbbe5
@ -18,6 +18,7 @@ chat_colors:
|
||||
'&d': 'default'
|
||||
'&e': 'default'
|
||||
'&f': 'default'
|
||||
'&g': '{#11f014}'
|
||||
|
||||
###############################################
|
||||
# Chat Color GUI #
|
||||
@ -86,4 +87,8 @@ color_gui:
|
||||
'Black':
|
||||
color: '&0'
|
||||
item: 'BLACK_WOOL'
|
||||
permission: 'ultrachat.chatcolor.black'
|
||||
permission: 'ultrachat.chatcolor.black'
|
||||
'Pumpkin Orange':
|
||||
color: '{#f59b14}'
|
||||
item: 'BLACK_WOOL'
|
||||
permission: 'ultrachat.chatcolor.pumpkinorange'
|
@ -87,10 +87,6 @@ chat_format: 'normal'
|
||||
#The default color that opped players chat in. Do &r for none.
|
||||
Op_Chat_Color: '&c'
|
||||
|
||||
#Console Chat Log: (JSON chat only!)
|
||||
#With json on the chat no longer prints to the console. This option fixes that issue! Set to true if you want it enabled!
|
||||
console_log: false
|
||||
|
||||
#Variables: %prefix% - Gives you the players prefix. %suffix% - gives you the player suffix!
|
||||
#You can use PlaceHolderAPI here! Check out the placeholders here: https://www.spigotmc.org/wiki/placeholderapi-placeholders/
|
||||
#You can have unlimited custom chat formats.
|
||||
|
@ -1,13 +1,5 @@
|
||||
package me.ryandw11.ultrachat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import me.ryandw11.ultrachat.api.ChatType;
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.managers.AddonManager;
|
||||
@ -15,24 +7,14 @@ import me.ryandw11.ultrachat.chatcolor.ChatColorManager;
|
||||
import me.ryandw11.ultrachat.chatcolor.ChatColorUtil_Latest;
|
||||
import me.ryandw11.ultrachat.chatcolor.ChatColorUtil_Old;
|
||||
import me.ryandw11.ultrachat.chatcolor.ChatColorUtils;
|
||||
import me.ryandw11.ultrachat.commands.ChannelCmd;
|
||||
import me.ryandw11.ultrachat.commands.ChatCommand;
|
||||
import me.ryandw11.ultrachat.commands.CommandTabCompleter;
|
||||
import me.ryandw11.ultrachat.commands.Global;
|
||||
import me.ryandw11.ultrachat.commands.StaffChat;
|
||||
import me.ryandw11.ultrachat.commands.StaffChatToggle;
|
||||
import me.ryandw11.ultrachat.commands.World;
|
||||
import me.ryandw11.ultrachat.commands.SpyCommand;
|
||||
import me.ryandw11.ultrachat.commands.*;
|
||||
import me.ryandw11.ultrachat.formatting.ChannelJSON;
|
||||
import me.ryandw11.ultrachat.formatting.NormalJSON;
|
||||
import me.ryandw11.ultrachat.formatting.RangeJSON;
|
||||
import me.ryandw11.ultrachat.gui.*;
|
||||
import me.ryandw11.ultrachat.listner.ConsoleLogChat;
|
||||
import me.ryandw11.ultrachat.listner.JoinListner;
|
||||
import me.ryandw11.ultrachat.listner.NoSwear;
|
||||
import me.ryandw11.ultrachat.listner.Notify;
|
||||
import me.ryandw11.ultrachat.listner.Spy;
|
||||
import me.ryandw11.ultrachat.listner.StopChat;
|
||||
import me.ryandw11.ultrachat.gui.ColorGUI;
|
||||
import me.ryandw11.ultrachat.gui.ColorGUI_1_15_R1;
|
||||
import me.ryandw11.ultrachat.gui.ColorGUI_Latest;
|
||||
import me.ryandw11.ultrachat.listner.*;
|
||||
import me.ryandw11.ultrachat.pluginhooks.AdvancedBanMute;
|
||||
import me.ryandw11.ultrachat.pluginhooks.EssentialsMute;
|
||||
import me.ryandw11.ultrachat.util.Metrics;
|
||||
@ -41,7 +23,6 @@ import me.ryandw11.ultrachat.util.papi.PAPIEnabled;
|
||||
import me.ryandw11.ultrachat.util.papi.PlaceHolderAPIHook;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -49,51 +30,49 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Main Class
|
||||
*
|
||||
* <p>Updated for 1.16.1.</p>
|
||||
* <p>Note: You should access manager classes from the {@link me.ryandw11.ultrachat.api.UltraChatAPI} class.</p>
|
||||
* @author Ryandw11
|
||||
* @version 2.4
|
||||
* Updated for 1.14.
|
||||
* (Very few API methods here)
|
||||
* @version 2.5
|
||||
*/
|
||||
public class UltraChat extends JavaPlugin {
|
||||
|
||||
public static UltraChat plugin;
|
||||
public Permission perms = null;
|
||||
public Chat chat = null;
|
||||
public Boolean chatStop = false;
|
||||
public ChatType md;
|
||||
public ArrayList<UUID> stafftoggle = new ArrayList<>();
|
||||
public ArrayList<UUID> spytoggle = new ArrayList<>();
|
||||
|
||||
public PlaceHolderAPIHook papi;
|
||||
|
||||
public File datafile = new File(getDataFolder() + "/data/players.yml");
|
||||
public FileConfiguration data = YamlConfiguration.loadConfiguration(datafile);
|
||||
public File channelfile;
|
||||
public FileConfiguration channel;
|
||||
|
||||
public File chatColorFile = new File(getDataFolder() + "/chatcolor.yml");
|
||||
public FileConfiguration chatColorFC = YamlConfiguration.loadConfiguration(chatColorFile);
|
||||
|
||||
public String prefix;
|
||||
public static YamlConfiguration LANG;
|
||||
public static File LANG_FILE;
|
||||
|
||||
private ColorGUI colorGUI;
|
||||
public Permission perms;
|
||||
public Chat chat;
|
||||
public Boolean isChatStopped = false;
|
||||
public ChatType chatType;
|
||||
public List<UUID> staffToggle = new ArrayList<>();
|
||||
public List<UUID> spyToggle = new ArrayList<>();
|
||||
public PlaceHolderAPIHook papi;
|
||||
public File dataFile = new File(getDataFolder() + "/data/players.yml");
|
||||
public FileConfiguration data = YamlConfiguration.loadConfiguration(dataFile);
|
||||
public File channelFile;
|
||||
public FileConfiguration channel;
|
||||
public File chatColorFile = new File(getDataFolder() + "/chatcolor.yml");
|
||||
public FileConfiguration chatColorFC = YamlConfiguration.loadConfiguration(chatColorFile);
|
||||
public String prefix;
|
||||
public ChatColorManager chatColorManager;
|
||||
public AddonManager addonManager;
|
||||
public ChatColorUtils chatColorUtil;
|
||||
|
||||
private ColorGUI colorGUI;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
|
||||
/*
|
||||
* Plugin setup area
|
||||
*/
|
||||
plugin = this;
|
||||
if (getServer().getPluginManager().getPlugin("Vault") == null && !setupChat()) {
|
||||
getLogger().info(String.format("[%s] - Vault is not found!", getDescription().getName()));
|
||||
@ -101,6 +80,7 @@ public class UltraChat extends JavaPlugin {
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
getLogger().info("Hooked into PlaceholderAPI! You can use the place holders!");
|
||||
papi = new PAPIEnabled();
|
||||
@ -128,7 +108,6 @@ public class UltraChat extends JavaPlugin {
|
||||
setupFormatting();
|
||||
loadLang();
|
||||
if (plugin.getConfig().getBoolean("bstats")) {
|
||||
@SuppressWarnings("unused")
|
||||
Metrics m = new Metrics(this);
|
||||
}
|
||||
addonManager = new AddonManager();
|
||||
@ -136,7 +115,7 @@ public class UltraChat extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("[UltraChat] has been disabled correctly!");
|
||||
getLogger().info("The plugin has been disabled correctly!");
|
||||
saveFile();
|
||||
saveChannel();
|
||||
}
|
||||
@ -146,6 +125,7 @@ public class UltraChat extends JavaPlugin {
|
||||
*/
|
||||
public void setupFormatting() {
|
||||
String type = getConfig().getString("chat_format");
|
||||
assert type != null;
|
||||
if (type.equals("")) {
|
||||
getLogger().info("UltraChat will not format the chat. To change this go into the config.");
|
||||
return;
|
||||
@ -154,25 +134,87 @@ public class UltraChat extends JavaPlugin {
|
||||
switch (type.toLowerCase()) {
|
||||
case "channel":
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new ChannelJSON(), this);
|
||||
md = ChatType.CHANNEL;
|
||||
chatType = ChatType.CHANNEL;
|
||||
getLogger().info("Channel chat mode enabled.");
|
||||
break;
|
||||
case "range":
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new RangeJSON(), this);
|
||||
getCommand("global").setExecutor(new Global());
|
||||
getCommand("world").setExecutor(new World());
|
||||
Objects.requireNonNull(getCommand("global")).setExecutor(new Global());
|
||||
Objects.requireNonNull(getCommand("world")).setExecutor(new World());
|
||||
getLogger().info("Range chat mode enabled. The commands /global and /world are now also active.");
|
||||
md = ChatType.RANGE;
|
||||
chatType = ChatType.RANGE;
|
||||
break;
|
||||
default:
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new NormalJSON(), this);
|
||||
md = ChatType.NORMAL;
|
||||
chatType = ChatType.NORMAL;
|
||||
getLogger().info("Normal chat mode activated!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Vault set-up =========================================================
|
||||
/**
|
||||
* Loads all of the Events and Commands.
|
||||
*/
|
||||
public void loadMethod() {
|
||||
Objects.requireNonNull(getCommand("chat")).setExecutor(new NewChatCommand(this));
|
||||
Objects.requireNonNull(getCommand("chat")).setTabCompleter(new CommandTabCompleter());
|
||||
Objects.requireNonNull(getCommand("sc")).setExecutor(new StaffChat());
|
||||
Objects.requireNonNull(getCommand("sctoggle")).setExecutor(new StaffChatToggle());
|
||||
Objects.requireNonNull(getCommand("spy")).setExecutor(new SpyCommand());
|
||||
Objects.requireNonNull(getCommand("channel")).setExecutor(new ChannelCmd());
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new StopChat(), this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new NoSwear(), this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new Spy(), this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new JoinListner(), this);
|
||||
loadVersions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads classes based upon the server version.
|
||||
*/
|
||||
private void loadVersions() {
|
||||
String version;
|
||||
|
||||
try {
|
||||
|
||||
version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||
|
||||
} catch (ArrayIndexOutOfBoundsException w0w) {
|
||||
version = " ";
|
||||
}
|
||||
if (version.equals("v1_14_R1") || version.equals("v1_15_R1")) {
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new Notify(), this);
|
||||
colorGUI = new ColorGUI_1_15_R1();
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new ColorGUI_Latest(), this);
|
||||
if (!(plugin.getConfig().getBoolean("ChatColor_Command")))
|
||||
Objects.requireNonNull(getCommand("color")).setExecutor(new ColorGUI_1_15_R1());
|
||||
|
||||
this.chatColorUtil = new ChatColorUtil_Old();
|
||||
|
||||
} else {
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new Notify(), this);
|
||||
colorGUI = new ColorGUI_Latest();
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new ColorGUI_Latest(), this);
|
||||
|
||||
chatColorManager = new ChatColorManager(this, Objects.requireNonNull(chatColorFC.getConfigurationSection("chat_colors")));
|
||||
|
||||
if (!(plugin.getConfig().getBoolean("ChatColor_Command")))
|
||||
Objects.requireNonNull(getCommand("color")).setExecutor(new ColorGUI_Latest());
|
||||
|
||||
this.chatColorUtil = new ChatColorUtil_Latest(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ColorGUI class for the right version.
|
||||
*
|
||||
* @return A class that implements ColorGUI
|
||||
*/
|
||||
public ColorGUI getColorGUI() {
|
||||
return colorGUI;
|
||||
}
|
||||
|
||||
private boolean setupChat() {
|
||||
RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class);
|
||||
@ -185,14 +227,13 @@ public class UltraChat extends JavaPlugin {
|
||||
perms = rsp.getProvider();
|
||||
return perms != null;
|
||||
}
|
||||
//========================================================================= END ===============================
|
||||
|
||||
/**
|
||||
* Save the data file.
|
||||
*/
|
||||
public void saveFile() {
|
||||
try {
|
||||
data.save(datafile);
|
||||
data.save(dataFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@ -203,9 +244,9 @@ public class UltraChat extends JavaPlugin {
|
||||
* load the data file
|
||||
*/
|
||||
public void loadFile() {
|
||||
if (datafile.exists()) {
|
||||
if (dataFile.exists()) {
|
||||
try {
|
||||
data.load(datafile);
|
||||
data.load(dataFile);
|
||||
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
|
||||
@ -213,7 +254,7 @@ public class UltraChat extends JavaPlugin {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
data.save(datafile);
|
||||
data.save(dataFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -239,7 +280,7 @@ public class UltraChat extends JavaPlugin {
|
||||
public void saveChannel() {
|
||||
|
||||
try {
|
||||
channel.save(channelfile);
|
||||
channel.save(channelFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@ -251,14 +292,14 @@ public class UltraChat extends JavaPlugin {
|
||||
* Load the cannel file.
|
||||
*/
|
||||
public void loadChannel() {
|
||||
channelfile = new File(getDataFolder(), "channel.yml");
|
||||
if (!channelfile.exists()) {
|
||||
channelfile.getParentFile().mkdirs();
|
||||
channelFile = new File(getDataFolder(), "channel.yml");
|
||||
if (!channelFile.exists()) {
|
||||
channelFile.getParentFile().mkdirs();
|
||||
saveResource("channel.yml", false);
|
||||
}
|
||||
channel = new YamlConfiguration();
|
||||
try {
|
||||
channel.load(channelfile);
|
||||
channel.load(channelFile);
|
||||
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
|
||||
@ -283,9 +324,8 @@ public class UltraChat extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Load the language file.
|
||||
*/
|
||||
@SuppressWarnings("static-access")
|
||||
public void loadLang() {
|
||||
File lang = new File(getDataFolder(), "lang.yml");
|
||||
if (!lang.exists()) {
|
||||
@ -313,8 +353,8 @@ public class UltraChat extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
Lang.setFile(conf);
|
||||
this.LANG = conf;
|
||||
this.LANG_FILE = lang;
|
||||
LANG = conf;
|
||||
LANG_FILE = lang;
|
||||
try {
|
||||
conf.save(getLangFile());
|
||||
} catch (IOException e) {
|
||||
@ -328,93 +368,5 @@ public class UltraChat extends JavaPlugin {
|
||||
saveDefaultConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all of the Events and Commands.
|
||||
*/
|
||||
public void loadMethod() {
|
||||
getCommand("chat").setExecutor(new ChatCommand());
|
||||
getCommand("chat").setTabCompleter(new CommandTabCompleter());
|
||||
getCommand("sc").setExecutor(new StaffChat());
|
||||
getCommand("sctoggle").setExecutor(new StaffChatToggle());
|
||||
getCommand("spy").setExecutor(new SpyCommand());
|
||||
getCommand("channel").setExecutor(new ChannelCmd());
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new StopChat(), this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new NoSwear(), this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new Spy(), this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new JoinListner(), this);
|
||||
//Bukkit.getServer().getPluginManager().registerEvents(new Format(this), this);
|
||||
if (getConfig().getBoolean("console_log"))
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new ConsoleLogChat(), this);
|
||||
loadVersions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads classes based upon the server version.
|
||||
*/
|
||||
private void loadVersions() {
|
||||
String version;
|
||||
|
||||
try {
|
||||
|
||||
version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||
|
||||
} catch (ArrayIndexOutOfBoundsException w0w) {
|
||||
version = " ";
|
||||
}
|
||||
if (version.equals("v1_14_R1") || version.equals("v1_15_R1")) {
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new Notify(), this);
|
||||
colorGUI = new ColorGUI_1_15_R1();
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new ColorGUI_Latest(), this);
|
||||
if (!(plugin.getConfig().getBoolean("ChatColor_Command")))
|
||||
getCommand("color").setExecutor(new ColorGUI_1_15_R1());
|
||||
|
||||
this.chatColorUtil = new ChatColorUtil_Old();
|
||||
|
||||
} else {
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new Notify(), this);
|
||||
colorGUI = new ColorGUI_Latest();
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new ColorGUI_Latest(), this);
|
||||
|
||||
chatColorManager = new ChatColorManager(this, Objects.requireNonNull(chatColorFC.getConfigurationSection("chat_colors")));
|
||||
|
||||
if (!(plugin.getConfig().getBoolean("ChatColor_Command")))
|
||||
getCommand("color").setExecutor(new ColorGUI_Latest());
|
||||
|
||||
this.chatColorUtil = new ChatColorUtil_Latest(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ColorGUI class for the right version.
|
||||
*
|
||||
* @return A class that implements ColorGUI
|
||||
*/
|
||||
public ColorGUI getColorGUI() {
|
||||
return colorGUI;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Permmisions:
|
||||
//ultrachat.stopchat
|
||||
//ultrachat.stopchat.bypass
|
||||
//ultrachat.mode
|
||||
//ultrachat.vipchat
|
||||
//ultrachat.broadcast
|
||||
//ultrachat.staffchat
|
||||
//ultrachat.staffchat.toggle
|
||||
//ultrachat.spy
|
||||
//ultrachat.staffmode
|
||||
//ultrachat.clearchat
|
||||
//ultrachat.commandblock.bypass
|
||||
//ultrachat.sjoin
|
||||
//ultrachat.color
|
||||
//ultrachat.worldmute
|
||||
//ultrachat.sjoin.alert
|
||||
//ultrachat.spy.others
|
||||
//ultrachat.fakejoin
|
||||
//ultrachat.fakeleave
|
||||
//ultrachat.help
|
||||
}
|
@ -49,7 +49,7 @@ public class UltraChatAPI{
|
||||
* @return chat type
|
||||
*/
|
||||
public ChatType getChatType(){
|
||||
return plugin.md;
|
||||
return plugin.chatType;
|
||||
}
|
||||
|
||||
|
||||
@ -121,7 +121,7 @@ public class UltraChatAPI{
|
||||
* @return The value of the config.
|
||||
*/
|
||||
public ChatType getFormattingType(){
|
||||
return plugin.md;
|
||||
return plugin.chatType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,7 +83,7 @@ public class ChannelBuilder {
|
||||
|
||||
/**
|
||||
* Set if the channel is always appear
|
||||
* @param alwaysAppear
|
||||
* @param alwaysAppear If the channel should always appear.
|
||||
* @return The builder
|
||||
*/
|
||||
public ChannelBuilder setAlwaysAppear(boolean alwaysAppear) {
|
||||
@ -95,15 +95,15 @@ public class ChannelBuilder {
|
||||
* Build the channel
|
||||
* @return The channel. Note: If the channel name is already used it will return the existing one.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ChatChannel build() {
|
||||
if(UltraChat.plugin.channel.contains(this.name)) {
|
||||
ConfigurationSection cs = UltraChat.plugin.channel.getConfigurationSection(this.name);
|
||||
assert cs != null;
|
||||
this.setPrefix(cs.getString("prefix"));
|
||||
this.setPermission(cs.getString("permission"));
|
||||
this.setAlwaysAppear(cs.getBoolean("always_appear"));
|
||||
this.setFormat(cs.getString("format"));
|
||||
this.setJson((ArrayList<String>) cs.get("JSON"));
|
||||
this.setJson(cs.getStringList("JSON"));
|
||||
}
|
||||
return new ChatChannel(this);
|
||||
}
|
||||
|
@ -4,6 +4,10 @@ import java.util.List;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
|
||||
/**
|
||||
* This class is used the manage channels.
|
||||
* <p>Note: All set methods automatically call the {@link #update()} method.</p>
|
||||
*/
|
||||
public class ChatChannel {
|
||||
|
||||
private String name;
|
||||
@ -15,7 +19,7 @@ public class ChatChannel {
|
||||
|
||||
/**
|
||||
* For internal use only. Always use the channel builder.
|
||||
* @param cb
|
||||
* @param cb The builder that was used to build the channel.
|
||||
*/
|
||||
public ChatChannel(ChannelBuilder cb) {
|
||||
this.name = cb.getName();
|
||||
@ -31,9 +35,9 @@ public class ChatChannel {
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto calls the update() method.
|
||||
* Set the name of the channel.
|
||||
* <p>Note: If this channel is the default channel then you will need to change the default channel name manually</p>
|
||||
* @param name
|
||||
* @param name The name of the channel.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
UltraChat.plugin.channel.set(this.name, null);
|
||||
@ -41,44 +45,76 @@ public class ChatChannel {
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the prefix of the channel.
|
||||
* @return The prefix of the channel.
|
||||
*/
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the prefix of the channel.
|
||||
* @param prefix The prefix of the channel.
|
||||
*/
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permission for the channel.
|
||||
* @return The permission for the channel.
|
||||
*/
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the permission for the channel.
|
||||
* @param permission The permission for the channel.
|
||||
*/
|
||||
public void setPermission(String permission) {
|
||||
this.permission = permission;
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* If the channel always appears.
|
||||
* @return If the channel always appears.
|
||||
*/
|
||||
public boolean isAlwaysAppear() {
|
||||
return alwaysAppear;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the channel will always appear in chat.
|
||||
* @param alwaysAppear If the channel will always appear.
|
||||
*/
|
||||
public void setAlwaysAppear(boolean alwaysAppear) {
|
||||
this.alwaysAppear = alwaysAppear;
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the json of the channel
|
||||
* @return The json.
|
||||
*/
|
||||
public List<String> getJson() {
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the json for the channel.
|
||||
* @param json The json.
|
||||
*/
|
||||
public void setJson(List<String> json) {
|
||||
this.json = json;
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this after every change and after intialization to save the channel to the files.
|
||||
* Call this after every change and after initialization to save the channel to the files.
|
||||
*/
|
||||
private void update() {
|
||||
UltraChat plugin = UltraChat.plugin;
|
||||
@ -91,15 +127,24 @@ public class ChatChannel {
|
||||
|
||||
/**
|
||||
* Delete the channel
|
||||
* @deprecated It is not recommended to use this.
|
||||
*/
|
||||
public void delete() {
|
||||
UltraChat.plugin.channel.set(this.getName(), null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the format of the channel.
|
||||
* @return The format
|
||||
*/
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the format of the channel.
|
||||
* @param format The format.
|
||||
*/
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
update();
|
||||
|
@ -2,6 +2,7 @@ package me.ryandw11.ultrachat.chatcolor;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ChatColorUtil_Latest implements ChatColorUtils {
|
||||
|
||||
@ -17,6 +18,16 @@ public class ChatColorUtil_Latest implements ChatColorUtils {
|
||||
return finalMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translateChatColor(String message, Player p) {
|
||||
String finalMessage = message;
|
||||
if(p.hasPermission("ultrachat.chat.hex"))
|
||||
finalMessage = translateHexColor(message);
|
||||
if(p.hasPermission("ultrachat.chat.color"))
|
||||
finalMessage = plugin.chatColorManager.translateMapColors(finalMessage);
|
||||
return finalMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatColor translateChatCode(String code) {
|
||||
if(code.startsWith("&")){
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.ryandw11.ultrachat.chatcolor;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ChatColorUtil_Old implements ChatColorUtils {
|
||||
|
||||
@ -9,9 +10,19 @@ public class ChatColorUtil_Old implements ChatColorUtils {
|
||||
return ChatColor.translateAlternateColorCodes('&', message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translateChatColor(String message, Player p) {
|
||||
if(p.hasPermission("ultrachat.chat.color"))
|
||||
return ChatColor.translateAlternateColorCodes('&', message);
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatColor translateChatCode(String code) {
|
||||
return null;
|
||||
if(code.startsWith("&")){
|
||||
return ChatColor.getByChar(code.replace("&", "").charAt(0));
|
||||
}
|
||||
return ChatColor.RED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,9 +1,11 @@
|
||||
package me.ryandw11.ultrachat.chatcolor;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface ChatColorUtils {
|
||||
String translateChatColor(String message);
|
||||
String translateChatColor(String message, Player p);
|
||||
ChatColor translateChatCode(String code);
|
||||
boolean isChatCode(String code);
|
||||
}
|
||||
|
@ -1,283 +0,0 @@
|
||||
package me.ryandw11.ultrachat.commands;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.UltraChatAPI;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ryandw11
|
||||
*
|
||||
*/
|
||||
public class ChatCommand implements CommandExecutor {
|
||||
|
||||
|
||||
private UltraChat plugin;
|
||||
public ChatCommand(){
|
||||
plugin = UltraChat.plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String s, String[] args) {
|
||||
if(!(sender instanceof Player )){
|
||||
plugin.getLogger().info(ChatColor.RED + "This command is for players only!");
|
||||
return true;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
|
||||
|
||||
if(args.length == 0){
|
||||
p.sendMessage(ChatColor.BLUE + "=============={" + ChatColor.GREEN + "Ultra Chat" + ChatColor.BLUE + "}==============");
|
||||
p.sendMessage(ChatColor.BLUE + "Plugin developed by:" + ChatColor.GREEN + " Ryandw11");
|
||||
p.sendMessage(ChatColor.BLUE + "Version: " + ChatColor.GREEN + String.format("%s", plugin.getDescription().getVersion()));
|
||||
p.sendMessage(ChatColor.BLUE + "Plugin wiki:" + ChatColor.GREEN + " https://github.com/ryandw11/UltraChat/wiki");
|
||||
p.sendMessage(ChatColor.BLUE + "Do " + ChatColor.GREEN + " /chat help " + ChatColor.BLUE + "for the list of commands!");
|
||||
p.sendMessage(ChatColor.BLUE + "=============={" + ChatColor.GREEN + "Ultra Chat" + ChatColor.BLUE + "}==============");
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Chat Stop Command
|
||||
else if(args.length == 1 && args[0].equalsIgnoreCase("stop")){
|
||||
if(p.hasPermission("ultrachat.stopchat")){
|
||||
|
||||
if(plugin.chatStop == true){
|
||||
plugin.chatStop = false;
|
||||
p.sendMessage(Lang.CHAT_UNSTOP_PERSONAL.toString());
|
||||
Bukkit.getServer().broadcastMessage(Lang.CHAT_STOP_OFF.toString().replace("%p", p.getDisplayName()));
|
||||
}
|
||||
else if(plugin.chatStop == false){
|
||||
plugin.chatStop = true;
|
||||
p.sendMessage(Lang.CHAT_STOP_PERSONAL.toString());
|
||||
Bukkit.getServer().broadcastMessage(Lang.CHAT_STOP_ON.toString().replace("%p", p.getDisplayName()));
|
||||
}
|
||||
else{
|
||||
p.sendMessage("An error has occured!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
else if(args.length >= 1 && args[0].equalsIgnoreCase("broadcast")){
|
||||
if(p.hasPermission("ultrachat.broadcast")){
|
||||
String Message = "";
|
||||
for (int i = 1; i < args.length; i++){
|
||||
Message = Message + " " + args[i];
|
||||
}
|
||||
Bukkit.getServer().broadcastMessage(Lang.BROADCAST_PREFIX.toString() + ChatColor.translateAlternateColorCodes('&', Message));
|
||||
}
|
||||
else{
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
|
||||
}
|
||||
else if(args.length == 1 && args[0].equalsIgnoreCase("broadcast")){
|
||||
if(p.hasPermission("ultrachat.broadcast")){
|
||||
p.sendMessage(ChatColor.RED + "Invalid Usage: /chat broadcast (broadcast)");
|
||||
}
|
||||
else{
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
}//end of broadcast======================================================================================
|
||||
//
|
||||
//================================================================================================================
|
||||
|
||||
else if(args.length == 1 && args[0].equalsIgnoreCase("clear")){
|
||||
if(p.hasPermission("ultrachat.clearchat")){
|
||||
for (int i = 0; i < 100; i++){
|
||||
for(Player pl : Bukkit.getOnlinePlayers()){
|
||||
pl.sendMessage(" ");
|
||||
}
|
||||
}
|
||||
Bukkit.getServer().broadcastMessage(Lang.CHAT_CLEAR.toString().replace("%p", p.getName()));
|
||||
|
||||
}
|
||||
else{
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
}
|
||||
//========================================================
|
||||
|
||||
//==========================================================
|
||||
|
||||
else if(args.length == 1 && args[0].equalsIgnoreCase("sjoin")){
|
||||
if(p.hasPermission("ultrachat.sjoin")){
|
||||
if(plugin.data.getBoolean(p.getUniqueId().toString() + ".sjoin")){
|
||||
p.sendMessage(Lang.SJOIN_SHOWN.toString());
|
||||
plugin.data.set(p.getUniqueId().toString() + ".sjoin", false);
|
||||
plugin.saveFile();
|
||||
}
|
||||
else{
|
||||
plugin.data.set(p.getUniqueId().toString() + ".sjoin", true);
|
||||
plugin.saveFile();
|
||||
p.sendMessage(Lang.SJOIN_HIDE.toString());
|
||||
}
|
||||
}
|
||||
else{
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
|
||||
}
|
||||
else if(args.length == 2 && args[0].equalsIgnoreCase("sjoin")){
|
||||
if(p.hasPermission("ultrachat.sjoin.others")){
|
||||
Player pl = (Player) Bukkit.getServer().getPlayer(args[1]);
|
||||
if(pl == null){p.sendMessage(ChatColor.RED + "Player can not be null!"); return true;}
|
||||
if(plugin.data.getBoolean(p.getUniqueId().toString() + ".sjoin")){
|
||||
p.sendMessage(String.format(Lang.SJOIN_OTHER_SHOW.toString(), pl.getName()));
|
||||
plugin.data.set(p.getUniqueId().toString() + ".sjoin", false);
|
||||
plugin.saveFile();
|
||||
}
|
||||
else{
|
||||
plugin.data.set(p.getUniqueId().toString() + ".sjoin", true);
|
||||
plugin.saveFile();
|
||||
p.sendMessage(String.format(Lang.SJOIN_OTHER_HIDE.toString(), pl.getName()));
|
||||
}
|
||||
}
|
||||
else{
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//======================================================================================================
|
||||
// Break
|
||||
//======================================================================================================
|
||||
|
||||
|
||||
else if(args.length == 2 && args[0].equalsIgnoreCase("join")){
|
||||
if(p.hasPermission("ultrachat.fakejoin")){
|
||||
Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Join_Message").replace("%player%", args[1])));
|
||||
|
||||
}
|
||||
else{
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
}//end of fake join
|
||||
|
||||
else if(args.length == 2 && args[0].equalsIgnoreCase("leave")){
|
||||
if(p.hasPermission("ultrachat.fakeleave")){
|
||||
Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Leave_Message").replace("%player%", args[1])));
|
||||
|
||||
}
|
||||
else{
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
}//end of fake leave
|
||||
//====================================================================
|
||||
|
||||
//================================================================
|
||||
else if(args.length == 1 && args[0].equalsIgnoreCase("help")){
|
||||
if(!p.hasPermission("ultrachat.help"))
|
||||
p.sendMessage(ChatColor.BLUE + "-------------------=[" + ChatColor.GREEN + "Utlra Chat" + ChatColor.BLUE + "]=-------------------");
|
||||
p.sendMessage(ChatColor.GREEN + "/chat help" + ChatColor.BLUE + " The help command.");
|
||||
p.sendMessage(ChatColor.GREEN + "/chat stop" + ChatColor.BLUE + " Stop the chat.");
|
||||
p.sendMessage(ChatColor.GREEN + "/chat broadcast (message)" + ChatColor.BLUE + " Send a message to every player.");
|
||||
p.sendMessage(ChatColor.GREEN + "/sc (message)" + ChatColor.BLUE + " Talk in staff chat.");
|
||||
p.sendMessage(ChatColor.GREEN + "/sctoggle" + ChatColor.BLUE + " Toggle staff chat.");
|
||||
p.sendMessage(ChatColor.GREEN + "/spy" + ChatColor.BLUE + " Enable or disable command spy.");
|
||||
p.sendMessage(ChatColor.GREEN + "/chat clear" + ChatColor.BLUE + " Clear the chat.");
|
||||
p.sendMessage(ChatColor.GREEN + "/chat sjoin" + ChatColor.BLUE + " Silently join and leave the server.");
|
||||
p.sendMessage(ChatColor.GREEN + "/chat leave (player)" + ChatColor.BLUE + " Send a fake leave message.");
|
||||
p.sendMessage(ChatColor.GREEN + "/chat join (player) " + ChatColor.BLUE + " Send a fake join message.");
|
||||
p.sendMessage(ChatColor.BLUE + "Do" + ChatColor.GREEN + " /chat help 2" + ChatColor.BLUE + " for more help pages!");
|
||||
p.sendMessage(ChatColor.BLUE + "Plugin made by: " + ChatColor.GREEN + "Ryandw11" + ChatColor.BLUE + "! Help Page: " + ChatColor.GREEN + "1/2" + ChatColor.BLUE + ".");
|
||||
p.sendMessage(ChatColor.BLUE + "---------------------------------------------------");
|
||||
|
||||
}//end of help
|
||||
|
||||
else if(args.length == 2 && args[0].equalsIgnoreCase("help")){
|
||||
if(p.hasPermission("ultrachat.help")){
|
||||
if(args[1].equals("2")){
|
||||
p.sendMessage(ChatColor.BLUE + "-------------------=[" + ChatColor.GREEN + "Utlra Chat" + ChatColor.BLUE + "]=-------------------");
|
||||
p.sendMessage(ChatColor.GREEN + "/chat color" + ChatColor.BLUE + " Change your chat color.");
|
||||
p.sendMessage(ChatColor.GREEN + "/chat raw {Message}" + ChatColor.BLUE + " Send a message in the chat without a prefix.");
|
||||
p.sendMessage(ChatColor.GREEN + "/chat reload" + ChatColor.BLUE + " Reload the config file.");
|
||||
p.sendMessage(ChatColor.GREEN + "/chat hooks" + ChatColor.BLUE + " Get the current plugin hooks!");
|
||||
p.sendMessage(ChatColor.GREEN + "/channels" + ChatColor.BLUE + " The channel command.");
|
||||
p.sendMessage(ChatColor.BLUE + "Plugin made by: " + ChatColor.GREEN + "Ryandw11" + ChatColor.BLUE + "! Help Page: " + ChatColor.GREEN + "2/2" + ChatColor.BLUE + ".");
|
||||
p.sendMessage(ChatColor.BLUE + "---------------------------------------------------");
|
||||
}
|
||||
if(!(args[1].equals("1") || args[1].equals("2"))){
|
||||
p.sendMessage(Lang.HELP_PAGE_ERROR.toString());
|
||||
}
|
||||
}
|
||||
else{
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("No_Permission")));
|
||||
}
|
||||
}//end of help page ========
|
||||
|
||||
else if(args.length > 1 && args[0].equalsIgnoreCase("raw")){
|
||||
if(p.hasPermission("ultrachat.raw")){
|
||||
String Message = "";
|
||||
for (int i = 1; i < args.length; i++){
|
||||
if(i == 1){
|
||||
Message = Message + args[i]; // Fixed bugs
|
||||
}else{
|
||||
Message = Message + " " + args[i];
|
||||
}
|
||||
}
|
||||
Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', ChatColor.translateAlternateColorCodes('&', Message)));
|
||||
}
|
||||
else{
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
}
|
||||
|
||||
else if(args.length == 1 && args[0].equalsIgnoreCase("reload")){
|
||||
if(p.hasPermission("ultrachat.reload")){
|
||||
plugin.reloadConfig();
|
||||
plugin.loadChannel();
|
||||
p.sendMessage(Lang.CONFIG_RELOAD.toString());
|
||||
}
|
||||
else{
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
}
|
||||
else if(args.length == 1 && args[0].equalsIgnoreCase("color")){
|
||||
if(p.hasPermission("ultrachat.color")){
|
||||
plugin.getColorGUI().openGUI(p.getPlayer(), 1);
|
||||
}
|
||||
else{
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
}
|
||||
else if(args.length == 1 && args[0].equalsIgnoreCase("hooks")){
|
||||
if(p.hasPermission("ultrachat.hooks")){
|
||||
UltraChatAPI uapi = new UltraChatAPI();
|
||||
p.sendMessage(ChatColor.BLUE + "Ultra Chat Hooks:");
|
||||
if(uapi.getActiveHooks() == null){
|
||||
p.sendMessage(ChatColor.GREEN + "No hooks are currently active!");
|
||||
}else{
|
||||
for(String st : uapi.getActiveHooks()){
|
||||
p.sendMessage(ChatColor.GREEN + " - " + st);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
}
|
||||
//=========================================----------------------------------------===========================================
|
||||
else{
|
||||
p.sendMessage(Lang.CHAT_CMD_NOT_VALID.toString());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -54,8 +54,7 @@ public class Global implements CommandExecutor {
|
||||
|
||||
ComponentBuilder cb = new ComponentBuilder("");
|
||||
cb.append(JComponentManager.formatComponents(form, p));
|
||||
TextComponent ct = new TextComponent(uce.getMessage());
|
||||
cb.append(ct);
|
||||
cb.append(new TextComponent(TextComponent.fromLegacyText(UltraChat.plugin.chatColorUtil.translateChatColor(uce.getMessage(), p), pf.getColor())), ComponentBuilder.FormatRetention.NONE);
|
||||
|
||||
for (Player pl : uce.getRecipients()) {
|
||||
pl.spigot().sendMessage(cb.create());
|
||||
@ -65,13 +64,11 @@ public class Global implements CommandExecutor {
|
||||
}
|
||||
|
||||
private String getMessage(String[] args, Player p) {
|
||||
String end = "";
|
||||
StringBuilder end = new StringBuilder();
|
||||
for (String s : args) {
|
||||
end += s + " ";
|
||||
end.append(s).append(" ");
|
||||
}
|
||||
if (p.hasPermission("ultrachat.color"))
|
||||
return ChatColor.translateAlternateColorCodes('&', end);
|
||||
return end;
|
||||
return end.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
231
src/me/ryandw11/ultrachat/commands/NewChatCommand.java
Normal file
231
src/me/ryandw11/ultrachat/commands/NewChatCommand.java
Normal file
@ -0,0 +1,231 @@
|
||||
package me.ryandw11.ultrachat.commands;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.UltraChatAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Ryandw11
|
||||
*/
|
||||
public class NewChatCommand implements CommandExecutor {
|
||||
|
||||
|
||||
private UltraChat plugin;
|
||||
|
||||
public NewChatCommand(UltraChat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String s, @NotNull String[] args) {
|
||||
// This is not a switch statement since I want to check the argument length along with the sub command name.
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.BLUE + "=============={" + ChatColor.GREEN + "Ultra Chat" + ChatColor.BLUE + "}==============");
|
||||
sender.sendMessage(ChatColor.BLUE + "Plugin developed by:" + ChatColor.GREEN + " Ryandw11");
|
||||
sender.sendMessage(ChatColor.BLUE + "Version: " + ChatColor.GREEN + String.format("%s", plugin.getDescription().getVersion()));
|
||||
sender.sendMessage(ChatColor.BLUE + "Plugin wiki:" + ChatColor.GREEN + " https://github.com/ryandw11/UltraChat/wiki");
|
||||
sender.sendMessage(ChatColor.BLUE + "Do " + ChatColor.GREEN + " /chat help " + ChatColor.BLUE + "for the list of commands!");
|
||||
sender.sendMessage(ChatColor.BLUE + "=============={" + ChatColor.GREEN + "Ultra Chat" + ChatColor.BLUE + "}==============");
|
||||
|
||||
} else if (args.length == 1 && args[0].equalsIgnoreCase("stop")) {
|
||||
if (sender.hasPermission("ultrachat.stopchat")) {
|
||||
|
||||
if (plugin.isChatStopped) {
|
||||
plugin.isChatStopped = false;
|
||||
sender.sendMessage(Lang.CHAT_UNSTOP_PERSONAL.toString());
|
||||
Bukkit.getServer().broadcastMessage(Lang.CHAT_STOP_OFF.toString().replace("%p", sender instanceof Player ? ((Player) sender).getDisplayName() :
|
||||
"CONSOLE"));
|
||||
} else {
|
||||
plugin.isChatStopped = true;
|
||||
sender.sendMessage(Lang.CHAT_STOP_PERSONAL.toString());
|
||||
Bukkit.getServer().broadcastMessage(Lang.CHAT_STOP_ON.toString().replace("%p", sender instanceof Player ? ((Player) sender).getDisplayName() :
|
||||
"CONSOLE"));
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
sender.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
|
||||
|
||||
} else if (args.length > 1 && args[0].equalsIgnoreCase("broadcast")) {
|
||||
if (sender.hasPermission("ultrachat.broadcast")) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
message.append(" ").append(args[i]);
|
||||
}
|
||||
Bukkit.getServer().broadcastMessage(Lang.BROADCAST_PREFIX.toString() + ChatColor.translateAlternateColorCodes('&', message.toString()));
|
||||
} else {
|
||||
sender.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
|
||||
} else if (args.length == 1 && args[0].equalsIgnoreCase("broadcast")) {
|
||||
if (sender.hasPermission("ultrachat.broadcast")) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid Usage: /chat broadcast (broadcast)");
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(Lang.NO_PERM.toString());
|
||||
} else if (args.length == 1 && args[0].equalsIgnoreCase("clear")) {
|
||||
if (sender.hasPermission("ultrachat.clearchat")) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
pl.sendMessage(" ");
|
||||
}
|
||||
}
|
||||
Bukkit.getServer().broadcastMessage(Lang.CHAT_CLEAR.toString().replace("%p", sender.getName()));
|
||||
|
||||
} else {
|
||||
sender.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
} else if (args.length == 1 && args[0].equalsIgnoreCase("sjoin")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is for players only!");
|
||||
return true;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (sender.hasPermission("ultrachat.sjoin")) {
|
||||
if (plugin.data.getBoolean(p.getUniqueId().toString() + ".sjoin")) {
|
||||
sender.sendMessage(Lang.SJOIN_SHOWN.toString());
|
||||
plugin.data.set(p.getUniqueId().toString() + ".sjoin", false);
|
||||
plugin.saveFile();
|
||||
} else {
|
||||
plugin.data.set(p.getUniqueId().toString() + ".sjoin", true);
|
||||
plugin.saveFile();
|
||||
sender.sendMessage(Lang.SJOIN_HIDE.toString());
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
|
||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("sjoin")) {
|
||||
if (sender.hasPermission("ultrachat.sjoin.others")) {
|
||||
Player pl = Bukkit.getServer().getPlayer(args[1]);
|
||||
if (pl == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Player can not be null!");
|
||||
return true;
|
||||
}
|
||||
if (plugin.data.getBoolean(pl.getUniqueId().toString() + ".sjoin")) {
|
||||
sender.sendMessage(String.format(Lang.SJOIN_OTHER_SHOW.toString(), pl.getName()));
|
||||
plugin.data.set(pl.getUniqueId().toString() + ".sjoin", false);
|
||||
plugin.saveFile();
|
||||
} else {
|
||||
plugin.data.set(pl.getUniqueId().toString() + ".sjoin", true);
|
||||
plugin.saveFile();
|
||||
sender.sendMessage(String.format(Lang.SJOIN_OTHER_HIDE.toString(), pl.getName()));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
|
||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("join")) {
|
||||
if (sender.hasPermission("ultrachat.fakejoin")) {
|
||||
Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Join_Message")).replace("%player%", args[1])));
|
||||
} else {
|
||||
sender.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("leave")) {
|
||||
if (sender.hasPermission("ultrachat.fakeleave")) {
|
||||
Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Leave_Message")).replace("%player%", args[1])));
|
||||
} else {
|
||||
sender.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
} else if (args.length == 1 && args[0].equalsIgnoreCase("help")) {
|
||||
if (!sender.hasPermission("ultrachat.help")) {
|
||||
sender.sendMessage(Lang.NO_PERM.toString());
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(ChatColor.BLUE + "-------------------=[" + ChatColor.GREEN + "Ultra Chat" + ChatColor.BLUE + "]=-------------------");
|
||||
sender.sendMessage(ChatColor.GREEN + "/chat help" + ChatColor.BLUE + " The help command.");
|
||||
sender.sendMessage(ChatColor.GREEN + "/chat stop" + ChatColor.BLUE + " Stop the chat.");
|
||||
sender.sendMessage(ChatColor.GREEN + "/chat broadcast (message)" + ChatColor.BLUE + " Send a message to every player.");
|
||||
sender.sendMessage(ChatColor.GREEN + "/sc (message)" + ChatColor.BLUE + " Talk in staff chat.");
|
||||
sender.sendMessage(ChatColor.GREEN + "/sctoggle" + ChatColor.BLUE + " Toggle staff chat.");
|
||||
sender.sendMessage(ChatColor.GREEN + "/spy" + ChatColor.BLUE + " Enable or disable command spy.");
|
||||
sender.sendMessage(ChatColor.GREEN + "/chat clear" + ChatColor.BLUE + " Clear the chat.");
|
||||
sender.sendMessage(ChatColor.GREEN + "/chat sjoin" + ChatColor.BLUE + " Silently join and leave the server.");
|
||||
sender.sendMessage(ChatColor.BLUE + "Do" + ChatColor.GREEN + " /chat help 2" + ChatColor.BLUE + " for more help pages!");
|
||||
sender.sendMessage(ChatColor.BLUE + "Plugin made by: " + ChatColor.GREEN + "Ryandw11" + ChatColor.BLUE + "! Help Page: " + ChatColor.GREEN + "1/2" + ChatColor.BLUE + ".");
|
||||
sender.sendMessage(ChatColor.BLUE + "---------------------------------------------------");
|
||||
|
||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("help")) {
|
||||
if (sender.hasPermission("ultrachat.help")) {
|
||||
if (args[1].equals("2")) {
|
||||
sender.sendMessage(ChatColor.BLUE + "-------------------=[" + ChatColor.GREEN + "Ultra Chat" + ChatColor.BLUE + "]=-------------------");
|
||||
sender.sendMessage(ChatColor.GREEN + "/chat leave (player)" + ChatColor.BLUE + " Send a fake leave message.");
|
||||
sender.sendMessage(ChatColor.GREEN + "/chat join (player) " + ChatColor.BLUE + " Send a fake join message.");
|
||||
sender.sendMessage(ChatColor.GREEN + "/chat color" + ChatColor.BLUE + " Change your chat color.");
|
||||
sender.sendMessage(ChatColor.GREEN + "/chat raw {Message}" + ChatColor.BLUE + " Send a message in the chat without a prefix.");
|
||||
sender.sendMessage(ChatColor.GREEN + "/chat reload" + ChatColor.BLUE + " Reload the config file.");
|
||||
sender.sendMessage(ChatColor.GREEN + "/chat hooks" + ChatColor.BLUE + " Get the current plugin hooks!");
|
||||
sender.sendMessage(ChatColor.GREEN + "/channels" + ChatColor.BLUE + " The channel command.");
|
||||
sender.sendMessage(ChatColor.BLUE + "Plugin made by: " + ChatColor.GREEN + "Ryandw11" + ChatColor.BLUE + "! Help Page: " + ChatColor.GREEN + "2/2" + ChatColor.BLUE + ".");
|
||||
sender.sendMessage(ChatColor.BLUE + "---------------------------------------------------");
|
||||
}
|
||||
if (!(args[1].equals("1") || args[1].equals("2"))) {
|
||||
sender.sendMessage(Lang.HELP_PAGE_ERROR.toString());
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("No_Permission"))));
|
||||
}
|
||||
} else if (args.length > 1 && args[0].equalsIgnoreCase("raw")) {
|
||||
if (sender.hasPermission("ultrachat.raw")) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
if (i == 1) {
|
||||
message.append(args[i]);
|
||||
} else {
|
||||
message.append(" ").append(args[i]);
|
||||
}
|
||||
}
|
||||
Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', ChatColor.translateAlternateColorCodes('&', message.toString())));
|
||||
} else {
|
||||
sender.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
} else if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
|
||||
if (sender.hasPermission("ultrachat.reload")) {
|
||||
plugin.reloadConfig();
|
||||
plugin.loadChannel();
|
||||
sender.sendMessage(Lang.CONFIG_RELOAD.toString());
|
||||
} else {
|
||||
sender.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
} else if (args.length == 1 && args[0].equalsIgnoreCase("color")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is for players only!");
|
||||
return true;
|
||||
}
|
||||
if (sender.hasPermission("ultrachat.color"))
|
||||
plugin.getColorGUI().openGUI((Player) sender, 1);
|
||||
else
|
||||
sender.sendMessage(Lang.NO_PERM.toString());
|
||||
} else if (args.length == 1 && args[0].equalsIgnoreCase("hooks")) {
|
||||
if (sender.hasPermission("ultrachat.hooks")) {
|
||||
UltraChatAPI uapi = new UltraChatAPI();
|
||||
sender.sendMessage(ChatColor.BLUE + "Ultra Chat Hooks:");
|
||||
if (uapi.getActiveHooks() == null) {
|
||||
sender.sendMessage(ChatColor.GREEN + "No hooks are currently active!");
|
||||
} else {
|
||||
for (String st : uapi.getActiveHooks()) {
|
||||
sender.sendMessage(ChatColor.GREEN + " - " + st);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(Lang.NO_PERM.toString());
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(Lang.CHAT_CMD_NOT_VALID.toString());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -39,14 +39,14 @@ public class SpyCommand implements CommandExecutor {
|
||||
|
||||
}
|
||||
else{
|
||||
if(plugin.spytoggle.contains(p.getUniqueId())){
|
||||
if(plugin.spyToggle.contains(p.getUniqueId())){
|
||||
p.sendMessage(Lang.CMD_SPY_OFF.toString());
|
||||
plugin.spytoggle.remove(p.getUniqueId());
|
||||
plugin.spyToggle.remove(p.getUniqueId());
|
||||
plugin.data.set(p.getUniqueId().toString() + ".spy", false);
|
||||
plugin.saveFile();
|
||||
}
|
||||
else{
|
||||
plugin.spytoggle.add(p.getUniqueId());
|
||||
plugin.spyToggle.add(p.getUniqueId());
|
||||
p.sendMessage(Lang.CMD_SPY_ON.toString());
|
||||
plugin.data.set(p.getUniqueId().toString() + ".spy", true);
|
||||
plugin.saveFile();
|
||||
@ -58,14 +58,14 @@ public class SpyCommand implements CommandExecutor {
|
||||
else if(args.length == 1){
|
||||
if(p.hasPermission("ultrachat.spy.others")){
|
||||
Player pl = (Player) Bukkit.getServer().getPlayer(args[0]);
|
||||
if(plugin.spytoggle.contains(pl.getUniqueId())){
|
||||
plugin.spytoggle.remove(pl.getUniqueId());
|
||||
if(plugin.spyToggle.contains(pl.getUniqueId())){
|
||||
plugin.spyToggle.remove(pl.getUniqueId());
|
||||
p.sendMessage(Lang.OTH_CMD_SPY_OFF.toString().replace("%p", args[0]));
|
||||
plugin.data.set(pl.getUniqueId().toString() + ".spy", false);
|
||||
plugin.saveFile();
|
||||
}
|
||||
else{
|
||||
plugin.spytoggle.add(pl.getUniqueId());
|
||||
plugin.spyToggle.add(pl.getUniqueId());
|
||||
p.sendMessage(Lang.OTH_CMD_SPY_ON.toString().replace("%p", args[0]));
|
||||
plugin.data.set(pl.getUniqueId().toString() + ".spy", true);
|
||||
plugin.saveFile();
|
||||
|
@ -43,7 +43,7 @@ public class StaffChat implements CommandExecutor {
|
||||
|
||||
for(Player p1 : Bukkit.getOnlinePlayers()){
|
||||
if(p1.hasPermission("ultrachat.staffchat")){
|
||||
if(!plugin.stafftoggle.contains(p1.getUniqueId())){
|
||||
if(!plugin.staffToggle.contains(p1.getUniqueId())){
|
||||
if (p instanceof Player)
|
||||
p1.spigot().sendMessage(JComponentManager.formatComponents(Lang.STAFF_CHAT_FORMAT.toString().replace("%p", p.getName()).replace("%s", message), (Player) p));
|
||||
else
|
||||
|
@ -28,13 +28,13 @@ public class StaffChatToggle implements CommandExecutor {
|
||||
Player p = (Player) sender;
|
||||
if(p.hasPermission("ultrachat.staffchat.toggle")){
|
||||
|
||||
if(plugin.stafftoggle.contains(p.getUniqueId())){
|
||||
plugin.stafftoggle.remove(p.getUniqueId());
|
||||
if(plugin.staffToggle.contains(p.getUniqueId())){
|
||||
plugin.staffToggle.remove(p.getUniqueId());
|
||||
p.sendMessage(Lang.STAFF_CHAT_ON.toString());
|
||||
|
||||
}
|
||||
else{
|
||||
plugin.stafftoggle.add(p.getUniqueId());
|
||||
plugin.staffToggle.add(p.getUniqueId());
|
||||
p.sendMessage(Lang.STAFF_CHAT_OFF.toString());
|
||||
}
|
||||
}//end of perm check
|
||||
|
@ -2,6 +2,7 @@ package me.ryandw11.ultrachat.commands;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -12,7 +13,6 @@ import org.bukkit.entity.Player;
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.ChatType;
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.UltraChatAPI;
|
||||
import me.ryandw11.ultrachat.api.events.UltraChatEvent;
|
||||
import me.ryandw11.ultrachat.api.events.properties.RangeProperties;
|
||||
import me.ryandw11.ultrachat.api.events.properties.RangeType;
|
||||
@ -24,7 +24,7 @@ import net.md_5.bungee.api.chat.TextComponent;
|
||||
public class World implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String s, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String s, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is for players only!");
|
||||
return true;
|
||||
@ -51,8 +51,7 @@ public class World implements CommandExecutor {
|
||||
.replace("%suffix%", pf.getSuffix()) + pf.getColor();
|
||||
ComponentBuilder cb = new ComponentBuilder("");
|
||||
cb.append(JComponentManager.formatComponents(form, p));
|
||||
TextComponent ct = new TextComponent(uce.getMessage());
|
||||
cb.append(ct);
|
||||
cb.append(new TextComponent(TextComponent.fromLegacyText(pf.getColor() + UltraChat.plugin.chatColorUtil.translateChatColor(uce.getMessage(), p), pf.getColor())), ComponentBuilder.FormatRetention.NONE);
|
||||
|
||||
for (Player pl : uce.getRecipients()) {
|
||||
pl.spigot().sendMessage(cb.create());
|
||||
@ -63,13 +62,11 @@ public class World implements CommandExecutor {
|
||||
}
|
||||
|
||||
private String getMessage(String[] args, Player p) {
|
||||
String end = "";
|
||||
StringBuilder end = new StringBuilder();
|
||||
for (String s : args) {
|
||||
end += s + " ";
|
||||
end.append(s).append(" ");
|
||||
}
|
||||
if (p.hasPermission("ultrachat.color"))
|
||||
return ChatColor.translateAlternateColorCodes('&', end);
|
||||
return end;
|
||||
return end.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class ChannelJSON implements Listener {
|
||||
|
||||
ComponentBuilder cb = new ComponentBuilder("");
|
||||
cb.append(JComponentManager.formatComponents(format, p));
|
||||
cb.append(new TextComponent(TextComponent.fromLegacyText(plugin.chatColorUtil.translateChatColor(uce.getMessage()), pf.getColor())), ComponentBuilder.FormatRetention.NONE);
|
||||
cb.append(new TextComponent(TextComponent.fromLegacyText(plugin.chatColorUtil.translateChatColor(uce.getMessage(), p), pf.getColor())), ComponentBuilder.FormatRetention.NONE);
|
||||
pl.spigot().sendMessage(cb.create());
|
||||
}
|
||||
}
|
||||
@ -80,7 +80,7 @@ public class ChannelJSON implements Listener {
|
||||
|
||||
ComponentBuilder cb = new ComponentBuilder("");
|
||||
cb.append(JComponentManager.formatComponents(formats, p));
|
||||
cb.append(new TextComponent(TextComponent.fromLegacyText(plugin.chatColorUtil.translateChatColor(uce.getMessage()), pf.getColor())), ComponentBuilder.FormatRetention.NONE);
|
||||
cb.append(new TextComponent(TextComponent.fromLegacyText(plugin.chatColorUtil.translateChatColor(uce.getMessage(), p), pf.getColor())), ComponentBuilder.FormatRetention.NONE);
|
||||
pl.spigot().sendMessage(cb.create());
|
||||
}
|
||||
}
|
||||
|
@ -63,9 +63,11 @@ public class NormalJSON implements Listener {
|
||||
return;
|
||||
}
|
||||
// If the player is not op
|
||||
for (String permission : Objects.requireNonNull(plugin.getConfig().getConfigurationSection("Custom_Chat.permission_format")).getKeys(false)) {
|
||||
for (String key : Objects.requireNonNull(plugin.getConfig().getConfigurationSection("Custom_Chat.permission_format")).getKeys(false)) {
|
||||
String permission = plugin.getConfig().getString("Custom_Chat.permission_format." + key + ".permission");
|
||||
assert permission != null;
|
||||
if (p.hasPermission(permission)) {
|
||||
String formats = pf.getCustomFormat(permission)
|
||||
String formats = pf.getCustomFormat(key)
|
||||
.replace("%prefix%", pf.getPrefix())
|
||||
.replace("%suffix%", pf.getSuffix())
|
||||
.replace("%player%", p.getDisplayName())
|
||||
@ -74,7 +76,7 @@ public class NormalJSON implements Listener {
|
||||
for (Player pl : event.getRecipients()) {
|
||||
ComponentBuilder cb = new ComponentBuilder("");
|
||||
cb.append(JComponentManager.formatComponents(formats, p));
|
||||
cb.append(new TextComponent(TextComponent.fromLegacyText(plugin.chatColorUtil.translateChatColor(event.getMessage()), pf.getColor())), ComponentBuilder.FormatRetention.NONE);
|
||||
cb.append(new TextComponent(TextComponent.fromLegacyText(pf.getColor() + plugin.chatColorUtil.translateChatColor(event.getMessage(), p), pf.getColor())), ComponentBuilder.FormatRetention.NONE);
|
||||
pl.spigot().sendMessage(cb.create());
|
||||
}
|
||||
return;
|
||||
@ -92,7 +94,7 @@ public class NormalJSON implements Listener {
|
||||
for (Player pl : event.getRecipients()) {
|
||||
ComponentBuilder cb = new ComponentBuilder("");
|
||||
cb.append(JComponentManager.formatComponents(formats, p));
|
||||
cb.append(new TextComponent(TextComponent.fromLegacyText(plugin.chatColorUtil.translateChatColor(event.getMessage()), pf.getColor())), ComponentBuilder.FormatRetention.NONE);
|
||||
cb.append(new TextComponent(TextComponent.fromLegacyText(pf.getColor() + plugin.chatColorUtil.translateChatColor(event.getMessage(), p), pf.getColor())), ComponentBuilder.FormatRetention.NONE);
|
||||
pl.spigot().sendMessage(cb.create());
|
||||
}
|
||||
}
|
||||
|
@ -24,13 +24,13 @@ public class PlayerFormatting {
|
||||
plugin = UltraChat.plugin;
|
||||
|
||||
color = plugin.data.getString(p.getUniqueId() + ".color");
|
||||
prefix = ChatColor.translateAlternateColorCodes('&', plugin.chat.getPlayerPrefix(p));
|
||||
suffix = ChatColor.translateAlternateColorCodes('&', plugin.chat.getPlayerSuffix(p));
|
||||
formatOp = plugin.papi.translatePlaceholders(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Custom_Chat.Op_Chat"))), p);
|
||||
defaults = plugin.papi.translatePlaceholders(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Custom_Chat.Default_Chat"))), p);
|
||||
global = plugin.papi.translatePlaceholders(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Global.format"))), p);
|
||||
world = plugin.papi.translatePlaceholders(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("World.format"))), p);
|
||||
local = plugin.papi.translatePlaceholders(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Local.format"))), p);
|
||||
prefix = ChatUtil.translateColorCodes( plugin.chat.getPlayerPrefix(p));
|
||||
suffix = ChatUtil.translateColorCodes( plugin.chat.getPlayerSuffix(p));
|
||||
formatOp = plugin.papi.translatePlaceholders(ChatUtil.translateColorCodes(Objects.requireNonNull(plugin.getConfig().getString("Custom_Chat.Op_Chat"))), p);
|
||||
defaults = plugin.papi.translatePlaceholders(ChatUtil.translateColorCodes( Objects.requireNonNull(plugin.getConfig().getString("Custom_Chat.Default_Chat"))), p);
|
||||
global = plugin.papi.translatePlaceholders(ChatUtil.translateColorCodes( Objects.requireNonNull(plugin.getConfig().getString("Global.format"))), p);
|
||||
world = plugin.papi.translatePlaceholders(ChatUtil.translateColorCodes( Objects.requireNonNull(plugin.getConfig().getString("World.format"))), p);
|
||||
local = plugin.papi.translatePlaceholders(ChatUtil.translateColorCodes( Objects.requireNonNull(plugin.getConfig().getString("Local.format"))), p);
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
@ -72,8 +72,8 @@ public class PlayerFormatting {
|
||||
return defaults;
|
||||
}
|
||||
|
||||
public String getCustomFormat(String name) {
|
||||
return plugin.papi.translatePlaceholders(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Custom_Chat.permission_format." + name))), p);
|
||||
public String getCustomFormat(String key) {
|
||||
return plugin.papi.translatePlaceholders(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Custom_Chat.permission_format." + key + ".format"))), p);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import me.ryandw11.ultrachat.api.events.properties.RangeType;
|
||||
import me.ryandw11.ultrachat.api.managers.JComponentManager;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
public class RangeJSON implements Listener {
|
||||
|
||||
@ -35,29 +36,33 @@ public class RangeJSON implements Listener {
|
||||
Player p = e.getPlayer();
|
||||
PlayerFormatting pf = new PlayerFormatting(p);
|
||||
e.getRecipients().removeAll(Bukkit.getOnlinePlayers());
|
||||
e.getRecipients().addAll(getNearbyPlayers(p));
|
||||
e.getRecipients().add(p);
|
||||
|
||||
RangeProperties rp = new RangeProperties(true, RangeType.LOCAL);
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
e.getRecipients().addAll(getNearbyPlayers(p));
|
||||
e.getRecipients().add(p);
|
||||
|
||||
UltraChatEvent uce = new UltraChatEvent(p, e.getMessage(), new HashSet<>(e.getRecipients()), ChatType.RANGE, rp);
|
||||
Bukkit.getServer().getPluginManager().callEvent(uce);
|
||||
e.getRecipients().clear();
|
||||
if (!uce.isCancelled()) {
|
||||
for (Player pl : uce.getRecipients()) {
|
||||
|
||||
String formats = pf.getLocal()
|
||||
.replace("%player%", p.getDisplayName())
|
||||
.replace("%prefix%", pf.getPrefix())
|
||||
.replace("%suffix%", pf.getSuffix())
|
||||
+ pf.getColor();
|
||||
RangeProperties rp = new RangeProperties(true, RangeType.LOCAL);
|
||||
|
||||
ComponentBuilder cb = new ComponentBuilder("");
|
||||
cb.append(JComponentManager.formatComponents(formats, p));
|
||||
cb.append(new TextComponent(TextComponent.fromLegacyText(plugin.chatColorUtil.translateChatColor(uce.getMessage()), pf.getColor())), ComponentBuilder.FormatRetention.NONE);
|
||||
pl.spigot().sendMessage(cb.create());
|
||||
}
|
||||
}
|
||||
UltraChatEvent uce = new UltraChatEvent(p, e.getMessage(), new HashSet<>(e.getRecipients()), ChatType.RANGE, rp);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, ()->{
|
||||
Bukkit.getServer().getPluginManager().callEvent(uce);
|
||||
e.getRecipients().clear();
|
||||
if (!uce.isCancelled()) {
|
||||
for (Player pl : uce.getRecipients()) {
|
||||
|
||||
String formats = pf.getLocal()
|
||||
.replace("%player%", p.getDisplayName())
|
||||
.replace("%prefix%", pf.getPrefix())
|
||||
.replace("%suffix%", pf.getSuffix())
|
||||
+ pf.getColor();
|
||||
|
||||
ComponentBuilder cb = new ComponentBuilder("");
|
||||
cb.append(JComponentManager.formatComponents(formats, p));
|
||||
cb.append(new TextComponent(TextComponent.fromLegacyText(plugin.chatColorUtil.translateChatColor(uce.getMessage(), p), pf.getColor())), ComponentBuilder.FormatRetention.NONE);
|
||||
pl.spigot().sendMessage(cb.create());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private ArrayList<Player> getNearbyPlayers(Player pl) {
|
||||
|
@ -34,18 +34,18 @@ private UltraChat plugin;
|
||||
|
||||
color = Objects.requireNonNull(plugin.data.getString(ud + ".color"));
|
||||
try {
|
||||
prefix = ChatColor.translateAlternateColorCodes('&', plugin.chat.getPlayerPrefix(world, op));
|
||||
suffix = ChatColor.translateAlternateColorCodes('&', plugin.chat.getPlayerSuffix(world, op));
|
||||
prefix = ChatUtil.translateColorCodes( plugin.chat.getPlayerPrefix(world, op));
|
||||
suffix = ChatUtil.translateColorCodes( plugin.chat.getPlayerSuffix(world, op));
|
||||
}
|
||||
catch(NullPointerException ex) {
|
||||
prefix = plugin.chat.getPlayerPrefix(world, op);
|
||||
suffix = plugin.chat.getPlayerSuffix(world, op);
|
||||
}
|
||||
formatOp = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Custom_Chat.Op_Chat")));
|
||||
defaults = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Custom_Chat.Default_Chat")));
|
||||
global = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Global.format")));
|
||||
this.world = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("World.format")));
|
||||
local = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Local.format")));
|
||||
formatOp = ChatUtil.translateColorCodes( Objects.requireNonNull(plugin.getConfig().getString("Custom_Chat.Op_Chat")));
|
||||
defaults = ChatUtil.translateColorCodes( Objects.requireNonNull(plugin.getConfig().getString("Custom_Chat.Default_Chat")));
|
||||
global = ChatUtil.translateColorCodes( Objects.requireNonNull(plugin.getConfig().getString("Global.format")));
|
||||
this.world = ChatUtil.translateColorCodes( Objects.requireNonNull(plugin.getConfig().getString("World.format")));
|
||||
local = ChatUtil.translateColorCodes(Objects.requireNonNull(plugin.getConfig().getString("Local.format")));
|
||||
this.op = op;
|
||||
worldName = world;
|
||||
}
|
||||
@ -89,8 +89,8 @@ private UltraChat plugin;
|
||||
return defaults;
|
||||
}
|
||||
|
||||
public String getCustomFormat(String name) {
|
||||
return plugin.getConfig().getString("Custom_Chat.permission_format." + name);
|
||||
public String getCustomFormat(String key) {
|
||||
return plugin.getConfig().getString("Custom_Chat.permission_format." + key + ".format");
|
||||
}
|
||||
|
||||
public OfflinePlayer getOfflinePlayer() {
|
||||
@ -107,9 +107,11 @@ private UltraChat plugin;
|
||||
if(uapi.getChatType() == ChatType.NORMAL) {
|
||||
if(op.isOp()) return this.getOpFormat();
|
||||
|
||||
for (String permission : Objects.requireNonNull(plugin.getConfig().getConfigurationSection("Custom_Chat.permission_format")).getKeys(false)) {
|
||||
for (String key : Objects.requireNonNull(plugin.getConfig().getConfigurationSection("Custom_Chat.permission_format")).getKeys(false)) {
|
||||
String permission = plugin.getConfig().getString("Custom_Chat.permission_format." + key + ".permission");
|
||||
assert permission != null;
|
||||
if (plugin.perms.playerHas(worldName, op, plugin.getConfig().getString(permission))) {
|
||||
return this.getCustomFormat(permission);
|
||||
return this.getCustomFormat(key);
|
||||
}
|
||||
}
|
||||
return this.getDefaultFormat();
|
||||
|
@ -185,7 +185,7 @@ public class ColorGUI_Latest implements CommandExecutor, Listener, ColorGUI{
|
||||
ItemStack item = e.getCurrentItem();
|
||||
if(!e.getInventory().contains(item)) return;
|
||||
|
||||
if(item.equals(getBottomStack()) || item.equals(getCurrentStack(page))) return;
|
||||
if(item.equals(getBottomStack()) || item.equals(getCurrentStack(page)) || item.equals(getNoPermItem())) return;
|
||||
if(item.equals(getNextStack(page))){
|
||||
p.closeInventory();
|
||||
openGUI(p, page+1);
|
||||
|
@ -1,22 +0,0 @@
|
||||
package me.ryandw11.ultrachat.listner;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.events.UltraChatEvent;
|
||||
|
||||
public class ConsoleLogChat implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void jsonChat(UltraChatEvent e){
|
||||
if(!e.getProperties().isComponent()) return;
|
||||
String msg = e.getMessage();
|
||||
String pname = e.getPlayer().getDisplayName();
|
||||
Bukkit.getLogger().log(Level.INFO, Lang.CONSOLE_CHAT_LOG.toString().replace("%p", pname).replace("%s", msg).replace('&', '§'));
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
package me.ryandw11.ultrachat.listner;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.managers.JComponentManager;
|
||||
|
||||
import me.ryandw11.ultrachat.util.ChatUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -13,116 +15,113 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
/**
|
||||
* @author Ryandw11
|
||||
*/
|
||||
public class JoinListner implements Listener {
|
||||
|
||||
private UltraChat plugin;
|
||||
public JoinListner(){
|
||||
plugin = UltraChat.plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event){
|
||||
Player p = event.getPlayer();
|
||||
|
||||
if(plugin.data.contains(p.getUniqueId().toString())){
|
||||
if(!(plugin.channel.contains(plugin.data.getString(p.getUniqueId() + ".channel")))){
|
||||
/*
|
||||
* Fail safe so that if the player joins with an invalid channel it goes back to default.
|
||||
*/
|
||||
plugin.data.set(p.getUniqueId() + ".channel", plugin.getConfig().getString("Default_Channel"));
|
||||
plugin.saveFile();
|
||||
|
||||
}else if(!(plugin.data.contains(p.getUniqueId().toString() + ".spy"))){
|
||||
plugin.data.set(p.getUniqueId().toString() + ".spy", false);
|
||||
plugin.saveFile();
|
||||
}
|
||||
}
|
||||
else{
|
||||
plugin.data.set(p.getUniqueId().toString() + ".color", "&f");
|
||||
plugin.data.set(p.getUniqueId().toString() + ".sjoin", false);
|
||||
plugin.data.set(p.getUniqueId().toString() + ".spy", false);
|
||||
plugin.data.set(p.getUniqueId().toString() + ".channel", plugin.getConfig().getString("Default_Channel"));
|
||||
plugin.saveFile();
|
||||
}
|
||||
|
||||
if(plugin.data.getBoolean(p.getUniqueId().toString() + ".sjoin")){
|
||||
event.setJoinMessage("");
|
||||
for(Player pl : Bukkit.getOnlinePlayers()){
|
||||
if(pl.hasPermission("ultrachat.sjoin.alert")){
|
||||
pl.sendMessage(Lang.SILENT_JOIN_MESSAGE.toString().replace("%p", p.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
String Join = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Join_Message").replace("%player%", p.getName()));
|
||||
event.setJoinMessage(Join);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* On leave event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onLeave(PlayerQuitEvent event){
|
||||
|
||||
Player p = event.getPlayer();
|
||||
if(plugin.data.getBoolean(p.getUniqueId().toString() + ".sjoin")){
|
||||
event.setQuitMessage("");
|
||||
for(Player pl : Bukkit.getOnlinePlayers()){
|
||||
if(pl.hasPermission("ultrachat.sjoin.alert")){
|
||||
pl.sendMessage(Lang.SILENT_LEAVE_MESSAGE.toString().replace("%p", p.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
String leave = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Leave_Message").replace("%player%", p.getName()));
|
||||
event.setQuitMessage(leave);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* For MOTD
|
||||
*/
|
||||
@EventHandler
|
||||
public void MOTD(PlayerJoinEvent event){
|
||||
Player p = event.getPlayer();
|
||||
if(plugin.getConfig().getBoolean("Motd_Enabled")){
|
||||
List <String> motd = plugin.getConfig().getStringList("Motd");
|
||||
for(String OutPut : motd){
|
||||
String message = OutPut;
|
||||
message = plugin.papi.translatePlaceholders(message, p);
|
||||
p.spigot().sendMessage(JComponentManager.formatComponents(ChatColor.translateAlternateColorCodes('&', message), p));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* If there is a new player.
|
||||
*/
|
||||
|
||||
@EventHandler
|
||||
public void NewPlayer(PlayerJoinEvent event){
|
||||
Player p = event.getPlayer();
|
||||
if(!(p.hasPlayedBefore()) && !(plugin.getConfig().getString("New_Player").equalsIgnoreCase("none"))){
|
||||
String msg = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("New_Player").replace("%player%", p.getDisplayName()));
|
||||
for(Player pl : Bukkit.getOnlinePlayers()) {
|
||||
pl.spigot().sendMessage(JComponentManager.formatComponents(msg, p));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private UltraChat plugin;
|
||||
|
||||
public JoinListner() {
|
||||
plugin = UltraChat.plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
|
||||
if (plugin.data.contains(p.getUniqueId().toString())) {
|
||||
if (!(plugin.channel.contains(Objects.requireNonNull(plugin.data.getString(p.getUniqueId() + ".channel"))))) {
|
||||
/*
|
||||
* Fail safe so that if the player joins with an invalid channel it goes back to default.
|
||||
*/
|
||||
plugin.data.set(p.getUniqueId() + ".channel", plugin.getConfig().getString("Default_Channel"));
|
||||
plugin.saveFile();
|
||||
|
||||
} else if (!(plugin.data.contains(p.getUniqueId().toString() + ".spy"))) {
|
||||
plugin.data.set(p.getUniqueId().toString() + ".spy", false);
|
||||
plugin.saveFile();
|
||||
}
|
||||
} else {
|
||||
plugin.data.set(p.getUniqueId().toString() + ".color", "&f");
|
||||
plugin.data.set(p.getUniqueId().toString() + ".sjoin", false);
|
||||
plugin.data.set(p.getUniqueId().toString() + ".spy", false);
|
||||
plugin.data.set(p.getUniqueId().toString() + ".channel", plugin.getConfig().getString("Default_Channel"));
|
||||
plugin.saveFile();
|
||||
}
|
||||
|
||||
if (plugin.data.getBoolean(p.getUniqueId().toString() + ".sjoin")) {
|
||||
event.setJoinMessage("");
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
if (pl.hasPermission("ultrachat.sjoin.alert")) {
|
||||
pl.sendMessage(Lang.SILENT_JOIN_MESSAGE.toString().replace("%p", p.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
String Join = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Join_Message")).replace("%player%", p.getName()));
|
||||
event.setJoinMessage(Join);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* On leave event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onLeave(PlayerQuitEvent event) {
|
||||
|
||||
Player p = event.getPlayer();
|
||||
if (plugin.data.getBoolean(p.getUniqueId().toString() + ".sjoin")) {
|
||||
event.setQuitMessage("");
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
if (pl.hasPermission("ultrachat.sjoin.alert")) {
|
||||
pl.sendMessage(Lang.SILENT_LEAVE_MESSAGE.toString().replace("%p", p.getDisplayName()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
String leave = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Leave_Message").replace("%player%", p.getName()));
|
||||
event.setQuitMessage(leave);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* For MOTD
|
||||
*/
|
||||
@EventHandler
|
||||
public void MOTD(PlayerJoinEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
if (plugin.getConfig().getBoolean("Motd_Enabled")) {
|
||||
List<String> motd = plugin.getConfig().getStringList("Motd");
|
||||
for (String OutPut : motd) {
|
||||
String message = OutPut;
|
||||
message = plugin.papi.translatePlaceholders(message, p);
|
||||
p.spigot().sendMessage(JComponentManager.formatComponents(plugin.chatColorUtil.translateChatColor(message), p));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* If there is a new player.
|
||||
*/
|
||||
|
||||
@EventHandler
|
||||
public void NewPlayer(PlayerJoinEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
if (!(p.hasPlayedBefore()) && !(Objects.requireNonNull(plugin.getConfig().getString("New_Player")).equalsIgnoreCase("none"))) {
|
||||
String msg = ChatUtil.translateColorCodes(Objects.requireNonNull(plugin.getConfig().getString("New_Player")).replace("%player%", p.getDisplayName()));
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
pl.spigot().sendMessage(JComponentManager.formatComponents(msg, p));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,37 +9,38 @@ import me.ryandw11.ultrachat.api.events.UltraChatEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
/**
|
||||
* @author Ryandw11
|
||||
*/
|
||||
public class NoSwear implements Listener {
|
||||
|
||||
private UltraChat plugin;
|
||||
public NoSwear(){
|
||||
plugin = UltraChat.plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJsonChat(UltraChatEvent event){
|
||||
if(plugin.getConfig().getBoolean("Anti_Swear_Enabled")){
|
||||
Player p = event.getPlayer();
|
||||
|
||||
|
||||
List <String> swear = plugin.getConfig().getStringList("Blocked_Words");
|
||||
int times = 0;
|
||||
|
||||
String Message = " " + event.getMessage().toLowerCase().replace(".", "") + " ";
|
||||
|
||||
for(String swearWord : swear){
|
||||
//Check if world chat is enabled
|
||||
if(Message.contains(swearWord + " ") && times == 0 || Message.contains(" " + swearWord + " ") && times == 0 || Message.contains(" " + swearWord) && times == 0 || Message.contains(swearWord)){
|
||||
//else do this:
|
||||
event.setCancelled(true);
|
||||
p.sendMessage(Lang.NO_SWEAR.toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private UltraChat plugin;
|
||||
|
||||
public NoSwear() {
|
||||
plugin = UltraChat.plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJsonChat(UltraChatEvent event) {
|
||||
if (plugin.getConfig().getBoolean("Anti_Swear_Enabled")) {
|
||||
Player p = event.getPlayer();
|
||||
|
||||
|
||||
List<String> swear = plugin.getConfig().getStringList("Blocked_Words");
|
||||
|
||||
String Message = " " + event.getMessage().toLowerCase().replace(".", "") + " ";
|
||||
|
||||
for (String swearWord : swear) {
|
||||
//Check if world chat is enabled
|
||||
if (Message.contains(swearWord + " ") || Message.contains(" " + swearWord + " ") || Message.contains(" " + swearWord) || Message.contains(swearWord)) {
|
||||
//else do this:
|
||||
event.setCancelled(true);
|
||||
p.sendMessage(Lang.NO_SWEAR.toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,30 +1,28 @@
|
||||
package me.ryandw11.ultrachat.listner;
|
||||
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.events.UltraChatEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.events.UltraChatEvent;
|
||||
/**
|
||||
*
|
||||
* @author Ryandw11
|
||||
* Updated for 1.13
|
||||
*
|
||||
*/
|
||||
public class Notify implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onJsonChat(UltraChatEvent e){
|
||||
for(Player p : Bukkit.getOnlinePlayers()){
|
||||
if(e.getMessage().contains("@" + p.getName())){
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 10, 0);
|
||||
p.sendMessage(Lang.MENTION.toString().replace("%p", e.getPlayer().getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onJsonChat(UltraChatEvent e) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (e.getMessage().contains("@" + p.getName())) {
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 10, 0);
|
||||
p.sendMessage(Lang.MENTION.toString().replace("%p", e.getPlayer().getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
package me.ryandw11.ultrachat.listner;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.events.UltraChatEvent;
|
||||
|
||||
/**
|
||||
* For 1.12 and below servers.
|
||||
*/
|
||||
public class Notify_1_12 implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onJsonChat(UltraChatEvent e){
|
||||
for(Player p : Bukkit.getOnlinePlayers()){
|
||||
if(e.getMessage().contains("@" + p.getName())){
|
||||
p.sendMessage(Lang.MENTION.toString().replace("%p", e.getPlayer().getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9,30 +9,29 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
public class Spy implements Listener{
|
||||
|
||||
private UltraChat plugin;
|
||||
public Spy(){
|
||||
plugin = UltraChat.plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCommand(PlayerCommandPreprocessEvent event){
|
||||
Player p1 = (Player) event.getPlayer();
|
||||
String msg = event.getMessage();//get user name
|
||||
|
||||
for(Player p : Bukkit.getOnlinePlayers()){
|
||||
if(plugin.spytoggle.contains(p.getUniqueId())){
|
||||
p.sendMessage(Lang.CMD_SPY_FORMAT.toString().replace("%p", p1.getName()).replace("%s", msg));
|
||||
}// end of if
|
||||
|
||||
|
||||
}//end of for loop
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class Spy implements Listener {
|
||||
|
||||
private UltraChat plugin;
|
||||
|
||||
public Spy() {
|
||||
plugin = UltraChat.plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
|
||||
Player p1 = (Player) event.getPlayer();
|
||||
String msg = event.getMessage();//get user name
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (plugin.spyToggle.contains(p.getUniqueId())) {
|
||||
p.sendMessage(Lang.CMD_SPY_FORMAT.toString().replace("%p", p1.getName()).replace("%s", msg));
|
||||
}// end of if
|
||||
|
||||
|
||||
}//end of for loop
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,35 +1,35 @@
|
||||
package me.ryandw11.ultrachat.listner;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.events.UltraChatEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
/**
|
||||
* Prevent players from chatting when the chat is stopped.
|
||||
* @author Ryandw11
|
||||
*
|
||||
* @author Ryandw11
|
||||
*/
|
||||
public class StopChat implements Listener {
|
||||
|
||||
private UltraChat plugin;
|
||||
public StopChat(){
|
||||
plugin = UltraChat.plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChat(UltraChatEvent e){
|
||||
Player p = e.getPlayer();
|
||||
if(plugin.chatStop){
|
||||
if(!p.hasPermission("ultrachat.stopchat.bypass")){
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(Lang.STOP_CHAT_MESSAGE.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private UltraChat plugin;
|
||||
|
||||
public StopChat() {
|
||||
plugin = UltraChat.plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChat(UltraChatEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (plugin.isChatStopped) {
|
||||
if (!p.hasPermission("ultrachat.stopchat.bypass")) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(Lang.STOP_CHAT_MESSAGE.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ public class EssentialsMute implements Listener{
|
||||
public void jsonChat(UltraChatEvent e){
|
||||
Player p = e.getPlayer();
|
||||
Essentials ess = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
|
||||
if(ess.getUser(p).isMuted()){
|
||||
assert ess != null;
|
||||
if(ess.getUser(p).isMuted()){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package me.ryandw11.ultrachat.util;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* This is a utility class to make chat easier.
|
||||
@ -18,6 +19,10 @@ public class ChatUtil {
|
||||
return UltraChat.plugin.chatColorUtil.translateChatColor(message);
|
||||
}
|
||||
|
||||
public static String translateColorCodes(String message, Player p){
|
||||
return UltraChat.plugin.chatColorUtil.translateChatColor(message, p);
|
||||
}
|
||||
|
||||
public static ChatColor translateColorCode(String code){
|
||||
return UltraChat.plugin.chatColorUtil.translateChatCode(code);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user