moved some stuff around and slight changes

This commit is contained in:
NewGarbo 2016-02-03 17:02:06 +00:00
parent 38cae1e3a2
commit 0cb557d922
16 changed files with 93 additions and 66 deletions

View File

@ -11,10 +11,10 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.siege.cannon.Cannon;
import mineplex.game.clans.clans.siege.catapult.Catapult;
import mineplex.game.clans.clans.siege.outpost.CommandSiegeSupplies;
import mineplex.game.clans.clans.siege.outpost.OutpostManager;
import mineplex.game.clans.clans.siege.weapon.Cannon;
import mineplex.game.clans.clans.siege.weapon.Catapult;
public class SiegeManager extends MiniPlugin
{

View File

@ -7,8 +7,8 @@ import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.siege.cannon.Cannon;
import mineplex.game.clans.clans.siege.catapult.Catapult;
import mineplex.game.clans.clans.siege.weapon.Cannon;
import mineplex.game.clans.clans.siege.weapon.Catapult;
public class CommandSiegeSupplies extends CommandBase<OutpostManager>
{

View File

@ -48,7 +48,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansBlacklist;
import mineplex.game.clans.clans.siege.cannon.Cannon;
import mineplex.game.clans.clans.siege.weapon.Cannon;
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
import mineplex.game.clans.core.repository.ClanTerritory;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;

View File

@ -1,7 +0,0 @@
package mineplex.game.clans.clans.siege.weapon;
public enum AccessType
{
RCLICK_BB,
LCLICK_BB,
}

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.siege.cannon;
package mineplex.game.clans.clans.siege.weapon;
import org.bukkit.Location;
import org.bukkit.Material;
@ -22,12 +22,11 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.siege.weapon.AccessRule;
import mineplex.game.clans.clans.siege.weapon.AccessType;
import mineplex.game.clans.clans.siege.weapon.ProjectileAttributes;
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
import mineplex.game.clans.clans.siege.weapon.WeaponProjectile;
import mineplex.game.clans.clans.siege.weapon.WeaponStateInfo;
import mineplex.game.clans.clans.siege.weapon.projectile.ProjectileAttributes;
import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
import mineplex.game.clans.clans.siege.weapon.util.AccessRule;
import mineplex.game.clans.clans.siege.weapon.util.AccessType;
import mineplex.game.clans.clans.siege.weapon.util.WeaponStateInfo;
public class Cannon extends SiegeWeapon
{
@ -101,8 +100,6 @@ public class Cannon extends SiegeWeapon
return !player.equals(getRider());
}));
System.out.println("Cannon initialized.");
}
private void loadEntities()

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.siege.catapult;
package mineplex.game.clans.clans.siege.weapon;
import org.bukkit.Location;
import org.bukkit.Material;
@ -22,12 +22,11 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.siege.weapon.AccessRule;
import mineplex.game.clans.clans.siege.weapon.AccessType;
import mineplex.game.clans.clans.siege.weapon.ProjectileAttributes;
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
import mineplex.game.clans.clans.siege.weapon.WeaponProjectile;
import mineplex.game.clans.clans.siege.weapon.WeaponStateInfo;
import mineplex.game.clans.clans.siege.weapon.projectile.ProjectileAttributes;
import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
import mineplex.game.clans.clans.siege.weapon.util.AccessRule;
import mineplex.game.clans.clans.siege.weapon.util.AccessType;
import mineplex.game.clans.clans.siege.weapon.util.WeaponStateInfo;
public class Catapult extends SiegeWeapon
{
@ -56,7 +55,7 @@ public class Catapult extends SiegeWeapon
setAmmunitionSlot(4);
setMaximumAmmunitionPerSlot(1);
setProjectileAttributes(new ProjectileAttributes().setPrimedTnt().setDoCrater().craterSize(3).craterChanceOfAir(1.5d));
setProjectileAttributes(new ProjectileAttributes().setFallingBlock().setFallingBlockType(Material.TNT).setDoCrater().craterSize(3).craterChanceOfAir(1.3d));
setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> {
if (!_owner.isMember(player))
@ -102,8 +101,6 @@ public class Catapult extends SiegeWeapon
return !player.equals(getRider());
}));
System.out.println("Cannon initialized.");
}
private void loadEntities()
@ -141,6 +138,12 @@ public class Catapult extends SiegeWeapon
addEntity(armorStand, "WEAPON");
}
@Override
public float Rotate(float nextYaw)
{
return nextYaw + 180;
}
@Override
public void Fire(WeaponProjectile projectile)
{

View File

@ -37,7 +37,12 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.siege.BarrierCollisionBox;
import mineplex.game.clans.clans.siege.weapon.projectile.ProjectileAttributes;
import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
import mineplex.game.clans.clans.siege.weapon.util.AccessRule;
import mineplex.game.clans.clans.siege.weapon.util.AccessType;
import mineplex.game.clans.clans.siege.weapon.util.BarrierCollisionBox;
import mineplex.game.clans.clans.siege.weapon.util.WeaponStateInfo;
public abstract class SiegeWeapon implements Listener
{
@ -83,12 +88,13 @@ public abstract class SiegeWeapon implements Listener
private ProjectileAttributes _projectileAttributes;
private WeaponProjectile _projectile;
private long _lastRight = -1;
private long _lastLeft = -1;
protected long _lastFired;
public SiegeWeapon(Location location, double maxHealth, String name, ClanInfo owner, ClansManager clansManager)
{
System.out.println("Siege Weapon initializing.");
_location = location;
_name = name;
_health = _maxHealth = maxHealth;
@ -106,6 +112,11 @@ public abstract class SiegeWeapon implements Listener
_clans = clansManager;
}
public ClansManager getClans()
{
return _clans;
}
protected void damage(Player player)
{
@ -169,7 +180,7 @@ public abstract class SiegeWeapon implements Listener
if (dif > 180) dif -= 360;
if (dif < -180) dif += 360;
double yaw = standYaw + Math.min(dif / 20.f, 4f);
double yaw = Rotate((float) ((float)standYaw + Math.min(dif / 20.f, 4f)));
armorStand.setHeadPose(new EulerAngle(0, Math.toRadians(yaw), 0));
}
@ -179,9 +190,6 @@ public abstract class SiegeWeapon implements Listener
protected boolean canBeFired()
{
System.out.println(getPowerLevel());
System.out.println(getAmmunition());
return getPowerLevel() > 0 && getAmmunition() > 0 && _projectile == null;
}
@ -192,7 +200,6 @@ public abstract class SiegeWeapon implements Listener
private void fire(Player player)
{
System.out.println("Firing siege weapon...");
_lastFired = System.currentTimeMillis();
double[] vel = getProjectileVelocity();
@ -270,8 +277,6 @@ public abstract class SiegeWeapon implements Listener
power += _inventory.getItem(slot).getAmount();
}
System.out.println("Power: " + power);
return power / 4;
}
@ -320,7 +325,6 @@ public abstract class SiegeWeapon implements Listener
private void handleMount(Player player)
{
System.out.println("handling mount");
getEntity("PLAYERMOUNT").setPassenger(player);
OnMount(player);
}
@ -332,9 +336,21 @@ public abstract class SiegeWeapon implements Listener
private void handleRightClick(Player player)
{
RightClick(player);
if (_lastRight == -1)
{
_lastRight = System.currentTimeMillis();
}
else
{
if (System.currentTimeMillis() - _lastRight <= 40)
{
return;
}
}
System.out.println("handling right click");
_lastRight = System.currentTimeMillis();
RightClick(player);
if (_isRideable && _mountAccess.allow(AccessType.RCLICK_BB, player))
{
@ -356,6 +372,20 @@ public abstract class SiegeWeapon implements Listener
private void handleLeftClick(Player player)
{
if (_lastLeft == -1)
{
_lastLeft = System.currentTimeMillis();
}
else
{
if (System.currentTimeMillis() - _lastLeft <= 40)
{
return;
}
}
_lastLeft = System.currentTimeMillis();
LeftClick(player);
if (_isRideable && _mountAccess.allow(AccessType.LCLICK_BB, player))
@ -412,6 +442,11 @@ public abstract class SiegeWeapon implements Listener
{
}
protected float Rotate(float yaw)
{
return yaw;
}
// Entity Management
protected final void addEntity(Entity entity, String uniqueName)
@ -466,8 +501,6 @@ public abstract class SiegeWeapon implements Listener
{
Validate.isTrue(_registeredStates.containsKey(state), "Provided state has not yet been registered.");
System.out.println("Updating siege weapon state");
((ArmorStand) getEntity("WEAPON")).setHelmet(new ItemStack(_registeredStates.get(state).getType(), 1, (short) 0, (byte) _registeredStates.get(state).getData()));
_currentState = state;
@ -527,14 +560,14 @@ public abstract class SiegeWeapon implements Listener
{
if (getRider() != null)
{
getRider().getInventory().addItem(new ItemStack(Material.TNT, item.getAmount() - _maxAmmunition));
getRider().getInventory().addItem(new ItemStack(_ammunitionType, item.getAmount() - _maxAmmunition));
}
else
{
_location.getWorld().dropItem(_location, item);
}
_inventory.setItem(slot, new ItemStack(Material.TNT, _maxAmmunition));
_inventory.setItem(slot, new ItemStack(_ammunitionType, _maxAmmunition));
}
}
}

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.siege.weapon;
package mineplex.game.clans.clans.siege.weapon.projectile;
import java.util.ArrayList;
import java.util.HashMap;
@ -23,6 +23,7 @@ import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
public class Crater implements Listener
{
@ -52,7 +53,7 @@ public class Crater implements Listener
_airChance = airChance;
_fire = doFire;
UtilServer.getPluginManager().registerEvents(this, _weapon._clans.getPlugin());
UtilServer.getPluginManager().registerEvents(this, _weapon.getClans().getPlugin());
createExplosion();
}

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.siege.weapon;
package mineplex.game.clans.clans.siege.weapon.projectile;
import org.bukkit.Location;
import org.bukkit.Material;

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.siege.weapon;
package mineplex.game.clans.clans.siege.weapon.projectile;
import org.bukkit.Material;

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.siege.weapon;
package mineplex.game.clans.clans.siege.weapon.projectile;
public enum ProjectileType
{

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.siege.weapon;
package mineplex.game.clans.clans.siege.weapon.projectile;
import org.bukkit.Location;
import org.bukkit.Sound;
@ -19,6 +19,7 @@ import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
public class WeaponProjectile implements Listener
{
@ -43,11 +44,9 @@ public class WeaponProjectile implements Listener
_yVel = yVel;
_xMulti = xMulti;
UtilServer.getPluginManager().registerEvents(this, weapon._clans.getPlugin());
UtilServer.getPluginManager().registerEvents(this, weapon.getClans().getPlugin());
spawn();
System.out.println("New Projectile");
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -168,9 +167,5 @@ public class WeaponProjectile implements Listener
tnt.setVelocity(velocity);
}
else
{
System.out.println("==== SIEGE WEAPON PROJECTILE ATTRIBUTES DOES NOT SPECIFY ENTITY TYPE ====");
}
}
}

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.siege.weapon;
package mineplex.game.clans.clans.siege.weapon.util;
import java.util.function.Predicate;

View File

@ -0,0 +1,7 @@
package mineplex.game.clans.clans.siege.weapon.util;
public enum AccessType
{
RCLICK_BB,
LCLICK_BB,
}

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.siege;
package mineplex.game.clans.clans.siege.weapon.util;
import java.util.ArrayList;
import java.util.Arrays;
@ -123,8 +123,6 @@ public class BarrierCollisionBox implements Listener
{
for (Location other : _collisionBlocks)
{
System.out.println(other + " : " + location);
if (other.equals(location))
{
return true;

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.siege.weapon;
package mineplex.game.clans.clans.siege.weapon.util;
import org.bukkit.Material;