9
0
mirror of https://github.com/HibiscusMC/HibiscusCommons.git synced 2025-12-19 15:09:26 +00:00

Merge remote-tracking branch 'origin/master'

This commit is contained in:
LoJoSho
2025-01-19 16:03:07 -06:00
6 changed files with 22 additions and 28 deletions

View File

@@ -11,7 +11,7 @@ plugins {
}
group = "me.lojosho"
version = "0.6.0${getGitCommitHash()}"
version = "0.6.1${getGitCommitHash()}"
allprojects {
apply(plugin = "java")

View File

@@ -20,13 +20,6 @@ public final class HibiscusCommonsPlugin extends HibiscusPlugin {
public void onStart() {
instance = this;
try {
NMSHandlers.setup();
} catch (RuntimeException e) {
getServer().getPluginManager().disablePlugin(this);
return;
}
// Detects if a user is running a paper server
if (ServerUtils.hasClass("com.destroystokyo.paper.PaperConfig") || ServerUtils.hasClass("io.papermc.paper.configuration.Configuration")) {
onPaper = true;
@@ -38,6 +31,13 @@ public final class HibiscusCommonsPlugin extends HibiscusPlugin {
getLogger().warning("Download Paper at: https://papermc.io/");
}
try {
NMSHandlers.setup();
} catch (RuntimeException e) {
getServer().getPluginManager().disablePlugin(this);
return;
}
// Plugin startup logic
Hooks.setup();

View File

@@ -63,12 +63,13 @@ public abstract class HibiscusPlugin extends JavaPlugin {
.onSuccess((commandSenders, latestVersion) -> {
this.latestVersion = (String) latestVersion;
String pluginName = getDescription().getName();
String version = getDescription().getVersion();
if (!this.latestVersion.equalsIgnoreCase(getDescription().getVersion())) {
if (!this.latestVersion.equalsIgnoreCase(version)) {
getLogger().info("+++++++++++++++++++++++++++++++++++");
getLogger().info("There is a new update for " + pluginName + "!");
getLogger().info("Please download it as soon as possible for possible fixes and new features.");
getLogger().info("Current Version " + getDescription().getVersion() + " | Latest Version " + latestVersion);
getLogger().info("Current Version " + version + " | Latest Version " + latestVersion);
//getLogger().info("Spigot: https://www.spigotmc.org/resources/100107/");
getLogger().info("Polymart: https://polymart.org/resource/" + resourceID);
getLogger().info("+++++++++++++++++++++++++++++++++++");

View File

@@ -81,11 +81,8 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
if (itemMeta == null) return item;
if (!nameNode.virtual()) {
if (HibiscusCommonsPlugin.isOnPaper()) {
itemMeta.displayName(AdventureUtils.MINI_MESSAGE.deserialize(nameNode.getString("")));
} else {
itemMeta.setDisplayName(StringUtils.parseStringToString(nameNode.getString("")));
}
if (HibiscusCommonsPlugin.isOnPaper()) itemMeta.displayName(AdventureUtils.MINI_MESSAGE.deserialize(nameNode.getString("")));
else itemMeta.setDisplayName(StringUtils.parseStringToString(nameNode.getString("")));
}
if (!unbreakableNode.virtual()) itemMeta.setUnbreakable(unbreakableNode.getBoolean());
if (!glowingNode.virtual()) {
@@ -93,13 +90,12 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
itemMeta.addEnchant(Enchantment.LUCK, 1, true);
}
if (!loreNode.virtual()) {
if (HibiscusCommonsPlugin.isOnPaper()) {
if (HibiscusCommonsPlugin.isOnPaper())
itemMeta.lore(loreNode.getList(String.class, new ArrayList<>()).
stream().map(AdventureUtils.MINI_MESSAGE::deserialize).collect(Collectors.toList()));
} else {
itemMeta.setLore(loreNode.getList(String.class, new ArrayList<>()).
else itemMeta.setLore(loreNode.getList(String.class, new ArrayList<>()).
stream().map(StringUtils::parseStringToString).collect(Collectors.toList()));
}
}
if (!modelDataNode.virtual()) itemMeta.setCustomModelData(modelDataNode.getInt());
@@ -113,13 +109,13 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
for (ConfigurationNode enchantNode : enchantsNode.childrenMap().values()) {
String enchantName = enchantNode.key().toString().toLowerCase();
NamespacedKey key = NamespacedKey.minecraft(enchantName);
Enchantment enchant = Enchantment.getByKey(key);
Enchantment enchant = Registry.ENCHANTMENT.get(key);
if (enchant == null) continue;
itemMeta.addEnchant(enchant, enchantNode.getInt(1), true);
}
}
try {
if (!itemFlagsNode.virtual()) {
for (String itemFlag : itemFlagsNode.getList(String.class)) {
if (!EnumUtils.isValidEnum(ItemFlag.class, itemFlag)) continue;
@@ -127,9 +123,6 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
itemMeta.addItemFlags(ItemFlag.valueOf(itemFlag));
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (item.getType() == Material.PLAYER_HEAD) {
SkullMeta skullMeta = (SkullMeta) itemMeta;
@@ -150,7 +143,7 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
skullMeta.getPersistentDataContainer().set(InventoryUtils.getSkullTexture(), PersistentDataType.STRING, textureString);
}
// Decodes the texture string and sets the texture url to the skull
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.randomUUID());
PlayerProfile profile = Bukkit.createProfile(UUID.randomUUID());
PlayerTextures textures = profile.getTextures();
String decoded = new String(Base64.getDecoder().decode(textureString));
@@ -166,7 +159,6 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
skullMeta.setOwnerProfile(profile);
}
}
itemMeta = skullMeta;
}
if (!colorNode.virtual()) {
@@ -186,6 +178,5 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
public void serialize(final Type type, @Nullable final ItemStack obj, final ConfigurationNode node) throws SerializationException {
}
}

View File

@@ -2,6 +2,7 @@ package me.lojosho.hibiscuscommons.util;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
import org.bukkit.Color;
import org.bukkit.entity.Entity;
@@ -104,6 +105,7 @@ public class ServerUtils {
*/
@NotNull
public static List<Player> getViewers(@NotNull Entity entity) {
if (HibiscusCommonsPlugin.isOnPaper()) return List.copyOf(entity.getTrackedBy());
ArrayList<Player> viewers = new ArrayList<>();
for (Player player : entity.getLocation().getWorld().getPlayers()) {
if (player.canSee(entity)) viewers.add(player);

View File

@@ -1 +1 @@
userdevVersion=2.0.0-beta.11
userdevVersion=2.0.0-beta.14