mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-13 18:14:38 +02:00
Moving all default messages back to the code, where they should be
Also tweaking I18n class and YamlStorageWriter a bit
This commit is contained in:
@@ -39,7 +39,7 @@ public class EssentialsSign
|
||||
// they won't change it to §1[Signname]
|
||||
return true;
|
||||
}
|
||||
sign.setLine(0, _("signFormatFail", this.signName));
|
||||
sign.setLine(0, _("[{0}]", this.signName));
|
||||
try
|
||||
{
|
||||
final boolean ret = onSignCreate(sign, user, getUsername(user), ess);
|
||||
@@ -63,12 +63,12 @@ public class EssentialsSign
|
||||
|
||||
public String getSuccessName()
|
||||
{
|
||||
return _("signFormatSuccess", this.signName);
|
||||
return _("[{0}]", this.signName);
|
||||
}
|
||||
|
||||
public String getTemplateName()
|
||||
{
|
||||
return _("signFormatTemplate", this.signName);
|
||||
return _("[{0}]", this.signName);
|
||||
}
|
||||
|
||||
private String getUsername(final IUser user)
|
||||
@@ -297,7 +297,7 @@ public class EssentialsSign
|
||||
getIntegerPositive(sign.getLine(amountIndex)), item.getType().getMaxStackSize() * player.getPlayer().getInventory().getSize());
|
||||
if (item.getTypeId() == 0 || amount < 1)
|
||||
{
|
||||
throw new SignException(_("moreThanZero"));
|
||||
throw new SignException(_("Quantities must be greater than 0."));
|
||||
}
|
||||
item.setAmount(amount);
|
||||
return new Trade(item, ess);
|
||||
@@ -319,7 +319,7 @@ public class EssentialsSign
|
||||
final int quantity = getInteger(line);
|
||||
if (quantity < 1)
|
||||
{
|
||||
throw new SignException(_("moreThanZero"));
|
||||
throw new SignException(_("Quantities must be greater than 0."));
|
||||
}
|
||||
return quantity;
|
||||
}
|
||||
@@ -363,7 +363,7 @@ public class EssentialsSign
|
||||
final double quantity = getDouble(line);
|
||||
if (Math.round(quantity * 100.0) < 1.0)
|
||||
{
|
||||
throw new SignException(_("moreThanZero"));
|
||||
throw new SignException(_("Quantities must be greater than 0."));
|
||||
}
|
||||
return quantity;
|
||||
}
|
||||
@@ -399,7 +399,7 @@ public class EssentialsSign
|
||||
final String[] split = line.split("[ :]+", 2);
|
||||
if (split.length != 2)
|
||||
{
|
||||
throw new SignException(_("invalidCharge"));
|
||||
throw new SignException(_("Invalid charge."));
|
||||
}
|
||||
final int quantity = getIntegerPositive(split[0]);
|
||||
|
||||
|
@@ -26,7 +26,7 @@ public class EssentialsSignsPlugin extends JavaPlugin implements ISignsPlugin
|
||||
final IEssentials ess = (IEssentials)plugin.getEssentials();
|
||||
if (!this.getDescription().getVersion().equals(plugin.getDescription().getVersion()))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("versionMismatchAll"));
|
||||
LOGGER.log(Level.WARNING, _("Version mismatch! Please update all Essentials jars to the same version."));
|
||||
}
|
||||
if (!plugin.isEnabled())
|
||||
{
|
||||
|
@@ -17,7 +17,7 @@ public class SignBalance extends EssentialsSign
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException
|
||||
{
|
||||
player.sendMessage(_("balance", FormatUtil.displayCurrency(player.getMoney(), ess)));
|
||||
player.sendMessage(_("Balance: {0}", FormatUtil.displayCurrency(player.getMoney(), ess)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -26,12 +26,12 @@ public class SignEnchant extends EssentialsSign
|
||||
final String[] enchantLevel = sign.getLine(2).split(":");
|
||||
if (enchantLevel.length != 2)
|
||||
{
|
||||
throw new SignException(_("invalidSignLine", 3));
|
||||
throw new SignException(_("Line {0} on sign is invalid.", 3));
|
||||
}
|
||||
final Enchantment enchantment = Enchantments.getByName(enchantLevel[0]);
|
||||
if (enchantment == null)
|
||||
{
|
||||
throw new SignException(_("enchantmentNotFound"));
|
||||
throw new SignException(_(" Enchantment not found"));
|
||||
}
|
||||
int level;
|
||||
try
|
||||
@@ -71,12 +71,12 @@ public class SignEnchant extends EssentialsSign
|
||||
final String[] enchantLevel = sign.getLine(2).split(":");
|
||||
if (enchantLevel.length != 2)
|
||||
{
|
||||
throw new SignException(_("invalidSignLine", 3));
|
||||
throw new SignException(_("Line {0} on sign is invalid.", 3));
|
||||
}
|
||||
final Enchantment enchantment = Enchantments.getByName(enchantLevel[0]);
|
||||
if (enchantment == null)
|
||||
{
|
||||
throw new SignException(_("enchantmentNotFound"));
|
||||
throw new SignException(_(" Enchantment not found"));
|
||||
}
|
||||
int level;
|
||||
try
|
||||
@@ -92,11 +92,11 @@ public class SignEnchant extends EssentialsSign
|
||||
if (playerHand == null || playerHand.getAmount() != 1 || (playerHand.containsEnchantment(enchantment) && playerHand.getEnchantmentLevel(
|
||||
enchantment) == level))
|
||||
{
|
||||
throw new SignException(_("missingItems", 1, sign.getLine(1)));
|
||||
throw new SignException(_("You do not have {0}x {1}.", 1, sign.getLine(1)));
|
||||
}
|
||||
if (search != null && playerHand.getType() != search.getType())
|
||||
{
|
||||
throw new SignException(_("missingItems", 1, search.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ')));
|
||||
throw new SignException(_("You do not have {0}x {1}.", 1, search.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ')));
|
||||
}
|
||||
|
||||
final ItemStack toEnchant = playerHand;
|
||||
|
@@ -28,7 +28,7 @@ public class SignFeed extends EssentialsSign
|
||||
final Trade charge = getTrade(sign, 1, ess);
|
||||
charge.isAffordableFor(player);
|
||||
player.getPlayer().setFoodLevel(20);
|
||||
player.sendMessage(_("feed"));
|
||||
player.sendMessage(_("Your appetite was sated."));
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ public class SignFree extends EssentialsSign
|
||||
final ItemStack item = getItemStack(sign.getLine(1), 1, ess);
|
||||
if (item.getType() == Material.AIR)
|
||||
{
|
||||
throw new SignException(_("cantSpawnItem", "Air"));
|
||||
throw new SignException(_("You are not allowed to spawn the item {0}.", "Air"));
|
||||
}
|
||||
|
||||
item.setAmount(item.getType().getMaxStackSize());
|
||||
|
@@ -39,13 +39,13 @@ public class SignGameMode extends EssentialsSign
|
||||
|
||||
if (mode.isEmpty())
|
||||
{
|
||||
throw new SignException(_("invalidSignLine", 2));
|
||||
throw new SignException(_("Line {0} on sign is invalid.", 2));
|
||||
}
|
||||
charge.isAffordableFor(player);
|
||||
|
||||
//TODO: this needs to be fixed
|
||||
player.getPlayer().setGameMode(player.getPlayer().getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
player.sendMessage(_("gameMode", _(player.getPlayer().getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getPlayer().getDisplayName()));
|
||||
player.sendMessage(_("Set game mode {0} for {1}.", _(player.getPlayer().getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getPlayer().getDisplayName()));
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ public class SignHeal extends EssentialsSign
|
||||
player.getPlayer().setHealth(20);
|
||||
player.getPlayer().setFoodLevel(20);
|
||||
player.getPlayer().setFireTicks(0);
|
||||
player.sendMessage(_("youAreHealed"));
|
||||
player.sendMessage(_("You have been healed."));
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
|
@@ -74,7 +74,7 @@ public class SignKit extends EssentialsSign
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SignException(_("noKitPermission", "essentials.kits." + kitName));
|
||||
throw new SignException(_("You need the {0} permission to use that kit.", "essentials.kits." + kitName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,14 +20,14 @@ public class SignMail extends EssentialsSign
|
||||
final List<String> mail = player.getData().getMails();
|
||||
if (mail == null || mail.isEmpty())
|
||||
{
|
||||
player.sendMessage(_("noNewMail"));
|
||||
player.sendMessage(_("You have no new mail."));
|
||||
return false;
|
||||
}
|
||||
for (String s : mail)
|
||||
{
|
||||
player.sendMessage(s);
|
||||
}
|
||||
player.sendMessage(_("markMailAsRead"));
|
||||
player.sendMessage(_("To mark your mail as read, type /mail clear."));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ public class SignRepair extends EssentialsSign
|
||||
}
|
||||
else if (!repairTarget.equalsIgnoreCase("all") && !repairTarget.equalsIgnoreCase("hand"))
|
||||
{
|
||||
throw new SignException(_("invalidSignLine", 2));
|
||||
throw new SignException(_("Line {0} on sign is invalid.", 2));
|
||||
}
|
||||
validateTrade(sign, 2, ess);
|
||||
return true;
|
||||
|
@@ -31,7 +31,7 @@ public class SignTime extends EssentialsSign
|
||||
sign.setLine(1, "§2Night");
|
||||
return true;
|
||||
}
|
||||
throw new SignException(_("onlyDayNight"));
|
||||
throw new SignException(_("/time only supports day/night."));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,6 +55,6 @@ public class SignTime extends EssentialsSign
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
throw new SignException(_("onlyDayNight"));
|
||||
throw new SignException(_("/time only supports day/night."));
|
||||
}
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ public class SignTrade extends EssentialsSign
|
||||
{
|
||||
if (store == null)
|
||||
{
|
||||
throw new SignException(_("tradeSignEmptyOwner"), e);
|
||||
throw new SignException(_("There is nothing to collect from this trade sign."), e);
|
||||
}
|
||||
}
|
||||
Trade.log("Sign", "Trade", "OwnerInteract", username, store, username, stored, sign.getBlock().getLocation(), ess);
|
||||
@@ -157,7 +157,7 @@ public class SignTrade extends EssentialsSign
|
||||
amount -= amount % money;
|
||||
if (amount < 0.01 || money < 0.01)
|
||||
{
|
||||
throw new SignException(_("moreThanZero"));
|
||||
throw new SignException(_("Quantities must be greater than 0."));
|
||||
}
|
||||
sign.setLine(index, FormatUtil.shortCurrency(money, ess) + ":" + FormatUtil.shortCurrency(amount, ess).substring(1));
|
||||
return;
|
||||
@@ -170,11 +170,11 @@ public class SignTrade extends EssentialsSign
|
||||
|
||||
if (amount < 1)
|
||||
{
|
||||
throw new SignException(_("moreThanZero"));
|
||||
throw new SignException(_("Quantities must be greater than 0."));
|
||||
}
|
||||
if (!(split[1].equalsIgnoreCase("exp") || split[1].equalsIgnoreCase("xp")) && getItemStack(split[1], amount, ess).getTypeId() == 0)
|
||||
{
|
||||
throw new SignException(_("moreThanZero"));
|
||||
throw new SignException(_("Quantities must be greater than 0."));
|
||||
}
|
||||
String newline = amount + " " + split[1] + ":0";
|
||||
if ((newline + amount).length() > 15)
|
||||
@@ -192,16 +192,16 @@ public class SignTrade extends EssentialsSign
|
||||
amount -= amount % stackamount;
|
||||
if (amount < 1 || stackamount < 1)
|
||||
{
|
||||
throw new SignException(_("moreThanZero"));
|
||||
throw new SignException(_("Quantities must be greater than 0."));
|
||||
}
|
||||
if (!(split[1].equalsIgnoreCase("exp") || split[1].equalsIgnoreCase("xp")) && getItemStack(split[1], stackamount, ess).getTypeId() == 0)
|
||||
{
|
||||
throw new SignException(_("moreThanZero"));
|
||||
throw new SignException(_("Quantities must be greater than 0."));
|
||||
}
|
||||
sign.setLine(index, stackamount + " " + split[1] + ":" + amount);
|
||||
return;
|
||||
}
|
||||
throw new SignException(_("invalidSignLine", index + 1));
|
||||
throw new SignException(_("Line {0} on sign is invalid.", index + 1));
|
||||
}
|
||||
|
||||
protected final Trade getTrade(final ISign sign, final int index, final boolean fullAmount, final boolean notEmpty, final IEssentials ess) throws SignException
|
||||
@@ -226,7 +226,7 @@ public class SignTrade extends EssentialsSign
|
||||
}
|
||||
catch (SignException e)
|
||||
{
|
||||
throw new SignException(_("tradeSignEmpty"), e);
|
||||
throw new SignException(_("The trade sign has nothing available for you."), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ public class SignTrade extends EssentialsSign
|
||||
amount -= amount % stackamount;
|
||||
if (notEmpty && (amount < 1 || stackamount < 1))
|
||||
{
|
||||
throw new SignException(_("tradeSignEmpty"));
|
||||
throw new SignException(_("The trade sign has nothing available for you."));
|
||||
}
|
||||
return new Trade(fullAmount ? amount : stackamount, ess);
|
||||
}
|
||||
@@ -251,13 +251,13 @@ public class SignTrade extends EssentialsSign
|
||||
amount -= amount % stackamount;
|
||||
if (notEmpty && (amount < 1 || stackamount < 1 || item.getTypeId() == 0))
|
||||
{
|
||||
throw new SignException(_("tradeSignEmpty"));
|
||||
throw new SignException(_("The trade sign has nothing available for you."));
|
||||
}
|
||||
item.setAmount(fullAmount ? amount : stackamount);
|
||||
return new Trade(item, ess);
|
||||
}
|
||||
}
|
||||
throw new SignException(_("invalidSignLine", index + 1));
|
||||
throw new SignException(_("Line {0} on sign is invalid.", index + 1));
|
||||
}
|
||||
|
||||
protected final void subtractAmount(final ISign sign, final int index, final Trade trade, final IEssentials ess) throws SignException
|
||||
@@ -354,6 +354,6 @@ public class SignTrade extends EssentialsSign
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new SignException(_("invalidSignLine", index + 1));
|
||||
throw new SignException(_("Line {0} on sign is invalid.", index + 1));
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ public class SignWeather extends EssentialsSign
|
||||
sign.setLine(1, "§2Storm");
|
||||
return true;
|
||||
}
|
||||
throw new SignException(_("onlySunStorm"));
|
||||
throw new SignException(_("/weather only supports sun/storm."));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,6 +53,6 @@ public class SignWeather extends EssentialsSign
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
throw new SignException(_("onlySunStorm"));
|
||||
throw new SignException(_("/weather only supports sun/storm."));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user