mirror of
https://github.com/EssentialsX/Essentials.git
synced 2026-11-05 01:00:13 -05:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40e106db13 | ||
|
|
3dc0659f66 | ||
|
|
e652ed2981 | ||
|
|
28db891aa5 | ||
|
|
b63ae9b771 | ||
|
|
27c84ceaac | ||
|
|
d67ccd03ca | ||
|
|
96b0f27c51 |
No files matched your search
@@ -96,6 +96,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
if (!Thread.currentThread().getStackTrace()[5].getMethodName().equals("loadPlugin")) {
|
||||
logger.log(Level.SEVERE, "Another plugin is trying to enable Essentials manually. Don't do this! It's probably "
|
||||
+ Thread.currentThread().getStackTrace()[5].getClassName());
|
||||
}
|
||||
if (enableErrorLogging)
|
||||
{
|
||||
logger.addHandler(errorHandler);
|
||||
|
||||
@@ -1,75 +1,55 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.Entity;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public enum Mob
|
||||
{
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY),
|
||||
COW("Cow", Enemies.FRIENDLY),
|
||||
CREEPER("Creeper", Enemies.ENEMY),
|
||||
GHAST("Ghast", Enemies.ENEMY),
|
||||
GIANT("Giant", "GiantZombie", Enemies.ENEMY),
|
||||
PIG("Pig", Enemies.FRIENDLY),
|
||||
PIGZOMB("PigZombie", Enemies.NEUTRAL),
|
||||
SHEEP("Sheep", Enemies.FRIENDLY, ""),
|
||||
SKELETON("Skeleton", Enemies.ENEMY),
|
||||
SLIME("Slime", Enemies.ENEMY),
|
||||
SPIDER("Spider", Enemies.ENEMY),
|
||||
SQUID("Squid", Enemies.FRIENDLY),
|
||||
ZOMBIE("Zombie", Enemies.ENEMY),
|
||||
MONSTER("Monster", Enemies.ENEMY),
|
||||
WOLF("Wolf", Enemies.NEUTRAL);
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY, CreatureType.CHICKEN),
|
||||
COW("Cow", Enemies.FRIENDLY, CreatureType.COW),
|
||||
CREEPER("Creeper", Enemies.ENEMY, CreatureType.CREEPER),
|
||||
GHAST("Ghast", Enemies.ENEMY, CreatureType.GHAST),
|
||||
GIANT("Giant", Enemies.ENEMY, CreatureType.GIANT),
|
||||
PIG("Pig", Enemies.FRIENDLY, CreatureType.PIG),
|
||||
PIGZOMB("PigZombie", Enemies.NEUTRAL, CreatureType.PIG_ZOMBIE),
|
||||
SHEEP("Sheep", Enemies.FRIENDLY, "", CreatureType.SHEEP),
|
||||
SKELETON("Skeleton", Enemies.ENEMY, CreatureType.SKELETON),
|
||||
SLIME("Slime", Enemies.ENEMY, CreatureType.SLIME),
|
||||
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);
|
||||
|
||||
public static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
private Mob(String n, Enemies en, String s)
|
||||
private Mob(String n, Enemies en, String s, CreatureType type)
|
||||
{
|
||||
this.s = s;
|
||||
this.suffix = s;
|
||||
this.name = n;
|
||||
this.craftClass = n;
|
||||
this.entityClass = n;
|
||||
this.type = en;
|
||||
this.bukkitType = type;
|
||||
}
|
||||
|
||||
private Mob(String n, Enemies en)
|
||||
private Mob(String n, Enemies en, CreatureType type)
|
||||
{
|
||||
this.name = n;
|
||||
this.craftClass = n;
|
||||
this.entityClass = n;
|
||||
this.type = en;
|
||||
this.bukkitType = type;
|
||||
}
|
||||
|
||||
private Mob(String n, String ec, Enemies en)
|
||||
{
|
||||
this.name = n;
|
||||
this.craftClass = n;
|
||||
this.entityClass = ec;
|
||||
this.type = en;
|
||||
}
|
||||
|
||||
private Mob(String n, String ec, String cc, Enemies en)
|
||||
{
|
||||
this.name = n;
|
||||
this.entityClass = ec;
|
||||
this.craftClass = cc;
|
||||
this.type = en;
|
||||
}
|
||||
public String s = "s";
|
||||
public String name;
|
||||
public Enemies type;
|
||||
private String entityClass;
|
||||
private String craftClass;
|
||||
public String suffix = "s";
|
||||
final public String name;
|
||||
final public Enemies type;
|
||||
final private CreatureType bukkitType;
|
||||
private static final Map<String, Mob> hashMap = new HashMap<String, Mob>();
|
||||
|
||||
static
|
||||
@@ -80,24 +60,16 @@ public enum Mob
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings(
|
||||
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
|
||||
{
|
||||
"unchecked", "CallToThreadDumpStack"
|
||||
})
|
||||
public CraftEntity spawn(Player player, Server server) throws MobException
|
||||
{
|
||||
try
|
||||
|
||||
final LivingEntity entity = player.getWorld().spawnCreature(loc, this.bukkitType);
|
||||
if (entity == null)
|
||||
{
|
||||
WorldServer world = ((org.bukkit.craftbukkit.CraftWorld)player.getWorld()).getHandle();
|
||||
Constructor<CraftEntity> craft = (Constructor<CraftEntity>)ClassLoader.getSystemClassLoader().loadClass("org.bukkit.craftbukkit.entity.Craft" + craftClass).getConstructors()[0];
|
||||
Constructor<Entity> entity = (Constructor<Entity>)ClassLoader.getSystemClassLoader().loadClass("net.minecraft.server.Entity" + entityClass).getConstructors()[0];
|
||||
return craft.newInstance((CraftServer)server, entity.newInstance(world));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("unableToSpawnMob"), ex);
|
||||
throw new MobException(ex);
|
||||
logger.log(Level.WARNING, Util.i18n("unableToSpawnMob"));
|
||||
throw new MobException();
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,22 +79,17 @@ public enum Mob
|
||||
NEUTRAL("neutral"),
|
||||
ENEMY("enemy");
|
||||
|
||||
private Enemies(String t)
|
||||
private Enemies(final String t)
|
||||
{
|
||||
this.type = t;
|
||||
}
|
||||
protected String type;
|
||||
final protected String type;
|
||||
}
|
||||
|
||||
|
||||
public static class MobException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private MobException(Exception ex)
|
||||
{
|
||||
super(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static Mob fromName(String n)
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.earth2me.essentials.api;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.EssentialsConf;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.UserData;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
@@ -79,8 +78,7 @@ public final class Economy
|
||||
if (user == null) {
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
// Use UserData to avoid calls to iConomy and Register
|
||||
return ((UserData)user).getMoney();
|
||||
return user.getMoney();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,8 +98,7 @@ public final class Economy
|
||||
{
|
||||
throw new NoLoanPermittedException();
|
||||
}
|
||||
// Use UserData to avoid calls to iConomy and Register
|
||||
((UserData)user).setMoney(balance);
|
||||
user.setMoney(balance);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.craftbukkit.block.CraftCreatureSpawner;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
|
||||
|
||||
@@ -19,12 +20,12 @@ public class Commandspawner extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
if (args.length < 1 || args[0].length() < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
Block target = user.getTarget().getTargetBlock();
|
||||
final Block target = user.getTarget().getTargetBlock();
|
||||
if (target.getType() != Material.MOB_SPAWNER)
|
||||
{
|
||||
throw new Exception(Util.i18n("mobSpawnTarget"));
|
||||
@@ -33,7 +34,8 @@ public class Commandspawner extends EssentialsCommand
|
||||
charge(user);
|
||||
try
|
||||
{
|
||||
((CreatureSpawner)target).setCreatureType(CreatureType.fromName(args[0]));
|
||||
final String name = args[0].substring(0, 1).toUpperCase() + args[0].substring(1).toLowerCase();
|
||||
new CraftCreatureSpawner(target).setCreatureType(CreatureType.fromName(name));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.earth2me.essentials.commands;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.Mob.MobException;
|
||||
@@ -20,6 +18,7 @@ import org.bukkit.craftbukkit.entity.CraftCreeper;
|
||||
import org.bukkit.craftbukkit.entity.CraftSheep;
|
||||
import org.bukkit.craftbukkit.entity.CraftSlime;
|
||||
import org.bukkit.craftbukkit.entity.CraftWolf;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
|
||||
public class Commandspawnmob extends EssentialsCommand
|
||||
@@ -62,9 +61,9 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
|
||||
|
||||
CraftEntity spawnedMob = null;
|
||||
Entity spawnedMob = null;
|
||||
Mob mob = null;
|
||||
CraftEntity spawnedMount = null;
|
||||
Entity spawnedMount = null;
|
||||
Mob mobMount = null;
|
||||
|
||||
mob = Mob.fromName(mobType);
|
||||
@@ -74,16 +73,6 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
charge(user);
|
||||
WorldServer world = ((CraftWorld)user.getWorld()).getHandle();
|
||||
try
|
||||
{
|
||||
spawnedMob = mob.spawn(user, server);
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
}
|
||||
int[] ignore =
|
||||
{
|
||||
8, 9
|
||||
@@ -96,8 +85,16 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
loc.setY(loc.getY() + 1);
|
||||
block = user.getWorld().getBlockAt(loc);
|
||||
}
|
||||
spawnedMob.teleportTo(loc);
|
||||
world.addEntity(spawnedMob.getHandle());
|
||||
|
||||
try
|
||||
{
|
||||
spawnedMob = mob.spawn(user, server, loc);
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (mountType != null)
|
||||
{
|
||||
@@ -109,16 +106,14 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
try
|
||||
{
|
||||
spawnedMount = mobMount.spawn(user, server);
|
||||
spawnedMount = mobMount.spawn(user, server, loc);
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
}
|
||||
spawnedMount.teleportTo(spawnedMob);
|
||||
spawnedMount.getHandle().setPassengerOf(spawnedMob.getHandle());
|
||||
world.addEntity(spawnedMount.getHandle());
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
}
|
||||
if (mobData != null)
|
||||
{
|
||||
@@ -142,23 +137,19 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
{
|
||||
for (int i = 1; i < mobCount; i++)
|
||||
{
|
||||
spawnedMob = mob.spawn(user, server);
|
||||
spawnedMob.teleportTo(loc);
|
||||
world.addEntity(spawnedMob.getHandle());
|
||||
spawnedMob = mob.spawn(user, server, loc);
|
||||
if (mobMount != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
spawnedMount = mobMount.spawn(user, server);
|
||||
spawnedMount = mobMount.spawn(user, server, loc);
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
}
|
||||
spawnedMount.teleportTo(spawnedMob);
|
||||
spawnedMount.getHandle().setPassengerOf(spawnedMob.getHandle());
|
||||
world.addEntity(spawnedMount.getHandle());
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
}
|
||||
if (mobData != null)
|
||||
{
|
||||
@@ -169,7 +160,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
changeMobData(mobMount.name, spawnedMount, mountData, user);
|
||||
}
|
||||
}
|
||||
user.sendMessage(args[1] + " " + mob.name.toLowerCase() + mob.s + Util.i18n("spawned"));
|
||||
user.sendMessage(args[1] + " " + mob.name.toLowerCase() + mob.suffix + Util.i18n("spawned"));
|
||||
}
|
||||
catch (MobException e1)
|
||||
{
|
||||
@@ -195,7 +186,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1);
|
||||
}
|
||||
|
||||
private void changeMobData(String type, CraftEntity spawned, String data, User user) throws Exception
|
||||
private void changeMobData(String type, Entity spawned, String data, User user) throws Exception
|
||||
{
|
||||
if ("Slime".equalsIgnoreCase(type))
|
||||
{
|
||||
|
||||
@@ -68,14 +68,6 @@ public class Methods {
|
||||
if(method.getDescription().getName().equals(name)) plugin = method; else plugin = manager.getPlugin(name);
|
||||
if(plugin == null) continue;
|
||||
|
||||
if(!plugin.isEnabled()) {
|
||||
this.self = true;
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, name + " Plugin was found, but not enabled before Essentials. Read the Essentials thread for help.");
|
||||
//manager.enablePlugin(plugin);
|
||||
}
|
||||
|
||||
if(plugin == null) continue;
|
||||
|
||||
Method current = this.createMethod(plugin);
|
||||
if(current == null) continue;
|
||||
|
||||
@@ -99,9 +91,7 @@ public class Methods {
|
||||
break;
|
||||
}
|
||||
|
||||
if(this.preferred.isEmpty()) this.Method = attached;
|
||||
|
||||
if(count == 0) {
|
||||
if(count != 0) {
|
||||
if(this.preferred.equalsIgnoreCase(attached.getName()))
|
||||
this.Method = attached;
|
||||
} else {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.nijikokun.bukkit.Permissions;
|
||||
import com.nijiko.Misc;
|
||||
import com.nijiko.configuration.DefaultConfiguration;
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.permissions.NijikoPermissionsProxy;
|
||||
@@ -55,6 +56,10 @@ public class Permissions extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (!Thread.currentThread().getStackTrace()[5].getMethodName().equals("loadPlugin")) {
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, "Another plugin is trying to enable Permissions manually. Don't do this! It's probably "
|
||||
+ Thread.currentThread().getStackTrace()[5].getClassName());
|
||||
}
|
||||
Server = this.getServer();
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
|
||||
|
||||
@@ -63,6 +63,10 @@ public class GroupManager extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (!Thread.currentThread().getStackTrace()[5].getMethodName().equals("loadPlugin")) {
|
||||
logger.log(Level.SEVERE, "Another plugin is trying to enable GroupManager manually. Don't do this! It's probably "
|
||||
+ Thread.currentThread().getStackTrace()[5].getClassName());
|
||||
}
|
||||
GroupManager.logger.setUseParentHandlers(false);
|
||||
GMLoggerHandler ch = new GMLoggerHandler();
|
||||
GroupManager.logger.addHandler(ch);
|
||||
|
||||
+21
-10
@@ -15,7 +15,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
public class EssentialsSpawnPlayerListener extends PlayerListener
|
||||
{
|
||||
@Override
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
final IEssentials ess = Essentials.getStatic();
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -25,7 +25,8 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
|
||||
if (ess.getSettings().getRespawnAtHome())
|
||||
{
|
||||
Location home = user.getHome(user.getLocation());
|
||||
if (home == null) {
|
||||
if (home == null)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
event.setRespawnLocation(home);
|
||||
@@ -36,28 +37,38 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
|
||||
{
|
||||
}
|
||||
Location spawn = ess.getSpawn().getSpawn(user.getGroup());
|
||||
if (spawn == null) {
|
||||
if (spawn == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
event.setRespawnLocation(spawn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
final IEssentials ess = Essentials.getStatic();
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
|
||||
if (!user.isNew())
|
||||
{
|
||||
return;
|
||||
}
|
||||
user.setNew(false);
|
||||
try {
|
||||
user.getTeleport().now(ess.getSpawn().getSpawn(ess.getSettings().getNewbieSpawn()));
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger("Minecraft").log(Level.WARNING, Util.i18n("teleportNewPlayerError"), ex);
|
||||
}
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
user.getTeleport().now(ess.getSpawn().getSpawn(ess.getSettings().getNewbieSpawn()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.WARNING, Util.i18n("teleportNewPlayerError"), ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (ess.getSettings().getAnnounceNewPlayers())
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user