Implement Jail Pay, this closes #11

This commit is contained in:
graywolf336 2014-03-20 15:33:42 -05:00
parent 126c1576c4
commit 4ade1bcf38
13 changed files with 514 additions and 20 deletions

View File

@ -9,6 +9,7 @@ Beta 2 Changes
*Changes since Beta 1*
* Fix the default Jail Stick not being loaded correctly, [#21](https://github.com/graywolf336/Jail/issues/21)
* Implement Scoreboards, with title and time configurable. ([#15](https://github.com/graywolf336/Jail/issues/15))
* Implemented Jail Pay [#11](https://github.com/graywolf336/Jail/issues/11)
* Convert old data and config values, only some are done and if you don't want the old data delete your `global.yml`
* Add config option to disallow the usage of Jail Sticks
@ -47,6 +48,7 @@ ToDo
Notice
===
* If you ran an alpha or beta, please delete the en.yml so that you get the additional messages added since your version (will update in the future)
* Old messages (language) will not be converted
* MaximumAFKTime setting will not convert over, the format isn't clear and the old version didn't provide a way to get values with decimal places
* EnableLogging has been removed, we are always going to be logging (unless major request to control this)

View File

@ -32,6 +32,7 @@ public class JailMain extends JavaPlugin {
private JailHandler jh;
private JailIO io;
private JailManager jm;
private JailPayManager jpm;
private JailStickManager jsm;
private JailTimer jt;
private PrisonerManager pm;
@ -90,6 +91,14 @@ public class JailMain extends JavaPlugin {
}
jt = new JailTimer(this);
try {
jpm = new JailPayManager(this);
} catch (Exception e) {
getLogger().severe(e.getMessage());
jpm = null;
}
sbm = new ScoreBoardManager(this);
getLogger().info("Completed enablement.");
@ -109,6 +118,7 @@ public class JailMain extends JavaPlugin {
jt = null;
sbm = null;
jpm = null;
cmdHand = null;
pm = null;
jm = null;
@ -163,7 +173,7 @@ public class JailMain extends JavaPlugin {
for(Jail j : jm.getJails()) {
for(Prisoner p : j.getAllPrisoners()) {
if(getServer().getPlayerExact(p.getName()) != null) {
this.sbm.addScoreBoard(getServer().getPlayerExact(p.getName()), j, p);
this.sbm.addScoreBoard(getServer().getPlayerExact(p.getName()), p);
}
}
}
@ -177,6 +187,16 @@ public class JailMain extends JavaPlugin {
this.jsm = new JailStickManager(this);
}
/**
* Reloads the {@link JailPayManager}.
*
* @throws Exception If we couldn't successfully create a new Jail Pay Manager instance.
*/
public void reloadJailPayManager() throws Exception {
this.jpm = null;
this.jpm = new JailPayManager(this);
}
/** Gets the {@link HandCuffManager} instance. */
public HandCuffManager getHandCuffManager() {
return this.hcm;
@ -192,6 +212,11 @@ public class JailMain extends JavaPlugin {
return this.jm;
}
/** Gets the {@link JailPayManager} instance. */
public JailPayManager getJailPayManager() {
return this.jpm;
}
/** Gets the {@link PrisonerManager} instance. */
public PrisonerManager getPrisonerManager() {
return this.pm;

View File

@ -0,0 +1,173 @@
package com.graywolf336.jail;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.RegisteredServiceProvider;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.enums.Settings;
public class JailPayManager {
private Economy economy = null;
private double minteCost, infiniteCost;
private Material item;
private boolean infinite, timed;
public JailPayManager(JailMain plugin) throws Exception {
this.item = Material.getMaterial(plugin.getConfig().getString(Settings.JAILPAYITEM.getPath().toUpperCase()));
if(this.item == null) this.item = Material.AIR;
this.minteCost = plugin.getConfig().getDouble(Settings.JAILPAYPRICEPERMINUTE.getPath());
if(!this.usingItemsForPayment()) {
if(!this.setupEconomy(plugin)) {
plugin.getConfig().set(Settings.JAILPAYENABLED.getPath(), false);
throw new Exception("Jail Pay couldn't find an economy, disabling Jail Pay.");
}
}
this.timed = plugin.getConfig().getDouble(Settings.JAILPAYPRICEPERMINUTE.getPath()) != 0;
this.infinite = plugin.getConfig().getDouble(Settings.JAILPAYPRICEINFINITE.getPath()) != 0;
}
/** Checks if paying for infinite is enabled. */
public boolean isInfiniteEnabled() {
return this.infinite;
}
/** Checks if paying for timed is enabled. */
public boolean isTimedEnabled() {
return this.timed;
}
/** Gets how much it cost per minute in string format. */
public String getCostPerMinute() {
return String.valueOf(this.minteCost);
}
/**
* Calculates how much players have to pay to get completely free.
*
* @param prisoner data of who we're calculating
* @return The economy cost the prisoner will need to pay to get completely free.
*/
public double calculateBill(Prisoner prisoner) {
return prisoner.getRemainingTime() > 0 ? prisoner.getRemainingTimeInMinutes() * this.minteCost : infiniteCost;
}
/** Gets how many minutes someone is paying for (rounds to the lowest number). */
public long getMinutesPayingFor(double amount) {
return (long) Math.floor(amount / this.minteCost);
}
/** Returns if we are using items for payment instead of economy. */
public boolean usingItemsForPayment() {
return this.item != Material.AIR;
}
/**
* Gets the {@link Material} it costs for jail pay, will be air if using economy.
*
* @return The item type it costs, air if using virtual economy.
*/
public Material getItemItCost() {
return this.item;
}
/**
* Checks if the player has enough money/items to pay what they have said they want to.
*
* @param p The player who is doing the paying.
* @param amt The amount to check they if they have.
* @return true if they have enough, false if not.
*/
public boolean hasEnoughToPay(Player p, double amt) {
if(this.usingItemsForPayment()) {
return p.getInventory().contains(this.item, (int) Math.ceil(amt));
}else {
return this.economy.has(p.getName(), amt);
}
}
/**
* Pays the required fees from the given player, removing items or money from economy.
*
* @param p The player who is paying.
* @param amt The amount of items or money to withdraw from the player.
*/
public void pay(Player p, double amt) {
if(this.usingItemsForPayment()) {
int amtNeeded = (int) Math.ceil(amt);
for (int i = 0; i < p.getInventory().getSize(); i++) {
ItemStack it = p.getInventory().getItem(i);
//The item is either air or we doesn't match out needs
if(it == null || it.getType() != this.item) continue;
//If the itemstack has more than or equal to the amount
//that we need, remove it and subject from the amt needed
if (amtNeeded >= it.getAmount()) {
amtNeeded -= it.getAmount();
p.getInventory().clear(i);
} else {
//Otherwise, subject from the itemstack just the amount we need
it.setAmount(it.getAmount() - amtNeeded);
p.getInventory().setItem(i, it);
amtNeeded = 0;
}
if (amtNeeded == 0) break;
}
}else {
this.economy.withdrawPlayer(p.getName(), amt);
}
}
/** Gets the name of the item in nice capitals. */
public String getCurrencyName(){
if(this.usingItemsForPayment()) {
String name = item.toString().replaceAll("_", " ");
if(name.contains(" ")){
String[] split = name.split(" ");
for(int i=0; i < split.length; i++){
split[i] = split[i].substring(0, 1).toUpperCase() + split[i].substring(1).toLowerCase();
}
name = "";
for(String s : split){
name += " " + s;
}
name = name.substring(1);
} else {
name = name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
}
return name;
}else {
return this.economy.currencyNamePlural();
}
}
/** Returns the economy provider to do transaction with. */
public Economy getEconomy() {
return this.economy;
}
private boolean setupEconomy(JailMain plugin) {
if (economy != null) return true;
RegisteredServiceProvider<Economy> economyProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
economy = economyProvider.getProvider();
}
return (economy != null);
}
}

View File

@ -269,7 +269,7 @@ public class PrisonerManager {
//Add the scoreboard to them if it is enabled
if(pl.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
pl.getScoreBoardManager().addScoreBoard(player, jail, prisoner);
pl.getScoreBoardManager().addScoreBoard(player, prisoner);
}
//Call our custom event for when a prisoner is actually jailed.
@ -296,6 +296,10 @@ public class PrisonerManager {
try {
unJail(j, j.getCellPrisonerIsIn(player.getName()), player, prisoner);
}catch(Exception e) {
if(pl.inDebug()) {
e.printStackTrace();
}
pl.getLogger().severe("Unable to unjail the prisoner " + player.getName() + " because '" + e.getMessage() + "'.");
}
@ -343,12 +347,17 @@ public class PrisonerManager {
//let's enable their sleeping state taking place again
player.setSleepingIgnored(false);
//If the config has us teleporting them back to their previous position
//then let's do that, but if it doesn't yet it has the teleport on release
//then let's teleport them to the free teleport location
//If the config has us teleporting them back to their
//previous position then let's do that
boolean tpd = false;
if(pl.getConfig().getBoolean(Settings.RELEASETOPREVIOUSPOSITION.getPath(), false)) {
player.teleport(prisoner.getPreviousLocation());
}else if(pl.getConfig().getBoolean(Settings.TELEPORTONRELEASE.getPath(), true)) {
if(prisoner.getPreviousLocation() != null)
tpd = player.teleport(prisoner.getPreviousLocation());
}
//If they haven't already been teleported and the config has us to teleport on release,
//then we teleport players to the jail's free spot
if(!tpd && pl.getConfig().getBoolean(Settings.TELEPORTONRELEASE.getPath(), true)) {
player.teleport(jail.getTeleportFree());
}

View File

@ -2,7 +2,6 @@ package com.graywolf336.jail;
import java.util.HashMap;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
@ -42,12 +41,12 @@ public class ScoreBoardManager {
* @param player of whom to add the scoreboard to.
* @param pris data for the provided prisoner
*/
public void addScoreBoard(Player player, Jail j, Prisoner pris) {
public void addScoreBoard(Player player, Prisoner pris) {
if(!boards.containsKey(player.getName())) {
boards.put(player.getName(), man.getNewScoreboard());
Objective o = boards.get(player.getName()).registerNewObjective("test", "dummy");
o.setDisplaySlot(DisplaySlot.SIDEBAR);
o.setDisplayName(Util.getColorfulMessage(pl.getConfig().getString(Settings.SCOREBOARDTITLE.getPath()) + ChatColor.WHITE + "" + ChatColor.ITALIC + " (" + j.getName() + ")"));
o.setDisplayName(Util.getColorfulMessage(pl.getConfig().getString(Settings.SCOREBOARDTITLE.getPath())));
o.getScore(time).setScore(pris.getRemainingTimeInMinutesInt());
player.setScoreboard(boards.get(player.getName()));
}else {
@ -86,7 +85,7 @@ public class ScoreBoardManager {
for(Jail j : pl.getJailManager().getJails()) {
for(Prisoner p : j.getAllPrisoners()) {
if(pl.getServer().getPlayerExact(p.getName()) != null) {
addScoreBoard(pl.getServer().getPlayerExact(p.getName()), j, p);
addScoreBoard(pl.getServer().getPlayerExact(p.getName()), p);
}
}
}

View File

@ -23,6 +23,7 @@ import com.graywolf336.jail.command.subcommands.JailDeleteCommand;
import com.graywolf336.jail.command.subcommands.JailListCellsCommand;
import com.graywolf336.jail.command.subcommands.JailListCommand;
import com.graywolf336.jail.command.subcommands.JailMuteCommand;
import com.graywolf336.jail.command.subcommands.JailPayCommand;
import com.graywolf336.jail.command.subcommands.JailRecordCommand;
import com.graywolf336.jail.command.subcommands.JailReloadCommand;
import com.graywolf336.jail.command.subcommands.JailStatusCommand;
@ -136,7 +137,10 @@ public class JailHandler {
return true;
}
} catch (Exception e) {
e.printStackTrace();
if(jailmanager.getPlugin().inDebug()) {
e.printStackTrace();
}
jailmanager.getPlugin().getLogger().severe("An error occured while handling the command: " + i.usage());
showUsage(sender, c);
return true;
@ -182,6 +186,7 @@ public class JailHandler {
load(JailListCellsCommand.class);
load(JailListCommand.class);
load(JailMuteCommand.class);
load(JailPayCommand.class);
load(JailRecordCommand.class);
load(JailReloadCommand.class);
load(JailStatusCommand.class);

View File

@ -0,0 +1,229 @@
package com.graywolf336.jail.command.subcommands;
import java.util.concurrent.TimeUnit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.JailPayManager;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Settings;
@CommandInfo(
maxArgs = 2,
minimumArgs = 0,
needsPlayer = true,
pattern = "pay",
permission = "jail.usercmd.jailpay",
usage = "/jail pay <amount> <player>"
)
public class JailPayCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
if(jm.getPlugin().getConfig().getBoolean(Settings.JAILPAYENABLED.getPath())) {
JailPayManager pm = jm.getPlugin().getJailPayManager();
switch(args.length) {
case 1:
// `/jail pay`
//send how much it costs to get out
if(jm.isPlayerJailed(sender.getName())) {
Prisoner p = jm.getPrisoner(sender.getName());
String amt = "";
if(pm.usingItemsForPayment()) {
amt = String.valueOf((int) Math.ceil(pm.calculateBill(p)));
}else {
amt = String.valueOf(pm.calculateBill(p));
}
if(p.getRemainingTime() > 0) {
if(pm.isTimedEnabled()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYCOST, new String[] { pm.getCostPerMinute(), pm.getCurrencyName(), amt }));
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
jm.getPlugin().debug("Jail pay 'timed' paying is not enabled (config has 0 as the cost).");
}
}else {
if(pm.isInfiniteEnabled()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYCOST, new String[] { amt, pm.getCurrencyName() }));
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
jm.getPlugin().debug("Jail pay 'infinite' paying is not enabled (config has 0 as the cost).");
}
}
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.YOUARENOTJAILED));
}
break;
case 2:
// `/jail pay <amount>`
//They are trying to pay for their self
if(jm.isPlayerJailed(sender.getName())) {
Prisoner p = jm.getPrisoner(sender.getName());
if(p.getRemainingTime() > 0) {
if(!pm.isTimedEnabled()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
return true;
}
}else {
if(!pm.isInfiniteEnabled()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
return true;
}
}
if(args[1].startsWith("-")) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNONEGATIVEAMOUNTS));
}else {
double amt = 0;
try {
amt = Double.parseDouble(args[1]);
}catch(NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "<amount> must be a number.");
throw e;
}
if(pm.hasEnoughToPay((Player) sender, amt)) {
double bill = pm.calculateBill(p);
if(p.getRemainingTime() > 0) {
//timed sentence
if(amt >= bill) {
pm.pay((Player) sender, bill);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASED, String.valueOf(bill)));
jm.getPlugin().getPrisonerManager().releasePrisoner((Player) sender, p);
}else {
long minutes = pm.getMinutesPayingFor(amt);
pm.pay((Player) sender, amt);
long remain = p.subtractTime(TimeUnit.MILLISECONDS.convert(minutes, TimeUnit.MINUTES));
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDLOWEREDTIME,
new String[] { String.valueOf(amt), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS)) }));
}
}else {
//infinite jailing
if(amt >= bill) {
pm.pay((Player) sender, bill);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASED, String.valueOf(bill)));
jm.getPlugin().getPrisonerManager().releasePrisoner((Player) sender, p);
}else {
//You haven't provided enough money to get them out
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENOUGHMONEYPROVIDED));
}
}
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENOUGHMONEY));
}
}
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.YOUARENOTJAILED));
}
break;
case 3:
// `/jail pay <amount> <person>
//they are trying to pay for someone else
if(jm.isPlayerJailed(sender.getName())) {
//When they are jailed they can not pay for someone else
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYCANTPAYWHILEJAILED));
}else {
if(jm.isPlayerJailed(args[2])) {
Prisoner p = jm.getPrisoner(args[2]);
if(p.getRemainingTime() > 0) {
if(!pm.isTimedEnabled()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
return true;
}
}else {
if(!pm.isInfiniteEnabled()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
return true;
}
}
if(args[1].startsWith("-")) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNONEGATIVEAMOUNTS));
}else {
double amt = 0;
try {
amt = Double.parseDouble(args[1]);
}catch(NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "<amount> must be a number.");
throw e;
}
if(pm.hasEnoughToPay((Player) sender, amt)) {
double bill = pm.calculateBill(p);
if(p.getRemainingTime() > 0) {
//timed sentence
if(amt >= bill) {
pm.pay((Player) sender, bill);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getName() }));
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayerExact(p.getName()), p);
}else {
long minutes = pm.getMinutesPayingFor(amt);
pm.pay((Player) sender, amt);
long remain = p.subtractTime(TimeUnit.MILLISECONDS.convert(minutes, TimeUnit.MINUTES));
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDLOWEREDTIMEELSE,
new String[] { String.valueOf(amt), p.getName(), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS)) }));
}
}else {
//infinite jailing
if(amt >= bill) {
pm.pay((Player) sender, bill);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getName() }));
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayerExact(p.getName()), p);
}else {
//You haven't provided enough money to get them out
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENOUGHMONEYPROVIDED));
}
}
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENOUGHMONEY));
}
}
}else {
//Person they're trying to pay for is not jailed
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[2]));
}
}
break;
default:
return false;
}
}else {
jm.getPlugin().debug("Jail pay not enabled.");
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
}
return true;
}
}
/*
*
Messages:
MessageJailPayAmountForever: To get out of this mess, you will have to pay <Amount>.
JailPayCannotPay: Sorry, money won't help you this time.
JailPayCannotPayHim: Sorry, money won't help him this time.
JailPayNotEnoughMoney: You don't have that much money!
JailPayCost: 1 minute of your sentence will cost you <MinutePrice>. That means that cost for releasing you out of the jail is <WholePrice>.
JailPayPaidReleased: You have just payed <Amount> and saved yourself from the jail!
JailPayPaidReleasedHim: You have just payed <Amount> and saved <Prisoner> from the jail!
JailPayLoweredTime: You have just payed <Amount> and lowered your sentence to <NewTime> minutes!
JailPayLoweredTimeHim: You have just payed <Amount> and lowered <Prisoner>'s sentence to <NewTime> minutes!
JailPay:
PricePerMinute: 10
PriceForInfiniteJail: 9999
Currency: 0
*/

