mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-03-31 00:46:01 +02:00
Fix MVINFO NPE, Fix NPE on startup with addWorld, Remove deprecated methods
This commit is contained in:
parent
c22a8a9d18
commit
c72f602045
@ -568,6 +568,9 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getRespawnToWorld() {
|
public World getRespawnToWorld() {
|
||||||
|
if (this.respawnWorld == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return (this.plugin.getServer().getWorld(this.respawnWorld));
|
return (this.plugin.getServer().getWorld(this.respawnWorld));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public class ModifyAddCommand extends MultiverseCommand {
|
|||||||
return;
|
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);
|
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE + " was " + ChatColor.GREEN + "added to " + ChatColor.GREEN + property);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(value + " could not be added to " + property);
|
sender.sendMessage(value + " could not be added to " + property);
|
||||||
|
@ -74,7 +74,7 @@ public class ModifyRemoveCommand extends MultiverseCommand {
|
|||||||
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
|
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
|
||||||
return;
|
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);
|
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE + " was " + ChatColor.RED + "removed from " + ChatColor.GREEN + property);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + "There was an error removing " + ChatColor.GRAY + value + ChatColor.WHITE + " from " + ChatColor.GOLD + property);
|
sender.sendMessage(ChatColor.RED + "There was an error removing " + ChatColor.GRAY + value + ChatColor.WHITE + " from " + ChatColor.GOLD + property);
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
package com.onarandombox.MultiverseCore.listeners;
|
package com.onarandombox.MultiverseCore.listeners;
|
||||||
|
|
||||||
import com.fernferret.allpay.GenericBank;
|
import com.fernferret.allpay.GenericBank;
|
||||||
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
|
|
||||||
import com.onarandombox.MultiverseCore.MVWorld;
|
import com.onarandombox.MultiverseCore.MVWorld;
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
|
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
|
||||||
|
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
|
||||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -176,7 +176,7 @@ public class MVPlayerListener extends PlayerListener {
|
|||||||
// Only check payments if it's a different world:
|
// Only check payments if it's a different world:
|
||||||
if (!toWorld.equals(fromWorld)) {
|
if (!toWorld.equals(fromWorld)) {
|
||||||
// If the player does not have to pay, return now.
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
GenericBank bank = plugin.getBank();
|
GenericBank bank = plugin.getBank();
|
||||||
|
@ -192,70 +192,6 @@ public class SafeTTeleporter {
|
|||||||
return false;
|
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
|
* 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.
|
* it's not, will adjust the final destination accordingly.
|
||||||
|
@ -47,16 +47,17 @@ public class WorldManager implements MVWorldManager {
|
|||||||
public boolean addWorld(String name, Environment env, String seedString, String generator) {
|
public boolean addWorld(String name, Environment env, String seedString, String generator) {
|
||||||
plugin.log(Level.FINE, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + generator);
|
plugin.log(Level.FINE, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + generator);
|
||||||
Long seed = null;
|
Long seed = null;
|
||||||
|
WorldCreator c = new WorldCreator(name);
|
||||||
if (seedString != null && seedString.length() > 0) {
|
if (seedString != null && seedString.length() > 0) {
|
||||||
try {
|
try {
|
||||||
seed = Long.parseLong(seedString);
|
seed = Long.parseLong(seedString);
|
||||||
} catch (NumberFormatException numberformatexception) {
|
} catch (NumberFormatException numberformatexception) {
|
||||||
seed = (long) seedString.hashCode();
|
seed = (long) seedString.hashCode();
|
||||||
}
|
}
|
||||||
|
c.seed(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldCreator c = new WorldCreator(name);
|
|
||||||
c.seed(seed);
|
|
||||||
// TODO: Use the fancy kind with the commandSender
|
// TODO: Use the fancy kind with the commandSender
|
||||||
c.generator(generator);
|
c.generator(generator);
|
||||||
c.environment(env);
|
c.environment(env);
|
||||||
|
Loading…
Reference in New Issue
Block a user