Fix Wind Blade, Hyper Axe

This commit is contained in:
samczsun 2016-05-21 20:17:32 -04:00 committed by Sam Sun
parent 4ba3148df7
commit 2f993dbe66
5 changed files with 77 additions and 74 deletions

View File

@ -555,19 +555,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_classManager.GetRepository().SaveCustomBuild(activeBuild);
}
}
@EventHandler
public void onPlayerKick(PlayerKickEvent event)
{
// Players using wind blade should not get kicked
if (event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getItemMeta() != null && (C.cGold + "Wind Blade").equals(event.getPlayer().getItemInHand().getItemMeta().getDisplayName()))
{
if (event.getReason().contains("flying is not enabled") || event.getReason().contains("floating too long"))
{
event.setCancelled(true);
}
}
}
@EventHandler
public void StaffIncognito(IncognitoStatusChangeEvent event)

View File

@ -585,35 +585,6 @@ public class ItemMapManager extends MiniPlugin
return _scale.get(scale);
}
//fixme Spam left click in a chest and this won't work
@EventHandler
public void preventMapMoveInventories(InventoryClickEvent event)
{
Inventory inv = event.getClickedInventory();
if (inv == null)
return;
// Yeah, the loop looks a little weird..
for (ItemStack item : new ItemStack[]
{
event.getCurrentItem(), event.getCursor()
})
{
if (!isItemClansMap(item))
continue;
if (inv.getHolder() instanceof Player ? !event.isShiftClick() : Objects.equal(event.getCurrentItem(), item))
continue;
event.setCancelled(true);
UtilPlayer.message(event.getWhoClicked(),
F.main("Inventory", "You cannot move " + F.item("Clans Map") + " between inventories."));
return;
}
}
//fixme So what appears to happen is that after you die, if your map is is the same then the map is frozen
@EventHandler
public void onDeath(PlayerDeathEvent event)

View File

@ -29,7 +29,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
* @author MrTwiggy
*
*/
public class CustomItem
public class CustomItem implements Listener
{
private static final ChatColor TITLE_COLOR = ChatColor.GOLD; // Chat color
@ -73,6 +73,7 @@ public class CustomItem
_material = material;
_attributes = new AttributeContainer();
_uuid = UUID.randomUUID().toString();
UtilServer.RegisterEvents(this);
}
public CustomItem(Material material)

View File

@ -31,7 +31,7 @@ public class HyperAxe extends LegendaryItem
C.cWhite + "blade can rip through any opponent.",
C.cWhite + " ",
C.cWhite + "Hit delay is reduced by " + C.cYellow + "50%",
C.cWhite + "Deals " + C.cYellow + "10 Damage" + C.cWhite + " with attack",
C.cWhite + "Deals " + C.cYellow + "3 Damage" + C.cWhite + " with attack",
C.cYellow + "Right-Click" + C.cWhite + " to use " + C.cGreen + "Dash",
}, Material.RECORD_3);
_speedAmount = amountGen.generateIntValue();

View File

