generated from TobiasDeBruijn/BaseBukkitPlugin
-
Notifications
You must be signed in to change notification settings - Fork 4
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 #44 from TobiasDeBruijn/direct-command
Direct command
- Loading branch information
Showing
10 changed files
with
121 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,9 @@ releases | |
bin/ | ||
|
||
actions/ | ||
|
||
# IntelliJ | ||
.idea/ | ||
|
||
# Vscode | ||
.vscode/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pluginVersion = 1.7.8 | ||
pluginVersion = 1.7.7 |
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
56 changes: 56 additions & 0 deletions
56
src/main/java/dev/array21/skinfixer/commands/subcommands/DirectCommand.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,56 @@ | ||
package dev.array21.skinfixer.commands.subcommands; | ||
|
||
import java.util.UUID; | ||
|
||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.command.TabCompleter; | ||
import org.bukkit.entity.Player; | ||
|
||
import dev.array21.skinfixer.SkinChangeHandler; | ||
import dev.array21.skinfixer.SkinFixer; | ||
import dev.array21.skinfixer.commands.CommandInfo; | ||
import dev.array21.skinfixer.commands.Subcommand; | ||
import dev.array21.skinfixer.common.AddNewSkin; | ||
import dev.array21.skinfixer.language.LangHandler; | ||
import net.md_5.bungee.api.ChatColor; | ||
|
||
@CommandInfo(name = "direct", description = "Fetches a skin code and immediately applies skin to sender. URL must be Skin image. Only accepts URLs.", permission = "skinfixer.set", globalCommand = "setskin") | ||
public class DirectCommand implements Subcommand { | ||
|
||
@Override | ||
public void onSubcommand(SkinFixer plugin, CommandSender sender, String[] args) { | ||
if (!(sender instanceof Player)) { | ||
sender.sendMessage(SkinFixer.getPrefix() + ChatColor.RED + LangHandler.model.commandPlayerOnly); | ||
return; | ||
} | ||
|
||
// User must provide a URL | ||
if (args.length == 0) { | ||
sender.sendMessage(ChatColor.RED + LangHandler.model.missingUrlArgument); | ||
return; | ||
} | ||
|
||
// Check that the user actually supplied a URL | ||
if (!(args[0].contains("https://") || args[0].contains("http://"))) { | ||
sender.sendMessage(ChatColor.RED + LangHandler.model.invalidUrlArguemnt); | ||
} | ||
|
||
// Filter off the query parameters | ||
int indexOfQuery = args[0].indexOf('?'); | ||
int endIndex = indexOfQuery > 0 ? indexOfQuery : args[0].length(); | ||
String url = args[0].substring(0, endIndex); | ||
|
||
// Check if the skin is a slim model | ||
boolean slim = args.length >= 2 && args[1].equalsIgnoreCase("true"); | ||
|
||
// Apply the skin | ||
new SkinChangeHandler(plugin).changeSkinJson(url, ((Player) sender).getUniqueId(), null, slim, false, false); | ||
} | ||
|
||
@Override | ||
public String[] onSubcommandComplete(SkinFixer plugin, CommandSender sender, String[] args) { | ||
return new String[0]; | ||
} | ||
} |
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