forked from AddstarMC/Minigames
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- removed region selection from other subcommands (regenRegion, DegenArea and Region) - added integration for world edit - you can now select via your trusty wooden axe and WECUI
- Loading branch information
1 parent
eb5825c
commit 51ff7ef
Showing
12 changed files
with
359 additions
and
120 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
103 changes: 103 additions & 0 deletions
103
Minigames/src/main/java/au/com/mineauz/minigames/commands/SelectCommand.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,103 @@ | ||
package au.com.mineauz.minigames.commands; | ||
|
||
import au.com.mineauz.minigames.MinigameUtils; | ||
import au.com.mineauz.minigames.Minigames; | ||
import au.com.mineauz.minigames.minigame.Minigame; | ||
import au.com.mineauz.minigames.objects.MinigamePlayer; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.format.NamedTextColor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
|
||
public class SelectCommand implements ICommand { | ||
@Override | ||
public @NotNull String getName() { | ||
return "select"; | ||
} | ||
|
||
@Override | ||
public @NotNull String[] getAliases() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean canBeConsole() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "select and clear region selections"; | ||
} | ||
|
||
@Override | ||
public @NotNull String[] getParameters() { | ||
return new String[]{ | ||
"1", | ||
"2", | ||
"clear" | ||
}; | ||
} | ||
|
||
@Override | ||
public @NotNull String[] getUsage() { | ||
return new String[]{ | ||
"/minigame select 1", | ||
"/minigame select 2", | ||
"/minigame select clear" | ||
}; | ||
} | ||
|
||
@Override | ||
public String getPermissionMessage() { | ||
return "You don't have permission to modify regions"; | ||
} | ||
|
||
@Override | ||
public @Nullable String getPermission() { | ||
return "minigame.region.select"; | ||
} | ||
|
||
@Override | ||
public boolean onCommand(@NotNull CommandSender sender, @Nullable Minigame minigame, | ||
String label, @NotNull String @Nullable [] args) { | ||
if (sender instanceof Player player) { | ||
MinigamePlayer mgPlayer = Minigames.getPlugin().getPlayerManager().getMinigamePlayer(player); | ||
|
||
if (args != null && args.length > 0) { | ||
if (args[0].equalsIgnoreCase("1")) { | ||
mgPlayer.setSelection1(player.getLocation()); | ||
mgPlayer.sendInfoMessage(Component.text("Point 1 selected", NamedTextColor.GRAY)); | ||
} else if (args[0].equalsIgnoreCase("2")) { | ||
mgPlayer.setSelection2(player.getLocation()); | ||
mgPlayer.sendInfoMessage(Component.text("Point 2 selected", NamedTextColor.GRAY)); | ||
|
||
} else if (args[0].equalsIgnoreCase("clear")) { | ||
mgPlayer.clearSelection(); | ||
mgPlayer.sendInfoMessage(Component.text("Selection cleared.", NamedTextColor.GRAY)); | ||
} else { // unknown param | ||
return false; | ||
} | ||
} else { // not enough args | ||
return false; | ||
} | ||
} else { | ||
sender.sendMessage(Component.text("You have to be a player.", NamedTextColor.RED)); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public @Nullable List<@NotNull String> onTabComplete(CommandSender sender, Minigame minigame, String alias, String[] args) { | ||
if (args != null && args.length == 1) { | ||
return MinigameUtils.tabCompleteMatch(List.of("1", "2", "clear"), args[0]); | ||
} | ||
return null; | ||
} | ||
} |
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.
51ff7ef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.