mirror of
https://github.com/IHasName/CustomHeads.git
synced 2025-02-17 19:21:28 +01:00
Fixed Permissions and some Language Files
This commit is contained in:
parent
c2ed19bd67
commit
a2ed15a03c
13
pom.xml
13
pom.xml
@ -36,15 +36,6 @@
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<!--<plugin>-->
|
||||
<!--<version>3.6.1</version>-->
|
||||
<!--<groupId>org.apache.maven.plugins</groupId>-->
|
||||
<!--<artifactId>maven-compiler-plugin</artifactId>-->
|
||||
<!--<configuration>-->
|
||||
<!--<source>1.8</source>-->
|
||||
<!--<target>1.8</target>-->
|
||||
<!--</configuration>-->
|
||||
<!--</plugin>-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
@ -78,8 +69,8 @@
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<!--<outputDirectory>N:\@OtherStuff\Netzwerk\hello_pom_readers _=D\plugins</outputDirectory>-->
|
||||
<outputDirectory>N:\@OtherStuff\Netzwerk\1.12\plugins</outputDirectory>
|
||||
<!--<outputDirectory>N:\@OtherStuff\Servers\hello_pom_readers _=D\plugins</outputDirectory>-->
|
||||
<outputDirectory>N:\@OtherStuff\Servers\1.12\plugins</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
@ -15,7 +15,7 @@
|
||||
"sub_categories": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "Holz",
|
||||
"name": "&6Holz",
|
||||
"icon": {
|
||||
"item": "SKULL_ITEM",
|
||||
"damage": 3,
|
||||
@ -134,7 +134,7 @@
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Stein",
|
||||
"name": "&7Stein",
|
||||
"icon": {
|
||||
"item": "SKULL_ITEM",
|
||||
"damage": 3,
|
||||
@ -253,7 +253,7 @@
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Nummern",
|
||||
"name": "&aNummern",
|
||||
"icon": {
|
||||
"item": "SKULL_ITEM",
|
||||
"damage": 3,
|
||||
|
@ -79,7 +79,7 @@ CATEGORIES:
|
||||
- '&7Benutzt: &e{USED}'
|
||||
HOVERINFO_SUBCATEGORY:
|
||||
- '&7ID: &e{ID}'
|
||||
- '&7Used: &e{USED}'
|
||||
- '&7Benutzt: &e{USED}'
|
||||
REMOVE:
|
||||
NOTFOUND: '&eRemove: &7Konnte nichts unter der ID &c{ID} &7finden'
|
||||
INUSE: '&eRemove: &7Kann Kategorie "&c{CATEGORY}" &7nicht entfernen da sie verwendet wird'
|
||||
|
@ -15,7 +15,7 @@
|
||||
"sub_categories": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "Wood",
|
||||
"name": "&6Wood",
|
||||
"icon": {
|
||||
"item": "SKULL_ITEM",
|
||||
"damage": 3,
|
||||
@ -134,7 +134,7 @@
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Stone",
|
||||
"name": "&7Stone",
|
||||
"icon": {
|
||||
"item": "SKULL_ITEM",
|
||||
"damage": 3,
|
||||
@ -253,7 +253,7 @@
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Numbers",
|
||||
"name": "&aNumbers",
|
||||
"icon": {
|
||||
"item": "SKULL_ITEM",
|
||||
"damage": 3,
|
||||
|
@ -87,7 +87,7 @@ public class CustomHeads extends JavaPlugin {
|
||||
private static boolean historyEnabled = false;
|
||||
private static boolean canSeeOwnHistory = false;
|
||||
private static boolean hasEconomy = false;
|
||||
private static boolean keepCategoryPermissions = true;
|
||||
private static boolean keepCategoryPermissions = false;
|
||||
private String bukkitVersion = Bukkit.getVersion().substring(Bukkit.getVersion().lastIndexOf("("));
|
||||
private boolean isInit = false;
|
||||
private static boolean reducedDebug = false;
|
||||
@ -139,6 +139,10 @@ public class CustomHeads extends JavaPlugin {
|
||||
return hasEconomy;
|
||||
}
|
||||
|
||||
public static boolean keepCategoryPermissions() {
|
||||
return keepCategoryPermissions;
|
||||
}
|
||||
|
||||
public static boolean hasReducedDebug() {
|
||||
return reducedDebug;
|
||||
}
|
||||
@ -148,10 +152,12 @@ public class CustomHeads extends JavaPlugin {
|
||||
sender.sendMessage((console ? chPrefix : "") + languageManager.RELOAD_CONFIG);
|
||||
headsConfig.reload();
|
||||
reducedDebug = headsConfig.get().getBoolean("reducedDebug");
|
||||
keepCategoryPermissions = headsConfig.get().getBoolean("keepCategoryPermissions");
|
||||
reloadEconomy();
|
||||
sender.sendMessage((console ? chPrefix : "") + languageManager.RELOAD_HISTORY);
|
||||
reloadHistoryData();
|
||||
sender.sendMessage((console ? chPrefix : "") + languageManager.RELOAD_LANGUAGE);
|
||||
PlayerWrapper.clearCache();
|
||||
if (!reloadTranslations(headsConfig.get().getString("langFile"))) {
|
||||
sender.sendMessage((console ? chPrefix : "") + languageManager.RELOAD_FAILED);
|
||||
return false;
|
||||
@ -164,8 +170,10 @@ public class CustomHeads extends JavaPlugin {
|
||||
public static boolean reload() {
|
||||
headsConfig.reload();
|
||||
reducedDebug = headsConfig.get().getBoolean("reducedDebug");
|
||||
keepCategoryPermissions = headsConfig.get().getBoolean("keepCategoryPermissions");
|
||||
reloadHistoryData();
|
||||
reloadEconomy();
|
||||
PlayerWrapper.clearCache();
|
||||
if (!reloadTranslations(headsConfig.get().getString("langFile"))) {
|
||||
return false;
|
||||
}
|
||||
@ -251,10 +259,12 @@ public class CustomHeads extends JavaPlugin {
|
||||
// Load rest of the Plugin after Language Download
|
||||
private void loadRest() {
|
||||
reducedDebug = headsConfig.get().getBoolean("reducedDebug");
|
||||
keepCategoryPermissions = headsConfig.get().getBoolean("keepCategoryPermissions");
|
||||
categoryLoaderConfig = new Configs(instance, "loadedCategories.yml", true);
|
||||
|
||||
tagEditor = new TagEditor("chTags");
|
||||
|
||||
|
||||
JsonFile.setDefaultSubfolder("plugins/CustomHeads");
|
||||
|
||||
// Convert old Head-Data if present
|
||||
@ -290,6 +300,7 @@ public class CustomHeads extends JavaPlugin {
|
||||
|
||||
// Check for updates
|
||||
spigetFetcher = new SpigetFetcher(29057);
|
||||
SpigetFetcher.setUserAgent("UC-CustomHeads");
|
||||
|
||||
spigetFetcher.fetchUpdates(new SpigetFetcher.FetchResult() {
|
||||
public void updateAvailable(SpigetFetcher.ResourceRelease release, SpigetFetcher.ResourceUpdate update) {
|
||||
@ -339,7 +350,7 @@ public class CustomHeads extends JavaPlugin {
|
||||
nextIcon = new ItemEditor(nextIcon)
|
||||
.setDisplayName(hasPermission(player, category.getPermission()) || unlocked ? "§a" + nextIcon.getItemMeta().getDisplayName() : "§7" + ChatColor.stripColor(nextIcon.getItemMeta().getDisplayName()) + " " + CustomHeads.getLanguageManager().LOCKED)
|
||||
.addLoreLine(CustomHeads.hasEconomy() ? bought ? CustomHeads.getLanguageManager().ECONOMY_BOUGHT : Utils.getPriceFormatted(category, true) + "\n" + CustomHeads.getLanguageManager().ECONOMY_BUY_CATEGORY_PROMPT : null)
|
||||
.addLoreLines(hasPermission(player, "heads.view.permissions") ? Arrays.asList("§8>===-------", "§7§oPermission: " + category.getPermission()) : null)
|
||||
.addLoreLines(hasPermission(player, "heads.view.permissions") ? Arrays.asList(" ", "§7§oPermission: " + category.getPermission()) : null)
|
||||
.getItem();
|
||||
if (CustomHeads.hasEconomy()) {
|
||||
if (!bought) {
|
||||
|
@ -2,7 +2,6 @@ package de.mrstein.customheads.listener;
|
||||
|
||||
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.SubCategory;
|
||||
import de.mrstein.customheads.headwriter.HeadFontType;
|
||||
@ -27,7 +26,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.mrstein.customheads.utils.Utils.*;
|
||||
|
||||
@ -66,14 +64,13 @@ public class InventoryListener implements Listener {
|
||||
if (categoryArgs[0].equals("category")) {
|
||||
Category category = CustomHeads.getCategoryLoader().getCategory(categoryArgs[1]);
|
||||
ItemStack nextIcon = category.nextIcon();
|
||||
boolean unlocked = customHeadsPlayer.getUnlockedCategories(false).stream().map(BaseCategory::getId).collect(Collectors.toList()).contains(category.getId());
|
||||
boolean bought = customHeadsPlayer.getUnlockedCategories(true).stream().map(BaseCategory::getId).collect(Collectors.toList()).contains(category.getId());
|
||||
boolean bought = customHeadsPlayer.getUnlockedCategories(true).contains(category);
|
||||
nextIcon = new ItemEditor(nextIcon)
|
||||
.setDisplayName(hasPermission(player, category.getPermission()) || unlocked ? "§a" + nextIcon.getItemMeta().getDisplayName() : "§7" + ChatColor.stripColor(nextIcon.getItemMeta().getDisplayName()) + " " + CustomHeads.getLanguageManager().LOCKED)
|
||||
.setDisplayName(customHeadsPlayer.getUnlockedCategories(CustomHeads.hasEconomy() && !CustomHeads.keepCategoryPermissions()).contains(category) ? "§a" + nextIcon.getItemMeta().getDisplayName() : "§7" + ChatColor.stripColor(nextIcon.getItemMeta().getDisplayName()) + " " + CustomHeads.getLanguageManager().LOCKED)
|
||||
.addLoreLine(CustomHeads.hasEconomy() ? bought ? CustomHeads.getLanguageManager().ECONOMY_BOUGHT : Utils.getPriceFormatted(category, true) + "\n" + CustomHeads.getLanguageManager().ECONOMY_BUY_CATEGORY_PROMPT : null)
|
||||
.addLoreLines(hasPermission(player, "heads.view.permissions") ? Arrays.asList("§8>===-------", "§7§oPermission: " + category.getPermission()) : null)
|
||||
.addLoreLines(hasPermission(player, "heads.view.permissions") ? Arrays.asList(" ", "§7§oPermission: " + category.getPermission()) : null)
|
||||
.getItem();
|
||||
if (CustomHeads.hasEconomy()) {
|
||||
if (CustomHeads.hasEconomy() && !CustomHeads.keepCategoryPermissions()) {
|
||||
if (!bought) {
|
||||
nextIcon = CustomHeads.getTagEditor().addTags(nextIcon, "buyCategory", category.getId());
|
||||
}
|
||||
@ -89,7 +86,7 @@ public class InventoryListener implements Listener {
|
||||
meta.setOwner(player.getName());
|
||||
contentItem.setItemMeta(meta);
|
||||
} else if (CustomHeads.getTagEditor().getTags(contentItem).contains("saved_heads")) {
|
||||
contentItem = new ItemEditor(contentItem).setDisplayName(hasPermission(player, "heads.use.more") ? contentItem.getItemMeta().getDisplayName().replace("{SIZE}", "(" + customHeadsPlayer.getSavedHeads().size() + ")") : "§7" + ChatColor.stripColor(contentItem.getItemMeta().getDisplayName().replace("{SIZE}", "") + " " + CustomHeads.getLanguageManager().LOCKED)).addLoreLines(hasPermission(player, "heads.view.permissions") ? Arrays.asList("§8>===-------", "§7§oPermission: heads.use.more") : null).getItem();
|
||||
contentItem = new ItemEditor(contentItem).setDisplayName(hasPermission(player, "heads.use.more") ? contentItem.getItemMeta().getDisplayName().replace("{SIZE}", "(" + customHeadsPlayer.getSavedHeads().size() + ")") : "§7" + ChatColor.stripColor(contentItem.getItemMeta().getDisplayName().replace("{SIZE}", "") + " " + CustomHeads.getLanguageManager().LOCKED)).addLoreLines(hasPermission(player, "heads.view.permissions") ? Arrays.asList(" ", "§7§oPermission: heads.use.more") : null).getItem();
|
||||
}
|
||||
if (CustomHeads.getTagEditor().getTags(contentItem).contains("openMenu")) {
|
||||
contentItem = CustomHeads.getTagEditor().addTags(contentItem, "needsPermission", CustomHeads.getLooks().getMenuInfo(CustomHeads.getTagEditor().getTags(contentItem).get(CustomHeads.getTagEditor().indexOf(contentItem, "openMenu") + 1).toLowerCase())[1]);
|
||||
@ -97,7 +94,7 @@ public class InventoryListener implements Listener {
|
||||
if (CustomHeads.getTagEditor().getTags(contentItem).contains("needsPermission")) {
|
||||
contentItem = new ItemEditor(contentItem)
|
||||
.setDisplayName(hasPermission(player, CustomHeads.getTagEditor().getTags(contentItem).get(CustomHeads.getTagEditor().indexOf(contentItem, "needsPermission") + 1)) ? "§a" + contentItem.getItemMeta().getDisplayName() : "§7" + ChatColor.stripColor(contentItem.getItemMeta().getDisplayName()) + " " + CustomHeads.getLanguageManager().LOCKED)
|
||||
.addLoreLines(hasPermission(player, "heads.view.permissions") ? Arrays.asList("§8>===-------", "§7Permission: " + CustomHeads.getTagEditor().getTags(contentItem).get(CustomHeads.getTagEditor().indexOf(contentItem, "needsPermission") + 1)) : null)
|
||||
.addLoreLines(hasPermission(player, "heads.view.permissions") ? Arrays.asList(" ", "§7Permission: " + CustomHeads.getTagEditor().getTags(contentItem).get(CustomHeads.getTagEditor().indexOf(contentItem, "needsPermission") + 1)) : null)
|
||||
.getItem();
|
||||
}
|
||||
}
|
||||
@ -114,7 +111,7 @@ public class InventoryListener implements Listener {
|
||||
if (event.getInventory() == null || event.getRawSlot() > event.getInventory().getSize() || event.getInventory().getType() != InventoryType.CHEST || event.getCurrentItem() == null || !hasPermission(player, "heads.use"))
|
||||
return;
|
||||
|
||||
player.sendMessage("§7[CHTags Tags] §r" + CustomHeads.getTagEditor().getTags(event.getCurrentItem()));
|
||||
// player.sendMessage("§7[CHTags Tags] §r" + CustomHeads.getTagEditor().getTags(event.getCurrentItem())); // Yeah debug at its finest
|
||||
|
||||
if (event.getInventory().getTitle().equals(CustomHeads.getLanguageManager().LOADING)) {
|
||||
event.setCancelled(true);
|
||||
@ -316,7 +313,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
if (args[0].equalsIgnoreCase("subCategory")) {
|
||||
SubCategory subCategory = CustomHeads.getCategoryLoader().getSubCategory(args[1]);
|
||||
if (subCategory != null && hasPermission(player, subCategory.getOriginCategory().getPermission())) {
|
||||
if (subCategory != null && customHeadsPlayer.getUnlockedCategories(CustomHeads.hasEconomy() && !CustomHeads.keepCategoryPermissions()).contains(subCategory.getOriginCategory())) {
|
||||
openPreloader(player);
|
||||
List<ItemStack> heads = new ArrayList<>(subCategory.getHeads());
|
||||
player.openInventory(new ScrollableInventory(subCategory.getName(), heads).setBarItem(1, Utils.getBackButton("invAction", "goBack#>category#>" + subCategory.getOriginCategory().getId())).setContentsClonable(true).getAsInventory());
|
||||
@ -394,7 +391,7 @@ public class InventoryListener implements Listener {
|
||||
player.openInventory(cloneInventory(menu, player));
|
||||
} else if (args[1].equalsIgnoreCase("category")) {
|
||||
Category originCategory = CustomHeads.getCategoryLoader().getCategory(args[2]);
|
||||
if (originCategory != null && hasPermission(player, originCategory.getPermission()))
|
||||
if (originCategory != null && customHeadsPlayer.getUnlockedCategories(CustomHeads.hasEconomy() && !CustomHeads.keepCategoryPermissions()).contains(originCategory))
|
||||
player.openInventory(CustomHeads.getLooks().subCategoryLooks.get(Integer.parseInt(originCategory.getId())));
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("retrySearch")) {
|
||||
@ -496,8 +493,8 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
|
||||
// No lookin at my Tags
|
||||
if (itemTags.contains("tempTags")) {
|
||||
event.setCurrentItem(TagEditor.clearTags(event.getCurrentItem()));
|
||||
if (itemTags.contains("tempTags") && player.getItemOnCursor() != null) {
|
||||
player.setItemOnCursor(TagEditor.clearTags(event.getCurrentItem()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,10 @@ public class CHCommand implements CommandExecutor {
|
||||
/* Test Command plez Ignore
|
||||
if (args[0].equalsIgnoreCase("test")) {
|
||||
Configs tempcon = new Configs(CustomHeads.getInstance(), "test.yml", false, "testing");
|
||||
return false;
|
||||
if(args[1].equalsIgnoreCase("gettags")) {
|
||||
player.sendMessage("[Tags] " + CustomHeads.getTagEditor().getTags(player.getItemInHand()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
@ -184,7 +187,7 @@ public class CHCommand implements CommandExecutor {
|
||||
hoverInfoCategoryBuilder = hoverInfoCategoryBuilder.substring(0, hoverInfoCategoryBuilder.length() - 1);
|
||||
hoverInfoCategoryBuilder += "\"}";
|
||||
|
||||
Utils.sendJSONMessage("[\"\",{\"text\":\" §e" + (i == (categories.size() - 1) ? "??" : "??") + " \"},{\"text\":\"" + (cCategory.isUsed() ? "§a" : "§7") + ChatColor.stripColor(cCategory.getName()) + "\"" +/*(CustomHeads.hasCategoryEditor() ? ",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/cedit " + cCategory.getId() + "\"}" : "") +*/",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + hoverInfoCategoryBuilder +/*",{\"text\":\"\n" + (CustomHeads.hasCategoryEditor() ? "§eClick to open in Editor" : "§eGet CategoryCreator to\n§eopen an Editor") + "\"}" +*/"]}}}]", player);
|
||||
Utils.sendJSONMessage("[\"\",{\"text\":\" §e" + (i == (categories.size() - 1) ? "┗╸" : "┣╸") + " \"},{\"text\":\"" + (cCategory.isUsed() ? "§a" : "§7") + ChatColor.stripColor(cCategory.getName()) + "\"" +/*(CustomHeads.hasCategoryEditor() ? ",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/cedit " + cCategory.getId() + "\"}" : "") +*/",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + hoverInfoCategoryBuilder +/*",{\"text\":\"\n" + (CustomHeads.hasCategoryEditor() ? "§eClick to open in Editor" : "§eGet CategoryCreator to\n§eopen an Editor") + "\"}" +*/"]}}}]", player);
|
||||
if (cCategory.hasSubCategories()) {
|
||||
for (int j = 0; j < cCategory.getSubCategories().size(); j++) {
|
||||
SubCategory cSubCategory = cCategory.getSubCategories().get(j);
|
||||
@ -193,11 +196,11 @@ public class CHCommand implements CommandExecutor {
|
||||
for (String hoverInfoSubCategory : CustomHeads.getLanguageManager().CATEGORIES_BASECOMMAND_HOVERINFO_SUBCATEGORY) {
|
||||
hoverInfoSubCategoryBuilder += hoverInfoSubCategory + "\n";
|
||||
}
|
||||
hoverInfoSubCategoryBuilder = hoverInfoSubCategoryBuilder.replace("{ID}", "" + cSubCategory.getId()).replace("{CATEGORY}", cSubCategory.getName()).replace("{USED}", cSubCategory.isUsed() ? CustomHeads.getLanguageManager().YES : CustomHeads.getLanguageManager().NO);
|
||||
hoverInfoSubCategoryBuilder = hoverInfoSubCategoryBuilder.replace("{ID}", "" + cCategory.getId()).replace("{CATEGORY}", cCategory.getName()).replace("{USED}", cSubCategory.isUsed() ? CustomHeads.getLanguageManager().YES : CustomHeads.getLanguageManager().NO);
|
||||
hoverInfoSubCategoryBuilder = hoverInfoSubCategoryBuilder.substring(0, hoverInfoSubCategoryBuilder.length() - 1);
|
||||
hoverInfoSubCategoryBuilder += "\"}";
|
||||
|
||||
Utils.sendJSONMessage("[\"\",{\"text\":\" §e" + (i == (categories.size() - 1) ? " " : "? ") + " " + (j == (cCategory.getSubCategories().size() - 1) ? "??" : "??") + " \"},{\"text\":\"" + (cCategory.isUsed() ? "§a" : "§7") + ChatColor.stripColor(cSubCategory.getName()) + "\"" +/*(CustomHeads.hasCategoryEditor() ? ",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/cedit " + cSubCategory.getId() + "\"}" : "") +*/",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + hoverInfoSubCategoryBuilder +/*",{\"text\":\"\n" + (CustomHeads.hasCategoryEditor() ? "§eClick to open in Editor" : "§eGet CategoryCreator to\n§eopen an Editor") + "\"}" +*/"]}}}]", player);
|
||||
Utils.sendJSONMessage("[\"\",{\"text\":\" §e" + (i == (categories.size() - 1) ? " " : "┃ ") + " " + (j == (cCategory.getSubCategories().size() - 1) ? "┗╸" : "┣╸") + " \"},{\"text\":\"" + (cCategory.isUsed() ? "§a" : "§7") + ChatColor.stripColor(cSubCategory.getName()) + "\"" +/*(CustomHeads.hasCategoryEditor() ? ",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/cedit " + cSubCategory.getId() + "\"}" : "") +*/",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + hoverInfoSubCategoryBuilder +/*",{\"text\":\"\n" + (CustomHeads.hasCategoryEditor() ? "§eClick to open in Editor" : "§eGet CategoryCreator to\n§eopen an Editor") + "\"}" +*/"]}}}]", player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -582,11 +585,10 @@ public class CHCommand implements CommandExecutor {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
// TODO Change to new Method
|
||||
if (args.length > 1) {
|
||||
if (hasPermission(player, "heads.use.more")) {
|
||||
CustomHeadsPlayer customHeadsPlayer = CustomHeads.getApi().wrapPlayer(player);
|
||||
if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("save")) {
|
||||
CustomHeadsPlayer customHeadsPlayer = CustomHeads.getApi().wrapPlayer(player);
|
||||
if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("save")) {
|
||||
if (hasPermission(player, "heads.use.more")) {
|
||||
if (args.length > 2) {
|
||||
if (args[2].equalsIgnoreCase("-t")) {
|
||||
if (hasPermission(player, "heads.use.saveastexture")) {
|
||||
@ -638,7 +640,11 @@ public class CHCommand implements CommandExecutor {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().SAVE_NOT_SKULL);
|
||||
return true;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("remove")) {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("remove")) {
|
||||
if (hasPermission(player, "heads.use.more")) {
|
||||
if (customHeadsPlayer.deleteHead(args[1])) {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().REMOVE_SUCCESSFUL.replace("{NAME}", format(args[1])));
|
||||
return true;
|
||||
@ -646,42 +652,42 @@ public class CHCommand implements CommandExecutor {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().REMOVE_FAILED.replace("{NAME}", format(args[1])));
|
||||
return true;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("write")) {
|
||||
if (hasPermission(player, "heads.use.more.write")) {
|
||||
if (args.length < 3) {
|
||||
player.sendMessage("§cPlease Note that this Comamnd is still an Beta-Command and may cause Issues!");
|
||||
player.sendMessage(CustomHeads.getLanguageManager().COMMAND_USAGE.replace("{COMMAND}", "§c/heads write <fontName> <text>"));
|
||||
return true;
|
||||
}
|
||||
HeadFontType fontType = new HeadFontType(args[1]);
|
||||
if (!fontType.exists()) {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().WRITE_NOFONT);
|
||||
return true;
|
||||
}
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
text.append(args[i]).append(" ");
|
||||
}
|
||||
text = new StringBuilder(text.substring(0, text.length() - 1));
|
||||
HeadWriter writer = new HeadWriter(fontType, text.toString().toLowerCase(), player);
|
||||
writer.writeAt(player.getLocation());
|
||||
return true;
|
||||
}
|
||||
player.sendMessage(CustomHeads.getLanguageManager().NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String permission : Utils.getPermissions(player)) {
|
||||
for (String subCommand : Utils.getPermissions().get(permission)) {
|
||||
builder.append(subCommand).append(", ");
|
||||
}
|
||||
}
|
||||
if (builder.length() != 0)
|
||||
builder.setLength(builder.length() - 2);
|
||||
player.sendMessage(CustomHeads.getLanguageManager().COMMAND_USAGE.replace("{COMMAND}", "/heads " + (builder.length() == 0 ? "" : "<" + builder.toString() + ">")));
|
||||
player.sendMessage(CustomHeads.getLanguageManager().NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
player.sendMessage(CustomHeads.getLanguageManager().NO_PERMISSION);
|
||||
if (args[0].equalsIgnoreCase("write")) {
|
||||
if (hasPermission(player, "heads.use.more.write")) {
|
||||
if (args.length < 3) {
|
||||
player.sendMessage("§cPlease Note that this Comamnd is still an Beta-Command and may cause Issues!");
|
||||
player.sendMessage(CustomHeads.getLanguageManager().COMMAND_USAGE.replace("{COMMAND}", "§c/heads write <fontName> <text>"));
|
||||
return true;
|
||||
}
|
||||
HeadFontType fontType = new HeadFontType(args[1]);
|
||||
if (!fontType.exists()) {
|
||||
player.sendMessage(CustomHeads.getLanguageManager().WRITE_NOFONT);
|
||||
return true;
|
||||
}
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
text.append(args[i]).append(" ");
|
||||
}
|
||||
text = new StringBuilder(text.substring(0, text.length() - 1));
|
||||
HeadWriter writer = new HeadWriter(fontType, text.toString().toLowerCase(), player);
|
||||
writer.writeAt(player.getLocation());
|
||||
return true;
|
||||
}
|
||||
player.sendMessage(CustomHeads.getLanguageManager().NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String permission : Utils.getPermissions(player)) {
|
||||
for (String subCommand : Utils.getPermissions().get(permission)) {
|
||||
builder.append(subCommand).append(", ");
|
||||
}
|
||||
}
|
||||
if (builder.length() != 0)
|
||||
builder.setLength(builder.length() - 2);
|
||||
player.sendMessage(CustomHeads.getLanguageManager().COMMAND_USAGE.replace("{COMMAND}", "/heads " + (builder.length() == 0 ? "" : "<" + builder.toString() + ">")));
|
||||
return true;
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -5,6 +5,7 @@ import de.mrstein.customheads.CustomHeads;
|
||||
import de.mrstein.customheads.utils.Configs;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -14,16 +15,17 @@ import java.lang.reflect.Type;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
/*
|
||||
* Project: CustomHeads in SpigetFetcher
|
||||
* by LikeWhat
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fetches Updates for Spigot Updates Spigot Resources
|
||||
* <p>Uses Spiget Resource API by inventivetalent
|
||||
*
|
||||
@ -32,9 +34,10 @@ import java.util.logging.Level;
|
||||
*/
|
||||
public class SpigetFetcher {
|
||||
|
||||
private static final String USER_AGENT = "UC-CustomHeads";
|
||||
private static final String DESCRIPTION_URL = "https://api.spiget.org/v2/resources/%s/updates?size=2147483647&spiget__ua=SpigetDocs";
|
||||
private static final String VERSION_URL = "https://api.spiget.org/v2/resources/%s/versions?size=2147483647&spiget__ua=SpigetDocs";
|
||||
private static final String DESCRIPTION_URL = "https://api.spiget.org/v2/resources/%s/updates?size=2147483647&sort=-date";
|
||||
private static final String VERSION_URL = "https://api.spiget.org/v2/resources/%s/versions?size=2147483647&sort=-releaseDate";
|
||||
@Setter
|
||||
private static String userAgent = "UpdateChecker-1.1";
|
||||
private static final Gson GSON = new GsonBuilder().disableHtmlEscaping()
|
||||
.registerTypeAdapter(ResourceRelease.class, new ResourceRelease.Serializer())
|
||||
.registerTypeAdapter(ResourceUpdate.class, new ResourceUpdate.Serializer())
|
||||
@ -65,7 +68,7 @@ public class SpigetFetcher {
|
||||
fromCache = true;
|
||||
} else {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(versionUrlFormatted).openConnection();
|
||||
connection.addRequestProperty("User-Agent", USER_AGENT);
|
||||
connection.addRequestProperty("User-Agent", userAgent);
|
||||
connection.setReadTimeout(5000);
|
||||
versionArray = jsonParser.parse(new InputStreamReader(connection.getInputStream())).getAsJsonArray();
|
||||
}
|
||||
@ -79,7 +82,6 @@ public class SpigetFetcher {
|
||||
updateFile.get().set("lastVersionFetch", new String(Base64.encodeBase64(GSON.toJson(releaseList).getBytes())));
|
||||
updateFile.save();
|
||||
}
|
||||
Collections.reverse(releaseList);
|
||||
ResourceRelease latestRelease = releaseList.get(0);
|
||||
int latestVersion = Integer.parseInt(latestRelease.getReleaseName().replace(".", ""));
|
||||
int currentVersion = Integer.parseInt(CustomHeads.getInstance().getDescription().getVersion().replace(".", ""));
|
||||
@ -113,7 +115,7 @@ public class SpigetFetcher {
|
||||
fromCache = true;
|
||||
} else {
|
||||
HttpURLConnection descriptionConnection = (HttpURLConnection) new URL(decriptionUrlFormatted).openConnection();
|
||||
descriptionConnection.addRequestProperty("User-Agent", USER_AGENT);
|
||||
descriptionConnection.addRequestProperty("User-Agent", userAgent);
|
||||
descriptionConnection.setReadTimeout(5000);
|
||||
descriptionArray = jsonParser.parse(new InputStreamReader(descriptionConnection.getInputStream())).getAsJsonArray();
|
||||
}
|
||||
@ -126,7 +128,6 @@ public class SpigetFetcher {
|
||||
updateFile.get().set("lastDescriptionFetch", new String(Base64.encodeBase64(GSON.toJson(updateList).getBytes())));
|
||||
updateFile.save();
|
||||
}
|
||||
Collections.reverse(updateList);
|
||||
consumer.accept(updateList);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
|
@ -91,15 +91,19 @@ public class PlayerWrapper implements CustomHeadsPlayer {
|
||||
uuidObject.add("unlockedCategories", unlockedCategories);
|
||||
JsonObject historyObject = new JsonObject();
|
||||
JsonArray searchHistory = new JsonArray();
|
||||
for (String entry : customHeadsPlayer.getSearchHistory().getEntries()) {
|
||||
searchHistory.add(new JsonPrimitive(entry));
|
||||
if (customHeadsPlayer.getSearchHistory().hasHistory()) {
|
||||
for (String entry : customHeadsPlayer.getSearchHistory().getEntries()) {
|
||||
searchHistory.add(new JsonPrimitive(entry));
|
||||
}
|
||||
historyObject.add("searchHistory", searchHistory);
|
||||
}
|
||||
historyObject.add("searchHistory", searchHistory);
|
||||
JsonArray getHistory = new JsonArray();
|
||||
for (String entry : customHeadsPlayer.getGetHistory().getEntries()) {
|
||||
getHistory.add(new JsonPrimitive(entry));
|
||||
if (customHeadsPlayer.getGetHistory().hasHistory()) {
|
||||
JsonArray getHistory = new JsonArray();
|
||||
for (String entry : customHeadsPlayer.getGetHistory().getEntries()) {
|
||||
getHistory.add(new JsonPrimitive(entry));
|
||||
}
|
||||
historyObject.add("getHistory", getHistory);
|
||||
}
|
||||
historyObject.add("getHistory", getHistory);
|
||||
uuidObject.add("history", historyObject);
|
||||
|
||||
rootObjects.add(uuids.toString(), uuidObject);
|
||||
|
@ -8,7 +8,6 @@ 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.reflection.AnvilGUI;
|
||||
import de.mrstein.customheads.reflection.TagEditor;
|
||||
@ -74,7 +73,8 @@ public class Utils {
|
||||
if (perms == null) {
|
||||
perms = new HashMap<>();
|
||||
perms.put("heads.view.help", new String[]{"help"});
|
||||
perms.put("heads.use.more", new String[]{"remove", "add", "firework"});
|
||||
perms.put("heads.use.more", new String[]{"remove", "add"});
|
||||
perms.put("heads.use.more.firework", new String[]{"firework"});
|
||||
perms.put("heads.use.more.get", new String[]{"get"});
|
||||
perms.put("heads.admin", new String[]{"reload", "categories", "language"});
|
||||
perms.put("heads.view.history", new String[]{"history"});
|
||||
@ -101,6 +101,9 @@ public class Utils {
|
||||
}
|
||||
event.getPlayer().sendMessage(CustomHeads.getLanguageManager().SEARCHING.replace("{SEARCH}", event.getName()));
|
||||
CHSearchQuery query = new CHSearchQuery(event.getName());
|
||||
List<Category> categories = CustomHeads.getCategoryLoader().getCategoryList();
|
||||
categories.removeAll(CustomHeads.getApi().wrapPlayer(player).getUnlockedCategories(false));
|
||||
query.excludeCategories(categories);
|
||||
if (query.getResults().isEmpty()) {
|
||||
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"));
|
||||
@ -205,7 +208,7 @@ public class Utils {
|
||||
subCommands.put("help", new String[]{"heads.view.help", "§eOpens this Menu\n{PERMISSION}", "/heads help", "§7Permission: §eheads.view.help\n"});
|
||||
subCommands.put("remove", new String[]{"heads.use.more", "§eRemove an Head from your Collection\n{PERMISSION}§eTip: §7You can Tab to \n§7AutoComplete your Heads", "/heads remove <headname>", "§7Permission: §eheads.use.more\n"});
|
||||
subCommands.put("add", new String[]{"heads.use.more", "§eAdd an Head to your Collection\n{PERMISSION}", "/heads add <headname> [-t]", "§7Permission: §eheads.use.more\n§7heads.use.saveastexture for -t\n"});
|
||||
subCommands.put("firework", new String[]{"heads.use.more", "§eStart some Fireworks\n{PERMISSION}", "/heads firework", "§7Permission: §eheads.use.more\n"});
|
||||
subCommands.put("firework", new String[]{"heads.use.more.firework", "§eStart some Fireworks\n{PERMISSION}", "/heads firework", "§7Permission: §eheads.use.more.firework\n"});
|
||||
subCommands.put("get", new String[]{"heads.use.more.get", "§eGives you an Head from an Player\n{PERMISSION}", "/heads get <playername>", "§7Permission: §eheads.use.more.get\n"});
|
||||
subCommands.put("reload", new String[]{"heads.admin", "§eReloads the Plugin\n{PERMISSION}§eGood to know: §7heads.admin acts like heads.*", "/heads reload", "§7Permission: §eheads.admin\n"});
|
||||
subCommands.put("categories", new String[]{"heads.admin", "§eShows you a List of all Categories\n{PERMISSION}§eGood to know: §7heads.admin acts like heads.*", "/heads categories [remove, delete, import]", "§7Permission: §eheads.admin\n"});
|
||||
@ -328,7 +331,7 @@ public class Utils {
|
||||
|
||||
public static void openCategory(Category category, Player player, String menuID) {
|
||||
CustomHeadsPlayer customHeadsPlayer = CustomHeads.getApi().wrapPlayer(player);
|
||||
if (customHeadsPlayer.getUnlockedCategories(false).stream().map(BaseCategory::getId).collect(Collectors.toList()).contains(category.getId())) {
|
||||
if (customHeadsPlayer.getUnlockedCategories(CustomHeads.hasEconomy() && !CustomHeads.keepCategoryPermissions()).contains(category)) {
|
||||
if (category.hasSubCategories()) {
|
||||
player.openInventory(CustomHeads.getLooks().subCategoryLooks.get(Integer.parseInt(category.getId())));
|
||||
} else {
|
||||
|
@ -22,7 +22,8 @@
|
||||
# --------------------------------------------------- #
|
||||
# keepCategoryPermissions: Used when Economy is #
|
||||
# enabled. Categories will only be able the be #
|
||||
# unlocked with Money (or for free when not defined) #
|
||||
# unlocked with Money when false #
|
||||
# (or for free when not defined) #
|
||||
# --------------------------------------------------- #
|
||||
# langFile: Used to determine which Language is used. #
|
||||
# You can use the default Languages as template to #
|
||||
@ -43,4 +44,4 @@ keepCategoryPermissions: true
|
||||
useEconomy: false
|
||||
updateNotify: true
|
||||
langFile: none
|
||||
reducedDebug: false
|
||||
reducedDebug: true
|
@ -23,6 +23,24 @@ permissions:
|
||||
default: op
|
||||
heads.viewCategory:
|
||||
default: op
|
||||
heads.use.more:
|
||||
default: op
|
||||
heads.use.more.firework:
|
||||
children:
|
||||
heads.use.more: true
|
||||
default: op
|
||||
heads.use.more.search:
|
||||
children:
|
||||
heads.use.more: true
|
||||
default: op
|
||||
heads.use.more.write:
|
||||
children:
|
||||
heads.use.more: true
|
||||
default: op
|
||||
heads.use.more.get:
|
||||
children:
|
||||
heads.use.more: true
|
||||
default: op
|
||||
heads.admin:
|
||||
description: Gives all Permission for the Plugin
|
||||
children:
|
||||
|
Loading…
Reference in New Issue
Block a user