View File

@ -1,5 +1,6 @@
package com.graywolf336.jail.command.subcommands;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import com.graywolf336.jail.JailManager;
@ -17,13 +18,19 @@ import com.graywolf336.jail.enums.LangString;
)
public class JailReloadCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) {
jm.getPlugin().reloadConfig();
jm.getPlugin().getJailIO().loadLanguage();
jm.getPlugin().getJailIO().loadJails();
jm.getPlugin().reloadScoreBoardManager();
jm.getPlugin().reloadJailSticks();
try {
jm.getPlugin().reloadConfig();
jm.getPlugin().getJailIO().loadLanguage();
jm.getPlugin().getJailIO().loadJails();
jm.getPlugin().reloadScoreBoardManager();
jm.getPlugin().reloadJailSticks();
jm.getPlugin().reloadJailPayManager();
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLUGINRELOADED));
}catch (Exception e) {
sender.sendMessage(ChatColor.RED + e.getMessage());
}
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLUGINRELOADED));
return true;
}
}

View File

@ -163,6 +163,30 @@ public enum LangString {
/** The message sent whenever someone does a command we don't know. */
UNKNOWNCOMMAND ("general"),
//Jail pay
/** The message sent when the jail pay portion is not enabled. */
PAYNOTENABLED ("jailpay", "notenabled"),
/** The message sent when finding out how much it costs. */
PAYCOST ("jailpay", "cost"),
/** The message sent when finding out how much it costs and they are jailed forever. */
PAYCOSTINFINITE ("jailpay", "costinfinite"),
/** The message sent when someone tries to pay a negative amount. */
PAYNONEGATIVEAMOUNTS ("jailpay", "nonegativeamounts"),
/** The message sent when someone is jailed and tries to pay for someone else. */
PAYCANTPAYWHILEJAILED ("jailpay", "cantpayforotherswhilejailed"),
/** The message sent whenever someone tries to pay an amount they don't have. */
PAYNOTENOUGHMONEY ("jailpay", "notenoughmoney"),
/** The message sent when they try to pay an amount but it isn't enough for the jailing sentence. */
PAYNOTENOUGHMONEYPROVIDED ("jailpay", "notenoughmoneyprovided"),
/** The message sent when they pay and get released. */
PAYPAIDRELEASED ("jailpay", "paidreleased"),
/** The message sent when they pay for someone else and release them. */
PAYPAIDRELEASEDELSE ("jailpay", "PAYPAIDRELEASEDELSE"),
/** The message sent when they pay and lower their time. */
PAYPAIDLOWEREDTIME ("jailpay", "paidloweredtime"),
/** The message sent when they pay and lower someone else's time. */
PAYPAIDLOWEREDTIMEELSE ("jailpay", "paidloweredtimeelse"),
//Confirming action messages.
/** The message sent when the sender is already confirming something. */

View File

@ -31,6 +31,10 @@ public enum Settings {
JAILDEFAULTTIME("jailing.jail.defaultTime"),
JAILEDGAMEMODE("jailing.jail.gameMode"),
JAILEDSTOREINVENTORY("jailing.jail.storeInventory"),
JAILPAYENABLED("jailpay.enabled"),
JAILPAYITEM("jailpay.item"),
JAILPAYPRICEPERMINUTE ("jailpay.pricePerMinute"),
JAILPAYPRICEINFINITE ("jailpay.priceInfinite"),
LOGJAILINGTOCONSOLE("jailing.jail.logToConsole"),
MAXAFKTIME("jailing.during.maxAFKTime"),
MOVEPENALTY("jailing.during.movePenalty"),

View File

@ -124,7 +124,7 @@ public class PlayerListener implements Listener {
//Add the scoreboard to them if it is enabled
if(pl.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
pl.getScoreBoardManager().addScoreBoard(event.getPlayer(), j, p);
pl.getScoreBoardManager().addScoreBoard(event.getPlayer(), p);
}
//if we are ignoring a prisoner's sleeping state, then let's set that

View File

@ -23,7 +23,7 @@ jailing:
blockPlaceWhiteList: ['crops', 'carrot', 'potato'] # these blocks can be placed at any time by prisoners
commandPenalty: 5m
commandProtection: true
commandWhitelist: ['/ping', '/list', '/jail status']
commandWhitelist: ['/ping', '/list', '/jail status', '/jail pay']
countDownTimeWhileOffline: false
cropTramplingPenalty: 5m
cropTramplingProtection: true
@ -63,6 +63,11 @@ jailing:
jails:
endermenProtection: true
explosionProtection: true
jailpay:
enabled: true
item: air
pricePerMinute: 1.5
priceInfinite: 10000
jailstick:
enabled: true
sticks: ["stick,30,,Running away"]

View File

@ -75,6 +75,18 @@ language:
unjailed: '&2You have been released! Please respect the server rules.'
willbeunjailed: '&2%0% will be released the next time they log on.'
youarenotjailed: '&2You are not jailed.'
jailpay:
cantpayforotherswhilejailed: '&cYou are jailed and as a result you can not pay for others.'
cost: '&9You have to pay %0% %1% per minute which equates to %2% %1%.'
costinfinite: '&9Since you are jailed forever, you have to pay %0% %1%.'
nonegativeamounts: '&cYou can not pay negative amounts.'
notenabled: "&cSorry, money won't help this time."
notenoughmoney: "&cYou don't have that much money!"
notenoughmoneyprovided: "&cYou have not provided enough money to cover the sentence!"
paidreleased: "&2You have just payed %0% and released yourself from jail!"
paidreleasedelse: "&2You have just payed %0% and released %1% from jail!"
paidloweredtime: "&2You have just payed %0% and lowered your sentence to %1% minutes!"
paidloweredtimeelse: "&2You have just payed %0% and lowered %1%'s sentence to %2% minutes!"
handcuffing:
cantbehandcuffed: '&9%0% &ccan not be handcuffed.'
currentlyjailed: '&9%0% &cis currently jailed, you can not handcuff a prisoner.'