Merge pull request 'Add Repeater, Comparator and Lectern to interact method' (#398) from psirobot-ai into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #398 Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
4655dbe21b
@ -35,10 +35,13 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Note;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Lectern;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Openable;
|
||||
import org.bukkit.block.data.Powerable;
|
||||
import org.bukkit.block.data.type.Comparator;
|
||||
import org.bukkit.block.data.type.NoteBlock;
|
||||
import org.bukkit.block.data.type.Repeater;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -170,6 +173,27 @@ public abstract class AI {
|
||||
});
|
||||
}
|
||||
|
||||
protected void interact(Vector pos, int n) {
|
||||
queue.add(new Action(1) {
|
||||
@Override
|
||||
public void run() {
|
||||
Location location = translate(pos, true);
|
||||
if (interactionDistanceViolation(location))
|
||||
return;
|
||||
Block block = location.getBlock();
|
||||
BlockData data = block.getBlockData();
|
||||
if (data instanceof Repeater) {
|
||||
Repeater repeater = (Repeater) data;
|
||||
repeater.setDelay(n);
|
||||
} else if (data instanceof Lectern) {
|
||||
Lectern lectern = (Lectern) data;
|
||||
lectern.setPage(n);
|
||||
}
|
||||
block.setBlockData(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void move(Vector pos) {
|
||||
queue.add(new Action(2) {
|
||||
@Override
|
||||
@ -200,6 +224,9 @@ public abstract class AI {
|
||||
} else if (data instanceof Openable) {
|
||||
Openable openable = (Openable) data;
|
||||
openable.setOpen(!openable.isOpen());
|
||||
} else if (data instanceof Comparator) {
|
||||
Comparator comparator = (Comparator) data;
|
||||
comparator.setMode(Comparator.Mode.values()[1 - comparator.getMode().ordinal()]);
|
||||
} else if (data instanceof Powerable) {
|
||||
Material type = block.getType();
|
||||
Powerable powerable = (Powerable) data;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren