Merge remote-tracking branch 'origin/clans/beta' into clans/beta
This commit is contained in:
commit
628604c353
@ -42,6 +42,7 @@ public class SiegeManager extends MiniPlugin
|
|||||||
public static SiegeManager Instance;
|
public static SiegeManager Instance;
|
||||||
|
|
||||||
public NautHashMap<Integer, SiegeWeapon> LiveSiegeWeapons = new NautHashMap<>();
|
public NautHashMap<Integer, SiegeWeapon> LiveSiegeWeapons = new NautHashMap<>();
|
||||||
|
public NautHashMap<Integer, SiegeWeapon> UnsyncedSiegeWeapons = new NautHashMap<>();
|
||||||
|
|
||||||
private Gson _gson;
|
private Gson _gson;
|
||||||
|
|
||||||
@ -174,6 +175,9 @@ public class SiegeManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
final SiegeWeaponToken token = weapon.toToken();
|
final SiegeWeaponToken token = weapon.toToken();
|
||||||
|
|
||||||
|
if (UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)))
|
||||||
|
continue;
|
||||||
|
|
||||||
queue.push(() -> {
|
queue.push(() -> {
|
||||||
_repository.updateWeapon(token);
|
_repository.updateWeapon(token);
|
||||||
});
|
});
|
||||||
@ -190,7 +194,7 @@ public class SiegeManager extends MiniPlugin
|
|||||||
|
|
||||||
_repository.getWeaponsByServer(_clansManager.getServerId(), tokens -> {
|
_repository.getWeaponsByServer(_clansManager.getServerId(), tokens -> {
|
||||||
tokens.forEach(token -> {
|
tokens.forEach(token -> {
|
||||||
if (!LiveSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)))
|
if (!LiveSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)) && !UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)))
|
||||||
{
|
{
|
||||||
System.out.println("LiveSiegeWeapons no longer contains old weapon " + token.UniqueId + ", deleting.");
|
System.out.println("LiveSiegeWeapons no longer contains old weapon " + token.UniqueId + ", deleting.");
|
||||||
_repository.deleteWeapon(token.UniqueId);
|
_repository.deleteWeapon(token.UniqueId);
|
||||||
@ -264,9 +268,14 @@ public class SiegeManager extends MiniPlugin
|
|||||||
|
|
||||||
public Cannon spawnCannon(Player player, Location location)
|
public Cannon spawnCannon(Player player, Location location)
|
||||||
{
|
{
|
||||||
Cannon cannon = new Cannon(location, _clansManager.getClan(player), this);
|
return spawnCannon(player, location, true);
|
||||||
|
}
|
||||||
|
|
||||||
LiveSiegeWeapons.put(Integer.valueOf(cannon.getUniqueId()), cannon);
|
public Cannon spawnCannon(Player player, Location location, boolean syncWithDb)
|
||||||
|
{
|
||||||
|
Cannon cannon = new Cannon(location, _clansManager.getClan(player), this, syncWithDb);
|
||||||
|
|
||||||
|
UnsyncedSiegeWeapons.put(Integer.valueOf(cannon.getUniqueId()), cannon);
|
||||||
|
|
||||||
return cannon;
|
return cannon;
|
||||||
}
|
}
|
||||||
@ -274,8 +283,10 @@ public class SiegeManager extends MiniPlugin
|
|||||||
public void dead(SiegeWeapon weapon)
|
public void dead(SiegeWeapon weapon)
|
||||||
{
|
{
|
||||||
LiveSiegeWeapons.remove(Integer.valueOf(weapon.getUniqueId()));
|
LiveSiegeWeapons.remove(Integer.valueOf(weapon.getUniqueId()));
|
||||||
|
SiegeWeapon unsynced = UnsyncedSiegeWeapons.remove(Integer.valueOf(weapon.getUniqueId()));
|
||||||
|
|
||||||
_repository.deleteWeapon(weapon.getUniqueId());
|
if (unsynced == null)
|
||||||
|
_repository.deleteWeapon(weapon.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public OutpostManager getOutpostManager()
|
public OutpostManager getOutpostManager()
|
||||||
|
@ -122,10 +122,12 @@ public class Cannon extends SiegeWeapon
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cannon(Location location, ClanInfo clan, SiegeManager siegeManager)
|
public Cannon(Location location, ClanInfo clan, SiegeManager siegeManager, boolean syncWithDb)
|
||||||
{
|
{
|
||||||
super(2, location, 1400, "Cannon", clan, clan.Clans, siegeManager);
|
super(2, location, 1400, "Cannon", clan, clan.Clans, siegeManager);
|
||||||
|
|
||||||
|
_syncWithDb = syncWithDb;
|
||||||
|
|
||||||
setBoundingBox(1);
|
setBoundingBox(1);
|
||||||
|
|
||||||
setStateInfo("Unloaded", new WeaponStateInfo(Material.SPONGE, (byte) 1));
|
setStateInfo("Unloaded", new WeaponStateInfo(Material.SPONGE, (byte) 1));
|
||||||
|
@ -112,6 +112,8 @@ public abstract class SiegeWeapon implements Listener
|
|||||||
protected final NautHashMap<String, WeaponStateInfo> _registeredStates;
|
protected final NautHashMap<String, WeaponStateInfo> _registeredStates;
|
||||||
protected final NautHashMap<String, Entity> _entityMapping;
|
protected final NautHashMap<String, Entity> _entityMapping;
|
||||||
|
|
||||||
|
protected boolean _syncWithDb;
|
||||||
|
|
||||||
// Customizability
|
// Customizability
|
||||||
private double[] _forcedVelocity;
|
private double[] _forcedVelocity;
|
||||||
|
|
||||||
@ -202,7 +204,8 @@ public abstract class SiegeWeapon implements Listener
|
|||||||
|
|
||||||
protected void insert()
|
protected void insert()
|
||||||
{
|
{
|
||||||
_siegeManager.getRepository().insertWeapon(toToken());
|
if (_syncWithDb)
|
||||||
|
_siegeManager.getRepository().insertWeapon(toToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int calculateDamage(Player player)
|
protected int calculateDamage(Player player)
|
||||||
@ -882,6 +885,11 @@ public abstract class SiegeWeapon implements Listener
|
|||||||
return _currentState;
|
return _currentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final boolean shouldSyncWithDb()
|
||||||
|
{
|
||||||
|
return _syncWithDb;
|
||||||
|
}
|
||||||
|
|
||||||
public SiegeWeaponToken toToken()
|
public SiegeWeaponToken toToken()
|
||||||
{
|
{
|
||||||
SiegeWeaponToken token = new SiegeWeaponToken();
|
SiegeWeaponToken token = new SiegeWeaponToken();
|
||||||
|
@ -36,9 +36,9 @@ public class AttackEnemyGoal extends ObjectiveGoal<ClanObjective>
|
|||||||
{
|
{
|
||||||
UtilInv.give(player, Material.TNT);
|
UtilInv.give(player, Material.TNT);
|
||||||
|
|
||||||
_cannon = SiegeManager.Instance.spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON));
|
_cannon = SiegeManager.Instance.spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON), false);
|
||||||
|
|
||||||
_cannon.SetForcedVelocity(0.4, -2.45);
|
_cannon.SetForcedVelocity(0.4, 2.45);
|
||||||
}
|
}
|
||||||
|
|
||||||
// use this event for figuring out if the cannon hit the base
|
// use this event for figuring out if the cannon hit the base
|
||||||
|
Loading…
Reference in New Issue
Block a user