-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
342387c
commit 541ee35
Showing
14 changed files
with
303 additions
and
84 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
52 changes: 52 additions & 0 deletions
52
src/main/java/us/tastybento/bskyblock/commands/admin/AdminClearResetAllCommand.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,52 @@ | ||
package us.tastybento.bskyblock.commands.admin; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
|
||
import us.tastybento.bskyblock.api.commands.CompositeCommand; | ||
import us.tastybento.bskyblock.api.user.User; | ||
import us.tastybento.bskyblock.util.Util; | ||
|
||
public class AdminClearResetAllCommand extends CompositeCommand { | ||
|
||
public AdminClearResetAllCommand(CompositeCommand parent) { | ||
super(parent, "clearresetall"); | ||
} | ||
|
||
@Override | ||
public void setup() { | ||
setPermission("admin.clearresetall"); | ||
setParameters("commands.admin.clearreset.parameters"); | ||
setDescription("commands.admin.clearreset.description"); | ||
} | ||
|
||
@Override | ||
public boolean execute(User user, String label, List<String> args) { | ||
// If args are not right, show help | ||
if (!args.isEmpty()) { | ||
showHelp(this, user); | ||
return false; | ||
} | ||
// Set the reset epoch to now | ||
getIWM().setResetEpoch(getWorld()); | ||
// Reset all current players | ||
Bukkit.getOnlinePlayers().stream().map(Player::getUniqueId).filter(getPlayers()::isKnown).forEach(u -> getPlayers().setResets(getWorld(), u, 0)); | ||
user.sendMessage("general.success"); | ||
return true; | ||
} | ||
|
||
@Override | ||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) { | ||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : ""; | ||
if (args.isEmpty()) { | ||
// Don't show every player on the server. Require at least the first letter | ||
return Optional.empty(); | ||
} | ||
List<String> options = new ArrayList<>(Util.getOnlinePlayerList(user)); | ||
return Optional.of(Util.tabLimit(options, lastArg)); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/us/tastybento/bskyblock/commands/admin/AdminClearResetCommand.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,59 @@ | ||
package us.tastybento.bskyblock.commands.admin; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
import us.tastybento.bskyblock.api.commands.CompositeCommand; | ||
import us.tastybento.bskyblock.api.user.User; | ||
import us.tastybento.bskyblock.util.Util; | ||
|
||
public class AdminClearResetCommand extends CompositeCommand { | ||
|
||
public AdminClearResetCommand(CompositeCommand parent) { | ||
super(parent, "clearreset"); | ||
} | ||
|
||
@Override | ||
public void setup() { | ||
setPermission("admin.clearreset"); | ||
setParameters("commands.admin.clearreset.parameters"); | ||
setDescription("commands.admin.clearreset.description"); | ||
} | ||
|
||
@Override | ||
public boolean execute(User user, String label, List<String> args) { | ||
// If args are not right, show help | ||
if (args.size() != 1) { | ||
showHelp(this, user); | ||
return false; | ||
} | ||
// Get target | ||
UUID targetUUID = getPlayers().getUUID(args.get(0)); | ||
if (targetUUID == null) { | ||
user.sendMessage("general.errors.unknown-player"); | ||
return false; | ||
} | ||
if (!getIslands().hasIsland(getWorld(), targetUUID)) { | ||
user.sendMessage("general.errors.player-has-no-island"); | ||
return false; | ||
} | ||
// Clear resets | ||
user.sendMessage("commands.admin.clearreset.cleared"); | ||
getPlayers().setResets(getWorld(), user.getUniqueId(), 0); | ||
user.sendMessage("general.success"); | ||
return true; | ||
} | ||
|
||
@Override | ||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) { | ||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : ""; | ||
if (args.isEmpty()) { | ||
// Don't show every player on the server. Require at least the first letter | ||
return Optional.empty(); | ||
} | ||
List<String> options = new ArrayList<>(Util.getOnlinePlayerList(user)); | ||
return Optional.of(Util.tabLimit(options, lastArg)); | ||
} | ||
} |
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
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.