-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added setwarp and removewarp commands to enable courses.
- Loading branch information
1 parent
9ab5ff0
commit dbd978c
Showing
6 changed files
with
111 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/world/bentobox/parkour/commands/RemoveWarpCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package world.bentobox.parkour.commands; | ||
|
||
import java.util.List; | ||
|
||
import world.bentobox.bentobox.api.commands.CompositeCommand; | ||
import world.bentobox.bentobox.api.user.User; | ||
import world.bentobox.bentobox.database.objects.Island; | ||
import world.bentobox.parkour.Parkour; | ||
import world.bentobox.parkour.ParkourManager; | ||
|
||
public class RemoveWarpCommand extends CompositeCommand { | ||
|
||
public RemoveWarpCommand(Parkour addon, CompositeCommand parent) { | ||
super(parent, "removewarp"); | ||
} | ||
|
||
@Override | ||
public void setup() { | ||
this.setPermission("parkour.removewarp"); | ||
setOnlyPlayer(true); | ||
setDescription("parkour.commands.parkour.removewarp.description"); | ||
} | ||
|
||
@Override | ||
public boolean canExecute(User user, String label, List<String> args) { | ||
Island island = getIslands().getIsland(getWorld(), user); | ||
ParkourManager pm = ((Parkour)getAddon()).getPm(); | ||
if (pm.getWarpSpot(island).isEmpty()) { | ||
user.sendMessage("parkour.errors.no-warp"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean execute(User user, String label, List<String> args) { | ||
ParkourManager pm = ((Parkour)getAddon()).getPm(); | ||
Island island = getIslands().getIsland(getWorld(), user); | ||
user.sendMessage("parkour.warp.removed"); | ||
pm.setWarpSpot(island, null); | ||
return true; | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/world/bentobox/parkour/commands/SetWarpCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package world.bentobox.parkour.commands; | ||
|
||
import java.util.List; | ||
|
||
import world.bentobox.bentobox.api.commands.CompositeCommand; | ||
import world.bentobox.bentobox.api.user.User; | ||
import world.bentobox.bentobox.database.objects.Island; | ||
import world.bentobox.parkour.Parkour; | ||
import world.bentobox.parkour.ParkourManager; | ||
|
||
public class SetWarpCommand extends CompositeCommand { | ||
|
||
|
||
|
||
public SetWarpCommand(Parkour addon, CompositeCommand parent) { | ||
super(parent, "setwarp"); | ||
} | ||
|
||
@Override | ||
public void setup() { | ||
this.setPermission("parkour.setwarp"); | ||
setOnlyPlayer(true); | ||
setDescription("parkour.commands.parkour.setwarp.description"); | ||
} | ||
|
||
@Override | ||
public boolean canExecute(User user, String label, List<String> args) { | ||
if (!getIslands().userIsOnIsland(getWorld(), user)) { | ||
user.sendMessage("parkour.errors.not-on-island"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean execute(User user, String label, List<String> args) { | ||
ParkourManager pm = ((Parkour)getAddon()).getPm(); | ||
Island island = getIslands().getIsland(getWorld(), user); | ||
if (pm.getWarpSpot(island).isEmpty()) { | ||
user.sendMessage("parkour.warp.set"); | ||
} else { | ||
user.sendMessage("parkour.warp.replaced"); | ||
} | ||
pm.setWarpSpot(island, user.getLocation()); | ||
|
||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters