From 506ab26858ebf5b94daf2af351dec7f0e3e78eae Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Tue, 31 Dec 2013 13:25:06 -0600 Subject: [PATCH] Send the unjail message and also execute the commands on releasing --- README.md | 1 + src/main/java/com/graywolf336/jail/PrisonerManager.java | 9 +++++++++ src/main/java/com/graywolf336/jail/enums/Settings.java | 1 + 3 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 0d58750..4e70d4d 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Done * Config value ``jailing.during.maxFoodLevel`` is now used in one part * Config value ``jailing.during.minFoodLevel`` is now used in one part * Config value ``jailing.release.teleport`` is used in unjailing +* Config value ``jailing.release.commands`` is now used [Jail 3.0 JavaDoc](http://ci.graywolf336.com/job/Jail/javadoc) ==== \ No newline at end of file diff --git a/src/main/java/com/graywolf336/jail/PrisonerManager.java b/src/main/java/com/graywolf336/jail/PrisonerManager.java index 5c47a40..a94174c 100644 --- a/src/main/java/com/graywolf336/jail/PrisonerManager.java +++ b/src/main/java/com/graywolf336/jail/PrisonerManager.java @@ -351,5 +351,14 @@ public class PrisonerManager { pl.getJailIO().removePrisoner(jail, prisoner); jail.removePrisoner(prisoner); } + + //Get the commands to execute prisoners are unjailed + //replace all of the %p% so that the commands can have a player name in them + for(String command : pl.getConfig().getStringList(Settings.COMMANDSONRELEASE.getPath())) { + command = command.replaceAll("%p%", player.getName()); + pl.getServer().dispatchCommand(pl.getServer().getConsoleSender(), command); + } + + player.sendMessage(pl.getJailIO().getLanguageString(LangString.UNJAILED)); } } diff --git a/src/main/java/com/graywolf336/jail/enums/Settings.java b/src/main/java/com/graywolf336/jail/enums/Settings.java index 4b3d7d9..5b65d22 100644 --- a/src/main/java/com/graywolf336/jail/enums/Settings.java +++ b/src/main/java/com/graywolf336/jail/enums/Settings.java @@ -3,6 +3,7 @@ package com.graywolf336.jail.enums; public enum Settings { BROADCASTJAILING("jailing.jail.broadcastJailing"), COMMANDSONJAIL("jailing.jail.commands"), + COMMANDSONRELEASE("jailing.release.commands"), DEBUG("system.debug"), DEFAULTJAIL("jailing.jail.defaultJail"), DELETEINVENTORY("jailing.jail.deleteInventory"),