Skip to content

Commit

Permalink
Add Votifier support. (World event "on votifier vote" with contexts: …
Browse files Browse the repository at this point in the history
…player, time, service)
  • Loading branch information
Morphan1 committed Aug 19, 2013
1 parent 4f1f2b1 commit 64cf39f
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 24 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Expand Up @@ -134,6 +134,13 @@
<artifactId>mcMMO</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.vexsoftware</groupId>
<artifactId>Votifier</artifactId>
<version>6.5.2</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/resources/Votifier.jar</systemPath>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
48 changes: 26 additions & 22 deletions src/main/java/net/gnomeffinway/depenizen/Depenizen.java
@@ -1,20 +1,19 @@
package net.gnomeffinway.depenizen;

import java.io.IOException;

import me.limebyte.battlenight.core.BattleNight;
import net.aufdemrand.denizen.Denizen;
import net.aufdemrand.denizen.tags.ObjectFetcher;
import net.gnomeffinway.depenizen.support.BattleNightSupport;
import net.gnomeffinway.depenizen.support.FactionsSupport;
import net.gnomeffinway.depenizen.support.McMMOSupport;
import net.gnomeffinway.depenizen.support.TownySupport;
import net.gnomeffinway.depenizen.support.VotifierSupport;

import org.bukkit.plugin.java.JavaPlugin;

import com.gmail.nossr50.mcMMO;
import com.massivecraft.factions.Factions;
import com.palmergames.bukkit.towny.Towny;
import com.vexsoftware.votifier.Votifier;

public class Depenizen extends JavaPlugin{

Expand All @@ -23,11 +22,13 @@ public class Depenizen extends JavaPlugin{
public static BattleNight battlenight;
public static Denizen denizen;
public static Towny towny;
public static Votifier votifier;

public McMMOSupport mcmmoSupport;
public BattleNightSupport battlenightSupport;
public TownySupport townySupport;
public FactionsSupport factionsSupport;
public VotifierSupport votifierSupport;

@Override
public void onEnable() {
Expand All @@ -47,8 +48,9 @@ public void checkPlugins() {
factions=(Factions) getServer().getPluginManager().getPlugin("Factions");
towny=(Towny) getServer().getPluginManager().getPlugin("Towny");
battlenight=(BattleNight) getServer().getPluginManager().getPlugin("BattleNight");
votifier=(Votifier) getServer().getPluginManager().getPlugin("Votifier");

if(denizen != null) {
if (denizen != null) {
getServer().getLogger().info("[Depenizen] Denizen hooked");
}
else {
Expand All @@ -57,46 +59,48 @@ public void checkPlugins() {
return;
}

if(mcmmo != null) {
getServer().getLogger().info("[Depenizen] mcMMO hooked, enabling addons");
if (mcmmo != null) {
getServer().getLogger().info("[Depenizen] mcMMO hooked, enabling add-ons.");
mcmmoSupport = new McMMOSupport(this);
mcmmoSupport.register();
}
else {
getServer().getLogger().info("[Depenizen] mcMMO not found, addons will not enable");
getServer().getLogger().info("[Depenizen] mcMMO not found, add-ons will not enable.");
}
if(towny != null) {
getServer().getLogger().info("[Depenizen] Towny hooked, enabling addons");
if (towny != null) {
getServer().getLogger().info("[Depenizen] Towny hooked, enabling add-ons.");
townySupport = new TownySupport(this);
townySupport.register();
}
else {
getServer().getLogger().info("[Depenizen] Towny not found, addons will not addons");
getServer().getLogger().info("[Depenizen] Towny not found, add-ons. will not add-ons.");
}

if(factions != null) {
getServer().getLogger().info("[Depenizen] Factions hooked, enabling addons");
if (factions != null) {
getServer().getLogger().info("[Depenizen] Factions hooked, enabling add-ons.");
factionsSupport = new FactionsSupport(this);
factionsSupport.register();
}
else {
getServer().getLogger().info("[Depenizen] Factions not found, addons will not enable");
getServer().getLogger().info("[Depenizen] Factions not found, add-ons will not enable.");
}

if(battlenight != null) {
getServer().getLogger().info("[Depenizen] BattleNight hooked, enabling addons");
if (battlenight != null) {
getServer().getLogger().info("[Depenizen] BattleNight hooked, enabling add-ons.");
battlenightSupport = new BattleNightSupport(this);
battlenightSupport.register();
}
else {
getServer().getLogger().info("[Depenizen] BattleNight not found, add-ons will not enable");
getServer().getLogger().info("[Depenizen] BattleNight not found, add-ons will not enable.");
}
if (votifier != null) {
getServer().getLogger().info("[Depenizen] Votifier hooked, enabling add-ons.");
votifierSupport = new VotifierSupport(this);
votifierSupport.register();
}
else {
getServer().getLogger().info("[Depenizen] Votifier not found, add-ons will not enable.");
}

try {
ObjectFetcher._initialize();
}
catch (ClassNotFoundException e) {}
catch (IOException e) {}

}

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

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

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

import com.vexsoftware.votifier.model.Vote;
import com.vexsoftware.votifier.model.VotifierEvent;

import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizen.scripts.containers.core.WorldScriptHelper;
import net.gnomeffinway.depenizen.Depenizen;

public class VotifierEvents implements Listener {

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

@EventHandler
public void onVotifierEvent(VotifierEvent event) {

Map<String, Object> context = new HashMap<String, Object>();
Vote vote = event.getVote();
Player player = Bukkit.getPlayer(vote.getUsername());

context.put("player", new dPlayer(player));
context.put("time", vote.getTimeStamp());
context.put("service", vote.getServiceName());

WorldScriptHelper.doEvents(Arrays.asList
("votifier vote"),
null, player, context);

}

}
@@ -1,5 +1,7 @@
package net.gnomeffinway.depenizen.support;

import org.bukkit.Bukkit;

import net.aufdemrand.denizen.tags.ObjectFetcher;
import net.gnomeffinway.depenizen.Depenizen;
import net.gnomeffinway.depenizen.objects.dNation;
Expand All @@ -19,6 +21,13 @@ public void register() {

ObjectFetcher.registerWithObjectFetcher(dTown.class);
ObjectFetcher.registerWithObjectFetcher(dNation.class);

try {
ObjectFetcher._initialize();
}
catch (Exception e) {
Bukkit.getLogger().severe("[Depenizen] Error loading Denizen ObjectFetcher. Towny tags may not function correctly.");
}
}

}
@@ -0,0 +1,18 @@
package net.gnomeffinway.depenizen.support;

import net.gnomeffinway.depenizen.Depenizen;
import net.gnomeffinway.depenizen.events.VotifierEvents;

public class VotifierSupport {

public Depenizen depenizen;

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

public void register() {
new VotifierEvents(depenizen);
}

}
Expand Up @@ -12,7 +12,6 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;

import com.palmergames.bukkit.towny.exceptions.AlreadyRegisteredException;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.object.TownyUniverse;

Expand Down
Binary file added src/main/resources/Votifier.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Expand Up @@ -3,7 +3,7 @@ author: GnomeffinWay
version: 0.2.0
main: net.gnomeffinway.depenizen.Depenizen
depend: [Denizen]
softdepend: [mcMMO, BattleNight, Towny, Factions]
softdepend: [mcMMO, BattleNight, Towny, Factions, Votifier]

commands:

Expand Down

0 comments on commit 64cf39f

Please sign in to comment.