Skip to content

Commit

Permalink
Fix sethome and spawn commands. Closes FallenMoonNetwork#65
Browse files Browse the repository at this point in the history
  • Loading branch information
14mRh4X0r committed Nov 23, 2012
1 parent 2696deb commit e8580e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/PlayerCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -617,13 +617,14 @@ protected void execute(MessageReceiver caller, String[] split) {

@Override
protected void execute(MessageReceiver caller, String[] args) {
if (!(caller instanceof Player) && args.length < 2) {
boolean callerIsPlayer = caller instanceof Player;
if (!callerIsPlayer && args.length < 2) {
return;
}

Player player;

if (args.length == 2 && (!(caller instanceof Player) || ((Player) caller).isAdmin())) {
if (args.length == 2 && (!callerIsPlayer || ((Player) caller).isAdmin())) {
player = etc.getServer().matchPlayer(args[1]);
} else {
player = (Player) caller;
Expand All @@ -635,17 +636,20 @@ protected void execute(MessageReceiver caller, String[] args) {
}
World world = player.getWorld();
if (world.getType() != World.Dimension.NORMAL) {
if (player.canIgnoreRestrictions()) {
if (!callerIsPlayer || ((Player) caller).canIgnoreRestrictions()) {
player.switchWorlds(world);
} else {
player.notify("You cannot set a home in the " + world.getType().name() + ", mortal.");
caller.notify("You cannot set a home in the " + world.getType().name() + ", mortal.");
return;
}
}

Warp home = new Warp();

home.Location = player.getLocation();


home.Location = callerIsPlayer ? ((Player) caller).getLocation()
: player.getLocation();
home.Group = ""; // no group neccessary, lol.
home.Name = player.getName();
etc.getInstance().changeHome(home);
Expand Down
2 changes: 1 addition & 1 deletion src/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public Location getSpawnLocation() {
spawn.z = info.e() + 0.5D;
spawn.rotX = 0.0F;
spawn.rotY = 0.0F;
spawn.dimension = this.getType().id;
spawn.dimension = 0;
spawn.world = this.getName();
return spawn;
}
Expand Down

0 comments on commit e8580e7

Please sign in to comment.