diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARAbstract.java b/src/com/massivecraft/massivecore/cmd/arg/ARAbstract.java index 3b837f5f..6972a452 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARAbstract.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARAbstract.java @@ -139,8 +139,6 @@ public abstract class ARAbstract implements AR ret.set(0, result); } - - return ret; } @@ -171,7 +169,7 @@ public abstract class ARAbstract implements AR // But we can't keep things after the first part either // because of spaces and stuff. if (suggestion.length() <= prefix.length()) continue; - int lastSpace = prefix.indexOf(' ', prefix.length()); + int lastSpace = suggestion.indexOf(' ', prefix.length()); int lastIndex = lastSpace != -1 ? lastSpace : suggestion.length(); ret.add(suggestion.substring(prefix.length(), lastIndex)); } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARDestination.java b/src/com/massivecraft/massivecore/cmd/arg/ARDestination.java index 49b29cf7..9525b710 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARDestination.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARDestination.java @@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.event.EventMassiveCoreDestination; +import com.massivecraft.massivecore.event.EventMassiveCoreDestinationTabList; import com.massivecraft.massivecore.teleport.Destination; public class ARDestination extends ARAbstract @@ -42,7 +43,9 @@ public class ARDestination extends ARAbstract @Override public Collection getTabList(CommandSender sender, String arg) { - return null; + EventMassiveCoreDestinationTabList event = new EventMassiveCoreDestinationTabList(arg, sender); + event.run(); + return event.getSuggestions(); } } diff --git a/src/com/massivecraft/massivecore/event/EventMassiveCoreDestinationTabList.java b/src/com/massivecraft/massivecore/event/EventMassiveCoreDestinationTabList.java new file mode 100644 index 00000000..738f2711 --- /dev/null +++ b/src/com/massivecraft/massivecore/event/EventMassiveCoreDestinationTabList.java @@ -0,0 +1,44 @@ +package com.massivecraft.massivecore.event; + +import java.util.List; + +import org.bukkit.command.CommandSender; +import org.bukkit.event.HandlerList; + +import com.massivecraft.massivecore.collections.MassiveList; + +public class EventMassiveCoreDestinationTabList extends EventMassiveCore +{ + // -------------------------------------------- // + // REQUIRED EVENT CODE + // -------------------------------------------- // + + private static final HandlerList handlers = new HandlerList(); + @Override public HandlerList getHandlers() { return handlers; } + public static HandlerList getHandlerList() { return handlers; } + + // -------------------------------------------- // + // FIELD + // -------------------------------------------- // + + private final String arg; + public String getArg() { return this.arg; } + + private final CommandSender sender; + public CommandSender getSender() { return this.sender; } + + private final List suggestions; + public List getSuggestions() { return this.suggestions; } + + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + public EventMassiveCoreDestinationTabList(String arg, CommandSender sender) + { + this.arg = arg; + this.sender = sender; + this.suggestions = new MassiveList(); + } + +}