Ban management plugin interoperability.
Added config options to use ban commands instead of directly adding to the server's ban list.
This commit is contained in:
parent
709bb55e98
commit
6db3e11ab1
|
|
@ -36,6 +36,8 @@ import me.ryanhamshire.GriefPrevention.DataStore.NoTransferException;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import org.bukkit.Achievement;
|
import org.bukkit.Achievement;
|
||||||
|
import org.bukkit.BanList;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
|
@ -43,6 +45,7 @@ import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.BanList.Type;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
@ -186,6 +189,10 @@ public class GriefPrevention extends JavaPlugin
|
||||||
public boolean config_logs_adminEnabled;
|
public boolean config_logs_adminEnabled;
|
||||||
public boolean config_logs_debugEnabled;
|
public boolean config_logs_debugEnabled;
|
||||||
|
|
||||||
|
//ban management plugin interop settings
|
||||||
|
public boolean config_ban_useCommand;
|
||||||
|
public String config_ban_commandFormat;
|
||||||
|
|
||||||
private String databaseUrl;
|
private String databaseUrl;
|
||||||
private String databaseUserName;
|
private String databaseUserName;
|
||||||
private String databasePassword;
|
private String databasePassword;
|
||||||
|
|
@ -571,6 +578,8 @@ public class GriefPrevention extends JavaPlugin
|
||||||
this.config_creaturesTrampleCrops = config.getBoolean("GriefPrevention.CreaturesTrampleCrops", false);
|
this.config_creaturesTrampleCrops = config.getBoolean("GriefPrevention.CreaturesTrampleCrops", false);
|
||||||
this.config_rabbitsEatCrops = config.getBoolean("GriefPrevention.RabbitsEatCrops", true);
|
this.config_rabbitsEatCrops = config.getBoolean("GriefPrevention.RabbitsEatCrops", true);
|
||||||
this.config_zombiesBreakDoors = config.getBoolean("GriefPrevention.HardModeZombiesBreakDoors", false);
|
this.config_zombiesBreakDoors = config.getBoolean("GriefPrevention.HardModeZombiesBreakDoors", false);
|
||||||
|
this.config_ban_useCommand = config.getBoolean("GriefPrevention.UseBanCommand", false);
|
||||||
|
this.config_ban_commandFormat = config.getString("GriefPrevention.BanCommandPattern", "ban %name% %reason%");
|
||||||
|
|
||||||
this.config_mods_ignoreClaimsAccounts = config.getStringList("GriefPrevention.Mods.PlayersIgnoringAllClaims");
|
this.config_mods_ignoreClaimsAccounts = config.getStringList("GriefPrevention.Mods.PlayersIgnoringAllClaims");
|
||||||
|
|
||||||
|
|
@ -819,6 +828,9 @@ public class GriefPrevention extends JavaPlugin
|
||||||
outConfig.set("GriefPrevention.Database.UserName", this.databaseUserName);
|
outConfig.set("GriefPrevention.Database.UserName", this.databaseUserName);
|
||||||
outConfig.set("GriefPrevention.Database.Password", this.databasePassword);
|
outConfig.set("GriefPrevention.Database.Password", this.databasePassword);
|
||||||
|
|
||||||
|
outConfig.set("GriefPrevention.UseBanCommand", this.config_ban_useCommand);
|
||||||
|
outConfig.set("GriefPrevention.BanCommandPattern", this.config_ban_commandFormat);
|
||||||
|
|
||||||
outConfig.set("GriefPrevention.Mods.BlockIdsRequiringAccessTrust", this.config_mods_accessTrustIds);
|
outConfig.set("GriefPrevention.Mods.BlockIdsRequiringAccessTrust", this.config_mods_accessTrustIds);
|
||||||
outConfig.set("GriefPrevention.Mods.BlockIdsRequiringContainerTrust", this.config_mods_containerTrustIds);
|
outConfig.set("GriefPrevention.Mods.BlockIdsRequiringContainerTrust", this.config_mods_containerTrustIds);
|
||||||
outConfig.set("GriefPrevention.Mods.BlockIdsExplodable", this.config_mods_explodableIds);
|
outConfig.set("GriefPrevention.Mods.BlockIdsExplodable", this.config_mods_explodableIds);
|
||||||
|
|
@ -3066,4 +3078,25 @@ public class GriefPrevention extends JavaPlugin
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void banPlayer(Player player, String reason, String source)
|
||||||
|
{
|
||||||
|
if(GriefPrevention.instance.config_ban_useCommand)
|
||||||
|
{
|
||||||
|
Bukkit.getServer().dispatchCommand(
|
||||||
|
Bukkit.getConsoleSender(),
|
||||||
|
GriefPrevention.instance.config_ban_commandFormat.replace("%name%", player.getName()).replace("%reason%", reason));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BanList bans = Bukkit.getServer().getBanList(Type.NAME);
|
||||||
|
bans.addBan(player.getName(), reason, null, source);
|
||||||
|
|
||||||
|
//kick
|
||||||
|
if(player.isOnline())
|
||||||
|
{
|
||||||
|
player.kickPlayer(reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -830,7 +830,7 @@ class PlayerEventHandler implements Listener
|
||||||
//otherwise if that account is still banned, ban this account, too
|
//otherwise if that account is still banned, ban this account, too
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GriefPrevention.AddLogEntry("Auto-banned " + player.getName() + " because that account is using an IP address very recently used by banned player " + info.bannedAccountName + " (" + info.address.toString() + ").", CustomLogEntryTypes.AdminActivity);
|
GriefPrevention.AddLogEntry("Auto-banned new player " + player.getName() + " because that account is using an IP address very recently used by banned player " + info.bannedAccountName + " (" + info.address.toString() + ").", CustomLogEntryTypes.AdminActivity);
|
||||||
|
|
||||||
//notify any online ops
|
//notify any online ops
|
||||||
Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers();
|
Collection<Player> players = (Collection<Player>)GriefPrevention.instance.getServer().getOnlinePlayers();
|
||||||
|
|
|
||||||
|
|
@ -54,14 +54,7 @@ class PlayerKickBanTask implements Runnable
|
||||||
if(this.ban)
|
if(this.ban)
|
||||||
{
|
{
|
||||||
//ban
|
//ban
|
||||||
BanList bans = Bukkit.getServer().getBanList(Type.NAME);
|
GriefPrevention.banPlayer(this.player, this.reason, this.source);
|
||||||
bans.addBan(this.player.getName(), this.reason, null, source);
|
|
||||||
|
|
||||||
//kick
|
|
||||||
if(this.player.isOnline())
|
|
||||||
{
|
|
||||||
this.player.kickPlayer(this.reason);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(this.player.isOnline())
|
else if(this.player.isOnline())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user