mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-01 14:08:08 +01:00
Implement new selector
This commit is contained in:
parent
547df2487f
commit
959b8b774f
@ -14,6 +14,7 @@ import net.citizensnpcs.api.event.CitizensReloadEvent;
|
||||
import net.citizensnpcs.api.exception.NPCLoadException;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.npc.NPCSelector;
|
||||
import net.citizensnpcs.api.scripting.EventRegistrar;
|
||||
import net.citizensnpcs.api.scripting.ObjectProvider;
|
||||
import net.citizensnpcs.api.scripting.ScriptCompiler;
|
||||
@ -36,7 +37,7 @@ import net.citizensnpcs.command.exception.WrappedCommandException;
|
||||
import net.citizensnpcs.editor.Editor;
|
||||
import net.citizensnpcs.npc.CitizensNPCRegistry;
|
||||
import net.citizensnpcs.npc.CitizensTraitFactory;
|
||||
import net.citizensnpcs.npc.NPCSelector;
|
||||
import net.citizensnpcs.npc.CitizensNPCSelector;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.Messaging;
|
||||
import net.citizensnpcs.util.StringHelper;
|
||||
@ -120,6 +121,10 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
return new File(getDataFolder(), "scripts");
|
||||
}
|
||||
|
||||
public NPCSelector getSelector() {
|
||||
return selector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraitFactory getTraitFactory() {
|
||||
return traitFactory;
|
||||
@ -211,7 +216,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
|
||||
npcRegistry = new CitizensNPCRegistry(saves);
|
||||
traitFactory = new CitizensTraitFactory();
|
||||
selector = new NPCSelector(this);
|
||||
selector = new CitizensNPCSelector(this);
|
||||
CitizensAPI.setImplementation(this);
|
||||
|
||||
getServer().getPluginManager().registerEvents(new EventListen(), this);
|
||||
|
@ -9,6 +9,7 @@ import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.event.PlayerCreateNPCEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.npc.NPCSelector;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.trait.MobType;
|
||||
import net.citizensnpcs.api.trait.trait.Owner;
|
||||
@ -21,7 +22,6 @@ import net.citizensnpcs.command.Requirements;
|
||||
import net.citizensnpcs.command.exception.CommandException;
|
||||
import net.citizensnpcs.command.exception.NoPermissionsException;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.NPCSelector;
|
||||
import net.citizensnpcs.trait.Age;
|
||||
import net.citizensnpcs.trait.Behaviour;
|
||||
import net.citizensnpcs.trait.Controllable;
|
||||
|
@ -8,6 +8,7 @@ import net.citizensnpcs.api.event.NPCRemoveEvent;
|
||||
import net.citizensnpcs.api.event.NPCRightClickEvent;
|
||||
import net.citizensnpcs.api.event.NPCSelectEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCSelector;
|
||||
import net.citizensnpcs.api.trait.trait.Owner;
|
||||
import net.citizensnpcs.editor.Editor;
|
||||
import net.citizensnpcs.util.Messaging;
|
||||
@ -24,15 +25,16 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class NPCSelector implements Listener {
|
||||
public class CitizensNPCSelector implements Listener, NPCSelector {
|
||||
private int consoleSelectedNPC = -1;
|
||||
private final Plugin plugin;
|
||||
|
||||
public NPCSelector(Plugin plugin) {
|
||||
public CitizensNPCSelector(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getSelected(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
List<MetadataValue> metadata = ((Player) sender).getMetadata("selected");
|
||||
@ -81,6 +83,7 @@ public class NPCSelector implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void select(CommandSender sender, NPC npc) {
|
||||
// Remove existing selection if any
|
||||
List<Object> selectors = npc.data().get("selectors", Lists.newArrayList());
|
Loading…
Reference in New Issue
Block a user