mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 02:19:05 +00:00
Merge branch 'master' into mute-rework
Conflicts: MineverseChat/mineverse/Aust1n46/chat/MineverseChat.java
This commit is contained in:
commit
93fcf38fbb
26
.classpath
26
.classpath
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="MineverseChat"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/Factions.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/Heroes.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/MassiveCore.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/pircbotx-2.0.1.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/PlaceholderAPI-2.8.2.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/Towny.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/Vault.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/BungeeCord.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/plugins_1.13/ProtocolLib.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.14.1.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.7.10-SNAPSHOT-b1657.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.8.8-R0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.9.4-R0.1-SNAPSHOT-latest.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.10-R0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.11.2-R0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.12.2.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.13.2.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.14.4.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.15.jar"/>
|
||||
<classpathentry kind="lib" path="lib"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
||||
/bin/
|
||||
/bin/
|
||||
/.classpath
|
||||
|
1
MineverseChat/.gitignore
vendored
Normal file
1
MineverseChat/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/TODO.txt
|
@ -1,4 +1,4 @@
|
||||
Version: 2.18.2
|
||||
Version: 2.20.0
|
||||
BlockCommandPlayer: '&cYou have been blocked from entering command {command}.'
|
||||
BlockCommandSender: '&cBlocked player &6{player} &cfrom entering command {command}.'
|
||||
BlockedCommand: '&cYou are blocked from entering this command: {command}'
|
||||
@ -14,6 +14,7 @@ ChannelListHeader: '&6Channel List : Alias'
|
||||
ChannelListWithPermissions: '{channel_color}{channel_name} : {channel_alias} - Permission Required'
|
||||
ChannelNoPermission: '&cYou do not have permission for this channel.'
|
||||
ChannelNoPermissionView: '&cYou do not have permission to look at this channel.'
|
||||
ChannelNoSpeakPermissions: '&cYou do not have permission to speak in this channel.'
|
||||
ChannelPlayerListHeader: '&6Players in Channel: {channel_color}{channel_name}'
|
||||
ChannelMuted: '&cYou are muted in this channel: {channel_color}{channel_name}&c{time}'
|
||||
CommandInvalidArguments: '&cInvalid command: {command} {args}'
|
||||
|
@ -1,4 +1,4 @@
|
||||
name: VentureChat
|
||||
main: mineverse.Aust1n46.chat.bungee.MineverseChatBungee
|
||||
version: 2.18.4
|
||||
version: 2.20.0
|
||||
author: Aust1n46
|
@ -95,24 +95,20 @@ saveinterval: 30
|
||||
# The time in seconds between each check to remove timed mutes
|
||||
unmuteinterval: 60
|
||||
|
||||
# The color of the private messages
|
||||
tellcolor: white
|
||||
|
||||
# Enables or disabled BungeeCord messaging
|
||||
bungeecordmessaging: true
|
||||
bungeecordmessaging: false
|
||||
|
||||
# This will allow vanished players to be exempt from being sent private messages, and will act as if they aren't online
|
||||
vanishsupport: true
|
||||
|
||||
# {playerto} : player receivings name
|
||||
# {playerfrom} : player sendings name
|
||||
# use Default for the basic formatting
|
||||
tellformatto: Default
|
||||
tellformatfrom: Default
|
||||
tellformatspy: Default
|
||||
replyformatto: Default
|
||||
replyformatfrom: Default
|
||||
replyformatspy: Default
|
||||
tellformatto: 'You message {playerto}:&7'
|
||||
tellformatfrom: '{playerfrom} messages you:&7'
|
||||
tellformatspy: '{playerfrom} messages {playerto}:&7'
|
||||
replyformatto: 'You reply to {playerto}:&7'
|
||||
replyformatfrom: '{playerfrom} replies to you:&7'
|
||||
replyformatspy: '{playerfrom} replied to {playerto}:&7'
|
||||
|
||||
# {host} : party hosts name
|
||||
# {player} : player name
|
||||
@ -297,7 +293,69 @@ enable_factions_channel: false
|
||||
# Use '' or "" around format, example: '[&2global&f] {vault_prefix} {player_displayname}&2:'
|
||||
# You must have prefixes and suffixes set in a Vault compatible permissions plugin to avoid errors
|
||||
# Use "" as the prefix or suffix to have none
|
||||
|
||||
# Set chatcolor to 'None' to have a group based chat color! Don't forget to put a suffix or other placeholder at the end of the format!
|
||||
|
||||
# Important!!!
|
||||
# Important!!!
|
||||
# If you delete a channel, restart the server! Do not use /chatreload!!!
|
||||
channels:
|
||||
GroupChatColorExample:
|
||||
color: '#706C1E'
|
||||
chatcolor: 'None'
|
||||
mutable: true
|
||||
filter: true
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: ge
|
||||
permissions: None
|
||||
speak_permissions: None
|
||||
format: '&f[#706C1EGroupColorChat&f] {vault_prefix} {player_displayname}#706C1E:{vault_suffix}'
|
||||
HexExample:
|
||||
color: '#ff0000'
|
||||
chatcolor: '#ff0000'
|
||||
mutable: true
|
||||
filter: true
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: he
|
||||
permissions: None
|
||||
speak_permissions: None
|
||||
format: '&f[#ff0000Hex&f] {vault_prefix} {player_displayname}#ff0000:'
|
||||
BungeeExample:
|
||||
color: gold
|
||||
chatcolor: gold
|
||||
mutable: true
|
||||
filter: true
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
cooldown: 3
|
||||
bungeecord: true
|
||||
alias: be
|
||||
permissions: None
|
||||
speak_permissions: None
|
||||
format: '&f[&6Network&f] {vault_prefix} {player_displayname}&6:'
|
||||
AnnouncementExample:
|
||||
color: red
|
||||
chatcolor: red
|
||||
mutable: false
|
||||
filter: false
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
cooldown: 0
|
||||
bungeecord: true
|
||||
alias: announce
|
||||
permissions: None
|
||||
speak_permissions: announcement
|
||||
format: '&f[&aServer Announcement&f] {vault_prefix} {player_displayname}&c:'
|
||||
Global:
|
||||
color: dark_green
|
||||
chatcolor: dark_green
|
||||
@ -310,6 +368,7 @@ channels:
|
||||
bungeecord: false
|
||||
alias: g
|
||||
permissions: None
|
||||
speak_permissions: None
|
||||
format: '&f[&2Global&f] {vault_prefix} {player_displayname}&2:'
|
||||
Staff:
|
||||
color: green
|
||||
@ -323,20 +382,8 @@ channels:
|
||||
bungeecord: false
|
||||
alias: st
|
||||
permissions: staffchannel
|
||||
speak_permissions: None
|
||||
format: '&f[&aStaff&f] {vault_prefix} {player_displayname}&a:'
|
||||
Admin:
|
||||
color: red
|
||||
chatcolor: red
|
||||
mutable: false
|
||||
filter: false
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: a
|
||||
permissions: adminchannel
|
||||
format: '&f[&cAdmin&f] {vault_prefix} {player_displayname}&c:'
|
||||
Donator:
|
||||
color: light_purple
|
||||
chatcolor: light_purple
|
||||
@ -349,6 +396,7 @@ channels:
|
||||
bungeecord: false
|
||||
alias: d
|
||||
permissions: donatorchannel
|
||||
speak_permissions: None
|
||||
format: '&f[&dDonator&f] {vault_prefix} {player_displayname}&d:'
|
||||
Help:
|
||||
color: aqua
|
||||
@ -362,6 +410,7 @@ channels:
|
||||
bungeecord: false
|
||||
alias: h
|
||||
permissions: None
|
||||
speak_permissions: None
|
||||
format: '&f[&bHelp&f] {vault_prefix} {player_displayname}&b:'
|
||||
Trade:
|
||||
color: dark_aqua
|
||||
@ -375,6 +424,7 @@ channels:
|
||||
bungeecord: false
|
||||
alias: t
|
||||
permissions: None
|
||||
speak_permissions: None
|
||||
format: '&f[&3Trade&f] {vault_prefix} {player_displayname}&3:'
|
||||
Local:
|
||||
color: yellow
|
||||
@ -388,17 +438,5 @@ channels:
|
||||
bungeecord: false
|
||||
alias: l
|
||||
permissions: None
|
||||
format: '&f[&eLocal&f] {vault_prefix} {player_displayname}&e:'
|
||||
Network:
|
||||
color: gold
|
||||
chatcolor: gold
|
||||
mutable: true
|
||||
filter: true
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
cooldown: 60
|
||||
bungeecord: true
|
||||
alias: n
|
||||
permissions: None
|
||||
format: '&f[&6Network&f] {vault_prefix} {player_displayname}&6:'
|
||||
speak_permissions: None
|
||||
format: '&f[&eLocal&f] {vault_prefix} {player_displayname}&e:'
|
@ -46,6 +46,8 @@ nicknames:
|
||||
|
||||
nickname-in-tablist: true
|
||||
|
||||
# {player} : player sending command
|
||||
# {command} : command typed
|
||||
commandspy:
|
||||
format: '&6{player}: {command}'
|
||||
worldeditcommands: true
|
||||
@ -93,24 +95,20 @@ saveinterval: 30
|
||||
# The time in seconds between each check to remove timed mutes
|
||||
unmuteinterval: 60
|
||||
|
||||
# The color of the private messages
|
||||
tellcolor: white
|
||||
|
||||
# Enables or disabled BungeeCord messaging
|
||||
bungeecordmessaging: true
|
||||
bungeecordmessaging: false
|
||||
|
||||
# This will allow vanished players to be exempt from being sent private messages, and will act as if they aren't online
|
||||
vanishsupport: true
|
||||
|
||||
# {playerto} : player receivings name
|
||||
# {playerfrom} : player sendings name
|
||||
# use Default for the basic formatting
|
||||
tellformatto: Default
|
||||
tellformatfrom: Default
|
||||
tellformatspy: Default
|
||||
replyformatto: Default
|
||||
replyformatfrom: Default
|
||||
replyformatspy: Default
|
||||
tellformatto: 'You message {playerto}:&7'
|
||||
tellformatfrom: '{playerfrom} messages you:&7'
|
||||
tellformatspy: '{playerfrom} messages {playerto}:&7'
|
||||
replyformatto: 'You reply to {playerto}:&7'
|
||||
replyformatfrom: '{playerfrom} replies to you:&7'
|
||||
replyformatspy: '{playerfrom} replied to {playerto}:&7'
|
||||
|
||||
# {host} : party hosts name
|
||||
# {player} : player name
|
||||
@ -295,7 +293,69 @@ enable_factions_channel: false
|
||||
# Use '' or "" around format, example: '[&2global&f] {vault_prefix} {player_displayname}&2:'
|
||||
# You must have prefixes and suffixes set in a Vault compatible permissions plugin to avoid errors
|
||||
# Use "" as the prefix or suffix to have none
|
||||
|
||||
# Set chatcolor to 'None' to have a group based chat color! Don't forget to put a suffix or other placeholder at the end of the format!
|
||||
|
||||
# Important!!!
|
||||
# Important!!!
|
||||
# If you delete a channel, restart the server! Do not use /chatreload!!!
|
||||
channels:
|
||||
GroupChatColorExample:
|
||||
color: '#706C1E'
|
||||
chatcolor: 'None'
|
||||
mutable: true
|
||||
filter: true
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: ge
|
||||
permissions: None
|
||||
speak_permissions: None
|
||||
format: '&f[#706C1EGroupColorChat&f] {vault_prefix} {player_displayname}#706C1E:{vault_suffix}'
|
||||
HexExample:
|
||||
color: '#ff0000'
|
||||
chatcolor: '#ff0000'
|
||||
mutable: true
|
||||
filter: true
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: he
|
||||
permissions: None
|
||||
speak_permissions: None
|
||||
format: '&f[#ff0000Hex&f] {vault_prefix} {player_displayname}#ff0000:'
|
||||
BungeeExample:
|
||||
color: gold
|
||||
chatcolor: gold
|
||||
mutable: true
|
||||
filter: true
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
cooldown: 3
|
||||
bungeecord: true
|
||||
alias: be
|
||||
permissions: None
|
||||
speak_permissions: None
|
||||
format: '&f[&6Network&f] {vault_prefix} {player_displayname}&6:'
|
||||
AnnouncementExample:
|
||||
color: red
|
||||
chatcolor: red
|
||||
mutable: false
|
||||
filter: false
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
cooldown: 0
|
||||
bungeecord: true
|
||||
alias: announce
|
||||
permissions: None
|
||||
speak_permissions: announcement
|
||||
format: '&f[&aServer Announcement&f] {vault_prefix} {player_displayname}&c:'
|
||||
Global:
|
||||
color: dark_green
|
||||
chatcolor: dark_green
|
||||
@ -308,6 +368,7 @@ channels:
|
||||
bungeecord: false
|
||||
alias: g
|
||||
permissions: None
|
||||
speak_permissions: None
|
||||
format: '&f[&2Global&f] {vault_prefix} {player_displayname}&2:'
|
||||
Staff:
|
||||
color: green
|
||||
@ -321,20 +382,8 @@ channels:
|
||||
bungeecord: false
|
||||
alias: st
|
||||
permissions: staffchannel
|
||||
speak_permissions: None
|
||||
format: '&f[&aStaff&f] {vault_prefix} {player_displayname}&a:'
|
||||
Admin:
|
||||
color: red
|
||||
chatcolor: red
|
||||
mutable: false
|
||||
filter: false
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: a
|
||||
permissions: adminchannel
|
||||
format: '&f[&cAdmin&f] {vault_prefix} {player_displayname}&c:'
|
||||
Donator:
|
||||
color: light_purple
|
||||
chatcolor: light_purple
|
||||
@ -347,6 +396,7 @@ channels:
|
||||
bungeecord: false
|
||||
alias: d
|
||||
permissions: donatorchannel
|
||||
speak_permissions: None
|
||||
format: '&f[&dDonator&f] {vault_prefix} {player_displayname}&d:'
|
||||
Help:
|
||||
color: aqua
|
||||
@ -360,6 +410,7 @@ channels:
|
||||
bungeecord: false
|
||||
alias: h
|
||||
permissions: None
|
||||
speak_permissions: None
|
||||
format: '&f[&bHelp&f] {vault_prefix} {player_displayname}&b:'
|
||||
Trade:
|
||||
color: dark_aqua
|
||||
@ -373,6 +424,7 @@ channels:
|
||||
bungeecord: false
|
||||
alias: t
|
||||
permissions: None
|
||||
speak_permissions: None
|
||||
format: '&f[&3Trade&f] {vault_prefix} {player_displayname}&3:'
|
||||
Local:
|
||||
color: yellow
|
||||
@ -386,17 +438,5 @@ channels:
|
||||
bungeecord: false
|
||||
alias: l
|
||||
permissions: None
|
||||
format: '&f[&eLocal&f] {vault_prefix} {player_displayname}&e:'
|
||||
Network:
|
||||
color: gold
|
||||
chatcolor: gold
|
||||
mutable: true
|
||||
filter: true
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
cooldown: 60
|
||||
bungeecord: true
|
||||
alias: n
|
||||
permissions: None
|
||||
format: '&f[&6Network&f] {vault_prefix} {player_displayname}&6:'
|
||||
speak_permissions: None
|
||||
format: '&f[&eLocal&f] {vault_prefix} {player_displayname}&e:'
|
@ -111,8 +111,6 @@ import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
|
||||
public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
||||
// Listeners --------------------------------
|
||||
private ChatListener chatListener;
|
||||
@ -319,7 +317,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
||||
commands.put("venturechat", new Venturechat("venturechat"));
|
||||
commands.put("mute", new Mute("mute"));
|
||||
commands.put("muteall", new Muteall("muteall"));
|
||||
commands.put("nick", new Nick("nick"));
|
||||
commands.put("setnickname", new Nick("setnickname"));
|
||||
commands.put("notifications", new Notifications("notifications"));
|
||||
commands.put("party", new Party("party"));
|
||||
commands.put("rangedspy", new RangedSpy("rangedspy"));
|
||||
@ -406,13 +404,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
||||
if(pluginManager.isPluginEnabled("PlaceholderAPI")) {
|
||||
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Enabling PlaceholderAPI Hook"));
|
||||
}
|
||||
boolean hooked = PlaceholderAPI.registerPlaceholderHook("venturechat", new VentureChatPlaceholders());
|
||||
if(hooked) {
|
||||
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Added placeholders to PlaceholderAPI!"));
|
||||
}
|
||||
else {
|
||||
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - &cPlaceholders were not added to PlaceholderAPI!"));
|
||||
}
|
||||
new VentureChatPlaceholders().register();
|
||||
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Loading player data"));
|
||||
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
|
||||
scheduler.runTaskTimerAsynchronously(this, new Runnable() {
|
||||
@ -437,7 +429,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
||||
// System.out.println(time + " " + timemark);
|
||||
if(time > timemark) {
|
||||
p.removeMute(channel.getName());
|
||||
if(p.isOnline()) p.getPlayer().sendMessage(ChatColor.RED + "You have just been unmuted in: " + ChatColor.valueOf(channel.getColor().toUpperCase()) + channel.getName());
|
||||
if(p.isOnline()) p.getPlayer().sendMessage(ChatColor.RED + "You have just been unmuted in: " + channel.getColor() + channel.getName());
|
||||
else p.setModified(true);
|
||||
}
|
||||
}
|
||||
@ -445,8 +437,8 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
||||
if(getConfig().getString("loglevel", "info").equals("debug")) {
|
||||
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Updating Player Mutes"));
|
||||
}
|
||||
}
|
||||
}, 0L, 1200L); //one minute interval
|
||||
}
|
||||
}, 0L, 1200L); //one minute interval
|
||||
this.firstRun = false;
|
||||
}
|
||||
|
||||
@ -822,7 +814,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
||||
playerList = playerList.substring(0, playerList.length() - 2);
|
||||
}
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_PLAYER_LIST_HEADER.toString()
|
||||
.replace("{channel_color}", (ChatColor.valueOf(chatchannel.getColor().toUpperCase())).toString())
|
||||
.replace("{channel_color}", chatchannel.getColor().toString())
|
||||
.replace("{channel_name}", chatchannel.getName()));
|
||||
mcp.getPlayer().sendMessage(Format.FormatStringAll(playerList));
|
||||
}
|
||||
|
@ -3,12 +3,11 @@ package mineverse.Aust1n46.chat;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.PlaceholderHook;
|
||||
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||
|
||||
public class VentureChatPlaceholders extends PlaceholderHook {
|
||||
public class VentureChatPlaceholders extends PlaceholderExpansion {
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player p, String identifier) {
|
||||
if(p == null) {
|
||||
@ -67,4 +66,29 @@ public class VentureChatPlaceholders extends PlaceholderHook {
|
||||
if(color.equalsIgnoreCase("white")) return "f";
|
||||
return "f";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRegister(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
return "Aust1n46";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "venturechat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return MineverseChat.getInstance().getDescription().getVersion();
|
||||
}
|
||||
}
|
@ -477,8 +477,9 @@ public class MineverseChatPlayer {
|
||||
}
|
||||
|
||||
public void setJsonFormat() {
|
||||
this.jsonFormat = "Default";
|
||||
for(JsonFormat j : MineverseChat.jfInfo.getJsonFormats()) {
|
||||
if(this.getPlayer().hasPermission("venturechat.json." + j.getName())) {
|
||||
if(this.getPlayer().isPermissionSet("venturechat.json." + j.getName())) {
|
||||
if(MineverseChat.jfInfo.getJsonFormat(this.getJsonFormat()).getPriority() > j.getPriority()) {
|
||||
this.jsonFormat = j.getName();
|
||||
}
|
||||
|
@ -3,242 +3,388 @@ package mineverse.Aust1n46.chat.channel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import mineverse.Aust1n46.chat.MineverseChat;
|
||||
import mineverse.Aust1n46.chat.utilities.Format;
|
||||
|
||||
//This class is used to create ChatChannel objects, which store all the information for a channel. This
|
||||
//information is read in from the config file when the server starts up.
|
||||
/**
|
||||
* Chat channel object pojo. Class also contains static initialization methods
|
||||
* for reading chat channels from the config file.
|
||||
*
|
||||
* @author Aust1n46
|
||||
*/
|
||||
public class ChatChannel {
|
||||
private String name;
|
||||
private String permission;
|
||||
private Boolean mutable;
|
||||
private String color;
|
||||
private String chatcolor;
|
||||
private Boolean defaultChannel;
|
||||
private Boolean autojoin;
|
||||
private String alias;
|
||||
private Double distance;
|
||||
private Boolean filter;
|
||||
private Boolean bungee;
|
||||
private String format;
|
||||
private int cooldown;
|
||||
private boolean irc;
|
||||
|
||||
private static final String PERMISSION_PREFIX = "venturechat.";
|
||||
private static final String NO_PERMISSIONS = "venturechat.none";
|
||||
|
||||
private static MineverseChat plugin = MineverseChat.getInstance();
|
||||
private static ChatChannel defaultChatChannel;
|
||||
private static ChatChannel[] channels;
|
||||
private static String defaultColor;
|
||||
|
||||
|
||||
private String name;
|
||||
private String permission;
|
||||
private String speakPermission;
|
||||
private boolean mutable;
|
||||
private String color;
|
||||
private String chatColor;
|
||||
private boolean defaultChannel;
|
||||
private boolean autojoin;
|
||||
private String alias;
|
||||
private double distance;
|
||||
private boolean filter;
|
||||
private boolean bungee;
|
||||
private String format;
|
||||
private int cooldown;
|
||||
|
||||
/**
|
||||
* Read chat channels from config file and initialize channel array.
|
||||
*/
|
||||
public static void initialize() {
|
||||
String _color = "";
|
||||
String _chatcolor = "";
|
||||
String _name = "";
|
||||
String _permission = "";
|
||||
Boolean _mutable = false;
|
||||
Boolean _filter = false;
|
||||
Boolean _defaultchannel = false;
|
||||
String _alias = "";
|
||||
Double _distance = (double) 0;
|
||||
Boolean _autojoin = false;
|
||||
Boolean _bungee = false;
|
||||
String _format = "";
|
||||
int _cooldown = 0;
|
||||
ConfigurationSection cs = plugin.getConfig().getConfigurationSection("channels");
|
||||
int len = (cs.getKeys(false)).size();
|
||||
channels = new ChatChannel[len];
|
||||
int x = 0;
|
||||
for(String key : cs.getKeys(false)) {
|
||||
_color = (String) cs.getString(key + ".color", "white");
|
||||
_chatcolor = (String) cs.getString(key + ".chatcolor", "white");
|
||||
if(!(Format.isValidColor(_color))) {
|
||||
plugin.getServer().getLogger().info("[" + plugin.getName() + "] " + _color + " is not valid. Changing to white.");
|
||||
_color = "white";
|
||||
}
|
||||
if(!(Format.isValidColor(_chatcolor)) && !_chatcolor.equalsIgnoreCase("None")) {
|
||||
plugin.getServer().getLogger().info("[" + plugin.getName() + "] " + _chatcolor + " is not valid. Changing to white.");
|
||||
_chatcolor = "white";
|
||||
}
|
||||
_name = key;
|
||||
_permission = (String) cs.getString(key + ".permissions", "None");
|
||||
_mutable = (Boolean) cs.getBoolean(key + ".mutable", false);
|
||||
_filter = (Boolean) cs.getBoolean(key + ".filter", true);
|
||||
_bungee = (Boolean) cs.getBoolean(key + ".bungeecord", false);
|
||||
_format = cs.getString(key + ".format", "Default");
|
||||
_defaultchannel = (Boolean) cs.getBoolean(key + ".default", false);
|
||||
_alias = (String) cs.getString(key + ".alias", "None");
|
||||
_distance = (Double) cs.getDouble(key + ".distance", (double) 0);
|
||||
_cooldown = (int) cs.getInt(key + ".cooldown", 0);
|
||||
_autojoin = (Boolean) cs.getBoolean(key + ".autojoin", false);
|
||||
ChatChannel c = new ChatChannel(_name, _color, _chatcolor, _permission, _mutable, _filter, _defaultchannel, _alias, _distance, _autojoin, _bungee, _cooldown, _format);
|
||||
channels[x++] = c;
|
||||
if(_defaultchannel) {
|
||||
defaultChatChannel = c;
|
||||
defaultColor = _color;
|
||||
int counter = 0;
|
||||
for (String key : cs.getKeys(false)) {
|
||||
String color = cs.getString(key + ".color", "white");
|
||||
String chatColor = cs.getString(key + ".chatcolor", "white");
|
||||
String name = key;
|
||||
String permission = cs.getString(key + ".permissions", "None");
|
||||
String speakPermission = cs.getString(key + ".speak_permissions", "None");
|
||||
boolean mutable = cs.getBoolean(key + ".mutable", false);
|
||||
boolean filter = cs.getBoolean(key + ".filter", true);
|
||||
boolean bungee = cs.getBoolean(key + ".bungeecord", false);
|
||||
String format = cs.getString(key + ".format", "Default");
|
||||
boolean defaultChannel = cs.getBoolean(key + ".default", false);
|
||||
String alias = cs.getString(key + ".alias", "None");
|
||||
double distance = cs.getDouble(key + ".distance", (double) 0);
|
||||
int cooldown = cs.getInt(key + ".cooldown", 0);
|
||||
boolean autojoin = cs.getBoolean(key + ".autojoin", false);
|
||||
ChatChannel chatChannel = new ChatChannel(name, color, chatColor, permission, speakPermission, mutable,
|
||||
filter, defaultChannel, alias, distance, autojoin, bungee, cooldown, format);
|
||||
channels[counter++] = chatChannel;
|
||||
if (defaultChannel) {
|
||||
defaultChatChannel = chatChannel;
|
||||
defaultColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get array of chat channels.
|
||||
*
|
||||
* @return {@link ChatChannel}[]
|
||||
*/
|
||||
public static ChatChannel[] getChannels() {
|
||||
return channels;
|
||||
}
|
||||
|
||||
public static ChatChannel getChannel(String ChannelName) {
|
||||
for(ChatChannel c : channels) {
|
||||
if(c.getName().equalsIgnoreCase(ChannelName) || c.getAlias().equalsIgnoreCase(ChannelName)) {
|
||||
|
||||
/**
|
||||
* Get a chat channel by name.
|
||||
*
|
||||
* @param channelName
|
||||
* name of channel to get.
|
||||
* @return {@link ChatChannel}
|
||||
*/
|
||||
public static ChatChannel getChannel(String channelName) {
|
||||
for (ChatChannel c : channels) {
|
||||
if (c.getName().equalsIgnoreCase(channelName) || c.getAlias().equalsIgnoreCase(channelName)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isChannel(String channel) {
|
||||
return getChannel(channel) != null;
|
||||
|
||||
/**
|
||||
* Checks if the chat channel exists.
|
||||
*
|
||||
* @param channelName
|
||||
* name of channel to check.
|
||||
* @return true if channel exists, false otherwise.
|
||||
*/
|
||||
public static boolean isChannel(String channelName) {
|
||||
return getChannel(channelName) != null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get default chat channel color.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public static String getDefaultColor() {
|
||||
return defaultColor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get default chat channel.
|
||||
*
|
||||
* @return {@link ChatChannel}
|
||||
*/
|
||||
public static ChatChannel getDefaultChannel() {
|
||||
return defaultChatChannel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get list of chat channels with autojoin set to true.
|
||||
*
|
||||
* @return {@link List}<{@link ChatChannel}>
|
||||
*/
|
||||
public static List<ChatChannel> getAutojoinList() {
|
||||
List<ChatChannel> joinlist = new ArrayList<ChatChannel>();
|
||||
for(ChatChannel c : channels) {
|
||||
if(c.getAutojoin()) {
|
||||
for (ChatChannel c : channels) {
|
||||
if (c.getAutojoin()) {
|
||||
joinlist.add(c);
|
||||
}
|
||||
}
|
||||
return joinlist;
|
||||
}
|
||||
|
||||
public ChatChannel(String _Name, String _color, String _chatcolor, String _Permission, Boolean _mutable, Boolean _filter, Boolean _defaultchannel, String _alias, Double _distance, Boolean _autojoin, Boolean _bungee, int _cooldown, String _format) {
|
||||
name = _Name;
|
||||
permission = "venturechat." + _Permission;
|
||||
mutable = _mutable;
|
||||
setColor(_color);
|
||||
setChatColor(_chatcolor);
|
||||
setDefaultChannel(_defaultchannel);
|
||||
setAlias(_alias);
|
||||
setDistance(_distance);
|
||||
setFilter(_filter);
|
||||
setAutojoin(_autojoin);
|
||||
setBungee(_bungee);
|
||||
setCooldown(_cooldown);
|
||||
setFormat(_format);
|
||||
/**
|
||||
* Parameterized constructor a {@link ChatChannel}.
|
||||
*
|
||||
* @param name
|
||||
* @param color
|
||||
* @param chatColor
|
||||
* @param permission
|
||||
* @param speakPermission
|
||||
* @param mutable
|
||||
* @param filter
|
||||
* @param defaultChannel
|
||||
* @param alias
|
||||
* @param distance
|
||||
* @param autojoin
|
||||
* @param bungee
|
||||
* @param cooldown
|
||||
* @param format
|
||||
*/
|
||||
public ChatChannel(String name, String color, String chatColor, String permission, String speakPermission,
|
||||
boolean mutable, boolean filter, boolean defaultChannel, String alias, double distance, boolean autojoin,
|
||||
boolean bungee, int cooldown, String format) {
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
this.chatColor = chatColor;
|
||||
this.permission = PERMISSION_PREFIX + permission;
|
||||
this.speakPermission = PERMISSION_PREFIX + speakPermission;
|
||||
this.mutable = mutable;
|
||||
this.filter = filter;
|
||||
this.defaultChannel = defaultChannel;
|
||||
this.alias = alias;
|
||||
this.distance = distance;
|
||||
this.autojoin = autojoin;
|
||||
this.bungee = bungee;
|
||||
this.cooldown = cooldown;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setFormat(String _format) {
|
||||
format = _format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the format of the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setCooldown(int _cooldown) {
|
||||
cooldown = _cooldown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cooldown of the chat channel in seconds.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getCooldown() {
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
public void setBungee(Boolean _bungee) {
|
||||
bungee = _bungee;
|
||||
}
|
||||
|
||||
public Boolean getBungee() {
|
||||
/**
|
||||
* Check if the chat channel is BungeeCord enabled.
|
||||
*
|
||||
* @return true if the chat channel is BungeeCord enabled, false otherwise.
|
||||
*/
|
||||
public boolean getBungee() {
|
||||
return bungee;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permissions node for the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public Boolean getAutojoin() {
|
||||
/**
|
||||
* Check if autojoin is enabled for the chat channel.
|
||||
*
|
||||
* @return true if autojoin is enabled, false otherwise.
|
||||
*/
|
||||
public boolean getAutojoin() {
|
||||
return autojoin;
|
||||
}
|
||||
|
||||
public void setAutojoin(Boolean _autojoin) {
|
||||
autojoin = _autojoin;
|
||||
}
|
||||
|
||||
public Boolean isMutable() {
|
||||
/**
|
||||
* Check if the chat channel allows muting.
|
||||
*
|
||||
* @return true if muting is allowed, false otherwise.
|
||||
*/
|
||||
public boolean isMutable() {
|
||||
return mutable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formatted color of the chat channel.
|
||||
*
|
||||
* @return {@link String}. Returns {@link Format#DEFAULT_COLOR_CODE} if the
|
||||
* color is invalid.
|
||||
*/
|
||||
public String getColor() {
|
||||
if (Format.isValidColor(color)) {
|
||||
return String.valueOf(ChatColor.valueOf(color.toUpperCase()));
|
||||
}
|
||||
if (Format.isValidHexColor(color)) {
|
||||
return Format.convertHexColorCodeToBukkitColorCode(color);
|
||||
}
|
||||
return Format.DEFAULT_COLOR_CODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw color value of the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getColorRaw() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formatted chat color of the chat channel.
|
||||
*
|
||||
* @return {@link String}. Returns {@link Format#DEFAULT_COLOR_CODE} if the chat
|
||||
* color is invalid.
|
||||
*/
|
||||
public String getChatColor() {
|
||||
return chatcolor;
|
||||
if (chatColor.equalsIgnoreCase("None")) {
|
||||
return chatColor;
|
||||
}
|
||||
if (Format.isValidColor(chatColor)) {
|
||||
return String.valueOf(ChatColor.valueOf(chatColor.toUpperCase()));
|
||||
}
|
||||
if (Format.isValidHexColor(chatColor)) {
|
||||
return Format.convertHexColorCodeToBukkitColorCode(chatColor);
|
||||
}
|
||||
return Format.DEFAULT_COLOR_CODE;
|
||||
}
|
||||
|
||||
public void setChatColor(String chatcolor) {
|
||||
this.chatcolor = chatcolor;
|
||||
/**
|
||||
* Get the raw chat color value of the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getChatColorRaw() {
|
||||
return chatColor;
|
||||
}
|
||||
|
||||
public Boolean isDefaultchannel() {
|
||||
/**
|
||||
* Check if the chat channel is the default chat channel.
|
||||
*
|
||||
* @return true if the chat channel is the default chat channel, false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isDefaultchannel() {
|
||||
return defaultChannel;
|
||||
}
|
||||
|
||||
public void setDefaultChannel(Boolean defaultChannel) {
|
||||
this.defaultChannel = defaultChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the alias of the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public void setAlias(String alias) {
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
public Double getDistance() {
|
||||
/**
|
||||
* Get the distance of the chat channel in blocks.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public double getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(Double distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public Boolean hasDistance() {
|
||||
/**
|
||||
* Checks if the chat channel has a distance set.
|
||||
*
|
||||
* @return true if the distance is greater than zero, false otherwise.
|
||||
*/
|
||||
public boolean hasDistance() {
|
||||
return distance > 0;
|
||||
}
|
||||
|
||||
public Boolean hasCooldown() {
|
||||
/**
|
||||
* Checks if the chat channel has a cooldown set.
|
||||
*
|
||||
* @return true if the cooldown is greater than zero, false otherwise.
|
||||
*/
|
||||
public boolean hasCooldown() {
|
||||
return cooldown > 0;
|
||||
}
|
||||
|
||||
public Boolean hasPermission() {
|
||||
return !permission.equalsIgnoreCase("venturechat.none");
|
||||
/**
|
||||
* Checks if the chat channel has a permission set.
|
||||
*
|
||||
* @return true if the permission does not equal
|
||||
* {@link ChatChannel#NO_PERMISSIONS}, false otherwise.
|
||||
*/
|
||||
public boolean hasPermission() {
|
||||
return !permission.equalsIgnoreCase(NO_PERMISSIONS);
|
||||
}
|
||||
|
||||
public Boolean isFiltered() {
|
||||
/**
|
||||
* Checks if the chat channel has a speak permission set.
|
||||
*
|
||||
* @return true if the speak permission does not equal
|
||||
* {@link ChatChannel#NO_PERMISSIONS}, false otherwise.
|
||||
*/
|
||||
public boolean hasSpeakPermission() {
|
||||
return !speakPermission.equalsIgnoreCase(NO_PERMISSIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the speak permissions node for the chat channel.
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
public String getSpeakPermission() {
|
||||
return speakPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the chat channel has the filter enabled.
|
||||
*
|
||||
* @return true if the chat channel has the filter enabled, false otherwise.
|
||||
*/
|
||||
public boolean isFiltered() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public void setFilter(Boolean filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public boolean isIRC() {
|
||||
return irc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the chat channel by name to determine equality.
|
||||
*
|
||||
* @param channel
|
||||
* Object to compare for equality.
|
||||
* @return true if the objects are equal, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object channel) {
|
||||
return channel instanceof ChatChannel && this.name.equals(((ChatChannel) channel).getName());
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineverse.Aust1n46.chat.command.chat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -39,7 +38,7 @@ public class Channel extends MineverseCommand implements Listener {
|
||||
}
|
||||
ChatChannel channel = ChatChannel.getChannel(args[0]);
|
||||
plugin.getServer().getPluginManager().callEvent(new ChannelJoinEvent(mcp.getPlayer(), channel, LocalizedMessage.SET_CHANNEL.toString()
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName())));
|
||||
return;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
||||
import mineverse.Aust1n46.chat.command.MineverseCommand;
|
||||
import mineverse.Aust1n46.chat.utilities.Format;
|
||||
|
||||
public class Channelinfo extends MineverseCommand {
|
||||
|
||||
@ -30,27 +31,38 @@ public class Channelinfo extends MineverseCommand {
|
||||
return;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(ChatColor.GOLD + "Channel: " + ChatColor.valueOf(chname.getColor().toUpperCase()) + chname.getName());
|
||||
sender.sendMessage(ChatColor.GOLD + "Alias: " + ChatColor.valueOf(chname.getColor().toUpperCase()) + chname.getAlias());
|
||||
sender.sendMessage(ChatColor.GOLD + "Color: " + ChatColor.valueOf(chname.getColor().toUpperCase()) + chname.getColor());
|
||||
sender.sendMessage(ChatColor.GOLD + "ChatColor: " + ChatColor.valueOf(chname.getChatColor().toUpperCase()) + chname.getChatColor());
|
||||
sender.sendMessage(ChatColor.GOLD + "Permission: " + ChatColor.valueOf(chname.getColor().toUpperCase()) + chname.getPermission());
|
||||
sender.sendMessage(ChatColor.GOLD + "Autojoin: " + ChatColor.valueOf(chname.getColor().toUpperCase()) + chname.getAutojoin());
|
||||
sender.sendMessage(ChatColor.GOLD + "Default: " + ChatColor.valueOf(chname.getColor().toUpperCase()) + chname.hasDistance());
|
||||
sender.sendMessage(ChatColor.GOLD + "Channel: " + chname.getColor() + chname.getName());
|
||||
sender.sendMessage(ChatColor.GOLD + "Alias: " + chname.getColor() + chname.getAlias());
|
||||
sender.sendMessage(ChatColor.GOLD + "Color: " + chname.getColor() + chname.getColorRaw());
|
||||
sender.sendMessage(ChatColor.GOLD + "ChatColor: " + (chname.getChatColor().equalsIgnoreCase("None") ? Format.DEFAULT_COLOR_CODE : chname.getChatColor()) + chname.getChatColorRaw());
|
||||
if(chname.hasPermission()) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Permission: " + chname.getColor() + chname.getPermission());
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Permission: " + chname.getColor() + "None");
|
||||
}
|
||||
if(chname.hasSpeakPermission()) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Speak Permission: " + chname.getColor() + chname.getSpeakPermission());
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Speak Permission: " + chname.getColor() + "None");
|
||||
}
|
||||
sender.sendMessage(ChatColor.GOLD + "Autojoin: " + chname.getColor() + chname.getAutojoin());
|
||||
sender.sendMessage(ChatColor.GOLD + "Default: " + chname.getColor() + chname.hasDistance());
|
||||
if(!chname.hasDistance() || chname.getBungee()) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Distance: " + ChatColor.RED + "N/A");
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Distance: " + ChatColor.valueOf(chname.getColor().toUpperCase()) + chname.getDistance().toString());
|
||||
sender.sendMessage(ChatColor.GOLD + "Distance: " + chname.getColor() + chname.getDistance());
|
||||
}
|
||||
if(!chname.hasCooldown()) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Cooldown: " + ChatColor.RED + "N/A");
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Cooldown: " + ChatColor.valueOf(chname.getColor().toUpperCase()) + chname.getCooldown());
|
||||
sender.sendMessage(ChatColor.GOLD + "Cooldown: " + chname.getColor() + chname.getCooldown());
|
||||
}
|
||||
sender.sendMessage(ChatColor.GOLD + "Bungeecord: " + ChatColor.valueOf(chname.getColor().toUpperCase()) + chname.getBungee().toString());
|
||||
sender.sendMessage(ChatColor.GOLD + "Format: " + ChatColor.valueOf(chname.getColor().toUpperCase()) + chname.getFormat());
|
||||
sender.sendMessage(ChatColor.GOLD + "Bungeecord: " + chname.getColor() + chname.getBungee());
|
||||
sender.sendMessage(ChatColor.GOLD + "Format: " + chname.getColor() + chname.getFormat());
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
@ -34,11 +34,11 @@ public class Chatinfo extends MineverseCommand {
|
||||
mcp.getPlayer().sendMessage(ChatColor.GOLD + "Player: " + ChatColor.GREEN + mcp.getName());
|
||||
for(String c : mcp.getListening()) {
|
||||
ChatChannel channel = ChatChannel.getChannel(c);
|
||||
listen += ChatColor.valueOf(channel.getColor().toUpperCase()) + channel.getName() + " ";
|
||||
listen += channel.getColor() + channel.getName() + " ";
|
||||
}
|
||||
for(String c : mcp.getMutes().keySet()) {
|
||||
ChatChannel channel = ChatChannel.getChannel(c);
|
||||
mute += ChatColor.valueOf(channel.getColor().toUpperCase()) + channel.getName() + " ";
|
||||
mute += channel.getColor() + channel.getName() + " ";
|
||||
}
|
||||
for(String bc : mcp.getBlockedCommands()) {
|
||||
blockedcommands += bc + " ";
|
||||
@ -95,11 +95,11 @@ public class Chatinfo extends MineverseCommand {
|
||||
sender.sendMessage(ChatColor.GOLD + "Player: " + ChatColor.GREEN + p.getName());
|
||||
for(String c : p.getListening()) {
|
||||
ChatChannel channel = ChatChannel.getChannel(c);
|
||||
listen += ChatColor.valueOf(channel.getColor().toUpperCase()) + channel.getName() + " ";
|
||||
listen += channel.getColor() + channel.getName() + " ";
|
||||
}
|
||||
for(String c : p.getMutes().keySet()) {
|
||||
ChatChannel channel = ChatChannel.getChannel(c);
|
||||
mute += ChatColor.valueOf(channel.getColor().toUpperCase()) + channel.getName() + " ";
|
||||
mute += channel.getColor() + channel.getName() + " ";
|
||||
}
|
||||
for(String bc : p.getBlockedCommands()) {
|
||||
blockedcommands += bc + " ";
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineverse.Aust1n46.chat.command.chat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
||||
@ -20,14 +19,14 @@ public class Chlist extends MineverseCommand {
|
||||
if(chname.hasPermission()) {
|
||||
if(sender.hasPermission(chname.getPermission())) {
|
||||
sender.sendMessage(LocalizedMessage.CHANNEL_LIST_WITH_PERMISSIONS.toString()
|
||||
.replace("{channel_color}", (ChatColor.valueOf(chname.getColor().toUpperCase())).toString())
|
||||
.replace("{channel_color}", (chname.getColor()).toString())
|
||||
.replace("{channel_name}", chname.getName())
|
||||
.replace("{channel_alias}", chname.getAlias()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocalizedMessage.CHANNEL_LIST.toString()
|
||||
.replace("{channel_color}", (ChatColor.valueOf(chname.getColor().toUpperCase())).toString())
|
||||
.replace("{channel_color}", chname.getColor().toString())
|
||||
.replace("{channel_name}", chname.getName())
|
||||
.replace("{channel_alias}", chname.getAlias()));
|
||||
}
|
||||
|
@ -76,11 +76,11 @@ public class Chwho extends MineverseCommand {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(pluginManager.isPluginEnabled("Towny") && sender instanceof Player) {
|
||||
if(plugin.getConfig().getBoolean("enable_towny_channel") && pluginManager.isPluginEnabled("Towny") && sender instanceof Player) {
|
||||
try {
|
||||
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
|
||||
Resident pp = TownyUniverse.getDataSource().getResident(((Player) sender).getName());
|
||||
if(channel.getName().equalsIgnoreCase("Town")) {
|
||||
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
|
||||
Resident pp = TownyUniverse.getDataSource().getResident(((Player) sender).getName());
|
||||
if(!pp.hasTown()) {
|
||||
if(playerlist.length() + p.getName().length() > linecount) {
|
||||
playerlist += "\n";
|
||||
@ -103,6 +103,8 @@ public class Chwho extends MineverseCommand {
|
||||
}
|
||||
}
|
||||
if(channel.getName().equalsIgnoreCase("Nation")) {
|
||||
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
|
||||
Resident pp = TownyUniverse.getDataSource().getResident(((Player) sender).getName());
|
||||
if(!pp.hasNation()) {
|
||||
if(playerlist.length() + p.getName().length() > linecount) {
|
||||
playerlist += "\n";
|
||||
@ -129,11 +131,11 @@ public class Chwho extends MineverseCommand {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(pluginManager.isPluginEnabled("Factions") && sender instanceof Player) {
|
||||
if(plugin.getConfig().getBoolean("enable_factions_channel") && pluginManager.isPluginEnabled("Factions") && sender instanceof Player) {
|
||||
try {
|
||||
MPlayer mplayer = MPlayer.get(p.getPlayer());
|
||||
MPlayer mplayerp = MPlayer.get((Player) sender);
|
||||
if(channel.getName().equalsIgnoreCase("Faction")) {
|
||||
MPlayer mplayer = MPlayer.get(p.getPlayer());
|
||||
MPlayer mplayerp = MPlayer.get((Player) sender);
|
||||
if(!mplayerp.hasFaction()) {
|
||||
if(playerlist.length() + p.getName().length() > linecount) {
|
||||
playerlist += "\n";
|
||||
@ -177,7 +179,7 @@ public class Chwho extends MineverseCommand {
|
||||
playerlist = playerlist.substring(0, playerlist.length() - 2);
|
||||
}
|
||||
sender.sendMessage(LocalizedMessage.CHANNEL_PLAYER_LIST_HEADER.toString()
|
||||
.replace("{channel_color}", (ChatColor.valueOf(channel.getColor().toUpperCase())).toString())
|
||||
.replace("{channel_color}", (channel.getColor()).toString())
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
sender.sendMessage(playerlist);
|
||||
return;
|
||||
@ -210,7 +212,7 @@ public class Chwho extends MineverseCommand {
|
||||
locreceip = p2.getLocation();
|
||||
if(locreceip.getWorld() == p1.getWorld()) {
|
||||
diff = locreceip.subtract(locsender);
|
||||
if(Math.abs(diff.getX()) > chDistance || Math.abs(diff.getZ()) > chDistance) {
|
||||
if(Math.abs(diff.getX()) > chDistance || Math.abs(diff.getZ()) > chDistance || Math.abs(diff.getY()) > chDistance) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -38,12 +38,12 @@ public class Kickchannel extends MineverseCommand {
|
||||
}
|
||||
sender.sendMessage(LocalizedMessage.KICK_CHANNEL.toString()
|
||||
.replace("{player}", args[0])
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
player.removeListening(channel.getName());
|
||||
if(player.isOnline()) {
|
||||
player.getPlayer().sendMessage(LocalizedMessage.LEAVE_CHANNEL.toString()
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
}
|
||||
else
|
||||
|
@ -34,7 +34,7 @@ public class Leave extends MineverseCommand {
|
||||
}
|
||||
mcp.removeListening(channel.getName());
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.LEAVE_CHANNEL.toString()
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
if(mcp.getListening().size() == 0) {
|
||||
mcp.addListening(ChatChannel.getDefaultChannel().getName());
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineverse.Aust1n46.chat.command.chat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -41,7 +40,7 @@ public class Listen extends MineverseCommand {
|
||||
}
|
||||
mcp.addListening(channel.getName());
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.LISTEN_CHANNEL.toString()
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
return;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineverse.Aust1n46.chat.command.chat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import mineverse.Aust1n46.chat.MineverseChat;
|
||||
@ -46,7 +45,7 @@ public class Setchannel extends MineverseCommand {
|
||||
player.removeListening(channel.getName());
|
||||
sender.sendMessage(LocalizedMessage.SET_CHANNEL_PLAYER_CHANNEL_NO_PERMISSION.toString()
|
||||
.replace("{player}", player.getName())
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
return;
|
||||
}
|
||||
@ -55,7 +54,7 @@ public class Setchannel extends MineverseCommand {
|
||||
player.setCurrentChannel(channel);
|
||||
sender.sendMessage(LocalizedMessage.SET_CHANNEL_SENDER.toString()
|
||||
.replace("{player}", player.getName())
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
if(player.hasConversation()) {
|
||||
for(MineverseChatPlayer p : MineverseChat.onlinePlayers) {
|
||||
@ -74,7 +73,7 @@ public class Setchannel extends MineverseCommand {
|
||||
}
|
||||
if(player.isOnline())
|
||||
player.getPlayer().sendMessage(LocalizedMessage.SET_CHANNEL.toString()
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
else
|
||||
player.setModified(true);
|
||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -103,8 +102,8 @@ public class VentureChatGui extends MineverseCommand {
|
||||
skullMeta.setOwner(target.getName());
|
||||
skullMeta.setDisplayName("§b" + target.getName());
|
||||
List<String> skullLore = new ArrayList<String>();
|
||||
skullLore.add("§7Channel: " + ChatColor.valueOf(channel.getColor().toUpperCase()) + channel.getName());
|
||||
skullLore.add("§7Hash: " + ChatColor.valueOf(channel.getColor().toUpperCase()) + hash);
|
||||
skullLore.add("§7Channel: " + channel.getColor() + channel.getName());
|
||||
skullLore.add("§7Hash: " + channel.getColor() + hash);
|
||||
skullMeta.setLore(skullLore);
|
||||
skull.setItemMeta(skullMeta);
|
||||
skull.setDurability((short) 3);
|
||||
@ -162,8 +161,8 @@ public class VentureChatGui extends MineverseCommand {
|
||||
skullMeta.setOwner("Scarsz");
|
||||
skullMeta.setDisplayName("§bDiscord_Message");
|
||||
List<String> skullLore = new ArrayList<String>();
|
||||
skullLore.add("§7Channel: " + ChatColor.valueOf(channel.getColor().toUpperCase()) + channel.getName());
|
||||
skullLore.add("§7Hash: " + ChatColor.valueOf(channel.getColor().toUpperCase()) + hash);
|
||||
skullLore.add("§7Channel: " + channel.getColor() + channel.getName());
|
||||
skullLore.add("§7Hash: " + channel.getColor() + hash);
|
||||
skullMeta.setLore(skullLore);
|
||||
skull.setItemMeta(skullMeta);
|
||||
skull.setDurability((short) 3);
|
||||
|
@ -30,16 +30,16 @@ public class Venturechat extends MineverseCommand {
|
||||
sender.sendMessage(InternalMessage.VENTURECHAT_AUTHOR.toString());
|
||||
if (sender instanceof Player && plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
||||
Player player = (Player) sender;
|
||||
String title = ChatColor.GOLD + " | " + ChatColor.BLUE.toString() + ChatColor.BOLD + "Click here to begin..." + ChatColor.RESET + ChatColor.GOLD + " | ";
|
||||
String title = ChatColor.GOLD + " | " + ChatColor.BLUE.toString() + ChatColor.BOLD + "SpigotAPI chat message" + ChatColor.RESET + ChatColor.GOLD + " | ";
|
||||
String spaces = " ";
|
||||
TextComponent tcSpaces = new TextComponent(spaces);
|
||||
TextComponent message = new TextComponent(title);
|
||||
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click here to rank up!").create()));
|
||||
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rules 1"));
|
||||
message.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "Sample SpigotAPI Click Event"));
|
||||
tcSpaces.addExtra(message);
|
||||
player.spigot().sendMessage(tcSpaces);
|
||||
|
||||
//sendActionBar(player, "NMS message");
|
||||
// sendActionBar(player, "NMS ActionBar message");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,6 @@ public class Message extends MineverseCommand {
|
||||
String send = "";
|
||||
String echo = "";
|
||||
String spy = "";
|
||||
String tellColor = plugin.getConfig().getString("tellcolor", "gray");
|
||||
for(int r = 1; r < args.length; r++) {
|
||||
msg += " " + args[r];
|
||||
}
|
||||
@ -62,24 +61,9 @@ public class Message extends MineverseCommand {
|
||||
if(mcp.getPlayer().hasPermission("venturechat.format")) {
|
||||
msg = Format.FormatString(msg);
|
||||
}
|
||||
if(plugin.getConfig().getString("tellformatfrom").equalsIgnoreCase("Default")) {
|
||||
send = "{playerfrom} messages you:" + ChatColor.valueOf(tellColor.toUpperCase()) + msg;
|
||||
}
|
||||
else {
|
||||
send = Format.FormatStringAll(plugin.getConfig().getString("tellformatfrom")) + msg;
|
||||
}
|
||||
if(plugin.getConfig().getString("tellformatto").equalsIgnoreCase("Default")) {
|
||||
echo = "You message {playerto}:" + ChatColor.valueOf(tellColor.toUpperCase()) + msg;
|
||||
}
|
||||
else {
|
||||
echo = Format.FormatStringAll(plugin.getConfig().getString("tellformatto")) + msg;
|
||||
}
|
||||
if(plugin.getConfig().getString("tellformatspy").equalsIgnoreCase("Default")) {
|
||||
spy = "{playerfrom} messages {playerto}:" + ChatColor.valueOf(tellColor.toUpperCase()) + msg;
|
||||
}
|
||||
else {
|
||||
spy = Format.FormatStringAll(plugin.getConfig().getString("tellformatspy")) + msg;
|
||||
}
|
||||
send = Format.FormatStringAll(plugin.getConfig().getString("tellformatfrom")) + msg;
|
||||
echo = Format.FormatStringAll(plugin.getConfig().getString("tellformatto")) + msg;
|
||||
spy = Format.FormatStringAll(plugin.getConfig().getString("tellformatspy")) + msg;
|
||||
try {
|
||||
out.writeUTF("Message");
|
||||
out.writeUTF("Send");
|
||||
|
@ -40,28 +40,12 @@ public class Reply extends MineverseCommand {
|
||||
String send = "";
|
||||
String echo = "";
|
||||
String spy = "";
|
||||
String tellColor = plugin.getConfig().getString("tellcolor", "gray");
|
||||
for(int r = 0; r < args.length; r++) {
|
||||
msg += " " + args[r];
|
||||
}
|
||||
if(plugin.getConfig().getString("tellformatfrom").equalsIgnoreCase("Default")) {
|
||||
send = "{playerfrom} replies to you:" + ChatColor.valueOf(tellColor.toUpperCase()) + msg;
|
||||
}
|
||||
else {
|
||||
send = Format.FormatStringAll(plugin.getConfig().getString("tellformatfrom")) + msg;
|
||||
}
|
||||
if(plugin.getConfig().getString("tellformatto").equalsIgnoreCase("Default")) {
|
||||
echo = "You reply to {playerto}:" + ChatColor.valueOf(tellColor.toUpperCase()) + msg;
|
||||
}
|
||||
else {
|
||||
echo = Format.FormatStringAll(plugin.getConfig().getString("tellformatto")) + msg;
|
||||
}
|
||||
if(plugin.getConfig().getString("tellformatspy").equalsIgnoreCase("Default")) {
|
||||
spy = "{playerfrom} replied to {playerto}:" + ChatColor.valueOf(tellColor.toUpperCase()) + msg;
|
||||
}
|
||||
else {
|
||||
spy = Format.FormatStringAll(plugin.getConfig().getString("tellformatspy")) + msg;
|
||||
}
|
||||
send = Format.FormatStringAll(plugin.getConfig().getString("replyformatfrom")) + msg;
|
||||
echo = Format.FormatStringAll(plugin.getConfig().getString("replyformatto")) + msg;
|
||||
spy = Format.FormatStringAll(plugin.getConfig().getString("replyformatspy")) + msg;
|
||||
try {
|
||||
out.writeUTF("Message");
|
||||
out.writeUTF("Send");
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineverse.Aust1n46.chat.command.mute;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import mineverse.Aust1n46.chat.MineverseChat;
|
||||
@ -37,7 +36,7 @@ public class Mute extends MineverseCommand {
|
||||
if(player.isMuted(channel.getName())) {
|
||||
sender.sendMessage(LocalizedMessage.PLAYER_ALREADY_MUTED.toString()
|
||||
.replace("{player}", player.getName())
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
return;
|
||||
}
|
||||
@ -45,11 +44,11 @@ public class Mute extends MineverseCommand {
|
||||
player.addMute(channel.getName(), 0);
|
||||
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER.toString()
|
||||
.replace("{player}", player.getName())
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
if(player.isOnline())
|
||||
player.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER.toString()
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
else
|
||||
player.setModified(true);
|
||||
@ -59,7 +58,7 @@ public class Mute extends MineverseCommand {
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(LocalizedMessage.CHANNEL_CANNOT_MUTE.toString()
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
return;
|
||||
}
|
||||
@ -72,7 +71,7 @@ public class Mute extends MineverseCommand {
|
||||
if(player.isMuted(channel.getName())) {
|
||||
sender.sendMessage(LocalizedMessage.PLAYER_ALREADY_MUTED.toString()
|
||||
.replace("{player}", player.getName())
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
return;
|
||||
}
|
||||
@ -94,13 +93,13 @@ public class Mute extends MineverseCommand {
|
||||
keyword = "minute";
|
||||
sender.sendMessage(LocalizedMessage.MUTE_PLAYER_SENDER_TIME.toString()
|
||||
.replace("{player}", player.getName())
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName())
|
||||
.replace("{time}", time + "")
|
||||
.replace("{units}", keyword));
|
||||
if(player.isOnline())
|
||||
player.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_PLAYER_TIME.toString()
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName())
|
||||
.replace("{time}", time + "")
|
||||
.replace("{units}", keyword));
|
||||
@ -121,7 +120,7 @@ public class Mute extends MineverseCommand {
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(LocalizedMessage.CHANNEL_CANNOT_MUTE.toString()
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
return;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineverse.Aust1n46.chat.command.mute;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import mineverse.Aust1n46.chat.MineverseChat;
|
||||
@ -36,19 +35,19 @@ public class Unmute extends MineverseCommand {
|
||||
if(!player.isMuted(channel.getName())) {
|
||||
sender.sendMessage(LocalizedMessage.PLAYER_NOT_MUTED.toString()
|
||||
.replace("{player}", player.getName())
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
return;
|
||||
}
|
||||
player.removeMute(channel.getName());
|
||||
sender.sendMessage(LocalizedMessage.UNMUTE_PLAYER_SENDER.toString()
|
||||
.replace("{player}", player.getName())
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
if(player.isOnline()) {
|
||||
player.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_PLAYER.toString()
|
||||
.replace("{player}", player.getName())
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
}
|
||||
else {
|
||||
|
@ -90,16 +90,16 @@ public class ChatListener implements Listener {
|
||||
mcp.setConversation(null);
|
||||
}
|
||||
else {
|
||||
if(tp.getIgnores().contains(mcp.getUUID())) {
|
||||
if(tp.getIgnores().contains(mcp.getUUID())) {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.IGNORING_MESSAGE.toString()
|
||||
.replace("{player}", tp.getName()));
|
||||
event.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(!tp.getMessageToggle()) {
|
||||
if(!tp.getMessageToggle()) {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.BLOCKING_MESSAGE.toString()
|
||||
.replace("{player}", tp.getName()));
|
||||
event.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
String filtered = chat;
|
||||
@ -227,7 +227,7 @@ public class ChatListener implements Listener {
|
||||
timedMute = " for " + remaining + " more " + keyword;
|
||||
}
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_MUTED.toString()
|
||||
.replace("{channel_color}", ChatColor.valueOf(eventChannel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", eventChannel.getColor() + "")
|
||||
.replace("{channel_name}", eventChannel.getName())
|
||||
.replace("{time}", timedMute));
|
||||
mcp.setQuickChat(false);
|
||||
@ -243,7 +243,12 @@ public class ChatListener implements Listener {
|
||||
mcp.setCurrentChannel(ChatChannel.getDefaultChannel());
|
||||
return;
|
||||
}
|
||||
curColor = eventChannel.getChatColor().toUpperCase();
|
||||
if(eventChannel.hasSpeakPermission() && !mcp.getPlayer().hasPermission(eventChannel.getSpeakPermission())) {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.CHANNEL_NO_SPEAK_PERMISSIONS.toString());
|
||||
mcp.setQuickChat(false);
|
||||
return;
|
||||
}
|
||||
curColor = eventChannel.getChatColor();
|
||||
bungee = eventChannel.getBungee();
|
||||
|
||||
int time = (int) (System.currentTimeMillis() / 1000);
|
||||
@ -294,7 +299,7 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
mcp.getSpam().get(eventChannel).set(0, 0);
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.MUTE_PLAYER_SPAM.toString()
|
||||
.replace("{channel_color}", ChatColor.valueOf(eventChannel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", eventChannel.getColor() + "")
|
||||
.replace("{channel_name}", eventChannel.getName())
|
||||
.replace("{time}", timedmute));
|
||||
mcp.setQuickChat(false);
|
||||
@ -323,7 +328,7 @@ public class ChatListener implements Listener {
|
||||
chDistance = eventChannel.getDistance();
|
||||
}
|
||||
|
||||
format = PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), Format.FormatStringAll(plugin.getConfig().getConfigurationSection("channels." + eventChannel.getName()).getString("format")));
|
||||
format = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), Format.FormatStringAll(plugin.getConfig().getConfigurationSection("channels." + eventChannel.getName()).getString("format"))));
|
||||
if(plugin.getConfig().getBoolean("formatcleaner", false)) {
|
||||
format = format.replace("[]", " ");
|
||||
format = format.replace(" ", " ").replace(" ", " ").replace(" ", " ");
|
||||
@ -350,9 +355,9 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
if(plugin.getConfig().getBoolean("enable_towny_channel") && pluginManager.isPluginEnabled("Towny")) {
|
||||
try {
|
||||
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
|
||||
Resident pp = TownyUniverse.getDataSource().getResident(mcp.getName());
|
||||
if(eventChannel.getName().equalsIgnoreCase("Town")) {
|
||||
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
|
||||
Resident pp = TownyUniverse.getDataSource().getResident(mcp.getName());
|
||||
if(!pp.hasTown()) {
|
||||
recipients.remove(p.getPlayer());
|
||||
recipientCount--;
|
||||
@ -370,6 +375,8 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
}
|
||||
if(eventChannel.getName().equalsIgnoreCase("Nation")) {
|
||||
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
|
||||
Resident pp = TownyUniverse.getDataSource().getResident(mcp.getName());
|
||||
if(!pp.hasNation()) {
|
||||
recipients.remove(p.getPlayer());
|
||||
recipientCount--;
|
||||
@ -394,9 +401,9 @@ public class ChatListener implements Listener {
|
||||
|
||||
if(plugin.getConfig().getBoolean("enable_factions_channel") && pluginManager.isPluginEnabled("Factions")) {
|
||||
try {
|
||||
MPlayer mplayer = MPlayer.get(mcp.getPlayer());
|
||||
MPlayer mplayerp = MPlayer.get(p.getPlayer());
|
||||
if(eventChannel.getName().equalsIgnoreCase("Faction")) {
|
||||
MPlayer mplayer = MPlayer.get(mcp.getPlayer());
|
||||
MPlayer mplayerp = MPlayer.get(p.getPlayer());
|
||||
if(!mplayer.hasFaction()) {
|
||||
recipients.remove(p.getPlayer());
|
||||
recipientCount--;
|
||||
@ -420,7 +427,7 @@ public class ChatListener implements Listener {
|
||||
locreceip = p.getPlayer().getLocation();
|
||||
if(locreceip.getWorld() == mcp.getPlayer().getWorld()) {
|
||||
diff = locreceip.subtract(locsender);
|
||||
if(Math.abs(diff.getX()) > chDistance || Math.abs(diff.getZ()) > chDistance) {
|
||||
if(Math.abs(diff.getX()) > chDistance || Math.abs(diff.getZ()) > chDistance || Math.abs(diff.getY()) > chDistance) {
|
||||
recipients.remove(p.getPlayer());
|
||||
recipientCount--;
|
||||
continue;
|
||||
@ -457,10 +464,10 @@ public class ChatListener implements Listener {
|
||||
chat = Format.getLastCode(format) + chat;
|
||||
}
|
||||
else {
|
||||
chat = ChatColor.valueOf(curColor) + chat;
|
||||
chat = curColor + chat;
|
||||
}
|
||||
|
||||
String globalJSON = Format.convertToJson(mcp, format, chat);
|
||||
String globalJSON = Format.convertToJson(mcp, format, chat);
|
||||
String consoleChat = format + chat;
|
||||
String message = consoleChat.replaceAll("(§([a-z0-9]))", "");
|
||||
int hash = message.hashCode();
|
||||
|
@ -150,7 +150,7 @@ public class CommandListener implements CommandExecutor, Listener {
|
||||
if(!channel.hasPermission() || mcp.getPlayer().hasPermission(channel.getPermission())) {
|
||||
if(message.equals("/" + channel.getAlias())) {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.SET_CHANNEL.toString()
|
||||
.replace("{channel_color}", ChatColor.valueOf(channel.getColor().toUpperCase()) + "")
|
||||
.replace("{channel_color}", channel.getColor() + "")
|
||||
.replace("{channel_name}", channel.getName()));
|
||||
if(mcp.hasConversation()) {
|
||||
for(MineverseChatPlayer p : MineverseChat.onlinePlayers) {
|
||||
@ -262,7 +262,7 @@ public class CommandListener implements CommandExecutor, Listener {
|
||||
if(target != null) {
|
||||
command = command.replace("{player_name}", target.getName());
|
||||
if(target.isOnline()) {
|
||||
command = PlaceholderAPI.setBracketPlaceholders(target.getPlayer(), command);
|
||||
command = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(target.getPlayer(), command));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -28,7 +28,7 @@ public class PacketListener extends PacketAdapter {
|
||||
return;
|
||||
}
|
||||
|
||||
MineverseChatPlayer mcp = MineverseChatAPI.getMineverseChatPlayer(event.getPlayer());
|
||||
MineverseChatPlayer mcp = MineverseChatAPI.getOnlineMineverseChatPlayer(event.getPlayer());
|
||||
if(mcp == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class Localization {
|
||||
private static MineverseChat plugin = MineverseChat.getInstance();
|
||||
private static FileConfiguration localization;
|
||||
|
||||
private static final String VERSION = "2.18.2";
|
||||
private static final String VERSION = "2.20.0";
|
||||
|
||||
public static void initialize() {
|
||||
File localizationFile = new File(plugin.getDataFolder().getAbsolutePath(), "Messages.yml");
|
||||
|
@ -21,6 +21,7 @@ public enum LocalizedMessage {
|
||||
CHANNEL_LIST_WITH_PERMISSIONS("ChannelListWithPermissions"),
|
||||
CHANNEL_NO_PERMISSION("ChannelNoPermission"),
|
||||
CHANNEL_NO_PERMISSION_VIEW("ChannelNoPermissionView"),
|
||||
CHANNEL_NO_SPEAK_PERMISSIONS("ChannelNoSpeakPermissions"),
|
||||
CHANNEL_PLAYER_LIST_HEADER("ChannelPlayerListHeader"),
|
||||
CHANNEL_MUTED("ChannelMuted"),
|
||||
COMMAND_INVALID_ARGUMENTS("CommandInvalidArguments"),
|
||||
|
@ -26,6 +26,13 @@ import mineverse.Aust1n46.chat.versions.VersionHandler;
|
||||
public class Format {
|
||||
private static MineverseChat plugin = MineverseChat.getInstance();
|
||||
|
||||
public static final int LEGACY_COLOR_CODE_LENGTH = 2;
|
||||
public static final int HEX_COLOR_CODE_LENGTH = 14;
|
||||
public static final String DEFAULT_COLOR_CODE = String.valueOf(ChatColor.WHITE);
|
||||
public static final String HEX_COLOR_CODE_PREFIX = "#";
|
||||
public static final String BUKKIT_COLOR_CODE_PREFIX = "§";
|
||||
public static final String BUKKIT_HEX_COLOR_CODE_PREFIX = "x";
|
||||
|
||||
public static String convertToJson(MineverseChatPlayer sender, String format, String chat) {
|
||||
JsonFormat JSONformat = MineverseChat.jfInfo.getJsonFormat(sender.getJsonFormat());
|
||||
String f = format.replace("\\", "\\\\").replace("\"", "\\\"");
|
||||
@ -36,10 +43,11 @@ public class Format {
|
||||
try {
|
||||
prefix = FormatStringAll(MineverseChat.chat.getPlayerPrefix(sender.getPlayer()));
|
||||
suffix = FormatStringAll(MineverseChat.chat.getPlayerSuffix(sender.getPlayer()));
|
||||
if(suffix.equals("")) {
|
||||
//Don't apply JSON if the prefix or suffix is just a color code
|
||||
if(suffix.isEmpty() || (suffix.length() == 2 && suffix.substring(1).matches("[0-9a-fA-F]"))) {
|
||||
suffix = "venturechat_no_suffix_code";
|
||||
}
|
||||
if(prefix.equals("")) {
|
||||
if(prefix.isEmpty() || (prefix.length() == 2 && prefix.substring(1).matches("[0-9a-fA-F]"))) {
|
||||
prefix = "venturechat_no_prefix_code";
|
||||
}
|
||||
}
|
||||
@ -91,26 +99,26 @@ public class Format {
|
||||
String hover = "";
|
||||
if(placeholder.contains(prefix)) {
|
||||
action = format.getClickPrefix();
|
||||
text = PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), format.getClickPrefixText());
|
||||
text = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), format.getClickPrefixText()));
|
||||
for(String st : format.getHoverTextPrefix()) {
|
||||
hover += Format.FormatStringAll(st) + "\n";
|
||||
}
|
||||
}
|
||||
if(placeholder.contains(nickname)) {
|
||||
action = format.getClickName();
|
||||
text = PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), format.getClickNameText());
|
||||
text = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), format.getClickNameText()));
|
||||
for(String st : format.getHoverTextName()) {
|
||||
hover += Format.FormatStringAll(st) + "\n";
|
||||
}
|
||||
}
|
||||
if(placeholder.contains(suffix)) {
|
||||
action = format.getClickSuffix();
|
||||
text = PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), format.getClickSuffixText());
|
||||
text = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), format.getClickSuffixText()));
|
||||
for(String st : format.getHoverTextSuffix()) {
|
||||
hover += Format.FormatStringAll(st) + "\n";
|
||||
}
|
||||
}
|
||||
hover = PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), hover.substring(0, hover.length() - 1));
|
||||
hover = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), hover.substring(0, hover.length() - 1)));
|
||||
temp += convertToJsonColors(lastCode + placeholder, ",\"clickEvent\":{\"action\":\"" + action + "\",\"value\":\"" + text + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(hover) + "]}}") + ",";
|
||||
lastCode = getLastCode(lastCode + placeholder);
|
||||
remaining = remaining.substring(indexEnd);
|
||||
@ -143,7 +151,7 @@ public class Format {
|
||||
String https = "";
|
||||
if(ChatColor.stripColor(link).contains("https://"))
|
||||
https = "s";
|
||||
temp += convertToJsonColors(lastCode + link, ",\"underlined\":\"" + plugin.getConfig().getBoolean("underlineurls", true) + "\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http" + https + "://" + ChatColor.stripColor(link.replace("http://", "").replace("https://", "")) + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(lastCode + link) + "]}}") + ",";
|
||||
temp += convertToJsonColors(lastCode + link, ",\"underlined\":\"" + underlineURLs() + "\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http" + https + "://" + ChatColor.stripColor(link.replace("http://", "").replace("https://", "")) + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(lastCode + link) + "]}}") + ",";
|
||||
lastCode = getLastCode(lastCode + link);
|
||||
remaining = remaining.substring(indexLinkEnd);
|
||||
}
|
||||
@ -160,16 +168,26 @@ public class Format {
|
||||
String ts = "";
|
||||
char[] ch = s.toCharArray();
|
||||
for(int a = 0; a < s.length() - 1; a ++) {
|
||||
if(String.valueOf(ch[a + 1]).matches("[lkonmr0123456789abcdef]") && ch[a] == '§') {
|
||||
if(String.valueOf(ch[a + 1]).matches("[lkomnLKOMN]") && ch[a] == '§') {
|
||||
ts += String.valueOf(ch[a]) + ch[a + 1];
|
||||
if(String.valueOf(ch[a + 1]).matches("[0123456789abcdefr]")) {
|
||||
ts = String.valueOf(ch[a]) + ch[a + 1];
|
||||
a ++;
|
||||
}
|
||||
else if(String.valueOf(ch[a + 1]).matches("[0123456789abcdefrABCDEFR]") && ch[a] == '§') {
|
||||
ts = String.valueOf(ch[a]) + ch[a + 1];
|
||||
a ++;
|
||||
}
|
||||
else if(ch[a + 1] == 'x' && ch[a] == '§') {
|
||||
if(ch.length > a + 13) {
|
||||
if(String.valueOf(ch[a + 3]).matches("[0123456789abcdefABCDEF]") && String.valueOf(ch[a + 5]).matches("[0123456789abcdefABCDEF]") && String.valueOf(ch[a + 7]).matches("[0123456789abcdefABCDEF]") && String.valueOf(ch[a + 9]).matches("[0123456789abcdefABCDEF]") && String.valueOf(ch[a + 11]).matches("[0123456789abcdefABCDEF]") && String.valueOf(ch[a + 13]).matches("[0123456789abcdefABCDEF]") && ch[a + 2] == '§' && ch[a + 4] == '§' && ch[a + 6] == '§' && ch[a + 8] == '§' && ch[a + 10] == '§' && ch[a + 12] == '§') {
|
||||
ts = String.valueOf(ch[a]) + ch[a + 1] + ch[a + 2] + ch[a + 3] + ch[a + 4] + ch[a + 5] + ch[a + 6] + ch[a + 7] + ch[a + 8] + ch[a + 9] + ch[a + 10] + ch[a + 11] + ch[a + 12] + ch[a + 13];
|
||||
a += 13;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
||||
private static String convertToJsonColors(String s) {
|
||||
return convertToJsonColors(s, "");
|
||||
}
|
||||
@ -184,46 +202,65 @@ public class Format {
|
||||
boolean bold = false;
|
||||
boolean obfuscated = false;
|
||||
boolean italic = false;
|
||||
boolean underlined = false;
|
||||
boolean strikethrough = false;
|
||||
boolean underlined = false;
|
||||
String previousColor = "";
|
||||
int colorLength = LEGACY_COLOR_CODE_LENGTH;
|
||||
do {
|
||||
if(remaining.length() < 2) {
|
||||
if(remaining.length() < LEGACY_COLOR_CODE_LENGTH) {
|
||||
temp = "{\"text\":\"" + remaining + "\"},";
|
||||
break;
|
||||
}
|
||||
modifier = "";
|
||||
indexColor = remaining.indexOf("§");
|
||||
indexColor = remaining.indexOf(BUKKIT_COLOR_CODE_PREFIX);
|
||||
previousColor = color;
|
||||
color = remaining.substring(1, indexColor + 2);
|
||||
if(!color.matches("[0123456789abcdef]")) {
|
||||
|
||||
color = remaining.substring(1, indexColor + LEGACY_COLOR_CODE_LENGTH);
|
||||
if(color.equals(BUKKIT_HEX_COLOR_CODE_PREFIX)) {
|
||||
if(remaining.length() >= HEX_COLOR_CODE_LENGTH) {
|
||||
color = HEX_COLOR_CODE_PREFIX + remaining.substring(LEGACY_COLOR_CODE_LENGTH, indexColor + HEX_COLOR_CODE_LENGTH).replace(BUKKIT_COLOR_CODE_PREFIX, "");
|
||||
colorLength = HEX_COLOR_CODE_LENGTH;
|
||||
bold = false;
|
||||
obfuscated = false;
|
||||
italic = false;
|
||||
strikethrough = false;
|
||||
underlined = false;
|
||||
}
|
||||
}
|
||||
else if(!color.matches("[0123456789abcdefABCDEF]")) {
|
||||
switch(color) {
|
||||
case "l": {
|
||||
case "l":
|
||||
case "L": {
|
||||
bold = true;
|
||||
break;
|
||||
}
|
||||
case "k": {
|
||||
case "k":
|
||||
case "K": {
|
||||
obfuscated = true;
|
||||
break;
|
||||
}
|
||||
case "o": {
|
||||
case "o":
|
||||
case "O": {
|
||||
italic = true;
|
||||
break;
|
||||
}
|
||||
case "n": {
|
||||
underlined = true;
|
||||
break;
|
||||
}
|
||||
case "m": {
|
||||
case "m":
|
||||
case "M": {
|
||||
strikethrough = true;
|
||||
break;
|
||||
}
|
||||
case "r": {
|
||||
case "n":
|
||||
case "N": {
|
||||
underlined = true;
|
||||
break;
|
||||
}
|
||||
case "r":
|
||||
case "R": {
|
||||
bold = false;
|
||||
obfuscated = false;
|
||||
italic = false;
|
||||
underlined = false;
|
||||
strikethrough = false;
|
||||
underlined = false;
|
||||
color = "f";
|
||||
break;
|
||||
}
|
||||
@ -237,8 +274,8 @@ public class Format {
|
||||
bold = false;
|
||||
obfuscated = false;
|
||||
italic = false;
|
||||
underlined = false;
|
||||
strikethrough = false;
|
||||
underlined = false;
|
||||
}
|
||||
if(bold)
|
||||
modifier += ",\"bold\":\"true\"";
|
||||
@ -250,12 +287,13 @@ public class Format {
|
||||
modifier += ",\"underlined\":\"true\"";
|
||||
if(strikethrough)
|
||||
modifier += ",\"strikethrough\":\"true\"";
|
||||
remaining = remaining.substring(2);
|
||||
indexNextColor = remaining.indexOf("§");
|
||||
remaining = remaining.substring(colorLength);
|
||||
colorLength = LEGACY_COLOR_CODE_LENGTH;
|
||||
indexNextColor = remaining.indexOf(BUKKIT_COLOR_CODE_PREFIX);
|
||||
if(indexNextColor == -1) {
|
||||
indexNextColor = remaining.length();
|
||||
}
|
||||
temp += "{\"text\":\"" + remaining.substring(0, indexNextColor) + "\",\"color\":\"" + hexidecimalToJsonColor(color) + "\"" + modifier + extensions + "},";
|
||||
temp += "{\"text\":\"" + remaining.substring(0, indexNextColor) + "\",\"color\":\"" + hexidecimalToJsonColorRGB(color) + "\"" + modifier + extensions + "},";
|
||||
remaining = remaining.substring(indexNextColor);
|
||||
}
|
||||
while(remaining.length() > 1 && indexColor != -1);
|
||||
@ -264,26 +302,38 @@ public class Format {
|
||||
return temp;
|
||||
}
|
||||
|
||||
private static String hexidecimalToJsonColor(String c) {
|
||||
switch(c) {
|
||||
case "0": return "black";
|
||||
case "1": return "dark_blue";
|
||||
case "2": return "dark_green";
|
||||
case "3": return "dark_aqua";
|
||||
case "4": return "dark_red";
|
||||
case "5": return "dark_purple";
|
||||
case "6": return "gold";
|
||||
case "7": return "gray";
|
||||
case "8": return "dark_gray";
|
||||
case "9": return "blue";
|
||||
case "a": return "green";
|
||||
case "b": return "aqua";
|
||||
case "c": return "red";
|
||||
case "d": return "light_purple";
|
||||
case "e": return "yellow";
|
||||
case "f": return "white";
|
||||
private static String hexidecimalToJsonColorRGB(String c) {
|
||||
if(c.length() == 1) {
|
||||
switch(c) {
|
||||
case "0": return "black";
|
||||
case "1": return "dark_blue";
|
||||
case "2": return "dark_green";
|
||||
case "3": return "dark_aqua";
|
||||
case "4": return "dark_red";
|
||||
case "5": return "dark_purple";
|
||||
case "6": return "gold";
|
||||
case "7": return "gray";
|
||||
case "8": return "dark_gray";
|
||||
case "9": return "blue";
|
||||
case "a":
|
||||
case "A": return "green";
|
||||
case "b":
|
||||
case "B": return "aqua";
|
||||
case "c":
|
||||
case "C": return "red";
|
||||
case "d":
|
||||
case "D": return "light_purple";
|
||||
case "e":
|
||||
case "E": return "yellow";
|
||||
case "f":
|
||||
case "F": return "white";
|
||||
default: return "white";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
if(isValidHexColor(c)) {
|
||||
return c;
|
||||
}
|
||||
return "white";
|
||||
}
|
||||
|
||||
public static String convertPlainTextToJson(String s, boolean convertURL) {
|
||||
@ -387,62 +437,42 @@ public class Format {
|
||||
}
|
||||
}
|
||||
|
||||
protected static Pattern chatColorPattern = Pattern.compile("(?i)&([0-9A-F])");
|
||||
protected static Pattern chatMagicPattern = Pattern.compile("(?i)&([K])");
|
||||
protected static Pattern chatBoldPattern = Pattern.compile("(?i)&([L])");
|
||||
protected static Pattern chatStrikethroughPattern = Pattern.compile("(?i)&([M])");
|
||||
protected static Pattern chatUnderlinePattern = Pattern.compile("(?i)&([N])");
|
||||
protected static Pattern chatItalicPattern = Pattern.compile("(?i)&([O])");
|
||||
protected static Pattern chatResetPattern = Pattern.compile("(?i)&([R])");
|
||||
protected static Pattern chatColorPattern = Pattern.compile("(?i)&([0-9])");
|
||||
|
||||
public static String FormatStringColor(String string) {
|
||||
String allFormated = string;
|
||||
allFormated = chatColorPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
|
||||
allFormated = allFormated.replaceAll("&[x]", "§x");
|
||||
allFormated = allFormated.replaceAll("&[aA]", "§a");
|
||||
allFormated = allFormated.replaceAll("&[bB]", "§b");
|
||||
allFormated = allFormated.replaceAll("&[cC]", "§c");
|
||||
allFormated = allFormated.replaceAll("&[dD]", "§d");
|
||||
allFormated = allFormated.replaceAll("&[eE]", "§e");
|
||||
allFormated = allFormated.replaceAll("&[fF]", "§f");
|
||||
|
||||
allFormated = allFormated.replaceAll("%", "\\%");
|
||||
|
||||
allFormated = convertHexColorCodeStringToBukkitColorCodeString(allFormated);
|
||||
return allFormated;
|
||||
}
|
||||
|
||||
public static String FormatString(String string) {
|
||||
String allFormated = string;
|
||||
allFormated = chatMagicPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = chatBoldPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = chatStrikethroughPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = chatUnderlinePattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = chatItalicPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = chatResetPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = allFormated.replaceAll("&[kK]", "§k");
|
||||
allFormated = allFormated.replaceAll("&[lL]", "§l");
|
||||
allFormated = allFormated.replaceAll("&[mM]", "§m");
|
||||
allFormated = allFormated.replaceAll("&[nN]", "§n");
|
||||
allFormated = allFormated.replaceAll("&[oO]", "§o");
|
||||
allFormated = allFormated.replaceAll("&[rR]", "§r");
|
||||
|
||||
allFormated = allFormated.replaceAll("%", "\\%");
|
||||
return allFormated;
|
||||
}
|
||||
|
||||
public static String FormatPlayerName(String playerPrefix, String playerDisplayName, String playerSuffix) {
|
||||
playerPrefix = chatColorPattern.matcher(playerPrefix).replaceAll("\u00A7$1");
|
||||
playerPrefix = chatMagicPattern.matcher(playerPrefix).replaceAll("\u00A7$1");
|
||||
playerPrefix = chatBoldPattern.matcher(playerPrefix).replaceAll("\u00A7$1");
|
||||
playerPrefix = chatStrikethroughPattern.matcher(playerPrefix).replaceAll("\u00A7$1");
|
||||
playerPrefix = chatUnderlinePattern.matcher(playerPrefix).replaceAll("\u00A7$1");
|
||||
playerPrefix = chatItalicPattern.matcher(playerPrefix).replaceAll("\u00A7$1");
|
||||
playerPrefix = chatResetPattern.matcher(playerPrefix).replaceAll("\u00A7$1");
|
||||
|
||||
playerSuffix = chatColorPattern.matcher(playerSuffix).replaceAll("\u00A7$1");
|
||||
playerSuffix = chatMagicPattern.matcher(playerSuffix).replaceAll("\u00A7$1");
|
||||
playerSuffix = chatBoldPattern.matcher(playerSuffix).replaceAll("\u00A7$1");
|
||||
playerSuffix = chatStrikethroughPattern.matcher(playerSuffix).replaceAll("\u00A7$1");
|
||||
playerSuffix = chatUnderlinePattern.matcher(playerSuffix).replaceAll("\u00A7$1");
|
||||
playerSuffix = chatItalicPattern.matcher(playerSuffix).replaceAll("\u00A7$1");
|
||||
playerSuffix = chatResetPattern.matcher(playerSuffix).replaceAll("\u00A7$1");
|
||||
return playerPrefix + playerDisplayName.trim() + playerSuffix;
|
||||
}
|
||||
|
||||
|
||||
public static String FormatStringAll(String string) {
|
||||
String allFormated = string;
|
||||
allFormated = chatColorPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = chatMagicPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = chatBoldPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = chatStrikethroughPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = chatUnderlinePattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = chatItalicPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = chatResetPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = allFormated.replaceAll("%", "\\%");
|
||||
String allFormated = Format.FormatString(string);
|
||||
allFormated = Format.FormatStringColor(allFormated);
|
||||
return allFormated;
|
||||
}
|
||||
|
||||
@ -465,7 +495,7 @@ public class Format {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public static Boolean isValidColor(String color) {
|
||||
public static boolean isValidColor(String color) {
|
||||
Boolean bFound = false;
|
||||
for(ChatColor bkColors : ChatColor.values()) {
|
||||
if(color.equalsIgnoreCase(bkColors.name())) {
|
||||
@ -475,7 +505,39 @@ public class Format {
|
||||
return bFound;
|
||||
}
|
||||
|
||||
public static boolean isValidHexColor(String color) {
|
||||
Pattern pattern = Pattern.compile("(^#[0-9a-fA-F]{6}\\b)");
|
||||
Matcher matcher = pattern.matcher(color);
|
||||
return matcher.find();
|
||||
}
|
||||
|
||||
public static String convertHexColorCodeToBukkitColorCode(String color) {
|
||||
StringBuilder bukkitColorCode = new StringBuilder(BUKKIT_COLOR_CODE_PREFIX + BUKKIT_HEX_COLOR_CODE_PREFIX);
|
||||
for(int a = 1; a < color.length(); a++) {
|
||||
bukkitColorCode.append(BUKKIT_COLOR_CODE_PREFIX + color.charAt(a));
|
||||
}
|
||||
return bukkitColorCode.toString().toLowerCase();
|
||||
}
|
||||
|
||||
public static String convertHexColorCodeStringToBukkitColorCodeString(String string) {
|
||||
Pattern pattern = Pattern.compile("(#[0-9a-fA-F]{6})");
|
||||
Matcher matcher = pattern.matcher(string);
|
||||
while(matcher.find()) {
|
||||
int indexStart = matcher.start();
|
||||
int indexEnd = matcher.end();
|
||||
String hexColor = string.substring(indexStart, indexEnd);
|
||||
String bukkitColor = convertHexColorCodeToBukkitColorCode(hexColor);
|
||||
string = string.replaceAll(hexColor, bukkitColor);
|
||||
matcher.reset(string);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public static String escapeAllRegex(String input) {
|
||||
return input.replace("[", "\\[").replace("]", "\\]").replace("{", "\\{").replace("}", "\\}").replace("(", "\\(").replace(")", "\\)").replace("|", "\\|").replace("+", "\\+").replace("*", "\\*");
|
||||
}
|
||||
|
||||
public static boolean underlineURLs() {
|
||||
return plugin.getConfig().getBoolean("underlineurls", true);
|
||||
}
|
||||
}
|
@ -81,6 +81,10 @@ public class VersionHandler {
|
||||
return Bukkit.getVersion().contains("1.15");
|
||||
}
|
||||
|
||||
public static boolean is1_16() {
|
||||
return Bukkit.getVersion().contains("1.16");
|
||||
}
|
||||
|
||||
public static boolean isCauldron() {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: VentureChat
|
||||
version: 2.18.4
|
||||
version: 2.20.0
|
||||
api-version: 1.13
|
||||
main: mineverse.Aust1n46.chat.MineverseChat
|
||||
depend: [Vault, ProtocolLib, PlaceholderAPI]
|
||||
@ -162,8 +162,8 @@ commands:
|
||||
aliases: [cb,vcommandblock]
|
||||
description: Toggle a player blocked from entering a command
|
||||
permission-message: You don't have <permission>
|
||||
nick:
|
||||
usage: /nick {player} [nickname]
|
||||
setnickname:
|
||||
usage: /setnickname {player} [nickname]
|
||||
aliases: [vnick]
|
||||
description: Set a players nickname
|
||||
permission-message: You don't have <permission>
|
||||
|
140
test/mineverse/Aust1n46/chat/utilities/FormatTest.java
Normal file
140
test/mineverse/Aust1n46/chat/utilities/FormatTest.java
Normal file
@ -0,0 +1,140 @@
|
||||
package mineverse.Aust1n46.chat.utilities;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import mineverse.Aust1n46.chat.MineverseChat;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest( { MineverseChat.class })
|
||||
public class FormatTest {
|
||||
|
||||
private MineverseChat mockPlugin;
|
||||
private FileConfiguration mockConfig;
|
||||
|
||||
private List<String> filters;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
filters = new ArrayList<String>();
|
||||
filters.add("ass,donut");
|
||||
|
||||
mockPlugin = Mockito.mock(MineverseChat.class);
|
||||
mockConfig = Mockito.mock(FileConfiguration.class);
|
||||
|
||||
PowerMockito.mockStatic(MineverseChat.class);
|
||||
PowerMockito.when(MineverseChat.getInstance()).thenReturn(mockPlugin);
|
||||
Mockito.when(mockPlugin.getConfig()).thenReturn(mockConfig);
|
||||
Mockito.when(mockConfig.getStringList("filters")).thenReturn(filters);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mockPlugin = null;
|
||||
mockConfig = null;
|
||||
filters = new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLastCodeSingleColor() {
|
||||
String input = "§cHello";
|
||||
String expectedResult = "§c";
|
||||
|
||||
String result = Format.getLastCode(input);
|
||||
|
||||
assertEquals(expectedResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLastCodeColorAfterFormat() {
|
||||
String input = "§o§cHello";
|
||||
String expectedResult = "§c";
|
||||
|
||||
String result = Format.getLastCode(input);
|
||||
|
||||
assertEquals(expectedResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLastCodeColorBeforeFormat() {
|
||||
String input = "§c§oHello";
|
||||
String expectedResult = "§c§o";
|
||||
|
||||
String result = Format.getLastCode(input);
|
||||
|
||||
assertEquals(expectedResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterChat() {
|
||||
String test = "I am an ass";
|
||||
String expectedResult = "I am an donut";
|
||||
|
||||
String result = Format.FilterChat(test);
|
||||
assertEquals(expectedResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsValidColor() {
|
||||
String color = "red";
|
||||
|
||||
boolean result = Format.isValidColor(color);
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsInvalidColor() {
|
||||
String color = "randomString";
|
||||
|
||||
boolean result = Format.isValidColor(color);
|
||||
assertFalse(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsValidHexColor() {
|
||||
String hexColor = "#ff00ff";
|
||||
|
||||
boolean result = Format.isValidHexColor(hexColor);
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsInvalidHexColor() {
|
||||
String hexColor = "#random";
|
||||
|
||||
boolean result = Format.isValidHexColor(hexColor);
|
||||
assertFalse(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertHexColorCodeToBukkitColorCode() {
|
||||
String hexColor = "#ff00ff";
|
||||
String expectedResult = "§x§f§f§0§0§f§f";
|
||||
|
||||
String result = Format.convertHexColorCodeToBukkitColorCode(hexColor);
|
||||
assertEquals(expectedResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertHexColorCodeStringToBukkitColorCodeString() {
|
||||
String input = "#ff00ffHello§cThere#00ff00Austin";
|
||||
String expectedResult = "§x§f§f§0§0§f§fHello§cThere§x§0§0§f§f§0§0Austin";
|
||||
|
||||
String result = Format.convertHexColorCodeStringToBukkitColorCodeString(input);
|
||||
assertEquals(expectedResult, result);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user