forked from Upstream/CommandPanels
3.15.5.6
This commit is contained in:
parent
08691c557f
commit
a2f84d4f72
@ -34,6 +34,9 @@ config:
|
|||||||
error: '&cError found in config.'
|
error: '&cError found in config.'
|
||||||
offline: 'Offline'
|
offline: 'Offline'
|
||||||
offlineHeadValue: 'eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmU1Mjg2YzQ3MGY2NmZmYTFhMTgzMzFjYmZmYjlhM2MyYTQ0MjRhOGM3MjU5YzQ0MzZmZDJlMzU1ODJhNTIyIn19fQ=='
|
offlineHeadValue: 'eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmU1Mjg2YzQ3MGY2NmZmYTFhMTgzMzFjYmZmYjlhM2MyYTQ0MjRhOGM3MjU5YzQ0MzZmZDJlMzU1ODJhNTIyIn19fQ=='
|
||||||
|
hexcodes:
|
||||||
|
start_tag: '#'
|
||||||
|
end_tag: ''
|
||||||
updater:
|
updater:
|
||||||
auto-update: true
|
auto-update: true
|
||||||
minor-updates-only: true
|
minor-updates-only: true
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version: 3.15.5.6
|
version: 3.15.6.0
|
||||||
main: me.rockyhawk.commandpanels.CommandPanels
|
main: me.rockyhawk.commandpanels.CommandPanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -9,6 +9,7 @@ import me.rockyhawk.commandpanels.classresources.ItemCreation;
|
|||||||
import me.rockyhawk.commandpanels.classresources.OpenEditorGuis;
|
import me.rockyhawk.commandpanels.classresources.OpenEditorGuis;
|
||||||
import me.rockyhawk.commandpanels.classresources.item_fall.ItemFallManager;
|
import me.rockyhawk.commandpanels.classresources.item_fall.ItemFallManager;
|
||||||
import me.rockyhawk.commandpanels.classresources.placeholders.CreateText;
|
import me.rockyhawk.commandpanels.classresources.placeholders.CreateText;
|
||||||
|
import me.rockyhawk.commandpanels.classresources.placeholders.HexColours;
|
||||||
import me.rockyhawk.commandpanels.classresources.placeholders.Placeholders;
|
import me.rockyhawk.commandpanels.classresources.placeholders.Placeholders;
|
||||||
import me.rockyhawk.commandpanels.commands.*;
|
import me.rockyhawk.commandpanels.commands.*;
|
||||||
import me.rockyhawk.commandpanels.commandtags.CommandTags;
|
import me.rockyhawk.commandpanels.commandtags.CommandTags;
|
||||||
@ -62,8 +63,6 @@ import java.io.InputStream;
|
|||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class CommandPanels extends JavaPlugin{
|
public class CommandPanels extends JavaPlugin{
|
||||||
public YamlConfiguration config;
|
public YamlConfiguration config;
|
||||||
@ -84,6 +83,7 @@ public class CommandPanels extends JavaPlugin{
|
|||||||
public Placeholders placeholders = new Placeholders(this);
|
public Placeholders placeholders = new Placeholders(this);
|
||||||
public DebugManager debug = new DebugManager(this);
|
public DebugManager debug = new DebugManager(this);
|
||||||
public CreateText tex = new CreateText(this);
|
public CreateText tex = new CreateText(this);
|
||||||
|
public HexColours hex = new HexColours(this);
|
||||||
|
|
||||||
public OpenEditorGuis editorGuis = new OpenEditorGuis(this);
|
public OpenEditorGuis editorGuis = new OpenEditorGuis(this);
|
||||||
public ExecuteOpenVoids openVoids = new ExecuteOpenVoids(this);
|
public ExecuteOpenVoids openVoids = new ExecuteOpenVoids(this);
|
||||||
@ -463,22 +463,6 @@ public class CommandPanels extends JavaPlugin{
|
|||||||
return r.nextInt((max - min) + 1) + min;
|
return r.nextInt((max - min) + 1) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
//used to translate hex colours into ChatColors
|
|
||||||
public String translateHexColorCodes(String message) {
|
|
||||||
final Pattern hexPattern = Pattern.compile("#" + "([A-Fa-f0-9]{6})");
|
|
||||||
Matcher matcher = hexPattern.matcher(message);
|
|
||||||
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
|
|
||||||
while (matcher.find()) {
|
|
||||||
String group = matcher.group(1);
|
|
||||||
matcher.appendReplacement(buffer, ChatColor.COLOR_CHAR + "x"
|
|
||||||
+ ChatColor.COLOR_CHAR + group.charAt(0) + ChatColor.COLOR_CHAR + group.charAt(1)
|
|
||||||
+ ChatColor.COLOR_CHAR + group.charAt(2) + ChatColor.COLOR_CHAR + group.charAt(3)
|
|
||||||
+ ChatColor.COLOR_CHAR + group.charAt(4) + ChatColor.COLOR_CHAR + group.charAt(5)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return matcher.appendTail(buffer).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
//returns true if the item is the MMO Item
|
//returns true if the item is the MMO Item
|
||||||
public boolean isMMOItem(ItemStack itm, String type, String id){
|
public boolean isMMOItem(ItemStack itm, String type, String id){
|
||||||
try {
|
try {
|
||||||
|
@ -70,7 +70,7 @@ public class CreateText {
|
|||||||
//change colour
|
//change colour
|
||||||
for(String temp : setpapi){
|
for(String temp : setpapi){
|
||||||
try {
|
try {
|
||||||
setpapi.set(tempInt, plugin.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', temp)));
|
setpapi.set(tempInt, plugin.hex.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', temp)));
|
||||||
}catch(NullPointerException ignore){
|
}catch(NullPointerException ignore){
|
||||||
}
|
}
|
||||||
tempInt += 1;
|
tempInt += 1;
|
||||||
@ -81,7 +81,7 @@ public class CreateText {
|
|||||||
//regular string papi, but only colours so Player doesn't need to be there
|
//regular string papi, but only colours so Player doesn't need to be there
|
||||||
public String papi(String setpapi) {
|
public String papi(String setpapi) {
|
||||||
try {
|
try {
|
||||||
setpapi = plugin.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
|
setpapi = plugin.hex.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
|
||||||
return setpapi;
|
return setpapi;
|
||||||
}catch(NullPointerException e){
|
}catch(NullPointerException e){
|
||||||
return setpapi;
|
return setpapi;
|
||||||
@ -110,7 +110,7 @@ public class CreateText {
|
|||||||
OfflinePlayer offp = plugin.getServer().getOfflinePlayer(p.getUniqueId());
|
OfflinePlayer offp = plugin.getServer().getOfflinePlayer(p.getUniqueId());
|
||||||
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
|
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
|
||||||
}
|
}
|
||||||
setpapi = plugin.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
|
setpapi = plugin.hex.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
|
||||||
return setpapi;
|
return setpapi;
|
||||||
}catch(NullPointerException e){
|
}catch(NullPointerException e){
|
||||||
return setpapi;
|
return setpapi;
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
package me.rockyhawk.commandpanels.classresources.placeholders;
|
||||||
|
|
||||||
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class HexColours {
|
||||||
|
CommandPanels plugin;
|
||||||
|
public HexColours(CommandPanels pl) {
|
||||||
|
this.plugin = pl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String translateHexColorCodes(String message) {
|
||||||
|
//add all the different HEX combinations, in order to ensure they do not cancel each other out
|
||||||
|
message = doTranslation(message,formatRegex("hexcodes.start_tag"),formatRegex("hexcodes.end_tag"));
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
//used to translate hex colours into ChatColors
|
||||||
|
private String doTranslation(String message, String startTag, String endTag) {
|
||||||
|
//final Pattern hexPattern = Pattern.compile("#" + "([A-Fa-f0-9]{6})");
|
||||||
|
final Pattern hexPattern = Pattern.compile(startTag + "([A-Fa-f0-9]{6})" + endTag);
|
||||||
|
Matcher matcher = hexPattern.matcher(message);
|
||||||
|
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
|
||||||
|
while (matcher.find()) {
|
||||||
|
String group = matcher.group(1);
|
||||||
|
matcher.appendReplacement(buffer, ChatColor.COLOR_CHAR + "x"
|
||||||
|
+ ChatColor.COLOR_CHAR + group.charAt(0) + ChatColor.COLOR_CHAR + group.charAt(1)
|
||||||
|
+ ChatColor.COLOR_CHAR + group.charAt(2) + ChatColor.COLOR_CHAR + group.charAt(3)
|
||||||
|
+ ChatColor.COLOR_CHAR + group.charAt(4) + ChatColor.COLOR_CHAR + group.charAt(5)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return matcher.appendTail(buffer).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
//automatically format regex to escape special characters
|
||||||
|
public String formatRegex(String path){
|
||||||
|
String inputString = plugin.config.getString(path);
|
||||||
|
final String[] metaCharacters = {"\\","^","$","{","}","[","]","(",")",".","*","+","?","|","<",">","-","&","%"};
|
||||||
|
|
||||||
|
for (String metaCharacter : metaCharacters) {
|
||||||
|
assert inputString != null;
|
||||||
|
if (inputString.contains(metaCharacter)) {
|
||||||
|
inputString = inputString.replace(metaCharacter, "\\" + metaCharacter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return inputString;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user