Fixed bug with gadgets and kings not being updated
This commit is contained in:
parent
49fd8d3941
commit
d88f183726
@ -1410,4 +1410,9 @@ public class GadgetManager extends MiniPlugin
|
||||
taunt.start(player);
|
||||
}
|
||||
|
||||
public CastleManager getCastleManager()
|
||||
{
|
||||
return _castleManager;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,16 @@
|
||||
package mineplex.core.gadget.gadgets.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
@ -20,16 +31,6 @@ import mineplex.core.preferences.Preference;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ItemBatGun extends ItemGadget
|
||||
{
|
||||
@ -94,6 +95,13 @@ public class ItemBatGun extends ItemGadget
|
||||
{
|
||||
if (!bat.isValid())
|
||||
continue;
|
||||
|
||||
if (Manager.getCastleManager().isInsideCastle(bat.getLocation()))
|
||||
{
|
||||
bat.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector rand = new Vector((Math.random() - 0.5)/3, (Math.random() - 0.5)/3, (Math.random() - 0.5)/3);
|
||||
bat.setVelocity(loc.getDirection().clone().multiply(0.5).add(rand));
|
||||
|
||||
|
@ -73,6 +73,9 @@ public class ItemFleshHook extends ItemGadget implements IThrown
|
||||
if (target instanceof ArmorStand)
|
||||
return;
|
||||
|
||||
if (Manager.getCastleManager().isInsideCastle(target.getLocation()))
|
||||
return;
|
||||
|
||||
//Pull
|
||||
UtilAction.velocity(target,
|
||||
UtilAlg.getTrajectory(target.getLocation(), player.getLocation()),
|
||||
|
@ -74,7 +74,7 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown
|
||||
{
|
||||
if (target != null)
|
||||
{
|
||||
if (!(target instanceof ArmorStand))
|
||||
if (!(target instanceof ArmorStand) && !Manager.getCastleManager().isInsideCastle(target.getLocation()))
|
||||
{
|
||||
//Push
|
||||
UtilAction.velocity(target,
|
||||
|
@ -67,7 +67,10 @@ public class ItemTNT extends ItemGadget
|
||||
{
|
||||
if (Manager.collideEvent(killer, this, player))
|
||||
continue;
|
||||
|
||||
|
||||
if (Manager.getCastleManager().isInsideCastle(player.getLocation()))
|
||||
continue;
|
||||
|
||||
double mult = players.get(player);
|
||||
|
||||
//Knockback
|
||||
|
@ -385,12 +385,7 @@ public class CastleManager extends MiniPlugin
|
||||
// Removes old king from the throne
|
||||
if (UtilAlg.inBoundingBox(oldKing.getKing().getLocation(), _castleLocationA, _castleLocationB))
|
||||
{
|
||||
Entity target = oldKing.getKing();
|
||||
while (target.getVehicle() != null)
|
||||
{
|
||||
target = target.getVehicle();
|
||||
}
|
||||
UtilAction.velocity(target, UtilAlg.getTrajectory(target.getLocation(), _removedKingLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
|
||||
oldKing.getKing().teleport(new Location(UtilWorld.getWorld("world"), 0, 78, -31));
|
||||
UtilPlayer.message(oldKing.getKing(), F.main("Kingdom", "You are no longer the king of that castle!"));
|
||||
}
|
||||
}
|
||||
@ -434,8 +429,23 @@ public class CastleManager extends MiniPlugin
|
||||
if (!isKing(player))
|
||||
return;
|
||||
|
||||
if (getKing().equals(getKing(player)))
|
||||
_king = null;
|
||||
|
||||
_kings.get(player).clearPeasants();
|
||||
_kings.remove(player);
|
||||
|
||||
if (_item != null)
|
||||
{
|
||||
if (_item.getPassenger() != null)
|
||||
{
|
||||
if (_item.getPassenger().equals(player))
|
||||
{
|
||||
player.leaveVehicle();
|
||||
}
|
||||
}
|
||||
}
|
||||
updateLobbyKing();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -486,6 +496,15 @@ public class CastleManager extends MiniPlugin
|
||||
if (!isPeasant(player))
|
||||
return;
|
||||
|
||||
if (getPeasant(player) != null)
|
||||
{
|
||||
Peasant peasant = getPeasant(player);
|
||||
if (peasant.getKing() != null)
|
||||
{
|
||||
peasant.getKing().removePeasant(peasant);
|
||||
peasant.removeKing();
|
||||
}
|
||||
}
|
||||
_peasants.remove(player);
|
||||
}
|
||||
|
||||
@ -585,4 +604,9 @@ public class CastleManager extends MiniPlugin
|
||||
location.getBlock().setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInsideCastle(Location location)
|
||||
{
|
||||
return UtilAlg.inBoundingBox(location, _castleLocationA, _castleLocationB);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user