Fix MVINFO NPE, Fix NPE on startup with addWorld, Remove deprecated methods

This commit is contained in:
Eric Stokes 2011-10-09 18:25:42 -06:00
parent c22a8a9d18
commit c72f602045
6 changed files with 10 additions and 70 deletions

View File

@ -568,6 +568,9 @@ public class MVWorld implements MultiverseWorld {
@Override
public World getRespawnToWorld() {
if (this.respawnWorld == null) {
return null;
}
return (this.plugin.getServer().getWorld(this.respawnWorld));
}

View File

@ -74,7 +74,7 @@ public class ModifyAddCommand extends MultiverseCommand {
return;
}
if (world.addToList(property, value)) {
if (world.addToVariable(property, value)) {
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE + " was " + ChatColor.GREEN + "added to " + ChatColor.GREEN + property);
} else {
sender.sendMessage(value + " could not be added to " + property);

View File

@ -74,7 +74,7 @@ public class ModifyRemoveCommand extends MultiverseCommand {
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
return;
}
if (world.removeFromList(property, value)) {
if (world.removeFromVariable(property, value)) {
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE + " was " + ChatColor.RED + "removed from " + ChatColor.GREEN + property);
} else {
sender.sendMessage(ChatColor.RED + "There was an error removing " + ChatColor.GRAY + value + ChatColor.WHITE + " from " + ChatColor.GOLD + property);

View File

@ -8,10 +8,10 @@
package com.onarandombox.MultiverseCore.listeners;
import com.fernferret.allpay.GenericBank;
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -176,7 +176,7 @@ public class MVPlayerListener extends PlayerListener {
// Only check payments if it's a different world:
if (!toWorld.equals(fromWorld)) {
// If the player does not have to pay, return now.
if (toWorld.isExempt(player)) {
if (this.plugin.getMVPerms().hasPermission(player, toWorld.getExemptPermission().getName(), true)) {
return false;
}
GenericBank bank = plugin.getBank();

View File

@ -192,70 +192,6 @@ public class SafeTTeleporter {
return false;
}
/**
* Deprectated. use safelyTeleport(Entity e, Destination d)
*
* @param e
* @param l
*
* @return
*/
@Deprecated
public boolean safelyTeleport(Entity e, Location l) {
Location safeLoc = this.getSafeLocation(e, l);
if (safeLoc != null) {
e.teleport(safeLoc);
return true;
}
return false;
}
/**
* @param e
* @param l
*
* @return
*/
@Deprecated
public Location getSafeLocation(Entity e, Location l) {
if (this.bs.playerCanSpawnHereSafely(l)) {
plugin.log(Level.FINE, "The first location you gave me was safe.");
return l;
}
if (e instanceof Minecart) {
Minecart m = (Minecart) e;
if (!this.bs.canSpawnCartSafely(m)) {
return null;
}
} else if (e instanceof Vehicle) {
Vehicle v = (Vehicle) e;
if (!this.bs.canSpawnVehicleSafely(v)) {
return null;
}
}
Location safeLocation = this.getSafeLocation(l);
if (safeLocation != null) {
// Add offset to account for a vehicle on dry land!
if (e instanceof Minecart && !this.bs.isEntitiyOnTrack(e, safeLocation)) {
safeLocation.setY(safeLocation.getBlockY() + .5);
this.plugin.log(Level.FINER, "Player was inside a minecart. Offsetting Y location.");
}
this.plugin.log(Level.FINE, "Had to look for a bit, but I found a safe place for ya!");
return safeLocation;
}
if (e instanceof Player) {
Player p = (Player) e;
this.plugin.getMessaging().sendMessage(p, "No safe locations found!");
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
} else if (e.getPassenger() instanceof Player) {
Player p = (Player) e.getPassenger();
this.plugin.getMessaging().sendMessage(p, "No safe locations found!");
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
}
this.plugin.log(Level.FINE, "Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now.");
return null;
}
/**
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if
* it's not, will adjust the final destination accordingly.

View File

@ -47,16 +47,17 @@ public class WorldManager implements MVWorldManager {
public boolean addWorld(String name, Environment env, String seedString, String generator) {
plugin.log(Level.FINE, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + generator);
Long seed = null;
WorldCreator c = new WorldCreator(name);
if (seedString != null && seedString.length() > 0) {
try {
seed = Long.parseLong(seedString);
} catch (NumberFormatException numberformatexception) {
seed = (long) seedString.hashCode();
}
c.seed(seed);
}
WorldCreator c = new WorldCreator(name);
c.seed(seed);
// TODO: Use the fancy kind with the commandSender
c.generator(generator);
c.environment(env);