Destination tab list and tab completon bugfix

This commit is contained in:
Magnus Ulf 2015-06-17 20:41:54 +02:00 committed by Olof Larsson
parent 7b67c58d2f
commit e97eff3309
3 changed files with 49 additions and 4 deletions

View File

@ -139,8 +139,6 @@ public abstract class ARAbstract<T> implements AR<T>
ret.set(0, result); ret.set(0, result);
} }
return ret; return ret;
} }
@ -171,7 +169,7 @@ public abstract class ARAbstract<T> implements AR<T>
// But we can't keep things after the first part either // But we can't keep things after the first part either
// because of spaces and stuff. // because of spaces and stuff.
if (suggestion.length() <= prefix.length()) continue; 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(); int lastIndex = lastSpace != -1 ? lastSpace : suggestion.length();
ret.add(suggestion.substring(prefix.length(), lastIndex)); ret.add(suggestion.substring(prefix.length(), lastIndex));
} }

View File

@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.event.EventMassiveCoreDestination; import com.massivecraft.massivecore.event.EventMassiveCoreDestination;
import com.massivecraft.massivecore.event.EventMassiveCoreDestinationTabList;
import com.massivecraft.massivecore.teleport.Destination; import com.massivecraft.massivecore.teleport.Destination;
public class ARDestination extends ARAbstract<Destination> public class ARDestination extends ARAbstract<Destination>
@ -42,7 +43,9 @@ public class ARDestination extends ARAbstract<Destination>
@Override @Override
public Collection<String> getTabList(CommandSender sender, String arg) public Collection<String> getTabList(CommandSender sender, String arg)
{ {
return null; EventMassiveCoreDestinationTabList event = new EventMassiveCoreDestinationTabList(arg, sender);
event.run();
return event.getSuggestions();
} }
} }

View File

@ -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<String> suggestions;
public List<String> getSuggestions() { return this.suggestions; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public EventMassiveCoreDestinationTabList(String arg, CommandSender sender)
{
this.arg = arg;
this.sender = sender;
this.suggestions = new MassiveList<String>();
}
}