(Olof) Using latest CAPI for integration

This commit is contained in:
Brettflan 2012-02-20 16:53:10 -06:00
parent 56de98f049
commit af85f0f503
4 changed files with 13 additions and 13 deletions

BIN
lib/MCore.jar Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,8 +1,6 @@
package com.massivecraft.factions.integration.capi; package com.massivecraft.factions.integration.capi;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
@ -11,11 +9,11 @@ public class CapiFeatures
{ {
public static void setup() public static void setup()
{ {
Plugin plug = Bukkit.getServer().getPluginManager().getPlugin("CAPI"); Plugin plug = Bukkit.getServer().getPluginManager().getPlugin("capi");
if (plug != null && plug.getClass().getName().equals("com.massivecraft.capi.CAPI")) if (plug != null && plug.getClass().getName().equals("com.massivecraft.capi.P"))
{ {
P.p.log("Integration with the CAPI plugin was successful"); P.p.log("Integration with the CAPI plugin was successful");
P.p.registerEvent(Event.Type.CUSTOM_EVENT, new PluginCapiListener(P.p), Priority.Normal); Bukkit.getPluginManager().registerEvents(new PluginCapiListener(P.p), P.p);
} }
} }
} }

View File

@ -5,6 +5,9 @@ import java.util.Set;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import com.massivecraft.capi.Channel; import com.massivecraft.capi.Channel;
import com.massivecraft.capi.Channels; import com.massivecraft.capi.Channels;
@ -12,14 +15,13 @@ import com.massivecraft.capi.events.CAPIListChannelsEvent;
import com.massivecraft.capi.events.CAPIMessageToChannelEvent; import com.massivecraft.capi.events.CAPIMessageToChannelEvent;
import com.massivecraft.capi.events.CAPIMessageToPlayerEvent; import com.massivecraft.capi.events.CAPIMessageToPlayerEvent;
import com.massivecraft.capi.events.CAPISelectChannelEvent; import com.massivecraft.capi.events.CAPISelectChannelEvent;
import com.massivecraft.capi.listeners.CapiListener;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
public class PluginCapiListener extends CapiListener public class PluginCapiListener implements Listener
{ {
P p; P p;
@ -50,10 +52,10 @@ public class PluginCapiListener extends CapiListener
return format; return format;
} }
@Override @EventHandler(priority = EventPriority.NORMAL)
public void onListChannelsEvent(CAPIListChannelsEvent event) public void onListChannelsEvent(CAPIListChannelsEvent event)
{ {
for (Channel c : Channels.i.get()) for (Channel c : Channels.i.getAll())
{ {
if (myChannelIds.contains(c.getId())) if (myChannelIds.contains(c.getId()))
{ {
@ -62,7 +64,7 @@ public class PluginCapiListener extends CapiListener
} }
} }
@Override @EventHandler(priority = EventPriority.NORMAL)
public void onMessageToChannel(CAPIMessageToChannelEvent event) public void onMessageToChannel(CAPIMessageToChannelEvent event)
{ {
if (event.isCancelled()) return; if (event.isCancelled()) return;
@ -81,7 +83,7 @@ public class PluginCapiListener extends CapiListener
for (Player somePlayer : Bukkit.getServer().getOnlinePlayers()) for (Player somePlayer : Bukkit.getServer().getOnlinePlayers())
{ {
FPlayer someFPlayer = FPlayers.i.get(somePlayer); FPlayer someFPlayer = FPlayers.i.get(somePlayer);
if (someFPlayer.getRelationTo(fme).value >= Relation.ALLY.value) if (someFPlayer.getRelationTo(fme).isAtLeast(Relation.ALLY))
{ {
event.getThem().add(somePlayer); event.getThem().add(somePlayer);
} }
@ -89,14 +91,14 @@ public class PluginCapiListener extends CapiListener
} }
} }
@Override @EventHandler(priority = EventPriority.NORMAL)
public void onMessageToPlayer(CAPIMessageToPlayerEvent event) public void onMessageToPlayer(CAPIMessageToPlayerEvent event)
{ {
if (event.isCancelled()) return; if (event.isCancelled()) return;
event.setFormat(this.replacePlayerTags(event.getFormat(), FPlayers.i.get(event.getMe()), FPlayers.i.get(event.getYou()))); event.setFormat(this.replacePlayerTags(event.getFormat(), FPlayers.i.get(event.getMe()), FPlayers.i.get(event.getYou())));
} }
@Override @EventHandler(priority = EventPriority.NORMAL)
public void onSelectChannel(CAPISelectChannelEvent event) public void onSelectChannel(CAPISelectChannelEvent event)
{ {
if (event.isCancelled()) return; if (event.isCancelled()) return;