9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-22 00:19:19 +00:00

Compare commits

..

14 Commits

Author SHA1 Message Date
LoJoSho
614892500c Version bump (2.1.2) 2023-02-03 13:16:38 -06:00
LoJoSho
872282f77a Fix publishing 2023-02-03 13:16:26 -06:00
LoJoSho
c0483bfefe Action Menu can override target menu permission with "-o" 2023-02-03 12:35:12 -06:00
LoJoSho
aecd40ba5a Hidden reason now saved in database 2023-02-03 12:19:34 -06:00
LoJoSho
c3db45cfc4 update checker more in align with HMCWraps 2023-02-02 22:26:30 -06:00
LoJoSho
99bc0a0756 Add color to apply command 2023-02-02 21:30:07 -06:00
LoJoSho
e9afd6deb8 Add ability to silent messages in command with -s 2023-02-02 21:25:29 -06:00
lucian929
0770ac456d Delete publish.yml 2023-02-02 17:44:16 -05:00
lucian929
327d602491 Fix repository link 2023-02-02 22:33:19 +00:00
LoJoSho
65f162c89c Update publish.yml 2023-02-02 15:51:24 -06:00
LoJoSho
e96d1f505e Update publish.yml 2023-02-02 15:48:08 -06:00
LoJoSho
2af1deb4c1 Update publish.yml 2023-02-02 15:42:59 -06:00
LoJoSho
d740989a01 add ia hook comment 2023-02-02 15:42:28 -06:00
LoJoSho
fdc0004b75 Repo workflow 2023-02-02 15:23:05 -06:00
13 changed files with 200 additions and 67 deletions

View File

@@ -2,14 +2,13 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
plugins {
id("java")
id("maven-publish")
id("com.github.johnrengelman.shadow") version "7.1.2"
id("xyz.jpenilla.run-paper") version "2.0.0"
id("net.minecrell.plugin-yml.bukkit") version "0.5.2"
}
group = "com.hibiscusmc"
version = "2.1.1"
version = "2.1.2"
allprojects {
apply(plugin = "java")
@@ -228,17 +227,4 @@ bukkit {
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17
))
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "${project.group}"
artifactId = "${project.name}"
version = "${project.version}"
from(components["java"])
}
}
}

View File

@@ -1,5 +1,6 @@
plugins {
id("java")
id("maven-publish")
}
dependencies {
@@ -31,3 +32,69 @@ java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17
))
}
publishing {
val publishData = PublishData(project)
publications {
create<MavenPublication>("maven") {
groupId = "${rootProject.group}"
artifactId = "${rootProject.name}"
version = "${rootProject.version}"
from(components["java"])
}
}
repositories {
maven {
authentication {
credentials(PasswordCredentials::class) {
username = System.getenv("REPO_USERNAME")
password = System.getenv("REPO_PASSWORD")
}
}
name = "HibiscusMCRepository"
url = uri(publishData.getRepository())
}
}
}
class PublishData(private val project: Project) {
var type: Type = getReleaseType()
var hashLength: Int = 7
private fun getReleaseType(): Type {
val branch = getCheckedOutBranch()
return when {
branch.contentEquals("master") || branch.contentEquals("local") -> Type.RELEASE
branch.startsWith("dev") -> Type.DEV
else -> Type.SNAPSHOT
}
}
private fun getCheckedOutGitCommitHash(): String =
System.getenv("GITHUB_SHA")?.substring(0, hashLength) ?: "local"
private fun getCheckedOutBranch(): String =
System.getenv("GITHUB_REF")?.replace("refs/heads/", "") ?: "local"
fun getVersion(): String = getVersion(false)
fun getVersion(appendCommit: Boolean): String =
type.append(getVersionString(), appendCommit, getCheckedOutGitCommitHash())
private fun getVersionString(): String =
(rootProject.version as String).replace("-SNAPSHOT", "").replace("-DEV", "")
fun getRepository(): String = type.repo
enum class Type(private val append: String, val repo: String, private val addCommit: Boolean) {
RELEASE("", "https://repo.hibiscusmc.com/releases/", false),
DEV("-DEV", "https://repo.hibiscusmc.com/development/", true),
SNAPSHOT("-SNAPSHOT", "https://repo.hibiscusmc.com/snapshots/", true);
fun append(name: String, appendCommit: Boolean, commitHash: String): String =
name.plus(append).plus(if (appendCommit && addCommit) "-".plus(commitHash) else "")
}
}

