Item upgrade effects

This commit is contained in:
Sam 2017-05-10 19:25:56 +01:00
parent eec8e5143d
commit dcb676c57b
21 changed files with 629 additions and 30 deletions

View File

@ -1217,6 +1217,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
player.setGameMode(GameMode.SURVIVAL);
player.setAllowFlight(false);
player.setFlySpeed(0.1F);
player.setWalkSpeed(0.2F);
UtilInv.Clear(player);

View File

@ -17,6 +17,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.DebugCommand;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.moba.fountain.MobaFountain;
import nautilus.game.arcade.game.games.moba.gold.GoldManager;
import nautilus.game.arcade.game.games.moba.kit.*;
import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath;
@ -38,6 +39,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.metadata.FixedMetadataValue;
@ -50,9 +53,11 @@ public class Moba extends TeamGame
{
private static final String[] DESCRIPTION = {
"MORE CAPTURE POINTS"
"..."
};
private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1);
// Health per 5 seconds.
private static final double HP5 = 0.33;
private final HeroKit[] _kits;
@ -101,6 +106,9 @@ public class Moba extends TeamGame
_goldManager = goldManager;
_listeners.add(goldManager);
MobaFountain fountain = new MobaFountain(this);
_listeners.add(fountain);
new CompassModule()
.setGiveCompass(true)
.setGiveCompassToSpecs(true)
@ -444,7 +452,6 @@ public class Moba extends TeamGame
}
}
//TODO announce to all
@Override
public DeathMessageType GetDeathMessageType()
{
@ -522,6 +529,41 @@ public class Moba extends TeamGame
}
}
/*
HP Regeneration
*/
@EventHandler
public void regeneration(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC_05)
{
return;
}
for (Player player : GetPlayers(true))
{
if (UtilPlayer.isSpectator(player))
{
continue;
}
MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5);
UtilServer.CallEvent(regenEvent);
player.setHealth(Math.min(player.getMaxHealth(), player.getHealth() + regenEvent.getHealth()));
}
}
@EventHandler
public void preventHungerRegeneration(EntityRegainHealthEvent event)
{
if (event.getRegainReason() == RegainReason.SATIATED)
{
event.setCancelled(true);
}
}
public Map<String, Location> getLocationStartsWith(String s)
{
Map<String, Location> map = new HashMap<>();

View File

@ -0,0 +1,49 @@
package nautilus.game.arcade.game.games.moba;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class MobaHPRegenEvent extends PlayerEvent
{
private static final HandlerList _handlers = new HandlerList();
private final double _initialHealth;
private double _health;
public MobaHPRegenEvent(Player who, double health)
{
super(who);
_initialHealth = health;
_health = health;
}
public void setHealth(double health)
{
_health = health;
}
public void increaseHealth(double factor)
{
_health = _initialHealth * factor;
}
public double getHealth()
{
return _health;
}
public static HandlerList getHandlerList()
{
return _handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
}

View File

@ -0,0 +1,91 @@
package nautilus.game.arcade.game.games.moba.fountain;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
public class MobaFountain implements Listener
{
private static final int FOUNTAIN_SIZE_SQUARED = 5;
private final Moba _host;
private final Map<GameTeam, Location> _average;
public MobaFountain(Moba host)
{
_host = host;
_average = new HashMap<>();
}
@EventHandler
public void prepare(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
for (GameTeam team : _host.GetTeamList())
{
_average.put(team, UtilAlg.getAverageLocation(team.GetSpawns()));
}
}
@EventHandler
public void respawn(PlayerGameRespawnEvent event)
{
Player player = event.GetPlayer();
_host.getArcadeManager().GetCondition().Factory().Regen("Fountain", player, null, 3, 9, false, true, false);
}
@EventHandler
public void updateInFountain(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || !_host.IsLive())
{
return;
}
for (Player player : _host.GetPlayers(true))
{
GameTeam playerTeam = _host.GetTeam(player);
for (Entry<GameTeam, Location> entry : _average.entrySet())
{
GameTeam team = entry.getKey();
Location location = entry.getValue();
if (UtilMath.offsetSquared(player.getLocation(), location) > FOUNTAIN_SIZE_SQUARED)
{
continue;
}
if (playerTeam.equals(team))
{
player.setHealth(Math.min(player.getMaxHealth(), player.getHealth() + 6));
}
else
{
_host.getArcadeManager().GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 6, false, true, true, "Fountain", "Fountain");
}
}
}
}
}

View File

