mirror of
https://github.com/IHasName/CustomHeads.git
synced 2025-02-17 19:21:28 +01:00
Update to API and more
This commit is contained in:
parent
136f141c25
commit
cb5d387a9e
4
pom.xml
4
pom.xml
@ -4,9 +4,9 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>de.mrstein.customheads</groupId>
|
||||
<groupId>de.likewhat.customheads</groupId>
|
||||
<artifactId>CustomHeads</artifactId>
|
||||
<version>2.9.8</version>
|
||||
<version>2.9.9</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
|
@ -1,24 +1,24 @@
|
||||
package de.mrstein.customheads;
|
||||
package de.likewhat.customheads;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import de.mrstein.customheads.api.CustomHeadsAPI;
|
||||
import de.mrstein.customheads.api.CustomHeadsPlayer;
|
||||
import de.mrstein.customheads.category.Category;
|
||||
import de.mrstein.customheads.category.CategoryManager;
|
||||
import de.mrstein.customheads.economy.EconomyManager;
|
||||
import de.mrstein.customheads.headwriter.HeadFontType;
|
||||
import de.mrstein.customheads.listener.InventoryListener;
|
||||
import de.mrstein.customheads.listener.OtherListeners;
|
||||
import de.mrstein.customheads.loader.Language;
|
||||
import de.mrstein.customheads.loader.Looks;
|
||||
import de.mrstein.customheads.reflection.TagEditor;
|
||||
import de.mrstein.customheads.stuff.CHCommand;
|
||||
import de.mrstein.customheads.stuff.CHTabCompleter;
|
||||
import de.mrstein.customheads.updaters.AsyncFileDownloader;
|
||||
import de.mrstein.customheads.updaters.GitHubDownloader;
|
||||
import de.mrstein.customheads.updaters.SpigetFetcher;
|
||||
import de.mrstein.customheads.utils.*;
|
||||
import de.likewhat.customheads.api.CustomHeadsAPI;
|
||||
import de.likewhat.customheads.api.CustomHeadsPlayer;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.CategoryManager;
|
||||
import de.likewhat.customheads.economy.EconomyManager;
|
||||
import de.likewhat.customheads.headwriter.HeadFontType;
|
||||
import de.likewhat.customheads.listener.InventoryListener;
|
||||
import de.likewhat.customheads.listener.OtherListeners;
|
||||
import de.likewhat.customheads.loader.Language;
|
||||
import de.likewhat.customheads.loader.Looks;
|
||||
import de.likewhat.customheads.utils.*;
|
||||
import de.likewhat.customheads.utils.reflection.TagEditor;
|
||||
import de.likewhat.customheads.utils.stuff.CHCommand;
|
||||
import de.likewhat.customheads.utils.stuff.CHTabCompleter;
|
||||
import de.likewhat.customheads.utils.updaters.AsyncFileDownloader;
|
||||
import de.likewhat.customheads.utils.updaters.GitHubDownloader;
|
||||
import de.likewhat.customheads.utils.updaters.SpigetFetcher;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -28,6 +28,7 @@ import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@ -35,7 +36,7 @@ import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static de.mrstein.customheads.utils.Utils.hasPermission;
|
||||
import static de.likewhat.customheads.utils.Utils.hasPermission;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in CustomHeads
|
||||
@ -54,7 +55,7 @@ public class CustomHeads extends JavaPlugin {
|
||||
public static int hisOverflow = 18;
|
||||
@Getter private static Configs updateFile;
|
||||
@Getter private static Configs headsConfig;
|
||||
@Getter private static Configs categoryLoaderConfig;
|
||||
// @Getter private static Configs categoryLoaderConfig;
|
||||
@Getter private static JsonFile playerDataFile;
|
||||
@Getter private static Looks looks;
|
||||
@Getter private static CustomHeads instance;
|
||||
@ -64,11 +65,11 @@ public class CustomHeads extends JavaPlugin {
|
||||
@Getter private static SpigetFetcher spigetFetcher;
|
||||
@Getter private static EconomyManager economyManager;
|
||||
@Getter private static CategoryManager categoryManager;
|
||||
private static List<String> versions = Arrays.asList("v1_8_R1", "v1_8_R2", "v1_8_R3", "v1_9_R1", "v1_9_R2", "v1_10_R1", "v1_11_R1", "v1_12_R1", "v1_13_R1", "v1_13_R2", "v1_14_R1");
|
||||
private static List<String> versions = Arrays.asList("v1_8_R1", "v1_8_R2", "v1_8_R3", "v1_9_R1", "v1_9_R2", "v1_10_R1", "v1_11_R1", "v1_12_R1", "v1_13_R1", "v1_13_R2", "v1_14_R1", "v1_15_R1");
|
||||
private static String packet = Bukkit.getServer().getClass().getPackage().getName();
|
||||
public static String version = packet.substring(packet.lastIndexOf('.') + 1);
|
||||
|
||||
public static final boolean USETEXTURES = versions.contains(version);
|
||||
public static final boolean USE_TEXTURES = versions.contains(version);
|
||||
private static boolean keepCategoryPermissions = false;
|
||||
private static boolean categoriesBuyable = false;
|
||||
private static boolean headsPermanentBuy = false;
|
||||
@ -147,6 +148,7 @@ public class CustomHeads extends JavaPlugin {
|
||||
return reducedDebug;
|
||||
}
|
||||
|
||||
|
||||
public static boolean reload(CommandSender sender) {
|
||||
boolean console = sender instanceof ConsoleCommandSender;
|
||||
sender.sendMessage((console ? chPrefix : "") + languageManager.RELOAD_CONFIG);
|
||||
@ -189,7 +191,7 @@ public class CustomHeads extends JavaPlugin {
|
||||
|
||||
public void onDisable() {
|
||||
if (isInit) {
|
||||
OtherListeners.saveLoc.values().forEach(loc -> loc.getBlock().setType(Material.AIR));
|
||||
OtherListeners.CACHED_LOCATIONS.values().forEach(loc -> loc.getBlock().setType(Material.AIR));
|
||||
PlayerWrapper.clearCache();
|
||||
}
|
||||
}
|
||||
@ -225,8 +227,9 @@ public class CustomHeads extends JavaPlugin {
|
||||
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
if(BETA)
|
||||
getServer().getConsoleSender().sendMessage("\n \n" + chWarning + "This is a Beta Version of the Plugin! Please update it as soon as the Project gets updated\n ");
|
||||
if(BETA) {
|
||||
getServer().getConsoleSender().sendMessage("[CustomHeads]\n§e=============================================================================================\nThis is a Beta Version of the Plugin! Please update it as soon as a new Version gets released\n=============================================================================================");
|
||||
}
|
||||
File oldHeadFile;
|
||||
if ((oldHeadFile = new File("plugins/CustomHeads", "heads.yml")).exists()) {
|
||||
oldHeadFile.renameTo(new File("plugins/CustomHeads", "config.yml"));
|
||||
@ -260,11 +263,11 @@ public class CustomHeads extends JavaPlugin {
|
||||
gitHubDownloader.download(getDescription().getVersion(), "en_EN.zip", new File(getDataFolder(), "language"), (AsyncFileDownloader.AfterTask) () -> {
|
||||
getServer().getConsoleSender().sendMessage(chPrefix + "§7Done downloading! Have fun with the Plugin =D");
|
||||
getServer().getConsoleSender().sendMessage(chPrefix + "§7---------------------------------------------");
|
||||
new BukkitRunnable() {
|
||||
Utils.runSynced(new BukkitRunnable() {
|
||||
public void run() {
|
||||
loadRest();
|
||||
}
|
||||
}.runTask(instance);
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@ -280,7 +283,7 @@ public class CustomHeads extends JavaPlugin {
|
||||
categoriesBuyable = headsConfig.get().getBoolean("economy.category.buyable");
|
||||
headsBuyable = headsConfig.get().getBoolean("economy.heads.buyable");
|
||||
headsPermanentBuy = headsConfig.get().getBoolean("economy.heads.permanentBuy");
|
||||
categoryLoaderConfig = new Configs(instance, "loadedCategories.yml", true);
|
||||
// categoryLoaderConfig = new Configs(instance, "loadedCategories.yml", true);
|
||||
|
||||
tagEditor = new TagEditor("chTags");
|
||||
|
||||
@ -289,7 +292,7 @@ public class CustomHeads extends JavaPlugin {
|
||||
// Convert old Head-Data if present
|
||||
playerDataFile = new JsonFile("playerData.json");
|
||||
if (headsConfig.get().contains("heads")) {
|
||||
Bukkit.getConsoleSender().sendMessage(chPrefix + "Found old Head Data! Trying to convertFromJson...");
|
||||
Bukkit.getConsoleSender().sendMessage(chPrefix + "Found old Head Data! Trying to convert...");
|
||||
convertOldHeadData();
|
||||
}
|
||||
|
||||
@ -302,9 +305,21 @@ public class CustomHeads extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
// Register Inventory Listener
|
||||
getServer().getPluginManager().registerEvents(new InventoryListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new OtherListeners(), this);
|
||||
// Add Category Permissions
|
||||
PluginManager manager = getServer().getPluginManager();
|
||||
// categoryManager.getCategoryList().forEach(category -> {
|
||||
// System.out.println("Adding Permission: " + category.getPermission());
|
||||
// Permission categoryPermission = new Permission(category.getPermission() + ".allheads");
|
||||
// categoryPermission.getChildren().put(category.getPermission(), true);
|
||||
// categoryPermission.addParent(category.getPermission() + ".allheads", false);
|
||||
// manager.addPermission(categoryPermission);
|
||||
// });
|
||||
|
||||
// Register Listeners
|
||||
manager.registerEvents(new InventoryListener(), this);
|
||||
manager.registerEvents(new OtherListeners(), this);
|
||||
// TODO Implement after 2.9.9 Update
|
||||
// manager.registerEvents(new CategoryEditorListener(), this);
|
||||
|
||||
// Setting up APIHandler
|
||||
api = new APIHandler();
|
||||
@ -332,9 +347,9 @@ public class CustomHeads extends JavaPlugin {
|
||||
}
|
||||
});
|
||||
|
||||
if (!USETEXTURES) {
|
||||
getServer().getConsoleSender().sendMessage(chWarning + "Uh oh. Seems like your Server Version " + bukkitVersion + " is not compatable with CustomHeads");
|
||||
getServer().getConsoleSender().sendMessage(chWarning + "I'll disable Custom Textures from Skulls to prevent any Bugs but don't worry only Effects /heads add");
|
||||
if (!USE_TEXTURES) {
|
||||
getServer().getConsoleSender().sendMessage(chWarning + "Hrm. Seems like CustomHeads wasn't tested on this Minecraft Version yet...");
|
||||
getServer().getConsoleSender().sendMessage(chWarning + "Please report this to me on Discord (Link's on the Spigot Page)");
|
||||
}
|
||||
|
||||
initMetrics();
|
||||
@ -382,7 +397,9 @@ public class CustomHeads extends JavaPlugin {
|
||||
contentItem = nextIcon;
|
||||
}
|
||||
}
|
||||
inventoryContent[i] = CustomHeads.getTagEditor().addTags(contentItem, "menuID", CustomHeads.getLooks().getIDbyTitle(player.getOpenInventory().getTitle()));
|
||||
if(tagEditor.hasMyTags(contentItem)) {
|
||||
inventoryContent[i] = CustomHeads.getTagEditor().addTags(contentItem, "menuID", CustomHeads.getLooks().getIDbyTitle(player.getOpenInventory().getTitle()));
|
||||
}
|
||||
}
|
||||
player.getOpenInventory().getTopInventory().setContents(inventoryContent);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.api;
|
||||
package de.likewhat.customheads.api;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in CustomHeadsAPI
|
||||
@ -7,9 +7,9 @@ package de.mrstein.customheads.api;
|
||||
* created on 20.08.2018 at 22:48
|
||||
*/
|
||||
|
||||
import de.mrstein.customheads.category.Category;
|
||||
import de.mrstein.customheads.category.CustomHead;
|
||||
import de.mrstein.customheads.headwriter.HeadFontType;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.CustomHead;
|
||||
import de.likewhat.customheads.headwriter.HeadFontType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.api;
|
||||
package de.likewhat.customheads.api;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in CustomHeadsPlayer
|
||||
@ -7,10 +7,10 @@ package de.mrstein.customheads.api;
|
||||
* created on 20.08.2018 at 17:14
|
||||
*/
|
||||
|
||||
import de.mrstein.customheads.category.Category;
|
||||
import de.mrstein.customheads.category.CustomHead;
|
||||
import de.mrstein.customheads.stuff.GetHistory;
|
||||
import de.mrstein.customheads.stuff.SearchHistory;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.CustomHead;
|
||||
import de.likewhat.customheads.utils.stuff.GetHistory;
|
||||
import de.likewhat.customheads.utils.stuff.SearchHistory;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.category;
|
||||
package de.likewhat.customheads.category;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
@ -1,10 +1,10 @@
|
||||
package de.mrstein.customheads.category;
|
||||
package de.likewhat.customheads.category;
|
||||
|
||||
import com.google.gson.*;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.utils.ItemEditor;
|
||||
import de.mrstein.customheads.utils.JsonToItem;
|
||||
import de.mrstein.customheads.utils.Utils;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.utils.JsonToItem;
|
||||
import de.likewhat.customheads.utils.Utils;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -28,7 +28,7 @@ import java.util.stream.Collectors;
|
||||
public class Category extends BaseCategory {
|
||||
|
||||
private static final Gson CATEGORY_TO_JSON = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().registerTypeAdapter(Category.class, new Serializer()).registerTypeAdapter(SubCategory.class, new SubCategory.Serializer()).create();
|
||||
public static int counter = 0;
|
||||
// public static int counter = 0;
|
||||
private int lastID = 1;
|
||||
|
||||
private List<SubCategory> subCategories;
|
||||
@ -127,7 +127,8 @@ public class Category extends BaseCategory {
|
||||
private int checkID(int id) {
|
||||
if (heads.stream().map(CustomHead::getId).collect(Collectors.toList()).contains(id)) {
|
||||
int newID = nextID();
|
||||
Bukkit.getLogger().warning("Duplicate ID " + id + "... Replacing with " + newID);
|
||||
if(!CustomHeads.hasReducedDebug())
|
||||
Bukkit.getLogger().warning("Duplicate or duplicate ID: " + id + ". Replacing with " + newID);
|
||||
return newID;
|
||||
}
|
||||
return id;
|
||||
@ -215,7 +216,7 @@ public class Category extends BaseCategory {
|
||||
//Sub Category Info Header
|
||||
categoryObject.addProperty("id", Integer.parseInt(category.getId().contains(":") ? category.getId().split(":")[0] : category.getId()));
|
||||
categoryObject.addProperty("name", category.getName());
|
||||
categoryObject.addProperty("permission", category.getPermission().replace("heads.viewCategory.", ""));
|
||||
categoryObject.addProperty("permission", category.getPermission().replaceFirst("heads.viewCategory.", ""));
|
||||
categoryObject.addProperty("fixed-icon", category.isFixedIcon());
|
||||
if (category.hasCategoryIcon())
|
||||
categoryObject.add("icon", new JsonParser().parse(JsonToItem.convertToJson(category.getCategoryIcon())));
|
@ -1,8 +1,8 @@
|
||||
package de.mrstein.customheads.category;
|
||||
package de.likewhat.customheads.category;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.utils.ItemEditor;
|
||||
import de.mrstein.customheads.utils.JsonFile;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.utils.JsonFile;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -16,7 +16,6 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in CategoryLoader
|
||||
@ -44,11 +43,6 @@ public class CategoryManager {
|
||||
int loaded = 0;
|
||||
int ignored = 0;
|
||||
int invalid = 0;
|
||||
if (!CustomHeads.hasReducedDebug())
|
||||
CustomHeads.getInstance().getServer().getConsoleSender().sendMessage(CustomHeads.chPrefix + "Loading " + CustomHeads.getCategoryLoaderConfig().get().getList("categories").size() + " Categories from " + language + "/categories");
|
||||
long timestamp = System.currentTimeMillis();
|
||||
CustomHeads.getCategoryLoaderConfig().reload();
|
||||
boolean ignoreInvalid = CustomHeads.getCategoryLoaderConfig().get().getBoolean("ignoreInvalid");
|
||||
|
||||
File langRootDir = new File("plugins/CustomHeads/language/" + language + "/categories");
|
||||
if (langRootDir.listFiles() == null) {
|
||||
@ -57,20 +51,28 @@ public class CategoryManager {
|
||||
return;
|
||||
}
|
||||
|
||||
List<File> fileList = Arrays.stream(langRootDir.listFiles()).filter(file -> file.getName().endsWith(".json") && CustomHeads.getCategoryLoaderConfig().get().getList("categories").contains(file.getName().substring(0, file.getName().lastIndexOf(".")))).collect(Collectors.toList());
|
||||
|
||||
//boolean ignoreInvalid = CustomHeads.getCategoryLoaderConfig().get().getBoolean("ignoreInvalid");
|
||||
|
||||
List<File> fileList = Arrays.asList(langRootDir.listFiles((dir, name) -> name.endsWith(".json") && !CustomHeads.getHeadsConfig().get().getList("disabledCategories").contains(name.substring(0, name.lastIndexOf(".")))));
|
||||
|
||||
if (!CustomHeads.hasReducedDebug())
|
||||
CustomHeads.getInstance().getServer().getConsoleSender().sendMessage(CustomHeads.chPrefix + "Loading " + fileList.size() + " Categories from " + language + "/categories");
|
||||
long timestamp = System.currentTimeMillis();
|
||||
CustomHeads.getHeadsConfig().reload();
|
||||
|
||||
for (File file : fileList) {
|
||||
JsonFile jsf = new JsonFile(file);
|
||||
ignored = CustomHeads.getCategoryLoaderConfig().get().getList("categories").size() - fileList.size();
|
||||
ignored = fileList.size() - CustomHeads.getHeadsConfig().get().getList("disabledCategories").size();
|
||||
try {
|
||||
Category category = Category.getConverter().fromJson(jsf.getJson(), Category.class);
|
||||
if (category == null) {
|
||||
if (ignoreInvalid) {
|
||||
//if (ignoreInvalid) {
|
||||
invalid++;
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(CustomHeads.chWarning + " Invalid Category in " + file.getName());
|
||||
} else {
|
||||
/*} else {
|
||||
throw new NullPointerException("Invalid Category in " + file.getName());
|
||||
}
|
||||
}*/
|
||||
} else {
|
||||
if (categories.containsKey(category.getId())) {
|
||||
CustomHeads.getInstance().getServer().getConsoleSender().sendMessage(CustomHeads.chWarning + file.getName() + ": §cAn Category with ID " + category.getId() + " (" + categories.get(category.getId()).getName() + ") already exists.");
|
||||
@ -91,17 +93,17 @@ public class CategoryManager {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (ignoreInvalid) {
|
||||
/*if (ignoreInvalid) {
|
||||
invalid++;
|
||||
} else {
|
||||
} else {*/
|
||||
CustomHeads.getInstance().getLogger().log(Level.WARNING, "Something went wrong while loading Category File " + file.getName(), e);
|
||||
return;
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
if (!CustomHeads.hasReducedDebug())
|
||||
CustomHeads.getInstance().getServer().getConsoleSender().sendMessage(CustomHeads.chPrefix + "Successfully loaded " + loaded + " Categories and " + getAllHeads().size() + " Heads from " + language + "/categories in " + (System.currentTimeMillis() - timestamp) + "ms " + (ignoreInvalid ? "(" + (ignored + invalid) + " " + ((ignored + invalid) == 1 ? "Category was" : "Categories were") + " ignored - " + ignored + " not loaded or not found, " + (invalid > 0 ? "§c" : "") + invalid + " Invalid§7)" : ""));
|
||||
CustomHeads.getInstance().getServer().getConsoleSender().sendMessage(CustomHeads.chPrefix + "Successfully loaded " + loaded + " Categories and " + getAllHeads().size() + " Heads from " + language + "/categories in " + (System.currentTimeMillis() - timestamp) + "ms (" + (ignored + invalid) + " " + ((ignored + invalid) == 1 ? "Category was" : "Categories were") + " ignored - " + ignored + " not loaded or not found, " + (invalid > 0 ? "§c" : "") + invalid + " Invalid§7)");
|
||||
CategoryManager.loaded = true;
|
||||
}
|
||||
|
||||
@ -137,10 +139,16 @@ public class CategoryManager {
|
||||
subCategories.put(subCategory.getId(), subCategory);
|
||||
}
|
||||
}
|
||||
List<String> disabledCategories = CustomHeads.getHeadsConfig().get().isList("disabledCategories") ? CustomHeads.getHeadsConfig().get().getStringList("disabledCategories") : new ArrayList<>();
|
||||
disabledCategories.add(file.getName().substring(0, file.getName().lastIndexOf(".")));
|
||||
CustomHeads.getHeadsConfig().get().set("disabledCategories", disabledCategories);
|
||||
CustomHeads.getHeadsConfig().save();
|
||||
/*
|
||||
List<String> loadedCategories = CustomHeads.getCategoryLoaderConfig().get().isList("categories") ? CustomHeads.getCategoryLoaderConfig().get().getStringList("categories") : new ArrayList<>();
|
||||
loadedCategories.add(file.getName().substring(0, file.getName().lastIndexOf(".")));
|
||||
CustomHeads.getCategoryLoaderConfig().get().set("categories", loadedCategories);
|
||||
CustomHeads.getCategoryLoaderConfig().save();
|
||||
*/
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CustomHeads.getInstance().getLogger().log(Level.WARNING, "Something went wrong while loading Category File " + file.getName(), e);
|
||||
@ -158,11 +166,18 @@ public class CategoryManager {
|
||||
public boolean removeCategory(Category category) {
|
||||
if (categories.containsKey(category.getId())) {
|
||||
categories.remove(category.getId());
|
||||
List<String> disabledCategories = CustomHeads.getHeadsConfig().get().isList("disabledCategories") ? CustomHeads.getHeadsConfig().get().getStringList("disabledCategories") : new ArrayList<>();
|
||||
disabledCategories.remove(CustomHeads.getCategoryManager().getSourceFile(category).getName().substring(0, CustomHeads.getCategoryManager().getSourceFile(category).getName().lastIndexOf(".")));
|
||||
CustomHeads.getHeadsConfig().get().set("disabledCategories", disabledCategories);
|
||||
CustomHeads.getHeadsConfig().save();
|
||||
return true;
|
||||
/*
|
||||
List<String> loadedCategories = CustomHeads.getCategoryLoaderConfig().get().isList("categories") ? CustomHeads.getCategoryLoaderConfig().get().getStringList("categories") : new ArrayList<>();
|
||||
loadedCategories.remove(CustomHeads.getCategoryManager().getSourceFile(category).getName().substring(0, CustomHeads.getCategoryManager().getSourceFile(category).getName().lastIndexOf(".")));
|
||||
CustomHeads.getCategoryLoaderConfig().get().set("categories", loadedCategories);
|
||||
CustomHeads.getCategoryLoaderConfig().save();
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
return false;
|
||||
}
|
@ -0,0 +1,189 @@
|
||||
package de.likewhat.customheads.category;
|
||||
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.utils.Utils;
|
||||
import de.likewhat.customheads.utils.reflection.AnvilGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in CategorySetup
|
||||
* by LikeWhat
|
||||
*
|
||||
* created on 23.09.2019 at 10:33
|
||||
*/
|
||||
public class CategorySetup {
|
||||
|
||||
private Category category;
|
||||
private Inventory setupInventory;
|
||||
|
||||
private ItemStack changeNameItem;
|
||||
private ItemStack changeIconItem;
|
||||
private ItemStack changePriceItem;
|
||||
private ItemStack changeDescriptionItem;
|
||||
|
||||
private int price;
|
||||
private String name;
|
||||
private ItemStack icon;
|
||||
private String description;
|
||||
|
||||
public static final HashMap<Player, CategorySetup> OPENED_SETUPS = new HashMap<>();
|
||||
|
||||
public static CategorySetup createCategory(String name) {
|
||||
return new CategorySetup(CustomHeads.getCategoryManager().createCategory(name));
|
||||
}
|
||||
|
||||
private CategorySetup(Category category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
if(setupInventory != null)
|
||||
return;
|
||||
|
||||
setupInventory = Bukkit.createInventory(null, 9*4, "Category Setup " + category.getPlainName());
|
||||
ItemStack createItem = new ItemEditor(Material.SKULL_ITEM, (byte)3).setDisplayName("§aCreate").setTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTMwZjQ1MzdkMjE0ZDM4NjY2ZTYzMDRlOWM4NTFjZDZmN2U0MWEwZWI3YzI1MDQ5YzlkMjJjOGM1ZjY1NDVkZiJ9fX0=").getItem();
|
||||
ItemStack cancelItem = new ItemEditor(Material.SKULL_ITEM, (byte)3).setDisplayName("§cCancel").setTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWE2Nzg3YmEzMjU2NGU3YzJmM2EwY2U2NDQ5OGVjYmIyM2I4OTg0NWU1YTY2YjVjZWM3NzM2ZjcyOWVkMzcifX19").getItem();
|
||||
setupInventory.setItem(27, cancelItem);
|
||||
setupInventory.setItem(35, createItem);
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new Listener() {
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if(!event.getClickedInventory().equals(setupInventory)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack clicked = event.getCurrentItem();
|
||||
if(clicked.equals(changeIconItem)) {
|
||||
if(event.getCursor() != null && event.getCursor().getType() != Material.AIR) {
|
||||
changeIcon(event.getCursor());
|
||||
player.setItemOnCursor(null);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
if(clicked.equals(changePriceItem)) {
|
||||
AnvilGUI anvilGUI = new AnvilGUI(player, "Category Setup", new AnvilGUI.AnvilClickEventHandler() {
|
||||
public void onAnvilClick(AnvilGUI.AnvilClickEvent anvilClickEvent) {
|
||||
event.setCancelled(true);
|
||||
|
||||
if(!Utils.isNumber(anvilClickEvent.getName())) {
|
||||
return;
|
||||
}
|
||||
changePrice(Integer.parseInt(anvilClickEvent.getName()));
|
||||
openInventory(player);
|
||||
}
|
||||
|
||||
public void onAnvilClose() {
|
||||
|
||||
}
|
||||
});
|
||||
anvilGUI.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, new ItemEditor(Material.PAPER).setDisplayName(String.valueOf(price)).getItem());
|
||||
anvilGUI.open();
|
||||
player.updateInventory();
|
||||
}
|
||||
if(clicked.equals(changeNameItem)) {
|
||||
AnvilGUI anvilGUI = new AnvilGUI(player, "Category Setup", new AnvilGUI.AnvilClickEventHandler() {
|
||||
public void onAnvilClick(AnvilGUI.AnvilClickEvent anvilClickEvent) {
|
||||
event.setCancelled(true);
|
||||
if(anvilClickEvent.getName().length() > 16 || anvilClickEvent.getName().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
changeName(anvilClickEvent.getName());
|
||||
openInventory(player);
|
||||
}
|
||||
|
||||
public void onAnvilClose() {
|
||||
|
||||
}
|
||||
});
|
||||
anvilGUI.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, new ItemEditor(Material.PAPER).setDisplayName(name).getItem());
|
||||
anvilGUI.open();
|
||||
player.updateInventory();
|
||||
}
|
||||
if(clicked.equals(changeDescriptionItem)) {
|
||||
AnvilGUI anvilGUI = new AnvilGUI(player, "Category Setup", new AnvilGUI.AnvilClickEventHandler() {
|
||||
public void onAnvilClick(AnvilGUI.AnvilClickEvent anvilClickEvent) {
|
||||
event.setCancelled(true);
|
||||
if(anvilClickEvent.getName().length() > 32 || anvilClickEvent.getName().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
changeDescription(anvilClickEvent.getName());
|
||||
openInventory(player);
|
||||
}
|
||||
|
||||
public void onAnvilClose() {
|
||||
|
||||
}
|
||||
});
|
||||
anvilGUI.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, new ItemEditor(Material.PAPER).setDisplayName(description).getItem());
|
||||
anvilGUI.open();
|
||||
player.updateInventory();
|
||||
}
|
||||
if(clicked.equals(cancelItem)) {
|
||||
HandlerList.unregisterAll(this);
|
||||
player.closeInventory();
|
||||
}
|
||||
if(clicked.equals(createItem)) {
|
||||
category.setName(name);
|
||||
category.setPrice(price);
|
||||
category.setIcons(Arrays.asList(new ItemEditor(icon).setDisplayName(name).setLore(description).getItem()));
|
||||
CustomHeads.getCategoryManager().updateCategory(category, CustomHeads.getLanguageManager().getCurrentLanguage());
|
||||
CustomHeads.reload();
|
||||
player.closeInventory();
|
||||
player.sendMessage("Successfully created Category");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
if(!event.getInventory().equals(setupInventory)) {
|
||||
return;
|
||||
}
|
||||
OPENED_SETUPS.remove(event.getPlayer());
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}, CustomHeads.getInstance());
|
||||
}
|
||||
|
||||
private void changeIcon(ItemStack newIcon) {
|
||||
setupInventory.setItem(10, changeIconItem = icon = new ItemEditor(newIcon).setDisplayName("§aChange Icon").setLore("§7Drag your Icon here\n§7to change it").getItem());
|
||||
}
|
||||
|
||||
private void changeName(String newName) {
|
||||
setupInventory.setItem(12, changeNameItem = new ItemEditor(Material.PAPER).setDisplayName("§aChange Name").setLore("§7Current:\n§e" + (name = newName)).getItem());
|
||||
}
|
||||
|
||||
private void changePrice(int newPrice) {
|
||||
setupInventory.setItem(14, changePriceItem = new ItemEditor(Material.EMERALD).setDisplayName("§aChange Price").setLore("§7Current:\n§e" + (price = newPrice)).getItem());
|
||||
}
|
||||
|
||||
private void changeDescription(String newDescription) {
|
||||
setupInventory.setItem(16, changeDescriptionItem = new ItemEditor(Material.PAPER).setDisplayName("§aChange Description").setLore("§7Current:\n§e" + (description = newDescription)).getItem());
|
||||
}
|
||||
|
||||
public void openInventory(Player player) {
|
||||
registerListeners();
|
||||
changeIcon(new ItemStack(Material.BARRIER));
|
||||
changeName(category.getName());
|
||||
changePrice(category.getPrice());
|
||||
changeDescription("Default Description");
|
||||
|
||||
OPENED_SETUPS.put(player, this);
|
||||
player.openInventory(setupInventory);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.category;
|
||||
package de.likewhat.customheads.category;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in CustomHead
|
||||
@ -7,10 +7,10 @@ package de.mrstein.customheads.category;
|
||||
* created on 21.11.2018 at 22:43
|
||||
*/
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.api.CustomHeadsPlayer;
|
||||
import de.mrstein.customheads.reflection.TagEditor;
|
||||
import de.mrstein.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.api.CustomHeadsPlayer;
|
||||
import de.likewhat.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.utils.reflection.TagEditor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -1,9 +1,9 @@
|
||||
package de.mrstein.customheads.category;
|
||||
package de.likewhat.customheads.category;
|
||||
|
||||
import com.google.gson.*;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.utils.ItemEditor;
|
||||
import de.mrstein.customheads.utils.JsonToItem;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.utils.JsonToItem;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -1,15 +1,15 @@
|
||||
package de.mrstein.customheads.economy;
|
||||
package de.likewhat.customheads.economy;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.api.CustomHeadsPlayer;
|
||||
import de.mrstein.customheads.category.Category;
|
||||
import de.mrstein.customheads.category.CustomHead;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.api.CustomHeadsPlayer;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.CustomHead;
|
||||
import lombok.Getter;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import static de.mrstein.customheads.utils.Utils.openCategory;
|
||||
import static de.likewhat.customheads.utils.Utils.openCategory;
|
||||
import static org.bukkit.Bukkit.getServer;
|
||||
|
||||
/*
|
@ -1,9 +1,9 @@
|
||||
package de.mrstein.customheads.headwriter;
|
||||
package de.likewhat.customheads.headwriter;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.utils.Configs;
|
||||
import de.mrstein.customheads.utils.ItemEditor;
|
||||
import de.mrstein.customheads.utils.Utils;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.utils.Configs;
|
||||
import de.likewhat.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.utils.Utils;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Material;
|
@ -1,7 +1,7 @@
|
||||
package de.mrstein.customheads.headwriter;
|
||||
package de.likewhat.customheads.headwriter;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.utils.ItemEditor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@ -17,8 +17,8 @@ import java.util.logging.Level;
|
||||
|
||||
public class HeadWriter {
|
||||
|
||||
private static BlockFace[] axisshifted = {BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH};
|
||||
private static BlockFace[] axis = {BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH, BlockFace.EAST};
|
||||
private static final BlockFace[] AXIS_SHIFTED = {BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH};
|
||||
private static final BlockFace[] AXIS = {BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH, BlockFace.EAST};
|
||||
|
||||
private static HashMap<Player, String> undoList = new HashMap<>();
|
||||
|
||||
@ -40,7 +40,7 @@ public class HeadWriter {
|
||||
}
|
||||
|
||||
public static void undoWriting(Player player, int times, Player sendTo) {
|
||||
int timesSucessful = 0;
|
||||
int timesSuccessful = 0;
|
||||
for (int i = 0; i < times; i++) {
|
||||
if (undoList.containsKey(player)) {
|
||||
if (undoList.containsKey(player)) {
|
||||
@ -55,11 +55,11 @@ public class HeadWriter {
|
||||
} else {
|
||||
undoList.put(player, undoList.get(player).substring(0, undoList.get(player).lastIndexOf("/#/")));
|
||||
}
|
||||
timesSucessful++;
|
||||
timesSuccessful++;
|
||||
}
|
||||
}
|
||||
}
|
||||
sendTo.sendMessage(timesSucessful == 0 ? CustomHeads.getLanguageManager().UNDO_NOTHING_LEFT : timesSucessful == 1 ? CustomHeads.getLanguageManager().UNDO_SUCCESSFUL.replace("{TIMES}", "") : CustomHeads.getLanguageManager().UNDO_SUCCESSFUL.replace("{TIMES}", "(" + timesSucessful + "x)"));
|
||||
sendTo.sendMessage(timesSuccessful == 0 ? CustomHeads.getLanguageManager().UNDO_NOTHING_LEFT : timesSuccessful == 1 ? CustomHeads.getLanguageManager().UNDO_SUCCESSFUL.replace("{TIMES}", "") : CustomHeads.getLanguageManager().UNDO_SUCCESSFUL.replace("{TIMES}", "(" + timesSuccessful + "x)"));
|
||||
}
|
||||
|
||||
public void writeAt(Location location) {
|
||||
@ -77,8 +77,8 @@ public class HeadWriter {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().WRITE_WRITING.replace("{TEXT}", text));
|
||||
}
|
||||
Location loc = location;
|
||||
int faceindex = Math.round((location.getYaw() * (-1)) / 90f) & 0x3;
|
||||
BlockFace face = axis[faceindex].getOppositeFace();
|
||||
int faceIndex = Math.round((location.getYaw() * (-1)) / 90f) & 0x3;
|
||||
BlockFace face = AXIS[faceIndex].getOppositeFace();
|
||||
loc = loc.getBlock().getLocation().add(face.getModX(), face.getModY(), face.getModZ());
|
||||
|
||||
if (recHis) {
|
||||
@ -93,7 +93,7 @@ public class HeadWriter {
|
||||
}
|
||||
}
|
||||
try {
|
||||
CustomHeads.getApi().setSkull(loc.getBlock(), new ItemEditor(fontType.getCharacter(text.charAt(i))).getTexture(), axis[Math.round((location.getYaw() * (-1)) / 90f) & 0x3]);
|
||||
CustomHeads.getApi().setSkull(loc.getBlock(), new ItemEditor(fontType.getCharacter(text.charAt(i))).getTexture(), AXIS[Math.round((location.getYaw() * (-1)) / 90f) & 0x3]);
|
||||
} catch (Exception e) {
|
||||
if (recHis) {
|
||||
player.sendMessage("§cUnsupported Character at collum " + (i + 1) + ": " + text.charAt(i));
|
||||
@ -102,8 +102,8 @@ public class HeadWriter {
|
||||
}
|
||||
}
|
||||
|
||||
BlockFace bface = axisshifted[faceindex].getOppositeFace();
|
||||
loc = loc.getBlock().getLocation().add(bface.getModX(), bface.getModY(), bface.getModZ());
|
||||
BlockFace bFace = AXIS_SHIFTED[faceIndex].getOppositeFace();
|
||||
loc = loc.getBlock().getLocation().add(bFace.getModX(), bFace.getModY(), bFace.getModZ());
|
||||
}
|
||||
if (recHis) {
|
||||
undoList.put(player, repBlock.toString());
|
@ -0,0 +1,277 @@
|
||||
package de.likewhat.customheads.listener;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in CategoryEditorListener
|
||||
* by LikeWhat
|
||||
*
|
||||
* created on 27.10.2019 at 15:42
|
||||
*/
|
||||
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.category.BaseCategory;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.CategorySetup;
|
||||
import de.likewhat.customheads.category.SubCategory;
|
||||
import de.likewhat.customheads.utils.CategoryEditor;
|
||||
import de.likewhat.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.utils.Utils;
|
||||
import de.likewhat.customheads.utils.reflection.AnvilGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static de.likewhat.customheads.utils.Utils.hasPermission;
|
||||
|
||||
// TODO Implement after 2.9.9
|
||||
public class CategoryEditorListener implements Listener {
|
||||
|
||||
private HashMap<UUID, String> cachedPlayers = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onEvent(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (event.getInventory() == null || event.getRawSlot() > event.getInventory().getSize() || event.getCurrentItem() == null || !hasPermission(player, "heads.admin"))
|
||||
return;
|
||||
if (CustomHeads.getTagEditor().getTags(event.getCurrentItem()).contains("cEditor")) {
|
||||
String[] args = CustomHeads.getTagEditor().getTags(event.getCurrentItem()).get(CustomHeads.getTagEditor().indexOf(event.getCurrentItem(), "cEditor") + 1).split("#>");
|
||||
|
||||
player.sendMessage("CEditor: §7" + CustomHeads.getTagEditor().getTags(event.getCurrentItem()));
|
||||
|
||||
switch (args[0]) {
|
||||
case "create":
|
||||
event.setCancelled(true);
|
||||
AnvilGUI anvilGUI = new AnvilGUI(player, "Name your Category", new AnvilGUI.AnvilClickEventHandler() {
|
||||
public void onAnvilClick(AnvilGUI.AnvilClickEvent anvilClickEvent) {
|
||||
event.setCancelled(true);
|
||||
if (anvilClickEvent.getName().length() > 16 || anvilClickEvent.getName().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
CategorySetup.createCategory(anvilClickEvent.getName()).openInventory(player);
|
||||
}
|
||||
|
||||
public void onAnvilClose() {
|
||||
|
||||
}
|
||||
});
|
||||
anvilGUI.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, new ItemEditor(Material.PAPER).setDisplayName("Category Name").getItem());
|
||||
anvilGUI.open();
|
||||
player.updateInventory();
|
||||
break;
|
||||
case "edit":
|
||||
event.setCancelled(true);
|
||||
if (cachedPlayers.containsKey(player.getUniqueId()) && cachedPlayers.get(player.getUniqueId()).contains("selectCategory")) {
|
||||
String[] actionSplitted = cachedPlayers.get(player.getUniqueId()).split("#>");
|
||||
Category category = CustomHeads.getCategoryManager().getCategory(actionSplitted[1]);
|
||||
if (category != null) {
|
||||
CategoryEditor editor = new CategoryEditor(category, player);
|
||||
editor.showCategoryInfos();
|
||||
cachedPlayers.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "delete":
|
||||
event.setCancelled(true);
|
||||
if (args.length < 2) {
|
||||
if (cachedPlayers.containsKey(player.getUniqueId()) && cachedPlayers.get(player.getUniqueId()).contains("selectCategory")) {
|
||||
String[] actionSplitted = cachedPlayers.get(player.getUniqueId()).split("#>");
|
||||
BaseCategory category = Utils.getBaseCategory(actionSplitted[1]);
|
||||
player.openInventory(Utils.getDialog("Delete " + category.getName(), new String[]{"cEditor", "confirmDelete"}, new String[]{"This Action cannot be undone!"}, new String[]{"cEditor", "open#>cOverview"}, null, category.isCategory() ? category.getAsCategory().getCategoryIcon() : category.getAsSubCategory().getCategoryIcon()));
|
||||
// player.openInventory(Utils.getDeleteInventory(category, new String[]{"cEditor", "open#>cOverview"}));
|
||||
}
|
||||
} else {
|
||||
|
||||
/*
|
||||
* ----------------------------
|
||||
* |0 |1 |2 |3 |4 |5 |6 |7 |8 |
|
||||
* |9 |10|11|12|13|14|15|16|17|
|
||||
* |18|19|20|21|22|23|24|25|26|
|
||||
* ----------------------------
|
||||
* */
|
||||
|
||||
if (args[1].equals("category")) {
|
||||
Category category = CustomHeads.getCategoryManager().getCategory(args[2]);
|
||||
if (category != null) {
|
||||
player.openInventory(Utils.getDialog("Delete " + category.getName(), new String[]{"cEditor", "confirmDelete"}, new String[]{"This Action cannot be undone!"}, new String[]{"cEditor", "openInfo#>" + category.getId()}, null, category.getCategoryIcon()));
|
||||
//player.openInventory(Utils.getDeleteInventory(category, new String[]{"cEditor", "openInfo#>" + category.getId()}));
|
||||
}
|
||||
return;
|
||||
} else if (args[1].equals("subCategory")) {
|
||||
SubCategory subCategory = CustomHeads.getCategoryManager().getSubCategory(args[2]);
|
||||
if (subCategory != null) {
|
||||
player.openInventory(Utils.getDialog("Delete " + subCategory.getName(), new String[]{"cEditor", "confirmDelete"}, new String[]{"This Action cannot be undone!"}, new String[]{"cEditor", "openInfo#>" + subCategory.getId()}, null, subCategory.getCategoryIcon()));
|
||||
// player.openInventory(Utils.getDeleteInventory(subCategory, new String[]{"cEditor", "openInfo#>" + subCategory.getId()}));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "open":
|
||||
event.setCancelled(true);
|
||||
if (args[1].equals("cOverview")) {
|
||||
CategoryEditor.openCategoryOverview(player);
|
||||
}
|
||||
break;
|
||||
case "convert":
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
case "blockMoving":
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
case "openInfo": {
|
||||
event.setCancelled(true);
|
||||
Category category = CustomHeads.getCategoryManager().getCategory(args[1]);
|
||||
if (category != null) {
|
||||
player.sendMessage(args[1]);
|
||||
CategoryEditor editor = new CategoryEditor(category, player);
|
||||
editor.showCategoryInfos();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "confirmDelete":
|
||||
// cEditor confirmDelete#>category/subCategory#>id
|
||||
if (args[1].equals("category")) {
|
||||
Category category = CustomHeads.getCategoryManager().getCategory(args[2]);
|
||||
CategoryEditor.openCategoryOverview(player);
|
||||
if (CustomHeads.getCategoryManager().deleteCategory(category)) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
return;
|
||||
} else if (args[1].equals("subCategory")) {
|
||||
SubCategory subCategory = CustomHeads.getCategoryManager().getSubCategory(args[2]);
|
||||
CategoryEditor.openCategoryOverview(player);
|
||||
if (CustomHeads.getCategoryManager().deleteSubCategory(subCategory)) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "selectCategory":
|
||||
String action;
|
||||
if (cachedPlayers.containsKey(player.getUniqueId()) && (action = cachedPlayers.get(player.getUniqueId())).contains("selectCategory#>")) {
|
||||
String[] actionSplitted = action.split("#>");
|
||||
if (actionSplitted[1].equals(args[1])) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
int invIndex = Integer.parseInt(actionSplitted[2]);
|
||||
ItemEditor item = new ItemEditor(event.getInventory().getItem(invIndex));
|
||||
event.getInventory().setItem(invIndex, item.setDisplayName(item.getDisplayName().substring(0, item.getDisplayName().lastIndexOf(":") - 3)).getItem());
|
||||
}
|
||||
ItemEditor item = new ItemEditor(event.getCurrentItem());
|
||||
event.setCurrentItem(item.setDisplayName(item.getDisplayName() + " §7: §aSelected").getItem());
|
||||
cachedPlayers.put(player.getUniqueId(), "selectCategory#>" + args[1] + "#>" + event.getSlot());
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
case "rename":
|
||||
if (args[1].equalsIgnoreCase("category")) {
|
||||
Category category = CustomHeads.getCategoryManager().getCategory(args[2]);
|
||||
if (category != null) {
|
||||
AnvilGUI gui = new AnvilGUI(player, "Rename Category", new AnvilGUI.AnvilClickEventHandler() {
|
||||
public void onAnvilClick(AnvilGUI.AnvilClickEvent anvilClickEvent) {
|
||||
anvilClickEvent.setCancelled(true);
|
||||
if (anvilClickEvent.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
|
||||
if (anvilClickEvent.getName().equals("")) {
|
||||
return;
|
||||
}
|
||||
if (anvilClickEvent.getName().length() > 16) {
|
||||
anvilClickEvent.getPlayer().sendMessage("§eCEdit: §7Name cannot be longer than §c16 §7Characters");
|
||||
return;
|
||||
}
|
||||
String newCategoryName = ChatColor.stripColor(Utils.format(anvilClickEvent.getName()));
|
||||
category.setName(newCategoryName);
|
||||
category.setPermission(newCategoryName.toLowerCase().replace(" ", "_"));
|
||||
|
||||
// Rewrite Category File
|
||||
File categoryFile = CustomHeads.getCategoryManager().getSourceFile(category);
|
||||
try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(categoryFile), StandardCharsets.UTF_8)) {
|
||||
writer.write(category.toString());
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to rewrite " + category.getName(), e);
|
||||
}
|
||||
player.sendMessage("§eCEdit: §7Successfully renamed Category to §a" + newCategoryName);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnvilClose() {
|
||||
CategorySetup.OPENED_SETUPS.get(player).openInventory(player);
|
||||
}
|
||||
});
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.OUTPUT, new ItemEditor(Material.PAPER).setDisplayName(category.getPlainName()).setLore("§7Set the Name of this Category").getItem());
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, new ItemEditor(Material.PAPER).setDisplayName(category.getPlainName()).setLore("§7Set the Name of this Category").getItem());
|
||||
gui.open();
|
||||
player.updateInventory();
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("subCategory")) {
|
||||
SubCategory subCategory = CustomHeads.getCategoryManager().getSubCategory(args[2]);
|
||||
if (subCategory != null) {
|
||||
AnvilGUI gui = new AnvilGUI(player, "Rename Subcategory", new AnvilGUI.AnvilClickEventHandler() {
|
||||
public void onAnvilClick(AnvilGUI.AnvilClickEvent anvilClickEvent) {
|
||||
anvilClickEvent.setCancelled(true);
|
||||
if (anvilClickEvent.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
|
||||
if (anvilClickEvent.getName().equals("")) {
|
||||
return;
|
||||
}
|
||||
if (anvilClickEvent.getName().length() > 16) {
|
||||
anvilClickEvent.getPlayer().sendMessage("§eCEdit: §7Name cannot be longer than §c16 §7Characters");
|
||||
return;
|
||||
}
|
||||
Category originCategory = subCategory.getOriginCategory();
|
||||
List<SubCategory> subCategories = subCategory.getOriginCategory().getSubCategories();
|
||||
int index = subCategories.indexOf(subCategory);
|
||||
String newCategoryName = ChatColor.stripColor(Utils.format(anvilClickEvent.getName()));
|
||||
subCategory.setName(newCategoryName);
|
||||
subCategory.setPermission(anvilClickEvent.getName().toLowerCase().replace(" ", "_"));
|
||||
subCategories.set(index, subCategory);
|
||||
originCategory.setSubCategories(subCategories);
|
||||
|
||||
// Rewrite Category File
|
||||
File categoryFile = CustomHeads.getCategoryManager().getSourceFile(originCategory);
|
||||
try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(categoryFile), StandardCharsets.UTF_8)) {
|
||||
writer.write(originCategory.toString());
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to rewrite " + originCategory.getName(), e);
|
||||
}
|
||||
player.sendMessage("§eCedit: §7Successfully renamed Subcategory to §a" + newCategoryName);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnvilClose() {
|
||||
CategorySetup.OPENED_SETUPS.get(player).openInventory(player);
|
||||
}
|
||||
});
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.OUTPUT, new ItemEditor(Material.PAPER).setDisplayName(subCategory.getPlainName()).setLore("§7Set the Name of this Category").getItem());
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, new ItemEditor(Material.PAPER).setDisplayName(subCategory.getPlainName()).setLore("§7Set the Name of this Category").getItem());
|
||||
gui.open();
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEvent(InventoryCloseEvent event) {
|
||||
cachedPlayers.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
}
|
@ -1,18 +1,19 @@
|
||||
package de.mrstein.customheads.listener;
|
||||
package de.likewhat.customheads.listener;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.api.CustomHeadsPlayer;
|
||||
import de.mrstein.customheads.category.Category;
|
||||
import de.mrstein.customheads.category.CustomHead;
|
||||
import de.mrstein.customheads.category.SubCategory;
|
||||
import de.mrstein.customheads.headwriter.HeadFontType;
|
||||
import de.mrstein.customheads.reflection.TagEditor;
|
||||
import de.mrstein.customheads.stuff.CHSearchQuery;
|
||||
import de.mrstein.customheads.updaters.AsyncFileDownloader;
|
||||
import de.mrstein.customheads.updaters.GitHubDownloader;
|
||||
import de.mrstein.customheads.utils.ItemEditor;
|
||||
import de.mrstein.customheads.utils.ScrollableInventory;
|
||||
import de.mrstein.customheads.utils.Utils;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.api.CustomHeadsPlayer;
|
||||
import de.likewhat.customheads.category.BaseCategory;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.CustomHead;
|
||||
import de.likewhat.customheads.category.SubCategory;
|
||||
import de.likewhat.customheads.headwriter.HeadFontType;
|
||||
import de.likewhat.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.utils.ScrollableInventory;
|
||||
import de.likewhat.customheads.utils.Utils;
|
||||
import de.likewhat.customheads.utils.reflection.TagEditor;
|
||||
import de.likewhat.customheads.utils.stuff.CHSearchQuery;
|
||||
import de.likewhat.customheads.utils.updaters.AsyncFileDownloader;
|
||||
import de.likewhat.customheads.utils.updaters.GitHubDownloader;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -20,18 +21,16 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.mrstein.customheads.utils.Utils.*;
|
||||
import static de.likewhat.customheads.utils.Utils.*;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in InventoryListener
|
||||
@ -75,9 +74,11 @@ public class InventoryListener implements Listener {
|
||||
.addLoreLine(CustomHeads.hasEconomy() && CustomHeads.categoriesBuyable() ? bought ? CustomHeads.getLanguageManager().ECONOMY_BOUGHT : Utils.getCategoryPriceFormatted(category, true) + "\n" + CustomHeads.getLanguageManager().ECONOMY_BUY_PROMPT : null)
|
||||
.addLoreLines(hasPermission(player, "heads.view.permissions") ? Arrays.asList(" ", "§7§oPermission: " + category.getPermission()) : null)
|
||||
.getItem();
|
||||
if (CustomHeads.hasEconomy() && !CustomHeads.keepCategoryPermissions()) {
|
||||
if (!bought) {
|
||||
nextIcon = CustomHeads.getTagEditor().addTags(nextIcon, "buyCategory", category.getId());
|
||||
if (CustomHeads.hasEconomy()) {
|
||||
if(!(CustomHeads.keepCategoryPermissions() && hasPermission(player, category.getPermission()))) {
|
||||
if (!bought && CustomHeads.categoriesBuyable()) {
|
||||
nextIcon = CustomHeads.getTagEditor().addTags(nextIcon, "buyCategory", category.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
contentItem = nextIcon;
|
||||
@ -113,8 +114,9 @@ public class InventoryListener implements Listener {
|
||||
@EventHandler
|
||||
public void onInvClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (event.getInventory() == null || event.getRawSlot() > event.getInventory().getSize() || event.getInventory().getType() != InventoryType.CHEST || event.getCurrentItem() == null || !hasPermission(player, "heads.use"))
|
||||
if (event.getInventory() == null || event.getRawSlot() >= event.getInventory().getSize() || event.getInventory().getType() != InventoryType.CHEST || !hasPermission(player, "heads.use")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// player.sendMessage("§7[CHTags Tags] §r" + CustomHeads.getTagEditor().getTags(event.getCurrentItem())); // Yeah debug at its finest
|
||||
|
||||
@ -160,15 +162,8 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
for(ItemStack item : event.getInventory().getContents()) {
|
||||
if(CustomHeads.getTagEditor().hasMyTags(item) && !CustomHeads.getTagEditor().hasMyTags(event.getCurrentItem())) {
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!CustomHeads.getTagEditor().hasMyTags(event.getCurrentItem())) {
|
||||
return;
|
||||
if(event.getAction().name().contains("PLACE")) {
|
||||
handleInventoryAction(event);
|
||||
}
|
||||
|
||||
ScrollableInventory currentScrollInventory = null;
|
||||
@ -340,7 +335,7 @@ public class InventoryListener implements Listener {
|
||||
if (itemTags.contains("buyCategory")) {
|
||||
event.setCancelled(true);
|
||||
if (event.getClick().isRightClick()) {
|
||||
Category buyCategory = CustomHeads.getCategoryManager().getCategory(itemTags.get(itemTags.indexOf("buyCategory") + 1).split("#>")[1]);
|
||||
Category buyCategory = CustomHeads.getCategoryManager().getCategory(itemTags.get(itemTags.indexOf("buyCategory") + 1));
|
||||
if (buyCategory != null && menuID != null) {
|
||||
if (buyCategory.isFree()) {
|
||||
customHeadsPlayer.unlockCategory(buyCategory);
|
||||
@ -549,4 +544,41 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEvent(InventoryDragEvent event) {
|
||||
if (event.getInventory() == null || event.getRawSlots().stream().max(Integer::compare).orElse(0) >= event.getInventory().getSize() || event.getInventory().getType() != InventoryType.CHEST || !hasPermission((Player)event.getWhoClicked(), "heads.use")) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleInventoryAction(event);
|
||||
}
|
||||
|
||||
private void handleInventoryAction(InventoryInteractEvent event) {
|
||||
Player player = (Player)event.getWhoClicked();
|
||||
|
||||
for(String name : CustomHeads.getCategoryManager().getAllCategories().stream().map(BaseCategory::getName).collect(Collectors.toList())) {
|
||||
if(event.getView().getTitle().equals(name)) {
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(String name : CustomHeads.getLooks().getCreatedMenuTitles().values()) {
|
||||
if(event.getView().getTitle().equals(name)) {
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack item : event.getInventory().getContents()) {
|
||||
if (CustomHeads.getTagEditor().hasMyTags(item)) {
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package de.likewhat.customheads.listener;
|
||||
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.category.CategorySetup;
|
||||
import de.likewhat.customheads.utils.Utils;
|
||||
import de.likewhat.customheads.utils.updaters.SpigetFetcher;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import static de.likewhat.customheads.utils.Utils.sendJSONMessage;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in OtherListeners
|
||||
* by LikeWhat
|
||||
*/
|
||||
|
||||
public class OtherListeners implements Listener {
|
||||
|
||||
public static final HashMap<Player, Location> CACHED_LOCATIONS = new HashMap<>();
|
||||
public static final HashMap<UUID, CategorySetup> CACHED_CATEGORYSETUPS = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void fireworkbreak(BlockBreakEvent event) {
|
||||
if (CACHED_LOCATIONS.containsValue(event.getBlock().getLocation().add(.5, 0, .5))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
if (CACHED_LOCATIONS.containsKey(event.getPlayer())) {
|
||||
CACHED_LOCATIONS.get(event.getPlayer()).getBlock().setType(Material.AIR);
|
||||
CACHED_LOCATIONS.remove(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void notifyUpdate(PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (Utils.hasPermission(player, "heads.admin") && CustomHeads.getHeadsConfig().get().getBoolean("update-notifications.onJoin")) {
|
||||
CustomHeads.getSpigetFetcher().fetchUpdates(new SpigetFetcher.FetchResult() {
|
||||
public void updateAvailable(SpigetFetcher.ResourceRelease release, SpigetFetcher.ResourceUpdate update) {
|
||||
sendJSONMessage("[\"\",{\"text\":\"§6-- CustomHeads Updater --\n§eFound new Update!\n§7Version: §e" + release.getReleaseName() + "\n§7Whats new: §e" + update.getTitle() + "\n\"},{\"text\":\"§6§nClick here to download the Update\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://www.spigotmc.org/resources/29057\"}}]", player);
|
||||
}
|
||||
|
||||
public void noUpdate() {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAsyncChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(CACHED_CATEGORYSETUPS.containsKey(player.getUniqueId())) {
|
||||
CategorySetup setup = CACHED_CATEGORYSETUPS.get(player.getUniqueId());
|
||||
// TODO Add Stuff later
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
package de.mrstein.customheads.loader;
|
||||
package de.likewhat.customheads.loader;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.utils.Configs;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.utils.Configs;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static de.mrstein.customheads.utils.Utils.format;
|
||||
import static de.likewhat.customheads.utils.Utils.format;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in Language
|
||||
@ -129,7 +129,7 @@ public class Language {
|
||||
public final String SAVE_GET_TEXTURE;
|
||||
public final String SAVE_OWN_SUCCESSFUL;
|
||||
public final String SAVE_OWN_FAILED;
|
||||
public final String SAVE_UNAVIABLE;
|
||||
public final String SAVE_UNAVAILABLE;
|
||||
public final String SAVE_NOT_CUSTOM_TEXTURE;
|
||||
public final String SAVE_SUCCESSFUL;
|
||||
public final String SAVE_ALREADY_EXIST;
|
||||
@ -312,7 +312,7 @@ public class Language {
|
||||
SAVE_GET_TEXTURE = getFromConfig("SAVE_GET_TEXTURE");
|
||||
SAVE_OWN_SUCCESSFUL = getFromConfig("SAVE_OWN_SUCCESSFUL");
|
||||
SAVE_OWN_FAILED = getFromConfig("SAVE_OWN_FAILED");
|
||||
SAVE_UNAVIABLE = getFromConfig("SAVE_UNAVIABLE");
|
||||
SAVE_UNAVAILABLE = getFromConfig("SAVE_UNAVIABLE");
|
||||
SAVE_NOT_CUSTOM_TEXTURE = getFromConfig("SAVE_NOT_CUSTOM_TEXTURE");
|
||||
SAVE_SUCCESSFUL = getFromConfig("SAVE_SUCCESSFUL");
|
||||
SAVE_ALREADY_EXIST = getFromConfig("SAVE_ALREADY_EXIST");
|
||||
@ -383,7 +383,7 @@ public class Language {
|
||||
|
||||
private <Type> Type getFromConfig(String path) {
|
||||
if (!languageConfig.get().contains(path))
|
||||
throw new NullPointerException("Error getting " + path + " from language/" + currentLanguage + "/language.yml");
|
||||
throw new NullPointerException("Error getting " + path + " from language/" + currentLanguage + "/language.yml. If this Error keeps occurring please try to delete the Language Folder");
|
||||
if (languageConfig.get().get(path) instanceof List) {
|
||||
return (Type) format(languageConfig.get().getStringList(path));
|
||||
} else if (languageConfig.get().get(path) instanceof String) {
|
@ -1,14 +1,14 @@
|
||||
package de.mrstein.customheads.loader;
|
||||
package de.likewhat.customheads.loader;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.category.Category;
|
||||
import de.mrstein.customheads.category.SubCategory;
|
||||
import de.mrstein.customheads.utils.ItemEditor;
|
||||
import de.mrstein.customheads.utils.JsonFile;
|
||||
import de.mrstein.customheads.utils.JsonToItem;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.SubCategory;
|
||||
import de.likewhat.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.utils.JsonFile;
|
||||
import de.likewhat.customheads.utils.JsonToItem;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -21,8 +21,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static de.mrstein.customheads.utils.Utils.format;
|
||||
import static de.mrstein.customheads.utils.Utils.getBackButton;
|
||||
import static de.likewhat.customheads.utils.Utils.format;
|
||||
import static de.likewhat.customheads.utils.Utils.getBackButton;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in Looks
|
131
src/main/java/de/likewhat/customheads/utils/APIHandler.java
Normal file
131
src/main/java/de/likewhat/customheads/utils/APIHandler.java
Normal file
@ -0,0 +1,131 @@
|
||||
package de.likewhat.customheads.utils;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in APIHandler
|
||||
* by LikeWhat
|
||||
*
|
||||
* created on 22.08.2018 at 22:12
|
||||
*/
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.api.CustomHeadsAPI;
|
||||
import de.likewhat.customheads.api.CustomHeadsPlayer;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.CustomHead;
|
||||
import de.likewhat.customheads.headwriter.HeadFontType;
|
||||
import de.likewhat.customheads.headwriter.HeadWriter;
|
||||
import de.likewhat.customheads.utils.reflection.NBTTagUtils;
|
||||
import de.likewhat.customheads.utils.reflection.TagEditor;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class APIHandler implements CustomHeadsAPI {
|
||||
|
||||
private static Class<?> tileEntitySkullClass, blockPositionClass;
|
||||
private static Constructor<?> blockPositionConstructor;
|
||||
|
||||
static {
|
||||
tileEntitySkullClass = Utils.getMCServerClassByName("TileEntitySkull");
|
||||
blockPositionClass = Utils.getMCServerClassByName("BlockPosition");
|
||||
try {
|
||||
blockPositionConstructor = blockPositionClass.getConstructor(int.class, int.class, int.class);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Head Util Impl
|
||||
public String getSkullTexture(ItemStack itemStack) {
|
||||
if(itemStack == null) {
|
||||
throw new NullPointerException("Item cannot be null");
|
||||
}
|
||||
try {
|
||||
Object nMSCopy = TagEditor.getAsMNSCopy(itemStack);
|
||||
Object tag = nMSCopy.getClass().getMethod("getTag").invoke(nMSCopy);
|
||||
Object skullOwner = tag.getClass().getMethod("getCompound", String.class).invoke(tag, "SkullOwner");
|
||||
Object properties = skullOwner.getClass().getMethod("getCompound", String.class).invoke(skullOwner, "Properties");
|
||||
Object textures = properties.getClass().getMethod("getList", String.class, int.class).invoke(properties, "textures", 10);
|
||||
Object list = textures.getClass().getMethod("get", int.class).invoke(textures, 0);
|
||||
return list.getClass().getMethod("getString", String.class).invoke(list, "Value").toString();
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Something went wrong while getting the Texture of an Skull", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getSkullTexture(Block block) {
|
||||
if (block.getType() != Material.SKULL) {
|
||||
throw new IllegalArgumentException("Block must be a Skull");
|
||||
}
|
||||
Skull s = (Skull) block.getState();
|
||||
if (s.getSkullType() != SkullType.PLAYER) {
|
||||
throw new IllegalArgumentException("Block must be a Player Skull");
|
||||
}
|
||||
try {
|
||||
Object nmsWorld = block.getWorld().getClass().getMethod("getHandle").invoke(block.getWorld());
|
||||
return Utils.getTextureFromProfile((GameProfile) tileEntitySkullClass.getMethod("getGameProfile").invoke(tileEntitySkullClass.cast(nmsWorld.getClass().getMethod("getTileEntity", blockPositionClass).invoke(nmsWorld, blockPositionClass.getConstructor(int.class, int.class, int.class).newInstance(block.getX(), block.getY(), block.getZ())))));
|
||||
} catch (Exception e) {
|
||||
CustomHeads.getInstance().getLogger().log(Level.WARNING, "Error getting Texture from Skull", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getAlphabetHead(String character, HeadFontType font) {
|
||||
if (!font.getCharacters().containsKey(character.charAt(0)))
|
||||
throw new UnsupportedOperationException("Unsupported Character: '" + character.charAt(0) + "'");
|
||||
return font.getCharacter(character.charAt(0));
|
||||
}
|
||||
|
||||
public void writeText(String text, Location location, HeadFontType fontType) {
|
||||
new HeadWriter(fontType, text).writeAt(location);
|
||||
}
|
||||
|
||||
public void setSkull(Block block, String texture, BlockFace blockFace) {
|
||||
try {
|
||||
block.setType(Material.AIR);
|
||||
Skull skull;
|
||||
Location location = block.getLocation();
|
||||
Object nmsWorld = block.getWorld().getClass().getMethod("getHandle").invoke(block.getWorld());
|
||||
if (NBTTagUtils.MC_VERSION > 12) {
|
||||
// Dont
|
||||
Object skullInstance = tileEntitySkullClass.getConstructor().newInstance();
|
||||
Object positionInstance = blockPositionConstructor.newInstance(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
|
||||
tileEntitySkullClass.getMethod("setLocation", Utils.getMCServerClassByName("World"), blockPositionClass).invoke(skullInstance, nmsWorld, positionInstance);
|
||||
|
||||
Class<?> craftBlockDataClass = Utils.getCBClass("block.data.CraftBlockData");
|
||||
Object blockDataState = craftBlockDataClass.getMethod("getState").invoke(craftBlockDataClass.cast(Material.class.getMethod("createBlockData").invoke(NMSUtils.getEnumFromClass(Material.class, "player_head"))));
|
||||
|
||||
nmsWorld.getClass().getMethod("setTypeAndData", blockPositionClass, Utils.getMCServerClassByName("IBlockData"), int.class).invoke(nmsWorld, positionInstance, blockDataState, 3);
|
||||
nmsWorld.getClass().getMethod("setTileEntity", blockPositionClass, Utils.getMCServerClassByName("TileEntity")).invoke(nmsWorld, positionInstance, skullInstance);
|
||||
skull = (Skull) block.getState();
|
||||
} else {
|
||||
block.setType(Material.SKULL);
|
||||
skull = (Skull) block.getState();
|
||||
skull.setSkullType(SkullType.PLAYER);
|
||||
}
|
||||
tileEntitySkullClass.getMethod("setGameProfile", GameProfile.class).invoke(tileEntitySkullClass.cast(nmsWorld.getClass().getMethod("getTileEntity", blockPositionClass).invoke(nmsWorld, blockPositionConstructor.newInstance(block.getX(), block.getY(), block.getZ()))), GameProfileBuilder.createProfileWithTexture(texture));
|
||||
skull.setRotation(blockFace);
|
||||
skull.update();
|
||||
} catch (Exception e) {
|
||||
CustomHeads.getInstance().getLogger().log(Level.WARNING, "Error placing Skull", e);
|
||||
}
|
||||
}
|
||||
|
||||
public CustomHead getHead(Category category, int id) {
|
||||
return category.getHeads().stream().filter(customHead -> customHead.getId() == id).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
// API Impl
|
||||
public CustomHeadsPlayer wrapPlayer(OfflinePlayer player) {
|
||||
return PlayerWrapper.wrapPlayer(player);
|
||||
}
|
||||
|
||||
}
|
129
src/main/java/de/likewhat/customheads/utils/CategoryEditor.java
Normal file
129
src/main/java/de/likewhat/customheads/utils/CategoryEditor.java
Normal file
@ -0,0 +1,129 @@
|
||||
package de.likewhat.customheads.utils;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in CategoryEditor
|
||||
* by LikeWhat
|
||||
*
|
||||
* created on 27.10.2019 at 15:22
|
||||
*/
|
||||
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.category.BaseCategory;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.CustomHead;
|
||||
import de.likewhat.customheads.category.SubCategory;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class CategoryEditor {
|
||||
|
||||
private final Category category;
|
||||
private Player player;
|
||||
|
||||
public CategoryEditor(Category category, Player editor) {
|
||||
this.category = category;
|
||||
player = editor;
|
||||
}
|
||||
|
||||
public static void openCategoryOverview(Player player) {
|
||||
List<ItemStack> categories = new ArrayList<>();
|
||||
for (Category category : CustomHeads.getCategoryManager().getCategoryList()) {
|
||||
categories.add(CustomHeads.getTagEditor().setTags(new ItemEditor(category.hasCategoryIcon() ? category.getCategoryIcon() : category.getIcons().get(0)).setDisplayName("§e" + category.getName())
|
||||
.setLore(Arrays.asList(
|
||||
"§7ID: §e" + category.getId(),
|
||||
"§7Permission: §e" + category.getPermission(),
|
||||
"§7Has Subcategories: §e" + (category.hasSubCategories() ? "Yes" : "No")
|
||||
)).getItem(), "cEditor", "selectCategory#>" + category.getId()));
|
||||
}
|
||||
ScrollableInventory scrollableInventory = new ScrollableInventory("§eAll Categories", categories);
|
||||
scrollableInventory.setBarItem(1, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.SKULL_ITEM, (byte) 3).setDisplayName("§aCreate").setTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2VkZDIwYmU5MzUyMDk0OWU2Y2U3ODlkYzRmNDNlZmFlYjI4YzcxN2VlNmJmY2JiZTAyNzgwMTQyZjcxNiJ9fX0=").getItem(), "cEditor", "create#>"));
|
||||
scrollableInventory.setBarItem(2, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.PAPER).setDisplayName("§bEdit").getItem(), "cEditor", "edit#>"));
|
||||
scrollableInventory.setBarItem(3, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.SKULL_ITEM, (byte) 3).setDisplayName("§cDelete").setTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTFmMjExYzZjMzJlNzdmYWY5MTEyNzhiOGM3MjljYTUwYzVkMjc5ZDU5OGZkYjg3MTk4NzVmNzg0ZGVmNmVhIn19fQ==").getItem(), "cEditor", "delete#>"));
|
||||
player.openInventory(scrollableInventory.getAsInventory());
|
||||
}
|
||||
|
||||
/*
|
||||
* ----------------------------
|
||||
* |0 |1 |2 |3 |4 |5 |6 |7 |8 |
|
||||
* |9 |10|11|12|13|14|15|16|17|
|
||||
* |18|19|20|21|22|23|24|25|26|
|
||||
* ----------------------------
|
||||
*
|
||||
* 09 :
|
||||
* 10 :
|
||||
* 11 : Category Icon
|
||||
* 12 : SKULL_ITEM -> Edit Heads
|
||||
* 13 : PAPER -> Rename
|
||||
* 14 : EMERALD -> Convert (only when not Subcategory)
|
||||
* 15 :
|
||||
* 16 : BARRIER -> Delete
|
||||
* 17 :
|
||||
* */
|
||||
|
||||
/*
|
||||
* -------------------
|
||||
* | Categories |
|
||||
* | |
|
||||
* | |
|
||||
* | 2 3 1 |
|
||||
* -------------------
|
||||
*
|
||||
* 1: Delete
|
||||
* 2: Create
|
||||
* 3: Edit
|
||||
*
|
||||
* Create:
|
||||
* Default: Normal
|
||||
* -> Can later be changed to Sub Category
|
||||
*
|
||||
* */
|
||||
|
||||
public void showCategoryInfos() {
|
||||
if (player.hasPermission("cc.editor.showinfos")) {
|
||||
Inventory categoryEdit;
|
||||
|
||||
CustomHead editHeads = getRandomHeadFromCategory(category);
|
||||
|
||||
if(category.isCategory()) {
|
||||
categoryEdit = Bukkit.createInventory(player, 27, "§eCategory Info §8: §e" + category.getName());
|
||||
categoryEdit.setItem(11, CustomHeads.getTagEditor().setTags(new ItemEditor(category.getAsCategory().getCategoryIcon()).setDisplayName("§7" + category.getAsCategory().getCategoryIcon().getItemMeta().getDisplayName()).getItem(), "cEditor", "blockMoving"));
|
||||
categoryEdit.setItem(12, CustomHeads.getTagEditor().setTags((editHeads == null ? new ItemEditor(Material.SKULL_ITEM, (short) 3).setTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmFkYzA0OGE3Y2U3OGY3ZGFkNzJhMDdkYTI3ZDg1YzA5MTY4ODFlNTUyMmVlZWQxZTNkYWYyMTdhMzhjMWEifX19") : new ItemEditor(editHeads)).setDisplayName("§aEdit Heads").setLore("").getItem(), "cEditor", "blockMoving"));
|
||||
categoryEdit.setItem(13, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.PAPER).setDisplayName("§aRename").getItem(), "cEditor", "rename#>category#>" + category.getId()));
|
||||
categoryEdit.setItem(14, CustomHeads.getTagEditor().setTags(new ItemEditor(category.getAsCategory().hasSubCategories() ? Material.REDSTONE : Material.EMERALD).setDisplayName(category.getAsCategory().hasSubCategories() ? "§cAlready converted" : "§aCovert to Subcategory").getItem(), "cEditor", category.getAsCategory().hasSubCategories() ? "convert" : "blockMoving"));
|
||||
} else {
|
||||
categoryEdit = Bukkit.createInventory(player, 27, "§eSubCategory Info §8: §e" + category.getName());
|
||||
categoryEdit.setItem(11, CustomHeads.getTagEditor().setTags(new ItemEditor(category.getAsSubCategory().getCategoryIcon()).setDisplayName("§7" + category.getAsSubCategory().getCategoryIcon().getItemMeta().getDisplayName()).getItem(), "cEditor", "blockMoving"));
|
||||
categoryEdit.setItem(12, CustomHeads.getTagEditor().setTags((editHeads == null ? new ItemEditor(Material.SKULL_ITEM, (short) 3).setTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmFkYzA0OGE3Y2U3OGY3ZGFkNzJhMDdkYTI3ZDg1YzA5MTY4ODFlNTUyMmVlZWQxZTNkYWYyMTdhMzhjMWEifX19") : new ItemEditor(editHeads)).setDisplayName("§aEdit Heads").setLore("").getItem(), "cEditor", "blockMoving"));
|
||||
categoryEdit.setItem(13, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.PAPER).setDisplayName("§aRename").getItem(), "cEditor", "rename#>category#>" + category.getId()));
|
||||
}
|
||||
categoryEdit.setItem(16, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.BARRIER).setDisplayName("§cDelete").getItem(), "cEditor", "delete#>category#>" + category.getId()));
|
||||
categoryEdit.setItem(18, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.SKULL_ITEM, (short) 3).setDisplayName("§cBack").setLore("§7Back to previous Menu").setTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzM3NjQ4YWU3YTU2NGE1Mjg3NzkyYjA1ZmFjNzljNmI2YmQ0N2Y2MTZhNTU5Y2U4YjU0M2U2OTQ3MjM1YmNlIn19fQ==").getItem(), "cEditor", (category.isCategory() ? "open#>cOverview" : "openInfo#>" + category.getAsSubCategory().getOriginCategory().getId())));
|
||||
|
||||
player.openInventory(categoryEdit);
|
||||
}
|
||||
}
|
||||
|
||||
private CustomHead getRandomHeadFromCategory(BaseCategory category) {
|
||||
List<CustomHead> heads = new ArrayList<>();
|
||||
if(category.isCategory()) {
|
||||
if (category.getAsCategory().hasSubCategories()) {
|
||||
for (SubCategory sub : category.getAsCategory().getSubCategories()) {
|
||||
heads.addAll(sub.getHeads());
|
||||
}
|
||||
} else {
|
||||
heads.addAll(category.getAsCategory().getHeads());
|
||||
}
|
||||
} else {
|
||||
heads.addAll(category.getAsSubCategory().getHeads());
|
||||
}
|
||||
return heads.isEmpty() ? null : heads.get(new Random().nextInt(heads.size() - 1));
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.utils;
|
||||
package de.likewhat.customheads.utils;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -9,8 +9,6 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static de.mrstein.customheads.utils.Utils.saveInternalFile;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in Configs
|
||||
* by LikeWhat
|
||||
@ -34,7 +32,7 @@ public class Configs {
|
||||
this.filename = filename;
|
||||
this.subfolder = subfolder.length > 0 ? "plugins/" + plugin.getName() + "/" + subfolder[0] : "plugins/" + plugin.getName();
|
||||
if (inPlugin = internalFile) {
|
||||
saveInternalFile(filename, this.subfolder);
|
||||
Utils.saveInternalFile(filename, this.subfolder);
|
||||
}
|
||||
get().options().copyDefaults(true);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.utils;
|
||||
package de.likewhat.customheads.utils;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.gson.*;
|
||||
@ -6,7 +6,7 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import com.mojang.util.UUIDTypeAdapter;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.mrstein.customheads.utils;
|
||||
package de.likewhat.customheads.utils;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.utils;
|
||||
package de.likewhat.customheads.utils;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
@ -11,8 +11,6 @@ import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static de.mrstein.customheads.utils.Utils.saveInternalFile;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in JsonFile
|
||||
* by LikeWhat
|
||||
@ -41,7 +39,7 @@ public class JsonFile {
|
||||
}
|
||||
|
||||
public JsonFile(String filename, String subFolder) {
|
||||
file = saveInternalFile(filename, subFolder);
|
||||
file = Utils.saveInternalFile(filename, subFolder);
|
||||
reload();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.mrstein.customheads.utils;
|
||||
package de.likewhat.customheads.utils;
|
||||
|
||||
import com.google.gson.*;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.enchantments.EnchantmentWrapper;
|
||||
@ -13,7 +13,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static de.mrstein.customheads.utils.Utils.format;
|
||||
import static de.likewhat.customheads.utils.Utils.format;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in JsonToItem
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.utils;
|
||||
package de.likewhat.customheads.utils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
25
src/main/java/de/likewhat/customheads/utils/NMSUtils.java
Normal file
25
src/main/java/de/likewhat/customheads/utils/NMSUtils.java
Normal file
@ -0,0 +1,25 @@
|
||||
package de.likewhat.customheads.utils;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in NMSUtils
|
||||
* by LikeWhat
|
||||
*
|
||||
* created on 29.12.2019 at 00:36
|
||||
*/
|
||||
|
||||
public class NMSUtils {
|
||||
|
||||
public static Enum<?> getEnumFromClass(Class clazz, String enumName) {
|
||||
try {
|
||||
for (Object eenum : clazz.getEnumConstants()) {
|
||||
if (((String)eenum.getClass().getMethod("name").invoke(eenum)).equalsIgnoreCase(enumName)) {
|
||||
return (Enum<?>) eenum;
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.utils;
|
||||
package de.likewhat.customheads.utils;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in PlayerWrapper
|
||||
@ -10,12 +10,12 @@ package de.mrstein.customheads.utils;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.api.CustomHeadsPlayer;
|
||||
import de.mrstein.customheads.category.Category;
|
||||
import de.mrstein.customheads.category.CustomHead;
|
||||
import de.mrstein.customheads.stuff.GetHistory;
|
||||
import de.mrstein.customheads.stuff.SearchHistory;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.api.CustomHeadsPlayer;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.CustomHead;
|
||||
import de.likewhat.customheads.utils.stuff.GetHistory;
|
||||
import de.likewhat.customheads.utils.stuff.SearchHistory;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -92,9 +92,9 @@ public class PlayerWrapper implements CustomHeadsPlayer {
|
||||
|
||||
JsonFile jsonFile = CustomHeads.getPlayerDataFile();
|
||||
JsonObject rootObjects = jsonFile.getJson().getAsJsonObject();
|
||||
for (UUID uuids : wrappedPlayersCache.keySet()) {
|
||||
CustomHeadsPlayer customHeadsPlayer = wrappedPlayersCache.get(uuids);
|
||||
JsonObject uuidObject = rootObjects.has(uuids.toString()) ? rootObjects.getAsJsonObject(uuids.toString()) : new JsonObject();
|
||||
for (UUID uuid : wrappedPlayersCache.keySet()) {
|
||||
CustomHeadsPlayer customHeadsPlayer = wrappedPlayersCache.get(uuid);
|
||||
JsonObject uuidObject = rootObjects.has(uuid.toString()) ? rootObjects.getAsJsonObject(uuid.toString()) : new JsonObject();
|
||||
JsonObject savedHeads = new JsonObject();
|
||||
List<ItemStack> saved = customHeadsPlayer.getSavedHeads();
|
||||
for (ItemStack head : saved) {
|
||||
@ -132,7 +132,7 @@ public class PlayerWrapper implements CustomHeadsPlayer {
|
||||
}
|
||||
uuidObject.add("history", historyObject);
|
||||
|
||||
rootObjects.add(uuids.toString(), uuidObject);
|
||||
rootObjects.add(uuid.toString(), uuidObject);
|
||||
}
|
||||
jsonFile.setJson(rootObjects);
|
||||
jsonFile.saveJson();
|
||||
@ -140,7 +140,7 @@ public class PlayerWrapper implements CustomHeadsPlayer {
|
||||
}
|
||||
|
||||
public List<Category> getUnlockedCategories(boolean ignorePermission) {
|
||||
return CustomHeads.getCategoryManager().getCategoryList().stream().filter(category -> (!ignorePermission && Utils.hasPermission(player.getPlayer(), category.getPermission())) || unlockedCategories.contains(category)).collect(Collectors.toList());
|
||||
return CustomHeads.getCategoryManager().getCategoryList().stream().filter(category -> (!ignorePermission && (Utils.hasPermission(player.getPlayer(), category.getPermission()) || Utils.hasPermission(player.getPlayer(), category.getPermission() + ".allheads"))) || unlockedCategories.contains(category)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Player unwrap() {
|
@ -1,8 +1,8 @@
|
||||
package de.mrstein.customheads.utils;
|
||||
package de.likewhat.customheads.utils;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.loader.Language;
|
||||
import de.mrstein.customheads.reflection.TagEditor;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.loader.Language;
|
||||
import de.likewhat.customheads.utils.reflection.TagEditor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
@ -1,21 +1,21 @@
|
||||
package de.mrstein.customheads.utils;
|
||||
package de.likewhat.customheads.utils;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.*;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.api.CustomHeadsPlayer;
|
||||
import de.mrstein.customheads.category.BaseCategory;
|
||||
import de.mrstein.customheads.category.Category;
|
||||
import de.mrstein.customheads.category.CustomHead;
|
||||
import de.mrstein.customheads.category.SubCategory;
|
||||
import de.mrstein.customheads.reflection.AnvilGUI;
|
||||
import de.mrstein.customheads.reflection.TagEditor;
|
||||
import de.mrstein.customheads.stuff.CHSearchQuery;
|
||||
import de.mrstein.customheads.updaters.AsyncFileDownloader;
|
||||
import de.mrstein.customheads.updaters.FetchResult;
|
||||
import de.mrstein.customheads.updaters.GitHubDownloader;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.api.CustomHeadsPlayer;
|
||||
import de.likewhat.customheads.category.BaseCategory;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.CustomHead;
|
||||
import de.likewhat.customheads.category.SubCategory;
|
||||
import de.likewhat.customheads.utils.reflection.AnvilGUI;
|
||||
import de.likewhat.customheads.utils.reflection.TagEditor;
|
||||
import de.likewhat.customheads.utils.stuff.CHSearchQuery;
|
||||
import de.likewhat.customheads.utils.updaters.AsyncFileDownloader;
|
||||
import de.likewhat.customheads.utils.updaters.FetchResult;
|
||||
import de.likewhat.customheads.utils.updaters.GitHubDownloader;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -37,6 +37,7 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
@ -59,6 +60,10 @@ public class Utils {
|
||||
|
||||
private static long lastRedownload = 0;
|
||||
|
||||
private static final String TEXTURE_LINK = "http://textures.minecraft.net/texture/%s";
|
||||
private static final Pattern KEY_PATTERN = Pattern.compile("[a-z0-9]\\w{63}");
|
||||
private static final String JSON_SKIN = "{\"textures\":{\"SKIN\":{\"url\":\"%s\"}}}";
|
||||
|
||||
public static String getTextureFromProfile(GameProfile profile) {
|
||||
String value = "";
|
||||
for (Property prop : profile.getProperties().get("textures")) {
|
||||
@ -90,66 +95,80 @@ public class Utils {
|
||||
return getPermissions().keySet().stream().filter(permission -> hasPermission(player, permission) || permission.equals("")).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static void openSearchGUI(Player player, String itemname, String... action) {
|
||||
AnvilGUI gui = new AnvilGUI(player, "Search", event -> {
|
||||
event.setCancelled(true);
|
||||
if (event.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
|
||||
if (event.getName().equals("")) {
|
||||
return;
|
||||
}
|
||||
if (event.getName().length() > 16) {
|
||||
event.getPlayer().sendMessage(CustomHeads.getLanguageManager().TO_LONG_INPUT);
|
||||
return;
|
||||
}
|
||||
event.getPlayer().sendMessage(CustomHeads.getLanguageManager().SEARCHING.replace("{SEARCH}", event.getName()));
|
||||
CHSearchQuery query = new CHSearchQuery(event.getName());
|
||||
List<Category> categories = CustomHeads.getCategoryManager().getCategoryList();
|
||||
categories.removeAll(CustomHeads.getApi().wrapPlayer(player).getUnlockedCategories(false));
|
||||
query.excludeCategories(categories);
|
||||
if (query.resultsReturned() == 0) {
|
||||
Inventory noRes = Bukkit.createInventory(event.getPlayer(), 9 * 3, CustomHeads.getLanguageManager().NO_RESULTS);
|
||||
noRes.setItem(13, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.BARRIER).setDisplayName(CustomHeads.getLanguageManager().NO_RESULTS).getItem(), "blockMoving"));
|
||||
if (action.length > 0) {
|
||||
noRes.setItem(18, Utils.getBackButton(action));
|
||||
} else {
|
||||
noRes.setItem(18, Utils.getBackButton("invAction", "willClose#>"));
|
||||
}
|
||||
noRes.setItem(26, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.SKULL_ITEM, 3).setDisplayName(CustomHeads.getLanguageManager().NO_RESULTS_TRY_AGAIN).setTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ==").getItem(), "invAction", "retrySearch#>" + event.getName()));
|
||||
player.closeInventory();
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
player.openInventory(noRes);
|
||||
}
|
||||
}.runTaskLater(CustomHeads.getInstance(), 20);
|
||||
return;
|
||||
}
|
||||
query.viewTo(event.getPlayer(), "willClose");
|
||||
}
|
||||
});
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.OUTPUT, new ItemEditor(Material.PAPER).setDisplayName(itemname).setLore(CustomHeads.getLanguageManager().SEARCH_LORE).getItem());
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, new ItemEditor(Material.PAPER).setDisplayName(itemname).setLore(CustomHeads.getLanguageManager().SEARCH_LORE).getItem());
|
||||
gui.open();
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
public static void openGetGUI(Player player) {
|
||||
AnvilGUI gui = new AnvilGUI(player, "Enter Player Name", event -> {
|
||||
event.update();
|
||||
if (event.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
|
||||
if (event.getItem().getType() == Material.PAPER) {
|
||||
event.setCancelled(true);
|
||||
if (event.getName().isEmpty()) {
|
||||
public static void openSearchGUI(Player player, String itemName, String... action) {
|
||||
AnvilGUI gui = new AnvilGUI(player, "Search", new AnvilGUI.AnvilClickEventHandler() {
|
||||
public void onAnvilClick(AnvilGUI.AnvilClickEvent event) {
|
||||
event.setCancelled(true);
|
||||
if (event.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
|
||||
if (event.getName().equals("")) {
|
||||
return;
|
||||
}
|
||||
if (event.getName().length() > 16) {
|
||||
event.getPlayer().sendMessage(CustomHeads.getLanguageManager().TO_LONG_INPUT);
|
||||
return;
|
||||
}
|
||||
CustomHeads.getApi().wrapPlayer(player).getGetHistory().addEntry(event.getName());
|
||||
event.getPlayer().setItemOnCursor(new ItemEditor(Material.SKULL_ITEM, 3).setDisplayName(CustomHeads.getLanguageManager().GET_HEAD_NAME.replace("{PLAYER}", event.getName())).setOwner(event.getName()).getItem());
|
||||
event.getPlayer().sendMessage(CustomHeads.getLanguageManager().SEARCHING.replace("{SEARCH}", event.getName()));
|
||||
CHSearchQuery query = new CHSearchQuery(event.getName());
|
||||
List<Category> categories = CustomHeads.getCategoryManager().getCategoryList();
|
||||
categories.removeAll(CustomHeads.getApi().wrapPlayer(player).getUnlockedCategories(false));
|
||||
query.excludeCategories(categories);
|
||||
if (query.resultsReturned() == 0) {
|
||||
Inventory noRes = Bukkit.createInventory(event.getPlayer(), 9 * 3, CustomHeads.getLanguageManager().NO_RESULTS);
|
||||
noRes.setItem(13, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.BARRIER).setDisplayName(CustomHeads.getLanguageManager().NO_RESULTS).getItem(), "blockMoving"));
|
||||
if (action.length > 0) {
|
||||
noRes.setItem(18, Utils.getBackButton(action));
|
||||
} else {
|
||||
noRes.setItem(18, Utils.getBackButton("invAction", "willClose#>"));
|
||||
}
|
||||
noRes.setItem(26, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.SKULL_ITEM, 3).setDisplayName(CustomHeads.getLanguageManager().NO_RESULTS_TRY_AGAIN).setTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ==").getItem(), "invAction", "retrySearch#>" + event.getName()));
|
||||
player.closeInventory();
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
player.openInventory(noRes);
|
||||
}
|
||||
}.runTaskLater(CustomHeads.getInstance(), 20);
|
||||
return;
|
||||
}
|
||||
query.viewTo(event.getPlayer(), "willClose");
|
||||
}
|
||||
} else if (event.getSlot() == AnvilGUI.AnvilSlot.INPUT_LEFT || event.getSlot() == AnvilGUI.AnvilSlot.INPUT_RIGHT) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public void onAnvilClose() {
|
||||
|
||||
}
|
||||
});
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.OUTPUT, new ItemEditor(Material.PAPER).setDisplayName(itemName).setLore(CustomHeads.getLanguageManager().SEARCH_LORE).getItem());
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, new ItemEditor(Material.PAPER).setDisplayName(itemName).setLore(CustomHeads.getLanguageManager().SEARCH_LORE).getItem());
|
||||
gui.open();
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
public static void openGetGUI(Player player) {
|
||||
AnvilGUI gui = new AnvilGUI(player, "Enter Player Name", new AnvilGUI.AnvilClickEventHandler() {
|
||||
@Override
|
||||
public void onAnvilClick(AnvilGUI.AnvilClickEvent event) {
|
||||
event.update();
|
||||
if (event.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
|
||||
if (event.getItem().getType() == Material.PAPER) {
|
||||
event.setCancelled(true);
|
||||
if (event.getName().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (event.getName().length() > 16) {
|
||||
event.getPlayer().sendMessage(CustomHeads.getLanguageManager().TO_LONG_INPUT);
|
||||
return;
|
||||
}
|
||||
CustomHeads.getApi().wrapPlayer(player).getGetHistory().addEntry(event.getName());
|
||||
event.getPlayer().setItemOnCursor(new ItemEditor(Material.SKULL_ITEM, 3).setDisplayName(CustomHeads.getLanguageManager().GET_HEAD_NAME.replace("{PLAYER}", event.getName())).setOwner(event.getName()).getItem());
|
||||
}
|
||||
} else if (event.getSlot() == AnvilGUI.AnvilSlot.INPUT_LEFT || event.getSlot() == AnvilGUI.AnvilSlot.INPUT_RIGHT) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnvilClose() {
|
||||
|
||||
}
|
||||
});
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, new ItemEditor(Material.PAPER).setDisplayName(CustomHeads.getLanguageManager().CHANGE_SEARCH_STRING).setLore(CustomHeads.getLanguageManager().SEARCH_LORE).getItem());
|
||||
@ -181,13 +200,13 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
int lines = (int) Math.ceil(items.size() / 7.0);
|
||||
Inventory helpMenu = Bukkit.createInventory(null, 9 * (2 + lines > 6 ? 6 : 2 + lines), CustomHeads.getLanguageManager().ITEMS_HELP);
|
||||
Inventory helpMenu = Bukkit.createInventory(null, 9 * (Math.min(2 + lines, 6)), CustomHeads.getLanguageManager().ITEMS_HELP);
|
||||
int itemCount = items.size();
|
||||
int offset = 10;
|
||||
int itemCounter = 0;
|
||||
while (itemCount >= 0) {
|
||||
int counter = 0;
|
||||
for (int lineIndex : line.get((itemCount > 7 ? 7 : itemCount) - 1)) {
|
||||
for (int lineIndex : line.get((Math.min(itemCount, 7)) - 1)) {
|
||||
if (lineIndex == 1) {
|
||||
helpMenu.setItem(offset + counter, items.get(itemCounter));
|
||||
itemCounter++;
|
||||
@ -355,7 +374,7 @@ public class Utils {
|
||||
inventory.setContent(categoryHeads.stream().map(customHead -> {
|
||||
boolean bought = customHeadsPlayer.getUnlockedHeads().contains(customHead);
|
||||
ItemEditor itemEditor = new ItemEditor(customHead);
|
||||
return CustomHeads.hasEconomy() && CustomHeads.headsBuyable() ? bought ? CustomHeads.getTagEditor().addTags(itemEditor.addLoreLine(CustomHeads.getLanguageManager().ECONOMY_BOUGHT).getItem(), "wearable", "clonable") : CustomHeads.getTagEditor().addTags(itemEditor.addLoreLine(formatPrice(customHead.getPrice(), true)).getItem(), "buyHead", "buyHead#>" + customHead.getOriginCategory().getId() + ":" + customHead.getId()) : CustomHeads.getTagEditor().addTags(itemEditor.getItem(), "wearable", "clonable");
|
||||
return CustomHeads.hasEconomy() && CustomHeads.headsBuyable() ? (bought || hasPermission(player, "heads.viewCategory." + baseCategory.getPermission().replaceFirst("heads.viewCategory.", "") + ".allheads")) ? CustomHeads.getTagEditor().addTags(itemEditor.addLoreLine(CustomHeads.getLanguageManager().ECONOMY_BOUGHT).getItem(), "wearable", "clonable") : CustomHeads.getTagEditor().addTags(itemEditor.addLoreLine(formatPrice(customHead.getPrice(), true)).getItem(), "buyHead", "buyHead#>" + customHead.getOriginCategory().getId() + ":" + customHead.getId()) : CustomHeads.getTagEditor().addTags(itemEditor.getItem(), "wearable", "clonable");
|
||||
}).collect(Collectors.toList()));
|
||||
inventory.setBarItem(1, Utils.getBackButton(backAction));
|
||||
inventory.setBarItem(3, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.PAPER).setDisplayName(CustomHeads.getLanguageManager().ITEMS_INFO).setLore(CustomHeads.getLanguageManager().ITEMS_INFO_LORE).getItem(), "dec", "info-item", "blockMoving"));
|
||||
@ -419,13 +438,20 @@ public class Utils {
|
||||
fetchResult.success(languages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Exception exception) {
|
||||
fetchResult.error(exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static BaseCategory getBaseCategory(String id) {
|
||||
return CustomHeads.getCategoryManager().getAllCategories().stream().filter(category -> category.getId().equals(id)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static boolean isNumber(String string) {
|
||||
return string.matches("[0-9]*");
|
||||
}
|
||||
|
||||
public static void getUUID(String name, Consumer<String> consumer) {
|
||||
if (CustomHeads.uuidCache.containsKey(name)) {
|
||||
consumer.accept(CustomHeads.uuidCache.get(name));
|
||||
@ -549,6 +575,13 @@ public class Utils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getSkinValue(String key) {
|
||||
if(!KEY_PATTERN.matcher(key).matches()) {
|
||||
throw new IllegalArgumentException("Key doesn't match Pattern : " + key);
|
||||
}
|
||||
return Base64.getEncoder().encodeToString(String.format(JSON_SKIN, String.format(TEXTURE_LINK, key)).getBytes());
|
||||
}
|
||||
|
||||
public static String getCategoryPriceFormatted(Category forCategory, boolean prefix) {
|
||||
return formatPrice(forCategory.getPrice(), prefix);
|
||||
}
|
||||
@ -584,11 +617,11 @@ public class Utils {
|
||||
|
||||
public static void sendJSONMessage(String json, Player p) {
|
||||
try {
|
||||
Object chat = getClassbyName("ChatSerializer").getMethod("a", String.class).invoke(null, json);
|
||||
Object packet = getClassbyName("PacketPlayOutChat").getConstructor(getClassbyName("IChatBaseComponent")).newInstance(chat);
|
||||
Object chat = getMCServerClassByName("ChatSerializer").getMethod("a", String.class).invoke(null, json);
|
||||
Object packet = getMCServerClassByName("PacketPlayOutChat").getConstructor(getMCServerClassByName("IChatBaseComponent")).newInstance(chat);
|
||||
Object player = p.getClass().getMethod("getHandle").invoke(p);
|
||||
Object connection = player.getClass().getField("playerConnection").get(player);
|
||||
connection.getClass().getMethod("sendPacket", getClassbyName("Packet")).invoke(connection, packet);
|
||||
connection.getClass().getMethod("sendPacket", getMCServerClassByName("Packet")).invoke(connection, packet);
|
||||
} catch (Exception e) {
|
||||
CustomHeads.getInstance().getLogger().log(Level.WARNING, "Could not send JSON-Message to Player", e);
|
||||
}
|
||||
@ -610,7 +643,7 @@ public class Utils {
|
||||
return "";
|
||||
}
|
||||
|
||||
public static Class<?> getClassbyName(String className) {
|
||||
public static Class<?> getMCServerClassByName(String className) {
|
||||
try {
|
||||
if (className.equals("ChatSerializer") && !CustomHeads.version.equals("v1_8_R1"))
|
||||
className = "IChatBaseComponent$ChatSerializer";
|
||||
@ -621,6 +654,15 @@ public class Utils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Class<?> getClassByName(String className) {
|
||||
try {
|
||||
return Class.forName(className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Class<?> getCBClass(String className) {
|
||||
try {
|
||||
return Class.forName("org.bukkit.craftbukkit." + CustomHeads.version + "." + className);
|
@ -1,6 +1,6 @@
|
||||
package de.mrstein.customheads.reflection;
|
||||
package de.likewhat.customheads.utils.reflection;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -80,6 +80,7 @@ public class AnvilGUI {
|
||||
if (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE) {
|
||||
player.setLevel(player.getLevel() - 1);
|
||||
}
|
||||
handler.onAnvilClose();
|
||||
inv.clear();
|
||||
destroy();
|
||||
}
|
||||
@ -94,6 +95,7 @@ public class AnvilGUI {
|
||||
if (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE) {
|
||||
player.setLevel(player.getLevel() - 1);
|
||||
}
|
||||
handler.onAnvilClose();
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
@ -131,7 +133,7 @@ public class AnvilGUI {
|
||||
int nextContainerId = (int) p.getClass().getMethod("nextContainerCounter").invoke(p);
|
||||
|
||||
Location location = player.getLocation();
|
||||
Object container = CustomHeads.version.contains("v1_14_") ?
|
||||
Object container = Integer.parseInt(CustomHeads.version.split("_")[1]) > 14/*CustomHeads.version.contains("v1_14_")*/ ?
|
||||
getClassbyName("ContainerAnvil").getConstructor(int.class, getClassbyName("PlayerInventory"), getClassbyName("ContainerAccess")).newInstance(nextContainerId, p.getClass().getField("inventory").get(p), getClassbyName("ContainerAccess").getMethod("at", getClassbyName("World"), getClassbyName("BlockPosition")).invoke(getClassbyName("ContainerAccess"), p.getClass().getField("world").get(p), getClassbyName("BlockPosition").getConstructor(int.class, int.class, int.class).newInstance(location.getBlockX(), location.getBlockY(), location.getBlockZ()))):
|
||||
getClassbyName("ContainerAnvil").getConstructor(getClassbyName("PlayerInventory"), getClassbyName("World"), getClassbyName("BlockPosition"), getClassbyName("EntityHuman")).newInstance(p.getClass().getField("inventory").get(p), p.getClass().getField("world").get(p), getClassbyName("BlockPosition").getConstructor(int.class, int.class, int.class).newInstance(location.getBlockX(), location.getBlockY(), location.getBlockZ()), p);;
|
||||
|
||||
@ -144,7 +146,7 @@ public class AnvilGUI {
|
||||
getClassbyName("Container").getField("checkReachable").set(container, false);
|
||||
Constructor<?> chatMessageConstructor = getClassbyName("ChatMessage").getConstructor(String.class, Object[].class);
|
||||
Object connection = p.getClass().getField("playerConnection").get(p);
|
||||
Object packet = CustomHeads.version.contains("v1_14_") ?
|
||||
Object packet = Integer.parseInt(CustomHeads.version.split("_")[1]) > 14/*CustomHeads.version.contains("v1_14_")*/ ?
|
||||
getClassbyName("PacketPlayOutOpenWindow").getConstructor(int.class, getClassbyName("Containers"), getClassbyName("IChatBaseComponent")).newInstance(nextContainerId, getClassbyName("Containers").getField("ANVIL").get(getClassbyName("Containers")), chatMessageConstructor.newInstance(title, new Object[]{})) :
|
||||
getClassbyName("PacketPlayOutOpenWindow").getConstructor(int.class, String.class, getClassbyName("IChatBaseComponent"), int.class).newInstance(nextContainerId, "minecraft:anvil", chatMessageConstructor.newInstance(title, new Object[]{}), 0);
|
||||
connection.getClass().getMethod("sendPacket", getClassbyName("Packet")).invoke(connection, packet);
|
||||
@ -191,6 +193,7 @@ public class AnvilGUI {
|
||||
|
||||
public interface AnvilClickEventHandler {
|
||||
void onAnvilClick(AnvilClickEvent event);
|
||||
void onAnvilClose();
|
||||
}
|
||||
|
||||
@Getter
|
@ -0,0 +1,62 @@
|
||||
package de.likewhat.customheads.utils.reflection;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in NBTTagCreator
|
||||
* by LikeWhat
|
||||
*
|
||||
* created on 17.12.2019 at 23:29
|
||||
*/
|
||||
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.utils.Utils;
|
||||
|
||||
public class NBTTagUtils {
|
||||
|
||||
public static final int MC_VERSION;
|
||||
|
||||
static {
|
||||
MC_VERSION = Integer.parseInt(CustomHeads.version.split("_")[1]);
|
||||
}
|
||||
|
||||
public static Object createNBTTagString(String string) {
|
||||
try {
|
||||
switch (MC_VERSION) {
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
return Utils.getMCServerClassByName("NBTTagString").getConstructor(String.class).newInstance(string);
|
||||
case 15:
|
||||
return Utils.getMCServerClassByName("NBTTagString").getMethod("a", String.class).invoke(null, string);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addObjectToNBTList(Object list, Object objectToAdd) {
|
||||
try {
|
||||
switch (MC_VERSION) {
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
list.getClass().getMethod("add", Utils.getMCServerClassByName("NBTBase")).invoke(list, objectToAdd);
|
||||
break;
|
||||
case 14:
|
||||
case 15:
|
||||
list.getClass().getMethod("add", int.class, Utils.getMCServerClassByName("NBTBase")).invoke(list, list.getClass().getMethod("size").invoke(list), objectToAdd);
|
||||
break;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +1,9 @@
|
||||
package de.mrstein.customheads.reflection;
|
||||
package de.likewhat.customheads.utils.reflection;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.utils.Utils;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.utils.Utils;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -27,11 +26,11 @@ public class TagEditor {
|
||||
public static ItemStack clearTags(ItemStack itemStack) {
|
||||
try {
|
||||
Object copy = getAsMNSCopy(itemStack);
|
||||
Object itemTagCompound = hasNBTTag(itemStack) ? copy.getClass().getMethod("getTag").invoke(copy) : Utils.getClassbyName("NBTTagCompound").newInstance();
|
||||
Object nbtTagCompound = Utils.getClassbyName("NBTTagCompound").newInstance();
|
||||
itemTagCompound.getClass().getMethod("set", String.class, Utils.getClassbyName("NBTBase")).invoke(itemTagCompound, "tagEditor", nbtTagCompound);
|
||||
copy.getClass().getMethod("setTag", Utils.getClassbyName("NBTTagCompound")).invoke(copy, itemTagCompound);
|
||||
return (ItemStack) Utils.getCBClass("inventory.CraftItemStack").getMethod("asBukkitCopy", Utils.getClassbyName("ItemStack")).invoke(Utils.getCBClass("inventory.CraftItemStack"), copy);
|
||||
Object itemTagCompound = hasNBTTag(itemStack) ? copy.getClass().getMethod("getTag").invoke(copy) : Utils.getMCServerClassByName("NBTTagCompound").newInstance();
|
||||
Object nbtTagCompound = Utils.getMCServerClassByName("NBTTagCompound").newInstance();
|
||||
itemTagCompound.getClass().getMethod("set", String.class, Utils.getMCServerClassByName("NBTBase")).invoke(itemTagCompound, "tagEditor", nbtTagCompound);
|
||||
copy.getClass().getMethod("setTag", Utils.getMCServerClassByName("NBTTagCompound")).invoke(copy, itemTagCompound);
|
||||
return (ItemStack) Utils.getCBClass("inventory.CraftItemStack").getMethod("asBukkitCopy", Utils.getMCServerClassByName("ItemStack")).invoke(Utils.getCBClass("inventory.CraftItemStack"), copy);
|
||||
} catch (Exception e) {
|
||||
CustomHeads.getInstance().getLogger().log(Level.WARNING, "Failed to reset Tags from Item", e);
|
||||
}
|
||||
@ -60,28 +59,16 @@ public class TagEditor {
|
||||
public ItemStack setTags(ItemStack itemStack, List<String> tags) {
|
||||
try {
|
||||
Object copy = getAsMNSCopy(itemStack);
|
||||
Object itemTagCompound = hasNBTTag(itemStack) ? copy.getClass().getMethod("getTag").invoke(copy) : Utils.getClassbyName("NBTTagCompound").newInstance();
|
||||
Object nbtTagCompound = ((boolean) itemTagCompound.getClass().getMethod("hasKey", String.class).invoke(itemTagCompound, "tagEditor")) ? itemTagCompound.getClass().getMethod("get", String.class).invoke(itemTagCompound, "tagEditor") : Utils.getClassbyName("NBTTagCompound").newInstance();
|
||||
Object nbtTagList = Utils.getClassbyName("NBTTagList").newInstance();
|
||||
Method nbtTagListAdd;
|
||||
|
||||
if (CustomHeads.version.contains("v1_14_")) {
|
||||
nbtTagListAdd = nbtTagList.getClass().getMethod("add", int.class, Utils.getClassbyName("NBTBase"));
|
||||
} else {
|
||||
nbtTagListAdd = nbtTagList.getClass().getMethod("add", Utils.getClassbyName("NBTBase"));
|
||||
}
|
||||
int c = 0;
|
||||
Object itemTagCompound = hasNBTTag(itemStack) ? copy.getClass().getMethod("getTag").invoke(copy) : Utils.getMCServerClassByName("NBTTagCompound").newInstance();
|
||||
Object nbtTagCompound = ((boolean) itemTagCompound.getClass().getMethod("hasKey", String.class).invoke(itemTagCompound, "tagEditor")) ? itemTagCompound.getClass().getMethod("get", String.class).invoke(itemTagCompound, "tagEditor") : Utils.getMCServerClassByName("NBTTagCompound").newInstance();
|
||||
Object nbtTagList = Utils.getMCServerClassByName("NBTTagList").newInstance();
|
||||
for (String tag : tags) {
|
||||
if(CustomHeads.version.contains("v1_14_")) {
|
||||
nbtTagListAdd.invoke(nbtTagList, c++, Utils.getClassbyName("NBTTagString").getConstructor(String.class).newInstance(tag));
|
||||
} else {
|
||||
nbtTagListAdd.invoke(nbtTagList, Utils.getClassbyName("NBTTagString").getConstructor(String.class).newInstance(tag));
|
||||
}
|
||||
NBTTagUtils.addObjectToNBTList(nbtTagList, NBTTagUtils.createNBTTagString(tag));
|
||||
}
|
||||
nbtTagCompound.getClass().getMethod("set", String.class, Utils.getClassbyName("NBTBase")).invoke(nbtTagCompound, tagname, nbtTagList);
|
||||
itemTagCompound.getClass().getMethod("set", String.class, Utils.getClassbyName("NBTBase")).invoke(itemTagCompound, "tagEditor", nbtTagCompound);
|
||||
copy.getClass().getMethod("setTag", Utils.getClassbyName("NBTTagCompound")).invoke(copy, itemTagCompound);
|
||||
return (ItemStack) Utils.getCBClass("inventory.CraftItemStack").getMethod("asBukkitCopy", Utils.getClassbyName("ItemStack")).invoke(Utils.getCBClass("inventory.CraftItemStack"), copy);
|
||||
nbtTagCompound.getClass().getMethod("set", String.class, Utils.getMCServerClassByName("NBTBase")).invoke(nbtTagCompound, tagname, nbtTagList);
|
||||
itemTagCompound.getClass().getMethod("set", String.class, Utils.getMCServerClassByName("NBTBase")).invoke(itemTagCompound, "tagEditor", nbtTagCompound);
|
||||
copy.getClass().getMethod("setTag", Utils.getMCServerClassByName("NBTTagCompound")).invoke(copy, itemTagCompound);
|
||||
return (ItemStack) Utils.getCBClass("inventory.CraftItemStack").getMethod("asBukkitCopy", Utils.getMCServerClassByName("ItemStack")).invoke(Utils.getCBClass("inventory.CraftItemStack"), copy);
|
||||
} catch (Exception e) {
|
||||
CustomHeads.getInstance().getLogger().log(Level.WARNING, "Failed to save Tags to Item", e);
|
||||
}
|
||||
@ -117,7 +104,9 @@ public class TagEditor {
|
||||
|
||||
public List<String> getTags(ItemStack itemStack) {
|
||||
try {
|
||||
if (!(hasNBTTag(itemStack) && hasMyTags(itemStack))) return new ArrayList<>();
|
||||
if (!(hasNBTTag(itemStack) && hasMyTags(itemStack))) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Object copy = getAsMNSCopy(itemStack);
|
||||
Object tag = copy.getClass().getMethod("getTag").invoke(copy);
|
||||
Object compound = tag.getClass().getMethod("getCompound", String.class).invoke(tag, "tagEditor");
|
||||
@ -143,14 +132,16 @@ public class TagEditor {
|
||||
|
||||
public boolean hasMyTags(ItemStack item) {
|
||||
try {
|
||||
if (!hasNBTTag(item)) return false;
|
||||
if (!hasNBTTag(item)) {
|
||||
return false;
|
||||
}
|
||||
Object copy = getAsMNSCopy(item);
|
||||
Object itemCompound = copy.getClass().getMethod("getTag").invoke(copy);
|
||||
Object tagCompound = itemCompound.getClass().getMethod("getCompound", String.class).invoke(itemCompound, "tagEditor");
|
||||
return tagCompound != null && (boolean) tagCompound.getClass().getMethod("hasKey", String.class).invoke(tagCompound, tagname);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +1,16 @@
|
||||
package de.mrstein.customheads.stuff;
|
||||
package de.likewhat.customheads.utils.stuff;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.api.CustomHeadsPlayer;
|
||||
import de.mrstein.customheads.category.Category;
|
||||
import de.mrstein.customheads.category.SubCategory;
|
||||
import de.mrstein.customheads.headwriter.HeadFontType;
|
||||
import de.mrstein.customheads.headwriter.HeadWriter;
|
||||
import de.mrstein.customheads.updaters.FetchResult;
|
||||
import de.mrstein.customheads.utils.*;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.api.CustomHeadsPlayer;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.CategorySetup;
|
||||
import de.likewhat.customheads.category.SubCategory;
|
||||
import de.likewhat.customheads.headwriter.HeadFontType;
|
||||
import de.likewhat.customheads.headwriter.HeadWriter;
|
||||
import de.likewhat.customheads.listener.OtherListeners;
|
||||
import de.likewhat.customheads.utils.*;
|
||||
import de.likewhat.customheads.utils.reflection.NBTTagUtils;
|
||||
import de.likewhat.customheads.utils.updaters.FetchResult;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.Command;
|
||||
@ -28,8 +31,7 @@ import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.mrstein.customheads.listener.OtherListeners.saveLoc;
|
||||
import static de.mrstein.customheads.utils.Utils.*;
|
||||
import static de.likewhat.customheads.utils.Utils.*;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in CHCommand
|
||||
@ -121,14 +123,20 @@ public class CHCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
player.sendMessage(CustomHeads.getLanguageManager().LANGUAGE_CHANGE_CHANGING.replace("{LANGUAGE}", args[2]));
|
||||
if (CustomHeads.reloadTranslations(args[2])) {
|
||||
boolean success = false;
|
||||
try {
|
||||
success = CustomHeads.reloadTranslations(args[2]);
|
||||
} catch(NullPointerException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to load Language", e);
|
||||
}
|
||||
if (success) {
|
||||
headsConfig.get().set("langFile", args[2]);
|
||||
headsConfig.save();
|
||||
player.sendMessage(CustomHeads.getLanguageManager().LANGUAGE_CHANGE_SUCCESSFUL.replace("{LANGUAGE}", CustomHeads.getLanguageManager().DEFINITION));
|
||||
return true;
|
||||
} else {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().LANGUAGE_CHANGE_FAILED);
|
||||
CustomHeads.reloadTranslations(headsConfig.get().getString("langFile"));
|
||||
player.sendMessage(CustomHeads.getLanguageManager().LANGUAGE_CHANGE_FAILED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -306,7 +314,7 @@ public class CHCommand implements CommandExecutor {
|
||||
if (CustomHeads.getCategoryManager().getLangRootDir().listFiles() == null) {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().CATEGORIES_IMPORT_NOCATEGORYFOLDER);
|
||||
}
|
||||
List<File> fileList = Arrays.stream(CustomHeads.getCategoryManager().getLangRootDir().listFiles()).filter(file -> file.getName().endsWith(".json") && !CustomHeads.getCategoryLoaderConfig().get().getList("categories").contains(file.getName().substring(0, file.getName().lastIndexOf(".")))).collect(Collectors.toList());
|
||||
List<File> fileList = Arrays.stream(CustomHeads.getCategoryManager().getLangRootDir().listFiles()).filter(file -> file.getName().endsWith(".json") && !CustomHeads.getHeadsConfig().get().getList("categories").contains(file.getName().substring(0, file.getName().lastIndexOf(".")))).collect(Collectors.toList());
|
||||
|
||||
List<File> files = new ArrayList<>();
|
||||
for (File file : fileList) {
|
||||
@ -352,6 +360,15 @@ public class CHCommand implements CommandExecutor {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().CATEGORIES_IMPORT_FILENOTFOUND.replace("{FILE}", args[2]));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("create")) {
|
||||
if(args.length < 3) {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().COMMAND_USAGE.replace("{COMMAND}", "/heads categories create <name>"));
|
||||
return true;
|
||||
}
|
||||
CategorySetup.createCategory(args[2]).openInventory(player);
|
||||
return true;
|
||||
}
|
||||
player.sendMessage(CustomHeads.getLanguageManager().COMMAND_USAGE.replace("{COMMAND}", "/heads categories <remove, delete, import>"));
|
||||
return true;
|
||||
}
|
||||
@ -425,30 +442,30 @@ public class CHCommand implements CommandExecutor {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().CANNOT_PLACE_IN_AIR);
|
||||
return true;
|
||||
}
|
||||
if (saveLoc.containsKey(player)) {
|
||||
if (OtherListeners.CACHED_LOCATIONS.containsKey(player)) {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().ALREADY_IN_USE);
|
||||
return true;
|
||||
}
|
||||
player.sendMessage(CustomHeads.getLanguageManager().STARTING);
|
||||
CustomHeads.getApi().setSkull(player.getLocation().getBlock(), "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGEzZDVkNWIyY2YzMzEyOTllNjNkNzYxOGExNDI2NmU4Y2NjNjE1OGU5ZTMxZmNiMGJkOTExZTEyZmY3NzM2In19fQ==", faces[ran.nextInt(faces.length)]);
|
||||
saveLoc.put(player, player.getLocation().getBlock().getLocation().add(.5, 0, .5));
|
||||
OtherListeners.CACHED_LOCATIONS.put(player, player.getLocation().getBlock().getLocation().add(.5, 0, .5));
|
||||
new BukkitRunnable() {
|
||||
Player cPlayer = player;
|
||||
int counter = 10;
|
||||
|
||||
public void run() {
|
||||
if (!saveLoc.containsKey(cPlayer)) {
|
||||
if (!OtherListeners.CACHED_LOCATIONS.containsKey(cPlayer)) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
if (counter <= 0) {
|
||||
saveLoc.get(cPlayer).getWorld().playEffect(saveLoc.get(cPlayer).getBlock().getLocation(), Effect.STEP_SOUND, 17);
|
||||
saveLoc.get(cPlayer).getBlock().setType(Material.AIR);
|
||||
saveLoc.remove(cPlayer);
|
||||
OtherListeners.CACHED_LOCATIONS.get(cPlayer).getWorld().playEffect(OtherListeners.CACHED_LOCATIONS.get(cPlayer).getBlock().getLocation(), Effect.STEP_SOUND, 17);
|
||||
OtherListeners.CACHED_LOCATIONS.get(cPlayer).getBlock().setType(Material.AIR);
|
||||
OtherListeners.CACHED_LOCATIONS.remove(cPlayer);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
Firework f = (Firework) saveLoc.get(cPlayer).getWorld().spawnEntity(saveLoc.get(cPlayer), EntityType.FIREWORK);
|
||||
Firework f = (Firework) OtherListeners.CACHED_LOCATIONS.get(cPlayer).getWorld().spawnEntity(OtherListeners.CACHED_LOCATIONS.get(cPlayer), EntityType.FIREWORK);
|
||||
FireworkMeta fm = f.getFireworkMeta();
|
||||
FireworkEffect.Builder fx = FireworkEffect.builder();
|
||||
fx.flicker(ran.nextBoolean()).trail(ran.nextBoolean()).with(fxTypes[ran.nextInt(fxTypes.length)]);
|
||||
@ -463,8 +480,19 @@ public class CHCommand implements CommandExecutor {
|
||||
fm.setPower(ran.nextInt(2) + 1);
|
||||
f.setFireworkMeta(fm);
|
||||
f.setVelocity(new Vector(ran.nextDouble() * (ran.nextBoolean() ? .01 : -.01), .2, ran.nextDouble() * (ran.nextBoolean() ? .01 : -.01)));
|
||||
for (int i = 0; i < 6; i++) {
|
||||
saveLoc.get(cPlayer).getWorld().playEffect(saveLoc.get(cPlayer), Effect.LAVA_POP, 11);
|
||||
Location location = OtherListeners.CACHED_LOCATIONS.get(cPlayer);
|
||||
World world = location.getWorld();
|
||||
if(NBTTagUtils.MC_VERSION > 13) {
|
||||
try {
|
||||
Class<?> particleClass = Utils.getClassByName("org.bukkit.Particle");
|
||||
World.class.getMethod("spawnParticle", particleClass, Location.class, int.class).invoke(world, NMSUtils.getEnumFromClass(particleClass, "LAVA"), location, 6);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
world.playEffect(location, Effect.LAVA_POP, 0);
|
||||
}
|
||||
}
|
||||
counter--;
|
||||
}
|
||||
@ -507,6 +535,11 @@ public class CHCommand implements CommandExecutor {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("editor")) {
|
||||
if(hasPermission(player, "heads.admin")) {
|
||||
CategoryEditor.openCategoryOverview(player);
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("undo")) {
|
||||
if (hasPermission(player, "heads.use.more.write")) {
|
||||
if (args.length == 1) {
|
||||
@ -651,10 +684,11 @@ public class CHCommand implements CommandExecutor {
|
||||
ItemEditor itemStack = new ItemEditor(player.getItemInHand());
|
||||
args[1] = toConfigString(args[1]);
|
||||
if (itemStack.getOwner() == null) {
|
||||
if (!CustomHeads.USETEXTURES) {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().SAVE_UNAVIABLE);
|
||||
return true;
|
||||
}
|
||||
|
||||
// if (!CustomHeads.USE_TEXTURES) {
|
||||
// player.sendMessage(CustomHeads.getLanguageManager().SAVE_UNAVAILABLE);
|
||||
// return true;
|
||||
// }
|
||||
String nbtstring = itemStack.getTexture();
|
||||
if (nbtstring == null || nbtstring.equals("")) {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().SAVE_NOT_CUSTOM_TEXTURE);
|
@ -1,12 +1,12 @@
|
||||
package de.mrstein.customheads.stuff;
|
||||
package de.likewhat.customheads.utils.stuff;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.api.CustomHeadsPlayer;
|
||||
import de.mrstein.customheads.category.Category;
|
||||
import de.mrstein.customheads.category.CustomHead;
|
||||
import de.mrstein.customheads.utils.ItemEditor;
|
||||
import de.mrstein.customheads.utils.ScrollableInventory;
|
||||
import de.mrstein.customheads.utils.Utils;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.api.CustomHeadsPlayer;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.CustomHead;
|
||||
import de.likewhat.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.utils.ScrollableInventory;
|
||||
import de.likewhat.customheads.utils.Utils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -39,7 +39,10 @@ public class CHSearchQuery {
|
||||
results = new ArrayList<>();
|
||||
return;
|
||||
}
|
||||
results = CustomHeads.getCategoryManager().getAllHeads().stream().filter(head -> ChatColor.stripColor(head.getItemMeta().getDisplayName().toLowerCase()).contains(search.toLowerCase())).collect(Collectors.toList());
|
||||
results = CustomHeads.getCategoryManager().getAllHeads().stream().filter(head -> {
|
||||
String nameStripped = ChatColor.stripColor(head.getItemMeta().getDisplayName().toLowerCase());
|
||||
return Arrays.stream(search.split(" ")).anyMatch(s -> s.equalsIgnoreCase(nameStripped));
|
||||
}).collect(Collectors.toList());
|
||||
Collections.reverse(results);
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package de.mrstein.customheads.stuff;
|
||||
package de.likewhat.customheads.utils.stuff;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.category.Category;
|
||||
import de.mrstein.customheads.category.SubCategory;
|
||||
import de.mrstein.customheads.utils.Utils;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.category.Category;
|
||||
import de.likewhat.customheads.category.SubCategory;
|
||||
import de.likewhat.customheads.utils.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.stuff;
|
||||
package de.likewhat.customheads.utils.stuff;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in GetHistory
|
||||
@ -9,8 +9,8 @@ package de.mrstein.customheads.stuff;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.utils.ItemEditor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.stuff;
|
||||
package de.likewhat.customheads.utils.stuff;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in SearchHistory
|
||||
@ -9,8 +9,8 @@ package de.mrstein.customheads.stuff;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.utils.ItemEditor;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.utils.ItemEditor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
@ -1,7 +1,7 @@
|
||||
package de.mrstein.customheads.updaters;
|
||||
package de.likewhat.customheads.utils.updaters;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
@ -52,30 +52,23 @@ public class AsyncFileDownloader {
|
||||
out.flush();
|
||||
out.close();
|
||||
callback.complete();
|
||||
return;
|
||||
}
|
||||
callback.failed(DownloaderStatus.HTTP_ERROR.setDescription("Server Responded with " + connection.getResponseCode()));
|
||||
callback.failed(DownloaderStatus.HTTP_ERROR.setDescription("Server Responded with " + connection.getResponseCode() + "(" + connection.getResponseMessage() + ")"));
|
||||
} catch (IOException e) {
|
||||
callback.failed(DownloaderStatus.ERROR.setDescription("Failed to download File").setException(e));
|
||||
return;
|
||||
}
|
||||
|
||||
callback.complete();
|
||||
}
|
||||
}.runTaskAsynchronously(CustomHeads.getInstance());
|
||||
}
|
||||
|
||||
public enum DownloaderStatus {
|
||||
ERROR(1, "ERROR"), HTTP_ERROR(2, "HTTP_ERROR"), FILE_ERROR(3, "FILE_ERROR");
|
||||
ERROR(1), HTTP_ERROR(2), FILE_ERROR(3);
|
||||
|
||||
String desc;
|
||||
String name;
|
||||
|
||||
Exception exception;
|
||||
|
||||
DownloaderStatus(int id, String name) {
|
||||
this.name = name;
|
||||
}
|
||||
DownloaderStatus(int id) {}
|
||||
|
||||
public Exception getException() {
|
||||
return exception;
|
||||
@ -94,6 +87,10 @@ public class AsyncFileDownloader {
|
||||
desc = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return desc == null ? name() : name() + " " + desc;
|
||||
}
|
||||
}
|
||||
|
||||
public interface FileDownloaderCallback {
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.updaters;
|
||||
package de.likewhat.customheads.utils.updaters;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in CachedResponse
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.updaters;
|
||||
package de.likewhat.customheads.utils.updaters;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in FetchResult
|
@ -1,12 +1,12 @@
|
||||
package de.mrstein.customheads.updaters;
|
||||
package de.likewhat.customheads.utils.updaters;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.utils.Utils;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.utils.Utils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -154,7 +154,6 @@ public class GitHubDownloader {
|
||||
|
||||
public void error(Exception exception) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to download Files", exception);
|
||||
// exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package de.mrstein.customheads.updaters;
|
||||
package de.likewhat.customheads.utils.updaters;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in JsonFetcher
|
||||
@ -9,7 +9,7 @@ package de.mrstein.customheads.updaters;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package de.mrstein.customheads.updaters;
|
||||
package de.likewhat.customheads.utils.updaters;
|
||||
|
||||
import com.google.gson.*;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.utils.Configs;
|
||||
import de.likewhat.customheads.CustomHeads;
|
||||
import de.likewhat.customheads.utils.Configs;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
@ -1,58 +0,0 @@
|
||||
package de.mrstein.customheads.listener;
|
||||
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.updaters.SpigetFetcher;
|
||||
import de.mrstein.customheads.utils.Utils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static de.mrstein.customheads.utils.Utils.sendJSONMessage;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in OtherListeners
|
||||
* by LikeWhat
|
||||
*/
|
||||
|
||||
public class OtherListeners implements Listener {
|
||||
|
||||
public static HashMap<Player, Location> saveLoc = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void fireworkbreak(BlockBreakEvent e) {
|
||||
if (saveLoc.containsValue(e.getBlock().getLocation().add(.5, 0, .5))) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
if (saveLoc.containsKey(e.getPlayer())) {
|
||||
saveLoc.get(e.getPlayer()).getBlock().setType(Material.AIR);
|
||||
saveLoc.remove(e.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void notifyUpdate(PlayerJoinEvent e) {
|
||||
final Player player = e.getPlayer();
|
||||
if (Utils.hasPermission(player, "heads.admin") && CustomHeads.getHeadsConfig().get().getBoolean("update-notifications.onJoin")) {
|
||||
CustomHeads.getSpigetFetcher().fetchUpdates(new SpigetFetcher.FetchResult() {
|
||||
public void updateAvailable(SpigetFetcher.ResourceRelease release, SpigetFetcher.ResourceUpdate update) {
|
||||
sendJSONMessage("[\"\",{\"text\":\"§6-- CustomHeads Updater --\n§eFound new Update!\n§7Version: §e" + release.getReleaseName() + "\n§7Whats new: §e" + update.getTitle() + "\n\"},{\"text\":\"§6§nClick here to download the Update\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://www.spigotmc.org/resources/29057\"}}]", player);
|
||||
}
|
||||
|
||||
public void noUpdate() {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package de.mrstein.customheads.utils;
|
||||
|
||||
/*
|
||||
* Project: CustomHeads in APIHandler
|
||||
* by LikeWhat
|
||||
*
|
||||
* created on 22.08.2018 at 22:12
|
||||
*/
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.api.CustomHeadsAPI;
|
||||
import de.mrstein.customheads.api.CustomHeadsPlayer;
|
||||
import de.mrstein.customheads.category.Category;
|
||||
import de.mrstein.customheads.category.CustomHead;
|
||||
import de.mrstein.customheads.headwriter.HeadFontType;
|
||||
import de.mrstein.customheads.headwriter.HeadWriter;
|
||||
import de.mrstein.customheads.reflection.TagEditor;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class APIHandler implements CustomHeadsAPI {
|
||||
|
||||
private static Class<?> tileEntityClass, blockPositionClass;
|
||||
|
||||
static {
|
||||
tileEntityClass = Utils.getClassbyName("TileEntitySkull");
|
||||
blockPositionClass = Utils.getClassbyName("BlockPosition");
|
||||
}
|
||||
|
||||
// Head Util Impl
|
||||
public String getSkullTexture(ItemStack itemStack) {
|
||||
if(itemStack == null) {
|
||||
throw new NullPointerException("Item cannot be null");
|
||||
}
|
||||
if (!itemStack.getData().toString().contains("SKULL_ITEM(3)")) {
|
||||
throw new IllegalArgumentException("An PlayerHead is required to get the Texture");
|
||||
}
|
||||
try {
|
||||
Object nmscopy = TagEditor.getAsMNSCopy(itemStack);
|
||||
Object tag = nmscopy.getClass().getMethod("getTag").invoke(nmscopy);
|
||||
Object so = tag.getClass().getMethod("getCompound", String.class).invoke(tag, "SkullOwner");
|
||||
Object prop = so.getClass().getMethod("getCompound", String.class).invoke(so, "Properties");
|
||||
Object tex = prop.getClass().getMethod("getList", String.class, int.class).invoke(prop, "textures", 10);
|
||||
Object list = tex.getClass().getMethod("get", int.class).invoke(tex, 0);
|
||||
return list.getClass().getMethod("getString", String.class).invoke(list, "Value").toString();
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Something went wrong while getting the Texture of an Skull", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getSkullTexture(Block block) {
|
||||
if (block.getType() != Material.SKULL) {
|
||||
throw new IllegalArgumentException("Block must be a Skull");
|
||||
}
|
||||
Skull s = (Skull) block.getState();
|
||||
if (s.getSkullType() != SkullType.PLAYER) {
|
||||
throw new IllegalArgumentException("Block must be a Player Skull");
|
||||
}
|
||||
try {
|
||||
Object nmsWorld = block.getWorld().getClass().getMethod("getHandle").invoke(block.getWorld());
|
||||
return Utils.getTextureFromProfile((GameProfile) tileEntityClass.getMethod("getGameProfile").invoke(tileEntityClass.cast(nmsWorld.getClass().getMethod("getTileEntity", blockPositionClass).invoke(nmsWorld, blockPositionClass.getConstructor(int.class, int.class, int.class).newInstance(block.getX(), block.getY(), block.getZ())))));
|
||||
} catch (Exception e) {
|
||||
CustomHeads.getInstance().getLogger().log(Level.WARNING, "Error getting Texture from Skull", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getAlphabetHead(String character, HeadFontType font) {
|
||||
if (!font.getCharacters().containsKey(character.charAt(0)))
|
||||
throw new UnsupportedOperationException("Unsupported Character: '" + character.charAt(0) + "'");
|
||||
return font.getCharacter(character.charAt(0));
|
||||
}
|
||||
|
||||
public void writeText(String text, Location location, HeadFontType fontType) {
|
||||
new HeadWriter(fontType, text).writeAt(location);
|
||||
}
|
||||
|
||||
public void setSkull(Block block, String texture, BlockFace blockFace) {
|
||||
block.setType(Material.AIR);
|
||||
block.setType(Material.SKULL);
|
||||
Skull s = (Skull) block.getState();
|
||||
s.setRotation(blockFace);
|
||||
s.setRawData((byte) 1);
|
||||
s.update();
|
||||
try {
|
||||
Object nmsWorld = block.getWorld().getClass().getMethod("getHandle").invoke(block.getWorld());
|
||||
tileEntityClass.getMethod("setGameProfile", GameProfile.class).invoke(tileEntityClass.cast(nmsWorld.getClass().getMethod("getTileEntity", blockPositionClass).invoke(nmsWorld, blockPositionClass.getConstructor(int.class, int.class, int.class).newInstance(block.getX(), block.getY(), block.getZ()))), GameProfileBuilder.createProfileWithTexture(texture));
|
||||
} catch (Exception e) {
|
||||
CustomHeads.getInstance().getLogger().log(Level.WARNING, "Error placing Skull", e);
|
||||
}
|
||||
}
|
||||
|
||||
public CustomHead getHead(Category category, int id) {
|
||||
Iterator<CustomHead> headIterator = category.getHeads().stream().filter(customHead -> customHead.getId() == id).iterator();
|
||||
return headIterator.hasNext() ? headIterator.next() : null;
|
||||
}
|
||||
|
||||
// API Impl
|
||||
public CustomHeadsPlayer wrapPlayer(OfflinePlayer player) {
|
||||
return PlayerWrapper.wrapPlayer(player);
|
||||
}
|
||||
|
||||
}
|
@ -20,14 +20,30 @@
|
||||
# historyMode can either be TEMP or FILE #
|
||||
# Overflow: default: 18 max: 27 #
|
||||
# --------------------------------------------------- #
|
||||
# keepCategoryPermissions: Used when Economy is #
|
||||
# enabled. Categories will only be able the be #
|
||||
# unlocked with Money when false #
|
||||
# (or for free when not defined) #
|
||||
# Economy: Category #
|
||||
# buyable: Defines if Categories can be bought with #
|
||||
# Money (only available when Economy is enabled) #
|
||||
# keePermissions: When set to true, Categories you #
|
||||
# have the Permission for will be unlocked without #
|
||||
# having to buy them #
|
||||
# Economy: Heads #
|
||||
# buyable: Defines if Heads can be bought with Money #
|
||||
# (only available when Economy is enabled) #
|
||||
# permanentBuy: Unlocks the Heads permanently once #
|
||||
# bought #
|
||||
# --------------------------------------------------- #
|
||||
# update-notifications: Choose if you cant to receive #
|
||||
# Update Notifications Ingame and or via Console #
|
||||
# --------------------------------------------------- #
|
||||
# disabledCategories: A List of Categories which will #
|
||||
# be ignored by the Plugin #
|
||||
# --------------------------------------------------- #
|
||||
# langFile: Used to determine which Language is used. #
|
||||
# You can use the default Languages as template to #
|
||||
# create your own Language Settings. #
|
||||
# --------------------------------------------------- #
|
||||
# reducedDebug: Will suppress any Debug Info from the #
|
||||
# Plugin #
|
||||
# #
|
||||
# Feel free to send me your Languages so others can #
|
||||
# use it too! (You will also be credited in the #
|
||||
@ -51,5 +67,6 @@ economy:
|
||||
update-notifications:
|
||||
onJoin: true
|
||||
console: true
|
||||
disabledCategories: []
|
||||
langFile: none
|
||||
reducedDebug: true
|
@ -1,17 +0,0 @@
|
||||
# Categories are Case Sensitive!
|
||||
# ignoreInvalid will skip invalid Categories while loading
|
||||
ignoreInvalid: false
|
||||
categories:
|
||||
- "Alphabet"
|
||||
- "Blocks"
|
||||
- "Characters"
|
||||
- "Color"
|
||||
- "Devices"
|
||||
- "Emojis"
|
||||
- "Event Heads"
|
||||
- "Food"
|
||||
- "Games"
|
||||
- "Interior"
|
||||
- "Misc"
|
||||
- "Mobs"
|
||||
- "Pokemon"
|
Loading…
Reference in New Issue
Block a user