-
-
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.
Merge pull request #3 from BentoBoxWorld/develop
Release 1.1.0
- Loading branch information
Showing
13 changed files
with
878 additions
and
143 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
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
58 changes: 58 additions & 0 deletions
58
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,58 @@ | ||
package world.bentobox.parkour.commands; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import world.bentobox.bentobox.api.commands.CompositeCommand; | ||
import world.bentobox.bentobox.api.localization.TextVariables; | ||
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(CompositeCommand parent) { | ||
super(parent, "removewarp"); | ||
} | ||
|
||
@Override | ||
public void setup() { | ||
this.setPermission("parkour.removewarp"); | ||
setOnlyPlayer(true); | ||
setDescription("parkour.commands.parkour.removewarp.description"); | ||
setConfigurableRankCommand(); | ||
} | ||
|
||
@Override | ||
public boolean canExecute(User user, String label, List<String> args) { | ||
if (!args.isEmpty()) { | ||
this.showHelp(this, user); | ||
return false; | ||
} | ||
Island island = getIslands().getIsland(getWorld(), user); | ||
// Check rank to use command | ||
int rank = Objects.requireNonNull(island).getRank(user); | ||
if (rank < island.getRankCommand(getUsage())) { | ||
user.sendMessage("general.errors.insufficient-rank", TextVariables.RANK, user.getTranslation(getPlugin().getRanksManager().getRank(rank))); | ||
return false; | ||
} | ||
|
||
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; | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
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,63 @@ | ||
package world.bentobox.parkour.commands; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import world.bentobox.bentobox.api.commands.CompositeCommand; | ||
import world.bentobox.bentobox.api.localization.TextVariables; | ||
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(CompositeCommand parent) { | ||
super(parent, "setwarp"); | ||
} | ||
|
||
@Override | ||
public void setup() { | ||
this.setPermission("parkour.setwarp"); | ||
setOnlyPlayer(true); | ||
setDescription("parkour.commands.parkour.setwarp.description"); | ||
setConfigurableRankCommand(); | ||
} | ||
|
||
@Override | ||
public boolean canExecute(User user, String label, List<String> args) { | ||
if (!args.isEmpty()) { | ||
this.showHelp(this, user); | ||
return false; | ||
} | ||
if (!getIslands().userIsOnIsland(getWorld(), user)) { | ||
user.sendMessage("parkour.errors.not-on-island"); | ||
return false; | ||
} | ||
// Check rank to use command | ||
Island island = getIslands().getIsland(getWorld(), user); | ||
int rank = Objects.requireNonNull(island).getRank(user); | ||
if (rank < island.getRankCommand(getUsage())) { | ||
user.sendMessage("general.errors.insufficient-rank", TextVariables.RANK, user.getTranslation(getPlugin().getRanksManager().getRank(rank))); | ||
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
Oops, something went wrong.