IRCMessageEvent should be cancellable.

This commit is contained in:
cnaude 2017-06-15 20:37:48 -07:00
parent 9510c0b894
commit e765453811
3 changed files with 36 additions and 6 deletions

18
pom.xml
View File

@ -51,8 +51,8 @@
<!-- Vault -->
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
@ -199,6 +199,12 @@
<artifactId>VaultAPI</artifactId>
<version>1.6</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Herochat -->
@ -360,6 +366,12 @@
<groupId>us.dynmap</groupId>
<artifactId>dynmap-api</artifactId>
<version>2.5</version>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Prism -->
@ -460,7 +472,7 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>

View File

@ -17,6 +17,7 @@
package com.cnaude.purpleirc.Events;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@ -25,13 +26,14 @@ import org.bukkit.event.HandlerList;
* @author Chris Naude Event listener for plugins that want to catch irc message
* events from PurpleIRC
*/
public class IRCMessageEvent extends Event {
public class IRCMessageEvent extends Event implements Cancellable{
private static final HandlerList HANDLERS = new HandlerList();
private String message;
private final String channel;
private final String permission;
private final Player player;
private boolean cancelled;
/**
*
@ -117,4 +119,14 @@ public class IRCMessageEvent extends Event {
public void setMessage(String message) {
this.message = message;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
}

View File

@ -1814,11 +1814,17 @@ public class PurpleIRC extends JavaPlugin {
}
public void broadcastToGame(final String message, final String channel, final String permission) {
getServer().getPluginManager().callEvent(new IRCMessageEvent(message, channel, permission));
IRCMessageEvent event = new IRCMessageEvent(message, channel, permission);
if (!event.isCancelled()) {
getServer().getPluginManager().callEvent(event);
}
}
public void broadcastToPlayer(final String message, final String channel, final String permission, final Player player) {
getServer().getPluginManager().callEvent(new IRCMessageEvent(message, channel, permission, player));
IRCMessageEvent event = new IRCMessageEvent(message, channel, permission, player);
if (!event.isCancelled()) {
getServer().getPluginManager().callEvent(event);
}
}
/**