@ -27,7 +27,7 @@ public class CooldownCalculateEvent extends PlayerEvent
public void decreaseCooldown(double factor)
{
_cooldown = (long) ((double) _initialCooldown * factor);
_cooldown -= (long) ((double) _initialCooldown * factor);
}
public long getCooldown()

View File

@ -2,13 +2,16 @@ package nautilus.game.arcade.game.games.moba.kit;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.MobaRole;
import nautilus.game.arcade.game.games.moba.shop.MobaItem;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
@ -18,6 +21,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import java.util.List;
public class HeroKit extends Kit
{
@ -136,9 +141,36 @@ public class HeroKit extends Kit
{
PlayerInventory inventory = player.getInventory();
// Give standard items
inventory.setItem(AMMO_SLOT, _ammo);
inventory.setItem(RECALL_SLOT, RECALL_ITEM);
// Give armour
List<MobaItem> items = ((Moba) Manager.GetGame()).getShop().getOwnedItems(player);
for (MobaItem item : items)
{
ItemStack armour = item.getItem();
if (UtilItem.isHelmet(armour))
{
inventory.setHelmet(armour);
}
else if (UtilItem.isChestplate(armour))
{
inventory.setChestplate(armour);
}
else if (UtilItem.isLeggings(armour))
{
inventory.setLeggings(armour);
}
else if (UtilItem.isBoots(armour))
{
inventory.setBoots(armour);
}
}
// Give all skill related items
for (Perk perk : GetPerks())
{
if (!(perk instanceof HeroSkill))

View File

@ -23,7 +23,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.*;
import java.util.function.Consumer;
public class HeroSkill extends Perk
{
@ -289,7 +288,7 @@ public class HeroSkill extends Perk
ItemStack itemStack = player.getInventory().getItem(getSlot());
itemStack.setAmount((int) (ticks / 20D));
UtilInv.addDullEnchantment(itemStack);
Recharge.Instance.useForce(player, GetName(), ticks, true);
Recharge.Instance.useForce(player, GetName(), time, true);
Recharge.Instance.setDisplayForce(player, GetName(), true);
Manager.runSyncTimer(new BukkitRunnable()

View File

@ -87,7 +87,7 @@ public class SkillBurnBeam extends HeroSkill
}
entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.EXPLODE, 2, 0.5F);
Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 20, true, true, false, UtilEnt.getName(player), GetName());
Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 15, true, true, false, UtilEnt.getName(player), GetName());
}
}
}, 0, 1);

View File

@ -72,7 +72,7 @@ public class SkillSnowball extends HeroSkill implements IThrown
{
Player thrower = (Player) data.getThrower();
if (target != null)
if (target != null && !isTeamDamage(target, thrower))
{
thrower.playSound(thrower.getLocation(), Sound.LAVA_POP, 1, 1.3F);
Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.PROJECTILE, 3, true, true, false, UtilEnt.getName(thrower), GetName());

View File

@ -1,8 +1,11 @@
package nautilus.game.arcade.game.games.moba.shop;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class MobaItem
@ -25,16 +28,27 @@ public class MobaItem
_effects = new ArrayList<>(effects.length);
}
for (MobaItemEffect effect : _effects)
{
_effects.add(effect);
}
Collections.addAll(_effects, effects);
return this;
}
public ItemStack getItem()
{
return _item;
ItemBuilder builder = new ItemBuilder(_item);
if (getEffects() != null)
{
builder.addLore("", C.cWhite + "Effects:");
for (MobaItemEffect effect : getEffects())
{
builder.addLore(" - " + effect.getDescription());
}
builder.addLore("");
}
return builder.build();
}
public int getCost()

View File

@ -1,17 +1,21 @@
package nautilus.game.arcade.game.games.moba.shop;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent;
import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent;
import org.bukkit.entity.Player;
public class MobaItemEffect
public interface MobaItemEffect
{
public void onCooldownCheck(CooldownCalculateEvent event)
{
}
void onCooldownCheck(CooldownCalculateEvent event);
public void onDeath(Player killed, Player killer)
{
}
void onDeath(Player killed, Player killer);
void onHPRegen(MobaHPRegenEvent event);
void onRespawn(PlayerGameRespawnEvent event);
String getDescription();
}

View File

