Handcuffing messages are now fully customizable via the language file
This commit is contained in:
parent
f1451f4179
commit
3f27410a7a
@ -91,7 +91,7 @@ public class JailIO {
|
|||||||
* @return The message as a colorful message or an empty message if that isn't defined in the language file.
|
* @return The message as a colorful message or an empty message if that isn't defined in the language file.
|
||||||
*/
|
*/
|
||||||
public String getLanguageString(LangString langString, String... variables) {
|
public String getLanguageString(LangString langString, String... variables) {
|
||||||
String message = lang.getString("language." + langString.toString().toLowerCase());
|
String message = lang.getString("language." + langString.getSection() + langString.getName());
|
||||||
|
|
||||||
if(message == null) return "";
|
if(message == null) return "";
|
||||||
|
|
||||||
|
@ -42,9 +42,9 @@ public class JailMain extends JavaPlugin {
|
|||||||
pm = new PrisonerManager(this);
|
pm = new PrisonerManager(this);
|
||||||
|
|
||||||
PluginManager plm = this.getServer().getPluginManager();
|
PluginManager plm = this.getServer().getPluginManager();
|
||||||
plm.registerEvents(new HandCuffListener(this), this);
|
|
||||||
plm.registerEvents(new BlockListener(), this);
|
plm.registerEvents(new BlockListener(), this);
|
||||||
plm.registerEvents(new EntityListener(), this);
|
plm.registerEvents(new EntityListener(), this);
|
||||||
|
plm.registerEvents(new HandCuffListener(this), this);
|
||||||
plm.registerEvents(new PlayerListener(this), this);
|
plm.registerEvents(new PlayerListener(this), this);
|
||||||
|
|
||||||
debug = getConfig().getBoolean(Settings.DEBUG.getPath());
|
debug = getConfig().getBoolean(Settings.DEBUG.getPath());
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package com.graywolf336.jail.command.commands;
|
package com.graywolf336.jail.command.commands;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.command.Command;
|
import com.graywolf336.jail.command.Command;
|
||||||
import com.graywolf336.jail.command.CommandInfo;
|
import com.graywolf336.jail.command.CommandInfo;
|
||||||
|
import com.graywolf336.jail.enums.LangString;
|
||||||
|
|
||||||
@CommandInfo(
|
@CommandInfo(
|
||||||
maxArgs = 1,
|
maxArgs = 1,
|
||||||
@ -21,19 +21,19 @@ public class HandCuffCommand implements Command {
|
|||||||
Player player = jm.getPlugin().getServer().getPlayer(args[0]);
|
Player player = jm.getPlugin().getServer().getPlayer(args[0]);
|
||||||
|
|
||||||
if(player == null) {
|
if(player == null) {
|
||||||
sender.sendMessage(ChatColor.RED + "That player is not online!");
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERNOTONLINE));
|
||||||
}else if(player.hasPermission("jail.cantbehandcuffed")) {
|
}else if(player.hasPermission("jail.cantbehandcuffed")) {
|
||||||
sender.sendMessage(ChatColor.RED + "That player can't be handcuffed.");
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CANTBEHANDCUFFED, new String[] { player.getName() }));
|
||||||
}else if(jm.isPlayerJailed(player.getName())) {
|
}else if(jm.isPlayerJailed(player.getName())) {
|
||||||
sender.sendMessage(ChatColor.RED + "That player is currently jailed, you can't handcuff a prisoner.");
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CURRENTLYJAILEDHANDCUFF, new String[] { player.getName() }));
|
||||||
}else if(jm.getPlugin().getHandCuffManager().isHandCuffed(player.getName())) {
|
}else if(jm.getPlugin().getHandCuffManager().isHandCuffed(player.getName())) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "That player is already handcuffed, releasing them now!");
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.HANDCUFFSRELEASED, new String[] { player.getName() }));
|
||||||
jm.getPlugin().getHandCuffManager().removeHandCuffs(player.getName());
|
jm.getPlugin().getHandCuffManager().removeHandCuffs(player.getName());
|
||||||
player.sendMessage(ChatColor.GREEN + "Your handcuffs have been rmeoved.");
|
player.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.UNHANDCUFFED));
|
||||||
}else {
|
}else {
|
||||||
jm.getPlugin().getHandCuffManager().addHandCuffs(player.getName(), player.getLocation());
|
jm.getPlugin().getHandCuffManager().addHandCuffs(player.getName(), player.getLocation());
|
||||||
sender.sendMessage(ChatColor.BLUE + args[0] + ChatColor.GREEN + " has been handcuffed!");
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.HANDCUFFSON, new String[] { player.getName() }));
|
||||||
player.sendMessage(ChatColor.RED + "You've been handcuffed.");
|
player.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.HANDCUFFED));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package com.graywolf336.jail.command.commands;
|
package com.graywolf336.jail.command.commands;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.command.Command;
|
import com.graywolf336.jail.command.Command;
|
||||||
import com.graywolf336.jail.command.CommandInfo;
|
import com.graywolf336.jail.command.CommandInfo;
|
||||||
|
import com.graywolf336.jail.enums.LangString;
|
||||||
|
|
||||||
@CommandInfo(
|
@CommandInfo(
|
||||||
maxArgs = 1,
|
maxArgs = 1,
|
||||||
@ -21,13 +21,13 @@ public class UnHandCuffCommand implements Command {
|
|||||||
Player player = jm.getPlugin().getServer().getPlayerExact(args[0]);
|
Player player = jm.getPlugin().getServer().getPlayerExact(args[0]);
|
||||||
|
|
||||||
if(player == null) {
|
if(player == null) {
|
||||||
sender.sendMessage(ChatColor.RED + "That player is not online!");
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERNOTONLINE));
|
||||||
}else if(jm.getPlugin().getHandCuffManager().isHandCuffed(player.getName())) {
|
}else if(jm.getPlugin().getHandCuffManager().isHandCuffed(player.getName())) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Releasing them now!");
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.HANDCUFFSRELEASED, new String[] { player.getName() }));
|
||||||
jm.getPlugin().getHandCuffManager().removeHandCuffs(player.getName());
|
jm.getPlugin().getHandCuffManager().removeHandCuffs(player.getName());
|
||||||
player.sendMessage(ChatColor.GREEN + "Your handcuffs have been rmeoved.");
|
player.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.UNHANDCUFFED));
|
||||||
}else {
|
}else {
|
||||||
sender.sendMessage(ChatColor.BLUE + player.getName() + ChatColor.RED + " doesn't have any handcuffs to remove!");
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTHANDCUFFED, new String[] { player.getName() }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,18 +1,62 @@
|
|||||||
package com.graywolf336.jail.enums;
|
package com.graywolf336.jail.enums;
|
||||||
|
|
||||||
public enum LangString {
|
public enum LangString {
|
||||||
|
//Jailing section
|
||||||
|
|
||||||
/** The message sent when we broadcast/log the message for time below -1. */
|
/** The message sent when we broadcast/log the message for time below -1. */
|
||||||
BROADCASTMESSAGEFOREVER,
|
BROADCASTMESSAGEFOREVER ("jailing"),
|
||||||
/** The message sent when we broadcast/log the message for any time above -1. */
|
/** The message sent when we broadcast/log the message for any time above -1. */
|
||||||
BROADCASTMESSAGEFORMINUTES,
|
BROADCASTMESSAGEFORMINUTES ("jailing"),
|
||||||
/** The message sent when trying to jail someone who can't be jailed by permission. */
|
/** The message sent when trying to jail someone who can't be jailed by permission. */
|
||||||
CANTBEJAILED,
|
CANTBEJAILED ("jailing"),
|
||||||
/** The message sent when someone is jailed without a reason. */
|
/** The message sent when someone is jailed without a reason. */
|
||||||
DEFAULTJAILEDREASON,
|
DEFAULTJAILEDREASON ("jailing"),
|
||||||
/** The message sent when players are jailed without a reason. */
|
/** The message sent when players are jailed without a reason. */
|
||||||
JAILED,
|
JAILED ("jailing"),
|
||||||
/** The message sent when players are jailed with a reason. */
|
/** The message sent when players are jailed with a reason. */
|
||||||
JAILEDWITHREASON,
|
JAILEDWITHREASON ("jailing"),
|
||||||
/** The message sent when players are released from jail. */
|
/** The message sent when players are released from jail. */
|
||||||
UNJAILED;
|
UNJAILED ("jailing"),
|
||||||
|
|
||||||
|
//Handcuffing section
|
||||||
|
|
||||||
|
/** The message setnt to the sender when trying to handcuff someone who can't be. */
|
||||||
|
CANTBEHANDCUFFED ("handcuffing"),
|
||||||
|
CURRENTLYJAILEDHANDCUFF ("handcuffing", "currentlyjailed"),
|
||||||
|
/** The message sent to the sender when the player doesn't have any handcuffs. */
|
||||||
|
NOTHANDCUFFED ("handcuffing"),
|
||||||
|
/** The message sent to the handcuff on a successful handcuffing. */
|
||||||
|
HANDCUFFSON ("handcuffing"),
|
||||||
|
/** The message sent when players are handcuffed. */
|
||||||
|
HANDCUFFED ("handcuffing"),
|
||||||
|
/** The message sent to the player who has release handcuffs. */
|
||||||
|
HANDCUFFSRELEASED ("handcuffing"),
|
||||||
|
/** The message sent when the player has his/her handcuffs removed. */
|
||||||
|
UNHANDCUFFED ("handcuffing"),
|
||||||
|
|
||||||
|
//General section, used by different parts
|
||||||
|
|
||||||
|
/** The message sent whenever an online player is required but not found. */
|
||||||
|
PLAYERNOTONLINE ("general");
|
||||||
|
|
||||||
|
private String section, name;
|
||||||
|
|
||||||
|
LangString(String section) {
|
||||||
|
this.section = section;
|
||||||
|
}
|
||||||
|
|
||||||
|
LangString(String section, String name) {
|
||||||
|
this.section = section;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets the section in the language file this is located at. */
|
||||||
|
public String getSection() {
|
||||||
|
return this.section;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns the name of this enum if a custom one isn't present. */
|
||||||
|
public String getName() {
|
||||||
|
return (name == null ? this.toString().toLowerCase() : name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,19 @@
|
|||||||
language:
|
language:
|
||||||
jailed: "&cYou have been jailed!"
|
general:
|
||||||
jailedwithreason: "&cYou have been jailed for: %0%"
|
playernotonline: '&cThat player is not online!'
|
||||||
unjailed: "&2You have been released! Please respect the server rules."
|
jailing:
|
||||||
broadcastmessageforever: "&9%0% has been jailed forever."
|
broadcastmessageforever: '&9%0% has been jailed forever.'
|
||||||
broadcastmessageforminutes: "&9%0% has been jailed for %1% minutes."
|
broadcastmessageforminutes: '&9%0% has been jailed for %1% minutes.'
|
||||||
cantbejailed: "&cThat player can't be jailed, due to permissions."
|
cantbejailed: '&cThat player can not be jailed.'
|
||||||
defaultjailedreason: "Breaking the rules."
|
defaultjailedreason: Breaking the rules.
|
||||||
|
jailed: '&cYou have been jailed!'
|
||||||
|
jailedwithreason: '&cYou have been jailed for: %0%'
|
||||||
|
unjailed: '&2You have been released! Please respect the server rules.'
|
||||||
|
handcuffing:
|
||||||
|
cantbehandcuffed: '&9%0% &ccan not be handcuffed.'
|
||||||
|
currentlyjailed: '&9%0% &cis currently jailed, you can not handcuff a prisoner.'
|
||||||
|
nothandcuffed: '&9%0% &cdoes not have any handcuffs to remove!'
|
||||||
|
handcuffson: '&9%0% &ahas been handcuffed!'
|
||||||
|
handcuffed: '&cYou have been handcuffed.'
|
||||||
|
handcuffsreleased: '&9%0% &ahas been released from their handcuffs.'
|
||||||
|
unhandcuffed: '&aYour handcuffs have been removed.'
|
Loading…
Reference in New Issue
Block a user