1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-12 09:35:26 +02:00

Cleanup debug message, code tidy.

This commit is contained in:
KHobbits
2011-10-25 22:18:28 +01:00
parent bb7183deeb
commit 1b1501c504
6 changed files with 87 additions and 64 deletions

View File

@@ -97,7 +97,6 @@ public class EssentialsEntityListener extends EntityListener
@Override
public void onFoodLevelChange(FoodLevelChangeEvent event)
{
LOGGER.log(Level.INFO, "Getting hungry...");
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
event.setCancelled(true);

View File

@@ -9,20 +9,23 @@ import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.World.Environment;
public class Spawn implements IConf {
public class Spawn implements IConf
{
private static final Logger logger = Logger.getLogger("Minecraft");
private final EssentialsConf config;
private final Server server;
public Spawn(Server server, File dataFolder) {
public Spawn(Server server, File dataFolder)
{
File configFile = new File(dataFolder, "spawn.yml");
this.server = server;
config = new EssentialsConf(configFile);
config.load();
}
public void setSpawn(Location loc, String group) {
public void setSpawn(Location loc, String group)
{
Map<String, Object> map = new HashMap<String, Object>();
map.put("world", loc.getWorld().getName());
map.put("x", loc.getX());
@@ -33,18 +36,24 @@ public class Spawn implements IConf {
config.setProperty(group, map);
config.save();
if ("default".equals(group)) {
if ("default".equals(group))
{
loc.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
}
}
public Location getSpawn(String group) {
if (config.getProperty(group) == null) {
public Location getSpawn(String group)
{
if (config.getProperty(group) == null)
{
group = "default";
}
if (config.getProperty(group) == null) {
for (World w : server.getWorlds()) {
if (w.getEnvironment() != Environment.NORMAL) {
if (config.getProperty(group) == null)
{
for (World w : server.getWorlds())
{
if (w.getEnvironment() != Environment.NORMAL)
{
continue;
}
return w.getSpawnLocation();
@@ -52,15 +61,19 @@ public class Spawn implements IConf {
}
String worldId = config.getString(group + ".world", "");
World world = server.getWorlds().get(server.getWorlds().size() > 1 ? 1 : 0);
for (World w : server.getWorlds()) {
if (w.getEnvironment() != Environment.NORMAL) {
for (World w : server.getWorlds())
{
if (w.getEnvironment() != Environment.NORMAL)
{
continue;
}
world = w;
break;
}
for (World w : server.getWorlds()) {
if (!w.getName().equals(worldId)) {
for (World w : server.getWorlds())
{
if (!w.getName().equals(worldId))
{
continue;
}
world = w;
@@ -74,14 +87,16 @@ public class Spawn implements IConf {
float pitch = (float)config.getDouble(group + ".pitch", config.getDouble("default.pitch", 0));
Location retval = new Location(world, x, y, z, yaw, pitch);
if (y < 1) {
if (y < 1)
{
retval.setY(world.getHighestBlockYAt(retval));
}
return retval;
}
public void reloadConfig() {
public void reloadConfig()
{
config.load();
}
}

View File

@@ -37,7 +37,8 @@ public class TNTExplodeListener extends EntityListener implements Runnable
timer = ess.scheduleSyncDelayedTask(this, 1000);
return;
}
if (timer != -1) {
if (timer != -1)
{
ess.getScheduler().cancelTask(timer);
timer = ess.scheduleSyncDelayedTask(this, 1000);
}
@@ -54,7 +55,8 @@ public class TNTExplodeListener extends EntityListener implements Runnable
{
return;
}
try {
try
{
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
final Player[] players = ess.getServer().getOnlinePlayers();
final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length);
@@ -75,7 +77,9 @@ public class TNTExplodeListener extends EntityListener implements Runnable
}
}
((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set));
} catch (Throwable ex) {
}
catch (Throwable ex)
{
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
}
event.setCancelled(true);

View File

@@ -22,13 +22,16 @@ public class Worth implements IConf
String itemname = itemStack.getType().toString().toLowerCase().replace("_", "");
double result;
result = config.getDouble("worth." + itemname + "." + itemStack.getDurability(), Double.NaN);
if (Double.isNaN(result)) {
if (Double.isNaN(result))
{
result = config.getDouble("worth." + itemname + ".0", Double.NaN);
}
if (Double.isNaN(result)) {
if (Double.isNaN(result))
{
result = config.getDouble("worth." + itemname, Double.NaN);
}
if (Double.isNaN(result)) {
if (Double.isNaN(result))
{
result = config.getDouble("worth-" + itemStack.getTypeId(), Double.NaN);
}
return result;
@@ -36,9 +39,12 @@ public class Worth implements IConf
public void setPrice(ItemStack itemStack, double price)
{
if (itemStack.getType().getData() == null) {
if (itemStack.getType().getData() == null)
{
config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", ""), price);
} else {
}
else
{
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", "") + "." + itemStack.getDurability(), price);
}
@@ -50,5 +56,4 @@ public class Worth implements IConf
{
config.load();
}
}