@ -7,8 +7,10 @@ import mineplex.minecraft.game.core.combat.CombatComponent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent;
import nautilus.game.arcade.game.games.moba.MobaPlayer;
import nautilus.game.arcade.game.games.moba.MobaRole;
import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent;
@ -79,7 +81,7 @@ public class MobaShop implements Listener
_host.CreatureAllowOverride = false;
}
private void openShop(MobaPlayer player)
public void openShop(MobaPlayer player)
{
MobaShopMenu menu = _roleMenus.get(player.Role);
@ -172,6 +174,20 @@ public class MobaShop implements Listener
owned.removeIf(previousItem -> getCategory(previousItem) == category);
}
// The respawn event needs to be called here so that effects like "Total Health Increase" will work straight away, instead of after the next respawn,
if (item.getEffects() != null)
{
// Prevents an infinite speed
player.setWalkSpeed(0.2F);
PlayerGameRespawnEvent fakeEvent = new PlayerGameRespawnEvent(null, player);
for (MobaItemEffect effect : item.getEffects())
{
effect.onRespawn(fakeEvent);
}
}
player.sendMessage(F.main("Game", "Purchased " + F.greenElem(item.getItem().getItemMeta().getDisplayName()) + "."));
_host.getGoldManager().removeGold(player, item.getCost());
owned.add(item);
@ -223,7 +239,7 @@ public class MobaShop implements Listener
}
@EventHandler
public void cooldownCalculate(CooldownCalculateEvent event)
public void hpRegeneration(CooldownCalculateEvent event)
{
Player player = event.getPlayer();
List<MobaItem> items = _upgrades.get(player);
@ -275,4 +291,44 @@ public class MobaShop implements Listener
}
}
}
@EventHandler
public void hpRegeneration(MobaHPRegenEvent event)
{
Player player = event.getPlayer();
List<MobaItem> items = _upgrades.get(player);
for (MobaItem item : items)
{
if (item.getEffects() == null)
{
continue;
}
for (MobaItemEffect effect : item.getEffects())
{
effect.onHPRegen(event);
}
}
}
@EventHandler
public void repawn(PlayerGameRespawnEvent event)
{
Player player = event.GetPlayer();
List<MobaItem> items = _upgrades.get(player);
for (MobaItem item : items)
{
if (item.getEffects() == null)
{
continue;
}
for (MobaItemEffect effect : item.getEffects())
{
effect.onRespawn(event);
}
}
}
}

View File

@ -1,12 +1,13 @@
package nautilus.game.arcade.game.games.moba.shop;
import javafx.scene.shape.Arc;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.menu.Menu;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.moba.Moba;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -17,6 +18,9 @@ public class MobaShopCategoryMenu extends Menu<ArcadeManager>
private static final int SLOTS = 27;
private static final int STARTING_SLOT = 10;
private static final ItemStack GO_BACK_ITEM = new ItemBuilder(Material.BED)
.setTitle(C.cGreen + "Go Back")
.build();
private final Moba _host;
private final MobaShop _shop;
@ -37,6 +41,8 @@ public class MobaShopCategoryMenu extends Menu<ArcadeManager>
Button[] buttons = new Button[SLOTS];
int slot = STARTING_SLOT;
buttons[4] = new GoBackButton(getPlugin());
for (MobaItem item : _category.getItems())
{
ItemBuilder builder = new ItemBuilder(item.getItem());
@ -45,10 +51,11 @@ public class MobaShopCategoryMenu extends Menu<ArcadeManager>
int gold = _host.getGoldManager().getGold(player);
builder.setTitle((canPurchase ? C.cGreen : C.cRed) + item.getItem().getItemMeta().getDisplayName());
builder.addLore("");
if (owns)
{
builder.setType(Material.WOOL);
builder.setData((byte) 5);
builder.addLore(C.cRed + "You already have purchased this upgrade.");
}
else
@ -101,4 +108,19 @@ public class MobaShopCategoryMenu extends Menu<ArcadeManager>
}
}
}
class GoBackButton extends Button<ArcadeManager>
{
public GoBackButton(ArcadeManager plugin)
{
super(GO_BACK_ITEM, plugin);
}
@Override
public void onClick(Player player, ClickType clickType)
{
_shop.openShop(_host.getData(player));
}
}
}

View File

