mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-26 04:35:50 +01:00
Set all connected command block sender selected
This commit is contained in:
parent
b8a608ec5c
commit
ef49f0762e
@ -133,8 +133,37 @@ public class NPCSelector implements Listener, net.citizensnpcs.api.npc.NPCSelect
|
|||||||
Editor.leave(player);
|
Editor.leave(player);
|
||||||
} else if (sender instanceof BlockCommandSender) {
|
} else if (sender instanceof BlockCommandSender) {
|
||||||
Block block = ((BlockCommandSender) sender).getBlock();
|
Block block = ((BlockCommandSender) sender).getBlock();
|
||||||
setMetadata(npc, block);
|
if (SUPPORT_BLOCK_STATE == null) {
|
||||||
selectors.add(toName(block));
|
try {
|
||||||
|
block.getState();
|
||||||
|
SUPPORT_BLOCK_STATE = true;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
SUPPORT_BLOCK_STATE = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (block != null) {
|
||||||
|
setMetadata(npc, block);
|
||||||
|
selectors.add(toName(block));
|
||||||
|
if (SUPPORT_BLOCK_STATE) {
|
||||||
|
if (block.getState() instanceof org.bukkit.block.data.Directional) {
|
||||||
|
block = block.getRelative(((org.bukkit.block.data.Directional) block.getState()).getFacing());
|
||||||
|
if (!(block.getState() instanceof org.bukkit.block.CommandBlock)) {
|
||||||
|
block = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
block = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (block.getBlockData() instanceof org.bukkit.material.Directional) {
|
||||||
|
block = block.getRelative(((org.bukkit.material.Directional) block.getState()).getFacing());
|
||||||
|
if (!(block.getBlockData() instanceof org.bukkit.block.data.type.CommandBlock)) {
|
||||||
|
block = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
block = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (sender instanceof ConsoleCommandSender) {
|
} else if (sender instanceof ConsoleCommandSender) {
|
||||||
consoleSelectedNPC = npc.getUniqueId();
|
consoleSelectedNPC = npc.getUniqueId();
|
||||||
selectors.add("console");
|
selectors.add("console");
|
||||||
@ -154,4 +183,6 @@ public class NPCSelector implements Listener, net.citizensnpcs.api.npc.NPCSelect
|
|||||||
return '@' + block.getWorld().getName() + ":" + Integer.toString(block.getX()) + ":"
|
return '@' + block.getWorld().getName() + ":" + Integer.toString(block.getX()) + ":"
|
||||||
+ Integer.toString(block.getY()) + ":" + Integer.toString(block.getZ());
|
+ Integer.toString(block.getY()) + ":" + Integer.toString(block.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Boolean SUPPORT_BLOCK_STATE = null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user