Merge branch '2.x' of github.com:drtshock/Essentials into 2.x

This commit is contained in:
Ali Moghnieh 2015-10-30 19:23:00 +00:00
commit e5ebeaf724
7 changed files with 75 additions and 34 deletions

View File

@ -58,6 +58,8 @@ public interface ISettings extends IConf {
void addKit(String name, List<String> lines, long delay); void addKit(String name, List<String> lines, long delay);
boolean isSkippingUsedOneTimeKitsFromKitList();
String getLocale(); String getLocale();
String getNewbieSpawn(); String getNewbieSpawn();

View File

@ -56,7 +56,10 @@ public class Kit {
} }
Kit kit = new Kit(kitItem, ess); Kit kit = new Kit(kitItem, ess);
if (kit.getNextUse(user) != 0) { double nextUse = kit.getNextUse(user);
if (nextUse == -1 && ess.getSettings().isSkippingUsedOneTimeKitsFromKitList()) {
continue;
} else if (nextUse != 0) {
name = tl("kitDelay", name); name = tl("kitDelay", name);
} }

View File

@ -351,6 +351,11 @@ public class Settings implements net.ess3.api.ISettings {
config.save(); config.save();
} }
@Override
public boolean isSkippingUsedOneTimeKitsFromKitList() {
return config.getBoolean("skip-used-one-time-kits-from-kit-list", false);
}
private ChatColor operatorColor = null; private ChatColor operatorColor = null;
@Override @Override

View File

@ -11,6 +11,7 @@ import com.earth2me.essentials.utils.NumberUtil;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.api.MaxMoneyException; import net.ess3.api.MaxMoneyException;
import net.ess3.api.events.AfkStatusChangeEvent; import net.ess3.api.events.AfkStatusChangeEvent;
import net.ess3.api.events.JailStatusChangeEvent;
import net.ess3.api.events.UserBalanceUpdateEvent; import net.ess3.api.events.UserBalanceUpdateEvent;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -445,6 +446,10 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
//Returns true if status expired during this check //Returns true if status expired during this check
public boolean checkJailTimeout(final long currentTime) { public boolean checkJailTimeout(final long currentTime) {
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed()) { if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed()) {
final JailStatusChangeEvent event = new JailStatusChangeEvent(this, null, false);
ess.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
setJailTimeout(0); setJailTimeout(0);
setJailed(false); setJailed(false);
sendMessage(tl("haveBeenReleased")); sendMessage(tl("haveBeenReleased"));
@ -459,6 +464,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
} }
return true; return true;
} }
}
return false; return false;
} }

View File

@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.DateUtil; import com.earth2me.essentials.utils.DateUtil;
import net.ess3.api.events.JailStatusChangeEvent;
import org.bukkit.Server; import org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl; import static com.earth2me.essentials.I18n.tl;
@ -33,6 +34,11 @@ public class Commandtogglejail extends EssentialsCommand {
return; return;
} }
} }
final User controller = sender.isPlayer() ? ess.getUser(sender.getPlayer()) : null;
final JailStatusChangeEvent event = new JailStatusChangeEvent(player, controller, true);
ess.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (player.getBase().isOnline()) { if (player.getBase().isOnline()) {
ess.getJails().sendToJail(player, args[1]); ess.getJails().sendToJail(player, args[1]);
} else { } else {
@ -50,6 +56,7 @@ public class Commandtogglejail extends EssentialsCommand {
player.setJailTimeout(timeDiff); player.setJailTimeout(timeDiff);
} }
sender.sendMessage((timeDiff > 0 ? tl("playerJailedFor", player.getName(), DateUtil.formatDateDiff(timeDiff)) : tl("playerJailed", player.getName()))); sender.sendMessage((timeDiff > 0 ? tl("playerJailedFor", player.getName(), DateUtil.formatDateDiff(timeDiff)) : tl("playerJailed", player.getName())));
}
return; return;
} }
@ -70,6 +77,11 @@ public class Commandtogglejail extends EssentialsCommand {
if (!player.isJailed()) { if (!player.isJailed()) {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
final User controller = sender.isPlayer() ? ess.getUser(sender.getPlayer()) : null;
final JailStatusChangeEvent event = new JailStatusChangeEvent(player, controller, false);
ess.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
player.setJailed(false); player.setJailed(false);
player.setJailTimeout(0); player.setJailTimeout(0);
player.sendMessage(tl("jailReleasedPlayerNotify")); player.sendMessage(tl("jailReleasedPlayerNotify"));
@ -81,3 +93,4 @@ public class Commandtogglejail extends EssentialsCommand {
} }
} }
} }
}

View File

@ -250,6 +250,10 @@ player-commands:
- worth - worth
- xmpp - xmpp
# When this option is enabled, one-time use kits (ie. delay < 0) will be
# removed from the /kit list when a player can no longer use it
skip-used-one-time-kits-from-kit-list: false
# Note: All items MUST be followed by a quantity! # Note: All items MUST be followed by a quantity!
# All kit names should be lower case, and will be treated as lower in permissions/costs. # All kit names should be lower case, and will be treated as lower in permissions/costs.
# Syntax: - itemID[:DataValue/Durability] Amount [Enchantment:Level].. [itemmeta:value]... # Syntax: - itemID[:DataValue/Durability] Amount [Enchantment:Level].. [itemmeta:value]...

View File

@ -10,6 +10,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.world.PortalCreateEvent;
public class EssentialsProtectBlockListener implements Listener { public class EssentialsProtectBlockListener implements Listener {
@ -77,4 +78,11 @@ public class EssentialsProtectBlockListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPortalLight(PortalCreateEvent event) {
if (event.getReason() == PortalCreateEvent.CreateReason.FIRE) {
event.setCancelled(prot.getSettingBool(ProtectConfig.prevent_portal_creation));
}
}
} }