mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-24 09:29:16 +00:00
Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17abd0c8cc | ||
|
|
a907cd51b9 | ||
|
|
9f6c7db8fd | ||
|
|
2ba83d8cc5 | ||
|
|
40bf0e173e | ||
|
|
a757292b4b | ||
|
|
b41d466546 | ||
|
|
135fdc94d4 | ||
|
|
d0092a2ffe | ||
|
|
acf31009d5 | ||
|
|
981c6155e7 | ||
|
|
2ecc86fc7b | ||
|
|
2682428354 | ||
|
|
df8ad26684 | ||
|
|
1f714c0153 | ||
|
|
0bfadad222 | ||
|
|
a1c719fc50 | ||
|
|
fe9812cd69 | ||
|
|
b9699b27c7 | ||
|
|
2c5ddb542e | ||
|
|
461642d64b | ||
|
|
37a8a2379d | ||
|
|
e698392e40 | ||
|
|
e1357b265f | ||
|
|
a5475b0268 | ||
|
|
60dba9efa6 | ||
|
|
e2d3391070 | ||
|
|
aed34ec28d | ||
|
|
ae6d88ab56 | ||
|
|
35be7283e9 | ||
|
|
224fcb83d9 | ||
|
|
98934536be | ||
|
|
5ac3712e56 | ||
|
|
2d2d4e6d44 | ||
|
|
4b1921b754 | ||
|
|
8ca1d44375 | ||
|
|
23c82cc6ed | ||
|
|
2bf5280827 | ||
|
|
475a1e0ef1 | ||
|
|
ef4d53eb85 | ||
|
|
97da4f7809 | ||
|
|
1622dac67f | ||
|
|
fce1ec5042 | ||
|
|
060bcc95e1 | ||
|
|
5aca80609a |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -23,7 +23,6 @@ atlassian-ide-plugin.xml
|
||||
*.ctxt
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
|
||||
@@ -8,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.hibiscusmc"
|
||||
version = "2.2.3"
|
||||
version = "2.2.5-DEV"
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
@@ -62,7 +62,7 @@ allprojects {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
|
||||
compileOnly("com.mojang:authlib:1.5.25")
|
||||
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||
@@ -77,7 +77,6 @@ allprojects {
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.6-4")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CosmeticCommand implements CommandExecutor {
|
||||
|
||||
// cosmetics apply cosmetics playerName
|
||||
@@ -92,7 +95,7 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
Cosmetic cosmetic;
|
||||
Color color = Color.WHITE;
|
||||
Color color = null;
|
||||
|
||||
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
||||
if (sender.hasPermission("hmccosmetics.cmd.apply.other")) {
|
||||
@@ -148,19 +151,11 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
CosmeticSlot cosmeticSlot;
|
||||
|
||||
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
||||
if (sender.hasPermission("hmccosmetics.cmd.unapply.other")) {
|
||||
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
|
||||
}
|
||||
|
||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1].toUpperCase())) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-slot");
|
||||
return true;
|
||||
}
|
||||
cosmeticSlot = CosmeticSlot.valueOf(args[1].toUpperCase());
|
||||
|
||||
if (player == null) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||
return true;
|
||||
@@ -168,20 +163,34 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
|
||||
if (user.getCosmetic(cosmeticSlot) == null) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-cosmetic-slot");
|
||||
return true;
|
||||
Set<CosmeticSlot> cosmeticSlots;
|
||||
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
cosmeticSlots = user.getSlotsWithCosmetics();
|
||||
} else {
|
||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1].toUpperCase())) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-slot");
|
||||
return true;
|
||||
}
|
||||
cosmeticSlots = Set.of(CosmeticSlot.valueOf(args[1].toUpperCase()));
|
||||
}
|
||||
|
||||
TagResolver placeholders =
|
||||
TagResolver.resolver(Placeholder.parsed("cosmetic", user.getCosmetic(cosmeticSlot).getId()),
|
||||
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
|
||||
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmeticSlot.name())));
|
||||
for (CosmeticSlot cosmeticSlot : cosmeticSlots) {
|
||||
if (user.getCosmetic(cosmeticSlot) == null) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-cosmetic-slot");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!silent) MessagesUtil.sendMessage(player, "unequip-cosmetic", placeholders);
|
||||
TagResolver placeholders =
|
||||
TagResolver.resolver(Placeholder.parsed("cosmetic", user.getCosmetic(cosmeticSlot).getId()),
|
||||
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
|
||||
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmeticSlot.name())));
|
||||
|
||||
user.removeCosmeticSlot(cosmeticSlot);
|
||||
user.updateCosmetic(cosmeticSlot);
|
||||
if (!silent) MessagesUtil.sendMessage(player, "unequip-cosmetic", placeholders);
|
||||
|
||||
user.removeCosmeticSlot(cosmeticSlot);
|
||||
user.updateCosmetic(cosmeticSlot);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case ("wardrobe") -> {
|
||||
|
||||
@@ -59,6 +59,7 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
for (Cosmetic cosmetic : user.getCosmetic()) {
|
||||
completions.add(cosmetic.getSlot().toString().toUpperCase());
|
||||
}
|
||||
completions.add("ALL");
|
||||
}
|
||||
case "menu" -> {
|
||||
for (Menu menu : Menus.getMenu()) {
|
||||
|
||||
@@ -32,6 +32,10 @@ public class Settings {
|
||||
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
||||
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
|
||||
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
||||
private static final String HOOK_SETTING_PATH = "hook-settings";
|
||||
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
||||
private static final String HOOK_RELOAD_CHANGE_PATH = "reload-on-change";
|
||||
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
||||
|
||||
private static String defaultMenu;
|
||||
private static String dyeMenuName;
|
||||
@@ -46,6 +50,8 @@ public class Settings {
|
||||
private static boolean debugMode;
|
||||
private static boolean unapplyOnDeath;
|
||||
private static boolean forcePermissionJoin;
|
||||
private static boolean itemsAdderChangeReload;
|
||||
private static boolean cosmeticEmoteBlockCheck;
|
||||
private static int lookDownPitch;
|
||||
private static int viewDistance;
|
||||
private static int tickPeriod;
|
||||
@@ -77,6 +83,7 @@ public class Settings {
|
||||
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
||||
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
||||
|
||||
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
||||
lookDownPitch = cosmeticSettings.node(LOOK_DOWN_PITCH_PATH).getInt();
|
||||
@@ -91,6 +98,10 @@ public class Settings {
|
||||
dyeMenuName = dyeMenuSettings.node(DYE_MENU_NAME).getString("Dye Menu");
|
||||
dyeMenuInputSlot = dyeMenuSettings.node(DYE_MENU_INPUT_SLOT).getInt(19);
|
||||
dyeMenuOutputSlot = dyeMenuSettings.node(DYE_MENU_OUTPUT_SLOT).getInt(25);
|
||||
|
||||
ConfigurationNode hookSettings = source.node(HOOK_SETTING_PATH);
|
||||
ConfigurationNode itemsAdderSettings = hookSettings.node(HOOK_ITEMADDER_PATH);
|
||||
itemsAdderChangeReload = itemsAdderSettings.node(HOOK_RELOAD_CHANGE_PATH).getBoolean(false);
|
||||
}
|
||||
|
||||
private static Vector loadVector(final ConfigurationNode config) {
|
||||
@@ -190,6 +201,9 @@ public class Settings {
|
||||
public static boolean isDebugEnabled() {
|
||||
return debugMode;
|
||||
}
|
||||
public static boolean getItemsAdderReloadChange() {
|
||||
return itemsAdderChangeReload;
|
||||
}
|
||||
|
||||
public static int getTickPeriod() {
|
||||
return tickPeriod;
|
||||
@@ -208,6 +222,11 @@ public class Settings {
|
||||
public static double getEmoteDistance() {
|
||||
return emoteDistance;
|
||||
}
|
||||
|
||||
public static boolean getCosmeticEmoteBlockCheck() {
|
||||
return cosmeticEmoteBlockCheck;
|
||||
}
|
||||
|
||||
public static void setDebugMode(boolean newSetting) {
|
||||
debugMode = newSetting;
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ public class WardrobeSettings {
|
||||
|
||||
public static boolean inDistanceOfStatic(final Location location) {
|
||||
if (wardrobeLocation == null) return false;
|
||||
if (staticRadius == -1) return false;
|
||||
if (staticRadius == -1) return true;
|
||||
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
||||
return wardrobeLocation.distanceSquared(location) <= staticRadius * staticRadius;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Cosmetic {
|
||||
public abstract class Cosmetic {
|
||||
|
||||
private String id;
|
||||
private String permission;
|
||||
@@ -22,6 +22,7 @@ public class Cosmetic {
|
||||
|
||||
protected Cosmetic(String id, @NotNull ConfigurationNode config) {
|
||||
this.id = id;
|
||||
|
||||
if (!config.node("permission").virtual()) {
|
||||
this.permission = config.node("permission").getString();
|
||||
} else {
|
||||
@@ -31,20 +32,20 @@ public class Cosmetic {
|
||||
if (!config.node("item").virtual()) this.item = generateItemStack(config.node("item"));
|
||||
|
||||
MessagesUtil.sendDebugMessages("Slot: " + config.node("slot").getString());
|
||||
setSlot(CosmeticSlot.valueOf(config.node("slot").getString()));
|
||||
|
||||
setSlot(CosmeticSlot.valueOf(config.node("slot").getString()));
|
||||
setDyable(config.node("dyeable").getBoolean(false));
|
||||
|
||||
MessagesUtil.sendDebugMessages("Dyeable " + dyable);
|
||||
|
||||
Cosmetics.addCosmetic(this);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
public String getPermission() {
|
||||
return this.permission;
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public CosmeticSlot getSlot() {
|
||||
@@ -54,6 +55,11 @@ public class Cosmetic {
|
||||
public void setSlot(CosmeticSlot slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return this.permission;
|
||||
}
|
||||
|
||||
public void setPermission(String permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
@@ -62,10 +68,6 @@ public class Cosmetic {
|
||||
return permission != null;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setDyable(boolean dyable) {
|
||||
this.dyable = dyable;
|
||||
}
|
||||
@@ -74,10 +76,7 @@ public class Cosmetic {
|
||||
return this.dyable;
|
||||
}
|
||||
|
||||
|
||||
public void update(CosmeticUser user) {
|
||||
// Override
|
||||
}
|
||||
public abstract void update(CosmeticUser user);
|
||||
|
||||
@Nullable
|
||||
public ItemStack getItem() {
|
||||
|
||||
@@ -33,6 +33,4 @@ public class CosmeticArmorType extends Cosmetic {
|
||||
public EquipmentSlot getEquipSlot() {
|
||||
return this.equipSlot;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -12,13 +13,13 @@ import org.spongepowered.configurate.ConfigurationNode;
|
||||
public class CosmeticBackpackType extends Cosmetic {
|
||||
|
||||
private final String modelName;
|
||||
private ConfigurationNode config;
|
||||
private UserBackpackManager.BackpackType backpackType;
|
||||
|
||||
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
this.config = config;
|
||||
modelName = config.node("model").getString();
|
||||
backpackType = UserBackpackManager.BackpackType.valueOf(config.node("type").getString("NORMAL").toUpperCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -28,14 +29,20 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
|
||||
Location loc = player.getLocation().clone().add(0, 2, 0);
|
||||
|
||||
if (user.isInWardrobe() || !user.isBackupSpawned()) return;
|
||||
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
||||
if (loc.getWorld() != user.getUserBackpackManager().getArmorStand().getWorld()) {
|
||||
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
||||
}
|
||||
|
||||
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
||||
|
||||
PacketManager.sendRidingPacket(player.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc);
|
||||
if (user.getUserBackpackManager().getBackpackType().equals(UserBackpackManager.BackpackType.FIRST_PERSON)) {
|
||||
user.getUserBackpackManager().teleportEffectEntity(loc);
|
||||
PacketManager.sendRidingPacket(player.getEntityId(), user.getUserBackpackManager().getAreaEffectEntityId(), loc);
|
||||
PacketManager.sendRidingPacket(user.getUserBackpackManager().getAreaEffectEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc);
|
||||
} else {
|
||||
PacketManager.sendRidingPacket(player.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc);
|
||||
}
|
||||
|
||||
user.getUserBackpackManager().getArmorStand().setRotation(loc.getYaw(), loc.getPitch());
|
||||
user.getUserBackpackManager().showBackpack();
|
||||
@@ -44,4 +51,8 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
public UserBackpackManager.BackpackType getBackpackType() {
|
||||
return backpackType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
|
||||
private final String modelName;
|
||||
private List<String> dyableParts;
|
||||
//private HashMap<Animations, String> animationBalloons;
|
||||
|
||||
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
@@ -27,17 +26,9 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
String modelId = config.node("model").getString();
|
||||
|
||||
try {
|
||||
if (!config.node("dyable-parts").virtual()) dyableParts = config.node("dyable-parts").getList(String.class);
|
||||
|
||||
/*
|
||||
if (!config.node("animations").virtual()) {
|
||||
for (ConfigurationNode animationNode : config.node("animations").childrenMap().values()) {
|
||||
if (EnumUtils.isValidEnum(Animations.class, animationNode.key().toString().toUpperCase())) continue;
|
||||
animationBalloons.put(Animations.valueOf(animationNode.key().toString().toUpperCase()), animationNode.getString());
|
||||
}
|
||||
if (!config.node("dyable-parts").virtual()) {
|
||||
dyableParts = config.node("dyable-parts").getList(String.class);
|
||||
}
|
||||
*/
|
||||
|
||||
} catch (SerializationException e) {
|
||||
// Seriously?
|
||||
throw new RuntimeException(e);
|
||||
@@ -89,10 +80,4 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
if (dyableParts.isEmpty()) return true;
|
||||
return dyableParts.contains(name);
|
||||
}
|
||||
|
||||
/*
|
||||
public String getAnimation(Animations animation) {
|
||||
return animationBalloons.get(animation);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -17,27 +17,20 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Data {
|
||||
public abstract class Data {
|
||||
|
||||
public void setup() {
|
||||
// Override
|
||||
}
|
||||
public abstract void setup();
|
||||
|
||||
public void save(CosmeticUser user) {
|
||||
// Override
|
||||
}
|
||||
public abstract void save(CosmeticUser user);
|
||||
|
||||
@Nullable
|
||||
public CosmeticUser get(UUID uniqueId) {
|
||||
// Override
|
||||
return null;
|
||||
}
|
||||
public abstract CosmeticUser get(UUID uniqueId);
|
||||
|
||||
public abstract void clear(UUID uniqueId);
|
||||
|
||||
public void clear(UUID uniqueId) {
|
||||
// Override
|
||||
}
|
||||
// BACKPACK=colorfulbackpack&RRGGBB,HELMET=niftyhat,BALLOON=colorfulballoon,CHESTPLATE=niftychestplate
|
||||
public String serializeData(@NotNull CosmeticUser user) {
|
||||
@NotNull
|
||||
public final String serializeData(@NotNull CosmeticUser user) {
|
||||
String data = "";
|
||||
if (user.getHidden()) {
|
||||
if (shouldHiddenSave(user.getHiddenReason())) {
|
||||
@@ -57,7 +50,8 @@ public class Data {
|
||||
return data;
|
||||
}
|
||||
|
||||
public Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw) {
|
||||
@NotNull
|
||||
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw) {
|
||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
||||
boolean checkPermission = Settings.getForcePermissionJoin();
|
||||
|
||||
|
||||
@@ -2,18 +2,15 @@ package com.hibiscusmc.hmccosmetics.database.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MySQLData extends Data {
|
||||
public class MySQLData extends SQLData {
|
||||
|
||||
// Connection Information
|
||||
private String host;
|
||||
@@ -22,6 +19,7 @@ public class MySQLData extends Data {
|
||||
private String password;
|
||||
private int port;
|
||||
|
||||
@Nullable
|
||||
private Connection connection;
|
||||
|
||||
@Override
|
||||
@@ -35,11 +33,12 @@ public class MySQLData extends Data {
|
||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||
try {
|
||||
openConnection();
|
||||
if (connection == null) throw new NullPointerException("Connection is null");
|
||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
|
||||
"(UUID varchar(36) PRIMARY KEY, " +
|
||||
"COSMETICS MEDIUMTEXT " +
|
||||
");").execute();
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | NullPointerException e) {
|
||||
plugin.getLogger().severe("");
|
||||
plugin.getLogger().severe("");
|
||||
plugin.getLogger().severe("MySQL DATABASE CAN NOT BE REACHED.");
|
||||
@@ -52,104 +51,58 @@ public class MySQLData extends Data {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void save(CosmeticUser user) {
|
||||
Runnable run = () -> {
|
||||
try {
|
||||
PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
|
||||
preparedSt.setString(1, user.getUniqueId().toString());
|
||||
preparedSt.setString(2, serializeData(user));
|
||||
preparedSt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
if (!HMCCosmeticsPlugin.isDisable()) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CosmeticUser get(UUID uniqueId) {
|
||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
try {
|
||||
PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
|
||||
preparedStatement.setString(1, uniqueId.toString());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
if (rs.next()) {
|
||||
String rawData = rs.getString("COSMETICS");
|
||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = deserializeData(user, rawData);
|
||||
for (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
|
||||
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
// This can not be async.
|
||||
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(UUID unqiueId) {
|
||||
public void clear(UUID uniqueId) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
try {
|
||||
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
||||
preparedSt.setString(1, unqiueId.toString());
|
||||
preparedSt.setString(1, uniqueId.toString());
|
||||
preparedSt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
// TODO
|
||||
}
|
||||
|
||||
private void openConnection() throws SQLException {
|
||||
if (connection != null && !connection.isClosed()) {
|
||||
return;
|
||||
// Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
// ...
|
||||
// });
|
||||
// connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
|
||||
|
||||
// Connection isn't null AND Connection isn't closed :: return
|
||||
try {
|
||||
if (isConnectionOpen()) {
|
||||
return;
|
||||
} else if (connection != null) close(); // Close connection if still active
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace(); // If isConnectionOpen() throws error
|
||||
}
|
||||
//Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
|
||||
//close Connection if still active
|
||||
if (connection != null) {
|
||||
close();
|
||||
}
|
||||
|
||||
//connect to database host
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
|
||||
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, setupProperties());
|
||||
|
||||
} catch (SQLException e) {
|
||||
System.out.println(e.getMessage());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
//});
|
||||
//connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
|
||||
// Connect to database host
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, setupProperties());
|
||||
} catch (SQLException e) {
|
||||
System.out.println(e.getMessage());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
try {
|
||||
if (connection == null) throw new NullPointerException("Connection is null");
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | NullPointerException e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Properties setupProperties() {
|
||||
Properties props = new Properties();
|
||||
props.put("user", user);
|
||||
@@ -158,7 +111,7 @@ public class MySQLData extends Data {
|
||||
return props;
|
||||
}
|
||||
|
||||
private boolean isConnectionOpen() {
|
||||
private boolean isConnectionOpen() throws RuntimeException {
|
||||
try {
|
||||
return connection != null && !connection.isClosed();
|
||||
} catch (SQLException e) {
|
||||
@@ -166,16 +119,21 @@ public class MySQLData extends Data {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreparedStatement preparedStatement(String query) {
|
||||
PreparedStatement ps = null;
|
||||
|
||||
if (!isConnectionOpen()) {
|
||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
||||
}
|
||||
|
||||
try {
|
||||
if (connection == null) throw new NullPointerException("Connection is null");
|
||||
ps = connection.prepareStatement(query);
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return ps;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
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.user.CosmeticUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class SQLData extends Data {
|
||||
@Override
|
||||
@SuppressWarnings({"Duplicates", "resource"}) // Duplicate is from deprecated InternalData
|
||||
public CosmeticUser get(UUID uniqueId) {
|
||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
try {
|
||||
PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
|
||||
preparedStatement.setString(1, uniqueId.toString());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
if (rs.next()) {
|
||||
String rawData = rs.getString("COSMETICS");
|
||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = deserializeData(user, rawData);
|
||||
for (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
|
||||
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
// This can not be async.
|
||||
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("resource")
|
||||
public void save(CosmeticUser user) {
|
||||
Runnable run = () -> {
|
||||
try {
|
||||
PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
|
||||
preparedSt.setString(1, user.getUniqueId().toString());
|
||||
preparedSt.setString(2, serializeData(user));
|
||||
preparedSt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
if (!HMCCosmeticsPlugin.isDisable()) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract PreparedStatement preparedStatement(String query);
|
||||
}
|
||||
@@ -1,31 +1,28 @@
|
||||
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.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SQLiteData extends Data {
|
||||
public class SQLiteData extends SQLData {
|
||||
|
||||
private Connection connection;
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
File dataFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder(), "database.db");
|
||||
boolean exists = dataFolder.exists();
|
||||
|
||||
if (!dataFolder.exists()){
|
||||
if (!exists) {
|
||||
try {
|
||||
dataFolder.createNewFile();
|
||||
boolean created = dataFolder.createNewFile();
|
||||
if (!created) throw new IOException("File didn't exist but now does");
|
||||
} catch (IOException e) {
|
||||
MessagesUtil.sendDebugMessages("File write error. Database will not work properly", Level.SEVERE);
|
||||
}
|
||||
@@ -39,66 +36,18 @@ public class SQLiteData extends Data {
|
||||
"(UUID varchar(36) PRIMARY KEY, " +
|
||||
"COSMETICS MEDIUMTEXT " +
|
||||
");").execute();
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(CosmeticUser user) {
|
||||
Runnable run = () -> {
|
||||
try {
|
||||
PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
|
||||
preparedSt.setString(1, user.getUniqueId().toString());
|
||||
preparedSt.setString(2, serializeData(user));
|
||||
preparedSt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
if (!HMCCosmeticsPlugin.isDisable()) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CosmeticUser get(UUID uniqueId) {
|
||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
try {
|
||||
PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
|
||||
preparedStatement.setString(1, uniqueId.toString());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
if (rs.next()) {
|
||||
String rawData = rs.getString("COSMETICS");
|
||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = deserializeData(user, rawData);
|
||||
for (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
|
||||
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
// This can not be async.
|
||||
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(UUID unqiueId) {
|
||||
@SuppressWarnings("resource")
|
||||
public void clear(UUID uniqueId) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
try {
|
||||
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
||||
preparedSt.setString(1, unqiueId.toString());
|
||||
preparedSt.setString(1, uniqueId.toString());
|
||||
preparedSt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
@@ -106,43 +55,41 @@ public class SQLiteData extends Data {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void openConnection() throws SQLException {
|
||||
if (connection != null && !connection.isClosed()) {
|
||||
return;
|
||||
}
|
||||
//Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
// Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
// ...
|
||||
// });
|
||||
// connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
|
||||
|
||||
//close Connection if still active
|
||||
if (connection != null && !connection.isClosed()) return;
|
||||
|
||||
// Close Connection if still active
|
||||
File dataFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder(), "database.db");
|
||||
|
||||
//connect to database host
|
||||
// Connect to database host
|
||||
try {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
|
||||
|
||||
} catch (SQLException e) {
|
||||
System.out.println(e.getMessage());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
//});
|
||||
//connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreparedStatement preparedStatement(String query) {
|
||||
PreparedStatement ps = null;
|
||||
if (!isConnectionOpen()) {
|
||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
||||
}
|
||||
|
||||
try {
|
||||
ps = connection.prepareStatement(query);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return ps;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Action {
|
||||
public abstract class Action {
|
||||
|
||||
private final String id;
|
||||
|
||||
@@ -16,7 +16,5 @@ public class Action {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
// Override
|
||||
}
|
||||
public abstract void run(CosmeticUser user, String raw);
|
||||
}
|
||||
|
||||
@@ -9,23 +9,24 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Actions {
|
||||
|
||||
private static final HashMap<String, Action> actions = new HashMap<>();
|
||||
|
||||
// [ID]
|
||||
private static ActionMessage ACTION_MESSAGE = new ActionMessage();
|
||||
private static ActionMenu ACTION_MENU = new ActionMenu();
|
||||
private static ActionPlayerCommand ACTION_CONSOLE_COMMAND = new ActionPlayerCommand();
|
||||
private static ActionConsoleCommand ACTION_PLAYER_COMMAND = new ActionConsoleCommand();
|
||||
private static ActionCloseMenu ACTION_EXIT_MENU = new ActionCloseMenu();
|
||||
private static ActionSound ACTION_SOUND = new ActionSound();
|
||||
private static ActionEquip ACTION_EQUIP = new ActionEquip();
|
||||
private static ActionUnequip ACTION_UNEQUIP = new ActionUnequip();
|
||||
private static ActionParticle ACTION_PARTICLE = new ActionParticle();
|
||||
private static ActionCosmeticShow ACTION_SHOW = new ActionCosmeticShow();
|
||||
private static ActionCosmeticHide ACTION_HIDE = new ActionCosmeticHide();
|
||||
private static ActionCosmeticToggle ACTION_TOGGLE = new ActionCosmeticToggle();
|
||||
private static final ActionMessage ACTION_MESSAGE = new ActionMessage();
|
||||
private static final ActionMenu ACTION_MENU = new ActionMenu();
|
||||
private static final ActionPlayerCommand ACTION_CONSOLE_COMMAND = new ActionPlayerCommand();
|
||||
private static final ActionConsoleCommand ACTION_PLAYER_COMMAND = new ActionConsoleCommand();
|
||||
private static final ActionCloseMenu ACTION_EXIT_MENU = new ActionCloseMenu();
|
||||
private static final ActionSound ACTION_SOUND = new ActionSound();
|
||||
private static final ActionEquip ACTION_EQUIP = new ActionEquip();
|
||||
private static final ActionUnequip ACTION_UNEQUIP = new ActionUnequip();
|
||||
private static final ActionParticle ACTION_PARTICLE = new ActionParticle();
|
||||
private static final ActionCosmeticShow ACTION_SHOW = new ActionCosmeticShow();
|
||||
private static final ActionCosmeticHide ACTION_HIDE = new ActionCosmeticHide();
|
||||
private static final ActionCosmeticToggle ACTION_TOGGLE = new ActionCosmeticToggle();
|
||||
|
||||
|
||||
public static Action getAction(@NotNull String id) {
|
||||
|
||||
@@ -15,5 +15,4 @@ public class ActionConsoleCommand extends Action {
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
HMCCosmeticsPlugin.getInstance().getServer().dispatchCommand(user.getPlayer(), raw);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,8 +12,7 @@ public class ActionCosmeticHide extends Action {
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
if (!user.getHidden()) {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
}
|
||||
if (user.getHidden()) return;
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,10 @@ public class ActionCosmeticShow extends Action {
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
if (user.getHidden()) {
|
||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return; // Do not hide if its already off for WG
|
||||
user.showCosmetics();
|
||||
}
|
||||
if (!user.getHidden()) return;
|
||||
|
||||
// Do not hide if it's already off for WG
|
||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
|
||||
user.showCosmetics();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public class ActionCosmeticToggle extends Action {
|
||||
user.showCosmetics();
|
||||
return;
|
||||
}
|
||||
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,8 @@ public class ActionEquip extends Action {
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(raw);
|
||||
if (cosmetic == null) {
|
||||
return;
|
||||
}
|
||||
if (cosmetic == null) return;
|
||||
|
||||
user.addPlayerCosmetic(cosmetic);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ActionMenu extends Action {
|
||||
|
||||
@@ -22,12 +25,14 @@ public class ActionMenu extends Action {
|
||||
raw = raw.replaceAll("-o", "");
|
||||
ignorePermission = true;
|
||||
}
|
||||
|
||||
if (!Menus.hasMenu(raw)) {
|
||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Invalid Action Menu -> " + raw);
|
||||
MessagesUtil.sendDebugMessages("Invalid Action Menu -> " + raw, Level.WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
Menu menu = Menus.getMenu(raw);
|
||||
HMCCosmeticsPlugin.getInstance().getLogger().info(raw + " | " + ignorePermission);
|
||||
MessagesUtil.sendDebugMessages(raw + " | " + ignorePermission);
|
||||
menu.openMenu(user, ignorePermission);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.owen1212055.particlehelper.api.particle.types.BlockDataParticle;
|
||||
import com.owen1212055.particlehelper.api.particle.types.DestinationParticle;
|
||||
import com.owen1212055.particlehelper.api.particle.types.velocity.VelocityParticle;
|
||||
import com.owen1212055.particlehelper.api.particle.types.vibration.VibrationParticle;
|
||||
import com.owen1212055.particlehelper.api.type.ParticleType;
|
||||
import com.owen1212055.particlehelper.api.type.Particles;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -22,17 +23,17 @@ public class ActionParticle extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void run(CosmeticUser user, @NotNull String raw) {
|
||||
String[] rawString = raw.split(" ");
|
||||
var particleType = Particles.fromKey(NamespacedKey.minecraft(rawString[0].toLowerCase()));
|
||||
ParticleType<?, ?> particleType = Particles.fromKey(NamespacedKey.minecraft(rawString[0].toLowerCase()));
|
||||
if (particleType == null) {
|
||||
MessagesUtil.sendDebugMessages("The particle " + rawString[0] + " does not exist!");
|
||||
return;
|
||||
}
|
||||
boolean multi = false;
|
||||
if (particleType.multi() != null) {
|
||||
multi = true; // Should work?
|
||||
}
|
||||
|
||||
// particleType.multi() should never be null, but particleType can be.
|
||||
boolean multi = particleType.multi() != null;
|
||||
|
||||
var particle = multi ? particleType.multi() : particleType.single();
|
||||
if (particle instanceof DestinationParticle || particle instanceof BlockDataParticle
|
||||
@@ -40,6 +41,7 @@ public class ActionParticle extends Action {
|
||||
MessagesUtil.sendDebugMessages("The particle " + rawString[0] + " is not supported by this action!");
|
||||
return;
|
||||
}
|
||||
|
||||
particle = ServerUtils.addParticleValues(particle, rawString);
|
||||
Location location = user.getPlayer().getLocation();
|
||||
for (Player player : PacketManager.getViewers(location)) {
|
||||
|
||||
@@ -25,11 +25,11 @@ public class ActionSound extends Action {
|
||||
float pitch = 1;
|
||||
|
||||
if (processedString.length > 2) {
|
||||
volume = Float.valueOf(processedString[1]);
|
||||
pitch = Float.valueOf(processedString[2]);
|
||||
volume = Float.parseFloat(processedString[1]);
|
||||
pitch = Float.parseFloat(processedString[2]);
|
||||
}
|
||||
|
||||
MessagesUtil.sendDebugMessages("Attempting to play " + soundName, Level.WARNING);
|
||||
MessagesUtil.sendDebugMessages("Attempting to play " + soundName, Level.INFO);
|
||||
|
||||
player.playSound(player.getLocation(), soundName, volume, pitch);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,8 @@ public class ActionUnequip extends Action {
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, raw)) {
|
||||
return;
|
||||
}
|
||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, raw)) return;
|
||||
|
||||
CosmeticSlot slot = CosmeticSlot.valueOf(raw);
|
||||
user.removeCosmeticSlot(slot);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
@@ -57,7 +56,7 @@ public class DyeMenu {
|
||||
gui.open(player);
|
||||
}
|
||||
|
||||
private static void addCosmetic(CosmeticUser user, Cosmetic cosmetic, Color color) {
|
||||
private static void addCosmetic(@NotNull CosmeticUser user, Cosmetic cosmetic, Color color) {
|
||||
Player player = user.getPlayer();
|
||||
user.addPlayerCosmetic(cosmetic, color);
|
||||
player.setItemOnCursor(new ItemStack(Material.AIR));
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
public class Type {
|
||||
public abstract class Type {
|
||||
|
||||
private final String id;
|
||||
|
||||
@@ -21,12 +21,8 @@ public class Type {
|
||||
public void run(CosmeticUser user, ConfigurationNode config) {
|
||||
run(user, config, null);
|
||||
}
|
||||
public void run(CosmeticUser user, ConfigurationNode config, ClickType clickType) {
|
||||
// Override
|
||||
}
|
||||
|
||||
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta) {
|
||||
//TODO: Finish this
|
||||
return null; // Override
|
||||
}
|
||||
public abstract void run(CosmeticUser user, ConfigurationNode config, ClickType clickType);
|
||||
|
||||
public abstract ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta);
|
||||
}
|
||||
|
||||
@@ -149,6 +149,7 @@ public class TypeCosmetic extends Type {
|
||||
|
||||
@Contract("_, _ -> param2")
|
||||
@NotNull
|
||||
@SuppressWarnings("Duplicates")
|
||||
private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) {
|
||||
List<String> processedLore = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.hibiscusmc.hmccosmetics.gui.type.types;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Actions;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HMCPlaceholderExpansion;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -18,7 +17,6 @@ import java.util.List;
|
||||
public class TypeEmpty extends Type {
|
||||
|
||||
// This can be used as an example for making your own types.
|
||||
|
||||
public TypeEmpty() {
|
||||
super("empty");
|
||||
// This is an empty type, meaning, when a menu item has a type of "empty" it will run the code in the method run.
|
||||
@@ -34,7 +32,7 @@ public class TypeEmpty extends Type {
|
||||
try {
|
||||
// This gets the actions with the item. We can add more, such as with the Cosmetic type, an equip and unequip action set.
|
||||
// We add that to a List of Strings, before running those actions through the server. This is not the area where we deal
|
||||
// with actions, mearly what should be done for each item.
|
||||
// with actions, merely what should be done for each item.
|
||||
if (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
|
||||
|
||||
if (clickType != null) {
|
||||
@@ -54,6 +52,7 @@ public class TypeEmpty extends Type {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("Duplicates")
|
||||
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, @NotNull ItemMeta itemMeta) {
|
||||
List<String> processedLore = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.hooks;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.items.*;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.misc.HookCMI;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.misc.HookHMCColor;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.misc.HookPremiumVanish;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.misc.HookSuperVanish;
|
||||
@@ -26,6 +27,7 @@ public class Hooks {
|
||||
private static HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish();
|
||||
private static HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish();
|
||||
private static HookHMCColor HMC_COLOR_HOOK = new HookHMCColor();
|
||||
private static HookCMI CMI_HOOK = new HookCMI();
|
||||
|
||||
public static Hook getHook(@NotNull String id) {
|
||||
return hooks.get(id.toLowerCase());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import dev.lone.itemsadder.api.CustomStack;
|
||||
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
|
||||
@@ -11,8 +12,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class HookItemAdder extends Hook implements Listener {
|
||||
|
||||
// I hate IA, this overcomplicate stuff is so unneeded if it just did its stuff when its needed.
|
||||
|
||||
private boolean enabled = false;
|
||||
|
||||
public HookItemAdder() {
|
||||
@@ -33,7 +32,7 @@ public class HookItemAdder extends Hook implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
|
||||
if (enabled) return; // Only run on the first event fired; ignore all rest
|
||||
if (enabled && !Settings.getItemsAdderReloadChange()) return; // Defaultly it will only run once at startup. If hook setting is enable
|
||||
this.enabled = true;
|
||||
HMCCosmeticsPlugin.setup();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||
|
||||
import com.Zrips.CMI.events.CMIPlayerUnVanishEvent;
|
||||
import com.Zrips.CMI.events.CMIPlayerVanishEvent;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HookCMI extends Hook implements Listener {
|
||||
|
||||
public HookCMI() {
|
||||
super("CMI");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerVanish(@NotNull CMIPlayerVanishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerShow(@NotNull CMIPlayerUnVanishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
user.showCosmetics();
|
||||
}
|
||||
}
|
||||
@@ -32,10 +32,12 @@ public class WGListener implements Listener {
|
||||
}
|
||||
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) return;
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||
return;
|
||||
}
|
||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
||||
if (!protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString().equalsIgnoreCase("ALLOW")) return;
|
||||
user.enterWardrobe();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ public class PlayerGameListener implements Listener {
|
||||
registerMenuChangeListener();
|
||||
registerPlayerEquipmentListener();
|
||||
registerPlayerArmListener();
|
||||
registerEntityUseListener();
|
||||
|
||||
//registerLookMovement();
|
||||
//registerMoveListener();
|
||||
@@ -101,7 +102,7 @@ public class PlayerGameListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||
user.getUserBackpackManager().hideBackpack();
|
||||
|
||||
user.getUserBackpackManager().getArmorStand().teleport(event.getTo());
|
||||
@@ -173,7 +174,7 @@ public class PlayerGameListener implements Listener {
|
||||
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
||||
Pose pose = event.getPose();
|
||||
if (pose.equals(Pose.STANDING)) {
|
||||
if (!user.isBackupSpawned()) {
|
||||
if (!user.isBackpackSpawned()) {
|
||||
user.spawnBackpack((CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK));
|
||||
}
|
||||
return;
|
||||
@@ -406,6 +407,21 @@ public class PlayerGameListener implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
private void registerEntityUseListener() {
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.USE_ENTITY) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
if (!(event.getPlayer() instanceof Player)) return;
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
if (user.getUserEmoteManager().isPlayingEmote() || user.isInWardrobe()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void registerLookMovement() {
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.LOOK) {
|
||||
@Override
|
||||
|
||||
@@ -151,6 +151,10 @@ public class CosmeticUser {
|
||||
return playerCosmetics.containsKey(slot);
|
||||
}
|
||||
|
||||
public Set<CosmeticSlot> getSlotsWithCosmetics() {
|
||||
return Set.copyOf(playerCosmetics.keySet());
|
||||
}
|
||||
|
||||
public void updateCosmetic(CosmeticSlot slot) {
|
||||
if (getCosmetic(slot) == null) {
|
||||
return;
|
||||
@@ -287,7 +291,7 @@ public class CosmeticUser {
|
||||
|
||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||
if (this.userBackpackManager != null) return;
|
||||
this.userBackpackManager = new UserBackpackManager(this);
|
||||
this.userBackpackManager = new UserBackpackManager(this, cosmeticBackpackType.getBackpackType());
|
||||
userBackpackManager.spawnBackpack(cosmeticBackpackType);
|
||||
}
|
||||
|
||||
@@ -297,7 +301,7 @@ public class CosmeticUser {
|
||||
userBackpackManager = null;
|
||||
}
|
||||
|
||||
public boolean isBackupSpawned() {
|
||||
public boolean isBackpackSpawned() {
|
||||
if (this.userBackpackManager == null) return false;
|
||||
return true;
|
||||
}
|
||||
@@ -401,7 +405,7 @@ public class CosmeticUser {
|
||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), -1, viewer);
|
||||
}
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
userBackpackManager.getArmorStand().getEquipment().clear();
|
||||
userBackpackManager.clearItems();
|
||||
}
|
||||
updateCosmetic();
|
||||
MessagesUtil.sendDebugMessages("HideCosmetics");
|
||||
@@ -427,7 +431,7 @@ public class CosmeticUser {
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) getCosmetic(CosmeticSlot.BACKPACK);
|
||||
ItemStack item = getUserCosmeticItem(cosmeticBackpackType);
|
||||
userBackpackManager.getArmorStand().getEquipment().setHelmet(item);
|
||||
userBackpackManager.setItem(item);
|
||||
}
|
||||
updateCosmetic();
|
||||
MessagesUtil.sendDebugMessages("ShowCosmetics");
|
||||
|
||||
@@ -9,6 +9,9 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -18,13 +21,14 @@ public class UserBackpackManager {
|
||||
|
||||
private boolean hideBackpack;
|
||||
private ArmorStand invisibleArmorStand;
|
||||
private AreaEffectCloud particleCloud;
|
||||
private final CosmeticUser user;
|
||||
private BackpackType backpackType;
|
||||
|
||||
public UserBackpackManager(CosmeticUser user) {
|
||||
public UserBackpackManager(CosmeticUser user, BackpackType backpackType) {
|
||||
this.user = user;
|
||||
hideBackpack = false;
|
||||
backpackType = BackpackType.NORMAL;
|
||||
this.backpackType = backpackType;
|
||||
}
|
||||
|
||||
public int getFirstArmorStandId() {
|
||||
@@ -38,6 +42,16 @@ public class UserBackpackManager {
|
||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Start");
|
||||
|
||||
if (getBackpackType().equals(BackpackType.NORMAL)) {
|
||||
spawnNormalBackpack(cosmeticBackpackType);
|
||||
}
|
||||
if (getBackpackType().equals(BackpackType.FIRST_PERSON)) {
|
||||
spawnFirstPersonBackpack(cosmeticBackpackType);
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnNormalBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||
|
||||
if (this.invisibleArmorStand != null) return;
|
||||
|
||||
this.invisibleArmorStand = (ArmorStand) NMSHandlers.getHandler().spawnBackpack(user, cosmeticBackpackType);
|
||||
@@ -56,11 +70,37 @@ public class UserBackpackManager {
|
||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Finish");
|
||||
}
|
||||
|
||||
public void spawnFirstPersonBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||
|
||||
if (this.invisibleArmorStand != null) return;
|
||||
|
||||
this.invisibleArmorStand = (ArmorStand) NMSHandlers.getHandler().spawnBackpack(user, cosmeticBackpackType);
|
||||
this.particleCloud = (AreaEffectCloud) NMSHandlers.getHandler().spawnHMCParticleCloud(user.getPlayer().getLocation());
|
||||
|
||||
if (cosmeticBackpackType.getModelName() != null && HMCCosmeticsPlugin.hasModelEngine()) {
|
||||
if (ModelEngineAPI.api.getModelRegistry().getBlueprint(cosmeticBackpackType.getModelName()) == null) {
|
||||
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + cosmeticBackpackType.getModelName(), Level.SEVERE);
|
||||
return;
|
||||
}
|
||||
ModeledEntity modeledEntity = ModelEngineAPI.getOrCreateModeledEntity(invisibleArmorStand);
|
||||
ActiveModel model = ModelEngineAPI.createActiveModel(ModelEngineAPI.getBlueprint(cosmeticBackpackType.getModelName()));
|
||||
model.setCanHurt(false);
|
||||
modeledEntity.addModel(model, false);
|
||||
}
|
||||
|
||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Finish");
|
||||
}
|
||||
|
||||
public void despawnBackpack() {
|
||||
if (invisibleArmorStand == null) return;
|
||||
invisibleArmorStand.setHealth(0);
|
||||
invisibleArmorStand.remove();
|
||||
this.invisibleArmorStand = null;
|
||||
if (invisibleArmorStand != null) {
|
||||
invisibleArmorStand.setHealth(0);
|
||||
invisibleArmorStand.remove();
|
||||
this.invisibleArmorStand = null;
|
||||
}
|
||||
if (particleCloud != null) {
|
||||
particleCloud.remove();
|
||||
this.particleCloud = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void hideBackpack() {
|
||||
@@ -81,6 +121,27 @@ public class UserBackpackManager {
|
||||
hideBackpack = shown;
|
||||
}
|
||||
|
||||
public BackpackType getBackpackType() {
|
||||
return backpackType;
|
||||
}
|
||||
|
||||
public int getAreaEffectEntityId() {
|
||||
return particleCloud.getEntityId();
|
||||
}
|
||||
|
||||
public void teleportEffectEntity(Location location) {
|
||||
particleCloud.teleport(location);
|
||||
}
|
||||
|
||||
public void setItem(ItemStack item) {
|
||||
getArmorStand().getEquipment().setHelmet(item);
|
||||
}
|
||||
|
||||
public void clearItems() {
|
||||
ItemStack item = new ItemStack(Material.AIR);
|
||||
getArmorStand().getEquipment().setHelmet(item);
|
||||
}
|
||||
|
||||
public enum BackpackType {
|
||||
NORMAL,
|
||||
FIRST_PERSON // First person not yet implemented
|
||||
|
||||
@@ -57,7 +57,7 @@ public class UserEmoteModel extends PlayerModel {
|
||||
double DISTANCE = Settings.getEmoteDistance();
|
||||
|
||||
Location thirdPersonLocation = newLocation.add(newLocation.getDirection().normalize().multiply(DISTANCE));
|
||||
if (thirdPersonLocation.getBlock().getType() != Material.AIR) {
|
||||
if (Settings.getCosmeticEmoteBlockCheck() && thirdPersonLocation.getBlock().getType().isOccluding()) {
|
||||
stopAnimation();
|
||||
MessagesUtil.sendMessage(player, "emote-blocked");
|
||||
return;
|
||||
|
||||
@@ -24,6 +24,7 @@ cosmetic-settings:
|
||||
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
|
||||
|
||||
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
|
||||
emote-block-check: true # If the server should check if the block is open (prevents players viewing through blocks)
|
||||
|
||||
# view distance in blocks that other players will see the backpack cosmetic
|
||||
# setting this to lower than the server player view distance should fix the
|
||||
@@ -40,6 +41,11 @@ dye-menu:
|
||||
title: "§f"
|
||||
input-slot: 19
|
||||
output-slot: 25
|
||||
hook-settings:
|
||||
itemsadder:
|
||||
# This causes the plugin to reload itself after any ItemsAdder change. This keeps the plugin fully up to date with IA, but
|
||||
# could cause console spam as HMCCosmetics has to reload itself as well.
|
||||
reload-on-change: false
|
||||
wardrobe:
|
||||
# spawn static wardrobe if in this radius of wardrobe-location
|
||||
static-radius: 10
|
||||
|
||||
BIN
lib/CMI-API9.3.1.5.jar
Normal file
BIN
lib/CMI-API9.3.1.5.jar
Normal file
Binary file not shown.
BIN
lib/CMILib1.2.4.6.jar
Normal file
BIN
lib/CMILib1.2.4.6.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user