@ -69,7 +69,7 @@ public class MobaShopMenu extends Menu<ArcadeManager>
}
builder.setTitle(C.cGreen + category.getName());
builder.addLore("", "Not sure what to put here", "");
builder.addLore("");
if (category.isAllowingMultiple())
{

View File

@ -8,7 +8,7 @@ import nautilus.game.arcade.game.games.moba.shop.MobaItem;
import nautilus.game.arcade.game.games.moba.shop.MobaShop;
import nautilus.game.arcade.game.games.moba.shop.MobaShopCategory;
import nautilus.game.arcade.game.games.moba.shop.MobaShopMenu;
import nautilus.game.arcade.game.games.moba.shop.effects.MobaKillHealEffect;
import nautilus.game.arcade.game.games.moba.shop.effects.*;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
@ -34,10 +34,95 @@ public class MobaAssassinShop extends MobaShopMenu
.build(), 1750)
), new ItemStack(Material.WOOD_SWORD));
private static final MobaShopCategory HELMET = new MobaShopCategory("Helmet", Arrays.asList(
new MobaItem(new ItemBuilder(Material.LEATHER_HELMET)
.setTitle(C.cGreen + "Leather Cap")
.build(), 200)
.addEffects(
new MobaHPRegenEffect(0.05)
),
new MobaItem(new ItemBuilder(Material.LEATHER_HELMET)
.setTitle(C.cGreen + "Ninja's Rainment")
.build(), 500)
.addEffects(
new MobaHPRegenEffect(0.1)
),
new MobaItem(new ItemBuilder(Material.CHAINMAIL_HELMET)
.setTitle(C.cYellow + "Bruiser's Helm")
.build(), 1000)
.addEffects(
new MobaHPRegenEffect(0.15)
)
), new ItemStack(Material.LEATHER_HELMET));
private static final MobaShopCategory CHESTPLATE = new MobaShopCategory("Chestplate", Arrays.asList(
new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE)
.setTitle(C.cGreen + "Leather Chestplate")
.build(), 250)
.addEffects(
new MobaCDREffect(0.05)
),
new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE)
.setTitle(C.cGreen + "Ninja's Rainment")
.build(), 750)
.addEffects(
new MobaCDREffect(0.15)
),
new MobaItem(new ItemBuilder(Material.CHAINMAIL_CHESTPLATE)
.setTitle(C.cYellow + "Bruiser's Chestplate")
.build(), 1250)
.addEffects(
new MobaCDREffect(0.1)
)
), new ItemStack(Material.LEATHER_CHESTPLATE));
private static final MobaShopCategory LEGGINGS = new MobaShopCategory("Leggings", Arrays.asList(
new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS)
.setTitle(C.cGreen + "Leather Leggings")
.build(), 250),
new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS)
.setTitle(C.cGreen + "Ninja's Rainment")
.build(), 750)
.addEffects(
new MobaTotalHealthEffect(2)
),
new MobaItem(new ItemBuilder(Material.CHAINMAIL_LEGGINGS)
.setTitle(C.cYellow + "Bruiser's Leggings")
.build(), 1250)
.addEffects(
new MobaTotalHealthEffect(4)
)
), new ItemStack(Material.LEATHER_LEGGINGS));
private static final MobaShopCategory BOOTS = new MobaShopCategory("Boots", Arrays.asList(
new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS)
.setTitle(C.cGreen + "Leather Boots")
.build(), 200)
.addEffects(
new MobaSpeedEffect(0.05)
),
new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS)
.setTitle(C.cGreen + "Ninja's Rainment")
.build(), 500)
.addEffects(
new MobaSpeedEffect(0.15)
),
new MobaItem(new ItemBuilder(Material.CHAINMAIL_BOOTS)
.setTitle(C.cYellow + "Bruiser's Boots")
.build(), 1000)
.addEffects(
new MobaSpeedEffect(0.1)
)
), new ItemStack(Material.LEATHER_BOOTS));
public MobaAssassinShop(Moba host, MobaShop shop)
{
super(host, shop, MobaRole.ASSASSIN);
addCategory(SWORD);
addCategory(HELMET);
addCategory(CHESTPLATE);
addCategory(LEGGINGS);
addCategory(BOOTS);
}
}

View File

@ -1,10 +1,13 @@
package nautilus.game.arcade.game.games.moba.shop.effects;
import mineplex.core.common.util.F;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent;
import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent;
import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect;
import org.bukkit.entity.Player;
public class MobaCDREffect extends MobaItemEffect
public class MobaCDREffect implements MobaItemEffect
{
private double _factor;
@ -19,4 +22,25 @@ public class MobaCDREffect extends MobaItemEffect
{
event.decreaseCooldown(_factor);
}
@Override
public void onDeath(Player killed, Player killer)
{
}
@Override
public void onHPRegen(MobaHPRegenEvent event)
{
}
@Override
public void onRespawn(PlayerGameRespawnEvent event)
{
}
@Override
public String getDescription()
{
return "Decreases ability cooldowns by " + F.greenElem(String.valueOf(_factor * 100)) + "%.";
}
}

View File