View File

@@ -26,6 +26,7 @@ import com.jeff_media.updatechecker.UpdateChecker;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.permissions.Permission;
@@ -46,6 +47,8 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
private static YamlConfigurationLoader configLoader;
private static final int pluginId = 13873;
private static boolean hasModelEngine = false;
private static boolean onLatestVersion = true;
private static String latestVersion = "";
@Override
public void onEnable() {
@@ -62,11 +65,24 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
}
// Update Checker
new UpdateChecker(this, UpdateCheckSource.POLYMART, "1879")
.setDownloadLink("https://polymart.org/resource/1879")
UpdateChecker checker = new UpdateChecker(this, UpdateCheckSource.POLYMART, "1879")
.onSuccess((commandSenders, latestVersion) -> {
this.latestVersion = (String) latestVersion;
if (!this.latestVersion.equalsIgnoreCase(getDescription().getVersion())) {
getLogger().info("+++++++++++++++++++++++++++++++++++");
getLogger().info("There is a new update for HMCCosmetics!");
getLogger().info("Please download it as soon as possible for possible fixes and new features.");
getLogger().info("Current Version " + getDescription().getVersion() + " | Latest Version " + latestVersion);
getLogger().info("Spigot: https://www.spigotmc.org/resources/100107/");
getLogger().info("Polymart: https://polymart.org/resource/1879");
getLogger().info("+++++++++++++++++++++++++++++++++++");
}
})
.setNotifyRequesters(false)
.setNotifyOpsOnJoin(false)
.checkEveryXHours(24)
.checkNow();
onLatestVersion = checker.isUsingLatestVersion();
// File setup
if (!getDataFolder().exists()) {
saveDefaultConfig();
@@ -241,4 +257,10 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
public static boolean hasModelEngine() {
return hasModelEngine;
}
public static boolean isOnLatestVersion() {
return onLatestVersion;
}
public static String getLatestVersion() {
return latestVersion;
}
}

View File

