diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d53ecaf --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "java.compile.nullAnalysis.mode": "automatic", + "java.configuration.updateBuildConfiguration": "automatic" +} \ No newline at end of file diff --git a/README.md b/README.md index 860439a..aa7e532 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,176 @@ # PlayerProfiles -If you're looking to get a support for this plugin, please add **mdaffa** on discord! -# License +A modern Minecraft plugin for viewing player profiles with detailed statistics, inventory, and more. This fork provides full support for **Paper 1.21.11+** servers. + +## Features + +- **Player Profiles** - View detailed player information, inventory, armor, ender chest, and statistics +- **Custom GUIs** - Create and manage custom GUI profiles with flexible configuration +- **WorldGuard Integration** - Region-based profile access control (disabled regions) +- **Combat Integration** - CombatLogX and DeluxeCombat support (disable profiles in combat) +- **PlaceholderAPI Support** - Full placeholder support for dynamic content +- **Profile Locking** - Players can lock/unlock their profiles +- **Cooldown System** - Configurable cooldowns for profile viewing +- **Distance Checks** - Auto-close profiles when players move too far apart +- **Multi-world Support** - Disable profiles in specific worlds +- **Auto-refresh** - Automatic placeholder updates in GUI items +- **Metrics** - bStats integration for plugin statistics + +## Requirements + +- **Paper 1.21.11+** (or compatible forks) +- **Java 21** +- **WorldGuard 7.x** (for region features) +- **WorldEdit 7.x** (required by WorldGuard) +- Optional: **PlaceholderAPI**, **CombatLogX**, **DeluxeCombat** + +## Installation + +1. Download the latest `PlayerProfiles-8.0.5.jar` from releases +2. Place in your server's `plugins/` folder +3. Restart the server +4. Configure `plugins/PlayerProfiles/config.yml` to your needs +5. Run `/playerprofiles reload` to apply changes + +## Configuration + +Main configuration files in `plugins/PlayerProfiles/`: + +| File | Description | +|------|-------------| +| `config.yml` | Main settings (cooldowns, combat, worlds, regions, sounds) | +| `gui.yml` | Default profile GUI layout and items | +| `gui-creator.yml` | Custom GUI creator settings | +| `data.yml` | Player profile data storage | +| `custom-gui/punish-gui.yml` | Example custom GUI | + +### Key Config Options + +```yaml +options: + disableNPC: true # Disable NPC profile viewing + disableInCombat: + enabled: true # Block profiles in combat + message: "{prefix} &cYou are not allowed to open profile while in combat!" + shiftClick: true # Shift+right-click to open profile + +autoRefresh: + enabled: true # Auto-update placeholders + refreshEvery: 20 # Update interval (ticks) + +cooldown: + enabled: true + duration: 3 # Seconds + message: "{prefix} &cPlease wait for another {time} second(s)!" + +disabledWorlds: + message: "{prefix} &cYou are not allowed to open profile in this world!" + worlds: + - 'pvpWorld' + +disabledRegions: + playerInDisabledRegionMessage: "{prefix} &cYou are not allowed to open profile in this region!" + targetInDisabledRegionMessage: "{prefix} &cThe target is in disabled region area!" + regions: + - 'disabledRegions' + - 'pvp' + +distanceCheck: + enabled: true + distance: 30 # Blocks + tooFarMessage: "{prefix} &e{player} &cis too far from you!" +``` + +## Commands + +| Command | Aliases | Permission | Description | +|---------|---------|------------|-------------| +| `/playerprofiles` | `/pp`, `/playerprofile`, `/playerp` | `playerprofiles.admin` | Main command | +| `/playerprofiles reload` | | `playerprofiles.admin` | Reload configuration | +| `/playerprofiles opengui ` | | `playerprofiles.admin` | Open custom GUI for player | +| `/playerprofiles listgui` | | `playerprofiles.admin` | List available custom GUIs | +| `/profile [player]` | `/p`, `/viewprofile` | `playerprofiles.profile` | View profile | +| `/lockprofile [player]` | `/lock`, `/profilelock` | `playerprofiles.lock` | Lock profile | +| `/unlockprofile [player]` | `/unlock`, `/profileunlock` | `playerprofiles.unlock` | Unlock profile | +| `/toggleprofile` | | `playerprofiles.toggle` | Toggle profile viewing | + +## Permissions + +``` +playerprofiles.* # All permissions +playerprofiles.admin # Admin commands (reload, opengui, listgui) +playerprofiles.profile # View profiles (/profile) +playerprofiles.profile.others # View other players' profiles +playerprofiles.lock # Lock own profile +playerprofiles.lock.others # Lock others' profiles +playerprofiles.unlock # Unlock own profile +playerprofiles.unlock.others # Unlock others' profiles +playerprofiles.toggle # Toggle profile viewing +playerprofiles.bypass.cooldown # Bypass profile cooldown +playerprofiles.bypass.distance # Bypass distance check +playerprofiles.bypass.combat # Bypass combat restriction +playerprofiles.bypass.disabledworld # Bypass disabled worlds +playerprofiles.bypass.disabledregion # Bypass disabled regions +``` + +## Custom GUI Creation + +Create custom GUIs in `gui-creator.yml` or use the in-game creator: + +1. Run `/playerprofiles opengui ` to open a custom GUI +2. Use `/playerprofiles listgui` to see available GUIs +3. Configure custom GUIs in `custom-gui/` folder + +## Placeholders + +With PlaceholderAPI installed, these placeholders are available: + +- `%playerprofiles_%` - Player statistics +- `%playerprofiles_kills%` - Player kills (if supported) +- `%playerprofiles_deaths%` - Player deaths (if supported) +- Any PAPI placeholder can be used in GUI items and messages + +## Building from Source + +```bash +# Requires Java 21 and Maven 3.8+ +git clone https://github.com/evnrca/PlayerProfiles26.git +cd PlayerProfiles26 +mvn clean package -DskipTests +# Output: target/PlayerProfiles-8.0.5.jar +``` + +## Module Structure + +``` +PlayerProfiles/ +├── api/ # Core API interfaces +├── core/ # Main plugin logic +├── worldguard-wrapper/ # WorldGuard version abstraction +├── worldguard7/ # WorldGuard 7.x implementation +└── dist/ # Final shaded JAR assembly +``` + +## Changes in This Fork (v8.0.5) + +- **Java 21** baseline +- **Paper 1.21.11** support +- **WorldGuard 7.0.10** / **WorldEdit 7.3.12** +- Removed legacy WorldGuard 6.x module +- Simplified WorldGuard wrapper (single implementation) +- Fixed DependencyManager brace issues +- Updated plugin.yml api-version to 1.21 +- Modernized RegionFinder for WG7 API + +## License + You can do whatever you want with the source code, just don't redistribute it. + +## Support + +For support, join the Discord and contact **mdaffa**. + +--- + +**Original Author**: aglerr, Starfruit2210 +**Fork Maintainer**: evnrca \ No newline at end of file diff --git a/api/pom.xml b/api/pom.xml index 83b5fea..ce5de65 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,14 +6,12 @@ com.muhammaddaffa PlayerProfiles - 8.0.4 + 8.0.5 api - 17 - 17 UTF-8 @@ -30,7 +28,7 @@ org.spigotmc spigot-api - 1.20.1-R0.1-SNAPSHOT + ${spigot.version} provided diff --git a/core/pom.xml b/core/pom.xml index 04cbed0..c62fd86 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -6,14 +6,12 @@ com.muhammaddaffa PlayerProfiles - 8.0.4 + 8.0.5 core - 21 - 21 UTF-8 @@ -71,7 +69,7 @@ org.spigotmc spigot-api - 1.21.5-R0.1-SNAPSHOT + ${spigot.version} provided @@ -84,22 +82,9 @@ com.github.mdaffa48 MDLib - 2.3.3 - - - - com.github.sirblobman.api - core - 2.9-SNAPSHOT - provided - - - - com.github.sirblobman.combatlogx - api - 11.4-SNAPSHOT - provided + 2.3.8 + com.github.timderspieler DeluxeCombat-API diff --git a/core/src/main/java/com/muhammaddaffa/playerprofiles/hooks/combatlogx/HCombatLogX.java b/core/src/main/java/com/muhammaddaffa/playerprofiles/hooks/combatlogx/HCombatLogX.java index aa310e6..ddf4fc4 100644 --- a/core/src/main/java/com/muhammaddaffa/playerprofiles/hooks/combatlogx/HCombatLogX.java +++ b/core/src/main/java/com/muhammaddaffa/playerprofiles/hooks/combatlogx/HCombatLogX.java @@ -1,16 +1,53 @@ package com.muhammaddaffa.playerprofiles.hooks.combatlogx; -import com.github.sirblobman.combatlogx.api.ICombatLogX; -import com.github.sirblobman.combatlogx.api.manager.ICombatManager; +import com.muhammaddaffa.mdlib.utils.Logger; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import java.lang.reflect.Method; public class HCombatLogX { - public static boolean isInCombat(Player player){ - ICombatLogX plugin = (ICombatLogX) Bukkit.getPluginManager().getPlugin("CombatLogX"); - ICombatManager combatManager = plugin.getCombatManager(); - return combatManager.isInCombat(player); + private static Method isInCombatMethod; + private static boolean initialized = false; + + private static void initialize() { + if (initialized) return; + initialized = true; + + Plugin plugin = Bukkit.getPluginManager().getPlugin("CombatLogX"); + if (plugin == null) return; + + try { + Class combatLogXClass = Class.forName("com.github.sirblobman.combatlogx.api.ICombatLogX"); + Class combatManagerClass = Class.forName("com.github.sirblobman.combatlogx.api.manager.ICombatManager"); + + Method getCombatManagerMethod = combatLogXClass.getMethod("getCombatManager"); + Object combatManager = getCombatManagerMethod.invoke(plugin); + + isInCombatMethod = combatManagerClass.getMethod("isInCombat", Player.class); + } catch (Exception e) { + Logger.severe("Failed to initialize CombatLogX hook: " + e.getMessage()); + } + } + + public static boolean isInCombat(Player player) { + initialize(); + if (isInCombatMethod == null) return false; + + try { + Plugin plugin = Bukkit.getPluginManager().getPlugin("CombatLogX"); + if (plugin == null) return false; + + Class combatLogXClass = Class.forName("com.github.sirblobman.combatlogx.api.ICombatLogX"); + Method getCombatManagerMethod = combatLogXClass.getMethod("getCombatManager"); + Object combatManager = getCombatManagerMethod.invoke(plugin); + + return (boolean) isInCombatMethod.invoke(combatManager, player); + } catch (Exception e) { + return false; + } } -} +} \ No newline at end of file diff --git a/core/src/main/java/com/muhammaddaffa/playerprofiles/manager/DependencyManager.java b/core/src/main/java/com/muhammaddaffa/playerprofiles/manager/DependencyManager.java index a879ec1..c23f0a1 100644 --- a/core/src/main/java/com/muhammaddaffa/playerprofiles/manager/DependencyManager.java +++ b/core/src/main/java/com/muhammaddaffa/playerprofiles/manager/DependencyManager.java @@ -32,13 +32,15 @@ public static void checkDependency(){ if(WORLD_GUARD){ Plugin plugin = pm.getPlugin("WorldGuard"); - if(plugin.getDescription().getVersion().startsWith("6")) + if(plugin.getDescription().getVersion().startsWith("6")) { Logger.info("&rFound WorldGuard! Using WorldGuard API version 6"); WORLD_GUARD_VERSION = 6; + } - if(plugin.getDescription().getVersion().startsWith("7")) + if(plugin.getDescription().getVersion().startsWith("7")) { Logger.info("&rFound WorldGuard! Using WorldGuard API version 7"); WORLD_GUARD_VERSION = 7; + } } } diff --git a/core/src/main/resources/plugin.yml b/core/src/main/resources/plugin.yml index 2216f36..35693a3 100644 --- a/core/src/main/resources/plugin.yml +++ b/core/src/main/resources/plugin.yml @@ -1,9 +1,9 @@ name: PlayerProfiles -version: 8.0.3 +version: 8.0.5 main: com.muhammaddaffa.playerprofiles.PlayerProfiles author: aglerr, Starfruit2210 description: Plugin to show player profiles -api-version: 1.13 +api-version: 1.21 softdepend: [CombatLogX, DeluxeCombat, PlaceholderAPI, WorldGuard, WorldEdit] commands: diff --git a/dist/pom.xml b/dist/pom.xml index 42bfb9b..1e3c9e8 100644 --- a/dist/pom.xml +++ b/dist/pom.xml @@ -6,14 +6,12 @@ com.muhammaddaffa PlayerProfiles - 8.0.4 + 8.0.5 dist - 21 - 21 UTF-8 @@ -55,11 +53,6 @@ api ${project.version} - - ${project.groupId} - worldguard6 - ${project.version} - ${project.groupId} worldguard7 diff --git a/pom.xml b/pom.xml index dc0274c..5f9e365 100644 --- a/pom.xml +++ b/pom.xml @@ -7,11 +7,15 @@ com.muhammaddaffa PlayerProfiles pom - 8.0.4 + 8.0.5 21 21 + UTF-8 + 1.21.11-R0.1-SNAPSHOT + 7.0.10 + 7.3.12 @@ -19,7 +23,6 @@ core api worldguard-wrapper - worldguard6 worldguard7 diff --git a/worldguard-wrapper/pom.xml b/worldguard-wrapper/pom.xml index f08a5c0..2c3f87c 100644 --- a/worldguard-wrapper/pom.xml +++ b/worldguard-wrapper/pom.xml @@ -6,14 +6,12 @@ com.muhammaddaffa PlayerProfiles - 8.0.4 + 8.0.5 worldguard-wrapper - 21 - 21 UTF-8 @@ -23,6 +21,10 @@ spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + sk89q-repo + https://maven.enginehub.org/repo/ + @@ -30,19 +32,9 @@ org.spigotmc spigot-api - 1.20.1-R0.1-SNAPSHOT + ${spigot.version} provided - - ${project.groupId} - worldguard6 - ${project.version} - - - ${project.groupId} - worldguard6 - ${project.version} - ${project.groupId} worldguard7 diff --git a/worldguard-wrapper/src/main/java/com/muhammaddaffa/playerprofiles/worldguardwrapper/WorldGuardWrapper.java b/worldguard-wrapper/src/main/java/com/muhammaddaffa/playerprofiles/worldguardwrapper/WorldGuardWrapper.java index 42517fc..81f03f3 100644 --- a/worldguard-wrapper/src/main/java/com/muhammaddaffa/playerprofiles/worldguardwrapper/WorldGuardWrapper.java +++ b/worldguard-wrapper/src/main/java/com/muhammaddaffa/playerprofiles/worldguardwrapper/WorldGuardWrapper.java @@ -1,7 +1,6 @@ package com.muhammaddaffa.playerprofiles.worldguardwrapper; import com.muhammaddaffa.api.IRegionFinder; -import com.muhammaddaffa.playerprofiles.worldguardwrapper.wg6.RegionFinder6; import com.muhammaddaffa.playerprofiles.worldguardwrapper.wg7.RegionFinder7; public class WorldGuardWrapper { @@ -12,18 +11,7 @@ public static WorldGuardWrapper getInstance(){ return instance; } - private final IRegionFinder regionFinder; - - private WorldGuardWrapper(){ - IRegionFinder selected; - try{ - Class.forName("com.sk89q.worldguard.WorldGuard"); - selected = new RegionFinder7(); - } catch (ClassNotFoundException ex){ - selected = new RegionFinder6(); - } - regionFinder = selected; - } + private final IRegionFinder regionFinder = new RegionFinder7(); public IRegionFinder getRegionFinder() { return regionFinder; diff --git a/worldguard7/pom.xml b/worldguard7/pom.xml index bcf10c5..28b0194 100644 --- a/worldguard7/pom.xml +++ b/worldguard7/pom.xml @@ -6,14 +6,12 @@ com.muhammaddaffa PlayerProfiles - 8.0.4 + 8.0.5 worldguard7 - 21 - 21 UTF-8 @@ -34,19 +32,19 @@ org.spigotmc spigot-api - 1.17-R0.1-SNAPSHOT + ${spigot.version} provided com.sk89q.worldguard - worldguard-core - 7.0.0-SNAPSHOT + worldguard-bukkit + ${worldguard.version} provided com.sk89q.worldedit worldedit-bukkit - 7.3.0-SNAPSHOT + ${worldedit.version} provided diff --git a/worldguard7/src/main/java/com/muhammaddaffa/playerprofiles/worldguardwrapper/wg7/RegionFinder7.java b/worldguard7/src/main/java/com/muhammaddaffa/playerprofiles/worldguardwrapper/wg7/RegionFinder7.java index 5b70e0a..f2e3308 100644 --- a/worldguard7/src/main/java/com/muhammaddaffa/playerprofiles/worldguardwrapper/wg7/RegionFinder7.java +++ b/worldguard7/src/main/java/com/muhammaddaffa/playerprofiles/worldguardwrapper/wg7/RegionFinder7.java @@ -13,22 +13,16 @@ public class RegionFinder7 implements IRegionFinder { @Override public List getRegions(Location location) { - // Get the location util using BukkitAdapter com.sk89q.worldedit.util.Location loc = BukkitAdapter.adapt(location); - // Get the RegionContainer + com.sk89q.worldguard.protection.regions.RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); - // Get the RegionQuery com.sk89q.worldguard.protection.regions.RegionQuery query = container.createQuery(); - // Get the ApplicableRegionSet com.sk89q.worldguard.protection.ApplicableRegionSet ars = query.getApplicableRegions(loc); - // Create an empty list of string + List regions = new ArrayList<>(); - // Loop through all regions in the location - for(ProtectedRegion region : ars){ - // Add the region name/id to the regions list + for (ProtectedRegion region : ars) { regions.add(region.getId()); } - // Finally, return the list of regions name return regions; }