Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/remapped' into remapped
Browse files Browse the repository at this point in the history
  • Loading branch information
LoJoSho committed Nov 15, 2023
2 parents d28bb23 + 502cb53 commit f98614c
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 28 deletions.
7 changes: 2 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ allprojects {
// PlaceholderAPI
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")

//Hikari
maven("https://mvnrepository.com/artifact/com.zaxxer/HikariCP")

// Citizens & Denizen
maven("https://maven.citizensnpcs.co/repo")

Expand Down Expand Up @@ -78,7 +75,7 @@ allprojects {
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.2")
compileOnly("com.github.oraxen:oraxen:1.160.0")
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
compileOnly("com.mineinabyss:geary-papermc:0.24.1")
compileOnly("com.mineinabyss:geary-papermc:0.27.0")
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
compileOnly("it.unimi.dsi:fastutil:8.5.11")
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
Expand Down Expand Up @@ -109,7 +106,7 @@ dependencies {
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
implementation("com.github.BG-Software-LLC:CommentedConfiguration:bed3c46369")
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
}

Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies {
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
implementation("com.github.BG-Software-LLC:CommentedConfiguration:bed3c46369")
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import lombok.Getter;
import org.bukkit.GameMode;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.util.Vector;
import org.spongepowered.configurate.ConfigurationNode;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;

public class Settings {
Expand All @@ -26,6 +29,8 @@ public class Settings {
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
private static final String DISABLED_GAMEMODE_PATH = "disabled-gamemode";
private static final String DISABLED_GAMEMODE_GAMEMODES_PATH = "gamemodes";
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";
Expand Down Expand Up @@ -110,6 +115,10 @@ public class Settings {
@Getter
private static boolean emotesEnabled;
@Getter
private static boolean disabledGamemodesEnabled;
@Getter
private static List<String> disabledGamemodes;
@Getter
private static int viewDistance;
@Getter
private static int tickPeriod;
Expand Down Expand Up @@ -164,6 +173,14 @@ public static void load(ConfigurationNode source) {

ConfigurationNode cosmeticSettings = source.node(COSMETIC_SETTINGS_PATH);

ConfigurationNode disabledGamemodeSettings = cosmeticSettings.node(DISABLED_GAMEMODE_PATH);
disabledGamemodesEnabled = disabledGamemodeSettings.node(ENABLED_PATH).getBoolean(true);
try {
disabledGamemodes = disabledGamemodeSettings.node(DISABLED_GAMEMODE_GAMEMODES_PATH).getList(String.class);
} catch (Exception e) {
disabledGamemodes = new ArrayList<>();
}

unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode;
Expand Down Expand Up @@ -186,6 +187,12 @@ private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta)
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
}
}

if (itemMeta instanceof SkullMeta skullMeta) {
if (skullMeta.hasOwner()) {
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
}
}
itemMeta.setLore(processedLore);
return itemMeta;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
Expand Down Expand Up @@ -72,6 +73,13 @@ public ItemStack setItem(CosmeticUser user, ConfigurationNode config, @NotNull I
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
}
}

if (itemMeta instanceof SkullMeta skullMeta) {
if (skullMeta.hasOwner()) {
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
}
}

itemMeta.setLore(processedLore);
itemStack.setItemMeta(itemMeta);
return itemStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
package com.hibiscusmc.hmccosmetics.hooks.items;

import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import com.mineinabyss.geary.addons.GearyPhase;
import com.mineinabyss.geary.modules.GearyModuleKt;
import com.mineinabyss.geary.papermc.tracking.items.ItemTrackingKt;
import com.mineinabyss.geary.prefabs.PrefabKey;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

/**
* A hook that integrates the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary} to provide custom items
*/
public class HookGeary extends Hook {
private boolean enabled = false;

public HookGeary() {
super("geary");
setEnabledItemHook(true);
}

@Override
public void load() {
if (!enabled) GearyModuleKt.getGeary().getPipeline().intercept(GearyPhase.INIT_ENTITIES, () -> {
enabled = true;
HMCCosmeticsPlugin.setup();
return null;
});
}

/**
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary}
*/
@Override
public ItemStack getItem(@NotNull String itemId) {
if (enabled) {
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
if (prefabKey == null) return null;
return ItemTrackingKt.getGearyItems().createItem(prefabKey, null);
} else return new ItemStack(Material.AIR);
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
if (prefabKey == null) return null;
return ItemTrackingKt.getGearyItems().createItem(prefabKey, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ public void onPortalTeleport(PlayerPortalEvent event) {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerHit(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity();
if (event.getEntity().getEntityId() == event.getDamager().getEntityId()) event.setCancelled(true);
if (!entity.getPersistentDataContainer().has(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT))
return;
event.setCancelled(true);
Expand Down Expand Up @@ -336,6 +335,16 @@ public void onPlayerGamemodeSwitch(PlayerGameModeChangeEvent event) {
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
if (user == null) return;

if (Settings.isDisabledGamemodesEnabled()) {
if (Settings.getDisabledGamemodes().contains(event.getNewGameMode().toString())) {
user.hideCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
} else {
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.GAMEMODE)) {
user.showCosmetics();
}
}
}

if (Settings.isDestroyLooseCosmetics()) {
ItemStack[] equippedArmor = event.getPlayer().getInventory().getArmorContents();
if (equippedArmor.length == 0) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ public enum HiddenReason {
POTION,
ACTION,
COMMAND,
EMOTE
EMOTE,
GAMEMODE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private boolean playerCheck(final Player player) {
CosmeticUser viewer = CosmeticUsers.getUser(player.getUniqueId());

if (user.getPlayer() == player) {
return true;
return (!user.getHidden());
} else {
if (user.isInWardrobe()) return false;
MessagesUtil.sendDebugMessages("playerCheck - Not Same Player");
Expand Down
6 changes: 6 additions & 0 deletions common/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ cosmetic-settings:
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
force-show-join: false # If the plugin should force show a player's cosmetics when they join the server.

disabled-gamemode:
enabled: true
# Which gamemodes should cosmetics be disabled for. This is useful for servers that have a creative world. All options are here, https://hub.spigotmc.org/javadocs/spigot/org/bukkit/GameMode.html
gamemodes:
- "SPECTATOR"

# This disables the entire internal emote system within the plugin. This option requires a restart.
emote-enable: true
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
Expand Down

0 comments on commit f98614c

Please sign in to comment.