mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-07 08:47:37 +01:00
Merge branch 'master' into development
This commit is contained in:
commit
ce8b042919
@ -1 +1 @@
|
|||||||
Subproject commit b6b450e8b67af96aee856469b2061cccbcfac87e
|
Subproject commit 5f40678ac750210a3121921af0c4e58e6516bfdb
|
15
pom.xml
15
pom.xml
@ -127,6 +127,14 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.iCo6</groupId>
|
||||||
|
<artifactId>iConomy</artifactId>
|
||||||
|
<version>6.0</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.iConomy</groupId>
|
<groupId>com.iConomy</groupId>
|
||||||
<artifactId>iConomy</artifactId>
|
<artifactId>iConomy</artifactId>
|
||||||
@ -149,6 +157,13 @@
|
|||||||
<version>2.4.2</version>
|
<version>2.4.2</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.ashtheking.currency</groupId>
|
||||||
|
<artifactId>MultiCurrency</artifactId>
|
||||||
|
<version>0.09</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- End of Economy Dependencies -->
|
<!-- End of Economy Dependencies -->
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public class MVPermissions implements PermissionsInterface {
|
|||||||
if (!this.plugin.isMVWorld(worldName)) {
|
if (!this.plugin.isMVWorld(worldName)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!canEnterLocation(p, d.getLocation(p))) {
|
if (!canEnterLocation(p, d.getLocation(p))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.hasPermission(p, d.getRequiredPermission(), false);
|
return this.hasPermission(p, d.getRequiredPermission(), false);
|
||||||
@ -107,29 +107,29 @@ public class MVPermissions implements PermissionsInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NO one can access a null permission (mainly used for destinations):w
|
// NO one can access a null permission (mainly used for destinations):w
|
||||||
if(node == null) {
|
if (node == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Everyone can access an empty permission
|
// Everyone can access an empty permission
|
||||||
// Currently used for the PlayerDestination
|
// Currently used for the PlayerDestination
|
||||||
if(node.equals("")) {
|
if (node.equals("")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
this.plugin.log(Level.FINEST, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]");
|
||||||
boolean opFallback = this.plugin.getConfig().getBoolean("opfallback", true);
|
boolean opFallback = this.plugin.getConfig().getBoolean("opfallback", true);
|
||||||
if (this.permissions != null && this.permissions.has(player, node)) {
|
if (this.permissions != null && this.permissions.has(player, node)) {
|
||||||
// If Permissions is enabled we check against them.
|
// If Permissions is enabled we check against them.
|
||||||
// this.plugin.log(Level.WARNING, "Allowed by P3/P2 ");
|
this.plugin.log(Level.FINEST, "Allowed by Permissions or something that looked like it.");
|
||||||
return true;
|
return true;
|
||||||
} else if (sender.hasPermission(node)) {
|
} else if (sender.hasPermission(node)) {
|
||||||
// If Now check the bukkit permissions
|
// If Now check the bukkit permissions
|
||||||
// this.plugin.log(Level.WARNING, "Allowed by BukkitPerms");
|
this.plugin.log(Level.FINEST, "Allowed by the built in Permissions.");
|
||||||
return true;
|
return true;
|
||||||
} else if (player.isOp() && opFallback) {
|
} else if (player.isOp() && opFallback) {
|
||||||
// If Player is Op we always let them use it if they have the fallback enabled!
|
// If Player is Op we always let them use it if they have the fallback enabled!
|
||||||
// this.plugin.log(Level.WARNING, "Allowed by OP");
|
this.plugin.log(Level.FINEST, "Allowed by OP (opfallback was on).");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,13 +138,16 @@ public class MVPermissions implements PermissionsInterface {
|
|||||||
// This allows us to act as a default permission guidance
|
// This allows us to act as a default permission guidance
|
||||||
|
|
||||||
// If they have the op fallback disabled, NO commands will work without a permissions plugin.
|
// If they have the op fallback disabled, NO commands will work without a permissions plugin.
|
||||||
|
if (!isOpRequired && opFallback) {
|
||||||
|
this.plugin.log(Level.FINEST, "Allowed because opfallback was set to true.");
|
||||||
|
}
|
||||||
return !isOpRequired && opFallback;
|
return !isOpRequired && opFallback;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
String opsfallback = "";
|
String opsfallback = "";
|
||||||
if(this.plugin.getConfig().getBoolean("opfallback", true)) {
|
if (this.plugin.getConfig().getBoolean("opfallback", true)) {
|
||||||
opsfallback = " WITH OPs.txt fallback";
|
opsfallback = " WITH OPs.txt fallback";
|
||||||
}
|
}
|
||||||
if (this.permissions != null) {
|
if (this.permissions != null) {
|
||||||
|
@ -9,15 +9,17 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.entity.Vehicle;
|
import org.bukkit.entity.Vehicle;
|
||||||
|
|
||||||
import com.onarandombox.utils.BlockSafety;
|
import com.onarandombox.utils.BlockSafety;
|
||||||
|
import com.onarandombox.utils.LocationManipulation;
|
||||||
|
|
||||||
public class MVTeleport {
|
public class MVTeleport {
|
||||||
|
|
||||||
MultiverseCore plugin;
|
MultiverseCore plugin;
|
||||||
|
|
||||||
BlockSafety bs = new BlockSafety();
|
BlockSafety bs;
|
||||||
|
|
||||||
public MVTeleport(MultiverseCore plugin) {
|
public MVTeleport(MultiverseCore plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.bs = new BlockSafety(this.plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,17 +49,23 @@ public class MVTeleport {
|
|||||||
if (safe != null) {
|
if (safe != null) {
|
||||||
safe.setX(safe.getBlockX() + .5);
|
safe.setX(safe.getBlockX() + .5);
|
||||||
safe.setZ(safe.getBlockZ() + .5);
|
safe.setZ(safe.getBlockZ() + .5);
|
||||||
|
this.plugin.log(Level.FINE, "Hey! I found one: " + LocationManipulation.strCoordsRaw(safe));
|
||||||
|
} else {
|
||||||
|
this.plugin.log(Level.FINE, "Uh oh! No safe place found!");
|
||||||
}
|
}
|
||||||
return safe;
|
return safe;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Location checkAboveAndBelowLocation(Location l, int tolerance, int radius) {
|
private Location checkAboveAndBelowLocation(Location l, int tolerance, int radius) {
|
||||||
|
|
||||||
// Tolerance must be an even number:
|
// Tolerance must be an even number:
|
||||||
if (tolerance % 2 != 0) {
|
if (tolerance % 2 != 0) {
|
||||||
tolerance += 1;
|
tolerance += 1;
|
||||||
}
|
}
|
||||||
// We want half of it, so we can go up and down
|
// We want half of it, so we can go up and down
|
||||||
tolerance /= 2;
|
tolerance /= 2;
|
||||||
|
this.plugin.log(Level.FINER, "Given Location of: " + LocationManipulation.strCoordsRaw(l));
|
||||||
|
this.plugin.log(Level.FINER, "Checking +-" + tolerance + " with a radius of " + radius);
|
||||||
|
|
||||||
// For now this will just do a straight up block.
|
// For now this will just do a straight up block.
|
||||||
Location locToCheck = l.clone();
|
Location locToCheck = l.clone();
|
||||||
@ -176,40 +184,43 @@ public class MVTeleport {
|
|||||||
public boolean safelyTeleport(Entity e, Location l) {
|
public boolean safelyTeleport(Entity e, Location l) {
|
||||||
if (this.bs.playerCanSpawnHereSafely(l)) {
|
if (this.bs.playerCanSpawnHereSafely(l)) {
|
||||||
e.teleport(l);
|
e.teleport(l);
|
||||||
//this.plugin.log(Level.WARNING, "The first location you gave me was safe.");
|
plugin.log(Level.FINE, "The first location you gave me was safe.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(e instanceof Minecart) {
|
if (e instanceof Minecart) {
|
||||||
Minecart m = (Minecart)e;
|
Minecart m = (Minecart) e;
|
||||||
if(!this.bs.canSpawnCartSafely(m)) {
|
if (!this.bs.canSpawnCartSafely(m)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(e instanceof Vehicle) {
|
else if (e instanceof Vehicle) {
|
||||||
Vehicle v = (Vehicle)e;
|
Vehicle v = (Vehicle) e;
|
||||||
if(!this.bs.canSpawnVehicleSafely(v)) {
|
if (!this.bs.canSpawnVehicleSafely(v)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Location safeLocation = this.getSafeLocation(l);
|
Location safeLocation = this.getSafeLocation(l);
|
||||||
if (safeLocation != null) {
|
if (safeLocation != null) {
|
||||||
// Add offset to account for a vehicle on dry land!
|
// Add offset to account for a vehicle on dry land!
|
||||||
if (!this.bs.isEntitiyOnTrack(e, safeLocation)) {
|
if (e instanceof Minecart && !this.bs.isEntitiyOnTrack(e, safeLocation)) {
|
||||||
safeLocation.setY(safeLocation.getBlockY() + .5);
|
safeLocation.setY(safeLocation.getBlockY() + .5);
|
||||||
|
this.plugin.log(Level.FINER, "Player was inside a minecart. Offsetting Y location.");
|
||||||
}
|
}
|
||||||
e.teleport(safeLocation);
|
e.teleport(safeLocation);
|
||||||
//this.plugin.log(Level.WARNING, "Had to look for a bit, but I found a safe place for ya!");
|
this.plugin.log(Level.FINE, "Had to look for a bit, but I found a safe place for ya!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (e instanceof Player) {
|
if (e instanceof Player) {
|
||||||
Player p = (Player) e;
|
Player p = (Player) e;
|
||||||
p.sendMessage("No safe locations found!");
|
p.sendMessage("No safe locations found!");
|
||||||
|
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
|
||||||
}
|
}
|
||||||
else if (e.getPassenger() instanceof Player) {
|
else if (e.getPassenger() instanceof Player) {
|
||||||
Player p = (Player) e.getPassenger();
|
Player p = (Player) e.getPassenger();
|
||||||
p.sendMessage("No safe locations found!");
|
p.sendMessage("No safe locations found!");
|
||||||
|
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
|
||||||
}
|
}
|
||||||
this.plugin.log(Level.WARNING, "Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now.");
|
this.plugin.log(Level.FINE, "Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ public class MVWorld {
|
|||||||
this.canSave = true;
|
this.canSave = true;
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
|
||||||
this.permission = new Permission("multiverse.access." + this.getName(), "Allows access to " + this.getName(), PermissionDefault.TRUE);
|
this.permission = new Permission("multiverse.access." + this.getName(), "Allows access to " + this.getName(), PermissionDefault.OP);
|
||||||
this.exempt = new Permission("multiverse.exempt." + this.getName(), "A player who has this does not pay to enter this world, or use any MV portals in it " + this.getName(), PermissionDefault.OP);
|
this.exempt = new Permission("multiverse.exempt." + this.getName(), "A player who has this does not pay to enter this world, or use any MV portals in it " + this.getName(), PermissionDefault.OP);
|
||||||
try {
|
try {
|
||||||
this.plugin.getServer().getPluginManager().addPermission(this.permission);
|
this.plugin.getServer().getPluginManager().addPermission(this.permission);
|
||||||
|
@ -36,6 +36,7 @@ import com.fernferret.allpay.GenericBank;
|
|||||||
import com.onarandombox.MultiverseCore.commands.ConfirmCommand;
|
import com.onarandombox.MultiverseCore.commands.ConfirmCommand;
|
||||||
import com.onarandombox.MultiverseCore.commands.CoordCommand;
|
import com.onarandombox.MultiverseCore.commands.CoordCommand;
|
||||||
import com.onarandombox.MultiverseCore.commands.CreateCommand;
|
import com.onarandombox.MultiverseCore.commands.CreateCommand;
|
||||||
|
import com.onarandombox.MultiverseCore.commands.DebugCommand;
|
||||||
import com.onarandombox.MultiverseCore.commands.DeleteCommand;
|
import com.onarandombox.MultiverseCore.commands.DeleteCommand;
|
||||||
import com.onarandombox.MultiverseCore.commands.EnvironmentCommand;
|
import com.onarandombox.MultiverseCore.commands.EnvironmentCommand;
|
||||||
import com.onarandombox.MultiverseCore.commands.HelpCommand;
|
import com.onarandombox.MultiverseCore.commands.HelpCommand;
|
||||||
@ -106,6 +107,8 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
|||||||
|
|
||||||
public UpdateChecker updateCheck;
|
public UpdateChecker updateCheck;
|
||||||
|
|
||||||
|
public static int GlobalDebug = 0;
|
||||||
|
|
||||||
// HashMap to contain all the Worlds which this Plugin will manage.
|
// HashMap to contain all the Worlds which this Plugin will manage.
|
||||||
private HashMap<String, MVWorld> worlds = new HashMap<String, MVWorld>();
|
private HashMap<String, MVWorld> worlds = new HashMap<String, MVWorld>();
|
||||||
|
|
||||||
@ -268,6 +271,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
|||||||
|
|
||||||
// Misc Commands
|
// Misc Commands
|
||||||
this.commandHandler.registerCommand(new EnvironmentCommand(this));
|
this.commandHandler.registerCommand(new EnvironmentCommand(this));
|
||||||
|
this.commandHandler.registerCommand(new DebugCommand(this));
|
||||||
this.commandHandler.registerCommand(new SleepCommand(this));
|
this.commandHandler.registerCommand(new SleepCommand(this));
|
||||||
this.commandHandler.registerCommand(new SpoutCommand(this));
|
this.commandHandler.registerCommand(new SpoutCommand(this));
|
||||||
|
|
||||||
@ -473,7 +477,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
|||||||
public Boolean deleteWorld(String name) {
|
public Boolean deleteWorld(String name) {
|
||||||
|
|
||||||
if (this.getServer().getWorld(name) != null) {
|
if (this.getServer().getWorld(name) != null) {
|
||||||
if(!unloadWorld(name, false)) {
|
if (!unloadWorld(name, false)) {
|
||||||
// If the world was loaded, and we couldn't unload it, return false. DON"T DELTEE
|
// If the world was loaded, and we couldn't unload it, return false. DON"T DELTEE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -626,9 +630,21 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
|||||||
* @param msg
|
* @param msg
|
||||||
*/
|
*/
|
||||||
public void log(Level level, String msg) {
|
public void log(Level level, String msg) {
|
||||||
|
// We're using Config as debug
|
||||||
|
if (level == Level.FINE && GlobalDebug >= 1) {
|
||||||
|
this.debugLog(Level.INFO, msg);
|
||||||
|
return;
|
||||||
|
} else if (level == Level.FINER && GlobalDebug >= 2) {
|
||||||
|
this.debugLog(Level.INFO, msg);
|
||||||
|
return;
|
||||||
|
} else if (level == Level.FINEST && GlobalDebug >= 3) {
|
||||||
|
this.debugLog(Level.INFO, msg);
|
||||||
|
return;
|
||||||
|
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
|
||||||
log.log(level, this.tag + " " + msg);
|
log.log(level, this.tag + " " + msg);
|
||||||
debugLog.log(level, this.tag + " " + msg);
|
debugLog.log(level, this.tag + " " + msg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print messages to the Debug Log, if the servers in Debug Mode then we also wan't to print the messages to the standard Server Console.
|
* Print messages to the Debug Log, if the servers in Debug Mode then we also wan't to print the messages to the standard Server Console.
|
||||||
@ -637,10 +653,8 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
|||||||
* @param msg
|
* @param msg
|
||||||
*/
|
*/
|
||||||
public void debugLog(Level level, String msg) {
|
public void debugLog(Level level, String msg) {
|
||||||
if (this.debug) {
|
log.log(level, "[MVCore-Debug] " + msg);
|
||||||
log.log(level, "[Debug] " + msg);
|
debugLog.log(level, "[MVCore-Debug] " + msg);
|
||||||
}
|
|
||||||
debugLog.log(level, "[Debug] " + msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.onarandombox.MultiverseCore.commands;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
|
|
||||||
|
public class DebugCommand extends MultiverseCommand {
|
||||||
|
|
||||||
|
public DebugCommand(MultiverseCore plugin) {
|
||||||
|
super(plugin);
|
||||||
|
this.setName("Turn Debug on/off?");
|
||||||
|
this.setCommandUsage("/mv who" + ChatColor.GOLD + " [1|2|3|off]");
|
||||||
|
this.setArgRange(0, 1);
|
||||||
|
this.addKey("mv debug");
|
||||||
|
this.addKey("mv d");
|
||||||
|
this.addKey("mvdebug");
|
||||||
|
this.setPermission("multiverse.core.debug", "Spams the console a bunch.", PermissionDefault.OP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runCommand(CommandSender sender, List<String> args) {
|
||||||
|
if (args.size() == 1) {
|
||||||
|
if (args.get(0).equalsIgnoreCase("off")) {
|
||||||
|
MultiverseCore.GlobalDebug = 0;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
int debugLevel = Integer.parseInt(args.get(0));
|
||||||
|
if(debugLevel > 3 || debugLevel < 0) {
|
||||||
|
throw new NumberFormatException();
|
||||||
|
}
|
||||||
|
MultiverseCore.GlobalDebug = debugLevel;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE + " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.displayDebugMode(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void displayDebugMode(CommandSender sender) {
|
||||||
|
if (MultiverseCore.GlobalDebug == 0) {
|
||||||
|
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + MultiverseCore.GlobalDebug);
|
||||||
|
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -73,7 +73,11 @@ public class InfoCommand extends MultiverseCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.plugin.isMVWorld(worldName)) {
|
if (this.plugin.isMVWorld(worldName)) {
|
||||||
showPage(pageNum, sender, this.buildEntireCommand(this.plugin.getMVWorld(worldName)));
|
Player p = null;
|
||||||
|
if(sender instanceof Player) {
|
||||||
|
p = (Player) sender;
|
||||||
|
}
|
||||||
|
showPage(pageNum, sender, this.buildEntireCommand(this.plugin.getMVWorld(worldName), p));
|
||||||
} else if (this.plugin.getServer().getWorld(worldName) != null) {
|
} else if (this.plugin.getServer().getWorld(worldName) != null) {
|
||||||
sender.sendMessage("That world exists, but multiverse does not know about it!");
|
sender.sendMessage("That world exists, but multiverse does not know about it!");
|
||||||
sender.sendMessage("You can import it with" + ChatColor.AQUA + "/mv import " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
|
sender.sendMessage("You can import it with" + ChatColor.AQUA + "/mv import " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
|
||||||
@ -81,7 +85,7 @@ public class InfoCommand extends MultiverseCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<List<FancyText>> buildEntireCommand(MVWorld world) {
|
private List<List<FancyText>> buildEntireCommand(MVWorld world, Player p) {
|
||||||
List<FancyText> message = new ArrayList<FancyText>();
|
List<FancyText> message = new ArrayList<FancyText>();
|
||||||
List<List<FancyText>> worldInfo = new ArrayList<List<FancyText>>();
|
List<List<FancyText>> worldInfo = new ArrayList<List<FancyText>>();
|
||||||
// Page 1
|
// Page 1
|
||||||
@ -94,7 +98,7 @@ public class InfoCommand extends MultiverseCommand {
|
|||||||
message.add(new FancyMessage("Spawn Location: ", "(" + spawn.getBlockX() + ", " + spawn.getBlockY() + ", " + spawn.getBlockZ() + ")", colors));
|
message.add(new FancyMessage("Spawn Location: ", "(" + spawn.getBlockX() + ", " + spawn.getBlockY() + ", " + spawn.getBlockZ() + ")", colors));
|
||||||
message.add(new FancyMessage("World Scale: ", world.getScaling().toString(), colors));
|
message.add(new FancyMessage("World Scale: ", world.getScaling().toString(), colors));
|
||||||
if (world.getPrice() > 0) {
|
if (world.getPrice() > 0) {
|
||||||
message.add(new FancyMessage("Price to enter this world: ", this.plugin.getBank().getFormattedAmount(world.getPrice(), world.getCurrency()), colors));
|
message.add(new FancyMessage("Price to enter this world: ", this.plugin.getBank().getFormattedAmount(p, world.getPrice(), world.getCurrency()), colors));
|
||||||
} else {
|
} else {
|
||||||
message.add(new FancyMessage("Price to enter this world: ", ChatColor.GREEN + "FREE!", colors));
|
message.add(new FancyMessage("Price to enter this world: ", ChatColor.GREEN + "FREE!", colors));
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.onarandombox.MultiverseCore.commands;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -72,7 +73,17 @@ public class TeleportCommand extends MultiverseCommand {
|
|||||||
teleporter = (Player) sender;
|
teleporter = (Player) sender;
|
||||||
teleportee = (Player) sender;
|
teleportee = (Player) sender;
|
||||||
}
|
}
|
||||||
|
// Special case for cannons:
|
||||||
|
if (destinationName.matches("(?i)cannon-[\\d]+(\\.[\\d]+)?")) {
|
||||||
|
String[] cannonSpeed = destinationName.split("-");
|
||||||
|
try {
|
||||||
|
double speed = Double.parseDouble(cannonSpeed[1]);
|
||||||
|
destinationName = "ca:" + teleportee.getWorld().getName() + ":" + teleportee.getLocation().getX() + "," + teleportee.getLocation().getY() + "," + teleportee.getLocation().getZ() + ":" + teleportee.getLocation().getPitch() + ":" + teleportee.getLocation().getYaw() + ":" + speed;
|
||||||
|
} catch (Exception e) {
|
||||||
|
destinationName = "i:invalid";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
DestinationFactory df = this.plugin.getDestinationFactory();// .parseDestination(worldName, (MultiverseCore) this.plugin);
|
DestinationFactory df = this.plugin.getDestinationFactory();// .parseDestination(worldName, (MultiverseCore) this.plugin);
|
||||||
MVDestination d = df.getDestination(destinationName);
|
MVDestination d = df.getDestination(destinationName);
|
||||||
if (d != null && d instanceof InvalidDestination) {
|
if (d != null && d instanceof InvalidDestination) {
|
||||||
@ -101,6 +112,8 @@ public class TeleportCommand extends MultiverseCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.playerTeleporter.safelyTeleport(teleportee, l)) {
|
if (!this.playerTeleporter.safelyTeleport(teleportee, l)) {
|
||||||
|
this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName() + " to " + l);
|
||||||
|
this.plugin.log(Level.FINE, "Queueing Command");
|
||||||
Class<?> paramTypes[] = { Player.class, Location.class };
|
Class<?> paramTypes[] = { Player.class, Location.class };
|
||||||
List<Object> items = new ArrayList<Object>();
|
List<Object> items = new ArrayList<Object>();
|
||||||
items.add(teleportee);
|
items.add(teleportee);
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
package com.onarandombox.MultiverseCore.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
|
||||||
import org.bukkit.event.block.BlockListener;
|
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
|
||||||
|
|
||||||
//import org.bukkit.event.block.BlockRightClickEvent;
|
|
||||||
|
|
||||||
public class MVBlockListener extends BlockListener {
|
|
||||||
|
|
||||||
MultiverseCore plugin;
|
|
||||||
|
|
||||||
public MVBlockListener(MultiverseCore plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void onBlockRightClicked(BlockRightClickEvent event){
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockDamage(BlockDamageEvent event) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int id = event.getChangedTypeId();
|
|
||||||
|
|
||||||
if (id == 90) { // && config.getBoolean("portalanywhere", false)
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onBlockPlaced(BlockPlaceEvent event) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -129,7 +129,7 @@ public class MVPlayerListener extends PlayerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GenericBank bank = plugin.getBank();
|
GenericBank bank = plugin.getBank();
|
||||||
if (!bank.hasEnough(event.getPlayer(), toWorld.getPrice(), toWorld.getCurrency(), "You need " + bank.getFormattedAmount(toWorld.getPrice(), toWorld.getCurrency()) + " to enter " + toWorld.getColoredWorldString())) {
|
if (!bank.hasEnough(event.getPlayer(), toWorld.getPrice(), toWorld.getCurrency(), "You need " + bank.getFormattedAmount(event.getPlayer(), toWorld.getPrice(), toWorld.getCurrency()) + " to enter " + toWorld.getColoredWorldString())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else {
|
} else {
|
||||||
bank.pay(event.getPlayer(), toWorld.getPrice(), toWorld.getCurrency());
|
bank.pay(event.getPlayer(), toWorld.getPrice(), toWorld.getCurrency());
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.onarandombox.utils;
|
package com.onarandombox.utils;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -7,7 +9,15 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Minecart;
|
import org.bukkit.entity.Minecart;
|
||||||
import org.bukkit.entity.Vehicle;
|
import org.bukkit.entity.Vehicle;
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
|
|
||||||
public class BlockSafety {
|
public class BlockSafety {
|
||||||
|
private MultiverseCore plugin;
|
||||||
|
|
||||||
|
public BlockSafety(MultiverseCore plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function checks whether the block at the given coordinates are above air or not.
|
* This function checks whether the block at the given coordinates are above air or not.
|
||||||
*
|
*
|
||||||
@ -45,18 +55,25 @@ public class BlockSafety {
|
|||||||
downOne.setY(downOne.getY() - 1);
|
downOne.setY(downOne.getY() - 1);
|
||||||
|
|
||||||
if (this.isSolidBlock(actual.getBlock().getType()) || this.isSolidBlock(upOne.getBlock().getType())) {
|
if (this.isSolidBlock(actual.getBlock().getType()) || this.isSolidBlock(upOne.getBlock().getType())) {
|
||||||
|
this.plugin.log(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
|
||||||
|
this.plugin.log(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (downOne.getBlock().getType() == Material.LAVA || downOne.getBlock().getType() == Material.STATIONARY_LAVA) {
|
if (downOne.getBlock().getType() == Material.LAVA || downOne.getBlock().getType() == Material.STATIONARY_LAVA) {
|
||||||
|
this.plugin.log(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
|
||||||
|
this.plugin.log(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (downOne.getBlock().getType() == Material.FIRE) {
|
if (downOne.getBlock().getType() == Material.FIRE) {
|
||||||
|
this.plugin.log(Level.FINER, "There's fire below! (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBlockAboveAir(actual)) {
|
if (isBlockAboveAir(actual)) {
|
||||||
|
this.plugin.log(Level.FINER, "Is block above air [" + isBlockAboveAir(actual) + "]");
|
||||||
|
this.plugin.log(Level.FINER, "Has 2 blocks of water below [" + this.hasTwoBlocksofWaterBelow(actual) + "]");
|
||||||
return this.hasTwoBlocksofWaterBelow(actual);
|
return this.hasTwoBlocksofWaterBelow(actual);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -122,6 +139,12 @@ public class BlockSafety {
|
|||||||
return false;
|
return false;
|
||||||
case SIGN_POST:
|
case SIGN_POST:
|
||||||
return false;
|
return false;
|
||||||
|
case WOODEN_DOOR:
|
||||||
|
return false;
|
||||||
|
case STATIONARY_WATER:
|
||||||
|
return false;
|
||||||
|
case WATER:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -145,23 +168,25 @@ public class BlockSafety {
|
|||||||
System.out.print("Location Down: " + downOne.getBlock().getType());
|
System.out.print("Location Down: " + downOne.getBlock().getType());
|
||||||
System.out.print(" " + downOne);
|
System.out.print(" " + downOne);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks recursively below location L for 2 blocks of water
|
* Checks recursively below location L for 2 blocks of water
|
||||||
|
*
|
||||||
* @param l
|
* @param l
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean hasTwoBlocksofWaterBelow(Location l) {
|
public boolean hasTwoBlocksofWaterBelow(Location l) {
|
||||||
if(l.getBlockY() < 0) {
|
if (l.getBlockY() < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location oneBelow = l.clone();
|
Location oneBelow = l.clone();
|
||||||
oneBelow.subtract(0, 1, 0);
|
oneBelow.subtract(0, 1, 0);
|
||||||
if(oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER) {
|
if (oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER) {
|
||||||
Location twoBelow = oneBelow.clone();
|
Location twoBelow = oneBelow.clone();
|
||||||
twoBelow.subtract(0, 1, 0);
|
twoBelow.subtract(0, 1, 0);
|
||||||
return (oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER);
|
return (oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER);
|
||||||
}
|
}
|
||||||
if(oneBelow.getBlock().getType() != Material.AIR) {
|
if (oneBelow.getBlock().getType() != Material.AIR) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return hasTwoBlocksofWaterBelow(oneBelow);
|
return hasTwoBlocksofWaterBelow(oneBelow);
|
||||||
@ -169,17 +194,17 @@ public class BlockSafety {
|
|||||||
|
|
||||||
public boolean canSpawnCartSafely(Minecart cart) {
|
public boolean canSpawnCartSafely(Minecart cart) {
|
||||||
|
|
||||||
if(this.isBlockAboveAir(cart.getLocation())) {
|
if (this.isBlockAboveAir(cart.getLocation())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(this.isEntitiyOnTrack(cart, LocationManipulation.getNextBlock(cart))) {
|
if (this.isEntitiyOnTrack(cart, LocationManipulation.getNextBlock(cart))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSpawnVehicleSafely(Vehicle vehicle) {
|
public boolean canSpawnVehicleSafely(Vehicle vehicle) {
|
||||||
if(this.isBlockAboveAir(vehicle.getLocation())) {
|
if (this.isBlockAboveAir(vehicle.getLocation())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -30,7 +30,7 @@ public class LocationManipulation {
|
|||||||
* @param location
|
* @param location
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String locationToString(Location location) {
|
public static String locationToString(Location location) {
|
||||||
StringBuilder l = new StringBuilder();
|
StringBuilder l = new StringBuilder();
|
||||||
l.append(location.getBlockX() + ":");
|
l.append(location.getBlockX() + ":");
|
||||||
l.append(location.getBlockY() + ":");
|
l.append(location.getBlockY() + ":");
|
||||||
@ -78,6 +78,19 @@ public class LocationManipulation {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String strCoordsRaw(Location l) {
|
||||||
|
String result = "";
|
||||||
|
DecimalFormat df = new DecimalFormat();
|
||||||
|
df.setMinimumFractionDigits(0);
|
||||||
|
df.setMaximumFractionDigits(2);
|
||||||
|
result += "X: " + df.format(l.getX()) + " ";
|
||||||
|
result += "Y: " + df.format(l.getY()) + " ";
|
||||||
|
result += "Z: " + df.format(l.getZ()) + " ";
|
||||||
|
result += "P: " + df.format(l.getPitch()) + " ";
|
||||||
|
result += "Y: " + df.format(l.getYaw()) + " ";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the NESW Direction a Location is facing.
|
* Return the NESW Direction a Location is facing.
|
||||||
*
|
*
|
||||||
|
5
src/main/java/com/onarandombox/utils/MVLevel.java
Normal file
5
src/main/java/com/onarandombox/utils/MVLevel.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package com.onarandombox.utils;
|
||||||
|
|
||||||
|
public class MVLevel {
|
||||||
|
|
||||||
|
}
|
@ -182,3 +182,7 @@ commands:
|
|||||||
description: Prints out version invo.
|
description: Prints out version invo.
|
||||||
usage: |
|
usage: |
|
||||||
/<command>
|
/<command>
|
||||||
|
mvdebug:
|
||||||
|
description: Turns on debugging.
|
||||||
|
usage: |
|
||||||
|
/<command>
|
Loading…
Reference in New Issue
Block a user