diff --git a/build.gradle b/build.gradle index 0dcfc0280..3f412f711 100644 --- a/build.gradle +++ b/build.gradle @@ -1 +1 @@ -allprojects { apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' group = 'be.isach' version = '2.5.0' compileJava.options.encoding = 'UTF-8' sourceCompatibility = 1.8 targetCompatibility = 1.8 configurations { shaded compile.extendsFrom shaded } afterEvaluate { jar { dependsOn configurations.shaded from configurations.shaded.collect { it.isDirectory() ? it : zipTree(it) } } } } boolean local = false if (local) libsDirName = '/Users/sacha/Documents/Development/Java/UC_1_11/testserver/plugins' sourceSets.remove(sourceSets.main) dependencies { subprojects.each { p -> shaded(p) { transitive false } } } subprojects { repositories { mavenLocal() mavenCentral() // Vault maven { url 'http://nexus.hc.to/content/repositories/pub_releases' } // Lib's Disguises maven { url 'http://repo.md-5.net/content/groups/public/' } maven { url 'https://repo.isach.be' } // BungeeCord maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } } } \ No newline at end of file +allprojects { apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' group = 'be.isach' version = '2.5.0-RELEASE' compileJava.options.encoding = 'UTF-8' sourceCompatibility = 1.8 targetCompatibility = 1.8 configurations { shaded compile.extendsFrom shaded } afterEvaluate { jar { dependsOn configurations.shaded from configurations.shaded.collect { it.isDirectory() ? it : zipTree(it) } } } } boolean local = false if (local) libsDirName = '/Users/sacha/Documents/Development/Java/UC_1_11/testserver/plugins' dependencies { subprojects.each { p -> shaded(p) { transitive false } } } subprojects { repositories { mavenLocal() mavenCentral() // Vault maven { url 'http://nexus.hc.to/content/repositories/pub_releases' } // Lib's Disguises maven { url 'http://repo.md-5.net/content/groups/public/' } maven { url 'https://repo.isach.be' } // BungeeCord maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } // PlaceholderAPI maven { url 'http://repo.extendedclip.com/content/repositories/placeholderapi/' } } } \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle index 4fa7acfd2..eada6c3ef 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -7,6 +7,7 @@ dependencies { compile('net.milkbowl.vault:VaultAPI:1.6') { exclude group: 'org.bukkit' } + compile 'me.clip:placeholderapi:2.8.2' } processResources { diff --git a/core/src/main/java/be/isach/ultracosmetics/UltraCosmetics.java b/core/src/main/java/be/isach/ultracosmetics/UltraCosmetics.java index 9e3e97ce3..08987eba2 100755 --- a/core/src/main/java/be/isach/ultracosmetics/UltraCosmetics.java +++ b/core/src/main/java/be/isach/ultracosmetics/UltraCosmetics.java @@ -12,6 +12,7 @@ import be.isach.ultracosmetics.manager.TreasureChestManager; import be.isach.ultracosmetics.menu.Menus; import be.isach.ultracosmetics.mysql.MySqlConnectionManager; +import be.isach.ultracosmetics.placeholderapi.PlaceholderHook; import be.isach.ultracosmetics.player.UltraPlayer; import be.isach.ultracosmetics.player.UltraPlayerManager; import be.isach.ultracosmetics.run.FallDamageManager; @@ -167,6 +168,13 @@ public void onEnable() { getSmartLogger().write("Morphs disabled."); getSmartLogger().write(""); } + + if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) { + getSmartLogger().write(""); + new PlaceholderHook(this).hook(); + getSmartLogger().write("Hooked into PlaceholderAPI"); + getSmartLogger().write(""); + } // Set up economy if needed. setupEconomy(); diff --git a/core/src/main/java/be/isach/ultracosmetics/placeholderapi/PlaceholderHook.java b/core/src/main/java/be/isach/ultracosmetics/placeholderapi/PlaceholderHook.java new file mode 100644 index 000000000..760130b73 --- /dev/null +++ b/core/src/main/java/be/isach/ultracosmetics/placeholderapi/PlaceholderHook.java @@ -0,0 +1,122 @@ +package be.isach.ultracosmetics.placeholderapi; + +import be.isach.ultracosmetics.UltraCosmetics; +import be.isach.ultracosmetics.cosmetics.suits.ArmorSlot; +import be.isach.ultracosmetics.player.UltraPlayer; +import me.clip.placeholderapi.external.EZPlaceholderHook; +import org.bukkit.entity.Player; + +/** + * PlaceholderAPI hook. + * + * @author RadBuilder + * @since 2.5 + */ +public class PlaceholderHook extends EZPlaceholderHook { + + private UltraCosmetics ultraCosmetics; + + public PlaceholderHook(UltraCosmetics ultraCosmetics) { + super(ultraCosmetics, "ultracosmetics"); + this.ultraCosmetics = ultraCosmetics; + } + + @Override + public String onPlaceholderRequest(Player player, String identifier) { + UltraPlayer ultraPlayer = ultraCosmetics.getPlayerManager().getUltraPlayer(player); + switch (identifier) { + // Current cosmetics + case "current_gadget": + return ultraPlayer.getCurrentGadget().getType().getName(); + case "current_mount": + return ultraPlayer.getCurrentMount().getType().getName(); + case "current_particleeffect": + return ultraPlayer.getCurrentParticleEffect().getType().getName(); + case "current_pet": + return ultraPlayer.getCurrentPet().getType().getName(); + case "current_morph": + return ultraPlayer.getCurrentMorph().getType().getName(); + case "current_hat": + return ultraPlayer.getCurrentHat().getType().getName(); + case "current_emote": + return ultraPlayer.getCurrentEmote().getType().getName(); + case "current_suit_helmet": + return ultraPlayer.getSuit(ArmorSlot.HELMET).getType().getName(ArmorSlot.HELMET); + case "current_suit_chestplate": + return ultraPlayer.getSuit(ArmorSlot.CHESTPLATE).getType().getName(ArmorSlot.CHESTPLATE); + case "current_suit_leggings": + return ultraPlayer.getSuit(ArmorSlot.LEGGINGS).getType().getName(ArmorSlot.LEGGINGS); + case "current_suit_boots": + return ultraPlayer.getSuit(ArmorSlot.BOOTS).getType().getName(ArmorSlot.BOOTS); + + // Balance, keys, and user-specific settings + case "balance": + return "" + ultraPlayer.getBalance(); + case "keys": + return "" + ultraPlayer.getKeys(); + case "gadgets_enabled": + return "" + ultraPlayer.hasGadgetsEnabled(); + case "morph_selfview": + return "" + ultraPlayer.canSeeSelfMorph(); + case "treasurechest_active": + return "" + (ultraPlayer.getCurrentTreasureChest() != null); + + // Gadget ammo + case "ammo_batblaster": + return "" + ultraPlayer.getAmmo("BatBlaster"); + case "ammo_chickenator": + return "" + ultraPlayer.getAmmo("Chickenator"); + case "ammo_colorbomb": + return "" + ultraPlayer.getAmmo("ColorBomb"); + case "ammo_discoball": + return "" + ultraPlayer.getAmmo("DiscoBall"); + case "ammo_etherealpearl": + return "" + ultraPlayer.getAmmo("EtherealPearl"); + case "ammo_fleshhook": + return "" + ultraPlayer.getAmmo("FleshHook"); + case "ammo_melonthrower": + return "" + ultraPlayer.getAmmo("MelonThrower"); + case "ammo_blizzardblaster": + return "" + ultraPlayer.getAmmo("BlizzardBlaster"); + case "ammo_portalgun": + return "" + ultraPlayer.getAmmo("PortalGun"); + case "ammo_explosivesheep": + return "" + ultraPlayer.getAmmo("ExplosiveSheep"); + case "ammo_paintballgun": + return "" + ultraPlayer.getAmmo("PaintballGun"); + case "ammo_thorhammer": + return "" + ultraPlayer.getAmmo("ThorHammer"); + case "ammo_antigravity": + return "" + ultraPlayer.getAmmo("AntiGravity"); + case "ammo_smashdown": + return "" + ultraPlayer.getAmmo("SmashDown"); + case "ammo_rocket": + return "" + ultraPlayer.getAmmo("Rocket"); + case "ammo_blackhole": + return "" + ultraPlayer.getAmmo("BlackHole"); + case "ammo_tsunami": + return "" + ultraPlayer.getAmmo("Tsunami"); + case "ammo_tnt": + return "" + ultraPlayer.getAmmo("TNT"); + case "ammo_fungun": + return "" + ultraPlayer.getAmmo("FunGun"); + case "ammo_parachute": + return "" + ultraPlayer.getAmmo("Parachute"); + case "ammo_quakegun": + return "" + ultraPlayer.getAmmo("QuakeGun"); + case "ammo_firework": + return "" + ultraPlayer.getAmmo("Firework"); + case "ammo_christmastree": + return "" + ultraPlayer.getAmmo("ChristmasTree"); + case "ammo_freezecannon": + return "" + ultraPlayer.getAmmo("FreezeCannon"); + case "ammo_snowball": + return "" + ultraPlayer.getAmmo("Snowball"); + case "ammo_partypopper": + return "" + ultraPlayer.getAmmo("PartyPopper"); + case "ammo_trampoline": + return "" + ultraPlayer.getAmmo("Trampoline"); + } + return null; + } +} diff --git a/core/src/main/resources/plugin.yml b/core/src/main/resources/plugin.yml index 72b9ce61b..96c767fd5 100644 --- a/core/src/main/resources/plugin.yml +++ b/core/src/main/resources/plugin.yml @@ -3,7 +3,7 @@ version: @VERSION@ author: iSach load: POSTWORLD main: be.isach.ultracosmetics.UltraCosmetics -softdepend: [LibsDisguises, Vault] +softdepend: [LibsDisguises, Vault, PlaceholderAPI] commands: ultracosmetics: aliases: [uc, cosmetics]