MVPortals Compatibility changes

This commit is contained in:
Eric Stokes 2011-07-16 20:19:37 -06:00
parent 099bd9dbb6
commit c9c58c93e6
6 changed files with 40 additions and 21 deletions

View File

@ -1,5 +1,6 @@
package com.onarandombox.MultiverseCore;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
@ -105,11 +106,16 @@ public class MVPermissions implements PermissionsInterface {
*/
private boolean inGroup(Player player, String worldName, String group) {
if (this.permissions != null) {
return this.permissions.inGroup(worldName, player.getName(), group);
} else {
return player.isOp();
}
}
public List<String> getGroups(String worldName, String name) {
return Arrays.asList(this.permissions.getGroups(worldName, name));
}
public void setPermissions(PermissionHandler handler) {
this.permissions = handler;

View File

@ -30,10 +30,12 @@ public class MVPlayerListener extends PlayerListener {
* Check the Player has actually moved a block to prevent unneeded calculations... This is to prevent huge performance drops on high player count servers.
*/
MVPlayerSession ps = this.plugin.getPlayerSession(p);
if (ps.loc.getBlockX() == loc.getBlockX() && ps.loc.getBlockY() == loc.getBlockY() && ps.loc.getBlockZ() == loc.getBlockZ()) {
if (ps.getLocation().getBlockX() == loc.getBlockX() && ps.getLocation().getBlockY() == loc.getBlockY() && ps.getLocation().getBlockZ() == loc.getBlockZ()) {
ps.setStaleLocation(true);
return;
} else {
ps.loc = loc; // Update the Players Session to the new Location.
ps.setLocation(loc); // Update the Players Session to the new Location.
ps.setStaleLocation(false);
}
}

View File

@ -13,13 +13,8 @@ import com.onarandombox.utils.BlockSafety;
public class MVPlayerSession {
private Player player; // Player holder, may be unnecessary.
protected Location loc = new Location(null, 0, 0, 0); // Contain the Players Location so on player move we can compare this and check if they've moved a block.
private Location loc = new Location(null, 0, 0, 0); // Contain the Players Location so on player move we can compare this and check if they've moved a block.
private BlockSafety bs = new BlockSafety();
// Move to portals plugin
protected String portal = null; // Allow a player to target a portal to prevent them typing its name every command.
// Move to portals plugin
public Location coord1 = null; // Coordinate 1 (Left Click)
public Location coord2 = null; // Coordinate 2 (Right Click)
private Long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
private Long messageLast = 0L; // Timestamp for the Players last Alert Message.
@ -31,10 +26,11 @@ public class MVPlayerSession {
private Location bedB;
private Configuration config; // Configuration file to find out Cooldown Timers.
private boolean staleLocation;
public MVPlayerSession(Player player, Configuration config, MultiverseCore multiVerseCore) {
this.player = player;
this.loc = player.getLocation();
this.setLocation(player.getLocation());
this.config = config;
this.bedSpawn = null;
}
@ -77,14 +73,6 @@ public class MVPlayerSession {
this.bedSpawn = location;
}
//
// public Location getRespawnLocation() {
// if (this.bedSpawn != null && !this.bs.playerCanSpawnHereSafely(this.bedSpawn)) {
// this.bedSpawn = null;
// }
// return this.bedSpawn;
// }
// This one simply spawns the player closer to the bed.
public Location getBedRespawnLocation() {
// There is a bedrespawn set
@ -111,4 +99,23 @@ public class MVPlayerSession {
}
return true;
}
public void setStaleLocation(boolean active) {
this.staleLocation = active;
}
public boolean isStaleLocation() {
return this.staleLocation;
}
public void setLocation(Location loc) {
// Perform rounding to always have integer values
this.loc = loc;
}
public Location getLocation() {
return this.loc;
}
}

View File

@ -63,14 +63,14 @@ public class MVTeleport {
* @return
*/
public Location getSafeBedDestination(Location bedLocation) {
System.out.print(bedLocation);
//System.out.print(bedLocation);
Location idealLocation = bedLocation;
idealLocation.setY(idealLocation.getY() + 1);
idealLocation.setX(idealLocation.getX() + .5);
idealLocation.setZ(idealLocation.getZ() + .5);
System.out.print(idealLocation);
//System.out.print(idealLocation);
if (this.bs.playerCanSpawnHereSafely(idealLocation)) {
System.out.print(idealLocation);
//System.out.print(idealLocation);
return bedLocation;
}
return null;

View File

@ -129,6 +129,7 @@ public class MultiverseCore extends JavaPlugin {
pm.registerEvent(Event.Type.PLAYER_KICK, this.playerListener, Priority.Highest, this);
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Priority.Low, this); // Let plugins which specialize in (re)spawning carry more weight.
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_MOVE, this.playerListener, Priority.Low, this);
pm.registerEvent(Event.Type.PLAYER_BED_LEAVE, this.playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, this.entityListener, Priority.Normal, this);

View File

@ -1,5 +1,7 @@
package com.onarandombox.utils;
import java.util.Arrays;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class Destination {
@ -60,12 +62,13 @@ public class Destination {
return new Destination(items[0], DestinationType.World);
}
if (items[0].equalsIgnoreCase("w") && plugin.isMVWorld(items[0])) {
if (items[0].equalsIgnoreCase("w") && plugin.isMVWorld(items[1])) {
return new Destination(items[1], DestinationType.World);
} else if (items[0].equalsIgnoreCase("p")) {
// TODO: Check for a valid portal, we can't right now, as portals aren't really in yet.
return new Destination(items[1], DestinationType.Portal);
}
System.out.print("Nothing valid found!!");
return getBadDestination();
}
}