Add GriefPrevention hook

This commit is contained in:
cnaude 2015-07-30 19:13:04 -07:00
parent 852a534f4c
commit d4095fc9f0
6 changed files with 91 additions and 2 deletions

View File

@ -323,6 +323,12 @@
<version>5.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.cnaude.griefprevention</groupId>
<artifactId>GriefPrevention</artifactId>
<version>11.9</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

@ -325,6 +325,13 @@
<version>5.0.1</version>
</dependency>
<!-- GriefPrevention -->
<dependency>
<groupId>com.cnaude.griefprevention</groupId>
<artifactId>GriefPrevention</artifactId>
<version>11.9</version>
</dependency>
<!-- Testing only -->
<dependency>
<groupId>junit</groupId>

View File

@ -16,7 +16,6 @@
*/
package com.cnaude.purpleirc.GameListeners;
import com.ammaraskar.adminonly.AdminChat;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;

View File

@ -0,0 +1,49 @@
/*
* Copyright (C) 2014 cnaude
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;
import com.cnaude.purpleirc.PurpleIRC;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import org.bukkit.entity.Player;
/**
*
* @author cnaude
*/
public class GriefPreventionHook {
private final PurpleIRC plugin;
public final GriefPrevention gp;
/**
*
* @param plugin
*/
public GriefPreventionHook(PurpleIRC plugin) {
this.plugin = plugin;
this.gp = (GriefPrevention) plugin.getServer().getPluginManager().getPlugin("GriefPrevention");
}
public boolean isMuted(Player player) {
plugin.logDebug("GriefPrevention: " + player.getDisplayName());
if (gp != null) {
return gp.dataStore.isSoftMuted(player.getUniqueId());
}
return false;
}
}

View File

@ -1065,6 +1065,9 @@ public final class PurpleBot {
if (!this.isConnected()) {
return;
}
if (plugin.isMuted(player)) {
return;
}
if (floodChecker.isSpam(player)) {
sendFloodWarning(player);
return;
@ -1686,6 +1689,9 @@ public final class PurpleBot {
if (!this.isConnected()) {
return;
}
if (plugin.isMuted(player)) {
return;
}
if (floodChecker.isSpam(player)) {
sendFloodWarning(player);
return;
@ -2691,6 +2697,9 @@ public final class PurpleBot {
public void playerCrossChat(User user, String from, String pName, String msg) {
if (true) {
Player player = plugin.getServer().getPlayer(pName);
if (plugin.isMuted(player)) {
return;
}
if (player != null) {
if (player.isOnline()) {
plugin.logDebug("Yup, " + pName + " is a valid player...");

View File

@ -43,6 +43,7 @@ import com.cnaude.purpleirc.Hooks.AdminPrivateChatHook;
import com.cnaude.purpleirc.Hooks.CommandBookHook;
import com.cnaude.purpleirc.Hooks.DynmapHook;
import com.cnaude.purpleirc.Hooks.FactionChatHook;
import com.cnaude.purpleirc.Hooks.GriefPreventionHook;
import com.cnaude.purpleirc.Hooks.JobsHook;
import com.cnaude.purpleirc.Hooks.McMMOChatHook;
import com.cnaude.purpleirc.Hooks.ReportRTSHook;
@ -175,6 +176,7 @@ public class PurpleIRC extends JavaPlugin {
public DynmapHook dynmapHook;
public JobsHook jobsHook;
public AdminPrivateChatHook adminPrivateChatHook;
public GriefPreventionHook griefPreventionHook;
public ShortifyHook shortifyHook;
public ReportRTSHook reportRTSHook;
public CommandBookHook commandBookHook;
@ -216,6 +218,7 @@ public class PurpleIRC extends JavaPlugin {
final String PL_PRISM = "Prism";
final String PL_TITANCHAT = "TitanChat";
final String PL_HEROCHAT = "Herochat";
final String PL_GRIEFPREVENTION = "GriefPrevention";
List<String> hookList = new ArrayList<>();
public static final String PURPLETAG = "UHVycGxlSVJDCg==";
public static final String TOWNYTAG = "VG93bnlDaGF0Cg==";
@ -1436,6 +1439,12 @@ public class PurpleIRC extends JavaPlugin {
} else {
hookList.add(hookFormat(PL_HEROCHAT, false));
}
if (isPluginEnabled(PL_GRIEFPREVENTION)) {
hookList.add(hookFormat(PL_GRIEFPREVENTION, true));
griefPreventionHook = new GriefPreventionHook(this);
} else {
hookList.add(hookFormat(PL_GRIEFPREVENTION, false));
}
if (isPluginEnabled(PL_TITANCHAT)) {
hookList.add(hookFormat(PL_TITANCHAT, true));
getServer().getPluginManager().registerEvents(new TitanChatListener(this), this);
@ -1635,4 +1644,14 @@ public class PurpleIRC extends JavaPlugin {
return count;
}
public boolean isMuted(Player player) {
if (griefPreventionHook != null) {
if (griefPreventionHook.isMuted(player)) {
logDebug("GP: Player " + player.getDisplayName() + " is muted.");
return true;
}
}
return false;
}
}