mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-07 15:16:41 +02:00
2.9 -> 3.0 merge
This commit is contained in:
@@ -120,6 +120,8 @@ public interface IUser extends Player, IStorageObjectHolder<UserData>, IReload,
|
||||
|
||||
void setInvSee(boolean invsee);
|
||||
|
||||
boolean hasInvulnerabilityAfterTeleport();
|
||||
|
||||
void update(final Player base);
|
||||
|
||||
}
|
||||
|
@@ -90,16 +90,10 @@ public class Commandkit extends EssentialsCommand
|
||||
throw new Exception(_("noKitPermission", "essentials.kit." + kitName));
|
||||
}
|
||||
final Kit kit = ess.getKits().getKit(kitName);
|
||||
|
||||
|
||||
|
||||
ess.getKits().checkTime(userFrom, kit);
|
||||
|
||||
final Trade charge = new Trade("kit-" + kitName, ess);
|
||||
charge.isAffordableFor(userFrom);
|
||||
|
||||
ess.getKits().sendKit(userTo, kit);
|
||||
|
||||
charge.charge(userFrom);
|
||||
userTo.sendMessage(_("kitGive", kitName));
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ public class Commandpowertool extends EssentialsCommand
|
||||
}
|
||||
|
||||
final String itemName = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replaceAll("_", " ");
|
||||
user.acquireReadLock();
|
||||
List<String> powertools = user.getData().getPowertool(itemStack.getType());
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
|
@@ -0,0 +1,51 @@
|
||||
package com.earth2me.essentials.craftbukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.ChunkPosition;
|
||||
import net.minecraft.server.Packet60Explosion;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
|
||||
public class FakeExplosion
|
||||
{
|
||||
public static void createExplosion(final EntityExplodeEvent event, final Server server, final Player[] players)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
|
||||
final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length);
|
||||
final Location loc = event.getLocation();
|
||||
for (Player player : players)
|
||||
{
|
||||
if (player.getWorld().equals(loc.getWorld()))
|
||||
{
|
||||
blocksUnderPlayers.add(new ChunkPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ()));
|
||||
}
|
||||
}
|
||||
for (Block block : event.blockList())
|
||||
{
|
||||
final ChunkPosition cp = new ChunkPosition(block.getX(), block.getY(), block.getZ());
|
||||
if (!blocksUnderPlayers.contains(cp))
|
||||
{
|
||||
set.add(cp);
|
||||
}
|
||||
}
|
||||
((CraftServer)server).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,9 +5,11 @@ import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import com.earth2me.essentials.user.UserData.TimestampType;
|
||||
import java.util.List;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -33,34 +35,59 @@ public class EssentialsEntityListener implements Listener
|
||||
{
|
||||
final Entity eAttack = event.getDamager();
|
||||
final Entity eDefend = event.getEntity();
|
||||
|
||||
if (eDefend instanceof Player && eAttack instanceof Player)
|
||||
{
|
||||
@Cleanup
|
||||
final IUser attacker = ess.getUser((Player)eAttack);
|
||||
@Cleanup
|
||||
final IUser defender = ess.getUser((Player)eDefend);
|
||||
@Cleanup
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
attacker.acquireReadLock();
|
||||
defender.acquireReadLock();
|
||||
|
||||
attacker.updateActivity(true);
|
||||
if (settings.getData().getGeneral().getLoginAttackDelay() > 0 && !Permissions.PVPDELAY_EXEMPT.isAuthorized(attacker)
|
||||
&& (System.currentTimeMillis() < (attacker.getTimestamp(TimestampType.LOGIN) + settings.getData().getGeneral().getLoginAttackDelay())))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
final ItemStack itemstack = attacker.getItemInHand();
|
||||
final List<String> commandList = attacker.getData().getPowertool(itemstack.getType());
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
{
|
||||
for (String command : commandList)
|
||||
for (final String command : commandList)
|
||||
{
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", ((Player)eDefend).getName()));
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker.getBase(), command.replaceAll("\\{player\\}", defender.getName()));
|
||||
}
|
||||
});
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (eDefend instanceof Animals && eAttack instanceof Player)
|
||||
else if (eDefend instanceof Ageable && eAttack instanceof Player)
|
||||
{
|
||||
final Player player = (Player)eAttack;
|
||||
final ItemStack hand = player.getItemInHand();
|
||||
if (hand != null && hand.getType() == Material.MILK_BUCKET)
|
||||
{
|
||||
((Animals)eDefend).setBaby();
|
||||
((Ageable)eDefend).setBaby();
|
||||
hand.setType(Material.BUCKET);
|
||||
player.setItemInHand(hand);
|
||||
player.updateInventory();
|
||||
|
@@ -59,6 +59,7 @@ public enum Permissions implements IPermission
|
||||
OVERSIZEDSTACKS(PermissionDefault.FALSE),
|
||||
POWERTOOL_APPEND,
|
||||
PTIME_OTHERS,
|
||||
PVPDELAY_EXEMPT,
|
||||
REPAIR_ARMOR,
|
||||
REPAIR_ENCHANTED,
|
||||
SEEN_BANREASON,
|
||||
|
@@ -81,9 +81,9 @@ public class General implements StorageObject
|
||||
"Give someone permission to teleport to a world with essentials.world.<worldname>"
|
||||
})
|
||||
private boolean worldTeleportPermissions = false;
|
||||
|
||||
private boolean worldHomePermissions = false;
|
||||
|
||||
|
||||
@Comment("Prevent creatures spawning")
|
||||
private Map<String, Boolean> creatureSpawn = new HashMap<String, Boolean>();
|
||||
|
||||
@@ -95,4 +95,12 @@ public class General implements StorageObject
|
||||
}
|
||||
return creatureSpawn.get(creatureName);
|
||||
}
|
||||
|
||||
@Comment("Delay to wait before people can cause attack damage after logging in ")
|
||||
private long loginAttackDelay = 0;
|
||||
|
||||
public long getLoginAttackDelay()
|
||||
{
|
||||
return loginAttackDelay * 1000;
|
||||
}
|
||||
}
|
||||
|
@@ -739,6 +739,10 @@ public class User extends UserBase implements IUser
|
||||
teleportInvulnerabilityTimestamp = 0;
|
||||
}
|
||||
}
|
||||
public boolean hasInvulnerabilityAfterTeleport()
|
||||
{
|
||||
return teleportInvulnerabilityTimestamp != 0 && teleportInvulnerabilityTimestamp >= System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleVanished()
|
||||
|
@@ -112,16 +112,9 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation()
|
||||
{
|
||||
if (isOnlineUser())
|
||||
{
|
||||
return base.getBedSpawnLocation();
|
||||
}
|
||||
else
|
||||
{
|
||||
return offlinePlayer.getBedSpawnLocation();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanned(boolean bln)
|
||||
|
@@ -696,7 +696,8 @@ public class EssentialsUpgrade
|
||||
{
|
||||
return;
|
||||
}
|
||||
ess.getSettings().setMetricsEnabled(false);
|
||||
//todo - metrics
|
||||
// ess.getSettings().setMetricsEnabled(false);
|
||||
doneFile.setProperty("warnMetrics", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
@@ -112,6 +112,7 @@ public abstract class EssentialsChatPlayer implements Listener
|
||||
|
||||
protected void handleLocalChat(final PlayerChatEvent event, final ChatStore chatStore)
|
||||
{
|
||||
|
||||
long radius = 0;
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
@@ -143,26 +144,6 @@ public abstract class EssentialsChatPlayer implements Listener
|
||||
event.setFormat(_(format.toString(), event.getFormat()));
|
||||
return;
|
||||
}
|
||||
if (!onlineUser.equals(sender))
|
||||
{
|
||||
if (onlineUser.isAuthorized("essentials.chat.spy"))
|
||||
{
|
||||
type = type.concat(_("chatTypeSpy"));
|
||||
}
|
||||
else
|
||||
{
|
||||
final Location playerLoc = onlineUser.getLocation();
|
||||
if (playerLoc.getWorld() != world)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final double delta = playerLoc.distanceSquared(loc);
|
||||
if (delta > chatStore.getRadius())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final StringBuilder errorMsg = new StringBuilder();
|
||||
errorMsg.append("notAllowedTo").append(chatStore.getType().substring(0, 1).toUpperCase(Locale.ENGLISH)).append(chatStore.getType().substring(1));
|
||||
|
@@ -43,6 +43,12 @@ public class EssentialsLocalChatEventListener implements Listener
|
||||
continue;
|
||||
}
|
||||
if (!user.equals(sender))
|
||||
{
|
||||
if (Permissions.CHAT_SPY.isAuthorized(user))
|
||||
{
|
||||
type = type.concat(_("chatTypeSpy"));
|
||||
}
|
||||
else
|
||||
{
|
||||
final Location playerLoc = user.getLocation();
|
||||
if (playerLoc.getWorld() != world)
|
||||
@@ -52,20 +58,15 @@ public class EssentialsLocalChatEventListener implements Listener
|
||||
final double delta = playerLoc.distanceSquared(loc);
|
||||
|
||||
if (delta > event.getRadius())
|
||||
{
|
||||
if (Permissions.CHAT_SPY.isAuthorized(user))
|
||||
{
|
||||
type = type.concat(_("chatTypeSpy"));
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final String message = type.concat(String.format(event.getFormat(), sender.getDisplayName(), event.getMessage()));
|
||||
user.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -24,4 +24,16 @@ public class ConfigHolder extends AsyncStorageObjectHolder<GeoIP>
|
||||
return new File(geoip.getDataFolder(), "config.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRead()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishWrite()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.protect;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.craftbukkit.FakeExplosion;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
@@ -3,7 +3,7 @@ package com.earth2me.essentials.signs;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
|
||||
|
||||
public class SignBalance extends EssentialsSign
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
@@ -32,7 +33,9 @@ public class SignBlockListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockBreak(final BlockBreakEvent event)
|
||||
{
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
if (plugin.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -65,14 +68,6 @@ public class SignBlockListener implements Listener
|
||||
LOGGER.log(Level.INFO, "Prevented that a block was broken next to a sign.");
|
||||
return true;
|
||||
}
|
||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||
{
|
||||
if (sign.getBlocks().contains(block.getType())
|
||||
&& !sign.onBlockBreak(block, player, ess))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "A block was protected by a sign.");
|
||||
return true;
|
||||
}
|
||||
for (EssentialsSign sign : plugin.getSettings().getEnabledSigns())
|
||||
{
|
||||
if (sign.getBlocks().contains(block.getType())
|
||||
@@ -82,18 +77,17 @@ public class SignBlockListener implements Listener
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onSignChange(final SignChangeEvent event)
|
||||
{
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
if (plugin.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
IUser user = ess.getUser(event.getPlayer());
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -120,7 +114,7 @@ public class SignBlockListener implements Listener
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockPlace(final BlockPlaceEvent event)
|
||||
{
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
if (plugin.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -154,7 +148,7 @@ public class SignBlockListener implements Listener
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockBurn(final BlockBurnEvent event)
|
||||
{
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
if (plugin.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -182,7 +176,7 @@ public class SignBlockListener implements Listener
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockIgnite(final BlockIgniteEvent event)
|
||||
{
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
if (plugin.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ public class SignEntityListener implements Listener
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityChangeBlock(final EntityChangeBlockEvent event)
|
||||
{
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
if (plugin.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -58,11 +59,10 @@ public class SignKit extends EssentialsSign
|
||||
final Trade charge = getTrade(sign, 3, ess);
|
||||
charge.isAffordableFor(player);
|
||||
try
|
||||
{
|
||||
{;
|
||||
final Kit kit = ess.getKits().getKit(kitName);
|
||||
Kit.checkTime(player, kitName, kit);
|
||||
final List<String> items = Kit.getItems(player, kit);
|
||||
Kit.expandItems(ess, player, items);
|
||||
ess.getKits().checkTime(player, kit);
|
||||
ess.getKits().sendKit(player,kit);
|
||||
charge.charge(player);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@@ -25,7 +25,7 @@ public class SignPlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
if (ess.getSettings().areSignsDisabled() || event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
if (plugin.getSettings().areSignsDisabled() || event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig>
|
||||
{
|
||||
private final Plugin plugin;
|
||||
private Set<EssentialsSign> enabledSigns = new HashSet<EssentialsSign>();
|
||||
private boolean signsEnabled = false;
|
||||
|
||||
public SignsConfigHolder(final IEssentials ess, final Plugin plugin)
|
||||
{
|
||||
@@ -24,6 +25,11 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig>
|
||||
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"))
|
||||
{
|
||||
signsEnabled = true;
|
||||
continue;
|
||||
}
|
||||
Signs sign = Signs.valueOf(entry.getKey().toUpperCase(Locale.ENGLISH));
|
||||
if (sign != null && entry.getValue())
|
||||
{
|
||||
@@ -61,4 +67,21 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig>
|
||||
{
|
||||
return enabledSigns;
|
||||
}
|
||||
|
||||
public boolean areSignsDisabled()
|
||||
{
|
||||
return !signsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRead()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishWrite()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -13,10 +13,4 @@ public class InstallationFinishedEvent extends Event
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user