From 216dd14bf81bb09b948f47035bad347311a04457 Mon Sep 17 00:00:00 2001 From: Magnus Ulf Date: Sun, 27 Jan 2019 18:02:32 +0100 Subject: [PATCH] Better tab completion for internal entities --- src/com/massivecraft/factions/Factions.java | 2 ++ .../cmd/type/TypeEntityInternalFaction.java | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index 71b4a68e..7d4f2b49 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -59,6 +59,7 @@ import com.massivecraft.factions.entity.migrator.MigratorMConf002CleanInactivity import com.massivecraft.factions.entity.migrator.MigratorMConf003CleanInactivity; import com.massivecraft.factions.entity.migrator.MigratorMConf004Rank; import com.massivecraft.factions.entity.migrator.MigratorMConf005Warps; +import com.massivecraft.factions.entity.migrator.MigratorMPerm001Warps; import com.massivecraft.factions.entity.migrator.MigratorMPlayer001Ranks; import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.integration.V18.IntegrationV18; @@ -147,6 +148,7 @@ public class Factions extends MassivePlugin MigratorMConf003CleanInactivity.class, MigratorMConf004Rank.class, MigratorMConf005Warps.class, + MigratorMPerm001Warps.class, MigratorMPlayer001Ranks.class ); } diff --git a/src/com/massivecraft/factions/cmd/type/TypeEntityInternalFaction.java b/src/com/massivecraft/factions/cmd/type/TypeEntityInternalFaction.java index 5e8ee7d7..ccee4da4 100644 --- a/src/com/massivecraft/factions/cmd/type/TypeEntityInternalFaction.java +++ b/src/com/massivecraft/factions/cmd/type/TypeEntityInternalFaction.java @@ -1,12 +1,15 @@ package com.massivecraft.factions.cmd.type; import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.entity.MPlayer; +import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.command.type.TypeAbstractChoice; import com.massivecraft.massivecore.store.EntityInternal; import org.bukkit.command.CommandSender; import java.util.Collection; import java.util.Collections; +import java.util.Set; public abstract class TypeEntityInternalFaction> extends TypeAbstractChoice { @@ -53,4 +56,25 @@ public abstract class TypeEntityInternalFaction> ext else return super.isValid(arg, sender); } + @Override + public Collection getTabList(CommandSender sender, String arg) + { + if (this.getFaction() != null) return super.getTabList(sender, arg); + + // Default to tab list for the sender + Faction faction = MPlayer.get(sender).getFaction(); + + // Create + Set ret = new MassiveSet<>(); + + // Fill + for (E value : this.getAll(faction)) + { + ret.addAll(this.createTabs(value)); + } + + // Return + return ret; + } + }