mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 06:57:39 +01:00
Updated for CB 602
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1043 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
5125181967
commit
17b3c793d9
@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.InventoryPlayer;
|
||||
@ -128,36 +127,52 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerEvent event)
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (!Essentials.getSettings().getReclaimSetting())
|
||||
{
|
||||
return;
|
||||
}
|
||||
User.get(event.getPlayer()).dispose();
|
||||
Thread thread = new Thread(new Runnable()
|
||||
{
|
||||
@SuppressWarnings("LoggerStringConcat")
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(1000);
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
double mem = rt.freeMemory();
|
||||
rt.runFinalization();
|
||||
rt.gc();
|
||||
mem = rt.freeMemory() - mem;
|
||||
mem /= 1024 * 1024;
|
||||
logger.info("Freed " + mem + " MB.");
|
||||
}
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.setPriority(Thread.MIN_PRIORITY);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerLogin(PlayerLoginEvent event)
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Essentials.getStatic().backup.onPlayerJoin();
|
||||
User user = User.get(event.getPlayer());
|
||||
if (event.getResult() != Result.ALLOWED)
|
||||
return;
|
||||
|
||||
if (user.isBanned())
|
||||
{
|
||||
event.disallow(Result.KICK_BANNED, "The Ban Hammer has spoken!");
|
||||
return;
|
||||
}
|
||||
|
||||
//we do not know the ip address on playerlogin so we need to do this here.
|
||||
if (user.isIpBanned())
|
||||
{
|
||||
user.kickPlayer("The Ban Hammer has spoken!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (server.getOnlinePlayers().length >= server.getMaxPlayers() && !user.isOp())
|
||||
{
|
||||
event.disallow(Result.KICK_FULL, "Server is full");
|
||||
return;
|
||||
}
|
||||
|
||||
user.setDisplayName(user.getNick());
|
||||
|
||||
if (!Essentials.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
|
||||
@ -175,6 +190,26 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
if (mail.isEmpty()) user.sendMessage("§7You have no new mail.");
|
||||
else user.sendMessage("§cYou have " + mail.size() + " messages!§f Type §7/mail read§f to view your mail.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerLogin(PlayerLoginEvent event)
|
||||
{
|
||||
User user = User.get(event.getPlayer());
|
||||
if (event.getResult() != Result.ALLOWED)
|
||||
return;
|
||||
|
||||
if (user.isBanned())
|
||||
{
|
||||
event.disallow(Result.KICK_BANNED, "The Ban Hammer has spoken!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (server.getOnlinePlayers().length >= server.getMaxPlayers() && !user.isOp())
|
||||
{
|
||||
event.disallow(Result.KICK_FULL, "Server is full");
|
||||
return;
|
||||
}
|
||||
|
||||
updateCompass(user);
|
||||
}
|
||||
@ -192,7 +227,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerTeleport(PlayerMoveEvent event)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
User user = User.get(event.getPlayer());
|
||||
if (user.currentJail == null || user.currentJail.isEmpty())
|
||||
|
@ -7,24 +7,25 @@ import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockInteractEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
|
||||
public class Jail extends BlockListener implements IConf {
|
||||
|
||||
public class Jail extends BlockListener implements IConf
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private EssentialsConf config;
|
||||
|
||||
public Jail(File dataFolder) {
|
||||
public Jail(File dataFolder)
|
||||
{
|
||||
config = new EssentialsConf(new File(dataFolder, "jail.yml"));
|
||||
config.load();
|
||||
}
|
||||
|
||||
public void setJail(Location loc, String jailName) throws Exception {
|
||||
public void setJail(Location loc, String jailName) throws Exception
|
||||
{
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("world", loc.getWorld().getName());
|
||||
map.put("x", loc.getX());
|
||||
@ -36,8 +37,10 @@ public class Jail extends BlockListener implements IConf {
|
||||
config.save();
|
||||
}
|
||||
|
||||
public Location getJail(String jailName) throws Exception {
|
||||
if (config.getProperty(jailName.toLowerCase()) == null) {
|
||||
public Location getJail(String jailName) throws Exception
|
||||
{
|
||||
if (config.getProperty(jailName.toLowerCase()) == null)
|
||||
{
|
||||
throw new Exception("That jail does not exist");
|
||||
}
|
||||
|
||||
@ -46,10 +49,12 @@ public class Jail extends BlockListener implements IConf {
|
||||
double x = config.getDouble(jailName + ".x", 0); // wh.spawnX
|
||||
double y = config.getDouble(jailName + ".y", 0); // wh.spawnY
|
||||
double z = config.getDouble(jailName + ".z", 0); // wh.spawnZ
|
||||
float yaw = (float) config.getDouble(jailName + ".yaw", 0);
|
||||
float pitch = (float) config.getDouble(jailName + ".pitch", 0);
|
||||
for (World w : Essentials.getStatic().getServer().getWorlds()) {
|
||||
if (w.getName().equalsIgnoreCase(world)) {
|
||||
float yaw = (float)config.getDouble(jailName + ".yaw", 0);
|
||||
float pitch = (float)config.getDouble(jailName + ".pitch", 0);
|
||||
for (World w : Essentials.getStatic().getServer().getWorlds())
|
||||
{
|
||||
if (w.getName().equalsIgnoreCase(world))
|
||||
{
|
||||
jWorld = w;
|
||||
break;
|
||||
}
|
||||
@ -58,21 +63,25 @@ public class Jail extends BlockListener implements IConf {
|
||||
return new Location(jWorld, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
public void sendToJail(User user, String jail) throws Exception {
|
||||
public void sendToJail(User user, String jail) throws Exception
|
||||
{
|
||||
user.teleportTo(getJail(jail));
|
||||
user.currentJail = jail;
|
||||
}
|
||||
|
||||
public void delJail(String jail) throws Exception {
|
||||
public void delJail(String jail) throws Exception
|
||||
{
|
||||
config.removeProperty(jail.toLowerCase());
|
||||
config.save();
|
||||
}
|
||||
|
||||
public List<String> getJails() throws Exception {
|
||||
public List<String> getJails() throws Exception
|
||||
{
|
||||
return config.getKeys(null);
|
||||
}
|
||||
|
||||
public void reloadConfig() {
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
}
|
||||
|
||||
@ -80,7 +89,8 @@ public class Jail extends BlockListener implements IConf {
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
User user = User.get(event.getPlayer());
|
||||
if (user.isJailed()) {
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -89,18 +99,19 @@ public class Jail extends BlockListener implements IConf {
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
User user = User.get(event.getPlayer());
|
||||
if (user.isJailed()) {
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
public void onBlockDamage(BlockDamageEvent event)
|
||||
{
|
||||
User user = User.get(event.getPlayer());
|
||||
if (user.isJailed()) {
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -283,4 +283,69 @@ public class OfflinePlayer implements Player
|
||||
public void sendRawMessage(String string) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public Location getCompassTarget()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public int getMaximumNoDamageTicks()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void setMaximumNoDamageTicks(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public int getLastDamage()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void setLastDamage(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public int getNoDamageTicks()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void setNoDamageTicks(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public boolean teleport(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public boolean teleport(Entity entity)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public Entity getPassenger()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public boolean setPassenger(Entity entity)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public boolean eject()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
@ -154,15 +154,15 @@ public class PlayerWrapper implements Player
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleportTo(Location lctn)
|
||||
public boolean teleport(Location lctn)
|
||||
{
|
||||
base.teleportTo(lctn);
|
||||
return base.teleport(lctn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleportTo(Entity entity)
|
||||
public boolean teleport(Entity entity)
|
||||
{
|
||||
base.teleportTo(entity);
|
||||
return base.teleport(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -329,7 +329,88 @@ public class PlayerWrapper implements Player
|
||||
return base.getEyeLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String string) {
|
||||
base.sendRawMessage(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getCompassTarget()
|
||||
{
|
||||
return base.getCompassTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumNoDamageTicks()
|
||||
{
|
||||
return base.getMaximumNoDamageTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaximumNoDamageTicks(int i)
|
||||
{
|
||||
base.setMaximumNoDamageTicks(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLastDamage()
|
||||
{
|
||||
return base.getLastDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastDamage(int i)
|
||||
{
|
||||
base.setLastDamage(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNoDamageTicks()
|
||||
{
|
||||
return base.getNoDamageTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoDamageTicks(int i)
|
||||
{
|
||||
base.setNoDamageTicks(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getPassenger()
|
||||
{
|
||||
return base.getPassenger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPassenger(Entity entity)
|
||||
{
|
||||
return base.setPassenger(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return base.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eject()
|
||||
{
|
||||
return base.eject();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleportTo(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleportTo(Entity entity)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
@ -151,6 +151,11 @@ public class Settings implements IConf
|
||||
return ChatColor.getByCode(Integer.parseInt(colorName, 16));
|
||||
}
|
||||
|
||||
public boolean getReclaimSetting()
|
||||
{
|
||||
return config.getBoolean("reclaim-onlogout", true);
|
||||
}
|
||||
|
||||
public String getNetherName()
|
||||
{
|
||||
return config.getString("nether.folder", "nether");
|
||||
|
@ -3,7 +3,7 @@ package com.earth2me.essentials.chat;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
@ -19,7 +19,7 @@ public class EssentialsChatPlayerListener extends PlayerListener
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("CallToThreadDumpStack")
|
||||
public void onPlayerJoin(PlayerEvent event)
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -2,18 +2,14 @@ package com.earth2me.essentials.protect;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockInteractEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockRightClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@ -128,7 +124,7 @@ public class EssentialsProtectBlockListener extends BlockListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockFlow(BlockFromToEvent event)
|
||||
public void onBlockFromTo(BlockFromToEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
Block block = event.getBlock();
|
||||
|
@ -5,7 +5,6 @@ import com.earth2me.essentials.User;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
@ -4,7 +4,7 @@ import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
@ -32,7 +32,7 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerEvent event)
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Essentials.loadClasses();
|
||||
User user = User.get(event.getPlayer());
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user