Allows console to use socialspy, fixed stripcolor (again)
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
command socialspy {
|
command socialspy {
|
||||||
format {
|
format {
|
||||||
|
run format_show;
|
||||||
|
help Displays your current format;
|
||||||
|
}
|
||||||
|
format --default {
|
||||||
run config_format_default;
|
run config_format_default;
|
||||||
help Resets your format back to the default: &e%s;
|
help Resets your format back to the default: &e%s;
|
||||||
}
|
}
|
||||||
@@ -45,17 +49,20 @@ command socialspy {
|
|||||||
}
|
}
|
||||||
on {
|
on {
|
||||||
run on;
|
run on;
|
||||||
|
type player;
|
||||||
}
|
}
|
||||||
off {
|
off {
|
||||||
run off;
|
run off;
|
||||||
|
type player;
|
||||||
}
|
}
|
||||||
[empty] {
|
[empty] {
|
||||||
run toggle;
|
run toggle;
|
||||||
|
type player;
|
||||||
}
|
}
|
||||||
perm utils.socialspy;
|
perm utils.socialspy;
|
||||||
type player;
|
|
||||||
migrate {
|
migrate {
|
||||||
run migrate;
|
run migrate;
|
||||||
type console;
|
type console;
|
||||||
}
|
}
|
||||||
|
type all;
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ import com.redstoner.modules.datamanager.DataManager;
|
|||||||
import net.nemez.chatapi.click.Message;
|
import net.nemez.chatapi.click.Message;
|
||||||
|
|
||||||
@Commands(CommandHolderType.File)
|
@Commands(CommandHolderType.File)
|
||||||
@Version(major = 4, minor = 0, revision = 1, compatible = 4)
|
@Version(major = 4, minor = 0, revision = 2, compatible = 4)
|
||||||
public class Socialspy implements CoreModule
|
public class Socialspy implements CoreModule
|
||||||
{
|
{
|
||||||
@Command(hook = "config_prefix_default")
|
@Command(hook = "config_prefix_default")
|
||||||
@@ -48,6 +48,14 @@ public class Socialspy implements CoreModule
|
|||||||
return configFormat(sender, getDefaultFormat());
|
return configFormat(sender, getDefaultFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(hook = "config_format_show")
|
||||||
|
public boolean configFormatShow(CommandSender sender, String format)
|
||||||
|
{
|
||||||
|
DataManager.getOrDefault(sender, "format", getDefaultFormat());
|
||||||
|
getLogger().message(sender, "Your current format is: " + format.replaceAll("[&§]", "&&"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Command(hook = "config_format")
|
@Command(hook = "config_format")
|
||||||
public boolean configFormat(CommandSender sender, String format)
|
public boolean configFormat(CommandSender sender, String format)
|
||||||
{
|
{
|
||||||
@@ -209,6 +217,13 @@ public class Socialspy implements CoreModule
|
|||||||
else
|
else
|
||||||
DataManager.setData(sender, "enabled", false);
|
DataManager.setData(sender, "enabled", false);
|
||||||
}
|
}
|
||||||
|
if (((JSONArray) DataManager.getOrDefault(Bukkit.getConsoleSender(), "commands", getDefaultCommandList()))
|
||||||
|
.contains(command))
|
||||||
|
{
|
||||||
|
Message m = new Message(Bukkit.getConsoleSender(), null);
|
||||||
|
m.appendText(formatMessage(Bukkit.getConsoleSender(), sender, target, message, command));
|
||||||
|
m.send();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void spyBroadcast(CommandSender sender, String target, String message, String command,
|
public static void spyBroadcast(CommandSender sender, String target, String message, String command,
|
||||||
@@ -246,26 +261,18 @@ public class Socialspy implements CoreModule
|
|||||||
else
|
else
|
||||||
DataManager.setData(sender, "enabled", false);
|
DataManager.setData(sender, "enabled", false);
|
||||||
}
|
}
|
||||||
|
if (((JSONArray) DataManager.getOrDefault(Bukkit.getConsoleSender(), "commands", getDefaultCommandList()))
|
||||||
|
.contains(command))
|
||||||
|
{
|
||||||
|
Message m = new Message(Bukkit.getConsoleSender(), null);
|
||||||
|
m.appendText(formatMessage(Bukkit.getConsoleSender(), sender, target, message, command));
|
||||||
|
m.send();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatMessage(CommandSender formatHolder, CommandSender sender, CommandSender target, String message,
|
private String formatMessage(CommandSender formatHolder, CommandSender sender, CommandSender target, String message,
|
||||||
String command)
|
String command)
|
||||||
{
|
{
|
||||||
Object o = DataManager.getOrDefault(formatHolder, "stripcolor", "off");
|
|
||||||
if (o instanceof Boolean)
|
|
||||||
{
|
|
||||||
boolean b = (boolean) o;
|
|
||||||
if (b)
|
|
||||||
o = "on";
|
|
||||||
else
|
|
||||||
o = "off";
|
|
||||||
DataManager.setData(formatHolder, "stripcolor", o);
|
|
||||||
}
|
|
||||||
String s = (String) o;
|
|
||||||
if (s.equals("on"))
|
|
||||||
message = ChatColor.stripColor(message);
|
|
||||||
else if (s.equals("partial"))
|
|
||||||
message = message.replace("§", "&&");
|
|
||||||
String format = (String) DataManager.getOrDefault(formatHolder, "format", getDefaultFormat());
|
String format = (String) DataManager.getOrDefault(formatHolder, "format", getDefaultFormat());
|
||||||
// Replace escaped % with placeholder
|
// Replace escaped % with placeholder
|
||||||
format = format.replace("%%", "§§");
|
format = format.replace("%%", "§§");
|
||||||
@@ -285,12 +292,7 @@ public class Socialspy implements CoreModule
|
|||||||
format = format.replace("%m", message);
|
format = format.replace("%m", message);
|
||||||
// Convert placeholder back
|
// Convert placeholder back
|
||||||
format = format.replace("§§", "%");
|
format = format.replace("§§", "%");
|
||||||
return format;
|
// Color stripping
|
||||||
}
|
|
||||||
|
|
||||||
private String formatMessage(CommandSender formatHolder, CommandSender sender, String target, String message,
|
|
||||||
String command)
|
|
||||||
{
|
|
||||||
Object o = DataManager.getOrDefault(formatHolder, "stripcolor", "off");
|
Object o = DataManager.getOrDefault(formatHolder, "stripcolor", "off");
|
||||||
if (o instanceof Boolean)
|
if (o instanceof Boolean)
|
||||||
{
|
{
|
||||||
@@ -305,7 +307,13 @@ public class Socialspy implements CoreModule
|
|||||||
if (s.equals("on"))
|
if (s.equals("on"))
|
||||||
message = ChatColor.stripColor(message);
|
message = ChatColor.stripColor(message);
|
||||||
else if (s.equals("partial"))
|
else if (s.equals("partial"))
|
||||||
message = message.replace("§", "&&");
|
message = message.replaceAll("[§&]", "&&");
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatMessage(CommandSender formatHolder, CommandSender sender, String target, String message,
|
||||||
|
String command)
|
||||||
|
{
|
||||||
String format = (String) DataManager.getOrDefault(formatHolder, "format", getDefaultFormat());
|
String format = (String) DataManager.getOrDefault(formatHolder, "format", getDefaultFormat());
|
||||||
// Replace escaped % with placeholder
|
// Replace escaped % with placeholder
|
||||||
format = format.replace("%%", "§§");
|
format = format.replace("%%", "§§");
|
||||||
@@ -325,6 +333,22 @@ public class Socialspy implements CoreModule
|
|||||||
format = format.replace("%m", message);
|
format = format.replace("%m", message);
|
||||||
// Convert placeholder back
|
// Convert placeholder back
|
||||||
format = format.replace("§§", "%");
|
format = format.replace("§§", "%");
|
||||||
|
// Color stripping
|
||||||
|
Object o = DataManager.getOrDefault(formatHolder, "stripcolor", "off");
|
||||||
|
if (o instanceof Boolean)
|
||||||
|
{
|
||||||
|
boolean b = (boolean) o;
|
||||||
|
if (b)
|
||||||
|
o = "on";
|
||||||
|
else
|
||||||
|
o = "off";
|
||||||
|
DataManager.setData(formatHolder, "stripcolor", o);
|
||||||
|
}
|
||||||
|
String s = (String) o;
|
||||||
|
if (s.equals("on"))
|
||||||
|
message = ChatColor.stripColor(message);
|
||||||
|
else if (s.equals("partial"))
|
||||||
|
message = message.replaceAll("[§&]", "&&");
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user