Merge branch 'refs/heads/master' into release

This commit is contained in:
snowleo 2011-11-17 15:34:27 +01:00
commit e271e60144
11 changed files with 108 additions and 10 deletions

View File

@ -30,7 +30,12 @@ public class Commandbanip extends EssentialsCommand
}
else
{
ess.getServer().banIP(u.getAddress().getAddress().getHostAddress());
final String ipAddress = u.getLastLoginAddress();
if (ipAddress.length() == 0)
{
throw new Exception(Util.i18n("playerNotFound"));
}
ess.getServer().banIP(u.getLastLoginAddress());
sender.sendMessage(Util.i18n("banIpAddress"));
}
}

View File

@ -38,7 +38,6 @@ public class Commandgamemode extends EssentialsCommand
}
}
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
//TODO: add this to messages?
sender.sendMessage(Util.format("gameMode", Util.i18n(player.getGameMode().toString().toLowerCase()), player.getDisplayName()));
}
}

View File

@ -50,7 +50,9 @@ public class Commandrepair extends EssentialsCommand
final List<String> repaired = new ArrayList<String>();
repairItems(user.getInventory().getContents(), user, repaired);
repairItems(user.getInventory().getArmorContents(), user, repaired);
if (user.isAuthorized("essentials.repair.armor")) {
repairItems(user.getInventory().getArmorContents(), user, repaired);
}
if (repaired.isEmpty())
{

View File

@ -0,0 +1,41 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
public class Commandsudo extends EssentialsCommand
{
public Commandsudo()
{
super("sudo");
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
throw new NotEnoughArgumentsException();
}
final User user = getPlayer(server, args, 0, false);
final String command = args[1];
final String[] arguments = new String[args.length - 2];
if (arguments.length > 0) {
System.arraycopy(args, 2, arguments, 0, args.length - 2);
}
//TODO: Translate this.
sender.sendMessage("Running the command as " + user.getDisplayName());
final PluginCommand pc = ess.getServer().getPluginCommand(command);
if (pc != null)
{
pc.execute(user.getBase(), command, arguments);
}
}
}

View File

@ -0,0 +1,36 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.GameMode;
public class SignGameMode extends EssentialsSign
{
public SignGameMode()
{
super("GameMode");
}
@Override
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{
validateTrade(sign, 1, ess);
return true;
}
@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
{
final Trade charge = getTrade(sign, 1, ess);
charge.isAffordableFor(player);
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
player.sendMessage(Util.format("gameMode", Util.i18n(player.getGameMode().toString().toLowerCase()), player.getDisplayName()));
charge.charge(player);
return true;
}
}

View File

@ -7,6 +7,7 @@ public enum Signs
BUY(new SignBuy()),
DISPOSAL(new SignDisposal()),
FREE(new SignFree()),
GAMEMODE(new SignGameMode()),
HEAL(new SignHeal()),
MAIL(new SignMail()),
PROTECTION(new SignProtection()),

View File

@ -274,6 +274,10 @@ commands:
description: Spawns a mob.
usage: /<command> <mob>[:data][,<mount>[:data]] [amount]
aliases: [espawnmob]
sudo:
description: Make another user do something.
usage: /<command> <player> <command [args]>
aliases: [esudo]
suicide:
description: Causes you to perish.
usage: /<command>

View File

@ -70,4 +70,6 @@ v 1.5:
If the files on Disc have changed AND there have been changes to it's in-memory data it will show a warning.
You then MUST issue a '/mansave force' to overwrite the disc files, or a '/manload' to overwrite the memory data.
- Fix for an error in checkFullUserPermission caused by players disconnecting mid perms update.
- Notification of being moved to the default group only happens if it's a demotion/promotion (not on join).
- Notification of being moved to the default group only happens if it's a demotion/promotion (not on join).
- Fixed GM holding files open and causing the time stamp to be incorrect. This caused GM to require a '/mansave force' when it shouldn't be needed.
- Fixed a crash on reload due to bukkit not unloading plugins before reloading.

View File

@ -130,6 +130,9 @@ public class GroupManager extends JavaPlugin {
throw new IllegalStateException("An error ocurred while loading GroupManager");
}
// Set a few defaults (reloads)
setLoaded(false);
// Initialize the world listener and bukkit permissions to handle
// events.
WorldEvents = new GMWorldListener(this);

View File

@ -338,7 +338,7 @@ public class WorldDataHolder {
}
this.setDefaultGroup(this.getGroup(ph.getDefaultGroup().getName()));
this.removeGroupsChangedFlag();
this.timeStampGroups = ph.getTimeStampGroups();
this.timeStampGroups = getGroupsFile().lastModified();
ph = null;
} catch (Exception ex) {
@ -368,7 +368,7 @@ public class WorldDataHolder {
tempUser.clone(this);
}
this.removeUsersChangedFlag();
this.timeStampUsers = ph.getTimeStampUsers();
this.timeStampUsers = getUsersFile().lastModified();
ph = null;
} catch (Exception ex) {
@ -925,6 +925,7 @@ public class WorldDataHolder {
out.write(newLine);
yaml.dump(root, out);
out.close();
} catch (UnsupportedEncodingException ex) {
} catch (FileNotFoundException ex) {
} catch (IOException e) {
@ -995,10 +996,13 @@ public class WorldDataHolder {
opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
final Yaml yaml = new Yaml(opt);
try {
yaml.dump(root, new OutputStreamWriter(new FileOutputStream(usersFile), "UTF-8"));
OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(usersFile), "UTF-8");
yaml.dump(root, out);
out.close();
} catch (UnsupportedEncodingException ex) {
} catch (FileNotFoundException ex) {
}
} catch (IOException e) {
}
}
// Update the LastModified time.

View File

@ -25,10 +25,11 @@ public class EssentialsProtectPlayerListener extends PlayerListener
@Override
public void onPlayerInteract(final PlayerInteractEvent event)
{
if (event.isCancelled())
// Do not return if cancelled, because the interact event has 2 cancelled states.
/*if (event.isCancelled())
{
return;
}
}*/
final User user = ess.getUser(event.getPlayer());
if (event.hasItem()