mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-03 14:38:53 +00:00
.
This commit is contained in:
1 parent
7c553bb420
commit
f147ab5f8a
4 files changed
+60
-6
No files matched your search
Binary file not shown.
Binary file not shown.
@@ -336,6 +336,32 @@ public class ClickHandler implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadCannonsWithPowder(Player player) {
|
||||||
|
for (Entity ent : CrunchSiegeCore.TrackedStands.get(player.getUniqueId())) {
|
||||||
|
if (ent.isDead()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SiegeEquipment equipment = CrunchSiegeCore.equipment.get(ent.getUniqueId());
|
||||||
|
if (equipment != null) {
|
||||||
|
equipment.LoadFuel(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadCannonsWithProjectile(Player player, ItemStack projectile) {
|
||||||
|
for (Entity ent : CrunchSiegeCore.TrackedStands.get(player.getUniqueId())) {
|
||||||
|
if (ent.isDead()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SiegeEquipment equipment = CrunchSiegeCore.equipment.get(ent.getUniqueId());
|
||||||
|
if (equipment != null) {
|
||||||
|
equipment.LoadProjectile(player, projectile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerClickSign(PlayerInteractEvent event){
|
public void onPlayerClickSign(PlayerInteractEvent event){
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@@ -356,7 +382,24 @@ public class ClickHandler implements Listener {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(sign.getLine(0).equalsIgnoreCase( "[Load]")){
|
||||||
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
|
LoadCannonsWithPowder(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
//load proj
|
||||||
|
ItemStack itemInHand = player.getInventory().getItemInMainHand();
|
||||||
|
if (itemInHand == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LoadCannonsWithProjectile(player, player.getInventory().getItemInMainHand());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(sign.getLine(0).equalsIgnoreCase( "[Aim]")){
|
if(sign.getLine(0).equalsIgnoreCase( "[Aim]")){
|
||||||
if (!CrunchSiegeCore.TrackedStands.containsKey(player.getUniqueId())) {
|
if (!CrunchSiegeCore.TrackedStands.containsKey(player.getUniqueId())) {
|
||||||
return;
|
return;
|
||||||
@@ -400,7 +443,6 @@ public class ClickHandler implements Listener {
|
|||||||
}
|
}
|
||||||
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) {
|
||||||
player.sendMessage(s.trim());
|
|
||||||
temp.add(UUID.fromString(s.trim()));
|
temp.add(UUID.fromString(s.trim()));
|
||||||
}
|
}
|
||||||
for (UUID Id : temp) {
|
for (UUID Id : temp) {
|
||||||
@@ -430,10 +472,7 @@ public class ClickHandler implements Listener {
|
|||||||
if (CrunchSiegeCore.equipment.containsKey(entity.getUniqueId())) {
|
if (CrunchSiegeCore.equipment.containsKey(entity.getUniqueId())) {
|
||||||
SiegeEquipment equipment = CrunchSiegeCore.equipment.get(entity.getUniqueId());
|
SiegeEquipment equipment = CrunchSiegeCore.equipment.get(entity.getUniqueId());
|
||||||
if (itemInHand.getType().equals(equipment.FuelMaterial)) {
|
if (itemInHand.getType().equals(equipment.FuelMaterial)) {
|
||||||
if (equipment.LoadFuel(player)) {
|
if (!equipment.LoadFuel(player)) {
|
||||||
player.sendMessage("Loaded " + equipment.AmmoHolder.LoadedFuel + "/" + equipment.MaxFuel);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage("Could not load powder.");
|
player.sendMessage("Could not load powder.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
AmmoHolder.LoadedFuel += 1;
|
AmmoHolder.LoadedFuel += 1;
|
||||||
SaveState();
|
SaveState();
|
||||||
player.getInventory().removeItem(fuelItem);
|
player.getInventory().removeItem(fuelItem);
|
||||||
|
player.sendMessage("Loaded " + this.AmmoHolder.LoadedFuel + "/" + this.MaxFuel);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -99,6 +100,20 @@ public class SiegeEquipment implements Cloneable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean LoadProjectile(Player player, ItemStack itemInHand) {
|
||||||
|
if (itemInHand.getAmount() <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.Projectiles.containsKey(itemInHand.getType()) && this.AmmoHolder.LoadedProjectile == 0){
|
||||||
|
this.AmmoHolder.LoadedProjectile = 1;
|
||||||
|
this.AmmoHolder.MaterialName = (Material) itemInHand.getType();
|
||||||
|
player.sendMessage("Adding projectile to cannon");
|
||||||
|
itemInHand.setAmount(itemInHand.getAmount() - 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void SaveState() {
|
public void SaveState() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user