mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-22 08:29:27 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
614892500c | ||
|
|
872282f77a | ||
|
|
c0483bfefe | ||
|
|
aecd40ba5a | ||
|
|
c3db45cfc4 | ||
|
|
99bc0a0756 | ||
|
|
e9afd6deb8 | ||
|
|
0770ac456d | ||
|
|
327d602491 | ||
|
|
65f162c89c | ||
|
|
e96d1f505e | ||
|
|
2af1deb4c1 | ||
|
|
d740989a01 | ||
|
|
fdc0004b75 |
@@ -2,14 +2,13 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
id("maven-publish")
|
|
||||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||||
id("xyz.jpenilla.run-paper") version "2.0.0"
|
id("xyz.jpenilla.run-paper") version "2.0.0"
|
||||||
id("net.minecrell.plugin-yml.bukkit") version "0.5.2"
|
id("net.minecrell.plugin-yml.bukkit") version "0.5.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.1.1"
|
version = "2.1.2"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -229,16 +228,3 @@ java {
|
|||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
create<MavenPublication>("maven") {
|
|
||||||
groupId = "${project.group}"
|
|
||||||
artifactId = "${project.name}"
|
|
||||||
version = "${project.version}"
|
|
||||||
|
|
||||||
from(components["java"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
|
id("maven-publish")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -31,3 +32,69 @@ java {
|
|||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
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 "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.jeff_media.updatechecker.UpdateChecker;
|
|||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
@@ -46,6 +47,8 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
private static YamlConfigurationLoader configLoader;
|
private static YamlConfigurationLoader configLoader;
|
||||||
private static final int pluginId = 13873;
|
private static final int pluginId = 13873;
|
||||||
private static boolean hasModelEngine = false;
|
private static boolean hasModelEngine = false;
|
||||||
|
private static boolean onLatestVersion = true;
|
||||||
|
private static String latestVersion = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@@ -62,11 +65,24 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update Checker
|
// Update Checker
|
||||||
new UpdateChecker(this, UpdateCheckSource.POLYMART, "1879")
|
UpdateChecker checker = new UpdateChecker(this, UpdateCheckSource.POLYMART, "1879")
|
||||||
.setDownloadLink("https://polymart.org/resource/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)
|
.checkEveryXHours(24)
|
||||||
.checkNow();
|
.checkNow();
|
||||||
|
onLatestVersion = checker.isUsingLatestVersion();
|
||||||
// File setup
|
// File setup
|
||||||
if (!getDataFolder().exists()) {
|
if (!getDataFolder().exists()) {
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
@@ -241,4 +257,10 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
public static boolean hasModelEngine() {
|
public static boolean hasModelEngine() {
|
||||||
return hasModelEngine;
|
return hasModelEngine;
|
||||||
}
|
}
|
||||||
|
public static boolean isOnLatestVersion() {
|
||||||
|
return onLatestVersion;
|
||||||
|
}
|
||||||
|
public static String getLatestVersion() {
|
||||||
|
return latestVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
boolean silent = false;
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
// Console
|
// Console
|
||||||
@@ -62,49 +64,61 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
Player player = sender instanceof Player ? (Player) sender : null;
|
Player player = sender instanceof Player ? (Player) sender : null;
|
||||||
|
|
||||||
String firstArgs = args[0].toLowerCase();
|
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) {
|
switch (firstArgs) {
|
||||||
case ("reload") -> {
|
case ("reload") -> {
|
||||||
if (!sender.hasPermission("HMCCosmetics.cmd.reload") || !sender.isOp()) {
|
if (!sender.hasPermission("HMCCosmetics.cmd.reload") || !sender.isOp()) {
|
||||||
MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
HMCCosmeticsPlugin.setup();
|
HMCCosmeticsPlugin.setup();
|
||||||
MessagesUtil.sendMessage(sender, "reloaded");
|
if (!silent) MessagesUtil.sendMessage(sender, "reloaded");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case ("apply") -> {
|
case ("apply") -> {
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.apply")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.apply")) {
|
||||||
MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Cosmetic cosmetic;
|
Cosmetic cosmetic;
|
||||||
|
Color color = Color.WHITE;
|
||||||
|
|
||||||
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
||||||
if (sender.hasPermission("hmccosmetics.cmd.apply.other")) {
|
if (sender.hasPermission("hmccosmetics.cmd.apply.other")) {
|
||||||
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
|
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) {
|
if (args.length == 1) {
|
||||||
MessagesUtil.sendMessage(player, "not-enough-args");
|
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cosmetic = Cosmetics.getCosmetic(args[1]);
|
cosmetic = Cosmetics.getCosmetic(args[1]);
|
||||||
|
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) {
|
||||||
MessagesUtil.sendMessage(sender, "invalid-cosmetic");
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-cosmetic");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
MessagesUtil.sendMessage(sender, "invalid-player");
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
|
||||||
if (!user.canEquipCosmetic(cosmetic)) {
|
if (!user.canEquipCosmetic(cosmetic)) {
|
||||||
MessagesUtil.sendMessage(player, "no-cosmetic-permission");
|
if (!silent) MessagesUtil.sendMessage(player, "no-cosmetic-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,19 +127,19 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
|
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
|
||||||
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmetic.getSlot().name())));
|
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());
|
user.updateCosmetic(cosmetic.getSlot());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case ("unapply") -> {
|
case ("unapply") -> {
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.unapply")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.unapply")) {
|
||||||
MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
MessagesUtil.sendMessage(player, "not-enough-args");
|
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,20 +151,20 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1].toUpperCase())) {
|
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1].toUpperCase())) {
|
||||||
MessagesUtil.sendMessage(sender, "invalid-slot");
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-slot");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
cosmeticSlot = CosmeticSlot.valueOf(args[1].toUpperCase());
|
cosmeticSlot = CosmeticSlot.valueOf(args[1].toUpperCase());
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
MessagesUtil.sendMessage(sender, "invalid-player");
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
|
||||||
if (user.getCosmetic(cosmeticSlot) == null) {
|
if (user.getCosmetic(cosmeticSlot) == null) {
|
||||||
MessagesUtil.sendMessage(sender, "no-cosmetic-slot");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-cosmetic-slot");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +173,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
|
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
|
||||||
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmeticSlot.name())));
|
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.removeCosmeticSlot(cosmeticSlot);
|
||||||
user.updateCosmetic(cosmeticSlot);
|
user.updateCosmetic(cosmeticSlot);
|
||||||
@@ -172,12 +186,12 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.wardrobe")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.wardrobe")) {
|
||||||
MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
MessagesUtil.sendMessage(sender, "invalid-player");
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +204,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
case ("menu") -> {
|
case ("menu") -> {
|
||||||
if (args.length == 1) return true;
|
if (args.length == 1) return true;
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.menu")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.menu")) {
|
||||||
MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Menu menu = Menus.getMenu(args[1]);
|
Menu menu = Menus.getMenu(args[1]);
|
||||||
@@ -202,12 +216,12 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
MessagesUtil.sendMessage(sender, "invalid-player");
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menu == null) {
|
if (menu == null) {
|
||||||
MessagesUtil.sendMessage(sender, "invalid-menu");
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-menu");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +233,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
OfflinePlayer selectedPlayer = Bukkit.getOfflinePlayer(args[1]);
|
OfflinePlayer selectedPlayer = Bukkit.getOfflinePlayer(args[1]);
|
||||||
if (selectedPlayer == null) return true;
|
if (selectedPlayer == null) return true;
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.dataclear") && !sender.isOp()) {
|
if (!sender.hasPermission("hmccosmetics.cmd.dataclear") && !sender.isOp()) {
|
||||||
MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Database.clearData(selectedPlayer.getUniqueId());
|
Database.clearData(selectedPlayer.getUniqueId());
|
||||||
@@ -231,17 +245,17 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return true;
|
if (user == null) return true;
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.dye") && !sender.isOp()) {
|
if (!sender.hasPermission("hmccosmetics.cmd.dye") && !sender.isOp()) {
|
||||||
MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
MessagesUtil.sendMessage(player, "not-enough-args");
|
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1])) {
|
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1])) {
|
||||||
MessagesUtil.sendMessage(player, "invalid-slot");
|
if (!silent) MessagesUtil.sendMessage(player, "invalid-slot");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
CosmeticSlot slot = CosmeticSlot.valueOf(args[1]);
|
CosmeticSlot slot = CosmeticSlot.valueOf(args[1]);
|
||||||
@@ -249,12 +263,12 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if (args.length >= 3) {
|
if (args.length >= 3) {
|
||||||
if (args[2].isEmpty()) {
|
if (args[2].isEmpty()) {
|
||||||
MessagesUtil.sendMessage(player, "invalid-color");
|
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Color color = ServerUtils.hex2Rgb(args[2]);
|
Color color = ServerUtils.hex2Rgb(args[2]);
|
||||||
if (color == null) {
|
if (color == null) {
|
||||||
MessagesUtil.sendMessage(player, "invalid-color");
|
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
user.addPlayerCosmetic(cosmetic, color); // #FFFFFF
|
user.addPlayerCosmetic(cosmetic, color); // #FFFFFF
|
||||||
@@ -264,32 +278,32 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
case ("setlocation") -> {
|
case ("setlocation") -> {
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.setlocation")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.setlocation")) {
|
||||||
MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player == null) return true;
|
if (player == null) return true;
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
MessagesUtil.sendMessage(player, "not-enough-args");
|
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("wardrobelocation")) {
|
if (args[1].equalsIgnoreCase("wardrobelocation")) {
|
||||||
WardrobeSettings.setWardrobeLocation(player.getLocation());
|
WardrobeSettings.setWardrobeLocation(player.getLocation());
|
||||||
MessagesUtil.sendMessage(player, "set-wardrobe-location");
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-location");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("viewerlocation")) {
|
if (args[1].equalsIgnoreCase("viewerlocation")) {
|
||||||
WardrobeSettings.setViewerLocation(player.getLocation());
|
WardrobeSettings.setViewerLocation(player.getLocation());
|
||||||
MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("leavelocation")) {
|
if (args[1].equalsIgnoreCase("leavelocation")) {
|
||||||
WardrobeSettings.setLeaveLocation(player.getLocation());
|
WardrobeSettings.setLeaveLocation(player.getLocation());
|
||||||
MessagesUtil.sendMessage(player, "set-wardrobe-leaving");
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-leaving");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,7 +312,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return true;
|
if (user == null) return true;
|
||||||
if (!sender.hasPermission("HMCCosmetic.cmd.dump") && !sender.isOp()) {
|
if (!sender.hasPermission("HMCCosmetic.cmd.dump") && !sender.isOp()) {
|
||||||
MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
player.sendMessage("Passengers -> " + player.getPassengers());
|
player.sendMessage("Passengers -> " + player.getPassengers());
|
||||||
@@ -316,17 +330,17 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.hide")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.hide")) {
|
||||||
MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
MessagesUtil.sendMessage(sender, "invalid-player");
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
MessagesUtil.sendMessage(sender, "hide-cosmetic");
|
if (!silent) MessagesUtil.sendMessage(sender, "hide-cosmetic");
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.COMMAND);
|
user.hideCosmetics(CosmeticUser.HiddenReason.COMMAND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -337,33 +351,33 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.show")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.show")) {
|
||||||
MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
MessagesUtil.sendMessage(sender, "invalid-player");
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
|
||||||
MessagesUtil.sendMessage(sender, "show-cosmetic");
|
if (!silent) MessagesUtil.sendMessage(sender, "show-cosmetic");
|
||||||
user.showCosmetics();
|
user.showCosmetics();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case ("debug") -> {
|
case ("debug") -> {
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.debug")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.debug")) {
|
||||||
MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.getDebugMode()) {
|
if (Settings.getDebugMode()) {
|
||||||
Settings.setDebugMode(false);
|
Settings.setDebugMode(false);
|
||||||
MessagesUtil.sendMessage(sender, "debug-disabled");
|
if (!silent) MessagesUtil.sendMessage(sender, "debug-disabled");
|
||||||
} else {
|
} else {
|
||||||
Settings.setDebugMode(true);
|
Settings.setDebugMode(true);
|
||||||
MessagesUtil.sendMessage(sender, "debug-enabled");
|
if (!silent) MessagesUtil.sendMessage(sender, "debug-enabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,11 +91,20 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
completions.add(player.getName());
|
completions.add(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
StringUtil.copyPartialMatches(args[2], completions, finalCompletitons);
|
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);
|
Collections.sort(finalCompletitons);
|
||||||
return finalCompletitons;
|
return finalCompletitons;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.database.types;
|
package com.hibiscusmc.hmccosmetics.database.types;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -34,6 +37,9 @@ public class Data {
|
|||||||
// BACKPACK=colorfulbackpack&RRGGBB,HELMET=niftyhat,BALLOON=colorfulballoon,CHESTPLATE=niftychestplate
|
// BACKPACK=colorfulbackpack&RRGGBB,HELMET=niftyhat,BALLOON=colorfulballoon,CHESTPLATE=niftychestplate
|
||||||
public String steralizeData(CosmeticUser user) {
|
public String steralizeData(CosmeticUser user) {
|
||||||
String data = "";
|
String data = "";
|
||||||
|
if (user.getHidden()) {
|
||||||
|
data = "HIDDEN=" + user.getHiddenReason();
|
||||||
|
}
|
||||||
for (Cosmetic cosmetic : user.getCosmetic()) {
|
for (Cosmetic cosmetic : user.getCosmetic()) {
|
||||||
Color color = user.getCosmeticColor(cosmetic.getSlot());
|
Color color = user.getCosmeticColor(cosmetic.getSlot());
|
||||||
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
|
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
|
||||||
@@ -47,7 +53,7 @@ public class Data {
|
|||||||
return 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<>();
|
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
||||||
|
|
||||||
String[] rawData = raw.split(",");
|
String[] rawData = raw.split(",");
|
||||||
@@ -57,8 +63,15 @@ public class Data {
|
|||||||
CosmeticSlot slot = null;
|
CosmeticSlot slot = null;
|
||||||
Cosmetic cosmetic = null;
|
Cosmetic cosmetic = null;
|
||||||
MessagesUtil.sendDebugMessages("First split (suppose slot) " + splitData[0]);
|
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 (CosmeticSlot.valueOf(splitData[0]) != null) slot = CosmeticSlot.valueOf(splitData[0]);
|
||||||
|
|
||||||
if (splitData[1].contains("&")) {
|
if (splitData[1].contains("&")) {
|
||||||
String[] colorSplitData = splitData[1].split("&");
|
String[] colorSplitData = splitData[1].split("&");
|
||||||
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
|
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class InternalData extends Data {
|
|||||||
if (!player.getPersistentDataContainer().has(key, PersistentDataType.STRING)) return user;
|
if (!player.getPersistentDataContainer().has(key, PersistentDataType.STRING)) return user;
|
||||||
String rawData = player.getPersistentDataContainer().get(key, PersistentDataType.STRING);
|
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 (Map<Cosmetic, Color> cosmeticColors : a.values()) {
|
||||||
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class MySQLData extends Data {
|
|||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
String rawData = rs.getString("COSMETICS");
|
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 (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
|
||||||
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class SQLiteData extends Data {
|
|||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
String rawData = rs.getString("COSMETICS");
|
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 (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
|
||||||
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
|||||||
@@ -14,11 +14,20 @@ public class ActionMenu extends Action {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
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)) {
|
if (!Menus.hasMenu(raw)) {
|
||||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Invalid Action Menu -> " + raw);
|
HMCCosmeticsPlugin.getInstance().getLogger().info("Invalid Action Menu -> " + raw);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Menu menu = Menus.getMenu(raw);
|
Menu menu = Menus.getMenu(raw);
|
||||||
menu.openMenu(user, true);
|
HMCCosmeticsPlugin.getInstance().getLogger().info(raw + " | " + ignorePermission);
|
||||||
|
menu.openMenu(user, ignorePermission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class ItemAdderHook extends ItemHook implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
|
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;
|
this.enabled = true;
|
||||||
HMCCosmeticsPlugin.setup();
|
HMCCosmeticsPlugin.setup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,18 @@ public class PlayerConnectionListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
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 = () -> {
|
Runnable run = () -> {
|
||||||
CosmeticUser user = Database.get(event.getPlayer().getUniqueId());
|
CosmeticUser user = Database.get(event.getPlayer().getUniqueId());
|
||||||
CosmeticUsers.addUser(user);
|
CosmeticUsers.addUser(user);
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ public class CosmeticUser {
|
|||||||
public ItemStack getUserCosmeticItem(Cosmetic cosmetic) {
|
public ItemStack getUserCosmeticItem(Cosmetic cosmetic) {
|
||||||
ItemStack item = null;
|
ItemStack item = null;
|
||||||
if (hideCosmetics) {
|
if (hideCosmetics) {
|
||||||
|
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticBalloonType) return new ItemStack(Material.AIR);
|
||||||
return getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmetic.getSlot()));
|
return getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmetic.getSlot()));
|
||||||
}
|
}
|
||||||
if (cosmetic instanceof CosmeticArmorType || cosmetic instanceof CosmeticMainhandType || cosmetic instanceof CosmeticBackpackType) {
|
if (cosmetic instanceof CosmeticArmorType || cosmetic instanceof CosmeticMainhandType || cosmetic instanceof CosmeticBackpackType) {
|
||||||
|
|||||||
Reference in New Issue
Block a user