mirror of
https://github.com/EssentialsX/Essentials.git
synced 2026-11-08 18:15:29 -05:00
Compare commits
97
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4aecc034c2 | ||
|
|
a111a07bca | ||
|
|
9ec398b39b | ||
|
|
eb71097546 | ||
|
|
1bb3eb0d07 | ||
|
|
5395b6f73a | ||
|
|
5851c5a88b | ||
|
|
1c1726cfa4 | ||
|
|
a6bafca091 | ||
|
|
6877f95636 | ||
|
|
cb41b7ac33 | ||
|
|
d2fa4523ce | ||
|
|
9129386f12 | ||
|
|
c7fcb72d6c | ||
|
|
02ee314ab1 | ||
|
|
04af8ef329 | ||
|
|
a34c92d55a | ||
|
|
4cdf803ab7 | ||
|
|
6012086fa5 | ||
|
|
67c0f57756 | ||
|
|
164070b487 | ||
|
|
d658c75cec | ||
|
|
4c69412501 | ||
|
|
75a0164ea0 | ||
|
|
9dde04e4b8 | ||
|
|
3496df6468 | ||
|
|
ac794bb2b7 | ||
|
|
7384991efa | ||
|
|
f3dc846b1b | ||
|
|
4595c15bee | ||
|
|
81994160e8 | ||
|
|
cf59a90c52 | ||
|
|
a9a87710f3 | ||
|
|
5984cd5835 | ||
|
|
8fe0887141 | ||
|
|
8389a59d54 | ||
|
|
010245e1a5 | ||
|
|
1e3d2fbfd2 | ||
|
|
313df9988d | ||
|
|
16384159e7 | ||
|
|
06900e19f0 | ||
|
|
57c25bf151 | ||
|
|
55fc8bdd57 | ||
|
|
ae030b227a | ||
|
|
aaf25d8b9a | ||
|
|
0645d58594 | ||
|
|
11d22f95cc | ||
|
|
4f85751694 | ||
|
|
65a78a6ea9 | ||
|
|
9f52931191 | ||
|
|
93d0ab7906 | ||
|
|
6b0d0daa2e | ||
|
|
9718e654ac | ||
|
|
4d5121c21d | ||
|
|
531f40ceee | ||
|
|
b672d38db8 | ||
|
|
401498a4f7 | ||
|
|
acdad5c6ac | ||
|
|
1a0aa7970b | ||
|
|
579b30c8f7 | ||
|
|
c1fa543524 | ||
|
|
0297d22fac | ||
|
|
608ebfdb4a | ||
|
|
da337284e5 | ||
|
|
0aa9f79629 | ||
|
|
9f4d79a756 | ||
|
|
aa0935c64b | ||
|
|
16111b56ad | ||
|
|
4c0fc6e52f | ||
|
|
7668af15b0 | ||
|
|
3b9aa445e9 | ||
|
|
b2614e363b | ||
|
|
49e2c38289 | ||
|
|
3030093907 | ||
|
|
0e867df195 | ||
|
|
bfd6049913 | ||
|
|
d2c02569d0 | ||
|
|
1f6daa7424 | ||
|
|
30af6f36ce | ||
|
|
f712b56671 | ||
|
|
0462026f33 | ||
|
|
ea76161ba5 | ||
|
|
629dee3a91 | ||
|
|
f415924811 | ||
|
|
4172c563d0 | ||
|
|
ab67d0e232 | ||
|
|
5ea512817a | ||
|
|
d4c7ea1cd1 | ||
|
|
4edf1ad3f5 | ||
|
|
6224b07215 | ||
|
|
a5239ef601 | ||
|
|
458068ae87 | ||
|
|
44e920e441 | ||
|
|
f8450e39e3 | ||
|
|
c6e68f72ea | ||
|
|
4a52cd7c98 | ||
|
|
9d68261bac |
No files matched your search
@@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
@@ -12,7 +13,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
public class Backup implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient final CraftServer server;
|
||||
private transient final Server server;
|
||||
private transient final IEssentials ess;
|
||||
private transient boolean running = false;
|
||||
private transient int taskId = -1;
|
||||
@@ -21,7 +22,7 @@ public class Backup implements Runnable
|
||||
public Backup(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
server = (CraftServer)ess.getServer();
|
||||
server = ess.getServer();
|
||||
if (server.getOnlinePlayers().length > 0)
|
||||
{
|
||||
startTask();
|
||||
@@ -60,7 +61,7 @@ public class Backup implements Runnable
|
||||
return;
|
||||
}
|
||||
LOGGER.log(Level.INFO, Util.i18n("backupStarted"));
|
||||
final CommandSender cs = server.getServer().console;
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
server.dispatchCommand(cs, "save-off");
|
||||
|
||||
|
||||
@@ -2,33 +2,35 @@ package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
public final class Console implements IReplyTo {
|
||||
|
||||
public final class Console implements IReplyTo
|
||||
{
|
||||
private static Console instance = new Console();
|
||||
private CommandSender replyTo;
|
||||
public final static String NAME = "Console";
|
||||
|
||||
private Console() {
|
||||
|
||||
}
|
||||
|
||||
public static CommandSender getCommandSender(Server server) throws Exception {
|
||||
if (! (server instanceof CraftServer)) {
|
||||
throw new Exception(Util.i18n("invalidServer"));
|
||||
}
|
||||
return ((CraftServer)server).getServer().console;
|
||||
|
||||
private Console()
|
||||
{
|
||||
}
|
||||
|
||||
public void setReplyTo(CommandSender user) {
|
||||
public static CommandSender getCommandSender(Server server) throws Exception
|
||||
{
|
||||
return server.getConsoleSender();
|
||||
}
|
||||
|
||||
public void setReplyTo(CommandSender user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
|
||||
public CommandSender getReplyTo() {
|
||||
public CommandSender getReplyTo()
|
||||
{
|
||||
return replyTo;
|
||||
}
|
||||
|
||||
public static Console getConsoleReplyTo() {
|
||||
|
||||
public static Console getConsoleReplyTo()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
Executable → Regular
File mode changed.
@@ -164,6 +164,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
pm.registerEvent(Type.PLAYER_EGG_THROW, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_ANIMATION, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_BED_ENTER, playerListener, Priority.Lowest, this);
|
||||
|
||||
final EssentialsBlockListener blockListener = new EssentialsBlockListener(this);
|
||||
pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Lowest, this);
|
||||
@@ -201,11 +202,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
pm.registerEvent(Type.PLAYER_TELEPORT, jailPlayerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_JOIN, jailPlayerListener, Priority.High, this);
|
||||
|
||||
if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2)
|
||||
{
|
||||
getServer().createWorld(settings.getNetherName(), World.Environment.NETHER);
|
||||
}
|
||||
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, tntListener, Priority.High, this);
|
||||
|
||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
@@ -93,7 +94,7 @@ public class EssentialsBlockListener extends BlockListener
|
||||
return;
|
||||
}
|
||||
boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (unlimitedForUser)
|
||||
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -69,16 +70,21 @@ public class EssentialsEntityListener extends EntityListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
public void onEntityDeath(final EntityDeathEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player)
|
||||
if (event instanceof PlayerDeathEvent)
|
||||
{
|
||||
User user = ess.getUser(event.getEntity());
|
||||
final PlayerDeathEvent pdevent = (PlayerDeathEvent)event;
|
||||
final User user = ess.getUser(pdevent.getEntity());
|
||||
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
|
||||
{
|
||||
user.setLastLocation();
|
||||
user.sendMessage(Util.i18n("backAfterDeath"));
|
||||
}
|
||||
if (!ess.getSettings().areDeathMessagesEnabled())
|
||||
{
|
||||
pdevent.setDeathMessage("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +93,9 @@ public class EssentialsEntityListener extends EntityListener
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
//TODO: Remove the following line, when we're happy to remove backwards compatability with 1185.
|
||||
event.setFoodLevel(20);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
import org.bukkit.event.player.PlayerAnimationType;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
@@ -46,11 +47,11 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setDisplayName(user.getNick());
|
||||
user.setDisplayNick(user.getNick());
|
||||
updateCompass(user);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
user.setDisplayNick(user.getNick());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
user.updateActivity(true);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
user.setDisplayNick(user.getNick());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,120 +95,24 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo().clone();
|
||||
to.setX(from.getX());
|
||||
to.setY(from.getBlock().getTypeId() == 0 ? from.getY() - 1 : from.getY());
|
||||
to.setY(from.getY());
|
||||
to.setZ(from.getZ());
|
||||
event.setTo(to);
|
||||
try
|
||||
{
|
||||
event.setTo(Util.getSafeDestination(to));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
event.setTo(to);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Location afk = user.getAfkPosition();
|
||||
final Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
|
||||
{
|
||||
user.updateActivity(true);
|
||||
}
|
||||
|
||||
if (!ess.getSettings().getNetherPortalsEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Block block = event.getPlayer().getWorld().getBlockAt(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
|
||||
final List<World> worlds = server.getWorlds();
|
||||
|
||||
if (block.getType() == Material.PORTAL && worlds.size() > 1 && user.isAuthorized("essentials.portal"))
|
||||
{
|
||||
if (user.getJustPortaled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
World nether = server.getWorld(ess.getSettings().getNetherName());
|
||||
if (nether == null)
|
||||
{
|
||||
for (World world : worlds)
|
||||
{
|
||||
if (world.getEnvironment() == World.Environment.NETHER)
|
||||
{
|
||||
nether = world;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nether == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
final World world = user.getWorld() == nether ? worlds.get(0) : nether;
|
||||
|
||||
double factor;
|
||||
if (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL)
|
||||
{
|
||||
factor = ess.getSettings().getNetherRatio();
|
||||
}
|
||||
else if (user.getWorld().getEnvironment() == World.Environment.NORMAL && world.getEnvironment() == World.Environment.NETHER)
|
||||
{
|
||||
factor = 1.0 / ess.getSettings().getNetherRatio();
|
||||
}
|
||||
else
|
||||
{
|
||||
factor = 1.0;
|
||||
}
|
||||
|
||||
Location loc = event.getTo();
|
||||
int x = loc.getBlockX();
|
||||
int y = loc.getBlockY();
|
||||
int z = loc.getBlockZ();
|
||||
|
||||
if (user.getWorld().getBlockAt(x, y, z - 1).getType() == Material.PORTAL)
|
||||
{
|
||||
z--;
|
||||
}
|
||||
if (user.getWorld().getBlockAt(x - 1, y, z).getType() == Material.PORTAL)
|
||||
{
|
||||
x--;
|
||||
}
|
||||
|
||||
x = (int)(x * factor);
|
||||
z = (int)(z * factor);
|
||||
loc = new Location(world, x + .5, y, z + .5);
|
||||
|
||||
Block dest = world.getBlockAt(x, y, z);
|
||||
NetherPortal portal = NetherPortal.findPortal(dest);
|
||||
if (portal == null)
|
||||
{
|
||||
if (world.getEnvironment() == World.Environment.NETHER || ess.getSettings().getGenerateExitPortals())
|
||||
{
|
||||
portal = NetherPortal.createPortal(dest);
|
||||
LOGGER.info(Util.format("userCreatedPortal", event.getPlayer().getName()));
|
||||
user.sendMessage(Util.i18n("generatingPortal"));
|
||||
loc = portal.getSpawn();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(Util.format("userUsedPortal", event.getPlayer().getName()));
|
||||
user.sendMessage(Util.i18n("usingPortal"));
|
||||
loc = portal.getSpawn();
|
||||
}
|
||||
|
||||
event.setFrom(loc);
|
||||
event.setTo(loc);
|
||||
try
|
||||
{
|
||||
user.getTeleport().now(loc, new Trade("portal", ess));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
user.sendMessage(ex.getMessage());
|
||||
}
|
||||
user.setJustPortaled(true);
|
||||
user.sendMessage(Util.i18n("teleportingPortal"));
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
user.setJustPortaled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -262,7 +167,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
user.setDisplayNick(user.getNick());
|
||||
}
|
||||
user.updateActivity(false);
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
@@ -351,7 +256,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
user.setDisplayNick(user.getNick());
|
||||
}
|
||||
updateCompass(user);
|
||||
}
|
||||
@@ -483,4 +388,16 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerBedEnter(PlayerBedEnterEvent event)
|
||||
{
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (event.getPlayer().isSleepingIgnored()) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage("You can't go to bed, your sleep is ignored.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class FakeInventory implements Inventory
|
||||
{
|
||||
ItemStack[] items;
|
||||
|
||||
public FakeInventory(ItemStack[] items)
|
||||
{
|
||||
this.items = new ItemStack[items.length];
|
||||
for (int i = 0; i < items.length; i++)
|
||||
{
|
||||
if (items[i] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
this.items[i] = new ItemStack(items[i].getTypeId(), items[i].getAmount(), items[i].getDurability());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize()
|
||||
{
|
||||
return items.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(int i)
|
||||
{
|
||||
return items[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(int i, ItemStack is)
|
||||
{
|
||||
items[i] = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ItemStack> addItem(ItemStack... iss)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ItemStack> removeItem(ItemStack... iss)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getContents()
|
||||
{
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContents(ItemStack[] iss)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Material mtrl)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ItemStack is)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int i, int i1)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Material mtrl, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ItemStack is, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ? extends ItemStack> all(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ? extends ItemStack> all(Material mtrl)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ? extends ItemStack> all(ItemStack is)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int first(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int first(Material mtrl)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int first(ItemStack is)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int firstEmpty()
|
||||
{
|
||||
for (int i = 0; i < items.length; i++)
|
||||
{
|
||||
if (items[i] == null || items[i].getTypeId() == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Material mtrl)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(ItemStack is)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(int i)
|
||||
{
|
||||
items[i] = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
for (int i = 0; i < items.length; i++)
|
||||
{
|
||||
items[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.util.UUID;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TreeType;
|
||||
@@ -437,4 +438,21 @@ public class FakeWorld implements World
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Difficulty getDifficulty()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDifficulty(Difficulty difficulty)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSeaLevel()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
@@ -35,8 +35,6 @@ public interface ISettings extends IConf
|
||||
|
||||
int getDefaultStackSize();
|
||||
|
||||
boolean getGenerateExitPortals();
|
||||
|
||||
double getHealCooldown();
|
||||
|
||||
Object getKit(String name);
|
||||
@@ -45,12 +43,6 @@ public interface ISettings extends IConf
|
||||
|
||||
String getLocale();
|
||||
|
||||
String getNetherName();
|
||||
|
||||
boolean getNetherPortalsEnabled();
|
||||
|
||||
double getNetherRatio();
|
||||
|
||||
String getNewbieSpawn();
|
||||
|
||||
String getNicknamePrefix();
|
||||
@@ -73,7 +65,11 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean getRespawnAtHome();
|
||||
|
||||
int getMultipleHomes();
|
||||
List getMultipleHomes();
|
||||
|
||||
int getHomeLimit(String set);
|
||||
|
||||
int getHomeLimit(User user);
|
||||
|
||||
boolean getSortListByGroups();
|
||||
|
||||
@@ -101,8 +97,6 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean isEcoDisabled();
|
||||
|
||||
boolean isNetherEnabled();
|
||||
|
||||
boolean isTradeInStacks(int id);
|
||||
|
||||
List<Integer> itemSpawnBlacklist();
|
||||
@@ -113,8 +107,6 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean spawnIfNoHome();
|
||||
|
||||
boolean use1to1RatioInNether();
|
||||
|
||||
boolean warnOnBuildDisallow();
|
||||
|
||||
boolean warnOnSmite();
|
||||
@@ -140,4 +132,6 @@ public interface ISettings extends IConf
|
||||
long getAutoAfkKick();
|
||||
|
||||
boolean getFreezeAfkPlayers();
|
||||
|
||||
boolean areDeathMessagesEnabled();
|
||||
}
|
||||
@@ -64,6 +64,20 @@ public final class InventoryWorkaround
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static boolean addAllItems(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
|
||||
{
|
||||
final Inventory fake = new FakeInventory(cinventory.getContents());
|
||||
if (addItem(fake, forceDurability, items).isEmpty())
|
||||
{
|
||||
addItem(cinventory, forceDurability, items);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
|
||||
{
|
||||
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
@@ -106,7 +120,7 @@ public final class InventoryWorkaround
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Do we already have a stack of it?
|
||||
|
||||
@@ -26,11 +26,10 @@ public enum Mob
|
||||
SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER),
|
||||
SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID),
|
||||
ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE),
|
||||
MONSTER("Monster", Enemies.ENEMY, CreatureType.MONSTER),
|
||||
WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF),
|
||||
CAVESPIDER("CaveSpider", Enemies.ENEMY, CreatureType.CAVE_SPIDER),
|
||||
ENDERMAN("Enderman", Enemies.ENEMY, CreatureType.ENDERMAN),
|
||||
SILVERFISH("Silverfish", Enemies.ENEMY, CreatureType.SILVERFISH);
|
||||
ENDERMAN("Enderman", Enemies.ENEMY, "", CreatureType.ENDERMAN),
|
||||
SILVERFISH("Silverfish", Enemies.ENEMY, "", CreatureType.SILVERFISH);
|
||||
|
||||
public static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
/**
|
||||
* @author SpaceManiac
|
||||
* @licent MIT
|
||||
* @origin https://github.com/SpaceManiac/Nether/blob/master/org/innectis/Nether/NetherPortal.java
|
||||
*/
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class NetherPortal
|
||||
{
|
||||
private Block block;
|
||||
|
||||
public NetherPortal(Block b)
|
||||
{
|
||||
block = b;
|
||||
}
|
||||
|
||||
public Block getBlock()
|
||||
{
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(Block b)
|
||||
{
|
||||
block = b;
|
||||
}
|
||||
|
||||
// Return a random spawnable location
|
||||
public Location getSpawn()
|
||||
{
|
||||
if (block.getWorld().getBlockAt(block.getX() + 1, block.getY(), block.getZ()).getType().equals(Material.PORTAL)
|
||||
|| block.getWorld().getBlockAt(block.getX() - 1, block.getY(), block.getZ()).getType().equals(Material.PORTAL))
|
||||
{
|
||||
// portal is in X direction
|
||||
return new Location(block.getWorld(), block.getX() + 1,
|
||||
block.getY(), block.getZ() + 1 - 2 * Math.round(Math.random()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// portal is in Z direction
|
||||
return new Location(block.getWorld(), block.getX() + 1 - 2 * Math.round(Math.random()),
|
||||
block.getY(), block.getZ() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// ==============================
|
||||
// Find a nearby portal within 16 blocks of the given block
|
||||
// Not guaranteed to be the nearest
|
||||
public static NetherPortal findPortal(Block dest)
|
||||
{
|
||||
World world = dest.getWorld();
|
||||
|
||||
// Get list of columns in a circle around the block
|
||||
ArrayList<Block> columns = new ArrayList<Block>();
|
||||
for (int x = dest.getX() - 16; x <= dest.getX() + 16; ++x)
|
||||
{
|
||||
for (int z = dest.getZ() - 16; z <= dest.getZ() + 16; ++z)
|
||||
{
|
||||
int dx = dest.getX() - x, dz = dest.getZ() - z;
|
||||
if (dx * dx + dz * dz <= 256)
|
||||
{
|
||||
columns.add(world.getBlockAt(x, 0, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For each column try to find a portal block
|
||||
for (Block col : columns)
|
||||
{
|
||||
for (int y = 127; y >= 0; --y)
|
||||
{
|
||||
Block b = world.getBlockAt(col.getX(), y, col.getZ());
|
||||
if (b.getType().equals(Material.PORTAL) && Math.abs(dest.getY() - y) <= 16)
|
||||
{
|
||||
// Huzzah!
|
||||
return new NetherPortal(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nope!
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create a new portal at the specified block, fudging position if needed
|
||||
// Will occasionally end up making portals in bad places, but let's hope not
|
||||
public static NetherPortal createPortal(Block dest)
|
||||
{
|
||||
World world = dest.getWorld();
|
||||
|
||||
// Try not to spawn within water or lava
|
||||
Material m = dest.getType();
|
||||
while (((m.equals(Material.LAVA) || m.equals(Material.WATER) || m.equals(Material.STATIONARY_LAVA)
|
||||
|| m.equals(Material.STATIONARY_WATER) || m.equals(Material.SAND) || m.equals(Material.GRAVEL))) &&
|
||||
dest.getY() < 120)
|
||||
{
|
||||
dest = world.getBlockAt(dest.getX(), dest.getY() + 4, dest.getZ());
|
||||
m = dest.getType();
|
||||
}
|
||||
|
||||
// Not too high or too low overall
|
||||
if (dest.getY() > 120)
|
||||
{
|
||||
dest = world.getBlockAt(dest.getX(), 120, dest.getZ());
|
||||
}
|
||||
else if (dest.getY() < 8)
|
||||
{
|
||||
dest = world.getBlockAt(dest.getX(), 8, dest.getZ());
|
||||
}
|
||||
|
||||
// Create the physical portal
|
||||
// For now, don't worry about direction
|
||||
|
||||
int x = dest.getX(), y = dest.getY(), z = dest.getZ();
|
||||
Logger.getLogger("Minecraft").log(Level.INFO, Util.format("creatingPortal", x, y, z));
|
||||
|
||||
// Clear area around portal
|
||||
ArrayList<Block> columns = new ArrayList<Block>();
|
||||
for (int x2 = x - 4; x2 <= x + 4; ++x2)
|
||||
{
|
||||
for (int z2 = z - 4; z2 <= z + 4; ++z2)
|
||||
{
|
||||
double dx = x + 0.5f - x2, dz = z - z2;
|
||||
if (dx * dx + dz * dz <= 13)
|
||||
{
|
||||
columns.add(world.getBlockAt(x2, 0, z2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear area around portal
|
||||
for (Block col : columns)
|
||||
{
|
||||
// Stone platform
|
||||
world.getBlockAt(col.getX(), y - 1, col.getZ()).setType(Material.STONE);
|
||||
for (int yd = 0; yd < 4; ++yd)
|
||||
{
|
||||
world.getBlockAt(col.getX(), y + yd, col.getZ()).setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
// Build obsidian frame
|
||||
for (int xd = -1; xd < 3; ++xd)
|
||||
{
|
||||
for (int yd = -1; yd < 4; ++yd)
|
||||
{
|
||||
if (xd == -1 || yd == -1 || xd == 2 || yd == 3)
|
||||
{
|
||||
world.getBlockAt(x + xd, y + yd, z).setType(Material.OBSIDIAN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set it alight!
|
||||
dest.setType(Material.FIRE);
|
||||
|
||||
return new NetherPortal(dest);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.earth2me.essentials;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Achievement;
|
||||
@@ -695,7 +696,7 @@ public class OfflinePlayer implements Player
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation()
|
||||
{
|
||||
@@ -713,5 +714,34 @@ public class OfflinePlayer implements Player
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPlayerListName(String name)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerListName()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTicksLived()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTicksLived(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> serialize()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
@@ -16,15 +16,6 @@ public class PlayerExtension extends PlayerWrapper
|
||||
super(base);
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public float getCorrectedYaw()
|
||||
{
|
||||
float angle = (getLocation().getYaw() - 90.0f) % 360.0f;
|
||||
if (angle < 0) {
|
||||
angle += 360.0f;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
public void showInventory(IInventory inventory)
|
||||
{
|
||||
|
||||
@@ -744,4 +744,34 @@ public class PlayerWrapper implements Player
|
||||
base.setSprinting(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerListName(String name)
|
||||
{
|
||||
base.setPlayerListName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerListName()
|
||||
{
|
||||
return base.getPlayerListName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTicksLived()
|
||||
{
|
||||
return base.getTicksLived();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTicksLived(int i)
|
||||
{
|
||||
base.setTicksLived(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> serialize()
|
||||
{
|
||||
return base.serialize();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,12 +30,6 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("respawn-at-home", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMultipleHomes()
|
||||
{
|
||||
return config.getInt("multiple-homes", 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBedSetsHome()
|
||||
@@ -43,6 +37,40 @@ public class Settings implements ISettings
|
||||
return config.getBoolean("bed-sethome", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMultipleHomes()
|
||||
{
|
||||
return config.getKeys("sethome-multiple");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHomeLimit(final User user)
|
||||
{
|
||||
final List<String> homeList = getMultipleHomes();
|
||||
if (homeList == null)
|
||||
{
|
||||
//TODO: Replace this code to remove backwards compat, after settings are automatically updated
|
||||
// return getHomeLimit("default");
|
||||
return config.getInt("multiple-homes", 5);
|
||||
}
|
||||
int limit = getHomeLimit("default");
|
||||
for (String set : homeList)
|
||||
{
|
||||
logger.log(Level.INFO, "Found home set: " + set);
|
||||
if (user.hasPermission("essentials.sethome.multiple." + set) && limit < getHomeLimit(set))
|
||||
{
|
||||
limit = getHomeLimit(set);
|
||||
}
|
||||
}
|
||||
return limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHomeLimit(final String set)
|
||||
{
|
||||
return config.getInt("sethome-multiple." + set, config.getInt("sethome-multiple.default", 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChatRadius()
|
||||
{
|
||||
@@ -60,19 +88,13 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getInt("default-stack-size", 64);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getStartingBalance()
|
||||
{
|
||||
return config.getInt("starting-balance", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getNetherPortalsEnabled()
|
||||
{
|
||||
return isNetherEnabled() && config.getBoolean("nether.portals-enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandDisabled(final IEssentialsCommand cmd)
|
||||
{
|
||||
@@ -84,7 +106,10 @@ public class Settings implements ISettings
|
||||
{
|
||||
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label)) continue;
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return config.getBoolean("disable-" + label.toLowerCase(), false);
|
||||
@@ -101,18 +126,24 @@ public class Settings implements ISettings
|
||||
{
|
||||
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label)) continue;
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return config.getBoolean("restrict-" + label.toLowerCase(), false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPlayerCommand(String label)
|
||||
{
|
||||
for (String c : config.getStringList("player-commands", new ArrayList<String>(0)))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label)) continue;
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -126,7 +157,9 @@ public class Settings implements ISettings
|
||||
for (String c : config.getStringList("overridden-commands", defaultList))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return config.getBoolean("override-" + name.toLowerCase(), false);
|
||||
@@ -143,7 +176,9 @@ public class Settings implements ISettings
|
||||
{
|
||||
double cost = config.getDouble("command-costs." + label, 0.0);
|
||||
if (cost == 0.0)
|
||||
{
|
||||
cost = config.getDouble("cost-" + label, 0.0);
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
@@ -171,13 +206,14 @@ public class Settings implements ISettings
|
||||
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
|
||||
for (Map.Entry<String, Object> entry : kits.entrySet())
|
||||
{
|
||||
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_'))) {
|
||||
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_')))
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getKits()
|
||||
{
|
||||
@@ -190,9 +226,13 @@ public class Settings implements ISettings
|
||||
String colorName = config.getString("ops-name-color", null);
|
||||
|
||||
if (colorName == null)
|
||||
{
|
||||
return ChatColor.RED;
|
||||
if("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
|
||||
}
|
||||
if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -211,35 +251,23 @@ public class Settings implements ISettings
|
||||
return config.getBoolean("reclaim-onlogout", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNetherName()
|
||||
{
|
||||
return config.getString("nether.folder", "nether");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetherEnabled()
|
||||
{
|
||||
return config.getBoolean("nether.enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpawnMobLimit()
|
||||
{
|
||||
return config.getInt("spawnmob-limit", 10);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean showNonEssCommandsInHelp()
|
||||
{
|
||||
return config.getBoolean("non-ess-in-help", true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hidePermissionlessHelp()
|
||||
public boolean hidePermissionlessHelp()
|
||||
{
|
||||
return config.getBoolean("hide-permissionless-help", true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtectCreeperMaxHeight()
|
||||
@@ -272,12 +300,6 @@ public class Settings implements ISettings
|
||||
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGenerateExitPortals()
|
||||
{
|
||||
return config.getBoolean("nether.generate-exit-portals", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAnnounceNewPlayers()
|
||||
{
|
||||
@@ -301,12 +323,13 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getString("newbies.spawnpoint", "default");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPerWarpPermission()
|
||||
public boolean getPerWarpPermission()
|
||||
{
|
||||
return config.getBoolean("per-warp-permission", false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getSortListByGroups()
|
||||
{
|
||||
@@ -314,7 +337,8 @@ public class Settings implements ISettings
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
}
|
||||
|
||||
@@ -322,16 +346,21 @@ public class Settings implements ISettings
|
||||
public List<Integer> itemSpawnBlacklist()
|
||||
{
|
||||
final List<Integer> epItemSpwn = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) {
|
||||
for (String itemName : config.getString("item-spawn-blacklist", "").split(","))
|
||||
{
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
if (itemName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
try
|
||||
{
|
||||
is = ess.getItemDb().get(itemName);
|
||||
epItemSpwn.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "item-spawn-blacklist"));
|
||||
}
|
||||
}
|
||||
@@ -350,21 +379,6 @@ public class Settings implements ISettings
|
||||
return config.getBoolean("protect.disable.warn-on-build-disallow", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean use1to1RatioInNether()
|
||||
{
|
||||
return config.getBoolean("nether.use-1to1-ratio", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNetherRatio()
|
||||
{
|
||||
if (config.getBoolean("nether.use-1to1-ratio", false)) {
|
||||
return 1.0;
|
||||
}
|
||||
return config.getDouble("nether.ratio", 8.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug()
|
||||
{
|
||||
@@ -374,9 +388,9 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean warnOnSmite()
|
||||
{
|
||||
return config.getBoolean("warn-on-smite" ,true);
|
||||
return config.getBoolean("warn-on-smite", true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean permissionBasedItemSpawn()
|
||||
{
|
||||
@@ -410,23 +424,28 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean getProtectPreventSpawn(final String creatureName)
|
||||
{
|
||||
return config.getBoolean("protect.prevent.spawn."+creatureName, false);
|
||||
return config.getBoolean("protect.prevent.spawn." + creatureName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getProtectList(final String configName)
|
||||
{
|
||||
final List<Integer> list = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString(configName, "").split(",")) {
|
||||
for (String itemName : config.getString(configName, "").split(","))
|
||||
{
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
if (itemName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ItemStack itemStack;
|
||||
try {
|
||||
try
|
||||
{
|
||||
itemStack = ess.getItemDb().get(itemName);
|
||||
list.add(itemStack.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, configName));
|
||||
}
|
||||
}
|
||||
@@ -444,12 +463,13 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean(configName, def);
|
||||
}
|
||||
|
||||
private final static double MAXMONEY = 10000000000000.0;
|
||||
|
||||
public double getMaxMoney()
|
||||
{
|
||||
double max = config.getDouble("max-money", MAXMONEY);
|
||||
if (Math.abs(max) > MAXMONEY) {
|
||||
if (Math.abs(max) > MAXMONEY)
|
||||
{
|
||||
max = max < 0 ? -MAXMONEY : MAXMONEY;
|
||||
}
|
||||
return max;
|
||||
@@ -459,7 +479,7 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("economy-log-enabled", false);
|
||||
}
|
||||
|
||||
|
||||
public boolean removeGodOnDisconnect()
|
||||
{
|
||||
return config.getBoolean("remove-god-on-disconnect", false);
|
||||
@@ -503,4 +523,10 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("freeze-afk-players", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areDeathMessagesEnabled()
|
||||
{
|
||||
return config.getBoolean("death-messages", true);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* Original authors: toi & Raphfrk
|
||||
*/
|
||||
@Deprecated
|
||||
public class TargetBlock
|
||||
{
|
||||
private transient final Location location;
|
||||
|
||||
@@ -256,7 +256,7 @@ public class Teleport implements Runnable
|
||||
|
||||
public void back() throws Exception
|
||||
{
|
||||
back(null);
|
||||
now(new Target(user.getLastLocation()));
|
||||
}
|
||||
|
||||
public void home(IUser user, String home, Trade chargeFor) throws Exception
|
||||
|
||||
@@ -18,22 +18,22 @@ public class Trade
|
||||
private final transient Double money;
|
||||
private final transient ItemStack itemStack;
|
||||
private final transient IEssentials ess;
|
||||
|
||||
|
||||
public Trade(final String command, final IEssentials ess)
|
||||
{
|
||||
this(command, null, null, ess);
|
||||
}
|
||||
|
||||
|
||||
public Trade(final double money, final IEssentials ess)
|
||||
{
|
||||
this(null, money, null, ess);
|
||||
}
|
||||
|
||||
|
||||
public Trade(final ItemStack items, final IEssentials ess)
|
||||
{
|
||||
this(null, null, items, ess);
|
||||
}
|
||||
|
||||
|
||||
private Trade(final String command, final Double money, final ItemStack item, final IEssentials ess)
|
||||
{
|
||||
this.command = command;
|
||||
@@ -41,7 +41,7 @@ public class Trade
|
||||
this.itemStack = item;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
|
||||
public void isAffordableFor(final IUser user) throws ChargeException
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
@@ -52,13 +52,13 @@ public class Trade
|
||||
{
|
||||
throw new ChargeException(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
|
||||
|
||||
if (getItemStack() != null
|
||||
&& !InventoryWorkaround.containsItem(user.getInventory(), true, itemStack))
|
||||
{
|
||||
throw new ChargeException(Util.format("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
|
||||
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command)
|
||||
@@ -69,24 +69,38 @@ public class Trade
|
||||
throw new ChargeException(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void pay(final IUser user)
|
||||
{
|
||||
pay(user, true);
|
||||
}
|
||||
|
||||
public boolean pay(final IUser user, final boolean dropItems)
|
||||
{
|
||||
boolean success = true;
|
||||
if (getMoney() != null && getMoney() > 0)
|
||||
{
|
||||
user.giveMoney(getMoney());
|
||||
}
|
||||
if (getItemStack() != null)
|
||||
{
|
||||
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
if (dropItems)
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = InventoryWorkaround.addAllItems(user.getInventory(), true, getItemStack());
|
||||
}
|
||||
user.updateInventory();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
public void charge(final IUser user) throws ChargeException
|
||||
{
|
||||
if (getMoney() != null)
|
||||
@@ -120,18 +134,18 @@ public class Trade
|
||||
user.takeMoney(cost);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Double getMoney()
|
||||
{
|
||||
return money;
|
||||
}
|
||||
|
||||
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
private static FileWriter fw = null;
|
||||
|
||||
|
||||
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
|
||||
{
|
||||
if (!ess.getSettings().isEcoLogEnabled())
|
||||
@@ -225,10 +239,11 @@ public class Trade
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void closeLog()
|
||||
{
|
||||
if (fw != null) {
|
||||
if (fw != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fw.close();
|
||||
|
||||
@@ -20,14 +20,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
private transient long lastOnlineActivity;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
private boolean hidden = false;
|
||||
private transient boolean godStateBeforeAfk;
|
||||
private transient Location afkPosition;
|
||||
|
||||
User(final Player base, final IEssentials ess)
|
||||
{
|
||||
super(base, ess);
|
||||
teleport = new Teleport(this, ess);
|
||||
godStateBeforeAfk = isGodModeEnabled();
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
|
||||
@@ -284,6 +282,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
return nickname.toString();
|
||||
}
|
||||
|
||||
public void setDisplayNick(String name)
|
||||
{
|
||||
setDisplayName(name);
|
||||
//TODO: Maybe we need to limit nick length, or try use a string trim.
|
||||
if (name.length() <= 16) {
|
||||
setPlayerListName(name);
|
||||
}
|
||||
}
|
||||
|
||||
public Teleport getTeleport()
|
||||
{
|
||||
@@ -348,15 +355,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
public void setAfk(final boolean set)
|
||||
{
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
||||
if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
godStateBeforeAfk = isGodModeEnabled();
|
||||
setGodModeEnabled(true);
|
||||
}
|
||||
if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
setGodModeEnabled(godStateBeforeAfk);
|
||||
}
|
||||
if (set && !isAfk()) {
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
@@ -460,7 +458,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
}
|
||||
final long autoafk = ess.getSettings().getAutoAfk();
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis())
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk"))
|
||||
{
|
||||
setAfk(true);
|
||||
if (!isHidden()) {
|
||||
@@ -481,5 +479,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
setFoodLevel(20);
|
||||
}
|
||||
return super.toggleGodModeEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGodModeEnabled()
|
||||
{
|
||||
return super.isGodModeEnabled() || (isAfk() && ess.getSettings().getFreezeAfkPlayers());
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
isSocialSpyEnabled = _isSocialSpyEnabled();
|
||||
isNPC = _isNPC();
|
||||
arePowerToolsEnabled = _arePowerToolsEnabled();
|
||||
kitTimestamps = _getKitTimestamps();
|
||||
}
|
||||
private double money;
|
||||
|
||||
@@ -163,7 +164,12 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public void delHome(String name) throws Exception
|
||||
{
|
||||
if (getHome(name) != null)
|
||||
String search = name;
|
||||
if (!homes.containsKey(search))
|
||||
{
|
||||
search = Util.sanitizeFileName(name);
|
||||
}
|
||||
if (homes.containsKey(search))
|
||||
{
|
||||
homes.remove(name);
|
||||
config.removeProperty("homes." + name);
|
||||
@@ -243,12 +249,13 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
}
|
||||
|
||||
public void clearAllPowertools() {
|
||||
public void clearAllPowertools()
|
||||
{
|
||||
powertools.clear();
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
|
||||
public List<String> getPowertool(ItemStack stack)
|
||||
{
|
||||
return (List<String>)powertools.get(stack.getTypeId());
|
||||
@@ -267,12 +274,11 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPowerTools()
|
||||
{
|
||||
return powertools.size() > 0;
|
||||
}
|
||||
|
||||
private Location lastLocation;
|
||||
|
||||
private Location _getLastLocation()
|
||||
@@ -294,6 +300,10 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public void setLastLocation(Location loc)
|
||||
{
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastLocation = loc;
|
||||
config.setProperty("lastlocation", loc);
|
||||
config.save();
|
||||
@@ -781,31 +791,57 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("npc", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean arePowerToolsEnabled;
|
||||
|
||||
|
||||
public boolean arePowerToolsEnabled()
|
||||
{
|
||||
return arePowerToolsEnabled;
|
||||
}
|
||||
|
||||
|
||||
public void setPowerToolsEnabled(boolean set)
|
||||
{
|
||||
arePowerToolsEnabled = set;
|
||||
config.setProperty("powertoolsenabled", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
|
||||
public boolean togglePowerToolsEnabled()
|
||||
{
|
||||
boolean ret = !arePowerToolsEnabled();
|
||||
setPowerToolsEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
private boolean _arePowerToolsEnabled()
|
||||
{
|
||||
return config.getBoolean("powertoolsenabled", true);
|
||||
}
|
||||
|
||||
private Map<String, Object> kitTimestamps;
|
||||
|
||||
private Map<String, Object> _getKitTimestamps()
|
||||
{
|
||||
final Object map = config.getProperty("timestamps.kits");
|
||||
|
||||
if (map instanceof Map)
|
||||
{
|
||||
return (Map<String, Object>)map;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
}
|
||||
|
||||
public Long getKitTimestamp(final String name)
|
||||
{
|
||||
final Number num = (Number)kitTimestamps.get(name.toLowerCase());
|
||||
return num == null ? null : num.longValue();
|
||||
}
|
||||
|
||||
public void setKitTimestamp(final String name, final long time)
|
||||
{
|
||||
kitTimestamps.put(name.toLowerCase(), time);
|
||||
config.setProperty("timestamps.kits", kitTimestamps);
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
@@ -227,30 +227,36 @@ public class Util
|
||||
AIR_MATERIALS.add(Material.SAPLING.getId());
|
||||
AIR_MATERIALS.add(Material.POWERED_RAIL.getId());
|
||||
AIR_MATERIALS.add(Material.DETECTOR_RAIL.getId());
|
||||
AIR_MATERIALS.add(Material.LONG_GRASS.getId());
|
||||
AIR_MATERIALS.add(Material.DEAD_BUSH.getId());
|
||||
AIR_MATERIALS.add(Material.RAILS.getId());
|
||||
AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId());
|
||||
AIR_MATERIALS.add(Material.RED_ROSE.getId());
|
||||
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.TORCH.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId());
|
||||
AIR_MATERIALS.add(Material.SEEDS.getId());
|
||||
AIR_MATERIALS.add(Material.SIGN_POST.getId());
|
||||
AIR_MATERIALS.add(Material.WALL_SIGN.getId());
|
||||
AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.LADDER.getId());
|
||||
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId());
|
||||
AIR_MATERIALS.add(Material.RAILS.getId());
|
||||
AIR_MATERIALS.add(Material.WALL_SIGN.getId());
|
||||
AIR_MATERIALS.add(Material.LEVER.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
|
||||
AIR_MATERIALS.add(Material.TORCH.getId());
|
||||
AIR_MATERIALS.add(Material.SOIL.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
|
||||
AIR_MATERIALS.add(Material.TRAP_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_BUTTON.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
|
||||
AIR_MATERIALS.add(Material.TRAP_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.PUMPKIN_STEM.getId());
|
||||
AIR_MATERIALS.add(Material.MELON_STEM.getId());
|
||||
AIR_MATERIALS.add(Material.VINE.getId());
|
||||
//TODO: Add 1.9 materials
|
||||
|
||||
}
|
||||
|
||||
public static Location getSafeDestination(final Location loc) throws Exception
|
||||
@@ -260,9 +266,9 @@ public class Util
|
||||
throw new Exception(Util.i18n("destinationNotSet"));
|
||||
}
|
||||
final World world = loc.getWorld();
|
||||
int x = (int)Math.round(loc.getX());
|
||||
int x = loc.getBlockX();
|
||||
int y = (int)Math.round(loc.getY());
|
||||
int z = (int)Math.round(loc.getZ());
|
||||
int z = loc.getBlockZ();
|
||||
|
||||
while (isBlockAboveAir(world, x, y, z))
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ public final class Economy
|
||||
}
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private static IEssentials ess;
|
||||
private static final String noCallBeforeLoad = "Essentials API is called before Essentials is loaded.";
|
||||
|
||||
/**
|
||||
* @param aEss the ess to set
|
||||
@@ -66,6 +67,10 @@ public final class Economy
|
||||
|
||||
private static User getUserByName(String name)
|
||||
{
|
||||
if (ess == null)
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
User user;
|
||||
Player player = ess.getServer().getPlayer(name);
|
||||
if (player != null)
|
||||
@@ -176,6 +181,10 @@ public final class Economy
|
||||
*/
|
||||
public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException
|
||||
{
|
||||
if (ess == null)
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
setMoney(name, ess.getSettings().getStartingBalance());
|
||||
}
|
||||
|
||||
@@ -231,6 +240,10 @@ public final class Economy
|
||||
*/
|
||||
public static String format(double amount)
|
||||
{
|
||||
if (ess == null)
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
return Util.formatCurrency(amount, ess);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -13,14 +14,24 @@ public class Commandbanip extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ess.getServer().banIP(args[0]);
|
||||
sender.sendMessage(Util.i18n("banIpAddress"));
|
||||
final User u = ess.getUser(args[0]);
|
||||
|
||||
if (u == null)
|
||||
{
|
||||
ess.getServer().banIP(args[0]);
|
||||
sender.sendMessage(Util.i18n("banIpAddress"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.getServer().banIP(u.getAddress().getAddress().getHostAddress());
|
||||
sender.sendMessage(Util.i18n("banIpAddress"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public class Commandcompass extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
int r = (int)user.getCorrectedYaw();
|
||||
int r = (int)user.getLocation().getYaw();
|
||||
String dir;
|
||||
if (r < 23) dir = "N";
|
||||
else if (r < 68) dir = "NE";
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Commanddelhome extends EssentialsCommand
|
||||
}
|
||||
else if (args.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
|
||||
{
|
||||
user = getPlayer(server, args, 0);
|
||||
user = getPlayer(server, args, 0, true);
|
||||
name = args[1];
|
||||
}
|
||||
else
|
||||
|
||||
@@ -56,7 +56,6 @@ public class Commandessentials extends EssentialsCommand
|
||||
}
|
||||
final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
|
||||
final String[] tune = tuneStr.split(",");
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
final Location loc = player.getLocation();
|
||||
@@ -91,7 +90,7 @@ public class Commandessentials extends EssentialsCommand
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
Block block = noteBlocks.get(player);
|
||||
if (block == null)
|
||||
if (block == null || block.getType() != Material.NOTE_BLOCK)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -110,7 +109,10 @@ public class Commandessentials extends EssentialsCommand
|
||||
ess.getScheduler().cancelTask(taskid);
|
||||
for (Block block : noteBlocks.values())
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
if (block.getType() == Material.NOTE_BLOCK)
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
noteBlocks.clear();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class Commandgetpos extends EssentialsCommand
|
||||
user.sendMessage("§7X: " + coords.getBlockX() + " (-North <-> +South)");
|
||||
user.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)");
|
||||
user.sendMessage("§7Z: " + coords.getBlockZ() + " (+East <-> -West)");
|
||||
user.sendMessage("§7Yaw: " + user.getCorrectedYaw() + " (Rotation)");
|
||||
user.sendMessage("§7Yaw: " + coords.getYaw() + " (Rotation)");
|
||||
user.sendMessage("§7Pitch: " + coords.getPitch() + " (Head angle)");
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public class Commandheal extends EssentialsCommand
|
||||
user.healCooldown();
|
||||
}
|
||||
user.setHealth(20);
|
||||
user.setFoodLevel(20);
|
||||
user.sendMessage(Util.i18n("heal"));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
|
||||
public class Commandkill extends EssentialsCommand
|
||||
@@ -23,6 +24,13 @@ public class Commandkill extends EssentialsCommand
|
||||
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
final EntityDamageEvent ede = new EntityDamageEvent(p, sender instanceof Player && ((Player)sender).getName().equals(p.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, 1000);
|
||||
server.getPluginManager().callEvent(ede);
|
||||
if (ede.isCancelled() && !sender.hasPermission("essentials.kill.force"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
p.setHealth(0);
|
||||
sender.sendMessage(Util.format("kill", p.getDisplayName()));
|
||||
}
|
||||
|
||||
@@ -15,22 +15,20 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Commandkit extends EssentialsCommand
|
||||
{
|
||||
static private final Map<User, Map<String, Long>> kitPlayers = new HashMap<User, Map<String, Long>>();
|
||||
|
||||
public Commandkit()
|
||||
{
|
||||
super("kit");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
Map<String, Object> kits = ess.getSettings().getKits();
|
||||
StringBuilder list = new StringBuilder();
|
||||
final Map<String, Object> kits = ess.getSettings().getKits();
|
||||
final StringBuilder list = new StringBuilder();
|
||||
for (String k : kits.keySet())
|
||||
{
|
||||
if (user.isAuthorized("essentials.kit." + k.toLowerCase()))
|
||||
@@ -56,8 +54,8 @@ public class Commandkit extends EssentialsCommand
|
||||
{
|
||||
try
|
||||
{
|
||||
String kitName = args[0].toLowerCase();
|
||||
Object kit = ess.getSettings().getKit(kitName);
|
||||
final String kitName = args[0].toLowerCase();
|
||||
final Object kit = ess.getSettings().getKit(kitName);
|
||||
List<String> items;
|
||||
|
||||
if (!user.isAuthorized("essentials.kit." + kitName))
|
||||
@@ -70,39 +68,26 @@ public class Commandkit extends EssentialsCommand
|
||||
{
|
||||
|
||||
//System.out.println("Kit is timed");
|
||||
Map<String, Object> els = (Map<String, Object>)kit;
|
||||
final Map<String, Object> els = (Map<String, Object>)kit;
|
||||
items = (List<String>)els.get("items");
|
||||
double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
|
||||
Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, (int)delay);
|
||||
c.add(Calendar.MILLISECOND, (int)((delay*1000.0)%1000.0));
|
||||
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
|
||||
final Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, -(int)delay);
|
||||
c.add(Calendar.MILLISECOND, -(int)((delay*1000.0)%1000.0));
|
||||
|
||||
long time = c.getTimeInMillis();
|
||||
Calendar now = new GregorianCalendar();
|
||||
|
||||
Map<String, Long> kitTimes;
|
||||
if (!kitPlayers.containsKey(user))
|
||||
{
|
||||
kitTimes = new HashMap<String, Long>();
|
||||
kitTimes.put(kitName, time);
|
||||
kitPlayers.put(user, kitTimes);
|
||||
}
|
||||
else
|
||||
{
|
||||
kitTimes = kitPlayers.get(user);
|
||||
if (!kitTimes.containsKey(kitName))
|
||||
{
|
||||
kitTimes.put(kitName, time);
|
||||
}
|
||||
else if (kitTimes.get(kitName) < now.getTimeInMillis())
|
||||
{
|
||||
kitTimes.put(kitName, time);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("kitTimed", Util.formatDateDiff(kitTimes.get(kitName))));
|
||||
return;
|
||||
}
|
||||
final long mintime = c.getTimeInMillis();
|
||||
|
||||
final Long lastTime = user.getKitTimestamp(kitName);
|
||||
if (lastTime == null || lastTime < mintime) {
|
||||
final Calendar now = new GregorianCalendar();
|
||||
user.setKitTimestamp(kitName, now.getTimeInMillis());
|
||||
} else {
|
||||
final Calendar future = new GregorianCalendar();
|
||||
future.setTimeInMillis(lastTime);
|
||||
future.add(Calendar.SECOND, (int)delay);
|
||||
future.add(Calendar.MILLISECOND, (int)((delay*1000.0)%1000.0));
|
||||
user.sendMessage(Util.format("kitTimed", Util.formatDateDiff(future.getTimeInMillis())));
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -110,7 +95,7 @@ public class Commandkit extends EssentialsCommand
|
||||
items = (List<String>)kit;
|
||||
}
|
||||
|
||||
Trade charge = new Trade("kit-" + kitName, ess);
|
||||
final Trade charge = new Trade("kit-" + kitName, ess);
|
||||
try
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
@@ -124,11 +109,11 @@ public class Commandkit extends EssentialsCommand
|
||||
boolean spew = false;
|
||||
for (String d : items)
|
||||
{
|
||||
String[] parts = d.split("[^0-9]+", 3);
|
||||
int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
|
||||
int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
|
||||
short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
|
||||
HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data));
|
||||
final String[] parts = d.split("[^0-9]+", 3);
|
||||
final int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
|
||||
final int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
|
||||
final short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
|
||||
final HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data));
|
||||
for (ItemStack itemStack : overfilled.values())
|
||||
{
|
||||
user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
|
||||
|
||||
@@ -23,13 +23,15 @@ public class Commandmail extends EssentialsCommand
|
||||
List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
throw new Exception(Util.i18n("noMail"));
|
||||
user.sendMessage(Util.i18n("noMail"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
for (String s : mail)
|
||||
{
|
||||
user.sendMessage(s);
|
||||
}
|
||||
throw new Exception(Util.i18n("mailClear"));
|
||||
user.sendMessage(Util.i18n("mailClear"));
|
||||
return;
|
||||
}
|
||||
if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
@@ -62,8 +64,9 @@ public class Commandmail extends EssentialsCommand
|
||||
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
user.setMails(null);
|
||||
throw new Exception(Util.i18n("mailCleared"));
|
||||
user.sendMessage(Util.i18n("mailCleared"));
|
||||
return;
|
||||
}
|
||||
throw new NoChargeException();
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class Commandnick extends EssentialsCommand
|
||||
String nick = args[0];
|
||||
if ("off".equalsIgnoreCase(nick) || user.getName().equalsIgnoreCase(nick))
|
||||
{
|
||||
user.setDisplayName(user.getName());
|
||||
user.setDisplayNick(user.getName());
|
||||
user.setNickname(null);
|
||||
user.sendMessage(Util.i18n("nickNoMore"));
|
||||
return;
|
||||
@@ -67,7 +67,7 @@ public class Commandnick extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
user.setDisplayName(ess.getSettings().getNicknamePrefix() + nick);
|
||||
user.setDisplayNick(ess.getSettings().getNicknamePrefix() + nick);
|
||||
user.setNickname(nick);
|
||||
user.sendMessage(Util.format("nickSet", user.getDisplayName() + "§7."));
|
||||
}
|
||||
@@ -95,13 +95,13 @@ public class Commandnick extends EssentialsCommand
|
||||
String nick = args[1];
|
||||
if ("off".equalsIgnoreCase(nick) || target.getName().equalsIgnoreCase(nick))
|
||||
{
|
||||
target.setDisplayName(target.getName());
|
||||
target.setDisplayNick(target.getName());
|
||||
target.setNickname(null);
|
||||
target.sendMessage(Util.i18n("nickNoMore"));
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setDisplayName(ess.getSettings().getNicknamePrefix() + nick);
|
||||
target.setDisplayNick(ess.getSettings().getNicknamePrefix() + nick);
|
||||
target.setNickname(nick);
|
||||
target.sendMessage(Util.format("nickSet", target.getDisplayName() + "§7."));
|
||||
}
|
||||
|
||||
Executable → Regular
File mode changed.
@@ -30,6 +30,10 @@ public class Commandrepair extends EssentialsCommand
|
||||
if (args[0].equalsIgnoreCase("hand"))
|
||||
{
|
||||
final ItemStack item = user.getItemInHand();
|
||||
if (item == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("repairInvalidType"));
|
||||
}
|
||||
final String itemName = item.getType().toString().toLowerCase();
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
|
||||
|
||||
@@ -84,6 +88,10 @@ public class Commandrepair extends EssentialsCommand
|
||||
{
|
||||
for (ItemStack item : items)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String itemName = item.getType().toString().toLowerCase();
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
|
||||
try
|
||||
|
||||
@@ -28,14 +28,14 @@ public class Commandsethome extends EssentialsCommand
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.multiple"))
|
||||
{
|
||||
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getMultipleHomes())
|
||||
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user))
|
||||
|| (user.getHomes().contains(args[0].toLowerCase())))
|
||||
{
|
||||
user.setHome(args[0].toLowerCase());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(Util.format("maxHomes", ess.getSettings().getMultipleHomes()));
|
||||
throw new Exception(Util.format("maxHomes", ess.getSettings().getHomeLimit(user)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,11 +56,6 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
if (ess.getSettings().getProtectPreventSpawn(mobType.toLowerCase())
|
||||
|| (mountType != null && ess.getSettings().getProtectPreventSpawn(mountType.toLowerCase())))
|
||||
{
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
|
||||
Entity spawnedMob = null;
|
||||
Mob mob = null;
|
||||
@@ -72,6 +67,12 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(Util.i18n("invalidMob"));
|
||||
}
|
||||
|
||||
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase()))
|
||||
{
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
|
||||
int[] ignore =
|
||||
{
|
||||
8, 9
|
||||
@@ -79,8 +80,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
Block block = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock();
|
||||
if (block == null)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
Location loc = block.getLocation();
|
||||
Location sloc = Util.getSafeDestination(loc);
|
||||
@@ -90,8 +90,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
|
||||
if (mountType != null)
|
||||
@@ -102,14 +101,18 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
user.sendMessage(Util.i18n("invalidMob"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ess.getSettings().getProtectPreventSpawn(mobMount.getType().toString().toLowerCase()))
|
||||
{
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
try
|
||||
{
|
||||
spawnedMount = mobMount.spawn(user, server, loc);
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
}
|
||||
@@ -144,8 +147,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
}
|
||||
|
||||
Executable → Regular
File mode changed.
@@ -17,26 +17,28 @@ public class Commandworld extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
World world;
|
||||
List<World> worlds = server.getWorlds();
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
World nether = server.getWorld(ess.getSettings().getNetherName());
|
||||
if (nether == null) {
|
||||
for (World world2 : worlds)
|
||||
World nether = null;
|
||||
|
||||
final List<World> worlds = server.getWorlds();
|
||||
|
||||
for (World world2 : worlds)
|
||||
{
|
||||
if (world2.getEnvironment() == World.Environment.NETHER)
|
||||
{
|
||||
if (world2.getEnvironment() == World.Environment.NETHER) {
|
||||
nether = world2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nether == null) {
|
||||
return;
|
||||
nether = world2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nether == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
world = user.getWorld() == nether ? worlds.get(0) : nether;
|
||||
}
|
||||
else
|
||||
@@ -54,23 +56,22 @@ public class Commandworld extends EssentialsCommand
|
||||
double factor;
|
||||
if (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL)
|
||||
{
|
||||
factor = ess.getSettings().getNetherRatio();
|
||||
factor = 8.0;
|
||||
}
|
||||
else if (user.getWorld().getEnvironment() != world.getEnvironment())
|
||||
else if (user.getWorld().getEnvironment() == World.Environment.NORMAL && world.getEnvironment() == World.Environment.NETHER)
|
||||
{
|
||||
factor = 1.0 / ess.getSettings().getNetherRatio();
|
||||
factor = 1.0 / 8.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
factor = 1.0;
|
||||
}
|
||||
|
||||
Location loc = user.getLocation();
|
||||
loc = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5);
|
||||
final Location loc = user.getLocation();
|
||||
final Location target = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5);
|
||||
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getTeleport().teleport(loc, charge);
|
||||
user.getTeleport().teleport(target, charge);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,23 @@ public interface Method
|
||||
*/
|
||||
public boolean hasBankAccount(String bank, String name);
|
||||
|
||||
/**
|
||||
* Forces an account creation
|
||||
*
|
||||
* @param name Account name
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
public boolean createAccount(String name);
|
||||
|
||||
/**
|
||||
* Forces an account creation
|
||||
*
|
||||
* @param name Account name
|
||||
* @param balance Initial account balance
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
public boolean createAccount(String name, Double balance);
|
||||
|
||||
/**
|
||||
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
|
||||
*
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.earth2me.essentials.register.payment;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
@@ -168,7 +169,7 @@ public class Methods
|
||||
}
|
||||
|
||||
plugin = manager.getPlugin(name);
|
||||
if (plugin == null)
|
||||
if (plugin == null || !plugin.isEnabled())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -71,6 +71,29 @@ public class BOSE6 implements Method
|
||||
|| this.BOSEconomy.isBankMember(bank, name);
|
||||
}
|
||||
|
||||
public boolean createAccount(String name)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.BOSEconomy.registerPlayer(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, Double balance)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.BOSEconomy.registerPlayer(name);
|
||||
this.BOSEconomy.setPlayerMoney(name, balance, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
if (!hasAccount(name))
|
||||
|
||||
@@ -70,6 +70,29 @@ public class BOSE7 implements Method
|
||||
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
|
||||
}
|
||||
|
||||
public boolean createAccount(String name)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.BOSEconomy.registerPlayer(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, Double balance)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.BOSEconomy.registerPlayer(name);
|
||||
this.BOSEconomy.setPlayerMoney(name, balance, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
if (!hasAccount(name))
|
||||
|
||||
@@ -64,6 +64,18 @@ public class MCUR implements Method
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name)
|
||||
{
|
||||
CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, Double balance)
|
||||
{
|
||||
CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, balance);
|
||||
return true;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
return new MCurrencyAccount(name);
|
||||
|
||||
@@ -64,6 +64,44 @@ public class iCo4 implements Method
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, Double balance)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name, balance);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
|
||||
|
||||
@@ -67,6 +67,33 @@ public class iCo5 implements Method
|
||||
return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(name);
|
||||
}
|
||||
|
||||
public boolean createAccount(String name)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return com.iConomy.iConomy.Accounts.create(name);
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, Double balance)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!com.iConomy.iConomy.Accounts.create(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
getAccount(name).set(balance);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
return new iCoAccount(com.iConomy.iConomy.getAccount(name));
|
||||
|
||||
@@ -66,6 +66,26 @@ public class iCo6 implements Method
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (new Accounts()).create(name);
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, Double balance)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (new Accounts()).create(name, balance);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
return new iCoAccount((new Accounts()).get(name));
|
||||
|
||||
@@ -223,7 +223,7 @@ public class EssentialsSign
|
||||
if (signblock.getType() == Material.WALL_SIGN)
|
||||
{
|
||||
final org.bukkit.material.Sign signMat = (org.bukkit.material.Sign)signblock.getState().getData();
|
||||
if (signMat.getFacing() == blockFace && isValidSign(new BlockSign(signblock)))
|
||||
if (signMat != null && signMat.getFacing() == blockFace && isValidSign(new BlockSign(signblock)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,9 @@ public class SignBuy extends EssentialsSign
|
||||
final Trade items = getTrade(sign, 1, 2, player, ess);
|
||||
final Trade charge = getTrade(sign, 3, ess);
|
||||
charge.isAffordableFor(player);
|
||||
items.pay(player);
|
||||
if (!items.pay(player, false)) {
|
||||
throw new ChargeException("Inventory full");
|
||||
}
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "Buy", "Interact", username, charge, username, items, sign.getBlock().getLocation(), ess);
|
||||
return true;
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class SignTrade extends EssentialsSign
|
||||
{
|
||||
|
||||
public SignTrade()
|
||||
{
|
||||
super("Trade");
|
||||
@@ -34,25 +33,33 @@ public class SignTrade extends EssentialsSign
|
||||
{
|
||||
if (sign.getLine(3).substring(2).equalsIgnoreCase(username))
|
||||
{
|
||||
final Trade store = rechargeSign(sign, ess, player);
|
||||
Trade stored = null;
|
||||
try
|
||||
{
|
||||
final Trade stored = getTrade(sign, 1, true, true, ess);
|
||||
stored = getTrade(sign, 1, true, true, ess);
|
||||
substractAmount(sign, 1, stored, ess);
|
||||
stored.pay(player);
|
||||
Trade.log("Sign", "Trade", "OwnerInteract", username, null, username, stored, sign.getBlock().getLocation(), ess);
|
||||
}
|
||||
}
|
||||
catch (SignException e)
|
||||
{
|
||||
throw new SignException(Util.i18n("tradeSignEmptyOwner"));
|
||||
}
|
||||
if (store == null)
|
||||
{
|
||||
throw new SignException(Util.i18n("tradeSignEmptyOwner"), e);
|
||||
}
|
||||
}
|
||||
Trade.log("Sign", "Trade", "OwnerInteract", username, store, username, stored, sign.getBlock().getLocation(), ess);
|
||||
}
|
||||
else
|
||||
{
|
||||
final Trade charge = getTrade(sign, 1, false, false, ess);
|
||||
final Trade trade = getTrade(sign, 2, false, true, ess);
|
||||
charge.isAffordableFor(player);
|
||||
if (!trade.pay(player, false))
|
||||
{
|
||||
throw new ChargeException("Full inventory");
|
||||
}
|
||||
substractAmount(sign, 2, trade, ess);
|
||||
trade.pay(player);
|
||||
addAmount(sign, 1, charge, ess);
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "Trade", "Interact", sign.getLine(3), charge, username, trade, sign.getBlock().getLocation(), ess);
|
||||
@@ -61,17 +68,48 @@ public class SignTrade extends EssentialsSign
|
||||
return true;
|
||||
}
|
||||
|
||||
private Trade rechargeSign(final ISign sign, final IEssentials ess, final User player) throws SignException, ChargeException
|
||||
{
|
||||
final Trade trade = getTrade(sign, 2, false, false, ess);
|
||||
if (trade.getItemStack() != null && player.getItemInHand() != null
|
||||
&& trade.getItemStack().getTypeId() == player.getItemInHand().getTypeId()
|
||||
&& trade.getItemStack().getDurability() == player.getItemInHand().getDurability())
|
||||
{
|
||||
int amount = player.getItemInHand().getAmount();
|
||||
amount -= amount % trade.getItemStack().getAmount();
|
||||
if (amount > 0)
|
||||
{
|
||||
final Trade store = new Trade(new ItemStack(player.getItemInHand().getTypeId(), amount, player.getItemInHand().getDurability()), ess);
|
||||
addAmount(sign, 2, store, ess);
|
||||
store.charge(player);
|
||||
return store;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignBreak(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
|
||||
{
|
||||
if ((sign.getLine(3).length() > 3 && sign.getLine(3).substring(2).equalsIgnoreCase(username))
|
||||
|| player.isAuthorized("essentials.signs.trade.override"))
|
||||
{
|
||||
final Trade stored1 = getTrade(sign, 1, true, false, ess);
|
||||
final Trade stored2 = getTrade(sign, 2, true, false, ess);
|
||||
stored1.pay(player);
|
||||
stored2.pay(player);
|
||||
Trade.log("Sign", "Trade", "Break", username, stored2, username, stored1, sign.getBlock().getLocation(), ess);
|
||||
try
|
||||
{
|
||||
final Trade stored1 = getTrade(sign, 1, true, false, ess);
|
||||
final Trade stored2 = getTrade(sign, 2, true, false, ess);
|
||||
stored1.pay(player);
|
||||
stored2.pay(player);
|
||||
Trade.log("Sign", "Trade", "Break", username, stored2, username, stored1, sign.getBlock().getLocation(), ess);
|
||||
}
|
||||
catch (SignException e)
|
||||
{
|
||||
if (player.isAuthorized("essentials.signs.trade.override"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -128,7 +166,7 @@ public class SignTrade extends EssentialsSign
|
||||
throw new SignException(Util.i18n("moreThanZero"));
|
||||
}
|
||||
String newline = amount + " " + split[1] + ":0";
|
||||
if ((newline + amount).length() > 16)
|
||||
if ((newline + amount).length() > 15)
|
||||
{
|
||||
throw new SignException("Line can be too long!");
|
||||
}
|
||||
@@ -237,7 +275,12 @@ public class SignTrade extends EssentialsSign
|
||||
final Double amount = getDouble(split[1]);
|
||||
if (money != null && amount != null)
|
||||
{
|
||||
sign.setLine(index, Util.formatCurrency(money, ess) + ":" + Util.formatCurrency(amount + value, ess).substring(1));
|
||||
final String newline = Util.formatCurrency(money, ess) + ":" + Util.formatCurrency(amount + value, ess).substring(1);
|
||||
if (newline.length() > 15)
|
||||
{
|
||||
throw new SignException("Line too long!");
|
||||
}
|
||||
sign.setLine(index, newline);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -247,7 +290,12 @@ public class SignTrade extends EssentialsSign
|
||||
final int stackamount = getIntegerPositive(split[0]);
|
||||
final ItemStack item = getItemStack(split[1], stackamount, ess);
|
||||
final int amount = getInteger(split[2]);
|
||||
sign.setLine(index, stackamount + " " + split[1] + ":" + (amount + Math.round(value)));
|
||||
final String newline = stackamount + " " + split[1] + ":" + (amount + Math.round(value));
|
||||
if (newline.length() > 15)
|
||||
{
|
||||
throw new SignException("Line too long!");
|
||||
}
|
||||
sign.setLine(index, newline);
|
||||
return;
|
||||
}
|
||||
throw new SignException(Util.format("invalidSignLine", index + 1));
|
||||
|
||||
+15
-11
@@ -79,12 +79,6 @@ reclaim-onlogout: false
|
||||
# Should primitive spawn protection be enabled? For most servers, this should be flase; it is better to use a third-party plugin to protect it.
|
||||
spawn-protection: false
|
||||
|
||||
# Nether settings
|
||||
# Sets wether you want to change the default behaviour of the nether portals.
|
||||
nether:
|
||||
portals-enabled: false
|
||||
generate-exit-portals: false
|
||||
|
||||
# Mob limit on spawnmob
|
||||
spawnmob-limit: 10
|
||||
|
||||
@@ -92,6 +86,7 @@ spawnmob-limit: 10
|
||||
warn-on-smite: true
|
||||
|
||||
# The message of the day, displayed on connect and by typing /motd.
|
||||
# Valid tags are: {PLAYER}, {IP}, {BALANCE}, {MAILS}, {WORLD}, {ONLINE}, {UNIQUE}, {PLAYERLIST}
|
||||
motd:
|
||||
- '&cWelcome, {PLAYER}&c!'
|
||||
- '&fType &c/help&f for a list of commands.'
|
||||
@@ -243,6 +238,9 @@ auto-afk-kick: -1
|
||||
# The player has to use the command /afk to leave the afk mode.
|
||||
freeze-afk-players: false
|
||||
|
||||
# You can disable the death messages of minecraft here
|
||||
death-messages: true
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | EssentialsHome | #
|
||||
@@ -259,10 +257,16 @@ bed-sethome: false
|
||||
# If no home is set send you to spawn when /home is used
|
||||
spawn-if-no-home: false
|
||||
|
||||
# If users have essentials.sethome.multiple how many homes can they have
|
||||
# People with essentials.sethome.multiple.unlimited are not limited by this number
|
||||
multiple-homes: 5
|
||||
|
||||
# Allow players to have multiple homes.
|
||||
# Define different amounts of multiple homes for different permissions, e.g. essentials.sethome.multiple.vip
|
||||
# People with essentials.sethome.multiple.unlimited are not limited by these numbers.
|
||||
sethome-multiple:
|
||||
# essentials.sethome.multiple
|
||||
default: 3
|
||||
# essentials.sethome.multiple.vip
|
||||
vip: 5
|
||||
# essentials.sethome.multiple.staff
|
||||
staff: 10
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
@@ -485,7 +489,7 @@ protect:
|
||||
use: true
|
||||
|
||||
# Should we tell people they are not allowed to build
|
||||
warn-on-build-disallow: false
|
||||
warn-on-build-disallow: true
|
||||
|
||||
|
||||
# Disable weather options
|
||||
|
||||
+31
-29
@@ -501,20 +501,20 @@ detecttrack,28,0
|
||||
detectrail,28,0
|
||||
dtrack,28,0
|
||||
drail,28,0
|
||||
stickypistonbase,29,0
|
||||
stickypiston,29,0
|
||||
stickpistonbase,29,0
|
||||
stickpiston,29,0
|
||||
stickyp,29,0
|
||||
spistonbase,29,0
|
||||
spiston,29,0
|
||||
pistonstickybase,29,0
|
||||
pistonsticky,29,0
|
||||
pistonstickbase,29,0
|
||||
pistonstick,29,0
|
||||
pistonsbase,29,0
|
||||
pistons,29,0
|
||||
psticky,29,0
|
||||
stickypistonbase,29,7
|
||||
stickypiston,29,7
|
||||
stickpistonbase,29,7
|
||||
stickpiston,29,7
|
||||
stickyp,29,7
|
||||
spistonbase,29,7
|
||||
spiston,29,7
|
||||
pistonstickybase,29,7
|
||||
pistonsticky,29,7
|
||||
pistonstickbase,29,7
|
||||
pistonstick,29,7
|
||||
pistonsbase,29,7
|
||||
pistons,29,7
|
||||
psticky,29,7
|
||||
spiderweb,30,0
|
||||
sweb,30,0
|
||||
web,30,0
|
||||
@@ -534,21 +534,21 @@ deadshrub,32,0
|
||||
shrubdead,32,0
|
||||
dshrub,32,0
|
||||
shrubd,32,0
|
||||
normalpistonbase,33,0
|
||||
normalpiston,33,0
|
||||
normpistonbase,33,0
|
||||
normpiston,33,0
|
||||
npistonbase,33,0
|
||||
npiston,33,0
|
||||
pistonnormalbase,33,0
|
||||
pistonnormal,33,0
|
||||
pistonnormbase,33,0
|
||||
pistonnorm,33,0
|
||||
pistonnbase,33,0
|
||||
pistonn,33,0
|
||||
pistonbase,33,0
|
||||
piston,33,0
|
||||
pistonblock,33,0
|
||||
normalpistonbase,33,7
|
||||
normalpiston,33,7
|
||||
normpistonbase,33,7
|
||||
normpiston,33,7
|
||||
npistonbase,33,7
|
||||
npiston,33,7
|
||||
pistonnormalbase,33,7
|
||||
pistonnormal,33,7
|
||||
pistonnormbase,33,7
|
||||
pistonnorm,33,7
|
||||
pistonnbase,33,7
|
||||
pistonn,33,7
|
||||
pistonbase,33,7
|
||||
piston,33,7
|
||||
pistonblock,33,7
|
||||
pistonextensionnormal,34,0
|
||||
pistonextensionnorm,34,0
|
||||
pistonextensionn,34,0
|
||||
@@ -1259,10 +1259,12 @@ sfstone,97,0
|
||||
stonesilverfish,97,0
|
||||
fishstone,97,0
|
||||
trapstone,97,0
|
||||
silverfish,97,0
|
||||
stonebrick,98,0
|
||||
stonebricks,98,0
|
||||
stonebrickblock,98,0
|
||||
stonebb,98,0
|
||||
sbrick,98,0
|
||||
mossystonebrick,98,1
|
||||
mossystonebricks,98,1
|
||||
mossystonebrickblock,98,1
|
||||
|
||||
|
@@ -87,7 +87,7 @@ generatingPortal = \u00a77Erstelle ein Ausgangsportal.
|
||||
geoIpUrlEmpty = GeoIP Download-URL ist leer.
|
||||
geoIpUrlInvalid = GeoIP Download-URL ist ung\u00fcltig.
|
||||
geoipJoinFormat = Spieler {0} kommt aus {1}
|
||||
godDisabledFor = aktiviert f\u00fcr {0}
|
||||
godDisabledFor = deaktiviert f\u00fcr {0}
|
||||
godEnabledFor = aktiviert f\u00fcr {0}
|
||||
godMode = \u00a77Unsterblichkeit {0}.
|
||||
haveBeenReleased = \u00a77Du wurdest frei gelassen.
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Essentials
|
||||
main: com.earth2me.essentials.Essentials
|
||||
# Note to developers: This next line cannot change, or the automatic versioning system will break.
|
||||
version: TeamCity
|
||||
website: http://www.earth2me.net:8001/
|
||||
website: http://ci.earth2me.net/
|
||||
description: Provides an essential, core set of commands for Bukkit.
|
||||
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits]
|
||||
commands:
|
||||
@@ -293,7 +293,7 @@ commands:
|
||||
togglejail:
|
||||
description: Prevents a player from interacting with the world and teleports him/her to the the jail specified
|
||||
usage: /<command> [player] [jailname] <datediff>
|
||||
aliases: [tjail,etogglejail]
|
||||
aliases: [tjail,unjail,eunjail,etogglejail]
|
||||
top:
|
||||
description: Teleport to the highest block at your current position.
|
||||
usage: /<command>
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
||||
public class EssentialsTest extends TestCase
|
||||
{
|
||||
public EssentialsTest(String testName)
|
||||
{
|
||||
super(testName);
|
||||
}
|
||||
|
||||
private static void should(String what)
|
||||
{
|
||||
System.out.println("Essentials should " + what);
|
||||
}
|
||||
|
||||
public void testLoadClasses()
|
||||
{
|
||||
should("make all classes accessible");
|
||||
try
|
||||
{
|
||||
ItemDb itemDb = null;
|
||||
Mob mob = null;
|
||||
NetherPortal netherPortal = null;
|
||||
OfflinePlayer offlinePlayer = null;
|
||||
Settings settings = null;
|
||||
Spawn spawn = null;
|
||||
TargetBlock targetBlock = null;
|
||||
User user = null;
|
||||
assertNull(itemDb);
|
||||
assertNull(mob);
|
||||
assertNull(netherPortal);
|
||||
assertNull(offlinePlayer);
|
||||
assertNull(settings);
|
||||
assertNull(spawn);
|
||||
assertNull(targetBlock);
|
||||
assertNull(user);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
fail(ex.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -14,7 +15,9 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
@@ -43,41 +46,48 @@ public class FakeServer implements Server
|
||||
return "1.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player[] getOnlinePlayers()
|
||||
{
|
||||
return players.toArray(new Player[0]);
|
||||
}
|
||||
|
||||
|
||||
public void setOnlinePlayers(List<Player> players)
|
||||
{
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPlayers()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort()
|
||||
{
|
||||
return 25565;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIp()
|
||||
{
|
||||
return "127.0.0.1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName()
|
||||
{
|
||||
return "Test Server";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerId()
|
||||
{
|
||||
return "Test Server";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int broadcastMessage(String string)
|
||||
{
|
||||
int i = 0;
|
||||
@@ -89,11 +99,19 @@ public class FakeServer implements Server
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUpdateFolder()
|
||||
{
|
||||
return "update";
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getUpdateFolderFile()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer(String string)
|
||||
{
|
||||
for (Player player : players)
|
||||
@@ -106,6 +124,7 @@ public class FakeServer implements Server
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> matchPlayer(String string)
|
||||
{
|
||||
List<Player> matches = new ArrayList<Player>();
|
||||
@@ -119,15 +138,17 @@ public class FakeServer implements Server
|
||||
return matches;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginManager getPluginManager()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitScheduler getScheduler()
|
||||
{
|
||||
return new BukkitScheduler() {
|
||||
|
||||
return new BukkitScheduler()
|
||||
{
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(Plugin plugin, Runnable r, long l)
|
||||
{
|
||||
@@ -215,16 +236,19 @@ public class FakeServer implements Server
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServicesManager getServicesManager()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<World> getWorlds()
|
||||
{
|
||||
return worlds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World createWorld(String string, Environment e)
|
||||
{
|
||||
World w = new FakeWorld(string, e);
|
||||
@@ -232,6 +256,7 @@ public class FakeServer implements Server
|
||||
return w;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World createWorld(String string, Environment e, long l)
|
||||
{
|
||||
World w = new FakeWorld(string, e);
|
||||
@@ -239,45 +264,54 @@ public class FakeServer implements Server
|
||||
return w;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld(String string)
|
||||
{
|
||||
for (World world : worlds)
|
||||
{
|
||||
if (world.getName().equalsIgnoreCase(string)) {
|
||||
if (world.getName().equalsIgnoreCase(string))
|
||||
{
|
||||
return world;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger()
|
||||
{
|
||||
return Logger.getLogger("Minecraft");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginCommand getPluginCommand(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePlayers()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchCommand(CommandSender cs, String string)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureDbConfig(ServerConfig sc)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addRecipe(Recipe recipe)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
@@ -287,7 +321,7 @@ public class FakeServer implements Server
|
||||
{
|
||||
players.add(base1);
|
||||
}
|
||||
|
||||
|
||||
public OfflinePlayer createPlayer(String name, IEssentials ess)
|
||||
{
|
||||
OfflinePlayer player = new OfflinePlayer(name, ess);
|
||||
@@ -295,41 +329,55 @@ public class FakeServer implements Server
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World createWorld(String string, Environment e, ChunkGenerator cg)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public World createWorld(String string, Environment e, long l, ChunkGenerator cg)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public World createWorld(WorldCreator creator)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadWorld(String string, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadWorld(World world, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getCommandAliases()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpawnRadius()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpawnRadius(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getOnlineMode()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
@@ -340,6 +388,7 @@ public class FakeServer implements Server
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld(UUID uuid)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
@@ -454,7 +503,19 @@ public class FakeServer implements Server
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultGameMode(GameMode gm)
|
||||
public void setDefaultGameMode(GameMode gamemode)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConsoleCommandSender getConsoleSender()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set getOperators()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class EssentialsChat extends JavaPlugin
|
||||
chatListener = new HashMap<String, IEssentialsChatListener>();
|
||||
|
||||
final EssentialsChatPlayerListener playerListener = new EssentialsChatPlayerListener(getServer(), ess, chatListener);
|
||||
pluginManager.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.Highest, this);
|
||||
pluginManager.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.High, this);
|
||||
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, Util.i18n("versionMismatchAll"));
|
||||
|
||||
@@ -22,4 +22,21 @@ v 1.1:
|
||||
- Added a BukkitPermsUpdateTask to only update superperms once on a load/reload.
|
||||
- Fix for GM not checking inheritance for known superperms nodes.
|
||||
- Optimized getAllPlayersPermissions and fixed pushing unknown perms to superperms.
|
||||
v 1.2:
|
||||
v 1.2:
|
||||
- Changed priority of Registered events to lowest.
|
||||
- Fixed an issue with superperms where plugins define perms with inheritance after the root perms
|
||||
v 1.3:
|
||||
- Rewrote Config loading to use Bukkits Configuration features
|
||||
- Added an opOverride setting in config.
|
||||
If present and set to false, op's will not get overriding permissions in GroupManager.
|
||||
(one op will not be able to alter another op's settings)
|
||||
- GM will now create all relevant world data files for non mirrored worlds.
|
||||
(for all worlds named in config.yml)
|
||||
- Attempt to stop GM wiping groups/users yml's on a bad shut down.
|
||||
- Added event handling to manage new world creation at runtime.
|
||||
- Added the ability to handle unknown worlds at server start.
|
||||
(GM will create the data files for any worlds it finds which are not in the config.yml)
|
||||
- Fix for Bukkit passing a null To location on a player Portaling
|
||||
- Fixed manudelsub not correctly selecting the group to remove.
|
||||
- Added two new permission nodes - groupmanager.notify.self & groupmanager.notify.other
|
||||
These allow players/admins to be notified when players are moved between groups.
|
||||
@@ -1,15 +1,22 @@
|
||||
settings:
|
||||
config:
|
||||
# With this enabled anyone set as op has full permissions when managing GroupManager
|
||||
opOverrides: true
|
||||
data:
|
||||
save:
|
||||
# How often GroupManager will save it's data back to groups and users.yml
|
||||
minutes: 10
|
||||
logging:
|
||||
# level of detail GroupManager will use when logging.
|
||||
# Acceptable entries are - ALL,CONFIG,FINE,FINER,FINEST,INFO,OFF,SEVERE,WARNING
|
||||
level: INFO
|
||||
permission:
|
||||
world:
|
||||
mirror:
|
||||
# Worlds listed here have their permissions mirrored in their children.
|
||||
world:
|
||||
- world_nether
|
||||
- world2
|
||||
- world3
|
||||
world4:
|
||||
- world5
|
||||
# world4:
|
||||
# - world5
|
||||
@@ -8,6 +8,7 @@ groups:
|
||||
- essentials.motd
|
||||
- essentials.rules
|
||||
- essentials.spawn
|
||||
- groupmanager.notify.self
|
||||
inheritance: []
|
||||
info:
|
||||
prefix: '&e'
|
||||
@@ -119,6 +120,7 @@ groups:
|
||||
- groupmanager.manuadd
|
||||
- groupmanager.manudel
|
||||
- groupmanager.manwhois
|
||||
- groupmanager.notify.other
|
||||
inheritance:
|
||||
- builder
|
||||
info:
|
||||
|
||||
Executable → Regular
+24
-67
@@ -5,15 +5,12 @@
|
||||
package org.anjocaido.groupmanager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.anjocaido.groupmanager.utils.Tasks;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
import org.yaml.snakeyaml.reader.UnicodeReader;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -22,9 +19,9 @@ import org.yaml.snakeyaml.reader.UnicodeReader;
|
||||
public class GMConfiguration {
|
||||
|
||||
private GroupManager plugin;
|
||||
private Map<String, Object> rootDataNode;
|
||||
private File configFile;
|
||||
|
||||
private Configuration GMconfig;
|
||||
|
||||
public GMConfiguration(GroupManager plugin) {
|
||||
this.plugin = plugin;
|
||||
load();
|
||||
@@ -44,77 +41,37 @@ public class GMConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
Yaml yaml = new Yaml(new SafeConstructor());
|
||||
FileInputStream rx = null;
|
||||
GMconfig = new Configuration(configFile);
|
||||
|
||||
try {
|
||||
rx = new FileInputStream(configFile);
|
||||
} catch (FileNotFoundException ex) {
|
||||
GroupManager.logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
try {
|
||||
rootDataNode = (Map<String, Object>) yaml.load(new UnicodeReader(rx));
|
||||
if (rootDataNode == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
GMconfig.load();
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + configFile.getPath(), ex);
|
||||
} finally {
|
||||
try {
|
||||
rx.close();
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
adjustLoggerLevel();
|
||||
}
|
||||
|
||||
public Map<String, Object> getMirrorsMap() {
|
||||
if (rootDataNode.get("settings") instanceof Map) {
|
||||
Map<String, Object> settingsNode = (Map<String, Object>) rootDataNode.get("settings");
|
||||
if (settingsNode.get("permission") instanceof Map) {
|
||||
Map<String, Object> permissionNode = (Map<String, Object>) settingsNode.get("permission");
|
||||
if (permissionNode.get("world") instanceof Map) {
|
||||
Map<String, Object> worldsNode = (Map<String, Object>) permissionNode.get("world");
|
||||
if (worldsNode.get("mirror") instanceof Map) {
|
||||
Map<String, Object> mirrorsNode = (Map<String, Object>) worldsNode.get("mirror");
|
||||
return mirrorsNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
public boolean isOpOverride() {
|
||||
return GMconfig.getBoolean("settings.config.opOverrides", true);
|
||||
}
|
||||
|
||||
public Integer getSaveInterval() {
|
||||
if (rootDataNode.get("settings") instanceof Map) {
|
||||
Map<String, Object> settingsNode = (Map<String, Object>) rootDataNode.get("settings");
|
||||
if (settingsNode.get("data") instanceof Map) {
|
||||
Map<String, Object> dataNode = (Map<String, Object>) settingsNode.get("data");
|
||||
if (dataNode.get("save") instanceof Map) {
|
||||
Map<String, Object> saveNode = (Map<String, Object>) dataNode.get("save");
|
||||
if (saveNode.get("minutes") instanceof Integer) {
|
||||
return (Integer) saveNode.get("minutes");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 10;
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> getMirrorsMap() {
|
||||
return (Map<String, Object>) GMconfig.getProperty("settings.permission.world.mirror");
|
||||
}
|
||||
|
||||
public Integer getSaveInterval() {
|
||||
return GMconfig.getInt("settings.data.save.minutes", 10);
|
||||
}
|
||||
|
||||
public void adjustLoggerLevel() {
|
||||
if (rootDataNode.get("settings") instanceof Map) {
|
||||
Map<String, Object> settingsNode = (Map<String, Object>) rootDataNode.get("settings");
|
||||
if (settingsNode.get("logging") instanceof Map) {
|
||||
Map<String, Object> loggingNode = (Map<String, Object>) settingsNode.get("logging");
|
||||
if (loggingNode.get("level") instanceof String) {
|
||||
String level = (String) loggingNode.get("level");
|
||||
try {
|
||||
GroupManager.logger.setLevel(Level.parse(level));
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
GroupManager.logger.setLevel(Level.parse(GMconfig.getString("settings.logging.level", "INFO")));
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
GroupManager.logger.setLevel(Level.INFO);
|
||||
|
||||
GroupManager.logger.setLevel(Level.INFO);
|
||||
}
|
||||
}
|
||||
@@ -24,17 +24,22 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder;
|
||||
import org.anjocaido.groupmanager.events.GMWorldListener;
|
||||
import org.anjocaido.groupmanager.utils.GMLoggerHandler;
|
||||
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
||||
import org.anjocaido.groupmanager.utils.Tasks;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.world.WorldListener;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
/**
|
||||
*
|
||||
@@ -55,6 +60,7 @@ public class GroupManager extends JavaPlugin {
|
||||
private GMConfiguration config;
|
||||
private GMLoggerHandler ch;
|
||||
public static BukkitPermissions BukkitPermissions;
|
||||
private static WorldListener WorldEvents;
|
||||
public static final Logger logger = Logger.getLogger(GroupManager.class.getName());
|
||||
|
||||
//PERMISSIONS FOR COMMAND BEING LOADED
|
||||
@@ -69,6 +75,10 @@ public class GroupManager extends JavaPlugin {
|
||||
worldsHolder.saveChanges();
|
||||
}
|
||||
disableScheduler();
|
||||
|
||||
WorldEvents = null;
|
||||
BukkitPermissions = null;
|
||||
|
||||
// EXAMPLE: Custom code, here we just output some info so we can check all is well
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is disabled!");
|
||||
@@ -94,8 +104,10 @@ public class GroupManager extends JavaPlugin {
|
||||
throw new IllegalStateException("An error ocurred while loading GroupManager");
|
||||
}
|
||||
|
||||
// Initialize the world listener and bukkit permissions to handle events.
|
||||
WorldEvents = new GMWorldListener(this);
|
||||
BukkitPermissions = new BukkitPermissions(this);
|
||||
|
||||
|
||||
enableScheduler();
|
||||
|
||||
/*
|
||||
@@ -108,9 +120,10 @@ public class GroupManager extends JavaPlugin {
|
||||
setLoaded(true);
|
||||
}
|
||||
|
||||
//setLoaded(true);
|
||||
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean isLoaded() {
|
||||
return isLoaded;
|
||||
@@ -147,7 +160,7 @@ public class GroupManager extends JavaPlugin {
|
||||
}
|
||||
};
|
||||
scheduler = new ScheduledThreadPoolExecutor(1);
|
||||
int minutes = getConfig().getSaveInterval();
|
||||
int minutes = getGMConfig().getSaveInterval();
|
||||
scheduler.scheduleAtFixedRate(commiter, minutes, minutes, TimeUnit.MINUTES);
|
||||
GroupManager.logger.info("Scheduled Data Saving is set for every " + minutes + " minutes!");
|
||||
}
|
||||
@@ -224,7 +237,7 @@ public class GroupManager extends JavaPlugin {
|
||||
* @param cmd
|
||||
* @param args
|
||||
*/
|
||||
@SuppressWarnings({"null", "deprecation"})
|
||||
@SuppressWarnings({"deprecation"})
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
boolean playerCanDo = false;
|
||||
@@ -232,6 +245,7 @@ public class GroupManager extends JavaPlugin {
|
||||
Player senderPlayer = null, targetPlayer = null;
|
||||
Group senderGroup = null;
|
||||
User senderUser = null;
|
||||
boolean isOpOverride = config.isOpOverride();
|
||||
|
||||
|
||||
//DETERMINING PLAYER INFORMATION
|
||||
@@ -239,8 +253,10 @@ public class GroupManager extends JavaPlugin {
|
||||
senderPlayer = (Player) sender;
|
||||
senderUser = worldsHolder.getWorldData(senderPlayer).getUser(senderPlayer.getName());
|
||||
senderGroup = senderUser.getGroup();
|
||||
isOpOverride = (isOpOverride && senderPlayer.isOp());
|
||||
|
||||
System.out.println("[PLAYER_COMMAND] " + senderPlayer.getName() + ": /" + commandLabel + " " + Tasks.join(args, " "));
|
||||
if (senderPlayer.isOp() || worldsHolder.getWorldPermissions(senderPlayer).has(senderPlayer, "groupmanager." + cmd.getName())) {
|
||||
if (isOpOverride || worldsHolder.getWorldPermissions(senderPlayer).has(senderPlayer, "groupmanager." + cmd.getName())) {
|
||||
playerCanDo = true;
|
||||
}
|
||||
} else if (sender instanceof ConsoleCommandSender) {
|
||||
@@ -338,27 +354,19 @@ public class GroupManager extends JavaPlugin {
|
||||
}
|
||||
|
||||
//VALIDANDO PERMISSAO
|
||||
if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
|
||||
return false;
|
||||
}
|
||||
if (!isConsole && !senderPlayer.isOp() && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
|
||||
if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
|
||||
sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher.");
|
||||
return false;
|
||||
}
|
||||
if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
|
||||
if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't modify player involving a group that you don't inherit.");
|
||||
return false;
|
||||
}
|
||||
if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't modify player using groups with different heritage line.");
|
||||
return false;
|
||||
}
|
||||
if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
|
||||
sender.sendMessage(ChatColor.RED + "The new group must be a higher rank.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//PARECE OK
|
||||
auxUser.setGroup(auxGroup);
|
||||
sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' group to '" + auxGroup.getName() + "'.");
|
||||
@@ -392,7 +400,7 @@ public class GroupManager extends JavaPlugin {
|
||||
auxUser = dataHolder.getUser(args[0]);
|
||||
}
|
||||
//VALIDANDO PERMISSAO
|
||||
if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
|
||||
return false;
|
||||
}
|
||||
@@ -436,7 +444,7 @@ public class GroupManager extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
//VALIDANDO PERMISSAO
|
||||
if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
|
||||
return false;
|
||||
}
|
||||
@@ -471,8 +479,14 @@ public class GroupManager extends JavaPlugin {
|
||||
} else {
|
||||
auxUser = dataHolder.getUser(args[0]);
|
||||
}
|
||||
auxGroup = dataHolder.getGroup(args[1]);
|
||||
if (auxGroup == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Group not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
//VALIDANDO PERMISSAO
|
||||
if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
|
||||
return false;
|
||||
}
|
||||
@@ -557,7 +571,7 @@ public class GroupManager extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]);
|
||||
if (!isConsole && !senderPlayer.isOp() && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
|
||||
if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
|
||||
|| permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't add a permission you don't have.");
|
||||
return false;
|
||||
@@ -620,12 +634,12 @@ public class GroupManager extends JavaPlugin {
|
||||
auxUser = dataHolder.getUser(args[0]);
|
||||
}
|
||||
//VALIDANDO SUA PERMISSAO
|
||||
if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't modify player with same group than you, or higher.");
|
||||
return false;
|
||||
}
|
||||
permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]);
|
||||
if (!isConsole && !senderPlayer.isOp() && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
|
||||
if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
|
||||
|| permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't remove a permission you don't have.");
|
||||
return false;
|
||||
@@ -1554,23 +1568,23 @@ public class GroupManager extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
//VALIDANDO PERMISSAO
|
||||
if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
|
||||
return false;
|
||||
}
|
||||
if (!isConsole && !senderPlayer.isOp() && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
|
||||
if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
|
||||
sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher.");
|
||||
return false;
|
||||
}
|
||||
if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
|
||||
if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't modify player involving a group that you don't inherit.");
|
||||
return false;
|
||||
}
|
||||
if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
|
||||
if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't modify player using groups with different heritage line.");
|
||||
return false;
|
||||
}
|
||||
if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
|
||||
if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
|
||||
sender.sendMessage(ChatColor.RED + "The new group must be a higher rank.");
|
||||
return false;
|
||||
}
|
||||
@@ -1612,23 +1626,23 @@ public class GroupManager extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
//VALIDANDO PERMISSAO
|
||||
if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
|
||||
return false;
|
||||
}
|
||||
if (!isConsole && !senderPlayer.isOp() && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
|
||||
if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
|
||||
sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher.");
|
||||
return false;
|
||||
}
|
||||
if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
|
||||
if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't modify player involving a group that you don' inherit.");
|
||||
return false;
|
||||
}
|
||||
if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
|
||||
if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't modify player using groups with different heritage line.");
|
||||
return false;
|
||||
}
|
||||
if (!isConsole && !senderPlayer.isOp() && (permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
|
||||
if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
|
||||
sender.sendMessage(ChatColor.RED + "The new group must be a lower rank.");
|
||||
return false;
|
||||
}
|
||||
@@ -1738,11 +1752,36 @@ public class GroupManager extends JavaPlugin {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Send confirmation of a group change.
|
||||
* using permission nodes...
|
||||
*
|
||||
* groupmanager.notify.self
|
||||
* groupmanager.notify.other
|
||||
*
|
||||
* @param name
|
||||
* @param msg
|
||||
*/
|
||||
public static void notify(String name, String msg) {
|
||||
|
||||
Player player = Bukkit.getServer().getPlayerExact(name);
|
||||
|
||||
for(Player test: Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (!test.equals(player)){
|
||||
if (test.hasPermission("groupmanager.notify.other"))
|
||||
test.sendMessage(ChatColor.YELLOW + name +" was " + msg);
|
||||
} else
|
||||
if ((player != null) && ((player.hasPermission("groupmanager.notify.self")) || (player.hasPermission("groupmanager.notify.other"))))
|
||||
player.sendMessage(ChatColor.YELLOW + "You were " + msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the config
|
||||
*/
|
||||
public GMConfiguration getConfig() {
|
||||
public GMConfiguration getGMConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ public class BukkitPermsUpdateTask implements Runnable {
|
||||
public void run() {
|
||||
// Signal loaded and update BukkitPermissions.
|
||||
GroupManager.setLoaded(true);
|
||||
GroupManager.BukkitPermissions.collectPermissions();
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
|
||||
GroupManager.logger.info("Bukkit Permissions Updated!");
|
||||
|
||||
Executable → Regular
File mode changed.
Executable → Regular
File mode changed.
@@ -119,9 +119,12 @@ public class User extends DataUnit implements Cloneable {
|
||||
group = getDataSource().getGroup(group.getName());
|
||||
this.group = group.getName();
|
||||
flagAsChanged();
|
||||
if (GroupManager.isLoaded())
|
||||
if (GroupManager.isLoaded()) {
|
||||
if (GroupManager.BukkitPermissions.player_join = false)
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
|
||||
GroupManager.notify(this.getName(), String.format(" moved to the group %s.", group.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
public void addSubGroup(Group subGroup) {
|
||||
|
||||
Executable → Regular
File mode changed.
Executable → Regular
File mode changed.
Executable → Regular
File mode changed.
+19
-14
@@ -767,13 +767,15 @@ public class WorldDataHolder {
|
||||
aGroupMap.put("permissions", group.getPermissionList());
|
||||
}
|
||||
|
||||
DumperOptions opt = new DumperOptions();
|
||||
opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
final Yaml yaml = new Yaml(opt);
|
||||
try {
|
||||
yaml.dump(root, new OutputStreamWriter(new FileOutputStream(groupsFile), "UTF-8"));
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
} catch (FileNotFoundException ex) {
|
||||
if (!root.isEmpty()) {
|
||||
DumperOptions opt = new DumperOptions();
|
||||
opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
final Yaml yaml = new Yaml(opt);
|
||||
try {
|
||||
yaml.dump(root, new OutputStreamWriter(new FileOutputStream(groupsFile), "UTF-8"));
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
} catch (FileNotFoundException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
/*FileWriter tx = null;
|
||||
@@ -829,13 +831,16 @@ public class WorldDataHolder {
|
||||
aUserMap.put("subgroups", user.subGroupListStringCopy());
|
||||
//END SUBGROUPS NODE - BETA
|
||||
}
|
||||
DumperOptions opt = new DumperOptions();
|
||||
opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
final Yaml yaml = new Yaml(opt);
|
||||
try {
|
||||
yaml.dump(root, new OutputStreamWriter(new FileOutputStream(usersFile), "UTF-8"));
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
} catch (FileNotFoundException ex) {
|
||||
|
||||
if (!root.isEmpty()) {
|
||||
DumperOptions opt = new DumperOptions();
|
||||
opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
final Yaml yaml = new Yaml(opt);
|
||||
try {
|
||||
yaml.dump(root, new OutputStreamWriter(new FileOutputStream(usersFile), "UTF-8"));
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
} catch (FileNotFoundException ex) {
|
||||
}
|
||||
}
|
||||
/*FileWriter tx = null;
|
||||
try {
|
||||
|
||||
+58
-16
@@ -21,6 +21,7 @@ import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
|
||||
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
|
||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||
import org.anjocaido.groupmanager.utils.Tasks;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
@@ -52,6 +53,7 @@ public class WorldsHolder {
|
||||
*/
|
||||
public WorldsHolder(GroupManager plugin) {
|
||||
this.plugin = plugin;
|
||||
// Setup folders and check files exist for the primary world
|
||||
verifyFirstRun();
|
||||
initialLoad();
|
||||
if (defaultWorld == null) {
|
||||
@@ -60,21 +62,48 @@ public class WorldsHolder {
|
||||
}
|
||||
|
||||
private void initialLoad() {
|
||||
// load the initial world
|
||||
initialWorldLoading();
|
||||
// Configure and load any mirrors and additional worlds as defined in config.yml
|
||||
mirrorSetUp();
|
||||
// search the worlds folder for any manually created worlds (not listed in config.yml)
|
||||
loadAllSearchedWorlds();
|
||||
}
|
||||
|
||||
private void initialWorldLoading() {
|
||||
//LOAD EVERY WORLD POSSIBLE
|
||||
//Load the default world
|
||||
loadWorld(serverDefaultWorldName);
|
||||
defaultWorld = worldsData.get(serverDefaultWorldName);
|
||||
|
||||
}
|
||||
|
||||
private void loadAllSearchedWorlds() {
|
||||
|
||||
/*
|
||||
* Read all known worlds from Bukkit
|
||||
* Create the data files if they don't already exist,
|
||||
* and they are not mirrored.
|
||||
*/
|
||||
for (World world: plugin.getServer().getWorlds())
|
||||
if ((!worldsData.containsKey(world.getName().toLowerCase()))
|
||||
&& (!mirrors.containsKey(world.getName().toLowerCase())))
|
||||
setupWorldFolder(world.getName());
|
||||
/*
|
||||
* Loop over all folders within the worlds folder
|
||||
* and attempt to load the world data
|
||||
*/
|
||||
for (File folder : worldsFolder.listFiles()) {
|
||||
if (folder.getName().equalsIgnoreCase(serverDefaultWorldName)) {
|
||||
continue;
|
||||
}
|
||||
if (folder.isDirectory()) {
|
||||
loadWorld(folder.getName());
|
||||
if (folder.isDirectory()) {
|
||||
GroupManager.logger.info("World Found: " + folder.getName());
|
||||
|
||||
/*
|
||||
* don't load any worlds which are already loaded
|
||||
* or mirrored worlds that don't need data.
|
||||
*/
|
||||
if (worldsData.containsKey(folder.getName().toLowerCase())
|
||||
|| mirrors.containsKey(folder.getName().toLowerCase())) {
|
||||
continue;
|
||||
}
|
||||
loadWorld(folder.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,9 +111,15 @@ public class WorldsHolder {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void mirrorSetUp() {
|
||||
mirrors.clear();
|
||||
Map<String, Object> mirrorsMap = plugin.getConfig().getMirrorsMap();
|
||||
Map<String, Object> mirrorsMap = plugin.getGMConfig().getMirrorsMap();
|
||||
if (mirrorsMap != null) {
|
||||
for (String source : mirrorsMap.keySet()) {
|
||||
// Make sure all non mirrored worlds have a set of data files.
|
||||
setupWorldFolder(source);
|
||||
// Load the world data
|
||||
if (!worldsData.containsKey(source.toLowerCase()))
|
||||
loadWorld(source);
|
||||
|
||||
if (mirrorsMap.get(source) instanceof ArrayList) {
|
||||
ArrayList mirrorList = (ArrayList) mirrorsMap.get(source);
|
||||
for (Object o : mirrorList) {
|
||||
@@ -246,18 +281,25 @@ public class WorldsHolder {
|
||||
}
|
||||
|
||||
private void verifyFirstRun() {
|
||||
|
||||
Properties server = new Properties();
|
||||
try {
|
||||
server.load(new FileInputStream(new File("server.properties")));
|
||||
serverDefaultWorldName = server.getProperty("level-name").toLowerCase();
|
||||
setupWorldFolder(serverDefaultWorldName);
|
||||
} catch (IOException ex) {
|
||||
GroupManager.logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setupWorldFolder(String worldName) {
|
||||
worldsFolder = new File(plugin.getDataFolder(), "worlds");
|
||||
if (!worldsFolder.exists()) {
|
||||
worldsFolder.mkdirs();
|
||||
}
|
||||
Properties server = new Properties();
|
||||
try {
|
||||
server.load(new FileInputStream(new File("server.properties")));
|
||||
} catch (IOException ex) {
|
||||
GroupManager.logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
serverDefaultWorldName = server.getProperty("level-name").toLowerCase();
|
||||
File defaultWorldFolder = new File(worldsFolder, serverDefaultWorldName);
|
||||
|
||||
File defaultWorldFolder = new File(worldsFolder, worldName);
|
||||
if (!defaultWorldFolder.exists()) {
|
||||
defaultWorldFolder.mkdirs();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.anjocaido.groupmanager.events;
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.event.world.WorldListener;
|
||||
|
||||
|
||||
/**
|
||||
* @author ElgarL
|
||||
*
|
||||
* Handle new world creation from other plugins
|
||||
*
|
||||
*/
|
||||
public class GMWorldListener extends WorldListener {
|
||||
|
||||
private final GroupManager plugin;
|
||||
|
||||
public GMWorldListener(GroupManager instance) {
|
||||
plugin = instance;
|
||||
registerEvents();
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
plugin.getServer().getPluginManager().registerEvent(Event.Type.WORLD_INIT, this, Event.Priority.Lowest, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorldInit(WorldInitEvent event) {
|
||||
String worldName = event.getWorld().getName();
|
||||
|
||||
if (GroupManager.isLoaded() && !plugin.getWorldsHolder().isInList(worldName)) {
|
||||
GroupManager.logger.info("New world detected...");
|
||||
GroupManager.logger.info("Creating data for: " + worldName);
|
||||
plugin.getWorldsHolder().setupWorldFolder(worldName);
|
||||
plugin.getWorldsHolder().loadWorld(worldName);
|
||||
if (plugin.getWorldsHolder().isInList(worldName)) {
|
||||
GroupManager.logger.info("Don't forget to configure/mirror this world in config.yml.");
|
||||
} else
|
||||
GroupManager.logger.severe("Failed to configure this world.");
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-12
@@ -43,7 +43,6 @@ import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
//import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
@@ -79,13 +78,13 @@ public class BukkitPermissions {
|
||||
|
||||
PlayerEvents playerEventListener = new PlayerEvents();
|
||||
|
||||
manager.registerEvent(Event.Type.PLAYER_JOIN, playerEventListener, Event.Priority.Normal, plugin);
|
||||
manager.registerEvent(Event.Type.PLAYER_KICK, playerEventListener, Event.Priority.Normal, plugin);
|
||||
manager.registerEvent(Event.Type.PLAYER_QUIT, playerEventListener, Event.Priority.Normal, plugin);
|
||||
manager.registerEvent(Event.Type.PLAYER_JOIN, playerEventListener, Event.Priority.Lowest, plugin);
|
||||
manager.registerEvent(Event.Type.PLAYER_KICK, playerEventListener, Event.Priority.Lowest, plugin);
|
||||
manager.registerEvent(Event.Type.PLAYER_QUIT, playerEventListener, Event.Priority.Lowest, plugin);
|
||||
|
||||
manager.registerEvent(Event.Type.PLAYER_RESPAWN, playerEventListener, Event.Priority.Normal, plugin);
|
||||
manager.registerEvent(Event.Type.PLAYER_TELEPORT, playerEventListener, Event.Priority.Normal, plugin);
|
||||
manager.registerEvent(Event.Type.PLAYER_PORTAL, playerEventListener, Event.Priority.Normal, plugin);
|
||||
manager.registerEvent(Event.Type.PLAYER_RESPAWN, playerEventListener, Event.Priority.Lowest, plugin);
|
||||
manager.registerEvent(Event.Type.PLAYER_TELEPORT, playerEventListener, Event.Priority.Lowest, plugin);
|
||||
manager.registerEvent(Event.Type.PLAYER_PORTAL, playerEventListener, Event.Priority.Lowest, plugin);
|
||||
|
||||
ServerListener serverListener = new BukkitEvents();
|
||||
|
||||
@@ -93,7 +92,7 @@ public class BukkitPermissions {
|
||||
manager.registerEvent(Event.Type.PLUGIN_DISABLE, serverListener, Event.Priority.Normal, plugin);
|
||||
}
|
||||
|
||||
private void collectPermissions() {
|
||||
public void collectPermissions() {
|
||||
registeredPermissions.clear();
|
||||
for (Plugin bukkitPlugin : Bukkit.getServer().getPluginManager().getPlugins()) {
|
||||
for(Permission permission : bukkitPlugin.getDescription().getPermissions())
|
||||
@@ -134,8 +133,8 @@ public class BukkitPermissions {
|
||||
Boolean value;
|
||||
for (Permission permission : registeredPermissions) {
|
||||
value = worldData.getPermissionsHandler().checkUserPermission(user, permission.getName());
|
||||
|
||||
attachment.setPermission(permission, value);
|
||||
if (value == true)
|
||||
attachment.setPermission(permission, value);
|
||||
}
|
||||
|
||||
// Add any missing permissions for this player (non bukkit plugins)
|
||||
@@ -199,7 +198,7 @@ public class BukkitPermissions {
|
||||
|
||||
@Override
|
||||
public void onPlayerPortal(PlayerPortalEvent event) { // will portal into another world
|
||||
if(!event.getFrom().getWorld().equals(event.getTo().getWorld())){ // only if world actually changed
|
||||
if(event.getTo() != null && !event.getFrom().getWorld().equals(event.getTo().getWorld())){ // only if world actually changed
|
||||
updatePermissions(event.getPlayer(), event.getTo().getWorld().getName());
|
||||
}
|
||||
}
|
||||
@@ -211,7 +210,7 @@ public class BukkitPermissions {
|
||||
|
||||
@Override
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) { // can be teleported into another world
|
||||
if (!event.getFrom().getWorld().equals(event.getTo().getWorld())) { // only if world actually changed
|
||||
if (event.getTo() != null && !event.getFrom().getWorld().equals(event.getTo().getWorld())) { // only if world actually changed
|
||||
updatePermissions(event.getPlayer(), event.getTo().getWorld().getName());
|
||||
}
|
||||
}
|
||||
|
||||
Executable → Regular
File mode changed.
Executable → Regular
File mode changed.
Executable → Regular
File mode changed.
Executable → Regular
File mode changed.
@@ -1,5 +1,5 @@
|
||||
name: GroupManager
|
||||
version: "1.2 (Phoenix)"
|
||||
version: "1.3 (Phoenix)"
|
||||
main: org.anjocaido.groupmanager.GroupManager
|
||||
website: http://www.anjocaido.info/
|
||||
description: Provides on-the-fly system for permissions system created by Nijikokun. But all in memory, and with flat-file saving schedule.
|
||||
|
||||
+3
-1
@@ -18,4 +18,6 @@ The default line ending is LF.
|
||||
|
||||
To build all jars, select the BuildAll project and build that. You'll find all jars inside the dist/lib folder of the BuildAll project.
|
||||
|
||||
If you create pull requests, always make them for the master branch.
|
||||
If you create pull requests, always make them for the master branch.
|
||||
|
||||
The essentials bug tracker can be found at http://www.assembla.com/spaces/essentials/tickets
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user