mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-19 16:55:21 +01:00
(Olof) Using latest CAPI for integration
This commit is contained in:
parent
56de98f049
commit
af85f0f503
BIN
lib/MCore.jar
Normal file
BIN
lib/MCore.jar
Normal file
Binary file not shown.
BIN
lib/capi.jar
BIN
lib/capi.jar
Binary file not shown.
@ -1,8 +1,6 @@
|
||||
package com.massivecraft.factions.integration.capi;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.massivecraft.factions.P;
|
||||
@ -11,11 +9,11 @@ public class CapiFeatures
|
||||
{
|
||||
public static void setup()
|
||||
{
|
||||
Plugin plug = Bukkit.getServer().getPluginManager().getPlugin("CAPI");
|
||||
if (plug != null && plug.getClass().getName().equals("com.massivecraft.capi.CAPI"))
|
||||
Plugin plug = Bukkit.getServer().getPluginManager().getPlugin("capi");
|
||||
if (plug != null && plug.getClass().getName().equals("com.massivecraft.capi.P"))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
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.Channels;
|
||||
@ -12,14 +15,13 @@ import com.massivecraft.capi.events.CAPIListChannelsEvent;
|
||||
import com.massivecraft.capi.events.CAPIMessageToChannelEvent;
|
||||
import com.massivecraft.capi.events.CAPIMessageToPlayerEvent;
|
||||
import com.massivecraft.capi.events.CAPISelectChannelEvent;
|
||||
import com.massivecraft.capi.listeners.CapiListener;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
|
||||
public class PluginCapiListener extends CapiListener
|
||||
public class PluginCapiListener implements Listener
|
||||
{
|
||||
P p;
|
||||
|
||||
@ -50,10 +52,10 @@ public class PluginCapiListener extends CapiListener
|
||||
return format;
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onListChannelsEvent(CAPIListChannelsEvent event)
|
||||
{
|
||||
for (Channel c : Channels.i.get())
|
||||
for (Channel c : Channels.i.getAll())
|
||||
{
|
||||
if (myChannelIds.contains(c.getId()))
|
||||
{
|
||||
@ -62,7 +64,7 @@ public class PluginCapiListener extends CapiListener
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onMessageToChannel(CAPIMessageToChannelEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
@ -81,7 +83,7 @@ public class PluginCapiListener extends CapiListener
|
||||
for (Player somePlayer : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -89,14 +91,14 @@ public class PluginCapiListener extends CapiListener
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onMessageToPlayer(CAPIMessageToPlayerEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
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)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
|
Loading…
Reference in New Issue
Block a user