weaps oops
This commit is contained in:
parent
263e3e7768
commit
d86ef81056
@ -19,6 +19,8 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import mineplex.core.vanish.events.PreVanishEvent;
|
||||
|
||||
public class UtilServer
|
||||
{
|
||||
public static Player[] getPlayers()
|
||||
@ -113,7 +115,7 @@ public class UtilServer
|
||||
return getServer().getPluginManager();
|
||||
}
|
||||
|
||||
public static void callEvent(Event event)
|
||||
public static <T extends Event> T callEvent(T event)
|
||||
{
|
||||
getPluginManager().callEvent(event);
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
package mineplex.game.clans.items.rares;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
public class Crossbow extends RareItem
|
||||
{
|
||||
private static final Material LOADED_TYPE = Material.COMMAND_MINECART;
|
||||
private static final Material UNLOADED_TYPE = Material.RECORD_6;
|
||||
|
||||
private long _lastFire = System.currentTimeMillis();
|
||||
private long _interactWait;
|
||||
|
||||
public Crossbow()
|
||||
{
|
||||
super("Crossbow", UtilText.splitLinesToArray(new String[] {
|
||||
"#" + C.cYellow + "Right-Click" + C.cWhite + " to fire Crossbow."
|
||||
}, LineFormat.LORE), UNLOADED_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Player wielder)
|
||||
{
|
||||
if (UtilInv.contains(wielder, Material.ARROW, (byte) 0, 1))
|
||||
{
|
||||
wielder.getItemInHand().setType(LOADED_TYPE);
|
||||
}
|
||||
else
|
||||
{
|
||||
wielder.getItemInHand().setType(UNLOADED_TYPE);
|
||||
}
|
||||
|
||||
if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
|
||||
{
|
||||
if (UtilInv.remove(wielder, Material.ARROW, (byte) 0, 1))
|
||||
{
|
||||
if (Recharge.Instance.use(wielder, "Crossbow", 4000, true, true))
|
||||
{
|
||||
fire(wielder);
|
||||
|
||||
_interactWait = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fire(final Player player)
|
||||
{
|
||||
Arrow arrow = player.shootArrow();
|
||||
|
||||
arrow.setShooter(player);
|
||||
|
||||
_lastFire = System.currentTimeMillis();
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package mineplex.game.clans.items.rares;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import mineplex.game.clans.items.CustomItem;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class RareItem extends CustomItem
|
||||
{
|
||||
public final long BLOCK_COOLDOWN = 200l; // Right clicking activates right click for 200ms
|
||||
|
||||
protected long _lastBlock; // Timestamp of last block from wielder
|
||||
public long timeSinceLastBlock() { return System.currentTimeMillis() - _lastBlock; }
|
||||
|
||||
public RareItem(String name, String[] description, Material material)
|
||||
{
|
||||
super(name, description, material);
|
||||
|
||||
_lastBlock = 0l;
|
||||
}
|
||||
|
||||
public void update(Player wielder)
|
||||
{
|
||||
// Leave implementation to potential subtypes
|
||||
}
|
||||
|
||||
public void preUpdate(Player wielder)
|
||||
{
|
||||
}
|
||||
|
||||
public void onAttack(CustomDamageEvent event, Player wielder)
|
||||
{
|
||||
// Leave implementation to potential subtypes
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttack(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetDamagerPlayer(true) != null)
|
||||
{
|
||||
onAttack(event, event.GetDamagerPlayer(true));
|
||||
}
|
||||
|
||||
super.onAttack(event);
|
||||
}
|
||||
|
||||
public void onInteract(PlayerInteractEvent event)
|
||||
{
|
||||
Action action = event.getAction();
|
||||
|
||||
if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
_lastBlock = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
super.onInteract(event);
|
||||
}
|
||||
|
||||
public boolean isHoldingRightClick()
|
||||
{
|
||||
return timeSinceLastBlock() <= BLOCK_COOLDOWN;
|
||||
}
|
||||
|
||||
protected void log(String message)
|
||||
{
|
||||
System.out.println("[Custom Item - " + _displayName + "] " + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param minValue - the minimum value for attribute value range
|
||||
* @param maxValue - the maximum value for attribute value range
|
||||
* @return newly instantiated {@link ValueDistribution} for attribute values in range [{@code minValue}. {@code maxValue}].
|
||||
*/
|
||||
public static ValueDistribution generateDistribution(double minValue, double maxValue)
|
||||
{
|
||||
return new ValueDistribution(minValue, maxValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a {@link PotionEffect} to {@code player} with specified {@code type}, {@code amplifier} (power) and
|
||||
* {@code tickDuration} of the effect.
|
||||
* @param player - the player to receive the potion effect
|
||||
* @param type - the type of potion to apply
|
||||
* @param tickDuration - the duration (in ticks) to apply the potion for
|
||||
* @param amplifier - the amplifier (level/power, zero-based) of the potion effect
|
||||
*/
|
||||
public static void grantPotionEffect(Player player, PotionEffectType type, int tickDuration, int amplifier)
|
||||
{
|
||||
player.removePotionEffect(type);
|
||||
player.addPotionEffect(new PotionEffect(type, amplifier, tickDuration));
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package mineplex.game.clans.items.rares;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.RGBData;
|
||||
import mineplex.core.common.util.UtilCollections;
|
||||
import mineplex.core.common.util.UtilColor;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilShapes;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.items.PlayerGear;
|
||||
|
||||
public class RunedPickaxe extends RareItem
|
||||
{
|
||||
private long _lastFire = System.currentTimeMillis();
|
||||
private long _interactWait;
|
||||
|
||||
private long _instamineEnabled;
|
||||
|
||||
private RGBData[] colors = { UtilColor.RgbLightBlue, UtilColor.RgbLightBlue.Lighten(), UtilColor.RgbLightBlue.Darken() };
|
||||
|
||||
public RunedPickaxe()
|
||||
{
|
||||
super("Runed Pickaxe", UtilText.splitLinesToArray(new String[] {
|
||||
"#" + C.cYellow + "Right-Click" + C.cWhite + " to use " + F.elem("Instant mine") + "."
|
||||
}, LineFormat.LORE), Material.RECORD_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Player wielder)
|
||||
{
|
||||
if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
|
||||
{
|
||||
if (Recharge.Instance.use(wielder, "Instant Mine", 30000, true, true))
|
||||
{
|
||||
fire(wielder);
|
||||
|
||||
_interactWait = System.currentTimeMillis();
|
||||
|
||||
_instamineEnabled = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void blockDamage(BlockDamageEvent event)
|
||||
{
|
||||
PlayerGear gear = ClansManager.getInstance().getGearManager().getPlayerGear(event.getPlayer());
|
||||
|
||||
if (gear.getWeapon() == this && !UtilTime.elapsed(_instamineEnabled, 12000))
|
||||
{
|
||||
event.setInstaBreak(true);
|
||||
|
||||
event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, event.getBlock().getType(), 10);
|
||||
|
||||
event.getPlayer().playSound(event.getBlock().getLocation(), Sound.LAVA_POP, 1.f, 1.f);
|
||||
}
|
||||
}
|
||||
|
||||
private void fire(final Player player)
|
||||
{
|
||||
}
|
||||
|
||||
private void playParticle(Location start, Location end)
|
||||
{
|
||||
for (Location loc : UtilShapes.getLinesDistancedPoints(start, end, 0.06))
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc, UtilCollections.random(colors).ToVector(), 1f, 0, ViewDist.LONG);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user