SteamWar/FightSystem
Archiviert
13
1

Add Repeater, Comparator and Lectern to interact method
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
PsiRobot 2023-09-02 15:20:33 +00:00
Ursprung 891a26cc12
Commit 071b76a4ce

Datei anzeigen

@ -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;
@ -217,8 +244,6 @@ public abstract class AI {
block.setBlockData(powerable);
}, type.name().endsWith("STONE_BUTTON") ? 20 : 30);
}
powerable.setPowered(!isPowered);
}
block.setBlockData(data);
}