Add config option for world blacklist

This commit is contained in:
GeorgH93 2018-04-02 18:27:27 +02:00
parent dab0fd95fd
commit 8a91a3539e
6 changed files with 68 additions and 6 deletions

View File

@ -17,7 +17,9 @@ BackpackTitle: "&bBackpack"
# Defines if the content of the backpack get dropped on the death of a player.
# If enabled, it can be disabled for individual players with the "backpack.KeepOnDeath" permission.
DropOnDeath: true
# Defines the max amount of columns for a backpack
# Defines the max amount of columns for a backpack.
# The size of the user's backpack will be defined by the permission, permissions for bigger backpacks than this value will be ignored.
# Can be set to anything > 0. Backpacks with more than 6 columns will have a broken UI! Sizes bigger than 9 may not work with all permission plugins.
MaxSize: 6
# Defines in which game-modes a player can access his backpack (name or id)
# Options: ADVENTURE, CREATIVE, SPECTATOR, SURVIVAL
@ -127,6 +129,19 @@ ItemFilter:
# List off items not allowed in the backpack. Can be name or id.
Blacklist: []
# This settings allow control over how the plugin behave in different worlds
WorldSettings:
# All worlds listed here will not have the plugin usable
# Blacklist: ["creative_world"]
# Blacklist: ["creative_world1", "creative_world2"]
Blacklist: []
# Defines how the Blacklist will be enforced
# Options:
# Message = The player will see an message that the usage of the backpack is denied in this world.
# MissingPermission = The player will receive the plugins no permission message.
# NoPlugin = The plugin will not be available at all and act as if it was not installed. This also exclude players with permission to bypass the world restriction from using it!
BlacklistMode: "Message"
Misc:
# Enables/Disables the auto-update function of the plugin.
AutoUpdate: true

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2017 GeorgH93
* Copyright (C) 2016-2018 GeorgH93
*
* 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
@ -19,7 +19,9 @@
import at.pcgamingfreaks.Bukkit.Configuration;
import at.pcgamingfreaks.Bukkit.MinecraftMaterial;
import at.pcgamingfreaks.ConsoleColor;
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper.OldFileUpdater;
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper.WorldBlacklistMode;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@ -280,7 +282,7 @@ public boolean isItemFilterEnabled()
public Collection<MinecraftMaterial> getItemFilterBlacklist()
{
List<String> stringBlacklist = config.getStringList("ItemFilter.Blacklist", new LinkedList<String>());
List<String> stringBlacklist = config.getStringList("ItemFilter.Blacklist", new LinkedList<>());
Collection<MinecraftMaterial> blacklist = new LinkedList<>();
for(String item : stringBlacklist)
{
@ -290,5 +292,27 @@ public Collection<MinecraftMaterial> getItemFilterBlacklist()
return blacklist;
}
//endregion
//region World settings
public Collection<String> getWorldBlacklist()
{
return new HashSet<>(config.getStringList("WorldSettings.Blacklist", new LinkedList<>()));
}
public WorldBlacklistMode getWorldBlacklistMode()
{
String mode = config.getString("WorldSettings.BlacklistMode", "Message");
WorldBlacklistMode blacklistMode = WorldBlacklistMode.Message;
try
{
blacklistMode = WorldBlacklistMode.valueOf(mode);
}
catch(IllegalArgumentException ignored)
{
logger.warning(ConsoleColor.YELLOW + "Unsupported mode \"" + mode + "\" for option \"WorldSettings.BlacklistMode\"" + ConsoleColor.RESET);
}
return blacklistMode;
}
//endregion
//endregion
}

View File

@ -0,0 +1,23 @@
/*
* Copyright (C) 2018 GeorgH93
*
* 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 at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper;
public enum WorldBlacklistMode
{
Message, MissingPermission, NoPlugin
}

View File

@ -37,7 +37,7 @@ public InventorySerializer()
String[] version = name.substring(name.lastIndexOf('.') + 2).split("_");
try
{
if(version[0].equals("1") && Integer.parseInt(version[1]) > 7)
if(NBTItemStackSerializer.isMCVersionCompatible())
{
serializer = new NBTItemStackSerializer();
}

View File

@ -213,7 +213,7 @@ protected final void buildQuerys()
queryGetBP += "{FieldName}=?;";
querySyncCooldown = "INSERT INTO {TableCooldowns} ({FieldCDPlayer},{FieldCDTime}) SELECT {FieldPlayerID},? FROM {TablePlayers} WHERE {FieldName}=?;";
}
queryInsertBp = "INSERT INTO {TableBackpacks} ({FieldBPOwner},{FieldBPITS},{FieldBPVersion}) VALUES (?,?,?);";
queryInsertBp = "REPLACE INTO {TableBackpacks} ({FieldBPOwner},{FieldBPITS},{FieldBPVersion}) VALUES (?,?,?);";
queryUpdateBp = "UPDATE {TableBackpacks} SET {FieldBPITS}=?,{FieldBPVersion}=?,{FieldBPLastUpdate}={NOW} WHERE {FieldBPOwner}=?;";
queryDeleteOldBackpacks = "DELETE FROM {TableBackpacks} WHERE {FieldBPLastUpdate} < DATE('now', '-{VarMaxAge} days')";
if(useUUIDSeparators)

View File

@ -89,7 +89,7 @@ protected void updateQuerysForDialect()
queryInsertBp = queryInsertBp.replaceAll("\\) VALUES \\(\\?,\\?,\\?", "{FieldBPLastUpdate}) VALUES (?,?,?,DATE('now')");
}
queryDeleteOldBackpacks = "DELETE FROM {TableBackpacks} WHERE {FieldBPLastUpdate} < DATE('now', '-{VarMaxAge} days')";
queryUpdateBp = queryUpdateBp.replaceAll("\\{NOW\\}", "DATE('now')");
queryUpdateBp = queryUpdateBp.replaceAll("\\{NOW}", "DATE('now')");
if(useUUIDs)
{
queryUpdatePlayerAdd = "INSERT OR IGNORE INTO {TablePlayers} ({FieldName},{FieldUUID}) VALUES (?,?);";