Skip to content

Commit

Permalink
Add PvP Arena support. Fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphan1 committed Oct 27, 2013
1 parent 43d76a9 commit 253ece2
Show file tree
Hide file tree
Showing 9 changed files with 297 additions and 2 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Expand Up @@ -170,5 +170,12 @@
<scope>system</scope>
<systemPath>${basedir}/src/main/resources/Jobs.jar</systemPath>
</dependency>
<dependency>
<groupId>net.slipcor</groupId>
<artifactId>pvparena</artifactId>
<version>1.0.9.287</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/resources/pvparena.jar</systemPath>
</dependency>
</dependencies>
</project>
13 changes: 13 additions & 0 deletions src/main/java/net/gnomeffinway/depenizen/Depenizen.java
Expand Up @@ -7,8 +7,10 @@
import net.gnomeffinway.depenizen.support.FactionsSupport;
import net.gnomeffinway.depenizen.support.JobsSupport;
import net.gnomeffinway.depenizen.support.McMMOSupport;
import net.gnomeffinway.depenizen.support.PVPArenaSupport;
import net.gnomeffinway.depenizen.support.TownySupport;
import net.gnomeffinway.depenizen.support.VotifierSupport;
import net.slipcor.pvparena.PVPArena;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
Expand All @@ -30,6 +32,7 @@ public class Depenizen extends JavaPlugin {
public static Votifier votifier;
public static Votifier bungeefier;
public static JobsPlugin jobs;
public static PVPArena pvparena;

public McMMOSupport mcmmoSupport;
public BattleNightSupport battlenightSupport;
Expand All @@ -38,6 +41,7 @@ public class Depenizen extends JavaPlugin {
public VotifierSupport votifierSupport;
public VotifierSupport bungeefierSupport;
public JobsSupport jobsSupport;
public PVPArenaSupport pvparenaSupport;

@Override
public void onEnable() {
Expand Down Expand Up @@ -71,6 +75,7 @@ public void checkPlugins() {
votifier = (Votifier) getServer().getPluginManager().getPlugin("Votifier");
bungeefier = (Votifier) getServer().getPluginManager().getPlugin("Bungeefier");
jobs = (JobsPlugin) getServer().getPluginManager().getPlugin("Jobs");
pvparena = (PVPArena) getServer().getPluginManager().getPlugin("pvparena");

if (denizen != null) {
getServer().getLogger().info("[Depenizen] Denizen hooked");
Expand Down Expand Up @@ -139,6 +144,14 @@ public void checkPlugins() {
else {
getServer().getLogger().info("[Depenizen] Jobs not found, add-ons will not enable.");
}
if (pvparena != null) {
getServer().getLogger().info("[Depenizen] PvP Arena hooked, enabling add-ons.");
pvparenaSupport = new PVPArenaSupport(this);
pvparenaSupport.register();
}
else {
getServer().getLogger().info("[Depenizen] PvP Arena not found, add-ons will not enable.");
}

}

Expand Down
@@ -0,0 +1,55 @@
package net.gnomeffinway.depenizen.events;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import net.aufdemrand.denizen.objects.Element;
import net.aufdemrand.denizen.objects.dList;
import net.aufdemrand.denizen.objects.dObject;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizen.scripts.containers.core.WorldScriptHelper;
import net.gnomeffinway.depenizen.Depenizen;
import net.slipcor.pvparena.arena.Arena;
import net.slipcor.pvparena.arena.ArenaPlayer;
import net.slipcor.pvparena.events.PAStartEvent;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

public class PVPArenaEvents implements Listener {

public PVPArenaEvents(Depenizen depenizen) {
depenizen.getServer().getPluginManager().registerEvents(this, depenizen);
}

// <--[event]
// @events arena starts
// @triggers when an arena starts a round.
// @context
// <context.arena> returns the arena name.
// <context.fighters> returns a dList of the fighters in the round.
// @plugin PvP Arena
// -->
@EventHandler
public void onArenaStarts(PAStartEvent event) {

Map<String, dObject> context = new HashMap<String, dObject>();
Arena arena = event.getArena();

context.put("arena", new Element(arena.getName()));

ArrayList<dPlayer> fighters = new ArrayList<dPlayer>();
for (ArenaPlayer player : event.getArena().getFighters())
fighters.add(new dPlayer(player.get()));

context.put("fighters", new dList(fighters));

WorldScriptHelper.doEvents(Arrays.asList
("arena starts"),
null, null, context);

}

}
Expand Up @@ -22,6 +22,22 @@ public VotifierEvents(Depenizen depenizen) {
depenizen.getServer().getPluginManager().registerEvents(this, depenizen);
}

// <--[event]
// @events votifier vote
// @triggers when a Votifier vote is made.
// @context
// <context.time> returns the time the vote was sent.
// <context.service> returns what service was used to send the vote.
// @plugin Votifier
// -->
// <--[event]
// @events bungeefier vote
// @triggers when a Bungeefier vote is made.
// @context
// <context.time> returns the time the vote was sent.
// <context.service> returns what service was used to send the vote.
// @plugin Bungeefier
// -->
@EventHandler
public void onVotifierEvent(VotifierEvent event) {

Expand All @@ -32,7 +48,7 @@ public void onVotifierEvent(VotifierEvent event) {
context.put("service", new Element(vote.getServiceName()));

WorldScriptHelper.doEvents(Arrays.asList
("votifier vote"),
("votifier vote", "bungeefier vote"),
null, Bukkit.getPlayer(vote.getUsername()), context);

}
Expand Down
@@ -0,0 +1,20 @@
package net.gnomeffinway.depenizen.support;

import net.gnomeffinway.depenizen.Depenizen;
import net.gnomeffinway.depenizen.events.PVPArenaEvents;
import net.gnomeffinway.depenizen.tags.PVPArenaTags;

public class PVPArenaSupport {

public Depenizen depenizen;

public PVPArenaSupport(Depenizen depenizen) {
this.depenizen = depenizen;
}

public void register() {
new PVPArenaTags(depenizen);
new PVPArenaEvents(depenizen);
}

}
7 changes: 6 additions & 1 deletion src/main/java/net/gnomeffinway/depenizen/tags/McMMOTags.java
Expand Up @@ -103,7 +103,6 @@ else if (attribute.startsWith("party"))
replaced = new Element(PartyAPI.getPartyName(p.getPlayerEntity()))
.getAttribute(attribute.fulfill(1));

// -->
else if (attribute.startsWith("xp")) {

String skill = attribute.getContext(1);
Expand All @@ -116,6 +115,7 @@ else if (attribute.startsWith("xp")) {
// Returns the amount of experience a player has left to level up
// in a skill.
// @plugin mcMMO
// -->
if (attribute.startsWith("tonextlevel") || attribute.startsWith("to_next_level")) {
if (p.isOnline()) {
replaced = new Element(ExperienceAPI.getXPToNextLevel(p.getPlayerEntity(), skill))
Expand All @@ -133,6 +133,7 @@ else if (attribute.startsWith("xp")) {
// @description
// Returns the player's experience level in a skill.
// @plugin mcMMO
// -->
else if (attribute.startsWith("level")) {
if (p.isOnline()) {
replaced = new Element(ExperienceAPI.getLevel(p.getPlayerEntity(), skill))
Expand All @@ -150,6 +151,7 @@ else if (attribute.startsWith("level")) {
// @description
// Returns the player's amount of experience in a skill.
// @plugin mcMMO
// -->
else if (p.isOnline()) {
replaced = new Element(ExperienceAPI.getXP(p.getPlayerEntity(), skill))
.getAttribute(attribute.fulfill(0));
Expand All @@ -170,6 +172,7 @@ else if (p.isOnline()) {
// Returns the player's current rank in a skill. If no skill is specified,
// this returns the player's overall rank.
// @plugin mcMMO
// -->
else if (attribute.startsWith("rank")) {
if (!attribute.hasContext(1)) {
replaced = new Element(ExperienceAPI.getPlayerRankOverall(p.getName()))
Expand Down Expand Up @@ -202,6 +205,7 @@ else if (event.matches("party")) {
// @description
// Returns the leader of the party.
// @plugin mcMMO
// -->
if (attribute.startsWith("leader"))
replaced = dPlayer.valueOf(party.getLeader())
.getAttribute(attribute.fulfill(1));
Expand All @@ -212,6 +216,7 @@ else if (event.matches("party")) {
// @description
// Returns the number of players in the party.
// @plugin mcMMO
// -->
else if(attribute.startsWith("playercount") || attribute.startsWith("player_count"))
replaced = new Element(party.getMembers().size())
.getAttribute(attribute.fulfill(1));
Expand Down

0 comments on commit 253ece2

Please sign in to comment.