mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-25 10:38:00 +01:00
Cleanup debug message, code tidy.
This commit is contained in:
parent
9af6bdb1d6
commit
5a54ef355f
@ -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);
|
||||
|
@ -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;
|
||||
@ -70,18 +83,20 @@ public class Spawn implements IConf {
|
||||
double x = config.getDouble(group + ".x", config.getDouble("default.x", 0));
|
||||
double y = config.getDouble(group + ".y", config.getDouble("default.y", 0));
|
||||
double z = config.getDouble(group + ".z", config.getDouble("default.z", 0));
|
||||
float yaw = (float) config.getDouble(group + ".yaw", config.getDouble("default.yaw", 0));
|
||||
float pitch = (float) config.getDouble(group + ".pitch", config.getDouble("default.pitch", 0));
|
||||
float yaw = (float)config.getDouble(group + ".yaw", config.getDouble("default.yaw", 0));
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -52,7 +52,7 @@ public class UserMap implements Function<String, User>, IConf
|
||||
}
|
||||
catch (ComputationException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.INFO, "Failed to preload user "+name, ex);
|
||||
Bukkit.getLogger().log(Level.INFO, "Failed to preload user " + name, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,28 +21,34 @@ 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)) {
|
||||
result = config.getDouble("worth."+itemname+".0", Double.NaN);
|
||||
result = config.getDouble("worth." + itemname + "." + itemStack.getDurability(), Double.NaN);
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth." + itemname + ".0", Double.NaN);
|
||||
}
|
||||
if (Double.isNaN(result)) {
|
||||
result = config.getDouble("worth."+itemname, Double.NaN);
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth." + itemname, Double.NaN);
|
||||
}
|
||||
if (Double.isNaN(result)) {
|
||||
result = config.getDouble("worth-"+itemStack.getTypeId(), Double.NaN);
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth-" + itemStack.getTypeId(), Double.NaN);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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 {
|
||||
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", "")+"."+itemStack.getDurability(), price);
|
||||
}
|
||||
config.removeProperty("worth-"+itemStack.getTypeId());
|
||||
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);
|
||||
}
|
||||
config.removeProperty("worth-" + itemStack.getTypeId());
|
||||
config.save();
|
||||
}
|
||||
|
||||
@ -50,5 +56,4 @@ public class Worth implements IConf
|
||||
{
|
||||
config.load();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user