@ -0,0 +1,46 @@
package nautilus.game.arcade.game.games.moba.shop.effects;
import mineplex.core.common.util.F;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent;
import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent;
import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect;
import org.bukkit.entity.Player;
public class MobaHPRegenEffect implements MobaItemEffect
{
private double _factor;
public MobaHPRegenEffect(double factor)
{
_factor = factor;
}
@Override
public void onCooldownCheck(CooldownCalculateEvent event)
{
}
@Override
public void onDeath(Player killed, Player killer)
{
}
@Override
public void onHPRegen(MobaHPRegenEvent event)
{
event.increaseHealth(_factor);
}
@Override
public void onRespawn(PlayerGameRespawnEvent event)
{
}
@Override
public String getDescription()
{
return "Increases HP regeneration by " + F.greenElem(String.valueOf(_factor * 100)) + "%.";
}
}

View File

@ -1,9 +1,14 @@
package nautilus.game.arcade.game.games.moba.shop.effects;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent;
import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent;
import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect;
import org.bukkit.entity.Player;
public class MobaKillHealEffect extends MobaItemEffect
public class MobaKillHealEffect implements MobaItemEffect
{
private double _health;
@ -13,9 +18,30 @@ public class MobaKillHealEffect extends MobaItemEffect
_health = health;
}
@Override
public void onCooldownCheck(CooldownCalculateEvent event)
{
}
@Override
public void onDeath(Player killed, Player killer)
{
killer.setHealth(Math.min(killer.getMaxHealth(), killer.getHealth() + _health));
}
@Override
public void onHPRegen(MobaHPRegenEvent event)
{
}
@Override
public void onRespawn(PlayerGameRespawnEvent event)
{
}
@Override
public String getDescription()
{
return "Killing a player heals you for " + F.greenElem(String.valueOf(_health / 2)) + C.cRed + "" + C.cGray + ".";
}
}

View File

@ -0,0 +1,48 @@
package nautilus.game.arcade.game.games.moba.shop.effects;
import mineplex.core.common.util.F;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent;
import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent;
import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect;
import org.bukkit.entity.Player;
public class MobaSpeedEffect implements MobaItemEffect
{
private double _factor;
public MobaSpeedEffect(double factor)
{
_factor = factor;
}
@Override
public void onCooldownCheck(CooldownCalculateEvent event)
{
}
@Override
public void onDeath(Player killed, Player killer)
{
}
@Override
public void onHPRegen(MobaHPRegenEvent event)
{
}
@Override
public void onRespawn(PlayerGameRespawnEvent event)
{
Player player = event.GetPlayer();
player.setWalkSpeed((float) (player.getWalkSpeed() + (player.getWalkSpeed() * _factor)));
}
@Override
public String getDescription()
{
return "Increases your movement speed by " + F.greenElem(String.valueOf(_factor * 100)) + "%.";
}
}

View File

@ -0,0 +1,50 @@
package nautilus.game.arcade.game.games.moba.shop.effects;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent;
import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent;
import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect;
import org.bukkit.entity.Player;
public class MobaTotalHealthEffect implements MobaItemEffect
{
private int _health;
public MobaTotalHealthEffect(int health)
{
_health = health;
}
@Override
public void onCooldownCheck(CooldownCalculateEvent event)
{
}
@Override
public void onDeath(Player killed, Player killer)
{
}
@Override
public void onHPRegen(MobaHPRegenEvent event)
{
}
@Override
public void onRespawn(PlayerGameRespawnEvent event)
{
Player player = event.GetPlayer();
player.setMaxHealth(player.getMaxHealth() + _health);
player.setHealth(player.getMaxHealth());
}
@Override
public String getDescription()
{
return "Increases your total hearts by " + F.greenElem(String.valueOf(_health / 2)) + C.cRed + "" + C.cGray + ".";
}
}

View File

@ -162,11 +162,21 @@ public class CustomScoreboardModule extends Module
if (prefix != null)
{
team.setPrefix(prefix + C.Reset + " ");
String prefixF = prefix + C.Reset + " ";
if (!team.getPrefix().equals(prefixF))
{
team.setPrefix(prefixF);
}
}
else if (suffix != null)
{
team.setSuffix(suffix + C.Reset + " ");
String suffixF = suffix + C.Reset + " ";
if (!team.getPrefix().equals(suffixF))
{
team.setSuffix(suffixF);
}
}
}
@ -188,7 +198,7 @@ public class CustomScoreboardModule extends Module
{
for (Player player : Bukkit.getOnlinePlayers())
{
_prefixFunction.apply(getOwner(), player);
setTag(getOwner(), _prefixFunction.apply(getOwner(), player), null);
}
}
}