mirror of
https://github.com/ryandw11/UltraChat.git
synced 2025-01-03 06:38:05 +01:00
Begining chanes of 2.4
This commit is contained in:
parent
23261db702
commit
ba2705429b
@ -1,5 +1,5 @@
|
||||
name: UltraChat
|
||||
version: 2.3.2
|
||||
version: 2.3.3
|
||||
main: me.ryandw11.ultrachat.UltraChat
|
||||
author: Ryandw11
|
||||
description: A chat formatting plugin.
|
||||
|
@ -8,6 +8,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.channels.ChannelBuilder;
|
||||
import me.ryandw11.ultrachat.api.channels.ChatChannel;
|
||||
import me.ryandw11.ultrachat.formatting.PlayerFormatting;
|
||||
/**
|
||||
* UltraChatAPI
|
||||
@ -23,60 +25,12 @@ public class UltraChatAPI{
|
||||
*
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Grab the Instance
|
||||
* @return #getPlugin()
|
||||
* @deprecated
|
||||
*/
|
||||
public static UltraChat getInstance(){
|
||||
return getPlugin();
|
||||
private UltraChat plugin;
|
||||
public UltraChatAPI(){
|
||||
this.plugin = UltraChat.plugin;
|
||||
}
|
||||
|
||||
private UltraChat plugin;
|
||||
public UltraChatAPI(UltraChat plugin){
|
||||
this.plugin = plugin;
|
||||
}
|
||||
/**
|
||||
* Grab the player's current channel.
|
||||
* @param player
|
||||
* @return The player's current channel.
|
||||
*/
|
||||
public String getPlayerChannel(Player player){
|
||||
return plugin.data.getString(player.getUniqueId() + ".channel");
|
||||
}
|
||||
/**
|
||||
* Get the servers default channel.
|
||||
* @return Default Channel
|
||||
*/
|
||||
public String getDefaultChannel(){
|
||||
return plugin.getConfig().getString("Default_Channel");
|
||||
}
|
||||
/**
|
||||
* Set the player's channel.
|
||||
* @param player
|
||||
* @param channel
|
||||
*/
|
||||
public void setPlayerChannel(Player player, String channel){
|
||||
plugin.data.set(player.getUniqueId() + ".channel", channel);
|
||||
plugin.saveFile();
|
||||
}
|
||||
/**
|
||||
* Set the default channel
|
||||
* @param channel
|
||||
*/
|
||||
public void setDefaultChannel(String channel){
|
||||
plugin.getConfig().set("Default_Config", channel);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
/**
|
||||
* Get a channel's json.
|
||||
* @param channel
|
||||
* @return Json array
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getChannelJson(String channel){
|
||||
return (ArrayList<String>) plugin.channel.get(channel + ".JSON");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a format's json.
|
||||
* @param number
|
||||
@ -86,15 +40,6 @@ public class UltraChatAPI{
|
||||
public ArrayList<String> getChatFormatJson(String number){
|
||||
return (ArrayList<String>) plugin.getConfig().get("Custom_Chat." + number + ".JSON");
|
||||
}
|
||||
/**
|
||||
* Set a channel's json.
|
||||
* @param json
|
||||
* @param channel
|
||||
*/
|
||||
public void setChannelJson(ArrayList<String> json, String channel){
|
||||
plugin.channel.set(channel + ".json", json);
|
||||
plugin.saveChannel();
|
||||
}
|
||||
/**
|
||||
* Set a format's json.
|
||||
* @param json
|
||||
@ -105,22 +50,6 @@ public class UltraChatAPI{
|
||||
plugin.getConfig().set("Custom_Chat." + number + ".JSON", json);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
/**
|
||||
* Check to see if channels are enabled.
|
||||
* @deprecated Use getMode()
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isChannelEnabled(){
|
||||
return plugin.getConfig().getBoolean("Channels");
|
||||
}
|
||||
/**
|
||||
* Check to see if json is enabled.
|
||||
* @deprecated Use getMode()
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isJsonEnabled(){
|
||||
return plugin.getConfig().getBoolean("JSON");
|
||||
}
|
||||
/**
|
||||
* Get the current chat mode.
|
||||
* @return chat mode
|
||||
@ -235,6 +164,7 @@ public class UltraChatAPI{
|
||||
* @param always_appear
|
||||
* @param format
|
||||
* @param json
|
||||
* @deprecated
|
||||
*/
|
||||
|
||||
public void createChannel(String channel, String prefix, String permission, boolean always_appear, String format, ArrayList<String> json){
|
||||
@ -247,6 +177,7 @@ public class UltraChatAPI{
|
||||
}
|
||||
/**
|
||||
* Remove a channel.
|
||||
* @deprecated
|
||||
* @param channel
|
||||
*/
|
||||
public void removeChannel(String channel){
|
||||
@ -254,13 +185,6 @@ public class UltraChatAPI{
|
||||
plugin.saveChannel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab the plugin.
|
||||
* @return plugin. Don't worry about the return
|
||||
*/
|
||||
public static UltraChat getPlugin(){
|
||||
return UltraChat.plugin;
|
||||
}
|
||||
/**
|
||||
* Get the current formatting type.
|
||||
* @return The value of the config.
|
||||
|
133
src/me/ryandw11/ultrachat/api/channels/ChannelBuilder.java
Normal file
133
src/me/ryandw11/ultrachat/api/channels/ChannelBuilder.java
Normal file
@ -0,0 +1,133 @@
|
||||
package me.ryandw11.ultrachat.api.channels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
|
||||
|
||||
/**
|
||||
* A Builder to make a channel.
|
||||
* @author Ryandw11
|
||||
* @since 2.3.3
|
||||
*/
|
||||
public class ChannelBuilder {
|
||||
|
||||
private String name;
|
||||
private String prefix;
|
||||
private String permission;
|
||||
private boolean alwaysAppear;
|
||||
private String format;
|
||||
private List<String> json;
|
||||
|
||||
/**
|
||||
* The Builder to create a channel.
|
||||
* @param name The name of the channel (usually lowercase)
|
||||
*/
|
||||
public ChannelBuilder(String name) {
|
||||
this.setName(name);
|
||||
setPrefix("[" + name + "]");
|
||||
setPermission("none");
|
||||
setAlwaysAppear(false);
|
||||
setJson(new ArrayList<String>());
|
||||
setFormat("%prefix% %player% %suffix%&7 >> ");
|
||||
}
|
||||
|
||||
protected String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the channel.
|
||||
* @param name The name. (Lowercase is standard)
|
||||
* @return The builder
|
||||
*/
|
||||
public ChannelBuilder setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the prefix of the channel
|
||||
* @param prefix The prefix (supports & codes)
|
||||
* @return The builder
|
||||
*/
|
||||
public ChannelBuilder setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the permission for the channel.
|
||||
* @param permission The permission
|
||||
* @return The builder.
|
||||
*/
|
||||
public ChannelBuilder setPermission(String permission) {
|
||||
this.permission = permission;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected boolean isAlwaysAppear() {
|
||||
return alwaysAppear;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the channel is always appear
|
||||
* @param alwaysAppear
|
||||
* @return The builder
|
||||
*/
|
||||
public ChannelBuilder setAlwaysAppear(boolean alwaysAppear) {
|
||||
this.alwaysAppear = alwaysAppear;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
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"));
|
||||
}
|
||||
return new ChatChannel(this);
|
||||
}
|
||||
|
||||
public List<String> getJson() {
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the json lore.
|
||||
* @param json List of lore.
|
||||
*/
|
||||
public ChannelBuilder setJson(List<String> json) {
|
||||
this.json = json;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public ChannelBuilder setFormat(String format) {
|
||||
this.format = format;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
108
src/me/ryandw11/ultrachat/api/channels/ChatChannel.java
Normal file
108
src/me/ryandw11/ultrachat/api/channels/ChatChannel.java
Normal file
@ -0,0 +1,108 @@
|
||||
package me.ryandw11.ultrachat.api.channels;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
|
||||
public class ChatChannel {
|
||||
|
||||
private String name;
|
||||
private String prefix;
|
||||
private String permission;
|
||||
private boolean alwaysAppear;
|
||||
private String format;
|
||||
private List<String> json;
|
||||
|
||||
/**
|
||||
* For internal use only. Always use the channel builder.
|
||||
* @param cb
|
||||
*/
|
||||
public ChatChannel(ChannelBuilder cb) {
|
||||
this.name = cb.getName();
|
||||
this.prefix = cb.getPrefix();
|
||||
this.permission = cb.getPermission();
|
||||
this.alwaysAppear = cb.isAlwaysAppear();
|
||||
this.json = cb.getJson();
|
||||
this.format = cb.getFormat();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto calls the update() method.
|
||||
* <p>Note: If this channel is the default channel then you will need to change the default channel name manually</p>
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
UltraChat.plugin.channel.set(this.name, null);
|
||||
this.name = name;
|
||||
update();
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
update();
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public void setPermission(String permission) {
|
||||
this.permission = permission;
|
||||
update();
|
||||
}
|
||||
|
||||
public boolean isAlwaysAppear() {
|
||||
return alwaysAppear;
|
||||
}
|
||||
|
||||
public void setAlwaysAppear(boolean alwaysAppear) {
|
||||
this.alwaysAppear = alwaysAppear;
|
||||
update();
|
||||
}
|
||||
|
||||
public List<String> getJson() {
|
||||
return 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.
|
||||
*/
|
||||
private void update() {
|
||||
UltraChat plugin = UltraChat.plugin;
|
||||
plugin.channel.set(this.getName() + ".prefix", this.getPrefix());
|
||||
plugin.channel.set(this.getName() + ".permission", this.getPrefix());
|
||||
plugin.channel.set(this.getName() + ".always_appear", this.isAlwaysAppear());
|
||||
plugin.channel.set(this.getName() + ".format", this.getFormat());
|
||||
plugin.channel.set(this.getName() + ".JSON", this.getJson());
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the channel
|
||||
*/
|
||||
public void delete() {
|
||||
UltraChat.plugin.channel.set(this.getName(), null);
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
update();
|
||||
}
|
||||
|
||||
}
|
78
src/me/ryandw11/ultrachat/api/events/ChannelChatEvent.java
Normal file
78
src/me/ryandw11/ultrachat/api/events/ChannelChatEvent.java
Normal file
@ -0,0 +1,78 @@
|
||||
package me.ryandw11.ultrachat.api.events;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import me.ryandw11.ultrachat.api.channels.ChatChannel;
|
||||
import me.ryandw11.ultrachat.api.managers.ChannelManager;
|
||||
/**
|
||||
* Event class -
|
||||
* Async Event
|
||||
* @author Ryandw11
|
||||
*
|
||||
*/
|
||||
public class ChannelChatEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player player;
|
||||
private String chat;
|
||||
private ChatChannel channel;
|
||||
private Set<Player> recipients;
|
||||
private boolean cancelled;
|
||||
|
||||
public ChannelChatEvent(Player p, String chat, Set<Player> recipients) {
|
||||
super(true);
|
||||
player = p;
|
||||
this.chat = chat;
|
||||
this.recipients = recipients;
|
||||
this.channel = new ChannelManager().getPlayerChannel(p);
|
||||
}
|
||||
/**
|
||||
* Grab the recipients.
|
||||
* @return The recipients.
|
||||
*/
|
||||
public Set<Player> getRecipients(){
|
||||
return recipients;
|
||||
}
|
||||
/**
|
||||
* Set the recipients.
|
||||
* @param recipents The set of recipients.
|
||||
*/
|
||||
public void setRecipients(Set<Player> recipients){
|
||||
this.recipients = recipients;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return chat;
|
||||
}
|
||||
|
||||
public ChatChannel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setMessage(String message){
|
||||
chat = message;
|
||||
}
|
||||
|
||||
public boolean isCancelled(){
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel){
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.ryandw11.ultrachat.api;
|
||||
package me.ryandw11.ultrachat.api.events;
|
||||
|
||||
|
||||
import org.bukkit.entity.Player;
|
@ -1,4 +1,4 @@
|
||||
package me.ryandw11.ultrachat.api;
|
||||
package me.ryandw11.ultrachat.api.events;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.ryandw11.ultrachat.api;
|
||||
package me.ryandw11.ultrachat.api.events;
|
||||
|
||||
import java.util.Set;
|
||||
|
137
src/me/ryandw11/ultrachat/api/managers/ChannelManager.java
Normal file
137
src/me/ryandw11/ultrachat/api/managers/ChannelManager.java
Normal file
@ -0,0 +1,137 @@
|
||||
package me.ryandw11.ultrachat.api.managers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.channels.ChannelBuilder;
|
||||
import me.ryandw11.ultrachat.api.channels.ChatChannel;
|
||||
|
||||
public class ChannelManager {
|
||||
private UltraChat plugin;
|
||||
public ChannelManager() {
|
||||
this.plugin = UltraChat.plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a channel via its name
|
||||
* @param name The name of the channel
|
||||
* @return The channel.
|
||||
*/
|
||||
public ChatChannel getChannelByName(String name) {
|
||||
ChannelBuilder cb = new ChannelBuilder(name);
|
||||
return cb.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab the player's current channel.
|
||||
* @param player
|
||||
* @return The player's current channel.
|
||||
*/
|
||||
public ChatChannel getPlayerChannel(Player player){
|
||||
ChannelBuilder cb = new ChannelBuilder(plugin.data.getString(player.getUniqueId() + ".channel"));
|
||||
return cb.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab an offline player's current channel.
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public ChatChannel getPlayerChannel(UUID player) {
|
||||
ChannelBuilder cb = new ChannelBuilder(plugin.data.getString(player + ".channel"));
|
||||
return cb.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the servers default channel.
|
||||
* @return Default Channel
|
||||
*/
|
||||
public ChatChannel getDefaultChannel(){
|
||||
ChannelBuilder cb = new ChannelBuilder(plugin.getConfig().getString("Default_Channel"));
|
||||
return cb.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the player's channel.
|
||||
* @param player
|
||||
* @param channel
|
||||
*/
|
||||
public void setPlayerChannel(Player player, ChatChannel channel){
|
||||
plugin.data.set(player.getUniqueId() + ".channel", channel.getName());
|
||||
plugin.saveFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the player's channel.
|
||||
* @param player
|
||||
* @param channel
|
||||
*/
|
||||
public void setPlayerChannel(UUID player, ChatChannel channel) {
|
||||
plugin.data.set(player + ".channel", channel.getName());
|
||||
plugin.saveFile();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the default channel
|
||||
* @param channel
|
||||
*/
|
||||
public void setDefaultChannel(ChatChannel channel){
|
||||
plugin.getConfig().set("Default_Config", channel.getName());
|
||||
plugin.saveConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* If a given channel exists (In this instance if it is save in the files)
|
||||
* @param channel
|
||||
*/
|
||||
public boolean channelExists(ChatChannel channel) {
|
||||
return plugin.channel.contains(channel.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* If a given channel exists based upon the name.
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public boolean channelExists(String name) {
|
||||
return plugin.channel.contains(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all online players in a given channel.
|
||||
* @param channel
|
||||
* @return
|
||||
*/
|
||||
public List<Player> getPlayersInChannel(ChatChannel channel){
|
||||
List<Player> output = new ArrayList<>();
|
||||
for(Player p : Bukkit.getOnlinePlayers()) {
|
||||
if(this.getPlayerChannel(p).getName().equals(channel.getName())) {
|
||||
output.add(p);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all players in a channel online or offline.
|
||||
* @param channel
|
||||
* @return
|
||||
*/
|
||||
public List<UUID> getAllPlayersInChannel(ChatChannel channel){
|
||||
List<UUID> output = new ArrayList<>();
|
||||
for(String s : plugin.data.getConfigurationSection("").getKeys(false)) {
|
||||
UUID ud = UUID.fromString(s);
|
||||
if(this.getPlayerChannel(ud).getName().equals(channel.getName())) {
|
||||
output.add(ud);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
@ -258,7 +258,7 @@ public class ChatCommand implements CommandExecutor {
|
||||
}
|
||||
else if(args.length == 1 && args[0].equalsIgnoreCase("hooks")){
|
||||
if(p.hasPermission("ultrachat.hooks")){
|
||||
UltraChatAPI uapi = new UltraChatAPI(plugin);
|
||||
UltraChatAPI uapi = new UltraChatAPI();
|
||||
p.sendMessage(ChatColor.BLUE + "Ultra Chat Hooks:");
|
||||
if(uapi.getActiveHooks() == null){
|
||||
p.sendMessage(ChatColor.GREEN + "No hooks are currently active!");
|
||||
|
@ -10,10 +10,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.GlobalChatEvent;
|
||||
import me.ryandw11.ultrachat.api.JSON;
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.UltraChatAPI;
|
||||
import me.ryandw11.ultrachat.api.events.GlobalChatEvent;
|
||||
import me.ryandw11.ultrachat.formatting.PlayerFormatting;
|
||||
|
||||
public class Global implements CommandExecutor {
|
||||
@ -34,7 +34,7 @@ public class Global implements CommandExecutor {
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
return true;
|
||||
}
|
||||
UltraChatAPI uapi = new UltraChatAPI(plugin);
|
||||
UltraChatAPI uapi = new UltraChatAPI();
|
||||
PlayerFormatting pf = new PlayerFormatting(p);
|
||||
if(!uapi.isRangeJson()){
|
||||
GlobalChatEvent e = new GlobalChatEvent(p, this.getMessage(args, p));
|
||||
|
@ -14,7 +14,7 @@ import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.JSON;
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.UltraChatAPI;
|
||||
import me.ryandw11.ultrachat.api.WorldChatEvent;
|
||||
import me.ryandw11.ultrachat.api.events.WorldChatEvent;
|
||||
import me.ryandw11.ultrachat.formatting.PlayerFormatting;
|
||||
|
||||
public class World implements CommandExecutor {
|
||||
@ -35,7 +35,7 @@ public class World implements CommandExecutor {
|
||||
p.sendMessage(Lang.NO_PERM.toString());
|
||||
return true;
|
||||
}
|
||||
UltraChatAPI uapi = new UltraChatAPI(plugin);
|
||||
UltraChatAPI uapi = new UltraChatAPI();
|
||||
PlayerFormatting pf = new PlayerFormatting(p);
|
||||
if(!uapi.isRangeJson()){
|
||||
WorldChatEvent e = new WorldChatEvent(p, this.getMessage(args, p), new HashSet<Player>( p.getWorld().getPlayers()));
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.JSON;
|
||||
import me.ryandw11.ultrachat.api.JsonChatEvent;
|
||||
import me.ryandw11.ultrachat.api.events.JsonChatEvent;
|
||||
/**
|
||||
* If JSON is enabled.
|
||||
* @author Ryandw11
|
||||
|
@ -14,6 +14,11 @@ import net.md_5.bungee.api.ChatColor;
|
||||
*/
|
||||
public class PlayerFormatting {
|
||||
private UltraChat plugin;
|
||||
|
||||
/**
|
||||
* Get the formatting for a player.
|
||||
* @param p
|
||||
*/
|
||||
public PlayerFormatting(Player p){
|
||||
plugin = UltraChat.plugin;
|
||||
|
||||
@ -27,6 +32,25 @@ public class PlayerFormatting {
|
||||
local = PlaceholderAPI.setPlaceholders(p, ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Local.format")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formatting for an offline player.
|
||||
* <p>Note: Placeholders will not work in this mode.</p>
|
||||
* @param op The offline player
|
||||
* @param worldname The name of the world to get the preffix and suffix from.
|
||||
* @since 2.3.3
|
||||
*/
|
||||
public PlayerFormatting(OfflinePlayer op, String worldname) {
|
||||
plugin = UltraChat.plugin;
|
||||
color = ChatColor.translateAlternateColorCodes('&', plugin.data.getString(op.getUniqueId() + ".color"));
|
||||
prefix = ChatColor.translateAlternateColorCodes('&', plugin.chat.getPlayerPrefix(worldname, op));
|
||||
suffix = ChatColor.translateAlternateColorCodes('&', plugin.chat.getPlayerSuffix(worldname, op));
|
||||
formatOp = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Custom_Chat.Op_Chat.Format"));
|
||||
defaults = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Custom_Chat.Default_Chat.Format"));
|
||||
global = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Global.format"));
|
||||
world = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("World.format"));
|
||||
local = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Local.format"));
|
||||
}
|
||||
|
||||
private String prefix;
|
||||
private String suffix;
|
||||
public String color;
|
||||
|
@ -14,8 +14,8 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.JSON;
|
||||
import me.ryandw11.ultrachat.api.JsonChatEvent;
|
||||
import me.ryandw11.ultrachat.api.UltraChatAPI;
|
||||
import me.ryandw11.ultrachat.api.events.JsonChatEvent;
|
||||
|
||||
public class Range implements Listener{
|
||||
private UltraChat plugin;
|
||||
@ -28,7 +28,7 @@ public class Range implements Listener{
|
||||
public void onChat(AsyncPlayerChatEvent e){
|
||||
Player p = e.getPlayer();
|
||||
PlayerFormatting pf = new PlayerFormatting(p);
|
||||
UltraChatAPI uapi = new UltraChatAPI(plugin);
|
||||
UltraChatAPI uapi = new UltraChatAPI();
|
||||
if(p.hasPermission("ultrachat.chat.color")){
|
||||
e.setMessage(ChatColor.translateAlternateColorCodes('&', e.getMessage()));
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import me.ryandw11.ultrachat.api.JsonChatEvent;
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.events.JsonChatEvent;
|
||||
|
||||
public class ConsoleLogChat implements Listener{
|
||||
|
||||
|
@ -3,8 +3,8 @@ package me.ryandw11.ultrachat.listner;
|
||||
import java.util.List;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.JsonChatEvent;
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.events.JsonChatEvent;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -8,8 +8,8 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.JsonChatEvent;
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.events.JsonChatEvent;
|
||||
/**
|
||||
*
|
||||
* @author Ryandw11
|
||||
|
@ -7,8 +7,8 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.JsonChatEvent;
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.events.JsonChatEvent;
|
||||
|
||||
/**
|
||||
* For 1.12 and below servers.
|
||||
|
@ -6,8 +6,8 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import me.ryandw11.ultrachat.UltraChat;
|
||||
import me.ryandw11.ultrachat.api.JsonChatEvent;
|
||||
import me.ryandw11.ultrachat.api.Lang;
|
||||
import me.ryandw11.ultrachat.api.events.JsonChatEvent;
|
||||
/**
|
||||
* Prevent players from chatting when the chat is stopped.
|
||||
* @author Ryandw11
|
||||
|
@ -6,9 +6,9 @@ import org.bukkit.event.Listener;
|
||||
|
||||
import me.leoko.advancedban.manager.PunishmentManager;
|
||||
import me.leoko.advancedban.manager.UUIDManager;
|
||||
import me.ryandw11.ultrachat.api.GlobalChatEvent;
|
||||
import me.ryandw11.ultrachat.api.JsonChatEvent;
|
||||
import me.ryandw11.ultrachat.api.WorldChatEvent;
|
||||
import me.ryandw11.ultrachat.api.events.GlobalChatEvent;
|
||||
import me.ryandw11.ultrachat.api.events.JsonChatEvent;
|
||||
import me.ryandw11.ultrachat.api.events.WorldChatEvent;
|
||||
|
||||
public class AdvancedBanMute implements Listener{
|
||||
|
||||
|
@ -6,9 +6,10 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import me.ryandw11.ultrachat.api.GlobalChatEvent;
|
||||
import me.ryandw11.ultrachat.api.JsonChatEvent;
|
||||
import me.ryandw11.ultrachat.api.WorldChatEvent;
|
||||
|
||||
import me.ryandw11.ultrachat.api.events.GlobalChatEvent;
|
||||
import me.ryandw11.ultrachat.api.events.JsonChatEvent;
|
||||
import me.ryandw11.ultrachat.api.events.WorldChatEvent;
|
||||
|
||||
public class EssentialsMute implements Listener{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user