mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-26 02:19:25 +00:00
Compare commits
159 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8962539e8 | ||
|
|
01db728b99 | ||
|
|
8525dda6f4 | ||
|
|
e8f7f57e0b | ||
|
|
8c62b47d5b | ||
|
|
2ab0b119e7 | ||
|
|
20d919c65e | ||
|
|
bd41c5b9ff | ||
|
|
60aaf0cff6 | ||
|
|
71c8f8171b | ||
|
|
2bc4e3dd3f | ||
|
|
302eaa13c9 | ||
|
|
23ff51bab8 | ||
|
|
96ee695521 | ||
|
|
a9a587495a | ||
|
|
0b69e20adc | ||
|
|
a08e531226 | ||
|
|
1e27933573 | ||
|
|
0b4815842f | ||
|
|
cc6aec99e0 | ||
|
|
b51bace9f5 | ||
|
|
c70223a800 | ||
|
|
36353b5693 | ||
|
|
d4fc903c14 | ||
|
|
980d2d89df | ||
|
|
c952a8ac08 | ||
|
|
a651c9b8da | ||
|
|
c695e8b2f9 | ||
|
|
ee72bc2ef5 | ||
|
|
ebd47e9b56 | ||
|
|
5cf5e7c543 | ||
|
|
7f2d62b5e5 | ||
|
|
8d07f7cf9f | ||
|
|
789db52b57 | ||
|
|
5fb3458a98 | ||
|
|
f6935ce60b | ||
|
|
b1eb592137 | ||
|
|
913f8ccdf7 | ||
|
|
3f951263b9 | ||
|
|
744fc87491 | ||
|
|
ca01a94502 | ||
|
|
879a58d1f4 | ||
|
|
aab40b68a7 | ||
|
|
9533e2ec46 | ||
|
|
7b2e767cac | ||
|
|
4bdd000917 | ||
|
|
b397ae52f9 | ||
|
|
40620f1daa | ||
|
|
4d8d43ee2a | ||
|
|
4f8a32c3e8 | ||
|
|
1d303dee71 | ||
|
|
e9659ab1e8 | ||
|
|
ee917dbf32 | ||
|
|
2a275fe503 | ||
|
|
a5631cd2e4 | ||
|
|
1ed1a2c41d | ||
|
|
c2bf0322a7 | ||
|
|
3f8f84735f | ||
|
|
2fb28dda32 | ||
|
|
6192515550 | ||
|
|
6fcf893bac | ||
|
|
d0dfa19f2d | ||
|
|
c3b4abea40 | ||
|
|
a030d1272b | ||
|
|
d6c4b51b98 | ||
|
|
a306d76c19 | ||
|
|
1d51ee0711 | ||
|
|
e340874270 | ||
|
|
093b01d7ff | ||
|
|
5b129cc254 | ||
|
|
7a32697906 | ||
|
|
2ea272ee4a | ||
|
|
9ebfc9748d | ||
|
|
d1a2b6a016 | ||
|
|
af78424b07 | ||
|
|
c35546e536 | ||
|
|
7db03a2f8a | ||
|
|
99f3765e6e | ||
|
|
fae001a48f | ||
|
|
1ccb35ad62 | ||
|
|
2b4e570172 | ||
|
|
965b6cc740 | ||
|
|
ffda4ba6f5 | ||
|
|
df2da4fc89 | ||
|
|
cea40033f9 | ||
|
|
42a01a44aa | ||
|
|
17c07d0e01 | ||
|
|
ea4d088b04 | ||
|
|
591198175a | ||
|
|
be93369a8b | ||
|
|
fd6553a52a | ||
|
|
961f460ffb | ||
|
|
eb925d9022 | ||
|
|
d05072eb2c | ||
|
|
f456ddf8a4 | ||
|
|
c395b68d6a | ||
|
|
fddd5d0311 | ||
|
|
f08c38ff1a | ||
|
|
a4bd9108b1 | ||
|
|
de1377dc8f | ||
|
|
00ce32c528 | ||
|
|
0ddcb12b31 | ||
|
|
adadecfa19 | ||
|
|
ac35ef8b5d | ||
|
|
65f1c72b8e | ||
|
|
178bff37f5 | ||
|
|
48b9d4fb41 | ||
|
|
81d6583430 | ||
|
|
0304c9ff44 | ||
|
|
bf591e708d | ||
|
|
14bbd111f9 | ||
|
|
2185c27be5 | ||
|
|
aef9e24d28 | ||
|
|
d1a35b721e | ||
|
|
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 |
13
.github/CONTRIBUTING.md
vendored
Normal file
13
.github/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
If you wish to contribute to the HMCCosmetics codebase, feel free to fork the repository and [submit a pull request](https://github.com/HibiscusMC/HMCCosmetics/compare).
|
||||||
|
> **Note** Contributions to the HMCCosmetics codebase should remain consistent with current code style. Remember to keep your code clean, documented and understandable, and to avoid messy or confusing code.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
To get ready to work on the codebase, please do the following:
|
||||||
|
|
||||||
|
1. Fork & clone the repository, and make sure you're on the **remapped** branch. (*This is the default branch*)
|
||||||
|
2. Code your heart out!
|
||||||
|
3. Run `./gradlew build` to ensure your project successfully builds. (*This may take a while*)
|
||||||
|
4. Finally, [submit a pull request](https://github.com/HibiscusMC/HMCCosmetics/compare)!
|
||||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
2
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
2
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
name: Feature Request
|
name: Feature Request
|
||||||
description: Create a feature request to help us keep track of all features you want to be added
|
description: Create a feature request to help us keep track of all features you want to be added
|
||||||
title: "[FEATURE] <title>"
|
title: "[FEATURE] <title>"
|
||||||
labels: [feature]
|
labels: [enhancement]
|
||||||
|
|
||||||
body:
|
body:
|
||||||
- type: "checkboxes"
|
- type: "checkboxes"
|
||||||
|
|||||||
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#### Select the option(s) that best describes this PR:
|
||||||
|
- [ ] Major breaking change
|
||||||
|
- [ ] Minor change
|
||||||
|
- [ ] Bug fix
|
||||||
|
- [ ] Feature implementation
|
||||||
|
- [ ] Documentation
|
||||||
|
- [ ] Cleaning
|
||||||
|
- [ ] Refactoring
|
||||||
|
|
||||||
|
#### Please describe the changes this PR makes and why it should be merged:
|
||||||
|
|
||||||
|
#### Check that:
|
||||||
|
- [ ] *Any* new classes, public methods and/or properties are properly documented with `JavaDocs`
|
||||||
|
- [ ] Syntax and style are consistent with existing code
|
||||||
|
- [ ] *Any* replaced method isn't deleted, but rather labeled as deprecated
|
||||||
|
> **Note** In the case where the new method has the exact same signature as the method it's replacing, mention above that the old method *was* deleted.
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -23,7 +23,6 @@ atlassian-ide-plugin.xml
|
|||||||
*.ctxt
|
*.ctxt
|
||||||
|
|
||||||
# Package Files #
|
# Package Files #
|
||||||
*.jar
|
|
||||||
*.war
|
*.war
|
||||||
*.nar
|
*.nar
|
||||||
*.ear
|
*.ear
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.2.3"
|
version = "2.2.7"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -59,10 +59,13 @@ allprojects {
|
|||||||
|
|
||||||
// PlayerAnimator
|
// PlayerAnimator
|
||||||
maven("https://mvn.lumine.io/repository/maven/")
|
maven("https://mvn.lumine.io/repository/maven/")
|
||||||
|
|
||||||
|
// md-5 Repo
|
||||||
|
maven("https://repo.md-5.net/content/groups/public/")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
|
||||||
compileOnly("com.mojang:authlib:1.5.25")
|
compileOnly("com.mojang:authlib:1.5.25")
|
||||||
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||||
@@ -77,7 +80,6 @@ allprojects {
|
|||||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.6-4")
|
compileOnly("com.github.LeonMangler:SuperVanish:6.2.6-4")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +89,7 @@ dependencies {
|
|||||||
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
|
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
|
||||||
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
||||||
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
|
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
|
||||||
|
implementation(project(path = ":v1_19_R3", configuration = "reobf"))
|
||||||
|
|
||||||
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
||||||
implementation("net.kyori:adventure-api:4.11.0")
|
implementation("net.kyori:adventure-api:4.11.0")
|
||||||
@@ -117,7 +120,7 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runServer {
|
runServer {
|
||||||
minecraftVersion("1.19.2")
|
minecraftVersion("1.19.4")
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
@@ -125,6 +128,7 @@ tasks {
|
|||||||
dependsOn(":v1_18_R2:reobfJar")
|
dependsOn(":v1_18_R2:reobfJar")
|
||||||
dependsOn(":v1_19_R1:reobfJar")
|
dependsOn(":v1_19_R1:reobfJar")
|
||||||
dependsOn(":v1_19_R2:reobfJar")
|
dependsOn(":v1_19_R2:reobfJar")
|
||||||
|
dependsOn(":v1_19_R3:reobfJar")
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
|
||||||
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGListener;
|
|||||||
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
|
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
|
||||||
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
|
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
||||||
import com.jeff_media.updatechecker.UpdateCheckSource;
|
import com.jeff_media.updatechecker.UpdateCheckSource;
|
||||||
@@ -120,7 +123,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WorldGuard
|
// WorldGuard
|
||||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
|
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheckEnabled()) {
|
||||||
getServer().getPluginManager().registerEvents(new WGListener(), this);
|
getServer().getPluginManager().registerEvents(new WGListener(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,11 +138,16 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
// Plugin shutdown logic
|
||||||
disable = true;
|
disable = true;
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
Database.save(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) continue;
|
||||||
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
|
player.setInvisible(false);
|
||||||
|
}
|
||||||
|
Database.save(user);
|
||||||
}
|
}
|
||||||
// Plugin shutdown logic
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HMCCosmeticsPlugin getInstance() {
|
public static HMCCosmeticsPlugin getInstance() {
|
||||||
@@ -239,14 +247,16 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
File[] emotesFiles = emoteFolder.listFiles();
|
File[] emotesFiles = emoteFolder.listFiles();
|
||||||
for (File emoteFile : emotesFiles) {
|
for (File emoteFile : emotesFiles) {
|
||||||
if (!emoteFile.getName().contains("bbmodel")) continue;
|
if (!emoteFile.getName().contains("bbmodel")) continue;
|
||||||
String animationName = emoteFile.getName().replaceAll(".bbmodel", "");
|
String animationName = FilenameUtils.removeExtension(emoteFile.getName());
|
||||||
PlayerAnimator.api.getAnimationManager().importAnimations(FilenameUtils.removeExtension(emoteFile.getName()), emoteFile);
|
PlayerAnimator.api.getAnimationManager().importAnimations(animationName, emoteFile);
|
||||||
MessagesUtil.sendDebugMessages("Added '" + animationName + "' to Player Animator ");
|
MessagesUtil.sendDebugMessages("Added '" + animationName + "' to Player Animator ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
for (Map.Entry<String, AnimationPack> packEntry : PlayerAnimator.api.getAnimationManager().getRegistry().entrySet()) {
|
for (Map.Entry<String, AnimationPack> packEntry : PlayerAnimator.api.getAnimationManager().getRegistry().entrySet()) {
|
||||||
//Set<String> animationNames = packEntry.getValue().getAnimations().keySet().stream().map(animation -> packEntry.getKey().replace(":", ".") + "." + animation).collect(Collectors.toSet());
|
Set<String> animationNames = packEntry.getValue().getAnimations().keySet().stream().map(animation -> packEntry.getKey().replace(":", ".") + "." + animation).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the plugin is set up and/or reloaded
|
||||||
|
*/
|
||||||
public class HMCCosmeticSetupEvent extends Event {
|
public class HMCCosmeticSetupEvent extends Event {
|
||||||
|
|
||||||
public HMCCosmeticSetupEvent() {
|
|
||||||
// Empty
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -18,6 +16,7 @@ public class HMCCosmeticSetupEvent extends Event {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,53 +3,68 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerCosmeticEquipEvent extends Event implements Cancellable {
|
/**
|
||||||
|
* Called when a player equips a cosmetic
|
||||||
private final CosmeticUser user;
|
*/
|
||||||
|
public class PlayerCosmeticEquipEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
private Cosmetic cosmetic;
|
private Cosmetic cosmetic;
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerCosmeticEquipEvent(CosmeticUser user, Cosmetic cosmetic) {
|
public PlayerCosmeticEquipEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
|
||||||
this.user = user;
|
super(who);
|
||||||
|
this.cosmetic = cosmetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Cosmetic} being equipped in this event
|
||||||
|
*
|
||||||
|
* @return The {@link Cosmetic} which is being equipped in this event
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public Cosmetic getCosmetic() {
|
||||||
|
return cosmetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link Cosmetic} that the player will equip
|
||||||
|
*
|
||||||
|
* @param cosmetic The {@link Cosmetic} that the player will equip
|
||||||
|
*/
|
||||||
|
public void setCosmetic(@NotNull Cosmetic cosmetic) {
|
||||||
this.cosmetic = cosmetic;
|
this.cosmetic = cosmetic;
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return isCancelled;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from equipping the cosmetic
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cosmetic getCosmetic() {
|
|
||||||
return cosmetic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCosmetic(Cosmetic cosmetic) {
|
|
||||||
this.cosmetic = cosmetic;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a cosmetic user related event
|
||||||
|
*/
|
||||||
|
public abstract class PlayerCosmeticEvent extends Event {
|
||||||
|
protected CosmeticUser user;
|
||||||
|
|
||||||
|
public PlayerCosmeticEvent(@NotNull final CosmeticUser who) {
|
||||||
|
user = who;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the user involved in this event
|
||||||
|
*
|
||||||
|
* @return User who is involved in this event
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public final CosmeticUser getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,48 +2,59 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerCosmeticHideEvent extends Event implements Cancellable {
|
/**
|
||||||
|
* Called when cosmetics are hidden from a player
|
||||||
private final CosmeticUser user;
|
*/
|
||||||
|
public class PlayerCosmeticHideEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
private final CosmeticUser.HiddenReason reason;
|
private final CosmeticUser.HiddenReason reason;
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerCosmeticHideEvent(CosmeticUser user, CosmeticUser.HiddenReason reason) {
|
public PlayerCosmeticHideEvent(@NotNull CosmeticUser who, @NotNull CosmeticUser.HiddenReason reason) {
|
||||||
this.user = user;
|
super(who);
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
this.isCancelled = false;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link CosmeticUser.HiddenReason} as to why cosmetics are being hidden for the player
|
||||||
|
*
|
||||||
|
* @return The {@link CosmeticUser.HiddenReason} why cosmetics are being hidden for the player
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public CosmeticUser.HiddenReason getReason() {
|
||||||
|
return reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return isCancelled;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from hiding cosmetics
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
public CosmeticUser.HiddenReason getReason() {
|
|
||||||
return reason;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,34 +3,50 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerCosmeticRemoveEvent extends Event implements Cancellable {
|
/**
|
||||||
|
* Called when a player removes a cosmetic
|
||||||
private final CosmeticUser user;
|
*/
|
||||||
|
public class PlayerCosmeticRemoveEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
private final Cosmetic cosmetic;
|
private final Cosmetic cosmetic;
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerCosmeticRemoveEvent(CosmeticUser user, Cosmetic cosmetic) {
|
public PlayerCosmeticRemoveEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
|
||||||
this.user = user;
|
super(who);
|
||||||
this.cosmetic = cosmetic;
|
this.cosmetic = cosmetic;
|
||||||
this.isCancelled = false;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Cosmetic} being removed in this event
|
||||||
|
*
|
||||||
|
* @return The {@link Cosmetic} which is being removed in this event
|
||||||
|
*/
|
||||||
|
public Cosmetic getCosmetic() {
|
||||||
|
return cosmetic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return isCancelled;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from removing the cosmetic
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
@@ -40,12 +56,4 @@ public class PlayerCosmeticRemoveEvent extends Event implements Cancellable {
|
|||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cosmetic getCosmetic() {
|
|
||||||
return cosmetic;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,43 +2,47 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerCosmeticShowEvent extends Event implements Cancellable {
|
/**
|
||||||
|
* Called when cosmetics are shown from a player
|
||||||
|
*/
|
||||||
|
public class PlayerCosmeticShowEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
private final CosmeticUser user;
|
public PlayerCosmeticShowEvent(@NotNull CosmeticUser who) {
|
||||||
private boolean isCancelled;
|
super(who);
|
||||||
|
|
||||||
public PlayerCosmeticShowEvent(CosmeticUser user) {
|
|
||||||
this.user = user;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return isCancelled;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from showing cosmetics
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player starts playing an emote
|
||||||
|
*/
|
||||||
|
public class PlayerEmoteStartEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
private final String animationId;
|
||||||
|
|
||||||
|
public PlayerEmoteStartEvent(@NotNull CosmeticUser who, @NotNull String animationId) {
|
||||||
|
super(who);
|
||||||
|
this.animationId = animationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the animation id of the emote the player started playing
|
||||||
|
* @implNote The returned string of this method may be an invalid animation id. Make sure to validate it before use
|
||||||
|
*
|
||||||
|
* @return The animation id of the emote which the player started playing
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public String getAnimationId() {
|
||||||
|
return animationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from playing the emote
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player stops playing an emote
|
||||||
|
*/
|
||||||
|
public class PlayerEmoteStopEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
private final UserEmoteManager.StopEmoteReason reason;
|
||||||
|
|
||||||
|
public PlayerEmoteStopEvent(@NotNull CosmeticUser who, @NotNull UserEmoteManager.StopEmoteReason reason) {
|
||||||
|
super(who);
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing
|
||||||
|
*
|
||||||
|
* @return The {@link UserEmoteManager.StopEmoteReason} why the emote has stopped playing
|
||||||
|
* @deprecated As of release 2.2.5+, replaced by {@link #getReason()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@NotNull
|
||||||
|
public UserEmoteManager.StopEmoteReason getStopEmoteReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing
|
||||||
|
*
|
||||||
|
* @return The {@link UserEmoteManager.StopEmoteReason} why the emote has stopped playing
|
||||||
|
* @since 2.2.5
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public UserEmoteManager.StopEmoteReason getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from stopping the emote
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a menu is closed by a player
|
||||||
|
*/
|
||||||
|
public class PlayerMenuCloseEvent extends PlayerMenuEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
public PlayerMenuCloseEvent(@NotNull CosmeticUser who, @NotNull Menu menu) {
|
||||||
|
super(who, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a menu related event
|
||||||
|
*/
|
||||||
|
public abstract class PlayerMenuEvent extends PlayerCosmeticEvent {
|
||||||
|
protected Menu menu;
|
||||||
|
|
||||||
|
public PlayerMenuEvent(@NotNull CosmeticUser who, @NotNull Menu menu) {
|
||||||
|
super(who);
|
||||||
|
this.menu = menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Menu} involved with this event
|
||||||
|
*
|
||||||
|
* @return The {@link Menu} which is involved with the event
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public final Menu getMenu() {
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,49 +3,47 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerMenuOpenEvent extends Event implements Cancellable {
|
/**
|
||||||
|
* Called when a menu is opened by a player
|
||||||
|
*/
|
||||||
|
public class PlayerMenuOpenEvent extends PlayerMenuEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
private final CosmeticUser user;
|
public PlayerMenuOpenEvent(@NotNull CosmeticUser who, @NotNull Menu menu) {
|
||||||
private final Menu menu;
|
super(who, menu);
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerMenuOpenEvent(CosmeticUser user, Menu menu) {
|
|
||||||
this.user = user;
|
|
||||||
this.menu = menu;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return isCancelled;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from opening a {@link Menu}
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Menu getMenu() {
|
|
||||||
return menu;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,43 +2,47 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerWardrobeEnterEvent extends Event implements Cancellable {
|
/**
|
||||||
|
* Called when a player enters their wardrobe
|
||||||
|
*/
|
||||||
|
public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
private final CosmeticUser user;
|
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who) {
|
||||||
private boolean isCancelled;
|
super(who);
|
||||||
|
|
||||||
public PlayerWardrobeEnterEvent(CosmeticUser user) {
|
|
||||||
this.user = user;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return isCancelled;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from entering their wardrobe
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,43 +2,47 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerWardrobeLeaveEvent extends Event implements Cancellable {
|
/**
|
||||||
|
* Called when a player leaves their wardrobe
|
||||||
|
*/
|
||||||
|
public class PlayerWardrobeLeaveEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
private final CosmeticUser user;
|
public PlayerWardrobeLeaveEvent(@NotNull CosmeticUser who) {
|
||||||
private boolean isCancelled;
|
super(who);
|
||||||
|
|
||||||
public PlayerWardrobeLeaveEvent(CosmeticUser user) {
|
|
||||||
this.user = user;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return isCancelled;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from leaving their wardrobe
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class CosmeticCommand implements CommandExecutor {
|
public class CosmeticCommand implements CommandExecutor {
|
||||||
|
|
||||||
// cosmetics apply cosmetics playerName
|
// cosmetics apply cosmetics playerName
|
||||||
@@ -92,7 +94,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Cosmetic cosmetic;
|
Cosmetic cosmetic;
|
||||||
Color color = Color.WHITE;
|
Color color = null;
|
||||||
|
|
||||||
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")) {
|
||||||
@@ -148,19 +150,11 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CosmeticSlot cosmeticSlot;
|
|
||||||
|
|
||||||
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
||||||
if (sender.hasPermission("hmccosmetics.cmd.unapply.other")) {
|
if (sender.hasPermission("hmccosmetics.cmd.unapply.other")) {
|
||||||
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
|
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 (player == null) {
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||||
return true;
|
return true;
|
||||||
@@ -168,20 +162,34 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
|
||||||
if (user.getCosmetic(cosmeticSlot) == null) {
|
Set<CosmeticSlot> cosmeticSlots;
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "no-cosmetic-slot");
|
|
||||||
return true;
|
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 =
|
for (CosmeticSlot cosmeticSlot : cosmeticSlots) {
|
||||||
TagResolver.resolver(Placeholder.parsed("cosmetic", user.getCosmetic(cosmeticSlot).getId()),
|
if (user.getCosmetic(cosmeticSlot) == null) {
|
||||||
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
|
if (!silent) MessagesUtil.sendMessage(sender, "no-cosmetic-slot");
|
||||||
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmeticSlot.name())));
|
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);
|
if (!silent) MessagesUtil.sendMessage(player, "unequip-cosmetic", placeholders);
|
||||||
user.updateCosmetic(cosmeticSlot);
|
|
||||||
|
user.removeCosmeticSlot(cosmeticSlot);
|
||||||
|
user.updateCosmetic(cosmeticSlot);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case ("wardrobe") -> {
|
case ("wardrobe") -> {
|
||||||
@@ -324,7 +332,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getArmorStand().getLocation());
|
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getArmorStand().getLocation());
|
||||||
}
|
}
|
||||||
player.sendMessage("Cosmetics -> " + user.getCosmetic());
|
player.sendMessage("Cosmetics -> " + user.getCosmetics());
|
||||||
player.sendMessage("EntityId -> " + player.getEntityId());
|
player.sendMessage("EntityId -> " + player.getEntityId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,9 +56,10 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
completions.addAll(applyCommandComplete(user, args));
|
completions.addAll(applyCommandComplete(user, args));
|
||||||
}
|
}
|
||||||
case "unapply" -> {
|
case "unapply" -> {
|
||||||
for (Cosmetic cosmetic : user.getCosmetic()) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
completions.add(cosmetic.getSlot().toString().toUpperCase());
|
completions.add(cosmetic.getSlot().toString().toUpperCase());
|
||||||
}
|
}
|
||||||
|
completions.add("ALL");
|
||||||
}
|
}
|
||||||
case "menu" -> {
|
case "menu" -> {
|
||||||
for (Menu menu : Menus.getMenu()) {
|
for (Menu menu : Menus.getMenu()) {
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ package com.hibiscusmc.hmccosmetics.config;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Settings {
|
public class Settings {
|
||||||
|
|
||||||
// General Settings
|
// General Settings
|
||||||
@@ -32,6 +35,20 @@ public class Settings {
|
|||||||
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
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 FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
|
||||||
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
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 HOOK_WORLDGUARD_PATH = "worldguard";
|
||||||
|
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
||||||
|
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
||||||
|
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
||||||
|
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
||||||
|
private static final String COSMETIC_EMOTE_INVINCIBLE_PATH = "emote-invincible";
|
||||||
|
private static final String COSMETIC_ADD_ENCHANTS_HELMET_PATH = "helmet-add-enchantments";
|
||||||
|
private static final String COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH = "chest-add-enchantments";
|
||||||
|
private static final String COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH = "leggings-add-enchantments";
|
||||||
|
private static final String COSMETIC_ADD_ENCHANTS_BOOTS_PATH = "boots-add-enchantments";
|
||||||
|
private static final String COSMETIC_DESTROY_LOOSE_COSMETIC_PATH = "destroy-loose-cosmetics";
|
||||||
|
|
||||||
private static String defaultMenu;
|
private static String defaultMenu;
|
||||||
private static String dyeMenuName;
|
private static String dyeMenuName;
|
||||||
@@ -46,6 +63,16 @@ public class Settings {
|
|||||||
private static boolean debugMode;
|
private static boolean debugMode;
|
||||||
private static boolean unapplyOnDeath;
|
private static boolean unapplyOnDeath;
|
||||||
private static boolean forcePermissionJoin;
|
private static boolean forcePermissionJoin;
|
||||||
|
private static boolean itemsAdderChangeReload;
|
||||||
|
private static boolean worldGuardMoveCheck;
|
||||||
|
private static boolean cosmeticEmoteBlockCheck;
|
||||||
|
private static boolean addHelmetEnchants;
|
||||||
|
private static boolean addChestplateEnchants;
|
||||||
|
private static boolean addLeggingEnchants;
|
||||||
|
private static boolean addBootsEnchants;
|
||||||
|
private static boolean emoteDamageLeave;
|
||||||
|
private static boolean emoteInvincible;
|
||||||
|
private static boolean destroyLooseCosmetics;
|
||||||
private static int lookDownPitch;
|
private static int lookDownPitch;
|
||||||
private static int viewDistance;
|
private static int viewDistance;
|
||||||
private static int tickPeriod;
|
private static int tickPeriod;
|
||||||
@@ -77,6 +104,14 @@ public class Settings {
|
|||||||
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
||||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
||||||
|
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
||||||
|
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
|
||||||
|
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
||||||
|
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
||||||
|
addHelmetEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_HELMET_PATH).getBoolean(false);
|
||||||
|
addChestplateEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH).getBoolean(false);
|
||||||
|
addLeggingEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH).getBoolean(false);
|
||||||
|
addBootsEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_BOOTS_PATH).getBoolean(false);
|
||||||
|
|
||||||
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
||||||
lookDownPitch = cosmeticSettings.node(LOOK_DOWN_PITCH_PATH).getInt();
|
lookDownPitch = cosmeticSettings.node(LOOK_DOWN_PITCH_PATH).getInt();
|
||||||
@@ -91,6 +126,18 @@ public class Settings {
|
|||||||
dyeMenuName = dyeMenuSettings.node(DYE_MENU_NAME).getString("Dye Menu");
|
dyeMenuName = dyeMenuSettings.node(DYE_MENU_NAME).getString("Dye Menu");
|
||||||
dyeMenuInputSlot = dyeMenuSettings.node(DYE_MENU_INPUT_SLOT).getInt(19);
|
dyeMenuInputSlot = dyeMenuSettings.node(DYE_MENU_INPUT_SLOT).getInt(19);
|
||||||
dyeMenuOutputSlot = dyeMenuSettings.node(DYE_MENU_OUTPUT_SLOT).getInt(25);
|
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);
|
||||||
|
|
||||||
|
ConfigurationNode worldGuardSettings = hookSettings.node(HOOK_WORLDGUARD_PATH);
|
||||||
|
worldGuardMoveCheck = worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH).getBoolean(true);
|
||||||
|
// I messed up in release 2.2.6 and forgot to change player_move_check to player-move-check.
|
||||||
|
if (!worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH_LEGACY).virtual()) {
|
||||||
|
MessagesUtil.sendDebugMessages("There is a deprecated way of using WG hook setting. Change player_move_check to player-move-check in your configuration to prevent issues in the future. ", Level.WARNING);
|
||||||
|
worldGuardMoveCheck = worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH_LEGACY).getBoolean(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Vector loadVector(final ConfigurationNode config) {
|
private static Vector loadVector(final ConfigurationNode config) {
|
||||||
@@ -190,6 +237,9 @@ public class Settings {
|
|||||||
public static boolean isDebugEnabled() {
|
public static boolean isDebugEnabled() {
|
||||||
return debugMode;
|
return debugMode;
|
||||||
}
|
}
|
||||||
|
public static boolean getItemsAdderReloadChange() {
|
||||||
|
return itemsAdderChangeReload;
|
||||||
|
}
|
||||||
|
|
||||||
public static int getTickPeriod() {
|
public static int getTickPeriod() {
|
||||||
return tickPeriod;
|
return tickPeriod;
|
||||||
@@ -208,6 +258,47 @@ public class Settings {
|
|||||||
public static double getEmoteDistance() {
|
public static double getEmoteDistance() {
|
||||||
return emoteDistance;
|
return emoteDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getCosmeticEmoteBlockCheck() {
|
||||||
|
return cosmeticEmoteBlockCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isEmoteDamageLeave() {
|
||||||
|
return emoteDamageLeave;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isEmoteInvincible() {
|
||||||
|
return emoteInvincible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWorldGuardMoveCheckEnabled() {
|
||||||
|
return worldGuardMoveCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isDestroyLooseCosmetics() {
|
||||||
|
return destroyLooseCosmetics;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getShouldAddEnchants(EquipmentSlot slot) {
|
||||||
|
switch (slot) {
|
||||||
|
case HEAD -> {
|
||||||
|
return addHelmetEnchants;
|
||||||
|
}
|
||||||
|
case CHEST -> {
|
||||||
|
return addChestplateEnchants;
|
||||||
|
}
|
||||||
|
case LEGS -> {
|
||||||
|
return addLeggingEnchants;
|
||||||
|
}
|
||||||
|
case FEET -> {
|
||||||
|
return addBootsEnchants;
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setDebugMode(boolean newSetting) {
|
public static void setDebugMode(boolean newSetting) {
|
||||||
debugMode = newSetting;
|
debugMode = newSetting;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
||||||
import net.kyori.adventure.bossbar.BossBar;
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
import org.apache.commons.lang3.EnumUtils;
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
import org.spongepowered.configurate.serialize.SerializationException;
|
||||||
@@ -29,6 +30,9 @@ public class WardrobeSettings {
|
|||||||
private static final String LEAVE_LOCATION_PATH = "leave-location";
|
private static final String LEAVE_LOCATION_PATH = "leave-location";
|
||||||
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
|
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
|
||||||
private static final String RETURN_LAST_LOCATION = "return-last-location";
|
private static final String RETURN_LAST_LOCATION = "return-last-location";
|
||||||
|
private static final String GAMEMODE_OPTIONS_PATH = "gamemode-options";
|
||||||
|
private static final String FORCE_EXIT_GAMEMODE_PATH = "exit-gamemode-enabled";
|
||||||
|
private static final String EXIT_GAMEMODE_PATH = "exit-gamemode";
|
||||||
private static final String BOSSBAR_PATH = "bossbar";
|
private static final String BOSSBAR_PATH = "bossbar";
|
||||||
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
||||||
private static final String BOSSBAR_TEXT_PATH = "text";
|
private static final String BOSSBAR_TEXT_PATH = "text";
|
||||||
@@ -57,6 +61,8 @@ public class WardrobeSettings {
|
|||||||
private static boolean equipPumpkin;
|
private static boolean equipPumpkin;
|
||||||
private static boolean returnLastLocation;
|
private static boolean returnLastLocation;
|
||||||
private static boolean enabledBossbar;
|
private static boolean enabledBossbar;
|
||||||
|
private static boolean forceExitGamemode;
|
||||||
|
private static GameMode exitGamemode;
|
||||||
private static Location wardrobeLocation;
|
private static Location wardrobeLocation;
|
||||||
private static Location viewerLocation;
|
private static Location viewerLocation;
|
||||||
private static Location leaveLocation;
|
private static Location leaveLocation;
|
||||||
@@ -85,6 +91,10 @@ public class WardrobeSettings {
|
|||||||
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
|
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
|
||||||
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
|
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
|
||||||
|
|
||||||
|
ConfigurationNode gamemodeNode = source.node(GAMEMODE_OPTIONS_PATH);
|
||||||
|
forceExitGamemode = gamemodeNode.node(FORCE_EXIT_GAMEMODE_PATH).getBoolean(false);
|
||||||
|
exitGamemode = GameMode.valueOf(gamemodeNode.node(EXIT_GAMEMODE_PATH).getString("SURVIVAL"));
|
||||||
|
|
||||||
ConfigurationNode bossBarNode = source.node(BOSSBAR_PATH);
|
ConfigurationNode bossBarNode = source.node(BOSSBAR_PATH);
|
||||||
enabledBossbar = bossBarNode.node(BOSSBAR_ENABLE_PATH).getBoolean(false);
|
enabledBossbar = bossBarNode.node(BOSSBAR_ENABLE_PATH).getBoolean(false);
|
||||||
bossbarProgress = bossBarNode.node(BOSSBAR_PROGRESS_PATH).getFloat(1.0f);
|
bossbarProgress = bossBarNode.node(BOSSBAR_PROGRESS_PATH).getFloat(1.0f);
|
||||||
@@ -182,7 +192,7 @@ public class WardrobeSettings {
|
|||||||
|
|
||||||
public static boolean inDistanceOfStatic(final Location location) {
|
public static boolean inDistanceOfStatic(final Location location) {
|
||||||
if (wardrobeLocation == null) return false;
|
if (wardrobeLocation == null) return false;
|
||||||
if (staticRadius == -1) return false;
|
if (staticRadius == -1) return true;
|
||||||
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
||||||
return wardrobeLocation.distanceSquared(location) <= staticRadius * staticRadius;
|
return wardrobeLocation.distanceSquared(location) <= staticRadius * staticRadius;
|
||||||
}
|
}
|
||||||
@@ -227,6 +237,14 @@ public class WardrobeSettings {
|
|||||||
return transitionFadeOut;
|
return transitionFadeOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isForceExitGamemode() {
|
||||||
|
return forceExitGamemode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameMode getExitGamemode() {
|
||||||
|
return exitGamemode;
|
||||||
|
}
|
||||||
|
|
||||||
public static void setWardrobeLocation(Location newLocation) {
|
public static void setWardrobeLocation(Location newLocation) {
|
||||||
wardrobeLocation = newLocation;
|
wardrobeLocation = newLocation;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import org.spongepowered.configurate.serialize.SerializationException;
|
|||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Cosmetic {
|
public abstract class Cosmetic {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String permission;
|
private String permission;
|
||||||
@@ -22,6 +22,7 @@ public class Cosmetic {
|
|||||||
|
|
||||||
protected Cosmetic(String id, @NotNull ConfigurationNode config) {
|
protected Cosmetic(String id, @NotNull ConfigurationNode config) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
if (!config.node("permission").virtual()) {
|
if (!config.node("permission").virtual()) {
|
||||||
this.permission = config.node("permission").getString();
|
this.permission = config.node("permission").getString();
|
||||||
} else {
|
} else {
|
||||||
@@ -31,20 +32,20 @@ public class Cosmetic {
|
|||||||
if (!config.node("item").virtual()) this.item = generateItemStack(config.node("item"));
|
if (!config.node("item").virtual()) this.item = generateItemStack(config.node("item"));
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Slot: " + config.node("slot").getString());
|
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));
|
setDyable(config.node("dyeable").getBoolean(false));
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Dyeable " + dyable);
|
MessagesUtil.sendDebugMessages("Dyeable " + dyable);
|
||||||
|
|
||||||
Cosmetics.addCosmetic(this);
|
Cosmetics.addCosmetic(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
public String getPermission() {
|
|
||||||
return this.permission;
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticSlot getSlot() {
|
public CosmeticSlot getSlot() {
|
||||||
@@ -54,6 +55,11 @@ public class Cosmetic {
|
|||||||
public void setSlot(CosmeticSlot slot) {
|
public void setSlot(CosmeticSlot slot) {
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPermission() {
|
||||||
|
return this.permission;
|
||||||
|
}
|
||||||
|
|
||||||
public void setPermission(String permission) {
|
public void setPermission(String permission) {
|
||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
}
|
}
|
||||||
@@ -62,10 +68,6 @@ public class Cosmetic {
|
|||||||
return permission != null;
|
return permission != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDyable(boolean dyable) {
|
public void setDyable(boolean dyable) {
|
||||||
this.dyable = dyable;
|
this.dyable = dyable;
|
||||||
}
|
}
|
||||||
@@ -74,10 +76,7 @@ public class Cosmetic {
|
|||||||
return this.dyable;
|
return this.dyable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void update(CosmeticUser user);
|
||||||
public void update(CosmeticUser user) {
|
|
||||||
// Override
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import org.apache.commons.lang3.EnumUtils;
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||||
import org.spongepowered.configurate.ConfigurateException;
|
import org.spongepowered.configurate.ConfigurateException;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
@@ -33,6 +34,7 @@ public class Cosmetics {
|
|||||||
COSMETICS.remove(cosmetic);
|
COSMETICS.remove(cosmetic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static Cosmetic getCosmetic(String id) {
|
public static Cosmetic getCosmetic(String id) {
|
||||||
return COSMETICS.get(id);
|
return COSMETICS.get(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
@@ -24,15 +28,20 @@ public class CosmeticArmorType extends Cosmetic {
|
|||||||
public void update(@NotNull CosmeticUser user) {
|
public void update(@NotNull CosmeticUser user) {
|
||||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
Player player = Bukkit.getPlayer(user.getUniqueId());
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
|
||||||
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
|
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
|
||||||
if (!player.getInventory().getItemInOffHand().getType().isAir()) return;
|
if (!player.getInventory().getItemInOffHand().getType().isAir()) return;
|
||||||
}
|
}
|
||||||
PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation()));
|
ItemStack equippedItem = player.getInventory().getItem(equipSlot);
|
||||||
|
if (Settings.getShouldAddEnchants(equipSlot)) {
|
||||||
|
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
||||||
|
}
|
||||||
|
|
||||||
|
NMSHandlers.getHandler().equipmentSlotUpdate(player.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(player.getLocation()));
|
||||||
|
//PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation())); Old method
|
||||||
}
|
}
|
||||||
|
|
||||||
public EquipmentSlot getEquipSlot() {
|
public EquipmentSlot getEquipSlot() {
|
||||||
return this.equipSlot;
|
return this.equipSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -9,16 +11,18 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CosmeticBackpackType extends Cosmetic {
|
public class CosmeticBackpackType extends Cosmetic {
|
||||||
|
|
||||||
private final String modelName;
|
private final String modelName;
|
||||||
private ConfigurationNode config;
|
private UserBackpackManager.BackpackType backpackType;
|
||||||
|
|
||||||
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
||||||
super(id, config);
|
super(id, config);
|
||||||
|
|
||||||
this.config = config;
|
|
||||||
modelName = config.node("model").getString();
|
modelName = config.node("model").getString();
|
||||||
|
backpackType = UserBackpackManager.BackpackType.valueOf(config.node("type").getString("NORMAL").toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -28,14 +32,25 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
|
|
||||||
Location loc = player.getLocation().clone().add(0, 2, 0);
|
Location loc = player.getLocation().clone().add(0, 2, 0);
|
||||||
|
|
||||||
if (user.isInWardrobe() || !user.isBackupSpawned()) return;
|
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
||||||
|
if (!user.getUserBackpackManager().getArmorStand().isValid()) {
|
||||||
|
MessagesUtil.sendDebugMessages("Invalid Backpack detected! Respawning backpack, report this on the discord if this happens often!", Level.WARNING);
|
||||||
|
user.respawnBackpack();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (loc.getWorld() != user.getUserBackpackManager().getArmorStand().getWorld()) {
|
if (loc.getWorld() != user.getUserBackpackManager().getArmorStand().getWorld()) {
|
||||||
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
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().getArmorStand().setRotation(loc.getYaw(), loc.getPitch());
|
||||||
user.getUserBackpackManager().showBackpack();
|
user.getUserBackpackManager().showBackpack();
|
||||||
@@ -44,4 +59,8 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
public String getModelName() {
|
public String getModelName() {
|
||||||
return modelName;
|
return modelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserBackpackManager.BackpackType getBackpackType() {
|
||||||
|
return backpackType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,25 +19,19 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
|
|
||||||
private final String modelName;
|
private final String modelName;
|
||||||
private List<String> dyableParts;
|
private List<String> dyableParts;
|
||||||
//private HashMap<Animations, String> animationBalloons;
|
private boolean showLead;
|
||||||
|
|
||||||
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
||||||
super(id, config);
|
super(id, config);
|
||||||
|
|
||||||
String modelId = config.node("model").getString();
|
String modelId = config.node("model").getString();
|
||||||
|
|
||||||
|
showLead = config.node("show-lead").getBoolean(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!config.node("dyable-parts").virtual()) dyableParts = config.node("dyable-parts").getList(String.class);
|
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
// Seriously?
|
// Seriously?
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@@ -54,6 +48,11 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
if (player == null || userBalloonManager == null) return;
|
if (player == null || userBalloonManager == null) return;
|
||||||
if (user.isInWardrobe()) return;
|
if (user.isInWardrobe()) return;
|
||||||
|
|
||||||
|
if (!userBalloonManager.getModelEntity().isValid()) {
|
||||||
|
user.respawnBalloon();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Location newLocation = player.getLocation();
|
Location newLocation = player.getLocation();
|
||||||
Location currentLocation = user.getBalloonManager().getLocation();
|
Location currentLocation = user.getBalloonManager().getLocation();
|
||||||
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
|
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
|
||||||
@@ -72,7 +71,7 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
userBalloonManager.setLocation(newLocation);
|
userBalloonManager.setLocation(newLocation);
|
||||||
|
|
||||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||||
if (!user.getHidden()) PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), player.getEntityId(), viewer);
|
if (!user.getHidden() && showLead) PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), player.getEntityId(), viewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModelName() {
|
public String getModelName() {
|
||||||
@@ -90,9 +89,7 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
return dyableParts.contains(name);
|
return dyableParts.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
public boolean isShowLead() {
|
||||||
public String getAnimation(Animations animation) {
|
return showLead;
|
||||||
return animationBalloons.get(animation);
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,34 +17,27 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Data {
|
public abstract class Data {
|
||||||
|
|
||||||
public void setup() {
|
public abstract void setup();
|
||||||
// Override
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save(CosmeticUser user) {
|
public abstract void save(CosmeticUser user);
|
||||||
// Override
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public CosmeticUser get(UUID uniqueId) {
|
public abstract CosmeticUser get(UUID uniqueId);
|
||||||
// Override
|
|
||||||
return null;
|
public abstract void clear(UUID uniqueId);
|
||||||
}
|
|
||||||
|
|
||||||
public void clear(UUID uniqueId) {
|
|
||||||
// Override
|
|
||||||
}
|
|
||||||
// BACKPACK=colorfulbackpack&RRGGBB,HELMET=niftyhat,BALLOON=colorfulballoon,CHESTPLATE=niftychestplate
|
// 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 = "";
|
String data = "";
|
||||||
if (user.getHidden()) {
|
if (user.getHidden()) {
|
||||||
if (shouldHiddenSave(user.getHiddenReason())) {
|
if (shouldHiddenSave(user.getHiddenReason())) {
|
||||||
data = "HIDDEN=" + user.getHiddenReason();
|
data = "HIDDEN=" + user.getHiddenReason();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Cosmetic cosmetic : user.getCosmetic()) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
Color color = user.getCosmeticColor(cosmetic.getSlot());
|
Color color = user.getCosmeticColor(cosmetic.getSlot());
|
||||||
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
|
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
|
||||||
if (color != null) input = input + "&" + color.asRGB();
|
if (color != null) input = input + "&" + color.asRGB();
|
||||||
@@ -57,7 +50,8 @@ public class Data {
|
|||||||
return 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<>();
|
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
||||||
boolean checkPermission = Settings.getForcePermissionJoin();
|
boolean checkPermission = Settings.getForcePermissionJoin();
|
||||||
|
|
||||||
|
|||||||
@@ -2,18 +2,15 @@ package com.hibiscusmc.hmccosmetics.database.types;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
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.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MySQLData extends Data {
|
public class MySQLData extends SQLData {
|
||||||
|
|
||||||
// Connection Information
|
// Connection Information
|
||||||
private String host;
|
private String host;
|
||||||
@@ -22,6 +19,7 @@ public class MySQLData extends Data {
|
|||||||
private String password;
|
private String password;
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -35,11 +33,12 @@ public class MySQLData extends Data {
|
|||||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||||
try {
|
try {
|
||||||
openConnection();
|
openConnection();
|
||||||
|
if (connection == null) throw new NullPointerException("Connection is null");
|
||||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
|
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
|
||||||
"(UUID varchar(36) PRIMARY KEY, " +
|
"(UUID varchar(36) PRIMARY KEY, " +
|
||||||
"COSMETICS MEDIUMTEXT " +
|
"COSMETICS MEDIUMTEXT " +
|
||||||
");").execute();
|
");").execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException | NullPointerException e) {
|
||||||
plugin.getLogger().severe("");
|
plugin.getLogger().severe("");
|
||||||
plugin.getLogger().severe("");
|
plugin.getLogger().severe("");
|
||||||
plugin.getLogger().severe("MySQL DATABASE CAN NOT BE REACHED.");
|
plugin.getLogger().severe("MySQL DATABASE CAN NOT BE REACHED.");
|
||||||
@@ -52,104 +51,58 @@ public class MySQLData extends Data {
|
|||||||
throw new RuntimeException(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
|
@Override
|
||||||
public CosmeticUser get(UUID uniqueId) {
|
public void clear(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) {
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
try {
|
try {
|
||||||
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
||||||
preparedSt.setString(1, unqiueId.toString());
|
preparedSt.setString(1, uniqueId.toString());
|
||||||
preparedSt.executeUpdate();
|
preparedSt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openConnection() throws SQLException {
|
private void openConnection() throws SQLException {
|
||||||
if (connection != null && !connection.isClosed()) {
|
// Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
return;
|
// ...
|
||||||
|
// });
|
||||||
|
// 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
|
// Connect to database host
|
||||||
if (connection != null) {
|
try {
|
||||||
close();
|
Class.forName("com.mysql.jdbc.Driver");
|
||||||
}
|
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, setupProperties());
|
||||||
|
} catch (SQLException e) {
|
||||||
//connect to database host
|
System.out.println(e.getMessage());
|
||||||
try {
|
} catch (ClassNotFoundException e) {
|
||||||
Class.forName("com.mysql.jdbc.Driver");
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
try {
|
try {
|
||||||
|
if (connection == null) throw new NullPointerException("Connection is null");
|
||||||
connection.close();
|
connection.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException | NullPointerException e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
private Properties setupProperties() {
|
private Properties setupProperties() {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.put("user", user);
|
props.put("user", user);
|
||||||
@@ -158,7 +111,7 @@ public class MySQLData extends Data {
|
|||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isConnectionOpen() {
|
private boolean isConnectionOpen() throws RuntimeException {
|
||||||
try {
|
try {
|
||||||
return connection != null && !connection.isClosed();
|
return connection != null && !connection.isClosed();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@@ -166,16 +119,21 @@ public class MySQLData extends Data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public PreparedStatement preparedStatement(String query) {
|
public PreparedStatement preparedStatement(String query) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
|
||||||
if (!isConnectionOpen()) {
|
if (!isConnectionOpen()) {
|
||||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (connection == null) throw new NullPointerException("Connection is null");
|
||||||
ps = connection.prepareStatement(query);
|
ps = connection.prepareStatement(query);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException | NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ps;
|
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;
|
package com.hibiscusmc.hmccosmetics.database.types;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
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 com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class SQLiteData extends Data {
|
public class SQLiteData extends SQLData {
|
||||||
|
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
File dataFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder(), "database.db");
|
File dataFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder(), "database.db");
|
||||||
|
boolean exists = dataFolder.exists();
|
||||||
|
|
||||||
if (!dataFolder.exists()){
|
if (!exists) {
|
||||||
try {
|
try {
|
||||||
dataFolder.createNewFile();
|
boolean created = dataFolder.createNewFile();
|
||||||
|
if (!created) throw new IOException("File didn't exist but now does");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
MessagesUtil.sendDebugMessages("File write error. Database will not work properly", Level.SEVERE);
|
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, " +
|
"(UUID varchar(36) PRIMARY KEY, " +
|
||||||
"COSMETICS MEDIUMTEXT " +
|
"COSMETICS MEDIUMTEXT " +
|
||||||
");").execute();
|
");").execute();
|
||||||
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(CosmeticUser user) {
|
@SuppressWarnings("resource")
|
||||||
Runnable run = () -> {
|
public void clear(UUID uniqueId) {
|
||||||
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) {
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
try {
|
try {
|
||||||
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
||||||
preparedSt.setString(1, unqiueId.toString());
|
preparedSt.setString(1, uniqueId.toString());
|
||||||
preparedSt.executeUpdate();
|
preparedSt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -106,43 +55,41 @@ public class SQLiteData extends Data {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void openConnection() throws SQLException {
|
private void openConnection() throws SQLException {
|
||||||
if (connection != null && !connection.isClosed()) {
|
// Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
return;
|
// ...
|
||||||
}
|
// });
|
||||||
//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");
|
File dataFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder(), "database.db");
|
||||||
|
|
||||||
//connect to database host
|
// Connect to database host
|
||||||
try {
|
try {
|
||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
|
|
||||||
connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
|
connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//});
|
|
||||||
//connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public PreparedStatement preparedStatement(String query) {
|
public PreparedStatement preparedStatement(String query) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
if (!isConnectionOpen()) {
|
if (!isConnectionOpen()) {
|
||||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ps = connection.prepareStatement(query);
|
ps = connection.prepareStatement(query);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class Action {
|
public abstract class Action {
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
@@ -16,7 +16,5 @@ public class Action {
|
|||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(CosmeticUser user, String raw) {
|
public abstract void run(CosmeticUser user, String raw);
|
||||||
// Override
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,23 +9,24 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class Actions {
|
public class Actions {
|
||||||
|
|
||||||
private static final HashMap<String, Action> actions = new HashMap<>();
|
private static final HashMap<String, Action> actions = new HashMap<>();
|
||||||
|
|
||||||
// [ID]
|
// [ID]
|
||||||
private static ActionMessage ACTION_MESSAGE = new ActionMessage();
|
private static final ActionMessage ACTION_MESSAGE = new ActionMessage();
|
||||||
private static ActionMenu ACTION_MENU = new ActionMenu();
|
private static final ActionMenu ACTION_MENU = new ActionMenu();
|
||||||
private static ActionPlayerCommand ACTION_CONSOLE_COMMAND = new ActionPlayerCommand();
|
private static final ActionPlayerCommand ACTION_CONSOLE_COMMAND = new ActionPlayerCommand();
|
||||||
private static ActionConsoleCommand ACTION_PLAYER_COMMAND = new ActionConsoleCommand();
|
private static final ActionConsoleCommand ACTION_PLAYER_COMMAND = new ActionConsoleCommand();
|
||||||
private static ActionCloseMenu ACTION_EXIT_MENU = new ActionCloseMenu();
|
private static final ActionCloseMenu ACTION_EXIT_MENU = new ActionCloseMenu();
|
||||||
private static ActionSound ACTION_SOUND = new ActionSound();
|
private static final ActionSound ACTION_SOUND = new ActionSound();
|
||||||
private static ActionEquip ACTION_EQUIP = new ActionEquip();
|
private static final ActionEquip ACTION_EQUIP = new ActionEquip();
|
||||||
private static ActionUnequip ACTION_UNEQUIP = new ActionUnequip();
|
private static final ActionUnequip ACTION_UNEQUIP = new ActionUnequip();
|
||||||
private static ActionParticle ACTION_PARTICLE = new ActionParticle();
|
private static final ActionParticle ACTION_PARTICLE = new ActionParticle();
|
||||||
private static ActionCosmeticShow ACTION_SHOW = new ActionCosmeticShow();
|
private static final ActionCosmeticShow ACTION_SHOW = new ActionCosmeticShow();
|
||||||
private static ActionCosmeticHide ACTION_HIDE = new ActionCosmeticHide();
|
private static final ActionCosmeticHide ACTION_HIDE = new ActionCosmeticHide();
|
||||||
private static ActionCosmeticToggle ACTION_TOGGLE = new ActionCosmeticToggle();
|
private static final ActionCosmeticToggle ACTION_TOGGLE = new ActionCosmeticToggle();
|
||||||
|
|
||||||
|
|
||||||
public static Action getAction(@NotNull String id) {
|
public static Action getAction(@NotNull String id) {
|
||||||
|
|||||||
@@ -15,5 +15,4 @@ public class ActionConsoleCommand extends Action {
|
|||||||
public void run(@NotNull CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, String raw) {
|
||||||
HMCCosmeticsPlugin.getInstance().getServer().dispatchCommand(user.getPlayer(), raw);
|
HMCCosmeticsPlugin.getInstance().getServer().dispatchCommand(user.getPlayer(), raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ public class ActionCosmeticHide extends Action {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(@NotNull CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, String raw) {
|
||||||
if (!user.getHidden()) {
|
if (user.getHidden()) return;
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ public class ActionCosmeticShow extends Action {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(@NotNull CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, String raw) {
|
||||||
if (user.getHidden()) {
|
if (!user.getHidden()) return;
|
||||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return; // Do not hide if its already off for WG
|
|
||||||
user.showCosmetics();
|
// 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();
|
user.showCosmetics();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ public class ActionEquip extends Action {
|
|||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
public void run(CosmeticUser user, String raw) {
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(raw);
|
Cosmetic cosmetic = Cosmetics.getCosmetic(raw);
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
user.addPlayerCosmetic(cosmetic);
|
user.addPlayerCosmetic(cosmetic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import com.hibiscusmc.hmccosmetics.gui.Menu;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class ActionMenu extends Action {
|
public class ActionMenu extends Action {
|
||||||
|
|
||||||
@@ -22,12 +25,14 @@ public class ActionMenu extends Action {
|
|||||||
raw = raw.replaceAll("-o", "");
|
raw = raw.replaceAll("-o", "");
|
||||||
ignorePermission = true;
|
ignorePermission = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Menus.hasMenu(raw)) {
|
if (!Menus.hasMenu(raw)) {
|
||||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Invalid Action Menu -> " + raw);
|
MessagesUtil.sendDebugMessages("Invalid Action Menu -> " + raw, Level.WARNING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu menu = Menus.getMenu(raw);
|
Menu menu = Menus.getMenu(raw);
|
||||||
HMCCosmeticsPlugin.getInstance().getLogger().info(raw + " | " + ignorePermission);
|
MessagesUtil.sendDebugMessages(raw + " | " + ignorePermission);
|
||||||
menu.openMenu(user, 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.DestinationParticle;
|
||||||
import com.owen1212055.particlehelper.api.particle.types.velocity.VelocityParticle;
|
import com.owen1212055.particlehelper.api.particle.types.velocity.VelocityParticle;
|
||||||
import com.owen1212055.particlehelper.api.particle.types.vibration.VibrationParticle;
|
import com.owen1212055.particlehelper.api.particle.types.vibration.VibrationParticle;
|
||||||
|
import com.owen1212055.particlehelper.api.type.ParticleType;
|
||||||
import com.owen1212055.particlehelper.api.type.Particles;
|
import com.owen1212055.particlehelper.api.type.Particles;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
@@ -22,17 +23,17 @@ public class ActionParticle extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
public void run(CosmeticUser user, @NotNull String raw) {
|
public void run(CosmeticUser user, @NotNull String raw) {
|
||||||
String[] rawString = raw.split(" ");
|
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) {
|
if (particleType == null) {
|
||||||
MessagesUtil.sendDebugMessages("The particle " + rawString[0] + " does not exist!");
|
MessagesUtil.sendDebugMessages("The particle " + rawString[0] + " does not exist!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean multi = false;
|
|
||||||
if (particleType.multi() != null) {
|
// particleType.multi() should never be null, but particleType can be.
|
||||||
multi = true; // Should work?
|
boolean multi = particleType.multi() != null;
|
||||||
}
|
|
||||||
|
|
||||||
var particle = multi ? particleType.multi() : particleType.single();
|
var particle = multi ? particleType.multi() : particleType.single();
|
||||||
if (particle instanceof DestinationParticle || particle instanceof BlockDataParticle
|
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!");
|
MessagesUtil.sendDebugMessages("The particle " + rawString[0] + " is not supported by this action!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
particle = ServerUtils.addParticleValues(particle, rawString);
|
particle = ServerUtils.addParticleValues(particle, rawString);
|
||||||
Location location = user.getPlayer().getLocation();
|
Location location = user.getPlayer().getLocation();
|
||||||
for (Player player : PacketManager.getViewers(location)) {
|
for (Player player : PacketManager.getViewers(location)) {
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ public class ActionSound extends Action {
|
|||||||
float pitch = 1;
|
float pitch = 1;
|
||||||
|
|
||||||
if (processedString.length > 2) {
|
if (processedString.length > 2) {
|
||||||
volume = Float.valueOf(processedString[1]);
|
volume = Float.parseFloat(processedString[1]);
|
||||||
pitch = Float.valueOf(processedString[2]);
|
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);
|
player.playSound(player.getLocation(), soundName, volume, pitch);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ public class ActionUnequip extends Action {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
public void run(CosmeticUser user, String raw) {
|
||||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, raw)) {
|
if (!EnumUtils.isValidEnum(CosmeticSlot.class, raw)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
CosmeticSlot slot = CosmeticSlot.valueOf(raw);
|
CosmeticSlot slot = CosmeticSlot.valueOf(raw);
|
||||||
user.removeCosmeticSlot(slot);
|
user.removeCosmeticSlot(slot);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import com.hibiscusmc.hmccosmetics.config.Settings;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
@@ -57,7 +56,7 @@ public class DyeMenu {
|
|||||||
gui.open(player);
|
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();
|
Player player = user.getPlayer();
|
||||||
user.addPlayerCosmetic(cosmetic, color);
|
user.addPlayerCosmetic(cosmetic, color);
|
||||||
player.setItemOnCursor(new ItemStack(Material.AIR));
|
player.setItemOnCursor(new ItemStack(Material.AIR));
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.bukkit.event.inventory.ClickType;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
public class Type {
|
public abstract class Type {
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
@@ -21,12 +21,8 @@ public class Type {
|
|||||||
public void run(CosmeticUser user, ConfigurationNode config) {
|
public void run(CosmeticUser user, ConfigurationNode config) {
|
||||||
run(user, config, null);
|
run(user, config, null);
|
||||||
}
|
}
|
||||||
public void run(CosmeticUser user, ConfigurationNode config, ClickType clickType) {
|
|
||||||
// Override
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta) {
|
public abstract void run(CosmeticUser user, ConfigurationNode config, ClickType clickType);
|
||||||
//TODO: Finish this
|
|
||||||
return null; // Override
|
public abstract ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ public class TypeCosmetic extends Type {
|
|||||||
|
|
||||||
@Contract("_, _ -> param2")
|
@Contract("_, _ -> param2")
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@SuppressWarnings("Duplicates")
|
||||||
private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) {
|
private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) {
|
||||||
List<String> processedLore = new ArrayList<>();
|
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.action.Actions;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HMCPlaceholderExpansion;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
@@ -18,7 +17,6 @@ import java.util.List;
|
|||||||
public class TypeEmpty extends Type {
|
public class TypeEmpty extends Type {
|
||||||
|
|
||||||
// This can be used as an example for making your own types.
|
// This can be used as an example for making your own types.
|
||||||
|
|
||||||
public TypeEmpty() {
|
public TypeEmpty() {
|
||||||
super("empty");
|
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.
|
// 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 {
|
try {
|
||||||
// This gets the actions with the item. We can add more, such as with the Cosmetic type, an equip and unequip action set.
|
// 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
|
// 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 (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
|
||||||
|
|
||||||
if (clickType != null) {
|
if (clickType != null) {
|
||||||
@@ -54,6 +52,7 @@ public class TypeEmpty extends Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("Duplicates")
|
||||||
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, @NotNull ItemMeta itemMeta) {
|
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, @NotNull ItemMeta itemMeta) {
|
||||||
List<String> processedLore = new ArrayList<>();
|
List<String> processedLore = new ArrayList<>();
|
||||||
|
|
||||||
|
|||||||
@@ -2,45 +2,92 @@ package com.hibiscusmc.hmccosmetics.hooks;
|
|||||||
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class Hook implements Listener {
|
/**
|
||||||
|
* Represents a hook into other minecraft plugins
|
||||||
|
*/
|
||||||
|
public abstract class Hook implements Listener {
|
||||||
private final String id;
|
private final String id;
|
||||||
private boolean active;
|
private boolean active = false;
|
||||||
private boolean itemHook;
|
private boolean itemHook = false;
|
||||||
|
|
||||||
public Hook(String id) {
|
public Hook(@NotNull String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
active = false;
|
|
||||||
Hooks.addHook(this);
|
Hooks.addHook(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
/**
|
||||||
// Override
|
* Loads this hook
|
||||||
}
|
*
|
||||||
|
* @implNote By default, this method does nothing. It should be overridden by child classes to implement any necessary loading logic
|
||||||
|
*/
|
||||||
|
public void load() { }
|
||||||
|
|
||||||
public ItemStack getItem(String itemId) {
|
/**
|
||||||
|
* Gets an {@link ItemStack} that is associated with the provided id from the hooked plugin
|
||||||
|
* @param itemId The id of the {@link ItemStack}
|
||||||
|
* @return The {@link ItemStack} with the id provided. If an invalid id was provided or if the hook doesn't have any related {@link ItemStack}s then this will return null
|
||||||
|
* @implNote By default, this method returns null. It should be overridden by child classes if you will to have your hook return a related {@link ItemStack}
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
return null;
|
return null;
|
||||||
// Override
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
/**
|
||||||
|
* Gets the id of this hook
|
||||||
|
*
|
||||||
|
* @return The unique id for this hook
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public final String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActive(boolean active) {
|
/**
|
||||||
this.active = active;
|
* Gets whether this hook has been activated
|
||||||
}
|
* @return true if this hook is active, false otherwise
|
||||||
|
* @deprecated As of release 2.2.5+, replaced by {@link #isActive()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean getActive() {
|
public boolean getActive() {
|
||||||
return this.active;
|
return this.active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabledItemHook(boolean enabled) {
|
/**
|
||||||
itemHook = enabled;
|
* Gets whether this hook has been activated
|
||||||
|
* @return true if this hook is active, false otherwise
|
||||||
|
* @since 2.2.5
|
||||||
|
*/
|
||||||
|
public final boolean isActive() {
|
||||||
|
return this.active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasEnabledItemHook() {
|
/**
|
||||||
|
* Sets whether this hook is active
|
||||||
|
* @param active true to activate the hook, false otherwise
|
||||||
|
*/
|
||||||
|
public final void setActive(boolean active) {
|
||||||
|
this.active = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the method {@link #getItem(String)} should return a non-null value
|
||||||
|
* @return true if {@link #getItem(String)} should return a non-null value, false otherwise
|
||||||
|
*
|
||||||
|
* @apiNote Even though this method returns true does not mean that {@link #getItem(String)} won't return null, rather if this returns false then {@link #getItem(String)} should return false everytime
|
||||||
|
*/
|
||||||
|
public final boolean hasEnabledItemHook() {
|
||||||
return itemHook;
|
return itemHook;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the method {@link #getItem(String)} should return a non-null value
|
||||||
|
* @param enabled true if {@link #getItem(String)} should return a non-null value, false otherwise
|
||||||
|
*/
|
||||||
|
public final void setEnabledItemHook(boolean enabled) {
|
||||||
|
itemHook = enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.hooks;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.items.*;
|
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.HookHMCColor;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.misc.HookPremiumVanish;
|
import com.hibiscusmc.hmccosmetics.hooks.misc.HookPremiumVanish;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.misc.HookSuperVanish;
|
import com.hibiscusmc.hmccosmetics.hooks.misc.HookSuperVanish;
|
||||||
@@ -26,6 +27,7 @@ public class Hooks {
|
|||||||
private static HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish();
|
private static HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish();
|
||||||
private static HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish();
|
private static HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish();
|
||||||
private static HookHMCColor HMC_COLOR_HOOK = new HookHMCColor();
|
private static HookHMCColor HMC_COLOR_HOOK = new HookHMCColor();
|
||||||
|
private static HookCMI CMI_HOOK = new HookCMI();
|
||||||
|
|
||||||
public static Hook getHook(@NotNull String id) {
|
public static Hook getHook(@NotNull String id) {
|
||||||
return hooks.get(id.toLowerCase());
|
return hooks.get(id.toLowerCase());
|
||||||
@@ -65,13 +67,13 @@ public class Hooks {
|
|||||||
if (!isItemHook(split[0])) return null;
|
if (!isItemHook(split[0])) return null;
|
||||||
Hook hook = getHook(split[0]);
|
Hook hook = getHook(split[0]);
|
||||||
if (!hook.hasEnabledItemHook()) return null;
|
if (!hook.hasEnabledItemHook()) return null;
|
||||||
if (!hook.getActive()) return null;
|
if (!hook.isActive()) return null;
|
||||||
return hook.getItem(split[1]);
|
return hook.getItem(split[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isActiveHook(String id) {
|
public static boolean isActiveHook(String id) {
|
||||||
Hook hook = getHook(id);
|
Hook hook = getHook(id);
|
||||||
if (hook == null) return false;
|
if (hook == null) return false;
|
||||||
return hook.getActive();
|
return hook.isActive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,23 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookHMCCosmetics extends Hook implements Listener {
|
/**
|
||||||
|
* A hook that integrates the plugin {@link com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin HMCCosmetics} to provide cosmetic items
|
||||||
|
*/
|
||||||
|
public class HookHMCCosmetics extends Hook {
|
||||||
public HookHMCCosmetics() {
|
public HookHMCCosmetics() {
|
||||||
super("HMCCosmetics");
|
super("HMCCosmetics");
|
||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin HMCCosmetics}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(String itemId) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(itemId);
|
Cosmetic cosmetic = Cosmetics.getCosmetic(itemId);
|
||||||
if (cosmetic == null) return null;
|
if (cosmetic == null) return null;
|
||||||
return cosmetic.getItem();
|
return cosmetic.getItem();
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import dev.lone.itemsadder.api.CustomStack;
|
import dev.lone.itemsadder.api.CustomStack;
|
||||||
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
|
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookItemAdder extends Hook implements Listener {
|
/**
|
||||||
|
* A hook that integrates the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder} to provide custom items
|
||||||
// I hate IA, this overcomplicate stuff is so unneeded if it just did its stuff when its needed.
|
*/
|
||||||
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
|
public class HookItemAdder extends Hook {
|
||||||
private boolean enabled = false;
|
private boolean enabled = false;
|
||||||
|
|
||||||
public HookItemAdder() {
|
public HookItemAdder() {
|
||||||
@@ -20,8 +22,11 @@ public class HookItemAdder extends Hook implements Listener {
|
|||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(String itemId) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
CustomStack stack = CustomStack.getInstance(itemId);
|
CustomStack stack = CustomStack.getInstance(itemId);
|
||||||
if (stack == null) return null;
|
if (stack == null) return null;
|
||||||
@@ -33,7 +38,8 @@ public class HookItemAdder extends Hook implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
|
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
|
||||||
if (enabled) return; // Only run on the first event fired; ignore all rest
|
// By default, it will only run once at startup, if hook setting is enabled
|
||||||
|
if (enabled && !Settings.getItemsAdderReloadChange()) return;
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
HMCCosmeticsPlugin.setup();
|
HMCCosmeticsPlugin.setup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,24 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
|
|||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import com.mineinabyss.geary.prefabs.PrefabKey;
|
import com.mineinabyss.geary.prefabs.PrefabKey;
|
||||||
import com.mineinabyss.looty.LootyFactory;
|
import com.mineinabyss.looty.LootyFactory;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookLooty extends Hook implements Listener {
|
/**
|
||||||
|
* A hook that integrates the plugin {@link com.mineinabyss.looty.LootyPlugin Looty} to provide custom items
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
|
public class HookLooty extends Hook {
|
||||||
public HookLooty() {
|
public HookLooty() {
|
||||||
super("looty");
|
super("looty");
|
||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.looty.LootyPlugin Looty}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(String itemId) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
||||||
if (prefabKey == null) return null;
|
if (prefabKey == null) return null;
|
||||||
return LootyFactory.INSTANCE.createFromPrefab(prefabKey);
|
return LootyFactory.INSTANCE.createFromPrefab(prefabKey);
|
||||||
|
|||||||
@@ -2,17 +2,24 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import io.lumine.mythic.bukkit.MythicBukkit;
|
import io.lumine.mythic.bukkit.MythicBukkit;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookMythic extends Hook implements Listener {
|
/**
|
||||||
|
* A hook that integrates the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit} to provide custom items
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
|
public class HookMythic extends Hook {
|
||||||
public HookMythic() {
|
public HookMythic() {
|
||||||
super("mythicmobs");
|
super("mythicmobs");
|
||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(String itemId) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
return MythicBukkit.inst().getItemManager().getItemStack(itemId);
|
return MythicBukkit.inst().getItemManager().getItemStack(itemId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,24 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
|
|||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import io.th0rgal.oraxen.api.OraxenItems;
|
import io.th0rgal.oraxen.api.OraxenItems;
|
||||||
import io.th0rgal.oraxen.items.ItemBuilder;
|
import io.th0rgal.oraxen.items.ItemBuilder;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookOraxen extends Hook implements Listener {
|
/**
|
||||||
|
* A hook that integrates the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin} to provide custom items
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
|
public class HookOraxen extends Hook {
|
||||||
public HookOraxen() {
|
public HookOraxen() {
|
||||||
super("oraxen");
|
super("oraxen");
|
||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(String itemId) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
ItemBuilder builder = OraxenItems.getItemById(itemId);
|
ItemBuilder builder = OraxenItems.getItemById(itemId);
|
||||||
if (builder == null) return null;
|
if (builder == null) return null;
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
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.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link com.Zrips.CMI.CMI CMI}
|
||||||
|
*/
|
||||||
|
public class HookCMI extends Hook {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
public class HookHMCColor extends Hook implements Listener {
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link com.hibiscusmc.hmccolor.HMCColor HMCColor}
|
||||||
|
*/
|
||||||
|
public class HookHMCColor extends Hook {
|
||||||
public HookHMCColor() {
|
public HookHMCColor() {
|
||||||
super("HMCColor");
|
super("HMCColor");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ import de.myzelyam.api.vanish.PlayerHideEvent;
|
|||||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookPremiumVanish extends Hook implements Listener {
|
/**
|
||||||
|
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
|
||||||
// NOTE: Supervanish and Premium Vanish both use the same api
|
*
|
||||||
|
* @implSpec Supervanish and Premium Vanish both use the same api
|
||||||
|
*/
|
||||||
|
public class HookPremiumVanish extends Hook {
|
||||||
public HookPremiumVanish() {
|
public HookPremiumVanish() {
|
||||||
super("PremiumVanish");
|
super("PremiumVanish");
|
||||||
}
|
}
|
||||||
@@ -33,5 +34,4 @@ public class HookPremiumVanish extends Hook implements Listener {
|
|||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
user.showCosmetics();
|
user.showCosmetics();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ import de.myzelyam.api.vanish.PlayerHideEvent;
|
|||||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookSuperVanish extends Hook implements Listener {
|
/**
|
||||||
|
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
|
||||||
// NOTE: Supervanish and Premium Vanish both use the same api
|
*
|
||||||
|
* @implSpec Supervanish and Premium Vanish both use the same api
|
||||||
|
*/
|
||||||
|
public class HookSuperVanish extends Hook {
|
||||||
public HookSuperVanish() {
|
public HookSuperVanish() {
|
||||||
super("SuperVanish");
|
super("SuperVanish");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,18 +6,23 @@ 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.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link me.clip.placeholderapi.PlaceholderAPIPlugin PlaceholderAPIPlugin}
|
||||||
|
*/
|
||||||
public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||||
|
|
||||||
private static boolean papiEnabled = false;
|
private static boolean papiEnabled = false;
|
||||||
|
|
||||||
public HMCPlaceholderExpansion() {
|
public HMCPlaceholderExpansion() {
|
||||||
@@ -73,7 +78,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
||||||
switch (placeholderArgs.get(2).toLowerCase()) {
|
switch (placeholderArgs.get(2).toLowerCase()) {
|
||||||
case "material" -> {
|
case "material" -> {
|
||||||
return getMaterial(user.getCosmetic(slot));
|
return getMaterialName(user.getCosmetic(slot));
|
||||||
}
|
}
|
||||||
case "custommodeldata" -> {
|
case "custommodeldata" -> {
|
||||||
return getModelData(user.getCosmetic(slot));
|
return getModelData(user.getCosmetic(slot));
|
||||||
@@ -113,13 +118,29 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (placeholderArgs.get(1) != null) {
|
if (placeholderArgs.get(1) != null) {
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
String args1 = placeholderArgs.get(1);
|
||||||
if (cosmetic == null) {
|
|
||||||
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
|
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
||||||
if (secondAttemptCosmetic == null) {
|
if (user.getCosmetic(CosmeticSlot.valueOf(args1.toUpperCase())) != null) {
|
||||||
return "INVALID_COSMETIC";
|
return "true";
|
||||||
} else {
|
} else {
|
||||||
cosmetic = secondAttemptCosmetic;
|
return "false";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages(args1);
|
||||||
|
|
||||||
|
Cosmetic cosmetic = Cosmetics.getCosmetic(args1);
|
||||||
|
if (cosmetic == null) {
|
||||||
|
if (placeholderArgs.size() == 3) {
|
||||||
|
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
|
||||||
|
if (secondAttemptCosmetic == null) {
|
||||||
|
return "INVALID_COSMETIC";
|
||||||
|
} else {
|
||||||
|
cosmetic = secondAttemptCosmetic;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return "INVALID_COSMETIC";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (user.getCosmetic(cosmetic.getSlot()) == null) return "false";
|
if (user.getCosmetic(cosmetic.getSlot()) == null) return "false";
|
||||||
@@ -135,33 +156,76 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of the cosmetic item {@link org.bukkit.Material Material}
|
||||||
|
* @param cosmetic The cosmetic to get its {@link org.bukkit.Material Material}s name
|
||||||
|
* @return The name of the cosmetic item {@link org.bukkit.Material Material}
|
||||||
|
* @deprecated As of release 2.2.5+, use {@link #getMaterialName(Cosmetic)} instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Nullable
|
||||||
public String getMaterial(@NotNull Cosmetic cosmetic) {
|
public String getMaterial(@NotNull Cosmetic cosmetic) {
|
||||||
ItemStack item = cosmetic.getItem();
|
ItemStack item = cosmetic.getItem();
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
return cosmetic.getItem().getType().toString();
|
return item.getType().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of the cosmetic item {@link org.bukkit.Material Material}
|
||||||
|
* @param cosmetic The cosmetic to get its {@link org.bukkit.Material Material}s name
|
||||||
|
* @return The name of the cosmetic item {@link org.bukkit.Material Material}
|
||||||
|
* @since 2.2.5
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getMaterialName(@NotNull Cosmetic cosmetic) {
|
||||||
|
ItemStack item = cosmetic.getItem();
|
||||||
|
if (item == null) return null;
|
||||||
|
return item.getType().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cosmetic items custom model data
|
||||||
|
* @param cosmetic The cosmetic to get its custom model data
|
||||||
|
* @return The cosmetic items custom model data
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
public String getModelData(@NotNull Cosmetic cosmetic) {
|
public String getModelData(@NotNull Cosmetic cosmetic) {
|
||||||
ItemStack item = cosmetic.getItem();
|
ItemStack item = cosmetic.getItem();
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
if (!item.hasItemMeta()) return null;
|
if (!item.hasItemMeta()) return null;
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
if (itemMeta == null) return null;
|
||||||
return String.valueOf(itemMeta.getCustomModelData());
|
return String.valueOf(itemMeta.getCustomModelData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cosmetic items display name
|
||||||
|
* @param cosmetic The cosmetic to get its items display name
|
||||||
|
* @return The cosmetic items display name
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
public String getItemName(@NotNull Cosmetic cosmetic) {
|
public String getItemName(@NotNull Cosmetic cosmetic) {
|
||||||
ItemStack item = cosmetic.getItem();
|
ItemStack item = cosmetic.getItem();
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
if (!item.hasItemMeta()) return null;
|
if (!item.hasItemMeta()) return null;
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
if (itemMeta == null) return null;
|
||||||
return itemMeta.getDisplayName();
|
return itemMeta.getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cosmetic items lore
|
||||||
|
* @param cosmetic The cosmetic to get its items lore
|
||||||
|
* @return The cosmetic items lore
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
public String getItemLore(@NotNull Cosmetic cosmetic) {
|
public String getItemLore(@NotNull Cosmetic cosmetic) {
|
||||||
ItemStack item = cosmetic.getItem();
|
ItemStack item = cosmetic.getItem();
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
if (item.hasItemMeta()) {
|
if (item.hasItemMeta()) {
|
||||||
return String.valueOf(item.getItemMeta().getLore());
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
if (itemMeta == null) return null;
|
||||||
|
return String.valueOf(itemMeta.getLore());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,17 @@ package com.hibiscusmc.hmccosmetics.hooks.placeholders;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link me.clip.placeholderapi.PlaceholderAPI PlaceholderAPI}
|
||||||
|
*/
|
||||||
public class HookPlaceholderAPI extends Hook {
|
public class HookPlaceholderAPI extends Hook {
|
||||||
|
|
||||||
public HookPlaceholderAPI() {
|
public HookPlaceholderAPI() {
|
||||||
super("PlaceholderAPI");
|
super("PlaceholderAPI");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers HMCCosmetics Placeholder Expansion
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
new HMCPlaceholderExpansion().register();
|
new HMCPlaceholderExpansion().register();
|
||||||
|
|||||||
@@ -9,9 +9,18 @@ import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
|||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link com.sk89q.worldguard.WorldGuard WorldGuard}
|
||||||
|
*/
|
||||||
public class WGHook {
|
public class WGHook {
|
||||||
|
/**
|
||||||
|
* @implNote Please use {@link #getCosmeticEnableFlag()} instead
|
||||||
|
*/
|
||||||
public static StateFlag COSMETIC_ENABLE_FLAG;
|
public static StateFlag COSMETIC_ENABLE_FLAG;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implNote Please use {@link #getCosmeticWardrobeFlag()} instead
|
||||||
|
*/
|
||||||
public static StateFlag COSMETIC_WARDROBE_FLAG;
|
public static StateFlag COSMETIC_WARDROBE_FLAG;
|
||||||
|
|
||||||
public WGHook() {
|
public WGHook() {
|
||||||
@@ -35,10 +44,18 @@ public class WGHook {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cosmetic enable {@link StateFlag}
|
||||||
|
* @return The cosmetic enable {@link StateFlag}
|
||||||
|
*/
|
||||||
public static StateFlag getCosmeticEnableFlag() {
|
public static StateFlag getCosmeticEnableFlag() {
|
||||||
return COSMETIC_ENABLE_FLAG;
|
return COSMETIC_ENABLE_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cosmetic wardrobe {@link StateFlag}
|
||||||
|
* @return The cosmetic wardrobe {@link StateFlag}
|
||||||
|
*/
|
||||||
public static StateFlag getCosmeticWardrobeFlag() {
|
public static StateFlag getCosmeticWardrobeFlag() {
|
||||||
return COSMETIC_WARDROBE_FLAG;
|
return COSMETIC_WARDROBE_FLAG;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains {@link com.sk89q.worldguard.WorldGuard WorldGuard} related event listeners
|
||||||
|
*/
|
||||||
public class WGListener implements Listener {
|
public class WGListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
public void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
@@ -32,10 +34,12 @@ public class WGListener implements Listener {
|
|||||||
}
|
}
|
||||||
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||||
|
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) return;
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
||||||
|
if (!protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString().equalsIgnoreCase("ALLOW")) return;
|
||||||
user.enterWardrobe();
|
user.enterWardrobe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
|||||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@@ -57,10 +58,11 @@ public class PlayerConnectionListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (user.isInWardrobe()) user.leaveWardrobe();
|
if (user.isInWardrobe()) user.leaveWardrobe();
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
user.getUserEmoteManager().stopEmote();
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.CONNECTION);
|
||||||
event.getPlayer().setInvisible(false);
|
event.getPlayer().setInvisible(false);
|
||||||
}
|
}
|
||||||
Database.save(user);
|
Database.save(user);
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ import com.hibiscusmc.hmccosmetics.gui.Menu;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -32,7 +34,6 @@ import org.bukkit.entity.Pose;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.*;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
@@ -51,6 +52,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
registerMenuChangeListener();
|
registerMenuChangeListener();
|
||||||
registerPlayerEquipmentListener();
|
registerPlayerEquipmentListener();
|
||||||
registerPlayerArmListener();
|
registerPlayerArmListener();
|
||||||
|
registerEntityUseListener();
|
||||||
|
|
||||||
//registerLookMovement();
|
//registerLookMovement();
|
||||||
//registerMoveListener();
|
//registerMoveListener();
|
||||||
@@ -59,12 +61,20 @@ public class PlayerGameListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerClick(@NotNull InventoryClickEvent event) {
|
public void onPlayerClick(@NotNull InventoryClickEvent event) {
|
||||||
if (event.getClick() != ClickType.SHIFT_LEFT && event.getClick() != ClickType.SHIFT_RIGHT) return;
|
// || !event.getClickedInventory().getType().equals(InventoryType.PLAYER)
|
||||||
|
if (event.getClick().isShiftClick()) return;
|
||||||
|
MessagesUtil.sendDebugMessages("inventoryclickevent");
|
||||||
//if (event.getSlotType() != InventoryType.SlotType.ARMOR) return;
|
//if (event.getSlotType() != InventoryType.SlotType.ARMOR) return;
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getWhoClicked().getUniqueId());
|
CosmeticUser user = CosmeticUsers.getUser(event.getWhoClicked().getUniqueId());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
ItemStack item = event.getCurrentItem();
|
ItemStack item = event.getCurrentItem();
|
||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
|
|
||||||
|
if (Settings.isDestroyLooseCosmetics() && InventoryUtils.isCosmeticItem(event.getCurrentItem())) {
|
||||||
|
MessagesUtil.sendDebugMessages("remvoe item");
|
||||||
|
event.getWhoClicked().getInventory().removeItem(event.getCurrentItem());
|
||||||
|
}
|
||||||
|
|
||||||
EquipmentSlot slot = getArmorSlot(item.getType());
|
EquipmentSlot slot = getArmorSlot(item.getType());
|
||||||
if (slot == null) return;
|
if (slot == null) return;
|
||||||
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
|
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
|
||||||
@@ -82,7 +92,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
|
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (event.isSneaking()) {
|
if (event.isSneaking()) {
|
||||||
user.getUserEmoteManager().stopEmote();
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.SNEAK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event.isSneaking()) return;
|
if (!event.isSneaking()) return;
|
||||||
@@ -101,7 +111,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||||
user.getUserBackpackManager().hideBackpack();
|
user.getUserBackpackManager().hideBackpack();
|
||||||
|
|
||||||
user.getUserBackpackManager().getArmorStand().teleport(event.getTo());
|
user.getUserBackpackManager().getArmorStand().teleport(event.getTo());
|
||||||
@@ -120,6 +130,9 @@ public class PlayerGameListener implements Listener {
|
|||||||
user.spawnBalloon(cosmeticBalloonType);
|
user.spawnBalloon(cosmeticBalloonType);
|
||||||
}, 2);
|
}, 2);
|
||||||
}
|
}
|
||||||
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -152,6 +165,26 @@ public class PlayerGameListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerDamaged(EntityDamageEvent event) {
|
||||||
|
if (event.isCancelled()) return;
|
||||||
|
if (!(event.getEntity() instanceof Player)) return;
|
||||||
|
Player player = ((Player) event.getEntity()).getPlayer();
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
|
if (Settings.isEmoteInvincible()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (Settings.isEmoteDamageLeave()) {
|
||||||
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.DAMAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (user.isInWardrobe()) {
|
||||||
|
user.leaveWardrobe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerLook(PlayerMoveEvent event) {
|
public void onPlayerLook(PlayerMoveEvent event) {
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@@ -173,12 +206,22 @@ public class PlayerGameListener implements Listener {
|
|||||||
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
||||||
Pose pose = event.getPose();
|
Pose pose = event.getPose();
|
||||||
if (pose.equals(Pose.STANDING)) {
|
if (pose.equals(Pose.STANDING)) {
|
||||||
if (!user.isBackupSpawned()) {
|
// #84, Riptides mess with backpacks
|
||||||
|
ItemStack currentItem = player.getInventory().getItemInMainHand();
|
||||||
|
if (currentItem != null) {
|
||||||
|
if (currentItem.hasItemMeta()) {
|
||||||
|
if (currentItem.containsEnchantment(Enchantment.RIPTIDE)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!user.isBackpackSpawned()) {
|
||||||
user.spawnBackpack((CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK));
|
user.spawnBackpack((CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pose.equals(Pose.SLEEPING) || pose.equals(Pose.SWIMMING) || pose.equals(Pose.FALL_FLYING)) {
|
if (pose.equals(Pose.SLEEPING) || pose.equals(Pose.SWIMMING) || pose.equals(Pose.FALL_FLYING) || pose.equals(Pose.SPIN_ATTACK)) {
|
||||||
user.despawnBackpack();
|
user.despawnBackpack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,6 +313,14 @@ public class PlayerGameListener implements Listener {
|
|||||||
user.updateCosmetic(CosmeticSlot.MAINHAND);
|
user.updateCosmetic(CosmeticSlot.MAINHAND);
|
||||||
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
||||||
}, 2);
|
}, 2);
|
||||||
|
|
||||||
|
// #84, Riptides mess with backpacks
|
||||||
|
ItemStack currentItem = event.getPlayer().getInventory().getItem(event.getNewSlot());
|
||||||
|
if (currentItem == null) return;
|
||||||
|
if (!currentItem.hasItemMeta()) return;
|
||||||
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && currentItem.containsEnchantment(Enchantment.RIPTIDE)) {
|
||||||
|
user.despawnBackpack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -325,7 +376,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
|
|
||||||
HashMap<Integer, ItemStack> items = new HashMap<>();
|
HashMap<Integer, ItemStack> items = new HashMap<>();
|
||||||
|
|
||||||
for (Cosmetic cosmetic : user.getCosmetic()) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) {
|
if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) {
|
||||||
items.put(InventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType));
|
items.put(InventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType));
|
||||||
}
|
}
|
||||||
@@ -406,6 +457,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() {
|
private void registerLookMovement() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.LOOK) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.LOOK) {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class NMSHandlers {
|
public class NMSHandlers {
|
||||||
|
|
||||||
private static final String[] SUPPORTED_VERSION = new String[]{"v1_17_R1", "v1_18_R2", "v1_19_R1", "v1_19_R2"};
|
private static final String[] SUPPORTED_VERSION = new String[]{"v1_17_R1", "v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3"};
|
||||||
private static NMSHandler handler;
|
private static NMSHandler handler;
|
||||||
private static String version;
|
private static String version;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user;
|
package com.hibiscusmc.hmccosmetics.user;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableCollection;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.api.*;
|
import com.hibiscusmc.hmccosmetics.api.*;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
@@ -16,13 +18,11 @@ import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Color;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.*;
|
import org.bukkit.inventory.meta.*;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -77,10 +77,15 @@ public class CosmeticUser {
|
|||||||
return playerCosmetics.get(slot);
|
return playerCosmetics.get(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public Collection<Cosmetic> getCosmetic() {
|
public Collection<Cosmetic> getCosmetic() {
|
||||||
return playerCosmetics.values();
|
return playerCosmetics.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ImmutableCollection<Cosmetic> getCosmetics() {
|
||||||
|
return ImmutableList.copyOf(playerCosmetics.values());
|
||||||
|
}
|
||||||
|
|
||||||
public void addPlayerCosmetic(Cosmetic cosmetic) {
|
public void addPlayerCosmetic(Cosmetic cosmetic) {
|
||||||
addPlayerCosmetic(cosmetic, null);
|
addPlayerCosmetic(cosmetic, null);
|
||||||
}
|
}
|
||||||
@@ -151,6 +156,10 @@ public class CosmeticUser {
|
|||||||
return playerCosmetics.containsKey(slot);
|
return playerCosmetics.containsKey(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<CosmeticSlot> getSlotsWithCosmetics() {
|
||||||
|
return Set.copyOf(playerCosmetics.keySet());
|
||||||
|
}
|
||||||
|
|
||||||
public void updateCosmetic(CosmeticSlot slot) {
|
public void updateCosmetic(CosmeticSlot slot) {
|
||||||
if (getCosmetic(slot) == null) {
|
if (getCosmetic(slot) == null) {
|
||||||
return;
|
return;
|
||||||
@@ -201,6 +210,8 @@ public class CosmeticUser {
|
|||||||
mapMeta.setColor(color);
|
mapMeta.setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
itemMeta.getPersistentDataContainer().set(InventoryUtils.getKey(), PersistentDataType.STRING, "true");
|
||||||
|
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
@@ -287,7 +298,7 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
if (this.userBackpackManager != null) return;
|
if (this.userBackpackManager != null) return;
|
||||||
this.userBackpackManager = new UserBackpackManager(this);
|
this.userBackpackManager = new UserBackpackManager(this, cosmeticBackpackType.getBackpackType());
|
||||||
userBackpackManager.spawnBackpack(cosmeticBackpackType);
|
userBackpackManager.spawnBackpack(cosmeticBackpackType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +308,7 @@ public class CosmeticUser {
|
|||||||
userBackpackManager = null;
|
userBackpackManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBackupSpawned() {
|
public boolean isBackpackSpawned() {
|
||||||
if (this.userBackpackManager == null) return false;
|
if (this.userBackpackManager == null) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -311,8 +322,6 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(player);
|
List<Player> viewer = PlayerUtils.getNearbyPlayers(player);
|
||||||
viewer.add(player);
|
viewer.add(player);
|
||||||
|
|
||||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), player.getEntityId(), viewer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void despawnBalloon() {
|
public void despawnBalloon() {
|
||||||
@@ -354,7 +363,7 @@ public class CosmeticUser {
|
|||||||
public List<CosmeticSlot> getDyeableSlots() {
|
public List<CosmeticSlot> getDyeableSlots() {
|
||||||
ArrayList<CosmeticSlot> dyableSlots = new ArrayList();
|
ArrayList<CosmeticSlot> dyableSlots = new ArrayList();
|
||||||
|
|
||||||
for (Cosmetic cosmetic : getCosmetic()) {
|
for (Cosmetic cosmetic : getCosmetics()) {
|
||||||
if (cosmetic.isDyable()) dyableSlots.add(cosmetic.getSlot());
|
if (cosmetic.isDyable()) dyableSlots.add(cosmetic.getSlot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,11 +406,10 @@ public class CosmeticUser {
|
|||||||
hiddenReason = reason;
|
hiddenReason = reason;
|
||||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
getBalloonManager().removePlayerFromModel(getPlayer());
|
getBalloonManager().removePlayerFromModel(getPlayer());
|
||||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(getPlayer());
|
getBalloonManager().sendRemoveLeashPacket();
|
||||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), -1, viewer);
|
|
||||||
}
|
}
|
||||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
userBackpackManager.getArmorStand().getEquipment().clear();
|
userBackpackManager.clearItems();
|
||||||
}
|
}
|
||||||
updateCosmetic();
|
updateCosmetic();
|
||||||
MessagesUtil.sendDebugMessages("HideCosmetics");
|
MessagesUtil.sendDebugMessages("HideCosmetics");
|
||||||
@@ -427,7 +435,7 @@ public class CosmeticUser {
|
|||||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) getCosmetic(CosmeticSlot.BACKPACK);
|
CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) getCosmetic(CosmeticSlot.BACKPACK);
|
||||||
ItemStack item = getUserCosmeticItem(cosmeticBackpackType);
|
ItemStack item = getUserCosmeticItem(cosmeticBackpackType);
|
||||||
userBackpackManager.getArmorStand().getEquipment().setHelmet(item);
|
userBackpackManager.setItem(item);
|
||||||
}
|
}
|
||||||
updateCosmetic();
|
updateCosmetic();
|
||||||
MessagesUtil.sendDebugMessages("ShowCosmetics");
|
MessagesUtil.sendDebugMessages("ShowCosmetics");
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
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.entity.ArmorStand;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@@ -18,13 +21,14 @@ public class UserBackpackManager {
|
|||||||
|
|
||||||
private boolean hideBackpack;
|
private boolean hideBackpack;
|
||||||
private ArmorStand invisibleArmorStand;
|
private ArmorStand invisibleArmorStand;
|
||||||
|
private AreaEffectCloud particleCloud;
|
||||||
private final CosmeticUser user;
|
private final CosmeticUser user;
|
||||||
private BackpackType backpackType;
|
private BackpackType backpackType;
|
||||||
|
|
||||||
public UserBackpackManager(CosmeticUser user) {
|
public UserBackpackManager(CosmeticUser user, BackpackType backpackType) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
hideBackpack = false;
|
hideBackpack = false;
|
||||||
backpackType = BackpackType.NORMAL;
|
this.backpackType = backpackType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFirstArmorStandId() {
|
public int getFirstArmorStandId() {
|
||||||
@@ -38,6 +42,16 @@ public class UserBackpackManager {
|
|||||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Start");
|
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;
|
if (this.invisibleArmorStand != null) return;
|
||||||
|
|
||||||
this.invisibleArmorStand = (ArmorStand) NMSHandlers.getHandler().spawnBackpack(user, cosmeticBackpackType);
|
this.invisibleArmorStand = (ArmorStand) NMSHandlers.getHandler().spawnBackpack(user, cosmeticBackpackType);
|
||||||
@@ -56,11 +70,37 @@ public class UserBackpackManager {
|
|||||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Finish");
|
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() {
|
public void despawnBackpack() {
|
||||||
if (invisibleArmorStand == null) return;
|
if (invisibleArmorStand != null) {
|
||||||
invisibleArmorStand.setHealth(0);
|
invisibleArmorStand.setHealth(0);
|
||||||
invisibleArmorStand.remove();
|
invisibleArmorStand.remove();
|
||||||
this.invisibleArmorStand = null;
|
this.invisibleArmorStand = null;
|
||||||
|
}
|
||||||
|
if (particleCloud != null) {
|
||||||
|
particleCloud.remove();
|
||||||
|
this.particleCloud = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideBackpack() {
|
public void hideBackpack() {
|
||||||
@@ -81,6 +121,27 @@ public class UserBackpackManager {
|
|||||||
hideBackpack = shown;
|
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 {
|
public enum BackpackType {
|
||||||
NORMAL,
|
NORMAL,
|
||||||
FIRST_PERSON // First person not yet implemented
|
FIRST_PERSON // First person not yet implemented
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
|||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
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 com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||||
@@ -17,12 +19,14 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class UserBalloonManager {
|
public class UserBalloonManager {
|
||||||
|
|
||||||
private BalloonType balloonType;
|
private BalloonType balloonType;
|
||||||
|
private CosmeticBalloonType cosmeticBalloonType;
|
||||||
private final int balloonID;
|
private final int balloonID;
|
||||||
private final UUID uniqueID;
|
private final UUID uniqueID;
|
||||||
private final ArmorStand modelEntity;
|
private final ArmorStand modelEntity;
|
||||||
@@ -44,6 +48,7 @@ public class UserBalloonManager {
|
|||||||
balloonType = BalloonType.NONE;
|
balloonType = BalloonType.NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.cosmeticBalloonType = cosmeticBalloonType;
|
||||||
MessagesUtil.sendDebugMessages("balloontype is " + balloonType);
|
MessagesUtil.sendDebugMessages("balloontype is " + balloonType);
|
||||||
|
|
||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
@@ -85,6 +90,7 @@ public class UserBalloonManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
modelEntity.remove();
|
modelEntity.remove();
|
||||||
|
cosmeticBalloonType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
|
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
|
||||||
@@ -156,6 +162,19 @@ public class UserBalloonManager {
|
|||||||
this.getModelEntity().setVelocity(vector);
|
this.getModelEntity().setVelocity(vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendRemoveLeashPacket(List<Player> viewer) {
|
||||||
|
PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, viewer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendRemoveLeashPacket() {
|
||||||
|
PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendLeashPacket(int entityId) {
|
||||||
|
if (cosmeticBalloonType == null) return;
|
||||||
|
if (cosmeticBalloonType.isShowLead()) PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
public enum BalloonType {
|
public enum BalloonType {
|
||||||
MODELENGINE,
|
MODELENGINE,
|
||||||
ITEM,
|
ITEM,
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStartEvent;
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStopEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||||
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.bukkit.Bukkit;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class UserEmoteManager {
|
public class UserEmoteManager {
|
||||||
@@ -22,6 +25,13 @@ public class UserEmoteManager {
|
|||||||
public void playEmote(String animationId) {
|
public void playEmote(String animationId) {
|
||||||
if (isPlayingEmote()) return;
|
if (isPlayingEmote()) return;
|
||||||
if (user.isInWardrobe()) return;
|
if (user.isInWardrobe()) return;
|
||||||
|
// API
|
||||||
|
PlayerEmoteStartEvent event = new PlayerEmoteStartEvent(user, animationId);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Internal
|
||||||
try {
|
try {
|
||||||
model = new UserEmoteModel(user);
|
model = new UserEmoteModel(user);
|
||||||
model.playAnimation(animationId);
|
model.playAnimation(animationId);
|
||||||
@@ -35,8 +45,22 @@ public class UserEmoteManager {
|
|||||||
return model.isPlayingAnimation();
|
return model.isPlayingAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopEmote() {
|
public void stopEmote(StopEmoteReason emoteReason) {
|
||||||
if (!isPlayingEmote()) return;
|
if (!isPlayingEmote()) return;
|
||||||
|
// API
|
||||||
|
PlayerEmoteStopEvent event = new PlayerEmoteStopEvent(user, emoteReason);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Internal
|
||||||
model.stopAnimation();
|
model.stopAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum StopEmoteReason {
|
||||||
|
SNEAK,
|
||||||
|
DAMAGE,
|
||||||
|
CONNECTION,
|
||||||
|
TELEPORT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
double DISTANCE = Settings.getEmoteDistance();
|
double DISTANCE = Settings.getEmoteDistance();
|
||||||
|
|
||||||
Location thirdPersonLocation = newLocation.add(newLocation.getDirection().normalize().multiply(DISTANCE));
|
Location thirdPersonLocation = newLocation.add(newLocation.getDirection().normalize().multiply(DISTANCE));
|
||||||
if (thirdPersonLocation.getBlock().getType() != Material.AIR) {
|
if (Settings.getCosmeticEmoteBlockCheck() && thirdPersonLocation.getBlock().getType().isOccluding()) {
|
||||||
stopAnimation();
|
stopAnimation();
|
||||||
MessagesUtil.sendMessage(player, "emote-blocked");
|
MessagesUtil.sendMessage(player, "emote-blocked");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ public class UserWardrobeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), -1, viewer);
|
user.getBalloonManager().sendRemoveLeashPacket(viewer);
|
||||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), NPC_ID, viewer); // This needs a possible fix
|
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
||||||
|
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.clone().add(Settings.getBalloonOffset()), false, viewer);
|
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.clone().add(Settings.getBalloonOffset()), false, viewer);
|
||||||
@@ -156,25 +156,32 @@ public class UserWardrobeManager {
|
|||||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
||||||
outsideViewers.remove(player);
|
outsideViewers.remove(player);
|
||||||
|
|
||||||
MessagesUtil.sendMessage(player, "closed-wardrobe");
|
if (player != null) MessagesUtil.sendMessage(player, "closed-wardrobe");
|
||||||
|
|
||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
this.active = false;
|
this.active = false;
|
||||||
|
|
||||||
// NPC
|
// NPC
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) PacketManager.sendLeashPacket(user.getBalloonManager().getModelId(), -1, viewer);
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) user.getBalloonManager().sendRemoveLeashPacket();
|
||||||
PacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
|
PacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
|
||||||
PacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success
|
PacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success
|
||||||
|
|
||||||
// Player
|
// Player
|
||||||
PacketManager.sendCameraPacket(player.getEntityId(), viewer);
|
PacketManager.sendCameraPacket(player.getEntityId(), viewer);
|
||||||
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success
|
|
||||||
|
|
||||||
// Armorstand
|
// Armorstand
|
||||||
PacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess
|
PacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess
|
||||||
|
|
||||||
//PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success
|
//PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success
|
||||||
player.setGameMode(this.originalGamemode);
|
if (WardrobeSettings.isForceExitGamemode()) {
|
||||||
|
MessagesUtil.sendDebugMessages("Force Exit Gamemode " + WardrobeSettings.getExitGamemode());
|
||||||
|
player.setGameMode(WardrobeSettings.getExitGamemode());
|
||||||
|
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(WardrobeSettings.getExitGamemode())); // Success
|
||||||
|
} else {
|
||||||
|
MessagesUtil.sendDebugMessages("Original Gamemode " + this.originalGamemode);
|
||||||
|
player.setGameMode(this.originalGamemode);
|
||||||
|
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success
|
||||||
|
}
|
||||||
user.showPlayer();
|
user.showPlayer();
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
@@ -200,7 +207,7 @@ public class UserWardrobeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For Wardrobe Temp Cosmetics
|
// For Wardrobe Temp Cosmetics
|
||||||
for (Cosmetic cosmetic : user.getCosmetic()) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
if (cosmetic.requiresPermission()) {
|
if (cosmetic.requiresPermission()) {
|
||||||
if (!player.hasPermission(cosmetic.getPermission())) user.removeCosmeticSlot(cosmetic.getSlot());
|
if (!player.hasPermission(cosmetic.getPermission())) user.removeCosmeticSlot(cosmetic.getSlot());
|
||||||
}
|
}
|
||||||
@@ -254,9 +261,9 @@ public class UserWardrobeManager {
|
|||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer);
|
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer);
|
||||||
user.getBalloonManager().getModelEntity().teleport(WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()));
|
user.getBalloonManager().getModelEntity().teleport(WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()));
|
||||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), -1, outsideViewers);
|
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
||||||
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
||||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), NPC_ID, viewer); // Pufferfish goes away for some reason?
|
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WardrobeSettings.isEquipPumpkin()) {
|
if (WardrobeSettings.isEquipPumpkin()) {
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util;
|
package com.hibiscusmc.hmccosmetics.util;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -137,4 +141,14 @@ public class InventoryUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isCosmeticItem(ItemStack itemStack) {
|
||||||
|
itemStack = itemStack.clone();
|
||||||
|
if (!itemStack.hasItemMeta()) return false;
|
||||||
|
return itemStack.getItemMeta().getPersistentDataContainer().has(getKey(), PersistentDataType.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NamespacedKey getKey() {
|
||||||
|
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetic");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class BasePacket {
|
public class BasePacket {
|
||||||
|
|
||||||
public static void sendPacket(Player player, PacketContainer packet) {
|
public static void sendPacket(Player player, PacketContainer packet) {
|
||||||
|
if (player == null) return;
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,8 @@ public class PacketManager extends BasePacket {
|
|||||||
packet.getModifier().writeDefaults();
|
packet.getModifier().writeDefaults();
|
||||||
packet.getIntegers().write(0, entityId);
|
packet.getIntegers().write(0, entityId);
|
||||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||||
if (!NMSHandlers.getVersion().contains("v1_19_R2")) {
|
|
||||||
|
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
||||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||||
} else {
|
} else {
|
||||||
@@ -305,19 +306,17 @@ public class PacketManager extends BasePacket {
|
|||||||
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
|
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
|
||||||
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
|
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
|
||||||
if (skinData != null) wrappedGameProfile.getProperties().put("textures", skinData);
|
if (skinData != null) wrappedGameProfile.getProperties().put("textures", skinData);
|
||||||
if (!NMSHandlers.getVersion().contains("v1_19_R2")) {
|
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1") || NMSHandlers.getVersion().contains("v1_19_R3")) {
|
||||||
info.setData(List.of(new PlayerInfoData(wrappedGameProfile, 0, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(name))));
|
|
||||||
} else {
|
|
||||||
info.getHandle().getPlayerInfoDataLists().write(1, Collections.singletonList(new PlayerInfoData(
|
info.getHandle().getPlayerInfoDataLists().write(1, Collections.singletonList(new PlayerInfoData(
|
||||||
wrappedGameProfile,
|
wrappedGameProfile,
|
||||||
0,
|
0,
|
||||||
EnumWrappers.NativeGameMode.CREATIVE,
|
EnumWrappers.NativeGameMode.CREATIVE,
|
||||||
WrappedChatComponent.fromText(name)
|
WrappedChatComponent.fromText(name)
|
||||||
)));
|
)));
|
||||||
|
} else {
|
||||||
|
info.setData(List.of(new PlayerInfoData(wrappedGameProfile, 0, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(name))));
|
||||||
}
|
}
|
||||||
for (final Player p : sendTo) sendPacket(p, info.getHandle());
|
for (final Player p : sendTo) sendPacket(p, info.getHandle());
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -364,7 +363,7 @@ public class PacketManager extends BasePacket {
|
|||||||
final UUID uuid,
|
final UUID uuid,
|
||||||
final List<Player> sendTo
|
final List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
if (!NMSHandlers.getVersion().contains("v1_19_R2")) {
|
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||||
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
|
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
|
||||||
info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
||||||
|
|
||||||
@@ -377,6 +376,7 @@ public class PacketManager extends BasePacket {
|
|||||||
for (final Player p : sendTo) sendPacket(p, info.getHandle());
|
for (final Player p : sendTo) sendPacket(p, info.getHandle());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE);
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE);
|
||||||
packet.getUUIDLists().write(0, List.of(uuid));
|
packet.getUUIDLists().write(0, List.of(uuid));
|
||||||
for (final Player p : sendTo) sendPacket(p, packet);
|
for (final Player p : sendTo) sendPacket(p, packet);
|
||||||
|
|||||||
@@ -26,11 +26,12 @@ public class WrapperPlayServerPlayerInfo extends AbstractPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAction(PlayerInfoAction value) {
|
public void setAction(PlayerInfoAction value) {
|
||||||
if (!NMSHandlers.getVersion().contains("v1_19_R2")) {
|
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||||
handle.getPlayerInfoAction().write(0, value);
|
handle.getPlayerInfoAction().write(0, value);
|
||||||
} else {
|
return;
|
||||||
handle.getPlayerInfoActions().write(0, Set.of(value));
|
|
||||||
}
|
}
|
||||||
|
// New way of handling it 1.19.3+
|
||||||
|
handle.getPlayerInfoActions().write(0, Set.of(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PlayerInfoData> getData() {
|
public List<PlayerInfoData> getData() {
|
||||||
|
|||||||
@@ -24,6 +24,18 @@ cosmetic-settings:
|
|||||||
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
|
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-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 where the camera is placed (prevents players viewing through blocks)
|
||||||
|
emote-damage-leave: true # If the player should leave the emote when they take damage
|
||||||
|
emote-invincible: false # If the player should not take damage while doing an emote
|
||||||
|
|
||||||
|
helmet-add-enchantments: false # If the plugin should keep enchants on helmets. This is useful as some enchantments are client side only.
|
||||||
|
chest-add-enchantments: false # If the plugin should keep enchants on chestplate. This is useful as some enchantments are client side only.
|
||||||
|
leggings-add-enchantments: false # If the plugin should keep enchants on leggings. This is useful as some enchantments are client side only.
|
||||||
|
boots-add-enchantments: false # If the plugin should keep enchants on boots. This is useful as some enchantments are client side only.
|
||||||
|
|
||||||
|
# This attempts to destroy cosmetics that get loose in the wild, such as through a player entering creative mode.
|
||||||
|
# Most servers who don't use creative mode and have properly set up the plugin should have no need for this and can leave it disabled.
|
||||||
|
destroy-loose-cosmetics: false
|
||||||
|
|
||||||
# view distance in blocks that other players will see the backpack cosmetic
|
# 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
|
# setting this to lower than the server player view distance should fix the
|
||||||
@@ -40,6 +52,15 @@ dye-menu:
|
|||||||
title: "§f"
|
title: "§f"
|
||||||
input-slot: 19
|
input-slot: 19
|
||||||
output-slot: 25
|
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
|
||||||
|
worldguard:
|
||||||
|
# Checks worldguard regions for HMCC flags. If set to false, flags will not work properly.
|
||||||
|
# Requires restart to apply changes.
|
||||||
|
player-move-check: true
|
||||||
wardrobe:
|
wardrobe:
|
||||||
# spawn static wardrobe if in this radius of wardrobe-location
|
# spawn static wardrobe if in this radius of wardrobe-location
|
||||||
static-radius: 10
|
static-radius: 10
|
||||||
@@ -49,6 +70,11 @@ wardrobe:
|
|||||||
equip-pumpkin: false
|
equip-pumpkin: false
|
||||||
# Rather than having a set exit location, this will send the player back to where they entered the wardrobe. Not recommended for WG regions
|
# Rather than having a set exit location, this will send the player back to where they entered the wardrobe. Not recommended for WG regions
|
||||||
return-last-location: false
|
return-last-location: false
|
||||||
|
|
||||||
|
gamemode-options:
|
||||||
|
exit-gamemode-enabled: false # Setting this to false will set the gamemode the player came in as. True sets to exit-gamemode gamemode
|
||||||
|
exit-gamemode: "SURVIVAL" # Only activates if force-exit-gamemode is true, find gamemodes here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/GameMode.html
|
||||||
|
|
||||||
# Bossbar that shows when a player is in a wardrobe.
|
# Bossbar that shows when a player is in a wardrobe.
|
||||||
bossbar:
|
bossbar:
|
||||||
enabled: false
|
enabled: false
|
||||||
@@ -58,6 +84,8 @@ wardrobe:
|
|||||||
color: BLUE
|
color: BLUE
|
||||||
transition:
|
transition:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
# If you use ItemsAdder, set this to "<black>%img_title%
|
||||||
|
# If you use Oraxen, set this to "<black><glyph:title>"
|
||||||
text: "<black>"
|
text: "<black>"
|
||||||
delay: 40
|
delay: 40
|
||||||
title-fade-in: 1000 # milliseconds
|
title-fade-in: 1000 # milliseconds
|
||||||
|
|||||||
@@ -110,4 +110,23 @@ explorer_backpack:
|
|||||||
material: LEATHER_HORSE_ARMOR
|
material: LEATHER_HORSE_ARMOR
|
||||||
model-data: 3
|
model-data: 3
|
||||||
name: "<white>Explorer's Backpack"
|
name: "<white>Explorer's Backpack"
|
||||||
|
amount: 1
|
||||||
|
garbage_truck_balloon:
|
||||||
|
slot: BALLOON
|
||||||
|
permission: "hmccosmetics.garbage_truck_balloon"
|
||||||
|
model: garbage_truck_balloon
|
||||||
|
item:
|
||||||
|
material: PAPER
|
||||||
|
model-data: 14
|
||||||
|
name: "<green>Garbage Truck Balloon"
|
||||||
|
amount: 1
|
||||||
|
earth_day_grabber:
|
||||||
|
slot: OFFHAND
|
||||||
|
dyeable: true
|
||||||
|
permission: "hmccosmetics.earth_day_grabber"
|
||||||
|
model: earth_day_grabber
|
||||||
|
item:
|
||||||
|
material: LEATHER_HORSE_ARMOR
|
||||||
|
model-data: 4
|
||||||
|
name: "<green>Earth Day Grabber"
|
||||||
amount: 1
|
amount: 1
|
||||||
@@ -167,4 +167,26 @@ items:
|
|||||||
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_explorer_backpack%"
|
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_explorer_backpack%"
|
||||||
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_explorer_backpack%"
|
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_explorer_backpack%"
|
||||||
type: cosmetic
|
type: cosmetic
|
||||||
cosmetic: explorer_backpack
|
cosmetic: explorer_backpack
|
||||||
|
garbage_truck_balloon:
|
||||||
|
slots:
|
||||||
|
- 16
|
||||||
|
item:
|
||||||
|
material: hmccosmetics:garbage_truck_balloon
|
||||||
|
lore:
|
||||||
|
- ""
|
||||||
|
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_garbage_truck_balloon%"
|
||||||
|
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_garbage_truck_balloon%"
|
||||||
|
type: cosmetic
|
||||||
|
cosmetic: garbage_truck_balloon
|
||||||
|
earth_day_grabber:
|
||||||
|
slots:
|
||||||
|
- 17
|
||||||
|
item:
|
||||||
|
material: hmccosmetics:earth_day_grabber
|
||||||
|
lore:
|
||||||
|
- ""
|
||||||
|
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_earth_day_grabber%"
|
||||||
|
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_earth_day_grabber%"
|
||||||
|
type: cosmetic
|
||||||
|
cosmetic: earth_day_grabber
|
||||||
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.
@@ -11,5 +11,6 @@ include(
|
|||||||
"v1_17_R1",
|
"v1_17_R1",
|
||||||
"v1_18_R2",
|
"v1_18_R2",
|
||||||
"v1_19_R1",
|
"v1_19_R1",
|
||||||
"v1_19_R2"
|
"v1_19_R2",
|
||||||
|
"v1_19_R3",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|||||||
27
v1_19_R3/build.gradle.kts
Normal file
27
v1_19_R3/build.gradle.kts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
plugins {
|
||||||
|
id("java")
|
||||||
|
id("io.papermc.paperweight.userdev") version "1.5.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
paperDevBundle("1.19.4-R0.1-SNAPSHOT")
|
||||||
|
implementation(project(":common"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
|
||||||
|
build {
|
||||||
|
dependsOn(reobfJar)
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
options.release.set(17)
|
||||||
|
}
|
||||||
|
javadoc {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
}
|
||||||
|
processResources {
|
||||||
|
filteringCharset = Charsets.UTF_8.name()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
||||||
|
|
||||||
|
public class HMCArmorStand extends ArmorStand {
|
||||||
|
|
||||||
|
public HMCArmorStand(Level world, double x, double y, double z) {
|
||||||
|
super(world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HMCArmorStand(Location loc) {
|
||||||
|
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
setInvisible(true);
|
||||||
|
setInvulnerable(true);
|
||||||
|
setMarker(true);
|
||||||
|
setSilent(true);
|
||||||
|
getBukkitLivingEntity().setCollidable(false);
|
||||||
|
persist = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
|
||||||
|
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.AreaEffectCloud;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
||||||
|
|
||||||
|
public class HMCParticleCloud extends AreaEffectCloud {
|
||||||
|
|
||||||
|
public HMCParticleCloud(Level world, double x, double y, double z) {
|
||||||
|
super(world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HMCParticleCloud(Location loc) {
|
||||||
|
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
setInvisible(true);
|
||||||
|
setInvulnerable(true);
|
||||||
|
setSilent(true);
|
||||||
|
setNoGravity(true);
|
||||||
|
persist = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
|
public class MEGEntity extends ArmorStand {
|
||||||
|
public MEGEntity(Location loc) {
|
||||||
|
super(EntityType.ARMOR_STAND, ((CraftWorld) loc.getWorld()).getHandle());
|
||||||
|
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages("Spawned MEGEntity at " + loc);
|
||||||
|
setInvisible(true);
|
||||||
|
setNoGravity(true);
|
||||||
|
setSilent(true);
|
||||||
|
setInvulnerable(true);
|
||||||
|
setSmall(true);
|
||||||
|
setMarker(true);
|
||||||
|
|
||||||
|
persist = false;
|
||||||
|
getBukkitEntity().getPersistentDataContainer().set(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT, Short.valueOf("1"));
|
||||||
|
|
||||||
|
((CraftWorld) loc.getWorld()).getHandle().addFreshEntity(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,250 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
import net.minecraft.network.protocol.Packet;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
import net.minecraft.world.scores.PlayerTeam;
|
||||||
|
import net.minecraft.world.scores.Team;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_19_R3.CraftEquipmentSlot;
|
||||||
|
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
|
||||||
|
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.craftbukkit.v1_19_R3.scoreboard.CraftScoreboard;
|
||||||
|
import org.bukkit.entity.ArmorStand;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||||
|
@Override
|
||||||
|
public int getNextEntityId() {
|
||||||
|
return Entity.nextEntityId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity getEntity(int entityId) {
|
||||||
|
net.minecraft.world.entity.Entity entity = getNMSEntity(entityId);
|
||||||
|
if (entity == null) return null;
|
||||||
|
return entity.getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
||||||
|
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
||||||
|
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
||||||
|
if (entity == null) return null;
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity getHMCArmorStand(Location loc) {
|
||||||
|
HMCArmorStand hmcArmorStand = new HMCArmorStand(loc);
|
||||||
|
return hmcArmorStand.getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity spawnHMCParticleCloud(Location location) {
|
||||||
|
HMCParticleCloud hmcParticleCloud = new HMCParticleCloud(location);
|
||||||
|
return hmcParticleCloud.getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
||||||
|
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getPlayer().getLocation());
|
||||||
|
|
||||||
|
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
||||||
|
|
||||||
|
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
||||||
|
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
||||||
|
|
||||||
|
return invisibleArmorstand.getBukkitLivingEntity();
|
||||||
|
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
|
||||||
|
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||||
|
Player player = user.getPlayer();
|
||||||
|
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
|
||||||
|
|
||||||
|
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
|
||||||
|
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
|
||||||
|
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
|
||||||
|
|
||||||
|
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
|
||||||
|
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||||
|
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||||
|
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||||
|
|
||||||
|
return userBalloonManager1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void equipmentSlotUpdate(
|
||||||
|
int entityId,
|
||||||
|
CosmeticUser user,
|
||||||
|
CosmeticSlot cosmeticSlot,
|
||||||
|
List<Player> sendTo
|
||||||
|
) {
|
||||||
|
|
||||||
|
EquipmentSlot nmsSlot = null;
|
||||||
|
net.minecraft.world.item.ItemStack nmsItem = null;
|
||||||
|
|
||||||
|
if (!(user.getCosmetic(cosmeticSlot) instanceof CosmeticArmorType)) {
|
||||||
|
|
||||||
|
if (user.getCosmetic(cosmeticSlot) instanceof CosmeticMainhandType) {
|
||||||
|
CosmeticMainhandType cosmeticMainhandType = (CosmeticMainhandType) user.getCosmetic(CosmeticSlot.MAINHAND);
|
||||||
|
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticMainhandType));
|
||||||
|
} else {
|
||||||
|
nmsItem = CraftItemStack.asNMSCopy(user.getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmeticSlot)));
|
||||||
|
}
|
||||||
|
|
||||||
|
nmsSlot = CraftEquipmentSlot.getNMS(InventoryUtils.getEquipmentSlot(cosmeticSlot));
|
||||||
|
|
||||||
|
if (nmsSlot == null) return;
|
||||||
|
|
||||||
|
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
||||||
|
|
||||||
|
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
||||||
|
|
||||||
|
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
||||||
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(cosmeticSlot);
|
||||||
|
|
||||||
|
// Converting EquipmentSlot and ItemStack to NMS ones.
|
||||||
|
nmsSlot = CraftEquipmentSlot.getNMS(cosmeticArmor.getEquipSlot());
|
||||||
|
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticArmor));
|
||||||
|
|
||||||
|
if (nmsSlot == null) return;
|
||||||
|
|
||||||
|
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
||||||
|
|
||||||
|
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
||||||
|
|
||||||
|
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
||||||
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void equipmentSlotUpdate(
|
||||||
|
int entityId,
|
||||||
|
org.bukkit.inventory.EquipmentSlot slot,
|
||||||
|
ItemStack item,
|
||||||
|
List<Player> sendTo
|
||||||
|
) {
|
||||||
|
|
||||||
|
EquipmentSlot nmsSlot = null;
|
||||||
|
net.minecraft.world.item.ItemStack nmsItem = null;
|
||||||
|
|
||||||
|
// Converting EquipmentSlot and ItemStack to NMS ones.
|
||||||
|
nmsSlot = CraftEquipmentSlot.getNMS(slot);
|
||||||
|
nmsItem = CraftItemStack.asNMSCopy(item);
|
||||||
|
|
||||||
|
if (nmsSlot == null) return;
|
||||||
|
|
||||||
|
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
||||||
|
|
||||||
|
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
||||||
|
|
||||||
|
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
||||||
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void slotUpdate(
|
||||||
|
Player player,
|
||||||
|
int slot
|
||||||
|
) {
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
ServerPlayer player1 = ((CraftPlayer) player).getHandle();
|
||||||
|
|
||||||
|
if (index < Inventory.getSelectionSize()) {
|
||||||
|
index += 36;
|
||||||
|
} else if (index > 39) {
|
||||||
|
index += 5; // Off hand
|
||||||
|
} else if (index > 35) {
|
||||||
|
index = 8 - (index - 36);
|
||||||
|
}
|
||||||
|
ItemStack item = player.getInventory().getItem(slot);
|
||||||
|
|
||||||
|
Packet packet = new ClientboundContainerSetSlotPacket(player1.inventoryMenu.containerId, player1.inventoryMenu.incrementStateId(), index, CraftItemStack.asNMSCopy(item));
|
||||||
|
sendPacket(player, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideNPCName(Player player, String NPCName) {
|
||||||
|
//Creating the team
|
||||||
|
PlayerTeam team = new PlayerTeam(((CraftScoreboard) Bukkit.getScoreboardManager().getMainScoreboard()).getHandle(), NPCName);
|
||||||
|
|
||||||
|
//Setting name visibility
|
||||||
|
team.setNameTagVisibility(Team.Visibility.NEVER);
|
||||||
|
|
||||||
|
//Remove the Team (i assume so if it exists)
|
||||||
|
ClientboundSetPlayerTeamPacket removeTeamPacket = ClientboundSetPlayerTeamPacket.createRemovePacket(team);
|
||||||
|
sendPacket(player, removeTeamPacket);
|
||||||
|
//Creating the Team
|
||||||
|
ClientboundSetPlayerTeamPacket createTeamPacket = ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true);
|
||||||
|
sendPacket(player, createTeamPacket);
|
||||||
|
//Adding players to the team (You have to use the NPC's name, and add it to a list)
|
||||||
|
ClientboundSetPlayerTeamPacket createPlayerTeamPacket = ClientboundSetPlayerTeamPacket.createMultiplePlayerPacket(team, new ArrayList<String>() {{
|
||||||
|
add(NPCName);
|
||||||
|
}}, ClientboundSetPlayerTeamPacket.Action.ADD);
|
||||||
|
sendPacket(player, createPlayerTeamPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendPacket(Player player, Packet packet) {
|
||||||
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getSupported() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user