-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add destination teleport subcommand (#420)
- Loading branch information
1 parent
d23a3e6
commit af5018d
Showing
7 changed files
with
78 additions
and
3 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
58 changes: 58 additions & 0 deletions
58
...a/com/sekwah/advancedportals/core/commands/subcommands/desti/TeleportDestiSubCommand.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 com.sekwah.advancedportals.core.commands.subcommands.desti; | ||
|
||
import com.google.inject.Inject; | ||
import com.sekwah.advancedportals.core.commands.SubCommand; | ||
import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; | ||
import com.sekwah.advancedportals.core.permissions.PortalPermissions; | ||
import com.sekwah.advancedportals.core.services.DestinationServices; | ||
import com.sekwah.advancedportals.core.util.Lang; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class TeleportDestiSubCommand implements SubCommand { | ||
|
||
@Inject | ||
DestinationServices destinationServices; | ||
@Override | ||
public void onCommand(CommandSenderContainer sender, String[] args) { | ||
if(args.length > 1) { | ||
if(destinationServices.teleportToDestination(args[1], sender.getPlayerContainer())) { | ||
sender.sendMessage(Lang.translate("messageprefix.positive") | ||
+ Lang.translate("command.destination.teleport.success") | ||
.replaceAll("@destiname", args[1])); | ||
} else { | ||
sender.sendMessage(Lang.translate("messageprefix.negative") + | ||
Lang.translate("command.destination.teleport.error") | ||
.replaceAll("@destiname", args[1])); | ||
} | ||
} else { | ||
sender.sendMessage(Lang.translate("command.destination.noname")); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean hasPermission(CommandSenderContainer sender) { | ||
return sender.isOp() || PortalPermissions.DESTI.hasPermission(sender); | ||
} | ||
|
||
@Override | ||
public List<String> onTabComplete(CommandSenderContainer sender, String[] args) { | ||
if(args.length > 2) { | ||
return Collections.emptyList(); | ||
} | ||
List<String> destiNames = destinationServices.getDestinationNames(); | ||
Collections.sort(destiNames); | ||
return destiNames; | ||
} | ||
|
||
@Override | ||
public String getBasicHelpText() { | ||
return Lang.translate("command.destination.teleport.help"); | ||
} | ||
|
||
@Override | ||
public String getDetailedHelpText() { | ||
return Lang.translate("command.destination.teleport.detailedhelp"); | ||
} | ||
} |
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