From c35b3b04f0c26ab4ab5abddf88205c65af37561e Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Wed, 25 Dec 2013 23:20:52 -0600 Subject: [PATCH] Add a config value to set their gamemode to. Also, eject them. --- README.md | 1 + .../java/com/graywolf336/jail/PrisonerManager.java | 11 +++++++++++ .../java/com/graywolf336/jail/enums/Settings.java | 1 + src/main/resources/config.yml | 1 + 4 files changed, 14 insertions(+) diff --git a/README.md b/README.md index f1ddad2..6de629a 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Done * Config value ``jailing.jail.deleteInventory`` is now used * Config value ``jailing.release.backToPreviousPosition`` is now used * Config value ``jailing.release.restorePreviousGameMode`` is now used +* Config value ``jailing.jail.gameMode`` 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 f540b14..d1d0520 100644 --- a/src/main/java/com/graywolf336/jail/PrisonerManager.java +++ b/src/main/java/com/graywolf336/jail/PrisonerManager.java @@ -1,5 +1,6 @@ package com.graywolf336.jail; +import org.bukkit.GameMode; import org.bukkit.entity.Player; import com.graywolf336.jail.beans.Cell; @@ -122,5 +123,15 @@ public class PrisonerManager { if(pl.getConfig().getBoolean(Settings.RESTOREPREVIOUSGAMEMODE.getPath(), false)) { prisoner.setPreviousGameMode(player.getGameMode()); } + + //Set their gamemode to the one in the config, if we get a null value + //from the parsing then we set theirs to adventure + player.setGameMode(GameMode.valueOf(pl.getConfig().getString(Settings.JAILEDGAMEMODE.getPath(), "ADVENTURE"))); + + //only eject them if they're inside a vehicle and also eject anyone else on top of them + if(player.isInsideVehicle()) { + player.eject(); + player.getVehicle().eject(); + } } } diff --git a/src/main/java/com/graywolf336/jail/enums/Settings.java b/src/main/java/com/graywolf336/jail/enums/Settings.java index ff8091b..9c66f4f 100644 --- a/src/main/java/com/graywolf336/jail/enums/Settings.java +++ b/src/main/java/com/graywolf336/jail/enums/Settings.java @@ -6,6 +6,7 @@ public enum Settings { DEFAULTJAIL("jailing.jail.defaultJail"), DELETEINVENTORY("jailing.jail.deleteInventory"), JAILDEFAULTTIME("jailing.jail.defaultTime"), + JAILEDGAMEMODE("jailing.jail.gameMode"), LOGJAILING("jailing.jail.logToConsole"), RELEASETOPREVIOUSPOSITION("jailing.release.backToPreviousPosition"), RESTOREPREVIOUSGAMEMODE("jailing.release.restorePreviousGameMode"), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index dc48f71..1f541d4 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -22,6 +22,7 @@ jailing: defaultJail: nearest #the jail nearest to the player defaultTime: 30m #default the time to 30 minutes, if no time deleteInventory: false + gameMode: adventure logToConsole: true logToProfile: false storeInventory: true