Let /saveskin ignore .png

This commit is contained in:
libraryaddict 2020-12-27 13:31:06 +13:00
parent b3274cc88b
commit 73d2d6b1a5

View File

@ -29,7 +29,9 @@ public class GrabSkinCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) { public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
if (sender instanceof Player && !sender.isOp() && if (sender instanceof Player && !sender.isOp() &&
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!"); sender.sendMessage(ChatColor.RED +
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " +
"non-admin usage!");
return true; return true;
} }
@ -54,8 +56,8 @@ public class GrabSkinCommand implements CommandExecutor {
return true; return true;
} }
if (tName == null && skin.matches("(.*\\/)?[a-zA-Z0-9_-]{3,20}\\.png")) { if (tName == null && skin.matches("(.*\\/)?[a-zA-Z0-9_-]{3,20}(\\.png)?")) {
tName = skin.substring(skin.lastIndexOf("/") + 1, skin.lastIndexOf(".")); tName = skin.substring(skin.lastIndexOf("/") + 1, skin.contains(".") ? skin.lastIndexOf(".") : skin.length());
if (DisguiseUtilities.hasGameProfile(tName)) { if (DisguiseUtilities.hasGameProfile(tName)) {
tName = null; tName = null;
@ -101,8 +103,7 @@ public class GrabSkinCommand implements CommandExecutor {
} }
if (profile.getName() == null || !profile.getName().equals(nName)) { if (profile.getName() == null || !profile.getName().equals(nName)) {
profile = ReflectionManager profile = ReflectionManager.getGameProfileWithThisSkin(profile.getUUID(), profile.getName(), profile);
.getGameProfileWithThisSkin(profile.getUUID(), profile.getName(), profile);
} }
DisguiseAPI.addGameProfile(nName, profile); DisguiseAPI.addGameProfile(nName, profile);
@ -112,32 +113,31 @@ public class GrabSkinCommand implements CommandExecutor {
int start = 0; int start = 0;
int msg = 1; int msg = 1;
//if (NmsVersion.v1_13.isSupported()) { //if (NmsVersion.v1_13.isSupported()) {
ComponentBuilder builder = new ComponentBuilder("").appendLegacy(LibsMsg.CLICK_TO_COPY.get()); ComponentBuilder builder = new ComponentBuilder("").appendLegacy(LibsMsg.CLICK_TO_COPY.get());
while (start < string.length()) { while (start < string.length()) {
int end = Math.min(256, string.length() - start); int end = Math.min(256, string.length() - start);
String sub = string.substring(start, start + end); String sub = string.substring(start, start + end);
builder.append(" "); builder.append(" ");
if (string.length() <= 256) { if (string.length() <= 256) {
builder.appendLegacy(LibsMsg.CLICK_TO_COPY_DATA.get()); builder.appendLegacy(LibsMsg.CLICK_TO_COPY_DATA.get());
} else { } else {
builder.reset(); builder.reset();
builder.appendLegacy(LibsMsg.CLICK_COPY.get(msg)); builder.appendLegacy(LibsMsg.CLICK_COPY.get(msg));
}
start += end;
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, sub));
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
new ComponentBuilder(LibsMsg.CLICK_TO_COPY_HOVER.get() + " " + msg).create()));
msg += 1;
} }
sender.spigot().sendMessage(builder.create()); start += end;
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, sub));
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(LibsMsg.CLICK_TO_COPY_HOVER.get() + " " + msg).create()));
msg += 1;
}
sender.spigot().sendMessage(builder.create());
/*} else { /*} else {
LibsMsg.SKIN_DATA.send(sender, string); LibsMsg.SKIN_DATA.send(sender, string);
}*/ }*/