mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-25 19:45:54 +01:00
Add GriefPrevention hook
This commit is contained in:
parent
852a534f4c
commit
d4095fc9f0
@ -323,6 +323,12 @@
|
|||||||
<version>5.0.1</version>
|
<version>5.0.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cnaude.griefprevention</groupId>
|
||||||
|
<artifactId>GriefPrevention</artifactId>
|
||||||
|
<version>11.9</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
7
pom.xml
7
pom.xml
@ -325,6 +325,13 @@
|
|||||||
<version>5.0.1</version>
|
<version>5.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- GriefPrevention -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cnaude.griefprevention</groupId>
|
||||||
|
<artifactId>GriefPrevention</artifactId>
|
||||||
|
<version>11.9</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Testing only -->
|
<!-- Testing only -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.cnaude.purpleirc.GameListeners;
|
package com.cnaude.purpleirc.GameListeners;
|
||||||
|
|
||||||
import com.ammaraskar.adminonly.AdminChat;
|
|
||||||
import com.cnaude.purpleirc.PurpleBot;
|
import com.cnaude.purpleirc.PurpleBot;
|
||||||
import com.cnaude.purpleirc.PurpleIRC;
|
import com.cnaude.purpleirc.PurpleIRC;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1065,6 +1065,9 @@ public final class PurpleBot {
|
|||||||
if (!this.isConnected()) {
|
if (!this.isConnected()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (plugin.isMuted(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (floodChecker.isSpam(player)) {
|
if (floodChecker.isSpam(player)) {
|
||||||
sendFloodWarning(player);
|
sendFloodWarning(player);
|
||||||
return;
|
return;
|
||||||
@ -1686,6 +1689,9 @@ public final class PurpleBot {
|
|||||||
if (!this.isConnected()) {
|
if (!this.isConnected()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (plugin.isMuted(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (floodChecker.isSpam(player)) {
|
if (floodChecker.isSpam(player)) {
|
||||||
sendFloodWarning(player);
|
sendFloodWarning(player);
|
||||||
return;
|
return;
|
||||||
@ -2691,6 +2697,9 @@ public final class PurpleBot {
|
|||||||
public void playerCrossChat(User user, String from, String pName, String msg) {
|
public void playerCrossChat(User user, String from, String pName, String msg) {
|
||||||
if (true) {
|
if (true) {
|
||||||
Player player = plugin.getServer().getPlayer(pName);
|
Player player = plugin.getServer().getPlayer(pName);
|
||||||
|
if (plugin.isMuted(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
plugin.logDebug("Yup, " + pName + " is a valid player...");
|
plugin.logDebug("Yup, " + pName + " is a valid player...");
|
||||||
|
@ -43,6 +43,7 @@ import com.cnaude.purpleirc.Hooks.AdminPrivateChatHook;
|
|||||||
import com.cnaude.purpleirc.Hooks.CommandBookHook;
|
import com.cnaude.purpleirc.Hooks.CommandBookHook;
|
||||||
import com.cnaude.purpleirc.Hooks.DynmapHook;
|
import com.cnaude.purpleirc.Hooks.DynmapHook;
|
||||||
import com.cnaude.purpleirc.Hooks.FactionChatHook;
|
import com.cnaude.purpleirc.Hooks.FactionChatHook;
|
||||||
|
import com.cnaude.purpleirc.Hooks.GriefPreventionHook;
|
||||||
import com.cnaude.purpleirc.Hooks.JobsHook;
|
import com.cnaude.purpleirc.Hooks.JobsHook;
|
||||||
import com.cnaude.purpleirc.Hooks.McMMOChatHook;
|
import com.cnaude.purpleirc.Hooks.McMMOChatHook;
|
||||||
import com.cnaude.purpleirc.Hooks.ReportRTSHook;
|
import com.cnaude.purpleirc.Hooks.ReportRTSHook;
|
||||||
@ -175,6 +176,7 @@ public class PurpleIRC extends JavaPlugin {
|
|||||||
public DynmapHook dynmapHook;
|
public DynmapHook dynmapHook;
|
||||||
public JobsHook jobsHook;
|
public JobsHook jobsHook;
|
||||||
public AdminPrivateChatHook adminPrivateChatHook;
|
public AdminPrivateChatHook adminPrivateChatHook;
|
||||||
|
public GriefPreventionHook griefPreventionHook;
|
||||||
public ShortifyHook shortifyHook;
|
public ShortifyHook shortifyHook;
|
||||||
public ReportRTSHook reportRTSHook;
|
public ReportRTSHook reportRTSHook;
|
||||||
public CommandBookHook commandBookHook;
|
public CommandBookHook commandBookHook;
|
||||||
@ -216,6 +218,7 @@ public class PurpleIRC extends JavaPlugin {
|
|||||||
final String PL_PRISM = "Prism";
|
final String PL_PRISM = "Prism";
|
||||||
final String PL_TITANCHAT = "TitanChat";
|
final String PL_TITANCHAT = "TitanChat";
|
||||||
final String PL_HEROCHAT = "Herochat";
|
final String PL_HEROCHAT = "Herochat";
|
||||||
|
final String PL_GRIEFPREVENTION = "GriefPrevention";
|
||||||
List<String> hookList = new ArrayList<>();
|
List<String> hookList = new ArrayList<>();
|
||||||
public static final String PURPLETAG = "UHVycGxlSVJDCg==";
|
public static final String PURPLETAG = "UHVycGxlSVJDCg==";
|
||||||
public static final String TOWNYTAG = "VG93bnlDaGF0Cg==";
|
public static final String TOWNYTAG = "VG93bnlDaGF0Cg==";
|
||||||
@ -1436,6 +1439,12 @@ public class PurpleIRC extends JavaPlugin {
|
|||||||
} else {
|
} else {
|
||||||
hookList.add(hookFormat(PL_HEROCHAT, false));
|
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)) {
|
if (isPluginEnabled(PL_TITANCHAT)) {
|
||||||
hookList.add(hookFormat(PL_TITANCHAT, true));
|
hookList.add(hookFormat(PL_TITANCHAT, true));
|
||||||
getServer().getPluginManager().registerEvents(new TitanChatListener(this), this);
|
getServer().getPluginManager().registerEvents(new TitanChatListener(this), this);
|
||||||
@ -1635,4 +1644,14 @@ public class PurpleIRC extends JavaPlugin {
|
|||||||
return count;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user