mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-23 16:41:42 +01:00
Fixed island multihome to match new syntax.
Renamed island multihome to start with "Custom" to make it clearer. This class is as much an example as anything of how to override the default help. Renamed my author tag to be tastybento. :-)
This commit is contained in:
parent
a0cbb451fa
commit
d86c763716
@ -6,7 +6,7 @@ import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Interface for BSkyBlock Commands
|
||||
* @author ben
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public interface BSBCommand {
|
||||
|
@ -24,7 +24,7 @@ import us.tastybento.bskyblock.util.Util;
|
||||
|
||||
/**
|
||||
* BSB composite command
|
||||
* @author ben, poslovich
|
||||
* @author tastybento, poslovich
|
||||
*
|
||||
*/
|
||||
public abstract class CompositeCommand extends Command implements PluginIdentifiableCommand, BSBCommand {
|
||||
|
@ -2,12 +2,10 @@ package us.tastybento.bskyblock.api.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* Adds a default help to every command that will show the usage of the command
|
||||
* and the usage of any subcommands that the command has.
|
||||
* @author ben
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class DefaultHelpCommand extends CompositeCommand {
|
||||
|
@ -21,7 +21,7 @@ import us.tastybento.bskyblock.config.Settings;
|
||||
|
||||
/**
|
||||
* BSB's user object. Wraps Player.
|
||||
* @author ben
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class User {
|
||||
|
@ -2,8 +2,6 @@ package us.tastybento.bskyblock.commands.island;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||
import us.tastybento.bskyblock.api.commands.User;
|
||||
import us.tastybento.bskyblock.config.Settings;
|
||||
@ -12,12 +10,14 @@ import us.tastybento.bskyblock.util.Util;
|
||||
/**
|
||||
* This is a custom help for the /island go and /island sethome commands. It overrides the default help sub command.
|
||||
* The number of homes can change depending on the player's permissions and config.yml settings.
|
||||
* @author ben
|
||||
* This is an example of a custom help as much as anything.
|
||||
*
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class IslandMultiHomeHelp extends CompositeCommand {
|
||||
public class CustomIslandMultiHomeHelp extends CompositeCommand {
|
||||
|
||||
public IslandMultiHomeHelp(CompositeCommand parent) {
|
||||
public CustomIslandMultiHomeHelp(CompositeCommand parent) {
|
||||
super(parent, "help");
|
||||
}
|
||||
|
||||
@ -35,17 +35,18 @@ public class IslandMultiHomeHelp extends CompositeCommand {
|
||||
// This will only be shown if it is for a player
|
||||
if (user.isPlayer()) {
|
||||
// Get elements
|
||||
String usage = parent.getUsage().isEmpty() ? "" : user.getTranslationOrNothing("commands.help.color.usage") + user.getTranslation(parent.getUsage());
|
||||
String params = getParameters().isEmpty() ? "" : ChatColor.RESET + " " + user.getTranslationOrNothing("commands.help.color.parameters") + user.getTranslation(getParameters());
|
||||
String desc = getDescription().isEmpty() ? "" : ChatColor.RESET + user.getTranslationOrNothing("commands.help.color.description") + " " + user.getTranslation(getDescription());
|
||||
String usage = parent.getUsage().isEmpty() ? "" : user.getTranslation(parent.getUsage());
|
||||
String params = "";
|
||||
String desc = getDescription().isEmpty() ? "" : user.getTranslation(getDescription());
|
||||
// Player. Check perms
|
||||
if (user.hasPermission(getPermission())) {
|
||||
int maxHomes = Util.getPermValue(user.getPlayer(), Settings.PERMPREFIX + "island.maxhomes", Settings.maxHomes);
|
||||
if (maxHomes > 1) {
|
||||
user.sendRawMessage(usage + params + desc);
|
||||
params = getParameters().isEmpty() ? "" : user.getTranslation(getParameters());
|
||||
user.sendMessage("commands.help.syntax", "[usage]", usage, "[parameters]", params, "[description]", desc);
|
||||
} else {
|
||||
// No params
|
||||
user.sendRawMessage(usage + desc);
|
||||
user.sendMessage("commands.help.syntax", "[usage]", usage, "[parameters]", params, "[description]", desc);
|
||||
}
|
||||
return true;
|
||||
} else {
|
@ -14,7 +14,7 @@ import us.tastybento.bskyblock.config.Settings;
|
||||
import us.tastybento.bskyblock.database.managers.island.NewIsland;
|
||||
|
||||
/**
|
||||
* @author ben
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class IslandCreateCommand extends CompositeCommand {
|
||||
|
@ -15,7 +15,7 @@ import us.tastybento.bskyblock.config.Settings;
|
||||
import us.tastybento.bskyblock.util.Util;
|
||||
|
||||
/**
|
||||
* @author ben
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class IslandGoCommand extends CompositeCommand {
|
||||
@ -29,7 +29,7 @@ public class IslandGoCommand extends CompositeCommand {
|
||||
this.setPermission(Settings.PERMPREFIX + "island.home");
|
||||
this.setOnlyPlayer(true);
|
||||
this.setDescription("commands.island.go.description");
|
||||
new IslandMultiHomeHelp(this);
|
||||
new CustomIslandMultiHomeHelp(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -11,7 +11,7 @@ import us.tastybento.bskyblock.api.commands.User;
|
||||
import us.tastybento.bskyblock.config.Settings;
|
||||
|
||||
/**
|
||||
* @author ben
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class IslandResetnameCommand extends CompositeCommand {
|
||||
|
@ -19,7 +19,7 @@ public class IslandSethomeCommand extends CompositeCommand {
|
||||
this.setPermission(Settings.PERMPREFIX + "island.sethome");
|
||||
this.setOnlyPlayer(true);
|
||||
this.setDescription("commands.island.sethome.description");
|
||||
new IslandMultiHomeHelp(this);
|
||||
new CustomIslandMultiHomeHelp(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,7 +15,7 @@ import us.tastybento.bskyblock.api.commands.User;
|
||||
import us.tastybento.bskyblock.config.Settings;
|
||||
|
||||
/**
|
||||
* @author ben
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class IslandSetnameCommand extends CompositeCommand {
|
||||
|
@ -17,7 +17,7 @@ import us.tastybento.bskyblock.config.Settings;
|
||||
|
||||
/**
|
||||
* A safe common space for team commands to share data
|
||||
* @author ben
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractIslandTeamCommand extends CompositeCommand {
|
||||
|
@ -18,7 +18,7 @@ import us.tastybento.bskyblock.island.builders.IslandBuilder.IslandType;
|
||||
|
||||
/**
|
||||
* Create and paste a new island
|
||||
* @author ben
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class NewIsland {
|
||||
@ -56,7 +56,7 @@ public class NewIsland {
|
||||
|
||||
/**
|
||||
* Build a new island for a player using a schematic
|
||||
* @author ben
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public static class Builder {
|
||||
|
Loading…
Reference in New Issue
Block a user