@ -1,9 +1,14 @@
package mineplex.game.clans.items.legendaries;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.items.PlayerGear;
import net.minecraft.server.v1_8_R3.PlayerConnection;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
@ -16,85 +21,101 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import java.lang.reflect.Field;
public class WindBlade extends LegendaryItem
{
private static final Field G_FIELD;
static
{
try
{
G_FIELD = PlayerConnection.class.getDeclaredField("g");
G_FIELD.setAccessible(true);
}
catch (ReflectiveOperationException exception)
{
throw new RuntimeException("Could not reflectively access field", exception);
}
}
public static final double FLIGHT_VELOCITY = 0.75d;
private double _power;
private double _burnoutThreshold;
private int _messageTimer;
public WindBlade()
{
super("Wind Blade", new String[] {
super("Wind Blade", new String[]{
C.cWhite + "Long ago, a race of cloud dwellers",
C.cWhite + "terrorized the skies. A remnant of",
C.cWhite + "their tyranny, this airy blade is",
C.cWhite + "the last surviving memorium from",
C.cWhite + "their final battle against the Titans.",
" ",
C.cYellow + "Right-Click" + C.cWhite + " to use" + C.cGreen + " Fly",
C.cYellow + "Right-Click" + C.cWhite + " to use" + C.cGreen + " Fly",
}, Material.GREEN_RECORD);
}
@Override
public void update(Player wielder)
{
long burnoutRemaining = -1L;
if (Recharge.Instance.Get(wielder) != null && Recharge.Instance.Get(wielder).containsKey("clans_legendary_windblade_burnout"))
{
burnoutRemaining = Recharge.Instance.Get(wielder).get("clans_legendary_windblade_burnout").GetRemaining();
}
// Check if player is attempting to fly and activate
if (isHoldingRightClick())
{
if (canPropel(wielder))
{
wielder.setFallDistance(0f);
if (burnoutRemaining > 0)
{
_messageTimer++;
if (_messageTimer % 4 == 0)
{
UtilParticle.PlayParticle(ParticleType.SMOKE, wielder.getLocation(), 0.f, 0.f, 0.f, .1f, 1, ViewDist.NORMAL);
wielder.playSound(wielder.getLocation(), Sound.FIZZ, .5f, 1.f);
removePower(0.15);
_burnoutThreshold = 0;
}
if (_messageTimer % 5 == 0)
{
UtilPlayer.message(wielder, F.main("Wind Blade", "Flight power damaged whilst scraping the ground! Repairs will be finish in " + F.time(UtilTime.MakeStr(burnoutRemaining)) + "."));
}
if (_messageTimer % 10 == 0)
{
wielder.playSound(wielder.getLocation(), Sound.ANVIL_USE, .5f, 1.5f);
}
return;
}
removePower(UtilEnt.isGrounded(wielder) ? 1.17 : .88);
propelPlayer(wielder);
UtilParticle.PlayParticle(ParticleType.EXPLODE, wielder.getLocation().add(0, 1, 0), 0, 0, 0, .1f, 3, ViewDist.NORMAL);
wielder.playSound(wielder.getLocation(), Sound.FIRE, .25f, 1.75f);
}
if (UtilEnt.isGrounded(wielder))
{
_burnoutThreshold++;
@ -109,44 +130,67 @@ public class WindBlade extends LegendaryItem
{
_burnoutThreshold = UtilMath.clamp(_burnoutThreshold - .5, 0, _burnoutThreshold);
}
if (UtilEnt.isGrounded(wielder, wielder.getLocation()) || UtilEnt.isGrounded(wielder, wielder.getLocation().subtract(0, 1, 0)))
{
addPower(0.65);
}
if (_burnoutThreshold > 15 && burnoutRemaining <= 0)
{
Recharge.Instance.use(wielder, "clans_legendary_windblade_burnout", 2500, false, false);
}
UtilTextBottom.displayProgress(UtilMath.clamp(_power, .0, 80.) / 80., wielder);
}
@Override
public void onAttack(CustomDamageEvent event, Player wielder)
{
event.AddMod("Wind Blade", 6);
}
@EventHandler
public void onFall(CustomDamageEvent event)
{
if (event.GetDamageePlayer() != null && event.GetCause() == EntityDamageEvent.DamageCause.FALL)
{
PlayerGear playerGear = GearManager.getInstance().getPlayerGear(event.GetDamageePlayer());
if (playerGear.getWeapon() instanceof WindBlade)
{
event.SetCancelled("Wind Blade No Fall Damage");
}
}
}
private void propelPlayer(Player player)
{
Vector direction = player.getLocation().getDirection().normalize();
direction.multiply(FLIGHT_VELOCITY);
player.setVelocity(direction);
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
try
{
G_FIELD.set(connection, 0);
}
catch (IllegalAccessException e)
{
new RuntimeException("Could not update g field", e).printStackTrace();
}
}
private boolean canPropel(Player player)
{
return _power > 0 && !UtilItem.isLiquid(player.getLocation().getBlock().getType());
}
private void addPower(double power)
{
_power = UtilMath.clamp(_power + power, -20, 80);
}
private void removePower(double power)
{
_power = UtilMath.clamp(_power - power, -20, 80);