From ac78c941bfaa3ec9d292558a83437e26047f7c55 Mon Sep 17 00:00:00 2001 From: Bradley Hilton Date: Mon, 15 Apr 2019 13:22:38 -0500 Subject: [PATCH] Add an option to disallow jailing offline players. This closes #163 and adds a new configuration option --- .../jail/command/subcommands/JailCommand.java | 5 +++++ src/main/java/com/graywolf336/jail/enums/Lang.java | 2 ++ src/main/java/com/graywolf336/jail/enums/Settings.java | 1 + src/main/resources/config.yml | 9 +++++---- src/main/resources/locales/en.yml | 1 + src/main/resources/plugin.yml | 3 +++ 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/graywolf336/jail/command/subcommands/JailCommand.java b/src/main/java/com/graywolf336/jail/command/subcommands/JailCommand.java index c58b7d1..bcd3279 100644 --- a/src/main/java/com/graywolf336/jail/command/subcommands/JailCommand.java +++ b/src/main/java/com/graywolf336/jail/command/subcommands/JailCommand.java @@ -99,6 +99,11 @@ public class JailCommand implements Command { String uuid = ""; if(p == null) { + if (!jm.getPlugin().getConfig().getBoolean(Settings.ALLOWJAILINGOFFLINEPLAYERS.getPath())) { + sender.sendMessage(Lang.PLAYERHASNEVERPLAYEDBEFORE.get()); + return true; + } + //TODO: Make this whole jail command non-blocking OfflinePlayer of = jm.getPlugin().getServer().getOfflinePlayer(params.getPlayer()); diff --git a/src/main/java/com/graywolf336/jail/enums/Lang.java b/src/main/java/com/graywolf336/jail/enums/Lang.java index 25a94bf..e15dc47 100644 --- a/src/main/java/com/graywolf336/jail/enums/Lang.java +++ b/src/main/java/com/graywolf336/jail/enums/Lang.java @@ -101,6 +101,8 @@ public enum Lang { UNJAILED("jailing"), /** The message sent to the person who released a prisoner from jail. */ UNJAILSUCCESS("jailing"), + /** The message sent when you jailing offline players is not allowed. */ + UNALLOWEDTOJAILOFFLINE("jailing"), /** The message went when an offline player is unjailed. */ WILLBEUNJAILED("jailing"), /** The message sent when trying to jail a player in an unloaded world. */ diff --git a/src/main/java/com/graywolf336/jail/enums/Settings.java b/src/main/java/com/graywolf336/jail/enums/Settings.java index 0a1bc1b..2826e4f 100644 --- a/src/main/java/com/graywolf336/jail/enums/Settings.java +++ b/src/main/java/com/graywolf336/jail/enums/Settings.java @@ -2,6 +2,7 @@ package com.graywolf336.jail.enums; public enum Settings { ALLOWJAILINGNEVERPLAYEDBEFOREPLAYERS("jailing.jail.allowJailingNeverPlayedBeforePlayers"), + ALLOWJAILINGOFFLINEPLAYERS("jailing.jail.allowJaillingOfflinePlayers"), AUTOMATICCELL("jailing.jail.automaticCell"), AUTOMATICMUTE("jailing.jail.automaticMute"), BROADCASTJAILING("jailing.jail.broadcastJailing"), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 08b9d40..0408878 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -20,10 +20,10 @@ jailing: during: blockBreakPenalty: 5m blockBreakProtection: true - blockBreakWhiteList: ['crops', 'carrot', 'potato'] # these blocks can be broken at any time by prisoners + blockBreakWhiteList: ['farmland', 'carrot', 'potato'] # these blocks can be broken at any time by prisoners blockPlacePenalty: 5m blockPlaceProtection: true - blockPlaceWhiteList: ['crops', 'carrot', 'potato'] # these blocks can be placed at any time by prisoners + blockPlaceWhiteList: ['farmland', 'carrot', 'potato'] # these blocks can be placed at any time by prisoners cellsign: - '%player%' - '%prettytime%' @@ -44,17 +44,18 @@ jailing: movePenalty: 10m moveProtection: true openChest: true - preventInteractionBlocks: ['wooden_door', 'iron_door_block'] + preventInteractionBlocks: ['oak_door', 'spruce_door', 'birch_door', 'jungle_door', 'acacia_door', 'dark_oak_door', 'iron_door'] preventInteractionBlocksPenalty: 5m preventInteractionItems: [] preventInteractionItemsPenalty: 5m recieveMessages: true scoreboard: - enabled: false + enabled: true title: 'Jail Info' time: '&aTime:' jail: allowJailingNeverPlayedBeforePlayers: false + allowJaillingOfflinePlayers: true automaticCell: true automaticMute: true broadcastJailing: false diff --git a/src/main/resources/locales/en.yml b/src/main/resources/locales/en.yml index b089a44..a160524 100644 --- a/src/main/resources/locales/en.yml +++ b/src/main/resources/locales/en.yml @@ -84,6 +84,7 @@ language: transfercompletecell: '&2Successfully transferred %0% to %1% in the cell %2%.' transfercompletenocell: '&2Successfully transferred %0% to %1%.' transferred: '&9You have been transferred to %0%.' + unallowedtojailoffline: '&cJailing offline players is not allowed.' unjailed: '&2You have been released! Please respect the server rules.' unjailsuccess: '&2%0% has been released from jail.' willbeunjailed: '&2%0% will be released the next time they log on.' diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 46ad900..1198394 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -6,6 +6,8 @@ authors: [graywolf336] website: dev.bukkit.org/server-mods/jail/ softdepend: [WorldEdit, Vault, Multiverse-Core] load: POSTWORLD +api-version: 1.13 + commands: jail: description: Jail specified player for specified amount of time. @@ -19,6 +21,7 @@ commands: description: Allows the player to handcuff another player unhandcuff: description: Allows the player to unhandcuff someone + permissions: jail.*: children: