Skip to content

Instantly share code, notes, and snippets.

@aarontwf
Created June 26, 2012 04:33
Show Gist options
  • Save aarontwf/2993303 to your computer and use it in GitHub Desktop.
Save aarontwf/2993303 to your computer and use it in GitHub Desktop.
Untested example of hooking into BattleNight
package me.limebyte.bnhookexample;
import java.util.logging.Logger;
import me.limebyte.battlenight.core.BattleNight;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
public class BNHookExample extends JavaPlugin {
private Logger log;
private BattleNight battleNight;
public void onEnable() {
log = this.getLogger();
Plugin bnPlugin = this.getServer().getPluginManager().getPlugin("BattleNight");
if (bnPlugin == null) {
log.severe(ChatColor.RED + "BattleNight not found!");
}
else {
battleNight = new BattleNight();
}
}
private boolean isPlayingBattleNight(Player player) {
if (battleNight == null) return false;
return battleNight.BattleUsersTeam.containsKey(player.getName());
}
private boolean isWatchingBattleNight(Player player) {
if (battleNight == null) return false;
return battleNight.BattleSpectators.containsKey(player.getName());
}
private String getBattleNightTeam(Player player) {
if (!isPlayingBattleNight(player)) return "none";
return battleNight.BattleUsersTeam.get(player.getName());
}
private String getBattleNightClass(Player player) {
if (!isPlayingBattleNight(player)) return "none";
return battleNight.BattleUsersClass.get(player.getName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment