Save their previous GameMode if it is enabled in the config.
Need to update the wiki with the new config option.
This commit is contained in:
parent
6423e8d2e5
commit
aaa286fbdd
@ -21,6 +21,7 @@ Done
|
|||||||
* Config value ``jailing.jail.logToConsole`` is now used
|
* Config value ``jailing.jail.logToConsole`` is now used
|
||||||
* Config value ``jailing.jail.deleteInventory`` is now used
|
* Config value ``jailing.jail.deleteInventory`` is now used
|
||||||
* Config value ``jailing.release.backToPreviousPosition`` is now used
|
* Config value ``jailing.release.backToPreviousPosition`` is now used
|
||||||
|
* Config value ``jailing.release.restorePreviousGameMode`` is now used
|
||||||
|
|
||||||
[Jail 3.0 JavaDoc](http://ci.graywolf336.com/job/Jail/javadoc)
|
[Jail 3.0 JavaDoc](http://ci.graywolf336.com/job/Jail/javadoc)
|
||||||
====
|
====
|
@ -219,6 +219,7 @@ public class JailIO {
|
|||||||
flat.set(cNode + "prisoner.offlinePending", p.isOfflinePending());
|
flat.set(cNode + "prisoner.offlinePending", p.isOfflinePending());
|
||||||
flat.set(cNode + "prisoner.reason", p.getReason());
|
flat.set(cNode + "prisoner.reason", p.getReason());
|
||||||
flat.set(cNode + "prisoner.previousLocation", p.getPreviousLocationString());
|
flat.set(cNode + "prisoner.previousLocation", p.getPreviousLocationString());
|
||||||
|
flat.set(cNode + "prisoner.previousGameMode", p.getPreviousGameMode().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,6 +230,7 @@ public class JailIO {
|
|||||||
flat.set(pNode + "offlinePending", p.isOfflinePending());
|
flat.set(pNode + "offlinePending", p.isOfflinePending());
|
||||||
flat.set(pNode + "reason", p.getReason());
|
flat.set(pNode + "reason", p.getReason());
|
||||||
flat.set(pNode + "previousLocation", p.getPreviousLocationString());
|
flat.set(pNode + "previousLocation", p.getPreviousLocationString());
|
||||||
|
flat.set(pNode + "previousGameMode", p.getPreviousGameMode().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -308,6 +310,7 @@ public class JailIO {
|
|||||||
flat.getString(cellNode + "prisoner.reason"));
|
flat.getString(cellNode + "prisoner.reason"));
|
||||||
p.setOfflinePending(flat.getBoolean(cellNode + "prisoner.offlinePending"));
|
p.setOfflinePending(flat.getBoolean(cellNode + "prisoner.offlinePending"));
|
||||||
p.setPreviousPosition(flat.getString(cellNode + "prisoner.previousLocation"));
|
p.setPreviousPosition(flat.getString(cellNode + "prisoner.previousLocation"));
|
||||||
|
p.setPreviousGameMode(flat.getString(cellNode + "prisoner.previousGameMode"));
|
||||||
c.setPrisoner(p);
|
c.setPrisoner(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,6 +327,7 @@ public class JailIO {
|
|||||||
Prisoner pris = new Prisoner(prisoner, flat.getBoolean(pNode + "muted"), flat.getLong(pNode + "time"), flat.getString(pNode + "reason"));
|
Prisoner pris = new Prisoner(prisoner, flat.getBoolean(pNode + "muted"), flat.getLong(pNode + "time"), flat.getString(pNode + "reason"));
|
||||||
pris.setOfflinePending(flat.getBoolean(pNode + "offlinePending"));
|
pris.setOfflinePending(flat.getBoolean(pNode + "offlinePending"));
|
||||||
pris.setPreviousPosition(flat.getString(pNode + "previousLocation"));
|
pris.setPreviousPosition(flat.getString(pNode + "previousLocation"));
|
||||||
|
pris.setPreviousGameMode(flat.getString(pNode + "previousGameMode"));
|
||||||
j.addPrisoner(pris);
|
j.addPrisoner(pris);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,5 +116,11 @@ public class PrisonerManager {
|
|||||||
if(pl.getConfig().getBoolean(Settings.RELEASETOPREVIOUSPOSITION.getPath(), false)) {
|
if(pl.getConfig().getBoolean(Settings.RELEASETOPREVIOUSPOSITION.getPath(), false)) {
|
||||||
prisoner.setPreviousPosition(player.getLocation());
|
prisoner.setPreviousPosition(player.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If the config has restoring their previous gamemode enabled,
|
||||||
|
//then let's set it in their prisoner data.
|
||||||
|
if(pl.getConfig().getBoolean(Settings.RESTOREPREVIOUSGAMEMODE.getPath(), false)) {
|
||||||
|
prisoner.setPreviousGameMode(player.getGameMode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.graywolf336.jail.beans;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,6 +18,7 @@ public class Prisoner {
|
|||||||
private boolean muted, offlinePending, teleporting;
|
private boolean muted, offlinePending, teleporting;
|
||||||
private long time;
|
private long time;
|
||||||
private Location previousPosition;
|
private Location previousPosition;
|
||||||
|
private GameMode previousGameMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new prisoner with a name and whether they are muted or not.
|
* Creates a new prisoner with a name and whether they are muted or not.
|
||||||
@ -33,6 +35,7 @@ public class Prisoner {
|
|||||||
this.offlinePending = false;
|
this.offlinePending = false;
|
||||||
this.teleporting = false;
|
this.teleporting = false;
|
||||||
this.previousPosition = null;
|
this.previousPosition = null;
|
||||||
|
this.previousGameMode = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the name of this player. */
|
/** Gets the name of this player. */
|
||||||
@ -133,4 +136,21 @@ public class Prisoner {
|
|||||||
Float.valueOf(s[4]),
|
Float.valueOf(s[4]),
|
||||||
Float.valueOf(s[5]));
|
Float.valueOf(s[5]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Gets the previous gamemode of this player. */
|
||||||
|
public GameMode getPreviousGameMode() {
|
||||||
|
return this.previousGameMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sets the previous gamemode of this player. */
|
||||||
|
public void setPreviousGameMode(GameMode previous) {
|
||||||
|
this.previousGameMode = previous;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sets the previous gamemode of this player based upon the provided string. */
|
||||||
|
public void setPreviousGameMode(String previous) {
|
||||||
|
if(previous == null) return;
|
||||||
|
else if(previous.isEmpty()) return;
|
||||||
|
else this.previousGameMode = GameMode.valueOf(previous);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ public enum Settings {
|
|||||||
JAILDEFAULTTIME("jailing.jail.defaultTime"),
|
JAILDEFAULTTIME("jailing.jail.defaultTime"),
|
||||||
LOGJAILING("jailing.jail.logToConsole"),
|
LOGJAILING("jailing.jail.logToConsole"),
|
||||||
RELEASETOPREVIOUSPOSITION("jailing.release.backToPreviousPosition"),
|
RELEASETOPREVIOUSPOSITION("jailing.release.backToPreviousPosition"),
|
||||||
|
RESTOREPREVIOUSGAMEMODE("jailing.release.restorePreviousGameMode"),
|
||||||
UPDATENOTIFICATIONS("system.updateNotifications");
|
UPDATENOTIFICATIONS("system.updateNotifications");
|
||||||
|
|
||||||
private String path;
|
private String path;
|
||||||
|
@ -28,4 +28,5 @@ jailing:
|
|||||||
release:
|
release:
|
||||||
backToPreviousPosition: false
|
backToPreviousPosition: false
|
||||||
commands: []
|
commands: []
|
||||||
|
restorePreviousGameMode: false
|
||||||
teleport: true
|
teleport: true
|
Loading…
Reference in New Issue
Block a user