Fix and improve tab completion of Sender stuff.
This commit is contained in:
parent
d42c363086
commit
e29be0888f
@ -1,13 +1,10 @@
|
||||
package com.massivecraft.massivecore.cmd.arg;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import java.util.Iterator;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.massivecore.mixin.Mixin;
|
||||
import com.massivecraft.massivecore.store.SenderIdSourceMixinAllSenderIds;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
@ -32,22 +29,28 @@ public class ARPlayer extends ARSenderIdAbstract<Player>
|
||||
@Override
|
||||
public Player getResultForSenderId(String senderId)
|
||||
{
|
||||
// Null check is done in IdUtil :)
|
||||
// Null check is done in IdUtil
|
||||
return IdUtil.getPlayer(senderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getTabList(CommandSender sender, String arg)
|
||||
{
|
||||
Set<String> ret = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
||||
// Super Ret
|
||||
Collection<String> ret = super.getTabList(sender, arg);
|
||||
|
||||
for (String name : IdUtil.getOnlineNames())
|
||||
// Filter Ret
|
||||
Iterator<String> iter = ret.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
if ( ! MUtil.isValidPlayerName(name)) continue;
|
||||
if ( ! Mixin.canSee(sender, name)) continue;
|
||||
ret.add(name);
|
||||
String name = iter.next();
|
||||
if ( ! MUtil.isValidPlayerName(name))
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Return Ret
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,7 @@
|
||||
package com.massivecraft.massivecore.cmd.arg;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.massivecore.mixin.Mixin;
|
||||
import com.massivecraft.massivecore.store.SenderIdSourceMixinAllSenderIds;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
|
||||
@ -34,18 +29,4 @@ public class ARSender extends ARSenderIdAbstract<CommandSender>
|
||||
return IdUtil.getSender(senderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getTabList(CommandSender sender, String arg)
|
||||
{
|
||||
Set<String> ret = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
for (String name : IdUtil.getOnlineNames())
|
||||
{
|
||||
if ( ! Mixin.canSee(sender, name)) continue;
|
||||
ret.add(name);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,10 @@
|
||||
package com.massivecraft.massivecore.cmd.arg;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.massivecore.mixin.Mixin;
|
||||
import com.massivecraft.massivecore.store.SenderColl;
|
||||
import com.massivecraft.massivecore.store.SenderEntity;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
|
||||
public class ARSenderEntity<T extends SenderEntity<T>> extends ARSenderIdAbstract<T> implements ARAllAble<T>
|
||||
{
|
||||
@ -53,20 +48,6 @@ public class ARSenderEntity<T extends SenderEntity<T>> extends ARSenderIdAbstrac
|
||||
return this.coll.get(senderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getTabList(CommandSender sender, String arg)
|
||||
{
|
||||
Set<String> ret = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
for (String name : IdUtil.getOnlineNames())
|
||||
{
|
||||
if ( ! Mixin.canSee(sender, name)) continue;
|
||||
ret.add(name);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<T> getAll(CommandSender sender)
|
||||
{
|
||||
|
@ -1,15 +1,7 @@
|
||||
package com.massivecraft.massivecore.cmd.arg;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.massivecore.mixin.Mixin;
|
||||
import com.massivecraft.massivecore.store.SenderIdSource;
|
||||
import com.massivecraft.massivecore.store.SenderIdSourceMixinAllSenderIds;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
|
||||
public class ARSenderId extends ARSenderIdAbstract<String>
|
||||
{
|
||||
@ -51,18 +43,4 @@ public class ARSenderId extends ARSenderIdAbstract<String>
|
||||
return senderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getTabList(CommandSender sender, String arg)
|
||||
{
|
||||
Set<String> ret = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
for (String id : IdUtil.getOnlineIds())
|
||||
{
|
||||
if ( ! Mixin.canSee(sender, id)) continue;
|
||||
ret.add(id);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.massivecraft.massivecore.cmd.arg;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@ -89,6 +91,24 @@ public abstract class ARSenderIdAbstract<T> extends ARAbstract<T>
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getTabList(CommandSender sender, String arg)
|
||||
{
|
||||
// Create Ret
|
||||
Set<String> ret = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
// Fill Ret
|
||||
Set<String> names = (online ? IdUtil.getOnlineNames() : IdUtil.getAllNames());
|
||||
for (String name : names)
|
||||
{
|
||||
if ( ! Mixin.canSee(sender, name)) continue;
|
||||
ret.add(name);
|
||||
}
|
||||
|
||||
// Return Ret
|
||||
return ret;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// UTIL
|
||||
// -------------------------------------------- //
|
||||
|
Loading…
Reference in New Issue
Block a user