Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
Merged #358 and resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
RadBuilder committed Nov 4, 2017
2 parents 8a529cb + 1c5c0b5 commit 7af5b43
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -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 = falseif (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' } }}
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 = falseif (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/' } }}
Expand Down
1 change: 1 addition & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies {
compile('net.milkbowl.vault:VaultAPI:1.6') {
exclude group: 'org.bukkit'
}
compile 'me.clip:placeholderapi:2.8.2'
}

processResources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
2 changes: 1 addition & 1 deletion core/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 7af5b43

Please sign in to comment.