mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
Add /back
This commit is contained in:
1 parent
0e33fb8014
commit
5b8352411e
7 files changed
+30
-107
No files matched your search
@@ -139,8 +139,9 @@ public class HuskHomesBukkit extends JavaPlugin implements HuskHomes {
|
|||||||
this.savedPositionManager = new SavedPositionManager(database, cache);
|
this.savedPositionManager = new SavedPositionManager(database, cache);
|
||||||
|
|
||||||
// Register commands - todo add all here
|
// Register commands - todo add all here
|
||||||
final CommandBase[] commands = new CommandBase[]{new HomeCommand(this), new SetHomeCommand(this),
|
final CommandBase[] commands = new CommandBase[]{
|
||||||
new HomeListCommand(this)};
|
new HomeCommand(this), new SetHomeCommand(this),
|
||||||
|
new HomeListCommand(this), new BackCommand(this)};
|
||||||
for (CommandBase commandBase : commands) {
|
for (CommandBase commandBase : commands) {
|
||||||
final PluginCommand pluginCommand = getCommand(commandBase.command);
|
final PluginCommand pluginCommand = getCommand(commandBase.command);
|
||||||
if (pluginCommand != null) {
|
if (pluginCommand != null) {
|
||||||
|
|||||||
@@ -11,3 +11,5 @@ commands:
|
|||||||
usage: /sethome <name>
|
usage: /sethome <name>
|
||||||
homelist:
|
homelist:
|
||||||
usage: /homelist [page]
|
usage: /homelist [page]
|
||||||
|
back:
|
||||||
|
usage: /back
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package net.william278.huskhomes.command;
|
||||||
|
|
||||||
|
import net.william278.huskhomes.HuskHomes;
|
||||||
|
import net.william278.huskhomes.player.Player;
|
||||||
|
import net.william278.huskhomes.player.User;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class BackCommand extends CommandBase {
|
||||||
|
|
||||||
|
private final static String PERMISSION = "huskhomes.command.back";
|
||||||
|
|
||||||
|
public BackCommand(@NotNull HuskHomes implementor) {
|
||||||
|
super("back", PERMISSION, implementor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(@NotNull Player player, @NotNull String[] args) {
|
||||||
|
plugin.getDatabase().getLastPosition(new User(player)).thenAccept(lastPosition ->
|
||||||
|
lastPosition.ifPresentOrElse(position -> plugin.getTeleportManager().teleport(player, position)
|
||||||
|
.thenAccept(result -> plugin.getTeleportManager().finishTeleport(player, result)),
|
||||||
|
() -> plugin.getLocales().getLocale("error_no_last_position").ifPresent(player::sendMessage)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,12 +4,8 @@ import net.william278.huskhomes.HuskHomes;
|
|||||||
import net.william278.huskhomes.list.PrivateHomeList;
|
import net.william278.huskhomes.list.PrivateHomeList;
|
||||||
import net.william278.huskhomes.player.Player;
|
import net.william278.huskhomes.player.Player;
|
||||||
import net.william278.huskhomes.player.User;
|
import net.william278.huskhomes.player.User;
|
||||||
import net.william278.huskhomes.util.RegexUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class HomeListCommand extends CommandBase implements ConsoleExecutable {
|
public class HomeListCommand extends CommandBase implements ConsoleExecutable {
|
||||||
|
|
||||||
private final static String PERMISSION = "huskhomes.command.home";
|
private final static String PERMISSION = "huskhomes.command.home";
|
||||||
@@ -21,9 +17,7 @@ public class HomeListCommand extends CommandBase implements ConsoleExecutable {
|
|||||||
@Override
|
@Override
|
||||||
public void onExecute(@NotNull Player player, @NotNull String[] args) {
|
public void onExecute(@NotNull Player player, @NotNull String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0 -> {
|
case 0 -> showHomeList(player, 1);
|
||||||
showHomeList(player, 1);
|
|
||||||
}
|
|
||||||
case 1 -> {
|
case 1 -> {
|
||||||
try {
|
try {
|
||||||
int pageNumber = Integer.parseInt(args[0]);
|
int pageNumber = Integer.parseInt(args[0]);
|
||||||
|
|||||||
@@ -2,16 +2,11 @@ package net.william278.huskhomes.command;
|
|||||||
|
|
||||||
import de.themoep.minedown.MineDown;
|
import de.themoep.minedown.MineDown;
|
||||||
import net.william278.huskhomes.HuskHomes;
|
import net.william278.huskhomes.HuskHomes;
|
||||||
import net.william278.huskhomes.list.PrivateHomeList;
|
|
||||||
import net.william278.huskhomes.player.Player;
|
import net.william278.huskhomes.player.Player;
|
||||||
import net.william278.huskhomes.player.User;
|
import net.william278.huskhomes.player.User;
|
||||||
import net.william278.huskhomes.position.PositionMeta;
|
import net.william278.huskhomes.position.PositionMeta;
|
||||||
import net.william278.huskhomes.util.RegexUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class SetHomeCommand extends CommandBase {
|
public class SetHomeCommand extends CommandBase {
|
||||||
|
|
||||||
private final static String PERMISSION = "huskhomes.command.sethome";
|
private final static String PERMISSION = "huskhomes.command.sethome";
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
package net.william278.huskhomes.list;
|
|
||||||
|
|
||||||
import de.themoep.minedown.MineDown;
|
|
||||||
import net.william278.huskhomes.position.Home;
|
|
||||||
import net.william278.huskhomes.position.SavedPosition;
|
|
||||||
import net.william278.huskhomes.position.Warp;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class PublicHomeList extends PositionList {
|
|
||||||
|
|
||||||
public PublicHomeList(@NotNull List<Home> homes, int itemsPerPage) {
|
|
||||||
super(homes.stream().map(position -> (SavedPosition) position).collect(Collectors.toList()), itemsPerPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getItemSeparator() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected MineDown getHeader(int pageItemStart, int pageItemEnd, int totalItemCount) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected MineDown getFooter(@NotNull FooterLayout layout, int pageNumber, int maxPages) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getFormattedItem(SavedPosition position) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected MineDown getNoItemsMessage() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected MineDown getInvalidPageNumberMessage() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package net.william278.huskhomes.list;
|
|
||||||
|
|
||||||
import de.themoep.minedown.MineDown;
|
|
||||||
import net.william278.huskhomes.position.SavedPosition;
|
|
||||||
import net.william278.huskhomes.position.Warp;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class WarpList extends PositionList {
|
|
||||||
|
|
||||||
public WarpList(@NotNull List<Warp> warps, int itemsPerPage) {
|
|
||||||
super(warps.stream().map(position -> (SavedPosition) position).collect(Collectors.toList()), itemsPerPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getItemSeparator() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected MineDown getHeader(int pageItemStart, int pageItemEnd, int totalItemCount) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected MineDown getFooter(@NotNull FooterLayout layout, int pageNumber, int maxPages) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getFormattedItem(SavedPosition position) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected MineDown getNoItemsMessage() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected MineDown getInvalidPageNumberMessage() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user