-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.21.0
- Add ability to teleport to another player's home...
Intended for admin use.
- Loading branch information
1 parent
61a3161
commit 2076c54
Showing
6 changed files
with
139 additions
and
56 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
69 changes: 69 additions & 0 deletions
69
src/main/java/com/fibermc/essentialcommands/commands/HomeTeleportOtherCommand.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,69 @@ | ||
package com.fibermc.essentialcommands.commands; | ||
|
||
import com.fibermc.essentialcommands.PlayerData; | ||
import com.fibermc.essentialcommands.access.ServerPlayerEntityAccess; | ||
import com.fibermc.essentialcommands.commands.suggestions.ListSuggestion; | ||
import com.fibermc.essentialcommands.types.MinecraftLocation; | ||
import com.mojang.brigadier.Command; | ||
import com.mojang.brigadier.arguments.StringArgumentType; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import com.mojang.brigadier.suggestion.SuggestionProvider; | ||
import net.minecraft.command.argument.EntityArgumentType; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
|
||
public class HomeTeleportOtherCommand extends HomeCommand implements Command<ServerCommandSource> { | ||
|
||
public HomeTeleportOtherCommand() { | ||
} | ||
|
||
@Override | ||
public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException { | ||
PlayerData senderPlayerData = ((ServerPlayerEntityAccess) context.getSource().getPlayer()).getEcPlayerData(); | ||
String homeName = StringArgumentType.getString(context, "home_name"); | ||
|
||
return HomeCommand.exec(senderPlayerData, getTargetPlayerData(context), homeName); | ||
} | ||
|
||
private static PlayerData getTargetPlayerData(CommandContext<ServerCommandSource> context) throws CommandSyntaxException { | ||
return ((ServerPlayerEntityAccess) EntityArgumentType.getPlayer(context, "target_player")).getEcPlayerData(); | ||
} | ||
|
||
public int runDefault(CommandContext<ServerCommandSource> context) throws CommandSyntaxException { | ||
var senderPlayerData = ((ServerPlayerEntityAccess) context.getSource().getPlayer()).getEcPlayerData(); | ||
var targetPlayerData = getTargetPlayerData(context); | ||
|
||
return HomeCommand.exec( | ||
senderPlayerData, | ||
targetPlayerData, | ||
HomeCommand.getSoleHomeName(targetPlayerData) | ||
); | ||
} | ||
|
||
public static class Suggestion { | ||
//Brigader Suggestions | ||
public static final SuggestionProvider<ServerCommandSource> suggestedStrings | ||
= ListSuggestion.ofContext(HomeTeleportOtherCommand.Suggestion::getSuggestionsList); | ||
|
||
/** | ||
* Gets a list of suggested strings to be used with Brigader | ||
*/ | ||
public static List<String> getSuggestionsList(CommandContext<ServerCommandSource> context) throws CommandSyntaxException { | ||
return new ArrayList<>(HomeTeleportOtherCommand.getTargetPlayerData(context).getHomeNames()); | ||
} | ||
|
||
/** | ||
* Gets a set of suggestion entries to be used with ListCommandFactory | ||
*/ | ||
public static Set<Map.Entry<String, MinecraftLocation>> getSuggestionEntries(CommandContext<ServerCommandSource> context) throws CommandSyntaxException { | ||
return HomeTeleportOtherCommand.getTargetPlayerData(context).getHomeEntries(); | ||
} | ||
|
||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
src/main/java/com/fibermc/essentialcommands/commands/suggestions/HomeSuggestion.java
This file was deleted.
Oops, something went wrong.