mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-19 21:11:25 +02:00
Cleanup signs, update and xmpp, more to come.
This commit is contained in:
@@ -22,12 +22,12 @@ public class EssentialsSign
|
||||
{
|
||||
private static final Set<Material> EMPTY_SET = new HashSet<Material>();
|
||||
protected transient final String signName;
|
||||
|
||||
|
||||
public EssentialsSign(final String signName)
|
||||
{
|
||||
this.signName = signName;
|
||||
}
|
||||
|
||||
|
||||
public final boolean onSignCreate(final SignChangeEvent event, final IEssentials ess)
|
||||
{
|
||||
final ISign sign = new EventSign(event);
|
||||
@@ -59,22 +59,22 @@ public class EssentialsSign
|
||||
// Return true, so the player sees the wrong sign.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public String getSuccessName()
|
||||
{
|
||||
return _("signFormatSuccess", this.signName);
|
||||
}
|
||||
|
||||
|
||||
public String getTemplateName()
|
||||
{
|
||||
return _("signFormatTemplate", this.signName);
|
||||
}
|
||||
|
||||
|
||||
private String getUsername(final IUser user)
|
||||
{
|
||||
return user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
|
||||
}
|
||||
|
||||
|
||||
public final boolean onSignInteract(final Block block, final Player player, final IEssentials ess)
|
||||
{
|
||||
final ISign sign = new BlockSign(block);
|
||||
@@ -86,7 +86,7 @@ public class EssentialsSign
|
||||
}
|
||||
catch (ChargeException ex)
|
||||
{
|
||||
ess.getCommandHandler().showCommandError(user,signName, ex);
|
||||
ess.getCommandHandler().showCommandError(user, signName, ex);
|
||||
return false;
|
||||
}
|
||||
catch (SignException ex)
|
||||
@@ -95,7 +95,7 @@ public class EssentialsSign
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public final boolean onSignBreak(final Block block, final Player player, final IEssentials ess)
|
||||
{
|
||||
final ISign sign = new BlockSign(block);
|
||||
@@ -111,25 +111,25 @@ public class EssentialsSign
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected boolean onSignCreate(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected boolean onSignInteract(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected boolean onSignBreak(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public final boolean onBlockPlace(final Block block, final Player player, final IEssentials ess)
|
||||
{
|
||||
IUser user = ess.getUser(player);
|
||||
final IUser user = ess.getUser(player);
|
||||
try
|
||||
{
|
||||
return onBlockPlace(block, user, getUsername(user), ess);
|
||||
@@ -144,10 +144,10 @@ public class EssentialsSign
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public final boolean onBlockInteract(final Block block, final Player player, final IEssentials ess)
|
||||
{
|
||||
IUser user = ess.getUser(player);
|
||||
final IUser user = ess.getUser(player);
|
||||
try
|
||||
{
|
||||
return onBlockInteract(block, user, getUsername(user), ess);
|
||||
@@ -162,10 +162,10 @@ public class EssentialsSign
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public final boolean onBlockBreak(final Block block, final Player player, final IEssentials ess)
|
||||
{
|
||||
IUser user = ess.getUser(player);
|
||||
final IUser user = ess.getUser(player);
|
||||
try
|
||||
{
|
||||
return onBlockBreak(block, user, getUsername(user), ess);
|
||||
@@ -176,32 +176,32 @@ public class EssentialsSign
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean onBlockBreak(final Block block, final IEssentials ess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean onBlockExplode(final Block block, final IEssentials ess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean onBlockBurn(final Block block, final IEssentials ess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean onBlockIgnite(final Block block, final IEssentials ess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean onBlockPush(final Block block, final IEssentials ess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static boolean checkIfBlockBreaksSigns(final Block block)
|
||||
{
|
||||
final Block sign = block.getRelative(BlockFace.UP);
|
||||
@@ -230,32 +230,32 @@ public class EssentialsSign
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isValidSign(final ISign sign)
|
||||
{
|
||||
return sign.getLine(0).matches("§1\\[.*\\]");
|
||||
}
|
||||
|
||||
|
||||
protected boolean onBlockPlace(final Block block, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected boolean onBlockInteract(final Block block, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected boolean onBlockBreak(final Block block, final IUser player, final String username, final IEssentials ess) throws SignException
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public Set<Material> getBlocks()
|
||||
{
|
||||
return EMPTY_SET;
|
||||
}
|
||||
|
||||
|
||||
protected final void validateTrade(final ISign sign, final int index, final IEssentials ess) throws SignException
|
||||
{
|
||||
final String line = sign.getLine(index).trim();
|
||||
@@ -270,7 +270,7 @@ public class EssentialsSign
|
||||
sign.setLine(index, Util.shortCurrency(money, ess));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected final void validateTrade(final ISign sign, final int amountIndex, final int itemIndex,
|
||||
final IUser player, final IEssentials ess) throws SignException
|
||||
{
|
||||
@@ -286,7 +286,7 @@ public class EssentialsSign
|
||||
sign.setLine(amountIndex, Integer.toString(item.getAmount()));
|
||||
sign.setLine(itemIndex, sign.getLine(itemIndex).trim());
|
||||
}
|
||||
|
||||
|
||||
protected final Trade getTrade(final ISign sign, final int amountIndex, final int itemIndex,
|
||||
final IUser player, final IEssentials ess) throws SignException
|
||||
{
|
||||
@@ -304,7 +304,7 @@ public class EssentialsSign
|
||||
item.setAmount(amount);
|
||||
return new Trade(item, ess);
|
||||
}
|
||||
|
||||
|
||||
protected final void validateInteger(final ISign sign, final int index) throws SignException
|
||||
{
|
||||
final String line = sign.getLine(index).trim();
|
||||
@@ -315,7 +315,7 @@ public class EssentialsSign
|
||||
final int quantity = getIntegerPositive(line);
|
||||
sign.setLine(index, Integer.toString(quantity));
|
||||
}
|
||||
|
||||
|
||||
protected final int getIntegerPositive(final String line) throws SignException
|
||||
{
|
||||
final int quantity = getInteger(line);
|
||||
@@ -325,13 +325,13 @@ public class EssentialsSign
|
||||
}
|
||||
return quantity;
|
||||
}
|
||||
|
||||
|
||||
protected final int getInteger(final String line) throws SignException
|
||||
{
|
||||
try
|
||||
{
|
||||
final int quantity = Integer.parseInt(line);
|
||||
|
||||
|
||||
return quantity;
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
@@ -339,7 +339,7 @@ public class EssentialsSign
|
||||
throw new SignException("Invalid sign", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected final ItemStack getItemStack(final String itemName, final int quantity, final IEssentials ess) throws SignException
|
||||
{
|
||||
try
|
||||
@@ -353,13 +353,13 @@ public class EssentialsSign
|
||||
throw new SignException(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected final Double getMoney(final String line) throws SignException
|
||||
{
|
||||
final boolean isMoney = line.matches("^[^0-9-\\.][\\.0-9]+$");
|
||||
return isMoney ? getDoublePositive(line.substring(1)) : null;
|
||||
}
|
||||
|
||||
|
||||
protected final Double getDoublePositive(final String line) throws SignException
|
||||
{
|
||||
final double quantity = getDouble(line);
|
||||
@@ -369,7 +369,7 @@ public class EssentialsSign
|
||||
}
|
||||
return quantity;
|
||||
}
|
||||
|
||||
|
||||
protected final Double getDouble(final String line) throws SignException
|
||||
{
|
||||
try
|
||||
@@ -381,12 +381,12 @@ public class EssentialsSign
|
||||
throw new SignException(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected final Trade getTrade(final ISign sign, final int index, final IEssentials ess) throws SignException
|
||||
{
|
||||
return getTrade(sign, index, 1, ess);
|
||||
}
|
||||
|
||||
|
||||
protected final Trade getTrade(final ISign sign, final int index, final int decrement, final IEssentials ess) throws SignException
|
||||
{
|
||||
final String line = sign.getLine(index).trim();
|
||||
@@ -394,7 +394,7 @@ public class EssentialsSign
|
||||
{
|
||||
return new Trade(signName.toLowerCase(Locale.ENGLISH) + "sign", ess);
|
||||
}
|
||||
|
||||
|
||||
final Double money = getMoney(line);
|
||||
if (money == null)
|
||||
{
|
||||
@@ -404,7 +404,7 @@ public class EssentialsSign
|
||||
throw new SignException(_("invalidCharge"));
|
||||
}
|
||||
final int quantity = getIntegerPositive(split[0]);
|
||||
|
||||
|
||||
final String item = split[1].toLowerCase(Locale.ENGLISH);
|
||||
if (item.equalsIgnoreCase("times"))
|
||||
{
|
||||
@@ -428,89 +428,89 @@ public class EssentialsSign
|
||||
return new Trade(money, ess);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static class EventSign implements ISign
|
||||
{
|
||||
private final transient SignChangeEvent event;
|
||||
private final transient Block block;
|
||||
|
||||
|
||||
public EventSign(final SignChangeEvent event)
|
||||
{
|
||||
this.event = event;
|
||||
this.block = event.getBlock();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final String getLine(final int index)
|
||||
{
|
||||
return event.getLine(index);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void setLine(final int index, final String text)
|
||||
{
|
||||
event.setLine(index, text);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Block getBlock()
|
||||
{
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateSign()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static class BlockSign implements ISign
|
||||
{
|
||||
private final transient Sign sign;
|
||||
private final transient Block block;
|
||||
|
||||
|
||||
public BlockSign(final Block block)
|
||||
{
|
||||
this.block = block;
|
||||
this.sign = (Sign)block.getState();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final String getLine(final int index)
|
||||
{
|
||||
return sign.getLine(index);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void setLine(final int index, final String text)
|
||||
{
|
||||
sign.setLine(index, text);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final Block getBlock()
|
||||
{
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void updateSign()
|
||||
{
|
||||
sign.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public interface ISign
|
||||
{
|
||||
String getLine(final int index);
|
||||
|
||||
|
||||
void setLine(final int index, final String text);
|
||||
|
||||
|
||||
public Block getBlock();
|
||||
|
||||
|
||||
void updateSign();
|
||||
}
|
||||
}
|
||||
|
@@ -12,14 +12,13 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
public class EssentialsSignsPlugin extends JavaPlugin implements ISignsPlugin
|
||||
{
|
||||
private static final transient Logger LOGGER = Bukkit.getLogger();
|
||||
private transient IEssentials ess;
|
||||
private transient SignsConfigHolder config;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
final PluginManager pluginManager = getServer().getPluginManager();
|
||||
ess = (IEssentials)pluginManager.getPlugin("Essentials3");
|
||||
final IEssentials ess = (IEssentials)pluginManager.getPlugin("Essentials3");
|
||||
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("versionMismatchAll"));
|
||||
@@ -38,8 +37,8 @@ public class EssentialsSignsPlugin extends JavaPlugin implements ISignsPlugin
|
||||
|
||||
final SignEntityListener signEntityListener = new SignEntityListener(ess, this);
|
||||
pluginManager.registerEvents(signEntityListener, this);
|
||||
|
||||
config = new SignsConfigHolder(ess, this);
|
||||
|
||||
config = new SignsConfigHolder(ess, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -2,6 +2,8 @@ package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentialsModule;
|
||||
|
||||
public interface ISignsPlugin extends IEssentialsModule {
|
||||
|
||||
public interface ISignsPlugin extends IEssentialsModule
|
||||
{
|
||||
SignsConfigHolder getSettings();
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
|
||||
|
||||
public class SignBuy extends EssentialsSign
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.bukkit.Enchantments;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.bukkit.Enchantments;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@@ -28,7 +28,7 @@ public class SignEntityListener implements Listener
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (Block block : event.blockList())
|
||||
{
|
||||
if (((block.getTypeId() == Material.WALL_SIGN.getId()
|
||||
|
@@ -1,13 +1,11 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
|
||||
|
||||
public class SignHeal extends EssentialsSign
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.Kits;
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
@@ -33,7 +32,7 @@ public class SignKit extends EssentialsSign
|
||||
{
|
||||
try
|
||||
{
|
||||
ess.getKits().getKit(kitName);
|
||||
ess.getKits().getKit(kitName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -60,9 +59,9 @@ public class SignKit extends EssentialsSign
|
||||
charge.isAffordableFor(player);
|
||||
try
|
||||
{;
|
||||
final Kit kit = ess.getKits().getKit(kitName);
|
||||
ess.getKits().checkTime(player, kit);
|
||||
ess.getKits().sendKit(player,kit);
|
||||
final Kit kit = ess.getKits().getKit(kitName);
|
||||
ess.getKits().checkTime(player, kit);
|
||||
ess.getKits().sendKit(player, kit);
|
||||
charge.charge(player);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import java.util.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
|
||||
|
||||
public class SignSell extends EssentialsSign
|
||||
|
@@ -1,10 +1,10 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.commands.Commandspawnmob;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
|
||||
|
||||
public class SignSpawnmob extends EssentialsSign
|
||||
@@ -22,14 +22,13 @@ public class SignSpawnmob extends EssentialsSign
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//TODO: This should call a method not a command
|
||||
@Override
|
||||
protected boolean onSignInteract(ISign sign, IUser player, String username, IEssentials ess) throws SignException, ChargeException
|
||||
{
|
||||
final Trade charge = getTrade(sign, 3, ess);
|
||||
charge.isAffordableFor(player);
|
||||
Commandspawnmob command = new Commandspawnmob();
|
||||
Commandspawnmob command = new Commandspawnmob();
|
||||
command.init(ess, "spawnmob");
|
||||
String[] args = new String[]
|
||||
{
|
||||
|
@@ -1,10 +1,10 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
|
||||
|
||||
public class SignTime extends EssentialsSign
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.permissions.WarpPermissions;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
|
||||
|
||||
public class SignWeather extends EssentialsSign
|
||||
|
@@ -19,7 +19,6 @@ public enum Signs
|
||||
TRADE(new SignTrade()),
|
||||
WARP(new SignWarp()),
|
||||
WEATHER(new SignWeather());
|
||||
|
||||
private final EssentialsSign sign;
|
||||
|
||||
private Signs(final EssentialsSign sign)
|
||||
|
@@ -4,7 +4,9 @@ import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SignsConfig implements StorageObject {
|
||||
|
||||
public class SignsConfig implements StorageObject
|
||||
{
|
||||
private Map<String, Boolean> signs = new HashMap<String, Boolean>();
|
||||
|
||||
public Map<String, Boolean> getSigns()
|
||||
@@ -12,7 +14,7 @@ public class SignsConfig implements StorageObject {
|
||||
return signs;
|
||||
}
|
||||
|
||||
public void setSigns(Map<String, Boolean> signs)
|
||||
public void setSigns(final Map<String, Boolean> signs)
|
||||
{
|
||||
this.signs = signs;
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig>
|
||||
{
|
||||
private final Plugin plugin;
|
||||
private final transient Plugin plugin;
|
||||
private Set<EssentialsSign> enabledSigns = new HashSet<EssentialsSign>();
|
||||
private boolean signsEnabled = false;
|
||||
|
||||
@@ -22,15 +22,15 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig>
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
Map<String, Boolean> signs = getData().getSigns();
|
||||
final Map<String, Boolean> signs = getData().getSigns();
|
||||
for (Map.Entry<String, Boolean> entry : signs.entrySet())
|
||||
{
|
||||
if(entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOR") || entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOUR"))
|
||||
if (entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOR") || entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOUR"))
|
||||
{
|
||||
signsEnabled = true;
|
||||
continue;
|
||||
}
|
||||
Signs sign = Signs.valueOf(entry.getKey().toUpperCase(Locale.ENGLISH));
|
||||
final Signs sign = Signs.valueOf(entry.getKey().toUpperCase(Locale.ENGLISH));
|
||||
if (sign != null && entry.getValue())
|
||||
{
|
||||
enabledSigns.add(sign.getSign());
|
||||
@@ -44,7 +44,7 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig>
|
||||
acquireWriteLock();
|
||||
try
|
||||
{
|
||||
Map<String, Boolean> signs = new HashMap<String, Boolean>();
|
||||
final Map<String, Boolean> signs = new HashMap<String, Boolean>();
|
||||
for (Signs sign : Signs.values())
|
||||
{
|
||||
signs.put(sign.toString(), enabledSigns.contains(sign.getSign()));
|
||||
@@ -67,7 +67,7 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig>
|
||||
{
|
||||
return enabledSigns;
|
||||
}
|
||||
|
||||
|
||||
public boolean areSignsDisabled()
|
||||
{
|
||||
return !signsEnabled;
|
||||
@@ -76,12 +76,10 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig>
|
||||
@Override
|
||||
public void finishRead()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishWrite()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -37,4 +37,4 @@ public class PastieUpload
|
||||
throw new IOException("Failed to upload to pastie.org");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -188,7 +188,7 @@ public class UpdateCheck
|
||||
private int getBukkitVersion()
|
||||
{
|
||||
final Matcher versionMatch = Pattern.compile("git-Bukkit-(?:(?:[0-9]+)\\.)+[0-9]+-R[\\.0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(plugin.getServer().getVersion());
|
||||
if (versionMatch.matches())
|
||||
if (versionMatch.matches())
|
||||
{
|
||||
return Integer.parseInt(versionMatch.group(1));
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.update;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.KeyFactory;
|
||||
@@ -15,6 +16,7 @@ import java.util.TreeMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@@ -25,7 +27,6 @@ public class UpdateFile
|
||||
private final static String UPDATE_URL = "http://goo.gl/67jev";
|
||||
private final static BigInteger PUBLIC_KEY = new BigInteger("5ha6a2d4qdy17ttkg8evh74sl5a87djojwenu12k1lvy8ui6003e6l06rntczpoh99mhc3txj8mqlxw111oyy9yl7s7qpyluyzix3j1odxrxx4u52gxvyu6qiteapczkzvi7rxgeqsozz7b19rdx73a7quo9ybwpz1cr82r7x5k0pg2a73pjjsv2j1awr13azo7klrcxp9y5xxwf5qv1s3tw4zqftli18u0ek5qkbzfbgk1v5n2f11pkwwk6p0mibrn26wnjbv11vyiqgu95o7busmt6vf5q7grpcenl637w83mbin56s3asj1131b2mscj9xep3cbj7la9tgsxl5bj87vzy8sk2d34kzwqdqgh9nry43nqqus12l1stmiv184r8r3jcy8w43e8h1u1mzklldb5eytkuhayqik8l3ns04hwt8sgacvw534be8sx26qrn5s1", 36);
|
||||
private final transient File file;
|
||||
private transient YamlConfiguration updateConfig;
|
||||
private final transient Plugin plugin;
|
||||
private final transient TreeMap<Version, VersionInfo> versions = new TreeMap<Version, VersionInfo>();
|
||||
|
||||
@@ -185,16 +186,14 @@ public class UpdateFile
|
||||
return false;
|
||||
}
|
||||
|
||||
private void readVersions() throws Exception
|
||||
private void readVersions() throws FileNotFoundException, InvalidConfigurationException, IOException
|
||||
{
|
||||
updateConfig = new YamlConfiguration();
|
||||
final YamlConfiguration updateConfig = new YamlConfiguration();
|
||||
updateConfig.load(file);
|
||||
versions.clear();
|
||||
for (String versionString : updateConfig.getKeys(false))
|
||||
{
|
||||
final Version version = new Version(versionString);
|
||||
final VersionInfo info = new VersionInfo(updateConfig, versionString);
|
||||
versions.put(version, info);
|
||||
versions.put(new Version(versionString), new VersionInfo(updateConfig, versionString));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,7 @@ import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
// TODO: This whole thing should make use of the conversations api
|
||||
public class UpdateProcess implements Listener
|
||||
{
|
||||
private transient Player currentPlayer;
|
||||
|
@@ -61,6 +61,5 @@ public class ConfigCommand extends AbstractFileCommand implements Command
|
||||
player.sendMessage(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,6 @@ public class IrcBot extends PircBot
|
||||
try
|
||||
{
|
||||
connect(SERVER, PORT);
|
||||
return;
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
|
@@ -39,7 +39,7 @@ public abstract class AbstractState
|
||||
|
||||
/**
|
||||
* Check if we already know the answer, so the user does not have to answer the question.
|
||||
*
|
||||
*
|
||||
* @return true, if the answer could be guessed.
|
||||
*/
|
||||
public boolean guessAnswer()
|
||||
@@ -49,12 +49,14 @@ public abstract class AbstractState
|
||||
|
||||
/**
|
||||
* Ask the user the question.
|
||||
* @param sender
|
||||
*
|
||||
* @param sender
|
||||
*/
|
||||
public abstract void askQuestion(Player sender);
|
||||
|
||||
/**
|
||||
* React on the answer and set internal variables
|
||||
*
|
||||
* @param answer
|
||||
* @return true, if the answer could be recognized as a valid answer
|
||||
*/
|
||||
|
@@ -11,7 +11,7 @@ public class EssentialsChat extends AbstractYesNoState
|
||||
{
|
||||
public EssentialsChat(final StateMap states)
|
||||
{
|
||||
super(states, EssentialsChatSettings.class, EssentialsSpawn.class);
|
||||
super(states, EssentialsChatSettings.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -7,7 +7,7 @@ public class EssentialsChatSettings extends AbstractYesNoState
|
||||
{
|
||||
public EssentialsChatSettings(final StateMap states)
|
||||
{
|
||||
super(states, EssentialsSpawn.class);
|
||||
super(states, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -44,4 +44,4 @@ public class EssentialsGeoIP extends AbstractYesNoState
|
||||
}
|
||||
listener.onWorkDone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -44,4 +44,4 @@ public class EssentialsProtect extends AbstractYesNoState
|
||||
}
|
||||
listener.onWorkDone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,47 +0,0 @@
|
||||
package com.earth2me.essentials.update.states;
|
||||
|
||||
import com.earth2me.essentials.update.AbstractWorkListener;
|
||||
import com.earth2me.essentials.update.tasks.InstallModule;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class EssentialsSpawn extends AbstractYesNoState
|
||||
{
|
||||
public EssentialsSpawn(final StateMap states)
|
||||
{
|
||||
super(states, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean guessAnswer()
|
||||
{
|
||||
final Plugin plugin = Bukkit.getPluginManager().getPlugin("EssentialsSpawn");
|
||||
if (plugin != null)
|
||||
{
|
||||
setAnswer(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void askQuestion(final Player sender)
|
||||
{
|
||||
sender.sendMessage("Do you want to install EssentialsSpawn? (yes/no)");
|
||||
sender.sendMessage("EssentialsSpawn lets you control player spawning");
|
||||
sender.sendMessage("It allows you to set different places where players spawn on death, new players join and allows players to return to spawn.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(final AbstractWorkListener listener)
|
||||
{
|
||||
if (getAnswer())
|
||||
{
|
||||
new InstallModule(listener, "EssentialsSpawn").start();
|
||||
return;
|
||||
}
|
||||
listener.onWorkDone();
|
||||
}
|
||||
}
|
@@ -6,11 +6,16 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
public class InstallationFinishedEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@@ -37,4 +37,4 @@ public class Commandxmppspy extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
package com.earth2me.essentials.xmpp;
|
||||
|
||||
import com.earth2me.essentials.commands.EssentialsCommandHandler;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.ICommandHandler;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.commands.EssentialsCommandHandler;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
@@ -55,7 +55,7 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP
|
||||
|
||||
ess.addReloadListener(users);
|
||||
ess.addReloadListener(xmpp);
|
||||
|
||||
|
||||
commandHandler = new EssentialsCommandHandler(EssentialsXMPP.class.getClassLoader(), "com.earth2me.essentials.xmpp.Command", "essentials.", ess);
|
||||
}
|
||||
|
||||
|
@@ -11,14 +11,14 @@ import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jivesoftware.smack.Roster.SubscriptionMode;
|
||||
import org.jivesoftware.smack.*;
|
||||
import org.jivesoftware.smack.Roster.SubscriptionMode;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
|
||||
public class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IReload
|
||||
public final class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IReload
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient YamlConfiguration config = null;
|
||||
@@ -132,7 +132,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
|
||||
}
|
||||
}
|
||||
|
||||
public final void disconnect()
|
||||
public void disconnect()
|
||||
{
|
||||
if (loggerThread != null)
|
||||
{
|
||||
@@ -165,7 +165,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onReload()
|
||||
public void onReload()
|
||||
{
|
||||
LOGGER.removeHandler(this);
|
||||
config = YamlConfiguration.loadConfiguration(new File(parent.getDataFolder(), "config.yml"));
|
||||
|
Reference in New Issue
Block a user