mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-04 14:38:53 +00:00
sequence firing and persistent data
This commit is contained in:
1 parent
55ce0674db
commit
39c32c4266
8 files changed
+32
-14
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -65,7 +65,9 @@ public class ClickHandler implements Listener {
|
|||||||
|
|
||||||
|
|
||||||
public void Shoot(Player player) {
|
public void Shoot(Player player) {
|
||||||
|
int delay = 6;
|
||||||
for (Entity ent : CrunchSiegeCore.TrackedStands.get(player.getUniqueId())){{
|
for (Entity ent : CrunchSiegeCore.TrackedStands.get(player.getUniqueId())){{
|
||||||
|
|
||||||
if (ent == null || ent.isDead()) {
|
if (ent == null || ent.isDead()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -86,9 +88,10 @@ public class ClickHandler implements Listener {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage("Cannot fire, missing cobblestone, requires 10 per shot");
|
player.sendMessage("Cannot fire, missing cobblestone, requires 10 per shot");
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
siege.Fire(player);
|
siege.Fire(player, delay);
|
||||||
|
delay += 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -176,19 +179,16 @@ public class ClickHandler implements Listener {
|
|||||||
public void onPlayerClickSign(PlayerInteractEvent event){
|
public void onPlayerClickSign(PlayerInteractEvent event){
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
if(event.getClickedBlock() != null && event.getClickedBlock().getType().toString().contains("SIGN")){
|
if(event.getClickedBlock() != null && event.getClickedBlock().getType().toString().contains("SIGN")){
|
||||||
if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
|
|
||||||
Sign sign = (Sign) event.getClickedBlock().getState();
|
Sign sign = (Sign) event.getClickedBlock().getState();
|
||||||
//^^ .getState(); really important
|
|
||||||
if(sign.getLine(0).equalsIgnoreCase( "[Cannon]")){
|
if(sign.getLine(0).equalsIgnoreCase( "[Cannon]")){
|
||||||
|
if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
|
||||||
NamespacedKey key = new NamespacedKey(CrunchSiegeCore.plugin, "cannons");
|
NamespacedKey key = new NamespacedKey(CrunchSiegeCore.plugin, "cannons");
|
||||||
TileState state = (TileState) sign.getBlock().getState();
|
TileState state = (TileState) sign.getBlock().getState();
|
||||||
|
CrunchSiegeCore.TrackedStands.remove(p.getUniqueId());
|
||||||
List<UUID> temp = new ArrayList<UUID>();
|
List<UUID> temp = new ArrayList<UUID>();
|
||||||
event.getPlayer().sendMessage("1");
|
|
||||||
if (!state.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
|
if (!state.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.getPlayer().sendMessage("2");
|
|
||||||
String[] split = state.getPersistentDataContainer().get(key, PersistentDataType.STRING).replace("[", "").replace("]", "").split(",");
|
String[] split = state.getPersistentDataContainer().get(key, PersistentDataType.STRING).replace("[", "").replace("]", "").split(",");
|
||||||
for (String s : split) {
|
for (String s : split) {
|
||||||
p.sendMessage(s.trim());
|
p.sendMessage(s.trim());
|
||||||
@@ -203,6 +203,10 @@ public class ClickHandler implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
|
CrunchSiegeCore.TrackedStands.remove(p.getUniqueId());
|
||||||
|
p.sendMessage("Releasing the cannons!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,8 +156,8 @@ public class CrunchSiegeCore extends JavaPlugin {
|
|||||||
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
|
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
|
||||||
stand.addEquipmentLock(EquipmentSlot.FEET, LockType.ADDING_OR_CHANGING);
|
stand.addEquipmentLock(EquipmentSlot.FEET, LockType.ADDING_OR_CHANGING);
|
||||||
ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1));
|
ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1));
|
||||||
// stand.setSmall(true);
|
stand.setSmall(true);
|
||||||
// stand.setVisible(true);
|
stand.setVisible(true);
|
||||||
//stand.setSmall(true);
|
//stand.setSmall(true);
|
||||||
ent.getEquipment().setHelmet(item);
|
ent.getEquipment().setHelmet(item);
|
||||||
if (TrackedStands.containsKey(player.getUniqueId())) {
|
if (TrackedStands.containsKey(player.getUniqueId())) {
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public class RotationHandler implements Listener {
|
|||||||
|
|
||||||
if (equipment.RotateUpDown) {
|
if (equipment.RotateUpDown) {
|
||||||
stand.setHeadPose(new EulerAngle(player.getLocation().getDirection().getY()*(-1),0,0));
|
stand.setHeadPose(new EulerAngle(player.getLocation().getDirection().getY()*(-1),0,0));
|
||||||
|
loc.setPitch(player.getLocation().getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class SiegeEquipment implements Cloneable {
|
public class SiegeEquipment implements Cloneable {
|
||||||
|
|
||||||
@@ -30,6 +32,9 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
|
|
||||||
public String WorldName;
|
public String WorldName;
|
||||||
|
|
||||||
|
public int XOffset = 5;
|
||||||
|
public int YOffset = 0;
|
||||||
|
|
||||||
public int FuseTime;
|
public int FuseTime;
|
||||||
public double Velocity = 3;
|
public double Velocity = 3;
|
||||||
public long NextShotTime = System.currentTimeMillis();
|
public long NextShotTime = System.currentTimeMillis();
|
||||||
@@ -41,7 +46,7 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
public Location location;
|
public Location location;
|
||||||
public int ModelNumberToFireAt;
|
public int ModelNumberToFireAt;
|
||||||
public Boolean CycleThroughModelsBeforeFiring = false;
|
public Boolean CycleThroughModelsBeforeFiring = false;
|
||||||
public Boolean RotateSideways = true;
|
public Boolean RotateSideways = false;
|
||||||
public Boolean RotateUpDown = true;
|
public Boolean RotateUpDown = true;
|
||||||
|
|
||||||
public Boolean HasFired = false;
|
public Boolean HasFired = false;
|
||||||
@@ -61,9 +66,11 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
EntityId = id;
|
EntityId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Fire(Player player) {
|
public void Fire(Player player, int delay) {
|
||||||
LivingEntity living = (LivingEntity) Entity;
|
LivingEntity living = (LivingEntity) Entity;
|
||||||
Location loc = living.getEyeLocation();
|
Location loc = living.getEyeLocation();
|
||||||
|
Vector direction = Entity.getLocation().getDirection().multiply(XOffset);
|
||||||
|
loc.add(direction);
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
float randomVar = random.nextFloat() * (7 - -7) + -7;
|
float randomVar = random.nextFloat() * (7 - -7) + -7;
|
||||||
@@ -73,7 +80,7 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
this.NextShotTime = System.currentTimeMillis() + 6000;
|
this.NextShotTime = System.currentTimeMillis() + 6000;
|
||||||
player.sendMessage("Cannot fire for another " + CrunchSiegeCore.convertTime(this.NextShotTime - System.currentTimeMillis()));
|
player.sendMessage("Cannot fire for another " + CrunchSiegeCore.convertTime(this.NextShotTime - System.currentTimeMillis()));
|
||||||
this.WorldName = Entity.getWorld().getName();
|
this.WorldName = Entity.getWorld().getName();
|
||||||
Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_BAT_DEATH, 20, 2);
|
|
||||||
if (this.CycleThroughModelsBeforeFiring) {
|
if (this.CycleThroughModelsBeforeFiring) {
|
||||||
|
|
||||||
|
|
||||||
@@ -117,7 +124,7 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
|
|
||||||
ClickHandler.projectiles.put(tnt.getUniqueId(), this.projectile);
|
ClickHandler.projectiles.put(tnt.getUniqueId(), this.projectile);
|
||||||
tnt.setVelocity(loc.getDirection().multiply(this.Velocity));
|
tnt.setVelocity(loc.getDirection().multiply(this.Velocity));
|
||||||
|
Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_BAT_DEATH, 20, 2);
|
||||||
}
|
}
|
||||||
this.NextModelNumber += 1;
|
this.NextModelNumber += 1;
|
||||||
|
|
||||||
@@ -129,10 +136,16 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
}, 0, this.MillisecondsBetweenFiringStages);
|
}, 0, this.MillisecondsBetweenFiringStages);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL);
|
|
||||||
|
|
||||||
|
this.TaskNumber = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CrunchSiegeCore.plugin, () -> {
|
||||||
|
//player.sendMessage("task");
|
||||||
|
Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL);
|
||||||
ClickHandler.projectiles.put(tnt.getUniqueId(), this.projectile);
|
ClickHandler.projectiles.put(tnt.getUniqueId(), this.projectile);
|
||||||
tnt.setVelocity(loc.getDirection().multiply(this.Velocity));
|
tnt.setVelocity(loc.getDirection().multiply(this.Velocity));
|
||||||
|
Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_GENERIC_EXPLODE, 20, 2);
|
||||||
|
Bukkit.getServer().getWorld(this.WorldName).spawnParticle(Particle.SMOKE_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||||
|
}, delay);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user