Finalize Amplifier system
This commit is contained in:
parent
891a3231d8
commit
869dfc1dfa
@ -53,6 +53,7 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.Clans;
|
||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.clans.amplifiers.AmplifierManager;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
import mineplex.game.clans.clans.banners.BannerManager;
|
||||
import mineplex.game.clans.clans.commands.ClanManagementCommand;
|
||||
@ -195,6 +196,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
private ClassManager _classManager;
|
||||
private BannerManager _bannerManager;
|
||||
private AmplifierManager _amplifierManager;
|
||||
|
||||
public ClassManager getClassManager()
|
||||
{
|
||||
@ -394,6 +396,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
_scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, _tutorial, clientManager, donationManager);
|
||||
_clanDataAccess = new ClansDataAccessLayer(this, _scoreboard);
|
||||
|
||||
_bannerManager = new BannerManager(plugin);
|
||||
|
||||
for (ClanToken token : _clanDataAccess.getRepository().retrieveClans())
|
||||
{
|
||||
loadClan(token);
|
||||
@ -457,7 +461,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
_siegeManager = new SiegeManager(this);
|
||||
_netherManager = new NetherManager(this);
|
||||
_bannerManager = new BannerManager(plugin);
|
||||
_amplifierManager = new AmplifierManager(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -544,6 +548,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
return _bannerManager;
|
||||
}
|
||||
|
||||
public AmplifierManager getAmplifierManager()
|
||||
{
|
||||
return _amplifierManager;
|
||||
}
|
||||
|
||||
public int getInviteExpire()
|
||||
{
|
||||
return _inviteExpire;
|
||||
|
@ -6,8 +6,27 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class Amplifier
|
||||
{
|
||||
private Player _owner;
|
||||
private long _end;
|
||||
|
||||
public Amplifier(Player owner, AmplifierType type)
|
||||
{
|
||||
_owner = owner;
|
||||
_end = System.currentTimeMillis() + type.getDuration();
|
||||
}
|
||||
|
||||
public Player getOwner()
|
||||
{
|
||||
return _owner;
|
||||
}
|
||||
|
||||
public long getRemainingTime()
|
||||
{
|
||||
return Math.max(0, _end - System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public boolean isEnded()
|
||||
{
|
||||
return System.currentTimeMillis() >= _end;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package mineplex.game.clans.clans.amplifiers;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AmplifierCommand extends CommandBase<AmplifierManager>
|
||||
{
|
||||
public AmplifierCommand(AmplifierManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "amplifier", "runeamplifier");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
new AmplifierGUI(caller, Plugin);
|
||||
}
|
||||
}
|
@ -3,8 +3,9 @@ package mineplex.game.clans.clans.amplifiers;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.amplifiers.AmplifierManager.AmplifierType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -19,7 +20,7 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public abstract class AmplifierGUI implements Listener
|
||||
public class AmplifierGUI implements Listener
|
||||
{
|
||||
private Player _viewer;
|
||||
private AmplifierManager _manager;
|
||||
@ -31,8 +32,12 @@ public abstract class AmplifierGUI implements Listener
|
||||
public AmplifierGUI(Player viewer, AmplifierManager manager)
|
||||
{
|
||||
_viewer = viewer;
|
||||
_inventory = Bukkit.createInventory(viewer, 9 * Math.max(1, AmplifierType.values().length % 9), C.cClansNether + "Rune Amplifiers");
|
||||
Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin());
|
||||
_manager = manager;
|
||||
_inventory = Bukkit.createInventory(viewer, 9, C.cClansNether + "Rune Amplifiers");
|
||||
Bukkit.getPluginManager().registerEvents(this, manager.getPlugin());
|
||||
|
||||
propagate();
|
||||
open();
|
||||
}
|
||||
|
||||
public Player getViewer()
|
||||
@ -51,9 +56,13 @@ public abstract class AmplifierGUI implements Listener
|
||||
Integer slot = 0;
|
||||
for (AmplifierType type : AmplifierType.values())
|
||||
{
|
||||
getItems().put(slot, new ItemBuilder(Material.NETHER_STAR).setAmount(_manager.getAmountOwned(getViewer(), type)).setTitle(type.getDisplayName()).build());
|
||||
int owned = _manager.getAmountOwned(getViewer(), type);
|
||||
owned = Math.max(owned, 0);
|
||||
getItems().put(slot, new ItemBuilder(Material.NETHER_STAR).setAmount(Math.min(owned, 1)).setTitle(type.getDisplayName()).setLore(F.elem(owned) + " Owned").build());
|
||||
_boundSlots.put(slot, type);
|
||||
slot++;
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
public void propagateConfirmation()
|
||||
@ -62,13 +71,48 @@ public abstract class AmplifierGUI implements Listener
|
||||
_boundSlots.clear();
|
||||
getItems().put(3, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short) 5).setTitle(C.cGreen + "Confirm").build());
|
||||
getItems().put(5, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short) 14).setTitle(C.cRed + "Cancel").build());
|
||||
refresh();
|
||||
}
|
||||
|
||||
public void onClick(Integer slot, ClickType type)
|
||||
{
|
||||
if (_boundSlots.containsKey(slot))
|
||||
{
|
||||
if (_manager.hasActiveAmplifier())
|
||||
{
|
||||
UtilPlayer.message(getViewer(), F.main(_manager.getName(), "An amplifier is already active!"));
|
||||
_manager.runSyncLater(() ->
|
||||
{
|
||||
getViewer().closeInventory();
|
||||
}, 1L);
|
||||
}
|
||||
else
|
||||
{
|
||||
_selected = _boundSlots.get(slot);
|
||||
if (_manager.getAmountOwned(getViewer(), _selected) > 0)
|
||||
{
|
||||
propagateConfirmation();
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(getViewer(), F.main(_manager.getName(), "You do not have enough of that amplifier! Purchase some at http://www.mineplex.com/shop!"));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (slot == 3)
|
||||
{
|
||||
_manager.runSyncLater(() ->
|
||||
{
|
||||
_manager.useAmplifier(getViewer(), _selected);
|
||||
getViewer().closeInventory();
|
||||
}, 1L);
|
||||
}
|
||||
if (slot == 5)
|
||||
{
|
||||
_selected = null;
|
||||
propagate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,20 +2,36 @@ package mineplex.game.clans.clans.amplifiers;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class AmplifierManager extends MiniPlugin
|
||||
{
|
||||
private static final String AMPLIFIER_NAME = "Rune Amplifier";
|
||||
private Amplifier _active;
|
||||
|
||||
public AmplifierManager(JavaPlugin plugin)
|
||||
{
|
||||
super("Rune Amplifiers", plugin);
|
||||
|
||||
addCommand(new AmplifierCommand(this));
|
||||
}
|
||||
|
||||
public boolean hasActiveAmplifier()
|
||||
{
|
||||
return _active != null;
|
||||
}
|
||||
|
||||
public int getAmountOwned(Player player, AmplifierType type)
|
||||
@ -23,6 +39,55 @@ public class AmplifierManager extends MiniPlugin
|
||||
return ClansManager.getInstance().getInventoryManager().Get(player).getItemCount(type.getFullItemName());
|
||||
}
|
||||
|
||||
public void useAmplifier(Player user, AmplifierType type)
|
||||
{
|
||||
if (getAmountOwned(user, type) < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (hasActiveAmplifier())
|
||||
{
|
||||
return;
|
||||
}
|
||||
ClansManager.getInstance().getInventoryManager().addItemToInventory(user, type.getFullItemName(), -1);
|
||||
UtilTextMiddle.display(C.cClansNether + AMPLIFIER_NAME, "Has been activated by " + F.elem(user.getName()));
|
||||
Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether(AMPLIFIER_NAME) + " has been activated on this server by " + F.elem(user.getName()) + " for " + F.elem(UtilTime.MakeStr(type.getDuration())) + "!"));
|
||||
_active = new Amplifier(user, type);
|
||||
runSyncLater(() ->
|
||||
{
|
||||
ClansManager.getInstance().getNetherManager().spawnPortal(type.getDuration());
|
||||
}, 60L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_active != null && _active.isEnded())
|
||||
{
|
||||
Bukkit.broadcastMessage(F.main(getName(), "The " + F.clansNether(AMPLIFIER_NAME) + " owned by " + F.elem(_active.getOwner()) + " has run out! You can purchase another at http://www.mineplex.com/shop!"));
|
||||
_active = null;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (_active != null)
|
||||
{
|
||||
runSyncLater(() ->
|
||||
{
|
||||
if (_active != null)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "A " + F.clansNether(AMPLIFIER_NAME) + " owned by " + F.elem(_active.getOwner().getName()) + " is active on this server with " + F.elem(UtilTime.MakeStr(_active.getRemainingTime())) + " remaining!"));
|
||||
}
|
||||
}, 40L);
|
||||
}
|
||||
}
|
||||
|
||||
public static enum AmplifierType
|
||||
{
|
||||
TWENTY("20", "Twenty Minute Amplifier", UtilTime.convert(20, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)),
|
||||
|
@ -33,6 +33,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
public class ArcherMiniboss extends NetherMiniBoss<Skeleton>
|
||||
{
|
||||
private static final int BARBED_LEVEL = 1;
|
||||
private static final double RUNE_DROP_CHANCE = .1;
|
||||
|
||||
public ArcherMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type)
|
||||
{
|
||||
@ -61,7 +62,12 @@ public class ArcherMiniboss extends NetherMiniBoss<Skeleton>
|
||||
public void customDeath(Location deathLocation)
|
||||
{
|
||||
deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(5) + 1));
|
||||
if (new Random().nextDouble() <= .1)
|
||||
double runeDropChance = RUNE_DROP_CHANCE;
|
||||
if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier())
|
||||
{
|
||||
runeDropChance *= 2;
|
||||
}
|
||||
if (new Random().nextDouble() <= runeDropChance)
|
||||
{
|
||||
RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)];
|
||||
deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType));
|
||||
|
@ -1,10 +1,13 @@
|
||||
package mineplex.game.clans.clans.nether.miniboss.bosses;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.nether.miniboss.MinibossFireball;
|
||||
import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss;
|
||||
import mineplex.game.clans.items.runes.RuneManager.RuneAttribute;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -22,6 +25,7 @@ public class GhastMiniboss extends NetherMiniBoss<Ghast>
|
||||
private static final long MAIN_FIREBALL_COOLDOWN = 5000;
|
||||
private static final long FIREBALL_LAUNCH_RATE = 500;
|
||||
private static final int FIREBALLS_PER_USE = 5;
|
||||
private static final double RUNE_DROP_CHANCE = .1;
|
||||
private long _lastFireballUse;
|
||||
private int _fireballsRemaining;
|
||||
|
||||
@ -61,6 +65,16 @@ public class GhastMiniboss extends NetherMiniBoss<Ghast>
|
||||
public void customDeath(Location deathLocation)
|
||||
{
|
||||
deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(5) + 1));
|
||||
double runeDropChance = RUNE_DROP_CHANCE;
|
||||
if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier())
|
||||
{
|
||||
runeDropChance *= 2;
|
||||
}
|
||||
if (new Random().nextDouble() <= runeDropChance)
|
||||
{
|
||||
RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)];
|
||||
deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,6 +31,8 @@ import org.bukkit.potion.PotionEffectType;
|
||||
*/
|
||||
public class WarriorMiniboss extends NetherMiniBoss<Zombie>
|
||||
{
|
||||
private static final double RUNE_DROP_CHANCE = .1;
|
||||
|
||||
public WarriorMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type)
|
||||
{
|
||||
super(displayName, maxHealth, spawn, type);
|
||||
@ -58,7 +60,12 @@ public class WarriorMiniboss extends NetherMiniBoss<Zombie>
|
||||
public void customDeath(Location deathLocation)
|
||||
{
|
||||
deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(5) + 1));
|
||||
if (new Random().nextDouble() <= .1)
|
||||
double runeDropChance = RUNE_DROP_CHANCE;
|
||||
if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier())
|
||||
{
|
||||
runeDropChance *= 2;
|
||||
}
|
||||
if (new Random().nextDouble() <= runeDropChance)
|
||||
{
|
||||
RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)];
|
||||
deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType));
|
||||
|
@ -4,6 +4,38 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.weight.Weight;
|
||||
import mineplex.core.common.weight.WeightSet;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
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.event.ClansWaterPlaceEvent;
|
||||
import mineplex.game.clans.clans.event.IronDoorOpenEvent;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import mineplex.game.clans.items.GearManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.BlockTossLandEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
@ -14,7 +46,6 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -47,38 +78,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.Dye;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.common.weight.Weight;
|
||||
import mineplex.core.common.weight.WeightSet;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
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.event.ClansWaterPlaceEvent;
|
||||
import mineplex.game.clans.clans.event.IronDoorOpenEvent;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.BlockTossLandEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
|
||||
public class Gameplay extends MiniPlugin
|
||||
{
|
||||
private ClansManager _clansManager;
|
||||
@ -828,6 +827,12 @@ public class Gameplay extends MiniPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
if (GearManager.isCustomItem(item))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Repair", "You cannot repair " + F.item(item.getItemMeta().getDisplayName()) + "."));
|
||||
return;
|
||||
}
|
||||
|
||||
int repairs = ItemStackFactory.Instance.GetLoreVar(item, "Repaired", 0);
|
||||
boolean canRepair = canRepair(item);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user