mirror of
https://github.com/darksaid98/SupremeTags.git
synced 2026-12-01 22:22:13 +00:00
1.3.7
This commit is contained in:
1 parent
2c17494fbd
commit
b76c9c8e19
4 files changed
+89
-9
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.noscape.project.supremetags</groupId>
|
||||
<artifactId>SupremeTags</artifactId>
|
||||
<version>1.3.6</version>
|
||||
<version>1.3.7</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>SupremeTags</name>
|
||||
|
||||
@@ -5,9 +5,13 @@ import net.noscape.project.supremetags.guis.*;
|
||||
import net.noscape.project.supremetags.storage.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.configuration.file.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import static net.noscape.project.supremetags.utils.Utils.*;
|
||||
|
||||
public class Tags implements CommandExecutor {
|
||||
@@ -20,10 +24,10 @@ public class Tags implements CommandExecutor {
|
||||
if (args.length == 0) {
|
||||
} else if (args.length == 3) {
|
||||
if (args[0].equalsIgnoreCase("create")) {
|
||||
String name = args[1];
|
||||
String tag = args[2];
|
||||
String name = args[1];
|
||||
String tag = args[2];
|
||||
|
||||
SupremeTags.getInstance().getTagManager().createTag(sender, name, tag);
|
||||
SupremeTags.getInstance().getTagManager().createTag(sender, name, tag, "&7My tag is " + name, "supremetags.tag." + name);
|
||||
} else if (args[0].equalsIgnoreCase("settag")) {
|
||||
String name = args[1];
|
||||
String tag = args[2];
|
||||
@@ -92,7 +96,11 @@ public class Tags implements CommandExecutor {
|
||||
if (cmd.getName().equalsIgnoreCase("tags")) {
|
||||
if (args.length == 0) {
|
||||
if (player.hasPermission("supremetags.menu")) {
|
||||
new TagMenu(SupremeTags.getMenuUtil(player)).open();
|
||||
if (hasTags(player)) {
|
||||
new TagMenu(SupremeTags.getMenuUtil(player)).open();
|
||||
} else {
|
||||
msgPlayer(player, "&cYou have no tags yet.");
|
||||
}
|
||||
} else {
|
||||
msgPlayer(player, "&cNo Permission, required permission: &7'supremetags.menu'");
|
||||
}
|
||||
@@ -102,7 +110,7 @@ public class Tags implements CommandExecutor {
|
||||
String name = args[1];
|
||||
String tag = args[2];
|
||||
|
||||
SupremeTags.getInstance().getTagManager().createTag(player, name, tag);
|
||||
SupremeTags.getInstance().getTagManager().createTag(player, name, tag, "&7My tag is " + name, "supremetags.tag." + name);
|
||||
} else {
|
||||
msgPlayer(player, "&cNo Permission.");
|
||||
}
|
||||
@@ -149,14 +157,47 @@ public class Tags implements CommandExecutor {
|
||||
"&6/tags &7- will open the tag menu.",
|
||||
"&6/tags create <identifier> <tag> &7- creates a new tag.",
|
||||
"&6/tags delete <identifier> &7- creates a new tag.",
|
||||
"&6/tags settag <identifier> <tag> &7- sets tag style for the existing tag.",
|
||||
"&6/tags set <player> <identifier> &7- sets a new tag for that player.",
|
||||
"&6/tags reset <player> &7- resets the players tag to None.",
|
||||
"&6/tags merge &7- merges deluxetags into supremetags.",
|
||||
"&6/tags reload &7- reloads the config.yml & unloads/loads tags.",
|
||||
"&6/tags help &7- displays this help message.",
|
||||
"");
|
||||
} else {
|
||||
msgPlayer(player, "&cNo Permission.");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("merge")) {
|
||||
if (player.hasPermission("supremetags.admin")) {
|
||||
File configFile = new File(Bukkit.getServer().getWorldContainer().getAbsolutePath() + "/plugins/DeluxeTags/config.yml"); // First we will load the file.
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(configFile); // Now we will load the file into a FileConfiguration.
|
||||
|
||||
//deluxetags:
|
||||
//example:
|
||||
//order: 1
|
||||
//tag: '&8[&bDeluxeTags&8]'
|
||||
//description: '&cAwarded for using DeluxeTags!'
|
||||
//permission: deluxetags.tag.example
|
||||
|
||||
if (config.getConfigurationSection("deluxetags") != null) {
|
||||
for (String identifier : Objects.requireNonNull(config.getConfigurationSection("deluxetags")).getKeys(false)) {
|
||||
if (!SupremeTags.getInstance().getTagManager().getTags().containsKey(identifier)) {
|
||||
|
||||
String tag = config.getString("deluxetags." + identifier + ".tag");
|
||||
String description = config.getString("deluxetags." + identifier + ".description");
|
||||
String permission = config.getString("deluxetags." + identifier + ".permission");
|
||||
|
||||
SupremeTags.getInstance().getTagManager().createTag(player, identifier, tag, description, permission);
|
||||
}
|
||||
|
||||
msgPlayer(player, "&6Merger: &7Added all new tags from &6DeluxeTags&7 were added, any existing tags with the same name won't be added.");
|
||||
}
|
||||
} else {
|
||||
msgPlayer(player, "&6Error: &7DeluxeTags tag config area is empty.");
|
||||
}
|
||||
} else {
|
||||
msgPlayer(player, "&cNo Permission.");
|
||||
}
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("delete")) {
|
||||
@@ -197,4 +238,12 @@ public class Tags implements CommandExecutor {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasTags(Player player) {
|
||||
for (String tag : SupremeTags.getInstance().getTagManager().getTags().keySet())
|
||||
|
||||
if (player.hasPermission(Objects.requireNonNull(SupremeTags.getInstance().getConfig().getString("tags." + tag + ".permission"))))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -87,8 +87,35 @@ public class TagMenu extends Paged {
|
||||
if(index >= tag.size()) break;
|
||||
if (tag.get(index) != null){
|
||||
|
||||
if (menuUtil.getOwner().hasPermission(Objects.requireNonNull(SupremeTags.getInstance().getConfig().getString("tags." + tag.get(index) + ".permission")))) {
|
||||
String permission = SupremeTags.getInstance().getConfig().getString("tags." + tag.get(index) + ".permission");
|
||||
|
||||
assert permission != null;
|
||||
if (menuUtil.getOwner().hasPermission(permission) && !permission.equalsIgnoreCase("none")) {
|
||||
|
||||
ItemStack tagItem = new ItemStack(Material.valueOf(Objects.requireNonNull(SupremeTags.getInstance().getConfig().getString("gui.layout.tag-material")).toUpperCase()), 1);
|
||||
ItemMeta tagMeta = tagItem.getItemMeta();
|
||||
assert tagMeta != null;
|
||||
|
||||
String displayname = Objects.requireNonNull(SupremeTags.getInstance().getConfig().getString("gui.style.tag-item.displayname")).replaceAll("%tag%", tags.get(tag.get(index)).getTag());
|
||||
|
||||
tagMeta.setDisplayName(format(displayname));
|
||||
tagMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
tagMeta.addItemFlags(ItemFlag.HIDE_DYE);
|
||||
tagMeta.addItemFlags(ItemFlag.HIDE_DESTROYS);
|
||||
|
||||
// set lore
|
||||
ArrayList<String> lore = (ArrayList<String>) SupremeTags.getInstance().getConfig().getStringList("gui.style.tag-item.lore");
|
||||
lore.replaceAll(s -> ChatColor.translateAlternateColorCodes('&', s).replaceAll("%description%", format(Objects.requireNonNull(SupremeTags.getInstance().getConfig().getString("tags." + tag.get(index) + ".description")))));
|
||||
lore.replaceAll(s -> ChatColor.translateAlternateColorCodes('&', s).replaceAll("%identifier%", tags.get(tag.get(index)).getIdentifier()));
|
||||
lore.replaceAll(s -> ChatColor.translateAlternateColorCodes('&', s).replaceAll("%tag%", tags.get(tag.get(index)).getTag()));
|
||||
|
||||
tagMeta.setLore(lore);
|
||||
|
||||
tagItem.setItemMeta(tagMeta);
|
||||
|
||||
inventory.addItem(tagItem);
|
||||
dataItem.put(index, tags.get(tag.get(index)).getIdentifier());
|
||||
} else if (!menuUtil.getOwner().hasPermission(permission) && permission.equalsIgnoreCase("none")) {
|
||||
ItemStack tagItem = new ItemStack(Material.valueOf(Objects.requireNonNull(SupremeTags.getInstance().getConfig().getString("gui.layout.tag-material")).toUpperCase()), 1);
|
||||
ItemMeta tagMeta = tagItem.getItemMeta();
|
||||
assert tagMeta != null;
|
||||
|
||||
@@ -16,12 +16,14 @@ public class TagManager {
|
||||
private final Map<String, Tag> tags = new HashMap<>();
|
||||
private final Map<Integer, String> dataItem = new HashMap<>();
|
||||
|
||||
public void createTag(Player player, String identifier, String tag_string) {
|
||||
public void createTag(Player player, String identifier, String tag_string, String description, String permission) {
|
||||
if (!tags.containsKey(identifier)) {
|
||||
Tag tag = new Tag(identifier, tag_string);
|
||||
tags.put(identifier, tag);
|
||||
|
||||
SupremeTags.getInstance().getConfig().set("tags." + identifier + ".tag", tag_string);
|
||||
SupremeTags.getInstance().getConfig().set("tags." + identifier + ".permission", permission);
|
||||
SupremeTags.getInstance().getConfig().set("tags." + identifier + ".description", description);
|
||||
SupremeTags.getInstance().saveConfig();
|
||||
SupremeTags.getInstance().reloadConfig();
|
||||
|
||||
@@ -31,12 +33,14 @@ public class TagManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void createTag(CommandSender player, String identifier, String tag_string) {
|
||||
public void createTag(CommandSender player, String identifier, String tag_string, String description, String permission) {
|
||||
if (!tags.containsKey(identifier)) {
|
||||
Tag tag = new Tag(identifier, tag_string);
|
||||
tags.put(identifier, tag);
|
||||
|
||||
SupremeTags.getInstance().getConfig().set("tags." + identifier + ".tag", tag_string);
|
||||
SupremeTags.getInstance().getConfig().set("tags." + identifier + ".permission", permission);
|
||||
SupremeTags.getInstance().getConfig().set("tags." + identifier + ".description", description);
|
||||
SupremeTags.getInstance().saveConfig();
|
||||
SupremeTags.getInstance().reloadConfig();
|
||||
|
||||
|
||||
Reference in new issue
Block a user