Finally get all the messages on the jail command to come from the
language system. :)
This commit is contained in:
parent
9a9a75dc1e
commit
06aa6629b7
@ -215,6 +215,7 @@ public class JailIO {
|
||||
flat.set(cNode + "prisoner.muted", p.isMuted());
|
||||
flat.set(cNode + "prisoner.time", p.getRemainingTime());
|
||||
flat.set(cNode + "prisoner.offlinePending", p.isOfflinePending());
|
||||
flat.set(cNode + "prisoner.jailer", p.getJailer());
|
||||
flat.set(cNode + "prisoner.reason", p.getReason());
|
||||
flat.set(cNode + "prisoner.inventory", p.getInventory());
|
||||
flat.set(cNode + "prisoner.armor", p.getArmor());
|
||||
@ -232,6 +233,7 @@ public class JailIO {
|
||||
flat.set(pNode + "muted", p.isMuted());
|
||||
flat.set(pNode + "time", p.getRemainingTime());
|
||||
flat.set(pNode + "offlinePending", p.isOfflinePending());
|
||||
flat.set(pNode + "jailer", p.getJailer());
|
||||
flat.set(pNode + "reason", p.getReason());
|
||||
flat.set(pNode + "inventory", p.getInventory());
|
||||
flat.set(pNode + "armor", p.getArmor());
|
||||
@ -314,6 +316,7 @@ public class JailIO {
|
||||
Prisoner p = new Prisoner(flat.getString(cellNode + "prisoner.name"),
|
||||
flat.getBoolean(cellNode + "prisoner.muted"),
|
||||
flat.getLong(cellNode + "prisoner.time"),
|
||||
flat.getString(cellNode + "prisoner.jailer"),
|
||||
flat.getString(cellNode + "prisoner.reason"));
|
||||
p.setOfflinePending(flat.getBoolean(cellNode + "prisoner.offlinePending"));
|
||||
p.setPreviousPosition(flat.getString(cellNode + "prisoner.previousLocation"));
|
||||
@ -333,7 +336,11 @@ public class JailIO {
|
||||
if(!prisoners.isEmpty()) {
|
||||
for(String prisoner : prisoners) {
|
||||
String pNode = node + "prisoners." + prisoner + ".";
|
||||
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 + "jailer"),
|
||||
flat.getString(pNode + "reason"));
|
||||
pris.setOfflinePending(flat.getBoolean(pNode + "offlinePending"));
|
||||
pris.setPreviousPosition(flat.getString(pNode + "previousLocation"));
|
||||
pris.setPreviousGameMode(flat.getString(pNode + "previousGameMode"));
|
||||
|
@ -14,7 +14,7 @@ import org.bukkit.Location;
|
||||
* @version 3.0.0
|
||||
*/
|
||||
public class Prisoner {
|
||||
private String name, reason, inventory, armor;
|
||||
private String name, jailer, reason, inventory, armor;
|
||||
private boolean muted, offlinePending, teleporting;
|
||||
private long time, afk;
|
||||
private Location previousPosition;
|
||||
@ -26,11 +26,14 @@ public class Prisoner {
|
||||
* @param name The name of the prisoner
|
||||
* @param muted Whether the prisoner is muted or not
|
||||
* @param time The amount of remaining time the prisoner has
|
||||
* @param jailer The name of the person who jailed this prisoner
|
||||
* @param reason The reason why this prisoner is in jail
|
||||
*/
|
||||
public Prisoner(String name, boolean muted, long time, String reason) {
|
||||
public Prisoner(String name, boolean muted, long time, String jailer, String reason) {
|
||||
this.name = name;
|
||||
this.muted = muted;
|
||||
this.time = time;
|
||||
this.jailer = jailer;
|
||||
this.reason = reason;
|
||||
this.offlinePending = false;
|
||||
this.teleporting = false;
|
||||
@ -56,6 +59,16 @@ public class Prisoner {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/** Gets the person who jailed this prisoner. */
|
||||
public String getJailer() {
|
||||
return this.jailer;
|
||||
}
|
||||
|
||||
/** Sets the person who jailed this prisoner. */
|
||||
public void setJailer(String jailer) {
|
||||
this.jailer = jailer;
|
||||
}
|
||||
|
||||
/** Gets whether the prisoner is muted or not. */
|
||||
public boolean isMuted() {
|
||||
return this.muted;
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -43,7 +41,7 @@ public class JailCommand implements Command {
|
||||
*/
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
|
||||
if(jm.getJails().size() == 0) {
|
||||
if(jm.getJails().isEmpty()) {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
|
||||
return true;
|
||||
}
|
||||
@ -117,10 +115,16 @@ public class JailCommand implements Command {
|
||||
}
|
||||
}
|
||||
|
||||
//If the jailer gave no reason, then let's get the default reason
|
||||
if(params.reason().isEmpty()) {
|
||||
params.setReason(jm.getPlugin().getJailIO().getLanguageString(LangString.DEFAULTJAILEDREASON));
|
||||
}
|
||||
|
||||
//If the config has automatic muting, then let's set them as muted
|
||||
if(jm.getPlugin().getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath())) {
|
||||
params.setMuted(true);
|
||||
}
|
||||
|
||||
Player p = jm.getPlugin().getServer().getPlayer(params.player());
|
||||
|
||||
//If the player instance is not null and the player has the permission
|
||||
@ -133,10 +137,10 @@ public class JailCommand implements Command {
|
||||
//Get the jail instance from the name of jail in the params.
|
||||
Jail j = jm.getJail(params.jail());
|
||||
Cell c = j.getCell(params.cell());
|
||||
Prisoner pris = new Prisoner(params.player(), params.muted(), time, params.reason());
|
||||
Prisoner pris = new Prisoner(params.player(), params.muted(), time, sender.getName(), params.reason());
|
||||
|
||||
//call the event
|
||||
PrePrisonerJailedEvent event = new PrePrisonerJailedEvent(j, c, pris, p, p == null, sender.getName());
|
||||
PrePrisonerJailedEvent event = new PrePrisonerJailedEvent(j, c, pris, p, p == null, pris.getJailer());
|
||||
jm.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
//check if the event is cancelled
|
||||
@ -154,7 +158,14 @@ public class JailCommand implements Command {
|
||||
c = event.getCell();
|
||||
pris = event.getPrisoner();
|
||||
p = event.getPlayer();
|
||||
String jailer = event.getJailer();
|
||||
|
||||
//Player is not online
|
||||
if(p == null) {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.OFFLINEJAIL, new String[] { pris.getName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
|
||||
}else {
|
||||
//Player *is* online
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ONLINEJAIL, new String[] { pris.getName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
|
||||
}
|
||||
|
||||
try {
|
||||
jm.getPlugin().getPrisonerManager().prepareJail(j, c, p, pris);
|
||||
@ -163,16 +174,6 @@ public class JailCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
//Player is not online
|
||||
if(p == null) {
|
||||
sender.sendMessage(pris.getName() + " is offline and will be jailed for " + pris.getRemainingTime() + " milliseconds in the jail " + params.jail() + " in the cell " + params.cell() + " and will be muted: " + pris.isMuted() + ".");
|
||||
sender.sendMessage(pris.getName() + " will be jailed for " + TimeUnit.MINUTES.convert(pris.getRemainingTime(), TimeUnit.MILLISECONDS) + " minutes by " + jailer + ".");
|
||||
}else {
|
||||
//Player *is* online
|
||||
sender.sendMessage(pris.getName() + " is online and will be jailed for " + pris.getRemainingTime() + " milliseconds in the jail " + params.jail() + " in the cell " + params.cell() + " and will be muted: " + pris.isMuted() + ".");
|
||||
sender.sendMessage(pris.getName() + " will be jailed for " + TimeUnit.MINUTES.convert(pris.getRemainingTime(), TimeUnit.MILLISECONDS) + " minutes by " + jailer + ".");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,10 @@ public enum LangString {
|
||||
NOEMPTYCELLS ("jailing"),
|
||||
/** The message sent when a player is not jailed and the sender is trying to see/do something about it. */
|
||||
NOTJAILED ("jailing"),
|
||||
/** The message sent to the jailer when they jail someone offline. */
|
||||
OFFLINEJAIL ("jailing"),
|
||||
/** The message sent to the jailer when they jail someone who is online. */
|
||||
ONLINEJAIL ("jailing"),
|
||||
/** The message sent to the prisoner when they try to do something but it is protected. */
|
||||
PROTECTIONMESSAGE ("jailing"),
|
||||
/** The message sent to the prisoner when they try to do something and it is protected, but no penalty. */
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.graywolf336.jail.enums;
|
||||
|
||||
public enum Settings {
|
||||
AUTOMATICMUTE("jailing.jail.automaticMute"),
|
||||
BROADCASTJAILING("jailing.jail.broadcastJailing"),
|
||||
BLOCKBREAKPENALTY("jailing.during.blockBreakPenalty"),
|
||||
BLOCKBREAKPROTECTION("jailing.during.blockBreakProtection"),
|
||||
|
@ -31,6 +31,8 @@ language:
|
||||
muted: '&cStop talking, you are in jail.'
|
||||
noemptycells: '&cNo empty cells were found for %0%, all them appear to be full.'
|
||||
notjailed: '&c%0% is not jailed.'
|
||||
offlinejail: '&2%0% is offline and will be jailed when they next come online for %1% minutes.'
|
||||
onlinejail: '&2%0% was jailed for %1% minutes.'
|
||||
protectionmessage: '&c%0% minutes has been added to your time for %1%.'
|
||||
protectionmessagenopenalty: '&cProtection enabled for %0%, do not do it again.'
|
||||
suggestedcell: '&cAn empty cell in the same jail, %0%, was found: %1%'
|
||||
|
Loading…
Reference in New Issue
Block a user