@@ -33,6 +33,8 @@ public class CosmeticCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
boolean silent = false;
if (args.length == 0) {
if (!(sender instanceof Player)) {
// Console
@@ -62,49 +64,61 @@ public class CosmeticCommand implements CommandExecutor {
Player player = sender instanceof Player ? (Player) sender : null;
String firstArgs = args[0].toLowerCase();
if (sender.hasPermission("HMCCosmetics.cmd.silent") || sender.isOp()) {
for (String singleArg : args) {
if (singleArg.equalsIgnoreCase("-s")) silent = true;
}
}
switch (firstArgs) {
case ("reload") -> {
if (!sender.hasPermission("HMCCosmetics.cmd.reload") || !sender.isOp()) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
HMCCosmeticsPlugin.setup();
MessagesUtil.sendMessage(sender, "reloaded");
if (!silent) MessagesUtil.sendMessage(sender, "reloaded");
return true;
}
case ("apply") -> {
if (!sender.hasPermission("hmccosmetics.cmd.apply")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
Cosmetic cosmetic;
Color color = Color.WHITE;
if (sender instanceof Player) player = ((Player) sender).getPlayer();
if (sender.hasPermission("hmccosmetics.cmd.apply.other")) {
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
}
if (sender.hasPermission("hmccosmetics.cmd.apply.color")) {
if (args.length >= 4) color = ServerUtils.hex2Rgb(args[3]);
}
if (args.length == 1) {
MessagesUtil.sendMessage(player, "not-enough-args");
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
return true;
}
cosmetic = Cosmetics.getCosmetic(args[1]);
if (cosmetic == null) {
MessagesUtil.sendMessage(sender, "invalid-cosmetic");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-cosmetic");
return true;
}
if (player == null) {
MessagesUtil.sendMessage(sender, "invalid-player");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
CosmeticUser user = CosmeticUsers.getUser(player);
if (!user.canEquipCosmetic(cosmetic)) {
MessagesUtil.sendMessage(player, "no-cosmetic-permission");
if (!silent) MessagesUtil.sendMessage(player, "no-cosmetic-permission");
return true;
}
@@ -113,19 +127,19 @@ public class CosmeticCommand implements CommandExecutor {
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmetic.getSlot().name())));
MessagesUtil.sendMessage(player, "equip-cosmetic", placeholders);
if (!silent) MessagesUtil.sendMessage(player, "equip-cosmetic", placeholders);
user.addPlayerCosmetic(cosmetic);
user.addPlayerCosmetic(cosmetic, color);
user.updateCosmetic(cosmetic.getSlot());
return true;
}
case ("unapply") -> {
if (!sender.hasPermission("hmccosmetics.cmd.unapply")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (args.length == 1) {
MessagesUtil.sendMessage(player, "not-enough-args");
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
return true;
}
@@ -137,20 +151,20 @@ public class CosmeticCommand implements CommandExecutor {
}
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1].toUpperCase())) {
MessagesUtil.sendMessage(sender, "invalid-slot");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-slot");
return true;
}
cosmeticSlot = CosmeticSlot.valueOf(args[1].toUpperCase());
if (player == null) {
MessagesUtil.sendMessage(sender, "invalid-player");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
CosmeticUser user = CosmeticUsers.getUser(player);
if (user.getCosmetic(cosmeticSlot) == null) {
MessagesUtil.sendMessage(sender, "no-cosmetic-slot");
if (!silent) MessagesUtil.sendMessage(sender, "no-cosmetic-slot");
return true;
}
@@ -159,7 +173,7 @@ public class CosmeticCommand implements CommandExecutor {
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmeticSlot.name())));
MessagesUtil.sendMessage(player, "unequip-cosmetic", placeholders);
if (!silent) MessagesUtil.sendMessage(player, "unequip-cosmetic", placeholders);
user.removeCosmeticSlot(cosmeticSlot);
user.updateCosmetic(cosmeticSlot);
@@ -172,12 +186,12 @@ public class CosmeticCommand implements CommandExecutor {
}
if (!sender.hasPermission("hmccosmetics.cmd.wardrobe")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (player == null) {
MessagesUtil.sendMessage(sender, "invalid-player");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
@@ -190,7 +204,7 @@ public class CosmeticCommand implements CommandExecutor {
case ("menu") -> {
if (args.length == 1) return true;
if (!sender.hasPermission("hmccosmetics.cmd.menu")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
Menu menu = Menus.getMenu(args[1]);
@@ -202,12 +216,12 @@ public class CosmeticCommand implements CommandExecutor {
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) {
MessagesUtil.sendMessage(sender, "invalid-player");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
if (menu == null) {
MessagesUtil.sendMessage(sender, "invalid-menu");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-menu");
return true;
}
@@ -219,7 +233,7 @@ public class CosmeticCommand implements CommandExecutor {
OfflinePlayer selectedPlayer = Bukkit.getOfflinePlayer(args[1]);
if (selectedPlayer == null) return true;
if (!sender.hasPermission("hmccosmetics.cmd.dataclear") && !sender.isOp()) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
Database.clearData(selectedPlayer.getUniqueId());
@@ -231,17 +245,17 @@ public class CosmeticCommand implements CommandExecutor {
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return true;
if (!sender.hasPermission("hmccosmetics.cmd.dye") && !sender.isOp()) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (args.length == 1) {
MessagesUtil.sendMessage(player, "not-enough-args");
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
return true;
}
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1])) {
MessagesUtil.sendMessage(player, "invalid-slot");
if (!silent) MessagesUtil.sendMessage(player, "invalid-slot");
return true;
}
CosmeticSlot slot = CosmeticSlot.valueOf(args[1]);
@@ -249,12 +263,12 @@ public class CosmeticCommand implements CommandExecutor {
if (args.length >= 3) {
if (args[2].isEmpty()) {
MessagesUtil.sendMessage(player, "invalid-color");
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
return true;
}
Color color = ServerUtils.hex2Rgb(args[2]);
if (color == null) {
MessagesUtil.sendMessage(player, "invalid-color");
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
return true;
}
user.addPlayerCosmetic(cosmetic, color); // #FFFFFF
@@ -264,32 +278,32 @@ public class CosmeticCommand implements CommandExecutor {
}
case ("setlocation") -> {
if (!sender.hasPermission("hmccosmetics.cmd.setlocation")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (player == null) return true;
if (args.length < 2) {
MessagesUtil.sendMessage(player, "not-enough-args");
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
return true;
}
if (args[1].equalsIgnoreCase("wardrobelocation")) {
WardrobeSettings.setWardrobeLocation(player.getLocation());
MessagesUtil.sendMessage(player, "set-wardrobe-location");
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-location");
return true;
}
if (args[1].equalsIgnoreCase("viewerlocation")) {
WardrobeSettings.setViewerLocation(player.getLocation());
MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
return true;
}
if (args[1].equalsIgnoreCase("leavelocation")) {
WardrobeSettings.setLeaveLocation(player.getLocation());
MessagesUtil.sendMessage(player, "set-wardrobe-leaving");
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-leaving");
return true;
}
}
@@ -298,7 +312,7 @@ public class CosmeticCommand implements CommandExecutor {
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return true;
if (!sender.hasPermission("HMCCosmetic.cmd.dump") && !sender.isOp()) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
player.sendMessage("Passengers -> " + player.getPassengers());
@@ -316,17 +330,17 @@ public class CosmeticCommand implements CommandExecutor {
}
if (!sender.hasPermission("hmccosmetics.cmd.hide")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (player == null) {
MessagesUtil.sendMessage(sender, "invalid-player");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
CosmeticUser user = CosmeticUsers.getUser(player);
MessagesUtil.sendMessage(sender, "hide-cosmetic");
if (!silent) MessagesUtil.sendMessage(sender, "hide-cosmetic");
user.hideCosmetics(CosmeticUser.HiddenReason.COMMAND);
return true;
}
@@ -337,33 +351,33 @@ public class CosmeticCommand implements CommandExecutor {
}
if (!sender.hasPermission("hmccosmetics.cmd.show")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (player == null) {
MessagesUtil.sendMessage(sender, "invalid-player");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
CosmeticUser user = CosmeticUsers.getUser(player);
MessagesUtil.sendMessage(sender, "show-cosmetic");
if (!silent) MessagesUtil.sendMessage(sender, "show-cosmetic");
user.showCosmetics();
return true;
}
case ("debug") -> {
if (!sender.hasPermission("hmccosmetics.cmd.debug")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (Settings.getDebugMode()) {
Settings.setDebugMode(false);
MessagesUtil.sendMessage(sender, "debug-disabled");
if (!silent) MessagesUtil.sendMessage(sender, "debug-disabled");
} else {
Settings.setDebugMode(true);
MessagesUtil.sendMessage(sender, "debug-enabled");
if (!silent) MessagesUtil.sendMessage(sender, "debug-enabled");
}
}

View File

@@ -91,11 +91,20 @@ public class CosmeticCommandTabComplete implements TabCompleter {
completions.add(player.getName());
}
}
}
StringUtil.copyPartialMatches(args[2], completions, finalCompletitons);
}
if (args.length == 4) {
String subcommand = args[0].toLowerCase();
switch (subcommand) {
case "apply" -> {
completions.add("#FFFFFF");
}
}
StringUtil.copyPartialMatches(args[3], completions, finalCompletitons);
}
Collections.sort(finalCompletitons);
return finalCompletitons;
}

View File

@@ -1,10 +1,13 @@
package com.hibiscusmc.hmccosmetics.database.types;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.apache.commons.lang3.EnumUtils;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.jetbrains.annotations.Nullable;
@@ -34,6 +37,9 @@ public class Data {
// BACKPACK=colorfulbackpack&RRGGBB,HELMET=niftyhat,BALLOON=colorfulballoon,CHESTPLATE=niftychestplate
public String steralizeData(CosmeticUser user) {
String data = "";
if (user.getHidden()) {
data = "HIDDEN=" + user.getHiddenReason();
}
for (Cosmetic cosmetic : user.getCosmetic()) {
Color color = user.getCosmeticColor(cosmetic.getSlot());
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
@@ -47,7 +53,7 @@ public class Data {
return data;
}
public Map<CosmeticSlot, Map<Cosmetic, Color>> desteralizedata(String raw) {
public Map<CosmeticSlot, Map<Cosmetic, Color>> desteralizedata(CosmeticUser user, String raw) {
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
String[] rawData = raw.split(",");
@@ -57,8 +63,15 @@ public class Data {
CosmeticSlot slot = null;
Cosmetic cosmetic = null;
MessagesUtil.sendDebugMessages("First split (suppose slot) " + splitData[0]);
if (splitData[0].equalsIgnoreCase("HIDDEN")) {
if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) {
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
user.hideCosmetics(CosmeticUser.HiddenReason.valueOf(splitData[1]));
});
}
continue;
}
if (CosmeticSlot.valueOf(splitData[0]) != null) slot = CosmeticSlot.valueOf(splitData[0]);
if (splitData[1].contains("&")) {
String[] colorSplitData = splitData[1].split("&");
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);

View File

@@ -38,7 +38,7 @@ public class InternalData extends Data {
if (!player.getPersistentDataContainer().has(key, PersistentDataType.STRING)) return user;
String rawData = player.getPersistentDataContainer().get(key, PersistentDataType.STRING);
Map<CosmeticSlot, Map<Cosmetic, Color>> a = desteralizedata(rawData);
Map<CosmeticSlot, Map<Cosmetic, Color>> a = desteralizedata(user, rawData);
for (Map<Cosmetic, Color> cosmeticColors : a.values()) {
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {

View File

@@ -82,7 +82,7 @@ public class MySQLData extends Data {
ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) {
String rawData = rs.getString("COSMETICS");
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = desteralizedata(rawData);
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = desteralizedata(user, rawData);
for (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {

View File

@@ -76,7 +76,7 @@ public class SQLiteData extends Data {
ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) {
String rawData = rs.getString("COSMETICS");
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = desteralizedata(rawData);
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = desteralizedata(user, rawData);
for (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {

View File

@@ -14,11 +14,20 @@ public class ActionMenu extends Action {
@Override
public void run(CosmeticUser user, String raw) {
boolean ignorePermission = false;
raw = raw.replaceAll(" ", ""); // Removes all spaces
if (raw.contains("-o")) {
raw = raw.replaceAll("-o", "");
ignorePermission = true;
}
if (!Menus.hasMenu(raw)) {
HMCCosmeticsPlugin.getInstance().getLogger().info("Invalid Action Menu -> " + raw);
return;
}
Menu menu = Menus.getMenu(raw);
menu.openMenu(user, true);
HMCCosmeticsPlugin.getInstance().getLogger().info(raw + " | " + ignorePermission);
menu.openMenu(user, ignorePermission);
}
}

View File

@@ -31,7 +31,7 @@ public class ItemAdderHook extends ItemHook implements Listener {
@EventHandler
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
if (this.enabled) return;
if (enabled) return; // Only run on the first event fired; ignore all rest
this.enabled = true;
HMCCosmeticsPlugin.setup();
}

View File

@@ -18,6 +18,18 @@ public class PlayerConnectionListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if (event.getPlayer().isOp() || event.getPlayer().hasPermission("hmccosmetics.notifyupdate")) {
if (!HMCCosmeticsPlugin.getLatestVersion().equalsIgnoreCase(HMCCosmeticsPlugin.getInstance().getDescription().getVersion()) && HMCCosmeticsPlugin.getLatestVersion() != null)
MessagesUtil.sendMessageNoKey(
event.getPlayer(),
"<br>" +
"<GRAY>There is a new version of <light_purple><Bold>HMCCosmetics<reset><gray> available!<br>" +
"<GRAY>Current version: <red>" + HMCCosmeticsPlugin.getInstance().getDescription().getVersion() + " <GRAY>| Latest version: <light_purple>" + HMCCosmeticsPlugin.getLatestVersion() + "<br>" +
"<GRAY>Download it on <gold><click:OPEN_URL:'https://www.spigotmc.org/resources/100107/'>Spigot<reset> <gray>or <gold><click:OPEN_URL:'https://polymart.org/resource/1879'>Polymart<reset><gray>!" +
"<br>"
);
}
Runnable run = () -> {
CosmeticUser user = Database.get(event.getPlayer().getUniqueId());
CosmeticUsers.addUser(user);

View File

@@ -191,6 +191,7 @@ public class CosmeticUser {
public ItemStack getUserCosmeticItem(Cosmetic cosmetic) {
ItemStack item = null;
if (hideCosmetics) {
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticBalloonType) return new ItemStack(Material.AIR);
return getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmetic.getSlot()));
}
if (cosmetic instanceof CosmeticArmorType || cosmetic instanceof CosmeticMainhandType || cosmetic instanceof CosmeticBackpackType) {