Fix #82, don't jail players haven't played before
There is a configuration node which can be set to true to allow this.
This commit is contained in:
parent
312fe5105b
commit
e598b0c424
@ -6,6 +6,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -81,6 +82,30 @@ public class JailCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p = jm.getPlugin().getServer().getPlayer(params.getPlayer());
|
||||
|
||||
//If the player instance is not null and the player has the permission
|
||||
//'jail.cantbejailed' then don't allow this to happen
|
||||
if(p != null && p.hasPermission("jail.cantbejailed")) {
|
||||
sender.sendMessage(Lang.CANTBEJAILED.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
String uuid = "";
|
||||
if(p == null) {
|
||||
//TODO: Make this whole jail command non-blocking
|
||||
OfflinePlayer of = jm.getPlugin().getServer().getOfflinePlayer(params.getPlayer());
|
||||
|
||||
if(!of.hasPlayedBefore() && !jm.getPlugin().getConfig().getBoolean(Settings.ALLOWJAILINGNEVERPLAYEDBEFOREPLAYERS.getPath())) {
|
||||
sender.sendMessage(Lang.PLAYERHASNEVERPLAYEDBEFORE.get(params.getPlayer()));
|
||||
return true;
|
||||
}else {
|
||||
uuid = of.getUniqueId().toString();
|
||||
}
|
||||
}else {
|
||||
uuid = p.getUniqueId().toString();
|
||||
}
|
||||
|
||||
//Try to parse the time, if they give us nothing in the time parameter then we get the default time
|
||||
//from the config and if that isn't there then we default to thirty minutes.
|
||||
Long time = 10L;
|
||||
@ -190,23 +215,6 @@ public class JailCommand implements Command {
|
||||
muted = true;
|
||||
}
|
||||
|
||||
Player p = jm.getPlugin().getServer().getPlayer(params.getPlayer());
|
||||
|
||||
//If the player instance is not null and the player has the permission
|
||||
//'jail.cantbejailed' then don't allow this to happen
|
||||
if(p != null && p.hasPermission("jail.cantbejailed")) {
|
||||
sender.sendMessage(Lang.CANTBEJAILED.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
String uuid = "";
|
||||
if(p == null) {
|
||||
//TODO: Make this whole jail command non-blocking
|
||||
uuid = jm.getPlugin().getServer().getOfflinePlayer(params.getPlayer()).getUniqueId().toString();
|
||||
}else {
|
||||
uuid = p.getUniqueId().toString();
|
||||
}
|
||||
|
||||
Prisoner pris = new Prisoner(uuid, params.getPlayer(), muted, time, sender.getName(), reason);
|
||||
|
||||
//call the event
|
||||
|
@ -63,6 +63,8 @@ public enum Lang {
|
||||
OFFLINEJAIL("jailing"),
|
||||
/** The message sent to the jailer when they jail someone who is online. */
|
||||
ONLINEJAIL("jailing"),
|
||||
/** The message sent to the jailer when they jail someone who has never played before. */
|
||||
PLAYERHASNEVERPLAYEDBEFORE("jailing"),
|
||||
/** The message sent when finding out how much time a prisoner has. */
|
||||
PRISONERSTIME("jailing"),
|
||||
/** The message sent to the prisoner when they try to do something but it is protected. */
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.graywolf336.jail.enums;
|
||||
|
||||
public enum Settings {
|
||||
ALLOWJAILINGNEVERPLAYEDBEFOREPLAYERS("jailing.jail.allowJailingNeverPlayedBeforePlayers"),
|
||||
AUTOMATICCELL("jailing.jail.automaticCell"),
|
||||
AUTOMATICMUTE("jailing.jail.automaticMute"),
|
||||
BROADCASTJAILING("jailing.jail.broadcastJailing"),
|
||||
|
@ -54,6 +54,7 @@ jailing:
|
||||
title: 'Jail Info'
|
||||
time: '&aTime:'
|
||||
jail:
|
||||
allowJailingNeverPlayedBeforePlayers: false
|
||||
automaticCell: true
|
||||
automaticMute: true
|
||||
broadcastJailing: false
|
||||
|
@ -67,6 +67,7 @@ language:
|
||||
nowunmuted: '&9%0% is now unmuted.'
|
||||
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.'
|
||||
playerhasneverplayedbefore: '&cThe player %0% has never played on the server before.'
|
||||
prisonerstime: '&2%0% has %1% minutes remaining.'
|
||||
protectionmessage: '&c%0% minutes have been added to your time for %1%.'
|
||||
protectionmessagenopenalty: '&cProtection enabled for %0%, do not do it again.'
|
||||
|
@ -123,6 +123,7 @@ public class TestJailDefaultConfig {
|
||||
|
||||
@Test
|
||||
public void testJailingDefaultConfig() {
|
||||
assertFalse("Default setting for allowing jailing offline players is true.", main.getConfig().getBoolean(Settings.ALLOWJAILINGNEVERPLAYEDBEFOREPLAYERS.getPath()));
|
||||
assertTrue("Default setting for automatically jailing in cells is false.", main.getConfig().getBoolean(Settings.AUTOMATICCELL.getPath()));
|
||||
assertTrue("Default setting for automatically muting is false.", main.getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath()));
|
||||
assertFalse("Default setting for broadcasting a jailing is true.", main.getConfig().getBoolean(Settings.BROADCASTJAILING.getPath()));
|
||||
|
Loading…
Reference in New Issue
Block a user