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;
|
package com.massivecraft.massivecore.cmd.arg;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Iterator;
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.mixin.Mixin;
|
|
||||||
import com.massivecraft.massivecore.store.SenderIdSourceMixinAllSenderIds;
|
import com.massivecraft.massivecore.store.SenderIdSourceMixinAllSenderIds;
|
||||||
import com.massivecraft.massivecore.util.IdUtil;
|
import com.massivecraft.massivecore.util.IdUtil;
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
import com.massivecraft.massivecore.util.MUtil;
|
||||||
@ -32,22 +29,28 @@ public class ARPlayer extends ARSenderIdAbstract<Player>
|
|||||||
@Override
|
@Override
|
||||||
public Player getResultForSenderId(String senderId)
|
public Player getResultForSenderId(String senderId)
|
||||||
{
|
{
|
||||||
// Null check is done in IdUtil :)
|
// Null check is done in IdUtil
|
||||||
return IdUtil.getPlayer(senderId);
|
return IdUtil.getPlayer(senderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> getTabList(CommandSender sender, String arg)
|
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;
|
String name = iter.next();
|
||||||
if ( ! Mixin.canSee(sender, name)) continue;
|
if ( ! MUtil.isValidPlayerName(name))
|
||||||
ret.add(name);
|
{
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return Ret
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
package com.massivecraft.massivecore.cmd.arg;
|
package com.massivecraft.massivecore.cmd.arg;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.mixin.Mixin;
|
|
||||||
import com.massivecraft.massivecore.store.SenderIdSourceMixinAllSenderIds;
|
import com.massivecraft.massivecore.store.SenderIdSourceMixinAllSenderIds;
|
||||||
import com.massivecraft.massivecore.util.IdUtil;
|
import com.massivecraft.massivecore.util.IdUtil;
|
||||||
|
|
||||||
@ -30,22 +25,8 @@ public class ARSender extends ARSenderIdAbstract<CommandSender>
|
|||||||
@Override
|
@Override
|
||||||
public CommandSender getResultForSenderId(String senderId)
|
public CommandSender getResultForSenderId(String senderId)
|
||||||
{
|
{
|
||||||
//Null check is done in IdUtil
|
// Null check is done in IdUtil
|
||||||
return IdUtil.getSender(senderId);
|
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;
|
package com.massivecraft.massivecore.cmd.arg;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.mixin.Mixin;
|
|
||||||
import com.massivecraft.massivecore.store.SenderColl;
|
import com.massivecraft.massivecore.store.SenderColl;
|
||||||
import com.massivecraft.massivecore.store.SenderEntity;
|
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>
|
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);
|
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
|
@Override
|
||||||
public Collection<T> getAll(CommandSender sender)
|
public Collection<T> getAll(CommandSender sender)
|
||||||
{
|
{
|
||||||
|
@ -1,15 +1,7 @@
|
|||||||
package com.massivecraft.massivecore.cmd.arg;
|
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.SenderIdSource;
|
||||||
import com.massivecraft.massivecore.store.SenderIdSourceMixinAllSenderIds;
|
import com.massivecraft.massivecore.store.SenderIdSourceMixinAllSenderIds;
|
||||||
import com.massivecraft.massivecore.util.IdUtil;
|
|
||||||
|
|
||||||
public class ARSenderId extends ARSenderIdAbstract<String>
|
public class ARSenderId extends ARSenderIdAbstract<String>
|
||||||
{
|
{
|
||||||
@ -51,18 +43,4 @@ public class ARSenderId extends ARSenderIdAbstract<String>
|
|||||||
return senderId;
|
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;
|
package com.massivecraft.massivecore.cmd.arg;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@ -89,6 +91,24 @@ public abstract class ARSenderIdAbstract<T> extends ARAbstract<T>
|
|||||||
return false;
|
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
|
// UTIL
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
Loading…
Reference in New Issue
Block a user