From 8d32c35f889300df58cccb78eaf036b54a8d2703 Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 2 May 2017 18:57:20 +0200 Subject: [PATCH 001/283] Add basic Quest system --- .../src/mineplex/core/quests/Quest.java | 112 ++++++++++ .../mineplex/core/quests/QuestClientData.java | 18 ++ .../mineplex/core/quests/QuestManager.java | 26 +++ .../src/mineplex/core/quests/QuestRarity.java | 44 ++++ .../src/mineplex/core/quests/TriggerType.java | 36 ++++ .../quests/repository/QuestRepository.java | 19 ++ .../database/tables/AccountQuest.java | 114 ++++++++++ .../tables/records/AccountQuestRecord.java | 202 ++++++++++++++++++ 8 files changed, 571 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/QuestRarity.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/AccountQuest.java create mode 100644 Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountQuestRecord.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java new file mode 100644 index 000000000..7557e2baf --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java @@ -0,0 +1,112 @@ +package mineplex.core.quests; + +import mineplex.core.game.GameDisplay; + +/** + * Quest + * + * @author xXVevzZXx + */ +public class Quest +{ + private int _questID; + + private String _questName; + private String _questTask; + + private int _questCost; + private int _questReward; + + private QuestRarity _rarity; + private GameDisplay _game; + private TriggerType _trigger; + private String _item; + private int _statToComplete; + + private int _current; + + public Quest(int questID, String name, String task, int cost, int reward, QuestRarity rarity, GameDisplay game, TriggerType trigger, String item, int statToComplete) + { + _questID = questID; + _questName = name; + _questTask = task; + _questCost = cost; + _questReward = reward; + _rarity = rarity; + _game = game; + _trigger = trigger; + _item = item; + _statToComplete = statToComplete; + } + + public int getID() + { + return _questID; + } + + public String getName() + { + return _questName; + } + + public String getTask() + { + return _questTask; + } + + public int getCost() + { + return _questCost; + } + + public int getReward() + { + return _questReward; + } + + public QuestRarity getRarity() + { + return _rarity; + } + + public GameDisplay getGame() + { + return _game; + } + + public TriggerType getTrigger() + { + return _trigger; + } + + public String getItem() + { + return _item; + } + + public int getStatToComplete() + { + return _statToComplete; + } + + public void setProgress(int progress) + { + _current = progress; + } + + public void increment() + { + _current++; + } + + public void decrement() + { + _current--; + } + + public boolean isCompleted() + { + return _current == _statToComplete; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java new file mode 100644 index 000000000..1f7809dd8 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java @@ -0,0 +1,18 @@ +package mineplex.core.quests; + +import org.bukkit.entity.Player; + +/** + * QuestClientData + * + * @author xXVevzZXx + */ +public class QuestClientData +{ + + public QuestClientData(Player player) + { + + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java new file mode 100644 index 000000000..9da8eaae2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -0,0 +1,26 @@ +package mineplex.core.quests; + +import java.util.UUID; + +import mineplex.core.MiniClientPlugin; + +/** + * QuestManager + * + * @author xXVevzZXx + */ +public class QuestManager extends MiniClientPlugin +{ + + public QuestManager() + { + super("Quest Manager"); + } + + @Override + protected QuestClientData addPlayer(UUID uuid) + { + return null; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestRarity.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestRarity.java new file mode 100644 index 000000000..860fa52c8 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestRarity.java @@ -0,0 +1,44 @@ +package mineplex.core.quests; + +import org.bukkit.ChatColor; + +/** + * QuestRarity + * + * @author xXVevzZXx + */ +public enum QuestRarity +{ + COMMON("Common", ChatColor.YELLOW), RARE("Rare", ChatColor.LIGHT_PURPLE), LEGENDARY("Legendary", ChatColor.GREEN); + + private String _name; + private ChatColor _color; + + private QuestRarity(String name, ChatColor color) + { + _name = name; + _color = color; + } + + @Override + public String toString() + { + return _name; + } + + public ChatColor getColor() + { + return _color; + } + + public static QuestRarity getByName(String name) + { + for (QuestRarity rarity : values()) + { + if (rarity.toString().equalsIgnoreCase(name)) + return rarity; + } + return null; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java new file mode 100644 index 000000000..1cf1b7b32 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java @@ -0,0 +1,36 @@ +package mineplex.core.quests; + +/** + * TriggerType + * + * @author xXVevzZXx + */ +public enum TriggerType +{ + + KILL("Kill"), DIE("Die"), WIN("Win"), LOSE("Lose"), COLLECT("Collect"); + + private String _name; + + private TriggerType(String name) + { + _name = name; + } + + @Override + public String toString() + { + return _name; + } + + public static TriggerType getByName(String name) + { + for (TriggerType type : values()) + { + if (type.toString().equalsIgnoreCase(name)) + return type; + } + return null; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java new file mode 100644 index 000000000..faaa1077a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java @@ -0,0 +1,19 @@ +package mineplex.core.quests.repository; + +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; + +/** + * QuestRepository + * + * @author xXVevzZXx + */ +public class QuestRepository extends RepositoryBase +{ + + public QuestRepository() + { + super(DBPool.getAccount()); + } + +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountQuest.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountQuest.java new file mode 100644 index 000000000..e2794b6a1 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountQuest.java @@ -0,0 +1,114 @@ +package mineplex.database.tables; + +import org.jooq.impl.TableImpl; + +/** + * This class is generated by jOOQ. + */ +@javax.annotation.Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.5.2" + }, + comments = "This class is generated by jOOQ" +) +@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AccountQuest extends TableImpl implements java.io.Serializable, java.lang.Cloneable +{ + + /** + * + */ + private static final long serialVersionUID = -8158716179851336044L; + + /** + * The reference instance of Account.accountStat + */ + public static final mineplex.database.tables.AccountStat accountStat = new mineplex.database.tables.AccountStat(); + + /** + * The class holding records for this type + */ + @Override + public java.lang.Class getRecordType() { + return mineplex.database.tables.records.AccountQuestRecord.class; + } + + /** + * The column Account.accountStat.accountId. + */ + public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountStat.statId. + */ + public final org.jooq.TableField statId = createField("statId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Account.accountStat.value. + */ + public final org.jooq.TableField value = createField("value", org.jooq.impl.SQLDataType.BIGINTUNSIGNED.defaulted(true), this, ""); + + /** + * Create a Account.accountStat table reference + */ + public AccountQuest() + { + super("accountquest", null); + } + + /** + * Create an aliased Account.accountStat table reference + */ + public AccountQuest(java.lang.String alias) { + this(alias, mineplex.database.tables.AccountQuest.accountStat); + } + + private AccountQuest(java.lang.String alias, org.jooq.Table aliased) { + this(alias, aliased, null); + } + + private AccountQuest(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { + super(alias, mineplex.database.Account.Account, aliased, parameters, ""); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.UniqueKey getPrimaryKey() { + return mineplex.database.Keys.KEY_accountStat_PRIMARY; + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getKeys() { + return java.util.Arrays.>asList(mineplex.database.Keys.KEY_accountStat_PRIMARY); + } + + /** + * {@inheritDoc} + */ + @Override + public java.util.List> getReferences() { + return java.util.Arrays.>asList(mineplex.database.Keys.accountStat_account, mineplex.database.Keys.accountStat_stat); + } + + /** + * {@inheritDoc} + */ + @Override + public mineplex.database.tables.AccountStat as(java.lang.String alias) { + return new mineplex.database.tables.AccountStat(alias, this); + } + + /** + * Rename this table + */ + public mineplex.database.tables.AccountStat rename(java.lang.String name) { + return new mineplex.database.tables.AccountStat(name, null); + } + +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountQuestRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountQuestRecord.java new file mode 100644 index 000000000..c707a42c7 --- /dev/null +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountQuestRecord.java @@ -0,0 +1,202 @@ +package mineplex.database.tables.records; + +import org.jooq.Table; + +/** + * AccountQuest + * + * @author xXVevzZXx + */ +public class AccountQuestRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 +{ + + /** + * + */ + private static final long serialVersionUID = 5171965369180094201L; + + public AccountQuestRecord(Table table) + { + super(table); + } + + /** + * Setter for Account.accountStat.accountId. + */ + public void setAccountId(java.lang.Integer value) { + setValue(0, value); + } + + /** + * Getter for Account.accountStat.accountId. + */ + public java.lang.Integer getAccountId() { + return (java.lang.Integer) getValue(0); + } + + /** + * Setter for Account.accountStat.statId. + */ + public void setStatId(java.lang.Integer value) { + setValue(1, value); + } + + /** + * Getter for Account.accountStat.statId. + */ + public java.lang.Integer getStatId() { + return (java.lang.Integer) getValue(1); + } + + /** + * Setter for Account.accountStat.value. + */ + public void setValue(org.jooq.types.ULong value) { + setValue(2, value); + } + + /** + * Getter for Account.accountStat.value. + */ + public org.jooq.types.ULong getValue() { + return (org.jooq.types.ULong) getValue(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Record2 key() { + return (org.jooq.Record2) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 fieldsRow() { + return (org.jooq.Row3) super.fieldsRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Row3 valuesRow() { + return (org.jooq.Row3) super.valuesRow(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field1() { + return mineplex.database.tables.AccountStat.accountStat.accountId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field2() { + return mineplex.database.tables.AccountStat.accountStat.statId; + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.Field field3() { + return mineplex.database.tables.AccountStat.accountStat.value; + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value1() { + return getAccountId(); + } + + /** + * {@inheritDoc} + */ + @Override + public java.lang.Integer value2() { + return getStatId(); + } + + /** + * {@inheritDoc} + */ + @Override + public org.jooq.types.ULong value3() { + return getValue(); + } + + /** + * {@inheritDoc} + */ + @Override + public AccountStatRecord value1(java.lang.Integer value) { + setAccountId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountStatRecord value2(java.lang.Integer value) { + setStatId(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountStatRecord value3(org.jooq.types.ULong value) { + setValue(value); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AccountStatRecord values(java.lang.Integer value1, java.lang.Integer value2, org.jooq.types.ULong value3) { + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached AccountStatRecord + */ + public AccountStatRecord() { + super(mineplex.database.tables.AccountStat.accountStat); + } + + /** + * Create a detached, initialised AccountStatRecord + */ + public AccountStatRecord(java.lang.Integer accountId, java.lang.Integer statId, org.jooq.types.ULong value) { + super(mineplex.database.tables.AccountStat.accountStat); + + setValue(0, accountId); + setValue(1, statId); + setValue(2, value); + } + +} From ff13d07a7c5d5652e283cd4f54a3cfe8eebcb6e5 Mon Sep 17 00:00:00 2001 From: Kenny Date: Tue, 2 May 2017 20:29:36 -0400 Subject: [PATCH 002/283] Port redis pubsub messaging API from PE --- Plugins/Mineplex.ServerData/pom.xml | 10 + .../redis/messaging/PubSubJedisClient.java | 356 ++++++++++++++++++ .../redis/messaging/PubSubLibraryClient.java | 61 +++ .../redis/messaging/PubSubMessager.java | 56 +++ .../redis/messaging/PubSubRouter.java | 165 ++++++++ .../redis/messaging/Subscriber.java | 19 + 6 files changed, 667 insertions(+) create mode 100644 Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubJedisClient.java create mode 100644 Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubLibraryClient.java create mode 100644 Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubMessager.java create mode 100644 Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubRouter.java create mode 100644 Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/Subscriber.java diff --git a/Plugins/Mineplex.ServerData/pom.xml b/Plugins/Mineplex.ServerData/pom.xml index 84a00934c..85d99c4e7 100644 --- a/Plugins/Mineplex.ServerData/pom.xml +++ b/Plugins/Mineplex.ServerData/pom.xml @@ -8,6 +8,10 @@ mineplex-parent dev-SNAPSHOT + + + 18.0 + mineplex-serverdata @@ -33,5 +37,11 @@ jooq 3.5.2 + + com.google.guava + guava + ${version.guava} + compile + diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubJedisClient.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubJedisClient.java new file mode 100644 index 000000000..5a8cfa8a5 --- /dev/null +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubJedisClient.java @@ -0,0 +1,356 @@ +package mineplex.serverdata.redis.messaging; + +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; + +import mineplex.serverdata.Utility; +import mineplex.serverdata.servers.ConnectionData; + +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.JedisPubSub; +import redis.clients.jedis.exceptions.JedisConnectionException; +import redis.clients.jedis.exceptions.JedisDataException; + +/** + * A subscription to a Redis pub/sub system through a Jedis client. Includes a publishing mechanism + * as well. + *

+ * Subscribes to Jedis and offers a variety of methods to edit the channels that this listens to + * over time. Does not support pattern-matching, even though Jedis can. Takes a single subscriber to + * inform of incoming messages (on all channels this is subscribed to). + *

+ * For the sake of internal efficiency, this does not protect the sanity or unchangeability of + * arguments passed into its methods. Clients should not generally interact with this directly. + *

+ * The Jedis pub/sub interface is a little confusing, especially when it comes to multithreading. At + * any given time, if this class is subscribed to any channels at all, it will have a single thread + * that is listening for incoming messages from redis with a blocking method. After that listening + * thread is created, we can add and remove subscriptions as desired, but the initial subscription + * and actual listening must be done on its own thread. When all channels are unsubscribed from, the + * listening thread returns. Note that this is stated with about 70% certainty, as the internals of + * the pub/sub mechanism are not entirely clear to me. + *

+ * This class maintains a constant connection to its redis server by subscribing to a base channel. + * This makes it much easier to protect its operation from potentially insane client commands. + *

+ * If the connection to the given redis instance fails or is interrupted, will keep attempting to + * reconnect periodically until destroyed. Publishers and subscribers are not informed of failure in + * any way. + *

+ * When {@link #unsubscribe()} or {@link #destroy()} is called, this class ceases operation. + */ +public class PubSubJedisClient extends JedisPubSub implements PubSubLibraryClient +{ + + private static final long RECONNECT_PERIOD_MILLIS = 800; + private static final String BASE_CHANNEL = "pG8n5jp#"; + + private static final String BOLD = "\u001B[1m"; + private static final String RESET = "\u001B[0m"; + + private final String _id; + private JedisPool _writePool; + private final ConnectionData _readConn; + private JedisPool _readPool; + private final ExecutorService _threadPool = Executors.newCachedThreadPool(); + private volatile Subscriber _sub; + + private final Set _channels = Collections + .newSetFromMap(new ConcurrentHashMap()); + private final Map> _pendingFutures = new ConcurrentHashMap>(); + + private volatile boolean _subscribed; // Is there a base subscription yet? + private volatile boolean _destroyed; // has this been deliberately destroyed? + + /** + * Class constructor. + * + * @param writeTo The connection info for the redis instance this client should publish to. + * @param readFrom The connection info for the redis instance this client to subscribe to. + */ + public PubSubJedisClient(ConnectionData writeTo, ConnectionData readFrom) + { + if (writeTo == null) + { + throw new IllegalArgumentException("redis connection info cannot be null"); + } + + _id = writeTo.getName(); + _writePool = Utility.generatePool(writeTo); + + _readConn = readFrom; + _readPool = Utility.generatePool(readFrom); + + createSubscription(BASE_CHANNEL); + } + + @Override + public final synchronized void setSubscriber(Subscriber sub) + { + _sub = sub; + } + + @Override + public final ListenableFuture addChannel(String channel) + { + SettableFuture ret = _pendingFutures.get(channel); + if (ret == null) + { + ret = SettableFuture.create(); + _pendingFutures.put(channel, ret); + } + + try + { + _channels.add(channel); + + if (_subscribed) + { // Already has a subscription thread and can just add a new channel to it. + subscribe(channel); + } + } catch (Exception ex) + { + log("Encountered issue subscribing to a channel."); + ex.printStackTrace(); + ret.setException(ex); + } + + return ret; + } + + @Override + public final void removeChannel(String channel) + { + if (BASE_CHANNEL.equals(channel)) + { // Protects the base subscription + return; + } + + _channels.remove(channel); + + if (_subscribed) + { + unsubscribe(channel); + } + } + + @Override + public final void unsubscribe() + { + destroy(); + } + + @Override + public final void destroy() + { + _destroyed = true; + try + { + super.unsubscribe(); + } catch (NullPointerException e) + { + } + + for (SettableFuture fut : _pendingFutures.values()) + { + fut.set(false); + } + } + + @Override + public final void onMessage(String channel, String message) + { + if (_sub == null || BASE_CHANNEL.equals(channel)) + { + return; + } + + try + { + _sub.onMessage(channel, message); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + @Override + public final ListenableFuture publish(final String channel, final String message) + { + final SettableFuture ret = SettableFuture.create(); + _threadPool.execute(new Runnable() + { + @Override + public void run() + { + Jedis bJedis = null; + try + { + bJedis = _writePool.getResource(); + bJedis.publish(channel, message); + _writePool.returnResource((Jedis) bJedis); + ret.set(true); + + } catch (Exception e) + { + log("Encountered issue while publishing a message."); + e.printStackTrace(); + if (bJedis != null) + { + _writePool.returnBrokenResource((Jedis) bJedis); + } + ret.set(false); + } + } + }); + return ret; + } + + // Confirms successful subscriptions/unsubscriptions. + @Override + public void onSubscribe(String channel, int subscribedChannels) + { + + // informs subscriber that this subscription completed successfully + SettableFuture fut = _pendingFutures.remove(channel); + if (fut != null) + { + fut.set(true); + } + + if (!_subscribed) + { + for (String subscribeTo : _channels) + { + subscribe(subscribeTo); + } + } + _subscribed = true; + + log("Subscribed to channel: " + channel); + } + + @Override + public void onUnsubscribe(String channel, int subscribedChannels) + { + log("Unsubscribed from channel: " + channel); + } + + /** + * Creates the initial listening thread which blocks as it polls redis for new messages. + * Subsequent subscriptions can simply be added using {@link #subscribe(String...)} after the + * subscription thread has been created. + * + * @param firstChannel The first channel to initially subscribe to. If you do not have a first + * channel, there is no reason to create a subscriber thread yet. + */ + private void createSubscription(final String firstChannel) + { + + final JedisPubSub pubsub = this; + + new Thread(new Runnable() + { + @Override + public void run() + { + + boolean first = true; + + while (!_destroyed) + { + + if (!first) + { + log("Jedis connection to " + _readConn.getHost() + ":" + + _readConn.getPort() + + " failed or was interrupted, attempting to reconnect"); + } + first = false; + + Jedis jedisInstance = null; + + try + { + // gets a non-thread-safe jedis instance from the thread-safe pool. + jedisInstance = _readPool.getResource(); + + log("Creating initial jedis subscription to channel " + firstChannel); + // this will block as long as there are subscriptions + jedisInstance.subscribe(pubsub, firstChannel); + + log("jedisInstance.subscribe() returned, subscription over."); + + // when the subscription ends (subscribe() returns), returns the instance to + // the pool + _readPool.returnResource(jedisInstance); + + } catch (JedisConnectionException e) + { + log("Jedis connection encountered an issue."); + e.printStackTrace(); + if (jedisInstance != null) + { + _readPool.returnBrokenResource((Jedis) jedisInstance); + } + + } catch (JedisDataException e) + { + log("Jedis connection encountered an issue."); + e.printStackTrace(); + if (jedisInstance != null) + { + _readPool.returnBrokenResource((Jedis) jedisInstance); + } + } + _subscribed = false; + + // sleeps for a short pause, rather than constantly retrying connection + if (!_destroyed) + { + try + { + Thread.sleep(RECONNECT_PERIOD_MILLIS); + } catch (InterruptedException e) + { + _destroyed = true; + log("Reconnection pause thread was interrupted."); + e.printStackTrace(); + } + } + } + } + }).start(); + } + + // This implementation does not support pattern-matching subscriptions + @Override + public void onPMessage(String pattern, String channel, String message) + { + } + + @Override + public void onPSubscribe(String pattern, int subscribedChannels) + { + } + + @Override + public void onPUnsubscribe(String pattern, int subscribedChannels) + { + } + + private void log(String msg) + { + System.out.println(BOLD + "[" + getClass().getSimpleName() + + (_id != null && !_id.isEmpty() ? " " + _id : "") + "] " + RESET + msg); + } + +} diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubLibraryClient.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubLibraryClient.java new file mode 100644 index 000000000..4a9f2820c --- /dev/null +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubLibraryClient.java @@ -0,0 +1,61 @@ +package mineplex.serverdata.redis.messaging; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * A multi-channel subscription and publisher to a pub/sub messaging implementation. An interface to + * the actual low-level pub/sub library, whatever it may be. + * + * For the sake of internal efficiency, this makes no guarantees for the sanity or unchangeability + * of arguments passed into its methods. Clients should not generally interact with this directly. + */ +public interface PubSubLibraryClient +{ + + /** + * Publishes a message to all subscribers of a given channel. + * + * @param channel The channel to publish the message on. + * @param message The message to send. + * @return A future object that will complete after an unknown amount of time with + * false if for some locally known reason the message definitely could not + * be published, else completes with true. + */ + ListenableFuture publish(String channel, String message); + + /** + * Adds a channel to this subscription. + * + * @param channel The channel to add. Should not change after being passed in. + * @return The asynchronous, future result of this attempt to add the channel. Will have + * true when the subscription starts successfully. + */ + ListenableFuture addChannel(String channel); + + /** + * Removes a channel from this subscription. + * + * @param channel The channel to remove. Should not change after being passed in. + */ + void removeChannel(String channel); + + /** + * Removes all channels from this subscription, kills its connections, and relinquishes any + * resources it was occupying. + *

+ * Depending on the implementation, once a subscription has been destroyed, it may not be + * reusable and it may be necessary to construct a new one in order to resume. + *

+ * Call this when the subscription is no longer being used. Holding unnecessary connections can + * cause serious performance and other issues on both ends. + */ + void destroy(); + + /** + * Sets the subscriber to inform of messages received by this subscription. + * + * @param sub The listener for this subscription. + */ + void setSubscriber(Subscriber sub); + +} diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubMessager.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubMessager.java new file mode 100644 index 000000000..ea45109e1 --- /dev/null +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubMessager.java @@ -0,0 +1,56 @@ +package mineplex.serverdata.redis.messaging; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Messager for standard pub/sub model. Handles multiple publishers and subscribers. + *

+ * All messaging is asynchronous and non-blocking, even to local subscribers. + *

+ * For more about the pub/sub messaging paradigm, see http://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern + */ +public interface PubSubMessager +{ + + /** + * Publishes a message to all subscribers of a given channel. + *

+ * Publishes to all connected subscribers, including local ones. + * + * @param channel The channel to publish the message on. + * @param message The message to send. + * @return A future object that will complete after an unknown amount of time with + * false if for some locally known reason the message definitely could not + * be published, else completes with true (which does not guarantee it + * succeeded 100%). + */ + ListenableFuture publish(String channel, String message); + + /** + * Subscribes to a messaging channel. + *

+ * When incoming messages arrive, the subscriber is called from an arbitrary new thread. + * + * @param channel The channel to subscribe to. + * @param sub The subscriber to inform of incoming messages. + * @return The asynchronous, future result of this attempt to subscribe to the channel. Will + * have true when the subscription starts successfully. + */ + ListenableFuture subscribe(String channel, Subscriber sub); + + /** + * Unsubscribes from a messaging channel. + * + * @param channel The channel to unsubscribe from. + * @param sub The subscriber to stop informing of incoming messages. + */ + void unsubscribe(String channel, Subscriber sub); + + /** + * Attempts to gracefully shut down this messager. Generally irreversible. + */ + void shutdown(); + +} diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubRouter.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubRouter.java new file mode 100644 index 000000000..453b90743 --- /dev/null +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/PubSubRouter.java @@ -0,0 +1,165 @@ +package mineplex.serverdata.redis.messaging; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; + +/** + * A pub/sub messager that simply routes messages to some underlying pub/sub implementation, which + * is in turn represented by a multi-channel subscription and a publishing mechanism. + *

+ * This class handles: + *

    + *
  1. Providing a modular messaging interface that is thread-safe. + *
  2. Protecting pub/sub implementations from some bad client behavior/data. + *
  3. Routing messages for multiple subscribers to the same channel(s). + *
+ */ +public class PubSubRouter implements PubSubMessager, Subscriber +{ + + private final PubSubLibraryClient _pubSubClient; + private final Map> _subscribers; + + private final ExecutorService _threadPool; + + public PubSubRouter(PubSubLibraryClient client) + { + if (client == null) + { + throw new IllegalArgumentException("pubsub client cannot be null"); + } + + this._pubSubClient = client; + this._pubSubClient.setSubscriber(this); + this._subscribers = new ConcurrentHashMap>(); + + this._threadPool = Executors.newCachedThreadPool(); + } + + @Override + public final ListenableFuture publish(String channel, String message) + { + if (channel == null || channel.isEmpty()) + { + throw new IllegalArgumentException("channel cannot be null or empty"); + } + + // messages of 0 length are allowed. Null messages are treated as messages of 0 length. + if (message == null) + { + message = ""; + } + + return _pubSubClient.publish(channel, message); + } + + @Override + public final ListenableFuture subscribe(String channel, Subscriber sub) + { + if (channel == null || channel.isEmpty() || sub == null) + { + throw new IllegalArgumentException("params cannot be null and channel cannot be empty"); + } + + ListenableFuture ret = null; + + Set channelSubs = _subscribers.get(channel); + if (channelSubs == null) + { + // uses CopyOnWriteArraySet for fast and consistent iteration (forwarding messages to + // subscribers) but slow writes (adding/removing subscribers). + // See a discussion of the issue here: + // http://stackoverflow.com/questions/6720396/different-types-of-thread-safe-sets-in-java + channelSubs = new CopyOnWriteArraySet(); + _subscribers.put(channel, channelSubs); + + // starts a jedis subscription to the channel if there were no subscribers before + ret = _pubSubClient.addChannel(channel); + + } else + { + ret = SettableFuture.create(); + ((SettableFuture) ret).set(true); // already subscribed, calls back immediately + } + + channelSubs.add(sub); + + return ret; + } + + @Override + public final void unsubscribe(String channel, Subscriber sub) + { + if (channel == null || channel.isEmpty() || sub == null) + { + throw new IllegalArgumentException("params cannot be null and channel cannot be empty"); + } + + Set channelSubs = _subscribers.get(channel); + if (channelSubs == null) + { // no subscribers for the channel to begin with. + return; + } + + channelSubs.remove(sub); + + // stops the subscription to this channel if the unsubscribed was the last subscriber + if (channelSubs.isEmpty()) + { + _subscribers.remove(channel); + _pubSubClient.removeChannel(channel); + } + } + + @Override + public final void onMessage(final String channel, final String message) + { + if (channel == null || message == null || channel.isEmpty()) + { + return; + } + + Set channelSubs = _subscribers.get(channel); + + if (channelSubs == null) + { // We should not still be listening + _pubSubClient.removeChannel(channel); + return; + } else if (channelSubs.isEmpty()) + { + _subscribers.remove(channel); + _pubSubClient.removeChannel(channel); + return; + } + + for (final Subscriber sub : channelSubs) + { + + // Gives subscribers their own thread from the thread pool in which to react to the + // message. + // Avoids interruptions and other problems while iterating over the subscriber set. + _threadPool.execute(new Runnable() + { + @Override + public void run() + { + sub.onMessage(channel, message); + } + }); + } + } + + @Override + public void shutdown() + { + _pubSubClient.destroy(); + } + +} diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/Subscriber.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/Subscriber.java new file mode 100644 index 000000000..5ecc09796 --- /dev/null +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/messaging/Subscriber.java @@ -0,0 +1,19 @@ +package mineplex.serverdata.redis.messaging; + +/** + * A subscriber to a pub/sub channel. + */ +public interface Subscriber +{ + + /** + * Called when a message is sent on a channel that this is subscribed to. + *

+ * No guarantees are made about what thread this will be called from. + * + * @param channel The channel that the message was sent on. + * @param message The message that was received. + */ + void onMessage(String channel, String message); + +} From 87c01f994c37c6b272bf44d2fa8d42f73bb187d2 Mon Sep 17 00:00:00 2001 From: Kenny Date: Tue, 2 May 2017 20:31:40 -0400 Subject: [PATCH 003/283] Port questmanager service from PE --- Plugins/mineplex-questmanager/pom.xml | 69 ++++++ .../quest/client/RedisQuestSupplier.java | 93 +++++++ .../client/event/QuestsUpdatedEvent.java | 44 ++++ .../src/mineplex/quest/common/Quest.java | 43 ++++ .../mineplex/quest/common/QuestRarity.java | 25 ++ .../mineplex/quest/common/QuestSupplier.java | 29 +++ .../src/mineplex/quest/common/Quests.java | 69 ++++++ .../quest/common/redis/PubSubChannels.java | 11 + .../redis/QuestRedisDataRepository.java | 28 +++ .../common/redis/QuestTypeDeserialiazer.java | 34 +++ .../common/redis/QuestTypeSerializer.java | 44 ++++ .../quest/common/util/RandomCollection.java | 53 ++++ .../mineplex/quest/daemon/QuestDaemon.java | 160 ++++++++++++ .../mineplex/quest/daemon/QuestManager.java | 227 ++++++++++++++++++ Plugins/pom.xml | 1 + 15 files changed, 930 insertions(+) create mode 100644 Plugins/mineplex-questmanager/pom.xml create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/client/event/QuestsUpdatedEvent.java create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/common/Quest.java create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/common/QuestRarity.java create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/common/QuestSupplier.java create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/common/Quests.java create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/PubSubChannels.java create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestRedisDataRepository.java create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestTypeDeserialiazer.java create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestTypeSerializer.java create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/common/util/RandomCollection.java create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestDaemon.java create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java diff --git a/Plugins/mineplex-questmanager/pom.xml b/Plugins/mineplex-questmanager/pom.xml new file mode 100644 index 000000000..e41a4c469 --- /dev/null +++ b/Plugins/mineplex-questmanager/pom.xml @@ -0,0 +1,69 @@ + + 4.0.0 + + com.mineplex + mineplex-parent + dev-SNAPSHOT + + mineplex-questmanager + Mineplex.QuestManager + A centralized service that selects daily quests + + + 18.0 + 2.12 + 1.8.8-1.9-SNAPSHOT + + + + + ${project.groupId} + mineplex-serverdata + ${project.version} + + + com.google.guava + guava + ${version.guava} + compile + + + jline + jline + ${version.jline} + compile + + + com.mineplex + spigot + provided + + + + + + + org.apache.maven.plugins + maven-shade-plugin + + false + + + mineplex.quest.daemon.QuestDaemon + + + + + + package + + shade + + + + + + + \ No newline at end of file diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java new file mode 100644 index 000000000..1adf05571 --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java @@ -0,0 +1,93 @@ +package mineplex.quest.client; + +import java.util.HashSet; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.collect.ImmutableSet; + +import mineplex.quest.client.event.QuestsUpdatedEvent; +import mineplex.quest.common.Quest; +import mineplex.quest.common.QuestSupplier; +import mineplex.quest.common.redis.PubSubChannels; +import mineplex.quest.common.redis.QuestTypeSerializer; +import mineplex.serverdata.redis.messaging.PubSubMessager; + +/** + * Provides methods to retrieve currently active quests. Retrieves active quests from the + * centralized quest service via redis. + *

+ * Intended to be thread-safe. + */ +public class RedisQuestSupplier implements QuestSupplier +{ + + private final JavaPlugin _plugin; + private final PubSubMessager _pubSub; + private final ReadWriteLock _lock = new ReentrantReadWriteLock(); + + private final Set _quests = new HashSet<>(); + + public RedisQuestSupplier(JavaPlugin plugin, PubSubMessager pubSub) + { + _plugin = plugin; + _pubSub = pubSub; + + // update quests when received + _pubSub.subscribe(PubSubChannels.QUEST_SUPPLIER_CHANNEL, this::updateQuests); + } + + private void updateQuests(String channel, String message) + { + _lock.writeLock().lock(); + try + { + _quests.clear(); + _quests.addAll(deserialize(message)); + + // notify + _plugin.getServer().getPluginManager().callEvent(new QuestsUpdatedEvent(get())); + } + finally + { + _lock.writeLock().unlock(); + } + } + + private Set deserialize(String json) + { + return QuestTypeSerializer.QUEST_GSON.fromJson(json, QuestTypeSerializer.QUEST_TYPE); + } + + @Override + public Set get() + { + _lock.readLock().lock(); + try + { + return ImmutableSet.copyOf(_quests); + } + finally + { + _lock.readLock().unlock(); + } + } + + @Override + public Optional getById(int uniquePersistentId) + { + _lock.readLock().lock(); + try + { + return _quests.stream().filter(q -> q.getUniqueId() == uniquePersistentId).findFirst(); + } + finally + { + _lock.readLock().unlock(); + } + } +} \ No newline at end of file diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/client/event/QuestsUpdatedEvent.java b/Plugins/mineplex-questmanager/src/mineplex/quest/client/event/QuestsUpdatedEvent.java new file mode 100644 index 000000000..82b70450a --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/client/event/QuestsUpdatedEvent.java @@ -0,0 +1,44 @@ +package mineplex.quest.client.event; + +import java.util.Set; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.quest.common.Quest; + +/** + * An event called when the currently active quests are rotated at the end of a day. + */ +public class QuestsUpdatedEvent extends Event +{ + + private static final HandlerList HANDLERS = new HandlerList(); + + private final Set _to; + + public QuestsUpdatedEvent(Set to) + { + _to = to; + } + + /** + * @return The currently active quests. + */ + public Set getActiveQuests() + { + return _to; + } + + @Override + public HandlerList getHandlers() + { + return HANDLERS; + } + + public static HandlerList getHandlerList() + { + return HANDLERS; + } + +} diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quest.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quest.java new file mode 100644 index 000000000..3802b928d --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quest.java @@ -0,0 +1,43 @@ +package mineplex.quest.common; + +import mineplex.serverdata.data.Data; +import mineplex.serverdata.data.DataRepository; + +/** + * A quest that can be completed by users for a reward. + */ +public interface Quest extends Data +{ + /** + * Gets the name of this quest. + * + * @return The name of this quest. + */ + String getName(); + + /** + * Gets the unique persistent id for this quest. This id will be used to store quests per user + * and should not be changed. + * + * @return The unique persistent id for this quest. + */ + int getUniqueId(); + + /** + * Gets the {@link QuestRarity} of this quest. + * + * @return The rarity of this quest. + */ + QuestRarity getRarity(); + + /** + * Get the unique persistent id for this quest as a String. Intended to be used for storage + * within Redis via {@link DataRepository}. + *

+ * Don't use this to get the quest unique id, use {@link Quest#getUniqueId()} instead. + * + * @return A string version of the unique persistent id for this quest. + */ + @Override + String getDataId(); +} diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/QuestRarity.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/QuestRarity.java new file mode 100644 index 000000000..b5d85b0e9 --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/QuestRarity.java @@ -0,0 +1,25 @@ +package mineplex.quest.common; + +/** + * How rare a quest is. In other words, how often this quest should be chosen. + */ +public enum QuestRarity +{ + // TODO fill in actual weights + COMMON(0.5), + RARE(0.3), + LEGENDARY(0.1) + ; + + private final double _weight; + + private QuestRarity(double weight) + { + _weight = weight; + } + + public double getWeight() + { + return _weight; + } +} diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/QuestSupplier.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/QuestSupplier.java new file mode 100644 index 000000000..9e32a2d80 --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/QuestSupplier.java @@ -0,0 +1,29 @@ +package mineplex.quest.common; + +import java.util.Optional; +import java.util.Set; +import java.util.function.Supplier; + +/** + * Provides access to {@link Quest}s tracked by this QuestManager. + */ +public interface QuestSupplier extends Supplier> +{ + + /** + * Get an immutable set containing all of the currently active quests. + */ + @Override + Set get(); + + /** + * Attempts to get the {@link Quest} matching the supplied persistent id. + * + * @param uniquePersistentId The unique id of the quest. + * + * @return An {@link Optional} describing the {@link Quest}, or an empty Optional if none is + * found. + */ + Optional getById(int uniquePersistentId); + +} diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quests.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quests.java new file mode 100644 index 000000000..1057ef12b --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quests.java @@ -0,0 +1,69 @@ +package mineplex.quest.common; + +/** + * A centralized list of {@link Quest}s. + *

+ * When adding new quests they should be given an enum field here & then added to the minecraft + * server plugin in the form of a "tracker" that watches progress per user. + */ +public enum Quests implements Quest +{ + // TODO add actual quests + + EXAMPLE_QUEST_1("1", 0, QuestRarity.COMMON), + EXAMPLE_QUEST_2("2", 1, QuestRarity.COMMON), + EXAMPLE_QUEST_3("3", 2, QuestRarity.RARE), + EXAMPLE_QUEST_4("4", 3, QuestRarity.LEGENDARY), + EXAMPLE_QUEST_5("5", 4, QuestRarity.COMMON), + + ; + + private final String _name; + private final int _uniqueId; + private final QuestRarity _rarity; + + Quests(String name, int uniqueId, QuestRarity rarity) + { + _name = name; + _uniqueId = uniqueId; + _rarity = rarity; + } + + @Override + public String getName() + { + return _name; + } + + @Override + public QuestRarity getRarity() + { + return _rarity; + } + + @Override + public int getUniqueId() + { + return _uniqueId; + } + + @Override + public String getDataId() + { + return String.valueOf(_uniqueId); + } + + public static Quest fromId(int id) + { + for (Quest q : values()) + { + if (q.getUniqueId() == id) + { + return q; + } + } + + return null; + } + +} \ No newline at end of file diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/PubSubChannels.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/PubSubChannels.java new file mode 100644 index 000000000..886250950 --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/PubSubChannels.java @@ -0,0 +1,11 @@ +package mineplex.quest.common.redis; + +/** + * Provides constants for Quests redis pub sub channels. + */ +public class PubSubChannels +{ + + public static final String QUEST_SUPPLIER_CHANNEL = "quest-manager"; + +} diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestRedisDataRepository.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestRedisDataRepository.java new file mode 100644 index 000000000..2037aaa9a --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestRedisDataRepository.java @@ -0,0 +1,28 @@ +package mineplex.quest.common.redis; + +import mineplex.quest.common.Quest; +import mineplex.quest.common.Quests; +import mineplex.serverdata.Region; +import mineplex.serverdata.redis.RedisDataRepository; +import mineplex.serverdata.servers.ConnectionData; + +/** + * A {@link RedisDataRepository} that can serialize & deserialize (and thus store & retrieve from + * redis) Quest instances. + */ +public class QuestRedisDataRepository extends RedisDataRepository +{ + + public QuestRedisDataRepository(ConnectionData writeConn, ConnectionData readConn, Region region, + String elementLabel) + { + super(writeConn, readConn, region, Quest.class, elementLabel); + } + + @Override + protected Quest deserialize(String json) + { + return Quests.fromId(Integer.parseInt(json)); + } + +} diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestTypeDeserialiazer.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestTypeDeserialiazer.java new file mode 100644 index 000000000..6e97775c8 --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestTypeDeserialiazer.java @@ -0,0 +1,34 @@ +package mineplex.quest.common.redis; + +import java.lang.reflect.Type; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; + +import com.google.gson.Gson; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; + +import mineplex.quest.common.Quest; +import mineplex.quest.common.Quests; + +/** + * An implementation of a {@link JsonDeserializer} intended for use in {@link Gson}. Deserializes a + * {@link JsonElement} String into a Set. + */ +public class QuestTypeDeserialiazer implements JsonDeserializer> +{ + + @Override + public Set deserialize(JsonElement json, Type typeOfT, + JsonDeserializationContext context) throws JsonParseException + { + String[] split = json.getAsString().split(QuestTypeSerializer.SEPARATOR); + return Arrays.stream(split).map(questId -> Quests.fromId(Integer.valueOf(questId))) + .collect(Collectors.toCollection(HashSet::new)); + } + +} diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestTypeSerializer.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestTypeSerializer.java new file mode 100644 index 000000000..67905f1a2 --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestTypeSerializer.java @@ -0,0 +1,44 @@ +package mineplex.quest.common.redis; + +import java.lang.reflect.Type; +import java.util.Set; +import java.util.stream.Collectors; + +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import mineplex.quest.common.Quest; + +/** + * An implementation of a {@link JsonSerializer} intended for use in {@link Gson}. Serializes a + * Set into a {@link JsonElement} String. + */ +public class QuestTypeSerializer implements JsonSerializer> +{ + + @SuppressWarnings("serial") + public static final Type QUEST_TYPE = new TypeToken>(){}.getType(); + + public static final Gson QUEST_GSON = new GsonBuilder() + .registerTypeAdapter(QuestTypeSerializer.QUEST_TYPE, new QuestTypeDeserialiazer()) + .registerTypeAdapter(QuestTypeSerializer.QUEST_TYPE, new QuestTypeSerializer()) + .create(); + + public static final String SEPARATOR = ","; + + @Override + public JsonElement serialize(Set src, Type typeOfSrc, JsonSerializationContext context) + { + StringBuilder builder = new StringBuilder(); + Joiner.on(SEPARATOR).appendTo(builder, + src.stream().map(Quest::getDataId).collect(Collectors.toSet())); + return new JsonPrimitive(builder.toString()); + } + +} diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/RandomCollection.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/RandomCollection.java new file mode 100644 index 000000000..b624e1319 --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/RandomCollection.java @@ -0,0 +1,53 @@ +package mineplex.quest.common.util; + +import java.util.Map; +import java.util.NavigableMap; +import java.util.Random; +import java.util.TreeMap; +import java.util.concurrent.ThreadLocalRandom; + +/** + * Provides random, weighted access to a collection of elements. + * + * @param The generic type parameter of the elements. + */ +public class RandomCollection +{ + + private final NavigableMap _map = new TreeMap(); + private final Random _random; + + private double total = 0; + + public RandomCollection(Random random) + { + _random = random; + } + + public RandomCollection() + { + this(ThreadLocalRandom.current()); + } + + public void addAll(Map values) + { + values.forEach(this::add); + } + + public void add(E result, double weight) + { + if (weight <= 0) + { + return; + } + + total += weight; + _map.put(total, result); + } + + public E next() + { + double value = _random.nextDouble() * total; + return _map.ceilingEntry(value).getValue(); + } +} diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestDaemon.java b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestDaemon.java new file mode 100644 index 000000000..ae124459e --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestDaemon.java @@ -0,0 +1,160 @@ +package mineplex.quest.daemon; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.logging.FileHandler; +import java.util.logging.Formatter; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +import org.fusesource.jansi.AnsiConsole; + +import com.google.common.base.Throwables; + +import mineplex.serverdata.redis.messaging.PubSubJedisClient; +import mineplex.serverdata.redis.messaging.PubSubRouter; +import mineplex.serverdata.servers.ServerManager; + +import jline.console.ConsoleReader; + +/** + * Entry point for a {@link QuestManager} service. + */ +public class QuestDaemon +{ + + public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("MM:dd:yyyy HH:mm:ss"); + + private static final Logger _logger = Logger.getLogger("QuestManager"); + static + { + FileHandler fileHandler; + try + { + fileHandler = new FileHandler("monitor.log", true); + fileHandler.setFormatter(new Formatter() + { + @Override + public String format(LogRecord record) + { + return record.getMessage() + "\n"; + } + }); + _logger.addHandler(fileHandler); + _logger.setUseParentHandlers(false); + } + catch (SecurityException | IOException e) + { + log("COuld not initialize log file!"); + log(e); + } + } + + private volatile boolean _alive = true; + + private QuestManager _questManager; + + public static void main(String[] args) + { + try + { + new QuestDaemon().run(); + System.exit(0); + } + catch (Throwable t) + { + log("Error in startup/console thread."); + log(t); + System.exit(1); + } + } + + private void run() throws Exception + { + log("Starting QuestDaemon..."); + + _questManager = new QuestManager( + new PubSubRouter(new PubSubJedisClient(ServerManager.getMasterConnection(), + ServerManager.getSlaveConnection()))); + _questManager.start(); + + Runtime.getRuntime().addShutdownHook(new Thread(() -> _questManager.onShutdown())); + + AnsiConsole.systemInstall(); + ConsoleReader consoleReader = new ConsoleReader(); + consoleReader.setExpandEvents(false); + + String command; + while (_alive && (command = consoleReader.readLine(">")) != null) + { + try + { + if (command.equals("help")) + { + log("QuestManager commands:"); + log("stop: Shuts down this QuestManager instance."); + log("clearactivequests: Clears active quests. New ones will be selected on this instance's next iteration."); + log("clearrecentrequests: Clear recently selected quests. This effectively allows any quest to be set to active, even ones selected within the past few days."); + } + if (command.contains("stop")) + { + stopCommand(); + } + else if (command.contains("clearactivequests")) + { + clearQuestsCommand(); + } + else if (command.contains("clearrecentquests")) + { + + } + } + catch (Throwable t) + { + log("Exception encountered while executing command " + command + ": " + + t.getMessage()); + log(t); + } + } + } + + private void stopCommand() throws Exception + { + log("Shutting down QuestDaemon..."); + + System.exit(0); + } + + private void clearQuestsCommand() + { + _questManager.clearActiveQuests(); + + log("Cleared active quests. New ones will be selected on this instance's next iteration."); + } + + public static void log(String message) + { + log(message, false); + } + + public static void log(Throwable t) + { + log(Throwables.getStackTraceAsString(t)); + } + + public static void log(String message, boolean fileOnly) + { + _logger.info("[" + DATE_FORMAT.format(new Date()) + "] " + message); + + if (!fileOnly) + { + System.out.println("[" + DATE_FORMAT.format(new Date()) + "] " + message); + } + } + + public static String getLogPrefix(Object loggingClass) + { + return "[" + DATE_FORMAT.format(new Date()) + "] "; + } +} diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java new file mode 100644 index 000000000..4bb36e371 --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java @@ -0,0 +1,227 @@ +package mineplex.quest.daemon; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import mineplex.quest.common.Quest; +import mineplex.quest.common.QuestRarity; +import mineplex.quest.common.Quests; +import mineplex.quest.common.redis.PubSubChannels; +import mineplex.quest.common.redis.QuestRedisDataRepository; +import mineplex.quest.common.redis.QuestTypeSerializer; +import mineplex.quest.common.util.RandomCollection; +import mineplex.serverdata.Region; +import mineplex.serverdata.data.DataRepository; +import mineplex.serverdata.redis.messaging.PubSubMessager; +import mineplex.serverdata.servers.ServerManager; + +/** + * A centralized service that handles setting {@link Quest} instances as active for servers to + * display to players. Uses redis to notify servers of active quests changes and to store recently + * selected quests. + *

+ * Uses {@link QuestRarity} to randomly select active quests based on relative weight. + */ +public class QuestManager extends Thread +{ + + private static final int RECENT_QUESTS_EXPIRE_SECONDS = (int) TimeUnit.DAYS.toSeconds(5); + private static final long SLEEP_MILLIS = TimeUnit.MINUTES.toMillis(1); + private static final int NUM_ACTIVE_QUESTS = 5; + private static final ZoneId EST_TIMEZONE = ZoneId.of("America/New_York"); + private static final String LAST_UPDATE_FILE = "last-quest-update.dat"; + + // all quests, mapped from rarity weight to quest + private final RandomCollection _quests = new RandomCollection<>(); + + // currently active quests + private final Set _activeQuests = Collections.synchronizedSet(new HashSet<>()); + + // redis pubsub messager, used to publish active quests to servers + private final PubSubMessager _pubSub; + + // redis repository to track recently selected quests, to prevent selecting a quest too soon + // after it's been active + private final DataRepository _recentlySelectedQuestsRepo; + + // the current date, e.g. the last date active quests were updated + private volatile LocalDate _currentDate; + + // whether this instance is running or not + private volatile boolean _alive = true; + + public QuestManager(PubSubMessager pubSub) + { + _pubSub = pubSub; + + _recentlySelectedQuestsRepo = new QuestRedisDataRepository( + ServerManager.getMasterConnection(), + ServerManager.getSlaveConnection(), Region.currentRegion(), "recently-selected-quests"); + + _quests.addAll(Arrays.stream(Quests.values()) + .collect(Collectors.toMap(q -> q, q -> q.getRarity().getWeight()))); + + loadLastActiveQuests(); + + if (_activeQuests.size() > 0) + { + QuestDaemon.log("Active quests loaded from file:"); + _activeQuests.forEach(quest -> QuestDaemon.log(((Quests) quest).name())); + } + } + + /** + * Loads last set active quests & the date they were set to active from a flat file, if the file + * exists. + */ + private void loadLastActiveQuests() + { + File file = new File(LAST_UPDATE_FILE); + if (!file.exists()) + { + _currentDate = LocalDate.now(EST_TIMEZONE); + + return; + } + + try + { + List lines = Files.readAllLines(Paths.get(file.getAbsolutePath())); + _currentDate = LocalDate.parse(lines.get(0)); + + if (lines.size() > 1) + { + for (int i = 1; i < lines.size(); i++) + { + Quest quest = Quests.fromId(Integer.parseInt(lines.get(i))); + _activeQuests.add(quest); + } + } + } + catch (IOException e) + { + QuestDaemon.log( + "Exception encountered while loading last updated quests: " + e.getMessage()); + QuestDaemon.log(e); + + _currentDate = LocalDate.now(EST_TIMEZONE); + } + } + + @Override + public void run() + { + try + { + while (_alive) + { + LocalDate now = LocalDate.now(EST_TIMEZONE); + // check if date has changed; if so we need to choose new quests + if (_currentDate.isBefore(now) || _activeQuests.isEmpty()) + { + QuestDaemon.log("Updating active quests..."); + _currentDate = now; + + // select new quests + selectRandomQuests(); + + // publish new quests + _pubSub.publish(PubSubChannels.QUEST_SUPPLIER_CHANNEL, serialize(_activeQuests)); + } + + // take a small break, important so CPU isn't constantly running + Thread.sleep(SLEEP_MILLIS); + } + } + catch (InterruptedException e) + { + QuestDaemon.log( + "Exception encountered updating active quests repo: " + e.getMessage()); + QuestDaemon.log(e); + } + } + + /** + * Called on shutdown of this service. Writes the date quests were last updated to a file, so + * this service will know whether to update them or not on the next startup. This is all that's + * needed to keep active quests in a sane state because they are stored in redis. + */ + public void onShutdown() + { + _alive = false; + + try + { + File file = new File(LAST_UPDATE_FILE); + if (!file.exists()) + { + file.createNewFile(); + } + + List lines = new ArrayList<>(); + + // add active quests date + lines.add(_currentDate.toString()); + + // add currently active quests + _activeQuests.stream().map(Quest::getDataId).forEach(lines::add); + + Files.write(Paths.get(file.getAbsolutePath()), lines); + } + catch (IOException e) + { + QuestDaemon.log("Exception encountered saving " + LAST_UPDATE_FILE + " file: " + e.getMessage()); + QuestDaemon.log(e); + } + } + + public void clearActiveQuests() + { + _activeQuests.clear(); + } + + private void selectRandomQuests() + { + if (!_activeQuests.isEmpty()) + { + _activeQuests.clear(); + } + + while (_activeQuests.size() < NUM_ACTIVE_QUESTS) + { + Quest q = _quests.next(); + // select random weighted quest, ignore those recently selected + while (_activeQuests.contains(q) + && _recentlySelectedQuestsRepo.elementExists(q.getDataId())) + { + // quest is already active or it's been active recently + q = _quests.next(); + } + + // add active quest + _activeQuests.add(q); + + QuestDaemon.log("Selected quest: " + ((Quests) q).name()); + + // flag quest as recently selected + _recentlySelectedQuestsRepo.addElement(q, RECENT_QUESTS_EXPIRE_SECONDS); + } + } + + private String serialize(Set quests) + { + return QuestTypeSerializer.QUEST_GSON.toJson(quests, QuestTypeSerializer.QUEST_TYPE); + } +} diff --git a/Plugins/pom.xml b/Plugins/pom.xml index 46ff3c9e3..bbf652166 100644 --- a/Plugins/pom.xml +++ b/Plugins/pom.xml @@ -43,6 +43,7 @@ mavericks-review-hub mineplex-game-gemhunters mineplex-google-sheets + mineplex-questmanager From 47c816087ec777135feeb13c9d251a26359c3969 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 4 May 2017 15:45:04 +0100 Subject: [PATCH 004/283] MOBA base --- .../src/mineplex/core/game/GameDisplay.java | 2 + .../src/nautilus/game/arcade/GameType.java | 5 +- .../game/arcade/game/games/moba/Moba.java | 34 +-- .../game/arcade/game/games/moba/MobaRole.java | 32 +++ .../arcade/game/games/moba/kit/KitPlayer.java | 27 +++ .../moba/structure/point/CapturePoint.java | 225 ++++++++++++++++++ .../point/CapturePointCaptureEvent.java | 37 +++ 7 files changed, 337 insertions(+), 25 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitPlayer.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index cc5ba27d4..430a198b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -99,6 +99,8 @@ public enum GameDisplay StrikeGames("Strike Games", Material.DIAMOND_LEGGINGS, (byte) 0, GameCategory.SURVIVAL, 66, false), + MOBA("Heroes of the Craft", Material.SKULL_ITEM, (byte)1, GameCategory.CLASSICS, 70, true), + Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999, false), Brawl("Brawl", Material.DIAMOND, (byte) 0, GameCategory.EVENT, 998, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 66bef53c0..f7bac3e5e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -1,5 +1,6 @@ package nautilus.game.arcade; +import nautilus.game.arcade.game.games.moba.Moba; import org.bukkit.Material; import mineplex.core.common.MinecraftVersion; @@ -223,7 +224,9 @@ public enum GameType BouncyBalls(BouncyBalls.class, GameDisplay.BouncyBalls), Valentines(Valentines.class, GameDisplay.Valentines), - + + MOBA(Moba.class, GameDisplay.MOBA), + Event(EventGame.class, GameDisplay.Event, new GameType[]{ GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, GameType.Cards, GameType.CastleSiege, GameType.ChampionsDominate, GameType.ChampionsTDM, GameType.Christmas, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 17f393dd6..081417c5b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,39 +1,25 @@ package nautilus.game.arcade.game.games.moba; -import java.util.ArrayList; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.sheep.kits.*; +import nautilus.game.arcade.game.games.moba.kit.KitPlayer; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.NullKit; public class Moba extends TeamGame { - private ArrayList _lastScoreboard = new ArrayList(); - public Moba(ArcadeManager manager) + private static final String[] DESCRIPTION = { + "MORE CAPTURE POINTS" + }; + + public Moba(ArcadeManager manager) { - super(manager, GameType.Sheep, + super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION); - new Kit[] - { - new NullKit(manager) - }, - - new String[] - { - "..." - }); - - this.DeathOut = false; - this.DeathSpectateSecs = 8; - - this.HungerSet = 20; - - registerChatStats(); + DeathSpectateSecs = 8; + HungerSet = 20; new CompassModule() .setGiveCompass(true) @@ -43,7 +29,7 @@ public class Moba extends TeamGame } @Override - public void ParseData() + public void ParseData() { } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java new file mode 100644 index 000000000..91f0fa6e5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.moba; + +import nautilus.game.arcade.kit.Kit; + +public enum MobaRole +{ + + ASSASSIN("Assassin", null), + HUNTER("Hunter", null), + MAGE("Mage", null), + WARRIOR("Warrior", null), + ; + + private String _name; + private Kit[] _kits; + + MobaRole(String name, Kit[] kits) + { + _name = name; + _kits = kits; + } + + public String getName() + { + return _name; + } + + public Kit[] getKits() + { + return _kits; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitPlayer.java new file mode 100644 index 000000000..41d6428c2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitPlayer.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +public class KitPlayer extends Kit +{ + + private static final String[] DESCRIPTION = { + + }; + + public KitPlayer(ArcadeManager manager) + { + super(manager, "Player", KitAvailability.Free, DESCRIPTION, new Perk[0], EntityType.PIG, null); + } + + @Override + public void GiveItems(Player player) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java new file mode 100644 index 000000000..6d8c7f08d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -0,0 +1,225 @@ +package nautilus.game.arcade.game.games.moba.structure.point; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; + +import java.util.*; +import java.util.Map.Entry; + +public class CapturePoint +{ + + private static final int MAX_RADIUS = 5; + private static final int MAX_PROGRESS = 10; + + private final Moba _host; + + private final Location _center; + private final List _wool; + private final List _changed; + + private final double _captureDist; + + private GameTeam _owner; + private GameTeam _side; + private int _progress; + + public CapturePoint(Moba host, Location center) + { + _host = host; + _center = center; + _wool = new ArrayList<>(36); + _changed = new ArrayList<>(_wool.size()); + + double highestDist = 0; + + for (Entry entry : UtilBlock.getInRadius(center, MAX_RADIUS).entrySet()) + { + Block block = entry.getKey(); + double offset = entry.getValue(); + + if (block.getType() != Material.WOOL) + { + continue; + } + + if (offset > highestDist) + { + highestDist = offset; + } + + _wool.add(block); + } + Collections.shuffle(_wool); + + _captureDist = highestDist * (double) MAX_RADIUS; + } + + public boolean update() + { + // Store the number of players in a team in this map + Map playersOnPoint = new HashMap<>(); + + for (GameTeam team : _host.GetTeamList()) + { + // Populate + playersOnPoint.put(team, 0); + int players = 0; + + for (Player player : team.GetPlayers(true)) + { + // Ignore for spectators + // If they are not in the range + if (UtilPlayer.isSpectator(player) || UtilMath.offset(player.getLocation(), _center) > _captureDist) + { + continue; + } + + // Increment + players++; + } + + // Put in map + playersOnPoint.put(team, players); + } + + // For each team get the team with the non-zero players + GameTeam highest = null; + for (Entry entry : playersOnPoint.entrySet()) + { + GameTeam team = entry.getKey(); + int players = entry.getValue(); + + // Only care if people are on it + if (players > 0) + { + // If this is the first team on the point + if (highest == null) + { + highest = team; + } + // This means there are 2 teams on the point + else + { + return false; + } + } + } + + // No one at all is on the point + if (highest == null) + { + return false; + } + + // If it has just reached the maximum progress, set the owner. + if (_owner != null && _owner.equals(highest) && _progress == MAX_PROGRESS) + { + return false; + } + + capture(highest); + return true; + } + + private void capture(GameTeam team) + { + // No player has ever stood on the point + if (_side == null) + { + _side = team; + } + + // If it is the same team + if (_side.equals(team)) + { + // Captured + if (_progress == MAX_PROGRESS) + { + setOwner(team); + } + + // Increase progress + _progress++; + display(team, true); + } + // Other team + else + { + // Point back to a neutral state + if (_progress == 0) + { + _side = team; + // Recursively call this method now that the first (same team) condition will be true + capture(team); + return; + } + + _progress--; + display(team, false); + } + } + + private void setOwner(GameTeam team) + { + _owner = team; + + UtilServer.CallEvent(new CapturePointCaptureEvent(this)); + } + + private void display(GameTeam team, boolean forward) + { + Bukkit.broadcastMessage("progress=" + _progress + " forward=" + forward); + + double toChange = Math.ceil(_wool.size() / MAX_PROGRESS); + int changed = 0; + for (Block block : _wool) + { + if (changed >= toChange) + { + return; + } + + Block glass = block.getRelative(BlockFace.UP); + + if (forward) + { + if (_changed.contains(block)) + { + continue; + } + + block.setData(team.GetColorData()); + glass.setData(team.GetColorData()); + changed++; + } + else + { + if (!_changed.contains(block)) + { + continue; + } + + block.setData((byte) 0); + glass.setData((byte) 0); + changed++; + } + } + } + + public GameTeam getOwner() + { + return _owner; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java new file mode 100644 index 000000000..4383350aa --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.moba.structure.point; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import java.util.List; + +public class CapturePointCaptureEvent extends Event +{ + + private static final HandlerList _handlers = new HandlerList(); + + private CapturePoint _point; + + public CapturePointCaptureEvent(CapturePoint point) + { + _point = point; + } + + public CapturePoint getPoint() + { + return _point; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} From 321084339542a20c8c43c4bd40781909ef956cd1 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 4 May 2017 20:20:48 +0100 Subject: [PATCH 005/283] Capture point fix --- .../game/arcade/game/games/moba/Moba.java | 89 ++++++++++++++++++- .../game/games/moba/kit/KitSelection.java | 30 +++++++ .../moba/structure/point/CapturePoint.java | 51 ++++++----- 3 files changed, 148 insertions(+), 22 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 081417c5b..ce6d35041 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,11 +1,18 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.kit.KitPlayer; +import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; +import org.bukkit.Location; +import org.bukkit.event.EventHandler; + +import java.util.*; public class Moba extends TeamGame { @@ -14,12 +21,16 @@ public class Moba extends TeamGame "MORE CAPTURE POINTS" }; + private final List _capturePoints = new ArrayList<>(3); + public Moba(ArcadeManager manager) { super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION); + DeathOut = false; DeathSpectateSecs = 8; HungerSet = 20; + DontAllowOverfill = false; new CompassModule() .setGiveCompass(true) @@ -31,6 +42,82 @@ public class Moba extends TeamGame @Override public void ParseData() { - + Collection capturePoints = getLocationStartsWith("POINT").values(); + + for (Location location : capturePoints) + { + _capturePoints.add(new CapturePoint(this, location)); + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + GameState state = GetState(); + + switch (state) + { + case Prepare: + writePrepare(); + break; + case Live: + writeLive(); + break; + case End: + writeEnd(); + break; + } + + Scoreboard.draw(); + } + + private void writePrepare() + { + + } + + private void writeLive() + { + + } + + private void writeEnd() + { + + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + for (CapturePoint point : _capturePoints) + { + point.update(); + } + } + + private Map getLocationStartsWith(String s) + { + Map map = new HashMap<>(); + + for (String key : WorldData.GetAllCustomLocs().keySet()) + { + if (key.startsWith(s)) + { + map.put(key, WorldData.GetCustomLocs(key).get(0)); + } + } + + return map; } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java new file mode 100644 index 000000000..1fcea1335 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import mineplex.core.common.util.UtilServer; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class KitSelection implements Listener +{ + + private final + + public KitSelection(Moba moba) + { + UtilServer.RegisterEvents(this); + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + UtilServer.Unregister(this); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index 6d8c7f08d..95cbc8edc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -1,15 +1,10 @@ package nautilus.game.arcade.game.games.moba.structure.point; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.*; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; +import org.bukkit.*; +import org.bukkit.FireworkEffect.Type; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -66,7 +61,7 @@ public class CapturePoint _captureDist = highestDist * (double) MAX_RADIUS; } - public boolean update() + public void update() { // Store the number of players in a team in this map Map playersOnPoint = new HashMap<>(); @@ -112,7 +107,7 @@ public class CapturePoint // This means there are 2 teams on the point else { - return false; + return; } } } @@ -120,17 +115,16 @@ public class CapturePoint // No one at all is on the point if (highest == null) { - return false; + return; } // If it has just reached the maximum progress, set the owner. - if (_owner != null && _owner.equals(highest) && _progress == MAX_PROGRESS) + if (_owner != null && _owner.equals(highest) && _progress >= MAX_PROGRESS) { - return false; + return; } capture(highest); - return true; } private void capture(GameTeam team) @@ -144,15 +138,15 @@ public class CapturePoint // If it is the same team if (_side.equals(team)) { - // Captured - if (_progress == MAX_PROGRESS) - { - setOwner(team); - } - // Increase progress _progress++; display(team, true); + + // Captured + if (_progress >= MAX_PROGRESS) + { + setOwner(team); + } } // Other team else @@ -160,6 +154,7 @@ public class CapturePoint // Point back to a neutral state if (_progress == 0) { + setBeaconColour(null); _side = team; // Recursively call this method now that the first (same team) condition will be true capture(team); @@ -175,6 +170,9 @@ public class CapturePoint { _owner = team; + setBeaconColour(team); + UtilFirework.playFirework(_center, Type.BURST, team.GetColorBase(), false, false); + UtilServer.CallEvent(new CapturePointCaptureEvent(this)); } @@ -182,7 +180,7 @@ public class CapturePoint { Bukkit.broadcastMessage("progress=" + _progress + " forward=" + forward); - double toChange = Math.ceil(_wool.size() / MAX_PROGRESS); + double toChange = Math.ceil(_wool.size() / MAX_PROGRESS) + 1; int changed = 0; for (Block block : _wool) { @@ -203,6 +201,7 @@ public class CapturePoint block.setData(team.GetColorData()); glass.setData(team.GetColorData()); changed++; + _changed.add(block); } else { @@ -214,10 +213,20 @@ public class CapturePoint block.setData((byte) 0); glass.setData((byte) 0); changed++; + _changed.remove(block); } + + glass.getWorld().playEffect(glass.getLocation().add(0.5, 0.5, 0.5), Effect.STEP_SOUND, block.getType(), team.GetColorData()); } } + private void setBeaconColour(GameTeam team) + { + byte colour = team == null ? 0 : team.GetColorData(); + + _center.getBlock().getRelative(BlockFace.DOWN).setData(colour); + } + public GameTeam getOwner() { return _owner; From 54858e14ee7d7526c707c8230dd01356a8d5705d Mon Sep 17 00:00:00 2001 From: Kenny Date: Fri, 5 May 2017 15:22:37 -0400 Subject: [PATCH 006/283] Convert questmanager to read quests from google sheets --- Plugins/Mineplex.Core/pom.xml | 5 + Plugins/mineplex-questmanager/pom.xml | 2 +- .../src/mineplex/quest/common/BaseQuest.java | 44 ++++++++ .../src/mineplex/quest/common/Quests.java | 106 +++++++++--------- .../redis/QuestRedisDataRepository.java | 15 ++- .../common/redis/QuestTypeDeserialiazer.java | 2 + .../quest/common/util/RandomCollection.java | 11 +- .../quest/common/util/UtilGoogleSheet.java | 77 +++++++++++++ .../mineplex/quest/daemon/QuestDaemon.java | 22 ++-- .../mineplex/quest/daemon/QuestManager.java | 87 ++++++++------ 10 files changed, 272 insertions(+), 99 deletions(-) create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/common/BaseQuest.java create mode 100644 Plugins/mineplex-questmanager/src/mineplex/quest/common/util/UtilGoogleSheet.java diff --git a/Plugins/Mineplex.Core/pom.xml b/Plugins/Mineplex.Core/pom.xml index a59a05b9b..50bfe79f3 100644 --- a/Plugins/Mineplex.Core/pom.xml +++ b/Plugins/Mineplex.Core/pom.xml @@ -32,6 +32,11 @@ mineplex-serverdata ${project.version} + + ${project.groupId} + mineplex-questmanager + ${project.version} + org.apache.commons commons-dbcp2 diff --git a/Plugins/mineplex-questmanager/pom.xml b/Plugins/mineplex-questmanager/pom.xml index e41a4c469..49a9fd32c 100644 --- a/Plugins/mineplex-questmanager/pom.xml +++ b/Plugins/mineplex-questmanager/pom.xml @@ -7,7 +7,7 @@ dev-SNAPSHOT mineplex-questmanager - Mineplex.QuestManager + Mineplex.questmanager A centralized service that selects daily quests diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/BaseQuest.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/BaseQuest.java new file mode 100644 index 000000000..5b778bf50 --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/BaseQuest.java @@ -0,0 +1,44 @@ +package mineplex.quest.common; + +/** + * Implementation of baseline {@link Quest}. + */ +public class BaseQuest implements Quest +{ + + private final int _uniqueId; + private final String _name; + private final QuestRarity _rarity; + + public BaseQuest(int uniqueId, String name, QuestRarity rarity) + { + _uniqueId = uniqueId; + _name = name; + _rarity = rarity; + } + + @Override + public String getName() + { + return _name; + } + + @Override + public int getUniqueId() + { + return _uniqueId; + } + + @Override + public QuestRarity getRarity() + { + return _rarity; + } + + @Override + public String getDataId() + { + return _uniqueId + ""; + } + +} diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quests.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quests.java index 1057ef12b..34f16c4d9 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quests.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quests.java @@ -1,69 +1,71 @@ package mineplex.quest.common; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +import com.google.common.collect.ImmutableSet; + +import mineplex.quest.common.util.UtilGoogleSheet; +import mineplex.quest.daemon.QuestDaemon; + /** - * A centralized list of {@link Quest}s. + * Provides access to all quests. *

- * When adding new quests they should be given an enum field here & then added to the minecraft - * server plugin in the form of a "tracker" that watches progress per user. + * Loads quests from a google sheets json file. */ -public enum Quests implements Quest +public class Quests { - // TODO add actual quests - EXAMPLE_QUEST_1("1", 0, QuestRarity.COMMON), - EXAMPLE_QUEST_2("2", 1, QuestRarity.COMMON), - EXAMPLE_QUEST_3("3", 2, QuestRarity.RARE), - EXAMPLE_QUEST_4("4", 3, QuestRarity.LEGENDARY), - EXAMPLE_QUEST_5("5", 4, QuestRarity.COMMON), + private static final String ALL_QUESTS_FILE = "QUESTS_SHEET"; + private static final String QUEST_SHEET_KEY = "Quests"; + + private static final int UNIQUE_ID_COLUMN = 0; + private static final int NAME_COLUMN = 1; + private static final int RARITY_COLUMN = 9; - ; - - private final String _name; - private final int _uniqueId; - private final QuestRarity _rarity; - - Quests(String name, int uniqueId, QuestRarity rarity) - { - _name = name; - _uniqueId = uniqueId; - _rarity = rarity; - } + public static final Set QUESTS; - @Override - public String getName() + static { - return _name; - } + ImmutableSet.Builder builder = ImmutableSet.builder(); + + Map>> sheets = UtilGoogleSheet.getSheetData(ALL_QUESTS_FILE); - @Override - public QuestRarity getRarity() - { - return _rarity; - } + List> rows = sheets.getOrDefault(QUEST_SHEET_KEY, Collections.emptyList()); - @Override - public int getUniqueId() - { - return _uniqueId; - } - - @Override - public String getDataId() - { - return String.valueOf(_uniqueId); - } - - public static Quest fromId(int id) - { - for (Quest q : values()) + // get each row of spreadsheet, start at 1 since row 0 contains headers + for (int i = 1; i < rows.size(); i++) { - if (q.getUniqueId() == id) + List row = rows.get(i); + + // attempt to parse quest data we need + try { - return q; + int uniqueId = Integer.parseInt(row.get(UNIQUE_ID_COLUMN)); + String name = row.get(NAME_COLUMN); + QuestRarity rarity = QuestRarity.valueOf(row.get(RARITY_COLUMN).toUpperCase()); + + Quest quest = new BaseQuest(uniqueId, name, rarity); + + builder.add(quest); + } + catch (Exception e) + { + QuestDaemon.log("Exception encountered while parsing quest sheet row: " + row + ", " + + e.getMessage()); + e.printStackTrace(); } } - - return null; + + QUESTS = builder.build(); } - -} \ No newline at end of file + + public static Optional fromId(int uniqueId) + { + return QUESTS.stream().filter(quest -> quest.getUniqueId() == uniqueId).findFirst(); + } + +} diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestRedisDataRepository.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestRedisDataRepository.java index 2037aaa9a..825c1364e 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestRedisDataRepository.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestRedisDataRepository.java @@ -12,7 +12,7 @@ import mineplex.serverdata.servers.ConnectionData; */ public class QuestRedisDataRepository extends RedisDataRepository { - + public QuestRedisDataRepository(ConnectionData writeConn, ConnectionData readConn, Region region, String elementLabel) { @@ -22,7 +22,18 @@ public class QuestRedisDataRepository extends RedisDataRepository @Override protected Quest deserialize(String json) { - return Quests.fromId(Integer.parseInt(json)); + if (json == null || json.isEmpty()) + { + return null; + } + + return Quests.fromId(Integer.parseInt(json)).orElse(null); + } + + @Override + protected String serialize(Quest quest) + { + return quest.getDataId(); } } diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestTypeDeserialiazer.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestTypeDeserialiazer.java index 6e97775c8..4b71efc77 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestTypeDeserialiazer.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/QuestTypeDeserialiazer.java @@ -3,6 +3,7 @@ package mineplex.quest.common.redis; import java.lang.reflect.Type; import java.util.Arrays; import java.util.HashSet; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -28,6 +29,7 @@ public class QuestTypeDeserialiazer implements JsonDeserializer> { String[] split = json.getAsString().split(QuestTypeSerializer.SEPARATOR); return Arrays.stream(split).map(questId -> Quests.fromId(Integer.valueOf(questId))) + .filter(Optional::isPresent).map(Optional::get) .collect(Collectors.toCollection(HashSet::new)); } diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/RandomCollection.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/RandomCollection.java index b624e1319..c74225c91 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/RandomCollection.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/RandomCollection.java @@ -1,5 +1,7 @@ package mineplex.quest.common.util; +import java.util.Collection; +import java.util.Collections; import java.util.Map; import java.util.NavigableMap; import java.util.Random; @@ -8,13 +10,15 @@ import java.util.concurrent.ThreadLocalRandom; /** * Provides random, weighted access to a collection of elements. + *

+ * Intended to be thread-safe. * * @param The generic type parameter of the elements. */ public class RandomCollection { - private final NavigableMap _map = new TreeMap(); + private final NavigableMap _map = Collections.synchronizedNavigableMap(new TreeMap()); private final Random _random; private double total = 0; @@ -50,4 +54,9 @@ public class RandomCollection double value = _random.nextDouble() * total; return _map.ceilingEntry(value).getValue(); } + + public Collection values() + { + return _map.values(); + } } diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/UtilGoogleSheet.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/UtilGoogleSheet.java new file mode 100644 index 000000000..53aa8731e --- /dev/null +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/UtilGoogleSheet.java @@ -0,0 +1,77 @@ +package mineplex.quest.common.util; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +/** + * Provides utility methods for deserializing google sheets json files. + * @author Kenny + * + */ +public class UtilGoogleSheet +{ + private static final File DATA_STORE_DIR = new File( + ".." + File.separatorChar + ".." + File.separatorChar + "update" + File.separatorChar + + "files"); + + public static Map>> getSheetData(String name) + { + return getSheetData(new File(DATA_STORE_DIR + File.separator + name + ".json")); + } + + public static Map>> getSheetData(File file) + { + if (!file.exists()) + { + return null; + } + + Map>> valuesMap = new HashMap<>(); + + try + { + JsonParser parser = new JsonParser(); + JsonElement data = parser.parse(new FileReader(file)); + JsonArray parent = data.getAsJsonObject().getAsJsonArray("data"); + + for (int i = 0; i < parent.size(); i++) + { + JsonObject sheet = parent.get(i).getAsJsonObject(); + String name = sheet.get("name").getAsString(); + JsonArray values = sheet.getAsJsonArray("values"); + List> valuesList = new ArrayList<>(values.size()); + + for (int j = 0; j < values.size(); j++) + { + List list = new ArrayList<>(); + Iterator iterator = values.get(j).getAsJsonArray().iterator(); + + while (iterator.hasNext()) + { + String value = iterator.next().getAsString(); + list.add(value); + } + + valuesList.add(list); + } + + valuesMap.put(name, valuesList); + } + } + catch (FileNotFoundException e) + {} + + return valuesMap; + } +} \ No newline at end of file diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestDaemon.java b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestDaemon.java index ae124459e..474684b84 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestDaemon.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestDaemon.java @@ -74,9 +74,8 @@ public class QuestDaemon { log("Starting QuestDaemon..."); - _questManager = new QuestManager( - new PubSubRouter(new PubSubJedisClient(ServerManager.getMasterConnection(), - ServerManager.getSlaveConnection()))); + _questManager = new QuestManager(new PubSubRouter(new PubSubJedisClient( + ServerManager.getMasterConnection(), ServerManager.getSlaveConnection()))); _questManager.start(); Runtime.getRuntime().addShutdownHook(new Thread(() -> _questManager.onShutdown())); @@ -94,10 +93,12 @@ public class QuestDaemon { log("QuestManager commands:"); log("stop: Shuts down this QuestManager instance."); - log("clearactivequests: Clears active quests. New ones will be selected on this instance's next iteration."); - log("clearrecentrequests: Clear recently selected quests. This effectively allows any quest to be set to active, even ones selected within the past few days."); + log("clearactivequests: Clears active quests. New ones will be selected on this" + + " instance's next iteration."); + log("clearrecentrequests: Clear recently selected quests. This effectively allows " + + "any quest to be set to active, even ones selected within the past few days."); } - if (command.contains("stop")) + else if (command.contains("stop")) { stopCommand(); } @@ -107,7 +108,7 @@ public class QuestDaemon } else if (command.contains("clearrecentquests")) { - + clearRecentQuestsCommand(); } } catch (Throwable t) @@ -133,6 +134,13 @@ public class QuestDaemon log("Cleared active quests. New ones will be selected on this instance's next iteration."); } + private void clearRecentQuestsCommand() + { + _questManager.clearRecentlyActiveQuests(); + + log("Cleared recently active quests. This means that any quest can be chosen to be active now, even ones selected within the past few days."); + } + public static void log(String message) { log(message, false); diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java index 4bb36e371..03689d005 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java @@ -7,7 +7,6 @@ import java.nio.file.Paths; import java.time.LocalDate; import java.time.ZoneId; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -37,15 +36,16 @@ import mineplex.serverdata.servers.ServerManager; public class QuestManager extends Thread { - private static final int RECENT_QUESTS_EXPIRE_SECONDS = (int) TimeUnit.DAYS.toSeconds(5); + private static final int RECENT_QUESTS_EXPIRE_SECONDS = (int) TimeUnit.DAYS.toSeconds(5); private static final long SLEEP_MILLIS = TimeUnit.MINUTES.toMillis(1); private static final int NUM_ACTIVE_QUESTS = 5; + private static final ZoneId EST_TIMEZONE = ZoneId.of("America/New_York"); private static final String LAST_UPDATE_FILE = "last-quest-update.dat"; // all quests, mapped from rarity weight to quest private final RandomCollection _quests = new RandomCollection<>(); - + // currently active quests private final Set _activeQuests = Collections.synchronizedSet(new HashSet<>()); @@ -58,7 +58,7 @@ public class QuestManager extends Thread // the current date, e.g. the last date active quests were updated private volatile LocalDate _currentDate; - + // whether this instance is running or not private volatile boolean _alive = true; @@ -67,21 +67,21 @@ public class QuestManager extends Thread _pubSub = pubSub; _recentlySelectedQuestsRepo = new QuestRedisDataRepository( - ServerManager.getMasterConnection(), - ServerManager.getSlaveConnection(), Region.currentRegion(), "recently-selected-quests"); + ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), + Region.currentRegion(), "recently-selected-quests"); - _quests.addAll(Arrays.stream(Quests.values()) - .collect(Collectors.toMap(q -> q, q -> q.getRarity().getWeight()))); + _quests.addAll(Quests.QUESTS.stream().collect( + Collectors.toMap(q -> q, q -> q.getRarity().getWeight()))); loadLastActiveQuests(); - + if (_activeQuests.size() > 0) { QuestDaemon.log("Active quests loaded from file:"); - _activeQuests.forEach(quest -> QuestDaemon.log(((Quests) quest).name())); + _activeQuests.forEach(quest -> QuestDaemon.log(quest.getName())); } } - + /** * Loads last set active quests & the date they were set to active from a flat file, if the file * exists. @@ -92,7 +92,7 @@ public class QuestManager extends Thread if (!file.exists()) { _currentDate = LocalDate.now(EST_TIMEZONE); - + return; } @@ -105,12 +105,13 @@ public class QuestManager extends Thread { for (int i = 1; i < lines.size(); i++) { - Quest quest = Quests.fromId(Integer.parseInt(lines.get(i))); + int uniqueId = Integer.parseInt(lines.get(i)); + Quest quest = getById(uniqueId); _activeQuests.add(quest); } } } - catch (IOException e) + catch (Exception e) { QuestDaemon.log( "Exception encountered while loading last updated quests: " + e.getMessage()); @@ -133,22 +134,24 @@ public class QuestManager extends Thread { QuestDaemon.log("Updating active quests..."); _currentDate = now; - + // select new quests selectRandomQuests(); - + // publish new quests - _pubSub.publish(PubSubChannels.QUEST_SUPPLIER_CHANNEL, serialize(_activeQuests)); + _pubSub.publish(PubSubChannels.QUEST_SUPPLIER_CHANNEL, + serialize(_activeQuests)); } - + + QuestDaemon.log("Done updating active quests."); + // take a small break, important so CPU isn't constantly running Thread.sleep(SLEEP_MILLIS); } } catch (InterruptedException e) { - QuestDaemon.log( - "Exception encountered updating active quests repo: " + e.getMessage()); + QuestDaemon.log("Exception encountered updating active quests repo: " + e.getMessage()); QuestDaemon.log(e); } } @@ -158,10 +161,10 @@ public class QuestManager extends Thread * this service will know whether to update them or not on the next startup. This is all that's * needed to keep active quests in a sane state because they are stored in redis. */ - public void onShutdown() + public void onShutdown() { _alive = false; - + try { File file = new File(LAST_UPDATE_FILE); @@ -169,20 +172,21 @@ public class QuestManager extends Thread { file.createNewFile(); } - + List lines = new ArrayList<>(); - + // add active quests date lines.add(_currentDate.toString()); - + // add currently active quests _activeQuests.stream().map(Quest::getDataId).forEach(lines::add); - + Files.write(Paths.get(file.getAbsolutePath()), lines); } catch (IOException e) { - QuestDaemon.log("Exception encountered saving " + LAST_UPDATE_FILE + " file: " + e.getMessage()); + QuestDaemon.log("Exception encountered saving " + LAST_UPDATE_FILE + " file: " + + e.getMessage()); QuestDaemon.log(e); } } @@ -192,6 +196,17 @@ public class QuestManager extends Thread _activeQuests.clear(); } + public void clearRecentlyActiveQuests() + { + _recentlySelectedQuestsRepo.clean(); + } + + public Quest getById(int uniqueId) + { + return _quests.values().stream().filter(q -> q.getUniqueId() == uniqueId).findFirst() + .orElse(null); + } + private void selectRandomQuests() { if (!_activeQuests.isEmpty()) @@ -199,27 +214,27 @@ public class QuestManager extends Thread _activeQuests.clear(); } - while (_activeQuests.size() < NUM_ACTIVE_QUESTS) + while (_activeQuests.size() < NUM_ACTIVE_QUESTS && _activeQuests.size() < _quests.values().size()) { Quest q = _quests.next(); // select random weighted quest, ignore those recently selected - while (_activeQuests.contains(q) - && _recentlySelectedQuestsRepo.elementExists(q.getDataId())) + if (_activeQuests.contains(q) + || _recentlySelectedQuestsRepo.elementExists(q.getDataId())) { // quest is already active or it's been active recently - q = _quests.next(); + continue; } - + // add active quest _activeQuests.add(q); - - QuestDaemon.log("Selected quest: " + ((Quests) q).name()); - + + QuestDaemon.log("Selected quest: " + q.getName()); + // flag quest as recently selected _recentlySelectedQuestsRepo.addElement(q, RECENT_QUESTS_EXPIRE_SECONDS); } } - + private String serialize(Set quests) { return QuestTypeSerializer.QUEST_GSON.toJson(quests, QuestTypeSerializer.QUEST_TYPE); From 20281648c24776c3f7679d097cb0810507715c32 Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 5 May 2017 23:02:15 +0200 Subject: [PATCH 007/283] Add Quest triggers, add a Repository, add Spreadsheet parsing, and add menus. --- .../src/mineplex/core/quests/Quest.java | 41 +- .../mineplex/core/quests/QuestClientData.java | 39 +- .../mineplex/core/quests/QuestManager.java | 156 ++++++- .../core/quests/command/OpenGuiCommand.java | 28 ++ .../quests/repository/QuestRepository.java | 80 +++- .../core/quests/shop/BuyQuestButton.java | 67 +++ .../mineplex/core/quests/shop/QuestPage.java | 132 ++++++ .../mineplex/core/quests/shop/QuestSale.java | 25 ++ .../mineplex/core/quests/shop/QuestShop.java | 34 ++ .../quests/shop/RedeemDeclineQuestButton.java | 85 ++++ .../database/tables/AccountQuest.java | 190 ++++----- .../tables/records/AccountQuestRecord.java | 380 +++++++++--------- .../src/mineplex/hub/HubManager.java | 22 +- .../nautilus/game/arcade/ArcadeManager.java | 10 +- .../src/nautilus/game/arcade/game/Game.java | 24 ++ .../arcade/quest/CollectQuestTracker.java | 43 ++ .../game/arcade/quest/KillQuestTracker.java | 39 ++ .../game/arcade/quest/QuestTracker.java | 74 ++++ .../game/arcade/quest/WinQuestTracker.java | 37 ++ .../googlesheets/SpreadsheetType.java | 2 + 20 files changed, 1207 insertions(+), 301 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestSale.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestShop.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/WinQuestTracker.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java index 7557e2baf..fe5237cc6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java @@ -9,6 +9,8 @@ import mineplex.core.game.GameDisplay; */ public class Quest { + private static final Object _progressLock = new Object(); + private int _questID; private String _questName; @@ -89,24 +91,57 @@ public class Quest return _statToComplete; } + public int getProgress() + { + return _current; + } + public void setProgress(int progress) { _current = progress; } + public void increment(int value) + { + synchronized (_progressLock) + { + _current += value; + } + } + public void increment() { - _current++; + synchronized (_progressLock) + { + _current++; + } + } + + public void decrement(int value) + { + synchronized (_progressLock) + { + _current -= value; + } } public void decrement() { - _current--; + synchronized (_progressLock) + { + _current--; + } } public boolean isCompleted() { - return _current == _statToComplete; + return _current >= _statToComplete; + } + + @Override + public Quest clone() + { + return new Quest(_questID, _questName, _questTask, _questCost, _questReward, _rarity, _game, _trigger, _item, _statToComplete); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java index 1f7809dd8..6d9aba667 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java @@ -1,6 +1,6 @@ package mineplex.core.quests; -import org.bukkit.entity.Player; +import java.util.ArrayList; /** * QuestClientData @@ -9,10 +9,41 @@ import org.bukkit.entity.Player; */ public class QuestClientData { + private ArrayList _quests = new ArrayList<>(); - public QuestClientData(Player player) + public void addQuest(Quest quest) { - + _quests.add(quest); + } + + public ArrayList getQuests() + { + return _quests; + } + + public boolean hasQuest(Quest quest) + { + for (Quest other : _quests) + { + if (other.getID() == quest.getID()) + return true; + } + return false; + } + + public Quest getQuest(int id) + { + for (Quest quest : _quests) + { + if (quest.getID() == id) + return quest; + } + return null; + } + + public void removeQuest(int id) + { + Quest toRemove = getQuest(id); + _quests.remove(toRemove); } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index 9da8eaae2..239b9e149 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -1,8 +1,24 @@ package mineplex.core.quests; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import java.util.UUID; +import org.apache.commons.lang3.tuple.Triple; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; + import mineplex.core.MiniClientPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.UtilTime; +import mineplex.core.donation.DonationManager; +import mineplex.core.game.GameDisplay; +import mineplex.core.google.GoogleSheetsManager; +import mineplex.core.quests.command.OpenGuiCommand; +import mineplex.core.quests.repository.QuestRepository; /** * QuestManager @@ -11,16 +27,154 @@ import mineplex.core.MiniClientPlugin; */ public class QuestManager extends MiniClientPlugin { + private static final String GOOGLE_SHEET = "QUESTS_SHEET"; + private static final String GOOGLE_TABLE = "Quests"; + + private QuestRepository _repository; + private GoogleSheetsManager _sheetsManager; + private CoreClientManager _clients; + private DonationManager _donationManager; + + public ArrayList _availableQuests; public QuestManager() { super("Quest Manager"); + + _repository = new QuestRepository(); + _sheetsManager = require(GoogleSheetsManager.class); + _clients = require(CoreClientManager.class); + _availableQuests = new ArrayList<>(); + + setupQuests(); + } + + @Override + public void addCommands() + { + addCommand(new OpenGuiCommand(this)); + } + + public void setupQuests() + { + _availableQuests.clear(); + Map>> sheet = _sheetsManager.getSheetData(GOOGLE_SHEET); + List> table = new ArrayList<>(); + for (String key : sheet.keySet()) + { + if (key.equalsIgnoreCase(GOOGLE_TABLE)) + table = sheet.get(key); + } + + int size = table.size(); + + for (int i = 1; i < size; i++) + { + String name = table.get(i).get(0); + String task = table.get(i).get(1); + String game = table.get(i).get(2); + String cost = table.get(i).get(3); + String reward = table.get(i).get(4); + String trigger = table.get(i).get(5); + String statcompletion = table.get(i).get(6); + String item = table.get(i).get(7); + String rarity = table.get(i).get(8); + + _availableQuests.add(new Quest(i, name, task, + Integer.parseInt(cost), + Integer.parseInt(reward), + QuestRarity.getByName(rarity), + GameDisplay.matchName(game), + TriggerType.getByName(trigger), + item, + Integer.parseInt(statcompletion))); + } + } + + @EventHandler + public void playerJoin(PlayerJoinEvent event) + { + QuestClientData data = Get(event.getPlayer()); + for (Triple triple : _repository.getQuests(_clients.Get(event.getPlayer()))) + { + int id = triple.getLeft(); + int value = triple.getMiddle(); + long time = triple.getRight(); + + if (value == -1) + continue; + + if (!UtilTime.elapsed(time, 1000*60*60*24)) + continue; + + for (Quest quest : _availableQuests) + { + if (quest.getID() == id) + { + Quest clone = quest.clone(); + clone.setProgress(value); + data.addQuest(clone); + } + } + } + } + + public Quest getQuestByID(int id) + { + for (Quest quest : _availableQuests) + { + if (quest.getID() == id) + return quest; + } + return null; + } + + public void addNewQuest(Player player, Quest quest) + { + Quest clone = quest.clone(); + clone.setProgress(0); + Get(player).addQuest(clone); + + _repository.addNew(_clients.Get(player), quest); + } + + public void resetQuest(Player player, Quest quest, boolean completed) + { + Get(player).removeQuest(quest.getID()); + + _repository.resetQuest(_clients.Get(player), quest, completed); + } + + public void incrementQuest(CoreClient client, Quest quest, int value) + { + quest.increment(value); + _repository.incrementQuest(client, quest); + } + + public int[] getCurrentQuests() + { + return new int[]{2, 4}; } + public CoreClientManager getClients() + { + return _clients; + } + + public DonationManager getDonations() + { + return _donationManager; + } + @Override protected QuestClientData addPlayer(UUID uuid) { - return null; + return new QuestClientData(); + } + + public ArrayList getAvailableQuests() + { + return _availableQuests; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java new file mode 100644 index 000000000..7daeb4b4f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java @@ -0,0 +1,28 @@ +package mineplex.core.quests.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.quests.QuestManager; +import mineplex.core.quests.shop.QuestShop; + +/** + * OpenGuiCommand + * + * @author xXVevzZXx + */ +public class OpenGuiCommand extends CommandBase +{ + public OpenGuiCommand(QuestManager plugin) + { + super(plugin, Rank.ALL, "Quests"); + } + + @Override + public void Execute(Player caller, String[] args) + { + new QuestShop(Plugin, Plugin.getClients(), Plugin.getDonations()).attemptShopOpen(caller); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java index faaa1077a..324feb381 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java @@ -1,5 +1,14 @@ package mineplex.core.quests.repository; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +import org.apache.commons.lang3.tuple.Triple; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClient; +import mineplex.core.quests.Quest; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; @@ -10,10 +19,79 @@ import mineplex.serverdata.database.RepositoryBase; */ public class QuestRepository extends RepositoryBase { - + private HashMap>> _db; + public QuestRepository() { super(DBPool.getAccount()); + + _db = new HashMap<>(); + } + + public void player(Player player) + { + for (String string : _db.keySet()) + { + if (string.equalsIgnoreCase(player.getUniqueId().toString())) + return; + } + _db.put(player.getUniqueId().toString(), new ArrayList<>()); + } + + public ArrayList> getQuests(CoreClient client) + { + player(client.GetPlayer()); +// ArrayList> list = new ArrayList<>(); +// for (int i = 2; i <= 3; i++) +// { +// list.add(Triple.of(i, UtilMath.r(10) + 1, System.currentTimeMillis() - (1000*60*60*48))); +// } +// return list; + return _db.get(client.GetPlayer().getUniqueId().toString()); + } + + public void resetQuest(CoreClient client, Quest quest, boolean completed) + { + player(client.GetPlayer()); + Triple toAdd = null; + ArrayList> liste = _db.get(client.GetPlayer().getUniqueId().toString()); + Iterator> iterator = liste.iterator(); + while (iterator.hasNext()) + { + Triple triple = iterator.next(); + if (triple.getLeft() == quest.getID()) + { + toAdd = Triple.of(triple.getLeft(), -1, (completed ? System.currentTimeMillis() : (long) 0)); + iterator.remove(); + } + } + if (toAdd != null) + _db.get(client.GetPlayer().getUniqueId().toString()).add(toAdd); + } + + public void addNew(CoreClient client, Quest quest) + { + player(client.GetPlayer()); + _db.get(client.GetPlayer().getUniqueId().toString()).add(Triple.of(quest.getID(), 0, (long) 0)); + } + + public void incrementQuest(CoreClient client, Quest quest) + { + player(client.GetPlayer()); + Triple toAdd = null; + ArrayList> liste = _db.get(client.GetPlayer().getUniqueId().toString()); + Iterator> iterator = liste.iterator(); + while (iterator.hasNext()) + { + Triple triple = iterator.next(); + if (triple.getLeft() == quest.getID()) + { + toAdd = Triple.of(triple.getLeft(), triple.getMiddle() + 1, triple.getRight()); + iterator.remove(); + } + } + if (toAdd != null) + _db.get(client.GetPlayer().getUniqueId().toString()).add(toAdd); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java new file mode 100644 index 000000000..27053ee37 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java @@ -0,0 +1,67 @@ +package mineplex.core.quests.shop; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.quests.Quest; +import mineplex.core.quests.QuestManager; +import mineplex.core.recharge.Recharge; +import mineplex.core.shop.confirmation.ConfirmationPage; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.SalesPackageBase; +import mineplex.core.shop.item.SalesPackageProcessor; + +/** + * BuyQuestButton + * + * @author xXVevzZXx + */ +public class BuyQuestButton implements IButton +{ + private QuestManager _questManager; + + private QuestPage _page; + + private Quest _quest; + + public BuyQuestButton(QuestManager questManager, QuestPage page, Quest quest) + { + _questManager = questManager; + _quest = quest; + _page = page; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + if (!Recharge.Instance.use(player, "Buy Quest", 1000, false, false)) + { + return; + } + + if (_questManager.Get(player).hasQuest(_quest)) + { + UtilPlayer.message(player, F.main("Quest", "You already own that Quest!")); + return; + } + + SalesPackageBase salesPackage = new QuestSale(_quest.getName(), Material.PAPER, _quest.getCost()); + _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, _page.getDonationManager(), () -> + { + _questManager.addNewQuest(player, _quest); + + player.closeInventory(); + + QuestPage page = new QuestPage(_page.getPlugin(), _page.getQuestShop(), _page.getClientManager(), _page.getDonationManager(), player); + _page.getQuestShop().openPageForPlayer(player, page); + + }), salesPackage.buildIcon())); + + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java new file mode 100644 index 000000000..208810b8a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java @@ -0,0 +1,132 @@ +package mineplex.core.quests.shop; + +import java.util.Arrays; + +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.quests.Quest; +import mineplex.core.quests.QuestManager; +import mineplex.core.shop.page.ShopPageBase; + +/** + * QuestPage + * + * @author xXVevzZXx + */ +public class QuestPage extends ShopPageBase +{ + + public QuestPage(QuestManager plugin, QuestShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Quest Page", player); + + buildPage(); + } + + @Override + protected void buildPage() + { + int i = 0; + while (i < 9) + { + setItem(i, ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.BLACK.getData())); + i++; + } + + { + int currentSlot = 4; + int diff = 0; + boolean forward = true; + for (int questID : getQuestShop().getQuestManager().getCurrentQuests()) + { + if (forward) + { + currentSlot += diff; + } + else + { + currentSlot -= diff; + } + diff++; + forward = !forward; + + Quest quest = _shop.getQuestManager().getQuestByID(questID); + + ItemStack item = new ItemStack(Material.PAPER); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + quest.getName()); + meta.setLore(Arrays.asList( + ChatColor.YELLOW + quest.getTask(), + "", + ChatColor.GREEN + "Cost: " + quest.getCost() + " Gems", + ChatColor.AQUA + "Reward: " + quest.getReward() + " Shards", + "", + quest.getRarity().getColor() + "" + ChatColor.BOLD + quest.getRarity().toString(), + "", + ChatColor.GREEN + "Click to buy Quest!" + )); + item.setItemMeta(meta); + + addButton(i + currentSlot, item, new BuyQuestButton(_plugin, this, quest)); + } + } + i = 9*2; + while (i < (9*3)) + { + setItem(i, ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.BLACK.getData())); + i++; + } + i = 9*4; + + { + int currentSlot = 4; + int diff = 0; + boolean forward = true; + for (Quest quest : _shop.getQuestManager().Get(_player).getQuests()) + { + if (forward) + { + currentSlot += diff; + } + else + { + currentSlot -= diff; + } + diff++; + forward = !forward; + + ItemStack item = new ItemStack(Material.PAPER); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + quest.getName()); + meta.setLore(Arrays.asList( + ChatColor.YELLOW + quest.getTask(), + "", + ChatColor.AQUA + "Reward: " + quest.getReward() + " Shards", + "", + quest.getRarity().getColor() + "" + ChatColor.BOLD + quest.getRarity().toString(), + "", + ChatColor.YELLOW + "Progress: " + (quest.isCompleted() ? ChatColor.GREEN + "Completed!" : quest.getProgress() + "/" + quest.getStatToComplete()), + "", + (quest.isCompleted() ? ChatColor.GREEN + "Left Click to Complete" : ChatColor.RED + "Right Shift Click to cancell") + )); + item.setItemMeta(meta); + + addButton(i + currentSlot, item, new RedeemDeclineQuestButton(_donationManager, _plugin, this, quest)); + } + } + } + + public QuestShop getQuestShop() + { + return _shop; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestSale.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestSale.java new file mode 100644 index 000000000..dfb266baa --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestSale.java @@ -0,0 +1,25 @@ +package mineplex.core.quests.shop; + +import org.bukkit.Material; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.shop.item.SalesPackageBase; + +/** + * QuestSale + * + * @author xXVevzZXx + */ +public class QuestSale extends SalesPackageBase +{ + + public QuestSale(String name, Material mat, int cost) + { + super(name, mat, (byte) 0, new String[] {}, cost); + + KnownPackage = false; + OneTimePurchaseOnly = false; + CurrencyCostMap.clear(); + CurrencyCostMap.put(GlobalCurrency.GEM, cost); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestShop.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestShop.java new file mode 100644 index 000000000..10219c8b5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestShop.java @@ -0,0 +1,34 @@ +package mineplex.core.quests.shop; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.quests.QuestManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; + +/** + * QuestShop + * + * @author xXVevzZXx + */ +public class QuestShop extends ShopBase +{ + public QuestShop(QuestManager plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super(plugin, clientManager, donationManager, "Quest Shop"); + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return new QuestPage(getPlugin(), this, getClientManager(), getDonationManager(), player); + } + + public QuestManager getQuestManager() + { + return getPlugin(); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java new file mode 100644 index 000000000..a33c2f3e4 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java @@ -0,0 +1,85 @@ +package mineplex.core.quests.shop; + +import javax.jws.Oneway; + +import net.md_5.bungee.api.ChatColor; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; +import mineplex.core.quests.Quest; +import mineplex.core.quests.QuestManager; +import mineplex.core.recharge.Recharge; +import mineplex.core.shop.item.IButton; + +/** + * RedeemDeclineQuest + * + * @author xXVevzZXx + */ +public class RedeemDeclineQuestButton implements IButton +{ + private QuestManager _questManager; + private DonationManager _donations; + + private QuestPage _page; + + private Quest _quest; + + public RedeemDeclineQuestButton(DonationManager donations, QuestManager questManager, QuestPage page, Quest quest) + { + _questManager = questManager; + _donations = donations; + _quest = quest; + _page = page; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + if (!Recharge.Instance.use(player, "Decline Quest", 1000, false, false)) + { + return; + } + + if (!_questManager.Get(player).hasQuest(_quest)) + { + UtilPlayer.message(player, F.main("Quest", "You dont own that Quest!")); + return; + } + + if (clickType == ClickType.SHIFT_RIGHT) + { + if (_quest.isCompleted()) + { + UtilPlayer.message(player, F.main("Quest", "You can't cancell a completed Quest!")); + return; + } + _questManager.resetQuest(player, _quest, false); + UtilPlayer.message(player, F.main("Quest", "You have cancelled that Quest!")); + } + + if (clickType == ClickType.LEFT) + { + if (!_quest.isCompleted()) + { + UtilPlayer.message(player, F.main("Quest", "You havent completed that Quest yet!")); + return; + } + _questManager.resetQuest(player, _quest, true); + _donations.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completed Quest: " + _quest.getID(), _quest.getReward()); + UtilPlayer.message(player, F.main("Quest", "You have recieved " + ChatColor.AQUA + _quest.getReward() + " Shards " + ChatColor.GRAY + "for completing a Quest!")); + } + + if (clickType == ClickType.LEFT || clickType == ClickType.SHIFT_RIGHT) + { + QuestPage page = new QuestPage(_page.getPlugin(), _page.getQuestShop(), _page.getClientManager(), _page.getDonationManager(), player); + _page.getQuestShop().openPageForPlayer(player, page); + } + + } +} diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountQuest.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountQuest.java index e2794b6a1..a5e501bd3 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountQuest.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/AccountQuest.java @@ -13,102 +13,102 @@ import org.jooq.impl.TableImpl; comments = "This class is generated by jOOQ" ) @java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" }) -public class AccountQuest extends TableImpl implements java.io.Serializable, java.lang.Cloneable +public class AccountQuest //extends TableImpl implements java.io.Serializable, java.lang.Cloneable { - /** - * - */ - private static final long serialVersionUID = -8158716179851336044L; - - /** - * The reference instance of Account.accountStat - */ - public static final mineplex.database.tables.AccountStat accountStat = new mineplex.database.tables.AccountStat(); - - /** - * The class holding records for this type - */ - @Override - public java.lang.Class getRecordType() { - return mineplex.database.tables.records.AccountQuestRecord.class; - } - - /** - * The column Account.accountStat.accountId. - */ - public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); - - /** - * The column Account.accountStat.statId. - */ - public final org.jooq.TableField statId = createField("statId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); - - /** - * The column Account.accountStat.value. - */ - public final org.jooq.TableField value = createField("value", org.jooq.impl.SQLDataType.BIGINTUNSIGNED.defaulted(true), this, ""); - - /** - * Create a Account.accountStat table reference - */ - public AccountQuest() - { - super("accountquest", null); - } - - /** - * Create an aliased Account.accountStat table reference - */ - public AccountQuest(java.lang.String alias) { - this(alias, mineplex.database.tables.AccountQuest.accountStat); - } - - private AccountQuest(java.lang.String alias, org.jooq.Table aliased) { - this(alias, aliased, null); - } - - private AccountQuest(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { - super(alias, mineplex.database.Account.Account, aliased, parameters, ""); - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.UniqueKey getPrimaryKey() { - return mineplex.database.Keys.KEY_accountStat_PRIMARY; - } - - /** - * {@inheritDoc} - */ - @Override - public java.util.List> getKeys() { - return java.util.Arrays.>asList(mineplex.database.Keys.KEY_accountStat_PRIMARY); - } - - /** - * {@inheritDoc} - */ - @Override - public java.util.List> getReferences() { - return java.util.Arrays.>asList(mineplex.database.Keys.accountStat_account, mineplex.database.Keys.accountStat_stat); - } - - /** - * {@inheritDoc} - */ - @Override - public mineplex.database.tables.AccountStat as(java.lang.String alias) { - return new mineplex.database.tables.AccountStat(alias, this); - } - - /** - * Rename this table - */ - public mineplex.database.tables.AccountStat rename(java.lang.String name) { - return new mineplex.database.tables.AccountStat(name, null); - } +// /** +// * +// */ +// private static final long serialVersionUID = -8158716179851336044L; +// +// /** +// * The reference instance of Account.accountStat +// */ +// public static final mineplex.database.tables.AccountStat accountStat = new mineplex.database.tables.AccountStat(); +// +// /** +// * The class holding records for this type +// */ +// @Override +// public java.lang.Class getRecordType() { +// return mineplex.database.tables.records.AccountQuestRecord.class; +// } +// +// /** +// * The column Account.accountStat.accountId. +// */ +// public final org.jooq.TableField accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); +// +// /** +// * The column Account.accountStat.statId. +// */ +// public final org.jooq.TableField statId = createField("statId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); +// +// /** +// * The column Account.accountStat.value. +// */ +// public final org.jooq.TableField value = createField("value", org.jooq.impl.SQLDataType.BIGINTUNSIGNED.defaulted(true), this, ""); +// +// /** +// * Create a Account.accountStat table reference +// */ +// public AccountQuest() +// { +// super("accountquest", null); +// } +// +// /** +// * Create an aliased Account.accountStat table reference +// */ +// public AccountQuest(java.lang.String alias) { +// this(alias, mineplex.database.tables.AccountQuest.accountStat); +// } +// +// private AccountQuest(java.lang.String alias, org.jooq.Table aliased) { +// this(alias, aliased, null); +// } +// +// private AccountQuest(java.lang.String alias, org.jooq.Table aliased, org.jooq.Field[] parameters) { +// super(alias, mineplex.database.Account.Account, aliased, parameters, ""); +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public org.jooq.UniqueKey getPrimaryKey() { +// return mineplex.database.Keys.KEY_accountStat_PRIMARY; +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public java.util.List> getKeys() { +// return java.util.Arrays.>asList(mineplex.database.Keys.KEY_accountStat_PRIMARY); +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public java.util.List> getReferences() { +// return java.util.Arrays.>asList(mineplex.database.Keys.accountStat_account, mineplex.database.Keys.accountStat_stat); +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public mineplex.database.tables.AccountStat as(java.lang.String alias) { +// return new mineplex.database.tables.AccountStat(alias, this); +// } +// +// /** +// * Rename this table +// */ +// public mineplex.database.tables.AccountStat rename(java.lang.String name) { +// return new mineplex.database.tables.AccountStat(name, null); +// } } diff --git a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountQuestRecord.java b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountQuestRecord.java index c707a42c7..8b1926b2e 100644 --- a/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountQuestRecord.java +++ b/Plugins/Mineplex.Database/src/mineplex/database/tables/records/AccountQuestRecord.java @@ -7,196 +7,196 @@ import org.jooq.Table; * * @author xXVevzZXx */ -public class AccountQuestRecord extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 +public class AccountQuestRecord //extends org.jooq.impl.UpdatableRecordImpl implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record3 { - - /** - * - */ - private static final long serialVersionUID = 5171965369180094201L; - - public AccountQuestRecord(Table table) - { - super(table); - } - - /** - * Setter for Account.accountStat.accountId. - */ - public void setAccountId(java.lang.Integer value) { - setValue(0, value); - } - - /** - * Getter for Account.accountStat.accountId. - */ - public java.lang.Integer getAccountId() { - return (java.lang.Integer) getValue(0); - } - - /** - * Setter for Account.accountStat.statId. - */ - public void setStatId(java.lang.Integer value) { - setValue(1, value); - } - - /** - * Getter for Account.accountStat.statId. - */ - public java.lang.Integer getStatId() { - return (java.lang.Integer) getValue(1); - } - - /** - * Setter for Account.accountStat.value. - */ - public void setValue(org.jooq.types.ULong value) { - setValue(2, value); - } - - /** - * Getter for Account.accountStat.value. - */ - public org.jooq.types.ULong getValue() { - return (org.jooq.types.ULong) getValue(2); - } - - // ------------------------------------------------------------------------- - // Primary key information - // ------------------------------------------------------------------------- - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Record2 key() { - return (org.jooq.Record2) super.key(); - } - - // ------------------------------------------------------------------------- - // Record3 type implementation - // ------------------------------------------------------------------------- - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Row3 fieldsRow() { - return (org.jooq.Row3) super.fieldsRow(); - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Row3 valuesRow() { - return (org.jooq.Row3) super.valuesRow(); - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field1() { - return mineplex.database.tables.AccountStat.accountStat.accountId; - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field2() { - return mineplex.database.tables.AccountStat.accountStat.statId; - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.Field field3() { - return mineplex.database.tables.AccountStat.accountStat.value; - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.Integer value1() { - return getAccountId(); - } - - /** - * {@inheritDoc} - */ - @Override - public java.lang.Integer value2() { - return getStatId(); - } - - /** - * {@inheritDoc} - */ - @Override - public org.jooq.types.ULong value3() { - return getValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public AccountStatRecord value1(java.lang.Integer value) { - setAccountId(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public AccountStatRecord value2(java.lang.Integer value) { - setStatId(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public AccountStatRecord value3(org.jooq.types.ULong value) { - setValue(value); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public AccountStatRecord values(java.lang.Integer value1, java.lang.Integer value2, org.jooq.types.ULong value3) { - return this; - } - - // ------------------------------------------------------------------------- - // Constructors - // ------------------------------------------------------------------------- - - /** - * Create a detached AccountStatRecord - */ - public AccountStatRecord() { - super(mineplex.database.tables.AccountStat.accountStat); - } - - /** - * Create a detached, initialised AccountStatRecord - */ - public AccountStatRecord(java.lang.Integer accountId, java.lang.Integer statId, org.jooq.types.ULong value) { - super(mineplex.database.tables.AccountStat.accountStat); - - setValue(0, accountId); - setValue(1, statId); - setValue(2, value); - } +// +// /** +// * +// */ +// private static final long serialVersionUID = 5171965369180094201L; +// +// public AccountQuestRecord(Table table) +// { +// super(table); +// } +// +// /** +// * Setter for Account.accountStat.accountId. +// */ +// public void setAccountId(java.lang.Integer value) { +// setValue(0, value); +// } +// +// /** +// * Getter for Account.accountStat.accountId. +// */ +// public java.lang.Integer getAccountId() { +// return (java.lang.Integer) getValue(0); +// } +// +// /** +// * Setter for Account.accountStat.statId. +// */ +// public void setStatId(java.lang.Integer value) { +// setValue(1, value); +// } +// +// /** +// * Getter for Account.accountStat.statId. +// */ +// public java.lang.Integer getStatId() { +// return (java.lang.Integer) getValue(1); +// } +// +// /** +// * Setter for Account.accountStat.value. +// */ +// public void setValue(org.jooq.types.ULong value) { +// setValue(2, value); +// } +// +// /** +// * Getter for Account.accountStat.value. +// */ +// public org.jooq.types.ULong getValue() { +// return (org.jooq.types.ULong) getValue(2); +// } +// +// // ------------------------------------------------------------------------- +// // Primary key information +// // ------------------------------------------------------------------------- +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public org.jooq.Record2 key() { +// return (org.jooq.Record2) super.key(); +// } +// +// // ------------------------------------------------------------------------- +// // Record3 type implementation +// // ------------------------------------------------------------------------- +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public org.jooq.Row3 fieldsRow() { +// return (org.jooq.Row3) super.fieldsRow(); +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public org.jooq.Row3 valuesRow() { +// return (org.jooq.Row3) super.valuesRow(); +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public org.jooq.Field field1() { +// return mineplex.database.tables.AccountStat.accountStat.accountId; +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public org.jooq.Field field2() { +// return mineplex.database.tables.AccountStat.accountStat.statId; +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public org.jooq.Field field3() { +// return mineplex.database.tables.AccountStat.accountStat.value; +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public java.lang.Integer value1() { +// return getAccountId(); +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public java.lang.Integer value2() { +// return getStatId(); +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public org.jooq.types.ULong value3() { +// return getValue(); +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public AccountStatRecord value1(java.lang.Integer value) { +// setAccountId(value); +// return this; +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public AccountStatRecord value2(java.lang.Integer value) { +// setStatId(value); +// return this; +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public AccountStatRecord value3(org.jooq.types.ULong value) { +// setValue(value); +// return this; +// } +// +// /** +// * {@inheritDoc} +// */ +// @Override +// public AccountStatRecord values(java.lang.Integer value1, java.lang.Integer value2, org.jooq.types.ULong value3) { +// return this; +// } +// +// // ------------------------------------------------------------------------- +// // Constructors +// // ------------------------------------------------------------------------- +// +// /** +// * Create a detached AccountStatRecord +// */ +// public AccountStatRecord() { +// super(mineplex.database.tables.AccountStat.accountStat); +// } +// +// /** +// * Create a detached, initialised AccountStatRecord +// */ +// public AccountStatRecord(java.lang.Integer accountId, java.lang.Integer statId, org.jooq.types.ULong value) { +// super(mineplex.database.tables.AccountStat.accountStat); +// +// setValue(0, accountId); +// setValue(1, statId); +// setValue(2, value); +// } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 1e7dfd060..dd2f94aef 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -4,6 +4,13 @@ import java.util.HashMap; import java.util.Iterator; import java.util.UUID; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.HoverEvent.Action; +import net.md_5.bungee.api.chat.TextComponent; +import net.minecraft.server.v1_8_R3.EntityInsentient; +import net.minecraft.server.v1_8_R3.EntityPlayer; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -96,6 +103,7 @@ import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; +import mineplex.core.quests.QuestManager; import mineplex.core.scoreboard.MineplexScoreboard; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.stats.StatsManager; @@ -131,12 +139,6 @@ import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.condition.ConditionManager; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.HoverEvent.Action; -import net.md_5.bungee.api.chat.TextComponent; -import net.minecraft.server.v1_8_R3.EntityInsentient; -import net.minecraft.server.v1_8_R3.EntityPlayer; public class HubManager extends MiniClientPlugin implements IChatMessageFormatter { @@ -175,6 +177,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess // private HalloweenSpookinessManager _halloweenManager; // private TrickOrTreatManager _trickOrTreatManager; private MavericksManager _mavericksManager; + private QuestManager _questManager; private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class); private HologramManager _hologramManager; @@ -288,6 +291,8 @@ public class HubManager extends MiniClientPlugin implements IChatMess _hologramManager = hologramManager; new EasterEggHunt(plugin, _clientManager); + + _questManager = new QuestManager(); ScoreboardManager scoreboardManager = new ScoreboardManager(plugin) { @@ -1024,4 +1029,9 @@ public class HubManager extends MiniClientPlugin implements IChatMess { return _jumpManager; } + + public QuestManager getQuestManager() + { + return _questManager; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index af4d8cea5..c15f4d3fa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -94,6 +94,7 @@ import mineplex.core.preferences.PreferencesManager; import mineplex.core.progression.KitProgressionManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; +import mineplex.core.quests.QuestManager; import mineplex.core.rankGiveaway.eternal.EternalGiveawayManager; import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager; import mineplex.core.resourcepack.ResourcePackManager; @@ -233,7 +234,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation private ScoreboardManager _scoreboardManager; private NextBestGameManager _nextBestGameManager; private TrackManager _trackManager; - + private QuestManager _questManager; + private IncognitoManager _incognitoManager; private TaskManager _taskManager; @@ -389,6 +391,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _kitProgressionManager = new KitProgressionManager(getPlugin(), donationManager, clientManager); _progressionKitManager = new ProgressingKitManager(this); _serverUptimeManager = new ServerUptimeManager(this); + _questManager = new QuestManager(); if (GetHost() != null && !GetHost().isEmpty() && !GetHost().startsWith("COM-")) { @@ -2063,4 +2066,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation { return this._titles; } + + public QuestManager getQuestManager() + { + return _questManager; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 89fe831d5..f4d15da89 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -101,6 +101,10 @@ import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.managers.lobby.LobbyManager; +import nautilus.game.arcade.quest.CollectQuestTracker; +import nautilus.game.arcade.quest.KillQuestTracker; +import nautilus.game.arcade.quest.QuestTracker; +import nautilus.game.arcade.quest.WinQuestTracker; import nautilus.game.arcade.scoreboard.GameScoreboard; import nautilus.game.arcade.stats.AssistsStatTracker; import nautilus.game.arcade.stats.DamageDealtStatTracker; @@ -343,6 +347,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public int EloStart = 1000; public boolean CanAddStats = true; + public boolean CanProgressQuests = true; public boolean CanGiveLoot = true; public boolean HideTeamSheep = false; @@ -378,6 +383,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed private NautHashMap _deadBodiesExpire = new NautHashMap(); private final Set> _statTrackers = new HashSet<>(); + private final Set _questTrackers = new HashSet<>(); private NautHashMap _teamReqs = new NautHashMap(); public WinEffectManager WinEffectManager = new WinEffectManager(); @@ -450,6 +456,9 @@ public abstract class Game extends ListenerComponent implements Lifetimed registerStatTrackers(new KillsStatTracker(this), new DeathsStatTracker(this), new AssistsStatTracker(this), new ExperienceStatTracker(this), new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker( this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this)); + + // Quest Trackers + registerQuestTrackers(new WinQuestTracker(this), new KillQuestTracker(this), new CollectQuestTracker(this)); Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(this), gameType.isEnforceResourcePack(this)); @@ -1773,6 +1782,20 @@ public abstract class Game extends ListenerComponent implements Lifetimed { return _statTrackers; } + + public void registerQuestTrackers(QuestTracker... questTrackers) + { + for (QuestTracker tracker : questTrackers) + { + if (_questTrackers.add(tracker)) + Bukkit.getPluginManager().registerEvents(tracker, Manager.getPlugin()); + } + } + + public Collection getQuestTrackers() + { + return _questTrackers; + } @EventHandler public void onHangingBreak(HangingBreakEvent event) @@ -2360,6 +2383,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed Managers.get(AntiHack.class).resetIgnoredChecks(); getLifetime().end(); getStatTrackers().forEach(HandlerList::unregisterAll); + getQuestTrackers().forEach(HandlerList::unregisterAll); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java new file mode 100644 index 000000000..cf8b584f8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java @@ -0,0 +1,43 @@ +package nautilus.game.arcade.quest; + +import java.util.ArrayList; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.Game; + +/** + * CollectQuestTracker + * + * @author xXVevzZXx + */ +public class CollectQuestTracker extends QuestTracker +{ + private ArrayList _alreadyCounted; + + public CollectQuestTracker(Game game) + { + super(game, TriggerType.COLLECT); + + _alreadyCounted = new ArrayList<>(); + } + + @EventHandler + public void collectItem(InventoryClickEvent event) + { + if (event.getClickedInventory() instanceof PlayerInventory) + return; + + System.out.println(event.getCurrentItem().getType().toString()); + _alreadyCounted.add(event.getCurrentItem()); + + incrementQuests((Player) event.getWhoClicked(), event.getCurrentItem().getType().toString(), 1); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java new file mode 100644 index 000000000..b4e82c4dc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.quest; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.Game; + +/** + * WInQuestTracker + * + * @author xXVevzZXx + */ +public class KillQuestTracker extends QuestTracker +{ + + public KillQuestTracker(Game game) + { + super(game, TriggerType.WIN); + } + + @EventHandler + public void onKil(EntityDamageByEntityEvent event) + { + if (!(event.getDamager() instanceof Player)) + return; + + if (!(event.getEntity() instanceof Player)) + return; + + if (((Player) event.getEntity()).getHealth() > 0) + return; + + incrementQuests((Player) event.getDamager(), 1); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java new file mode 100644 index 000000000..c6ec9d2d1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java @@ -0,0 +1,74 @@ +package nautilus.game.arcade.quest; + +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +import mineplex.core.game.GameDisplay; +import mineplex.core.quests.Quest; +import mineplex.core.quests.QuestClientData; +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.Game; + +/** + * QuestTracker + * + * @author xXVevzZXx + */ +public class QuestTracker implements Listener +{ + private Game _game; + private TriggerType _trigger; + + public QuestTracker(Game game, TriggerType type) + { + _game = game; + _trigger = type; + } + + public Game getGame() + { + return _game; + } + + public boolean canProgressQuests() + { + return getGame().CanProgressQuests; + } + + public void incrementQuests(Player player, int value) + { + incrementQuests(player, "", value); + } + + public void incrementQuests(Player player, String item, int value) + { + if (canProgressQuests()) + { + for (Quest quest : getGame().getArcadeManager().getQuestManager().getAvailableQuests()) + { + if (getGame().GetType().getDisplay() != quest.getGame()) + continue; + + if (quest.getTrigger() != _trigger) + continue; + + if (!quest.getItem().equalsIgnoreCase(item)) + continue; + + QuestClientData data = _game.getArcadeManager().getQuestManager().Get(player); + if (!data.hasQuest(quest)) + continue; + + Quest toProgress = data.getQuest(quest.getID()); + + _game.getArcadeManager().getQuestManager().incrementQuest(_game.getArcadeManager().GetClients().Get(player), toProgress, value); + } + } + } + + public TriggerType getTrigger() + { + return _trigger; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/WinQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/WinQuestTracker.java new file mode 100644 index 000000000..183ee7f60 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/WinQuestTracker.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.quest; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; + +/** + * WinQuestTracker + * + * @author xXVevzZXx + */ +public class WinQuestTracker extends QuestTracker +{ + + public WinQuestTracker(Game game) + { + super(game, TriggerType.WIN); + } + + @EventHandler + public void onWin(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + return; + + for (Player player : getGame().getWinners()) + { + incrementQuests(player, 1); + } + } + +} diff --git a/Plugins/mineplex-google-sheets/src/mineplex/googlesheets/SpreadsheetType.java b/Plugins/mineplex-google-sheets/src/mineplex/googlesheets/SpreadsheetType.java index af2acf11c..7c14a68b4 100644 --- a/Plugins/mineplex-google-sheets/src/mineplex/googlesheets/SpreadsheetType.java +++ b/Plugins/mineplex-google-sheets/src/mineplex/googlesheets/SpreadsheetType.java @@ -8,6 +8,8 @@ public enum SpreadsheetType GEM_HUNTERS_CHESTS("11Noztgbpu_gUKkc5F4evKKfyxS-Jv1coE0IrBToX_gg"), GEM_HUNTERS_SHOP("1OcYktxVZaW6Fm29Zh6w4Lb-UVyuN8r1x-TFb_3USYYI"), + + QUESTS_SHEET("1Gy1a7GCVopmOLwYE3Sk1DNVCAIwT8ReaLu4wRe0sfDE") ; private String _id; From a32ae91996d49168283736d1da0f668da32a63a2 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 5 May 2017 22:30:37 +0100 Subject: [PATCH 008/283] Gotta go fast! --- .../core/common/entity/ClientArmorStand.java | 1038 +++++++++++++++++ .../src/nautilus/game/arcade/game/Game.java | 3 +- .../game/arcade/game/games/moba/Moba.java | 124 +- .../game/arcade/game/games/moba/MobaRole.java | 18 +- .../arcade/game/games/moba/kit/HeroKit.java | 124 ++ .../game/games/moba/kit/KitSelection.java | 30 - .../game/games/moba/kit/PregameSelection.java | 164 +++ .../game/games/moba/kit/RoleSelectEvent.java | 61 + .../games/moba/kit/heroes/HeroHattori.java | 32 + .../arcade/game/games/moba/recall/Recall.java | 136 +++ .../game/games/moba/recall/RecallSession.java | 19 + .../arcade/game/games/moba/shop/MobaShop.java | 16 + .../moba/structure/point/CapturePoint.java | 2 - .../games/moba/structure/tower/Tower.java | 95 ++ .../structure/tower/TowerDestroyEvent.java | 34 + .../game/arcade/game/games/uhc/UHC.java | 2 + .../game/arcade/managers/GameHostManager.java | 2 +- .../game/arcade/managers/GameManager.java | 2 +- .../serverreset/ServerResetCommand.java | 2 +- 19 files changed, 1862 insertions(+), 42 deletions(-) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/RoleSelectEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerDestroyEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java new file mode 100644 index 000000000..239f0af5c --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java @@ -0,0 +1,1038 @@ +package mineplex.core.common.entity; + +import mineplex.core.common.util.UtilPlayer; +import net.minecraft.server.v1_8_R3.*; +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Server; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.*; +import org.bukkit.entity.Entity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.MetadataValue; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionAttachment; +import org.bukkit.permissions.PermissionAttachmentInfo; +import org.bukkit.plugin.Plugin; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.EulerAngle; +import org.bukkit.util.Vector; + +import java.util.*; + +public class ClientArmorStand implements ArmorStand +{ + + private static final int HAND = 0; + private static final int HELMET = 4; + private static final int CHESTPLATE = 3; + private static final int LEGGINGS = 2; + private static final int BOOTS = 1; + + public static ClientArmorStand spawn(Location location) + { + EntityArmorStand entityArmorStand = new EntityArmorStand(((CraftWorld) location.getWorld()).getHandle()); + entityArmorStand.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + ClientArmorStand clientArmorStand = new ClientArmorStand(entityArmorStand); + + for (Player other : clientArmorStand.getObservers()) + { + UtilPlayer.sendPacket(other, new PacketPlayOutSpawnEntityLiving(entityArmorStand)); + } + + return clientArmorStand; + } + + public static ClientArmorStand spawn(Location loc, Player... players) + { + EntityArmorStand entityArmorStand = new EntityArmorStand(((CraftWorld) loc.getWorld()).getHandle()); + entityArmorStand.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); + ClientArmorStand clientArmorStand = new ClientArmorStand(entityArmorStand, players); + Packet packet = new PacketPlayOutSpawnEntityLiving(entityArmorStand); + + for (Player observer : players) + { + UtilPlayer.sendPacket(observer, packet); + } + + return clientArmorStand; + } + + private final EntityArmorStand _armorStand; + private ItemStack _itemInHand, _helmet, _chestplate, _leggings, _boots; + private boolean _visible; + private final DataWatcher _dataWatcher; + + private Player[] _observers; + + private ClientArmorStand(EntityArmorStand armorStand, Player... players) + { + _armorStand = armorStand; + _dataWatcher = armorStand.getDataWatcher(); + _observers = players; + } + + public EntityArmorStand getHandle() + { + return _armorStand; + } + + @Override + public ItemStack getItemInHand() + { + return _itemInHand; + } + + @Override + public void setItemInHand(ItemStack itemStack) + { + _itemInHand = itemStack; + sendPacket(new PacketPlayOutEntityEquipment(getEntityId(), HAND, CraftItemStack.asNMSCopy(itemStack))); + } + + @Override + public ItemStack getHelmet() + { + return _helmet; + } + + @Override + public void setHelmet(ItemStack itemStack) + { + _helmet = itemStack; + sendPacket(new PacketPlayOutEntityEquipment(getEntityId(), HELMET, CraftItemStack.asNMSCopy(itemStack))); + } + + @Override + public ItemStack getChestplate() + { + return _chestplate; + } + + @Override + public void setChestplate(ItemStack itemStack) + { + _chestplate = itemStack; + sendPacket(new PacketPlayOutEntityEquipment(getEntityId(), CHESTPLATE, CraftItemStack.asNMSCopy(itemStack))); + } + + @Override + public ItemStack getLeggings() + { + return _leggings; + } + + @Override + public void setLeggings(ItemStack itemStack) + { + _leggings = itemStack; + sendPacket(new PacketPlayOutEntityEquipment(getEntityId(), LEGGINGS, CraftItemStack.asNMSCopy(itemStack))); + } + + @Override + public ItemStack getBoots() + { + return _boots; + } + + @Override + public void setBoots(ItemStack itemStack) + { + _boots = itemStack; + sendPacket(new PacketPlayOutEntityEquipment(getEntityId(), BOOTS, CraftItemStack.asNMSCopy(itemStack))); + } + + @Override + public Location getEyeLocation() + { + return getLocation().add(0, getEyeHeight(), 0); + } + + @Override + public double getEyeHeight() + { + return 1.62; + } + + @Override + public double getEyeHeight(boolean sneaking) + { + return getEyeHeight(); + } + + @Override + public String getCustomName() + { + return _armorStand.getCustomName(); + } + + @Override + public Location getLocation() + { + return new Location(getWorld(), _armorStand.locX, _armorStand.locY, _armorStand.locZ); + } + + @Override + public boolean isVisible() + { + return _visible; + } + + @Override + public void setVisible(boolean visible) + { + _visible = visible; + _armorStand.setInvisible(!visible); + sendMetaPacket(); + } + + private void sendMetaPacket() + { + sendPacket(new PacketPlayOutEntityMetadata(getEntityId(), _dataWatcher, true), _observers); + } + + @Override + public Entity getPassenger() + { + return null; + } + + @Override + public Entity getVehicle() + { + return null; + } + + @Override + public org.bukkit.World getWorld() + { + return _armorStand.getWorld().getWorld(); + } + + @Override + public void remove() + { + sendPacket(new PacketPlayOutEntityDestroy(new int[]{_armorStand.getId()})); + } + + public void remove(Player... player) + { + sendPacket(new PacketPlayOutEntityDestroy(new int[]{_armorStand.getId()}), player); + } + + @Override + public void setCustomName(String arg0) + { + _armorStand.setCustomName(arg0); + sendMetaPacket(); + } + + @Override + public boolean setPassenger(Entity arg0) + { + return false; + } + + @Override + public boolean teleport(Location loc) + { + _armorStand.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); + sendPacket(new PacketPlayOutEntityTeleport(_armorStand)); + return false; + } + + @Override + public EulerAngle getBodyPose() + { + return null; + } + + @Override + public EulerAngle getHeadPose() + { + return fromNMS(_armorStand.headPose); + } + + @Override + public void setHeadPose(EulerAngle pose) + { + _armorStand.setHeadPose(toNMS(pose)); + sendMetaPacket(); + } + + @Override + public EulerAngle getLeftArmPose() + { + return null; + } + + @Override + public EulerAngle getLeftLegPose() + { + return null; + } + + @Override + public EulerAngle getRightArmPose() + { + return null; + } + + @Override + public EulerAngle getRightLegPose() + { + return null; + } + + @Override + public boolean hasArms() + { + return false; + } + + @Override + public boolean hasBasePlate() + { + return false; + } + + @Override + public boolean hasGravity() + { + return false; + } + + @Override + public boolean isMarker() + { + return false; + } + + @Override + public boolean isSmall() + { + return false; + } + + @Override + public void setArms(boolean arg0) + { + _armorStand.setArms(arg0); + sendMetaPacket(); + } + + @Override + public void setBasePlate(boolean arg0) + { + _armorStand.setBasePlate(arg0); + sendMetaPacket(); + } + + @Override + public void setBodyPose(EulerAngle arg0) + { + } + + @Override + public void setLeftArmPose(EulerAngle arg0) + { + } + + @Override + public void setLeftLegPose(EulerAngle arg0) + { + } + + @Override + public void setRightArmPose(EulerAngle arg0) + { + } + + @Override + public void setRightLegPose(EulerAngle arg0) + { + } + + @Override + public void setSmall(boolean arg0) + { + _armorStand.setSmall(arg0); + sendMetaPacket(); + } + + @Override + public int getEntityId() + { + return _armorStand.getId(); + } + + public Player[] getObservers() + { + return _observers; + } + + public void sendPacket(Packet packet) + { + sendPacket(packet, getObservers()); + } + + public void sendPacket(Packet packet, Collection observers) + { + for (Player player : observers) + { + UtilPlayer.sendPacket(player, packet); + } + } + + public void sendPacket(Packet packet, Player... observers) + { + for (Player player : observers) + { + UtilPlayer.sendPacket(player, packet); + } + } + + // Not needed + + @Override + public void setGravity(boolean b) + { + + } + + @Override + public void setMarker(boolean b) + { + + } + + @Override + public List getLineOfSight(HashSet hashSet, int i) + { + return null; + } + + @Override + public List getLineOfSight(Set set, int i) + { + return null; + } + + @Override + public Block getTargetBlock(HashSet hashSet, int i) + { + return null; + } + + @Override + public Block getTargetBlock(Set set, int i) + { + return null; + } + + @Override + public List getLastTwoTargetBlocks(HashSet hashSet, int i) + { + return null; + } + + @Override + public List getLastTwoTargetBlocks(Set set, int i) + { + return null; + } + + @Override + public Egg throwEgg() + { + return null; + } + + @Override + public Snowball throwSnowball() + { + return null; + } + + @Override + public Arrow shootArrow() + { + return null; + } + + @Override + public int getRemainingAir() + { + return 0; + } + + @Override + public void setRemainingAir(int i) + { + + } + + @Override + public int getMaximumAir() + { + return 0; + } + + @Override + public void setMaximumAir(int i) + { + + } + + @Override + public int getMaximumNoDamageTicks() + { + return 0; + } + + @Override + public void setMaximumNoDamageTicks(int i) + { + + } + + @Override + public double getLastDamage() + { + return 0; + } + + @Override + public void setLastDamage(double v) + { + + } + + @Override + public int getNoDamageTicks() + { + return 0; + } + + @Override + public void setNoDamageTicks(int i) + { + + } + + @Override + public Player getKiller() + { + return null; + } + + @Override + public boolean addPotionEffect(PotionEffect potionEffect) + { + return false; + } + + @Override + public boolean addPotionEffect(PotionEffect potionEffect, boolean b) + { + return false; + } + + @Override + public boolean addPotionEffects(Collection collection) + { + return false; + } + + @Override + public boolean hasPotionEffect(PotionEffectType potionEffectType) + { + return false; + } + + @Override + public void removePotionEffect(PotionEffectType potionEffectType) + { + + } + + @Override + public Collection getActivePotionEffects() + { + return null; + } + + @Override + public boolean hasLineOfSight(org.bukkit.entity.Entity entity) + { + return false; + } + + @Override + public boolean getRemoveWhenFarAway() + { + return false; + } + + @Override + public void setRemoveWhenFarAway(boolean b) + { + + } + + @Override + public EntityEquipment getEquipment() + { + return null; + } + + @Override + public void setCanPickupItems(boolean b) + { + + } + + @Override + public boolean getCanPickupItems() + { + return false; + } + + @Override + public boolean isLeashed() + { + return false; + } + + @Override + public org.bukkit.entity.Entity getLeashHolder() throws IllegalStateException + { + return null; + } + + @Override + public boolean setLeashHolder(org.bukkit.entity.Entity entity) + { + return false; + } + + @Override + public boolean shouldBreakLeash() + { + return false; + } + + @Override + public void setShouldBreakLeash(boolean b) + { + + } + + @Override + public boolean shouldPullWhileLeashed() + { + return false; + } + + @Override + public void setPullWhileLeashed(boolean b) + { + + } + + @Override + public boolean isVegetated() + { + return false; + } + + @Override + public void setVegetated(boolean b) + { + + } + + @Override + public boolean isGhost() + { + return false; + } + + @Override + public void setGhost(boolean b) + { + + } + + @Override + public void damage(double v) + { + + } + + @Override + public void damage(double v, org.bukkit.entity.Entity entity) + { + + } + + @Override + public double getHealth() + { + return 0; + } + + @Override + public void setHealth(double v) + { + + } + + @Override + public double getMaxHealth() + { + return 0; + } + + @Override + public void setMaxHealth(double v) + { + + } + + @Override + public void resetMaxHealth() + { + + } + + @Override + public Location getLocation(Location location) + { + return null; + } + + @Override + public void setVelocity(Vector vector) + { + + } + + @Override + public Vector getVelocity() + { + return null; + } + + @Override + public boolean isOnGround() + { + return false; + } + + @Override + public boolean teleport(Location location, TeleportCause teleportCause) + { + return false; + } + + @Override + public boolean teleport(org.bukkit.entity.Entity entity) + { + return false; + } + + @Override + public boolean teleport(org.bukkit.entity.Entity entity, TeleportCause teleportCause) + { + return false; + } + + @Override + public List getNearbyEntities(double v, double v1, double v2) + { + return null; + } + + @Override + public int getFireTicks() + { + return 0; + } + + @Override + public int getMaxFireTicks() + { + return 0; + } + + @Override + public void setFireTicks(int i) + { + + } + + @Override + public boolean isDead() + { + return false; + } + + @Override + public boolean isValid() + { + return false; + } + + @Override + public Server getServer() + { + return null; + } + + @Override + public boolean isEmpty() + { + return false; + } + + @Override + public boolean eject() + { + return false; + } + + @Override + public float getFallDistance() + { + return 0; + } + + @Override + public void setFallDistance(float v) + { + + } + + @Override + public void setLastDamageCause(EntityDamageEvent entityDamageEvent) + { + + } + + @Override + public EntityDamageEvent getLastDamageCause() + { + return null; + } + + @Override + public UUID getUniqueId() + { + return null; + } + + @Override + public int getTicksLived() + { + return 0; + } + + @Override + public void setTicksLived(int i) + { + + } + + @Override + public void playEffect(EntityEffect entityEffect) + { + + } + + @Override + public EntityType getType() + { + return null; + } + + @Override + public boolean isInsideVehicle() + { + return false; + } + + @Override + public boolean leaveVehicle() + { + return false; + } + + @Override + public void setCustomNameVisible(boolean b) + { + _armorStand.setCustomNameVisible(b); + } + + @Override + public boolean isCustomNameVisible() + { + return false; + } + + @Override + public Spigot spigot() + { + return null; + } + + @Override + public void sendMessage(String s) + { + + } + + @Override + public void sendMessage(String[] strings) + { + + } + + @Override + public String getName() + { + return null; + } + + @Override + public void setMetadata(String s, MetadataValue metadataValue) + { + + } + + @Override + public List getMetadata(String s) + { + return null; + } + + @Override + public boolean hasMetadata(String s) + { + return false; + } + + @Override + public void removeMetadata(String s, Plugin plugin) + { + + } + + @Override + public boolean isPermissionSet(String s) + { + return false; + } + + @Override + public boolean isPermissionSet(Permission permission) + { + return false; + } + + @Override + public boolean hasPermission(String s) + { + return false; + } + + @Override + public boolean hasPermission(Permission permission) + { + return false; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b) + { + return null; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin) + { + return null; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b, int i) + { + return null; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, int i) + { + return null; + } + + @Override + public void removeAttachment(PermissionAttachment permissionAttachment) + { + + } + + @Override + public void recalculatePermissions() + { + + } + + @Override + public Set getEffectivePermissions() + { + return null; + } + + @Override + public boolean isOp() + { + return false; + } + + @Override + public void setOp(boolean b) + { + + } + + @Override + public T launchProjectile(Class aClass) + { + return null; + } + + @Override + public T launchProjectile(Class aClass, Vector vector) + { + return null; + } + + private static EulerAngle fromNMS(Vector3f old) + { + return new EulerAngle(Math.toRadians(old.getX()), Math.toRadians(old.getY()), Math.toRadians(old.getZ())); + } + + private static Vector3f toNMS(EulerAngle old) + { + return new Vector3f((float) Math.toDegrees(old.getX()), (float) Math.toDegrees(old.getY()), (float) Math.toDegrees(old.getZ())); + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 89fe831d5..9a1006b42 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -257,7 +257,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed public int HealthSet = -1; public boolean SpawnTeleport = true; - public boolean PrepareFreeze = true; private double _itemMergeRadius = 0; @@ -293,7 +292,9 @@ public abstract class Game extends ListenerComponent implements Lifetimed public boolean AllowParticles = true; + public boolean Prepare = true; public long PrepareTime = 9000; + public boolean PrepareFreeze = true; public boolean PlaySoundGameStart = true; public double XpMult = 1; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index ce6d35041..c7c79dd48 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,18 +1,27 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.kit.KitPlayer; +import nautilus.game.arcade.game.games.moba.kit.PregameSelection; +import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import org.bukkit.Location; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import java.util.*; +import java.util.Map.Entry; public class Moba extends TeamGame { @@ -22,13 +31,20 @@ public class Moba extends TeamGame }; private final List _capturePoints = new ArrayList<>(3); + private final List _towers = new ArrayList<>(12); + + private final Map _roles = new HashMap<>(); + + private final Set _listeners = new HashSet<>(); public Moba(ArcadeManager manager) { super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION); + //Prepare = false; + PrepareFreeze = false; DeathOut = false; - DeathSpectateSecs = 8; + DeathSpectateSecs = 10; HungerSet = 20; DontAllowOverfill = false; @@ -37,6 +53,12 @@ public class Moba extends TeamGame .setGiveCompassToSpecs(true) .setGiveCompassToAlive(false) .register(this); + + Listener preGameSelection = new PregameSelection(this, null); + _listeners.add(preGameSelection); + + Listener recall = new Recall(this); + _listeners.add(recall); } @Override @@ -48,6 +70,60 @@ public class Moba extends TeamGame { _capturePoints.add(new CapturePoint(this, location)); } + + Map towers = getLocationStartsWith("TOWER"); + + for (Entry entry : towers.entrySet()) + { + String key = entry.getKey(); + Location location = entry.getValue(); + String[] components = key.split(" "); + + if (components.length < 4) + { + continue; + } + + String team = components[1]; + String lane = components[2]; + int laneInt = 0; + + switch (lane) + { + case "A": + laneInt = 0; + break; + case "B": + laneInt = 1; + break; + case "C": + laneInt = 2; + break; + } + + boolean firstTower; + + try + { + firstTower = Integer.parseInt(components[3]) == 1; + } + catch (NumberFormatException e) + { + continue; + } + + int health = 1000; + GameTeam gameTeam = getTeam(team); + + if (gameTeam == null) + { + continue; + } + + _towers.add(new Tower(this, location, gameTeam, laneInt, health, firstTower)); + } + + _listeners.forEach(UtilServer::RegisterEvents); } @Override @@ -72,6 +148,8 @@ public class Moba extends TeamGame case End: writeEnd(); break; + default: + return; } Scoreboard.draw(); @@ -92,6 +170,37 @@ public class Moba extends TeamGame } + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (Tower tower : _towers) + { + tower.setup(); + } + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + } + + @Override + public void disable() + { + super.disable(); + _listeners.forEach(UtilServer::Unregister); + _listeners.clear(); + } + @EventHandler public void update(UpdateEvent event) { @@ -120,4 +229,17 @@ public class Moba extends TeamGame return map; } + + private GameTeam getTeam(String name) + { + for (GameTeam team : GetTeamList()) + { + if (team.GetName().equals(name)) + { + return team; + } + } + + return null; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index 91f0fa6e5..8bcb73016 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,22 +1,25 @@ package nautilus.game.arcade.game.games.moba; import nautilus.game.arcade.kit.Kit; +import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", null), - HUNTER("Hunter", null), - MAGE("Mage", null), - WARRIOR("Warrior", null), + ASSASSIN("Assassin", Color.BLUE, null), + HUNTER("Hunter", Color.LIME, null), + MAGE("Mage", Color.RED, null), + WARRIOR("Warrior", Color.YELLOW, null), ; private String _name; + private Color _color; private Kit[] _kits; - MobaRole(String name, Kit[] kits) + MobaRole(String name, Color color, Kit[] kits) { _name = name; + _color = color; _kits = kits; } @@ -25,6 +28,11 @@ public enum MobaRole return _name; } + public Color getColor() + { + return _color; + } + public Kit[] getKits() { return _kits; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java new file mode 100644 index 000000000..a29eaf563 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -0,0 +1,124 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +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.MobaRole; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +public class HeroKit extends Kit +{ + + private final MobaRole _role; + + private static final int AMMO_SLOT = 7; + private ItemStack _ammo; + private long _giveTime; + private int _maxAmmo; + + private static final int RECALL_SLOT = 8; + private static final ItemStack RECALL_ITEM = new ItemBuilder(Material.BED) + .setTitle(C.cGreenB + "Recall to you Base") + .addLore("Clicking this item will teleport you back to your", "base after " + F.time("5") + " seconds.", "Taking damage or moving will cancel your teleport.") + .build(); + + public HeroKit(ArcadeManager manager, String name, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand, MobaRole role) + { + super(manager, name, KitAvailability.Free, kitDesc, kitPerks, null, itemInHand); + + _role = role; + } + + public MobaRole getRole() + { + return _role; + } + + public void setAmmo(ItemStack ammo, long giveTime) + { + _ammo = ammo; + _giveTime = giveTime; + } + + public void setMaxAmmo(int max) + { + _maxAmmo = max; + } + + protected boolean useAmmo(Player player, int amount) + { + ItemStack itemStack = player.getInventory().getItem(AMMO_SLOT); + + if (itemStack == null || itemStack.getAmount() < amount) + { + return false; + } + + itemStack.setAmount(itemStack.getAmount() - amount); + player.updateInventory(); + return true; + } + + @EventHandler + public void giveAmmo(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || Manager.GetGame() == null || !Manager.GetGame().IsLive()) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!HasKit(player)) + { + continue; + } + + ItemStack itemStack = player.getInventory().getItem(AMMO_SLOT); + long giveTime = _giveTime; + + //TODO shop cooldown reduction + + if (!Recharge.Instance.use(player, "Ammo", giveTime, false, false)) + { + continue; + } + + if (itemStack == null) + { + itemStack = _ammo; + player.getInventory().setItem(AMMO_SLOT, itemStack); + player.updateInventory(); + continue; + } + + if (itemStack.getAmount() >= _maxAmmo) + { + continue; + } + + itemStack.setAmount(itemStack.getAmount() + 1); + player.updateInventory(); + } + } + + @Override + public void GiveItems(Player player) + { + PlayerInventory inventory = player.getInventory(); + + inventory.setItem(AMMO_SLOT, _ammo); + inventory.setItem(RECALL_SLOT, RECALL_ITEM); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java deleted file mode 100644 index 1fcea1335..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java +++ /dev/null @@ -1,30 +0,0 @@ -package nautilus.game.arcade.game.games.moba.kit; - -import mineplex.core.common.util.UtilServer; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.games.moba.Moba; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -public class KitSelection implements Listener -{ - - private final - - public KitSelection(Moba moba) - { - UtilServer.RegisterEvents(this); - } - - @EventHandler - public void live(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - { - return; - } - - UtilServer.Unregister(this); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java new file mode 100644 index 000000000..ae14c6523 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java @@ -0,0 +1,164 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import mineplex.core.common.entity.ClientArmorStand; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilSkull; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketHandler.ListenerPriority; +import mineplex.core.packethandler.PacketInfo; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.kit.Kit; +import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + +public class PregameSelection implements Listener, IPacketHandler +{ + + private final Moba _host; + private final Kit[] _kits; + private final Map _roleStands = new HashMap<>(); + + public PregameSelection(Moba host, Kit[] kits) + { + _host = host; + _kits = kits; + + _host.getArcadeManager().getPacketHandler().addPacketHandler(this, ListenerPriority.NORMAL, true, PacketPlayInUseEntity.class); + } + + // Setup + @EventHandler(priority = EventPriority.HIGHEST) + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (GameTeam team : _host.GetTeamList()) + { + if (team.GetColor() == ChatColor.RED) + { + spawnRoleUI(team, "PINK"); + } + else + { + spawnRoleUI(team, "PURPLE"); + } + } + } + + private void spawnRoleUI(GameTeam team, String dataKey) + { + AtomicInteger i = new AtomicInteger(); + List spawns = _host.WorldData.GetDataLocs(dataKey); + Location average = UtilAlg.getAverageLocation(team.GetSpawns()); + Player[] players = team.GetPlayers(true).toArray(new Player[0]); + + ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 3).build(); + + UtilServer.runSyncLater(() -> + { + for (Location location : spawns) + { + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); + + MobaRole role = MobaRole.values()[i.getAndIncrement()]; + ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players); + + stand.setCustomNameVisible(true); + stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + C.cGreenB + "AVAILABLE"); + stand.setArms(true); + stand.setHelmet(head); + stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); + stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); + stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); + + _roleStands.put(stand, role); + } + }, 5); + } + + private Location prepareLocation(Location location) + { + Block block = location.getBlock(); + + block.setType(Material.SMOOTH_BRICK); + block.setData((byte) 3); + + return location.clone().add(0, 1, 0); + } + + private ItemStack buildColouredStack(Material material, MobaRole role) + { + return new ItemBuilder(material).setColor(role.getColor()).build(); + } + + // Listen for those packety clicks + @Override + public void handle(PacketInfo packetInfo) + { + PacketPlayInUseEntity packet = (PacketPlayInUseEntity) packetInfo.getPacket(); + Player player = packetInfo.getPlayer(); + int entityId = packet.a; + + for (ClientArmorStand stand : _roleStands.keySet()) + { + if (stand.getEntityId() != entityId) + { + continue; + } + + Bukkit.broadcastMessage("Beep beep I'm an amourstand, I said beep beep I have an id of " + entityId); + + packetInfo.setCancelled(true); + + MobaRole role = _roleStands.get(stand); + RoleSelectEvent event = new RoleSelectEvent(player, stand, role); + UtilServer.CallEvent(event); + + if (event.isCancelled()) + { + return; + } + + for (ClientArmorStand stand2 : _roleStands.keySet()) + { + stand2.remove(player); + } + } + } + + // Unregister + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + _host.getArcadeManager().getPacketHandler().removePacketHandler(this); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/RoleSelectEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/RoleSelectEvent.java new file mode 100644 index 000000000..d4c170c40 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/RoleSelectEvent.java @@ -0,0 +1,61 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import mineplex.core.common.entity.ClientArmorStand; +import nautilus.game.arcade.game.games.moba.MobaRole; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class RoleSelectEvent extends PlayerEvent implements Cancellable +{ + + private static final HandlerList _handlers = new HandlerList(); + + private final ClientArmorStand _stand; + private final MobaRole _role; + + private boolean _cancel; + + public RoleSelectEvent(Player who, ClientArmorStand stand, MobaRole role) + { + super(who); + + _stand = stand; + _role = role; + } + + public ClientArmorStand getStand() + { + return _stand; + } + + public MobaRole getRole() + { + return _role; + } + + @Override + public boolean isCancelled() + { + return _cancel; + } + + @Override + public void setCancelled(boolean b) + { + _cancel = b; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java new file mode 100644 index 000000000..ffda5fba2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.moba.kit.heroes; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroHattori extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new PerkDoubleJump("Double Jump", 1, 1, true) + }; + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemStack(Material.WOOD_SWORD), + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.NETHER_STAR); + + public HeroHattori(ArcadeManager manager) + { + super(manager, "Hattori", DESCRIPTION, PERKS, IN_HAND, MobaRole.ASSASSIN); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java new file mode 100644 index 000000000..136dd7d1f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java @@ -0,0 +1,136 @@ +package nautilus.game.arcade.game.games.moba.recall; + +import com.sun.org.apache.regexp.internal.RE; +import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.jooq.util.derby.sys.Sys; + +import java.util.*; + +public class Recall implements Listener +{ + + private static final int RECALL_TIME = 5000; + private static final double PARTICLE_HEIGHT = 2.5; + private static final double PARTICLE_RADIUS = 2.5; + + private final Moba _host; + + private final Set _sessions; + + public Recall(Moba host) + { + _host = host; + + _sessions = new HashSet<>(); + } + + @EventHandler + public void interactBed(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = player.getItemInHand(); + + if (itemStack == null || itemStack.getType() != Material.BED) + { + return; + } + + _sessions.add(new RecallSession(player)); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + { + return; + } + + long now = System.currentTimeMillis(); + + for (Player player : _host.GetPlayers(true)) + { + if (!_lastRecallStart.containsKey(player.getUniqueId())) + { + continue; + } + + long start = _lastRecallStart.get(player.getUniqueId()); + + if (UtilTime.elapsed(start, RECALL_TIME)) + { + _host.GetTeam(player).SpawnTeleport(player); + _lastRecallStart.remove(player.getUniqueId()); + } + else + { + Location location = player.getLocation().add(0, 0.25, 0); + double height = (now - start) / RECALL_TIME; + + for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 10) + { + double x = PARTICLE_RADIUS * Math.sin(theta); + double z = PARTICLE_RADIUS * Math.cos(theta); + + for (int y = 0; y < height * PARTICLE_HEIGHT; y += 0.5) + { + location.add(x, y, z); + + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); + + location.subtract(x, y, z); + } + } + } + } + } + + @EventHandler + public void damage(CustomDamageEvent event) + { + if (event.GetDamageePlayer() == null) + { + return; + } + + RecallSession session = + } + + public RecallSession getSession(Player player) + { + for (RecallSession session : _sessions) + { + if (session.Player.equals(player)) + { + return session; + } + } + + return null; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java new file mode 100644 index 000000000..0abca7401 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java @@ -0,0 +1,19 @@ +package nautilus.game.arcade.game.games.moba.recall; + +import org.bukkit.Location; +import org.bukkit.entity.Player; + +class RecallSession +{ + + public Player Player; + public long Start; + public Location Location; + + public RecallSession(Player player) + { + Player = player; + Start = System.currentTimeMillis(); + Location = player.getLocation(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java new file mode 100644 index 000000000..95da9011c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -0,0 +1,16 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class MobaShop implements Listener +{ + + private final Moba _host; + + public MobaShop(Moba host) + { + _host = host; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index 95cbc8edc..3c5167baa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -178,8 +178,6 @@ public class CapturePoint private void display(GameTeam team, boolean forward) { - Bukkit.broadcastMessage("progress=" + _progress + " forward=" + forward); - double toChange = Math.ceil(_wool.size() / MAX_PROGRESS) + 1; int changed = 0; for (Block block : _wool) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java new file mode 100644 index 000000000..c5d448938 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -0,0 +1,95 @@ +package nautilus.game.arcade.game.games.moba.structure.tower; + +import mineplex.core.common.util.UtilBlock; +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.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.utils.UtilVariant; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Guardian; + +public class Tower +{ + + private final Moba _host; + private final Location _location; + private final GameTeam _team; + private int _lane; + private double _health; + private int _maxHealth; + private boolean _firstTower; + private Guardian _guardian; + private boolean _dead; + + public Tower(Moba host, Location location, GameTeam team, int lane, int health, boolean firstTower) + { + _host = host; + _location = location; + _team = team; + _lane = lane; + _health = health; + _maxHealth = health; + _firstTower = firstTower; + } + + public void setup() + { + if (_firstTower) + { + _guardian = _location.getWorld().spawn(_location, Guardian.class); + } + else + { + _guardian = UtilVariant.spawnElderGuardian(_location); + } + + _guardian.setCustomNameVisible(true); + updateDisplay(); + } + + public void updateTarget() + { + + } + + public void damage(double damage) + { + _health -= damage; + + if (_health <= 0) + { + UtilServer.CallEvent(new TowerDestroyEvent(this)); + _dead = true; + _guardian.remove(); + explode(); + } + else + { + updateDisplay(); + } + } + + private void updateDisplay() + { + float percentage = (float) _health / (float) _maxHealth; + + _guardian.setCustomName(UtilTextMiddle.progress(percentage)); + } + + private void explode() + { + _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_location.clone().subtract(0, 4, 0), 4), _location, false); + _location.getWorld().playSound(_location, Sound.EXPLODE, 2, 0.6F); + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); + } + + public boolean isDead() + { + return _dead; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerDestroyEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerDestroyEvent.java new file mode 100644 index 000000000..a7107a423 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerDestroyEvent.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.game.games.moba.structure.tower; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class TowerDestroyEvent extends Event +{ + + private static final HandlerList _handlers = new HandlerList(); + + private Tower _tower; + + public TowerDestroyEvent(Tower tower) + { + _tower = tower; + } + + public Tower getTower() + { + return _tower; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index ce027ddac..1af689550 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -211,6 +211,8 @@ public abstract class UHC extends Game _state = UHCState.SAFE; + Prepare = false; + HideTeamSheep = true; StrictAntiHack = true; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 126bb399b..f046626b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -104,7 +104,7 @@ public class GameHostManager implements Listener ultraGames.add(GameType.MonsterMaze); ultraGames.add(GameType.Gladiators); - //Hero Games + //HeroKit Games heroGames.add(GameType.ChampionsDominate); heroGames.add(GameType.ChampionsTDM); heroGames.add(GameType.ChampionsCTF); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index 6d3c8e18b..fd1dc5e82 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -636,7 +636,7 @@ public class GameManager implements Listener return; // Sir, I'll handle this. - if (game instanceof UHC) + if (!game.Prepare) return; final ArrayList players = game.GetPlayers(true); diff --git a/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/serverreset/ServerResetCommand.java b/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/serverreset/ServerResetCommand.java index 8356e8fd6..d716ee669 100644 --- a/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/serverreset/ServerResetCommand.java +++ b/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/serverreset/ServerResetCommand.java @@ -44,7 +44,7 @@ public class ServerResetCommand extends CommandBase clientEvent.GetClient().Game().SetEconomyBalance(0); } - File economyDir = new File("economy/"); + File economyDir = new File("shop/"); FilenameFilter statsFilter = new FilenameFilter() { From 23d924f1371e7790524ce13cf3026fdd477f9a40 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 6 May 2017 20:51:49 +0100 Subject: [PATCH 009/283] Kit system --- .../gadgets/particle/ParticleCoalFumes.java | 2 +- .../src/mineplex/clanshub/HubManager.java | 2 +- .../src/nautilus/game/arcade/game/Game.java | 1 + .../game/arcade/game/games/moba/Moba.java | 295 +++++++++++++++++- .../arcade/game/games/moba/MobaPlayer.java | 17 + .../game/arcade/game/games/moba/MobaRole.java | 20 +- .../arcade/game/games/moba/kit/HeroKit.java | 32 +- .../arcade/game/games/moba/kit/HeroSkill.java | 227 ++++++++++++++ .../game/games/moba/kit/PregameSelection.java | 131 +++++++- .../game/games/moba/kit/devon/HeroDevon.java | 59 ++++ .../game/games/moba/kit/devon/SkillBoost.java | 63 ++++ .../games/moba/kit/devon/SkillInfinity.java | 114 +++++++ .../games/moba/kit/devon/SkillTNTArrows.java | 104 ++++++ .../games/moba/kit/hattori/HeroHattori.java | 54 ++++ .../games/moba/kit/hattori/SkillDash.java | 105 +++++++ .../moba/kit/hattori/SkillNinjaBlade.java | 94 ++++++ .../games/moba/kit/hattori/SkillSnowball.java | 91 ++++++ .../games/moba/kit/heroes/HeroHattori.java | 32 -- .../arcade/game/games/moba/recall/Recall.java | 47 ++- .../games/moba/structure/tower/Tower.java | 25 +- .../game/arcade/managers/GameManager.java | 29 +- 21 files changed, 1432 insertions(+), 112 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java index 467db55d2..236bc1e8a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java @@ -20,7 +20,7 @@ public class ParticleCoalFumes extends ParticleGadget public ParticleCoalFumes(GadgetManager manager) { super(manager, "Coal Fumes", - UtilText.splitLineToArray(C.cGray + "Being on the Naughty List does have some perks... if you love coal, that is...", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "Being on the Naughty List does have some hattori... if you love coal, that is...", LineFormat.LORE), -1, Material.COAL, (byte) 0); } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index bc74ec6f1..29e6ab472 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -674,7 +674,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter _lastPlayerCount = playerCount; Bukkit.getOnlinePlayers().stream().filter(player -> _clientManager.Get(player).GetRank() == Rank.ALL).forEach(player -> { - UtilTextBottom.display(C.cGray + "Visit " + F.elem("http://www.mineplex.com/shop") + " for exclusive perks!", player); + UtilTextBottom.display(C.cGray + "Visit " + F.elem("http://www.mineplex.com/shop") + " for exclusive hattori!", player); }); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 9a1006b42..74f2baf73 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -295,6 +295,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public boolean Prepare = true; public long PrepareTime = 9000; public boolean PrepareFreeze = true; + public boolean PrepareAutoAnnounce = true; public boolean PlaySoundGameStart = true; public double XpMult = 1; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index c7c79dd48..fe6591cc4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,27 +1,39 @@ package nautilus.game.arcade.game.games.moba; -import mineplex.core.common.util.UtilServer; +import mineplex.core.common.entity.ClientArmorStand; +import mineplex.core.common.util.*; +import mineplex.core.explosion.ExplosionEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.moba.kit.KitPlayer; -import nautilus.game.arcade.game.games.moba.kit.PregameSelection; +import nautilus.game.arcade.game.games.moba.kit.*; +import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; +import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.Perk; import org.bukkit.Location; 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.EntityExplodeEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.metadata.FixedMetadataValue; import java.util.*; import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; public class Moba extends TeamGame { @@ -29,11 +41,14 @@ public class Moba extends TeamGame private static final String[] DESCRIPTION = { "MORE CAPTURE POINTS" }; + private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1); + + private final HeroKit[] _kits; private final List _capturePoints = new ArrayList<>(3); private final List _towers = new ArrayList<>(12); - private final Map _roles = new HashMap<>(); + private final Set _playerData = new HashSet<>(); private final Set _listeners = new HashSet<>(); @@ -41,20 +56,28 @@ public class Moba extends TeamGame { super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION); - //Prepare = false; + _kits = new HeroKit[] { + new HeroHattori(Manager), + new HeroDevon(Manager) + }; + + PrepareAutoAnnounce = false; PrepareFreeze = false; + PrepareTime = PREPARE_TIME; DeathOut = false; DeathSpectateSecs = 10; HungerSet = 20; DontAllowOverfill = false; + DamageFall = false; + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) .setGiveCompassToAlive(false) .register(this); - Listener preGameSelection = new PregameSelection(this, null); + Listener preGameSelection = new PregameSelection(this); _listeners.add(preGameSelection); Listener recall = new Recall(this); @@ -105,14 +128,14 @@ public class Moba extends TeamGame try { - firstTower = Integer.parseInt(components[3]) == 1; + firstTower = components[3].equalsIgnoreCase("1"); } catch (NumberFormatException e) { continue; } - int health = 1000; + int health = firstTower ? 250 : 500; GameTeam gameTeam = getTeam(team); if (gameTeam == null) @@ -157,7 +180,27 @@ public class Moba extends TeamGame private void writePrepare() { + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellowB + "Hero Selection"); + Scoreboard.write(UtilTime.MakeStr(GetStateTime() + PREPARE_TIME - System.currentTimeMillis())); + + Scoreboard.writeNewLine(); + + Scoreboard.write(C.cYellowB + "Players"); + int kits = 0; + + for (MobaPlayer player : _playerData) + { + if (player.Kit != null) + { + kits++; + } + } + + Scoreboard.write(kits + "/" + GetPlayers(true).size()); + + Scoreboard.writeNewLine(); } private void writeLive() @@ -178,10 +221,21 @@ public class Moba extends TeamGame return; } + // Override those kits! + setKits(_kits); + + // Store player data + for (Player player : GetPlayers(true)) + { + _playerData.add(new MobaPlayer(player)); + } + + CreatureAllowOverride = true; for (Tower tower : _towers) { tower.setup(); } + CreatureAllowOverride = false; } @EventHandler @@ -191,6 +245,19 @@ public class Moba extends TeamGame { return; } + + UtilTextBottom.display(C.cRedB + "!!! Battle !!!", UtilServer.getPlayers()); + + for (MobaPlayer mobaPlayer : _playerData) + { + HeroKit kit = mobaPlayer.Kit; + Perk perk = kit.GetPerks()[kit.GetPerks().length - 1]; + + if (perk instanceof HeroSkill) + { + ((HeroSkill) perk).useSkill(mobaPlayer.Player); + } + } } @Override @@ -215,6 +282,118 @@ public class Moba extends TeamGame } } + @EventHandler + public void updatePrepare(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || GetState() != GameState.Prepare) + { + return; + } + + if (!UtilTime.elapsed(GetStateTime(), PREPARE_TIME)) + { + for (Player player : GetPlayers(true)) + { + Kit kit = GetKit(player); + + if (!(kit instanceof HeroKit)) + { + return; + } + } + } + + AnnounceGame(); + StartPrepareCountdown(); + + //Event + GamePrepareCountdownCommence countdownEvent = new GamePrepareCountdownCommence(this); + UtilServer.CallEvent(countdownEvent); + + // If players took too long, just give them a random free role and kit. + for (Player player : GetPlayers(true)) + { + Kit kit = GetKit(player); + + if (kit instanceof HeroKit) + { + continue; + } + + HeroKit heroKit = getRandomKit(player); + MobaPlayer mobaPlayer = getData(player); + + mobaPlayer.Role = heroKit.getRole(); + mobaPlayer.Kit = heroKit; + + SetKit(player, heroKit, true); + } + + PrepareTime = 0; + Manager.GetChat().Silence(0, false); + } + + @EventHandler + public void roleSelect(RoleSelectEvent event) + { + Player player = event.getPlayer(); + MobaRole role = event.getRole(); + ClientArmorStand stand = event.getStand(); + + if (stand.hasMetadata("owned")) + { + player.sendMessage(F.main("Game", "Another player has already chosen this role.")); + event.setCancelled(true); + return; + } + + // Store inside the stand that it is claimed by a player + stand.setMetadata("owned", new FixedMetadataValue(Manager.getPlugin(), true)); + + // Show that the kit is claimed. + stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + player.getName()); + + // Store the role of the player + getData(player).Role = role; + } + + @Override + public void SetKit(Player player, Kit kit, boolean announce) + { + super.SetKit(player, kit, announce); + + if (kit instanceof HeroKit) + { + getData(player).Kit = (HeroKit) kit; + } + } + + @Override + public void RespawnPlayer(Player player) + { + MobaPlayer mobaPlayer = getData(player); + + player.eject(); + Manager.Clear(player); + GetTeam(player).SpawnTeleport(player); + SetKit(player, mobaPlayer.Kit, false); + } + + @EventHandler + public void combatDeath(CombatDeathEvent event) + { + event.SetBroadcastType(DeathMessageType.Detailed); + } + + // Clear up memory + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + _playerData.removeIf(mobaPlayer -> mobaPlayer.Player.equals(player)); + } + private Map getLocationStartsWith(String s) { Map map = new HashMap<>(); @@ -234,7 +413,7 @@ public class Moba extends TeamGame { for (GameTeam team : GetTeamList()) { - if (team.GetName().equals(name)) + if (team.GetName().equalsIgnoreCase(name)) { return team; } @@ -242,4 +421,102 @@ public class Moba extends TeamGame return null; } + + public HeroKit[] getKits() + { + return _kits; + } + + public List getKits(MobaRole role) + { + List kits = new ArrayList<>(); + + for (HeroKit kit : _kits) + { + if (kit.getRole() == role) + { + kits.add(kit); + } + } + + return kits; + } + + public MobaPlayer getData(Player player) + { + for (MobaPlayer mobaPlayer : _playerData) + { + if (mobaPlayer.Player.equals(player)) + { + return mobaPlayer; + } + } + + return null; + } + + private HeroKit getRandomKit(Player player) + { + MobaPlayer mobaPlayer = getData(player); + + if (mobaPlayer.Role == null) + { + MobaRole role = getRandomRole(player); + + return getRandomKit(role); + } + else if (mobaPlayer.Kit == null) + { + return getRandomKit(mobaPlayer.Role); + } + + return null; + } + + private HeroKit getRandomKit(MobaRole role) + { + for (HeroKit kit : _kits) + { + if (kit.getRole() == role) + { + return kit; + } + } + + return null; + } + + private MobaRole getRandomRole(Player player) + { + List roles = new ArrayList<>(); + + for (MobaPlayer mobaPlayer : getTeamData(GetTeam(player))) + { + MobaRole role = mobaPlayer.Role; + + if (role != null) + { + roles.add(role); + } + } + + return UtilAlg.Random(Arrays.asList(MobaRole.values()), roles); + } + + public List getTeamData(GameTeam team) + { + List players = new ArrayList<>(); + + for (MobaPlayer mobaPlayer : _playerData) + { + GameTeam otherTeam = GetTeam(mobaPlayer.Player); + + if (team.equals(otherTeam)) + { + players.add(mobaPlayer); + } + } + + return players; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java new file mode 100644 index 000000000..82c06bf33 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java @@ -0,0 +1,17 @@ +package nautilus.game.arcade.game.games.moba; + +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import org.bukkit.entity.Player; + +public class MobaPlayer +{ + + public final Player Player; + public MobaRole Role; + public HeroKit Kit; + + public MobaPlayer(Player player) + { + Player = player; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index 8bcb73016..ee648883c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,26 +1,26 @@ package nautilus.game.arcade.game.games.moba; -import nautilus.game.arcade.kit.Kit; +import org.bukkit.ChatColor; import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", Color.BLUE, null), - HUNTER("Hunter", Color.LIME, null), - MAGE("Mage", Color.RED, null), - WARRIOR("Warrior", Color.YELLOW, null), + ASSASSIN("Assassin", Color.BLUE, ChatColor.AQUA), + HUNTER("Hunter", Color.LIME, ChatColor.GREEN), + MAGE("Mage", Color.RED, ChatColor.RED), + WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD), ; private String _name; private Color _color; - private Kit[] _kits; + private ChatColor _chatColor; - MobaRole(String name, Color color, Kit[] kits) + MobaRole(String name, Color color, ChatColor chatColor) { _name = name; _color = color; - _kits = kits; + _chatColor = chatColor; } public String getName() @@ -33,8 +33,8 @@ public enum MobaRole return _color; } - public Kit[] getKits() + public ChatColor getChatColor() { - return _kits; + return _chatColor; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index a29eaf563..705581001 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -2,6 +2,7 @@ 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.UtilPlayer; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -11,6 +12,7 @@ import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -29,8 +31,8 @@ public class HeroKit extends Kit private static final int RECALL_SLOT = 8; private static final ItemStack RECALL_ITEM = new ItemBuilder(Material.BED) - .setTitle(C.cGreenB + "Recall to you Base") - .addLore("Clicking this item will teleport you back to your", "base after " + F.time("5") + " seconds.", "Taking damage or moving will cancel your teleport.") + .setTitle(C.cGreenB + "Recall to your Base") + .addLore("Clicking this item will teleport you back to your", "base after " + F.time("5") + " seconds.", "Taking damage or moving will cancel", "your teleport.") .build(); public HeroKit(ArcadeManager manager, String name, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand, MobaRole role) @@ -38,6 +40,7 @@ public class HeroKit extends Kit super(manager, name, KitAvailability.Free, kitDesc, kitPerks, null, itemInHand); _role = role; + _maxAmmo = 64; } public MobaRole getRole() @@ -73,14 +76,14 @@ public class HeroKit extends Kit @EventHandler public void giveAmmo(UpdateEvent event) { - if (event.getType() != UpdateType.TICK || Manager.GetGame() == null || !Manager.GetGame().IsLive()) + if (event.getType() != UpdateType.FASTEST || Manager.GetGame() == null || !Manager.GetGame().IsLive() || _ammo == null) { return; } for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!HasKit(player)) + if (!HasKit(player) || UtilPlayer.isSpectator(player)) { continue; } @@ -99,7 +102,6 @@ public class HeroKit extends Kit { itemStack = _ammo; player.getInventory().setItem(AMMO_SLOT, itemStack); - player.updateInventory(); continue; } @@ -109,7 +111,6 @@ public class HeroKit extends Kit } itemStack.setAmount(itemStack.getAmount() + 1); - player.updateInventory(); } } @@ -120,5 +121,24 @@ public class HeroKit extends Kit inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(RECALL_SLOT, RECALL_ITEM); + + Bukkit.broadcastMessage(""); + Bukkit.broadcastMessage(player.getName()); + + for (Perk perk : GetPerks()) + { + if (!(perk instanceof HeroSkill)) + { + continue; + } + + HeroSkill skill = (HeroSkill) perk; + + if (skill.getItemStack() != null) + { + Bukkit.broadcastMessage("Giving kit " + GetName() + ", perk " + skill.GetName() + ", item " + skill.getItemStack().getItemMeta().getDisplayName()); + inventory.setItem(skill.getSlot(), skill.isOnCooldown(player) ? skill.getCooldownItemStack() : skill.getItemStack()); + } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java new file mode 100644 index 000000000..252a69089 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -0,0 +1,227 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.PlayerKitGiveEvent; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +public class HeroSkill extends Perk +{ + + private ItemStack _item; + private ItemStack _cooldownItem; + private final int _slot; + private final ActionType _actionType; + private final boolean _sneakActivate; + + private long _cooldown; + + private final Map _lastSkill = new HashMap<>(); + + public HeroSkill(String name, String[] perkDesc) + { + this(name, perkDesc, null, -1, null); + } + + public HeroSkill(String name, String[] perkDesc, ItemStack itemStack, int slot, ActionType actionType) + { + this(name, perkDesc, itemStack, slot, actionType, false); + } + + public HeroSkill(String name, String[] perkDesc, ItemStack itemStack, int slot, ActionType actionType, boolean sneakActivate) + { + super(name, perkDesc); + + _item = itemStack; + _slot = slot; + _actionType = actionType; + _sneakActivate = sneakActivate; + + prettifyItem(); + } + + protected void setCooldown(long cooldown) + { + _cooldown = cooldown; + } + + private void prettifyItem() + { + String action = "Click"; + + if (_actionType == ActionType.L) + { + action = "Left Click"; + } + else if (_actionType == ActionType.R) + { + action = "Right Click"; + } + + if (_sneakActivate) + { + action += "/Sneak"; + } + + _item = new ItemBuilder(_item) + .setTitle(C.cYellowB + action + C.cGray + " - " + C.cGreenB + GetName()) + .addLore(GetDesc()) + .build(); + _cooldownItem = new ItemBuilder(Material.INK_SACK, (byte) 8) + .setTitle(C.cRed + GetName()) + .addLore(GetDesc()) + .build(); + } + +// @Override +// public void SetHost(Kit kit) +// { +// super.SetHost(kit); +// +// _kit = (HeroKit) kit; +// } + + @EventHandler + public void giveItem(PlayerKitGiveEvent event) + { + event.getPlayer().getInventory().setItem(_slot, isOnCooldown(event.getPlayer()) ? _cooldownItem : _item); + } + + @EventHandler + public void clearCooldowns(PlayerQuitEvent event) + { + UUID key = event.getPlayer().getUniqueId(); + + _lastSkill.remove(key); + } + + protected boolean isSkillItem(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return false; + } + + if (!UtilEvent.isAction(event, _actionType)) + { + if (_actionType != null || event.getAction() == Action.PHYSICAL) + { + return false; + } + } + + Player player = event.getPlayer(); + ItemStack itemStack = event.getItem(); + + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || itemStack == null || !itemStack.isSimilar(_item)) + { + return false; + } + + return true; + } + + protected boolean isSkillSneak(PlayerToggleSneakEvent event) + { + if (event.isCancelled() || !event.isSneaking()) + { + return false; + } + + Player player = event.getPlayer(); + + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !player.getInventory().getItem(_slot).isSimilar(_item)) + { + return false; + } + + return true; + } + + public void useSkill(Player player) + { + _lastSkill.put(player.getUniqueId(), System.currentTimeMillis()); + if (_cooldown > 0 && !UtilPlayer.isSpectator(player)) + { + player.getInventory().setItem(_slot, _cooldownItem); + } + } + + @EventHandler + public void updateCooldowns(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST || _item == null) + { + return; + } + + long current = System.currentTimeMillis(); + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !_lastSkill.containsKey(player.getUniqueId())) + { + continue; + } + + ItemStack itemStack = player.getInventory().getItem(_slot); + long start = _lastSkill.get(player.getUniqueId()); + long cooldown = _cooldown; + + //TODO Shop cooldown reduction + + boolean done = UtilTime.elapsed(start, cooldown); + + if (done) + { + _lastSkill.remove(player.getUniqueId()); + player.getInventory().setItem(_slot, _item); + } + else + { + long timeDiff = current - start; + double amount = (int) (cooldown / 1000) - Math.ceil((double) timeDiff / 1000); + + itemStack.setAmount((int) amount); + } + } + } + + public ItemStack getItemStack() + { + return _item; + } + + public ItemStack getCooldownItemStack() + { + return _cooldownItem; + } + + public int getSlot() + { + return _slot; + } + + public boolean isOnCooldown(Player player) + { + return _lastSkill.containsKey(player.getUniqueId()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java index ae14c6523..4d56b39ee 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java @@ -1,25 +1,22 @@ package nautilus.game.arcade.game.games.moba.kit; import mineplex.core.common.entity.ClientArmorStand; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilSkull; +import mineplex.core.common.util.*; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler.ListenerPriority; import mineplex.core.packethandler.PacketInfo; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerKitApplyEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.kit.Kit; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; +import org.bukkit.*; +import org.bukkit.FireworkEffect.Type; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -36,13 +33,12 @@ public class PregameSelection implements Listener, IPacketHandler { private final Moba _host; - private final Kit[] _kits; private final Map _roleStands = new HashMap<>(); + private final Map _kitStands = new HashMap<>(); - public PregameSelection(Moba host, Kit[] kits) + public PregameSelection(Moba host) { _host = host; - _kits = kits; _host.getArcadeManager().getPacketHandler().addPacketHandler(this, ListenerPriority.NORMAL, true, PacketPlayInUseEntity.class); } @@ -80,6 +76,11 @@ public class PregameSelection implements Listener, IPacketHandler UtilServer.runSyncLater(() -> { + for (Player player : _host.GetPlayers(true)) + { + displayRoleInformation(player); + } + for (Location location : spawns) { location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); @@ -100,6 +101,48 @@ public class PregameSelection implements Listener, IPacketHandler }, 5); } + private void spawnKitUI(Player player, String dataKey) + { + AtomicInteger i = new AtomicInteger(); + GameTeam team = _host.GetTeam(player); + List spawns = _host.WorldData.GetDataLocs(dataKey); + Location average = UtilAlg.getAverageLocation(team.GetSpawns()); + + MobaPlayer mobaPlayer = _host.getData(player); + + List heroKits = _host.getKits(mobaPlayer.Role); + + ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 2).build(); + + UtilServer.runSyncLater(() -> + { + for (Location location : spawns) + { + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); + + HeroKit kit = heroKits.get(i.getAndIncrement()); + ClientArmorStand stand = ClientArmorStand.spawn(location.clone().add(0, 1, 0), player); + + stand.setCustomNameVisible(true); + stand.setCustomName(C.cGreenB + kit.GetName()); + stand.setArms(true); + stand.setHelmet(head); +// stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); +// stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); +// stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); + FireworkEffect effect = FireworkEffect.builder().with(Type.BURST).withColor(Color.LIME).withFade(Color.WHITE).withFlicker().build(); + UtilFirework.playFirework(stand.getLocation(), effect); + + _kitStands.put(stand, kit); + + if (i.get() == heroKits.size()) + { + break; + } + } + }, 20); + } + private Location prepareLocation(Location location) { Block block = location.getBlock(); @@ -115,6 +158,12 @@ public class PregameSelection implements Listener, IPacketHandler return new ItemBuilder(material).setColor(role.getColor()).build(); } + private void removePodiums() + { + _host.WorldData.GetDataLocs("PINK").forEach(location -> location.getBlock().setType(Material.AIR)); + _host.WorldData.GetDataLocs("PURPLE").forEach(location -> location.getBlock().setType(Material.AIR)); + } + // Listen for those packety clicks @Override public void handle(PacketInfo packetInfo) @@ -130,8 +179,6 @@ public class PregameSelection implements Listener, IPacketHandler continue; } - Bukkit.broadcastMessage("Beep beep I'm an amourstand, I said beep beep I have an id of " + entityId); - packetInfo.setCancelled(true); MobaRole role = _roleStands.get(stand); @@ -147,7 +194,54 @@ public class PregameSelection implements Listener, IPacketHandler { stand2.remove(player); } + + GameTeam team = _host.GetTeam(player); + + if (team == null) + { + return; + } + + if (team.GetColor() == ChatColor.RED) + { + spawnKitUI(player, "PINK"); + } + else + { + spawnKitUI(player, "PURPLE"); + } + + displayKitInformation(player, role); } + + for (ClientArmorStand stand : _kitStands.keySet()) + { + if (stand.getEntityId() != entityId) + { + continue; + } + + packetInfo.setCancelled(true); + + HeroKit kit = _kitStands.get(stand); + + for (ClientArmorStand stand2 : _kitStands.keySet()) + { + stand2.remove(player); + } + + _host.SetKit(player, kit, true); + } + } + + private void displayRoleInformation(Player player) + { + UtilTextMiddle.display(C.cYellowB + "Role", "Select the role you would like to play", 10, 40, 10, player); + } + + private void displayKitInformation(Player player, MobaRole role) + { + UtilTextMiddle.display(role.getChatColor() + role.getName(), "Select your " + role.getChatColor() + "Hero", 10, 40, 10, player); } // Unregister @@ -159,6 +253,17 @@ public class PregameSelection implements Listener, IPacketHandler return; } + for (ClientArmorStand stand : _roleStands.keySet()) + { + stand.remove(); + } + + for (ClientArmorStand stand : _kitStands.keySet()) + { + stand.remove(); + } + + removePodiums(); _host.getArcadeManager().getPacketHandler().removePacketHandler(this); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java new file mode 100644 index 000000000..a60d08800 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -0,0 +1,59 @@ +package nautilus.game.arcade.game.games.moba.kit.devon; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.hattori.SkillDash; +import nautilus.game.arcade.game.games.moba.kit.hattori.SkillNinjaBlade; +import nautilus.game.arcade.game.games.moba.kit.hattori.SkillSnowball; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkFletcher; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +public class HeroDevon extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new SkillTNTArrows(1), + new SkillBoost(2), + new SkillInfinity(3) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.BOW); + + private static final ItemStack BOW = new ItemBuilder(Material.BOW) + .setTitle(C.cGreenB + "Bow") + .setUnbreakable(true) + .build(); + + private static final ItemStack AMMO = new ItemBuilder(Material.ARROW) + .setTitle(C.cYellowB + "Hunting Arrow") + .build(); + + public HeroDevon(ArcadeManager manager) + { + super(manager, "Devon", DESCRIPTION, PERKS, IN_HAND, MobaRole.HUNTER); + + setAmmo(AMMO, 3000); + setMaxAmmo(3); + } + + @Override + public void GiveItems(Player player) + { + // TODO remove this when shop is implemented + PlayerInventory inventory = player.getInventory(); + inventory.setItem(0, BOW); + + super.GiveItems(player); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java new file mode 100644 index 000000000..6de9c1330 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java @@ -0,0 +1,63 @@ +package nautilus.game.arcade.game.games.moba.kit.devon; + +import mineplex.minecraft.game.core.condition.ConditionFactory; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; + +public class SkillBoost extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Gain Speed II and Jump Boost I for 3 seconds.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillBoost(int slot) + { + super("Hunters Boost", DESCRIPTION, SKILL_ITEM, slot, null, true); + + setCooldown(10000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + useSkill(player); + } + + @EventHandler + public void toggleSneak(PlayerToggleSneakEvent event) + { + if (!isSkillSneak(event)) + { + return; + } + + Player player = event.getPlayer(); + useSkill(player); + } + + @Override + public void useSkill(Player player) + { + super.useSkill(player); + + ConditionFactory factory = Manager.GetCondition().Factory(); + int time = 3; + + factory.Speed(GetName(), player, null, time, 1, true, true, false); + factory.Jump(GetName(), player, null, time, 0, true, true, false); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java new file mode 100644 index 000000000..85f4852f0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -0,0 +1,114 @@ +package nautilus.game.arcade.game.games.moba.kit.devon; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +public class SkillInfinity extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "For 7 seconds, your arrow shots don't consume arrows.", + "They also become heat-seeking and inflict wither onto players." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + + private final Map _arrows = new HashMap<>(); + + public SkillInfinity(int slot) + { + super("Infinity", DESCRIPTION, SKILL_ITEM, slot, null); + + setCooldown(60000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + ItemStack bow = player.getInventory().getItem(0); + + if (bow == null || bow.getType() != Material.BOW) + { + return; + } + + bow.addEnchantment(Enchantment.ARROW_INFINITE, 0); + Recharge.Instance.useForce(player, GetName(), 7000, false); + + Manager.runSyncLater(() -> bow.removeEnchantment(Enchantment.ARROW_INFINITE), 7 * 20); + } + + @EventHandler + public void shootArrow(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.getEntity(); + + _arrows.put(event.getProjectile(), player); + } + + @EventHandler + public void updateArrowTarget(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST || !Manager.isGameInProgress()) + { + return; + } + + for (Entry entry : _arrows.entrySet()) + { + Entity entity = entry.getKey(); + Player player = entry.getValue(); + GameTeam team = Manager.GetGame().GetTeam(player); + + for (LivingEntity nearby : UtilEnt.getInRadius(entity.getLocation(), 3).keySet()) + { + if (nearby instanceof Player) + { + // If the target is on the same team + if (team.equals(Manager.GetGame().GetTeam((Player) nearby))) + { + continue; + } + } + + entity.setVelocity(UtilAlg.getTrajectory(entity.getLocation(), nearby.getLocation())); + } + } + } + + @EventHandler + public void projectileHit(ProjectileHitEvent event) + { + _arrows.remove(event.getEntity()); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java new file mode 100644 index 000000000..999cd5c69 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java @@ -0,0 +1,104 @@ +package nautilus.game.arcade.game.games.moba.kit.devon; + +import mineplex.core.common.util.UtilInv; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.hattori.SkillSnowball; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +public class SkillTNTArrows extends HeroSkill implements IThrown +{ + + private static final String[] DESCRIPTION = { + "Your next 3 arrows are infused with TNT.", + "They explode on contact dealing damage and knockback." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.TNT); + + private final Map _arrows = new HashMap<>(); + + public SkillTNTArrows(int slot) + { + super("TNT Infusion", DESCRIPTION, SKILL_ITEM, slot, null); + + setCooldown(17000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + _arrows.put(player.getUniqueId(), 3); + player.getItemInHand().addEnchantment(UtilInv.getDullEnchantment(), 1); + } + + @EventHandler + public void shootArrow(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.getEntity(); + + if (!hasPerk(player) || !_arrows.containsKey(player.getUniqueId())) + { + return; + } + + int arrows = _arrows.get(player.getUniqueId()); + + if (arrows == 1) + { + _arrows.remove(player.getUniqueId()); + useSkill(player); + } + else + { + _arrows.put(player.getUniqueId(), arrows - 1); + } + + Manager.GetProjectile().AddThrow(event.getProjectile(), player, this, -1, true, true, true, false, 0.5F); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Location location = data.getThrown().getLocation(); + location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), 4, false, false); + data.getThrown().remove(); + } + + @Override + public void Idle(ProjectileUser data) + { + + } + + @Override + public void Expire(ProjectileUser data) + { + + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java new file mode 100644 index 000000000..0234ed154 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java @@ -0,0 +1,54 @@ +package nautilus.game.arcade.game.games.moba.kit.hattori; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +public class HeroHattori extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new PerkDoubleJump("Double Jump", 1, 1, true), + new SkillSnowball(0), + new SkillDash(2), + new SkillNinjaBlade(3) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.NETHER_STAR); + + private static final ItemStack SWORD = new ItemBuilder(Material.WOOD_SWORD) + .setTitle(C.cGreenB + "Sword") + .setUnbreakable(true) + .build(); + + public HeroHattori(ArcadeManager manager) + { + super(manager, "Hattori", DESCRIPTION, PERKS, IN_HAND, MobaRole.ASSASSIN); + } + + @Override + public void GiveItems(Player player) + { + Bukkit.broadcastMessage("Hello " + player.getName()); + + // TODO remove this when shop is implemented + PlayerInventory inventory = player.getInventory(); + inventory.setItem(1, SWORD); + + Bukkit.broadcastMessage("Now call the super for " + player.getName()); + super.GiveItems(player); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java new file mode 100644 index 000000000..8d73dc8ac --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java @@ -0,0 +1,105 @@ +package nautilus.game.arcade.game.games.moba.kit.hattori; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.particles.effects.LineParticle; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +public class SkillDash extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Dash forward dealing damage to any enemy", + "you collide with." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillDash(int slot) + { + super("Dash", DESCRIPTION, SKILL_ITEM, slot, null, true); + + setCooldown(7000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @EventHandler + public void toggleSneak(PlayerToggleSneakEvent event) + { + if (!isSkillSneak(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @Override + public void useSkill(Player player) + { + super.useSkill(player); + + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.8, 10, null, ParticleType.FIREWORKS_SPARK, + UtilServer.getPlayers()); + Set hitPlayers = new HashSet<>(); + Game game = Manager.GetGame(); + GameTeam team = game.GetTeam(player); + + while (!lineParticle.update()) + { + for (Player other : UtilPlayer.getNearby(lineParticle.getLastLocation(), 2)) + { + if (hitPlayers.contains(other.getUniqueId()) || player.equals(other) || team.equals(game.GetTeam(other))) + { + continue; + } + + hitPlayers.add(other.getUniqueId()); + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, 8, true, true, false, player.getName(), GetName()); + player.sendMessage(F.main("Game", "You hit " + F.elem(other.getName()) + " with " + F.skill(GetName()) + ".")); + } + } + + Location location = lineParticle.getDestination(); + FireworkEffect effect = FireworkEffect.builder().with(Type.BALL).withColor(team.GetColorBase()).withFlicker().build(); + + UtilFirework.playFirework(player.getLocation(), effect); + player.teleport(location.add(0, 0.5, 0)); + UtilFirework.playFirework(player.getLocation(), effect); + + player.sendMessage(F.main("Game", "You used " + F.skill(GetName()) + ".")); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java new file mode 100644 index 000000000..e4562334a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -0,0 +1,94 @@ +package nautilus.game.arcade.game.games.moba.kit.hattori; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +public class SkillNinjaBlade extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Turns into a Diamond Sword that deals extreme", + "damage to any player hit by it." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + private static final ItemStack ACTIVE_ITEM = new ItemBuilder(Material.DIAMOND_SWORD) + .setTitle(C.cGreenB + "NINJA BLADE") + .build(); + + private Set _active = new HashSet<>(); + + public SkillNinjaBlade(int slot) + { + super("Ninja Blade", DESCRIPTION, SKILL_ITEM, slot, null); + + setCooldown(60000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + player.getInventory().setItem(getSlot(), ACTIVE_ITEM); + _active.add(player.getUniqueId()); + Recharge.Instance.useForce(player, GetName(), 7000, true); + + Manager.runSyncLater(() -> + { + + _active.remove(player.getUniqueId()); + useSkill(player); + + }, 7 * 20); + } + + @EventHandler + public void damage(CustomDamageEvent event) + { + Entity entity = event.GetDamageeEntity(); + Player player = event.GetDamagerPlayer(false); + Player damageePlayer = event.GetDamageePlayer(); + + if (player != null && damageePlayer != null) + { + Game game = Manager.GetGame(); + if (game.GetTeam(player).equals(game.GetTeam(damageePlayer))) + { + return; + } + } + + if (player == null || !_active.contains(player.getUniqueId())) + { + return; + } + + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, entity.getLocation().add(0, 1, 0), 1F, 1F, 1F, 0.1F, 50, ViewDist.LONG); + entity.getWorld().playSound(entity.getLocation(), Sound.EXPLODE, 2, 0.5F); + event.AddMod(GetName(), 4); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java new file mode 100644 index 000000000..3d4db31d9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -0,0 +1,91 @@ +package nautilus.game.arcade.game.games.moba.kit.hattori; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Snowball; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; + +public class SkillSnowball extends HeroSkill implements IThrown +{ + + private static final String[] DESCRIPTION = { + "Fires 3 snowballs, one after another.", + "Each snowball deals 3 damage to any enemy it hits." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.SNOW_BALL); + + public SkillSnowball(int slot) + { + super("Snowball", DESCRIPTION, SKILL_ITEM, slot, null); + + setCooldown(1000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + + Manager.runSyncTimer(new BukkitRunnable() + { + int balls = 0; + + @Override + public void run() + { + Snowball snowball = player.launchProjectile(Snowball.class); + + Manager.GetProjectile().AddThrow(snowball, player, SkillSnowball.this, -1, true, true, true, false, 0.5F); + + if (++balls == 3) + { + cancel(); + } + } + }, 0, 4); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Player thrower = (Player) data.getThrower(); + + if (target != null) + { + 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()); + } + } + + @Override + public void Idle(ProjectileUser data) + { + data.getThrown().remove(); + } + + @Override + public void Expire(ProjectileUser data) + { + data.getThrown().remove(); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java deleted file mode 100644 index ffda5fba2..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java +++ /dev/null @@ -1,32 +0,0 @@ -package nautilus.game.arcade.game.games.moba.kit.heroes; - -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.moba.MobaRole; -import nautilus.game.arcade.game.games.moba.kit.HeroKit; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkDoubleJump; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -public class HeroHattori extends HeroKit -{ - - private static final String[] DESCRIPTION = { - "Something something" - }; - - private static final Perk[] PERKS = { - new PerkDoubleJump("Double Jump", 1, 1, true) - }; - - private static final ItemStack[] PLAYER_ITEMS = { - new ItemStack(Material.WOOD_SWORD), - }; - - private static final ItemStack IN_HAND = new ItemStack(Material.NETHER_STAR); - - public HeroHattori(ArcadeManager manager) - { - super(manager, "Hattori", DESCRIPTION, PERKS, IN_HAND, MobaRole.ASSASSIN); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java index 136dd7d1f..ebf2a3a83 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.moba.recall; -import com.sun.org.apache.regexp.internal.RE; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -10,6 +9,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -17,16 +17,16 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; -import org.jooq.util.derby.sys.Sys; -import java.util.*; +import java.util.HashSet; +import java.util.Set; public class Recall implements Listener { private static final int RECALL_TIME = 5000; private static final double PARTICLE_HEIGHT = 2.5; - private static final double PARTICLE_RADIUS = 2.5; + private static final double PARTICLE_RADIUS = 1.5; private final Moba _host; @@ -55,12 +55,15 @@ public class Recall implements Listener Player player = event.getPlayer(); ItemStack itemStack = player.getItemInHand(); - if (itemStack == null || itemStack.getType() != Material.BED) + if (itemStack == null || itemStack.getType() != Material.BED || getSession(player) != null) { return; } - _sessions.add(new RecallSession(player)); + if (Recharge.Instance.use(player, "Recall", RECALL_TIME, false, true)) + { + _sessions.add(new RecallSession(player)); + } } @EventHandler @@ -75,29 +78,33 @@ public class Recall implements Listener for (Player player : _host.GetPlayers(true)) { - if (!_lastRecallStart.containsKey(player.getUniqueId())) + RecallSession session = getSession(player); + + if (session == null) { continue; } - long start = _lastRecallStart.get(player.getUniqueId()); - - if (UtilTime.elapsed(start, RECALL_TIME)) + if (UtilTime.elapsed(session.Start, RECALL_TIME)) { _host.GetTeam(player).SpawnTeleport(player); - _lastRecallStart.remove(player.getUniqueId()); + removeSession(player, null); + } + else if (UtilMath.offsetSquared(player.getLocation(), session.Location) > 4) + { + removeSession(player, "You moved!"); } else { Location location = player.getLocation().add(0, 0.25, 0); - double height = (now - start) / RECALL_TIME; + double height = (double) (now - session.Start) / (double) RECALL_TIME; for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 10) { double x = PARTICLE_RADIUS * Math.sin(theta); double z = PARTICLE_RADIUS * Math.cos(theta); - for (int y = 0; y < height * PARTICLE_HEIGHT; y += 0.5) + for (double y = 0; y < height * PARTICLE_HEIGHT; y += 0.5) { location.add(x, y, z); @@ -118,10 +125,20 @@ public class Recall implements Listener return; } - RecallSession session = + removeSession(event.GetDamageePlayer(), "You took damage!"); } - public RecallSession getSession(Player player) + private void removeSession(Player player, String reason) + { + boolean had = _sessions.removeIf(session -> session.Player.equals(player)); + + if (had && reason != null) + { + player.sendMessage(F.main("Game", reason + " You recall has been cancelled")); + } + } + + private RecallSession getSession(Player player) { for (RecallSession session : _sessions) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index c5d448938..48156e3e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -1,11 +1,8 @@ package nautilus.game.arcade.game.games.moba.structure.tower; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.utils.UtilVariant; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; @@ -39,15 +36,19 @@ public class Tower public void setup() { - if (_firstTower) - { - _guardian = _location.getWorld().spawn(_location, Guardian.class); - } - else - { - _guardian = UtilVariant.spawnElderGuardian(_location); - } +// if (_firstTower) +// { + _guardian = _location.getWorld().spawn(_location, Guardian.class); +// } +// else +// { +// _guardian = UtilVariant.spawnElderGuardian(_location); +// } + UtilEnt.vegetate(_guardian); + UtilEnt.setFakeHead(_guardian, true); + UtilEnt.silence(_guardian, true); + _guardian.setRemoveWhenFarAway(false); _guardian.setCustomNameVisible(true); updateDisplay(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index fd1dc5e82..2b94686d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -672,21 +672,24 @@ public class GameManager implements Listener } }, i * game.TickPerTeleport); } - - //Announce Game after every player is TP'd in - UtilServer.getServer().getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() + + if (game.PrepareAutoAnnounce) { - public void run() + //Announce Game after every player is TP'd in + UtilServer.getServer().getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() { - game.AnnounceGame(); - game.StartPrepareCountdown(); - - //Event - GamePrepareCountdownCommence event = new GamePrepareCountdownCommence(game); - UtilServer.getServer().getPluginManager().callEvent(event); - } - }, players.size() * game.TickPerTeleport); - + public void run() + { + game.AnnounceGame(); + game.StartPrepareCountdown(); + + //Event + GamePrepareCountdownCommence event = new GamePrepareCountdownCommence(game); + UtilServer.getServer().getPluginManager().callEvent(event); + } + }, players.size() * game.TickPerTeleport); + } + //Spectators Move for (Player player : UtilServer.getPlayers()) { From 5398bf5e81216da85ddfb9b2d8f117faddad2252 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 7 May 2017 22:35:15 +0100 Subject: [PATCH 010/283] More progress --- .../util/particles/effects/LineParticle.java | 17 +- .../games/evolution/mobs/KitEnderman.java | 2 +- .../games/evolution/mobs/KitSkeleton.java | 2 +- .../game/games/gravity/kits/KitJetpack.java | 6 +- .../minecraftleague/MinecraftLeague.java | 4 +- .../game/arcade/game/games/moba/Moba.java | 120 ++++++++-- .../arcade/game/games/moba/kit/HeroKit.java | 35 ++- .../arcade/game/games/moba/kit/HeroSkill.java | 186 +++++++++++--- .../game/games/moba/kit/PregameSelection.java | 5 +- .../game/games/moba/kit/anath/HeroAnath.java | 39 +++ .../games/moba/kit/anath/SkillBurnBeam.java | 95 ++++++++ .../moba/kit/anath/SkillFireProjectile.java | 49 ++++ .../games/moba/kit/anath/SkillFlameDash.java | 51 ++++ .../games/moba/kit/anath/SkillMeteor.java | 164 +++++++++++++ .../game/games/moba/kit/common/DashSkill.java | 226 ++++++++++++++++++ .../game/games/moba/kit/common/SkillBow.java | 20 ++ .../games/moba/kit/common/SkillSword.java | 25 ++ .../game/games/moba/kit/dana/HeroDana.java | 31 +++ .../games/moba/kit/dana/SkillDanaDash.java | 82 +++++++ .../games/moba/kit/dana/SkillPulseHeal.java | 164 +++++++++++++ .../game/games/moba/kit/dana/SkillRally.java | 205 ++++++++++++++++ .../game/games/moba/kit/devon/HeroDevon.java | 23 +- .../game/games/moba/kit/devon/SkillBoost.java | 3 +- .../games/moba/kit/devon/SkillInfinity.java | 49 +++- .../games/moba/kit/devon/SkillTNTArrows.java | 75 +++++- .../games/moba/kit/hattori/HeroHattori.java | 26 +- .../games/moba/kit/hattori/SkillDash.java | 105 -------- .../moba/kit/hattori/SkillNinjaBlade.java | 14 +- .../moba/kit/hattori/SkillNinjaDash.java | 72 ++++++ .../games/moba/kit/hattori/SkillSnowball.java | 5 +- .../game/games/moba/shop/MobaMainMenu.java | 89 +++++++ .../arcade/game/games/moba/shop/MobaShop.java | 88 +++++++ .../game/games/moba/shop/MobaUpgrade.java | 19 ++ .../game/games/moba/shop/MobaUpgradeType.java | 13 + .../moba/shop/common/CooldownUpgrade.java | 22 ++ .../src/nautilus/game/arcade/kit/Kit.java | 1 + 36 files changed, 1878 insertions(+), 254 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java index 5eb91a337..2842cdd75 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java @@ -31,10 +31,16 @@ public class LineParticle private double _maxRange; private Set _ignoredTypes; + private boolean _ignoreAllBlocks; private ParticleType _particleType; private Player[] _toDisplay; + public LineParticle(Location start, Vector direction, double incrementedRange, double maxRange, ParticleType particleType, Player... toDisplay) + { + this(start, null, direction, incrementedRange, maxRange, null, particleType, toDisplay); + } + public LineParticle(Location start, Vector direction, double incrementedRange, double maxRange, Set ignoredTypes, ParticleType particleType, Player... toDisplay) { this(start, null, direction, incrementedRange, maxRange, ignoredTypes, particleType, toDisplay); @@ -56,7 +62,7 @@ public class LineParticle if (_direction == null) { - direction = UtilAlg.getTrajectory(start, end).normalize(); + _direction = UtilAlg.getTrajectory(start, end).normalize(); } } @@ -73,7 +79,7 @@ public class LineParticle Location newTarget = _start.clone().add(new Vector(0, 0.2, 0)).add(_direction.clone().multiply(_curRange)); _lastLocation = newTarget; - if (!(UtilBlock.airFoliage(newTarget.getBlock()) || UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP)))) + if (!_ignoreAllBlocks && (!(UtilBlock.airFoliage(newTarget.getBlock()) || UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP))))) { if (_ignoredTypes == null || !_ignoredTypes.contains(newTarget.getBlock().getType())) { @@ -87,7 +93,12 @@ public class LineParticle return done; } - + + public void setIgnoreAllBlocks(boolean b) + { + _ignoreAllBlocks = b; + } + public Location getLastLocation() { return _lastLocation; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitEnderman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitEnderman.java index 60fb991dd..34196d101 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitEnderman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitEnderman.java @@ -19,7 +19,7 @@ public class KitEnderman // @Override // protected void giveItems(Player player) // { -// player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD)); +// player.getInventory().addSkillItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD)); // // player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_IDLE, 4f, 1f); // diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSkeleton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSkeleton.java index d4831cbbb..ffe96719e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSkeleton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSkeleton.java @@ -34,7 +34,7 @@ public class KitSkeleton // player.getInventory().setLeggings(new ItemBuilder(Material.CHAINMAIL_LEGGINGS).build()); // player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).build()); // -// player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); +// player.getInventory().addSkillItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); // // player.getWorld().playSound(player.getLocation(), Sound.SKELETON_IDLE, 4f, 1f); // diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/kits/KitJetpack.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/kits/KitJetpack.java index f1797298f..ab3ffbf3b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/kits/KitJetpack.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/kits/KitJetpack.java @@ -42,9 +42,9 @@ public class KitJetpack extends ProgressingKit @Override public void GiveItems(Player player) { - //player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SHEARS, (byte)0, 1, "Block Cannon")); - //player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, "Space Shooter")); - //player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, (byte)0, 64, "Space Arrows")); + //player.getInventory().addSkillItem(ItemStackFactory.Instance.CreateStack(Material.SHEARS, (byte)0, 1, "Block Cannon")); + //player.getInventory().addSkillItem(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, "Space Shooter")); + //player.getInventory().addSkillItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, (byte)0, 64, "Space Arrows")); player.getInventory().addItem(PLAYER_ITEMS); player.getInventory().setArmorContents(PLAYER_ARMOR); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 1590dc86f..d0d92f862 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -1470,7 +1470,7 @@ public class MinecraftLeague extends RankedTeamGame player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.BLUE).setUnbreakable(true).build()); player.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); - //player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); + //player.getInventory().addSkillItem(new ItemStack(Material.COOKED_BEEF, 5)); _blockLock.put(player, new BlockProtection(this, player)); _noFall.add(player); } @@ -1482,7 +1482,7 @@ public class MinecraftLeague extends RankedTeamGame player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.RED).setUnbreakable(true).build()); player.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); - //player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); + //player.getInventory().addSkillItem(new ItemStack(Material.COOKED_BEEF, 5)); _blockLock.put(player, new BlockProtection(this, player)); _noFall.add(player); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index fe6591cc4..36e6b1158 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,19 +1,25 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.common.Rank; import mineplex.core.common.entity.ClientArmorStand; import mineplex.core.common.util.*; -import mineplex.core.explosion.ExplosionEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.condition.Condition; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GamePrepareCountdownCommence; 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.kit.*; +import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath; +import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana; import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.recall.Recall; @@ -23,11 +29,12 @@ import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; import org.bukkit.Location; +import org.bukkit.entity.Arrow; 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.EntityExplodeEvent; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.metadata.FixedMetadataValue; @@ -58,7 +65,9 @@ public class Moba extends TeamGame _kits = new HeroKit[] { new HeroHattori(Manager), - new HeroDevon(Manager) + new HeroDevon(Manager), + new HeroAnath(Manager), + new HeroDana(Manager), }; PrepareAutoAnnounce = false; @@ -67,7 +76,7 @@ public class Moba extends TeamGame DeathOut = false; DeathSpectateSecs = 10; HungerSet = 20; - DontAllowOverfill = false; + DontAllowOverfill = true; DamageFall = false; @@ -82,6 +91,33 @@ public class Moba extends TeamGame Listener recall = new Recall(this); _listeners.add(recall); + + registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) + { + @Override + public void Execute(Player caller, String[] args) + { + String kit = ""; + + for (int i = 0; i < args.length; i++) + { + kit += args[i] + " "; + } + + kit = kit.trim(); + + for (Kit kits : _kits) + { + if (kit.equalsIgnoreCase(kits.GetName())) + { + SetKit(caller, kits, true); + return; + } + } + + caller.sendMessage(F.main("Kit", "Sorry that is not a kit!")); + } + }); } @Override @@ -213,7 +249,7 @@ public class Moba extends TeamGame } - @EventHandler + @EventHandler(priority = EventPriority.LOWEST) public void prepare(GameStateChangeEvent event) { if (event.GetState() != GameState.Prepare) @@ -368,21 +404,64 @@ public class Moba extends TeamGame } } + //TODO announce to all @Override - public void RespawnPlayer(Player player) + public DeathMessageType GetDeathMessageType() { - MobaPlayer mobaPlayer = getData(player); - - player.eject(); - Manager.Clear(player); - GetTeam(player).SpawnTeleport(player); - SetKit(player, mobaPlayer.Kit, false); + return DeathMessageType.Detailed; } @EventHandler - public void combatDeath(CombatDeathEvent event) + public void preventTeamDamage(CustomDamageEvent event) { - event.SetBroadcastType(DeathMessageType.Detailed); + Player damagee = event.GetDamageePlayer(); + Player damager = event.GetDamagerPlayer(true); + + if (damagee == null || damager == null) + { + return; + } + + GameTeam damageeTeam = GetTeam(damagee); + GameTeam damagerTeam = GetTeam(damager); + + if (damageeTeam == null || damagerTeam == null) + { + return; + } + + if (damageeTeam.equals(damagerTeam)) + { + event.SetCancelled("Team Damage"); + } + } + + @EventHandler + public void preventTeamFire(ConditionApplyEvent event) + { + Condition condition = event.GetCondition(); + + if (condition.GetType() != ConditionType.BURNING) + { + return; + } + + if (condition.GetEnt() == null || condition.GetSource() == null) + { + return; + } + + if (!(condition.GetEnt() instanceof Player && condition.GetSource() instanceof Player)) + { + return; + } + + if (!GetTeam((Player) condition.GetEnt()).equals(GetTeam((Player) condition.GetSource()))) + { + return; + } + + event.setCancelled(true); } // Clear up memory @@ -394,7 +473,16 @@ public class Moba extends TeamGame _playerData.removeIf(mobaPlayer -> mobaPlayer.Player.equals(player)); } - private Map getLocationStartsWith(String s) + @EventHandler + public void projectileHit(ProjectileHitEvent event) + { + if (event.getEntity() instanceof Arrow) + { + event.getEntity().remove(); + } + } + + public Map getLocationStartsWith(String s) { Map map = new HashMap<>(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 705581001..bdb8dc67d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -48,6 +48,11 @@ public class HeroKit extends Kit return _role; } + public ItemStack getAmmo() + { + return _ammo; + } + public void setAmmo(ItemStack ammo, long giveTime) { _ammo = ammo; @@ -59,17 +64,30 @@ public class HeroKit extends Kit _maxAmmo = max; } - protected boolean useAmmo(Player player, int amount) + public boolean useAmmo(Player player, int amount) { ItemStack itemStack = player.getInventory().getItem(AMMO_SLOT); - if (itemStack == null || itemStack.getAmount() < amount) + if (itemStack == null) { return false; } - itemStack.setAmount(itemStack.getAmount() - amount); - player.updateInventory(); + int newAmount = itemStack.getAmount() - amount; + + if (itemStack.getAmount() < amount) + { + return false; + } + + if (newAmount == 0) + { + player.getInventory().remove(itemStack); + } + else + { + itemStack.setAmount(newAmount); + } return true; } @@ -122,9 +140,6 @@ public class HeroKit extends Kit inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(RECALL_SLOT, RECALL_ITEM); - Bukkit.broadcastMessage(""); - Bukkit.broadcastMessage(player.getName()); - for (Perk perk : GetPerks()) { if (!(perk instanceof HeroSkill)) @@ -134,11 +149,7 @@ public class HeroKit extends Kit HeroSkill skill = (HeroSkill) perk; - if (skill.getItemStack() != null) - { - Bukkit.broadcastMessage("Giving kit " + GetName() + ", perk " + skill.GetName() + ", item " + skill.getItemStack().getItemMeta().getDisplayName()); - inventory.setItem(skill.getSlot(), skill.isOnCooldown(player) ? skill.getCooldownItemStack() : skill.getItemStack()); - } + skill.giveItem(player); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 252a69089..6a63a8db3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -1,16 +1,18 @@ package nautilus.game.arcade.game.games.moba.kit; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.*; import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; 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.events.PlayerKitGiveEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; @@ -18,20 +20,21 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; +import java.util.*; +import java.util.function.Consumer; public class HeroSkill extends Perk { - private ItemStack _item; + protected List _items; private ItemStack _cooldownItem; private final int _slot; private final ActionType _actionType; private final boolean _sneakActivate; + protected HeroKit _kit; private long _cooldown; private final Map _lastSkill = new HashMap<>(); @@ -50,12 +53,13 @@ public class HeroSkill extends Perk { super(name, perkDesc); - _item = itemStack; + _items = new ArrayList<>(2); + _items.add(itemStack); _slot = slot; _actionType = actionType; _sneakActivate = sneakActivate; - prettifyItem(); + prettifyItems(); } protected void setCooldown(long cooldown) @@ -63,10 +67,14 @@ public class HeroSkill extends Perk _cooldown = cooldown; } - private void prettifyItem() + private void prettifyItems() { - String action = "Click"; + String action = null; + if (_actionType == ActionType.ANY) + { + action = "Click"; + } if (_actionType == ActionType.L) { action = "Left Click"; @@ -81,28 +89,57 @@ public class HeroSkill extends Perk action += "/Sneak"; } - _item = new ItemBuilder(_item) - .setTitle(C.cYellowB + action + C.cGray + " - " + C.cGreenB + GetName()) - .addLore(GetDesc()) - .build(); + List items = new ArrayList<>(2); + + for (ItemStack itemStack : _items) + { + items.add(new ItemBuilder(itemStack) + .setTitle((action != null ? C.cYellowB + action + C.cGray + " - " : "") + C.cGreenB + GetName()) + .addLore(GetDesc()) + .setUnbreakable(true) + .build()); + } + + _items = items; _cooldownItem = new ItemBuilder(Material.INK_SACK, (byte) 8) .setTitle(C.cRed + GetName()) .addLore(GetDesc()) + .setUnbreakable(true) .build(); } -// @Override -// public void SetHost(Kit kit) -// { -// super.SetHost(kit); -// -// _kit = (HeroKit) kit; -// } + protected void addSkillItem(ItemStack itemStack) + { + _items.add(itemStack); + prettifyItems(); + } + + @Override + public void SetHost(Kit kit) + { + super.SetHost(kit); + + _kit = (HeroKit) kit; + } @EventHandler public void giveItem(PlayerKitGiveEvent event) { - event.getPlayer().getInventory().setItem(_slot, isOnCooldown(event.getPlayer()) ? _cooldownItem : _item); + Player player = event.getPlayer(); + + if (!hasPerk(player)) + { + return; + } + + if (isOnCooldown(player)) + { + player.getInventory().setItem(_slot, _cooldownItem); + } + else + { + giveItem(player); + } } @EventHandler @@ -131,12 +168,20 @@ public class HeroSkill extends Perk Player player = event.getPlayer(); ItemStack itemStack = event.getItem(); - if (!hasPerk(player) || UtilPlayer.isSpectator(player) || itemStack == null || !itemStack.isSimilar(_item)) + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || itemStack == null) { return false; } - return true; + for (ItemStack correctItem : _items) + { + if (itemStack.isSimilar(correctItem)) + { + return true; + } + } + + return false; } protected boolean isSkillSneak(PlayerToggleSneakEvent event) @@ -147,13 +192,22 @@ public class HeroSkill extends Perk } Player player = event.getPlayer(); + ItemStack itemStack = player.getInventory().getItem(_slot); - if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !player.getInventory().getItem(_slot).isSimilar(_item)) + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || itemStack == null) { return false; } - return true; + for (ItemStack correctItem : _items) + { + if (itemStack.isSimilar(correctItem)) + { + return true; + } + } + + return false; } public void useSkill(Player player) @@ -168,7 +222,7 @@ public class HeroSkill extends Perk @EventHandler public void updateCooldowns(UpdateEvent event) { - if (event.getType() != UpdateType.FASTEST || _item == null) + if (event.getType() != UpdateType.FASTEST || _items == null) { return; } @@ -193,26 +247,90 @@ public class HeroSkill extends Perk if (done) { _lastSkill.remove(player.getUniqueId()); - player.getInventory().setItem(_slot, _item); + giveItem(player); } else { long timeDiff = current - start; double amount = (int) (cooldown / 1000) - Math.ceil((double) timeDiff / 1000); + if (itemStack == null) + { + itemStack = _cooldownItem; + } + itemStack.setAmount((int) amount); } } } - public ItemStack getItemStack() + public void giveItem(Player player) { - return _item; + if (_items.isEmpty()) + { + return; + } + + player.getInventory().setItem(_slot, _items.get(0)); } - public ItemStack getCooldownItemStack() + public void useActiveSkill(Player player, long time) { - return _cooldownItem; + useActiveSkill(null, player, time); + } + + public void useActiveSkill(Runnable complete, Player player, long time) + { + long ticks = (long) (time / 1000D); + ItemStack itemStack = player.getInventory().getItem(getSlot()); + itemStack.setAmount((int) (ticks / 20D)); + UtilInv.addDullEnchantment(itemStack); + Recharge.Instance.useForce(player, GetName(), ticks, true); + Recharge.Instance.setDisplayForce(player, GetName(), true); + + Manager.runSyncTimer(new BukkitRunnable() + { + int iterations = 0; + + @Override + public void run() + { + if (iterations++ > ticks) + { + if (complete != null) + { + complete.run(); + } + useSkill(player); + cancel(); + return; + } + + itemStack.setAmount(itemStack.getAmount() - 1); + } + }, 0, 20); + } + + protected boolean isTeamDamage(LivingEntity damagee, LivingEntity damager) + { + if (!(damagee instanceof Player || damager instanceof Player)) + { + return false; + } + + Player damageePlayer = (Player) damagee; + Player damagerPlayer = (Player) damager; + + Game game = Manager.GetGame(); + GameTeam damageeTeam = game.GetTeam(damageePlayer); + GameTeam damagerTeam = game.GetTeam(damagerPlayer); + + if (damageeTeam == null || damagerTeam == null) + { + return false; + } + + return damageeTeam.equals(damagerTeam); } public int getSlot() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java index 4d56b39ee..cc620307f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java @@ -2,6 +2,8 @@ package nautilus.game.arcade.game.games.moba.kit; import mineplex.core.common.entity.ClientArmorStand; import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler.ListenerPriority; @@ -130,8 +132,7 @@ public class PregameSelection implements Listener, IPacketHandler // stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); // stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); // stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); - FireworkEffect effect = FireworkEffect.builder().with(Type.BURST).withColor(Color.LIME).withFade(Color.WHITE).withFlicker().build(); - UtilFirework.playFirework(stand.getLocation(), effect); + UtilParticle.PlayParticle(ParticleType.CLOUD, location.clone().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 1, ViewDist.LONG, player); _kitStands.put(stand, kit); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java new file mode 100644 index 000000000..d4ef4a78f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.game.games.moba.kit.anath; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroAnath extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new SkillFireProjectile(0), + new SkillBurnBeam(1), + new SkillFlameDash(2), + new SkillMeteor(3) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.BLAZE_ROD); + + private static final ItemStack AMMO = new ItemBuilder(Material.BLAZE_POWDER) + .setTitle(C.cYellowB + "Embers") + .build(); + + public HeroAnath(ArcadeManager manager) + { + super(manager, "Anath the Unsworn", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); + + setAmmo(AMMO, 1000); + setMaxAmmo(4); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java new file mode 100644 index 000000000..2a2f1f23d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java @@ -0,0 +1,95 @@ +package nautilus.game.arcade.game.games.moba.kit.anath; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +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.UtilServer; +import mineplex.core.common.util.particles.effects.LineParticle; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +public class SkillBurnBeam extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FIREBALL); + + public SkillBurnBeam(int slot) + { + super("Burn Beam", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(10000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + Vector direction = player.getLocation().getDirection().setY(0); + + player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 2, 0.5F); + + useSkill(player); + + LineParticle particle = new LineParticle(player.getLocation().add(direction), direction, 0.2, 9, null, ParticleType.LAVA, UtilServer.getPlayers()); + + particle.setIgnoreAllBlocks(true); + + Manager.runSyncTimer(new BukkitRunnable() + { + @Override + public void run() + { + for (int i = 0; i < 3; i++) + { + if (particle.update()) + { + cancel(); + return; + } + else + { + UtilParticle.PlayParticleToAll(ParticleType.FLAME, particle.getLastLocation().clone().add(0, 5, 0), 0.4F, 5, 0.4F, 0.05F, 30, ViewDist.LONG); + } + } + + if (Math.random() < 0.1) + { + particle.getLastLocation().getWorld().playSound(particle.getLastLocation(), Sound.GHAST_FIREBALL, 2, 0.5F); + } + + for (LivingEntity entity : UtilEnt.getInRadius(particle.getLastLocation(), 2).keySet()) + { + if (entity.equals(player)) + { + continue; + } + + 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()); + } + } + }, 0, 1); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java new file mode 100644 index 000000000..895064ae7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.moba.kit.anath; + +import mineplex.core.common.util.UtilEvent.ActionType; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +public class SkillFireProjectile extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.BLAZE_ROD); + + public SkillFireProjectile(int slot) + { + super("Fire Item", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + if (!_kit.useAmmo(player, 1)) + { + return; + } + + Vector direction = player.getLocation().getDirection().multiply(1.25); + Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), _kit.getAmmo()); + item.setVelocity(direction); + + Manager.GetFire().Add(item, player, 3, 0, 1, 5, GetName(), false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java new file mode 100644 index 000000000..5c65b976a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java @@ -0,0 +1,51 @@ +package nautilus.game.arcade.game.games.moba.kit.anath; + +import mineplex.core.common.util.UtilBlock; +import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class SkillFlameDash extends DashSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving fire behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillFlameDash(int slot) + { + super("Flame Dash", DESCRIPTION, SKILL_ITEM, slot); + + setCooldown(12000); + + _collide = false; + _velocityTime = 600; + _velocityStopOnEnd = true; + _horizontial = true; + } + + @Override + public void dashTick(Player player) + { + Block block = player.getLocation().getBlock(); + + while (!UtilBlock.solid(block)) + { + block = block.getRelative(BlockFace.DOWN); + } + + Block fBlock = block; + Manager.runSyncLater(() -> Manager.GetBlockRestore().add(fBlock.getRelative(BlockFace.UP), Material.FIRE.getId(), (byte) 0, 5000), 10); + } + + @Override + public void postDash(Player player) + { + Manager.GetBlockRestore().restore(player.getLocation().getBlock()); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java new file mode 100644 index 000000000..3fa7a24b7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -0,0 +1,164 @@ +package nautilus.game.arcade.game.games.moba.kit.anath; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.kit.perks.data.MeteorShowerData; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.*; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashSet; +import java.util.Set; + +public class SkillMeteor extends HeroSkill implements IThrown +{ + + private static final String[] DESCRIPTION = { + "It doesn't blow up the map :)", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + + private final Set _data = new HashSet<>(); + + public SkillMeteor(int slot) + { + super("Meteor Shower", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(60000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + if (!Recharge.Instance.use(player, GetName() + " Trigger", 10000, false, false)) + { + return; + } + + FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.NETHERRACK, (byte) 0); + block.setVelocity(player.getLocation().getDirection()); + + Manager.GetProjectile().AddThrow(block, player, this, 2000, true, true, true, false, 0.5F); + + useActiveSkill(player, 7000); + } + + @EventHandler + public void entityChangeBlock(EntityChangeBlockEvent event) + { + if (event.getEntity() instanceof FallingBlock) + { + event.getEntity().remove(); + event.setCancelled(true); + } + } + + @EventHandler + public void updateShower(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + _data.removeIf(MeteorShowerData::update); + + for (MeteorShowerData data : _data) + { + Location location = data.Target; + + for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 100) + { + double x = 10 * Math.sin(theta); + double z = 10 * Math.cos(theta); + + location.add(x, 0.25, z); + + UtilParticle.PlayParticleToAll(ParticleType.FLAME, location, 0, 0, 0, 0.001F, 1, ViewDist.LONG); + + location.subtract(x, 0.25, z); + } + + for (LivingEntity nearby : UtilEnt.getInRadius(location, 10).keySet()) + { + if (isTeamDamage(data.Shooter, nearby)) + { + continue; + } + + nearby.setFireTicks(20); + Manager.GetDamage().NewDamageEvent(nearby, data.Shooter, null, DamageCause.CUSTOM, 2, true, true, false, UtilEnt.getName(data.Shooter), GetName()); + } + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void projectileHit(EntityExplodeEvent event) + { + if (event.getEntity() instanceof LargeFireball) + { + event.blockList().clear(); + } + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Entity thrown = data.getThrown(); + + startShower(data); + + thrown.remove(); + } + + @Override + public void Idle(ProjectileUser data) + { + + } + + @Override + public void Expire(ProjectileUser data) + { + for (MeteorShowerData showerData : _data) + { + if (showerData.Shooter.equals(data.getThrower())) + { + return; + } + } + + startShower(data); + } + + private void startShower(ProjectileUser data) + { + Manager.GetBlockRestore().add(data.getThrown().getLocation().getBlock(), Material.NETHERRACK.getId(), (byte) 0, 6000); + _data.add(new MeteorShowerData((Player) data.getThrower(), data.getThrown().getLocation(), 6000)); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java new file mode 100644 index 000000000..85952a767 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -0,0 +1,226 @@ +package nautilus.game.arcade.game.games.moba.kit.common; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.*; +import java.util.Map.Entry; + +public class DashSkill extends HeroSkill +{ + + // Teleport Only + protected boolean _teleport = false; + protected boolean _horizontial = false; + protected double _range = 10; + protected ParticleType _particleType = ParticleType.FIREWORKS_SPARK; + + // Velocity + protected long _velocityTime; + protected double _velocityMagnitude = 1; + protected boolean _velocityStopOnEnd = false; + + // Collisions + protected boolean _collide = true; + protected double _collideRange = 2; + protected boolean _collideTeammates = false; + protected boolean _collidePlayers = true; + protected boolean _collideEntities = true; + protected boolean _collideOnce = true; + + private final Map _startTime; + + public DashSkill(String name, String[] perkDesc, ItemStack itemStack, int slot) + { + super(name, perkDesc, itemStack, slot, ActionType.ANY, true); + + _startTime = new HashMap<>(); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @EventHandler + public void toggleSneak(PlayerToggleSneakEvent event) + { + if (!isSkillSneak(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @Override + public void useSkill(Player player) + { + super.useSkill(player); + + preDash(player); + + if (_teleport) + { + Vector direction = player.getLocation().getDirection(); + + if (_horizontial) + { + direction.setY(0); + } + + LineParticle particle = new LineParticle(player.getEyeLocation(), direction, 0.8, _range, null, _particleType, UtilServer.getPlayers()); + + while (!particle.update()) + { + dashTick(player); + checkCollisions(player, particle.getLastLocation()); + } + + player.teleport(particle.getDestination()); + postDash(player); + } + // Otherwise we set their velocity. + else if (_velocityTime > 0) + { + _startTime.put(player, System.currentTimeMillis()); + } + else + { + setVelocity(player); + } + } + + @EventHandler + public void updateVelocity(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Entry entry : _startTime.entrySet()) + { + Player player = entry.getKey(); + long start = entry.getValue(); + + if (UtilTime.elapsed(start, _velocityTime)) + { + if (_velocityStopOnEnd) + { + UtilAction.zeroVelocity(player); + } + _startTime.remove(player); + postDash(player); + } + else + { + checkCollisions(player, player.getLocation()); + setVelocity(player); + } + } + } + + private void setVelocity(Player player) + { + Vector direction = player.getLocation().getDirection().multiply(_velocityMagnitude); + + if (_horizontial) + { + direction.setY(0); + } + + dashTick(player); + UtilAction.velocity(player, direction); + } + + private void checkCollisions(Player player, Location location) + { + // No colliding + if (!_collide || !_collideEntities && !_collidePlayers) + { + return; + } + + // All Living entities within the range + for (Entry entry : UtilEnt.getInRadius(location, _collideRange).entrySet()) + { + LivingEntity entity = entry.getKey(); + double scale = entry.getValue(); + + // If player hit themselves or the entity has already been hit + if (player.equals(entity) || !Recharge.Instance.use(player, GetName() + " by " + player.getName(), 500, false, false) && _collideOnce) + { + continue; + } + + // If allowing collisions with players + if (entity instanceof Player) + { + if (!_collidePlayers) + { + continue; + } + + boolean sameTeam = isTeamDamage(entity, player); + + // If their teams are the same and we don't allow collisions with teammates, ignore + if (sameTeam && !_collideTeammates) + { + continue; + } + + collideEntity(entity, player, scale, sameTeam); + } + // Any other entities and if we allow collisions with them + else if (_collideEntities) + { + collideEntity(entity, player, scale, false); + } + } + } + + public void preDash(Player player) + { + } + + public void dashTick(Player player) + { + } + + public void collideEntity(LivingEntity entity, Player damager, double scale, boolean sameTeam) + { + } + + public void postDash(Player player) + { + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java new file mode 100644 index 000000000..3ce67db5e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java @@ -0,0 +1,20 @@ +package nautilus.game.arcade.game.games.moba.kit.common; + +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class SkillBow extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Please work" + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.BOW); + + public SkillBow(int slot) + { + super("Bow", DESCRIPTION, SKILL_ITEM, slot, null); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java new file mode 100644 index 000000000..7aa94f22a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java @@ -0,0 +1,25 @@ +package nautilus.game.arcade.game.games.moba.kit.common; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class SkillSword extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Please work" + }; + + private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.WOOD_SWORD) + .setTitle(C.cGreenB + "Sword") + .setUnbreakable(true) + .build(); + + public SkillSword(int slot) + { + super("Sword", DESCRIPTION, SKILL_ITEM, slot, null); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java new file mode 100644 index 000000000..ce24c96b5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java @@ -0,0 +1,31 @@ +package nautilus.game.arcade.game.games.moba.kit.dana; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroDana extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new SkillSword(0), + new SkillPulseHeal(1), + new SkillDanaDash(2), + new SkillRally(3), + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); + + public HeroDana(ArcadeManager manager) + { + super(manager, "Dana", DESCRIPTION, PERKS, IN_HAND, MobaRole.WARRIOR); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java new file mode 100644 index 000000000..f4efd724e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java @@ -0,0 +1,82 @@ +package nautilus.game.arcade.game.games.moba.kit.dana; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.Random; + +public class SkillDanaDash extends DashSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving fire behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillDanaDash(int slot) + { + super("Knock up", DESCRIPTION, SKILL_ITEM, slot); + + setCooldown(10000); + + _velocityTime = 600; + _horizontial = true; + _velocityStopOnEnd = true; + } + + @Override + public void preDash(Player player) + { + player.getWorld().playSound(player.getLocation(), Sound.BLAZE_HIT, 2, 0.4F); + } + + @Override + public void dashTick(Player player) + { + Random random = UtilMath.random; + Location location = player.getLocation().add(random.nextInt(5) - 2.5, random.nextInt(3), random.nextInt(5) - 2.5); + UtilParticle.PlayParticle(ParticleType.CLOUD, location.add(0, 1, 0), 0.5F, 0.5F, 0.5f, 0.1F, 10, ViewDist.LONG); + } + + @Override + public void collideEntity(LivingEntity entity, Player damager, double scale, boolean sameTeam) + { + double damage; + + if (entity instanceof Player) + { + damage = 10; + UtilAction.velocity(entity, new Vector(Math.random() / 2 - 0.25, 2, Math.random() / 2 - 0.25)); + } + else + { + damage = 6; + UtilAction.velocity(entity, new Vector(Math.random() - 0.5, 1, Math.random() - 0.5)); + } + + entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_HIT, 1, 0.5F); + Manager.GetDamage().NewDamageEvent(entity, damager, null, DamageCause.CUSTOM, damage, false, false, false, UtilEnt.getName(damager), GetName()); + } + + @Override + public void postDash(Player player) + { + player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 2, 0.4F); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5f, 0.1F, 3, ViewDist.LONG); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java new file mode 100644 index 000000000..dd815d1df --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -0,0 +1,164 @@ +package nautilus.game.arcade.game.games.moba.kit.dana; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +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.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.game.games.moba.kit.HeroSkill; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.HashSet; +import java.util.Set; + +public class SkillPulseHeal extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + + private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.INK_SACK, (byte) 10).build(); + private static final ItemStack SKILL_ITEM_TOGGLED = new ItemBuilder(Material.INK_SACK, (byte) 12).build(); + + private Set _toggled = new HashSet<>(); + + public SkillPulseHeal(int slot) + { + super("Pulse Heal", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + addSkillItem(SKILL_ITEM_TOGGLED); + setCooldown(2000); + } + + @Override + public void giveItem(Player player) + { + if (_toggled.contains(player)) + { + player.getInventory().setItem(getSlot(), _items.get(1)); + } + else + { + player.getInventory().setItem(getSlot(), _items.get(0)); + } + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + if (_toggled.contains(player)) + { + _toggled.remove(player); + } + else + { + _toggled.add(player); + } + + useSkill(player); + } + + @EventHandler + public void updatePulse(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !Recharge.Instance.use(player, GetName(), 10000, false, false)) + { + continue; + } + + Location location = player.getLocation(); + + if (_toggled.contains(player)) + { + for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) + { + // Don't heal self or enemies + if (entity.equals(player) || !isTeamDamage(entity, player)) + { + continue; + } + + entity.setHealth(Math.min(entity.getHealth() + 2, entity.getMaxHealth())); + } + + displayPulse(location, false); + } + else + { + player.setHealth(Math.min(player.getHealth() + 2, player.getMaxHealth())); + + displayPulse(location, true); + } + } + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _toggled.remove(event.getPlayer()); + } + + private void displayPulse(Location location, boolean inwards) + { + Manager.runSyncTimer(new BukkitRunnable() + { + + double theta = 0; + double radius = inwards ? 5 : 0; + + @Override + public void run() + { + if (inwards && radius < 0 || !inwards && radius > 5) + { + cancel(); + return; + } + + double increment = inwards ? -0.2 : 0.2; + for (double theta2 = 0; theta2 < 2 * Math.PI; theta2 += Math.PI / 3) + { + double x = radius * Math.sin(theta + theta2); + double z = radius * Math.cos(theta + theta2); + + location.add(x, 0.5, z); + + UtilParticle.PlayParticleToAll(inwards ? ParticleType.HAPPY_VILLAGER : ParticleType.DRIP_WATER, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); + + location.subtract(x, 0.5, z); + } + + theta += Math.PI / 100; + radius += increment; + } + }, 0, 1); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java new file mode 100644 index 000000000..cd5c004db --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -0,0 +1,205 @@ +package nautilus.game.arcade.game.games.moba.kit.dana; + +import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.*; +import org.bukkit.block.Banner; +import org.bukkit.block.Block; +import org.bukkit.block.banner.Pattern; +import org.bukkit.block.banner.PatternType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class SkillRally extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + + private Set _data = new HashSet<>(); + + public SkillRally(int slot) + { + super("Rally", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(40000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + Vector vector = player.getLocation().getDirection(); + + for (RallyData data : _data) + { + if (data.Owner.equals(player)) + { + return; + } + } + + vector.setY(Math.min(vector.getY(), 1)); + vector.setY(Math.max(vector.getY(), 1.5)); + + UtilAction.velocity(player, vector); + _data.add(new RallyData(player)); + } + + @EventHandler + public void updateLand(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + Iterator iterator = _data.iterator(); + + while (iterator.hasNext()) + { + RallyData data = iterator.next(); + Player player = data.Owner; + + if (data.Landed) + { + if (UtilTime.elapsed(data.LandTime, 7000)) + { + iterator.remove(); + } + else + { + for (Player nearby : UtilPlayer.getNearby(data.Banner, 5)) + { + // Only heal allies + if (!isTeamDamage(nearby, player)) + { + continue; + } + + UtilParticle.PlayParticleToAll(ParticleType.HEART, nearby.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 1, ViewDist.LONG); + Manager.GetCondition().Factory().Regen(GetName(), nearby, data.Owner, 3, 1, false, true, false); + } + } + } + else if (UtilTime.elapsed(data.LaunchTime, 1000) && UtilEnt.isGrounded(data.Owner)) + { + data.LandTime = System.currentTimeMillis(); + data.Landed = true; + Location location = data.Owner.getLocation(); + data.Banner = location; + + useActiveSkill(player, 7000); + + GameTeam team = Manager.GetGame().GetTeam(player); + Block block = location.getBlock(); + + Manager.GetBlockRestore().add(block, Material.STANDING_BANNER.getId(), (byte) 0, 7500); + + Banner banner = (Banner) block.getState(); + banner.setBaseColor(team.GetColor() == ChatColor.RED ? DyeColor.RED : DyeColor.BLUE); + banner.addPattern(getPattern(team)); + banner.update(); + + for (Block nearby : UtilBlock.getBlocksInRadius(banner.getLocation(), 5)) + { + if (UtilBlock.airFoliage(nearby)) + { + continue; + } + + Manager.GetBlockRestore().add(nearby, Material.STAINED_CLAY.getId(), team.GetColorData(), (long) (7000 + (Math.random() * 500))); + if (Math.random() > 0.9) + { + nearby.getWorld().playEffect(nearby.getLocation(), Effect.STEP_SOUND, Material.STAINED_CLAY, team.GetColorData()); + } + } + + for (LivingEntity nearby : UtilEnt.getInRadius(player.getLocation(), 3).keySet()) + { + Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, 5, true, true, false, UtilEnt.getName(player), GetName()); + } + } + } + } + + @EventHandler + public void updateParticles(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (RallyData data : _data) + { + if (!data.Landed) + { + continue; + } + + Location banner = data.Banner; + + for (int i = 0; i < 5; i++) + { + double x = 5 * Math.sin(data.ParticleTheta); + double z = 5 * Math.cos(data.ParticleTheta); + + banner.add(x, 0.25, z); + + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, banner, 0, 0, 0, 0.1F, 1, ViewDist.LONG); + + banner.subtract(x, 0.25, z); + + data.ParticleTheta += Math.PI / 100; + } + } + } + + private Pattern getPattern(GameTeam team) + { + return team.GetColor() == ChatColor.RED ? new Pattern(DyeColor.WHITE, PatternType.CROSS) : new Pattern(DyeColor.WHITE, PatternType.CIRCLE_MIDDLE); + } + + private class RallyData + { + + Player Owner; + Location Banner; + boolean Landed; + long LaunchTime; + long LandTime; + double ParticleTheta; + + RallyData(Player owner) + { + Owner = owner; + LaunchTime = System.currentTimeMillis(); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java index a60d08800..b7bd131c5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -5,15 +5,10 @@ import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; -import nautilus.game.arcade.game.games.moba.kit.hattori.SkillDash; -import nautilus.game.arcade.game.games.moba.kit.hattori.SkillNinjaBlade; -import nautilus.game.arcade.game.games.moba.kit.hattori.SkillSnowball; +import nautilus.game.arcade.game.games.moba.kit.common.SkillBow; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkFletcher; import org.bukkit.Material; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; public class HeroDevon extends HeroKit { @@ -23,6 +18,7 @@ public class HeroDevon extends HeroKit }; private static final Perk[] PERKS = { + new SkillBow(0), new SkillTNTArrows(1), new SkillBoost(2), new SkillInfinity(3) @@ -30,11 +26,6 @@ public class HeroDevon extends HeroKit private static final ItemStack IN_HAND = new ItemStack(Material.BOW); - private static final ItemStack BOW = new ItemBuilder(Material.BOW) - .setTitle(C.cGreenB + "Bow") - .setUnbreakable(true) - .build(); - private static final ItemStack AMMO = new ItemBuilder(Material.ARROW) .setTitle(C.cYellowB + "Hunting Arrow") .build(); @@ -46,14 +37,4 @@ public class HeroDevon extends HeroKit setAmmo(AMMO, 3000); setMaxAmmo(3); } - - @Override - public void GiveItems(Player player) - { - // TODO remove this when shop is implemented - PlayerInventory inventory = player.getInventory(); - inventory.setItem(0, BOW); - - super.GiveItems(player); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java index 6de9c1330..edfb3e95f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.devon; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.minecraft.game.core.condition.ConditionFactory; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; @@ -19,7 +20,7 @@ public class SkillBoost extends HeroSkill public SkillBoost(int slot) { - super("Hunters Boost", DESCRIPTION, SKILL_ITEM, slot, null, true); + super("Hunters Boost", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY, true); setCooldown(10000); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 85f4852f0..279dd195f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -1,12 +1,17 @@ package nautilus.game.arcade.game.games.moba.kit.devon; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; @@ -17,10 +22,13 @@ import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; public class SkillInfinity extends HeroSkill { @@ -32,10 +40,11 @@ public class SkillInfinity extends HeroSkill private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); private final Map _arrows = new HashMap<>(); + private final Set _active = new HashSet<>(); public SkillInfinity(int slot) { - super("Infinity", DESCRIPTION, SKILL_ITEM, slot, null); + super("Infinity", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); } @@ -56,10 +65,14 @@ public class SkillInfinity extends HeroSkill return; } - bow.addEnchantment(Enchantment.ARROW_INFINITE, 0); - Recharge.Instance.useForce(player, GetName(), 7000, false); + bow.addEnchantment(Enchantment.ARROW_INFINITE, 1); + _active.add(player); - Manager.runSyncLater(() -> bow.removeEnchantment(Enchantment.ARROW_INFINITE), 7 * 20); + useActiveSkill(() -> + { + bow.removeEnchantment(Enchantment.ARROW_INFINITE); + _active.remove(player); + }, player, 7000); } @EventHandler @@ -72,13 +85,18 @@ public class SkillInfinity extends HeroSkill Player player = (Player) event.getEntity(); + if (!hasPerk(player) || !_active.contains(player)) + { + return; + } + _arrows.put(event.getProjectile(), player); } @EventHandler public void updateArrowTarget(UpdateEvent event) { - if (event.getType() != UpdateType.FASTEST || !Manager.isGameInProgress()) + if (event.getType() != UpdateType.FASTEST) { return; } @@ -89,22 +107,37 @@ public class SkillInfinity extends HeroSkill Player player = entry.getValue(); GameTeam team = Manager.GetGame().GetTeam(player); - for (LivingEntity nearby : UtilEnt.getInRadius(entity.getLocation(), 3).keySet()) + for (LivingEntity nearby : UtilEnt.getInRadius(entity.getLocation(), 6).keySet()) { if (nearby instanceof Player) { // If the target is on the same team - if (team.equals(Manager.GetGame().GetTeam((Player) nearby))) + if (UtilPlayer.isSpectator(player) || team.equals(Manager.GetGame().GetTeam((Player) nearby))) { continue; } } - entity.setVelocity(UtilAlg.getTrajectory(entity.getLocation(), nearby.getLocation())); + UtilAction.velocity(nearby, UtilAlg.getTrajectory(entity.getLocation(), nearby.getLocation().add(0, 1.5, 0))); } } } + @EventHandler + public void arrowDamage(CustomDamageEvent event) + { + if (event.GetProjectile() == null) + { + return; + } + + if (_arrows.containsKey(event.GetProjectile())) + { + Bukkit.broadcastMessage("Wither"); + Manager.GetCondition().Factory().Wither(GetName(), event.GetDamageeEntity(), event.GetDamagerEntity(true), 3, 0, false, true, false); + } + } + @EventHandler public void projectileHit(ProjectileHitEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java index 999cd5c69..9dcd7895c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java @@ -1,23 +1,32 @@ package nautilus.game.arcade.game.games.moba.kit.devon; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import nautilus.game.arcade.game.games.moba.kit.hattori.SkillSnowball; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.Map; -import java.util.UUID; +import java.util.Map.Entry; public class SkillTNTArrows extends HeroSkill implements IThrown { @@ -28,11 +37,11 @@ public class SkillTNTArrows extends HeroSkill implements IThrown }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.TNT); - private final Map _arrows = new HashMap<>(); + private final Map _arrows = new HashMap<>(); public SkillTNTArrows(int slot) { - super("TNT Infusion", DESCRIPTION, SKILL_ITEM, slot, null); + super("TNT Infusion", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(17000); } @@ -47,8 +56,9 @@ public class SkillTNTArrows extends HeroSkill implements IThrown Player player = event.getPlayer(); - _arrows.put(player.getUniqueId(), 3); + _arrows.put(player, 3); player.getItemInHand().addEnchantment(UtilInv.getDullEnchantment(), 1); + player.getItemInHand().setAmount(3); } @EventHandler @@ -61,31 +71,74 @@ public class SkillTNTArrows extends HeroSkill implements IThrown Player player = (Player) event.getEntity(); - if (!hasPerk(player) || !_arrows.containsKey(player.getUniqueId())) + if (!hasPerk(player) || !_arrows.containsKey(player)) { return; } - int arrows = _arrows.get(player.getUniqueId()); + ItemStack itemStack = player.getInventory().getItem(getSlot()); + int arrows = _arrows.get(player); if (arrows == 1) { - _arrows.remove(player.getUniqueId()); + _arrows.remove(player); useSkill(player); } else { - _arrows.put(player.getUniqueId(), arrows - 1); + arrows--; + _arrows.put(player, arrows); + itemStack.setAmount(arrows); } - Manager.GetProjectile().AddThrow(event.getProjectile(), player, this, -1, true, true, true, false, 0.5F); + Manager.GetProjectile().AddThrow(event.getProjectile(), player, this, -1, true, true, true, false, 0); + } + + @EventHandler + public void playerDeath(CombatDeathEvent event) + { + _arrows.remove(event.GetEvent().getEntity()); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _arrows.remove(event.getPlayer()); } @Override public void Collide(LivingEntity target, Block block, ProjectileUser data) { + LivingEntity thrower = data.getThrower(); Location location = data.getThrown().getLocation(); - location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), 4, false, false); + + location.getWorld().playSound(location, Sound.EXPLODE, 1, 0.9F); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); + double damage = 10; + + // Scale damage with the damage on the player's bow + if (thrower instanceof Player) + { + Player throwerPlayer = (Player) thrower; + ItemStack itemStack = throwerPlayer.getInventory().getItem(0); + + // Player has a bow + if (itemStack != null && itemStack.getType() == Material.BOW) + { + damage += damage * itemStack.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) * 0.25; + } + } + + for (Entry entry : UtilEnt.getInRadius(location, 5).entrySet()) + { + if (entry.getKey().equals(thrower)) + { + continue; + } + + Manager.GetDamage().NewDamageEvent(entry.getKey(), thrower, null, DamageCause.BLOCK_EXPLOSION, (entry.getValue() + 0.5) * damage, true, true, false, UtilEnt.getName(data.getThrower()), GetName()); + } + data.getThrown().remove(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java index 0234ed154..539768e27 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java @@ -1,17 +1,13 @@ package nautilus.game.arcade.game.games.moba.kit.hattori; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.PerkDoubleJump; -import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; public class HeroHattori extends HeroKit { @@ -23,32 +19,16 @@ public class HeroHattori extends HeroKit private static final Perk[] PERKS = { new PerkDoubleJump("Double Jump", 1, 1, true), new SkillSnowball(0), - new SkillDash(2), + new SkillSword(1), + new SkillNinjaDash(2), new SkillNinjaBlade(3) }; private static final ItemStack IN_HAND = new ItemStack(Material.NETHER_STAR); - private static final ItemStack SWORD = new ItemBuilder(Material.WOOD_SWORD) - .setTitle(C.cGreenB + "Sword") - .setUnbreakable(true) - .build(); public HeroHattori(ArcadeManager manager) { super(manager, "Hattori", DESCRIPTION, PERKS, IN_HAND, MobaRole.ASSASSIN); } - - @Override - public void GiveItems(Player player) - { - Bukkit.broadcastMessage("Hello " + player.getName()); - - // TODO remove this when shop is implemented - PlayerInventory inventory = player.getInventory(); - inventory.setItem(1, SWORD); - - Bukkit.broadcastMessage("Now call the super for " + player.getName()); - super.GiveItems(player); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java deleted file mode 100644 index 8d73dc8ac..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java +++ /dev/null @@ -1,105 +0,0 @@ -package nautilus.game.arcade.game.games.moba.kit.hattori; - -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.particles.effects.LineParticle; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import org.bukkit.FireworkEffect; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -public class SkillDash extends HeroSkill -{ - - private static final String[] DESCRIPTION = { - "Dash forward dealing damage to any enemy", - "you collide with." - }; - - private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); - - public SkillDash(int slot) - { - super("Dash", DESCRIPTION, SKILL_ITEM, slot, null, true); - - setCooldown(7000); - } - - @EventHandler - public void interact(PlayerInteractEvent event) - { - if (!isSkillItem(event)) - { - return; - } - - Player player = event.getPlayer(); - - useSkill(player); - } - - @EventHandler - public void toggleSneak(PlayerToggleSneakEvent event) - { - if (!isSkillSneak(event)) - { - return; - } - - Player player = event.getPlayer(); - - useSkill(player); - } - - @Override - public void useSkill(Player player) - { - super.useSkill(player); - - LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.8, 10, null, ParticleType.FIREWORKS_SPARK, - UtilServer.getPlayers()); - Set hitPlayers = new HashSet<>(); - Game game = Manager.GetGame(); - GameTeam team = game.GetTeam(player); - - while (!lineParticle.update()) - { - for (Player other : UtilPlayer.getNearby(lineParticle.getLastLocation(), 2)) - { - if (hitPlayers.contains(other.getUniqueId()) || player.equals(other) || team.equals(game.GetTeam(other))) - { - continue; - } - - hitPlayers.add(other.getUniqueId()); - Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, 8, true, true, false, player.getName(), GetName()); - player.sendMessage(F.main("Game", "You hit " + F.elem(other.getName()) + " with " + F.skill(GetName()) + ".")); - } - } - - Location location = lineParticle.getDestination(); - FireworkEffect effect = FireworkEffect.builder().with(Type.BALL).withColor(team.GetColorBase()).withFlicker().build(); - - UtilFirework.playFirework(player.getLocation(), effect); - player.teleport(location.add(0, 0.5, 0)); - UtilFirework.playFirework(player.getLocation(), effect); - - player.sendMessage(F.main("Game", "You used " + F.skill(GetName()) + ".")); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index e4562334a..9f4fe1071 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.kit.hattori; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; @@ -37,7 +38,7 @@ public class SkillNinjaBlade extends HeroSkill public SkillNinjaBlade(int slot) { - super("Ninja Blade", DESCRIPTION, SKILL_ITEM, slot, null); + super("Ninja Blade", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); } @@ -54,15 +55,8 @@ public class SkillNinjaBlade extends HeroSkill player.getInventory().setItem(getSlot(), ACTIVE_ITEM); _active.add(player.getUniqueId()); - Recharge.Instance.useForce(player, GetName(), 7000, true); - Manager.runSyncLater(() -> - { - - _active.remove(player.getUniqueId()); - useSkill(player); - - }, 7 * 20); + useActiveSkill(() -> _active.remove(player.getUniqueId()), player, 7000); } @EventHandler @@ -81,7 +75,7 @@ public class SkillNinjaBlade extends HeroSkill } } - if (player == null || !_active.contains(player.getUniqueId())) + if (player == null || !_active.contains(player.getUniqueId()) || player.getItemInHand() == null || player.getItemInHand().getType() != Material.DIAMOND_SWORD) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java new file mode 100644 index 000000000..93439e6ca --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java @@ -0,0 +1,72 @@ +package nautilus.game.arcade.game.games.moba.kit.hattori; + +import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.particles.effects.LineParticle; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; +import org.bukkit.Bukkit; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +public class SkillNinjaDash extends DashSkill +{ + + private static final String[] DESCRIPTION = { + "Dash forward dealing damage to any enemy", + "you collide with." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillNinjaDash(int slot) + { + super("Dash", DESCRIPTION, SKILL_ITEM, slot); + + setCooldown(7000); + + _teleport = true; + _range = 10; + } + + @Override + public void preDash(Player player) + { + playFirework(player); + } + + @Override + public void collideEntity(LivingEntity entity, Player player, double scale, boolean sameTeam) + { + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 8, true, true, false, UtilEnt.getName(player), GetName()); + } + + @Override + public void postDash(Player player) + { + playFirework(player); + } + + private void playFirework(Player player) + { + GameTeam team = Manager.GetGame().GetTeam(player); + FireworkEffect effect = FireworkEffect.builder().with(Type.BALL).withColor(team.GetColorBase()).withFlicker().build(); + UtilFirework.playFirework(player.getLocation(), effect); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 3d4db31d9..5ad950ee0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.kit.hattori; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; @@ -28,7 +29,7 @@ public class SkillSnowball extends HeroSkill implements IThrown public SkillSnowball(int slot) { - super("Snowball", DESCRIPTION, SKILL_ITEM, slot, null); + super("Snowball", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(1000); } @@ -41,6 +42,8 @@ public class SkillSnowball extends HeroSkill implements IThrown return; } + event.setCancelled(true); + Player player = event.getPlayer(); useSkill(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java new file mode 100644 index 000000000..b080347bb --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java @@ -0,0 +1,89 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import mineplex.core.common.util.UtilUI; +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.MobaPlayer; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +public class MobaMainMenu extends Menu +{ + + private static final int SLOTS = 27; + + private final MobaPlayer _player; + + public MobaMainMenu(MobaPlayer player, ArcadeManager plugin) + { + super(player.Kit.GetName() + " Shop", plugin); + + _player = player; + } + + @Override + protected Button[] setUp(Player player) + { + Button[] buttons = new Button[SLOTS]; + HeroKit kit = _player.Kit; + List skills = new ArrayList<>(3); + + for (Perk perk : kit.GetPerks()) + { + if (!(perk instanceof HeroSkill)) + { + continue; + } + + skills.add((HeroSkill) perk); + } + + int slots[] = UtilUI.getIndicesFor(skills.size(), 1, 3); + + for (HeroSkill skill : skills) + { + + } + + return buttons; + } + + private ItemStack getMainMenuItem(HeroSkill skill) + { + ItemBuilder builder; + + if (skill instanceof SkillSword) + { + builder = + } + } + + class MobaMainButton extends Button + { + + private MobaPlayer _player; + + public MobaMainButton(MobaPlayer player, ArcadeManager plugin) + { + super(item, plugin); + + _player = player; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 95da9011c..d40d78dd1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -1,16 +1,104 @@ package nautilus.game.arcade.game.games.moba.shop; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaPlayer; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; + +import java.util.*; public class MobaShop implements Listener { private final Moba _host; + private final List _entities; + private final Map> _upgrades; public MobaShop(Moba host) { _host = host; + _entities = new ArrayList<>(2); + _upgrades = new HashMap<>(); + } + + @EventHandler + public void spawnNpc(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + List locations = _host.WorldData.GetDataLocs("CYAN"); + + for (Location location : locations) + { + Villager villager = location.getWorld().spawn(location, Villager.class); + + villager.setProfession(Profession.LIBRARIAN); + villager.setAgeLock(true); + villager.setRemoveWhenFarAway(false); + + _entities.add(villager); + } + } + + public void purchaseUpgrade(Player player, MobaUpgrade upgrade) + { + _upgrades.putIfAbsent(player, new HashSet<>(3)); + _upgrades.get(player).add(upgrade); + } + + private void openShop(MobaPlayer player) + { + + } + + @EventHandler + public void entityDamage(EntityDamageByEntityEvent event) + { + npcInteract(event.getEntity(), event.getDamager()); + } + + @EventHandler + public void entityInteract(PlayerInteractAtEntityEvent event) + { + npcInteract(event.getRightClicked(), event.getPlayer()); + } + + private void npcInteract(Entity clicked, Entity clicker) + { + if (!(clicker instanceof Player)) + { + return; + } + + Player player = (Player) clicked; + + for (LivingEntity shop : _entities) + { + if (clicked.equals(shop)) + { + MobaPlayer data = _host.getData(player); + + if (data == null) + { + return; + } + + openShop(data); + return; + } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java new file mode 100644 index 000000000..55312fdc6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java @@ -0,0 +1,19 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import org.bukkit.inventory.ItemStack; + +public class MobaUpgrade +{ + + private ItemStack _item; + + public MobaUpgrade(ItemStack item) + { + _item = item; + } + + public ItemStack getItem() + { + return _item; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java new file mode 100644 index 000000000..432e868a8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java @@ -0,0 +1,13 @@ +package nautilus.game.arcade.game.games.moba.shop; + +public enum MobaUpgradeType +{ + + SWORD, + BOW, + HELMET, + CHEST, + LEGS, + BOOTS + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java new file mode 100644 index 000000000..0c7d0c84c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java @@ -0,0 +1,22 @@ +package nautilus.game.arcade.game.games.moba.shop.common; + +import nautilus.game.arcade.game.games.moba.shop.MobaUpgrade; +import org.bukkit.inventory.ItemStack; + +public class CooldownUpgrade extends MobaUpgrade +{ + + private double _reductionFactor; + + public CooldownUpgrade(ItemStack item, double reductionFactor) + { + super(item); + + _reductionFactor = reductionFactor; + } + + public double getReductionFactor() + { + return _reductionFactor; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java index bc6d41347..dbfe01cf6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java @@ -6,6 +6,7 @@ import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.events.PlayerKitGiveEvent; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.*; From 9b38558268683e2cf970654914a62ddcb1b2f224 Mon Sep 17 00:00:00 2001 From: Kenny Date: Mon, 8 May 2017 15:24:12 -0400 Subject: [PATCH 011/283] Have servers request active quests from quest service on startup --- .../quest/client/RedisQuestSupplier.java | 10 ++++- .../quest/common/redis/PubSubChannels.java | 2 + .../mineplex/quest/daemon/QuestManager.java | 44 ++++++++++++++----- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java index 1adf05571..128644bb5 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java @@ -37,12 +37,20 @@ public class RedisQuestSupplier implements QuestSupplier _plugin = plugin; _pubSub = pubSub; + String serverUniqueId = plugin.getConfig().getString("serverstatus.name"); + + // request current active quests, send server unique id so we can send a response just to this server + _pubSub.publish(PubSubChannels.QUEST_REQUEST_BASE, serverUniqueId); + + // update quests sent specifically to this server when it requests them (like on startup) + _pubSub.subscribe(PubSubChannels.QUEST_REQUEST_BASE + serverUniqueId, this::updateQuests); + // update quests when received _pubSub.subscribe(PubSubChannels.QUEST_SUPPLIER_CHANNEL, this::updateQuests); } private void updateQuests(String channel, String message) - { + { _lock.writeLock().lock(); try { diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/PubSubChannels.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/PubSubChannels.java index 886250950..f28490ec8 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/PubSubChannels.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/redis/PubSubChannels.java @@ -7,5 +7,7 @@ public class PubSubChannels { public static final String QUEST_SUPPLIER_CHANNEL = "quest-manager"; + + public static final String QUEST_REQUEST_BASE = "quest-manager-request:"; } diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java index 03689d005..2dba4ccc1 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -80,6 +81,22 @@ public class QuestManager extends Thread QuestDaemon.log("Active quests loaded from file:"); _activeQuests.forEach(quest -> QuestDaemon.log(quest.getName())); } + + // listen for servers requesting active quests on startup + _pubSub.subscribe(PubSubChannels.QUEST_REQUEST_BASE, this::handleQuestRequest); + } + + private void handleQuestRequest(String channel, String message) + { + // first make sure we have some active quests selected + if (_activeQuests.isEmpty()) + { + selectRandomQuests(); + } + + // send active quests to the server + String server = message; + publishActiveQuests(PubSubChannels.QUEST_REQUEST_BASE + server); } /** @@ -106,8 +123,14 @@ public class QuestManager extends Thread for (int i = 1; i < lines.size(); i++) { int uniqueId = Integer.parseInt(lines.get(i)); - Quest quest = getById(uniqueId); - _activeQuests.add(quest); + Optional quest = Quests.fromId(uniqueId); + if (!quest.isPresent()) + { + QuestDaemon.log("Tried to load active quest that doesn't exist: " + uniqueId); + continue; + } + + _activeQuests.add(quest.get()); } } } @@ -139,8 +162,7 @@ public class QuestManager extends Thread selectRandomQuests(); // publish new quests - _pubSub.publish(PubSubChannels.QUEST_SUPPLIER_CHANNEL, - serialize(_activeQuests)); + publishActiveQuests(PubSubChannels.QUEST_SUPPLIER_CHANNEL); } QuestDaemon.log("Done updating active quests."); @@ -155,6 +177,12 @@ public class QuestManager extends Thread QuestDaemon.log(e); } } + + private void publishActiveQuests(String channel) + { + _pubSub.publish(channel, + serialize(_activeQuests)); + } /** * Called on shutdown of this service. Writes the date quests were last updated to a file, so @@ -200,13 +228,7 @@ public class QuestManager extends Thread { _recentlySelectedQuestsRepo.clean(); } - - public Quest getById(int uniqueId) - { - return _quests.values().stream().filter(q -> q.getUniqueId() == uniqueId).findFirst() - .orElse(null); - } - + private void selectRandomQuests() { if (!_activeQuests.isEmpty()) From d107c8d6f4c850ea1c85154e48d9d334b95e9bb3 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 8 May 2017 21:09:09 +0100 Subject: [PATCH 012/283] Bob Ross --- .../game/arcade/game/games/moba/Moba.java | 40 +++- .../game/games/moba/gold/GoldManager.java | 135 ++++++++++++ .../moba/kit/CooldownCalculateEvent.java | 49 +++++ .../arcade/game/games/moba/kit/HeroKit.java | 46 +++- .../arcade/game/games/moba/kit/HeroSkill.java | 11 +- .../games/moba/kit/anath/SkillFlameDash.java | 6 - .../game/games/moba/kit/bob/HeroBob.java | 40 ++++ .../games/moba/kit/bob/SkillBeatTheDevil.java | 47 ++++ .../moba/kit/bob/SkillBuildPainting.java | 206 ++++++++++++++++++ .../games/moba/kit/bob/SkillHappyTrees.java | 174 +++++++++++++++ .../game/games/moba/kit/bob/SkillPaint.java | 100 +++++++++ .../game/games/moba/kit/common/DashSkill.java | 9 +- .../games/moba/kit/common/SkillSword.java | 1 + .../games/moba/kit/dana/SkillDanaDash.java | 4 +- .../game/games/moba/kit/dana/SkillRally.java | 2 +- .../moba/kit/hattori/SkillNinjaBlade.java | 10 +- .../games/moba/kit/hattori/SkillSnowball.java | 2 - .../arcade/game/games/moba/shop/MobaItem.java | 50 +++++ .../game/games/moba/shop/MobaItemEffect.java | 17 ++ .../game/games/moba/shop/MobaMainMenu.java | 89 -------- .../arcade/game/games/moba/shop/MobaShop.java | 174 ++++++++++++++- .../games/moba/shop/MobaShopCategory.java | 47 ++++ .../games/moba/shop/MobaShopCategoryMenu.java | 96 ++++++++ .../game/games/moba/shop/MobaShopMenu.java | 124 +++++++++++ .../game/games/moba/shop/MobaUpgrade.java | 19 -- .../game/games/moba/shop/MobaUpgradeType.java | 13 -- .../moba/shop/assassin/MobaAssassinShop.java | 43 ++++ .../moba/shop/common/CooldownUpgrade.java | 22 -- .../moba/shop/effects/MobaCDREffect.java | 22 ++ .../moba/shop/effects/MobaKillHealEffect.java | 21 ++ .../moba/structure/point/CapturePoint.java | 6 + .../point/CapturePointCaptureEvent.java | 3 - 32 files changed, 1442 insertions(+), 186 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 36e6b1158..98f5a29a7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -17,12 +17,15 @@ 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.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.*; import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath; +import nautilus.game.arcade.game.games.moba.kit.bob.HeroBob; import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana; import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.recall.Recall; +import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.modules.compass.CompassModule; @@ -59,6 +62,9 @@ public class Moba extends TeamGame private final Set _listeners = new HashSet<>(); + private final MobaShop _shop; + private final GoldManager _goldManager; + public Moba(ArcadeManager manager) { super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION); @@ -68,6 +74,7 @@ public class Moba extends TeamGame new HeroDevon(Manager), new HeroAnath(Manager), new HeroDana(Manager), + new HeroBob(Manager) }; PrepareAutoAnnounce = false; @@ -92,6 +99,14 @@ public class Moba extends TeamGame Listener recall = new Recall(this); _listeners.add(recall); + MobaShop shop = new MobaShop(this); + _shop = shop; + _listeners.add(shop); + + GoldManager goldManager = new GoldManager(this); + _goldManager = goldManager; + _listeners.add(goldManager); + registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) { @Override @@ -356,7 +371,7 @@ public class Moba extends TeamGame continue; } - HeroKit heroKit = getRandomKit(player); + HeroKit heroKit = getFirstKit(player); MobaPlayer mobaPlayer = getData(player); mobaPlayer.Role = heroKit.getRole(); @@ -543,7 +558,7 @@ public class Moba extends TeamGame return null; } - private HeroKit getRandomKit(Player player) + private HeroKit getFirstKit(Player player) { MobaPlayer mobaPlayer = getData(player); @@ -551,17 +566,17 @@ public class Moba extends TeamGame { MobaRole role = getRandomRole(player); - return getRandomKit(role); + return getFirstKit(role); } else if (mobaPlayer.Kit == null) { - return getRandomKit(mobaPlayer.Role); + return getFirstKit(mobaPlayer.Role); } return null; } - private HeroKit getRandomKit(MobaRole role) + private HeroKit getFirstKit(MobaRole role) { for (HeroKit kit : _kits) { @@ -607,4 +622,19 @@ public class Moba extends TeamGame return players; } + + public List getCapturePoints() + { + return _capturePoints; + } + + public MobaShop getShop() + { + return _shop; + } + + public GoldManager getGoldManager() + { + return _goldManager; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java new file mode 100644 index 000000000..cfd386e62 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -0,0 +1,135 @@ +package nautilus.game.arcade.game.games.moba.gold; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.DebugCommand; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +public class GoldManager implements Listener +{ + + private static final int GOLD_PER_5 = 20; + private static final int GOLD_PER_CAPTURE_5 = 5; + + private final Moba _host; + + private final Map _playerGold; + + public GoldManager(Moba host) + { + _host = host; + + _playerGold = new HashMap<>(); + + host.registerDebugCommand(new DebugCommand("gold", Rank.ADMIN) + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + caller.sendMessage(F.main("Debug", "/gold ")); + return; + } + + try + { + int amount = Integer.parseInt(args[0]); + + addGold(caller, amount); + caller.sendMessage(F.main("Debug", "Gave yourself " + F.elem(args[0]) + " gold.")); + } + catch (NumberFormatException e) + { + caller.sendMessage(F.main("Debug", F.elem(args[0]) + " is not a number.")); + } + } + }); + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (Player player : _host.GetPlayers(true)) + { + _playerGold.put(player, 0); + } + } + + @EventHandler + public void passiveGain(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC_05 || !_host.IsLive()) + { + return; + } + + // Every player passive + for (Player player : _host.GetPlayers(true)) + { + addGold(player, GOLD_PER_5); + } + + // Capture points + for (CapturePoint point : _host.getCapturePoints()) + { + GameTeam owner = point.getOwner(); + + if (owner == null) + { + continue; + } + + for (Player player : owner.GetPlayers(true)) + { + addGold(player, GOLD_PER_CAPTURE_5); + } + } + } + + public void addGold(Player player, int amount) + { + _playerGold.put(player, _playerGold.get(player) + amount); + } + + public void removeGold(Player player, int amount) + { + _playerGold.put(player, _playerGold.get(player) - amount); + } + + public boolean hasGold(Player player, int amount) + { + return _playerGold.get(player) >= amount; + } + + /** + * Returns a map binding the player to the amount of gold they currently have. + * + * @return An unmodifiable version of the internal map used. If you want to edit the player's gold consider using the other methods within this class. + */ + public Map getPlayerGoldMap() + { + return Collections.unmodifiableMap(_playerGold); + } + + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java new file mode 100644 index 000000000..93c0cee45 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class CooldownCalculateEvent extends PlayerEvent +{ + + private static final HandlerList _handlers = new HandlerList(); + + private final long _initialCooldown; + private long _cooldown; + + public CooldownCalculateEvent(Player who, long cooldown) + { + super(who); + + _initialCooldown = cooldown; + _cooldown = cooldown; + } + + public void setCooldown(long cooldown) + { + _cooldown = cooldown; + } + + public void decreaseCooldown(double factor) + { + _cooldown = (long) ((double) _initialCooldown * factor); + } + + public long getCooldown() + { + return _cooldown; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index bdb8dc67d..cf31fe78e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -2,13 +2,18 @@ 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.kit.common.SkillBow; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; +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; @@ -19,6 +24,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 { @@ -140,7 +147,10 @@ public class HeroKit extends Kit inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(RECALL_SLOT, RECALL_ITEM); - for (Perk perk : GetPerks()) + Moba host = (Moba) Manager.GetGame(); + List ownedItems = host.getShop().getOwnedItems(player); + + perkLoop: for (Perk perk : GetPerks()) { if (!(perk instanceof HeroSkill)) { @@ -149,7 +159,39 @@ public class HeroKit extends Kit HeroSkill skill = (HeroSkill) perk; - skill.giveItem(player); + // Sword upgrades + if (skill instanceof SkillSword) + { + for (MobaItem item : ownedItems) + { + if (UtilItem.isSword(item.getItem())) + { + player.getInventory().setItem(skill.getSlot(), item.getItem()); + continue perkLoop; + } + } + } + // Bow upgrades + else if (skill instanceof SkillBow) + { + for (MobaItem item : ownedItems) + { + if (item.getItem().getType() == Material.BOW) + { + player.getInventory().setItem(skill.getSlot(), item.getItem()); + continue perkLoop; + } + } + } + + if (skill.isOnCooldown(player)) + { + player.getInventory().setItem(skill.getSlot(), skill.getCooldownItem()); + } + else + { + skill.giveItem(player); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 6a63a8db3..991e2afe5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -240,7 +240,11 @@ public class HeroSkill extends Perk long start = _lastSkill.get(player.getUniqueId()); long cooldown = _cooldown; - //TODO Shop cooldown reduction + // Modify the cooldown with respect to the upgrade items purchased from the shop + CooldownCalculateEvent cooldownEvent = new CooldownCalculateEvent(player, cooldown); + UtilServer.CallEvent(cooldownEvent); + + cooldown = cooldownEvent.getCooldown(); boolean done = UtilTime.elapsed(start, cooldown); @@ -338,6 +342,11 @@ public class HeroSkill extends Perk return _slot; } + public ItemStack getCooldownItem() + { + return _cooldownItem; + } + public boolean isOnCooldown(Player player) { return _lastSkill.containsKey(player.getUniqueId()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java index 5c65b976a..e51aa1004 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java @@ -41,11 +41,5 @@ public class SkillFlameDash extends DashSkill Block fBlock = block; Manager.runSyncLater(() -> Manager.GetBlockRestore().add(fBlock.getRelative(BlockFace.UP), Material.FIRE.getId(), (byte) 0, 5000), 10); } - - @Override - public void postDash(Player player) - { - Manager.GetBlockRestore().restore(player.getLocation().getBlock()); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java new file mode 100644 index 000000000..82ad6b064 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.moba.kit.bob; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroBob extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new SkillPaint(0), + new SkillHappyTrees(1), + new SkillBeatTheDevil(2), + new SkillBuildPainting(3) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.PAINTING); + + private static final ItemStack AMMO = new ItemBuilder(Material.SNOW_BALL) + .setTitle(C.cYellowB + "Paint") + .build(); + + public HeroBob(ArcadeManager manager) + { + super(manager, "Robert Ross", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); + + setAmmo(AMMO, 500); + setMaxAmmo(8); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java new file mode 100644 index 000000000..596b43a76 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java @@ -0,0 +1,47 @@ +package nautilus.game.arcade.game.games.moba.kit.bob; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class SkillBeatTheDevil extends DashSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving fire behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillBeatTheDevil(int slot) + { + super("Beat The Devil Out Of It", DESCRIPTION, SKILL_ITEM, slot); + + setCooldown(12000); + + _collide = false; + _velocityTime = 800; + _velocityStopOnEnd = true; + } + + @Override + public void dashTick(Player player) + { + player.getWorld().playSound(player.getLocation(), player.getTicksLived() % 2 == 0 ? Sound.DOOR_OPEN : Sound.DOOR_CLOSE, 1, 0.5F); + + for (int i = 0; i < 10; i++) + { + UtilParticle.playColoredParticleToAll(Color.RED, ParticleType.RED_DUST, UtilAlg.getRandomLocation(player.getLocation().add(0, 1, 0), 2), 1, ViewDist.LONG); + } + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java new file mode 100644 index 000000000..63a42f160 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java @@ -0,0 +1,206 @@ +package nautilus.game.arcade.game.games.moba.kit.bob; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.HashSet; +import java.util.Map.Entry; +import java.util.Set; + +public class SkillBuildPainting extends HeroSkill implements IThrown +{ + + private static final String[] DESCRIPTION = { + "Bob Ross" + }; + private static final BlockFace[] AXIS = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST }; + private static final byte[][] PAINTING = { + { + 3, 3, 3, 3, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3 + }, + { + 3, 3, 0, 0, 0, 0, 3, 3, 0, 0, 0, 3, 3, 3, 3 + }, + { + 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 3, 3 + }, + { + 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 13, 3 + }, + { + 3, 3, 0, 0, 0, 3, 3, 3, 5, 3, 3, 13, 3, 13, 3 + }, + { + 3, 3, 8, 8, 8, 8, 3, 5, 5, 5, 3, 13, 13, 13, 13 + }, + { + 3, 3, 8, 8, 8, 8, 3, 3, 12, 3, 13, 13, 13, 13, 13 + }, + { + 3, 3, 7, 7, 7, 7, 7, 3, 12, 3, 3, 12, 3, 12, 3 + }, + { + 5, 7, 7, 7, 7, 7, 7, 5, 12, 5, 5, 12, 5, 12, 5 + } + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + + public SkillBuildPainting(int slot) + { + super("The Joy Of Painting", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(60000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + if (!Recharge.Instance.use(player, GetName() + " Trigger", 5000, false, false)) + { + return; + } + + useActiveSkill(player, 4000); + + Set blocks = new HashSet<>(); + + Vector direction = player.getLocation().getDirection().normalize().setY(0); + Location start = player.getLocation().add(direction); + BlockFace facing = getFace(start.getYaw() + 180F); + Block center = start.getBlock().getRelative(facing).getRelative(BlockFace.UP); + + float leftYaw = start.getYaw() - 90; + BlockFace leftSide = getFace(leftYaw); + + for (int i = 0; i < 7; i++) + { + center = center.getRelative(leftSide); + } + + BlockFace rightSide = leftSide.getOppositeFace(); + + // Rows + for (int y = 0; y < PAINTING.length; y++) + { + byte[] row = PAINTING[y]; + + // Column in row + for (int x = 0; x < row.length; x++) + { + Block result = center; + + for (int i = 0; i < x; i++) + { + result = result.getRelative(rightSide); + } + + result = result.getRelative(0, 8, 0); + + for (int i = 0; i < y; i++) + { + result = result.getRelative(BlockFace.DOWN); + } + + Block fResult = result; + byte blockData = row[x]; + + Manager.runSyncLater(() -> + { + blocks.add(fResult); + Manager.GetBlockRestore().add(fResult, Material.WOOL.getId(), blockData, Long.MAX_VALUE); + + }, UtilMath.r(40)); + } + } + + Manager.runSyncLater(() -> + { + for (Block block : blocks) + { + if (Math.random() < 0.2) + { + FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().add(0.5, 0.5, 0.5), block.getType(), block.getData()); + + fallingBlock.setVelocity(direction.clone().multiply(1 + (Math.random() * 0.4))); + Manager.GetProjectile().AddThrow(fallingBlock, player, this, 2000, true, true, true, false, 0.5F); + } + + Manager.GetBlockRestore().restore(block); + } + }, 80); + } + + @EventHandler + public void itemSpawn(ItemSpawnEvent event) + { + if (event.getEntity().getItemStack().getType() == Material.WOOL) + { + event.setCancelled(true); + } + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + damage(data); + } + + @Override + public void Idle(ProjectileUser data) + { + + } + + @Override + public void Expire(ProjectileUser data) + { + damage(data); + } + + private void damage(ProjectileUser data) + { + Entity entity = data.getThrown(); + data.getThrown().getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, Material.WOOL, (byte) 0); + + for (Entry entry : UtilEnt.getInRadius(entity.getLocation(), 3).entrySet()) + { + Manager.GetDamage().NewDamageEvent(entry.getKey(), data.getThrower(), null, DamageCause.BLOCK_EXPLOSION, 5, true, true, false, UtilEnt.getName(data.getThrower()), GetName()); + } + + data.getThrown().remove(); + } + + private BlockFace getFace(float yaw) + { + return AXIS[Math.round(yaw / 90F) & 0x3]; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java new file mode 100644 index 000000000..3b429be01 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java @@ -0,0 +1,174 @@ +package nautilus.game.arcade.game.games.moba.kit.bob; + +import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.*; +import java.util.Map.Entry; + +public class SkillHappyTrees extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Bob Ross" + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.SAPLING); + + private final Set _data = new HashSet<>(); + + public SkillHappyTrees(int slot) + { + super("Happy Little Trees", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(15000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + _data.add(new HappyTreeData(player)); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + Iterator iterator = _data.iterator(); + + while (iterator.hasNext()) + { + HappyTreeData data = iterator.next(); + + if (UtilTime.elapsed(data.Start, 9000)) + { + iterator.remove(); + } + else if (data.Tree1 == null) + { + data.Tree1 = buildTree(data.Center); + } + else if (data.Tree2 == null) + { + data.Tree2 = buildTree(data.Center); + } + + if (UtilTime.elapsed(data.Start, 2000)) + { + healPlayers(data.Owner, data.Tree1); + healPlayers(data.Owner, data.Tree2); + } + } + } + + private Block buildTree(Location center) + { + Location start = UtilAlg.getRandomLocation(center, 5, 0, 5); + Map blocks = getTree(start); + + for (Entry entry : blocks.entrySet()) + { + Manager.runSyncLater(() -> Manager.GetBlockRestore().add(entry.getKey(), entry.getValue().getId(), (byte) 0, (long) (6000 + (Math.random() * 1000))), UtilMath.r(60)); + } + + return start.getBlock(); + } + + private Map getTree(Location start) + { + Block last = start.getBlock().getRelative(BlockFace.DOWN); + Map blocks = new HashMap<>(); + + // Trunk + for (int i = 0; i < 5; i++) + { + Block next = last.getRelative(BlockFace.UP); + last = next; + blocks.put(next, Material.LOG); + } + + last = last.getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN); + + // Bottom Leaves + for (Block block : UtilBlock.getInBoundingBox(last.getLocation().add(2, 1, 2), last.getLocation().subtract(2, 0, 2), false)) + { + blocks.put(block, Material.LEAVES); + } + + last = last.getRelative(BlockFace.UP).getRelative(BlockFace.UP); + + // Middle Leaves + for (Block block : UtilBlock.getInBoundingBox(last.getLocation().add(1, 0, 1), last.getLocation().subtract(1, 0, 1), false)) + { + blocks.put(block, Material.LEAVES); + } + + last = last.getRelative(BlockFace.UP); + + // Top Leaves + blocks.put(last.getRelative(BlockFace.NORTH), Material.LEAVES); + blocks.put(last.getRelative(BlockFace.WEST), Material.LEAVES); + blocks.put(last.getRelative(BlockFace.EAST), Material.LEAVES); + blocks.put(last.getRelative(BlockFace.SOUTH), Material.LEAVES); + blocks.put(last.getRelative(BlockFace.UP), Material.LEAVES); + + return blocks; + } + + private void healPlayers(Player owner, Block block) + { + for (LivingEntity entity : UtilEnt.getInRadius(block.getLocation(), 5).keySet()) + { + // Don't heal enemies + if (!isTeamDamage(entity, owner)) + { + continue; + } + + entity.setHealth(Math.min(entity.getHealth() + 2, entity.getMaxHealth())); + UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 4, ViewDist.LONG); + } + } + + private class HappyTreeData + { + public Player Owner; + public long Start; + public Location Center; + public Block Tree1; + public Block Tree2; + + public HappyTreeData(Player owner) + { + Owner = owner; + Start = System.currentTimeMillis(); + Center = owner.getLocation(); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java new file mode 100644 index 000000000..df990d0dd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java @@ -0,0 +1,100 @@ +package nautilus.game.arcade.game.games.moba.kit.bob; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Snowball; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.Random; + +public class SkillPaint extends HeroSkill implements IThrown +{ + + private static final String[] DESCRIPTION = { + "Bob Ross" + }; + private static final byte[] COLOURS = { 14, 1, 4, 5, 3, 11, 0}; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.DIAMOND_BARDING); + + public SkillPaint(int slot) + { + super("1-Inch Brush", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + if (!_kit.useAmmo(player, 1)) + { + return; + } + + useSkill(player); + + Snowball snowball = player.launchProjectile(Snowball.class); + + Manager.GetProjectile().AddThrow(snowball, player, this, -1, true, true, true, false, 0.5F); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Player thrower = (Player) data.getThrower(); + Random random = UtilMath.random; + + if (target != null) + { + thrower.playSound(thrower.getLocation(), Sound.LAVA_POP, 1, 1.3F); + Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.PROJECTILE, 2, true, true, false, UtilEnt.getName(thrower), GetName()); + } + + for (Block nearby : UtilBlock.getBlocksInRadius(data.getThrown().getLocation(), 2)) + { + if (UtilBlock.airFoliage(nearby)) + { + continue; + } + + Manager.GetBlockRestore().add(nearby, Material.STAINED_CLAY.getId(), COLOURS[random.nextInt(COLOURS.length)], (long) (3000 + (Math.random() * 500))); + } + + for (LivingEntity entity : UtilEnt.getInRadius(data.getThrown().getLocation(), 2).keySet()) + { + Manager.GetDamage().NewDamageEvent(entity, thrower, (Projectile) data.getThrown(), DamageCause.PROJECTILE, 2, true, true, false, UtilEnt.getName(thrower), GetName()); + } + } + + @Override + public void Idle(ProjectileUser data) + { + + } + + @Override + public void Expire(ProjectileUser data) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java index 85952a767..b9e51c378 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -175,8 +175,13 @@ public class DashSkill extends HeroSkill LivingEntity entity = entry.getKey(); double scale = entry.getValue(); - // If player hit themselves or the entity has already been hit - if (player.equals(entity) || !Recharge.Instance.use(player, GetName() + " by " + player.getName(), 500, false, false) && _collideOnce) + // If player hit themselves + if (player.equals(entity)) + { + continue; + } + + if (!(entity instanceof Player) || !Recharge.Instance.use((Player) entity, GetName() + " by " + player.getName(), 500, false, false) && _collideOnce) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java index 7aa94f22a..864c35188 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java @@ -4,6 +4,7 @@ import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; public class SkillSword extends HeroSkill diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java index f4efd724e..f6ca20836 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java @@ -60,12 +60,12 @@ public class SkillDanaDash extends DashSkill if (entity instanceof Player) { damage = 10; - UtilAction.velocity(entity, new Vector(Math.random() / 2 - 0.25, 2, Math.random() / 2 - 0.25)); + UtilAction.velocity(entity, new Vector(Math.random() / 2 - 0.25, 1, Math.random() / 2 - 0.25)); } else { damage = 6; - UtilAction.velocity(entity, new Vector(Math.random() - 0.5, 1, Math.random() - 0.5)); + UtilAction.velocity(entity, new Vector(Math.random() - 0.5, 0.5, Math.random() - 0.5)); } entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_HIT, 1, 0.5F); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index cd5c004db..c0ac9b8a2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -73,7 +73,7 @@ public class SkillRally extends HeroSkill @EventHandler public void updateLand(UpdateEvent event) { - if (event.getType() != UpdateType.FASTEST) + if (event.getType() != UpdateType.TICK) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index 9f4fe1071..9e8546707 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -66,16 +66,12 @@ public class SkillNinjaBlade extends HeroSkill Player player = event.GetDamagerPlayer(false); Player damageePlayer = event.GetDamageePlayer(); - if (player != null && damageePlayer != null) + if (player == null || damageePlayer == null || isTeamDamage(damageePlayer, player)) { - Game game = Manager.GetGame(); - if (game.GetTeam(player).equals(game.GetTeam(damageePlayer))) - { - return; - } + return; } - if (player == null || !_active.contains(player.getUniqueId()) || player.getItemInHand() == null || player.getItemInHand().getType() != Material.DIAMOND_SWORD) + if (!_active.contains(player.getUniqueId()) || player.getItemInHand() == null || player.getItemInHand().getType() != Material.DIAMOND_SWORD) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 5ad950ee0..2d353db1c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -82,13 +82,11 @@ public class SkillSnowball extends HeroSkill implements IThrown @Override public void Idle(ProjectileUser data) { - data.getThrown().remove(); } @Override public void Expire(ProjectileUser data) { - data.getThrown().remove(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java new file mode 100644 index 000000000..7cabddd2a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java @@ -0,0 +1,50 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +public class MobaItem +{ + + private final ItemStack _item; + private final int _cost; + private List _effects; + + public MobaItem(ItemStack item, int cost) + { + _item = item; + _cost = cost; + } + + public MobaItem addEffects(MobaItemEffect... effects) + { + if (_effects == null) + { + _effects = new ArrayList<>(effects.length); + } + + for (MobaItemEffect effect : _effects) + { + _effects.add(effect); + } + return this; + } + + public ItemStack getItem() + { + return _item; + } + + public int getCost() + { + return _cost; + } + + public List getEffects() + { + return _effects; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java new file mode 100644 index 000000000..8af399784 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -0,0 +1,17 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import org.bukkit.entity.Player; + +public class MobaItemEffect +{ + + public void onCooldownCheck(CooldownCalculateEvent event) + { + } + + public void onDeath(Player killed, Player killer) + { + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java deleted file mode 100644 index b080347bb..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java +++ /dev/null @@ -1,89 +0,0 @@ -package nautilus.game.arcade.game.games.moba.shop; - -import mineplex.core.common.util.UtilUI; -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.MobaPlayer; -import nautilus.game.arcade.game.games.moba.kit.HeroKit; -import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; -import nautilus.game.arcade.kit.Perk; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.List; - -public class MobaMainMenu extends Menu -{ - - private static final int SLOTS = 27; - - private final MobaPlayer _player; - - public MobaMainMenu(MobaPlayer player, ArcadeManager plugin) - { - super(player.Kit.GetName() + " Shop", plugin); - - _player = player; - } - - @Override - protected Button[] setUp(Player player) - { - Button[] buttons = new Button[SLOTS]; - HeroKit kit = _player.Kit; - List skills = new ArrayList<>(3); - - for (Perk perk : kit.GetPerks()) - { - if (!(perk instanceof HeroSkill)) - { - continue; - } - - skills.add((HeroSkill) perk); - } - - int slots[] = UtilUI.getIndicesFor(skills.size(), 1, 3); - - for (HeroSkill skill : skills) - { - - } - - return buttons; - } - - private ItemStack getMainMenuItem(HeroSkill skill) - { - ItemBuilder builder; - - if (skill instanceof SkillSword) - { - builder = - } - } - - class MobaMainButton extends Button - { - - private MobaPlayer _player; - - public MobaMainButton(MobaPlayer player, ArcadeManager plugin) - { - super(item, plugin); - - _player = player; - } - - @Override - public void onClick(Player player, ClickType clickType) - { - - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index d40d78dd1..0518b8c21 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -1,10 +1,21 @@ package nautilus.game.arcade.game.games.moba.shop; +import mineplex.core.common.Rank; +import mineplex.core.common.util.*; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.CombatComponent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.moba.Moba; 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; +import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop; import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -13,22 +24,29 @@ import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import java.util.*; +import java.util.Map.Entry; public class MobaShop implements Listener { private final Moba _host; - private final List _entities; - private final Map> _upgrades; + private final Map _entities; + private final Map _roleMenus; + private final Map> _upgrades; public MobaShop(Moba host) { _host = host; - _entities = new ArrayList<>(2); + _entities = new HashMap<>(2); + _roleMenus = new HashMap<>(4); _upgrades = new HashMap<>(); + + // Create menus + _roleMenus.put(MobaRole.ASSASSIN, new MobaAssassinShop(host, this)); } @EventHandler @@ -41,6 +59,7 @@ public class MobaShop implements Listener List locations = _host.WorldData.GetDataLocs("CYAN"); + _host.CreatureAllowOverride = true; for (Location location : locations) { Villager villager = location.getWorld().spawn(location, Villager.class); @@ -48,20 +67,61 @@ public class MobaShop implements Listener villager.setProfession(Profession.LIBRARIAN); villager.setAgeLock(true); villager.setRemoveWhenFarAway(false); + villager.setCustomName(C.cGoldB + "GOLD UPGRADES"); + villager.setCustomNameVisible(true); + UtilEnt.vegetate(villager); + UtilEnt.silence(villager, true); + UtilEnt.CreatureForceLook(villager, 0, UtilAlg.GetYaw(UtilAlg.getTrajectory(villager.getLocation(), _host.GetSpectatorLocation()))); - _entities.add(villager); + _entities.put(villager, location); } - } - - public void purchaseUpgrade(Player player, MobaUpgrade upgrade) - { - _upgrades.putIfAbsent(player, new HashSet<>(3)); - _upgrades.get(player).add(upgrade); + _host.CreatureAllowOverride = false; } private void openShop(MobaPlayer player) { + MobaShopMenu menu = _roleMenus.get(player.Role); + if (menu == null) + { + player.Player.sendMessage(F.main("Game", "There isn't an upgrade shop for that kit yet.")); + return; + } + + menu.open(player.Player); + } + + @EventHandler + public void npcMove(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + for (Entry entry : _entities.entrySet()) + { + LivingEntity entity = entry.getKey(); + Location location = entry.getValue(); + + ((CraftLivingEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ()); + } + } + + @EventHandler + public void npcDamage(EntityDamageEvent event) + { + for (Entry entry : _entities.entrySet()) + { + LivingEntity entity = entry.getKey(); + + if (entity.equals(event.getEntity())) + { + entity.setFireTicks(0); + event.setCancelled(true); + return; + } + } } @EventHandler @@ -83,9 +143,9 @@ public class MobaShop implements Listener return; } - Player player = (Player) clicked; + Player player = (Player) clicker; - for (LivingEntity shop : _entities) + for (LivingEntity shop : _entities.keySet()) { if (clicked.equals(shop)) { @@ -93,6 +153,7 @@ public class MobaShop implements Listener if (data == null) { + player.sendMessage(F.main("Game", "You don't appear to have any data?")); return; } @@ -101,4 +162,93 @@ public class MobaShop implements Listener } } } + + public void purchaseItem(Player player, MobaItem item) + { + player.sendMessage(F.main("Game", "Purchased " + F.greenElem(item.getItem().getItemMeta().getDisplayName()) + ".")); + _host.getGoldManager().removeGold(player, item.getCost()); + _upgrades.get(player).add(item); + } + + public boolean ownsItem(Player player, MobaItem item) + { + return _upgrades.get(player).contains(item); + } + + public List getOwnedItems(Player player) + { + return _upgrades.get(player); + } + + /* + Handle MobaItem events + */ + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (Player player : _host.GetPlayers(true)) + { + _upgrades.put(player, new ArrayList<>()); + } + } + + @EventHandler + public void cooldownCalculate(CooldownCalculateEvent event) + { + Player player = event.getPlayer(); + List items = _upgrades.get(player); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onCooldownCheck(event); + } + } + } + + @EventHandler + public void combatDeath(CombatDeathEvent event) + { + CombatComponent component = event.GetLog().GetKiller(); + + if (component == null || !component.IsPlayer() || !(event.GetEvent().getEntity() instanceof Player)) + { + return; + } + + Player killed = (Player) event.GetEvent().getEntity(); + Player killer = UtilPlayer.searchExact(component.getUniqueIdOfEntity()); + + if (killer == null) + { + return; + } + + List items = _upgrades.get(killer); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onDeath(killed, killer); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java new file mode 100644 index 000000000..224433e3f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java @@ -0,0 +1,47 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import org.bukkit.inventory.ItemStack; + +import java.util.List; + +public class MobaShopCategory +{ + + private final String _name; + private final List _items; + private final ItemStack _menuItem; + private boolean _allowMultiple; + + public MobaShopCategory(String name, List items, ItemStack menuItem) + { + _name = name; + _items = items; + _menuItem = menuItem; + } + + public String getName() + { + return _name; + } + + public List getItems() + { + return _items; + } + + public ItemStack getMenuItem() + { + return _menuItem; + } + + public MobaShopCategory allowMultiple(boolean allow) + { + _allowMultiple = allow; + return this; + } + + public boolean isAllowingMultiple() + { + return _allowMultiple; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java new file mode 100644 index 000000000..3dd51cc3a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -0,0 +1,96 @@ +package nautilus.game.arcade.game.games.moba.shop; + +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.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +public class MobaShopCategoryMenu extends Menu +{ + + private static final int SLOTS = 27; + private static final int STARTING_SLOT = 10; + + private final Moba _host; + private final MobaShop _shop; + private final MobaShopCategory _category; + + public MobaShopCategoryMenu(Moba host, MobaShop shop, MobaShopCategory category, ArcadeManager plugin) + { + super(category.getName() + " Shop", plugin); + + _host = host; + _shop = shop; + _category = category; + } + + @Override + protected Button[] setUp(Player player) + { + Button[] buttons = new Button[SLOTS]; + int slot = STARTING_SLOT; + + for (MobaItem item : _category.getItems()) + { + ItemBuilder builder = new ItemBuilder(item.getItem()); + boolean owns = _shop.ownsItem(player, item); + boolean canPurchase = _host.getGoldManager().hasGold(player, item.getCost()); + + builder.setTitle((canPurchase ? C.cGreen : C.cRed) + item.getItem().getItemMeta().getDisplayName()); + + if (owns) + { + builder.addLore(C.cRed + "You already have purchased this upgrade"); + } + else + { + builder.addLore("Cost: " + C.cGold + item.getCost()); + + if (canPurchase) + { + builder.addLore(C.cGreen + "Click to purchase"); + } + else + { + builder.addLore(C.cRed + "You cannot afford this item."); + } + } + + buttons[slot++] = new MobaPurchaseButton(builder.build(), getPlugin(), item); + } + + return buttons; + } + + class MobaPurchaseButton extends Button + { + + private MobaItem _item; + + public MobaPurchaseButton(ItemStack itemStack, ArcadeManager plugin, MobaItem item) + { + super(itemStack, plugin); + + _item = item; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + boolean owns = _shop.ownsItem(player, _item); + boolean canPurchase = _host.getGoldManager().hasGold(player, _item.getCost()); + + if (!owns && canPurchase) + { + _shop.purchaseItem(player, _item); + player.closeInventory(); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java new file mode 100644 index 000000000..5c3d4582e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java @@ -0,0 +1,124 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilUI; +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 nautilus.game.arcade.game.games.moba.MobaRole; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +public class MobaShopMenu extends Menu +{ + + private static final int SLOTS = 27; + + private final Moba _host; + private final MobaShop _shop; + private final List _categories; + + public MobaShopMenu(Moba host, MobaShop shop, MobaRole role) + { + super(role.getName() + " Upgrade Shop", host.getArcadeManager()); + + _host = host; + _shop = shop; + _categories = new ArrayList<>(); + } + + protected void addCategory(MobaShopCategory category) + { + _categories.add(category); + } + + @Override + protected Button[] setUp(Player player) + { + Button[] buttons = new Button[SLOTS]; + int[] slots = UtilUI.getIndicesFor(_categories.size(), 1); + int slot = 0; + + for (MobaShopCategory category : _categories) + { + ItemBuilder builder; + MobaItem owned = null; + + for (MobaItem item : category.getItems()) + { + if (_shop.ownsItem(player, item)) + { + owned = item; + break; + } + } + + if (owned == null) + { + builder = new ItemBuilder(category.getMenuItem()); + } + else + { + builder = new ItemBuilder(owned.getItem()); + } + + builder.setTitle(C.cGreen + category.getName()); + builder.addLore("", "Not sure what to put here", ""); + + if (category.isAllowingMultiple()) + { + builder.addLore(C.cWhite + "Current Upgrades:"); + boolean ownsAtLeastOne = false; + + for (MobaItem item : category.getItems()) + { + if (_shop.ownsItem(player, item)) + { + ownsAtLeastOne = true; + builder.addLore(" - " + item.getItem().getItemMeta().getDisplayName()); + } + } + + if (!ownsAtLeastOne) + { + builder.addLore(" - None"); + } + } + else + { + builder.addLore(C.cWhite + "Current Upgrade: " + (owned == null ? C.cGray + "None" : owned.getItem().getItemMeta().getDisplayName())); + } + + builder.addLore("", C.cYellow + "Click to view the upgrades."); + + buttons[slots[slot++]] = new MobaCategoryButton(builder.build(), getPlugin(), category); + } + + return buttons; + } + + class MobaCategoryButton extends Button + { + + private MobaShopCategory _category; + + public MobaCategoryButton(ItemStack itemStack, ArcadeManager plugin, MobaShopCategory category) + { + super(itemStack, plugin); + + _category = category; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + new MobaShopCategoryMenu(_host, _shop, _category, getPlugin()).open(player); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java deleted file mode 100644 index 55312fdc6..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java +++ /dev/null @@ -1,19 +0,0 @@ -package nautilus.game.arcade.game.games.moba.shop; - -import org.bukkit.inventory.ItemStack; - -public class MobaUpgrade -{ - - private ItemStack _item; - - public MobaUpgrade(ItemStack item) - { - _item = item; - } - - public ItemStack getItem() - { - return _item; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java deleted file mode 100644 index 432e868a8..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java +++ /dev/null @@ -1,13 +0,0 @@ -package nautilus.game.arcade.game.games.moba.shop; - -public enum MobaUpgradeType -{ - - SWORD, - BOW, - HELMET, - CHEST, - LEGS, - BOOTS - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java new file mode 100644 index 000000000..5908c9c6a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java @@ -0,0 +1,43 @@ +package nautilus.game.arcade.game.games.moba.shop.assassin; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +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.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 org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; + +public class MobaAssassinShop extends MobaShopMenu +{ + + private static final MobaShopCategory SWORD = new MobaShopCategory("Sword", Arrays.asList( + new MobaItem(new ItemBuilder(Material.GOLD_SWORD) + .setTitle(C.cGreenB + "Sword of Time") + .build(), 800) + .addEffects( + new MobaKillHealEffect(3) + ), + new MobaItem(new ItemBuilder(Material.IRON_SWORD) + .setTitle(C.cYellowB + "Adventurer's Sword") + .build(), 1000), + new MobaItem(new ItemBuilder(Material.DIAMOND_SWORD) + .setTitle(C.cDRedB + "Pumpkin King's Blade") + .addEnchantment(Enchantment.DAMAGE_ALL, 3) + .build(), 1750) + ), new ItemStack(Material.WOOD_SWORD)); + + public MobaAssassinShop(Moba host, MobaShop shop) + { + super(host, shop, MobaRole.ASSASSIN); + + addCategory(SWORD); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java deleted file mode 100644 index 0c7d0c84c..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java +++ /dev/null @@ -1,22 +0,0 @@ -package nautilus.game.arcade.game.games.moba.shop.common; - -import nautilus.game.arcade.game.games.moba.shop.MobaUpgrade; -import org.bukkit.inventory.ItemStack; - -public class CooldownUpgrade extends MobaUpgrade -{ - - private double _reductionFactor; - - public CooldownUpgrade(ItemStack item, double reductionFactor) - { - super(item); - - _reductionFactor = reductionFactor; - } - - public double getReductionFactor() - { - return _reductionFactor; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java new file mode 100644 index 000000000..ea6b08db8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java @@ -0,0 +1,22 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +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 +{ + + private double _factor; + + public MobaCDREffect(double factor) + { + _factor = factor; + } + + @Override + public void onCooldownCheck(CooldownCalculateEvent event) + { + event.decreaseCooldown(_factor); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java new file mode 100644 index 000000000..4aaca0a0c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -0,0 +1,21 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import org.bukkit.entity.Player; + +public class MobaKillHealEffect extends MobaItemEffect +{ + + private double _health; + + public MobaKillHealEffect(double health) + { + _health = health; + } + + @Override + public void onDeath(Player killed, Player killer) + { + killer.setHealth(Math.min(killer.getMaxHealth(), killer.getHealth() + _health)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index 3c5167baa..c97b92bee 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -168,6 +168,12 @@ public class CapturePoint private void setOwner(GameTeam team) { + // Same team + if (_owner != null && _owner.equals(team)) + { + return; + } + _owner = team; setBeaconColour(team); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java index 4383350aa..c7443a151 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java @@ -1,11 +1,8 @@ package nautilus.game.arcade.game.games.moba.structure.point; -import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import java.util.List; - public class CapturePointCaptureEvent extends Event { From 50da7139476a989b3a6555ad7733917749bb8405 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 8 May 2017 22:01:27 +0100 Subject: [PATCH 013/283] Remove the previous upgrade when switching upgrades --- .../game/games/moba/gold/GoldManager.java | 12 ++++++ .../arcade/game/games/moba/kit/HeroKit.java | 38 +---------------- .../game/games/moba/kit/common/SkillBow.java | 23 ++++++++++ .../games/moba/kit/common/SkillSword.java | 24 +++++++++++ .../arcade/game/games/moba/shop/MobaShop.java | 42 +++++++++++++++---- .../games/moba/shop/MobaShopCategoryMenu.java | 8 ++-- .../game/games/moba/shop/MobaShopMenu.java | 5 +++ 7 files changed, 103 insertions(+), 49 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index cfd386e62..79edc6baa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -13,6 +13,7 @@ import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; import java.util.Collections; import java.util.HashMap; @@ -74,6 +75,12 @@ public class GoldManager implements Listener } } + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _playerGold.remove(event.getPlayer()); + } + @EventHandler public void passiveGain(UpdateEvent event) { @@ -105,6 +112,11 @@ public class GoldManager implements Listener } } + public int getGold(Player player) + { + return _playerGold.get(player); + } + public void addGold(Player player, int amount) { _playerGold.put(player, _playerGold.get(player) + amount); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index cf31fe78e..ce57121ca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -2,30 +2,22 @@ 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.kit.common.SkillBow; -import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; -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; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -import java.util.List; - public class HeroKit extends Kit { @@ -147,10 +139,7 @@ public class HeroKit extends Kit inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(RECALL_SLOT, RECALL_ITEM); - Moba host = (Moba) Manager.GetGame(); - List ownedItems = host.getShop().getOwnedItems(player); - - perkLoop: for (Perk perk : GetPerks()) + for (Perk perk : GetPerks()) { if (!(perk instanceof HeroSkill)) { @@ -159,31 +148,6 @@ public class HeroKit extends Kit HeroSkill skill = (HeroSkill) perk; - // Sword upgrades - if (skill instanceof SkillSword) - { - for (MobaItem item : ownedItems) - { - if (UtilItem.isSword(item.getItem())) - { - player.getInventory().setItem(skill.getSlot(), item.getItem()); - continue perkLoop; - } - } - } - // Bow upgrades - else if (skill instanceof SkillBow) - { - for (MobaItem item : ownedItems) - { - if (item.getItem().getType() == Material.BOW) - { - player.getInventory().setItem(skill.getSlot(), item.getItem()); - continue perkLoop; - } - } - } - if (skill.isOnCooldown(player)) { player.getInventory().setItem(skill.getSlot(), skill.getCooldownItem()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java index 3ce67db5e..3edfe97a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java @@ -1,9 +1,14 @@ package nautilus.game.arcade.game.games.moba.kit.common; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.shop.MobaItem; import org.bukkit.Material; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.List; + public class SkillBow extends HeroSkill { @@ -17,4 +22,22 @@ public class SkillBow extends HeroSkill { super("Bow", DESCRIPTION, SKILL_ITEM, slot, null); } + + @Override + public void giveItem(Player player) + { + Moba host = (Moba) Manager.GetGame(); + List ownedItems = host.getShop().getOwnedItems(player); + + for (MobaItem item : ownedItems) + { + if (item.getItem().getType() == Material.BOW) + { + player.getInventory().setItem(getSlot(), item.getItem()); + return; + } + } + + player.getInventory().setItem(getSlot(), SKILL_ITEM); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java index 864c35188..8b892c4eb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java @@ -1,12 +1,18 @@ package nautilus.game.arcade.game.games.moba.kit.common; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilItem; import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.shop.MobaItem; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.List; + public class SkillSword extends HeroSkill { @@ -23,4 +29,22 @@ public class SkillSword extends HeroSkill { super("Sword", DESCRIPTION, SKILL_ITEM, slot, null); } + + @Override + public void giveItem(Player player) + { + Moba host = (Moba) Manager.GetGame(); + List ownedItems = host.getShop().getOwnedItems(player); + + for (MobaItem item : ownedItems) + { + if (UtilItem.isSword(item.getItem())) + { + player.getInventory().setItem(getSlot(), item.getItem()); + return; + } + } + + player.getInventory().setItem(getSlot(), SKILL_ITEM); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 0518b8c21..fd0933d45 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -1,18 +1,18 @@ package nautilus.game.arcade.game.games.moba.shop; -import mineplex.core.common.Rank; import mineplex.core.common.util.*; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; 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.game.DebugCommand; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.moba.Moba; 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; +import nautilus.game.arcade.game.games.moba.shop.MobaShopMenu.MobaCategoryButton; import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; @@ -22,6 +22,7 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; @@ -109,16 +110,14 @@ public class MobaShop implements Listener } @EventHandler - public void npcDamage(EntityDamageEvent event) + public void npcDamage(CustomDamageEvent event) { - for (Entry entry : _entities.entrySet()) + for (LivingEntity entity : _entities.keySet()) { - LivingEntity entity = entry.getKey(); - - if (entity.equals(event.getEntity())) + if (entity.equals(event.GetDamageeEntity())) { entity.setFireTicks(0); - event.setCancelled(true); + event.SetCancelled("Shop NPC"); return; } } @@ -165,9 +164,18 @@ public class MobaShop implements Listener public void purchaseItem(Player player, MobaItem item) { + List owned = _upgrades.get(player); + MobaShopCategory category = getCategory(item); + + if (!category.isAllowingMultiple()) + { + owned.removeIf(previousItem -> getCategory(previousItem) == category); + } + player.sendMessage(F.main("Game", "Purchased " + F.greenElem(item.getItem().getItemMeta().getDisplayName()) + ".")); _host.getGoldManager().removeGold(player, item.getCost()); - _upgrades.get(player).add(item); + owned.add(item); + _host.GetKit(player).ApplyKit(player); } public boolean ownsItem(Player player, MobaItem item) @@ -180,6 +188,22 @@ public class MobaShop implements Listener return _upgrades.get(player); } + private MobaShopCategory getCategory(MobaItem item) + { + for (MobaShopMenu menu : _roleMenus.values()) + { + for (MobaShopCategory category : menu.getCategories()) + { + if (category.getItems().contains(item)) + { + return category; + } + } + } + + return null; + } + /* Handle MobaItem events */ diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java index 3dd51cc3a..69477ad5b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -41,20 +41,22 @@ public class MobaShopCategoryMenu extends Menu ItemBuilder builder = new ItemBuilder(item.getItem()); boolean owns = _shop.ownsItem(player, item); boolean canPurchase = _host.getGoldManager().hasGold(player, item.getCost()); + int gold = _host.getGoldManager().getGold(player); builder.setTitle((canPurchase ? C.cGreen : C.cRed) + item.getItem().getItemMeta().getDisplayName()); + builder.addLore(""); if (owns) { - builder.addLore(C.cRed + "You already have purchased this upgrade"); + builder.addLore(C.cRed + "You already have purchased this upgrade."); } else { - builder.addLore("Cost: " + C.cGold + item.getCost()); + builder.addLore(C.cWhite + "Cost: " + C.cGold + item.getCost(), C.cWhite + "Your Gold: " + C.cGold + gold, ""); if (canPurchase) { - builder.addLore(C.cGreen + "Click to purchase"); + builder.addLore(C.cGreen + "Click to purchase."); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java index 5c3d4582e..515445f82 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java @@ -121,4 +121,9 @@ public class MobaShopMenu extends Menu new MobaShopCategoryMenu(_host, _shop, _category, getPlugin()).open(player); } } + + public List getCategories() + { + return _categories; + } } From 5f7574a0affa231b69a1d8edfee9921bf33dda51 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 8 May 2017 22:07:14 +0100 Subject: [PATCH 014/283] Increase particles displayed when selecting a kit --- .../game/arcade/game/games/moba/kit/PregameSelection.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java index cc620307f..168e0a97e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java @@ -132,7 +132,8 @@ public class PregameSelection implements Listener, IPacketHandler // stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); // stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); // stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); - UtilParticle.PlayParticle(ParticleType.CLOUD, location.clone().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 1, ViewDist.LONG, player); + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 0.5F); + UtilParticle.PlayParticle(ParticleType.CLOUD, location.clone().add(0, 2, 0), 0.5F, 0.5F, 0.5F, 0.01F, 20, ViewDist.LONG, player); _kitStands.put(stand, kit); From eec8e5143d7d7cc5eeebc27598382e5ea07a2099 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 9 May 2017 23:16:34 +0100 Subject: [PATCH 015/283] Per player scoreboards --- .../nautilus/game/arcade/ArcadeManager.java | 5 + .../src/nautilus/game/arcade/game/Game.java | 1 + .../game/arcade/game/games/moba/Moba.java | 45 +++- .../games/moba/shop/MobaShopCategoryMenu.java | 6 + .../game/modules/CustomScoreboardModule.java | 200 ++++++++++++++++++ .../game/arcade/managers/GameManager.java | 9 +- .../arcade/managers/GamePlayerManager.java | 19 +- .../arcade/managers/lobby/LobbyManager.java | 10 +- .../arcade/scoreboard/GameScoreboard.java | 9 +- 9 files changed, 280 insertions(+), 24 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 20c226a03..9cce4fec6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -416,6 +416,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation @Override public void handlePlayerJoin(String playerName) { + if (GetGame() != null && GetGame().GetState() != GameState.Loading && GetGame().GetState() != GameState.Recruit && GetGame().UseCustomScoreboard) + { + return; + } + CoreClient client = GetClients().Get(playerName); for (MineplexScoreboard scoreboard : getScoreboards().values()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 74f2baf73..26aacf6fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -177,6 +177,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed // Scoreboard protected GameScoreboard Scoreboard; + public boolean UseCustomScoreboard = false; // Loaded from Map Config public WorldData WorldData = null; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 98f5a29a7..a9f1c238c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -28,6 +28,7 @@ import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; @@ -77,22 +78,15 @@ public class Moba extends TeamGame new HeroBob(Manager) }; + DontAllowOverfill = true; PrepareAutoAnnounce = false; PrepareFreeze = false; PrepareTime = PREPARE_TIME; DeathOut = false; DeathSpectateSecs = 10; HungerSet = 20; - DontAllowOverfill = true; - DamageFall = false; - new CompassModule() - .setGiveCompass(true) - .setGiveCompassToSpecs(true) - .setGiveCompassToAlive(false) - .register(this); - Listener preGameSelection = new PregameSelection(this); _listeners.add(preGameSelection); @@ -107,6 +101,37 @@ public class Moba extends TeamGame _goldManager = goldManager; _listeners.add(goldManager); + new CompassModule() + .setGiveCompass(true) + .setGiveCompassToSpecs(true) + .setGiveCompassToAlive(false) + .register(this); + + new CustomScoreboardModule() + .setSidebar((player, scoreboard) -> + { + scoreboard.writeNewLine(); + + scoreboard.write("Testing"); + + int gold = _goldManager.getGold(player); + scoreboard.write("Gold " + gold); + + scoreboard.writeNewLine(); + }) + .setPrefix((perspective, subject) -> + { + if (!IsAlive(subject)) + { + return C.cGray; + } + + GameTeam team = GetTeam(subject); + + return team.GetColor().toString(); + }) + .register(this); + registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) { @Override @@ -114,9 +139,9 @@ public class Moba extends TeamGame { String kit = ""; - for (int i = 0; i < args.length; i++) + for (String arg : args) { - kit += args[i] + " "; + kit += arg + " "; } kit = kit.trim(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java index 69477ad5b..5a6ed5f70 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -7,6 +7,7 @@ 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.Sound; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; @@ -90,9 +91,14 @@ public class MobaShopCategoryMenu extends Menu if (!owns && canPurchase) { + player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 1.6F); _shop.purchaseItem(player, _item); player.closeInventory(); } + else + { + player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0.6F); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java new file mode 100644 index 000000000..a14c40e36 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java @@ -0,0 +1,200 @@ +package nautilus.game.arcade.game.modules; + +import mineplex.core.common.util.C; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.scoreboard.GameScoreboard; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.scoreboard.Scoreboard; +import org.bukkit.scoreboard.Team; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; + +public class CustomScoreboardModule extends Module +{ + + private final Map _scoreboard; + + private BiConsumer _scoreboardConsumer; + private BiFunction _prefixFunction; + + public CustomScoreboardModule() + { + _scoreboard = new HashMap<>(); + } + + @Override + protected void setup() + { + getGame().UseCustomScoreboard = true; + } + + @EventHandler + public void playerJoin(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + GameState state = getGame().GetState(); + + if (state == GameState.Loading || state == GameState.Recruit) + { + return; + } + + setupScoreboard(player); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + _scoreboard.remove(player.getUniqueId()); + + for (CustomArcadeScoreboard scoreboard : _scoreboard.values()) + { + scoreboard.getHandle().getTeam(player.getName()).unregister(); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (Player player : Bukkit.getOnlinePlayers()) + { + setupScoreboard(player); + } + + refresh(); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (CustomArcadeScoreboard scoreboard : _scoreboard.values()) + { + scoreboard.draw(); + } + } + + private void setupScoreboard(Player player) + { + UUID key = player.getUniqueId(); + CustomArcadeScoreboard scoreboard = _scoreboard.get(key); + + if (scoreboard == null) + { + scoreboard = new CustomArcadeScoreboard(player); + _scoreboard.put(player.getUniqueId(), scoreboard); + player.setScoreboard(scoreboard.getHandle()); + } + else + { + player.setScoreboard(scoreboard.getHandle()); + } + } + + public CustomScoreboardModule setSidebar(BiConsumer consumer) + { + _scoreboardConsumer = consumer; + return this; + } + + public CustomScoreboardModule setPrefix(BiFunction function) + { + _prefixFunction = function; + return this; + } + + public void refresh() + { + for (CustomArcadeScoreboard scoreboard : _scoreboard.values()) + { + scoreboard.draw(false); + } + } + + @Override + public void cleanup() + { + _scoreboard.clear(); + } + + class CustomArcadeScoreboard extends GameScoreboard + { + + CustomArcadeScoreboard(Player owner) + { + super(getGame(), owner); + } + + public void setTag(Player subject, String prefix, String suffix) + { + Scoreboard handle = getHandle(); + String teamName = subject.getName(); + Team team = handle.getTeam(teamName); + + if (team == null) + { + team = handle.registerNewTeam(teamName); + team.addEntry(subject.getName()); + } + + if (prefix != null) + { + team.setPrefix(prefix + C.Reset + " "); + } + else if (suffix != null) + { + team.setSuffix(suffix + C.Reset + " "); + } + } + + @Override + public void draw() + { + draw(true); + } + + public void draw(boolean sidebarOnly) + { + if (_scoreboardConsumer != null) + { + _scoreboardConsumer.accept(getOwner(), this); + } + if (sidebarOnly) + { + if (_prefixFunction != null) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + _prefixFunction.apply(getOwner(), player); + } + } + } + super.draw(); + } + } + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index 2b94686d0..57a1eff12 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -475,9 +475,12 @@ public class GameManager implements Listener return; Game game = Manager.GetGame(); - if (game == null) return; - - game.GetScoreboard().updateTitle(); + if (game == null) return; + + if (!game.UseCustomScoreboard) + { + game.GetScoreboard().updateTitle(); + } } public void TeamPreferenceJoin(Game game) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java index 00e52236a..98d0cfb35 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.managers; import java.util.ArrayList; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -83,14 +84,15 @@ public class GamePlayerManager implements Listener final Player player = event.getPlayer(); //Player List - UtilTabTitle.setHeaderAndFooter(player, - Manager.GetGame() != null ? C.cGold + C.Bold + Manager.GetGame().GetType().GetName() : " ", - "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop"); + UtilTabTitle.setHeaderAndFooter(player, + Manager.GetGame() != null ? C.cGold + C.Bold + Manager.GetGame().GetType().GetName() : " ", + "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop"); //Lobby Spawn if (Manager.GetGame() == null || !Manager.GetGame().InProgress()) { Manager.Clear(player); + Manager.getScoreboardManager().getScoreboards().entrySet().stream().filter(ent -> Bukkit.getPlayer(ent.getKey()) != null).forEach(ent -> Bukkit.getPlayer(ent.getKey()).setScoreboard(ent.getValue().getHandle())); player.teleport(Manager.GetLobby().getSpawn()); //Load default kit for this game if (Manager.GetGame() != null && Manager.GetGame().GetType().name().toLowerCase().contains("champions")) @@ -133,19 +135,24 @@ public class GamePlayerManager implements Listener if (loc != null && !loc.getWorld().getName().equalsIgnoreCase("world")) { player.teleport(loc); - } else + } + else { Manager.Clear(player); player.teleport(Manager.GetGame().GetTeam(player).GetSpawn()); } - } else + } + else { Manager.Clear(player); Manager.addSpectator(player, true); UtilPlayer.message(player, F.main("Game", Manager.GetGame().GetName() + " is in progress, please wait for next game!")); } - player.setScoreboard(Manager.GetGame().GetScoreboard().getScoreboard()); + if (!Manager.GetGame().UseCustomScoreboard) + { + player.setScoreboard(Manager.GetGame().GetScoreboard().getScoreboard()); + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java index 72f1dc35f..c27497c40 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java @@ -479,10 +479,14 @@ public abstract class LobbyManager implements Listener return; } - if (_manager.GetGame() != null && - (_manager.GetGame().GetState() != GameState.Loading && - _manager.GetGame().GetState() != GameState.Recruit)) + Game game = _manager.GetGame(); + if (game != null && game.GetState() != GameState.Loading && game.GetState() != GameState.Recruit) { + if (game.UseCustomScoreboard) + { + return; + } + for (Player player : UtilServer.getPlayers()) player.setScoreboard(_manager.GetGame().GetScoreboard().getScoreboard()); //XXX } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java index def71d516..e912a550b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java @@ -29,10 +29,15 @@ public class GameScoreboard extends WritableMineplexScoreboard public GameScoreboard(Game game) { + this(game, null); + } + + public GameScoreboard(Game game, Player player) + { + super(player); + _game = game; - _title = " MINEPLEX "; - setSidebarName(C.Bold + _title); } From dcb676c57be5854664975ae17aed1d4d5b18dd07 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 10 May 2017 19:25:56 +0100 Subject: [PATCH 016/283] Item upgrade effects --- .../nautilus/game/arcade/ArcadeManager.java | 1 + .../game/arcade/game/games/moba/Moba.java | 46 +++++++++- .../game/games/moba/MobaHPRegenEvent.java | 49 ++++++++++ .../games/moba/fountain/MobaFountain.java | 91 +++++++++++++++++++ .../moba/kit/CooldownCalculateEvent.java | 2 +- .../arcade/game/games/moba/kit/HeroKit.java | 32 +++++++ .../arcade/game/games/moba/kit/HeroSkill.java | 3 +- .../games/moba/kit/anath/SkillBurnBeam.java | 2 +- .../games/moba/kit/hattori/SkillSnowball.java | 2 +- .../arcade/game/games/moba/shop/MobaItem.java | 24 ++++- .../game/games/moba/shop/MobaItemEffect.java | 18 ++-- .../arcade/game/games/moba/shop/MobaShop.java | 60 +++++++++++- .../games/moba/shop/MobaShopCategoryMenu.java | 26 +++++- .../game/games/moba/shop/MobaShopMenu.java | 2 +- .../moba/shop/assassin/MobaAssassinShop.java | 87 +++++++++++++++++- .../moba/shop/effects/MobaCDREffect.java | 26 +++++- .../moba/shop/effects/MobaHPRegenEffect.java | 46 ++++++++++ .../moba/shop/effects/MobaKillHealEffect.java | 28 +++++- .../moba/shop/effects/MobaSpeedEffect.java | 48 ++++++++++ .../shop/effects/MobaTotalHealthEffect.java | 50 ++++++++++ .../game/modules/CustomScoreboardModule.java | 16 +++- 21 files changed, 629 insertions(+), 30 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 9cce4fec6..49effeb23 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -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); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index a9f1c238c..aaf8d4cb6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -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 getLocationStartsWith(String s) { Map map = new HashMap<>(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java new file mode 100644 index 000000000..0ec5994c8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java @@ -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(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java new file mode 100644 index 000000000..c77112f5c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java @@ -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 _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 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"); + } + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java index 93c0cee45..caeab4cfa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java @@ -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() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index ce57121ca..276e92374 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -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 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)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 991e2afe5..9f228b05c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -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() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java index 2a2f1f23d..e4289850a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java @@ -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); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 2d353db1c..9eef19c67 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -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()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java index 7cabddd2a..dd5f49e9f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java @@ -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() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java index 8af399784..d04f2d149 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -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(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index fd0933d45..c64ddcc16 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -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 items = _upgrades.get(player); @@ -275,4 +291,44 @@ public class MobaShop implements Listener } } } + + @EventHandler + public void hpRegeneration(MobaHPRegenEvent event) + { + Player player = event.getPlayer(); + List 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 items = _upgrades.get(player); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onRespawn(event); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java index 5a6ed5f70..5a9567966 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -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 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 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 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 } } } + + class GoBackButton extends Button + { + + public GoBackButton(ArcadeManager plugin) + { + super(GO_BACK_ITEM, plugin); + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _shop.openShop(_host.getData(player)); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java index 515445f82..af128575b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java @@ -69,7 +69,7 @@ public class MobaShopMenu extends Menu } builder.setTitle(C.cGreen + category.getName()); - builder.addLore("", "Not sure what to put here", ""); + builder.addLore(""); if (category.isAllowingMultiple()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java index 5908c9c6a..9d3a43a7a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java @@ -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); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java index ea6b08db8..f3a64be2a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java @@ -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)) + "%."; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java new file mode 100644 index 000000000..dabdddf48 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java @@ -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)) + "%."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java index 4aaca0a0c..d869a752f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -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 + "."; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java new file mode 100644 index 000000000..41cf6e3e8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java @@ -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)) + "%."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java new file mode 100644 index 000000000..2fe9565b4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java @@ -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 + "."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java index a14c40e36..b167a378d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java @@ -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); } } } From 16e0f38dcf090fd737461c607b795269643e936e Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 11 May 2017 18:08:55 +0200 Subject: [PATCH 017/283] Menu Improvements and more Quest Trackers --- .../src/mineplex/core/quests/Quest.java | 43 ++++++- .../mineplex/core/quests/QuestClientData.java | 37 +++++- .../mineplex/core/quests/QuestManager.java | 104 ++++++++++----- .../src/mineplex/core/quests/TriggerType.java | 2 +- .../core/quests/command/GetQuestCommand.java | 45 +++++++ .../quests/repository/QuestRepository.java | 120 +++++++++++++----- .../core/quests/shop/BuyQuestButton.java | 45 ++++++- .../mineplex/core/quests/shop/QuestPage.java | 31 ++--- .../mineplex/core/quests/shop/QuestSale.java | 2 +- .../quests/shop/RedeemDeclineQuestButton.java | 17 ++- .../src/mineplex/hub/HubManager.java | 2 +- .../src/nautilus/game/arcade/Arcade.java | 5 + .../nautilus/game/arcade/ArcadeManager.java | 2 +- .../game/arcade/events/ChestRefillEvent.java | 55 ++++++++ .../src/nautilus/game/arcade/game/Game.java | 21 ++- .../game/games/champions/ChampionsCTF.java | 3 + .../games/champions/ChampionsDominate.java | 3 + .../games/champions/events/CaptureEvent.java | 41 ++++++ .../champions/quests/CaptureQuestTracker.java | 32 +++++ .../champions/quests/FlagQuestTracker.java | 30 +++++ .../common/dominate_data/CapturePoint.java | 4 + .../game/arcade/game/games/draw/Draw.java | 3 + .../games/draw/quests/GuessQuestTracker.java | 36 ++++++ .../arcade/game/games/hideseek/HideSeek.java | 3 + .../hideseek/quests/DisguiseQuestTracker.java | 34 +++++ .../arcade/game/games/skyfall/Skyfall.java | 9 ++ .../skyfall/quests/RingQuestTracker.java | 37 ++++++ .../games/speedbuilders/SpeedBuilders.java | 4 + .../quests/PerfectBuildQuestTracker.java | 29 +++++ .../games/survivalgames/SurvivalGames.java | 7 +- .../game/arcade/game/games/uhc/UHC.java | 3 + .../games/uhc/quests/TameQuestTracker.java | 38 ++++++ .../arcade/quest/ChestOpenQuestTracker.java | 57 +++++++++ .../arcade/quest/CollectQuestTracker.java | 88 ++++++++++++- .../arcade/quest/KillEntityQuestTracker.java | 55 ++++++++ .../game/arcade/quest/KillQuestTracker.java | 7 +- .../arcade/quest/ParticipateQuestTracker.java | 37 ++++++ .../arcade/quest/PlayGameQuestTracker.java | 37 ++++++ .../game/arcade/quest/QuestTracker.java | 18 +-- .../game/arcade/quest/WinQuestTracker.java | 6 +- 40 files changed, 1021 insertions(+), 131 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/ChestRefillEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/events/CaptureEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/CaptureQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/FlagQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/quests/GuessQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/quests/DisguiseQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/quests/RingQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/quests/PerfectBuildQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/quests/TameQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillEntityQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ParticipateQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/PlayGameQuestTracker.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java index fe5237cc6..f005c5637 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java @@ -1,5 +1,6 @@ package mineplex.core.quests; +import mineplex.core.game.GameCategory; import mineplex.core.game.GameDisplay; /** @@ -20,14 +21,22 @@ public class Quest private int _questReward; private QuestRarity _rarity; + + private String _type; + private GameDisplay _game; + private GameCategory _gameCategory; + private boolean _overworld; + private TriggerType _trigger; private String _item; private int _statToComplete; + private long _lastCompleted; + private int _current; - public Quest(int questID, String name, String task, int cost, int reward, QuestRarity rarity, GameDisplay game, TriggerType trigger, String item, int statToComplete) + public Quest(int questID, String name, String task, int cost, int reward, QuestRarity rarity, String type, TriggerType trigger, String item, int statToComplete) { _questID = questID; _questName = name; @@ -35,10 +44,18 @@ public class Quest _questCost = cost; _questReward = reward; _rarity = rarity; - _game = game; _trigger = trigger; _item = item; _statToComplete = statToComplete; + _type = type; + + if (GameDisplay.matchName(type) != null) + _game = GameDisplay.matchName(type); + + if (GameCategory.valueOf(type) != null) + _gameCategory = GameCategory.valueOf(type); + + _overworld = (_game == null && _gameCategory == null); } public int getID() @@ -76,6 +93,16 @@ public class Quest return _game; } + public GameCategory getGameCategory() + { + return _gameCategory; + } + + public boolean isInOverworld() + { + return _overworld; + } + public TriggerType getTrigger() { return _trigger; @@ -138,10 +165,20 @@ public class Quest return _current >= _statToComplete; } + public void setLastCompleted(long time) + { + _lastCompleted = time; + } + + public long getLastCompleted() + { + return _lastCompleted; + } + @Override public Quest clone() { - return new Quest(_questID, _questName, _questTask, _questCost, _questReward, _rarity, _game, _trigger, _item, _statToComplete); + return new Quest(_questID, _questName, _questTask, _questCost, _questReward, _rarity, _type, _trigger, _item, _statToComplete); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java index 6d9aba667..11c7ea556 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java @@ -18,12 +18,18 @@ public class QuestClientData public ArrayList getQuests() { - return _quests; + ArrayList quests = new ArrayList<>(); + for (Quest quest : _quests) + { + if (quest.getProgress() != -1) + quests.add(quest); + } + return quests; } public boolean hasQuest(Quest quest) { - for (Quest other : _quests) + for (Quest other : getQuests()) { if (other.getID() == quest.getID()) return true; @@ -32,6 +38,16 @@ public class QuestClientData } public Quest getQuest(int id) + { + for (Quest quest : getQuests()) + { + if (quest.getID() == id) + return quest; + } + return null; + } + + public Quest getQuestFromAll(int id) { for (Quest quest : _quests) { @@ -41,9 +57,24 @@ public class QuestClientData return null; } + public boolean hasQuestFromAll(Quest quest) + { + for (Quest other : _quests) + { + if (other.getID() == quest.getID()) + return true; + } + return false; + } + public void removeQuest(int id) { Quest toRemove = getQuest(id); - _quests.remove(toRemove); + toRemove.setProgress(-1); + } + + public ArrayList getAllQuests() + { + return _quests; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index 239b9e149..d0ba43e4f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -1,8 +1,10 @@ package mineplex.core.quests; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; import org.apache.commons.lang3.tuple.Triple; @@ -13,12 +15,20 @@ import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; +import mineplex.core.game.GameCategory; import mineplex.core.game.GameDisplay; import mineplex.core.google.GoogleSheetsManager; +import mineplex.core.quests.command.GetQuestCommand; import mineplex.core.quests.command.OpenGuiCommand; import mineplex.core.quests.repository.QuestRepository; +import mineplex.quest.client.RedisQuestSupplier; +import mineplex.quest.common.QuestSupplier; +import mineplex.serverdata.redis.messaging.PubSubJedisClient; +import mineplex.serverdata.redis.messaging.PubSubRouter; +import mineplex.serverdata.servers.ServerManager; /** * QuestManager @@ -37,7 +47,9 @@ public class QuestManager extends MiniClientPlugin public ArrayList _availableQuests; - public QuestManager() + private QuestSupplier _questSupplier = new RedisQuestSupplier(getPlugin(), new PubSubRouter(new PubSubJedisClient(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection()))); + + public QuestManager(DonationManager donationManager) { super("Quest Manager"); @@ -45,6 +57,7 @@ public class QuestManager extends MiniClientPlugin _sheetsManager = require(GoogleSheetsManager.class); _clients = require(CoreClientManager.class); _availableQuests = new ArrayList<>(); + _donationManager = donationManager; setupQuests(); } @@ -53,6 +66,7 @@ public class QuestManager extends MiniClientPlugin public void addCommands() { addCommand(new OpenGuiCommand(this)); + addCommand(new GetQuestCommand(this)); } public void setupQuests() @@ -70,21 +84,22 @@ public class QuestManager extends MiniClientPlugin for (int i = 1; i < size; i++) { - String name = table.get(i).get(0); - String task = table.get(i).get(1); - String game = table.get(i).get(2); - String cost = table.get(i).get(3); - String reward = table.get(i).get(4); - String trigger = table.get(i).get(5); - String statcompletion = table.get(i).get(6); - String item = table.get(i).get(7); - String rarity = table.get(i).get(8); + String id = table.get(i).get(0); + String name = table.get(i).get(1); + String task = table.get(i).get(2); + String type = table.get(i).get(3); + String cost = table.get(i).get(4); + String reward = table.get(i).get(5); + String trigger = table.get(i).get(6); + String statcompletion = table.get(i).get(7); + String item = table.get(i).get(8); + String rarity = table.get(i).get(9); - _availableQuests.add(new Quest(i, name, task, + _availableQuests.add(new Quest(Integer.parseInt(id), name, task, Integer.parseInt(cost), Integer.parseInt(reward), QuestRarity.getByName(rarity), - GameDisplay.matchName(game), + type, TriggerType.getByName(trigger), item, Integer.parseInt(statcompletion))); @@ -94,29 +109,31 @@ public class QuestManager extends MiniClientPlugin @EventHandler public void playerJoin(PlayerJoinEvent event) { - QuestClientData data = Get(event.getPlayer()); - for (Triple triple : _repository.getQuests(_clients.Get(event.getPlayer()))) - { - int id = triple.getLeft(); - int value = triple.getMiddle(); - long time = triple.getRight(); - - if (value == -1) - continue; - - if (!UtilTime.elapsed(time, 1000*60*60*24)) - continue; - - for (Quest quest : _availableQuests) + QuestClientData questData = Get(event.getPlayer()); + _repository.getQuests(_clients.Get(event.getPlayer()), new Callback>>() + { + @Override + public void run(ArrayList> data) { - if (quest.getID() == id) + for (Triple triple : data) { - Quest clone = quest.clone(); - clone.setProgress(value); - data.addQuest(clone); + int id = triple.getLeft(); + int value = triple.getMiddle(); + long time = triple.getRight(); + + for (Quest quest : _availableQuests) + { + if (quest.getID() == id) + { + Quest clone = quest.clone(); + clone.setProgress(value); + clone.setLastCompleted(time); + questData.addQuest(clone); + } + } } } - } + }); } public Quest getQuestByID(int id) @@ -131,10 +148,20 @@ public class QuestManager extends MiniClientPlugin public void addNewQuest(Player player, Quest quest) { + QuestClientData data = Get(player); + for (Quest other : data.getAllQuests()) + { + if (other.getID() == quest.getID()) + { + other.setProgress(0); + _repository.addQuest(_clients.Get(player), other); + return; + } + } + Quest clone = quest.clone(); clone.setProgress(0); Get(player).addQuest(clone); - _repository.addNew(_clients.Get(player), quest); } @@ -151,9 +178,18 @@ public class QuestManager extends MiniClientPlugin _repository.incrementQuest(client, quest); } - public int[] getCurrentQuests() + public Set getCurrentQuests() { - return new int[]{2, 4}; + Set set = new HashSet<>(); + for (mineplex.quest.common.Quest quest : _questSupplier.get()) + { + set.add(quest.getUniqueId()); + } +// set.add(2); +// set.add(1); +// set.add(3); +// set.add(0); + return set; } public CoreClientManager getClients() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java index 1cf1b7b32..861999fae 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java @@ -8,7 +8,7 @@ package mineplex.core.quests; public enum TriggerType { - KILL("Kill"), DIE("Die"), WIN("Win"), LOSE("Lose"), COLLECT("Collect"); + KILL("Kill"), DIE("Die"), WIN("Win"), LOSE("Lose"), COLLECT("Collect"), PLAY("Play"), COMPLETE("Complete"); private String _name; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java new file mode 100644 index 000000000..e4d776ebc --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java @@ -0,0 +1,45 @@ +package mineplex.core.quests.command; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.quests.Quest; +import mineplex.core.quests.QuestManager; + +/** + * GetQuestCommand + * + * @author xXVevzZXx + */ +public class GetQuestCommand extends CommandBase +{ + public GetQuestCommand(QuestManager plugin) + { + super(plugin, Rank.ADMIN, "GetQuest"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main("Quest Manager", "You have to define a quest")); + return; + } + + if (Plugin.getQuestByID(Integer.parseInt(args[0])) == null) + { + UtilPlayer.message(caller, F.main("Quest Manager", "Quest not found")); + return; + } + + Quest quest = Plugin.getQuestByID(Integer.parseInt(args[0])); + + Plugin.addNewQuest(caller, quest); + UtilPlayer.message(caller, F.main("Quest Manager", "Added Quest: " + ChatColor.YELLOW + quest.getName())); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java index 324feb381..09b7ecc5a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java @@ -1,16 +1,21 @@ package mineplex.core.quests.repository; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import org.apache.commons.lang3.tuple.Triple; import org.bukkit.entity.Player; import mineplex.core.account.CoreClient; +import mineplex.core.common.util.Callback; import mineplex.core.quests.Quest; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnLong; /** * QuestRepository @@ -19,6 +24,14 @@ import mineplex.serverdata.database.RepositoryBase; */ public class QuestRepository extends RepositoryBase { + private static final String INSTERT_NEW_QUEST = "INSERT INTO accountQuest (accountId, questId, progress, questCompletion, lastCompleted) VALUES (?, ?, ?, ?, ?);"; + private static final String INCREMENT_QUEST = "UPDATE accountQuest SET progress=progress+1 WHERE accountId=? AND questId=?;"; + private static final String RESET_QUEST = "UPDATE accountQuest SET progress=-1 WHERE accountId=? AND questId=?;"; + private static final String START_QUEST = "UPDATE accountQuest SET progress=0 WHERE accountId=? AND questId=?;"; + private static final String COMPLETE_QUEST = "UPDATE accountQuest SET progress=-1, questCompletion=questCompletion+1, lastCompleted=? WHERE accountId=? AND questId=?;"; + + private static final String FETCH_QUESTS = "SELECT questId, progress, lastCompleted FROM accountQuest WHERE accountId=?"; + private HashMap>> _db; public QuestRepository() @@ -38,60 +51,99 @@ public class QuestRepository extends RepositoryBase _db.put(player.getUniqueId().toString(), new ArrayList<>()); } - public ArrayList> getQuests(CoreClient client) + public void getQuests(CoreClient client, Callback>> callback) { - player(client.GetPlayer()); + //player(client.GetPlayer()); // ArrayList> list = new ArrayList<>(); // for (int i = 2; i <= 3; i++) // { // list.add(Triple.of(i, UtilMath.r(10) + 1, System.currentTimeMillis() - (1000*60*60*48))); // } // return list; - return _db.get(client.GetPlayer().getUniqueId().toString()); +// return _db.get(client.GetPlayer().getUniqueId().toString()); + + executeQuery(FETCH_QUESTS, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + ArrayList> list = new ArrayList<>(); + + while (resultSet.next()) + { + list.add(Triple.of(resultSet.getInt(1), resultSet.getInt(2), resultSet.getLong(3))); + } + + callback.run(list); + } + } ,new ColumnInt("accountId", client.getAccountId())); } public void resetQuest(CoreClient client, Quest quest, boolean completed) { - player(client.GetPlayer()); - Triple toAdd = null; - ArrayList> liste = _db.get(client.GetPlayer().getUniqueId().toString()); - Iterator> iterator = liste.iterator(); - while (iterator.hasNext()) +// player(client.GetPlayer()); +// Triple toAdd = null; +// ArrayList> liste = _db.get(client.GetPlayer().getUniqueId().toString()); +// Iterator> iterator = liste.iterator(); +// while (iterator.hasNext()) +// { +// Triple triple = iterator.next(); +// if (triple.getLeft() == quest.getID()) +// { +// toAdd = Triple.of(triple.getLeft(), -1, (completed ? System.currentTimeMillis() : (long) 0)); +// iterator.remove(); +// } +// } +// if (toAdd != null) +// _db.get(client.GetPlayer().getUniqueId().toString()).add(toAdd); + + if (completed) { - Triple triple = iterator.next(); - if (triple.getLeft() == quest.getID()) - { - toAdd = Triple.of(triple.getLeft(), -1, (completed ? System.currentTimeMillis() : (long) 0)); - iterator.remove(); - } + executeUpdate(COMPLETE_QUEST, new ColumnLong("lastCompleted", System.currentTimeMillis()), new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); } - if (toAdd != null) - _db.get(client.GetPlayer().getUniqueId().toString()).add(toAdd); + else + { + executeUpdate(RESET_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + } + } + + public void addQuest(CoreClient client, Quest quest) + { + executeUpdate(START_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); } public void addNew(CoreClient client, Quest quest) { - player(client.GetPlayer()); - _db.get(client.GetPlayer().getUniqueId().toString()).add(Triple.of(quest.getID(), 0, (long) 0)); + //player(client.GetPlayer()); + //_db.get(client.GetPlayer().getUniqueId().toString()).add(Triple.of(quest.getID(), 0, (long) 0)); + + executeInsert(INSTERT_NEW_QUEST, null, + new ColumnInt("accountId", client.getAccountId()), + new ColumnInt("questId", quest.getID()), + new ColumnInt("progress", 0), + new ColumnInt("questCompletion", 0), + new ColumnLong("lastCompleted", (long) 0)); } public void incrementQuest(CoreClient client, Quest quest) { - player(client.GetPlayer()); - Triple toAdd = null; - ArrayList> liste = _db.get(client.GetPlayer().getUniqueId().toString()); - Iterator> iterator = liste.iterator(); - while (iterator.hasNext()) - { - Triple triple = iterator.next(); - if (triple.getLeft() == quest.getID()) - { - toAdd = Triple.of(triple.getLeft(), triple.getMiddle() + 1, triple.getRight()); - iterator.remove(); - } - } - if (toAdd != null) - _db.get(client.GetPlayer().getUniqueId().toString()).add(toAdd); +// //player(client.GetPlayer()); +// Triple toAdd = null; +// ArrayList> liste = _db.get(client.GetPlayer().getUniqueId().toString()); +// Iterator> iterator = liste.iterator(); +// while (iterator.hasNext()) +// { +// Triple triple = iterator.next(); +// if (triple.getLeft() == quest.getID()) +// { +// toAdd = Triple.of(triple.getLeft(), triple.getMiddle() + 1, triple.getRight()); +// iterator.remove(); +// } +// } +// if (toAdd != null) +// _db.get(client.GetPlayer().getUniqueId().toString()).add(toAdd); + + executeUpdate(INCREMENT_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java index 27053ee37..63d573c53 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java @@ -1,5 +1,7 @@ package mineplex.core.quests.shop; +import net.md_5.bungee.api.ChatColor; + import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -8,9 +10,11 @@ import mineplex.core.common.currency.GlobalCurrency; 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.quests.Quest; import mineplex.core.quests.QuestManager; import mineplex.core.recharge.Recharge; +import mineplex.core.server.util.TransactionResponse; import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.SalesPackageBase; @@ -50,15 +54,50 @@ public class BuyQuestButton implements IButton return; } + if (_questManager.Get(player).getQuests().size() >= 3) + { + UtilPlayer.message(player, F.main("Quest", "You can't own more than 3 active quests at once!")); + return; + } + + if (_questManager.Get(player).hasQuestFromAll(_quest)) + { + if (!UtilTime.elapsed(_questManager.Get(player).getQuestFromAll(_quest.getID()).getLastCompleted(), 1000*60*60*24)) + { + UtilPlayer.message(player, F.main("Quest", "You already completed that Quest!")); + return; + } + } + +// if (_questManager.getDonations().Get(player).getBalance(GlobalCurrency.GEM) >= _quest.getCost()) +// { +// _questManager.getDonations().purchaseUnknownSalesPackage(player, _quest.getName(), GlobalCurrency.GEM, _quest.getCost(), false, response -> +// { +// if (response == TransactionResponse.Success) +// { +// _questManager.addNewQuest(player, _quest); +// UtilPlayer.message(player, F.main("Quest", "Purchase Succesfull!")); +// } +// else +// { +// UtilPlayer.message(player, F.main("Quest", "There was an Error while purchasing!")); +// } +// }); +// } +// else +// { +// UtilPlayer.message(player, F.main("Quest", "You dont have enough Gems!")); +// } + SalesPackageBase salesPackage = new QuestSale(_quest.getName(), Material.PAPER, _quest.getCost()); _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, _page.getDonationManager(), () -> { _questManager.addNewQuest(player, _quest); - + UtilPlayer.message(player, F.main("Quest", "You have bought: " + ChatColor.YELLOW + _quest.getName())); player.closeInventory(); - QuestPage page = new QuestPage(_page.getPlugin(), _page.getQuestShop(), _page.getClientManager(), _page.getDonationManager(), player); - _page.getQuestShop().openPageForPlayer(player, page); +// QuestPage page = new QuestPage(_page.getPlugin(), _page.getQuestShop(), _page.getClientManager(), _page.getDonationManager(), player); +// _page.getQuestShop().openPageForPlayer(player, page); }), salesPackage.buildIcon())); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java index 208810b8a..77ed1e7d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java @@ -26,7 +26,7 @@ public class QuestPage extends ShopPageBase public QuestPage(QuestManager plugin, QuestShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) { - super(plugin, shop, clientManager, donationManager, "Quest Page", player); + super(plugin, shop, clientManager, donationManager, "Quest Page", player, 27); buildPage(); } @@ -35,11 +35,7 @@ public class QuestPage extends ShopPageBase protected void buildPage() { int i = 0; - while (i < 9) - { - setItem(i, ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.BLACK.getData())); - i++; - } + setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, "")); { int currentSlot = 4; @@ -64,10 +60,10 @@ public class QuestPage extends ShopPageBase ItemMeta meta = item.getItemMeta(); meta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + quest.getName()); meta.setLore(Arrays.asList( - ChatColor.YELLOW + quest.getTask(), + ChatColor.LIGHT_PURPLE + quest.getTask(), "", - ChatColor.GREEN + "Cost: " + quest.getCost() + " Gems", - ChatColor.AQUA + "Reward: " + quest.getReward() + " Shards", + ChatColor.GRAY + "Cost: " + ChatColor.GREEN + quest.getCost() + " Gems", + ChatColor.GRAY + "Reward: " + ChatColor.AQUA + quest.getReward() + " Shards", "", quest.getRarity().getColor() + "" + ChatColor.BOLD + quest.getRarity().toString(), "", @@ -78,13 +74,14 @@ public class QuestPage extends ShopPageBase addButton(i + currentSlot, item, new BuyQuestButton(_plugin, this, quest)); } } - i = 9*2; - while (i < (9*3)) + i = 9; + while (i < (9*2)) { setItem(i, ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.BLACK.getData())); i++; } - i = 9*4; + i = 9*2; + setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMPTY_MAP, (byte) 0, 1, "")); { int currentSlot = 4; @@ -107,15 +104,15 @@ public class QuestPage extends ShopPageBase ItemMeta meta = item.getItemMeta(); meta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + quest.getName()); meta.setLore(Arrays.asList( - ChatColor.YELLOW + quest.getTask(), + ChatColor.LIGHT_PURPLE + quest.getTask(), "", - ChatColor.AQUA + "Reward: " + quest.getReward() + " Shards", + ChatColor.GRAY + "Reward: " + ChatColor.AQUA + quest.getReward() + " Shards", + "", + ChatColor.GRAY + "Progress: " + (quest.isCompleted() ? ChatColor.GREEN + "Completed!" : ChatColor.YELLOW + "" + quest.getProgress() + ChatColor.GRAY + "/" + ChatColor.YELLOW + quest.getStatToComplete()), "", quest.getRarity().getColor() + "" + ChatColor.BOLD + quest.getRarity().toString(), "", - ChatColor.YELLOW + "Progress: " + (quest.isCompleted() ? ChatColor.GREEN + "Completed!" : quest.getProgress() + "/" + quest.getStatToComplete()), - "", - (quest.isCompleted() ? ChatColor.GREEN + "Left Click to Complete" : ChatColor.RED + "Right Shift Click to cancell") + (quest.isCompleted() ? ChatColor.GREEN + "Left Click to Complete" : ChatColor.RED + "Shift Right-Click to cancel") )); item.setItemMeta(meta); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestSale.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestSale.java index dfb266baa..9ded66346 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestSale.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestSale.java @@ -19,7 +19,7 @@ public class QuestSale extends SalesPackageBase KnownPackage = false; OneTimePurchaseOnly = false; - CurrencyCostMap.clear(); +// CurrencyCostMap.clear(); CurrencyCostMap.put(GlobalCurrency.GEM, cost); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java index a33c2f3e4..97b5074ed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java @@ -48,7 +48,8 @@ public class RedeemDeclineQuestButton implements IButton if (!_questManager.Get(player).hasQuest(_quest)) { - UtilPlayer.message(player, F.main("Quest", "You dont own that Quest!")); + UtilPlayer.message(player, F.main("Quest", "You don't own that Quest!")); + player.closeInventory(); return; } @@ -57,28 +58,26 @@ public class RedeemDeclineQuestButton implements IButton if (_quest.isCompleted()) { UtilPlayer.message(player, F.main("Quest", "You can't cancell a completed Quest!")); + player.closeInventory(); return; } _questManager.resetQuest(player, _quest, false); UtilPlayer.message(player, F.main("Quest", "You have cancelled that Quest!")); + player.closeInventory(); } if (clickType == ClickType.LEFT) { if (!_quest.isCompleted()) { - UtilPlayer.message(player, F.main("Quest", "You havent completed that Quest yet!")); + UtilPlayer.message(player, F.main("Quest", "You haven't completed that Quest yet!")); + player.closeInventory(); return; } _questManager.resetQuest(player, _quest, true); _donations.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completed Quest: " + _quest.getID(), _quest.getReward()); - UtilPlayer.message(player, F.main("Quest", "You have recieved " + ChatColor.AQUA + _quest.getReward() + " Shards " + ChatColor.GRAY + "for completing a Quest!")); - } - - if (clickType == ClickType.LEFT || clickType == ClickType.SHIFT_RIGHT) - { - QuestPage page = new QuestPage(_page.getPlugin(), _page.getQuestShop(), _page.getClientManager(), _page.getDonationManager(), player); - _page.getQuestShop().openPageForPlayer(player, page); + UtilPlayer.message(player, F.main("Quest", "You have recieved " + ChatColor.AQUA + _quest.getReward() + " Shards " + ChatColor.GRAY + "for completing: " + ChatColor.YELLOW + _quest.getName())); + player.closeInventory(); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 13d2e075c..fc1429e60 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -293,7 +293,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess new EasterEggHunt(plugin, _clientManager); - _questManager = new QuestManager(); + _questManager = new QuestManager(_donationManager); ScoreboardManager scoreboardManager = new ScoreboardManager(plugin) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 731d73616..50a7acec4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -398,4 +398,9 @@ public class Arcade extends JavaPlugin config.GameModeMods.get(mode).put(var, value); } } + + public ServerConfiguration getServerConfig() + { + return _serverConfiguration; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 8df24ceb1..399ac7b0f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -391,7 +391,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _kitProgressionManager = new KitProgressionManager(getPlugin(), donationManager, clientManager); _progressionKitManager = new ProgressingKitManager(this); _serverUptimeManager = new ServerUptimeManager(this); - _questManager = new QuestManager(); + _questManager = new QuestManager(_donationManager); if (GetHost() != null && !GetHost().isEmpty() && !GetHost().startsWith("COM-")) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/ChestRefillEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/ChestRefillEvent.java new file mode 100644 index 000000000..ed2f18fff --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/ChestRefillEvent.java @@ -0,0 +1,55 @@ +package nautilus.game.arcade.events; + +import java.util.ArrayList; + +import org.bukkit.Location; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * ChestRefillEvent + * + * @author xXVevzZXx + */ +public class ChestRefillEvent extends Event implements Cancellable +{ + private static final HandlerList handlers = new HandlerList(); + + private boolean _cancelled = false; + + private ArrayList _chests; + + public ChestRefillEvent(ArrayList chests) + { + _chests = (ArrayList) chests.clone(); + } + + public ArrayList getChests() + { + return _chests; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index f4d15da89..adaaa630d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -101,8 +101,12 @@ import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.managers.lobby.LobbyManager; +import nautilus.game.arcade.quest.ChestOpenQuestTracker; import nautilus.game.arcade.quest.CollectQuestTracker; +import nautilus.game.arcade.quest.KillEntityQuestTracker; import nautilus.game.arcade.quest.KillQuestTracker; +import nautilus.game.arcade.quest.ParticipateQuestTracker; +import nautilus.game.arcade.quest.PlayGameQuestTracker; import nautilus.game.arcade.quest.QuestTracker; import nautilus.game.arcade.quest.WinQuestTracker; import nautilus.game.arcade.scoreboard.GameScoreboard; @@ -383,7 +387,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed private NautHashMap _deadBodiesExpire = new NautHashMap(); private final Set> _statTrackers = new HashSet<>(); - private final Set _questTrackers = new HashSet<>(); + private final Set> _questTrackers = new HashSet<>(); private NautHashMap _teamReqs = new NautHashMap(); public WinEffectManager WinEffectManager = new WinEffectManager(); @@ -458,7 +462,14 @@ public abstract class Game extends ListenerComponent implements Lifetimed this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this)); // Quest Trackers - registerQuestTrackers(new WinQuestTracker(this), new KillQuestTracker(this), new CollectQuestTracker(this)); + registerQuestTrackers( + new WinQuestTracker(this), + new KillQuestTracker(this), + new CollectQuestTracker(this), + new ChestOpenQuestTracker(this), + new KillEntityQuestTracker(this), + new PlayGameQuestTracker(this), + new ParticipateQuestTracker(this)); Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(this), gameType.isEnforceResourcePack(this)); @@ -1783,16 +1794,16 @@ public abstract class Game extends ListenerComponent implements Lifetimed return _statTrackers; } - public void registerQuestTrackers(QuestTracker... questTrackers) + public void registerQuestTrackers(QuestTracker... questTrackers) { - for (QuestTracker tracker : questTrackers) + for (QuestTracker tracker : questTrackers) { if (_questTrackers.add(tracker)) Bukkit.getPluginManager().registerEvents(tracker, Manager.getPlugin()); } } - public Collection getQuestTrackers() + public Collection> getQuestTrackers() { return _questTrackers; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java index d419b8c3f..1a28d319c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java @@ -14,6 +14,7 @@ import nautilus.game.arcade.game.games.champions.kits.KitBrute; import nautilus.game.arcade.game.games.champions.kits.KitKnight; import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; +import nautilus.game.arcade.game.games.champions.quests.FlagQuestTracker; import nautilus.game.arcade.game.games.common.CaptureTheFlag; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -83,6 +84,8 @@ public class ChampionsCTF extends CaptureTheFlag new ClutchStatTracker(this, "Clutch"), new SpecialWinStatTracker(this, "SpecialWin") ); + + registerQuestTrackers(new FlagQuestTracker(this)); registerChatStats( Kills, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java index 226a3e364..bc59c9d56 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java @@ -14,6 +14,7 @@ import nautilus.game.arcade.game.games.champions.kits.KitBrute; import nautilus.game.arcade.game.games.champions.kits.KitKnight; import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; +import nautilus.game.arcade.game.games.champions.quests.CaptureQuestTracker; import nautilus.game.arcade.game.games.common.Domination; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.stats.ElectrocutionStatTracker; @@ -77,6 +78,8 @@ public class ChampionsDominate extends Domination new TheLongestShotStatTracker(this), new SeismicSlamStatTracker(this) ); + + registerQuestTrackers(new CaptureQuestTracker(this)); registerChatStats( Kills, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/events/CaptureEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/events/CaptureEvent.java new file mode 100644 index 000000000..1bdd04cb3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/events/CaptureEvent.java @@ -0,0 +1,41 @@ +package nautilus.game.arcade.game.games.champions.events; + +import java.util.Collection; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * CaptureEvent + * + * @author xXVevzZXx + */ +public class CaptureEvent extends Event +{ + private Collection _players; + + public CaptureEvent(Collection players) + { + _players = players; + } + + public Collection getPlayers() + { + return _players; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private static HandlerList _handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return _handlers; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/CaptureQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/CaptureQuestTracker.java new file mode 100644 index 000000000..3e2e0fd17 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/CaptureQuestTracker.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.champions.quests; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.games.champions.ChampionsDominate; +import nautilus.game.arcade.game.games.champions.events.CaptureEvent; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * PointQuestTracker + * + * @author xXVevzZXx + */ +public class CaptureQuestTracker extends QuestTracker +{ + + public CaptureQuestTracker(ChampionsDominate game) + { + super(game, TriggerType.COLLECT); + } + + @EventHandler + public void capture(CaptureEvent event) + { + for (Player player : event.getPlayers()) + incrementQuests(player, "Point Capture", 1); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/FlagQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/FlagQuestTracker.java new file mode 100644 index 000000000..eb4af9e77 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/FlagQuestTracker.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.champions.quests; + +import org.bukkit.event.EventHandler; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.games.common.CaptureTheFlag; +import nautilus.game.arcade.game.games.common.ctf_data.PlayerCaptureFlagEvent; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * FlagQuestTracker + * + * @author xXVevzZXx + */ +public class FlagQuestTracker extends QuestTracker +{ + + public FlagQuestTracker(CaptureTheFlag game) + { + super(game, TriggerType.COLLECT); + } + + @EventHandler + public void captureFlag(PlayerCaptureFlagEvent event) + { + incrementQuests(event.GetPlayer(), "Flag Capture", 1); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/dominate_data/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/dominate_data/CapturePoint.java index 6dd87d7f5..2a2c11ecd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/dominate_data/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/dominate_data/CapturePoint.java @@ -7,9 +7,11 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilFirework; 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.UtilTextMiddle; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.champions.events.CaptureEvent; import nautilus.game.arcade.game.games.common.Domination; import org.bukkit.ChatColor; @@ -303,6 +305,8 @@ public class CapturePoint } UtilTextMiddle.display(null, _owner.GetColor() + _owner.GetName() + " captured " + _name, 5, 40, 5); + + UtilServer.CallEvent(new CaptureEvent(capturers)); } } //Count Down diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index 457fcb5ce..c3b1332e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -52,6 +52,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.GameScore; import nautilus.game.arcade.game.games.draw.kits.KitArtist; +import nautilus.game.arcade.game.games.draw.quests.GuessQuestTracker; import nautilus.game.arcade.game.games.draw.tools.Tool; import nautilus.game.arcade.game.games.draw.tools.ToolCircle; import nautilus.game.arcade.game.games.draw.tools.ToolLine; @@ -223,6 +224,8 @@ public class Draw extends SoloGame new DrawGuessStatTracker(this) ); + registerQuestTrackers(new GuessQuestTracker(this)); + registerChatStats( new ChatStatData("TotalGuess", "Total Guesses", true), new ChatStatData("PureLuck", "Lucky Guesses", true) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/quests/GuessQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/quests/GuessQuestTracker.java new file mode 100644 index 000000000..4d759661e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/quests/GuessQuestTracker.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.draw.quests; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.draw.Draw; +import nautilus.game.arcade.game.games.draw.DrawGuessCorrectlyEvent; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * GuesQuestTracker + * + * @author xXVevzZXx + */ +public class GuessQuestTracker extends QuestTracker +{ + + public GuessQuestTracker(Draw game) + { + super(game, TriggerType.COLLECT); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onDrawGuessCorrectly(DrawGuessCorrectlyEvent event) + { + if (getGame().GetState() != GameState.Live) + return; + + if (System.currentTimeMillis() - event.getDrawRound().Time < 8000) + incrementQuests(event.getPlayer(), "Guesses", 1); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index ea2c1d71c..eaedf92cf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -46,6 +46,7 @@ import nautilus.game.arcade.game.games.hideseek.kits.KitHiderSwapper; import nautilus.game.arcade.game.games.hideseek.kits.KitSeekerLeaper; import nautilus.game.arcade.game.games.hideseek.kits.KitSeekerRadar; import nautilus.game.arcade.game.games.hideseek.kits.KitSeekerTNT; +import nautilus.game.arcade.game.games.hideseek.quests.DisguiseQuestTracker; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; @@ -348,6 +349,8 @@ public class HideSeek extends TeamGame new HunterOfTheYearStatTracker(this), new BadHiderStatTracker(this) ); + + registerQuestTrackers(new DisguiseQuestTracker(this)); //Need ideas for this one registerChatStats(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/quests/DisguiseQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/quests/DisguiseQuestTracker.java new file mode 100644 index 000000000..9b7cab861 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/quests/DisguiseQuestTracker.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.game.games.hideseek.quests; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.hideseek.HideSeek; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * DisguiseQuestTracker + * + * @author xXVevzZXx + */ +public class DisguiseQuestTracker extends QuestTracker +{ + + public DisguiseQuestTracker(HideSeek game) + { + super(game, TriggerType.COLLECT); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onChangeForm(HideSeek.PlayerChangeFormEvent event) + { + if (getGame().GetState() != Game.GameState.Live) + return; + + incrementQuests(event.getPlayer(), "Disguise", 1); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java index 1043881ad..ee931072e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java @@ -75,6 +75,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.ChestRefillEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.skyfall.kits.KitAeronaught; @@ -82,6 +83,7 @@ import nautilus.game.arcade.game.games.skyfall.kits.KitDeadeye; import nautilus.game.arcade.game.games.skyfall.kits.KitJouster; import nautilus.game.arcade.game.games.skyfall.kits.KitSpeeder; import nautilus.game.arcade.game.games.skyfall.kits.KitStunner; +import nautilus.game.arcade.game.games.skyfall.quests.RingQuestTracker; import nautilus.game.arcade.game.games.skyfall.stats.AeronaughtStatTracker; import nautilus.game.arcade.game.games.skyfall.stats.RingStatTracker; import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent; @@ -192,6 +194,8 @@ public abstract class Skyfall extends Game new RingStatTracker(this), new AeronaughtStatTracker(this)); + registerQuestTrackers(new RingQuestTracker(this)); + registerChatStats( Kills, Assists, @@ -327,8 +331,13 @@ public abstract class Skyfall extends Game _chestsRefilled = System.currentTimeMillis(); _refillAnnounced = false; + ChestRefillEvent refillEvent = UtilServer.CallEvent(new ChestRefillEvent(_lowerIsland.getChests())); + if (refillEvent.isCancelled()) + return; + _lowerIsland.refillChests(); + Announce(ChatColor.AQUA + "" + ChatColor.BOLD + "Chests on the lower middle Island have been refilled!", true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/quests/RingQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/quests/RingQuestTracker.java new file mode 100644 index 000000000..5ca820dd0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/quests/RingQuestTracker.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.skyfall.quests; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.games.skyfall.PlayerBoostRingEvent; +import nautilus.game.arcade.game.games.skyfall.Skyfall; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * BoosterRingQuestTracker + * + * @author xXVevzZXx + */ +public class RingQuestTracker extends QuestTracker +{ + + public RingQuestTracker(Skyfall game) + { + super(game, TriggerType.COLLECT); + } + + @EventHandler(priority=EventPriority.MONITOR) + public void boosterRing(PlayerBoostRingEvent event) + { + if (event.isCancelled()) + return; + + if (!getGame().IsAlive(event.getPlayer())) + return; + + incrementQuests(event.getPlayer(), "Booster Rings", 1); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java index 3a04f2237..186b91746 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java @@ -32,12 +32,14 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.skyfall.quests.RingQuestTracker; import nautilus.game.arcade.game.games.speedbuilders.data.BuildData; import nautilus.game.arcade.game.games.speedbuilders.data.DemolitionData; import nautilus.game.arcade.game.games.speedbuilders.data.MobData; import nautilus.game.arcade.game.games.speedbuilders.data.RecreationData; import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent; import nautilus.game.arcade.game.games.speedbuilders.kits.DefaultKit; +import nautilus.game.arcade.game.games.speedbuilders.quests.PerfectBuildQuestTracker; import nautilus.game.arcade.game.games.speedbuilders.stattrackers.DependableTracker; import nautilus.game.arcade.game.games.speedbuilders.stattrackers.FirstBuildTracker; import nautilus.game.arcade.game.games.speedbuilders.stattrackers.PerfectionistTracker; @@ -190,6 +192,8 @@ public class SpeedBuilders extends SoloGame new SpeediestBuilderizerTracker(this), new BlockPlaceStatTracker(this, new Material[] {}) ); + + registerQuestTrackers(new PerfectBuildQuestTracker(this)); registerChatStats( new ChatStatData("BlocksPlaced", "Blocks Placed", true), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/quests/PerfectBuildQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/quests/PerfectBuildQuestTracker.java new file mode 100644 index 000000000..937e97bbd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/quests/PerfectBuildQuestTracker.java @@ -0,0 +1,29 @@ +package nautilus.game.arcade.game.games.speedbuilders.quests; + +import org.bukkit.event.EventHandler; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; +import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * PerfectBuildQuestTracker + * + * @author xXVevzZXx + */ +public class PerfectBuildQuestTracker extends QuestTracker +{ + + public PerfectBuildQuestTracker(SpeedBuilders game) + { + super(game, TriggerType.COLLECT); + } + + @EventHandler + public void onPerfectBuild(PerfectBuildEvent event) + { + incrementQuests(event.getPlayer(), "Perfect Build", 1); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index 7596dc85c..d9477949f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -112,6 +112,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.ChestRefillEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; @@ -1485,7 +1486,11 @@ public abstract class SurvivalGames extends Game public void refillChests() { ArrayList list = new ArrayList(_lootedBlocks); - + + ChestRefillEvent event = UtilServer.CallEvent(new ChestRefillEvent(list)); + if (event.isCancelled()) + return; + _lootedBlocks.clear(); WorldServer world = list.isEmpty() ? null : ((CraftWorld) list.get(0) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index ce027ddac..8b5778f94 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -103,6 +103,7 @@ import nautilus.game.arcade.game.games.AbsorptionFix; import nautilus.game.arcade.game.games.uhc.components.UHCBorder; import nautilus.game.arcade.game.games.uhc.components.UHCFreezer; import nautilus.game.arcade.game.games.uhc.components.UHCSpeedMode; +import nautilus.game.arcade.game.games.uhc.quests.TameQuestTracker; import nautilus.game.arcade.game.games.uhc.stat.CollectFoodStat; import nautilus.game.arcade.game.games.uhc.stat.HalfHeartHealStat; import nautilus.game.arcade.game.games.uhc.stat.HoeCraftingStat; @@ -294,6 +295,8 @@ public abstract class UHC extends Game registerStatTrackers(new CollectFoodStat(this), new HoeCraftingStat(this), new LuckyMinerStat(this), new HalfHeartHealStat(this)); + registerQuestTrackers(new TameQuestTracker(this)); + registerDebugCommand(new DebugCommand("startpvp", Rank.ADMIN) { @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/quests/TameQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/quests/TameQuestTracker.java new file mode 100644 index 000000000..a8aebc673 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/quests/TameQuestTracker.java @@ -0,0 +1,38 @@ +package nautilus.game.arcade.game.games.uhc.quests; + +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityTameEvent; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.games.uhc.UHC; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * TameQuestTracker + * + * @author xXVevzZXx + */ +public class TameQuestTracker extends QuestTracker +{ + + public TameQuestTracker(UHC game) + { + super(game, TriggerType.COLLECT); + } + + @EventHandler + public void tameEvent(EntityTameEvent event) + { + if (!getGame().IsLive()) + return; + + if (event.getEntityType() != EntityType.HORSE) + return; + + incrementQuests((Player) event.getOwner(), "Tamed Horse", 1); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java new file mode 100644 index 000000000..98799b6c9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java @@ -0,0 +1,57 @@ +package nautilus.game.arcade.quest; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.Game; + +/** + * ChestOpenQuestTracker + * + * @author xXVevzZXx + */ +public class ChestOpenQuestTracker extends QuestTracker +{ + private HashMap> _usedChests = new HashMap<>(); + + public ChestOpenQuestTracker(Game game) + { + super(game, TriggerType.COLLECT); + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void chestRegister(PlayerInteractEvent event) + { + if (!getGame().IsLive()) + return; + + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (event.getClickedBlock().getType() != Material.CHEST) + return; + + if (!_usedChests.containsKey(event.getPlayer())) + _usedChests.put(event.getPlayer(), new ArrayList<>()); + + ArrayList locs = _usedChests.get(event.getPlayer()); + + if (locs.contains(event.getClickedBlock().getLocation())) + return; + + locs.add(event.getClickedBlock().getLocation()); + + incrementQuests((Player) event.getPlayer(), "Chest", 1); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java index cf8b584f8..ea91d9382 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java @@ -2,14 +2,23 @@ package nautilus.game.arcade.quest; import java.util.ArrayList; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Chest; +import org.bukkit.block.DoubleChest; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import mineplex.core.quests.TriggerType; +import nautilus.game.arcade.events.ChestRefillEvent; import nautilus.game.arcade.game.Game; /** @@ -17,27 +26,94 @@ import nautilus.game.arcade.game.Game; * * @author xXVevzZXx */ -public class CollectQuestTracker extends QuestTracker +public class CollectQuestTracker extends QuestTracker { - private ArrayList _alreadyCounted; + private ArrayList _itemsAvailable = new ArrayList<>(); + private ArrayList _usedChests = new ArrayList<>(); public CollectQuestTracker(Game game) { super(game, TriggerType.COLLECT); + } + + @EventHandler(priority=EventPriority.LOWEST) + public void chestRefill(ChestRefillEvent event) + { + if (event.isCancelled()) + return; - _alreadyCounted = new ArrayList<>(); + _usedChests.clear(); + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void chestRegister(PlayerInteractEvent event) + { + if (!getGame().IsLive()) + return; + + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (event.getClickedBlock().getType() != Material.CHEST) + return; + + if (_usedChests.contains(event.getClickedBlock().getLocation())) + return; + + Chest chest = (Chest) event.getClickedBlock().getState(); + + if (chest instanceof DoubleChest) + { + DoubleChest doubleChest = (DoubleChest) chest; + for (ItemStack item : doubleChest.getLeftSide().getInventory()) + { + if (item == null) + continue; + + _itemsAvailable.add(item); + } + for (ItemStack item : doubleChest.getRightSide().getInventory()) + { + if (item == null) + continue; + + _itemsAvailable.add(item); + } + } + else if (chest instanceof Chest) + { + for (ItemStack item : chest.getInventory()) + { + if (item == null) + continue; + + _itemsAvailable.add(item); + } + } + + _usedChests.add(event.getClickedBlock().getLocation()); } @EventHandler public void collectItem(InventoryClickEvent event) { + if (!getGame().IsLive()) + return; + if (event.getClickedInventory() instanceof PlayerInventory) return; - System.out.println(event.getCurrentItem().getType().toString()); - _alreadyCounted.add(event.getCurrentItem()); + if (!_itemsAvailable.contains(event.getCurrentItem())) + return; - incrementQuests((Player) event.getWhoClicked(), event.getCurrentItem().getType().toString(), 1); + _itemsAvailable.remove(event.getCurrentItem()); + + String item = event.getCurrentItem().getType().toString(); + + if (event.getCurrentItem().hasItemMeta()) + item = event.getCurrentItem().getItemMeta().getDisplayName(); + + incrementQuests((Player) event.getWhoClicked(), ChatColor.stripColor(item), event.getCurrentItem().getAmount()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillEntityQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillEntityQuestTracker.java new file mode 100644 index 000000000..9c9ca24e0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillEntityQuestTracker.java @@ -0,0 +1,55 @@ +package nautilus.game.arcade.quest; + +import net.md_5.bungee.api.ChatColor; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.Game; + +/** + * KillEntityQuestTracker + * + * @author xXVevzZXx + */ +public class KillEntityQuestTracker extends QuestTracker +{ + + public KillEntityQuestTracker(Game game) + { + super(game, TriggerType.KILL); + } + + @EventHandler + public void killEntity(EntityDamageByEntityEvent event) + { + if (!getGame().IsLive()) + return; + + Entity entity = event.getEntity(); + + if (entity instanceof Player) + return; + + if (!(event.getDamager() instanceof Player)) + return; + + LivingEntity lEntity = (LivingEntity) entity; + + if (lEntity.getHealth() > 0) + return; + + String name = lEntity.getType().getName(); + + if (lEntity.isCustomNameVisible()) + name = lEntity.getCustomName(); + + incrementQuests((Player) event.getDamager(), ChatColor.stripColor(name), 1); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java index b4e82c4dc..be4f5ad12 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java @@ -13,7 +13,7 @@ import nautilus.game.arcade.game.Game; * * @author xXVevzZXx */ -public class KillQuestTracker extends QuestTracker +public class KillQuestTracker extends QuestTracker { public KillQuestTracker(Game game) @@ -24,6 +24,9 @@ public class KillQuestTracker extends QuestTracker @EventHandler public void onKil(EntityDamageByEntityEvent event) { + if (!getGame().IsLive()) + return; + if (!(event.getDamager() instanceof Player)) return; @@ -33,7 +36,7 @@ public class KillQuestTracker extends QuestTracker if (((Player) event.getEntity()).getHealth() > 0) return; - incrementQuests((Player) event.getDamager(), 1); + incrementQuests((Player) event.getDamager(), "Player", 1); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ParticipateQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ParticipateQuestTracker.java new file mode 100644 index 000000000..a9035ca7a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ParticipateQuestTracker.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.quest; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.Arcade; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; + +/** + * ParticipateQuestTracker + * + * @author xXVevzZXx + */ +public class ParticipateQuestTracker extends QuestTracker +{ + + public ParticipateQuestTracker(Game game) + { + super(game, TriggerType.COMPLETE); + } + + @EventHandler + public void completeGame(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + return; + + for (Player player : getGame().GetPlayers(true)) + incrementQuests(player, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), 1); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/PlayGameQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/PlayGameQuestTracker.java new file mode 100644 index 000000000..5cb917107 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/PlayGameQuestTracker.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.quest; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.Arcade; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; + +/** + * PlayGameQuestTracker + * + * @author xXVevzZXx + */ +public class PlayGameQuestTracker extends QuestTracker +{ + + public PlayGameQuestTracker(Game game) + { + super(game, TriggerType.PLAY); + } + + @EventHandler + public void gameStart(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + + for (Player player : getGame().GetPlayers(true)) + incrementQuests(player, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), 1); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java index c6ec9d2d1..f3f03090e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java @@ -3,7 +3,6 @@ package nautilus.game.arcade.quest; import org.bukkit.entity.Player; import org.bukkit.event.Listener; -import mineplex.core.game.GameDisplay; import mineplex.core.quests.Quest; import mineplex.core.quests.QuestClientData; import mineplex.core.quests.TriggerType; @@ -15,18 +14,18 @@ import nautilus.game.arcade.game.Game; * * @author xXVevzZXx */ -public class QuestTracker implements Listener +public class QuestTracker implements Listener { - private Game _game; + private T _game; private TriggerType _trigger; - public QuestTracker(Game game, TriggerType type) + public QuestTracker(T game, TriggerType type) { _game = game; _trigger = type; } - public Game getGame() + public T getGame() { return _game; } @@ -47,14 +46,17 @@ public class QuestTracker implements Listener { for (Quest quest : getGame().getArcadeManager().getQuestManager().getAvailableQuests()) { - if (getGame().GetType().getDisplay() != quest.getGame()) + if (getGame().GetType().getDisplay() != quest.getGame() && getGame().GetType().getDisplay().getGameCategory() != quest.getGameCategory()) continue; if (quest.getTrigger() != _trigger) continue; - if (!quest.getItem().equalsIgnoreCase(item)) - continue; + if (!quest.getItem().equalsIgnoreCase("")) + { + if (!quest.getItem().equalsIgnoreCase(item)) + continue; + } QuestClientData data = _game.getArcadeManager().getQuestManager().Get(player); if (!data.hasQuest(quest)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/WinQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/WinQuestTracker.java index 183ee7f60..4bcf45ab9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/WinQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/WinQuestTracker.java @@ -3,8 +3,10 @@ package nautilus.game.arcade.quest; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import mineplex.core.common.util.UtilServer; import mineplex.core.quests.TriggerType; +import nautilus.game.arcade.Arcade; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; @@ -14,7 +16,7 @@ import nautilus.game.arcade.game.Game.GameState; * * @author xXVevzZXx */ -public class WinQuestTracker extends QuestTracker +public class WinQuestTracker extends QuestTracker { public WinQuestTracker(Game game) @@ -30,7 +32,7 @@ public class WinQuestTracker extends QuestTracker for (Player player : getGame().getWinners()) { - incrementQuests(player, 1); + incrementQuests(player, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), 1); } } From 321acce3c39021c3c51dc06d0b0459a47fe28629 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 13 May 2017 15:34:13 +0100 Subject: [PATCH 018/283] Make Bob Ross an invisible kit --- .../nautilus/game/arcade/game/games/moba/Moba.java | 2 +- .../game/arcade/game/games/moba/kit/HeroKit.java | 12 ++++++++++++ .../game/arcade/game/games/moba/kit/bob/HeroBob.java | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index aaf8d4cb6..9c1bc4e7e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -603,7 +603,7 @@ public class Moba extends TeamGame for (HeroKit kit : _kits) { - if (kit.getRole() == role) + if (kit.getRole() == role && kit.isVisible()) { kits.add(kit); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 276e92374..7b93f23b8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -39,6 +39,8 @@ public class HeroKit extends Kit .addLore("Clicking this item will teleport you back to your", "base after " + F.time("5") + " seconds.", "Taking damage or moving will cancel", "your teleport.") .build(); + private boolean _visible = true; + public HeroKit(ArcadeManager manager, String name, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand, MobaRole role) { super(manager, name, KitAvailability.Free, kitDesc, kitPerks, null, itemInHand); @@ -190,4 +192,14 @@ public class HeroKit extends Kit } } } + + public boolean isVisible() + { + return _visible; + } + + public void setVisible(boolean visible) + { + _visible = visible; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java index 82ad6b064..bffc5c1d3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java @@ -35,6 +35,7 @@ public class HeroBob extends HeroKit setAmmo(AMMO, 500); setMaxAmmo(8); + setVisible(false); } } From 85a384bad735e18734e4784e92519003adf97b90 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 13 May 2017 15:34:39 +0100 Subject: [PATCH 019/283] Unneeded if statement --- .../game/games/moba/kit/common/DashSkill.java | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java index b9e51c378..e3ff6f068 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -186,29 +186,21 @@ public class DashSkill extends HeroSkill continue; } - // If allowing collisions with players - if (entity instanceof Player) + // If not allowing collisions with players + if (!_collidePlayers) { - if (!_collidePlayers) - { - continue; - } - - boolean sameTeam = isTeamDamage(entity, player); - - // If their teams are the same and we don't allow collisions with teammates, ignore - if (sameTeam && !_collideTeammates) - { - continue; - } - - collideEntity(entity, player, scale, sameTeam); + continue; } - // Any other entities and if we allow collisions with them - else if (_collideEntities) + + boolean sameTeam = isTeamDamage(entity, player); + + // If their teams are the same and we don't allow collisions with teammates, ignore + if (sameTeam && !_collideTeammates) { - collideEntity(entity, player, scale, false); + continue; } + + collideEntity(entity, player, scale, sameTeam); } } From bc5a9a1d5e9f287b785818643e26f4bfdbe878be Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 13 May 2017 15:34:49 +0100 Subject: [PATCH 020/283] Healing particle standard --- .../game/games/moba/kit/bob/SkillHappyTrees.java | 5 +++-- .../game/games/moba/kit/dana/SkillRally.java | 3 ++- .../game/games/moba/util/MobaParticles.java | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java index 3b429be01..4f18d3ae3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaParticles; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -55,7 +56,7 @@ public class SkillHappyTrees extends HeroSkill @EventHandler public void update(UpdateEvent event) { - if (event.getType() != UpdateType.FASTEST) + if (event.getType() != UpdateType.FASTER) { return; } @@ -152,7 +153,7 @@ public class SkillHappyTrees extends HeroSkill } entity.setHealth(Math.min(entity.getHealth() + 2, entity.getMaxHealth())); - UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 4, ViewDist.LONG); + MobaParticles.healing(entity, 3); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index c0ac9b8a2..df4d3f0a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -8,6 +8,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaParticles; import org.bukkit.*; import org.bukkit.block.Banner; import org.bukkit.block.Block; @@ -101,7 +102,7 @@ public class SkillRally extends HeroSkill continue; } - UtilParticle.PlayParticleToAll(ParticleType.HEART, nearby.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 1, ViewDist.LONG); + MobaParticles.healing(nearby, 3); Manager.GetCondition().Factory().Regen(GetName(), nearby, data.Owner, 3, 1, false, true, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java new file mode 100644 index 000000000..ce6024784 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java @@ -0,0 +1,16 @@ +package nautilus.game.arcade.game.games.moba.util; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import org.bukkit.entity.LivingEntity; + +public class MobaParticles +{ + + public static void healing(LivingEntity entity, int amount) + { + UtilParticle.PlayParticleToAll(ParticleType.HEART, entity.getEyeLocation(), 0.5F, 0.5F, 0.5F, 0.1F, amount, ViewDist.LONG); + } + +} From 5edbddb3d22fc4c9e7b4651db31b605215f04686 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 13 May 2017 17:30:59 +0100 Subject: [PATCH 021/283] Make MobaItemEffect abstract --- .../game/games/moba/shop/MobaItemEffect.java | 20 +++++++++++++------ .../moba/shop/effects/MobaCDREffect.java | 20 +------------------ .../moba/shop/effects/MobaHPRegenEffect.java | 20 +------------------ .../moba/shop/effects/MobaKillHealEffect.java | 17 +--------------- .../moba/shop/effects/MobaSpeedEffect.java | 17 +--------------- .../shop/effects/MobaTotalHealthEffect.java | 19 +----------------- 6 files changed, 19 insertions(+), 94 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java index d04f2d149..6c55b15b9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -5,17 +5,25 @@ import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import org.bukkit.entity.Player; -public interface MobaItemEffect +public abstract class MobaItemEffect { - void onCooldownCheck(CooldownCalculateEvent event); + protected void onCooldownCheck(CooldownCalculateEvent event) + { + } - void onDeath(Player killed, Player killer); + protected void onDeath(Player killed, Player killer) + { + } - void onHPRegen(MobaHPRegenEvent event); + protected void onHPRegen(MobaHPRegenEvent event) + { + } - void onRespawn(PlayerGameRespawnEvent event); + protected void onRespawn(PlayerGameRespawnEvent event) + { + } - String getDescription(); + public abstract String getDescription(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java index f3a64be2a..8b139c25c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java @@ -1,13 +1,10 @@ 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 implements MobaItemEffect +public class MobaCDREffect extends MobaItemEffect { private double _factor; @@ -23,21 +20,6 @@ public class MobaCDREffect implements 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() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java index dabdddf48..8e0b2491f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java @@ -1,13 +1,10 @@ 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 +public class MobaHPRegenEffect extends MobaItemEffect { private double _factor; @@ -17,27 +14,12 @@ public class MobaHPRegenEffect implements MobaItemEffect _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() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java index d869a752f..da364fee6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -8,7 +8,7 @@ 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 implements MobaItemEffect +public class MobaKillHealEffect extends MobaItemEffect { private double _health; @@ -18,27 +18,12 @@ public class MobaKillHealEffect implements 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() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java index 41cf6e3e8..41aee38b9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java @@ -7,7 +7,7 @@ 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 +public class MobaSpeedEffect extends MobaItemEffect { private double _factor; @@ -17,21 +17,6 @@ public class MobaSpeedEffect implements MobaItemEffect _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) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java index 2fe9565b4..2cce7bb6d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java @@ -3,12 +3,10 @@ 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 +public class MobaTotalHealthEffect extends MobaItemEffect { private int _health; @@ -18,21 +16,6 @@ public class MobaTotalHealthEffect implements MobaItemEffect _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) { From c3b5b9a8bdca2983d434d02b62b4f18592c96406 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 14 May 2017 11:41:09 +0100 Subject: [PATCH 022/283] Implement shops for all roles --- .../game/arcade/game/games/moba/Moba.java | 123 +++++++---- .../games/moba/fountain/MobaFountain.java | 2 +- .../game/games/moba/kit/AmmoGiveEvent.java | 54 +++++ .../moba/kit/CooldownCalculateEvent.java | 9 +- .../arcade/game/games/moba/kit/HeroKit.java | 45 ++-- .../arcade/game/games/moba/kit/HeroSkill.java | 9 +- .../game/games/moba/kit/anath/HeroAnath.java | 2 +- .../games/moba/kit/anath/SkillBurnBeam.java | 3 +- .../moba/kit/anath/SkillFireProjectile.java | 3 +- .../games/moba/kit/anath/SkillMeteor.java | 3 +- .../game/games/moba/kit/bob/HeroBob.java | 4 +- .../games/moba/kit/bob/SkillHappyTrees.java | 2 +- .../game/games/moba/kit/dana/SkillRally.java | 5 +- .../game/games/moba/kit/devon/HeroDevon.java | 1 + .../games/moba/kit/devon/SkillInfinity.java | 11 +- .../games/moba/kit/hattori/SkillSnowball.java | 2 +- .../arcade/game/games/moba/recall/Recall.java | 4 +- .../arcade/game/games/moba/shop/MobaItem.java | 2 +- .../game/games/moba/shop/MobaItemEffect.java | 34 +++ .../arcade/game/games/moba/shop/MobaShop.java | 97 +++++++- .../games/moba/shop/MobaShopCategoryMenu.java | 9 +- .../shop/effects/MobaAbilityDamageEffect.java | 37 ++++ .../shop/effects/MobaAmmoIncreaseEffect.java | 28 +++ .../effects/MobaBasicAttackDamageEffect.java | 36 +++ .../moba/shop/effects/MobaCDRAmmoEffect.java | 34 +++ .../moba/shop/effects/MobaCDREffect.java | 8 +- .../effects/MobaConditionImmunityEffect.java | 32 +++ .../moba/shop/effects/MobaHPRegenEffect.java | 2 +- .../shop/effects/MobaHitArrowAmmoEffect.java | 36 +++ .../shop/effects/MobaHitArrowHealEffect.java | 37 ++++ .../shop/effects/MobaHitConditionEffect.java | 56 +++++ .../moba/shop/effects/MobaKillHealEffect.java | 2 +- .../moba/shop/effects/MobaSpeedEffect.java | 2 +- .../shop/effects/MobaTotalHealthEffect.java | 2 +- .../moba/shop/hunter/MobaHunterShop.java | 207 ++++++++++++++++++ .../games/moba/shop/mage/MobaMageShop.java | 152 +++++++++++++ .../moba/shop/warrior/MobaWarriorShop.java | 201 +++++++++++++++++ .../game/games/moba/util/MobaConstants.java | 10 + .../game/games/moba/util/MobaParticles.java | 2 +- 39 files changed, 1209 insertions(+), 99 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/AmmoGiveEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAmmoIncreaseEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDRAmmoEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaConditionImmunityEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowHealEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 9c1bc4e7e..7ffeea140 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -33,6 +33,7 @@ import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.Location; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; @@ -118,14 +119,21 @@ public class Moba extends TeamGame new CustomScoreboardModule() .setSidebar((player, scoreboard) -> { - scoreboard.writeNewLine(); + GameState state = GetState(); - scoreboard.write("Testing"); - - int gold = _goldManager.getGold(player); - scoreboard.write("Gold " + gold); - - scoreboard.writeNewLine(); + switch (state) + { + case Prepare: + writePrepare(player, scoreboard); + break; + case Live: + writeLive(player, scoreboard); + break; + case End: + case WinRoom: + writeEnd(player, scoreboard); + break; + } }) .setPrefix((perspective, subject) -> { @@ -138,6 +146,34 @@ public class Moba extends TeamGame return team.GetColor().toString(); }) + .setSuffix((perspective, subject) -> + { + if (!IsAlive(subject)) + { + return ""; + } + + GameState state = GetState(); + GameTeam perspectiveTeam = GetTeam(perspective); + GameTeam subjectTeam = GetTeam(subject); + MobaPlayer mobaPlayer = getData(subject); + String suffix; + + if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam)) + { + suffix = "Unknown"; + } + else if (mobaPlayer.Kit == null) + { + suffix = "Selecting"; + } + else + { + suffix = mobaPlayer.Kit.GetName(); + } + + return C.cYellow + " " + suffix + C.Reset; + }) .register(this); registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) @@ -233,68 +269,65 @@ public class Moba extends TeamGame _listeners.forEach(UtilServer::RegisterEvents); } - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) + private void writePrepare(Player player, GameScoreboard scoreboard) { - if (event.getType() != UpdateType.FAST) - { - return; - } + MobaPlayer mobaPlayer = getData(player); - GameState state = GetState(); + scoreboard.writeNewLine(); - switch (state) - { - case Prepare: - writePrepare(); - break; - case Live: - writeLive(); - break; - case End: - writeEnd(); - break; - default: - return; - } + scoreboard.write(C.cYellowB + "Hero Selection"); + scoreboard.write(UtilTime.MakeStr(GetStateTime() + PREPARE_TIME - System.currentTimeMillis())); - Scoreboard.draw(); - } + scoreboard.writeNewLine(); - private void writePrepare() - { - Scoreboard.writeNewLine(); + scoreboard.write(C.cYellowB + "Hero"); + scoreboard.write(mobaPlayer.Kit == null ? "Unselected " : mobaPlayer.Kit.GetName() + " (" + mobaPlayer.Role.getName() + ")"); - Scoreboard.write(C.cYellowB + "Hero Selection"); - Scoreboard.write(UtilTime.MakeStr(GetStateTime() + PREPARE_TIME - System.currentTimeMillis())); + scoreboard.writeNewLine(); - Scoreboard.writeNewLine(); - - Scoreboard.write(C.cYellowB + "Players"); + scoreboard.write(C.cYellowB + "Players"); int kits = 0; - for (MobaPlayer player : _playerData) + for (MobaPlayer otherMobaPlayer : _playerData) { - if (player.Kit != null) + if (otherMobaPlayer.Kit != null) { kits++; } } - Scoreboard.write(kits + "/" + GetPlayers(true).size()); + scoreboard.write(kits + "/" + GetPlayers(true).size()); - Scoreboard.writeNewLine(); + scoreboard.writeNewLine(); } - private void writeLive() + private void writeLive(Player player, GameScoreboard scoreboard) { + scoreboard.writeNewLine(); + if (IsAlive(player)) + { + int gold = _goldManager.getGold(player); + + scoreboard.write(C.cGoldB + "Gold"); + scoreboard.write(String.valueOf(gold)); + } + else + { + scoreboard.write("You are dead lol"); + } + + + scoreboard.writeNewLine(); } - private void writeEnd() + private void writeEnd(Player player, GameScoreboard scoreboard) { + scoreboard.writeNewLine(); + scoreboard.write("Game Over"); + + scoreboard.writeNewLine(); } @EventHandler(priority = EventPriority.LOWEST) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java index c77112f5c..f5c1027b9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java @@ -22,7 +22,7 @@ import java.util.Map.Entry; public class MobaFountain implements Listener { - private static final int FOUNTAIN_SIZE_SQUARED = 5; + private static final int FOUNTAIN_SIZE_SQUARED = 25; private final Moba _host; private final Map _average; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/AmmoGiveEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/AmmoGiveEvent.java new file mode 100644 index 000000000..9bb26419a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/AmmoGiveEvent.java @@ -0,0 +1,54 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class AmmoGiveEvent extends PlayerEvent +{ + + private static final HandlerList _handlers = new HandlerList(); + + private int _ammoToGive; + private int _maxAmmo; + + public AmmoGiveEvent(Player who, int ammoToGive, int maxAmmo) + { + super(who); + + _ammoToGive = ammoToGive; + _maxAmmo = maxAmmo; + } + + public void setAmmoToGive(int ammo) + { + _ammoToGive = ammo; + } + + public int getAmmoToGive() + { + return _ammoToGive; + } + + public void setMaxAmmo(int ammo) + { + _maxAmmo = ammo; + } + + public int getMaxAmmo() + { + return _maxAmmo; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java index caeab4cfa..e2df2cc62 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java @@ -10,16 +10,23 @@ public class CooldownCalculateEvent extends PlayerEvent private static final HandlerList _handlers = new HandlerList(); private final long _initialCooldown; + private final String _ability; private long _cooldown; - public CooldownCalculateEvent(Player who, long cooldown) + public CooldownCalculateEvent(Player who, String ability, long cooldown) { super(who); _initialCooldown = cooldown; + _ability = ability; _cooldown = cooldown; } + public String getAbility() + { + return _ability; + } + public void setCooldown(long cooldown) { _cooldown = cooldown; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 7b93f23b8..04ebb87b0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -1,9 +1,6 @@ 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.common.util.*; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -12,6 +9,7 @@ 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.game.games.moba.util.MobaConstants; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; @@ -112,32 +110,47 @@ public class HeroKit extends Kit continue; } - ItemStack itemStack = player.getInventory().getItem(AMMO_SLOT); long giveTime = _giveTime; - //TODO shop cooldown reduction - - if (!Recharge.Instance.use(player, "Ammo", giveTime, false, false)) + if (!Recharge.Instance.usable(player, MobaConstants.AMMO)) { continue; } - if (itemStack == null) - { - itemStack = _ammo; - player.getInventory().setItem(AMMO_SLOT, itemStack); - continue; - } + CooldownCalculateEvent cooldownEvent = new CooldownCalculateEvent(player, MobaConstants.AMMO, giveTime); + UtilServer.CallEvent(cooldownEvent); - if (itemStack.getAmount() >= _maxAmmo) + if (!Recharge.Instance.use(player, MobaConstants.AMMO, cooldownEvent.getCooldown(), false, false)) { continue; } - itemStack.setAmount(itemStack.getAmount() + 1); + giveAmmo(player, 1); } } + public void giveAmmo(Player player, int amount) + { + ItemStack itemStack = player.getInventory().getItem(AMMO_SLOT); + + AmmoGiveEvent event = new AmmoGiveEvent(player, amount, _maxAmmo); + UtilServer.CallEvent(event); + + if (itemStack == null) + { + itemStack = _ammo; + player.getInventory().setItem(AMMO_SLOT, itemStack); + return; + } + + if (itemStack.getAmount() >= event.getMaxAmmo()) + { + return; + } + + itemStack.setAmount(itemStack.getAmount() + event.getAmmoToGive()); + } + @Override public void GiveItems(Player player) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 9f228b05c..97c682495 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -240,7 +240,7 @@ public class HeroSkill extends Perk long cooldown = _cooldown; // Modify the cooldown with respect to the upgrade items purchased from the shop - CooldownCalculateEvent cooldownEvent = new CooldownCalculateEvent(player, cooldown); + CooldownCalculateEvent cooldownEvent = new CooldownCalculateEvent(player, GetName(), cooldown); UtilServer.CallEvent(cooldownEvent); cooldown = cooldownEvent.getCooldown(); @@ -255,7 +255,10 @@ public class HeroSkill extends Perk else { long timeDiff = current - start; - double amount = (int) (cooldown / 1000) - Math.ceil((double) timeDiff / 1000); + // Work out the itemstack amount based on the cooldowns. + // Adding 1 as due to the nature of cooldowns it seems to take much longer to go + // from 2 -> 1 -> 0 as the itemstack doesn't change + double amount = (cooldown / 1000) - Math.ceil((double) timeDiff / 1000) + 1; if (itemStack == null) { @@ -316,7 +319,7 @@ public class HeroSkill extends Perk protected boolean isTeamDamage(LivingEntity damagee, LivingEntity damager) { - if (!(damagee instanceof Player || damager instanceof Player)) + if (!(damagee instanceof Player) || !(damager instanceof Player)) { return false; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java index d4ef4a78f..b7f805b65 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java @@ -31,7 +31,7 @@ public class HeroAnath extends HeroKit public HeroAnath(ArcadeManager manager) { - super(manager, "Anath the Unsworn", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); + super(manager, "Anath", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); setAmmo(AMMO, 1000); setMaxAmmo(4); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java index e4289850a..752d81e78 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; import org.bukkit.Sound; @@ -81,7 +82,7 @@ public class SkillBurnBeam extends HeroSkill for (LivingEntity entity : UtilEnt.getInRadius(particle.getLastLocation(), 2).keySet()) { - if (entity.equals(player)) + if (entity.equals(player) || !Recharge.Instance.use(player, GetName() + entity.getName() + player.getName(), 2000, false, false)) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 895064ae7..0ac1d5c5e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.kit.anath; import mineplex.core.common.util.UtilEvent.ActionType; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Material; import org.bukkit.entity.Item; import org.bukkit.entity.Player; @@ -44,6 +45,6 @@ public class SkillFireProjectile extends HeroSkill Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), _kit.getAmmo()); item.setVelocity(direction); - Manager.GetFire().Add(item, player, 3, 0, 1, 5, GetName(), false); + Manager.GetFire().Add(item, player, 3, 0, 1, 5, MobaConstants.BASIC_ATTACK, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index 3fa7a24b7..89fee9780 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -62,7 +62,7 @@ public class SkillMeteor extends HeroSkill implements IThrown FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.NETHERRACK, (byte) 0); block.setVelocity(player.getLocation().getDirection()); - Manager.GetProjectile().AddThrow(block, player, this, 2000, true, true, true, false, 0.5F); + Manager.GetProjectile().AddThrow(block, player, this, 1000, true, true, true, false, 0.5F); useActiveSkill(player, 7000); } @@ -153,6 +153,7 @@ public class SkillMeteor extends HeroSkill implements IThrown } startShower(data); + data.getThrown().remove(); } private void startShower(ProjectileUser data) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java index bffc5c1d3..89b56fa7f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java @@ -26,12 +26,12 @@ public class HeroBob extends HeroKit private static final ItemStack IN_HAND = new ItemStack(Material.PAINTING); private static final ItemStack AMMO = new ItemBuilder(Material.SNOW_BALL) - .setTitle(C.cYellowB + "Paint") + .setTitle(C.cYellowB + "Titanium Hwhite") .build(); public HeroBob(ArcadeManager manager) { - super(manager, "Robert Ross", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); + super(manager, "Bob Ross", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); setAmmo(AMMO, 500); setMaxAmmo(8); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java index 4f18d3ae3..801f63ba4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java @@ -153,7 +153,7 @@ public class SkillHappyTrees extends HeroSkill } entity.setHealth(Math.min(entity.getHealth() + 2, entity.getMaxHealth())); - MobaParticles.healing(entity, 3); + MobaParticles.healing(entity, 1); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index df4d3f0a1..ef24c59c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -102,7 +102,10 @@ public class SkillRally extends HeroSkill continue; } - MobaParticles.healing(nearby, 3); + if (Math.random() > 0.75) + { + MobaParticles.healing(nearby, 1); + } Manager.GetCondition().Factory().Regen(GetName(), nearby, data.Owner, 3, 1, false, true, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java index b7bd131c5..f40f3db4e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -28,6 +28,7 @@ public class HeroDevon extends HeroKit private static final ItemStack AMMO = new ItemBuilder(Material.ARROW) .setTitle(C.cYellowB + "Hunting Arrow") + .setUnbreakable(true) .build(); public HeroDevon(ArcadeManager manager) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 279dd195f..395955bad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -14,6 +14,7 @@ import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -118,7 +119,7 @@ public class SkillInfinity extends HeroSkill } } - UtilAction.velocity(nearby, UtilAlg.getTrajectory(entity.getLocation(), nearby.getLocation().add(0, 1.5, 0))); + UtilAction.velocity(entity, UtilAlg.getTrajectory(entity.getLocation(), nearby.getLocation().add(0, 1.5, 0))); } } } @@ -126,11 +127,6 @@ public class SkillInfinity extends HeroSkill @EventHandler public void arrowDamage(CustomDamageEvent event) { - if (event.GetProjectile() == null) - { - return; - } - if (_arrows.containsKey(event.GetProjectile())) { Bukkit.broadcastMessage("Wither"); @@ -141,7 +137,8 @@ public class SkillInfinity extends HeroSkill @EventHandler public void projectileHit(ProjectileHitEvent event) { - _arrows.remove(event.getEntity()); + // Delay this as the when the CustomDamageEvent is run. The arrow is already removed from the map. + Manager.runSyncLater(() -> _arrows.remove(event.getEntity()), 1); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 9eef19c67..eeb1c0f57 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -75,7 +75,7 @@ public class SkillSnowball extends HeroSkill implements IThrown 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()); + Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.CUSTOM, 3, true, true, false, UtilEnt.getName(thrower), GetName()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java index ebf2a3a83..2725ecf1f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java @@ -96,7 +96,7 @@ public class Recall implements Listener } else { - Location location = player.getLocation().add(0, 0.25, 0); + Location location = session.Location.clone(); double height = (double) (now - session.Start) / (double) RECALL_TIME; for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 10) @@ -104,7 +104,7 @@ public class Recall implements Listener double x = PARTICLE_RADIUS * Math.sin(theta); double z = PARTICLE_RADIUS * Math.cos(theta); - for (double y = 0; y < height * PARTICLE_HEIGHT; y += 0.5) + for (double y = 0.25; y < height * PARTICLE_HEIGHT; y += 0.5) { location.add(x, y, z); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java index dd5f49e9f..576bc305c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java @@ -34,7 +34,7 @@ public class MobaItem public ItemStack getItem() { - ItemBuilder builder = new ItemBuilder(_item); + ItemBuilder builder = new ItemBuilder(_item).setUnbreakable(true); if (getEffects() != null) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java index 6c55b15b9..6adeb01db 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -1,17 +1,47 @@ package nautilus.game.arcade.game.games.moba.shop; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; +import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import org.bukkit.entity.Player; +import java.text.DecimalFormat; + public abstract class MobaItemEffect { + private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.#"); + + protected static String format(double d) + { + return DECIMAL_FORMAT.format(d); + } + + protected static String format(ConditionType conditionType, int multi) + { + String condition = conditionType.toString().toLowerCase(); + char first = Character.toUpperCase(condition.charAt(0)); + condition = first + condition.substring(1); + + return condition + (multi == -1 ? "" : " " + (multi + 1)); + } + + protected void onAmmoGive(AmmoGiveEvent event) + { + } + protected void onCooldownCheck(CooldownCalculateEvent event) { } + protected void onDamage(CustomDamageEvent event) + { + } + protected void onDeath(Player killed, Player killer) { } @@ -24,6 +54,10 @@ public abstract class MobaItemEffect { } + protected void onCondition(ConditionApplyEvent event) + { + } + public abstract String getDescription(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index c64ddcc16..1ef2b3511 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -5,6 +5,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatComponent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; @@ -13,9 +14,12 @@ 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.AmmoGiveEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; -import nautilus.game.arcade.game.games.moba.shop.MobaShopMenu.MobaCategoryButton; import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop; +import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; +import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop; +import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Entity; @@ -24,13 +28,14 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; public class MobaShop implements Listener @@ -50,6 +55,9 @@ public class MobaShop implements Listener // Create menus _roleMenus.put(MobaRole.ASSASSIN, new MobaAssassinShop(host, this)); + _roleMenus.put(MobaRole.WARRIOR, new MobaWarriorShop(host, this)); + _roleMenus.put(MobaRole.HUNTER, new MobaHunterShop(host, this)); + _roleMenus.put(MobaRole.MAGE, new MobaMageShop(host, this)); } @EventHandler @@ -177,8 +185,9 @@ public class MobaShop implements Listener // 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 + // Prevents infinite speed player.setWalkSpeed(0.2F); + player.setMaxHealth(20); PlayerGameRespawnEvent fakeEvent = new PlayerGameRespawnEvent(null, player); @@ -239,7 +248,27 @@ public class MobaShop implements Listener } @EventHandler - public void hpRegeneration(CooldownCalculateEvent event) + public void ammoGive(AmmoGiveEvent event) + { + Player player = event.getPlayer(); + List items = _upgrades.get(player); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onAmmoGive(event); + } + } + } + + @EventHandler + public void cooldownCheck(CooldownCalculateEvent event) { Player player = event.getPlayer(); List items = _upgrades.get(player); @@ -258,6 +287,34 @@ public class MobaShop implements Listener } } + @EventHandler + public void damage(CustomDamageEvent event) + { + Player damagee = event.GetDamageePlayer(); + Player damager = event.GetDamagerPlayer(true); + + if (damagee == null || damager == null) + { + return; + } + + List items = _upgrades.get(damager); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onDamage(event); + } + } + } + + @EventHandler public void combatDeath(CombatDeathEvent event) { @@ -331,4 +388,32 @@ public class MobaShop implements Listener } } } + + @EventHandler + public void conditionApply(ConditionApplyEvent event) + { + LivingEntity entity = event.GetCondition().GetEnt(); + + if (!(entity instanceof Player)) + { + return; + } + + Player player = (Player) entity; + + List items = _upgrades.get(player); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onCondition(event); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java index 5a9567966..a6026d4fb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.moba.shop; -import javafx.scene.shape.Arc; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.menu.Button; @@ -28,7 +27,7 @@ public class MobaShopCategoryMenu extends Menu public MobaShopCategoryMenu(Moba host, MobaShop shop, MobaShopCategory category, ArcadeManager plugin) { - super(category.getName() + " Shop", plugin); + super(category.getName() + " Category", plugin); _host = host; _shop = shop; @@ -73,6 +72,12 @@ public class MobaShopCategoryMenu extends Menu } buttons[slot++] = new MobaPurchaseButton(builder.build(), getPlugin(), item); + + // Reached the end of the row, wrap it to keep it neat. + if (slot == 17) + { + slot = 19; + } } return buttons; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java new file mode 100644 index 000000000..6485a4082 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class MobaAbilityDamageEffect extends MobaItemEffect +{ + + private String _reason; + private double _factor; + + public MobaAbilityDamageEffect(String reason, double factor) + { + _reason = reason; + _factor = factor; + } + + @Override + protected void onDamage(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.CUSTOM || event.GetReason().contains(MobaConstants.BASIC_ATTACK)) + { + return; + } + + event.AddMod(_reason, event.GetDamage() * _factor); + } + + @Override + public String getDescription() + { + return "Increases ability damage by " + F.greenElem(format(_factor * 100)) + "%."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAmmoIncreaseEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAmmoIncreaseEffect.java new file mode 100644 index 000000000..c62f9d935 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAmmoIncreaseEffect.java @@ -0,0 +1,28 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; + +public class MobaAmmoIncreaseEffect extends MobaItemEffect +{ + + private int _maxAmmoIncrease; + + public MobaAmmoIncreaseEffect(int maxAmmoIncrease) + { + _maxAmmoIncrease = maxAmmoIncrease; + } + + @Override + protected void onAmmoGive(AmmoGiveEvent event) + { + event.setMaxAmmo(event.getMaxAmmo() + _maxAmmoIncrease); + } + + @Override + public String getDescription() + { + return "Increases max ammo by " + F.greenElem(format(_maxAmmoIncrease)) + "."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java new file mode 100644 index 000000000..3f19d483c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; + +public class MobaBasicAttackDamageEffect extends MobaItemEffect +{ + + private String _reason; + private double _factor; + + public MobaBasicAttackDamageEffect(String reason, double factor) + { + _reason = reason; + _factor = factor; + } + + @Override + protected void onDamage(CustomDamageEvent event) + { + if (!event.GetReason().contains(MobaConstants.BASIC_ATTACK)) + { + return; + } + + event.AddMod(_reason, event.GetDamage() * _factor); + } + + @Override + public String getDescription() + { + return "Increases basic attack damage by " + F.greenElem(format(_factor * 100)) + "%."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDRAmmoEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDRAmmoEffect.java new file mode 100644 index 000000000..ab0269862 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDRAmmoEffect.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; + +public class MobaCDRAmmoEffect extends MobaItemEffect +{ + + private double _factor; + + public MobaCDRAmmoEffect(double factor) + { + _factor = factor; + } + + @Override + public void onCooldownCheck(CooldownCalculateEvent event) + { + if (!event.getAbility().equals(MobaConstants.AMMO)) + { + return; + } + + event.decreaseCooldown(_factor); + } + + @Override + public String getDescription() + { + return "Decreases ammo reload time by " + F.greenElem(format(_factor * 100)) + "%."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java index 8b139c25c..a141f2a3a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.moba.shop.effects; import mineplex.core.common.util.F; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; public class MobaCDREffect extends MobaItemEffect { @@ -17,12 +18,17 @@ public class MobaCDREffect extends MobaItemEffect @Override public void onCooldownCheck(CooldownCalculateEvent event) { + if (event.getAbility().equals(MobaConstants.AMMO)) + { + return; + } + event.decreaseCooldown(_factor); } @Override public String getDescription() { - return "Decreases ability cooldowns by " + F.greenElem(String.valueOf(_factor * 100)) + "%."; + return "Decreases ability cooldowns by " + F.greenElem(format(_factor * 100)) + "%."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaConditionImmunityEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaConditionImmunityEffect.java new file mode 100644 index 000000000..d79a5e76c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaConditionImmunityEffect.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; + +public class MobaConditionImmunityEffect extends MobaItemEffect +{ + + private ConditionType _conditionType; + + public MobaConditionImmunityEffect(ConditionType conditionType) + { + _conditionType = conditionType; + } + + @Override + protected void onCondition(ConditionApplyEvent event) + { + if (event.GetCondition().GetType() == _conditionType) + { + event.setCancelled(true); + } + } + + @Override + public String getDescription() + { + return "Grants immunity to " + F.greenElem(format(_conditionType, -1)) + " effects."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java index 8e0b2491f..b9d8fc749 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java @@ -23,6 +23,6 @@ public class MobaHPRegenEffect extends MobaItemEffect @Override public String getDescription() { - return "Increases HP regeneration by " + F.greenElem(String.valueOf(_factor * 100)) + "%."; + return "Increases HP regeneration by " + F.greenElem(format(_factor * 100)) + "%."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java new file mode 100644 index 000000000..4d2393326 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.Managers; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; + +public class MobaHitArrowAmmoEffect extends MobaItemEffect +{ + + @Override + protected void onDamage(CustomDamageEvent event) + { + if (!(event.GetProjectile() instanceof Arrow)) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + + Moba host = (Moba) Managers.get(ArcadeManager.class).GetGame(); + HeroKit kit = host.getData(damager).Kit; + + kit.giveAmmo(damager, 1); + } + + @Override + public String getDescription() + { + return "Hitting a player with an arrow gives you a new arrow."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowHealEffect.java new file mode 100644 index 000000000..f5e22be7a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowHealEffect.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; + +public class MobaHitArrowHealEffect extends MobaItemEffect +{ + + private double _factor; + + public MobaHitArrowHealEffect(double factor) + { + _factor = factor; + } + + @Override + protected void onDamage(CustomDamageEvent event) + { + if (!(event.GetProjectile() instanceof Arrow)) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + + damager.setHealth(Math.min(damager.getMaxHealth(), damager.getHealth() + (event.GetDamage() * _factor))); + } + + @Override + public String getDescription() + { + return "Hitting a player with an arrow heals for " + F.greenElem(format(_factor * 100)) + "% of the damage."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java new file mode 100644 index 000000000..296c5e073 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java @@ -0,0 +1,56 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.Managers; +import mineplex.core.common.util.F; +import mineplex.minecraft.game.core.condition.Condition; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +public class MobaHitConditionEffect extends MobaItemEffect +{ + + private String _reason; + private ConditionType _conditionType; + private double _duration; + private int _multi; + private boolean _applyToDamagee; + + public MobaHitConditionEffect(String reason, ConditionType conditionType, double duration, int multi, boolean applyToDamagee) + { + _reason = reason; + _conditionType = conditionType; + _duration = duration; + _multi = multi; + _applyToDamagee = applyToDamagee; + } + + @Override + protected void onDamage(CustomDamageEvent event) + { + Player damagee = event.GetDamageePlayer(); + Player damager = event.GetDamagerPlayer(true); + + if (!_applyToDamagee) + { + // Swap damagee and damager + Player temp = damagee; + damagee = damager; + damager = temp; + } + + ConditionManager conditionManager = Managers.get(ArcadeManager.class).GetCondition(); + + conditionManager.AddCondition(new Condition(conditionManager, _reason, damagee, damager, _conditionType, _multi, (int) (_duration * 20), false, Material.WEB, (byte) 0, true, false)); + } + + @Override + public String getDescription() + { + return "Hitting a player applies " + F.greenElem(format(_conditionType, _multi)) + " for " + F.time(format(_duration)) + " seconds."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java index da364fee6..3086e7b84 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -27,6 +27,6 @@ public class MobaKillHealEffect extends MobaItemEffect @Override public String getDescription() { - return "Killing a player heals you for " + F.greenElem(String.valueOf(_health / 2)) + C.cRed + "❤" + C.cGray + "."; + return "Killing a player heals for " + F.greenElem(format(_health / 2)) + C.cRed + "❤" + C.cGray + "."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java index 41aee38b9..23f3e4bbe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java @@ -28,6 +28,6 @@ public class MobaSpeedEffect extends MobaItemEffect @Override public String getDescription() { - return "Increases your movement speed by " + F.greenElem(String.valueOf(_factor * 100)) + "%."; + return "Increases movement speed by " + F.greenElem(format(_factor * 100)) + "%."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java index 2cce7bb6d..80af5c495 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java @@ -28,6 +28,6 @@ public class MobaTotalHealthEffect extends MobaItemEffect @Override public String getDescription() { - return "Increases your total hearts by " + F.greenElem(String.valueOf(_health / 2)) + C.cRed + "❤" + C.cGray + "."; + return "Increases total hearts by " + F.greenElem(format(_health / 2)) + C.cRed + "❤" + C.cGray + "."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java new file mode 100644 index 000000000..06b6fdaf7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java @@ -0,0 +1,207 @@ +package nautilus.game.arcade.game.games.moba.shop.hunter; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +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.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.*; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; + +public class MobaHunterShop extends MobaShopMenu +{ + + private static final MobaShopCategory BOW = new MobaShopCategory("Bow", Arrays.asList( + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cGreenB + "Hunter's Bow") + .addEnchantment(Enchantment.ARROW_DAMAGE, 1) + .build(), 500), + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cGreenB + "Elven Bow") + .addEnchantment(Enchantment.ARROW_DAMAGE, 2) + .build(), 750), + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cGreenB + "Eagle's Bow") + .addEnchantment(Enchantment.ARROW_DAMAGE, 3) + .build(), 1000), + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cYellowB + "Bow of Pursuit") + .addEnchantment(Enchantment.ARROW_DAMAGE, 2) + .build(), 1200) + .addEffects( + new MobaHitConditionEffect("Bow of Pursuit", ConditionType.SPEED, 2, 0, false) + ), + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cYellowB + "Vampiric Bow") + .addEnchantment(Enchantment.ARROW_DAMAGE, 1) + .build(), 1500) + .addEffects( + new MobaHitArrowHealEffect(0.25) + ), + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cYellowB + "Bow of Renewal") + .addEnchantment(Enchantment.ARROW_DAMAGE, 1) + .build(), 1750) + .addEffects( + new MobaHitArrowAmmoEffect() + ), + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cYellowB + "Specialist's Bow") + .build(), 1000) + .addEffects( + new MobaCDREffect(0.1), + new MobaAbilityDamageEffect("Specialist's Bow", 0.2) + ) + ), new ItemStack(Material.BOW)); + + private static final MobaShopCategory HELMET = new MobaShopCategory("Helmet", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Leather Helmet") + .build(), 200), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Leather Cap of Holding") + .build(), 400) + .addEffects( + new MobaAmmoIncreaseEffect(1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Leather Cap of Nimble Fingers") + .build(), 400) + .addEffects( + new MobaCDRAmmoEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Focused Cap") + .build(), 500) + .addEffects( + new MobaCDREffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Vampiric Helmet") + .build(), 500) + .addEffects( + new MobaHitArrowHealEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_HELMET) + .setTitle(C.cGreen + "Chainmail Helmet") + .build(), 500) + ), 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), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Leather Chestplate of Nimble Fingers") + .build(), 750) + .addEffects( + new MobaCDRAmmoEffect(0.15) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Focused Chestplate") + .build(), 750) + .addEffects( + new MobaCDREffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Vampiric Chestplate") + .build(), 750) + .addEffects( + new MobaHitArrowHealEffect(0.15) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_CHESTPLATE) + .setTitle(C.cGreen + "Chainmail Chestplate") + .build(), 500) + ), 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 + "Leather Leggings of Nimble Fingers") + .build(), 750) + .addEffects( + new MobaCDRAmmoEffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Focused Leggings") + .build(), 750) + .addEffects( + new MobaCDREffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Vampiric Leggings") + .build(), 700) + .addEffects( + new MobaHitArrowHealEffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_LEGGINGS) + .setTitle(C.cGreen + "Chainmail Leggings") + .build(), 500) + ), 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(), 250), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Leather Boots of Nimble Fingers") + .build(), 400) + .addEffects( + new MobaCDRAmmoEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Focused Boots") + .build(), 600) + .addEffects( + new MobaCDREffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Vampiric Boots") + .build(), 500) + .addEffects( + new MobaHitArrowHealEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Leather Hiking Boots") + .build(), 300) + .addEffects( + new MobaSpeedEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_BOOTS) + .setTitle(C.cGreen + "Leather Moccasins") + .build(), 500) + .addEffects( + new MobaSpeedEffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_BOOTS) + .setTitle(C.cGreen + "Leather Crosstrainers") + .build(), 800) + .addEffects( + new MobaSpeedEffect(0.15) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_BOOTS) + .setTitle(C.cGreen + "Chainmail Boots") + .build(), 500) + ), new ItemStack(Material.LEATHER_BOOTS)); + + public MobaHunterShop(Moba host, MobaShop shop) + { + super(host, shop, MobaRole.HUNTER); + + addCategory(BOW); + addCategory(HELMET); + addCategory(CHESTPLATE); + addCategory(LEGGINGS); + addCategory(BOOTS); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java new file mode 100644 index 000000000..15103bdcd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java @@ -0,0 +1,152 @@ +package nautilus.game.arcade.game.games.moba.shop.mage; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +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.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.MobaAbilityDamageEffect; +import nautilus.game.arcade.game.games.moba.shop.effects.MobaBasicAttackDamageEffect; +import nautilus.game.arcade.game.games.moba.shop.effects.MobaCDREffect; +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; + +public class MobaMageShop extends MobaShopMenu +{ + + private static final MobaShopCategory HELMET = new MobaShopCategory("Helmet", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Leather Cap") + .build(), 200), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Adept's Cap") + .setColor(Color.BLACK) + .build(), 500) + .addEffects( + new MobaAbilityDamageEffect("Adept's Cap", 0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Helm of Focus") + .setColor(Color.PURPLE) + .build(), 500) + .addEffects( + new MobaCDREffect(0.03) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Battle Mage Cap") + .setColor(Color.YELLOW) + .build(), 500) + .addEffects( + new MobaBasicAttackDamageEffect("Battle Mage Cap", 0.03) + ), + new MobaItem(new ItemBuilder(Material.GOLD_HELMET) + .setTitle(C.cYellow + "Golden Helmet") + .build(), 750) + ), 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(), 400), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Adept's Chestplate") + .setColor(Color.BLACK) + .build(), 1250) + .addEffects( + new MobaAbilityDamageEffect("Adept's Chestplate", 0.15) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Chestplate of Focus") + .setColor(Color.PURPLE) + .build(), 1000) + .addEffects( + new MobaCDREffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Battle Mage Chestplate") + .setColor(Color.YELLOW) + .build(), 1000) + .addEffects( + new MobaBasicAttackDamageEffect("Battle Mage Chestplate", 0.1) + ), + new MobaItem(new ItemBuilder(Material.GOLD_CHESTPLATE) + .setTitle(C.cYellow + "Golden Chestplate") + .build(), 1000) + ), 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(), 400), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Adept's Leggings") + .setColor(Color.BLACK) + .build(), 750) + .addEffects( + new MobaAbilityDamageEffect("Adept's Leggings", 0.1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Leggings of Focus") + .setColor(Color.PURPLE) + .build(), 750) + .addEffects( + new MobaCDREffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Battle Mage Leggings") + .setColor(Color.YELLOW) + .build(), 750) + .addEffects( + new MobaBasicAttackDamageEffect("Battle Mage Leggings", 0.05) + ), + new MobaItem(new ItemBuilder(Material.GOLD_LEGGINGS) + .setTitle(C.cYellow + "Golden Leggings") + .build(), 1000) + ), 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), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Adept's Boots") + .setColor(Color.BLACK) + .build(), 500) + .addEffects( + new MobaAbilityDamageEffect("Adept's Boots", 0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Boots of Focus") + .setColor(Color.PURPLE) + .build(), 500) + .addEffects( + new MobaCDREffect(0.03) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Battle Mage Boots") + .setColor(Color.YELLOW) + .build(), 500) + .addEffects( + new MobaBasicAttackDamageEffect("Battle Mage Boots", 0.03) + ), + new MobaItem(new ItemBuilder(Material.GOLD_BOOTS) + .setTitle(C.cYellow + "Golden Boots") + .build(), 750) + ), new ItemStack(Material.LEATHER_BOOTS)); + + public MobaMageShop(Moba host, MobaShop shop) + { + super(host, shop, MobaRole.MAGE); + + addCategory(HELMET); + addCategory(CHESTPLATE); + addCategory(LEGGINGS); + addCategory(BOOTS); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java new file mode 100644 index 000000000..03bc1f529 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java @@ -0,0 +1,201 @@ +package nautilus.game.arcade.game.games.moba.shop.warrior; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +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.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.*; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; + +public class MobaWarriorShop extends MobaShopMenu +{ + + private static final MobaShopCategory SWORD = new MobaShopCategory("Sword", Arrays.asList( + new MobaItem(new ItemBuilder(Material.STONE_SWORD) + .setTitle(C.cGreenB + "Stone Sword") + .build(), 500), + new MobaItem(new ItemBuilder(Material.GOLD_SWORD) + .setTitle(C.cYellowB + "Frostbound Sword") + .build(), 750) + .addEffects( + new MobaHitConditionEffect("Frostbound Sword", ConditionType.SLOW, 3, 0, true) + ), + new MobaItem(new ItemBuilder(Material.GOLD_SWORD) + .setTitle(C.cYellowB + "Swift Blade") + .build(), 750) + .addEffects( + new MobaConditionImmunityEffect(ConditionType.SLOW) + ), + new MobaItem(new ItemBuilder(Material.IRON_SWORD) + .setTitle(C.cDRedB + "Knight's Blade") + .build(), 1250) + ), new ItemStack(Material.WOOD_SWORD)); + + private static final MobaShopCategory HELMET = new MobaShopCategory("Helmet", Arrays.asList( + new MobaItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cGreenB + "Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) + .build(), 400) + .addEffects( + new MobaHPRegenEffect(0.03) + ), + new MobaItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 750) + .addEffects( + new MobaHPRegenEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cGreenB + "Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) + .build(), 400) + .addEffects( + new MobaHPRegenEffect(0.03) + ), + new MobaItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cYellowB + "Superior Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) + .build(), 750) + .addEffects( + new MobaHPRegenEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.DIAMOND_HELMET) + .setTitle(C.cDRedB + "Prince's Plate") + .build(), 2000) + .addEffects( + new MobaHPRegenEffect(0.15) + ) + ), new ItemStack(Material.IRON_HELMET)); + + private static final MobaShopCategory CHESTPLATE = new MobaShopCategory("Chestplate", Arrays.asList( + new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cGreenB + "Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) + .build(), 600) + .addEffects( + new MobaTotalHealthEffect(2) + ), + new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 1000) + .addEffects( + new MobaTotalHealthEffect(4) + ), + new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cGreenB + "Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) + .build(), 600) + .addEffects( + new MobaTotalHealthEffect(2) + ), + new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cYellowB + "Superior Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) + .build(), 1000) + .addEffects( + new MobaTotalHealthEffect(4) + ), + new MobaItem(new ItemBuilder(Material.DIAMOND_CHESTPLATE) + .setTitle(C.cDRedB + "Prince's Plate") + .build(), 2500) + .addEffects( + new MobaTotalHealthEffect(4) + ) + ), new ItemStack(Material.IRON_CHESTPLATE)); + + private static final MobaShopCategory LEGGINGS = new MobaShopCategory("Leggings", Arrays.asList( + new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) + .setTitle(C.cGreenB + "Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) + .build(), 600) + .addEffects( + new MobaCDREffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 1000) + .addEffects( + new MobaCDREffect(0.07) + ), + new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) + .setTitle(C.cGreenB + "Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) + .build(), 600) + .addEffects( + new MobaCDREffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) + .setTitle(C.cYellowB + "Superior Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) + .build(), 1000) + .addEffects( + new MobaCDREffect(0.07) + ), + new MobaItem(new ItemBuilder(Material.DIAMOND_LEGGINGS) + .setTitle(C.cDRedB + "Prince's Plate") + .build(), 2500) + .addEffects( + new MobaCDREffect(0.1) + ) + ), new ItemStack(Material.IRON_LEGGINGS)); + + private static final MobaShopCategory BOOTS = new MobaShopCategory("Boots", Arrays.asList( + new MobaItem(new ItemBuilder(Material.IRON_BOOTS) + .setTitle(C.cGreenB + "Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) + .build(), 400) + .addEffects( + new MobaSpeedEffect(0.04) + ), + new MobaItem(new ItemBuilder(Material.IRON_BOOTS) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 750) + .addEffects( + new MobaSpeedEffect(0.06) + ), + new MobaItem(new ItemBuilder(Material.IRON_BOOTS) + .setTitle(C.cGreenB + "Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) + .build(), 400) + .addEffects( + new MobaSpeedEffect(0.04) + ), + new MobaItem(new ItemBuilder(Material.IRON_BOOTS) + .setTitle(C.cYellowB + "Superior Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) + .build(), 750) + .addEffects( + new MobaSpeedEffect(0.06) + ), + new MobaItem(new ItemBuilder(Material.DIAMOND_BOOTS) + .setTitle(C.cDRedB + "Prince's Plate") + .build(), 2000) + .addEffects( + new MobaSpeedEffect(0.1) + ) + ), new ItemStack(Material.IRON_BOOTS)); + + public MobaWarriorShop(Moba host, MobaShop shop) + { + super(host, shop, MobaRole.WARRIOR); + + addCategory(SWORD); + addCategory(HELMET); + addCategory(CHESTPLATE); + addCategory(LEGGINGS); + addCategory(BOOTS); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java new file mode 100644 index 000000000..01ef28c06 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java @@ -0,0 +1,10 @@ +package nautilus.game.arcade.game.games.moba.util; + +public class MobaConstants +{ + + // String constants + public static final String BASIC_ATTACK = "Basic Attack"; + public static final String AMMO = "Ammo"; + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java index ce6024784..0964306f4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java @@ -10,7 +10,7 @@ public class MobaParticles public static void healing(LivingEntity entity, int amount) { - UtilParticle.PlayParticleToAll(ParticleType.HEART, entity.getEyeLocation(), 0.5F, 0.5F, 0.5F, 0.1F, amount, ViewDist.LONG); + UtilParticle.PlayParticleToAll(ParticleType.HEART, entity.getLocation().add(0, 1.3, 0), 0.5F, 0.5F, 0.5F, 0.1F, amount, ViewDist.LONG); } } From f2130515f39ad36e938577e7427c20b98282bf7a Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 14 May 2017 11:41:26 +0100 Subject: [PATCH 023/283] Add suffixes to the scoreboard --- .../game/modules/CustomScoreboardModule.java | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java index b167a378d..95ce3bbb5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.modules; -import mineplex.core.common.util.C; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -28,6 +27,7 @@ public class CustomScoreboardModule extends Module private BiConsumer _scoreboardConsumer; private BiFunction _prefixFunction; + private BiFunction _suffixFunction; public CustomScoreboardModule() { @@ -83,6 +83,17 @@ public class CustomScoreboardModule extends Module refresh(); } + @EventHandler(priority = EventPriority.MONITOR) + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + refresh(); + } + @EventHandler public void update(UpdateEvent event) { @@ -106,12 +117,9 @@ public class CustomScoreboardModule extends Module { scoreboard = new CustomArcadeScoreboard(player); _scoreboard.put(player.getUniqueId(), scoreboard); - player.setScoreboard(scoreboard.getHandle()); - } - else - { - player.setScoreboard(scoreboard.getHandle()); } + + player.setScoreboard(scoreboard.getHandle()); } public CustomScoreboardModule setSidebar(BiConsumer consumer) @@ -126,6 +134,12 @@ public class CustomScoreboardModule extends Module return this; } + public CustomScoreboardModule setSuffix(BiFunction function) + { + _suffixFunction = function; + return this; + } + public void refresh() { for (CustomArcadeScoreboard scoreboard : _scoreboard.values()) @@ -148,7 +162,7 @@ public class CustomScoreboardModule extends Module super(getGame(), owner); } - public void setTag(Player subject, String prefix, String suffix) + private void setTag(Player subject, String prefix, String suffix) { Scoreboard handle = getHandle(); String teamName = subject.getName(); @@ -162,20 +176,16 @@ public class CustomScoreboardModule extends Module if (prefix != null) { - String prefixF = prefix + C.Reset + " "; - - if (!team.getPrefix().equals(prefixF)) + if (team.getPrefix() == null || !team.getPrefix().equals(prefix)) { - team.setPrefix(prefixF); + team.setPrefix(prefix); } } - else if (suffix != null) + if (suffix != null) { - String suffixF = suffix + C.Reset + " "; - - if (!team.getPrefix().equals(suffixF)) + if (team.getSuffix() == null || !team.getSuffix().equals(suffix)) { - team.setSuffix(suffixF); + team.setSuffix(suffix); } } } @@ -192,13 +202,13 @@ public class CustomScoreboardModule extends Module { _scoreboardConsumer.accept(getOwner(), this); } - if (sidebarOnly) + if (!sidebarOnly) { if (_prefixFunction != null) { for (Player player : Bukkit.getOnlinePlayers()) { - setTag(getOwner(), _prefixFunction.apply(getOwner(), player), null); + setTag(player, _prefixFunction.apply(getOwner(), player), _suffixFunction.apply(getOwner(), player)); } } } From d510dd9f580234726e589d1d3e9757b1aa933716 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 14 May 2017 11:46:24 +0100 Subject: [PATCH 024/283] Increase Fountain damage range --- .../game/arcade/game/games/moba/fountain/MobaFountain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java index f5c1027b9..0905cd1b8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java @@ -22,7 +22,7 @@ import java.util.Map.Entry; public class MobaFountain implements Listener { - private static final int FOUNTAIN_SIZE_SQUARED = 25; + private static final int FOUNTAIN_SIZE_SQUARED = 50; private final Moba _host; private final Map _average; From a450b23d226fb2b067191f636ccd3be39dd11508 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 15 May 2017 19:32:25 +0100 Subject: [PATCH 025/283] Wither and AI base --- .../game/arcade/game/games/moba/Moba.java | 48 +++--- .../game/arcade/game/games/moba/MobaLane.java | 43 +++++ .../arcade/game/games/moba/ai/MobaAI.java | 124 ++++++++++++++ .../game/games/moba/ai/goal/MobaAIMethod.java | 11 ++ .../moba/ai/goal/MobaDirectAIMethod.java | 70 ++++++++ .../moba/ai/goal/MobaEntityAIMethod.java | 15 ++ .../game/games/moba/boss/BossManager.java | 72 ++++++++ .../arcade/game/games/moba/boss/MobaBoss.java | 90 ++++++++++ .../games/moba/boss/wither/WitherBoss.java | 162 ++++++++++++++++++ .../boss/wither/WitherSkullProjectile.java | 82 +++++++++ .../game/games/moba/kit/common/SkillBow.java | 7 +- .../games/moba/kit/devon/SkillInfinity.java | 5 - .../arcade/game/games/moba/shop/MobaShop.java | 5 + .../games/moba/structure/tower/Tower.java | 58 ++++++- 14 files changed, 762 insertions(+), 30 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 7ffeea140..b3cf92d73 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -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.boss.BossManager; 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.*; @@ -34,6 +35,7 @@ import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.scoreboard.GameScoreboard; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; @@ -110,6 +112,9 @@ public class Moba extends TeamGame MobaFountain fountain = new MobaFountain(this); _listeners.add(fountain); + Listener boss = new BossManager(this); + _listeners.add(boss); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -228,21 +233,7 @@ public class Moba extends TeamGame } String team = components[1]; - String lane = components[2]; - int laneInt = 0; - - switch (lane) - { - case "A": - laneInt = 0; - break; - case "B": - laneInt = 1; - break; - case "C": - laneInt = 2; - break; - } + MobaLane lane = MobaLane.valueOf(components[2]); boolean firstTower; @@ -263,7 +254,7 @@ public class Moba extends TeamGame continue; } - _towers.add(new Tower(this, location, gameTeam, laneInt, health, firstTower)); + _towers.add(new Tower(this, location, gameTeam, lane, health, firstTower)); } _listeners.forEach(UtilServer::RegisterEvents); @@ -305,19 +296,29 @@ public class Moba extends TeamGame { scoreboard.writeNewLine(); +// GameTeam team = GetTeam(player); +// boolean blueBottom = team == null || team.GetColor() == ChatColor.BLUE; +// +// // Tower Data +// List lines = new ArrayList<>(); +// GameTeam red = GetTeam(ChatColor.RED); +// GameTeam blue = GetTeam(ChatColor.AQUA); +// +// lines.add("♚"); + + // Gold + scoreboard.write(C.cGoldB + "Gold"); if (IsAlive(player)) { int gold = _goldManager.getGold(player); - scoreboard.write(C.cGoldB + "Gold"); scoreboard.write(String.valueOf(gold)); } else { - scoreboard.write("You are dead lol"); + scoreboard.write("None"); } - scoreboard.writeNewLine(); } @@ -377,6 +378,13 @@ public class Moba extends TeamGame } } + @Override + public void RespawnPlayer(Player player) + { + super.RespawnPlayer(player); + player.setGameMode(GameMode.ADVENTURE); + } + @Override public void disable() { @@ -680,7 +688,7 @@ public class Moba extends TeamGame { for (HeroKit kit : _kits) { - if (kit.getRole() == role) + if (kit.getRole() == role && kit.isVisible()) { return kit; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java new file mode 100644 index 000000000..4681c4a42 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java @@ -0,0 +1,43 @@ +package nautilus.game.arcade.game.games.moba; + +import nautilus.game.arcade.game.GameTeam; +import org.bukkit.ChatColor; + +public enum MobaLane +{ + + A, + B, + C; + + public String getName(GameTeam team) + { + if (this == B) + { + return "Middle"; + } + else if (this == A) + { + if (team.GetColor() == ChatColor.AQUA) + { + return "Left"; + } + else + { + return "Right"; + } + } + else + { + if (team.GetColor() == ChatColor.AQUA) + { + return "Right"; + } + else + { + return "Left"; + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java new file mode 100644 index 000000000..013c97050 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -0,0 +1,124 @@ +package nautilus.game.arcade.game.games.moba.ai; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +import java.util.Map.Entry; + +public class MobaAI +{ + + public static final int TARGET_RANGE = 11; + public static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; + + private final Moba _host; + private final GameTeam _owner; + + private LivingEntity _entity; + private LivingEntity _target; + private Location _home; + + private MobaAIMethod _aiMethod; + + public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, MobaAIMethod aiMethod) + { + _host = host; + _owner = owner; + _entity = entity; + _home = home; + _aiMethod = aiMethod; + } + + public void updateTarget() + { + // Entity not spawned + if (_entity == null || !_entity.isValid()) + { + return; + } + + if (_target == null) + { + _target = getBestEntityTarget(); + + if (_target == null) + { + returnToHome(); + return; + } + } + else + { + double dist = UtilMath.offsetSquared(_home, _target.getLocation()); + + if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target)) + { + _target = null; + returnToHome(); + } + } + + if (_target != null) + { + _aiMethod.updateMovement(_entity, _target.getLocation(), 2.5F); + } + } + + private void returnToHome() + { + _aiMethod.updateMovement(_entity, _home, 3.5F); + } + + private LivingEntity getBestEntityTarget() + { + LivingEntity highest = null; + double bestDist = 0; + + for (Entry entry : UtilEnt.getInRadius(_home, TARGET_RANGE).entrySet()) + { + LivingEntity entity = entry.getKey(); + double dist = entry.getValue(); + + if (_entity.equals(entity)) + { + continue; + } + + // Make players more desirable + if (entity instanceof Player) + { + if (_owner.equals(_host.GetTeam((Player) entity))) + { + continue; + } + + dist += 0.5; + } + + if (bestDist < dist) + { + highest = entity; + bestDist = dist; + } + } + + return highest; + } + + public void setEntity(LivingEntity entity) + { + _entity = entity; + } + + public LivingEntity getTarget() + { + return _target; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java new file mode 100644 index 000000000..cb20ef390 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java @@ -0,0 +1,11 @@ +package nautilus.game.arcade.game.games.moba.ai.goal; + +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; + +public interface MobaAIMethod +{ + + void updateMovement(LivingEntity entity, Location goal, float speed); + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java new file mode 100644 index 000000000..65e458420 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -0,0 +1,70 @@ +package nautilus.game.arcade.game.games.moba.ai.goal; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.util.Vector; + +public class MobaDirectAIMethod implements MobaAIMethod +{ + + private static final float YAW_SNAP_LIMIT = 20F; + + @Override + public void updateMovement(LivingEntity entity, Location goal, float speed) + { + Location entityLocation = entity.getLocation(); + + float entityYaw = entityLocation.getYaw(); + + // Speed is blocks per second + float magnitude = speed / 20F; + + // Get the direct vector between the entity and the goal + Vector direction = UtilAlg.getTrajectory(entityLocation, goal); + + // From the direction, get the yaw of this direction + float directionYaw = UtilAlg.GetYaw(direction); + + // Get the absolute yaw offset from the direction + // This can then be used to see how far the entity is + // looking away from the goal + float yawOffset = Math.abs(directionYaw - entityYaw); + + // If the entity is facing too far away from the goal to consider the + // "Head Snapping" of turning the entity too severe + if (yawOffset > YAW_SNAP_LIMIT) + { + // Facing too far right + if (entityYaw > directionYaw) + { + entityYaw -= YAW_SNAP_LIMIT; + } + // Facing too far left + else + { + entityYaw += YAW_SNAP_LIMIT; + } + + // Only alter the entity's yaw + entityLocation.setYaw(entityYaw); + } + // If reached the goal + else if (UtilMath.offsetSquared(entityLocation, goal) < 0.5) + { + entityLocation = goal; + } + else + { + // Modify the direction's magnitude to be at the same rate as the speed + direction.multiply(magnitude); + + // Add the modified direction to the original entity location + entityLocation.add(direction); + } + + // Move the entity to its new location + entity.teleport(entityLocation); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java new file mode 100644 index 000000000..6e6b605cc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java @@ -0,0 +1,15 @@ +package nautilus.game.arcade.game.games.moba.ai.goal; + +import mineplex.core.common.util.UtilEnt; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; + +public class MobaEntityAIMethod implements MobaAIMethod +{ + + @Override + public void updateMovement(LivingEntity entity, Location goal, float speed) + { + UtilEnt.CreatureMoveFast(entity, goal, speed); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java new file mode 100644 index 000000000..73ba34407 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -0,0 +1,72 @@ +package nautilus.game.arcade.game.games.moba.boss; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; +import nautilus.game.arcade.world.WorldData; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import java.util.HashMap; +import java.util.Map; + +public class BossManager implements Listener +{ + + private final Moba _host; + + private Map _teamBosses; + + public BossManager(Moba host) + { + _host = host; + _teamBosses = new HashMap<>(2); + } + + private void spawnBosses() + { + _host.CreatureAllowOverride = true; + + WorldData worldData = _host.WorldData; + + // Spawn Team Withers + for (GameTeam team : _host.GetTeamList()) + { + WitherBoss boss = new WitherBoss(_host, worldData.GetDataLocs(team.GetName().toUpperCase()).get(0), team); + boss.setup(); + + _teamBosses.put(team, boss); + } + + _host.CreatureAllowOverride = false; + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + spawnBosses(); + } + + @EventHandler + public void cleanup(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End && event.GetState() != GameState.Dead) + { + return; + } + + _teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup()); + } + + public WitherBoss getWitherBoss(GameTeam team) + { + return _teamBosses.get(team); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java new file mode 100644 index 000000000..b995f0cd8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -0,0 +1,90 @@ +package nautilus.game.arcade.game.games.moba.boss; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDeathEvent; + +public abstract class MobaBoss implements Listener +{ + + protected final Moba _host; + protected LivingEntity _entity; + protected Location _location; + protected int _respawnTime; + private long _lastDeath; + + public MobaBoss(Moba host, Location location) + { + this(host, location, -1); + } + + public MobaBoss(Moba host, Location location, int respawnTime) + { + _host = host; + _location = location; + _respawnTime = respawnTime; + _lastDeath = -1; + } + + public void setup() + { + _entity = spawnEntity(); + UtilServer.RegisterEvents(this); + } + + public void cleanup() + { + UtilServer.Unregister(this); + } + + @EventHandler + public void updateMovement(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || _entity == null || !_host.IsLive()) + { + return; + } + + getAi().updateTarget(); + } + + @EventHandler + public void entityDeath(EntityDeathEvent event) + { + if (_entity != null && _entity.equals(event.getEntity())) + { + _entity = null; + _lastDeath = System.currentTimeMillis(); + getAi().setEntity(null); + } + } + + @EventHandler + public void updateRespawn(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || _lastDeath == -1 || UtilTime.elapsed(_lastDeath, _respawnTime)) + { + return; + } + + _lastDeath = -1; + _entity = spawnEntity(); + } + + public abstract LivingEntity spawnEntity(); + + public abstract MobaAI getAi(); + + public LivingEntity getEntity() + { + return _entity; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java new file mode 100644 index 000000000..c722ff083 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -0,0 +1,162 @@ +package nautilus.game.arcade.game.games.moba.boss.wither; + +import mineplex.core.common.util.UtilAlg; +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.UtilTextTop; +import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; +import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class WitherBoss extends MobaBoss +{ + + private static final int INITIAL_HEALTH = 1750; + private static final int FIRST_TOWER_HEALTH_REDUCTION = 100; + private static final int SECOND_TOWER_HEALTH_REDUCTION = 250; + + private GameTeam _team; + private MobaAI _ai; + + public WitherBoss(Moba host, Location location, GameTeam team) + { + super(host, location); + + _location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, host.GetSpectatorLocation()))); + _team = team; + } + + @Override + public LivingEntity spawnEntity() + { + ArmorStand stand = _location.getWorld().spawn(_location, ArmorStand.class); + + stand.setMaxHealth(INITIAL_HEALTH); + stand.setHealth(INITIAL_HEALTH); + stand.setGravity(false); + + DisguiseWither disguiseWither = new DisguiseWither(stand); + disguiseWither.setName(_team.GetColor() + _team.GetName() + "\'s Wither"); + disguiseWither.setCustomNameVisible(true); + _host.getArcadeManager().GetDisguise().disguise(disguiseWither); + + return stand; + } + + @Override + public MobaAI getAi() + { + if (_ai == null) + { + _ai = new MobaAI(_host, _team, _entity, _location, new MobaDirectAIMethod()); + } + + return _ai; + } + + @Override + @EventHandler + public void updateMovement(UpdateEvent event) + { + super.updateMovement(event); + + if (event.getType() == UpdateType.SEC && _entity != null && _host.IsLive() && getAi().getTarget() != null) + { + new WitherSkullProjectile(_host, _entity, getAi().getTarget(), _team); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void damage(CustomDamageEvent event) + { + // Not a Wither Boss + if (event.isCancelled() || !(event.GetDamageeEntity().equals(_entity))) + { + return; + } + + event.SetCancelled("Wither Boss"); + + if (event.GetDamagerPlayer(true) == null || event.GetCause() == DamageCause.FIRE || event.GetCause() == DamageCause.FIRE_TICK) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + Player damager = event.GetDamagerPlayer(true); + GameTeam team = _host.GetTeam(damager); + + if (_team.equals(team)) + { + return; + } + + double newHealth = damagee.getHealth() - event.GetDamage(); + + // Don't allow the wither to move because of damage + damagee.playEffect(EntityEffect.HURT); + + if (newHealth > 0) + { + damagee.setHealth(newHealth); + } + else + { + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _entity.getLocation().add(0, 1.5, 0), 0F, 0F, 0F, 0.1F, 1, ViewDist.LONG); + _entity.remove(); + } + } + + @EventHandler + public void towerDestroy(TowerDestroyEvent event) + { + Tower tower = event.getTower(); + + if (!_team.equals(tower.getOwner())) + { + return; + } + + if (tower.isFirstTower()) + { + _entity.setHealth(_entity.getHealth() - FIRST_TOWER_HEALTH_REDUCTION); + } + else + { + _entity.damage(_entity.getHealth() - SECOND_TOWER_HEALTH_REDUCTION); + } + } + + @EventHandler + public void updateTeamDisplay(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || _entity == null) + { + return; + } + + double percent = _entity.getHealth() / _entity.getMaxHealth(); + + for (Player player : _team.GetPlayers(true)) + { + UtilTextTop.displayTextBar(player, percent, _team.GetColor() + "Your Wither"); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java new file mode 100644 index 000000000..48c2173ee --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java @@ -0,0 +1,82 @@ +package nautilus.game.arcade.game.games.moba.boss.wither; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class WitherSkullProjectile implements IThrown +{ + + private static final int DAMAGE = 10; + + private final Moba _host; + private final ArcadeManager _manager; + private final GameTeam _owner; + + public WitherSkullProjectile(Moba host, LivingEntity shooter, LivingEntity target, GameTeam owner) + { + _host = host; + _manager = host.getArcadeManager(); + _owner = owner; + + WitherSkull skull = shooter.launchProjectile(WitherSkull.class); + + skull.setYield(0); + skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target)).normalize().multiply(3)); + + _manager.GetProjectile().AddThrow(skull, shooter, this, 2000, true, true, true, false, 0.5F); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + if (target == null) + { + Expire(data); + return; + } + + if (target instanceof Player) + { + Player targetPlayer = (Player) target; + GameTeam targetTeam = _host.GetTeam(targetPlayer); + + // Not team damage + if (!_owner.equals(targetTeam)) + { + _manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, DAMAGE, true, true, false, UtilEnt.getName(data.getThrower()), "Wither Skull"); + } + + Expire(data); + } + } + + @Override + public void Idle(ProjectileUser data) + { + } + + @Override + public void Expire(ProjectileUser data) + { + Entity thrown = data.getThrown(); + + thrown.getWorld().playSound(thrown.getLocation(), Sound.EXPLODE, 1, 1.6F); + UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, thrown.getLocation(), 0, 0, 0, 0.1F, 1, ViewDist.LONG); + thrown.remove(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java index 3edfe97a5..2d2a105a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java @@ -1,5 +1,7 @@ package nautilus.game.arcade.game.games.moba.kit.common; +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.shop.MobaItem; @@ -16,7 +18,10 @@ public class SkillBow extends HeroSkill "Please work" }; - private static final ItemStack SKILL_ITEM = new ItemStack(Material.BOW); + private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.BOW) + .setTitle(C.cGreenB + "Bow") + .setUnbreakable(true) + .build(); public SkillBow(int slot) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 395955bad..2f8d54223 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -5,16 +5,13 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -23,7 +20,6 @@ import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; import java.util.HashMap; import java.util.HashSet; @@ -129,7 +125,6 @@ public class SkillInfinity extends HeroSkill { if (_arrows.containsKey(event.GetProjectile())) { - Bukkit.broadcastMessage("Wither"); Manager.GetCondition().Factory().Wither(GetName(), event.GetDamageeEntity(), event.GetDamagerEntity(true), 3, 0, false, true, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 1ef2b3511..b259725f4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -91,6 +91,11 @@ public class MobaShop implements Listener public void openShop(MobaPlayer player) { + if (UtilPlayer.isSpectator(player.Player) || _host.GetState() != GameState.Live) + { + return; + } + MobaShopMenu menu = _roleMenus.get(player.Role); if (menu == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 48156e3e3..1a6decd79 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -3,9 +3,9 @@ package nautilus.game.arcade.game.games.moba.structure.tower; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.utils.UtilVariant; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaLane; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Guardian; @@ -16,14 +16,14 @@ public class Tower private final Moba _host; private final Location _location; private final GameTeam _team; - private int _lane; + private MobaLane _lane; private double _health; private int _maxHealth; private boolean _firstTower; private Guardian _guardian; private boolean _dead; - public Tower(Moba host, Location location, GameTeam team, int lane, int health, boolean firstTower) + public Tower(Moba host, Location location, GameTeam team, MobaLane lane, int health, boolean firstTower) { _host = host; _location = location; @@ -79,7 +79,7 @@ public class Tower { float percentage = (float) _health / (float) _maxHealth; - _guardian.setCustomName(UtilTextMiddle.progress(percentage)); + _guardian.setCustomName(getHealthBar(40)); } private void explode() @@ -93,4 +93,54 @@ public class Tower { return _dead; } + + private String getHealthBar(int bars) + { + String out = ""; + String colour; + double health = _guardian.getHealth() / _guardian.getMaxHealth(); + + if (health < 0.25) + { + colour = C.cRedB; + } + else if (health < 0.5) + { + colour = C.cGoldB; + } + else if (health < 0.75) + { + colour = C.cYellowB; + } + else + { + colour = C.cGreenB; + } + + for (int i = 0; i < bars; i++) + { + double cur = i * (1D / (double) bars); + + if (cur < health) + { + out += colour + "|"; + } + else + { + out += C.cGrayB + "|"; + } + } + + return out; + } + + public GameTeam getOwner() + { + return _team; + } + + public boolean isFirstTower() + { + return _firstTower; + } } From 989c9a028c015ed0d417f5eb692a3af224f2d64c Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 15 May 2017 19:55:39 +0100 Subject: [PATCH 026/283] End the game when a wither is killed --- .../game/arcade/game/games/moba/Moba.java | 71 +++++++++++++++++-- .../game/arcade/game/games/moba/MobaLane.java | 9 ++- .../game/arcade/game/games/moba/MobaRole.java | 17 +++-- .../boss/wither/WitherSkullProjectile.java | 2 +- 4 files changed, 87 insertions(+), 12 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index b3cf92d73..cdca741ad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -18,6 +18,7 @@ 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.boss.BossManager; +import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; 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.*; @@ -38,6 +39,7 @@ import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -73,12 +75,13 @@ public class Moba extends TeamGame private final MobaShop _shop; private final GoldManager _goldManager; + private final BossManager _boss; public Moba(ArcadeManager manager) { - super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION); + super(manager, GameType.MOBA, new Kit[]{new KitPlayer(manager)}, DESCRIPTION); - _kits = new HeroKit[] { + _kits = new HeroKit[]{ new HeroHattori(Manager), new HeroDevon(Manager), new HeroAnath(Manager), @@ -112,7 +115,8 @@ public class Moba extends TeamGame MobaFountain fountain = new MobaFountain(this); _listeners.add(fountain); - Listener boss = new BossManager(this); + BossManager boss = new BossManager(this); + _boss = boss; _listeners.add(boss); new CompassModule() @@ -368,13 +372,72 @@ public class Moba extends TeamGame for (MobaPlayer mobaPlayer : _playerData) { + Player player = mobaPlayer.Player; HeroKit kit = mobaPlayer.Kit; Perk perk = kit.GetPerks()[kit.GetPerks().length - 1]; + // Put Ultimates on cooldown if (perk instanceof HeroSkill) { ((HeroSkill) perk).useSkill(mobaPlayer.Player); } + + // Teleport players to their respective spawns + GameTeam team = GetTeam(player); + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); + player.teleport(toTeleport); + } + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + // Only one team online check + List teamsWithPlayers = new ArrayList<>(GetTeamList().size()); + + for (GameTeam team : GetTeamList()) + { + if (team.GetPlayers(true).isEmpty()) + { + continue; + } + + teamsWithPlayers.add(team); + } + + if (teamsWithPlayers.size() == 1) + { + AnnounceEnd(teamsWithPlayers.get(0)); + SetState(GameState.End); + return; + } + + // Wither Dead check + for (GameTeam team : GetTeamList()) + { + WitherBoss boss = _boss.getWitherBoss(team); + LivingEntity entity = boss.getEntity(); + + // Dead Wither + if (entity == null || !entity.isValid() || entity.isDead()) + { + // Get the other team + for (GameTeam otherTeam : GetTeamList()) + { + if (team.equals(otherTeam)) + { + continue; + } + + AnnounceEnd(otherTeam); + SetState(GameState.End); + } + } } } @@ -646,7 +709,7 @@ public class Moba extends TeamGame { if (kit.getRole() == role && kit.isVisible()) { - kits.add(kit); + kits.add(kit); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java index 4681c4a42..a6426575e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java @@ -8,11 +8,16 @@ public enum MobaLane A, B, - C; + C, + D; public String getName(GameTeam team) { - if (this == B) + if (this == D) + { + return "Jungle"; + } + else if (this == B) { return "Middle"; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index ee648883c..9f74a4a3f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,22 +1,24 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.common.util.C; import org.bukkit.ChatColor; import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", Color.BLUE, ChatColor.AQUA), - HUNTER("Hunter", Color.LIME, ChatColor.GREEN), - MAGE("Mage", Color.RED, ChatColor.RED), - WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD), + ASSASSIN("Assassin", MobaLane.D, Color.BLUE, ChatColor.AQUA), + HUNTER("Hunter", MobaLane.A, Color.LIME, ChatColor.GREEN), + MAGE("Mage", MobaLane.B, Color.RED, ChatColor.RED), + WARRIOR("Warrior", MobaLane.C, Color.YELLOW, ChatColor.GOLD), ; private String _name; + private MobaLane _lane; private Color _color; private ChatColor _chatColor; - MobaRole(String name, Color color, ChatColor chatColor) + MobaRole(String name, MobaLane lane, Color color, ChatColor chatColor) { _name = name; _color = color; @@ -28,6 +30,11 @@ public enum MobaRole return _name; } + public MobaLane getLane() + { + return _lane; + } + public Color getColor() { return _color; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java index 48c2173ee..753c06575 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java @@ -36,7 +36,7 @@ public class WitherSkullProjectile implements IThrown WitherSkull skull = shooter.launchProjectile(WitherSkull.class); skull.setYield(0); - skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target)).normalize().multiply(3)); + skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target)).normalize().multiply(2)); _manager.GetProjectile().AddThrow(skull, shooter, this, 2000, true, true, true, false, 0.5F); } From 4b6b04d4eb6bb915a55fc3f46118c56620f79e41 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 15 May 2017 19:55:58 +0100 Subject: [PATCH 027/283] Fix incorrect custom location --- .../src/nautilus/game/arcade/game/games/moba/Moba.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index cdca741ad..2e6b8598a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -384,6 +384,7 @@ public class Moba extends TeamGame // Teleport players to their respective spawns GameTeam team = GetTeam(player); + Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + mobaPlayer.Role.getLane().toString()).get(0); toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); player.teleport(toTeleport); } From f9cdddf1ad88d898b7bb68a526cc46a8cc3d52dc Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 15 May 2017 23:16:30 +0100 Subject: [PATCH 028/283] Towers --- .../game/arcade/game/games/moba/Moba.java | 62 +---- .../arcade/game/games/moba/ai/MobaAI.java | 39 +-- .../game/games/moba/kit/PregameSelection.java | 2 +- .../games/moba/structure/tower/Tower.java | 193 ++++++++++---- .../moba/structure/tower/TowerManager.java | 252 ++++++++++++++++++ .../arcade/game/games/moba/util/MobaUtil.java | 101 +++++++ 6 files changed, 501 insertions(+), 148 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 2e6b8598a..a06844e6d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -31,6 +31,7 @@ import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; @@ -67,7 +68,6 @@ public class Moba extends TeamGame private final HeroKit[] _kits; private final List _capturePoints = new ArrayList<>(3); - private final List _towers = new ArrayList<>(12); private final Set _playerData = new HashSet<>(); @@ -119,6 +119,9 @@ public class Moba extends TeamGame _boss = boss; _listeners.add(boss); + Listener tower = new TowerManager(this); + _listeners.add(tower); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -223,44 +226,6 @@ public class Moba extends TeamGame _capturePoints.add(new CapturePoint(this, location)); } - Map towers = getLocationStartsWith("TOWER"); - - for (Entry entry : towers.entrySet()) - { - String key = entry.getKey(); - Location location = entry.getValue(); - String[] components = key.split(" "); - - if (components.length < 4) - { - continue; - } - - String team = components[1]; - MobaLane lane = MobaLane.valueOf(components[2]); - - boolean firstTower; - - try - { - firstTower = components[3].equalsIgnoreCase("1"); - } - catch (NumberFormatException e) - { - continue; - } - - int health = firstTower ? 250 : 500; - GameTeam gameTeam = getTeam(team); - - if (gameTeam == null) - { - continue; - } - - _towers.add(new Tower(this, location, gameTeam, lane, health, firstTower)); - } - _listeners.forEach(UtilServer::RegisterEvents); } @@ -351,13 +316,6 @@ public class Moba extends TeamGame { _playerData.add(new MobaPlayer(player)); } - - CreatureAllowOverride = true; - for (Tower tower : _towers) - { - tower.setup(); - } - CreatureAllowOverride = false; } @EventHandler @@ -382,11 +340,11 @@ public class Moba extends TeamGame ((HeroSkill) perk).useSkill(mobaPlayer.Player); } - // Teleport players to their respective spawns - GameTeam team = GetTeam(player); - Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + mobaPlayer.Role.getLane().toString()).get(0); - toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); - player.teleport(toTeleport); +// // Teleport players to their respective spawns +// GameTeam team = GetTeam(player); +// Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + mobaPlayer.Role.getLane().toString()).get(0); +// toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); +// player.teleport(toTeleport); } } @@ -684,7 +642,7 @@ public class Moba extends TeamGame return map; } - private GameTeam getTeam(String name) + public GameTeam getTeam(String name) { for (GameTeam team : GetTeamList()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 013c97050..c92293b9f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -6,6 +6,7 @@ import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -46,7 +47,7 @@ public class MobaAI if (_target == null) { - _target = getBestEntityTarget(); + _target = MobaUtil.getBestEntityTarget(_host, _owner, _entity, _home, TARGET_RANGE); if (_target == null) { @@ -76,42 +77,6 @@ public class MobaAI _aiMethod.updateMovement(_entity, _home, 3.5F); } - private LivingEntity getBestEntityTarget() - { - LivingEntity highest = null; - double bestDist = 0; - - for (Entry entry : UtilEnt.getInRadius(_home, TARGET_RANGE).entrySet()) - { - LivingEntity entity = entry.getKey(); - double dist = entry.getValue(); - - if (_entity.equals(entity)) - { - continue; - } - - // Make players more desirable - if (entity instanceof Player) - { - if (_owner.equals(_host.GetTeam((Player) entity))) - { - continue; - } - - dist += 0.5; - } - - if (bestDist < dist) - { - highest = entity; - bestDist = dist; - } - } - - return highest; - } - public void setEntity(LivingEntity entity) { _entity = entity; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java index 168e0a97e..63d96919e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java @@ -100,7 +100,7 @@ public class PregameSelection implements Listener, IPacketHandler _roleStands.put(stand, role); } - }, 5); + }, 20); } private void spawnKitUI(Player player, String dataKey) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 1a6decd79..19c1c5152 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -3,26 +3,48 @@ package nautilus.game.arcade.game.games.moba.structure.tower; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.disguise.disguises.DisguiseGuardian; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaLane; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.entity.Guardian; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.EnderCrystal; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; public class Tower { + private static final int DAMAGE = 3; + private static final int TARGET_RANGE = 10; + public static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; + private final Moba _host; + private final Location _location; private final GameTeam _team; - private MobaLane _lane; + private final MobaLane _lane; + private double _health; private int _maxHealth; private boolean _firstTower; - private Guardian _guardian; + + private ArmorStand _stand; + private DisguiseGuardian _guardian; + private EnderCrystal _crystal; + private boolean _dead; + private float _fallbackYaw; + + private LivingEntity _target; + public Tower(Moba host, Location location, GameTeam team, MobaLane lane, int health, boolean firstTower) { _host = host; @@ -36,26 +58,78 @@ public class Tower public void setup() { -// if (_firstTower) -// { - _guardian = _location.getWorld().spawn(_location, Guardian.class); -// } -// else -// { -// _guardian = UtilVariant.spawnElderGuardian(_location); -// } + _fallbackYaw = UtilAlg.GetYaw(UtilAlg.getTrajectory(_location, _host.GetSpectatorLocation())); + _location.setYaw(_fallbackYaw); + _stand = _location.getWorld().spawn(_location, ArmorStand.class); + _stand.setGravity(false); + _stand.setMaxHealth(_maxHealth); + _stand.setHealth(_health); + + _guardian = new DisguiseGuardian(_stand); + _host.getArcadeManager().GetDisguise().disguise(_guardian); + + if (!_firstTower) + { + _guardian.setElder(true); + } - UtilEnt.vegetate(_guardian); - UtilEnt.setFakeHead(_guardian, true); - UtilEnt.silence(_guardian, true); - _guardian.setRemoveWhenFarAway(false); _guardian.setCustomNameVisible(true); + + _crystal = _location.getWorld().spawn(getTowerBase(), EnderCrystal.class); + _crystal.setCustomNameVisible(true); + updateDisplay(); } public void updateTarget() { + if (_target == null) + { + LivingEntity target = MobaUtil.getBestEntityTarget(_host, _team, _stand, _location, TARGET_RANGE, false); + _target = target; + setLaserTarget(target); + } + else + { + double dist = UtilMath.offsetSquared(_location, _target.getLocation()); + if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target)) + { + _target = null; + setLaserTarget(null); + } + } + } + + public void updateDamage() + { + if (_target == null || _dead) + { + return; + } + + _target.getWorld().playSound(_target.getLocation(), Sound.EXPLODE, 1, 0.2F); + UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, _target.getLocation().add(0, 1.5, 0), 0, 0, 0, 0.2F, 1, ViewDist.LONG); + _host.getArcadeManager().GetDamage().NewDamageEvent(_target, null, null, DamageCause.CUSTOM, DAMAGE, false, true, false, "Tower", "Tower"); + } + + private void setLaserTarget(LivingEntity target) + { + if (target == null) + { + _guardian.setTarget(0); + + Location standLocation = _stand.getLocation(); + standLocation.setYaw(_fallbackYaw); + + _guardian.getEntity().setLocation(standLocation.getX(), standLocation.getY(), standLocation.getZ(), standLocation.getYaw(), 0); + } + else + { + _guardian.setTarget(target.getEntityId()); + } + + _host.getArcadeManager().GetDisguise().updateDisguise(_guardian); } public void damage(double damage) @@ -65,73 +139,60 @@ public class Tower if (_health <= 0) { UtilServer.CallEvent(new TowerDestroyEvent(this)); + _target = null; + setLaserTarget(null); _dead = true; - _guardian.remove(); + _stand.remove(); + _crystal.remove(); explode(); } else { + _stand.setHealth(_health); updateDisplay(); } } private void updateDisplay() { - float percentage = (float) _health / (float) _maxHealth; + String out = MobaUtil.getHealthBar(_stand, 40); - _guardian.setCustomName(getHealthBar(40)); + _guardian.setName(out); + _crystal.setCustomName(out); } private void explode() { - _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_location.clone().subtract(0, 4, 0), 4), _location, false); + _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_location.clone().subtract(0, 3, 0), 3), _location, false); _location.getWorld().playSound(_location, Sound.EXPLODE, 2, 0.6F); UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); } - public boolean isDead() + private Location getTowerBase() { - return _dead; + Block last = _location.getBlock(); + boolean firstAir = false; + + while (true) + { + last = last.getRelative(BlockFace.DOWN); + + if (!firstAir && last.getType() == Material.AIR) + { + firstAir = true; + } + else if (firstAir && last.getType() != Material.AIR) + { + break; + } + } + + return last.getLocation().add(0.5, 0.5, 0.5); } - private String getHealthBar(int bars) + public Location getLocation() { - String out = ""; - String colour; - double health = _guardian.getHealth() / _guardian.getMaxHealth(); - - if (health < 0.25) - { - colour = C.cRedB; - } - else if (health < 0.5) - { - colour = C.cGoldB; - } - else if (health < 0.75) - { - colour = C.cYellowB; - } - else - { - colour = C.cGreenB; - } - - for (int i = 0; i < bars; i++) - { - double cur = i * (1D / (double) bars); - - if (cur < health) - { - out += colour + "|"; - } - else - { - out += C.cGrayB + "|"; - } - } - - return out; + return _location; } public GameTeam getOwner() @@ -139,8 +200,24 @@ public class Tower return _team; } + public MobaLane getLane() + { + return _lane; + } + + public EnderCrystal getCrystal() + { + return _crystal; + } + public boolean isFirstTower() { return _firstTower; } + + public boolean isDead() + { + return _dead; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java new file mode 100644 index 000000000..500de6b7e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -0,0 +1,252 @@ +package nautilus.game.arcade.game.games.moba.structure.tower; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaLane; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.EnderCrystal; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.projectiles.ProjectileSource; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +public class TowerManager implements Listener +{ + + private static final int FIRST_TOWER_HEALTH = 250; + private static final int SECOND_TOWER_HEALTH = 500; + + private final Moba _host; + + private final List _towers; + + public TowerManager(Moba host) + { + _host = host; + + _towers = new ArrayList<>(12); + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + Map towers = _host.getLocationStartsWith("TOWER"); + + for (Entry entry : towers.entrySet()) + { + String key = entry.getKey(); + Location location = entry.getValue(); + String[] components = key.split(" "); + + if (components.length < 4) + { + continue; + } + + String team = components[1]; + MobaLane lane = MobaLane.valueOf(components[2]); + + boolean firstTower; + + try + { + firstTower = components[3].equalsIgnoreCase("1"); + } + catch (NumberFormatException e) + { + continue; + } + + int health = firstTower ? FIRST_TOWER_HEALTH : SECOND_TOWER_HEALTH; + GameTeam gameTeam = _host.getTeam(team); + + if (gameTeam == null) + { + continue; + } + + _towers.add(new Tower(_host, location, gameTeam, lane, health, firstTower)); + } + + _host.CreatureAllowOverride = true; + for (Tower tower : _towers) + { + tower.setup(); + } + _host.CreatureAllowOverride = false; + } + + @EventHandler + public void updateTower(UpdateEvent event) + { + if (event.getType() == UpdateType.FASTEST) + { + for (Tower tower : _towers) + { + tower.updateTarget(); + } + } + else if (event.getType() == UpdateType.SEC) + { + for (Tower tower : _towers) + { + tower.updateDamage(); + } + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void crystalDamage(EntityDamageEvent event) + { + if (event.getEntity() instanceof EnderCrystal) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void crystalDamage(EntityDamageByEntityEvent event) + { + if (!(event.getEntity() instanceof EnderCrystal)) + { + return; + } + + Entity entity = event.getDamager(); + Player player = null; + + if (entity instanceof Player) + { + player = (Player) entity; + } + else if (entity instanceof Projectile) + { + Projectile projectile = (Projectile) entity; + ProjectileSource source = projectile.getShooter(); + + if (source instanceof Player) + { + player = (Player) source; + + // TODO TEMP + if (UtilMath.offsetSquared(player.getLocation(), event.getEntity().getLocation()) > Tower.TARGET_RANGE_SQUARED) + { + return; + } + } + } + + if (player == null) + { + return; + } + + GameTeam team = _host.GetTeam(player); + + if (UtilPlayer.isSpectator(player) || team == null) + { + return; + } + + for (Tower tower : _towers) + { + if (!event.getEntity().equals(tower.getCrystal()) || !canDamage(tower, team)) + { + continue; + } + + event.setCancelled(true); + tower.damage(event.getDamage()); + + if (Recharge.Instance.use(player, "Tower Sound", 1500, false, false)) + { + player.playSound(tower.getCrystal().getLocation(), Sound.BLAZE_HIT, 1, 0.8F); + } + return; + } + } + +// /* +// Hacky work arounds!!!! +// */ +// @EventHandler +// public void updateAnathBlazePowder(UpdateEvent event) +// { +// if (event.getType() != UpdateType.FASTEST) +// { +// return; +// } +// +// for (Tower tower : _towers) +// { +// for (Entity entity : UtilEnt.getAllInRadius(tower.getCrystal().getLocation(), 1.5).keySet()) +// { +// if (entity instanceof Item) +// { +// Item item = (Item) entity; +// if (item.getItemStack().getType() == Material.BLAZE_POWDER) +// { +// +// } +// } +// } +// } +// } + + private boolean canDamage(Tower tower, GameTeam team) + { + // Dead tower, nothing + // Same team + if (tower.isDead() || team.equals(tower.getOwner())) + { + return false; + } + + MobaLane lane = tower.getLane(); + + // First tower, all it + if (tower.isFirstTower()) + { + return true; + } + + // Second tower + // Need to check if previous was destroyed + for (Tower other : _towers) + { + // Is other team + // Is first tower + // Is same lane + // Is dead + if (team.equals(other.getOwner()) && other.isFirstTower() && lane == other.getLane() && other.isDead()) + { + return true; + } + } + + return false; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java new file mode 100644 index 000000000..81f0ab583 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -0,0 +1,101 @@ +package nautilus.game.arcade.game.games.moba.util; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +import java.util.Map.Entry; + +public class MobaUtil +{ + + public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange) + { + return getBestEntityTarget(host, owner, source, location, targetRange, true); + } + + public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayersMore) + { + LivingEntity highest = null; + double bestDist = 0; + + for (Entry entry : UtilEnt.getInRadius(location, targetRange).entrySet()) + { + LivingEntity entity = entry.getKey(); + double dist = entry.getValue(); + + if (source.equals(entity)) + { + continue; + } + + // Make players more desirable + if (entity instanceof Player) + { + if (owner.equals(host.GetTeam((Player) entity))) + { + continue; + } + + if (targetPlayersMore) + { + dist += 0.5; + } + } + + if (bestDist < dist) + { + highest = entity; + bestDist = dist; + } + } + + return highest; + } + + public static String getHealthBar(LivingEntity entity, int bars) + { + String out = ""; + String colour; + double health = entity.getHealth() / entity.getMaxHealth(); + + if (health < 0.25) + { + colour = C.cRedB; + } + else if (health < 0.5) + { + colour = C.cGoldB; + } + else if (health < 0.75) + { + colour = C.cYellowB; + } + else + { + colour = C.cGreenB; + } + + for (int i = 0; i < bars; i++) + { + double cur = i * (1D / (double) bars); + + if (cur < health) + { + out += colour + "|"; + } + else + { + out += C.cGrayB + "|"; + } + } + + return out; + } + + +} From 977907de61ba683d9b872fda1e33b28f0e88646d Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 11:56:50 +0100 Subject: [PATCH 029/283] Fix NPCs not spawning for some players --- .../game/arcade/game/games/moba/kit/PregameSelection.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java index 63d96919e..152a537c2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java @@ -100,7 +100,8 @@ public class PregameSelection implements Listener, IPacketHandler _roleStands.put(stand, role); } - }, 20); + // Only spawn the NPCs once all players have been loaded into the world. + }, _host.GetPlayers(true).size() * _host.TickPerTeleport + 10); } private void spawnKitUI(Player player, String dataKey) From 119b041ec1ae6c7132867f21fdd5557dd944a1ea Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 11:57:04 +0100 Subject: [PATCH 030/283] Fix second towers being invincible --- .../arcade/game/games/moba/structure/tower/TowerManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 500de6b7e..d5bc87989 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -241,7 +241,7 @@ public class TowerManager implements Listener // Is first tower // Is same lane // Is dead - if (team.equals(other.getOwner()) && other.isFirstTower() && lane == other.getLane() && other.isDead()) + if (!team.equals(other.getOwner()) && other.isFirstTower() && lane == other.getLane() && other.isDead()) { return true; } From 08744587542e5f46966dbb16e7c00635824afa73 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 11:58:00 +0100 Subject: [PATCH 031/283] Make the wither display its health --- .../games/moba/boss/wither/WitherBoss.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index c722ff083..bd54f0376 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -5,6 +5,7 @@ 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.UtilTextTop; +import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -16,6 +17,7 @@ import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; import nautilus.game.arcade.game.games.moba.boss.MobaBoss; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.entity.ArmorStand; @@ -35,6 +37,8 @@ public class WitherBoss extends MobaBoss private GameTeam _team; private MobaAI _ai; + private DisguiseWither _disguise; + public WitherBoss(Moba host, Location location, GameTeam team) { super(host, location); @@ -52,10 +56,10 @@ public class WitherBoss extends MobaBoss stand.setHealth(INITIAL_HEALTH); stand.setGravity(false); - DisguiseWither disguiseWither = new DisguiseWither(stand); - disguiseWither.setName(_team.GetColor() + _team.GetName() + "\'s Wither"); - disguiseWither.setCustomNameVisible(true); - _host.getArcadeManager().GetDisguise().disguise(disguiseWither); + _disguise = new DisguiseWither(stand); + _disguise.setName(_team.GetColor() + _team.GetName() + "\'s Wither"); + _disguise.setCustomNameVisible(true); + _host.getArcadeManager().GetDisguise().disguise(_disguise); return stand; } @@ -116,6 +120,7 @@ public class WitherBoss extends MobaBoss if (newHealth > 0) { damagee.setHealth(newHealth); + updateDisplay(); } else { @@ -140,7 +145,7 @@ public class WitherBoss extends MobaBoss } else { - _entity.damage(_entity.getHealth() - SECOND_TOWER_HEALTH_REDUCTION); + _entity.setHealth(_entity.getHealth() - SECOND_TOWER_HEALTH_REDUCTION); } } @@ -159,4 +164,9 @@ public class WitherBoss extends MobaBoss UtilTextTop.displayTextBar(player, percent, _team.GetColor() + "Your Wither"); } } + + private void updateDisplay() + { + _disguise.setName(MobaUtil.getHealthBar(_entity, 40)); + } } From 73ac34ec3d6196fde06bb8da5682a02ea4df7e12 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 11:58:11 +0100 Subject: [PATCH 032/283] Enable teleporting to lanes --- .../nautilus/game/arcade/game/games/moba/Moba.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index a06844e6d..c0ff0f7e8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -30,7 +30,6 @@ import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; -import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; @@ -52,7 +51,6 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.metadata.FixedMetadataValue; import java.util.*; -import java.util.Map.Entry; import java.util.concurrent.TimeUnit; public class Moba extends TeamGame @@ -340,11 +338,11 @@ public class Moba extends TeamGame ((HeroSkill) perk).useSkill(mobaPlayer.Player); } -// // Teleport players to their respective spawns -// GameTeam team = GetTeam(player); -// Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + mobaPlayer.Role.getLane().toString()).get(0); -// toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); -// player.teleport(toTeleport); + // Teleport players to their respective spawns + GameTeam team = GetTeam(player); + Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + mobaPlayer.Role.getLane().toString()).get(0); + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); + player.teleport(toTeleport); } } From 4148af92140b66add2aff7ce411a621b89c23dc3 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 12:16:50 +0100 Subject: [PATCH 033/283] Teleport players "correctly" to their lanes --- .../game/arcade/game/games/moba/Moba.java | 21 ++++++++++++++++--- .../game/arcade/game/games/moba/MobaRole.java | 10 ++++----- .../moba/structure/tower/TowerManager.java | 15 ++++++++++++- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index c0ff0f7e8..e5a3632f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -30,6 +30,7 @@ import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; @@ -74,6 +75,7 @@ public class Moba extends TeamGame private final MobaShop _shop; private final GoldManager _goldManager; private final BossManager _boss; + private final TowerManager _tower; public Moba(ArcadeManager manager) { @@ -117,7 +119,8 @@ public class Moba extends TeamGame _boss = boss; _listeners.add(boss); - Listener tower = new TowerManager(this); + TowerManager tower = new TowerManager(this); + _tower = tower; _listeners.add(tower); new CompassModule() @@ -340,8 +343,20 @@ public class Moba extends TeamGame // Teleport players to their respective spawns GameTeam team = GetTeam(player); - Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + mobaPlayer.Role.getLane().toString()).get(0); - toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); + MobaLane lane = mobaPlayer.Role.getLane(); + Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + lane.toString()).get(0); + + // Face the location toward the first tower of that lane + Tower tower = _tower.getFirsrtTower(lane); + if (tower != null) + { + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), tower.getLocation()))); + } + else + { + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), GetSpectatorLocation()))); + } + player.teleport(toTeleport); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index 9f74a4a3f..29e746afd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.moba; -import mineplex.core.common.util.C; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -13,14 +12,15 @@ public enum MobaRole WARRIOR("Warrior", MobaLane.C, Color.YELLOW, ChatColor.GOLD), ; - private String _name; - private MobaLane _lane; - private Color _color; - private ChatColor _chatColor; + private final String _name; + private final MobaLane _lane; + private final Color _color; + private final ChatColor _chatColor; MobaRole(String name, MobaLane lane, Color color, ChatColor chatColor) { _name = name; + _lane = lane; _color = color; _chatColor = chatColor; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index d5bc87989..fc8ae6a06 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -181,7 +181,7 @@ public class TowerManager implements Listener event.setCancelled(true); tower.damage(event.getDamage()); - if (Recharge.Instance.use(player, "Tower Sound", 1500, false, false)) + if (Recharge.Instance.use(player, "Tower Sound", 500, false, false)) { player.playSound(tower.getCrystal().getLocation(), Sound.BLAZE_HIT, 1, 0.8F); } @@ -189,6 +189,19 @@ public class TowerManager implements Listener } } + public Tower getFirsrtTower(MobaLane lane) + { + for (Tower tower : _towers) + { + if (tower.isFirstTower() && tower.getLane() == lane) + { + return tower; + } + } + + return null; + } + // /* // Hacky work arounds!!!! // */ From 833ebd310e460ff837a6dc593cc5194f46149c3d Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 18:02:34 +0100 Subject: [PATCH 034/283] Reorganise of code --- .../game/arcade/game/games/moba/Moba.java | 355 ++++-------------- .../arcade/game/games/moba/MobaPlayer.java | 44 ++- .../game/arcade/game/games/moba/MobaRole.java | 41 +- .../games/moba/boss/wither/WitherBoss.java | 2 + .../boss/wither/WitherSkullProjectile.java | 2 +- .../games/moba/general/TeamDamageManager.java | 76 ++++ .../game/games/moba/gold/GoldManager.java | 2 +- .../games/moba/kit/anath/SkillMeteor.java | 4 +- .../game/games/moba/kit/hp/HPManager.java | 57 +++ .../moba/{ => kit/hp}/MobaHPRegenEvent.java | 2 +- .../arcade/game/games/moba/minion/Minion.java | 6 + .../game/games/moba/minion/MinionManager.java | 17 + .../moba/prepare/PrepareInformation.java | 114 ++++++ .../games/moba/prepare/PrepareManager.java | 168 +++++++++ .../PrepareSelection.java} | 15 +- .../game/games/moba/shop/MobaItemEffect.java | 2 +- .../arcade/game/games/moba/shop/MobaShop.java | 12 +- .../games/moba/shop/MobaShopCategoryMenu.java | 2 +- .../moba/shop/effects/MobaHPRegenEffect.java | 2 +- .../shop/effects/MobaHitArrowAmmoEffect.java | 2 +- .../moba/shop/effects/MobaKillHealEffect.java | 3 - .../moba/shop/effects/MobaSpeedEffect.java | 2 - .../structure/point/CapturePointManager.java | 64 ++++ .../games/moba/structure/tower/Tower.java | 7 +- 24 files changed, 675 insertions(+), 326 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/{ => kit/hp}/MobaHPRegenEvent.java (93%) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/{kit/PregameSelection.java => prepare/PrepareSelection.java} (94%) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index e5a3632f5..ad0a4624f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,18 +1,10 @@ package nautilus.game.arcade.game.games.moba; import mineplex.core.common.Rank; -import mineplex.core.common.entity.ClientArmorStand; import mineplex.core.common.util.*; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; -import mineplex.minecraft.game.core.condition.Condition; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; -import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; @@ -20,22 +12,26 @@ import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.boss.BossManager; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; +import nautilus.game.arcade.game.games.moba.general.TeamDamageManager; 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.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.KitPlayer; import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath; import nautilus.game.arcade.game.games.moba.kit.bob.HeroBob; import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana; import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; +import nautilus.game.arcade.game.games.moba.kit.hp.HPManager; +import nautilus.game.arcade.game.games.moba.minion.MinionManager; +import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; +import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; -import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; -import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.GameMode; import org.bukkit.Location; @@ -45,11 +41,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; import java.util.*; import java.util.concurrent.TimeUnit; @@ -61,13 +54,9 @@ public class Moba extends TeamGame "..." }; 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; - private final List _capturePoints = new ArrayList<>(3); - private final Set _playerData = new HashSet<>(); private final Set _listeners = new HashSet<>(); @@ -76,6 +65,7 @@ public class Moba extends TeamGame private final GoldManager _goldManager; private final BossManager _boss; private final TowerManager _tower; + private final CapturePointManager _capturePoint; public Moba(ArcadeManager manager) { @@ -98,30 +88,29 @@ public class Moba extends TeamGame HungerSet = 20; DamageFall = false; - Listener preGameSelection = new PregameSelection(this); - _listeners.add(preGameSelection); + // Instantiate managers - Listener recall = new Recall(this); - _listeners.add(recall); + // Global managers + _shop = registerManager(new MobaShop(this)); + _goldManager = registerManager(new GoldManager(this)); + registerManager(new HPManager(this)); + registerManager(new TeamDamageManager(this)); + registerManager(new MobaFountain(this)); + registerManager(new Recall(this)); - MobaShop shop = new MobaShop(this); - _shop = shop; - _listeners.add(shop); + // Pregame managers + registerManager(new PrepareManager(this)); + registerManager(new PrepareSelection(this)); - GoldManager goldManager = new GoldManager(this); - _goldManager = goldManager; - _listeners.add(goldManager); + // Bosses + _boss = registerManager(new BossManager(this)); - MobaFountain fountain = new MobaFountain(this); - _listeners.add(fountain); + // Structures + _tower = registerManager(new TowerManager(this)); + _capturePoint = registerManager(new CapturePointManager(this)); - BossManager boss = new BossManager(this); - _boss = boss; - _listeners.add(boss); - - TowerManager tower = new TowerManager(this); - _tower = tower; - _listeners.add(tower); + // Minions + //registerManager(new MinionManager(this)); new CompassModule() .setGiveCompass(true) @@ -169,20 +158,20 @@ public class Moba extends TeamGame GameState state = GetState(); GameTeam perspectiveTeam = GetTeam(perspective); GameTeam subjectTeam = GetTeam(subject); - MobaPlayer mobaPlayer = getData(subject); + MobaPlayer mobaPlayer = getMobaData(subject); String suffix; if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam)) { suffix = "Unknown"; } - else if (mobaPlayer.Kit == null) + else if (mobaPlayer.getKit() == null) { suffix = "Selecting"; } else { - suffix = mobaPlayer.Kit.GetName(); + suffix = mobaPlayer.getKit().GetName(); } return C.cYellow + " " + suffix + C.Reset; @@ -217,22 +206,22 @@ public class Moba extends TeamGame }); } + private T registerManager(T listener) + { + _listeners.add(listener); + return listener; + } + @Override public void ParseData() { - Collection capturePoints = getLocationStartsWith("POINT").values(); - - for (Location location : capturePoints) - { - _capturePoints.add(new CapturePoint(this, location)); - } - + // Register all "Managers" _listeners.forEach(UtilServer::RegisterEvents); } private void writePrepare(Player player, GameScoreboard scoreboard) { - MobaPlayer mobaPlayer = getData(player); + MobaPlayer mobaPlayer = getMobaData(player); scoreboard.writeNewLine(); @@ -242,7 +231,7 @@ public class Moba extends TeamGame scoreboard.writeNewLine(); scoreboard.write(C.cYellowB + "Hero"); - scoreboard.write(mobaPlayer.Kit == null ? "Unselected " : mobaPlayer.Kit.GetName() + " (" + mobaPlayer.Role.getName() + ")"); + scoreboard.write(mobaPlayer.getKit() == null ? "Unselected " : mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getName() + ")"); scoreboard.writeNewLine(); @@ -251,7 +240,7 @@ public class Moba extends TeamGame for (MobaPlayer otherMobaPlayer : _playerData) { - if (otherMobaPlayer.Kit != null) + if (otherMobaPlayer.getKit() != null) { kits++; } @@ -319,48 +308,6 @@ public class Moba extends TeamGame } } - @EventHandler - public void live(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - { - return; - } - - UtilTextBottom.display(C.cRedB + "!!! Battle !!!", UtilServer.getPlayers()); - - for (MobaPlayer mobaPlayer : _playerData) - { - Player player = mobaPlayer.Player; - HeroKit kit = mobaPlayer.Kit; - Perk perk = kit.GetPerks()[kit.GetPerks().length - 1]; - - // Put Ultimates on cooldown - if (perk instanceof HeroSkill) - { - ((HeroSkill) perk).useSkill(mobaPlayer.Player); - } - - // Teleport players to their respective spawns - GameTeam team = GetTeam(player); - MobaLane lane = mobaPlayer.Role.getLane(); - Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + lane.toString()).get(0); - - // Face the location toward the first tower of that lane - Tower tower = _tower.getFirsrtTower(lane); - if (tower != null) - { - toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), tower.getLocation()))); - } - else - { - toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), GetSpectatorLocation()))); - } - - player.teleport(toTeleport); - } - } - @Override public void EndCheck() { @@ -428,95 +375,6 @@ public class Moba extends TeamGame _listeners.clear(); } - @EventHandler - public void update(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - { - return; - } - - for (CapturePoint point : _capturePoints) - { - point.update(); - } - } - - @EventHandler - public void updatePrepare(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC || GetState() != GameState.Prepare) - { - return; - } - - if (!UtilTime.elapsed(GetStateTime(), PREPARE_TIME)) - { - for (Player player : GetPlayers(true)) - { - Kit kit = GetKit(player); - - if (!(kit instanceof HeroKit)) - { - return; - } - } - } - - AnnounceGame(); - StartPrepareCountdown(); - - //Event - GamePrepareCountdownCommence countdownEvent = new GamePrepareCountdownCommence(this); - UtilServer.CallEvent(countdownEvent); - - // If players took too long, just give them a random free role and kit. - for (Player player : GetPlayers(true)) - { - Kit kit = GetKit(player); - - if (kit instanceof HeroKit) - { - continue; - } - - HeroKit heroKit = getFirstKit(player); - MobaPlayer mobaPlayer = getData(player); - - mobaPlayer.Role = heroKit.getRole(); - mobaPlayer.Kit = heroKit; - - SetKit(player, heroKit, true); - } - - PrepareTime = 0; - Manager.GetChat().Silence(0, false); - } - - @EventHandler - public void roleSelect(RoleSelectEvent event) - { - Player player = event.getPlayer(); - MobaRole role = event.getRole(); - ClientArmorStand stand = event.getStand(); - - if (stand.hasMetadata("owned")) - { - player.sendMessage(F.main("Game", "Another player has already chosen this role.")); - event.setCancelled(true); - return; - } - - // Store inside the stand that it is claimed by a player - stand.setMetadata("owned", new FixedMetadataValue(Manager.getPlugin(), true)); - - // Show that the kit is claimed. - stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + player.getName()); - - // Store the role of the player - getData(player).Role = role; - } - @Override public void SetKit(Player player, Kit kit, boolean announce) { @@ -524,7 +382,7 @@ public class Moba extends TeamGame if (kit instanceof HeroKit) { - getData(player).Kit = (HeroKit) kit; + getMobaData(player).setKit((HeroKit) kit); } } @@ -534,68 +392,16 @@ public class Moba extends TeamGame return DeathMessageType.Detailed; } - @EventHandler - public void preventTeamDamage(CustomDamageEvent event) - { - Player damagee = event.GetDamageePlayer(); - Player damager = event.GetDamagerPlayer(true); - - if (damagee == null || damager == null) - { - return; - } - - GameTeam damageeTeam = GetTeam(damagee); - GameTeam damagerTeam = GetTeam(damager); - - if (damageeTeam == null || damagerTeam == null) - { - return; - } - - if (damageeTeam.equals(damagerTeam)) - { - event.SetCancelled("Team Damage"); - } - } - - @EventHandler - public void preventTeamFire(ConditionApplyEvent event) - { - Condition condition = event.GetCondition(); - - if (condition.GetType() != ConditionType.BURNING) - { - return; - } - - if (condition.GetEnt() == null || condition.GetSource() == null) - { - return; - } - - if (!(condition.GetEnt() instanceof Player && condition.GetSource() instanceof Player)) - { - return; - } - - if (!GetTeam((Player) condition.GetEnt()).equals(GetTeam((Player) condition.GetSource()))) - { - return; - } - - event.setCancelled(true); - } - // Clear up memory @EventHandler public void playerQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); - _playerData.removeIf(mobaPlayer -> mobaPlayer.Player.equals(player)); + _playerData.removeIf(mobaPlayer -> mobaPlayer.getPlayer().equals(player)); } + // Clean up arrows @EventHandler public void projectileHit(ProjectileHitEvent event) { @@ -605,41 +411,6 @@ 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 getLocationStartsWith(String s) { Map map = new HashMap<>(); @@ -688,11 +459,16 @@ public class Moba extends TeamGame return kits; } - public MobaPlayer getData(Player player) + public Set getMobaData() + { + return _playerData; + } + + public MobaPlayer getMobaData(Player player) { for (MobaPlayer mobaPlayer : _playerData) { - if (mobaPlayer.Player.equals(player)) + if (mobaPlayer.getPlayer().equals(player)) { return mobaPlayer; } @@ -701,19 +477,19 @@ public class Moba extends TeamGame return null; } - private HeroKit getFirstKit(Player player) + public HeroKit getFirstKit(Player player) { - MobaPlayer mobaPlayer = getData(player); + MobaPlayer mobaPlayer = getMobaData(player); - if (mobaPlayer.Role == null) + if (mobaPlayer.getRole() == null) { MobaRole role = getRandomRole(player); return getFirstKit(role); } - else if (mobaPlayer.Kit == null) + else if (mobaPlayer.getKit() == null) { - return getFirstKit(mobaPlayer.Role); + return getFirstKit(mobaPlayer.getRole()); } return null; @@ -738,7 +514,7 @@ public class Moba extends TeamGame for (MobaPlayer mobaPlayer : getTeamData(GetTeam(player))) { - MobaRole role = mobaPlayer.Role; + MobaRole role = mobaPlayer.getRole(); if (role != null) { @@ -749,13 +525,13 @@ public class Moba extends TeamGame return UtilAlg.Random(Arrays.asList(MobaRole.values()), roles); } - public List getTeamData(GameTeam team) + private List getTeamData(GameTeam team) { List players = new ArrayList<>(); for (MobaPlayer mobaPlayer : _playerData) { - GameTeam otherTeam = GetTeam(mobaPlayer.Player); + GameTeam otherTeam = GetTeam(mobaPlayer.getPlayer()); if (team.equals(otherTeam)) { @@ -766,11 +542,6 @@ public class Moba extends TeamGame return players; } - public List getCapturePoints() - { - return _capturePoints; - } - public MobaShop getShop() { return _shop; @@ -780,4 +551,14 @@ public class Moba extends TeamGame { return _goldManager; } + + public TowerManager getTowerManager() + { + return _tower; + } + + public CapturePointManager getCapturePointManager() + { + return _capturePoint; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java index 82c06bf33..a085b8eaa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java @@ -6,12 +6,48 @@ import org.bukkit.entity.Player; public class MobaPlayer { - public final Player Player; - public MobaRole Role; - public HeroKit Kit; + private final Player _player; + private MobaRole _role; + private HeroKit _kit; + private int _gold; public MobaPlayer(Player player) { - Player = player; + _player = player; + } + + public Player getPlayer() + { + return _player; + } + + public void setRole(MobaRole role) + { + _role = role; + } + + public MobaRole getRole() + { + return _role; + } + + public void setKit(HeroKit kit) + { + _kit = kit; + } + + public HeroKit getKit() + { + return _kit; + } + + public void setGold(int gold) + { + _gold = gold; + } + + public int getGold() + { + return _gold; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index 29e746afd..a0c431980 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,25 +1,51 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.common.util.C; import org.bukkit.ChatColor; import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", MobaLane.D, Color.BLUE, ChatColor.AQUA), - HUNTER("Hunter", MobaLane.A, Color.LIME, ChatColor.GREEN), - MAGE("Mage", MobaLane.B, Color.RED, ChatColor.RED), - WARRIOR("Warrior", MobaLane.C, Color.YELLOW, ChatColor.GOLD), + ASSASSIN("Assassin", new String[] + { + + "You are playing", + "the " + C.cAqua + "Assassin" + C.cWhite + " role this game", + + }, MobaLane.D, Color.BLUE, ChatColor.AQUA), + HUNTER("Hunter", new String[] + { + "You are playing", + "the " + C.cGreen + "Hunter" + C.cWhite + " role this game", + + }, MobaLane.A, Color.LIME, ChatColor.GREEN), + MAGE("Mage", new String[] + { + + "You are playing", + "the " + C.cRed + "Mage" + C.cWhite + " role this game", + + }, MobaLane.B, Color.RED, ChatColor.RED), + WARRIOR("Warrior", new String[] + { + + "You are playing", + "the " + C.cGold + "Warrior" + C.cWhite + " role this game", + + }, MobaLane.C, Color.YELLOW, ChatColor.GOLD), ; private final String _name; + private final String[] _description; private final MobaLane _lane; private final Color _color; private final ChatColor _chatColor; - MobaRole(String name, MobaLane lane, Color color, ChatColor chatColor) + MobaRole(String name, String[] description, MobaLane lane, Color color, ChatColor chatColor) { _name = name; + _description = description; _lane = lane; _color = color; _chatColor = chatColor; @@ -30,6 +56,11 @@ public enum MobaRole return _name; } + public String[] getDescription() + { + return _description; + } + public MobaLane getLane() { return _lane; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index bd54f0376..ca472d25f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -147,6 +147,8 @@ public class WitherBoss extends MobaBoss { _entity.setHealth(_entity.getHealth() - SECOND_TOWER_HEALTH_REDUCTION); } + + updateDisplay(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java index 753c06575..787bfe95f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java @@ -36,7 +36,7 @@ public class WitherSkullProjectile implements IThrown WitherSkull skull = shooter.launchProjectile(WitherSkull.class); skull.setYield(0); - skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target)).normalize().multiply(2)); + skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target))); _manager.GetProjectile().AddThrow(skull, shooter, this, 2000, true, true, true, false, 0.5F); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java new file mode 100644 index 000000000..78c6cb874 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java @@ -0,0 +1,76 @@ +package nautilus.game.arcade.game.games.moba.general; + +import mineplex.minecraft.game.core.condition.Condition; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class TeamDamageManager implements Listener +{ + + private final Moba _host; + + public TeamDamageManager(Moba host) + { + _host = host; + } + + @EventHandler + public void preventTeamDamage(CustomDamageEvent event) + { + Player damagee = event.GetDamageePlayer(); + Player damager = event.GetDamagerPlayer(true); + + if (damagee == null || damager == null) + { + return; + } + + GameTeam damageeTeam = _host.GetTeam(damagee); + GameTeam damagerTeam = _host.GetTeam(damager); + + if (damageeTeam == null || damagerTeam == null) + { + return; + } + + if (damageeTeam.equals(damagerTeam)) + { + event.SetCancelled("Team Damage"); + } + } + + @EventHandler + public void preventTeamFire(ConditionApplyEvent event) + { + Condition condition = event.GetCondition(); + + if (condition.GetType() != ConditionType.BURNING) + { + return; + } + + if (condition.GetEnt() == null || condition.GetSource() == null) + { + return; + } + + if (!(condition.GetEnt() instanceof Player && condition.GetSource() instanceof Player)) + { + return; + } + + if (!_host.GetTeam((Player) condition.GetEnt()).equals(_host.GetTeam((Player) condition.GetSource()))) + { + return; + } + + event.setCancelled(true); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index 79edc6baa..e4fedc4a0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -96,7 +96,7 @@ public class GoldManager implements Listener } // Capture points - for (CapturePoint point : _host.getCapturePoints()) + for (CapturePoint point : _host.getCapturePointManager().getCapturePoints()) { GameTeam owner = point.getOwner(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index 89fee9780..5314786c3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -62,7 +62,7 @@ public class SkillMeteor extends HeroSkill implements IThrown FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.NETHERRACK, (byte) 0); block.setVelocity(player.getLocation().getDirection()); - Manager.GetProjectile().AddThrow(block, player, this, 1000, true, true, true, false, 0.5F); + Manager.GetProjectile().AddThrow(block, player, this, 2000, true, true, true, false, 0.5F); useActiveSkill(player, 7000); } @@ -138,7 +138,7 @@ public class SkillMeteor extends HeroSkill implements IThrown @Override public void Idle(ProjectileUser data) { - + Expire(data); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java new file mode 100644 index 000000000..298c46afa --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java @@ -0,0 +1,57 @@ +package nautilus.game.arcade.game.games.moba.kit.hp; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; + +public class HPManager implements Listener +{ + + // Health per 5 seconds. + private static final double HP5 = 0.33; + + private final Moba _host; + + public HPManager(Moba host) + { + _host = host; + } + + @EventHandler + public void regeneration(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC_05 || !_host.IsLive()) + { + return; + } + + for (Player player : _host.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); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java similarity index 93% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java index 0ec5994c8..770d2acfc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.moba; +package nautilus.game.arcade.game.games.moba.kit.hp; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java new file mode 100644 index 000000000..364b15edd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -0,0 +1,6 @@ +package nautilus.game.arcade.game.games.moba.minion; + +public class Minion +{ + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java new file mode 100644 index 000000000..6a64db0d6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -0,0 +1,17 @@ +package nautilus.game.arcade.game.games.moba.minion; + +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.event.Listener; + +public class MinionManager implements Listener +{ + + private final Moba _host; + + public MinionManager(Moba host) + { + _host = host; + } + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java new file mode 100644 index 000000000..4a2207562 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java @@ -0,0 +1,114 @@ +package nautilus.game.arcade.game.games.moba.prepare; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaPlayer; +import nautilus.game.arcade.game.games.moba.MobaRole; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; + +import java.util.concurrent.TimeUnit; + +public class PrepareInformation implements Listener +{ + + private static final long MESSAGE_TIME = TimeUnit.SECONDS.toMillis(5); + private static final int MESSAGE_TIME_TICKS = (int) (MESSAGE_TIME / 50D + 5); + + private final Moba _host; + + private long _lastMessage; + private int _messageIndex; + + public PrepareInformation(Moba host) + { + _host = host; + + // How long should the prepare time be. + int longestDescription = 0; + for (MobaRole role : MobaRole.values()) + { + int length = role.getDescription().length; + + if (length > longestDescription) + { + longestDescription = length; + } + } + + // Modify the prepare time + _host.PrepareTime = longestDescription * 1000 + 1000; + + UtilServer.RegisterEvents(this); + } + + @EventHandler + public void updateMessages(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !UtilTime.elapsed(_lastMessage, MESSAGE_TIME)) + { + return; + } + + Bukkit.broadcastMessage("updateMessages"); + + for (MobaPlayer mobaPlayer : _host.getMobaData()) + { + Bukkit.broadcastMessage(mobaPlayer.getPlayer().getName()); + String[] description = mobaPlayer.getRole().getDescription(); + + // Description is too short + if (description.length > _messageIndex + 2) + { + Bukkit.broadcastMessage("Too short"); + continue; + } + + UtilTextMiddle.display(description[_messageIndex], description[_messageIndex + 1], 0, MESSAGE_TIME_TICKS, 0, mobaPlayer.getPlayer()); + } + + _messageIndex++; + _lastMessage = System.currentTimeMillis(); + } + + @EventHandler + public void playerMove(PlayerMoveEvent event) + { + if (UtilPlayer.isSpectator(event.getPlayer())) + { + return; + } + + Location to = event.getTo(); + Location from = event.getFrom(); + + // Player hasn't moved along the X or Z axis + if (to.getX() == from.getX() && to.getZ() == from.getZ()) + { + return; + } + + event.setCancelled(true); + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + UtilServer.Unregister(this); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java new file mode 100644 index 000000000..bcc6e7ca6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java @@ -0,0 +1,168 @@ +package nautilus.game.arcade.game.games.moba.prepare; + +import mineplex.core.common.entity.ClientArmorStand; +import mineplex.core.common.util.*; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GamePrepareCountdownCommence; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaLane; +import nautilus.game.arcade.game.games.moba.MobaPlayer; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.metadata.FixedMetadataValue; + +import java.util.concurrent.TimeUnit; + +public class PrepareManager implements Listener +{ + + private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1); + private static final String OWNED_METADATA = "owned"; + + private final Moba _host; + + private boolean _informationStage; + + public PrepareManager(Moba host) + { + _host = host; + } + + @EventHandler(priority = EventPriority.LOW) + public void updatePrepare(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || _host.GetState() != GameState.Prepare || _informationStage) + { + return; + } + + if (!UtilTime.elapsed(_host.GetStateTime(), PREPARE_TIME)) + { + for (Player player : _host.GetPlayers(true)) + { + Kit kit = _host.GetKit(player); + + if (!(kit instanceof HeroKit)) + { + return; + } + } + } + + _informationStage = true; + + _host.AnnounceGame(); + _host.StartPrepareCountdown(); + + //Event + GamePrepareCountdownCommence countdownEvent = new GamePrepareCountdownCommence(_host); + UtilServer.CallEvent(countdownEvent); + + // If players took too long, just give them a random free role and kit. + for (Player player : _host.GetPlayers(true)) + { + Kit kit = _host.GetKit(player); + + if (kit instanceof HeroKit) + { + continue; + } + + HeroKit heroKit = _host.getFirstKit(player); + MobaPlayer mobaPlayer = _host.getMobaData(player); + + mobaPlayer.setRole(heroKit.getRole()); + + _host.SetKit(player, heroKit, true); + } + + for (MobaPlayer mobaPlayer : _host.getMobaData()) + { + // Teleport players to their respective spawns + Player player = mobaPlayer.getPlayer(); + GameTeam team = _host.GetTeam(player); + MobaLane lane = mobaPlayer.getRole().getLane(); + Location toTeleport = _host.WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + lane.toString()).get(0); + + // Face the location toward the first tower of that lane + Tower tower = _host.getTowerManager().getFirsrtTower(lane); + if (tower != null) + { + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), tower.getLocation()))); + } + else + { + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), _host.GetSpectatorLocation()))); + } + + player.teleport(toTeleport); + } + + _host.SetStateTime(System.currentTimeMillis()); + _host.getArcadeManager().GetChat().Silence(-1, false); + + // Start the pregame role information + new PrepareInformation(_host); + } + + @EventHandler + public void roleSelect(RoleSelectEvent event) + { + Player player = event.getPlayer(); + MobaRole role = event.getRole(); + ClientArmorStand stand = event.getStand(); + + if (stand.hasMetadata(OWNED_METADATA)) + { + player.sendMessage(F.main("Game", "Another player has already chosen this role.")); + event.setCancelled(true); + return; + } + + // Store inside the stand that it is claimed by a player + stand.setMetadata(OWNED_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), true)); + + // Show that the kit is claimed. + stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + player.getName()); + + // Store the role of the player + _host.getMobaData(player).setRole(role); + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + for (MobaPlayer mobaPlayer : _host.getMobaData()) + { + HeroKit kit = mobaPlayer.getKit(); + Perk perk = kit.GetPerks()[kit.GetPerks().length - 1]; + + // Put Ultimates on cooldown + if (perk instanceof HeroSkill) + { + ((HeroSkill) perk).useSkill(mobaPlayer.getPlayer()); + } + } + + _host.getArcadeManager().GetChat().Silence(0, true); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java similarity index 94% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index 152a537c2..c4c3bccba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.moba.kit; +package nautilus.game.arcade.game.games.moba.prepare; import mineplex.core.common.entity.ClientArmorStand; import mineplex.core.common.util.*; @@ -9,16 +9,15 @@ import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler.ListenerPriority; import mineplex.core.packethandler.PacketInfo; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerKitApplyEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; -import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import org.bukkit.*; -import org.bukkit.FireworkEffect.Type; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -31,14 +30,14 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -public class PregameSelection implements Listener, IPacketHandler +public class PrepareSelection implements Listener, IPacketHandler { private final Moba _host; private final Map _roleStands = new HashMap<>(); private final Map _kitStands = new HashMap<>(); - public PregameSelection(Moba host) + public PrepareSelection(Moba host) { _host = host; @@ -111,9 +110,9 @@ public class PregameSelection implements Listener, IPacketHandler List spawns = _host.WorldData.GetDataLocs(dataKey); Location average = UtilAlg.getAverageLocation(team.GetSpawns()); - MobaPlayer mobaPlayer = _host.getData(player); + MobaPlayer mobaPlayer = _host.getMobaData(player); - List heroKits = _host.getKits(mobaPlayer.Role); + List heroKits = _host.getKits(mobaPlayer.getRole()); ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 2).build(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java index 6adeb01db..ce3b3a233 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -4,7 +4,7 @@ import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; -import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; +import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index b259725f4..407450cc2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -11,11 +11,11 @@ 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.AmmoGiveEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop; import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop; @@ -91,20 +91,20 @@ public class MobaShop implements Listener public void openShop(MobaPlayer player) { - if (UtilPlayer.isSpectator(player.Player) || _host.GetState() != GameState.Live) + if (UtilPlayer.isSpectator(player.getPlayer()) || _host.GetState() != GameState.Live) { return; } - MobaShopMenu menu = _roleMenus.get(player.Role); + MobaShopMenu menu = _roleMenus.get(player.getRole()); if (menu == null) { - player.Player.sendMessage(F.main("Game", "There isn't an upgrade shop for that kit yet.")); + player.getPlayer().sendMessage(F.main("Game", "There isn't an upgrade shop for that kit yet.")); return; } - menu.open(player.Player); + menu.open(player.getPlayer()); } @EventHandler @@ -163,7 +163,7 @@ public class MobaShop implements Listener { if (clicked.equals(shop)) { - MobaPlayer data = _host.getData(player); + MobaPlayer data = _host.getMobaData(player); if (data == null) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java index a6026d4fb..f6ca8ac51 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -125,7 +125,7 @@ public class MobaShopCategoryMenu extends Menu @Override public void onClick(Player player, ClickType clickType) { - _shop.openShop(_host.getData(player)); + _shop.openShop(_host.getMobaData(player)); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java index b9d8fc749..0489fe986 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java @@ -1,7 +1,7 @@ package nautilus.game.arcade.game.games.moba.shop.effects; import mineplex.core.common.util.F; -import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; +import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; public class MobaHPRegenEffect extends MobaItemEffect diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java index 4d2393326..791794fc2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java @@ -23,7 +23,7 @@ public class MobaHitArrowAmmoEffect extends MobaItemEffect Player damager = event.GetDamagerPlayer(true); Moba host = (Moba) Managers.get(ArcadeManager.class).GetGame(); - HeroKit kit = host.getData(damager).Kit; + HeroKit kit = host.getMobaData(damager).getKit(); kit.giveAmmo(damager, 1); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java index 3086e7b84..7c6bdfba7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -2,9 +2,6 @@ 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; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java index 23f3e4bbe..15d7d7196 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java @@ -2,8 +2,6 @@ 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; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java new file mode 100644 index 000000000..70fe02415 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java @@ -0,0 +1,64 @@ +package nautilus.game.arcade.game.games.moba.structure.point; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Location; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class CapturePointManager implements Listener +{ + + private final Moba _host; + + private final List _capturePoints; + + public CapturePointManager(Moba host) + { + _host = host; + + _capturePoints = new ArrayList<>(3); + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + Collection capturePoints = _host.getLocationStartsWith("POINT").values(); + + for (Location location : capturePoints) + { + _capturePoints.add(new CapturePoint(_host, location)); + } + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + for (CapturePoint point : _capturePoints) + { + point.update(); + } + } + + public List getCapturePoints() + { + return _capturePoints; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 19c1c5152..84d9e7717 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -139,12 +139,16 @@ public class Tower if (_health <= 0) { UtilServer.CallEvent(new TowerDestroyEvent(this)); + + // Boom! + explode(); + + // Nullify everything and remove all entities _target = null; setLaserTarget(null); _dead = true; _stand.remove(); _crystal.remove(); - explode(); } else { @@ -163,7 +167,6 @@ public class Tower private void explode() { - _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_location.clone().subtract(0, 3, 0), 3), _location, false); _location.getWorld().playSound(_location, Sound.EXPLODE, 2, 0.6F); UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); } From 604804ff96bfd48c9116a3e0d865107115c1090b Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 18:02:50 +0100 Subject: [PATCH 035/283] Fix tower explosions not working as intended --- .../game/arcade/game/games/moba/structure/tower/Tower.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 84d9e7717..74624f3a6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -167,6 +167,7 @@ public class Tower private void explode() { + _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_crystal.getLocation().add(0, 2, 0), 3), _location, false); _location.getWorld().playSound(_location, Sound.EXPLODE, 2, 0.6F); UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); } From 5d63a19506203a0d7aefe647d8930640239556dd Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 22:33:08 +0100 Subject: [PATCH 036/283] Minion AI Base --- .../game/arcade/game/games/moba/Moba.java | 2 +- .../game/arcade/game/games/moba/MobaLane.java | 20 +- .../arcade/game/games/moba/ai/MobaAI.java | 4 - .../game/games/moba/ai/goal/MobaAIMethod.java | 2 +- .../moba/ai/goal/MobaDirectAIMethod.java | 3 +- .../moba/ai/goal/MobaEntityAIMethod.java | 10 +- .../games/moba/kit/anath/SkillBurnBeam.java | 2 +- .../game/games/moba/kit/common/DashSkill.java | 2 +- .../games/moba/kit/dana/SkillDanaDash.java | 2 +- .../arcade/game/games/moba/minion/Minion.java | 52 +++++ .../game/games/moba/minion/MinionManager.java | 122 ++++++++++++ .../game/games/moba/minion/MinionWave.java | 184 ++++++++++++++++++ .../moba/prepare/PrepareInformation.java | 7 +- .../arcade/game/games/moba/shop/MobaShop.java | 6 +- .../games/moba/structure/tower/Tower.java | 9 +- .../moba/structure/tower/TowerManager.java | 13 ++ .../arcade/game/games/moba/util/MobaUtil.java | 6 + 17 files changed, 421 insertions(+), 25 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index ad0a4624f..9131a3e7e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -110,7 +110,7 @@ public class Moba extends TeamGame _capturePoint = registerManager(new CapturePointManager(this)); // Minions - //registerManager(new MinionManager(this)); + registerManager(new MinionManager(this)); new CompassModule() .setGiveCompass(true) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java index a6426575e..19857dd19 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java @@ -6,10 +6,22 @@ import org.bukkit.ChatColor; public enum MobaLane { - A, - B, - C, - D; + A("ORANGE"), + B("YELLOW"), + C("LIME"), + D(null); + + private final String _minionPath; + + MobaLane(String minionPath) + { + _minionPath = minionPath; + } + + public String getMinionPathKey() + { + return _minionPath; + } public String getName(GameTeam team) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index c92293b9f..2a7588bf9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.moba.ai; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.GameTeam; @@ -9,9 +8,6 @@ import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -import java.util.Map.Entry; public class MobaAI { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java index cb20ef390..bba2324af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java @@ -6,6 +6,6 @@ import org.bukkit.entity.LivingEntity; public interface MobaAIMethod { - void updateMovement(LivingEntity entity, Location goal, float speed); + boolean updateMovement(LivingEntity entity, Location goal, float speed); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index 65e458420..b8b95c59a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -12,7 +12,7 @@ public class MobaDirectAIMethod implements MobaAIMethod private static final float YAW_SNAP_LIMIT = 20F; @Override - public void updateMovement(LivingEntity entity, Location goal, float speed) + public boolean updateMovement(LivingEntity entity, Location goal, float speed) { Location entityLocation = entity.getLocation(); @@ -66,5 +66,6 @@ public class MobaDirectAIMethod implements MobaAIMethod // Move the entity to its new location entity.teleport(entityLocation); + return true; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java index 6e6b605cc..44c921af7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.ai.goal; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -8,8 +9,13 @@ public class MobaEntityAIMethod implements MobaAIMethod { @Override - public void updateMovement(LivingEntity entity, Location goal, float speed) + public boolean updateMovement(LivingEntity entity, Location goal, float speed) { - UtilEnt.CreatureMoveFast(entity, goal, speed); + if (UtilMath.offsetSquared(entity.getLocation(), goal) < 4) + { + return false; + } + + return UtilEnt.CreatureMoveFast(entity, goal, speed); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java index 752d81e78..2349123f2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java @@ -82,7 +82,7 @@ public class SkillBurnBeam extends HeroSkill for (LivingEntity entity : UtilEnt.getInRadius(particle.getLastLocation(), 2).keySet()) { - if (entity.equals(player) || !Recharge.Instance.use(player, GetName() + entity.getName() + player.getName(), 2000, false, false)) + if (entity.equals(player) || !Recharge.Instance.use(player, GetName() + entity.getUniqueId() + player.getName(), 2000, false, false)) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java index e3ff6f068..b3217cd23 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -181,7 +181,7 @@ public class DashSkill extends HeroSkill continue; } - if (!(entity instanceof Player) || !Recharge.Instance.use((Player) entity, GetName() + " by " + player.getName(), 500, false, false) && _collideOnce) + if (_collideOnce && !Recharge.Instance.use(player, GetName() + player.getName() + entity.getUniqueId(), 500, false, false)) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java index f6ca20836..0bb7af0f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java @@ -69,7 +69,7 @@ public class SkillDanaDash extends DashSkill } entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_HIT, 1, 0.5F); - Manager.GetDamage().NewDamageEvent(entity, damager, null, DamageCause.CUSTOM, damage, false, false, false, UtilEnt.getName(damager), GetName()); + Manager.GetDamage().NewDamageEvent(entity, damager, null, DamageCause.CUSTOM, damage, false, true, false, UtilEnt.getName(damager), GetName()); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index 364b15edd..5b70ace78 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -1,6 +1,58 @@ package nautilus.game.arcade.game.games.moba.minion; +import mineplex.core.common.util.UtilEnt; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Zombie; + public class Minion { + private static final int HEALTH = 10; + + private final LivingEntity _entity; + + private int _targetIndex; + + public Minion(Location spawn, Class clazz, int targetIndex) + { + _targetIndex = targetIndex; + + LivingEntity entity = spawn.getWorld().spawn(spawn, clazz); + _entity = entity; + entity.setMaxHealth(HEALTH); + entity.setRemoveWhenFarAway(false); + + if (entity instanceof Zombie) + { + ((Zombie) entity).setBaby(true); + } + + UtilEnt.vegetate(entity); + UtilEnt.silence(entity, true); + + entity.setCustomNameVisible(true); + updateDisplay(); + } + + public void updateDisplay() + { + _entity.setCustomName(MobaUtil.getHealthBar(_entity, 10)); + } + + public LivingEntity getEntity() + { + return _entity; + } + + public void setTargetIndex(int index) + { + _targetIndex = index; + } + + public int getTargetIndex() + { + return _targetIndex; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 6a64db0d6..e796ef204 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -1,17 +1,139 @@ package nautilus.game.arcade.game.games.moba.minion; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GamePrepareCountdownCommence; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaLane; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.PigZombie; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; + public class MinionManager implements Listener { + private static final int MINION_SPAWN_DELAY_TICKS = 40; + private static final long MINION_SPAWN_TIME = TimeUnit.SECONDS.toMillis(30); + private final Moba _host; + private final Map> _path; + private final Set _waves; + + private long _lastWave; + private boolean _enabled; + public MinionManager(Moba host) { _host = host; + _path = new HashMap<>(3); + _waves = new HashSet<>(); } + @EventHandler + public void gameCountdownCommence(GamePrepareCountdownCommence event) + { + UtilServer.runSyncLater(() -> setEnabled(true), MINION_SPAWN_DELAY_TICKS); + } + + @EventHandler + public void spawnMinions(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || !_enabled || !_host.IsLive() || !UtilTime.elapsed(_lastWave, MINION_SPAWN_TIME)) + { + return; + } + + _lastWave = System.currentTimeMillis(); + + Set>> entries = _path.entrySet(); + + for (GameTeam team : _host.GetTeamList()) + { + boolean reverse = team.GetColor() == ChatColor.RED; + + for (Entry> entry : entries) + { + List path = new ArrayList<>(entry.getValue()); + + // If red team, reverse the pat + if (reverse) + { + Collections.reverse(path); + } + + MinionWave wave = new MinionWave(_host, this, team, path, reverse ? Zombie.class : PigZombie.class); + + _waves.add(wave); + } + } + } + + public void setEnabled(boolean enabled) + { + _enabled = enabled; + + if (enabled) + { + preparePaths(); + } + } + + public void unregisterWave(MinionWave wave) + { + _waves.remove(wave); + } + + /** + * This method fills the {@link #_path} map with the organised list of locations that the minions must follow.
+ * + * This says that the blue team is the start and the red team is the end. + */ + private void preparePaths() + { + for (MobaLane lane : MobaLane.values()) + { + // Jungle "Lane" + if (lane.getMinionPathKey() == null) + { + continue; + } + + // Step 1 - Find the starting location for the blue team + Location start = _host.WorldData.GetCustomLocs("SPAWN BLUE " + lane.toString()).get(0); + + // Step 2 - Fill a list with ordered locations, from blue to red + ArrayList path = new ArrayList<>(_host.WorldData.GetDataLocs(lane.getMinionPathKey())); + ArrayList organisedPath = new ArrayList<>(path.size()); + + while (organisedPath.size() != path.size()) + { + Location closest = UtilAlg.findClosest(start, path); + + if (closest == null) + { + // Rra rro Shaggy + continue; + } + + organisedPath.add(closest); + start = closest; + } + + // Step 3 - Put the ordered path inside the map + _path.put(lane, path); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java new file mode 100644 index 000000000..ceb36ae3c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -0,0 +1,184 @@ +package nautilus.game.arcade.game.games.moba.minion; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaEntityAIMethod; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +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.EntityCombustEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.ArrayList; +import java.util.List; + +public class MinionWave implements Listener +{ + + private static final int MAX_MINIONS_PER_WAVE = 6; + private static final MobaAIMethod AI_METHOD = new MobaEntityAIMethod(); + + private final Moba _host; + private final MinionManager _minionManager; + private final GameTeam _owner; + private final Class _clazz; + + private final List _path; + private final List _minions; + + public MinionWave(Moba host, MinionManager minionManager, GameTeam owner, List path, Class clazz) + { + _host = host; + _minionManager = minionManager; + _owner = owner; + _clazz = clazz; + _path = path; + _minions = new ArrayList<>(MAX_MINIONS_PER_WAVE); + + UtilServer.RegisterEvents(this); + + spawn(); + + UtilServer.runSyncTimer(new BukkitRunnable() + { + + @Override + public void run() + { + if (spawn()) + { + cancel(); + } + } + }, 0, 20); + } + + private boolean spawn() + { + _host.CreatureAllowOverride = true; + + Minion minion = new Minion(_path.get(0), _clazz, 1); + + minion.getEntity().setMetadata("team", new FixedMetadataValue(_host.getArcadeManager().getPlugin(), _owner.GetName())); + + _minions.add(minion); + + _host.CreatureAllowOverride = false; + + return _minions.size() >= MAX_MINIONS_PER_WAVE; + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Minion minion : _minions) + { + LivingEntity entity = minion.getEntity(); + + if (!AI_METHOD.updateMovement(entity, _path.get(minion.getTargetIndex()), 0.9F)) + { + int newTarget = minion.getTargetIndex() + 1; + + if (newTarget == _path.size()) + { + // TODO target wither, probably... + continue; + } + + minion.setTargetIndex(newTarget); + } + } + + _minions.removeIf(minion -> minion.getEntity() == null || minion.getEntity().isDead() || !minion.getEntity().isValid()); + + if (_minions.isEmpty()) + { + UtilServer.Unregister(this); + _minionManager.unregisterWave(this); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void damage(CustomDamageEvent event) + { + // Not a Minion + if (event.isCancelled() || !isMinion(event.GetDamageeEntity())) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + Player damager = event.GetDamagerPlayer(true); + GameTeam team = _host.GetTeam(damager); + + if (team != null && !_owner.equals(team)) + { + event.SetCancelled("Same Team Minion"); + } + else + { + Minion minion = getMinion(damagee); + + if (minion != null) + { + minion.updateDisplay(); + } + } + } + + @EventHandler + public void entityCombust(EntityCombustEvent event) + { + if (isMinion(event.getEntity())) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void entityDeath(EntityDeathEvent event) + { + if (!isMinion(event.getEntity())) + { + return; + } + + event.getDrops().clear(); + } + + private Minion getMinion(Entity entity) + { + for (Minion minion : _minions) + { + if (entity.equals(minion.getEntity())) + { + return minion; + } + } + + return null; + } + + private boolean isMinion(Entity entity) + { + return getMinion(entity) != null; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java index 4a2207562..94e9347e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java @@ -11,7 +11,6 @@ import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -60,17 +59,13 @@ public class PrepareInformation implements Listener return; } - Bukkit.broadcastMessage("updateMessages"); - for (MobaPlayer mobaPlayer : _host.getMobaData()) { - Bukkit.broadcastMessage(mobaPlayer.getPlayer().getName()); String[] description = mobaPlayer.getRole().getDescription(); // Description is too short if (description.length > _messageIndex + 2) { - Bukkit.broadcastMessage("Too short"); continue; } @@ -98,7 +93,7 @@ public class PrepareInformation implements Listener return; } - event.setCancelled(true); + event.setTo(from); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 407450cc2..542b8b354 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -405,9 +405,13 @@ public class MobaShop implements Listener } Player player = (Player) entity; - List items = _upgrades.get(player); + if (_upgrades == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 74624f3a6..826ae00e7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -93,7 +93,7 @@ public class Tower { double dist = UtilMath.offsetSquared(_location, _target.getLocation()); - if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target)) + if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target) || _target.isDead() || !_target.isValid()) { _target = null; setLaserTarget(null); @@ -167,7 +167,7 @@ public class Tower private void explode() { - _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_crystal.getLocation().add(0, 2, 0), 3), _location, false); + _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_crystal.getLocation().add(0, 4, 0), 4), _location, false); _location.getWorld().playSound(_location, Sound.EXPLODE, 2, 0.6F); UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); } @@ -209,6 +209,11 @@ public class Tower return _lane; } + public ArmorStand getStand() + { + return _stand; + } + public EnderCrystal getCrystal() { return _crystal; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index fc8ae6a06..92a646ba9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -5,6 +5,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; @@ -118,6 +119,18 @@ public class TowerManager implements Listener } } + @EventHandler + public void guardianDamage(CustomDamageEvent event) + { + for (Tower tower : _towers) + { + if (tower.getStand().equals(event.GetDamageeEntity())) + { + event.SetCancelled("Tower Guardian"); + } + } + } + @EventHandler(priority = EventPriority.LOWEST) public void crystalDamage(EntityDamageEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 81f0ab583..6aaec428b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -33,6 +33,12 @@ public class MobaUtil continue; } + // Check for team entities + if (entity.hasMetadata("team") && !entity.getMetadata("team").get(0).asString().equals(owner.GetName())) + { + continue; + } + // Make players more desirable if (entity instanceof Player) { From 9acfa361ade413af1dd872158755063f42097c9f Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 17 May 2017 19:21:19 +0100 Subject: [PATCH 037/283] Add mosted valued player to the map --- .../mineplex/gemhunters/beta/BetaModule.java | 5 ++-- .../gemhunters/economy/EconomyModule.java | 21 ++++++++++++++ .../gemhunters/map/ItemMapRenderer.java | 29 ++++++++++--------- .../progression/ProgressionModule.java | 17 +++++++++++ 4 files changed, 56 insertions(+), 16 deletions(-) create mode 100644 Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionModule.java diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/beta/BetaModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/beta/BetaModule.java index aa08bb811..03490754c 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/beta/BetaModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/beta/BetaModule.java @@ -19,7 +19,8 @@ public class BetaModule extends MiniPlugin "Thank you for playing Gem Hunters!", "Safezones are marked as green areas on your map!", "Players that have super valuable items show up on your map!", - "Tell us what you want added next by voting on our features Trello! https://trello.com/b/ia1kjwcx" + "Tell us what you want added next by voting on our features Trello! https://trello.com/b/ia1kjwcx", + "The highest value player is shown on the map as a red pointer." }; private int _lastIndex; @@ -30,7 +31,7 @@ public class BetaModule extends MiniPlugin } @EventHandler - public void annouce(UpdateEvent event) + public void announce(UpdateEvent event) { if (event.getType() != UpdateType.MIN_01) { diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java index 5ebb5e001..e9df24620 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java @@ -2,6 +2,7 @@ package mineplex.gemhunters.economy; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -29,6 +30,9 @@ public class EconomyModule extends MiniClientPlugin private final DonationManager _donation; + private Player _mostValuable; + private int _mostGems; + public EconomyModule() { super("Economy"); @@ -117,6 +121,23 @@ public class EconomyModule extends MiniClientPlugin return Get(player); } + @Override + protected void Set(Player player, Integer data) + { + super.Set(player, data); + + if (_mostValuable == null || _mostGems < data) + { + _mostValuable = player; + _mostGems = data; + } + } + + public Player getMostValuablePlayer() + { + return _mostValuable; + } + @Override protected Integer addPlayer(UUID uuid) { diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapRenderer.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapRenderer.java index 09d4aca84..d191cf23c 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapRenderer.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapRenderer.java @@ -1,29 +1,24 @@ package mineplex.gemhunters.map; -import java.awt.Color; -import java.util.Set; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.map.MapCanvas; -import org.bukkit.map.MapCursor; -import org.bukkit.map.MapCursorCollection; -import org.bukkit.map.MapPalette; -import org.bukkit.map.MapRenderer; -import org.bukkit.map.MapView; - import mineplex.core.Managers; import mineplex.core.common.util.UtilTime; import mineplex.core.party.Party; import mineplex.core.party.PartyManager; +import mineplex.gemhunters.economy.EconomyModule; import mineplex.gemhunters.loot.LootModule; import mineplex.gemhunters.safezone.SafezoneModule; import mineplex.gemhunters.supplydrop.SupplyDrop; import mineplex.gemhunters.supplydrop.SupplyDropModule; import mineplex.gemhunters.worldevent.WorldEvent; import mineplex.gemhunters.worldevent.WorldEventModule; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.map.*; + +import java.awt.*; +import java.util.Set; +import java.util.UUID; /** * All item map code was adapted from Clans.
@@ -35,6 +30,7 @@ public class ItemMapRenderer extends MapRenderer private static final int STANDARD_Y = 70; private final ItemMapModule _itemMap; + private final EconomyModule _economy; private final LootModule _loot; private final SafezoneModule _safezone; private final SupplyDropModule _supply; @@ -47,6 +43,7 @@ public class ItemMapRenderer extends MapRenderer super(true); _itemMap = Managers.require(ItemMapModule.class); + _economy = Managers.require(EconomyModule.class); _loot = Managers.require(LootModule.class); _safezone = Managers.require(SafezoneModule.class); _supply = Managers.require(SupplyDropModule.class); @@ -273,6 +270,10 @@ public class ItemMapRenderer extends MapRenderer { cursorDisplay = MapCursor.Type.GREEN_POINTER; } + else if (other.equals(_economy.getMostValuablePlayer())) + { + cursorDisplay = MapCursor.Type.RED_POINTER; + } if (cursorDisplay == null) { diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionModule.java new file mode 100644 index 000000000..f89dec275 --- /dev/null +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionModule.java @@ -0,0 +1,17 @@ +package mineplex.gemhunters.progression; + +import com.google.common.collect.ImmutableMap; +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; + +@ReflectivelyCreateMiniPlugin +public class ProgressionModule extends MiniPlugin +{ + + private final Map TITLES = ImmutableMap().builder().build(); + + public ProgressionModule() + { + super("Progression"); + } +} From 81a869c26465c9fcf1fb381a6c0e867ad1681e71 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 18 May 2017 00:28:08 +0100 Subject: [PATCH 038/283] Implement progression titles --- .../mineplex/gemhunters/chat/ChatModule.java | 10 +- .../progression/ProgressionModule.java | 28 +++++- .../progression/ProgressionTitle.java | 26 ++++++ .../scoreboard/GemHuntersScoreboard.java | 9 ++ .../scoreboard/ScoreboardModule.java | 92 ++++++++++++------- 5 files changed, 130 insertions(+), 35 deletions(-) create mode 100644 Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionTitle.java diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/chat/ChatModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/chat/ChatModule.java index 02e210ff5..f53b1eb44 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/chat/ChatModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/chat/ChatModule.java @@ -1,5 +1,7 @@ package mineplex.gemhunters.chat; +import mineplex.gemhunters.economy.EconomyModule; +import mineplex.gemhunters.progression.ProgressionModule; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -26,15 +28,19 @@ public class ChatModule extends MiniPlugin private final CoreClientManager _clientManager; private final Chat _chat; + private final EconomyModule _economy; private final PartyManager _party; - + private final ProgressionModule _progression; + private ChatModule() { super("Chat"); _clientManager = require(CoreClientManager.class); _chat = require(Chat.class); + _economy = require(EconomyModule.class); _party = require(PartyManager.class); + _progression = require(ProgressionModule.class); } @EventHandler(priority = EventPriority.LOWEST) @@ -90,7 +96,7 @@ public class ChatModule extends MiniPlugin } else { - message += C.cWhite; + message = _progression.getTitle(_economy.getGems(player)).getTitle() + " " + message + C.cWhite; } message += _chat.getFilteredMessage(player, event.getMessage()); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionModule.java index f89dec275..04d76ac24 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionModule.java @@ -1,17 +1,41 @@ package mineplex.gemhunters.progression; -import com.google.common.collect.ImmutableMap; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.common.util.C; + +import java.util.Arrays; +import java.util.List; @ReflectivelyCreateMiniPlugin public class ProgressionModule extends MiniPlugin { - private final Map TITLES = ImmutableMap().builder().build(); + private static final List TITLE_LIST = Arrays.asList( + new ProgressionTitle(C.cGray + "Bankrupt", 0), + new ProgressionTitle(C.cAqua + "Beggar", 100), + new ProgressionTitle(C.cGreen + "Poor", 250), + new ProgressionTitle(C.cGreen + "Middle Class", 500), + new ProgressionTitle(C.cGold + "Wealthy", 750), + new ProgressionTitle(C.cGold + "Loaded", 1000), + new ProgressionTitle(C.cRed + "Millionaire", 5000) + ); public ProgressionModule() { super("Progression"); } + + public ProgressionTitle getTitle(int gems) + { + for (ProgressionTitle title : TITLE_LIST) + { + if (title.getRequiredGems() >= gems) + { + return title; + } + } + + return TITLE_LIST.get(TITLE_LIST.size() - 1); + } } diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionTitle.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionTitle.java new file mode 100644 index 000000000..493959845 --- /dev/null +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionTitle.java @@ -0,0 +1,26 @@ +package mineplex.gemhunters.progression; + +import mineplex.core.common.util.C; + +public class ProgressionTitle +{ + + private String _title; + private int _requiredGems; + + public ProgressionTitle(String title, int requiredGems) + { + _title = title + C.Reset; + _requiredGems = requiredGems; + } + + public String getTitle() + { + return _title; + } + + public int getRequiredGems() + { + return _requiredGems; + } +} diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/scoreboard/GemHuntersScoreboard.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/scoreboard/GemHuntersScoreboard.java index 27e0eb487..ba3067ae3 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/scoreboard/GemHuntersScoreboard.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/scoreboard/GemHuntersScoreboard.java @@ -1,5 +1,7 @@ package mineplex.gemhunters.scoreboard; +import mineplex.gemhunters.progression.ProgressionModule; +import mineplex.gemhunters.progression.ProgressionTitle; import org.bukkit.entity.Player; import mineplex.core.Managers; @@ -17,6 +19,7 @@ public class GemHuntersScoreboard extends WritableMineplexScoreboard private final EconomyModule _economy; private final PlayerStatusModule _playerStatus; + private final ProgressionModule _progression; private final SupplyDropModule _supplyDrop; public GemHuntersScoreboard(Player player) @@ -25,6 +28,7 @@ public class GemHuntersScoreboard extends WritableMineplexScoreboard _economy = Managers.get(EconomyModule.class); _playerStatus = Managers.get(PlayerStatusModule.class); + _progression = Managers.get(ProgressionModule.class); _supplyDrop = Managers.get(SupplyDropModule.class); } @@ -60,4 +64,9 @@ public class GemHuntersScoreboard extends WritableMineplexScoreboard { return _economy.getGems(player); } + + public String getPrefix(Player perspective, Player subject) + { + return _progression.getTitle(_economy.getGems(subject)).getTitle() + " " + C.cYellow; + } } diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/scoreboard/ScoreboardModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/scoreboard/ScoreboardModule.java index 4b10288c0..e3677ca02 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/scoreboard/ScoreboardModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/scoreboard/ScoreboardModule.java @@ -70,17 +70,17 @@ public class ScoreboardModule extends MiniPlugin for (Player player : Bukkit.getOnlinePlayers()) { int gems = _economy.getGems(player); - + for (GemHuntersScoreboard scoreboard : _scoreboards.values()) { Objective objective = scoreboard.getHandle().getObjective(DisplaySlot.BELOW_NAME); Score score = objective.getScore(player.getName()); - + if (score.getScore() == gems) { continue; } - + score.setScore(gems); } } @@ -106,45 +106,75 @@ public class ScoreboardModule extends MiniPlugin _scoreboards.remove(player.getUniqueId()); } - public void createPlayerScoreboard(Player player) - { - if (!_scoreboards.containsKey(player.getUniqueId())) + @EventHandler + public void updateScoreboard(UpdateEvent event) + { + if (event.getType() != UpdateType.MIN_01) { - GemHuntersScoreboard scoreboard = new GemHuntersScoreboard(player); - Scoreboard handle = scoreboard.getHandle(); + return; + } + for (Player player : Bukkit.getOnlinePlayers()) + { + createPlayerScoreboard(player); + } + } + + public void createPlayerScoreboard(Player player) + { + GemHuntersScoreboard scoreboard; + + if (_scoreboards.containsKey(player.getUniqueId())) + { + scoreboard = _scoreboards.get(player.getUniqueId()); + } + else + { + scoreboard = new GemHuntersScoreboard(player); _scoreboards.put(player.getUniqueId(), scoreboard); // Gem Counter Undername - Objective gemCounter = handle.registerNewObjective("Gems", "Gems"); + Objective gemCounter = scoreboard.getHandle().registerNewObjective("Gems", "Gems"); gemCounter.setDisplaySlot(DisplaySlot.BELOW_NAME); + } - for (GemHuntersScoreboard other : _scoreboards.values()) + Scoreboard handle = scoreboard.getHandle(); + + for (GemHuntersScoreboard other : _scoreboards.values()) + { + // Set the other player's name tag for the player joining + Player otherPlayer = other.getOwner(); + Team team = handle.getTeam(otherPlayer.getName()); + + if (team == null) { - // Set the other player's name tag for the player joining - Player otherPlayer = other.getOwner(); - Team team = handle.registerNewTeam(otherPlayer.getName()); - - team.setPrefix(C.cYellow); - //team.setSuffix(scoreboard.getSuffix(player, otherPlayer)); - team.addEntry(otherPlayer.getName()); - - if (player.equals(otherPlayer)) - { - continue; - } - - // Set the player that is joining - Scoreboard otherHandle = other.getHandle(); - Team otherTeam = otherHandle.registerNewTeam(player.getName()); - - otherTeam.setPrefix(C.cYellow); - //otherTeam.setSuffix(other.getSuffix(other.getOwner(), player)); - otherTeam.addEntry(player.getName()); + team = handle.registerNewTeam(otherPlayer.getName()); } - player.setScoreboard(scoreboard.getHandle()); + team.setPrefix(scoreboard.getPrefix(player, otherPlayer)); + //team.setSuffix(scoreboard.getSuffix(player, otherPlayer)); + team.addEntry(otherPlayer.getName()); + + if (player.equals(otherPlayer)) + { + continue; + } + + // Set the player that is joining + Scoreboard otherHandle = other.getHandle(); + Team otherTeam = otherHandle.getTeam(player.getName()); + + if (otherTeam == null) + { + otherTeam = otherHandle.registerNewTeam(player.getName()); + } + + otherTeam.setPrefix(other.getPrefix(other.getOwner(), player)); + //otherTeam.setSuffix(other.getSuffix(other.getOwner(), player)); + otherTeam.addEntry(player.getName()); } + + player.setScoreboard(handle); } public void updateTitles() From 95b124e2f5cd65fbf6bf09ee35b255c2cc12cfc2 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 18 May 2017 00:30:07 +0100 Subject: [PATCH 039/283] Fix Millionair and Middle Class causing players to be disconnected --- .../src/mineplex/gemhunters/progression/ProgressionTitle.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionTitle.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionTitle.java index 493959845..0e512e225 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionTitle.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionTitle.java @@ -1,7 +1,5 @@ package mineplex.gemhunters.progression; -import mineplex.core.common.util.C; - public class ProgressionTitle { @@ -10,7 +8,7 @@ public class ProgressionTitle public ProgressionTitle(String title, int requiredGems) { - _title = title + C.Reset; + _title = title; _requiredGems = requiredGems; } From d51cc4f56e6298eafbf60962eb3308a45ab39688 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 18 May 2017 01:23:41 +0100 Subject: [PATCH 040/283] Swap buying and selling --- .../src/mineplex/gemhunters/progression/ProgressionModule.java | 2 +- .../src/mineplex/gemhunters/scoreboard/ScoreboardModule.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionModule.java index 04d76ac24..e99457acd 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/progression/ProgressionModule.java @@ -15,7 +15,7 @@ public class ProgressionModule extends MiniPlugin new ProgressionTitle(C.cGray + "Bankrupt", 0), new ProgressionTitle(C.cAqua + "Beggar", 100), new ProgressionTitle(C.cGreen + "Poor", 250), - new ProgressionTitle(C.cGreen + "Middle Class", 500), + new ProgressionTitle(C.cGreen + "MiddleClass", 500), new ProgressionTitle(C.cGold + "Wealthy", 750), new ProgressionTitle(C.cGold + "Loaded", 1000), new ProgressionTitle(C.cRed + "Millionaire", 5000) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/scoreboard/ScoreboardModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/scoreboard/ScoreboardModule.java index e3677ca02..6b6e90b27 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/scoreboard/ScoreboardModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/scoreboard/ScoreboardModule.java @@ -109,7 +109,7 @@ public class ScoreboardModule extends MiniPlugin @EventHandler public void updateScoreboard(UpdateEvent event) { - if (event.getType() != UpdateType.MIN_01) + if (event.getType() != UpdateType.SEC_20) { return; } From c042af4a5ac2b0a3260a6ab55017f49ecb9b625c Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 18 May 2017 01:52:26 +0100 Subject: [PATCH 041/283] Buying -> Buy --- .../src/mineplex/gemhunters/shop/ShopModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/shop/ShopModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/shop/ShopModule.java index 2f8725d8d..f647b4e18 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/shop/ShopModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/shop/ShopModule.java @@ -199,7 +199,7 @@ public class ShopModule extends MiniPlugin String name = NAMES[UtilMath.r(NAMES.length)]; - name = (properties.isSelling() ? C.cGold + "Buying" : C.cGreen + "Selling") + C.cGray + " - " + C.cWhite + name; + name = (properties.isSelling() ? C.cGold + "Buy" : C.cGreen + "Sell") + C.cGray + " - " + C.cWhite + name; //DebugModule.getInstance().d("Trader at " + UtilWorld.locToStrClean(randomLocation) + " with key=" + key + " and index=" + index + " and max=" + spawned + "/" + max); if (properties.isSelling()) From 176253faec656b24d27334d2fde2e31110fd8c76 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 21 May 2017 17:33:33 +0100 Subject: [PATCH 042/283] Remove minion command --- .../game/games/moba/minion/MinionManager.java | 18 ++++++++++++++++++ .../game/games/moba/minion/MinionWave.java | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index e796ef204..450482bae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -1,17 +1,21 @@ package nautilus.game.arcade.game.games.moba.minion; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GamePrepareCountdownCommence; +import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaLane; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.PigZombie; +import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -39,6 +43,20 @@ public class MinionManager implements Listener _host = host; _path = new HashMap<>(3); _waves = new HashSet<>(); + + host.registerDebugCommand(new DebugCommand("removeminions", Rank.DEVELOPER) + { + @Override + public void Execute(Player caller, String[] args) + { + for (MinionWave wave : _waves) + { + wave.cleanup(); + } + + caller.sendMessage(F.main("Debug", "Removed all minions.")); + } + }); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index ceb36ae3c..b3cf29a53 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -163,6 +163,14 @@ public class MinionWave implements Listener event.getDrops().clear(); } + public void cleanup() + { + for (Minion minion : _minions) + { + minion.getEntity().remove(); + } + } + private Minion getMinion(Entity entity) { for (Minion minion : _minions) From 4ed3135cdf38f85a091929c639887ca892b8afe8 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 22 May 2017 20:53:22 +0100 Subject: [PATCH 043/283] Implement improved targetting system --- .../mineplex/core/common/util/UtilPlayer.java | 2 +- .../game/arcade/game/games/moba/MobaLane.java | 60 ----------- .../game/arcade/game/games/moba/MobaRole.java | 17 +--- .../arcade/game/games/moba/ai/MobaAI.java | 8 +- .../game/games/moba/minion/MinionManager.java | 80 ++++++--------- .../game/games/moba/minion/MinionWave.java | 3 +- .../games/moba/prepare/PrepareManager.java | 22 +---- .../games/moba/prepare/PrepareSelection.java | 15 ++- .../arcade/game/games/moba/shop/MobaShop.java | 3 +- .../games/moba/structure/tower/Tower.java | 10 +- .../moba/structure/tower/TowerManager.java | 14 +-- .../game/games/moba/util/MobaConstants.java | 7 ++ .../arcade/game/games/moba/util/MobaUtil.java | 99 ++++++++++++++++++- 13 files changed, 168 insertions(+), 172 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 19b7b6059..6294181ab 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -654,7 +654,7 @@ public class UtilPlayer continue; } - double dist = UtilMath.offset(cur.getLocation(), loc); + double dist = UtilMath.offsetSquared(cur.getLocation(), loc); if (best == null || dist < bestDist) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java deleted file mode 100644 index 19857dd19..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java +++ /dev/null @@ -1,60 +0,0 @@ -package nautilus.game.arcade.game.games.moba; - -import nautilus.game.arcade.game.GameTeam; -import org.bukkit.ChatColor; - -public enum MobaLane -{ - - A("ORANGE"), - B("YELLOW"), - C("LIME"), - D(null); - - private final String _minionPath; - - MobaLane(String minionPath) - { - _minionPath = minionPath; - } - - public String getMinionPathKey() - { - return _minionPath; - } - - public String getName(GameTeam team) - { - if (this == D) - { - return "Jungle"; - } - else if (this == B) - { - return "Middle"; - } - else if (this == A) - { - if (team.GetColor() == ChatColor.AQUA) - { - return "Left"; - } - else - { - return "Right"; - } - } - else - { - if (team.GetColor() == ChatColor.AQUA) - { - return "Right"; - } - else - { - return "Left"; - } - } - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index a0c431980..70baf4c97 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -13,40 +13,38 @@ public enum MobaRole "You are playing", "the " + C.cAqua + "Assassin" + C.cWhite + " role this game", - }, MobaLane.D, Color.BLUE, ChatColor.AQUA), + }, Color.BLUE, ChatColor.AQUA), HUNTER("Hunter", new String[] { "You are playing", "the " + C.cGreen + "Hunter" + C.cWhite + " role this game", - }, MobaLane.A, Color.LIME, ChatColor.GREEN), + }, Color.LIME, ChatColor.GREEN), MAGE("Mage", new String[] { "You are playing", "the " + C.cRed + "Mage" + C.cWhite + " role this game", - }, MobaLane.B, Color.RED, ChatColor.RED), + }, Color.RED, ChatColor.RED), WARRIOR("Warrior", new String[] { "You are playing", "the " + C.cGold + "Warrior" + C.cWhite + " role this game", - }, MobaLane.C, Color.YELLOW, ChatColor.GOLD), + }, Color.YELLOW, ChatColor.GOLD), ; private final String _name; private final String[] _description; - private final MobaLane _lane; private final Color _color; private final ChatColor _chatColor; - MobaRole(String name, String[] description, MobaLane lane, Color color, ChatColor chatColor) + MobaRole(String name, String[] description, Color color, ChatColor chatColor) { _name = name; _description = description; - _lane = lane; _color = color; _chatColor = chatColor; } @@ -61,11 +59,6 @@ public enum MobaRole return _description; } - public MobaLane getLane() - { - return _lane; - } - public Color getColor() { return _color; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 2a7588bf9..a410b88b7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -6,6 +6,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -43,7 +44,7 @@ public class MobaAI if (_target == null) { - _target = MobaUtil.getBestEntityTarget(_host, _owner, _entity, _home, TARGET_RANGE); + _target = MobaUtil.getBestEntityTarget(_host, _owner, _entity, _home, _host.WorldData.GetDataLocs(getBoundaryKey())); if (_target == null) { @@ -82,4 +83,9 @@ public class MobaAI { return _target; } + + private String getBoundaryKey() + { + return _owner.GetColor() == ChatColor.RED ? "ORANGE" : "LIGHT_BLUE"; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 450482bae..525b2946d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -11,7 +11,7 @@ import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.MobaLane; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.PigZombie; @@ -21,7 +21,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import java.util.*; -import java.util.Map.Entry; import java.util.concurrent.TimeUnit; public class MinionManager implements Listener @@ -32,7 +31,7 @@ public class MinionManager implements Listener private final Moba _host; - private final Map> _path; + private List _path; private final Set _waves; private long _lastWave; @@ -41,7 +40,6 @@ public class MinionManager implements Listener public MinionManager(Moba host) { _host = host; - _path = new HashMap<>(3); _waves = new HashSet<>(); host.registerDebugCommand(new DebugCommand("removeminions", Rank.DEVELOPER) @@ -75,26 +73,20 @@ public class MinionManager implements Listener _lastWave = System.currentTimeMillis(); - Set>> entries = _path.entrySet(); - for (GameTeam team : _host.GetTeamList()) { + List path = new ArrayList<>(_path); boolean reverse = team.GetColor() == ChatColor.RED; - for (Entry> entry : entries) + // If red team, reverse the pat + if (reverse) { - List path = new ArrayList<>(entry.getValue()); - - // If red team, reverse the pat - if (reverse) - { - Collections.reverse(path); - } - - MinionWave wave = new MinionWave(_host, this, team, path, reverse ? Zombie.class : PigZombie.class); - - _waves.add(wave); + Collections.reverse(path); } + + MinionWave wave = new MinionWave(_host, this, team, path, reverse ? Zombie.class : PigZombie.class); + + _waves.add(wave); } } @@ -104,7 +96,7 @@ public class MinionManager implements Listener if (enabled) { - preparePaths(); + preparePath(); } } @@ -114,44 +106,34 @@ public class MinionManager implements Listener } /** - * This method fills the {@link #_path} map with the organised list of locations that the minions must follow.
- * + * This method fills the {@link #_path} with the organised list of locations that the minions must follow.
+ *

* This says that the blue team is the start and the red team is the end. */ - private void preparePaths() + private void preparePath() { - for (MobaLane lane : MobaLane.values()) + // Step 1 - Find the starting location for the blue team + Location start = _host.WorldData.GetDataLocs(MobaConstants.MINION_PATH_START).get(0); + + // Step 2 - Fill a list with ordered locations, from blue to red + ArrayList path = new ArrayList<>(_host.WorldData.GetDataLocs(MobaConstants.MINION_PATH)); + ArrayList organisedPath = new ArrayList<>(path.size()); + + while (organisedPath.size() != path.size()) { - // Jungle "Lane" - if (lane.getMinionPathKey() == null) + Location closest = UtilAlg.findClosest(start, path); + + if (closest == null) { + // Rra rro Shaggy continue; } - // Step 1 - Find the starting location for the blue team - Location start = _host.WorldData.GetCustomLocs("SPAWN BLUE " + lane.toString()).get(0); - - // Step 2 - Fill a list with ordered locations, from blue to red - ArrayList path = new ArrayList<>(_host.WorldData.GetDataLocs(lane.getMinionPathKey())); - ArrayList organisedPath = new ArrayList<>(path.size()); - - while (organisedPath.size() != path.size()) - { - Location closest = UtilAlg.findClosest(start, path); - - if (closest == null) - { - // Rra rro Shaggy - continue; - } - - organisedPath.add(closest); - start = closest; - } - - // Step 3 - Put the ordered path inside the map - _path.put(lane, path); + organisedPath.add(closest); + start = closest; } - } + // Step 3 - Put the ordered path inside the map + _path = path; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index b3cf29a53..bc533eeed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -8,6 +8,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaEntityAIMethod; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Entity; @@ -71,7 +72,7 @@ public class MinionWave implements Listener Minion minion = new Minion(_path.get(0), _clazz, 1); - minion.getEntity().setMetadata("team", new FixedMetadataValue(_host.getArcadeManager().getPlugin(), _owner.GetName())); + minion.getEntity().setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), _owner.GetName())); _minions.add(minion); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java index bcc6e7ca6..2dd066b55 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java @@ -9,7 +9,6 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.MobaLane; import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; @@ -90,26 +89,9 @@ public class PrepareManager implements Listener _host.SetKit(player, heroKit, true); } - for (MobaPlayer mobaPlayer : _host.getMobaData()) + for (GameTeam team : _host.GetTeamList()) { - // Teleport players to their respective spawns - Player player = mobaPlayer.getPlayer(); - GameTeam team = _host.GetTeam(player); - MobaLane lane = mobaPlayer.getRole().getLane(); - Location toTeleport = _host.WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + lane.toString()).get(0); - - // Face the location toward the first tower of that lane - Tower tower = _host.getTowerManager().getFirsrtTower(lane); - if (tower != null) - { - toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), tower.getLocation()))); - } - else - { - toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), _host.GetSpectatorLocation()))); - } - - player.teleport(toTeleport); + team.SpawnTeleport(); } _host.SetStateTime(System.currentTimeMillis()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index c4c3bccba..8cd08ee95 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -17,7 +17,10 @@ import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; -import org.bukkit.*; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -28,6 +31,7 @@ import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicInteger; public class PrepareSelection implements Listener, IPacketHandler @@ -68,8 +72,7 @@ public class PrepareSelection implements Listener, IPacketHandler private void spawnRoleUI(GameTeam team, String dataKey) { - AtomicInteger i = new AtomicInteger(); - List spawns = _host.WorldData.GetDataLocs(dataKey); + Map spawns = _host.getLocationStartsWith("KIT " + dataKey); Location average = UtilAlg.getAverageLocation(team.GetSpawns()); Player[] players = team.GetPlayers(true).toArray(new Player[0]); @@ -82,11 +85,13 @@ public class PrepareSelection implements Listener, IPacketHandler displayRoleInformation(player); } - for (Location location : spawns) + for (Entry entry : spawns.entrySet()) { + Location location = entry.getValue(); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); - MobaRole role = MobaRole.values()[i.getAndIncrement()]; + MobaRole role = MobaRole.valueOf(entry.getKey().split(" ")[2]); ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players); stand.setCustomNameVisible(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 542b8b354..6350670f0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -20,6 +20,7 @@ import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop; import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop; import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Entity; @@ -68,7 +69,7 @@ public class MobaShop implements Listener return; } - List locations = _host.WorldData.GetDataLocs("CYAN"); + List locations = _host.WorldData.GetDataLocs(MobaConstants.SHOP); _host.CreatureAllowOverride = true; for (Location location : locations) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 826ae00e7..83cddf9d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -6,7 +6,6 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseGuardian; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.MobaLane; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Material; @@ -29,7 +28,6 @@ public class Tower private final Location _location; private final GameTeam _team; - private final MobaLane _lane; private double _health; private int _maxHealth; @@ -45,12 +43,11 @@ public class Tower private LivingEntity _target; - public Tower(Moba host, Location location, GameTeam team, MobaLane lane, int health, boolean firstTower) + public Tower(Moba host, Location location, GameTeam team, int health, boolean firstTower) { _host = host; _location = location; _team = team; - _lane = lane; _health = health; _maxHealth = health; _firstTower = firstTower; @@ -204,11 +201,6 @@ public class Tower return _team; } - public MobaLane getLane() - { - return _lane; - } - public ArmorStand getStand() { return _stand; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 92a646ba9..98c72e1ab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -10,7 +10,6 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.MobaLane; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.EnderCrystal; @@ -68,13 +67,12 @@ public class TowerManager implements Listener } String team = components[1]; - MobaLane lane = MobaLane.valueOf(components[2]); boolean firstTower; try { - firstTower = components[3].equalsIgnoreCase("1"); + firstTower = components[2].equalsIgnoreCase("1"); } catch (NumberFormatException e) { @@ -89,7 +87,7 @@ public class TowerManager implements Listener continue; } - _towers.add(new Tower(_host, location, gameTeam, lane, health, firstTower)); + _towers.add(new Tower(_host, location, gameTeam, health, firstTower)); } _host.CreatureAllowOverride = true; @@ -202,11 +200,11 @@ public class TowerManager implements Listener } } - public Tower getFirsrtTower(MobaLane lane) + public Tower getFirstTower(GameTeam team) { for (Tower tower : _towers) { - if (tower.isFirstTower() && tower.getLane() == lane) + if (tower.isFirstTower() && tower.getOwner().equals(team)) { return tower; } @@ -251,8 +249,6 @@ public class TowerManager implements Listener return false; } - MobaLane lane = tower.getLane(); - // First tower, all it if (tower.isFirstTower()) { @@ -267,7 +263,7 @@ public class TowerManager implements Listener // Is first tower // Is same lane // Is dead - if (!team.equals(other.getOwner()) && other.isFirstTower() && lane == other.getLane() && other.isDead()) + if (!team.equals(other.getOwner()) && other.isFirstTower() && other.isDead()) { return true; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java index 01ef28c06..8c0dfb62e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java @@ -6,5 +6,12 @@ public class MobaConstants // String constants public static final String BASIC_ATTACK = "Basic Attack"; public static final String AMMO = "Ammo"; + public static final String TEAM_METADATA = "team"; + + // Location Constants + public static final String MINION_PATH_START = "WHITE"; + public static final String MINION_PATH = "BROWN"; + public static final String SHOP = "LIGHT_GRAY"; + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 6aaec428b..7d9e73918 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -1,14 +1,18 @@ package nautilus.game.arcade.game.games.moba.util; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.*; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; +import java.util.HashSet; +import java.util.List; import java.util.Map.Entry; +import java.util.Set; public class MobaUtil { @@ -34,7 +38,7 @@ public class MobaUtil } // Check for team entities - if (entity.hasMetadata("team") && !entity.getMetadata("team").get(0).asString().equals(owner.GetName())) + if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && !entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) { continue; } @@ -42,7 +46,7 @@ public class MobaUtil // Make players more desirable if (entity instanceof Player) { - if (owner.equals(host.GetTeam((Player) entity))) + if (owner.equals(host.GetTeam((Player) entity)) || UtilPlayer.isSpectator(entity)) { continue; } @@ -63,6 +67,93 @@ public class MobaUtil return highest; } + public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location center, List boundaries) + { + Set ignored = new HashSet<>(); + + if (owner != null) + { + // Add teammates to ignored players + ignored.addAll(owner.GetPlayers(true)); + } + + // Add all spectators to ignored players + for (Player player : Bukkit.getOnlinePlayers()) + { + if (UtilPlayer.isSpectator(player)) + { + ignored.add(player); + } + } + + // For each boundary + for (Location boundary : boundaries) + { + Location boundaryCloned = boundary.clone(); + // Get direction from center to boundary + Vector direction = UtilAlg.getTrajectory(center, boundary); + // Store the checked distance + double checkedDist = 0; + // Get the distance squared from the center to the boundary + double maxDist = UtilMath.offsetSquared(center, boundary); + + // Keep advancing the distance until it hits the boundary + while (checkedDist < maxDist) + { + // Advance the location + boundaryCloned.add(direction); + + LivingEntity highest = null; + double bestDist = 0; + + // Check for nearby entities + for (Entry entry : UtilEnt.getInRadius(boundaryCloned, 2).entrySet()) + { + LivingEntity entity = entry.getKey(); + double dist = entry.getValue(); + + if (source.equals(entity)) + { + continue; + } + + if (owner != null) + { + // Check for team entities + if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && !entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) + { + continue; + } + + // Check for same team players + if (entity instanceof Player) + { + if (owner.equals(host.GetTeam((Player) entity)) || UtilPlayer.isSpectator(entity)) + { + continue; + } + } + } + + if (bestDist < dist) + { + highest = entity; + bestDist = dist; + } + } + + if (highest != null) + { + return highest; + } + + checkedDist++; + } + } + + return null; + } + public static String getHealthBar(LivingEntity entity, int bars) { String out = ""; From 78b10e3cb8dc7d27804f2bd6659867b96c039ba1 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 23 May 2017 20:37:31 +0100 Subject: [PATCH 044/283] Fix the majority of bugs for the 1 lane game --- .../game/arcade/game/games/moba/Moba.java | 6 +++ .../arcade/game/games/moba/ai/MobaAI.java | 6 +-- .../moba/ai/goal/MobaEntityAIMethod.java | 21 -------- .../arcade/game/games/moba/boss/MobaBoss.java | 2 +- .../games/moba/boss/wither/WitherBoss.java | 4 +- .../arcade/game/games/moba/minion/Minion.java | 18 ++++++- .../game/games/moba/minion/MinionWave.java | 49 ++++++++++++++++--- .../games/moba/prepare/PrepareSelection.java | 26 ++++------ .../arcade/game/games/moba/shop/MobaShop.java | 31 ++++++------ .../moba/structure/tower/TowerManager.java | 7 ++- .../game/games/moba/util/MobaConstants.java | 2 +- .../arcade/game/games/moba/util/MobaUtil.java | 26 +++++----- 12 files changed, 117 insertions(+), 81 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 9131a3e7e..3e937efba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -217,6 +217,12 @@ public class Moba extends TeamGame { // Register all "Managers" _listeners.forEach(UtilServer::RegisterEvents); + + // Make all spawns face the center of the map + for (List locations : WorldData.SpawnLocs.values()) + { + locations.forEach(location -> location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, GetSpectatorLocation())))); + } } private void writePrepare(Player player, GameScoreboard scoreboard) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index a410b88b7..e8f3d0a8a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -13,8 +13,8 @@ import org.bukkit.entity.LivingEntity; public class MobaAI { - public static final int TARGET_RANGE = 11; - public static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; + private static final int TARGET_RANGE = 11; + private static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; private final Moba _host; private final GameTeam _owner; @@ -54,7 +54,7 @@ public class MobaAI } else { - double dist = UtilMath.offsetSquared(_home, _target.getLocation()); + double dist = UtilMath.offsetSquared(_entity, _target); if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java deleted file mode 100644 index 44c921af7..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java +++ /dev/null @@ -1,21 +0,0 @@ -package nautilus.game.arcade.game.games.moba.ai.goal; - -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import org.bukkit.Location; -import org.bukkit.entity.LivingEntity; - -public class MobaEntityAIMethod implements MobaAIMethod -{ - - @Override - public boolean updateMovement(LivingEntity entity, Location goal, float speed) - { - if (UtilMath.offsetSquared(entity.getLocation(), goal) < 4) - { - return false; - } - - return UtilEnt.CreatureMoveFast(entity, goal, speed); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index b995f0cd8..35ec8f8e4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -48,7 +48,7 @@ public abstract class MobaBoss implements Listener @EventHandler public void updateMovement(UpdateEvent event) { - if (event.getType() != UpdateType.TICK || _entity == null || !_host.IsLive()) + if (event.getType() != UpdateType.FASTEST || _entity == null || !_host.IsLive()) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index ca472d25f..e3f1ed077 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -13,6 +13,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; import nautilus.game.arcade.game.games.moba.boss.MobaBoss; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; @@ -33,6 +34,7 @@ public class WitherBoss extends MobaBoss private static final int INITIAL_HEALTH = 1750; private static final int FIRST_TOWER_HEALTH_REDUCTION = 100; private static final int SECOND_TOWER_HEALTH_REDUCTION = 250; + private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private GameTeam _team; private MobaAI _ai; @@ -69,7 +71,7 @@ public class WitherBoss extends MobaBoss { if (_ai == null) { - _ai = new MobaAI(_host, _team, _entity, _location, new MobaDirectAIMethod()); + _ai = new MobaAI(_host, _team, _entity, _location, AI_METHOD); } return _ai; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index 5b70ace78..b13e7d433 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -13,11 +13,12 @@ public class Minion private final LivingEntity _entity; + private Location _target; private int _targetIndex; - public Minion(Location spawn, Class clazz, int targetIndex) + public Minion(Location spawn, Class clazz) { - _targetIndex = targetIndex; + _target = spawn; LivingEntity entity = spawn.getWorld().spawn(spawn, clazz); _entity = entity; @@ -46,6 +47,19 @@ public class Minion return _entity; } + public void setTarget(Location location) + { + // Keep the Y constant + location.setY(_target.getY()); + + _target = location; + } + + public Location getTarget() + { + return _target; + } + public void setTargetIndex(int index) { _targetIndex = index; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index bc533eeed..3f61d7b9a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.minion; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -7,9 +8,9 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; -import nautilus.game.arcade.game.games.moba.ai.goal.MobaEntityAIMethod; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.util.MobaConstants; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -29,7 +30,7 @@ public class MinionWave implements Listener { private static final int MAX_MINIONS_PER_WAVE = 6; - private static final MobaAIMethod AI_METHOD = new MobaEntityAIMethod(); + private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private final Moba _host; private final MinionManager _minionManager; @@ -70,7 +71,7 @@ public class MinionWave implements Listener { _host.CreatureAllowOverride = true; - Minion minion = new Minion(_path.get(0), _clazz, 1); + Minion minion = new Minion(_path.get(0), _clazz); minion.getEntity().setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), _owner.GetName())); @@ -93,7 +94,11 @@ public class MinionWave implements Listener { LivingEntity entity = minion.getEntity(); - if (!AI_METHOD.updateMovement(entity, _path.get(minion.getTargetIndex()), 0.9F)) + if (targetTower(minion)) + { + + } + else if (!AI_METHOD.updateMovement(entity, minion.getTarget(), 0.1F)) { int newTarget = minion.getTargetIndex() + 1; @@ -116,6 +121,38 @@ public class MinionWave implements Listener } } + private boolean targetTower(Minion minion) + { + for (Tower tower : _host.getTowerManager().getTowers()) + { + if (tower.isDead() || tower.getOwner().equals(_owner)) + { + continue; + } + + double distSquared = UtilMath.offsetSquared(minion.getEntity(), tower.getCrystal()); + + if (distSquared < 3) + { + return true; + } + else if (distSquared > Tower.TARGET_RANGE_SQUARED) + { + continue; + } + + minion.setTarget(tower.getCrystal().getLocation()); + return true; + } + + return false; + } + + private void targetWither(Minion minion) + { + + } + @EventHandler(priority = EventPriority.HIGHEST) public void damage(CustomDamageEvent event) { @@ -129,7 +166,7 @@ public class MinionWave implements Listener Player damager = event.GetDamagerPlayer(true); GameTeam team = _host.GetTeam(damager); - if (team != null && !_owner.equals(team)) + if (team != null && _owner.equals(team)) { event.SetCancelled("Same Team Minion"); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index 8cd08ee95..0d5f125c0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -59,20 +59,13 @@ public class PrepareSelection implements Listener, IPacketHandler for (GameTeam team : _host.GetTeamList()) { - if (team.GetColor() == ChatColor.RED) - { - spawnRoleUI(team, "PINK"); - } - else - { - spawnRoleUI(team, "PURPLE"); - } + spawnRoleUI(team); } } - private void spawnRoleUI(GameTeam team, String dataKey) + private void spawnRoleUI(GameTeam team) { - Map spawns = _host.getLocationStartsWith("KIT " + dataKey); + Map spawns = _host.getLocationStartsWith("KIT " + team.GetName().toUpperCase()); Location average = UtilAlg.getAverageLocation(team.GetSpawns()); Player[] players = team.GetPlayers(true).toArray(new Player[0]); @@ -108,11 +101,11 @@ public class PrepareSelection implements Listener, IPacketHandler }, _host.GetPlayers(true).size() * _host.TickPerTeleport + 10); } - private void spawnKitUI(Player player, String dataKey) + private void spawnKitUI(Player player) { AtomicInteger i = new AtomicInteger(); GameTeam team = _host.GetTeam(player); - List spawns = _host.WorldData.GetDataLocs(dataKey); + Map spawns = _host.getLocationStartsWith("KIT " + team.GetName().toUpperCase()); Location average = UtilAlg.getAverageLocation(team.GetSpawns()); MobaPlayer mobaPlayer = _host.getMobaData(player); @@ -123,7 +116,7 @@ public class PrepareSelection implements Listener, IPacketHandler UtilServer.runSyncLater(() -> { - for (Location location : spawns) + for (Location location : spawns.values()) { location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); @@ -167,8 +160,7 @@ public class PrepareSelection implements Listener, IPacketHandler private void removePodiums() { - _host.WorldData.GetDataLocs("PINK").forEach(location -> location.getBlock().setType(Material.AIR)); - _host.WorldData.GetDataLocs("PURPLE").forEach(location -> location.getBlock().setType(Material.AIR)); + _host.getLocationStartsWith("KIT").forEach((key, location) -> location.getBlock().setType(Material.AIR)); } // Listen for those packety clicks @@ -211,11 +203,11 @@ public class PrepareSelection implements Listener, IPacketHandler if (team.GetColor() == ChatColor.RED) { - spawnKitUI(player, "PINK"); + spawnKitUI(player); } else { - spawnKitUI(player, "PURPLE"); + spawnKitUI(player); } displayKitInformation(player, role); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 6350670f0..c244dba1c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -188,24 +188,25 @@ 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 infinite speed - player.setWalkSpeed(0.2F); - player.setMaxHealth(20); - - 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); + + // 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, + // Prevents infinite speed + player.setWalkSpeed(0.2F); + player.setMaxHealth(20); + + PlayerGameRespawnEvent fakeEvent = new PlayerGameRespawnEvent(null, player); + + for (MobaItem ownedItem : owned) + { + if (ownedItem.getEffects() != null) + { + ownedItem.getEffects().forEach(effect -> effect.onRespawn(fakeEvent)); + } + } + _host.GetKit(player).ApplyKit(player); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 98c72e1ab..fb5a02f31 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -61,7 +61,7 @@ public class TowerManager implements Listener Location location = entry.getValue(); String[] components = key.split(" "); - if (components.length < 4) + if (components.length < 3) { continue; } @@ -271,4 +271,9 @@ public class TowerManager implements Listener return false; } + + public List getTowers() + { + return _towers; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java index 8c0dfb62e..3dab8cbf2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java @@ -11,7 +11,7 @@ public class MobaConstants // Location Constants public static final String MINION_PATH_START = "WHITE"; public static final String MINION_PATH = "BROWN"; - public static final String SHOP = "LIGHT_GRAY"; + public static final String SHOP = "SILVER"; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 7d9e73918..94478a893 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -1,6 +1,10 @@ package nautilus.game.arcade.game.games.moba.util; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import org.bukkit.Bukkit; @@ -17,11 +21,6 @@ import java.util.Set; public class MobaUtil { - public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange) - { - return getBestEntityTarget(host, owner, source, location, targetRange, true); - } - public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayersMore) { LivingEntity highest = null; @@ -38,7 +37,7 @@ public class MobaUtil } // Check for team entities - if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && !entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) + if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) { continue; } @@ -89,7 +88,7 @@ public class MobaUtil // For each boundary for (Location boundary : boundaries) { - Location boundaryCloned = boundary.clone(); + Location checking = center.clone(); // Get direction from center to boundary Vector direction = UtilAlg.getTrajectory(center, boundary); // Store the checked distance @@ -98,21 +97,21 @@ public class MobaUtil double maxDist = UtilMath.offsetSquared(center, boundary); // Keep advancing the distance until it hits the boundary - while (checkedDist < maxDist) + while (checkedDist * checkedDist < maxDist) { // Advance the location - boundaryCloned.add(direction); + checking.add(direction); LivingEntity highest = null; double bestDist = 0; // Check for nearby entities - for (Entry entry : UtilEnt.getInRadius(boundaryCloned, 2).entrySet()) + for (Entry entry : UtilEnt.getInRadius(checking, 2).entrySet()) { LivingEntity entity = entry.getKey(); double dist = entry.getValue(); - if (source.equals(entity)) + if (source.equals(entity) || ignored.contains(entity)) { continue; } @@ -120,7 +119,7 @@ public class MobaUtil if (owner != null) { // Check for team entities - if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && !entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) + if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) { continue; } @@ -144,6 +143,7 @@ public class MobaUtil if (highest != null) { + Bukkit.broadcastMessage("Found " + highest.getCustomName()); return highest; } From 6f48d0ee43b8f58adf18bccc3adb2a72fc8fa53d Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 23 May 2017 22:57:13 +0100 Subject: [PATCH 045/283] Improve the path finding ai --- .../game/arcade/game/games/moba/Moba.java | 5 ++ .../moba/ai/goal/MobaDirectAIMethod.java | 5 ++ .../game/games/moba/boss/BossManager.java | 11 +++ .../arcade/game/games/moba/boss/MobaBoss.java | 5 ++ .../games/moba/boss/wither/WitherBoss.java | 5 ++ .../game/games/moba/minion/MinionWave.java | 80 ++++++++++++++++--- 6 files changed, 100 insertions(+), 11 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 3e937efba..d0ada1134 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -567,4 +567,9 @@ public class Moba extends TeamGame { return _capturePoint; } + + public BossManager getBossManager() + { + return _boss; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index b8b95c59a..21e3f6ad3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -16,6 +16,11 @@ public class MobaDirectAIMethod implements MobaAIMethod { Location entityLocation = entity.getLocation(); + if (UtilMath.offsetSquared(entity.getLocation(), goal) < 6) + { + return false; + } + float entityYaw = entityLocation.getYaw(); // Speed is blocks per second diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java index 73ba34407..a7b1be645 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -9,7 +9,9 @@ import nautilus.game.arcade.world.WorldData; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; public class BossManager implements Listener @@ -69,4 +71,13 @@ public class BossManager implements Listener { return _teamBosses.get(team); } + + public List getBosses() + { + List bosses = new ArrayList<>(); + + bosses.addAll(_teamBosses.values()); + + return bosses; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index 35ec8f8e4..a429a6f63 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -87,4 +87,9 @@ public abstract class MobaBoss implements Listener { return _entity; } + + public boolean isDead() + { + return _entity == null || _entity.isDead() || !_entity.isValid(); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index e3f1ed077..4d7cfe3f2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -173,4 +173,9 @@ public class WitherBoss extends MobaBoss { _disguise.setName(MobaUtil.getHealthBar(_entity, 40)); } + + public GameTeam getTeam() + { + return _team; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 3f61d7b9a..130c279d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -9,8 +9,11 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; +import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -29,7 +32,7 @@ import java.util.List; public class MinionWave implements Listener { - private static final int MAX_MINIONS_PER_WAVE = 6; + private static final int MAX_MINIONS_PER_WAVE = 1; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private final Moba _host; @@ -93,22 +96,44 @@ public class MinionWave implements Listener for (Minion minion : _minions) { LivingEntity entity = minion.getEntity(); + Location target = null; + Location towerTarget = targetTower(minion); + Location witherTarget = targetWither(minion); - if (targetTower(minion)) + if (towerTarget != null) { - + target = towerTarget; } - else if (!AI_METHOD.updateMovement(entity, minion.getTarget(), 0.1F)) + else if (witherTarget != null) + { + target = witherTarget; + } + + if (target != null) + { + minion.setTarget(target); + + // Too close + if (UtilMath.offsetSquared(entity.getLocation(), target) < 12) + { + Bukkit.broadcastMessage("Too close"); + continue; + } + } + + if (!AI_METHOD.updateMovement(entity, minion.getTarget(), 4F)) { int newTarget = minion.getTargetIndex() + 1; if (newTarget == _path.size()) { - // TODO target wither, probably... + Bukkit.broadcastMessage("Done"); continue; } minion.setTargetIndex(newTarget); + minion.setTarget(_path.get(newTarget)); + Bukkit.broadcastMessage("Advance target " + newTarget); } } @@ -121,7 +146,7 @@ public class MinionWave implements Listener } } - private boolean targetTower(Minion minion) + private Location targetTower(Minion minion) { for (Tower tower : _host.getTowerManager().getTowers()) { @@ -130,27 +155,60 @@ public class MinionWave implements Listener continue; } + Location location = tower.getCrystal().getLocation(); double distSquared = UtilMath.offsetSquared(minion.getEntity(), tower.getCrystal()); if (distSquared < 3) { - return true; + return location; } else if (distSquared > Tower.TARGET_RANGE_SQUARED) { continue; } - minion.setTarget(tower.getCrystal().getLocation()); - return true; + return location; } - return false; + return null; } - private void targetWither(Minion minion) + private Location targetWither(Minion minion) { + for (MobaBoss boss : _host.getBossManager().getBosses()) + { + if (boss.isDead()) + { + continue; + } + if (boss instanceof WitherBoss) + { + WitherBoss witherBoss = (WitherBoss) boss; + + if (witherBoss.getTeam().equals(_owner)) + { + continue; + } + } + + Location location = boss.getEntity().getLocation(); + double distSquared = UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()); + + if (distSquared < 3) + { + return location; + } + else if (distSquared > Tower.TARGET_RANGE_SQUARED) + { + continue; + } + + minion.setTarget(boss.getEntity().getLocation()); + return location; + } + + return null; } @EventHandler(priority = EventPriority.HIGHEST) From a6c1e6c892989eb40b653c48b025e1cdd19c2122 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 24 May 2017 18:27:10 +0100 Subject: [PATCH 046/283] Make minions target each other --- .../games/moba/boss/wither/WitherBoss.java | 12 +- .../game/games/moba/minion/MinionManager.java | 5 + .../game/games/moba/minion/MinionWave.java | 161 +++++++++++++++++- .../moba/structure/tower/TowerManager.java | 2 +- 4 files changed, 172 insertions(+), 8 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 4d7cfe3f2..5e82dc48b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -100,18 +100,22 @@ public class WitherBoss extends MobaBoss event.SetCancelled("Wither Boss"); - if (event.GetDamagerPlayer(true) == null || event.GetCause() == DamageCause.FIRE || event.GetCause() == DamageCause.FIRE_TICK) + if (event.GetCause() == DamageCause.FIRE || event.GetCause() == DamageCause.FIRE_TICK) { return; } LivingEntity damagee = event.GetDamageeEntity(); Player damager = event.GetDamagerPlayer(true); - GameTeam team = _host.GetTeam(damager); - if (_team.equals(team)) + if (damager != null) { - return; + GameTeam team = _host.GetTeam(damager); + + if (team == null || _team.equals(team)) + { + return; + } } double newHealth = damagee.getHealth() - event.GetDamage(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 525b2946d..6253b9ef9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -105,6 +105,11 @@ public class MinionManager implements Listener _waves.remove(wave); } + public Set getWaves() + { + return _waves; + } + /** * This method fills the {@link #_path} with the organised list of locations that the minions must follow.
*

diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 130c279d0..bc89371f3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.minion; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; @@ -22,6 +23,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.scheduler.BukkitRunnable; @@ -33,6 +35,10 @@ public class MinionWave implements Listener { private static final int MAX_MINIONS_PER_WAVE = 1; + private static final int TOO_CLOSE_SQUARED = 12; + private static final int MINION_TOO_CLOSE_SQUARED = 4; + private static final int DAMAGE_RANGE_SQUARED = 15; + private static final int DAMAGE_AMOUNT = 4; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private final Moba _host; @@ -67,7 +73,7 @@ public class MinionWave implements Listener cancel(); } } - }, 0, 20); + }, 20, 20); } private boolean spawn() @@ -98,12 +104,28 @@ public class MinionWave implements Listener LivingEntity entity = minion.getEntity(); Location target = null; Location towerTarget = targetTower(minion); + Minion minionTarget = targetMinion(minion); Location witherTarget = targetWither(minion); + // Priority -> Tower -> Minion -> Wither + if (towerTarget != null) { target = towerTarget; } + else if (minionTarget != null) + { + target = minionTarget.getEntity().getLocation(); + minion.setTarget(target); + + // Too close + if (UtilMath.offsetSquared(entity.getLocation(), target) < MINION_TOO_CLOSE_SQUARED) + { + Bukkit.broadcastMessage("Attack"); + _host.getArcadeManager().GetDamage().NewDamageEvent(minion.getEntity(), minionTarget.getEntity(), null, DamageCause.CUSTOM, DAMAGE_AMOUNT, false, false, false, UtilEnt.getName(minion.getEntity()), "Minion"); + continue; + } + } else if (witherTarget != null) { target = witherTarget; @@ -114,7 +136,7 @@ public class MinionWave implements Listener minion.setTarget(target); // Too close - if (UtilMath.offsetSquared(entity.getLocation(), target) < 12) + if (UtilMath.offsetSquared(entity.getLocation(), target) < TOO_CLOSE_SQUARED) { Bukkit.broadcastMessage("Too close"); continue; @@ -146,6 +168,36 @@ public class MinionWave implements Listener } } + private Minion targetMinion(Minion minion) + { + for (MinionWave wave : _minionManager.getWaves()) + { + // Same team + if (wave.getOwner().equals(_owner)) + { + continue; + } + + for (Minion otherMinion : wave.getMinions()) + { + double distSquared = UtilMath.offsetSquared(minion.getEntity(), otherMinion.getEntity()); + + if (distSquared < 3) + { + return otherMinion; + } + else if (distSquared > Tower.TARGET_RANGE_SQUARED) + { + continue; + } + + return otherMinion; + } + } + + return null; + } + private Location targetTower(Minion minion) { for (Tower tower : _host.getTowerManager().getTowers()) @@ -204,13 +256,106 @@ public class MinionWave implements Listener continue; } - minion.setTarget(boss.getEntity().getLocation()); return location; } return null; } + @EventHandler + public void damageMinions(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (Minion minion : _minions) + { + for (MinionWave wave : _minionManager.getWaves()) + { + // Same team + if (wave.getOwner().equals(_owner)) + { + continue; + } + + for (Minion otherMinion : wave.getMinions()) + { + // Cannot damage, not close enough + if (UtilMath.offsetSquared(minion.getEntity(), otherMinion.getEntity()) > DAMAGE_RANGE_SQUARED) + { + continue; + } + + + } + } + } + + for (Minion minion : _minions) + { + for (Tower tower : _host.getTowerManager().getTowers()) + { + // Cannot damage, not close enough + if (!_host.getTowerManager().canDamage(tower, _owner) || UtilMath.offsetSquared(minion.getEntity(), tower.getCrystal()) > DAMAGE_RANGE_SQUARED) + { + continue; + } + + tower.damage(DAMAGE_AMOUNT); + } + } + } + + @EventHandler + public void damageTower(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (Minion minion : _minions) + { + for (Tower tower : _host.getTowerManager().getTowers()) + { + // Cannot damage, not close enough + if (!_host.getTowerManager().canDamage(tower, _owner) || UtilMath.offsetSquared(minion.getEntity(), tower.getCrystal()) > DAMAGE_RANGE_SQUARED) + { + continue; + } + + tower.damage(DAMAGE_AMOUNT); + } + } + } + + @EventHandler + public void damageWither(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + List bosses = _host.getBossManager().getBosses(); + + for (Minion minion : _minions) + { + for (MobaBoss boss : bosses) + { + // Dead, not close enough + if (boss.isDead() || UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()) > DAMAGE_RANGE_SQUARED) + { + continue; + } + + _host.getArcadeManager().GetDamage().NewDamageEvent(boss.getEntity(), minion.getEntity(), null, DamageCause.CUSTOM, DAMAGE_AMOUNT, false, false, false, UtilEnt.getName(minion.getEntity()), "Minion"); + } + } + } + @EventHandler(priority = EventPriority.HIGHEST) public void damage(CustomDamageEvent event) { @@ -267,6 +412,16 @@ public class MinionWave implements Listener } } + public List getMinions() + { + return _minions; + } + + public GameTeam getOwner() + { + return _owner; + } + private Minion getMinion(Entity entity) { for (Minion minion : _minions) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index fb5a02f31..7cd2e69f1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -240,7 +240,7 @@ public class TowerManager implements Listener // } // } - private boolean canDamage(Tower tower, GameTeam team) + public boolean canDamage(Tower tower, GameTeam team) { // Dead tower, nothing // Same team From b7ba5325680205ae14ceb0eaec34c05fe68dd10a Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 25 May 2017 00:40:41 +0200 Subject: [PATCH 047/283] Add quest stats page, make rewards be able to be items as well, fix some quest trackers, fix spelling mistakes --- .../src/mineplex/core/quests/Quest.java | 76 +++++++++++- .../mineplex/core/quests/QuestManager.java | 35 ++++-- .../quests/repository/QuestRepository.java | 77 ++---------- .../core/quests/shop/BuyQuestButton.java | 26 +--- .../mineplex/core/quests/shop/QuestPage.java | 48 +++++--- .../core/quests/shop/QuestStatShop.java | 35 ++++++ .../core/quests/shop/QuestStatsButton.java | 37 ++++++ .../core/quests/shop/QuestStatsPage.java | 111 ++++++++++++++++++ .../quests/shop/RedeemDeclineQuestButton.java | 41 +++++-- .../src/mineplex/hub/HubManager.java | 2 +- .../nautilus/game/arcade/ArcadeManager.java | 2 +- .../arcade/quest/KillEntityQuestTracker.java | 17 ++- .../game/arcade/quest/KillQuestTracker.java | 26 ++-- 13 files changed, 375 insertions(+), 158 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatShop.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java index f005c5637..a15d604f5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java @@ -1,7 +1,15 @@ package mineplex.core.quests; +import java.util.function.Consumer; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.donation.DonationManager; import mineplex.core.game.GameCategory; import mineplex.core.game.GameDisplay; +import mineplex.core.inventory.InventoryManager; /** * Quest @@ -18,7 +26,7 @@ public class Quest private String _questTask; private int _questCost; - private int _questReward; + private String _questReward; private QuestRarity _rarity; @@ -36,7 +44,9 @@ public class Quest private int _current; - public Quest(int questID, String name, String task, int cost, int reward, QuestRarity rarity, String type, TriggerType trigger, String item, int statToComplete) + private int _timesCompleted; + + public Quest(int questID, String name, String task, int cost, String reward, QuestRarity rarity, String type, TriggerType trigger, String item, int statToComplete) { _questID = questID; _questName = name; @@ -52,8 +62,11 @@ public class Quest if (GameDisplay.matchName(type) != null) _game = GameDisplay.matchName(type); - if (GameCategory.valueOf(type) != null) + try + { _gameCategory = GameCategory.valueOf(type); + } + catch (IllegalArgumentException e) {} _overworld = (_game == null && _gameCategory == null); } @@ -78,7 +91,7 @@ public class Quest return _questCost; } - public int getReward() + public String getReward() { return _questReward; } @@ -175,6 +188,61 @@ public class Quest return _lastCompleted; } + public void reward(InventoryManager inventory, DonationManager donations, Player player, Consumer callback) + { + if (_questReward.contains(":")) + { + if (getRewardName().equalsIgnoreCase("Shards")) + { + donations.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing Quest: " + _questID, Integer.parseInt(_questReward.split(":")[1]), callback); + } + else if (getRewardName().equalsIgnoreCase("Gems")) + { + donations.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing Quest: " + _questID, Integer.parseInt(_questReward.split(":")[1]), callback); + } + else + { + inventory.addItemToInventory(player, getRewardName(), getRewardAmount()); + callback.accept(true); + } + } + } + + public String getRewardName() + { + return _questReward.split(":")[0]; + } + + public int getRewardAmount() + { + return Integer.parseInt(_questReward.split(":")[1]); + } + + public void setTimesCompleted(int amount) + { + _timesCompleted = amount; + } + + public int getTimesCompleted() + { + return _timesCompleted; + } + + public String[] getQuestInfo() + { + String[] info = new String[]{ + ChatColor.LIGHT_PURPLE + getTask(), "", ChatColor.GRAY + "Reward: " + ChatColor.AQUA + getRewardAmount() + " " + getRewardName(), + "", + ChatColor.GRAY + "Progress: " + + (_current == -1 ? ChatColor.RED + "Not in your Quest Inventory" : + (isCompleted() ? ChatColor.GREEN + "Completed!" : + ChatColor.YELLOW + "" + getProgress() + ChatColor.GRAY + "/" + ChatColor.YELLOW + getStatToComplete())), + "", + getRarity().getColor() + "" + ChatColor.BOLD + getRarity().toString(), + }; + return info; + } + @Override public Quest clone() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index d0ba43e4f..939c94fad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -15,12 +15,14 @@ import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Pair; import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; import mineplex.core.game.GameCategory; import mineplex.core.game.GameDisplay; import mineplex.core.google.GoogleSheetsManager; +import mineplex.core.inventory.InventoryManager; import mineplex.core.quests.command.GetQuestCommand; import mineplex.core.quests.command.OpenGuiCommand; import mineplex.core.quests.repository.QuestRepository; @@ -44,12 +46,13 @@ public class QuestManager extends MiniClientPlugin private GoogleSheetsManager _sheetsManager; private CoreClientManager _clients; private DonationManager _donationManager; + private InventoryManager _inventoryManager; public ArrayList _availableQuests; private QuestSupplier _questSupplier = new RedisQuestSupplier(getPlugin(), new PubSubRouter(new PubSubJedisClient(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection()))); - public QuestManager(DonationManager donationManager) + public QuestManager(InventoryManager inventoryManager, DonationManager donationManager) { super("Quest Manager"); @@ -58,6 +61,7 @@ public class QuestManager extends MiniClientPlugin _clients = require(CoreClientManager.class); _availableQuests = new ArrayList<>(); _donationManager = donationManager; + _inventoryManager = inventoryManager; setupQuests(); } @@ -97,7 +101,7 @@ public class QuestManager extends MiniClientPlugin _availableQuests.add(new Quest(Integer.parseInt(id), name, task, Integer.parseInt(cost), - Integer.parseInt(reward), + reward, QuestRarity.getByName(rarity), type, TriggerType.getByName(trigger), @@ -110,16 +114,17 @@ public class QuestManager extends MiniClientPlugin public void playerJoin(PlayerJoinEvent event) { QuestClientData questData = Get(event.getPlayer()); - _repository.getQuests(_clients.Get(event.getPlayer()), new Callback>>() + _repository.getQuests(_clients.Get(event.getPlayer()), new Callback>>>() { @Override - public void run(ArrayList> data) + public void run(ArrayList>> data) { - for (Triple triple : data) + for (Pair> pair : data) { - int id = triple.getLeft(); - int value = triple.getMiddle(); - long time = triple.getRight(); + int id = pair.getLeft(); + int value = pair.getRight().getLeft(); + long time = pair.getRight().getMiddle(); + int timesCompleted = pair.getRight().getRight(); for (Quest quest : _availableQuests) { @@ -128,6 +133,7 @@ public class QuestManager extends MiniClientPlugin Quest clone = quest.clone(); clone.setProgress(value); clone.setLastCompleted(time); + clone.setTimesCompleted(timesCompleted); questData.addQuest(clone); } } @@ -167,15 +173,19 @@ public class QuestManager extends MiniClientPlugin public void resetQuest(Player player, Quest quest, boolean completed) { - Get(player).removeQuest(quest.getID()); + if (completed) + { + quest.setTimesCompleted(quest.getTimesCompleted() + 1); + } + Get(player).removeQuest(quest.getID()); _repository.resetQuest(_clients.Get(player), quest, completed); } public void incrementQuest(CoreClient client, Quest quest, int value) { quest.increment(value); - _repository.incrementQuest(client, quest); + _repository.incrementQuest(client, quest, value); } public Set getCurrentQuests() @@ -202,6 +212,11 @@ public class QuestManager extends MiniClientPlugin return _donationManager; } + public InventoryManager getInventoryManager() + { + return _inventoryManager; + } + @Override protected QuestClientData addPlayer(UUID uuid) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java index 09b7ecc5a..37733a116 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java @@ -3,12 +3,11 @@ package mineplex.core.quests.repository; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -import java.util.HashMap; import org.apache.commons.lang3.tuple.Triple; -import org.bukkit.entity.Player; import mineplex.core.account.CoreClient; +import mineplex.core.common.Pair; import mineplex.core.common.util.Callback; import mineplex.core.quests.Quest; import mineplex.serverdata.database.DBPool; @@ -25,55 +24,30 @@ import mineplex.serverdata.database.column.ColumnLong; public class QuestRepository extends RepositoryBase { private static final String INSTERT_NEW_QUEST = "INSERT INTO accountQuest (accountId, questId, progress, questCompletion, lastCompleted) VALUES (?, ?, ?, ?, ?);"; - private static final String INCREMENT_QUEST = "UPDATE accountQuest SET progress=progress+1 WHERE accountId=? AND questId=?;"; + private static final String INCREMENT_QUEST = "UPDATE accountQuest SET progress=progress+? WHERE accountId=? AND questId=?;"; private static final String RESET_QUEST = "UPDATE accountQuest SET progress=-1 WHERE accountId=? AND questId=?;"; private static final String START_QUEST = "UPDATE accountQuest SET progress=0 WHERE accountId=? AND questId=?;"; private static final String COMPLETE_QUEST = "UPDATE accountQuest SET progress=-1, questCompletion=questCompletion+1, lastCompleted=? WHERE accountId=? AND questId=?;"; - private static final String FETCH_QUESTS = "SELECT questId, progress, lastCompleted FROM accountQuest WHERE accountId=?"; - - private HashMap>> _db; + private static final String FETCH_QUESTS = "SELECT questId, progress, questCompletion, lastCompleted FROM accountQuest WHERE accountId=?"; public QuestRepository() { super(DBPool.getAccount()); - - _db = new HashMap<>(); } - public void player(Player player) + public void getQuests(CoreClient client, Callback>>> callback) { - for (String string : _db.keySet()) - { - if (string.equalsIgnoreCase(player.getUniqueId().toString())) - return; - } - _db.put(player.getUniqueId().toString(), new ArrayList<>()); - } - - public void getQuests(CoreClient client, Callback>> callback) - { - //player(client.GetPlayer()); -// ArrayList> list = new ArrayList<>(); -// for (int i = 2; i <= 3; i++) -// { -// list.add(Triple.of(i, UtilMath.r(10) + 1, System.currentTimeMillis() - (1000*60*60*48))); -// } -// return list; -// return _db.get(client.GetPlayer().getUniqueId().toString()); - executeQuery(FETCH_QUESTS, new ResultSetCallable() { @Override public void processResultSet(ResultSet resultSet) throws SQLException { - ArrayList> list = new ArrayList<>(); - + ArrayList>> list = new ArrayList<>(); while (resultSet.next()) { - list.add(Triple.of(resultSet.getInt(1), resultSet.getInt(2), resultSet.getLong(3))); + list.add(Pair.create(resultSet.getInt(1), Triple.of(resultSet.getInt(2), resultSet.getLong(4), resultSet.getInt(3)))); } - callback.run(list); } } ,new ColumnInt("accountId", client.getAccountId())); @@ -81,22 +55,6 @@ public class QuestRepository extends RepositoryBase public void resetQuest(CoreClient client, Quest quest, boolean completed) { -// player(client.GetPlayer()); -// Triple toAdd = null; -// ArrayList> liste = _db.get(client.GetPlayer().getUniqueId().toString()); -// Iterator> iterator = liste.iterator(); -// while (iterator.hasNext()) -// { -// Triple triple = iterator.next(); -// if (triple.getLeft() == quest.getID()) -// { -// toAdd = Triple.of(triple.getLeft(), -1, (completed ? System.currentTimeMillis() : (long) 0)); -// iterator.remove(); -// } -// } -// if (toAdd != null) -// _db.get(client.GetPlayer().getUniqueId().toString()).add(toAdd); - if (completed) { executeUpdate(COMPLETE_QUEST, new ColumnLong("lastCompleted", System.currentTimeMillis()), new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); @@ -114,9 +72,6 @@ public class QuestRepository extends RepositoryBase public void addNew(CoreClient client, Quest quest) { - //player(client.GetPlayer()); - //_db.get(client.GetPlayer().getUniqueId().toString()).add(Triple.of(quest.getID(), 0, (long) 0)); - executeInsert(INSTERT_NEW_QUEST, null, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID()), @@ -125,25 +80,9 @@ public class QuestRepository extends RepositoryBase new ColumnLong("lastCompleted", (long) 0)); } - public void incrementQuest(CoreClient client, Quest quest) + public void incrementQuest(CoreClient client, Quest quest, int value) { -// //player(client.GetPlayer()); -// Triple toAdd = null; -// ArrayList> liste = _db.get(client.GetPlayer().getUniqueId().toString()); -// Iterator> iterator = liste.iterator(); -// while (iterator.hasNext()) -// { -// Triple triple = iterator.next(); -// if (triple.getLeft() == quest.getID()) -// { -// toAdd = Triple.of(triple.getLeft(), triple.getMiddle() + 1, triple.getRight()); -// iterator.remove(); -// } -// } -// if (toAdd != null) -// _db.get(client.GetPlayer().getUniqueId().toString()).add(toAdd); - - executeUpdate(INCREMENT_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + executeUpdate(INCREMENT_QUEST, new ColumnInt("progress", value), new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java index 63d573c53..6267f1980 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java @@ -9,12 +9,10 @@ import org.bukkit.event.inventory.ClickType; import mineplex.core.common.currency.GlobalCurrency; 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.quests.Quest; import mineplex.core.quests.QuestManager; import mineplex.core.recharge.Recharge; -import mineplex.core.server.util.TransactionResponse; import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.SalesPackageBase; @@ -69,35 +67,13 @@ public class BuyQuestButton implements IButton } } -// if (_questManager.getDonations().Get(player).getBalance(GlobalCurrency.GEM) >= _quest.getCost()) -// { -// _questManager.getDonations().purchaseUnknownSalesPackage(player, _quest.getName(), GlobalCurrency.GEM, _quest.getCost(), false, response -> -// { -// if (response == TransactionResponse.Success) -// { -// _questManager.addNewQuest(player, _quest); -// UtilPlayer.message(player, F.main("Quest", "Purchase Succesfull!")); -// } -// else -// { -// UtilPlayer.message(player, F.main("Quest", "There was an Error while purchasing!")); -// } -// }); -// } -// else -// { -// UtilPlayer.message(player, F.main("Quest", "You dont have enough Gems!")); -// } - SalesPackageBase salesPackage = new QuestSale(_quest.getName(), Material.PAPER, _quest.getCost()); _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, _page.getDonationManager(), () -> { _questManager.addNewQuest(player, _quest); UtilPlayer.message(player, F.main("Quest", "You have bought: " + ChatColor.YELLOW + _quest.getName())); player.closeInventory(); - -// QuestPage page = new QuestPage(_page.getPlugin(), _page.getQuestShop(), _page.getClientManager(), _page.getDonationManager(), player); -// _page.getQuestShop().openPageForPlayer(player, page); + new QuestShop(_questManager, _questManager.getClients(), _questManager.getDonations()).attemptShopOpen(player); }), salesPackage.buildIcon())); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java index 77ed1e7d0..13c0fe7b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java @@ -2,18 +2,22 @@ package mineplex.core.quests.shop; import java.util.Arrays; +import org.apache.commons.lang3.ArrayUtils; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.account.CoreClientManager; import mineplex.core.donation.DonationManager; +import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.quests.Quest; import mineplex.core.quests.QuestManager; +import mineplex.core.shop.item.IButton; import mineplex.core.shop.page.ShopPageBase; /** @@ -23,11 +27,19 @@ import mineplex.core.shop.page.ShopPageBase; */ public class QuestPage extends ShopPageBase { - + private QuestShop _questShop; + private QuestManager _manager; + private InventoryManager _inventory; + public QuestPage(QuestManager plugin, QuestShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) { super(plugin, shop, clientManager, donationManager, "Quest Page", player, 27); + _questShop = shop; + _manager = plugin; + + _inventory = plugin.getInventoryManager(); + buildPage(); } @@ -35,8 +47,7 @@ public class QuestPage extends ShopPageBase protected void buildPage() { int i = 0; - setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, "")); - + setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " ")); { int currentSlot = 4; int diff = 0; @@ -63,7 +74,7 @@ public class QuestPage extends ShopPageBase ChatColor.LIGHT_PURPLE + quest.getTask(), "", ChatColor.GRAY + "Cost: " + ChatColor.GREEN + quest.getCost() + " Gems", - ChatColor.GRAY + "Reward: " + ChatColor.AQUA + quest.getReward() + " Shards", + ChatColor.GRAY + "Reward: " + ChatColor.AQUA + quest.getRewardAmount() + " " + quest.getRewardName(), "", quest.getRarity().getColor() + "" + ChatColor.BOLD + quest.getRarity().toString(), "", @@ -71,7 +82,7 @@ public class QuestPage extends ShopPageBase )); item.setItemMeta(meta); - addButton(i + currentSlot, item, new BuyQuestButton(_plugin, this, quest)); + addButton(i + currentSlot, item, new BuyQuestButton(_manager, this, quest)); } } i = 9; @@ -81,7 +92,15 @@ public class QuestPage extends ShopPageBase i++; } i = 9*2; - setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMPTY_MAP, (byte) 0, 1, "")); + addButton(i, ItemStackFactory.Instance.CreateStack(Material.EMPTY_MAP, (byte) 0, 1, ChatColor.RESET + "" + ChatColor.BOLD + "Quest Stats"), new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + player.closeInventory(); + new QuestStatShop(_manager, _manager.getClients(), _manager.getDonations()).attemptShopOpen(player); + } + }); { int currentSlot = 4; @@ -103,27 +122,22 @@ public class QuestPage extends ShopPageBase ItemStack item = new ItemStack(Material.PAPER); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + quest.getName()); - meta.setLore(Arrays.asList( - ChatColor.LIGHT_PURPLE + quest.getTask(), - "", - ChatColor.GRAY + "Reward: " + ChatColor.AQUA + quest.getReward() + " Shards", - "", - ChatColor.GRAY + "Progress: " + (quest.isCompleted() ? ChatColor.GREEN + "Completed!" : ChatColor.YELLOW + "" + quest.getProgress() + ChatColor.GRAY + "/" + ChatColor.YELLOW + quest.getStatToComplete()), - "", - quest.getRarity().getColor() + "" + ChatColor.BOLD + quest.getRarity().toString(), + + meta.setLore(Arrays.asList(ArrayUtils.addAll(quest.getQuestInfo(), "", (quest.isCompleted() ? ChatColor.GREEN + "Left Click to Complete" : ChatColor.RED + "Shift Right-Click to cancel") - )); + ))); + item.setItemMeta(meta); - addButton(i + currentSlot, item, new RedeemDeclineQuestButton(_donationManager, _plugin, this, quest)); + addButton(i + currentSlot, item, new RedeemDeclineQuestButton(_inventory, _donationManager, _manager, this, quest)); } } } public QuestShop getQuestShop() { - return _shop; + return _questShop; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatShop.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatShop.java new file mode 100644 index 000000000..44d99a1c7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatShop.java @@ -0,0 +1,35 @@ +package mineplex.core.quests.shop; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.quests.QuestManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; + +/** + * QuestStatShop + * + * @author xXVevzZXx + */ +public class QuestStatShop extends ShopBase +{ + + public QuestStatShop(QuestManager plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super(plugin, clientManager, donationManager, "Quest Stats"); + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return new QuestStatsPage(getPlugin(), this, getClientManager(), getDonationManager(), player, 0); + } + + public QuestManager getQuestManager() + { + return getPlugin(); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsButton.java new file mode 100644 index 000000000..f833691e6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsButton.java @@ -0,0 +1,37 @@ +package mineplex.core.quests.shop; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.quests.Quest; +import mineplex.core.quests.QuestManager; +import mineplex.core.shop.item.IButton; + +/** + * QuestStatsButton + * + * @author xXVevzZXx + */ +public class QuestStatsButton implements IButton +{ + + private QuestManager _questManager; + + private QuestPage _page; + + private Quest _quest; + + public QuestStatsButton(QuestManager questManager, QuestPage page, Quest quest) + { + _questManager = questManager; + _quest = quest; + _page = page; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java new file mode 100644 index 000000000..60b26f201 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java @@ -0,0 +1,111 @@ +package mineplex.core.quests.shop; + +import java.util.Arrays; + +import org.apache.commons.lang3.ArrayUtils; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.quests.Quest; +import mineplex.core.quests.QuestClientData; +import mineplex.core.quests.QuestManager; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.page.ShopPageBase; + +/** + * QuestStatsPage + * + * @author xXVevzZXx + */ +public class QuestStatsPage extends ShopPageBase +{ + private QuestStatShop _questShop; + private QuestManager _manager; + private int _siteIndex; + + public QuestStatsPage(QuestManager plugin, QuestStatShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, int site) + { + super(plugin, shop, clientManager, donationManager, "Quest Stats", player, 4*9); + + _siteIndex = site; + + _questShop = shop; + _manager = plugin; + + buildPage(); + } + + @Override + protected void buildPage() + { + int questID = (_siteIndex * 3 * 9); + for (int i = 0; i < 9*3; i++) + { + Quest quest = _manager.getQuestByID(questID); + + if (quest == null) + break; + + QuestClientData data = _manager.Get(getPlayer()); + ItemStack item = ItemStackFactory.Instance.CreateStack(Material.WOOL, DyeColor.GRAY.getWoolData(), 1, ChatColor.RED + "Quest not acquired"); + + if (data.hasQuestFromAll(quest)) + { + Quest used = data.getQuestFromAll(questID); + + item = ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte) 0, 1, ChatColor.YELLOW + used.getName()); + ItemMeta meta = item.getItemMeta(); + meta.setLore(Arrays.asList(ArrayUtils.addAll(used.getQuestInfo(), + "", + ChatColor.GRAY + "Times Completed: " + ChatColor.YELLOW + used.getTimesCompleted() + ))); + item.setItemMeta(meta); + } + setItem(i, item); + + questID++; + } + + if (_siteIndex != 0) + { + addButton(3*9, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Previous Page"), new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + player.closeInventory(); + getQuestStatsShop().openPageForPlayer(player, new QuestStatsPage(_manager, getQuestStatsShop(), _manager.getClients(), _manager.getDonations(), player, _siteIndex - 1)); + } + }); + } + + if (((_siteIndex + 1) * 3 * 9) < _manager.getAvailableQuests().size()) + { + addButton((4*9) - 1, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Next Page"), new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + player.closeInventory(); + getQuestStatsShop().openPageForPlayer(player, new QuestStatsPage(_manager, getQuestStatsShop(), _manager.getClients(), _manager.getDonations(), player, _siteIndex + 1)); + } + }); + } + + } + + + public QuestStatShop getQuestStatsShop() + { + return _questShop; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java index 97b5074ed..9a5cb36a1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java @@ -1,16 +1,21 @@ package mineplex.core.quests.shop; +import java.util.function.Consumer; + import javax.jws.Oneway; import net.md_5.bungee.api.ChatColor; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.donation.DonationManager; +import mineplex.core.inventory.InventoryManager; import mineplex.core.quests.Quest; import mineplex.core.quests.QuestManager; import mineplex.core.recharge.Recharge; @@ -25,15 +30,17 @@ public class RedeemDeclineQuestButton implements IButton { private QuestManager _questManager; private DonationManager _donations; + private InventoryManager _inventory; private QuestPage _page; private Quest _quest; - public RedeemDeclineQuestButton(DonationManager donations, QuestManager questManager, QuestPage page, Quest quest) + public RedeemDeclineQuestButton(InventoryManager inventory, DonationManager donations, QuestManager questManager, QuestPage page, Quest quest) { _questManager = questManager; _donations = donations; + _inventory = inventory; _quest = quest; _page = page; } @@ -49,7 +56,6 @@ public class RedeemDeclineQuestButton implements IButton if (!_questManager.Get(player).hasQuest(_quest)) { UtilPlayer.message(player, F.main("Quest", "You don't own that Quest!")); - player.closeInventory(); return; } @@ -57,13 +63,11 @@ public class RedeemDeclineQuestButton implements IButton { if (_quest.isCompleted()) { - UtilPlayer.message(player, F.main("Quest", "You can't cancell a completed Quest!")); - player.closeInventory(); + UtilPlayer.message(player, F.main("Quest", "You can't cancel a completed Quest!")); return; } _questManager.resetQuest(player, _quest, false); UtilPlayer.message(player, F.main("Quest", "You have cancelled that Quest!")); - player.closeInventory(); } if (clickType == ClickType.LEFT) @@ -71,14 +75,31 @@ public class RedeemDeclineQuestButton implements IButton if (!_quest.isCompleted()) { UtilPlayer.message(player, F.main("Quest", "You haven't completed that Quest yet!")); - player.closeInventory(); return; } - _questManager.resetQuest(player, _quest, true); - _donations.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completed Quest: " + _quest.getID(), _quest.getReward()); - UtilPlayer.message(player, F.main("Quest", "You have recieved " + ChatColor.AQUA + _quest.getReward() + " Shards " + ChatColor.GRAY + "for completing: " + ChatColor.YELLOW + _quest.getName())); - player.closeInventory(); + + _quest.reward(_inventory, _donations, player, new Consumer() + { + @Override + public void accept(Boolean succes) + { + if (succes) + { + _questManager.resetQuest(player, _quest, true); + UtilPlayer.message(player, F.main("Quest", "You have recieved " + ChatColor.AQUA + _quest.getRewardAmount() + " " + _quest.getRewardName() + " " + ChatColor.GRAY + "for completing: " + ChatColor.YELLOW + _quest.getName())); + } + else + { + UtilPlayer.message(player, F.main("Quest", "Something went wrong!")); + + } + } + }); + } + player.closeInventory(); + new QuestShop(_questManager, _questManager.getClients(), _donations).attemptShopOpen(player); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index ded28fa45..f9b628563 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -294,7 +294,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess new EasterEggHunt(plugin, _clientManager); - _questManager = new QuestManager(_donationManager); + _questManager = new QuestManager(_inventoryManager, _donationManager); new TemporaryGemHuntersServerSender(_portal); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 399ac7b0f..35a3b2eb0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -391,7 +391,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _kitProgressionManager = new KitProgressionManager(getPlugin(), donationManager, clientManager); _progressionKitManager = new ProgressingKitManager(this); _serverUptimeManager = new ServerUptimeManager(this); - _questManager = new QuestManager(_donationManager); + _questManager = new QuestManager(_inventoryManager, _donationManager); if (GetHost() != null && !GetHost().isEmpty() && !GetHost().startsWith("COM-")) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillEntityQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillEntityQuestTracker.java index 9c9ca24e0..72c40f5aa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillEntityQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillEntityQuestTracker.java @@ -7,8 +7,10 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDeathEvent; import mineplex.core.quests.TriggerType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.Game; @@ -26,22 +28,19 @@ public class KillEntityQuestTracker extends QuestTracker } @EventHandler - public void killEntity(EntityDamageByEntityEvent event) + public void killEntity(EntityDeathEvent event) { if (!getGame().IsLive()) return; - Entity entity = event.getEntity(); + LivingEntity lEntity = event.getEntity(); - if (entity instanceof Player) + if (!(lEntity.getKiller() instanceof Player)) return; - if (!(event.getDamager() instanceof Player)) - return; + Player player = lEntity.getKiller(); - LivingEntity lEntity = (LivingEntity) entity; - - if (lEntity.getHealth() > 0) + if (lEntity instanceof Player) return; String name = lEntity.getType().getName(); @@ -49,7 +48,7 @@ public class KillEntityQuestTracker extends QuestTracker if (lEntity.isCustomNameVisible()) name = lEntity.getCustomName(); - incrementQuests((Player) event.getDamager(), ChatColor.stripColor(name), 1); + incrementQuests((Player) player, ChatColor.stripColor(name), 1); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java index be4f5ad12..0dbadffb6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java @@ -2,9 +2,10 @@ package nautilus.game.arcade.quest; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageByEntityEvent; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.quests.TriggerType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.Game; @@ -18,25 +19,26 @@ public class KillQuestTracker extends QuestTracker public KillQuestTracker(Game game) { - super(game, TriggerType.WIN); + super(game, TriggerType.KILL); } @EventHandler - public void onKil(EntityDamageByEntityEvent event) + public void onKill(CombatDeathEvent event) { if (!getGame().IsLive()) return; - - if (!(event.getDamager() instanceof Player)) + + if (event.GetLog().GetKiller() == null) + return; + + if (!event.GetLog().GetKiller().IsPlayer()) + return; + + Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + if (player == null) return; - if (!(event.getEntity() instanceof Player)) - return; - - if (((Player) event.getEntity()).getHealth() > 0) - return; - - incrementQuests((Player) event.getDamager(), "Player", 1); + incrementQuests(player, "Player", 1); } } From 5c8a36b024f9475875ba5e942acf0ad1ca0b9217 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 26 May 2017 18:33:06 +0100 Subject: [PATCH 048/283] Sigils bug fixes --- .../game/arcade/game/games/moba/Moba.java | 2 +- .../arcade/game/games/moba/ai/MobaAI.java | 4 +- .../moba/ai/goal/MobaDirectAIMethod.java | 8 +- .../games/moba/kit/dana/SkillPulseHeal.java | 6 +- .../game/games/moba/kit/dana/SkillRally.java | 13 +++ .../game/games/moba/kit/devon/HeroDevon.java | 2 +- .../games/moba/kit/devon/SkillInfinity.java | 13 +-- .../games/moba/kit/devon/SkillTNTArrows.java | 88 ++++++++++--------- .../games/moba/kit/hattori/HeroHattori.java | 2 +- .../arcade/game/games/moba/minion/Minion.java | 15 ++++ .../game/games/moba/minion/MinionWave.java | 26 +++--- .../moba/prepare/PrepareInformation.java | 4 +- .../structure/point/CapturePointManager.java | 2 +- .../moba/structure/tower/TowerManager.java | 4 +- 14 files changed, 104 insertions(+), 85 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index d0ada1134..f409ea48f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -237,7 +237,7 @@ public class Moba extends TeamGame scoreboard.writeNewLine(); scoreboard.write(C.cYellowB + "Hero"); - scoreboard.write(mobaPlayer.getKit() == null ? "Unselected " : mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getName() + ")"); + scoreboard.write((mobaPlayer == null || mobaPlayer.getKit() == null) ? "Unselected " : mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getName() + ")"); scoreboard.writeNewLine(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index e8f3d0a8a..712b31aa9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -65,13 +65,13 @@ public class MobaAI if (_target != null) { - _aiMethod.updateMovement(_entity, _target.getLocation(), 2.5F); + _aiMethod.updateMovement(_entity, _target.getLocation(), 5F); } } private void returnToHome() { - _aiMethod.updateMovement(_entity, _home, 3.5F); + _aiMethod.updateMovement(_entity, _home, 7F); } public void setEntity(LivingEntity entity) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index 21e3f6ad3..1bfe6a4b1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -15,12 +15,6 @@ public class MobaDirectAIMethod implements MobaAIMethod public boolean updateMovement(LivingEntity entity, Location goal, float speed) { Location entityLocation = entity.getLocation(); - - if (UtilMath.offsetSquared(entity.getLocation(), goal) < 6) - { - return false; - } - float entityYaw = entityLocation.getYaw(); // Speed is blocks per second @@ -58,7 +52,7 @@ public class MobaDirectAIMethod implements MobaAIMethod // If reached the goal else if (UtilMath.offsetSquared(entityLocation, goal) < 0.5) { - entityLocation = goal; + return false; } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java index dd815d1df..5529afd8b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -89,7 +89,7 @@ public class SkillPulseHeal extends HeroSkill for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !Recharge.Instance.use(player, GetName(), 10000, false, false)) + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !Recharge.Instance.use(player, GetName(), 5000, false, false)) { continue; } @@ -106,14 +106,14 @@ public class SkillPulseHeal extends HeroSkill continue; } - entity.setHealth(Math.min(entity.getHealth() + 2, entity.getMaxHealth())); + entity.setHealth(Math.min(entity.getHealth() + 4, entity.getMaxHealth())); } displayPulse(location, false); } else { - player.setHealth(Math.min(player.getHealth() + 2, player.getMaxHealth())); + player.setHealth(Math.min(player.getHealth() + 4, player.getMaxHealth())); displayPulse(location, true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index ef24c59c9..35f94cafa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.dana; +import mineplex.core.common.events.EntityVelocityChangeEvent; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -184,6 +185,18 @@ public class SkillRally extends HeroSkill } } + @EventHandler + public void velocityChange(EntityVelocityChangeEvent event) + { + for (RallyData data : _data) + { + if (!data.Landed && data.Owner.equals(event.getEntity())) + { + event.setCancelled(true); + } + } + } + private Pattern getPattern(GameTeam team) { return team.GetColor() == ChatColor.RED ? new Pattern(DyeColor.WHITE, PatternType.CROSS) : new Pattern(DyeColor.WHITE, PatternType.CIRCLE_MIDDLE); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java index f40f3db4e..656679db5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -36,6 +36,6 @@ public class HeroDevon extends HeroKit super(manager, "Devon", DESCRIPTION, PERKS, IN_HAND, MobaRole.HUNTER); setAmmo(AMMO, 3000); - setMaxAmmo(3); + setMaxAmmo(1); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 2f8d54223..76fe165fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -2,7 +2,6 @@ package nautilus.game.arcade.game.games.moba.kit.devon; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; @@ -13,7 +12,6 @@ import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityShootBowEvent; @@ -104,15 +102,12 @@ public class SkillInfinity extends HeroSkill Player player = entry.getValue(); GameTeam team = Manager.GetGame().GetTeam(player); - for (LivingEntity nearby : UtilEnt.getInRadius(entity.getLocation(), 6).keySet()) + for (Player nearby : UtilPlayer.getInRadius(entity.getLocation(), 6).keySet()) { - if (nearby instanceof Player) + // If the target is on the same team + if (UtilPlayer.isSpectator(player) || team.equals(Manager.GetGame().GetTeam(nearby))) { - // If the target is on the same team - if (UtilPlayer.isSpectator(player) || team.equals(Manager.GetGame().GetTeam((Player) nearby))) - { - continue; - } + continue; } UtilAction.velocity(entity, UtilAlg.getTrajectory(entity.getLocation(), nearby.getLocation().add(0, 1.5, 0))); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java index 9dcd7895c..d94b7d9ec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java @@ -6,29 +6,32 @@ import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.projectiles.ProjectileSource; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; -public class SkillTNTArrows extends HeroSkill implements IThrown +public class SkillTNTArrows extends HeroSkill { private static final String[] DESCRIPTION = { @@ -37,7 +40,8 @@ public class SkillTNTArrows extends HeroSkill implements IThrown }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.TNT); - private final Map _arrows = new HashMap<>(); + private final Map _playerArrows = new HashMap<>(); + private final Set _arrows = new HashSet<>(); public SkillTNTArrows(int slot) { @@ -56,7 +60,7 @@ public class SkillTNTArrows extends HeroSkill implements IThrown Player player = event.getPlayer(); - _arrows.put(player, 3); + _playerArrows.put(player, 3); player.getItemInHand().addEnchantment(UtilInv.getDullEnchantment(), 1); player.getItemInHand().setAmount(3); } @@ -71,87 +75,85 @@ public class SkillTNTArrows extends HeroSkill implements IThrown Player player = (Player) event.getEntity(); - if (!hasPerk(player) || !_arrows.containsKey(player)) + if (!hasPerk(player) || !_playerArrows.containsKey(player)) { return; } ItemStack itemStack = player.getInventory().getItem(getSlot()); - int arrows = _arrows.get(player); + int arrows = _playerArrows.get(player); if (arrows == 1) { - _arrows.remove(player); + _playerArrows.remove(player); useSkill(player); } else { arrows--; - _arrows.put(player, arrows); + _playerArrows.put(player, arrows); itemStack.setAmount(arrows); } - Manager.GetProjectile().AddThrow(event.getProjectile(), player, this, -1, true, true, true, false, 0); + _arrows.add((Arrow) event.getProjectile()); } @EventHandler - public void playerDeath(CombatDeathEvent event) + public void projectileHit(ProjectileHitEvent event) { - _arrows.remove(event.GetEvent().getEntity()); - } + ProjectileSource source = event.getEntity().getShooter(); - @EventHandler - public void playerQuit(PlayerQuitEvent event) - { - _arrows.remove(event.getPlayer()); - } + if (!(source instanceof Player)) + { + return; + } - @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) - { - LivingEntity thrower = data.getThrower(); - Location location = data.getThrown().getLocation(); + Player player = (Player) source; + Projectile projectile = event.getEntity(); + + if (!_arrows.contains(projectile)) + { + return; + } + + _arrows.remove(projectile); + + Location location = projectile.getLocation(); location.getWorld().playSound(location, Sound.EXPLODE, 1, 0.9F); UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); double damage = 10; // Scale damage with the damage on the player's bow - if (thrower instanceof Player) - { - Player throwerPlayer = (Player) thrower; - ItemStack itemStack = throwerPlayer.getInventory().getItem(0); + ItemStack itemStack = player.getInventory().getItem(0); - // Player has a bow - if (itemStack != null && itemStack.getType() == Material.BOW) - { - damage += damage * itemStack.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) * 0.25; - } + // Player has a bow + if (itemStack != null && itemStack.getType() == Material.BOW) + { + damage += damage * itemStack.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) * 0.25; } for (Entry entry : UtilEnt.getInRadius(location, 5).entrySet()) { - if (entry.getKey().equals(thrower)) + if (entry.getKey().equals(player)) { continue; } - Manager.GetDamage().NewDamageEvent(entry.getKey(), thrower, null, DamageCause.BLOCK_EXPLOSION, (entry.getValue() + 0.5) * damage, true, true, false, UtilEnt.getName(data.getThrower()), GetName()); + Manager.GetDamage().NewDamageEvent(entry.getKey(), player, null, DamageCause.BLOCK_EXPLOSION, (entry.getValue() + 0.5) * damage, true, true, false, UtilEnt.getName(player), GetName()); } - - data.getThrown().remove(); } - @Override - public void Idle(ProjectileUser data) + @EventHandler + public void playerDeath(CombatDeathEvent event) { - + _playerArrows.remove(event.GetEvent().getEntity()); } - @Override - public void Expire(ProjectileUser data) + @EventHandler + public void playerQuit(PlayerQuitEvent event) { - + _playerArrows.remove(event.getPlayer()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java index 539768e27..1cec7ac34 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java @@ -17,7 +17,7 @@ public class HeroHattori extends HeroKit }; private static final Perk[] PERKS = { - new PerkDoubleJump("Double Jump", 1, 1, true), + new PerkDoubleJump("Double Jump", 1, 1, true, 3000, true), new SkillSnowball(0), new SkillSword(1), new SkillNinjaDash(2), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index b13e7d433..ac8678ca8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.minion; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilTime; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -10,15 +11,19 @@ public class Minion { private static final int HEALTH = 10; + private static final int DAMAGE_RATE = 500; private final LivingEntity _entity; private Location _target; private int _targetIndex; + private long _lastDamage; + public Minion(Location spawn, Class clazz) { _target = spawn; + damage(); LivingEntity entity = spawn.getWorld().spawn(spawn, clazz); _entity = entity; @@ -69,4 +74,14 @@ public class Minion { return _targetIndex; } + + public boolean canDamage() + { + return UtilTime.elapsed(_lastDamage, DAMAGE_RATE); + } + + public void damage() + { + _lastDamage = System.currentTimeMillis(); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index bc89371f3..6d9e12fa3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.moba.minion; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -14,7 +15,6 @@ import nautilus.game.arcade.game.games.moba.boss.MobaBoss; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.util.MobaConstants; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -34,11 +34,11 @@ import java.util.List; public class MinionWave implements Listener { - private static final int MAX_MINIONS_PER_WAVE = 1; - private static final int TOO_CLOSE_SQUARED = 12; - private static final int MINION_TOO_CLOSE_SQUARED = 4; - private static final int DAMAGE_RANGE_SQUARED = 15; - private static final int DAMAGE_AMOUNT = 4; + private static final int MAX_MINIONS_PER_WAVE = 6; + private static final int TOO_CLOSE_SQUARED = 9; + private static final int MINION_TOO_CLOSE_SQUARED = 16; + private static final int DAMAGE_RANGE_SQUARED = 16; + private static final double DAMAGE_AMOUNT = 0.2; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private final Moba _host; @@ -73,7 +73,7 @@ public class MinionWave implements Listener cancel(); } } - }, 20, 20); + }, 15, 15); } private boolean spawn() @@ -119,10 +119,10 @@ public class MinionWave implements Listener minion.setTarget(target); // Too close - if (UtilMath.offsetSquared(entity.getLocation(), target) < MINION_TOO_CLOSE_SQUARED) + if (UtilMath.offsetSquared(entity.getLocation(), target) < MINION_TOO_CLOSE_SQUARED && minionTarget.canDamage()) { - Bukkit.broadcastMessage("Attack"); - _host.getArcadeManager().GetDamage().NewDamageEvent(minion.getEntity(), minionTarget.getEntity(), null, DamageCause.CUSTOM, DAMAGE_AMOUNT, false, false, false, UtilEnt.getName(minion.getEntity()), "Minion"); + minionTarget.damage(); + _host.getArcadeManager().GetDamage().NewDamageEvent(minion.getEntity(), minionTarget.getEntity(), null, DamageCause.CUSTOM, DAMAGE_AMOUNT, false, true, false, UtilEnt.getName(minion.getEntity()), "Minion"); continue; } } @@ -138,7 +138,7 @@ public class MinionWave implements Listener // Too close if (UtilMath.offsetSquared(entity.getLocation(), target) < TOO_CLOSE_SQUARED) { - Bukkit.broadcastMessage("Too close"); + //Bukkit.broadcastMessage("Too close"); continue; } } @@ -149,13 +149,13 @@ public class MinionWave implements Listener if (newTarget == _path.size()) { - Bukkit.broadcastMessage("Done"); + //Bukkit.broadcastMessage("Done"); continue; } minion.setTargetIndex(newTarget); minion.setTarget(_path.get(newTarget)); - Bukkit.broadcastMessage("Advance target " + newTarget); + //Bukkit.broadcastMessage("Advance target " + newTarget); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java index 94e9347e3..559fdd4dd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java @@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit; public class PrepareInformation implements Listener { - private static final long MESSAGE_TIME = TimeUnit.SECONDS.toMillis(5); + private static final long MESSAGE_TIME = TimeUnit.SECONDS.toMillis(3); private static final int MESSAGE_TIME_TICKS = (int) (MESSAGE_TIME / 50D + 5); private final Moba _host; @@ -46,7 +46,7 @@ public class PrepareInformation implements Listener } // Modify the prepare time - _host.PrepareTime = longestDescription * 1000 + 1000; + _host.PrepareTime = longestDescription * MESSAGE_TIME + 1000; UtilServer.RegisterEvents(this); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java index 70fe02415..8534f1b32 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java @@ -46,7 +46,7 @@ public class CapturePointManager implements Listener @EventHandler public void update(UpdateEvent event) { - if (event.getType() != UpdateType.SEC) + if (event.getType() != UpdateType.SEC || !_host.IsLive()) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 7cd2e69f1..92ff670ac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -31,8 +31,8 @@ import java.util.Map.Entry; public class TowerManager implements Listener { - private static final int FIRST_TOWER_HEALTH = 250; - private static final int SECOND_TOWER_HEALTH = 500; + private static final int FIRST_TOWER_HEALTH = 500; + private static final int SECOND_TOWER_HEALTH = 1000; private final Moba _host; From 36733e9918087be57ed30d29ec80e1b5d3b238a1 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 26 May 2017 18:37:35 +0100 Subject: [PATCH 049/283] Fix gametype imports --- .../src/mineplex/core/game/GameDisplay.java | 2 ++ .../src/nautilus/game/arcade/GameType.java | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 159124422..405178375 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -102,6 +102,8 @@ public enum GameDisplay StrikeGames("Strike Games", Material.DIAMOND_LEGGINGS, (byte) 0, GameCategory.SURVIVAL, 66, false), + AlienInvasion("Alien Invasion", Material.ENDER_STONE, (byte) 0, GameCategory.EVENT, 69, false), + MOBA("Heroes of the Craft", Material.SKULL_ITEM, (byte)1, GameCategory.CLASSICS, 70, true), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999, false), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index d24483811..ac4f37774 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -1,14 +1,11 @@ package nautilus.game.arcade; -import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.smash.SuperSmashTraining; -import org.bukkit.Material; - import mineplex.core.common.MinecraftVersion; import mineplex.core.common.Pair; import mineplex.core.game.GameCategory; import mineplex.core.game.GameDisplay; import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.alieninvasion.AlienInvasion; import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.barbarians.Barbarians; import nautilus.game.arcade.game.games.basketball.Basketball; @@ -65,6 +62,7 @@ import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.game.games.minestrike.Minestrike; import nautilus.game.arcade.game.games.minestrike.modes.SuperPaintstrike; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.monsterleague.MonsterLeague; import nautilus.game.arcade.game.games.monstermaze.MonsterMaze; import nautilus.game.arcade.game.games.oldmineware.OldMineWare; @@ -93,6 +91,7 @@ import nautilus.game.arcade.game.games.skywars.modes.SkySmash; import nautilus.game.arcade.game.games.skywars.modes.UHCSkywars; import nautilus.game.arcade.game.games.smash.SoloSuperSmash; import nautilus.game.arcade.game.games.smash.SuperSmashDominate; +import nautilus.game.arcade.game.games.smash.SuperSmashTraining; import nautilus.game.arcade.game.games.smash.TeamSuperSmash; import nautilus.game.arcade.game.games.smash.modes.RandomKitSSM; import nautilus.game.arcade.game.games.snake.Snake; @@ -124,6 +123,7 @@ import nautilus.game.arcade.game.games.valentines.Valentines; import nautilus.game.arcade.game.games.wither.WitherGame; import nautilus.game.arcade.game.games.wizards.Wizards; import nautilus.game.arcade.game.games.zombiesurvival.ZombieSurvival; +import org.bukkit.Material; public enum GameType { @@ -230,6 +230,8 @@ public enum GameType Valentines(Valentines.class, GameDisplay.Valentines), + AlienInvasion(AlienInvasion.class, GameDisplay.AlienInvasion), + MOBA(Moba.class, GameDisplay.MOBA), Event(EventGame.class, GameDisplay.Event, new GameType[]{ From b9ad85dd1ec0b1807b9366e7aa92139c2ebbfcb0 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 27 May 2017 18:19:14 +0100 Subject: [PATCH 050/283] Pumpkin King boss --- .../arcade/game/games/moba/ai/MobaAI.java | 2 +- .../games/moba/boss/pumpkin/PumpkinBoss.java | 78 +++++++++++++++++++ .../moba/boss/pumpkin/PumpkinBossAI.java | 22 ++++++ 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 712b31aa9..199273682 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -84,7 +84,7 @@ public class MobaAI return _target; } - private String getBoundaryKey() + public String getBoundaryKey() { return _owner.GetColor() == ChatColor.RED ? "ORANGE" : "LIGHT_BLUE"; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java new file mode 100644 index 000000000..42ae0099c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -0,0 +1,78 @@ +package nautilus.game.arcade.game.games.moba.boss.pumpkin; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; +import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; + +import java.util.concurrent.TimeUnit; + +public class PumpkinBoss extends MobaBoss +{ + + private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(10); + private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); + private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); + + private MobaAI _ai; + + public PumpkinBoss(Moba host, Location location) + { + super(host, location, RESPAWN_TIME); + } + + @Override + public void setup() + { + // Override this so that the entity isn't spawned as soon as the game starts. + UtilServer.RegisterEvents(this); + } + + @Override + public LivingEntity spawnEntity() + { + Skeleton skeleton = UtilVariant.spawnWitherSkeleton(_location); + + skeleton.setCustomName(C.cDRedB + "Pumpkin King"); + skeleton.setCustomNameVisible(true); + + skeleton.getWorld().strikeLightningEffect(skeleton.getLocation()); + + UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10); + _host.Announce("The Pumpkin King Has Awoken!", false); + + return skeleton; + } + + @Override + public MobaAI getAi() + { + if (_ai == null) + { + _ai = new PumpkinBossAI(_host, _entity, _location, AI_METHOD); + } + + return _ai; + } + + @EventHandler + public void updateSpawn(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || !_host.IsLive() || !UtilTime.elapsed(_host.GetStateTime(), SPAWN_TIME)) + { + return; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java new file mode 100644 index 000000000..6237de968 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java @@ -0,0 +1,22 @@ +package nautilus.game.arcade.game.games.moba.boss.pumpkin; + +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; + +public class PumpkinBossAI extends MobaAI +{ + + public PumpkinBossAI(Moba host, LivingEntity entity, Location home, MobaAIMethod aiMethod) + { + super(host, null, entity, home, aiMethod); + } + + @Override + public String getBoundaryKey() + { + return "GRAY"; + } +} From 9e9bfe79de1da9d511415e492e7b6faf80c2f0df Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 28 May 2017 16:27:54 +0100 Subject: [PATCH 051/283] Pumpkin king boss --- .../arcade/game/games/moba/MobaPlayer.java | 11 ----------- .../arcade/game/games/moba/ai/MobaAI.java | 2 +- .../moba/ai/goal/MobaDirectAIMethod.java | 2 +- .../game/games/moba/boss/BossManager.java | 8 ++++++++ .../arcade/game/games/moba/boss/MobaBoss.java | 4 ++++ .../games/moba/boss/pumpkin/PumpkinBoss.java | 14 +++++++++++--- .../game/games/moba/gold/GoldManager.java | 12 ------------ .../arcade/game/games/moba/minion/Minion.java | 15 --------------- .../game/games/moba/minion/MinionWave.java | 19 ++++++++++--------- .../games/moba/structure/tower/Tower.java | 2 +- .../moba/structure/tower/TowerManager.java | 6 +++++- 11 files changed, 41 insertions(+), 54 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java index a085b8eaa..29d7083ed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java @@ -9,7 +9,6 @@ public class MobaPlayer private final Player _player; private MobaRole _role; private HeroKit _kit; - private int _gold; public MobaPlayer(Player player) { @@ -40,14 +39,4 @@ public class MobaPlayer { return _kit; } - - public void setGold(int gold) - { - _gold = gold; - } - - public int getGold() - { - return _gold; - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 199273682..16482e005 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -13,7 +13,7 @@ import org.bukkit.entity.LivingEntity; public class MobaAI { - private static final int TARGET_RANGE = 11; + private static final int TARGET_RANGE = 15; private static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; private final Moba _host; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index 1bfe6a4b1..4ceb43e6b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -50,7 +50,7 @@ public class MobaDirectAIMethod implements MobaAIMethod entityLocation.setYaw(entityYaw); } // If reached the goal - else if (UtilMath.offsetSquared(entityLocation, goal) < 0.5) + else if (UtilMath.offsetSquared(entityLocation, goal) < 4) { return false; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java index a7b1be645..156271af5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -4,6 +4,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.boss.pumpkin.PumpkinBoss; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.world.WorldData; import org.bukkit.event.EventHandler; @@ -20,6 +21,7 @@ public class BossManager implements Listener private final Moba _host; private Map _teamBosses; + private PumpkinBoss _pumpkinBoss; public BossManager(Moba host) { @@ -42,6 +44,10 @@ public class BossManager implements Listener _teamBosses.put(team, boss); } + // Pumpkin King + _pumpkinBoss = new PumpkinBoss(_host, worldData.GetDataLocs("BLACK").get(0)); + _pumpkinBoss.setup(); + _host.CreatureAllowOverride = false; } @@ -65,6 +71,7 @@ public class BossManager implements Listener } _teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup()); + _pumpkinBoss.cleanup(); } public WitherBoss getWitherBoss(GameTeam team) @@ -77,6 +84,7 @@ public class BossManager implements Listener List bosses = new ArrayList<>(); bosses.addAll(_teamBosses.values()); + bosses.add(_pumpkinBoss); return bosses; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index a429a6f63..2335509ca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -6,6 +6,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; @@ -59,8 +60,11 @@ public abstract class MobaBoss implements Listener @EventHandler public void entityDeath(EntityDeathEvent event) { + Bukkit.broadcastMessage(event.getEventName()); + if (_entity != null && _entity.equals(event.getEntity())) { + Bukkit.broadcastMessage(""); _entity = null; _lastDeath = System.currentTimeMillis(); getAi().setEntity(null); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 42ae0099c..84038e2f7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -22,11 +22,12 @@ import java.util.concurrent.TimeUnit; public class PumpkinBoss extends MobaBoss { - private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(10); + private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(1); private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private MobaAI _ai; + private boolean _initialSpawn; public PumpkinBoss(Moba host, Location location) { @@ -43,6 +44,8 @@ public class PumpkinBoss extends MobaBoss @Override public LivingEntity spawnEntity() { + _host.CreatureAllowOverride = true; + Skeleton skeleton = UtilVariant.spawnWitherSkeleton(_location); skeleton.setCustomName(C.cDRedB + "Pumpkin King"); @@ -51,7 +54,9 @@ public class PumpkinBoss extends MobaBoss skeleton.getWorld().strikeLightningEffect(skeleton.getLocation()); UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10); - _host.Announce("The Pumpkin King Has Awoken!", false); + _host.Announce(C.cRedB + "The Pumpkin King Has Awoken!", false); + + _host.CreatureAllowOverride = false; return skeleton; } @@ -70,9 +75,12 @@ public class PumpkinBoss extends MobaBoss @EventHandler public void updateSpawn(UpdateEvent event) { - if (event.getType() != UpdateType.SEC || !_host.IsLive() || !UtilTime.elapsed(_host.GetStateTime(), SPAWN_TIME)) + if (event.getType() != UpdateType.SEC || !_host.IsLive() || _initialSpawn || !UtilTime.elapsed(_host.GetStateTime(), SPAWN_TIME)) { return; } + + _initialSpawn = true; + spawnEntity(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index e4fedc4a0..7cf95af29 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -132,16 +132,4 @@ public class GoldManager implements Listener return _playerGold.get(player) >= amount; } - /** - * Returns a map binding the player to the amount of gold they currently have. - * - * @return An unmodifiable version of the internal map used. If you want to edit the player's gold consider using the other methods within this class. - */ - public Map getPlayerGoldMap() - { - return Collections.unmodifiableMap(_playerGold); - } - - - } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index ac8678ca8..b13e7d433 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -1,7 +1,6 @@ package nautilus.game.arcade.game.games.moba.minion; import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilTime; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -11,19 +10,15 @@ public class Minion { private static final int HEALTH = 10; - private static final int DAMAGE_RATE = 500; private final LivingEntity _entity; private Location _target; private int _targetIndex; - private long _lastDamage; - public Minion(Location spawn, Class clazz) { _target = spawn; - damage(); LivingEntity entity = spawn.getWorld().spawn(spawn, clazz); _entity = entity; @@ -74,14 +69,4 @@ public class Minion { return _targetIndex; } - - public boolean canDamage() - { - return UtilTime.elapsed(_lastDamage, DAMAGE_RATE); - } - - public void damage() - { - _lastDamage = System.currentTimeMillis(); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 6d9e12fa3..07b9106e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -117,14 +117,6 @@ public class MinionWave implements Listener { target = minionTarget.getEntity().getLocation(); minion.setTarget(target); - - // Too close - if (UtilMath.offsetSquared(entity.getLocation(), target) < MINION_TOO_CLOSE_SQUARED && minionTarget.canDamage()) - { - minionTarget.damage(); - _host.getArcadeManager().GetDamage().NewDamageEvent(minion.getEntity(), minionTarget.getEntity(), null, DamageCause.CUSTOM, DAMAGE_AMOUNT, false, true, false, UtilEnt.getName(minion.getEntity()), "Minion"); - continue; - } } else if (witherTarget != null) { @@ -288,7 +280,7 @@ public class MinionWave implements Listener continue; } - + _host.getArcadeManager().GetDamage().NewDamageEvent(otherMinion.getEntity(), minion.getEntity(), null, DamageCause.CUSTOM, DAMAGE_AMOUNT, false, true, false, UtilEnt.getName(minion.getEntity()), "Minion"); } } } @@ -393,6 +385,15 @@ public class MinionWave implements Listener } } + @EventHandler + public void suffocation(CustomDamageEvent event) + { + if (isMinion(event.GetDamageeEntity()) && event.GetCause() == DamageCause.SUFFOCATION) + { + event.SetCancelled("Minion Suffocation"); + } + } + @EventHandler(priority = EventPriority.HIGHEST) public void entityDeath(EntityDeathEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 83cddf9d0..5d50cc6a0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -88,7 +88,7 @@ public class Tower } else { - double dist = UtilMath.offsetSquared(_location, _target.getLocation()); + double dist = UtilMath.offsetSquared(_crystal.getLocation(), _target.getEyeLocation()); if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target) || _target.isDead() || !_target.isValid()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 92ff670ac..9dab1ca0d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -162,8 +162,12 @@ public class TowerManager implements Listener { player = (Player) source; + Location entityLocation = event.getEntity().getLocation(); + Location playerLocation = player.getLocation(); + playerLocation.setY(entityLocation.getY()); + // TODO TEMP - if (UtilMath.offsetSquared(player.getLocation(), event.getEntity().getLocation()) > Tower.TARGET_RANGE_SQUARED) + if (UtilMath.offsetSquared(playerLocation, entityLocation) > Tower.TARGET_RANGE_SQUARED) { return; } From c3a80ed0cb0cba23a26229070f4e0a540fbfd6f4 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 29 May 2017 12:40:18 +0100 Subject: [PATCH 052/283] Fix pumpkin king's death not being logged properly --- .../game/arcade/game/games/moba/Moba.java | 5 + .../arcade/game/games/moba/ai/MobaAI.java | 10 +- .../moba/ai/goal/MobaDirectAIMethod.java | 2 +- .../arcade/game/games/moba/boss/MobaBoss.java | 10 +- .../games/moba/boss/pumpkin/PumpkinBoss.java | 196 +++++++++++++++++- .../moba/boss/pumpkin/PumpkinBossAI.java | 5 +- .../games/moba/boss/wither/WitherBoss.java | 4 +- .../arcade/game/games/moba/minion/Minion.java | 2 + .../games/moba/structure/tower/Tower.java | 2 +- .../arcade/game/games/moba/util/MobaUtil.java | 5 +- 10 files changed, 224 insertions(+), 17 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index f409ea48f..e5bedf6cb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -285,6 +285,11 @@ public class Moba extends TeamGame } scoreboard.writeNewLine(); + + scoreboard.write(C.cYellowB + "Time"); + scoreboard.write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime())); + + scoreboard.writeNewLine(); } private void writeEnd(Player player, GameScoreboard scoreboard) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 16482e005..0bd0540ce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -18,6 +18,8 @@ public class MobaAI private final Moba _host; private final GameTeam _owner; + private final float _speedTarget; + private final float _speedHome; private LivingEntity _entity; private LivingEntity _target; @@ -25,10 +27,12 @@ public class MobaAI private MobaAIMethod _aiMethod; - public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, MobaAIMethod aiMethod) + public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod) { _host = host; _owner = owner; + _speedTarget = speedTarget; + _speedHome = speedHome; _entity = entity; _home = home; _aiMethod = aiMethod; @@ -65,13 +69,13 @@ public class MobaAI if (_target != null) { - _aiMethod.updateMovement(_entity, _target.getLocation(), 5F); + _aiMethod.updateMovement(_entity, _target.getLocation(), _speedTarget); } } private void returnToHome() { - _aiMethod.updateMovement(_entity, _home, 7F); + _aiMethod.updateMovement(_entity, _home, _speedTarget); } public void setEntity(LivingEntity entity) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index 4ceb43e6b..69ebbaa4c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -9,7 +9,7 @@ import org.bukkit.util.Vector; public class MobaDirectAIMethod implements MobaAIMethod { - private static final float YAW_SNAP_LIMIT = 20F; + private static final float YAW_SNAP_LIMIT = 30F; @Override public boolean updateMovement(LivingEntity entity, Location goal, float speed) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index 2335509ca..4158ed179 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -4,9 +4,9 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.MobaAI; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; @@ -60,11 +60,10 @@ public abstract class MobaBoss implements Listener @EventHandler public void entityDeath(EntityDeathEvent event) { - Bukkit.broadcastMessage(event.getEventName()); - if (_entity != null && _entity.equals(event.getEntity())) { - Bukkit.broadcastMessage(""); + event.getDrops().clear(); + event.setDroppedExp(0); _entity = null; _lastDeath = System.currentTimeMillis(); getAi().setEntity(null); @@ -74,13 +73,14 @@ public abstract class MobaBoss implements Listener @EventHandler public void updateRespawn(UpdateEvent event) { - if (event.getType() != UpdateType.SEC || _lastDeath == -1 || UtilTime.elapsed(_lastDeath, _respawnTime)) + if (event.getType() != UpdateType.SEC || _lastDeath == -1 || !UtilTime.elapsed(_lastDeath, _respawnTime)) { return; } _lastDeath = -1; _entity = spawnEntity(); + getAi().setEntity(_entity); } public abstract LivingEntity spawnEntity(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 84038e2f7..741b0b15b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -1,37 +1,82 @@ package nautilus.game.arcade.game.games.moba.boss.pumpkin; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +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.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilVariant; +import mineplex.minecraft.game.core.condition.ConditionFactory; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.MobaAI; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; +import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; +import java.util.HashSet; +import java.util.Map.Entry; +import java.util.Set; import java.util.concurrent.TimeUnit; public class PumpkinBoss extends MobaBoss { private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(1); - private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); + private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(1); private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); + private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN); + private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD); + private static final String DAMAGE_REASON = "Pumpkin King"; + private static final String CONDITION_REASON = DAMAGE_REASON + " Buff"; + private static final int CONDITION_LENGTH = (int) TimeUnit.MINUTES.toSeconds(3); + private static final int DAMAGE_RADIUS = 3; + private static final int DAMAGE_RANGE = 4; + private static final int DAMAGE_DIRECT = 10; + private static final int DAMAGE_DIRECT_RADIUS_SQUARED = 9; + private static final Material[] BLOCKS = { + Material.OBSIDIAN, + Material.NETHERRACK, + Material.NETHER_BRICK + }; private MobaAI _ai; private boolean _initialSpawn; + private final Set _changed; public PumpkinBoss(Moba host, Location location) { super(host, location, RESPAWN_TIME); + + _changed = new HashSet<>(); } @Override @@ -50,12 +95,36 @@ public class PumpkinBoss extends MobaBoss skeleton.setCustomName(C.cDRedB + "Pumpkin King"); skeleton.setCustomNameVisible(true); + skeleton.getEquipment().setHelmet(HELMET); + skeleton.getEquipment().setItemInHand(IN_HAND); + + UtilEnt.vegetate(skeleton); + UtilEnt.setFakeHead(skeleton, true); skeleton.getWorld().strikeLightningEffect(skeleton.getLocation()); UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10); _host.Announce(C.cRedB + "The Pumpkin King Has Awoken!", false); + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 0.4F); + } + + for (Entry entry : UtilBlock.getInRadius(skeleton.getLocation(), 20).entrySet()) + { + Block block = entry.getKey(); + double setChance = entry.getValue(); + + if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > setChance) + { + continue; + } + + _host.getArcadeManager().GetBlockRestore().add(block, BLOCKS[UtilMath.r(BLOCKS.length)].getId(), (byte) 0, Integer.MAX_VALUE); + _changed.add(block); + } + _host.CreatureAllowOverride = false; return skeleton; @@ -81,6 +150,129 @@ public class PumpkinBoss extends MobaBoss } _initialSpawn = true; - spawnEntity(); + _entity = spawnEntity(); + } + + @Override + public void cleanup() + { + super.cleanup(); + + for (Block block : _changed) + { + _host.getArcadeManager().GetBlockRestore().restore(block); + } + } + + @Override + @EventHandler + public void entityDeath(EntityDeathEvent event) + { + if (_entity == null || !event.getEntity().equals(_entity)) + { + return; + } + + Player player = _entity.getKiller(); + + if (player == null) + { + return; + } + + super.entityDeath(event); + + GameTeam team = _host.GetTeam(player); + + if (team == null) + { + return; + } + + giveBuffs(team); + + String base = C.mBody + "killed the " + C.cDRedB + "Pumpkin King"; + _host.Announce(team.GetFormattedName() + " " + base + C.mBody + "! They have been given buffs!", false); + UtilTextMiddle.display(team.GetFormattedName(), base, 10, 40, 10); + + for (Block block : _changed) + { + _host.getArcadeManager().GetBlockRestore().restore(block); + } + + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, event.getEntity().getEyeLocation(), 1, 1, 1, 0.1F, 3, ViewDist.LONG); + } + + @EventHandler + public void entityDamage(CustomDamageEvent event) + { + if (!event.GetDamageeEntity().equals(_entity) || event.GetCause() != DamageCause.SUFFOCATION) + { + return; + } + + event.SetCancelled("Pumpkin King Suffocation"); + } + + @EventHandler + public void updateDamage(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || _entity == null) + { + return; + } + + if (_ai.getTarget() != null && !UtilPlayer.isSpectator(_ai.getTarget()) && UtilMath.offsetSquared(_entity, _ai.getTarget()) < DAMAGE_DIRECT_RADIUS_SQUARED) + { + _host.getArcadeManager().GetDamage().NewDamageEvent(_ai.getTarget(), _entity, null, DamageCause.CUSTOM, DAMAGE_DIRECT, true, true, false, UtilEnt.getName(_entity), DAMAGE_REASON); + + // Send a fake hit packet + // Magic number 0 means swing item/attack + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(((CraftLivingEntity) _entity).getHandle(), 0); + + for (Player player : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + } + + for (LivingEntity entity : UtilEnt.getInRadius(_entity.getLocation(), DAMAGE_RADIUS).keySet()) + { + if (_entity.equals(entity)) + { + continue; + } + + _host.getArcadeManager().GetDamage().NewDamageEvent(entity, _entity, null, DamageCause.CUSTOM, DAMAGE_RANGE, false, true, false, UtilEnt.getName(entity), DAMAGE_REASON); + UtilAction.velocity(entity, UtilAlg.getTrajectory(_entity, entity).setY(1)); + UtilParticle.PlayParticleToAll(ParticleType.FLAME, entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 5, ViewDist.LONG); + } + } + + private void giveBuffs(GameTeam team) + { + ConditionFactory factory = _host.getArcadeManager().GetCondition().Factory(); + + for (Player player : team.GetPlayers(true)) + { + factory.Regen(CONDITION_REASON, player, null, CONDITION_LENGTH, 2, false, true, false); + factory.Strength(CONDITION_REASON, player, null, CONDITION_LENGTH, 1, false, true, false); + UtilParticle.PlayParticleToAll(ParticleType.LAVA, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG); + player.playSound(player.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F); + + // Magic number 4 means helmet + PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(HELMET)); + + for (Player other : Bukkit.getOnlinePlayers()) + { + // Don't send wearer their own data + if (other.equals(player)) + { + continue; + } + + UtilPlayer.sendPacket(other, packet); + } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java index 6237de968..66cc68a83 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java @@ -9,9 +9,12 @@ import org.bukkit.entity.LivingEntity; public class PumpkinBossAI extends MobaAI { + private static final float SPEED_TARGET = 12F; + private static final float SPEED_HOME = 16F; + public PumpkinBossAI(Moba host, LivingEntity entity, Location home, MobaAIMethod aiMethod) { - super(host, null, entity, home, aiMethod); + super(host, null, entity, home, SPEED_TARGET, SPEED_HOME, aiMethod); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 5e82dc48b..9d0ce78dd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -31,6 +31,8 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; public class WitherBoss extends MobaBoss { + private static final float SPEED_TARGET = 7F; + private static final float SPEED_HOME = 9F; private static final int INITIAL_HEALTH = 1750; private static final int FIRST_TOWER_HEALTH_REDUCTION = 100; private static final int SECOND_TOWER_HEALTH_REDUCTION = 250; @@ -71,7 +73,7 @@ public class WitherBoss extends MobaBoss { if (_ai == null) { - _ai = new MobaAI(_host, _team, _entity, _location, AI_METHOD); + _ai = new MobaAI(_host, _team, _entity, _location, SPEED_TARGET, SPEED_HOME, AI_METHOD); } return _ai; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index b13e7d433..decc4b408 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -10,6 +10,7 @@ public class Minion { private static final int HEALTH = 10; + private static final float HIT_BOX = 2F; private final LivingEntity _entity; @@ -32,6 +33,7 @@ public class Minion UtilEnt.vegetate(entity); UtilEnt.silence(entity, true); + UtilEnt.setBoundingBox(entity, HIT_BOX, HIT_BOX); entity.setCustomNameVisible(true); updateDisplay(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 5d50cc6a0..6d84e1a05 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -82,7 +82,7 @@ public class Tower { if (_target == null) { - LivingEntity target = MobaUtil.getBestEntityTarget(_host, _team, _stand, _location, TARGET_RANGE, false); + LivingEntity target = MobaUtil.getBestEntityTarget(_host, _team, _stand, _crystal.getLocation(), TARGET_RANGE, false); _target = target; setLaserTarget(target); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 94478a893..bb1daef50 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -45,7 +45,7 @@ public class MobaUtil // Make players more desirable if (entity instanceof Player) { - if (owner.equals(host.GetTeam((Player) entity)) || UtilPlayer.isSpectator(entity)) + if (owner.equals(host.GetTeam((Player) entity))) { continue; } @@ -127,7 +127,7 @@ public class MobaUtil // Check for same team players if (entity instanceof Player) { - if (owner.equals(host.GetTeam((Player) entity)) || UtilPlayer.isSpectator(entity)) + if (owner.equals(host.GetTeam((Player) entity))) { continue; } @@ -143,7 +143,6 @@ public class MobaUtil if (highest != null) { - Bukkit.broadcastMessage("Found " + highest.getCustomName()); return highest; } From f1bad41e89d1c3d3a5ba537e9e11f2be9ad0da11 Mon Sep 17 00:00:00 2001 From: cnr Date: Mon, 29 May 2017 22:44:54 -0500 Subject: [PATCH 053/283] Revert "Enable double XP + gems + shards for the weekend" This reverts commit aa271a1bd36087f37dd1161c54ce0fe2579052ad. --- .../src/nautilus/game/arcade/game/Game.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 5ee697db6..80329fe3f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -256,7 +256,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public long PrepareTime = 9000; public boolean PlaySoundGameStart = true; - public double XpMult = 2; + public double XpMult = 1; public boolean SpeedMeasurement = false; @@ -278,7 +278,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed // Gems public boolean CrownsEnabled = false; - public double GemMultiplier = 2; + public double GemMultiplier = 1; public boolean GemHunterEnabled = true; public boolean GemBoosterEnabled = true; public boolean GemDoubleEnabled = true; From 1a59c050d313962f3b3907422be38773c3b2955c Mon Sep 17 00:00:00 2001 From: cnr Date: Mon, 29 May 2017 22:45:54 -0500 Subject: [PATCH 054/283] Disable Alien Invasion event --- Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 13f2ee2b0..a4b0a0b88 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -1,6 +1,5 @@ package mineplex.hub; -import mineplex.hub.modules.AlienInvasion; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -248,7 +247,6 @@ public class Hub extends JavaPlugin implements IRelation require(AprilFoolsTreasureHunt.class); } require(TwitchIntegrationFix.class); - require(AlienInvasion.class); } @Override From 2895397aecc475d299f5cd9171e05bb6f1167eeb Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Wed, 24 May 2017 15:13:50 -0400 Subject: [PATCH 055/283] Implement CMA rank --- Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 8d5cd7db5..56c5a5e63 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -20,6 +20,7 @@ public enum Rank CMOD("C.Mod", "cmod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), EVENT_MODERATOR("Sr.Mod", "srmod_event", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 44, DyeColor.ORANGE), SNR_MODERATOR("Sr.Mod", "srmod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 44, DyeColor.ORANGE), + CMA("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), HELPER("Trainee", "train", ChatColor.GOLD, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 24, DyeColor.ORANGE), MAPLEAD("MapLead", "mapl", ChatColor.BLUE, "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders.", 25, DyeColor.BLUE), From cd8e805435543f8c3951333c7a3bde8d844d31e6 Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Wed, 24 May 2017 15:30:18 -0400 Subject: [PATCH 056/283] Give CMA access to unfreeze --- .../game/clans/clans/ban/commands/UnfreezeCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java index 7114d0e79..13e4aa098 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java @@ -16,7 +16,7 @@ public class UnfreezeCommand extends CommandBase { public UnfreezeCommand(ClansBanManager plugin) { - super(plugin, Rank.CMOD, "unfreeze"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "unfreeze"); } @Override @@ -41,4 +41,4 @@ public class UnfreezeCommand extends CommandBase Plugin.unfreeze(target, caller); } } -} \ No newline at end of file +} From 1adb4b8239eae251a7c64b9e13ac66b42446408c Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Wed, 24 May 2017 15:31:30 -0400 Subject: [PATCH 057/283] Give cma access to freeze --- .../mineplex/game/clans/clans/ban/commands/FreezeCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java index fedad6275..1a75c70d7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java @@ -16,7 +16,7 @@ public class FreezeCommand extends CommandBase { public FreezeCommand(ClansBanManager plugin) { - super(plugin, Rank.CMOD, "freeze"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "freeze"); } @Override @@ -41,4 +41,4 @@ public class FreezeCommand extends CommandBase Plugin.freeze(target, caller); } } -} \ No newline at end of file +} From 57f2f7b68679dba3099e103687f518828f3e683a Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Wed, 24 May 2017 15:32:29 -0400 Subject: [PATCH 058/283] Give cma access to clans punishments --- .../mineplex/game/clans/clans/ban/commands/ClansBanCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java index 6cca5d188..3275072c5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java @@ -13,7 +13,7 @@ public class ClansBanCommand extends CommandBase { public ClansBanCommand(ClansBanManager plugin) { - super(plugin, Rank.CMOD, "cbans", "cb", "cban", "cp", "cpunish", "clanspunish", "clanpunish"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "cbans", "cb", "cban", "cp", "cpunish", "clanspunish", "clanpunish"); } @Override From f793539cc4125e032e004b93848c250cc163400c Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Wed, 24 May 2017 15:37:59 -0400 Subject: [PATCH 059/283] Allow cma to see freeze/unfreeze information --- .../mineplex/game/clans/clans/ban/ClansBanManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java index 56c12bdec..8b3d18877 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java @@ -117,7 +117,7 @@ public class ClansBanManager extends MiniPlugin event.getPlayer().removePotionEffect(PotionEffectType.JUMP); for (Player staff : UtilServer.GetPlayers()) { - if (_clientManager.hasRank(staff, Rank.CMOD)) + if (_clientManager.Get(staff).GetRank().has(null, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false)) { UtilPlayer.message(staff, F.main(getName(), F.elem(event.getPlayer().getName()) + " has logged out while frozen!")); } @@ -266,7 +266,7 @@ public class ClansBanManager extends MiniPlugin player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, -10)); for (Player alert : UtilServer.GetPlayers()) { - if (_clientManager.hasRank(alert, Rank.CMOD)) + if (_clientManager.Get(staff).GetRank().has(null, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false)) { UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been frozen by " + F.elem(staff.getName()) + "!")); } @@ -287,7 +287,7 @@ public class ClansBanManager extends MiniPlugin player.removePotionEffect(PotionEffectType.JUMP); for (Player alert : UtilServer.GetPlayers()) { - if (_clientManager.hasRank(alert, Rank.CMOD)) + if (_clientManager.Get(staff).GetRank().has(null, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false)) { UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been unfrozen by " + F.elem(staff.getName()) + "!")); continue; @@ -312,4 +312,4 @@ public class ClansBanManager extends MiniPlugin callback.run(target); } -} \ No newline at end of file +} From e50198271241cb7d30bf791ed1dadd9f72f2ba7a Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Wed, 24 May 2017 18:40:45 -0400 Subject: [PATCH 060/283] Update cma scoreboard id --- Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 56c5a5e63..6f4602a11 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -20,7 +20,7 @@ public enum Rank CMOD("C.Mod", "cmod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), EVENT_MODERATOR("Sr.Mod", "srmod_event", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 44, DyeColor.ORANGE), SNR_MODERATOR("Sr.Mod", "srmod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 44, DyeColor.ORANGE), - CMA("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), + CMA("Mod", "cma", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), HELPER("Trainee", "train", ChatColor.GOLD, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 24, DyeColor.ORANGE), MAPLEAD("MapLead", "mapl", ChatColor.BLUE, "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders.", 25, DyeColor.BLUE), From b9af3a8dfb9156cf4b07588fcc54a3efc859f8fe Mon Sep 17 00:00:00 2001 From: cnr Date: Mon, 29 May 2017 22:49:01 -0500 Subject: [PATCH 061/283] Sort CMA in the tab list next to Mod --- Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 6f4602a11..43fdbacdc 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -20,7 +20,7 @@ public enum Rank CMOD("C.Mod", "cmod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), EVENT_MODERATOR("Sr.Mod", "srmod_event", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 44, DyeColor.ORANGE), SNR_MODERATOR("Sr.Mod", "srmod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 44, DyeColor.ORANGE), - CMA("Mod", "cma", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), + CMA("Mod", "mod_cma", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), HELPER("Trainee", "train", ChatColor.GOLD, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 24, DyeColor.ORANGE), MAPLEAD("MapLead", "mapl", ChatColor.BLUE, "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders.", 25, DyeColor.BLUE), From 2fc423306b526f3b9481dd6c7b8d2a13f3e75f68 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 27 May 2017 13:18:40 -0400 Subject: [PATCH 062/283] Add appropriate starter level for multi-tiered achievements with level names to fix incorrect array length --- .../core/achievement/Achievement.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index e9945effd..1d1dd47c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -412,8 +412,8 @@ public enum Achievement new String[]{"Earn Kill Streak Rewards"}, new int[][]{new int[]{0, 50, 500}, new int[]{0, 100, 750}, new int[]{0, 150, 1000}, new int[]{0, 200, 1500}, new int[]{0, 400, 2000}, new int[]{0, 500, 2500}, new int[]{0, 1000, 3000}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4000}, new int[]{0, 5000, 100000}}, new int[]{10, 20, 50, 100, 200, 250, 500, 750, 1000, 2000}, - "Novice I", - new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, + "Initiate", + new String[]{"Novice I", "Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, AchievementCategory.CASTLE_ASSAULT), CASTLE_ASSAULT_FIRST_BLOOD("First Blood", 0, @@ -421,8 +421,8 @@ public enum Achievement new String[]{"Obtain the first kill in a Match"}, new int[][]{new int[]{0, 100, 100}, new int[]{0, 150, 200}, new int[]{0, 200, 300}, new int[]{0, 250, 400}, new int[]{0, 500, 500}}, new int[]{2, 5, 10, 25, 50}, - "Novice I", - new String[]{"Novice II", "Novice III", "Novice IV", "Novice V"}, + "Initiate", + new String[]{"Novice I", "Novice II", "Novice III", "Novice IV", "Novice V"}, AchievementCategory.CASTLE_ASSAULT), CASTLE_ASSAULT_FIGHTER_KIT("Fighter", 0, @@ -430,8 +430,8 @@ public enum Achievement new String[]{"Kill opponents while wearing the Fighter Kit"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, - "Novice I", - new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, + "Initiate", + new String[]{"Novice I", "Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, AchievementCategory.CASTLE_ASSAULT), CASTLE_ASSAULT_TANK_KIT("Tank", 0, @@ -439,8 +439,8 @@ public enum Achievement new String[]{"Kill opponents while wearing the Tank Kit"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, - "Novice I", - new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, + "Initiate", + new String[]{"Novice I", "Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, AchievementCategory.CASTLE_ASSAULT), CASTLE_ASSAULT_ARCHER_KIT("Archer", 0, @@ -448,8 +448,8 @@ public enum Achievement new String[]{"Kill opponents while wearing the Archer Kit"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, - "Novice I", - new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, + "Initiate", + new String[]{"Novice I", "Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, AchievementCategory.CASTLE_ASSAULT), CASTLE_ASSAULT_DEMOLITIONIST_KIT("Demolitionist", 0, @@ -457,8 +457,8 @@ public enum Achievement new String[]{"Kill opponents while wearing the Demolitionist Kit"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, - "Novice I", - new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, + "Initiate", + new String[]{"Novice I", "Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, AchievementCategory.CASTLE_ASSAULT), CASTLE_ASSAULT_WINNER("Assault", 0, @@ -466,8 +466,8 @@ public enum Achievement new String[]{"Win games of Castle Assault"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{2, 5, 25, 50, 100, 150, 250, 500, 1000, 2000}, - "Novice I", - new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, + "Initiate", + new String[]{"Novice I", "Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, AchievementCategory.CASTLE_ASSAULT), //Champions From b139d0550b6989575714e1c0e63e9f82e0e5b0ef Mon Sep 17 00:00:00 2001 From: Kenny Goodin Date: Tue, 30 May 2017 20:36:39 -0400 Subject: [PATCH 063/283] Periodically purge expired elements from recently seelected quests repo --- .../src/mineplex/quest/daemon/QuestManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java index 2dba4ccc1..9a7025b85 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java @@ -151,6 +151,9 @@ public class QuestManager extends Thread { while (_alive) { + // purge recently selected quests repo of expired entries + _recentlySelectedQuestsRepo.clean(); + LocalDate now = LocalDate.now(EST_TIMEZONE); // check if date has changed; if so we need to choose new quests if (_currentDate.isBefore(now) || _activeQuests.isEmpty()) From 2c6112347a1dd5635f910f18ca23f296b8151d34 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 27 May 2017 00:13:49 -0500 Subject: [PATCH 064/283] Add Bob Ross Morph --- .../mineplex/core/common/skin/SkinData.java | 1 + .../mineplex/core/gadget/GadgetManager.java | 2 + .../gadget/gadgets/morph/MorphBobRoss.java | 507 ++++++++++++++++++ 3 files changed, 510 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index 55d6fd4ab..88dde15c3 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -67,6 +67,7 @@ public class SkinData public final static SkinData LEPRECHAUN = new SkinData("eyJ0aW1lc3RhbXAiOjE0ODc4NzI5Mjg1ODIsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS80ZTBkZjZhZGNiNzkzMzM5ZjFhOGNkM2E0ZGQ2ZThjNGQ2ZWFjYmU5NWMzZDA5OTI4NDMyMWFiZGI5MTgwOSJ9fX0=", "cyIYHTdzvVBOyYoiJZTvNS8Et5pzqBNxuz6GQspE2lBkW2Bj82JNv5oczsf3oxYAG4zxdb96G8+7UKBmoJdvx0x6UD7Dk0dnKrwpXfOhe+jRxtwMGMsdYCb8URWaoIoeKpxdCmAtjgV6FI8zDy2Yzi+MF4O9e4VqH0tMBoD2/CZScQwNEzc4YXf2M2fglKn9uK2+xrgLV+XS+SNdIn7BRiNlQf96u6N2G0lO+eb09LbIfIgAgfnyLiARccWa+VNo6gwlCFyRMnwOlgqxL5XA5Um4kkx2ZReRRCDFQ4NV5eLBktLd5wpECyOuY7v7S3zLqwbhwG47gS8hnXqmtHG5RW0RUQZEryg638Cw7hwr2k09iStfok8WeZUIJ+fuUWgdArvbtN36a2pCXyFdqzp+E8xzSF4E9SQv0K+1lNj+w4L58dh8pddeKK8m5bpjINj4xZ6nf7reWYQAX/imVNYTXTW8JqYnF+++xViBwmfeeM3PmEg+wyTduh+M25nyhGcqn5l+UyQ9aMzzdNs2aEdx12fOm1sOFXjHrHWeo6ciEm7sY1SDjiJ99VVXuGHCJWBtxq/B+c+vC/Cj8itEYOetwe5NKrgI99pZjG+KiRr4L0n8/NA3Px7SbKUUpHse80pNMjGfFW4pAOyFXJaKHrObWT2iL2AnTe+yfdY4sf/JZT4="); public final static SkinData BUGS_BUNNY = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTA0NzE5MDU2MTgsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84MmUyMjRkMGJkZGJmNjRiODIzMmUxNWRhNGRkN2NjN2NiYTYzM2NiODkyMTFhYjVjNDRhODU0ZjM1NDhlZWRiIn19fQ==", "QtM7YGNpqGcTnlUCTtQsQIEc8VGvL8cxWzAvN4LjYZrY4Fv15ysEVSPWPmRL/FJTRyUFCrJFO/0miVbuIEsGyUnsgHJAr9qkeyMvfD3+pZtKU1FkS58VNQkL/YaPDms7XPy1BPNo+ynQnVevdVCNDOvs2244Px3UljtuReBteKqL8QGMR1K6FFCQuKKvcvYsljdM8RV91r2yuT9UDxnzMRghWyRZuthvCeGL85g1LQxCnzJ0NUqIqCDrTWa8jeuncLnmRooKZYGsQjCAVOSFRk4KytD+fv8xgNK2igqBgVcqAINl5IjrFt7yyPQ2FVBbshETsjewusa6eZSBoy1Lc17G7bcndoOdwGMuztLjHPMzxFpIV1RkbZrngjcSTE/IQdSw79NlzMOEMKjE/34M7xcSnSZA1xwW33g+/xq+pNbqcXu85e7VXkziWDhHREp9ITT4YjrVdrss1yfYBzZgRmmLyaMpVmVsecKB9adpuZkhGzKIVrQHDGYEHoqoRnsRGJREdZQPxaSWp4+DSxpV/0oJXJWDz+XFztbcVbBcjBOD9kpFP0s+R5t1WA2B+jsf9J3LdsUUDbBiWikBwbAXKhHxTWWKv6OZLZovhgvGnW2lXQsHglEKuD7jE/mnFj4SF2qRO2N37AUjaG8AGQtTVhxW5JneIiBA0dbKIk06yoY="); public final static SkinData SLENDERMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTA0NzUyNzk4NTUsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9hMWNkOTI5OTFmYTRjZGQ2MGVlZDNhZTM3ZmI5NWRmZjFkNWNkOGNiZmYwYWFjMzE4MmQ0ODU2NDU5NTIzYyJ9fX0=", "OVqWFLCekyZcdGli6kPBKNh8/VYPhKZGNqlAvSOKc3RLgh4pIkI6TDPr/Y+VQdhz1wZozARFYSeoDJJJ4nZTi7gi3rVPG2rL1ZnKo7so5hdT8caEzSTRmgwPKzo03ZhEEsW9AEJo9mpiUxGSJdBlgEb9UgodpYFW1IjRC09CcBUqzRWP8QGZTSFSN5x9emQ97DyiFmt0NFWubHCKHdb7CExhchPRtbahL3hOEzPY8/Y+Irl9OZjx7jONE7O/sYItCuZoXc3FaTgCV0riiXHCgH2eA54s5TQVWumtp3FU7VIcKR6pm/o61+GusvqhNgdFNk9XSHWMUyp+HNU0R8sConZQN/eaVx9laJmUUb4zNZ7hX/hLYV+r9LFU1NXOeIZWJPShD+bYfZgEorIpD+EAL4BHht/f5e6a1IZUDBWb001PFibby2t9WWjoDVKz4McbxZ2Xui7EHKFG1K3biPibhWx6fvnOeJ2xW6UDIZcD+TCXwlW/knkFt44Xpyv3oNHk3UNkyrQgghd6qkc3gZHxP8PQCNvKIyK1I+pHR6JMZvSStp7ZQRDpvsvIUyOJvq+7Bs7lFYs8hcJHMzEB+8PYlH2k7P7iLuA6ZYFUmvOW1LLq0+hvxK96ZdNEsJdmMkVVTZBRw7vsZ4GPbkdp2cMOFH2lHcQj80xKqVbd43IqFDA="); + public final static SkinData BOB_ROSS = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTU2NjEyOTc2NTcsInByb2ZpbGVJZCI6IjdkYTJhYjNhOTNjYTQ4ZWU4MzA0OGFmYzNiODBlNjhlIiwicHJvZmlsZU5hbWUiOiJHb2xkYXBmZWwiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzVhNzZhN2NlMzZlZGRiYmZhNWMzMmJhZmVhYmUyNmQ3ZWJlNWRlOTBkNzYyYzJmNWY3OTQ1ZTQ1ODUxOTU2ZDYifX19", "b7pUQSZ1UkMZJNSqdaBPGWfm+rfvFkEh58pBvYTG2RBPwVju1kKinb1LfsyYhFKlyPvL1jfqi30udmb0302QvE0SKg7p3txxULa3Hr94+eCJWFxrOxUNorRT9E+TurJxH6jimu6KW1p6goPn77/kgNaWb9xn3+E84+vH0z9ETjgc5G0aYLT+cSzThUorhvOQ7DRLfRgSWiFxfm3Er0g+waLfDEeNNAd6OJ5k3X+kgM/+V6QTIFofnZZ6NdZZInTARAVol2H0pRfQfAuVYfJyVyvA0uF+ZX+wlMuBTG1MeyWjZgI1iUKmGaQADXsAV796kT+Z+tAXpbRYYYZnxil5jx5P4druiHvaQfV2KK3lbKm2uH9M3SZr5d57C3V24BKRRWGS4C9INzgO8ORIIomes7kp0gECS4MnSMI6hcl0JsXVlaAy88BgmT/PKxM+3q4PCQE1N9fTCuhoil7vVYIU3uBXwFUE7NTAOUdBee+3TtMstIu2WP8rtEZBVpGH9CmomaLTCzPZSdXGY31goOFXSRYMNi8j4ykuBgP0qJqimipWH0rBF1bMdHqMu359h62tTLRKipHWXPxj4N8c/n1CVPYjuXH9X3f1HAU4DnET+v93Vb/uzbx8rXFrz6jLPwAjSlJ8Th3VE+4ey/ZBHWPB+SuHetN+e0r/LYxiqwwlnwI="); // Comments this out for now, so it doesn't load the player profile // A better way to do this would check for the properties when getting the skull or the skin diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index e35168a9b..e0d211e34 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -10,6 +10,7 @@ import java.util.Set; import java.util.UUID; import java.util.function.Predicate; +import mineplex.core.gadget.gadgets.morph.MorphBobRoss; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -454,6 +455,7 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphLoveDoctor(this)); addGadget(new MorphGoldPot(this)); addGadget(new MorphAwkwardRabbit(this)); + addGadget(new MorphBobRoss(this, _hologramManager)); // Particles addGadget(new ParticleFoot(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java new file mode 100644 index 000000000..57735951c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java @@ -0,0 +1,507 @@ +package mineplex.core.gadget.gadgets.morph; + +import java.time.Month; +import java.time.YearMonth; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.HologramManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.ItemStack; + +import com.mojang.authlib.GameProfile; + +import mineplex.core.common.skin.SkinData; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; + +/** + * Bob Ross morph for Power Play Club (June 2017) + */ +public class MorphBobRoss extends MorphGadget +{ + /** The inventory slot in which the paint brush is placed */ + private static final int PAINT_BRUSH_SLOT = 2; + + /** Max # of blocks that can be destroyed every half second */ + private static final int DESTROY_LIMIT = 20; + + /** The # of minutes for which paint blocks exist */ + private static final int PAINT_MINUTES = 1; + + /** Likelihood that a quote will be shown above a player every certain number of seconds */ + private static final double QUOTE_CHANCE = 0.03; + + /** Height above a player's location at which quotes are to be displayed */ + private static final double QUOTE_HEIGHT = 2.12; + + /** The number of seconds for which quotes are displayed */ + private static final int QUOTE_PERSISTENCE = 9; + + /** Quote attribution for bob */ + private static final String ATTRIBUTION = C.cGray + "- " + C.cYellow + "Bob Ross"; + + /** Cooldown key for changing paint colors */ + private static final String COLOR_KEY = "Change Paint Color"; + + /** Cooldown key for cleaning and putting paint on the brush */ + private static final String PAINT_KEY = "Beat The Devil Out Of It"; + + /** List of wholesome Bob Ross quotes. */ + private static final String[][] QUOTES = { + {"We don't make mistakes,", "just happy little accidents."}, + {"Anything that you're willing to practice,", "you can do."}, + {"There's nothing wrong with having a tree as a friend."}, + {"Let's get a little crazy here!"}, + {"Express yourself to others through painting."}, + {"All you need to paint is a few tools,", "a little instruction,", "and a vision in your mind."}, + {"I can't think of anything more", "rewarding than being able to express", "yourself to others through painting."}, + {"The secret to doing anything is", "believing that you can do it."}, + {"Anything that you believe you can do strong enough,", "you can do."}, + {"Wash the brush, just beat the devil out of it!"}, + {"Beat the devil out of it!"}, + {"I started painting as a hobby when I was little."}, + {"Anybody can do what I do."}, + {"I believe talent is just a pursued interest."}, + {"Mix up a little more shadow color here,", "then we can put us a little shadow right in there."}, + {"You have unlimited power on this canvas!"}, + {"Believe that you can do it cause you can do it."}, + {"There's nothing in the world", "that breeds success like success."}, + {"Lets build a happy little cloud."}, + {"Lets build some happy little trees."}, + {"Everyday is a good day when you paint."}, + {"The only thing worse than", "yellow snow is green snow."}, + {"Look around.", "Look at what we have.", "Beauty is everywhere—", "you only have to look to see it."}, + {"Just go out and talk to a tree.", "Make friends with it."}, + {"How do you make a round circle with a square knife? That’s your challenge for the day."}, + {"Water's like me. It's laaazy...", "Boy, it always looks for the easiest way to do things"}, + {"Oooh, if you have never been to Alaska,", "go there while it is still wild."}, + {"If I paint something,", "I don't want to have to explain what it is."}, + {"We artists are a different breed of people.", "We're a happy bunch."}, + {"Any way you want it to be, that's just right."}, + {"As my son Steve says, just 'smoosh' it in there."}, + {"Use odorless paint-thinner.", "If it's not odorless, you'll find yourself", "working alone very, very quickly."}, + {"Let's just blend this little rascal here, ha!", "Happy as we can be."}, + {"Clouds are very, very free."}, + {"Maybe in our world there lives a", "happy little tree over there."}, + {"Shwooop! Hehe.", "You have to make those little noises,", "or it just doesn't work."}, + {"No pressure. Just relax and watch it happen."}, + {"Find freedom on this canvas."}, + {"It’s so important to do something every", "day that will make you happy."}, + {"Every day is a good day when you paint."}, + {"Hi, I'm Bob Ross!"}, + {"Everyone needs a friend."}, + {"Don’t forget to tell these special", "people in your life just how special", "they are to you."}, + {"I taught my son to paint mountains like these!"}, + {"You need the dark in order to show the light."}, + {"In nature, dead trees are just", "as normal as live trees."}, + {"This is happy place;", "little squirrels live here and play."}, + {"It’s life.", "It’s interesting.", "It’s fun."}, + {"I really believe that", "if you practice enough you could paint the", "'Mona Lisa' with a two-inch brush."}, + {"Don't be afraid to go out on a limb,", "because that's where the fruit is!"} + }; + + /** Map of items in players' inventories */ + private final Map _inventoryItems = new HashMap<>(); + + /** Blocks that have been painted */ + private final List _paintBlocks = new ArrayList<>(); + + private final HologramManager _holograms; + + public MorphBobRoss(GadgetManager manager, HologramManager holograms) + { + super(manager, "Bob Ross Morph", UtilText.splitLinesToArray(new String[] { + C.cGray + "Become the creator of your own world!", + C.cGray + "Leave a trail of paint behind you as you walk.", + "", + C.cGreen + "Right click " + C.cWhite + "on your " + C.cYellow + "Paintbrush" + C.cWhite + " (stick) to paint", + "", + C.cGreen + "Right click " + C.cWhite + "on your " + C.cYellow + "Paint" + C.cWhite + " (dyes) to stop painting", + "", + C.cGreen + "Left click " + C.cWhite + "on your " + C.cYellow + "Paint " + C.cWhite + "to change paintbrush colors.", + + }, LineFormat.LORE), -14, Material.PAINTING, (byte) 0, YearMonth.of(2017, Month.JUNE)); + + _holograms = holograms; + } + + /** + * Sets the player's skin to Bob Ross, then gives the player a 'paintbrush' item. + */ + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + GameProfile profile = UtilGameProfile.getGameProfile(player); + profile.getProperties().clear(); + profile.getProperties().put("textures", SkinData.BOB_ROSS.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile); + disguisePlayer.showInTabList(true, 0); + UtilMorph.disguise(player, disguisePlayer, Manager); + + givePaintbrush(player); + } + + /** + * Restores the player's skin and takes their 'paintbrush' item away. + */ + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + + takePaintbrush(player); + } + + /** + * Detect when a player clicks their paint brush item. + */ + @EventHandler + public void handlePlayerInteract(PlayerInteractEvent event) + { + if (!isActive(event.getPlayer())) + { + return; + } + + if (!_inventoryItems.containsKey(event.getPlayer().getUniqueId())) + { + return; + } + + if (!_inventoryItems.get(event.getPlayer().getUniqueId()).equals(event.getPlayer().getItemInHand())) + { + return; + } + + if (UtilEvent.isAction(event, UtilEvent.ActionType.L)) + { + if (Recharge.Instance.use(event.getPlayer(), COLOR_KEY, 220, false, false)) + { + changePaintColor(event.getPlayer()); + } + } + else if (UtilEvent.isAction(event, UtilEvent.ActionType.R)) + { + if (Recharge.Instance.use(event.getPlayer(), PAINT_KEY, 1000, false, false)) + { + togglePainting(event.getPlayer()); + } + } + } + + /** + * Randomly display a Bob Ross quote above morphed players' heads. + * Destroy old paint after a certain amount of time has elapsed. + */ + @EventHandler + public void updateEvent(UpdateEvent event) + { + if (event.getType() == UpdateType.FASTER) // do paint removal + { + int limit = 0; + + // destroy up to 20 paint blocks that are older than a set number of minutes + while (!_paintBlocks.isEmpty() + && _paintBlocks.get(0).time < System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(PAINT_MINUTES) + && limit < DESTROY_LIMIT) + { + Block block = _paintBlocks.remove(0).block; + + if (block.getType() == Material.CARPET) + { + block.setType(Material.AIR); + } + + limit++; + } + } + else if (event.getType() == UpdateType.SEC_30) // do random quote displaying + { + for (Player player : getActive()) + { + if (Math.random() >= QUOTE_CHANCE) + { + // select quote + String[] quote = QUOTES[ThreadLocalRandom.current().nextInt(0, QUOTES.length)]; + final Collection holograms = new ArrayList<>(); + + // add attribution + holograms.add(new Hologram(_holograms, player.getLocation().add(0, QUOTE_HEIGHT, 0), ATTRIBUTION)); + + // display the quote + double offset = 0.3; + for (int i = quote.length - 1; i >= 0; --i) + { + holograms.add(new Hologram(_holograms, player.getLocation().add(0, QUOTE_HEIGHT + offset, 0), + C.cWhite + quote[i])); + offset += 0.25; + } + + for (Hologram hologram : holograms) + { + hologram.setViewDistance(18); + hologram.setFollowEntity(player); + hologram.start(); + } + + // remove hologram a certain number of seconds later + Bukkit.getServer().getScheduler().runTaskLater(UtilServer.getPlugin(), () -> + holograms.forEach(Hologram::stop), QUOTE_PERSISTENCE * 20); + } + } + } + } + + /** + * When a player moves, paint the ground below them if they have it enabled. + */ + @EventHandler + public void paintGround(PlayerMoveEvent event) + { + Player player = event.getPlayer(); + + if (!isActive(player)) + { + return; + } + + // check if the player has been issued a paintbrush + if (_inventoryItems.containsKey(player.getUniqueId())) + { + ItemStack item = _inventoryItems.get(player.getUniqueId()); + + if (item.getType() == Material.STICK) + { + return; // player is not painting, do nothing + } + + Block block = player.getLocation().getBlock(); + Material down = block.getRelative(BlockFace.DOWN).getType(); + + boolean carpet = block.getType() == Material.CARPET; + + // check that there is room to paint and that the block below is solid and not more paint. + if ((block.isEmpty() || carpet) && down.isSolid() && down != Material.CARPET) + { + int index; + PaintedBlock blk = new PaintedBlock(block); + + if (carpet) // if block is a carpet + { + // remove old paint if it was painted + if ((index = _paintBlocks.indexOf(blk)) != -1) + { + _paintBlocks.remove(index); + } + else // if it's non-paint carpet + { + return; // don't paint + } + } + + // mark block as painted + _paintBlocks.add(blk); + + // actually paint block + block.setType(Material.CARPET); + block.setData((byte) (15 - item.getData().getData())); + } + } + } + + /** + * Cycle the selected paint color for a player. + */ + private void changePaintColor(Player player) + { + ItemStack item = _inventoryItems.remove(player.getUniqueId()); + byte data = item.getData().getData(); + data++; + if (data > 15) data = 0; + ItemStack newItem = ItemStackFactory.Instance.CreateStack(Material.INK_SACK, data, 1, getPaintColor(data) + " Paintbrush"); + _inventoryItems.put(player.getUniqueId(), newItem); + player.getInventory().remove(item); + player.getInventory().setItem(PAINT_BRUSH_SLOT, newItem); + player.updateInventory(); + } + + /** + * Toggle whether a player is currently painting or not. + */ + private void togglePainting(Player player) + { + ItemStack item = _inventoryItems.remove(player.getUniqueId()); + + ItemStack newItem; + if (item.getType() == Material.STICK) + { + byte data = ((byte) ThreadLocalRandom.current().nextInt(0, 16)); + newItem = ItemStackFactory.Instance.CreateStack(Material.INK_SACK, data, 1, getPaintColor(data) + " Paintbrush"); + } + else + { + newItem = ItemStackFactory.Instance.CreateStack(Material.STICK, (byte) 0, 1, "Clean Paintbrush"); + } + + _inventoryItems.put(player.getUniqueId(), newItem); + player.getInventory().remove(item); + player.getInventory().setItem(PAINT_BRUSH_SLOT, newItem); + player.updateInventory(); + } + + /** + * Give a paintbrush item to a player. + */ + private void givePaintbrush(Player player) + { + if (!_inventoryItems.containsKey(player.getUniqueId())) + { + ItemStack item = ItemStackFactory.Instance.CreateStack(Material.STICK, (byte) 0, 1, "Clean Paintbrush"); + player.getInventory().setItem(PAINT_BRUSH_SLOT, item); + _inventoryItems.put(player.getUniqueId(), item); + player.updateInventory(); + } + } + + /** + * Take the paintbrush item from the player + */ + private void takePaintbrush(Player player) + { + // check that paintbrush has been issued + if (_inventoryItems.containsKey(player.getUniqueId())) + { + ItemStack item = _inventoryItems.remove(player.getUniqueId()); + + // if player has paintbrush, take it + if (player.getInventory().contains(item)) + { + player.getInventory().remove(item); + } + + player.updateInventory(); + } + } + + /** + * Returns a paint color name base mainly on Bob Ross's common color selections, + * and on standard paint color names when the former is not available. + * + * @param color The data value of the dye for which to get a name. + * + * @return A string with a paint name + */ + private String getPaintColor(byte color) + { + switch(color) + { + case 0: + return "Midnight Black"; + case 1: + return "Alizarin Crimson"; + case 2: + return "Sap Green"; + case 3: + return "Van Dyke Brown"; + case 4: + return "Prussian Blue"; + case 5: + return "Studio Purple"; + case 6: + return "Phthalo Green"; + case 7: + return "Dusty Gray"; + case 8: + return "Tundora Gray"; + case 9: + return "Soft Flower Pink"; + case 10: + return "Lima Green"; + case 11: + return "Cadmium Yellow"; + case 12: + return "Danube Blue"; + case 13: + return "Soft Magenta"; + case 14: + return "Yellow Ochre"; + case 15: + return "Titanium White"; + default: + return "Mystery"; + + } + } + + /** + * Data class holding information on blocks which have been painted + */ + private class PaintedBlock + { + /** The time at which the block was painted */ + long time; + + /** The block which was painted */ + Block block; + + /** + * Construct a PaintedBlock + * + * @param block The block which has been painted. + */ + public PaintedBlock(Block block) + { + this.block = block; + this.time = System.currentTimeMillis(); + } + + /** + * Overrides default equals behavior to have comparisons between + * multiple {@link PaintedBlock} objects match comparisons between + * their contained {@link PaintedBlock#block} fields. + */ + @Override + public boolean equals(Object o) + { + if (o instanceof PaintedBlock) + { + return block.equals(((PaintedBlock) o).block); + } + else + { + return super.equals(o); + } + } + } +} From 7baf3bad30e886c30443f68b88d644cd6e462120 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 27 May 2017 16:14:48 -0500 Subject: [PATCH 065/283] Clean up Hologram class code --- .../src/mineplex/core/hologram/Hologram.java | 435 +++++++++++++----- 1 file changed, 325 insertions(+), 110 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java index f873ea35c..56b4b6cb3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java @@ -24,13 +24,13 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; +/** + * Floating text object with interaction and entity follow capabilities. + */ public class Hologram { - public enum HologramTarget { - BLACKLIST, WHITELIST; - } - private Packet _destroy1_8; + /** * 1.7 packets uses both EntityIDs while 1.8 uses only the first. */ @@ -38,6 +38,7 @@ public class Hologram { private Entity _followEntity; private HologramManager _hologramManager; private String[] _hologramText = new String[0]; + /** * Keeps track of the holograms movements. This fixes offset that * occasionally happens when moving a hologram around. @@ -60,15 +61,42 @@ public class Hologram { private long _maxLifetime = -1; private long _startTime; - public Hologram(HologramManager hologramManager, Location location, String... text) { + /** + * Construct a standard hologram. + * + * @param hologramManager The hologram manager. + * @param location The location at which to display the hologram. + * @param text An array of text lines which the hologram should display. + */ + public Hologram(HologramManager hologramManager, Location location, String... text) + { this(hologramManager, location, false, -1l, text); } - public Hologram(HologramManager hologramManager, Location location, boolean hideBoundingBox, String... text) { + /** + * Construct a hologram with a specified bounding box. + * + * @param hologramManager The hologram manager. + * @param location The location at which to display the hologram. + * @param hideBoundingBox Whether to hide the bounding box of the hologram. + * @param text An array of text lines which the hologram should display. + */ + public Hologram(HologramManager hologramManager, Location location, boolean hideBoundingBox, String... text) + { this(hologramManager, location, hideBoundingBox, -1l, text); } - public Hologram(HologramManager hologramManager, Location location, boolean hideBoundingBox, long maxLifetime, String... text) { + /** + * Construct a hologram with a limited lifetime. + * + * @param hologramManager The hologram manager. + * @param location The location at which to display the hologram. + * @param hideBoundingBox Whether to hide the bounding box of the hologram. + * @param maxLifetime The max lifetime of the hologram, specified in milliseconds. + * @param text An array of text lines which the hologram should display. + */ + public Hologram(HologramManager hologramManager, Location location, boolean hideBoundingBox, long maxLifetime, String... text) + { _hologramManager = hologramManager; _location = location.clone(); _maxLifetime = maxLifetime; @@ -76,9 +104,16 @@ public class Hologram { setText(text); } - public Hologram setInteraction(HologramInteraction interact) { + /** + * Set the interaction handler for the hologram. + * + * @param interact The handler. + * + * @return the original hologram object. + */ + public Hologram setInteraction(HologramInteraction interact) + { _interaction = interact; - return this; } @@ -89,37 +124,50 @@ public class Hologram { /** * Adds the player to the Hologram to be effected by Whitelist or Blacklist */ - public Hologram addPlayer(Player player) { + public Hologram addPlayer(Player player) + { return addPlayer(player.getUniqueId()); } /** * Adds the player to the Hologram to be effected by Whitelist or Blacklist */ - public Hologram addPlayer(UUID player) { + public Hologram addPlayer(UUID player) + { _playersInList.add(player); return this; } /** - * Warning! Bounding box if hidden will hide holograms for 1.8 to 1.8.2 + * Hides the bounding box for the hologram.
+ * + * Warning! Bounding box if hidden will hide holograms for 1.8 to 1.8.2 * - * @return + * @return the original hologram object. */ - public Hologram setHideBoundingBox() { + public Hologram setHideBoundingBox() + { _hideBoundingBox = true; return this; } /** - * Is there a player entry in the hologram for Whitelist and Blacklist + * @return if there is a player entry in the holograms whitelist/blacklist. */ - public boolean containsPlayer(Player player) { + public boolean containsPlayer(Player player) + { return _playersInList.contains(player.getUniqueId()); } - protected Packet getDestroyPacket() { - if (_makeDestroyPackets) { + /** + * Generates a packet to destroy the hologram client-side. + * + * @return the packet. + */ + protected Packet getDestroyPacket() + { + if (_makeDestroyPackets) + { makeDestroyPacket(); _makeDestroyPackets = false; } @@ -127,32 +175,44 @@ public class Hologram { return _destroy1_8; } - public Entity getEntityFollowing() { + /** + * @return the entity that this hologram is currently following. + */ + public Entity getEntityFollowing() + { return _followEntity; } /** - * Get who can see the hologram - * - * @Whitelist = Only people added can see the hologram - * @Blacklist = Anyone but people added can see the hologram + * @return The functionality that is currently being used for the object's internal + * player list. + * {@link HologramTarget#WHITELIST} = Only people added can see the hologram + * {@link HologramTarget#BLACKLIST} = Anyone but people added can see the hologram */ - public HologramTarget getHologramTarget() { + public HologramTarget getHologramTarget() + { return _target; } /** - * Get the hologram location + * @return the current location of the hologram. */ - public Location getLocation() { + public Location getLocation() + { return _location.clone(); } - protected ArrayList getNearbyPlayers() { - ArrayList nearbyPlayers = new ArrayList(); + /** + * @return A list of players that can currently see the hologram. + */ + protected ArrayList getNearbyPlayers() + { + ArrayList nearbyPlayers = new ArrayList<>(); - for (Player player : getLocation().getWorld().getPlayers()) { - if (isVisible(player)) { + for (Player player : getLocation().getWorld().getPlayers()) + { + if (isVisible(player)) + { nearbyPlayers.add(player); } } @@ -160,26 +220,37 @@ public class Hologram { return nearbyPlayers; } - protected ArrayList getPlayersTracking() { + /** + * @return The list of players that are in the holograms whitelist or blacklist. + */ + protected ArrayList getPlayersTracking() + { return _playersTracking; } - protected void checkSpawnPackets() { - if (_makeSpawnPackets) { + /** + * Generates hologram spawn packets if they have not been created already. + */ + protected void checkSpawnPackets() + { + if (_makeSpawnPackets) + { makeSpawnPackets(); _makeSpawnPackets = false; } } /** - * Get the text in the hologram + * @return the current text being displayed by the hologram. */ - public String[] getText() { + public String[] getText() + { // We reverse it again as the hologram would otherwise display the text // from the bottom row to the top row String[] reversed = new String[_hologramText.length]; - for (int i = 0; i < reversed.length; i++) { + for (int i = 0; i < reversed.length; i++) + { reversed[i] = _hologramText[reversed.length - (i + 1)]; } @@ -187,27 +258,45 @@ public class Hologram { } /** - * Get the view distance the hologram is viewable from. Default is 70 + * @return the view distance the hologram is viewable from. Default is 70 */ - public int getViewDistance() { + public int getViewDistance() + { return _viewDistance; } /** - * Is the hologram holograming? + * @return Is the hologram holograming? */ - public boolean isInUse() { + public boolean isInUse() + { return _lastMovement != null; } - public boolean isRemoveOnEntityDeath() { + /** + * @return whether to delete the hologram when the entity it is following dies. + */ + public boolean isRemoveOnEntityDeath() + { return _removeEntityDeath; } - public boolean isVisible(Player player) { - if (getLocation().getWorld() == player.getWorld()) { - if ((getHologramTarget() == HologramTarget.WHITELIST) == containsPlayer(player)) { - if (getLocation().distance(player.getLocation()) < getViewDistance()) { + /** + * Determines whether the hologram is visible to a player based on view distance, whitelist / + * blacklist, and current world. + * + * @param player The player to check. + * + * @return whether the hologram is visible to the player. + */ + public boolean isVisible(Player player) + { + if (getLocation().getWorld() == player.getWorld()) + { + if ((getHologramTarget() == HologramTarget.WHITELIST) == containsPlayer(player)) + { + if (getLocation().distance(player.getLocation()) < getViewDistance()) + { return true; } } @@ -216,34 +305,49 @@ public class Hologram { return false; } - private void makeDestroyPacket() { + /** + * Generates a packet to destroy the hologram client-side. + */ + private void makeDestroyPacket() + { int[] entityIds1_8 = new int[_entityIds.size()]; - for (int i = 0; i < _entityIds.size(); i++) { + for (int i = 0; i < _entityIds.size(); i++) + { entityIds1_8[i] = _entityIds.get(i); } _destroy1_8 = new PacketPlayOutEntityDestroy(entityIds1_8); } - private void makeSpawnPackets() { + /** + * Generates spawn packets for the hologram. + */ + private void makeSpawnPackets() + { _packets1_8 = new Packet[_hologramText.length]; _packets1_9 = new Packet[_hologramText.length]; - if (_entityIds.size() < _hologramText.length) { + if (_entityIds.size() < _hologramText.length) + { _makeDestroyPackets = true; - for (int i = _entityIds.size(); i < _hologramText.length; i++) { + for (int i = _entityIds.size(); i < _hologramText.length; i++) + { _entityIds.add(Integer.valueOf(UtilEnt.getNewEntityId())); } - } else { + } + else + { _makeDestroyPackets = true; - while (_entityIds.size() > _hologramText.length) { + while (_entityIds.size() > _hologramText.length) + { _entityIds.remove(_hologramText.length); } } - for (int textRow = 0; textRow < _hologramText.length; textRow++) { + for (int textRow = 0; textRow < _hologramText.length; textRow++) + { PacketPlayOutSpawnEntityLiving packet1_8 = makeSpawnPacket1_8(textRow, _entityIds.get(textRow), _hologramText[textRow]); PacketPlayOutSpawnEntityLiving packet1_9 = makeSpawnPacket1_9(textRow, _entityIds.get(textRow), _hologramText[textRow]); @@ -253,7 +357,7 @@ public class Hologram { } /** - * Used for sending 1.9 clients holograms with no bounding boxes + * Used for sending 1.9 clients holograms with no bounding boxes. */ private PacketPlayOutSpawnEntityLiving makeSpawnPacket1_9(int textRow, int entityId, String lineOfText) { @@ -269,7 +373,11 @@ public class Hologram { return packet; } - private PacketPlayOutSpawnEntityLiving makeSpawnPacket1_8(int textRow, int entityId, String lineOfText) { + /** + * Used for sending 1.8 clients holograms. + */ + private PacketPlayOutSpawnEntityLiving makeSpawnPacket1_8(int textRow, int entityId, String lineOfText) + { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); DataWatcher watcher = new DataWatcher(null); @@ -290,41 +398,54 @@ public class Hologram { } /** - * Removes the player from the Hologram so they are no longer effected by - * Whitelist or Blacklist + * Removes a player from the Hologram so they are no longer effected by + * whitelist or blacklist. + * + * @param player The player to remove. + * + * @return the original hologram object. */ - public Hologram removePlayer(Player player) { + public Hologram removePlayer(Player player) + { return removePlayer(player.getUniqueId()); } /** * Removes the player from the Hologram so they are no longer effected by - * Whitelist or Blacklist + * whitelist or blacklist + * + * @param player The player to remove. + * + * @return the original hologram object. */ - public Hologram removePlayer(UUID player) { + public Hologram removePlayer(UUID player) + { _playersInList.remove(player); return this; } /** - * If the entity moves, the hologram will update its position to appear - * relative to the movement. - * - * @Please note the hologram updates every tick. + * Sets an entity to which the hologram will remain relative to in position. + * + * @param entityToFollow the entity which to follow. + * + * @return the original hologram object. */ public Hologram setFollowEntity(Entity entityToFollow) { _followEntity = entityToFollow; - relativeToEntity = entityToFollow == null ? null - : _location.clone().subtract(entityToFollow.getLocation()).toVector(); + relativeToEntity = entityToFollow == null ? null : _location.clone().subtract(entityToFollow.getLocation()).toVector(); return this; } /** - * Set who can see the hologram - * - * @Whitelist = Only people added can see the hologram - * @Blacklist = Anyone but people added can see the hologram + * Set how the hologram's internal player list is used. + * + * @param newTarget The target which defines how the list is used. + * {@link HologramTarget#WHITELIST} = Only people added can see the hologram + * {@link HologramTarget#BLACKLIST} = Anyone but people added can see the hologram + * + * @retuen the original hologram object. */ public Hologram setHologramTarget(HologramTarget newTarget) { _target = newTarget; @@ -332,44 +453,61 @@ public class Hologram { } /** - * Sets the hologram to appear at this location + * Change the location of the hologram. + * + * @param newLocation the location to which to teleport the hologram. + * + * @return the original hologram object. */ - public Hologram setLocation(Location newLocation) { + public Hologram setLocation(Location newLocation) + { _makeSpawnPackets = true; Location oldLocation = getLocation(); _location = newLocation.clone(); - if (getEntityFollowing() != null) { + if (getEntityFollowing() != null) + { relativeToEntity = _location.clone().subtract(getEntityFollowing().getLocation()).toVector(); } - if (isInUse()) { + + if (isInUse()) + { ArrayList canSee = getNearbyPlayers(); Iterator itel = _playersTracking.iterator(); - while (itel.hasNext()) { + while (itel.hasNext()) + { Player player = itel.next(); - if (!canSee.contains(player)) { + if (!canSee.contains(player)) + { itel.remove(); - if (player.getWorld() == getLocation().getWorld()) { + if (player.getWorld() == getLocation().getWorld()) + { UtilPlayer.sendPacket(player, getDestroyPacket()); } } } + itel = canSee.iterator(); checkSpawnPackets(); - while (itel.hasNext()) { + + while (itel.hasNext()) + { Player player = itel.next(); - if (!_playersTracking.contains(player)) { + if (!_playersTracking.contains(player)) + { _playersTracking.add(player); itel.remove(); UtilPlayer.sendPacket(player, UtilPlayer.is1_9(player) ? _packets1_9 : _packets1_8); } } - if (!canSee.isEmpty()) { + + if (!canSee.isEmpty()) + { _lastMovement.add(new Vector(newLocation.getX() - oldLocation.getX(), newLocation.getY() - oldLocation.getY(), newLocation.getZ() - oldLocation.getZ())); @@ -381,9 +519,12 @@ public class Hologram { int i = 0; - if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127) { + if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127) + { _lastMovement.subtract(new Vector(x / 32D, y / 32D, z / 32D)); - for (Integer entityId : _entityIds) { + + for (Integer entityId : _entityIds) + { PacketPlayOutEntity.PacketPlayOutRelEntityMove relMove = new PacketPlayOutEntity.PacketPlayOutRelEntityMove(); relMove.a = entityId; @@ -394,13 +535,16 @@ public class Hologram { packets1_8[i] = relMove; i++; } - } else { + } + else + { x = (int) Math.floor(32 * newLocation.getX()); z = (int) Math.floor(32 * newLocation.getZ()); _lastMovement = new Vector(newLocation.getX() - (x / 32D), 0, newLocation.getZ() - (z / 32D)); - for (Integer entityId : _entityIds) { + for (Integer entityId : _entityIds) + { PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(); teleportPacket.a = entityId; teleportPacket.b = x; @@ -413,61 +557,93 @@ public class Hologram { } } - for (Player player : canSee) { - for (Packet packet : packets1_8) { + for (Player player : canSee) + { + for (Packet packet : packets1_8) + { UtilPlayer.sendPacket(player, packet); } } } } + return this; } + /** + * @return the time at which the hologram was last started. + */ public long getStartTime() { return _startTime; } + /** + * @return the max time after the hologram was started for which it will live. + */ public long getMaxLifetime() { return _maxLifetime; } - public Hologram setRemoveOnEntityDeath() { + /** + * Set the hologram to stop when the entity it is following dies. + * + * @return the original hologram object. + */ + public Hologram setRemoveOnEntityDeath() + { _removeEntityDeath = true; return this; } - public boolean isEntityId(int entityId) { + /** + * @param entityId an entity id. + * + * @return whether the entity ID is represented by this hologram object. + */ + public boolean isEntityId(int entityId) + { return _entityIds.contains(entityId); } /** * Set the hologram text + * + * @param newLines array of text lines for the hologram to display. + * + * @return the original hologram object. */ - public Hologram setText(String... newLines) { + public Hologram setText(String... newLines) + { String[] newText = new String[newLines.length]; - for (int i = 0; i < newText.length; i++) { + for (int i = 0; i < newText.length; i++) + { newText[i] = newLines[newText.length - (i + 1)]; } if (newText.equals(_hologramText)) + { return this; + } - if (isInUse()) { + if (isInUse()) + { int[] destroy1_8 = new int[0]; - ArrayList packets1_8 = new ArrayList(); + ArrayList packets1_8 = new ArrayList<>(); ArrayList packets1_9 = new ArrayList<>(); - if (_hologramText.length != newText.length) { + if (_hologramText.length != newText.length) + { _makeDestroyPackets = true; } - for (int i = 0; i < Math.max(_hologramText.length, newText.length); i++) { - // If more lines than previously - if (i >= _hologramText.length) { + for (int i = 0; i < Math.max(_hologramText.length, newText.length); i++) + { + if (i >= _hologramText.length) // If more lines than previously + { // Add entity id and send spawn packets // You add a entity id because the new hologram needs int entityId = UtilEnt.getNewEntityId(); @@ -476,14 +652,16 @@ public class Hologram { packets1_8.add(makeSpawnPacket1_8(i, entityId, newText[i])); packets1_9.add(makeSpawnPacket1_9(i, entityId, newText[i])); } - // If less lines than previously - else if (i >= newText.length) { + else if (i >= newText.length) // If less lines than previously + { // Remove entity id and send destroy packets Integer entityId = _entityIds.remove(newText.length); destroy1_8 = Arrays.copyOf(destroy1_8, destroy1_8.length + 1); destroy1_8[destroy1_8.length - 1] = entityId; - } else if (!newText[i].equals(_hologramText[i])) { + } + else if (!newText[i].equals(_hologramText[i])) + { // Send update metadata packets Integer entityId = _entityIds.get(i); @@ -495,10 +673,12 @@ public class Hologram { watcher1_8.a(2, newText[i], EntityArmorStand.META_CUSTOMNAME, newText[i]); watcher1_8.a(3, (byte) 1, EntityArmorStand.META_CUSTOMNAME_VISIBLE, true); } + { watcher1_9.a(0, (byte) 32, EntityArmorStand.META_ENTITYDATA, (byte) 32); watcher1_9.a(2, newText[i], EntityArmorStand.META_CUSTOMNAME, newText[i]); watcher1_9.a(3, (byte) 1, EntityArmorStand.META_CUSTOMNAME_VISIBLE, true); + if (_hideBoundingBox) { watcher1_9.a(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16); @@ -510,13 +690,16 @@ public class Hologram { } } - if (destroy1_8.length > 0) { + if (destroy1_8.length > 0) + { packets1_8.add(new PacketPlayOutEntityDestroy(destroy1_8)); packets1_9.add(new PacketPlayOutEntityDestroy(destroy1_8)); } - for (Player player : _playersTracking) { + for (Player player : _playersTracking) + { List packets = UtilPlayer.is1_9(player) ? packets1_9 : packets1_8; + for (Packet packet : packets) { UtilPlayer.sendPacket(player, packet); @@ -532,18 +715,26 @@ public class Hologram { /** * Set the distance the hologram is viewable from. Default is 70 + * + * @param newDistance The distance in blocks. + * + * @return the original hologram object. */ - public Hologram setViewDistance(int newDistance) { + public Hologram setViewDistance(int newDistance) + { _viewDistance = newDistance; return setLocation(getLocation()); } /** - * Start the hologram + * Start the hologram, displaying it to players. + * + * @return the original hologram object. */ - public Hologram start() { - if (!isInUse()) { - + public Hologram start() + { + if (!isInUse()) + { _startTime = System.currentTimeMillis(); _hologramManager.addHologram(this); @@ -553,9 +744,13 @@ public class Hologram { _lastMovement = new Vector(); } + return this; } + /** + * Sends hologram spawn packets to players. + */ private void sendPackets() { checkSpawnPackets(); @@ -566,6 +761,13 @@ public class Hologram { } } + /** + * Generates spawn packets based on minecraft version. + * + * @param player The player for which to generate the packets. + * + * @return the list of packets generated. + */ public Packet[] getSpawnPackets(Player player) { checkSpawnPackets(); @@ -574,13 +776,19 @@ public class Hologram { } /** - * Stop the hologram + * Stop the hologram, effectively destroying it once + * garbage collection has occurred. + * + * @return the original hologram object. */ - public Hologram stop() { - if (isInUse()) { + public Hologram stop() + { + if (isInUse()) + { _hologramManager.removeHologram(this); - for (Player player : _playersTracking) { + for (Player player : _playersTracking) + { UtilPlayer.sendPacket(player, getDestroyPacket()); } @@ -591,4 +799,11 @@ public class Hologram { return this; } + /** + * Enum defining to whom the hologram is displayed. + */ + public enum HologramTarget + { + BLACKLIST, WHITELIST + } } From 98929f043fd93dc59ef23b39c4537f2dec37e972 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 27 May 2017 16:27:29 -0500 Subject: [PATCH 066/283] Make brush types varied and colored in player hotbars --- .../gadget/gadgets/morph/MorphBobRoss.java | 112 +++++++++--------- 1 file changed, 54 insertions(+), 58 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java index 57735951c..0c7a51ee3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java @@ -64,15 +64,53 @@ public class MorphBobRoss extends MorphGadget /** The number of seconds for which quotes are displayed */ private static final int QUOTE_PERSISTENCE = 9; - /** Quote attribution for bob */ - private static final String ATTRIBUTION = C.cGray + "- " + C.cYellow + "Bob Ross"; - /** Cooldown key for changing paint colors */ private static final String COLOR_KEY = "Change Paint Color"; /** Cooldown key for cleaning and putting paint on the brush */ private static final String PAINT_KEY = "Beat The Devil Out Of It"; + /** Cooldown key for displaying a Bob Ross quote above head */ + private static final String QUOTE_KEY = "Bob Ross Quote"; + + /** Quote attribution for bob */ + private static final String ATTRIBUTION = C.cGray + "- " + C.cYellow + "Bob Ross"; + + /** Formatted name for the clean brush */ + private static final String BRUSH_NAME = C.cYellow + "Clean Paintbrush"; + + /** Paint colors for displaying in players' hotbars */ + private static final String[] PAINT_COLORS = { + C.cBlackB + "Midnight Black", + C.cRedB + "Alizarin Crimson", + C.cDGreenB + "Sap Green", + C.cGoldB + "Van Dyke Brown", + C.cDBlueB + "Prussian Blue", + C.cDPurpleB + "Studio Purple", + C.cDAquaB + "Phthalo Green", + C.cGrayB + "Dusty Gray", + C.cDGrayB + "Tundora Gray", + C.cPurpleB + "Soft Flower Pink", + C.cGreenB + "Lima Green", + C.cYellowB + "Cadmium Yellow", + C.cBlueB + "Danube Blue", + C.cPurpleB + "Soft Magenta", + C.cGoldB + "Yellow Ochre", + C.cWhiteB + "Titanium White" + }; + + /** Brush types for displaying in players' hotbars */ + private static final String[] PAINT_BRUSHES = { + "Landscape Brush", + "Foliage Brush", + "Background Brush", + "Blender Brush", + "Oval Brush", + "Round Brush", + "Fan Brush", + "Painting Knife" + }; + /** List of wholesome Bob Ross quotes. */ private static final String[][] QUOTES = { {"We don't make mistakes,", "just happy little accidents."}, @@ -133,6 +171,9 @@ public class MorphBobRoss extends MorphGadget /** Blocks that have been painted */ private final List _paintBlocks = new ArrayList<>(); + /** Hologram quotes that are currently above players' heads */ + private final Map> _spokenQuotes = new HashMap<>(); + private final HologramManager _holograms; public MorphBobRoss(GadgetManager manager, HologramManager holograms) @@ -146,7 +187,8 @@ public class MorphBobRoss extends MorphGadget C.cGreen + "Right click " + C.cWhite + "on your " + C.cYellow + "Paint" + C.cWhite + " (dyes) to stop painting", "", C.cGreen + "Left click " + C.cWhite + "on your " + C.cYellow + "Paint " + C.cWhite + "to change paintbrush colors.", - + "", + C.cWhite + "Hold " + C.cGreen + " crouch " + C.cWhite + "to say a Bob Ross quote." }, LineFormat.LORE), -14, Material.PAINTING, (byte) 0, YearMonth.of(2017, Month.JUNE)); _holograms = holograms; @@ -349,7 +391,10 @@ public class MorphBobRoss extends MorphGadget byte data = item.getData().getData(); data++; if (data > 15) data = 0; - ItemStack newItem = ItemStackFactory.Instance.CreateStack(Material.INK_SACK, data, 1, getPaintColor(data) + " Paintbrush"); + + ItemStack newItem = ItemStackFactory.Instance.CreateStack(Material.INK_SACK, data, 1, + PAINT_COLORS[data] + " " + PAINT_BRUSHES[ThreadLocalRandom.current().nextInt(0, PAINT_BRUSHES.length)]); + _inventoryItems.put(player.getUniqueId(), newItem); player.getInventory().remove(item); player.getInventory().setItem(PAINT_BRUSH_SLOT, newItem); @@ -367,11 +412,12 @@ public class MorphBobRoss extends MorphGadget if (item.getType() == Material.STICK) { byte data = ((byte) ThreadLocalRandom.current().nextInt(0, 16)); - newItem = ItemStackFactory.Instance.CreateStack(Material.INK_SACK, data, 1, getPaintColor(data) + " Paintbrush"); + newItem = ItemStackFactory.Instance.CreateStack(Material.INK_SACK, data, 1, + PAINT_COLORS[data] + " " + PAINT_BRUSHES[ThreadLocalRandom.current().nextInt(0, PAINT_BRUSHES.length)]); } else { - newItem = ItemStackFactory.Instance.CreateStack(Material.STICK, (byte) 0, 1, "Clean Paintbrush"); + newItem = ItemStackFactory.Instance.CreateStack(Material.STICK, (byte) 0, 1, BRUSH_NAME); } _inventoryItems.put(player.getUniqueId(), newItem); @@ -387,7 +433,7 @@ public class MorphBobRoss extends MorphGadget { if (!_inventoryItems.containsKey(player.getUniqueId())) { - ItemStack item = ItemStackFactory.Instance.CreateStack(Material.STICK, (byte) 0, 1, "Clean Paintbrush"); + ItemStack item = ItemStackFactory.Instance.CreateStack(Material.STICK, (byte) 0, 1, BRUSH_NAME); player.getInventory().setItem(PAINT_BRUSH_SLOT, item); _inventoryItems.put(player.getUniqueId(), item); player.updateInventory(); @@ -414,56 +460,6 @@ public class MorphBobRoss extends MorphGadget } } - /** - * Returns a paint color name base mainly on Bob Ross's common color selections, - * and on standard paint color names when the former is not available. - * - * @param color The data value of the dye for which to get a name. - * - * @return A string with a paint name - */ - private String getPaintColor(byte color) - { - switch(color) - { - case 0: - return "Midnight Black"; - case 1: - return "Alizarin Crimson"; - case 2: - return "Sap Green"; - case 3: - return "Van Dyke Brown"; - case 4: - return "Prussian Blue"; - case 5: - return "Studio Purple"; - case 6: - return "Phthalo Green"; - case 7: - return "Dusty Gray"; - case 8: - return "Tundora Gray"; - case 9: - return "Soft Flower Pink"; - case 10: - return "Lima Green"; - case 11: - return "Cadmium Yellow"; - case 12: - return "Danube Blue"; - case 13: - return "Soft Magenta"; - case 14: - return "Yellow Ochre"; - case 15: - return "Titanium White"; - default: - return "Mystery"; - - } - } - /** * Data class holding information on blocks which have been painted */ From a61c4cd816c6c1678fa52155fd5b80c684ae6dfb Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 27 May 2017 17:29:48 -0500 Subject: [PATCH 067/283] Fix holograms not following players in 1.9+ --- .../src/mineplex/core/hologram/Hologram.java | 77 ++++++++++++------- .../core/hologram/HologramManager.java | 1 + 2 files changed, 51 insertions(+), 27 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java index 56b4b6cb3..880190c79 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java @@ -34,7 +34,7 @@ public class Hologram { /** * 1.7 packets uses both EntityIDs while 1.8 uses only the first. */ - private ArrayList _entityIds = new ArrayList(); + private ArrayList _entityIds = new ArrayList<>(); private Entity _followEntity; private HologramManager _hologramManager; private String[] _hologramText = new String[0]; @@ -50,7 +50,7 @@ public class Hologram { private Packet[] _packets1_8; private Packet[] _packets1_9; private HashSet _playersInList = new HashSet<>(); - private ArrayList _playersTracking = new ArrayList(); + private ArrayList _playersTracking = new ArrayList<>(); private boolean _removeEntityDeath; private HologramTarget _target = HologramTarget.BLACKLIST; private int _viewDistance = 70; @@ -70,7 +70,7 @@ public class Hologram { */ public Hologram(HologramManager hologramManager, Location location, String... text) { - this(hologramManager, location, false, -1l, text); + this(hologramManager, location, false, -1L, text); } /** @@ -83,7 +83,7 @@ public class Hologram { */ public Hologram(HologramManager hologramManager, Location location, boolean hideBoundingBox, String... text) { - this(hologramManager, location, hideBoundingBox, -1l, text); + this(hologramManager, location, hideBoundingBox, -1L, text); } /** @@ -431,9 +431,14 @@ public class Hologram { * * @return the original hologram object. */ - public Hologram setFollowEntity(Entity entityToFollow) { + public Hologram setFollowEntity(Entity entityToFollow) + { _followEntity = entityToFollow; - relativeToEntity = entityToFollow == null ? null : _location.clone().subtract(entityToFollow.getLocation()).toVector(); + + if (entityToFollow != null) + { + relativeToEntity = _location.clone().subtract(entityToFollow.getLocation()).toVector(); + } return this; } @@ -447,7 +452,8 @@ public class Hologram { * * @retuen the original hologram object. */ - public Hologram setHologramTarget(HologramTarget newTarget) { + public Hologram setHologramTarget(HologramTarget newTarget) + { _target = newTarget; return this; } @@ -516,9 +522,32 @@ public class Hologram { int z = (int) Math.floor(32 * _lastMovement.getZ()); Packet[] packets1_8 = new Packet[_hologramText.length]; + Packet[] packets1_9 = new Packet[_hologramText.length]; int i = 0; + // Generate packets for 1.9 clients + x = (int) Math.floor(32 * newLocation.getX()); + z = (int) Math.floor(32 * newLocation.getZ()); + + _lastMovement = new Vector(newLocation.getX() - (x / 32D), 0, newLocation.getZ() - (z / 32D)); + + for (Integer entityId : _entityIds) + { + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(); + teleportPacket.a = entityId; + teleportPacket.b = x; + teleportPacket.c = (int) Math.floor((oldLocation.getY() + (-2.1) + ((double) i * 0.285)) * 32); + teleportPacket.d = z; + + packets1_9[i] = teleportPacket; + + i++; + } + + i = 0; + + // Generate move packets for 1.8 clients if the move is small enough. if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127) { _lastMovement.subtract(new Vector(x / 32D, y / 32D, z / 32D)); @@ -536,32 +565,26 @@ public class Hologram { i++; } } - else + else // Use teleport packets { - x = (int) Math.floor(32 * newLocation.getX()); - z = (int) Math.floor(32 * newLocation.getZ()); - - _lastMovement = new Vector(newLocation.getX() - (x / 32D), 0, newLocation.getZ() - (z / 32D)); - - for (Integer entityId : _entityIds) - { - PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(); - teleportPacket.a = entityId; - teleportPacket.b = x; - teleportPacket.c = (int) Math.floor((oldLocation.getY() + (-2.1) + ((double) i * 0.285)) * 32); - teleportPacket.d = z; - - packets1_8[i] = teleportPacket; - - i++; - } + packets1_8 = packets1_9; } for (Player player : canSee) { - for (Packet packet : packets1_8) + if (UtilPlayer.is1_9(player)) { - UtilPlayer.sendPacket(player, packet); + for (Packet packet : packets1_9) + { + UtilPlayer.sendPacket(player, packet); + } + } + else + { + for (Packet packet : packets1_8) + { + UtilPlayer.sendPacket(player, packet); + } } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/HologramManager.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/HologramManager.java index a68ce5944..88f6547cd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/hologram/HologramManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/HologramManager.java @@ -81,6 +81,7 @@ public class HologramManager extends MiniPlugin implements IPacketHandler hologram.stop(); continue; } + if (!hologram.relativeToEntity.equals(following.getLocation().subtract(hologram.getLocation()).toVector())) { // And we do this so in the rare offchance it changes by a decimal. It doesn't start turning wonky. From 6b2a99a8810cb19ae6f584ecbfbe3d3f90f5fca4 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 27 May 2017 17:30:56 -0500 Subject: [PATCH 068/283] Make quotes be activated with a shift click --- .../gadget/gadgets/morph/MorphBobRoss.java | 83 ++++++++++--------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java index 0c7a51ee3..bbc296896 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java @@ -55,24 +55,33 @@ public class MorphBobRoss extends MorphGadget /** The # of minutes for which paint blocks exist */ private static final int PAINT_MINUTES = 1; - /** Likelihood that a quote will be shown above a player every certain number of seconds */ - private static final double QUOTE_CHANCE = 0.03; - /** Height above a player's location at which quotes are to be displayed */ - private static final double QUOTE_HEIGHT = 2.12; + private static final double QUOTE_HEIGHT = 2.25; /** The number of seconds for which quotes are displayed */ - private static final int QUOTE_PERSISTENCE = 9; + private static final int QUOTE_PERSISTENCE = 10; /** Cooldown key for changing paint colors */ private static final String COLOR_KEY = "Change Paint Color"; + /** Cooldown time for changing paint colors (milliseconds) */ + private static final long COLOR_COOLDOWN = 220; + /** Cooldown key for cleaning and putting paint on the brush */ private static final String PAINT_KEY = "Beat The Devil Out Of It"; + /** Cooldown time for cleaning and putting paint on the brush (milliseconds) */ + private static final long PAINT_COOLDOWN = 700; + /** Cooldown key for displaying a Bob Ross quote above head */ private static final String QUOTE_KEY = "Bob Ross Quote"; + /** Cooldown time for displaying a Bob Ross quote (milliseconds) */ + private static final long QUOTE_COOLDOWN = 10100; + + /** Distance (in blocks) from which the quotes can be seen */ + private static final int VIEW_DISTANCE = 14; + /** Quote attribution for bob */ private static final String ATTRIBUTION = C.cGray + "- " + C.cYellow + "Bob Ross"; @@ -171,9 +180,6 @@ public class MorphBobRoss extends MorphGadget /** Blocks that have been painted */ private final List _paintBlocks = new ArrayList<>(); - /** Hologram quotes that are currently above players' heads */ - private final Map> _spokenQuotes = new HashMap<>(); - private final HologramManager _holograms; public MorphBobRoss(GadgetManager manager, HologramManager holograms) @@ -188,7 +194,7 @@ public class MorphBobRoss extends MorphGadget "", C.cGreen + "Left click " + C.cWhite + "on your " + C.cYellow + "Paint " + C.cWhite + "to change paintbrush colors.", "", - C.cWhite + "Hold " + C.cGreen + " crouch " + C.cWhite + "to say a Bob Ross quote." + C.cGreen + "Crouch " + C.cWhite + "to say a Bob Ross quote." }, LineFormat.LORE), -14, Material.PAINTING, (byte) 0, YearMonth.of(2017, Month.JUNE)); _holograms = holograms; @@ -248,14 +254,14 @@ public class MorphBobRoss extends MorphGadget if (UtilEvent.isAction(event, UtilEvent.ActionType.L)) { - if (Recharge.Instance.use(event.getPlayer(), COLOR_KEY, 220, false, false)) + if (Recharge.Instance.use(event.getPlayer(), COLOR_KEY, COLOR_COOLDOWN, false, false)) { changePaintColor(event.getPlayer()); } } else if (UtilEvent.isAction(event, UtilEvent.ActionType.R)) { - if (Recharge.Instance.use(event.getPlayer(), PAINT_KEY, 1000, false, false)) + if (Recharge.Instance.use(event.getPlayer(), PAINT_KEY, PAINT_COOLDOWN, false, false)) { togglePainting(event.getPlayer()); } @@ -263,7 +269,7 @@ public class MorphBobRoss extends MorphGadget } /** - * Randomly display a Bob Ross quote above morphed players' heads. + * Display a Bob Ross quote above players' heads when they sneak. * Destroy old paint after a certain amount of time has elapsed. */ @EventHandler @@ -288,38 +294,41 @@ public class MorphBobRoss extends MorphGadget limit++; } } - else if (event.getType() == UpdateType.SEC_30) // do random quote displaying + else if (event.getType() == UpdateType.TICK) // do random quote displaying { for (Player player : getActive()) { - if (Math.random() >= QUOTE_CHANCE) + if (player.isSneaking()) { - // select quote - String[] quote = QUOTES[ThreadLocalRandom.current().nextInt(0, QUOTES.length)]; - final Collection holograms = new ArrayList<>(); - - // add attribution - holograms.add(new Hologram(_holograms, player.getLocation().add(0, QUOTE_HEIGHT, 0), ATTRIBUTION)); - - // display the quote - double offset = 0.3; - for (int i = quote.length - 1; i >= 0; --i) + if (Recharge.Instance.use(player, QUOTE_KEY, QUOTE_COOLDOWN, false, false)) { - holograms.add(new Hologram(_holograms, player.getLocation().add(0, QUOTE_HEIGHT + offset, 0), - C.cWhite + quote[i])); - offset += 0.25; - } + // select quote + String[] quote = QUOTES[ThreadLocalRandom.current().nextInt(0, QUOTES.length)]; + final Collection holograms = new ArrayList<>(); - for (Hologram hologram : holograms) - { - hologram.setViewDistance(18); - hologram.setFollowEntity(player); - hologram.start(); - } + // add attribution + holograms.add(new Hologram(_holograms, player.getLocation().add(0, QUOTE_HEIGHT, 0), ATTRIBUTION)); - // remove hologram a certain number of seconds later - Bukkit.getServer().getScheduler().runTaskLater(UtilServer.getPlugin(), () -> - holograms.forEach(Hologram::stop), QUOTE_PERSISTENCE * 20); + // display the quote + double offset = 0.3; + for (int i = quote.length - 1; i >= 0; --i) + { + holograms.add(new Hologram(_holograms, player.getLocation().add(0, QUOTE_HEIGHT + offset, 0), + C.cWhite + quote[i])); + offset += 0.25; + } + + for (Hologram hologram : holograms) + { + hologram.setViewDistance(VIEW_DISTANCE); + hologram.setFollowEntity(player); + hologram.start(); + } + + // remove hologram a certain number of seconds later + Bukkit.getServer().getScheduler().runTaskLater(UtilServer.getPlugin(), () -> + holograms.forEach(Hologram::stop), QUOTE_PERSISTENCE * 20); + } } } } From 9c48919e4263939714929302d8b49a50b6272306 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 27 May 2017 17:58:53 -0500 Subject: [PATCH 069/283] Reduce paint time down to 30 seconds --- .../core/gadget/gadgets/morph/MorphBobRoss.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java index bbc296896..8a2a18b4d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java @@ -53,7 +53,7 @@ public class MorphBobRoss extends MorphGadget private static final int DESTROY_LIMIT = 20; /** The # of minutes for which paint blocks exist */ - private static final int PAINT_MINUTES = 1; + private static final int PAINT_SECONDS = 30; /** Height above a player's location at which quotes are to be displayed */ private static final double QUOTE_HEIGHT = 2.25; @@ -278,20 +278,26 @@ public class MorphBobRoss extends MorphGadget if (event.getType() == UpdateType.FASTER) // do paint removal { int limit = 0; + int offset = 0; // destroy up to 20 paint blocks that are older than a set number of minutes while (!_paintBlocks.isEmpty() - && _paintBlocks.get(0).time < System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(PAINT_MINUTES) + && offset < _paintBlocks.size() + && _paintBlocks.get(offset).time < System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(PAINT_SECONDS) && limit < DESTROY_LIMIT) { - Block block = _paintBlocks.remove(0).block; + Block block = _paintBlocks.get(0).block; if (block.getType() == Material.CARPET) { + _paintBlocks.remove(0); block.setType(Material.AIR); + limit++; + } + else + { + offset++; } - - limit++; } } else if (event.getType() == UpdateType.TICK) // do random quote displaying From cf8109b3bd17bf2afaef6ad7840977c7d965dfec Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 27 May 2017 20:00:00 -0500 Subject: [PATCH 070/283] Add method for detecting bottom slabs to UtilBlock --- .../mineplex/core/common/util/UtilBlock.java | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index 91c93c620..acfa65274 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -378,7 +378,45 @@ public class UtilBlock { return fullSolid.contains(block); } - + + /** + * Determines whether a block is a bottom slab. + * + * @param block The block object. + * + * @return true if block is a bottom slab. + */ + public static boolean bottomSlab(Block block) + { + return bottomSlab(block.getType().getId(), block.getData()); + } + + /** + * Determines whether a block is a bottom slab. + * + * @param block The block id + * @param data The block data + * + * @return true if block is a bottom slab. + */ + public static boolean bottomSlab(int block, byte data) + { + switch (block) + { + case 44: + if (data >= 0 && data <= 7) return true; + break; + case 182: + if (data == 0) return true; + break; + case 126: + if (data >= 0 && data <= 5) return true; + break; + } + + return false; + } + public static boolean usable(Block block) { if (block == null) return false; From a87685eae0ed497719f3ee7e5b66a536a0a0e974 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 27 May 2017 20:00:28 -0500 Subject: [PATCH 071/283] Change color selector and put colors in order --- .../gadget/gadgets/morph/MorphBobRoss.java | 174 ++++++++++++++---- 1 file changed, 143 insertions(+), 31 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java index 8a2a18b4d..7217d82c6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java @@ -13,6 +13,7 @@ import java.util.concurrent.TimeUnit; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; @@ -28,6 +29,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import com.mojang.authlib.GameProfile; @@ -49,12 +51,15 @@ public class MorphBobRoss extends MorphGadget /** The inventory slot in which the paint brush is placed */ private static final int PAINT_BRUSH_SLOT = 2; - /** Max # of blocks that can be destroyed every half second */ - private static final int DESTROY_LIMIT = 20; + /** Max # of blocks that can be destroyed every quarter second, per player */ + private static final int DESTROY_LIMIT = 4; - /** The # of minutes for which paint blocks exist */ + /** The # of seconds for which paint blocks exist */ private static final int PAINT_SECONDS = 30; + /** The # of minutes after which the code will stop trying to remove paint */ + private static final int PAINT_EXPIRE = 10; + /** Height above a player's location at which quotes are to be displayed */ private static final double QUOTE_HEIGHT = 2.25; @@ -67,12 +72,6 @@ public class MorphBobRoss extends MorphGadget /** Cooldown time for changing paint colors (milliseconds) */ private static final long COLOR_COOLDOWN = 220; - /** Cooldown key for cleaning and putting paint on the brush */ - private static final String PAINT_KEY = "Beat The Devil Out Of It"; - - /** Cooldown time for cleaning and putting paint on the brush (milliseconds) */ - private static final long PAINT_COOLDOWN = 700; - /** Cooldown key for displaying a Bob Ross quote above head */ private static final String QUOTE_KEY = "Bob Ross Quote"; @@ -88,6 +87,26 @@ public class MorphBobRoss extends MorphGadget /** Formatted name for the clean brush */ private static final String BRUSH_NAME = C.cYellow + "Clean Paintbrush"; + /** Determines the order in which colors are selected */ + private static final byte[] COLOR_ORDER = { + (byte) 1, + (byte) 14, + (byte) 11, + (byte) 10, + (byte) 2, + (byte) 6, + (byte) 12, + (byte) 4, + (byte) 5, + (byte) 13, + (byte) 9, + (byte) 15, + (byte) 7, + (byte) 8, + (byte) 0, + (byte) 3 + }; + /** Paint colors for displaying in players' hotbars */ private static final String[] PAINT_COLORS = { C.cBlackB + "Midnight Black", @@ -146,7 +165,7 @@ public class MorphBobRoss extends MorphGadget {"The only thing worse than", "yellow snow is green snow."}, {"Look around.", "Look at what we have.", "Beauty is everywhere—", "you only have to look to see it."}, {"Just go out and talk to a tree.", "Make friends with it."}, - {"How do you make a round circle with a square knife? That’s your challenge for the day."}, + {"How do you make a round circle with a square knife?", "That’s your challenge for the day."}, {"Water's like me. It's laaazy...", "Boy, it always looks for the easiest way to do things"}, {"Oooh, if you have never been to Alaska,", "go there while it is still wild."}, {"If I paint something,", "I don't want to have to explain what it is."}, @@ -177,6 +196,8 @@ public class MorphBobRoss extends MorphGadget /** Map of items in players' inventories */ private final Map _inventoryItems = new HashMap<>(); + private final Map _paintColors = new HashMap<>(); + /** Blocks that have been painted */ private final List _paintBlocks = new ArrayList<>(); @@ -188,11 +209,11 @@ public class MorphBobRoss extends MorphGadget C.cGray + "Become the creator of your own world!", C.cGray + "Leave a trail of paint behind you as you walk.", "", - C.cGreen + "Right click " + C.cWhite + "on your " + C.cYellow + "Paintbrush" + C.cWhite + " (stick) to paint", + C.cGreen + "Hold " + C.cWhite + "your " + C.cYellow + "paintbrush" + C.cWhite + " (stick) to paint.", "", - C.cGreen + "Right click " + C.cWhite + "on your " + C.cYellow + "Paint" + C.cWhite + " (dyes) to stop painting", - "", - C.cGreen + "Left click " + C.cWhite + "on your " + C.cYellow + "Paint " + C.cWhite + "to change paintbrush colors.", + C.cGreen + "Left" + C.cWhite + " and " + C.cGreen + "right click" + C.cWhite + " on your", + C.cYellow + "paintbrush" + C.cWhite + " and " + C.cYellow + "paints" + C.cWhite + " (dyes)", + C.cWhite + "to change paint colors.", "", C.cGreen + "Crouch " + C.cWhite + "to say a Bob Ross quote." }, LineFormat.LORE), -14, Material.PAINTING, (byte) 0, YearMonth.of(2017, Month.JUNE)); @@ -256,14 +277,14 @@ public class MorphBobRoss extends MorphGadget { if (Recharge.Instance.use(event.getPlayer(), COLOR_KEY, COLOR_COOLDOWN, false, false)) { - changePaintColor(event.getPlayer()); + changePaintColor(event.getPlayer(), true); } } else if (UtilEvent.isAction(event, UtilEvent.ActionType.R)) { - if (Recharge.Instance.use(event.getPlayer(), PAINT_KEY, PAINT_COOLDOWN, false, false)) + if (Recharge.Instance.use(event.getPlayer(), COLOR_KEY, COLOR_COOLDOWN, false, false)) { - togglePainting(event.getPlayer()); + changePaintColor(event.getPlayer(), false); } } } @@ -280,27 +301,35 @@ public class MorphBobRoss extends MorphGadget int limit = 0; int offset = 0; - // destroy up to 20 paint blocks that are older than a set number of minutes + // destroy paint blocks that are too old while (!_paintBlocks.isEmpty() && offset < _paintBlocks.size() && _paintBlocks.get(offset).time < System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(PAINT_SECONDS) - && limit < DESTROY_LIMIT) + && limit < DESTROY_LIMIT * getActive().size()) { - Block block = _paintBlocks.get(0).block; + Block block = _paintBlocks.get(offset).block; if (block.getType() == Material.CARPET) { - _paintBlocks.remove(0); + _paintBlocks.remove(offset); block.setType(Material.AIR); limit++; } else { - offset++; + // stop trying to remove paint after a certain amount of time + if (_paintBlocks.get(offset).time > System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(PAINT_EXPIRE)) + { + _paintBlocks.remove(offset); + } + else + { + offset++; + } } } } - else if (event.getType() == UpdateType.TICK) // do random quote displaying + else if (event.getType() == UpdateType.TICK) // do quote displaying { for (Player player : getActive()) { @@ -338,6 +367,25 @@ public class MorphBobRoss extends MorphGadget } } } + else if (event.getType() == UpdateType.FASTEST) + { + for (Player player : getActive()) + { + if (_inventoryItems.containsKey(player.getUniqueId())) + { + ItemStack item = _inventoryItems.get(player.getUniqueId()); + + if (item.getType() == Material.STICK && player.getItemInHand().equals(item)) + { + togglePainting(player); + } + else if (!player.getItemInHand().equals(item) && item.getType() != Material.STICK) + { + togglePainting(player); + } + } + } + } } /** @@ -364,12 +412,12 @@ public class MorphBobRoss extends MorphGadget } Block block = player.getLocation().getBlock(); - Material down = block.getRelative(BlockFace.DOWN).getType(); + Block down = block.getRelative(BlockFace.DOWN); boolean carpet = block.getType() == Material.CARPET; // check that there is room to paint and that the block below is solid and not more paint. - if ((block.isEmpty() || carpet) && down.isSolid() && down != Material.CARPET) + if ((block.isEmpty() || carpet) && UtilBlock.fullSolid(down) && !UtilBlock.bottomSlab(down)) { int index; PaintedBlock blk = new PaintedBlock(block); @@ -398,14 +446,28 @@ public class MorphBobRoss extends MorphGadget } /** - * Cycle the selected paint color for a player. + * Clean hash maps on player disconnect. */ - private void changePaintColor(Player player) + @EventHandler + public void onPlayerDisconnect(PlayerQuitEvent event) + { + if (isActive(event.getPlayer())) + { + UUID uuid = event.getPlayer().getUniqueId(); + _inventoryItems.remove(uuid); + _paintColors.remove(uuid); + } + } + + /** + * Cycle the selected paint color for a player. + * + * @param reverse Whether to cycle backwards through colors. + */ + private void changePaintColor(Player player, boolean reverse) { ItemStack item = _inventoryItems.remove(player.getUniqueId()); - byte data = item.getData().getData(); - data++; - if (data > 15) data = 0; + byte data = selectPaintColor(player, reverse); ItemStack newItem = ItemStackFactory.Instance.CreateStack(Material.INK_SACK, data, 1, PAINT_COLORS[data] + " " + PAINT_BRUSHES[ThreadLocalRandom.current().nextInt(0, PAINT_BRUSHES.length)]); @@ -426,12 +488,17 @@ public class MorphBobRoss extends MorphGadget ItemStack newItem; if (item.getType() == Material.STICK) { - byte data = ((byte) ThreadLocalRandom.current().nextInt(0, 16)); + byte data = selectPaintColor(player, false); newItem = ItemStackFactory.Instance.CreateStack(Material.INK_SACK, data, 1, PAINT_COLORS[data] + " " + PAINT_BRUSHES[ThreadLocalRandom.current().nextInt(0, PAINT_BRUSHES.length)]); } else { + if (_paintColors.containsKey(player.getUniqueId())) + { + _paintColors.remove(player.getUniqueId()); + } + newItem = ItemStackFactory.Instance.CreateStack(Material.STICK, (byte) 0, 1, BRUSH_NAME); } @@ -441,6 +508,51 @@ public class MorphBobRoss extends MorphGadget player.updateInventory(); } + /** + * Changes the paint color currently assigned to a player. + * If one is not assigned, a new one will be given. + * + * @param player The player to whom to assign the paint color. + * @param reverse Whether to reverse through paint colors when choosing a new one. + * + * @return the dye data value for the newly selected color. + */ + private byte selectPaintColor(Player player, boolean reverse) + { + UUID uuid = player.getUniqueId(); + + int value; + + if (!_paintColors.containsKey(uuid)) + { + value = ThreadLocalRandom.current().nextInt(0, 16); + _paintColors.put(uuid, value); + } + else + { + value = _paintColors.get(uuid); + + if (reverse) + { + if (--value < 0) + { + value = 15; + } + } + else + { + if (++value > 15) + { + value = 0; + } + } + + _paintColors.put(uuid, value); + } + + return COLOR_ORDER[value]; + } + /** * Give a paintbrush item to a player. */ From 6e2d39035de488a805db08a547d25ea96be18567 Mon Sep 17 00:00:00 2001 From: cnr Date: Tue, 30 May 2017 22:50:41 -0500 Subject: [PATCH 072/283] Add Bob Ross morph to PPC for June --- .../src/mineplex/core/powerplayclub/PowerPlayClubRewards.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 1857154fc..02388b67c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -38,6 +38,7 @@ public class PowerPlayClubRewards .put(YearMonth.of(2017, Month.MARCH), new UnknownSalesPackageItem("Gold Pot Morph")) .put(YearMonth.of(2017, Month.APRIL), new UnknownSalesPackageItem("Bumblebee's Wings")) .put(YearMonth.of(2017, Month.MAY), new UnknownSalesPackageItem("King")) + .put(YearMonth.of(2017, Month.JUNE), new UnknownSalesPackageItem("Bob Ross Morph")) .build(); public interface PowerPlayClubItem From ffdd82c34edd92c051455138a1ded851040200c3 Mon Sep 17 00:00:00 2001 From: Kenny Goodin Date: Wed, 31 May 2017 02:02:30 -0400 Subject: [PATCH 073/283] Ignore quests in QuestDaemon process that have a cost of -1 --- .../src/mineplex/quest/common/BaseQuest.java | 10 +++++++++- .../src/mineplex/quest/common/Quest.java | 10 ++++++++++ .../src/mineplex/quest/common/Quests.java | 4 +++- .../src/mineplex/quest/daemon/QuestManager.java | 4 ++-- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/BaseQuest.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/BaseQuest.java index 5b778bf50..2f5215e75 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/common/BaseQuest.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/BaseQuest.java @@ -9,11 +9,13 @@ public class BaseQuest implements Quest private final int _uniqueId; private final String _name; private final QuestRarity _rarity; + private final int _cost; - public BaseQuest(int uniqueId, String name, QuestRarity rarity) + public BaseQuest(int uniqueId, String name, int cost, QuestRarity rarity) { _uniqueId = uniqueId; _name = name; + _cost = cost; _rarity = rarity; } @@ -41,4 +43,10 @@ public class BaseQuest implements Quest return _uniqueId + ""; } + @Override + public boolean shouldRotate() + { + return _cost != -1; + } + } diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quest.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quest.java index 3802b928d..f2c7ac799 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quest.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quest.java @@ -1,5 +1,6 @@ package mineplex.quest.common; +import mineplex.quest.daemon.QuestManager; import mineplex.serverdata.data.Data; import mineplex.serverdata.data.DataRepository; @@ -40,4 +41,13 @@ public interface Quest extends Data */ @Override String getDataId(); + + /** + * Checks whether this quest should be selected by the {@link QuestManager} daemon process. + * Quests with a cost of -1 should not ever be selected as active quests by the daemon. + * + * @return true if this quest should be selected as an active quest, or + * false otherwise. + */ + boolean shouldRotate(); } diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quests.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quests.java index 34f16c4d9..1b1bd41dd 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quests.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/Quests.java @@ -24,6 +24,7 @@ public class Quests private static final int UNIQUE_ID_COLUMN = 0; private static final int NAME_COLUMN = 1; + private static final int COST_COLUMN = 4; private static final int RARITY_COLUMN = 9; public static final Set QUESTS; @@ -46,9 +47,10 @@ public class Quests { int uniqueId = Integer.parseInt(row.get(UNIQUE_ID_COLUMN)); String name = row.get(NAME_COLUMN); + int cost = Integer.parseInt(row.get(COST_COLUMN)); QuestRarity rarity = QuestRarity.valueOf(row.get(RARITY_COLUMN).toUpperCase()); - Quest quest = new BaseQuest(uniqueId, name, rarity); + Quest quest = new BaseQuest(uniqueId, name, cost, rarity); builder.add(quest); } diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java index 9a7025b85..e303b71de 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java @@ -243,8 +243,8 @@ public class QuestManager extends Thread { Quest q = _quests.next(); // select random weighted quest, ignore those recently selected - if (_activeQuests.contains(q) - || _recentlySelectedQuestsRepo.elementExists(q.getDataId())) + if (!q.shouldRotate() || _activeQuests.contains(q) + || _recentlySelectedQuestsRepo.elementExists(q.getDataId())) { // quest is already active or it's been active recently continue; From 028a4ecce32bf7c883aaca7580752c1a18691a92 Mon Sep 17 00:00:00 2001 From: Kenny Goodin Date: Wed, 31 May 2017 02:15:23 -0400 Subject: [PATCH 074/283] Remove author tag --- .../src/mineplex/quest/common/util/UtilGoogleSheet.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/UtilGoogleSheet.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/UtilGoogleSheet.java index 53aa8731e..6dee08b44 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/UtilGoogleSheet.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/util/UtilGoogleSheet.java @@ -16,8 +16,6 @@ import com.google.gson.JsonParser; /** * Provides utility methods for deserializing google sheets json files. - * @author Kenny - * */ public class UtilGoogleSheet { From ff1212192656a54971bbdf8b8fb0518ed6437f94 Mon Sep 17 00:00:00 2001 From: Kenny Goodin Date: Wed, 31 May 2017 02:35:16 -0400 Subject: [PATCH 075/283] Fix QuestDaemon command that didn't actually do anything --- .../src/mineplex/quest/daemon/QuestManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java index e303b71de..eb5aaae50 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java @@ -229,7 +229,8 @@ public class QuestManager extends Thread public void clearRecentlyActiveQuests() { - _recentlySelectedQuestsRepo.clean(); + _recentlySelectedQuestsRepo.getElements() + .forEach(_recentlySelectedQuestsRepo::removeElement); } private void selectRandomQuests() From 0edd2c89478d6f8f9d42d691327a155ac5c1734e Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 31 May 2017 13:05:06 +0100 Subject: [PATCH 076/283] Feedback from testing --- .../game/arcade/game/games/moba/Moba.java | 112 ++++++++++-- .../arcade/game/games/moba/ai/MobaAI.java | 2 +- .../moba/ai/goal/MobaDirectAIMethod.java | 29 +-- .../game/games/moba/boss/BossManager.java | 8 + .../games/moba/boss/pumpkin/PumpkinBoss.java | 125 ++++++++++--- .../games/moba/boss/wither/WitherBoss.java | 40 +++-- .../boss/wither/WitherSkullProjectile.java | 5 +- .../games/moba/fountain/MobaFountain.java | 2 +- .../games/moba/general/ArrowKBManager.java | 41 +++++ ...ageManager.java => MobaDamageManager.java} | 20 ++- .../game/games/moba/gold/GoldManager.java | 44 +++++ .../arcade/game/games/moba/kit/HeroSkill.java | 57 +++++- .../moba/kit/anath/SkillFireProjectile.java | 5 +- .../games/moba/kit/anath/SkillMeteor.java | 2 + .../moba/kit/bob/SkillBuildPainting.java | 2 + .../game/games/moba/kit/bob/SkillPaint.java | 5 +- .../game/games/moba/kit/common/DashSkill.java | 3 +- .../game/games/moba/kit/dana/SkillRally.java | 9 + .../game/games/moba/kit/devon/HeroDevon.java | 3 +- .../game/games/moba/kit/devon/SkillBoost.java | 3 +- .../games/moba/kit/devon/SkillInfinity.java | 7 + .../games/moba/kit/devon/SkillTNTArrows.java | 4 + .../moba/kit/hattori/SkillNinjaBlade.java | 8 +- .../games/moba/kit/hattori/SkillSnowball.java | 5 +- .../arcade/game/games/moba/minion/Minion.java | 6 +- .../game/games/moba/minion/MinionWave.java | 25 ++- .../moba/prepare/PrepareInformation.java | 2 +- .../games/moba/prepare/PrepareManager.java | 9 +- .../moba/structure/point/CapturePoint.java | 84 +++++++-- .../structure/point/CapturePointManager.java | 54 +++++- .../games/moba/structure/tower/Tower.java | 48 ++++- .../moba/structure/tower/TowerManager.java | 120 +++++++++---- .../game/games/moba/util/MobaConstants.java | 1 + .../arcade/game/games/moba/util/MobaUtil.java | 57 +++--- .../game/modules/CustomScoreboardModule.java | 170 ++++++++++++++++-- 35 files changed, 898 insertions(+), 219 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/ArrowKBManager.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/{TeamDamageManager.java => MobaDamageManager.java} (78%) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index e5bedf6cb..286854643 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,7 +1,11 @@ package nautilus.game.arcade.game.games.moba; import mineplex.core.common.Rank; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.minecraft.game.core.combat.DeathMessageType; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -12,7 +16,8 @@ import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.boss.BossManager; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; -import nautilus.game.arcade.game.games.moba.general.TeamDamageManager; +import nautilus.game.arcade.game.games.moba.general.ArrowKBManager; +import nautilus.game.arcade.game.games.moba.general.MobaDamageManager; import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.KitPlayer; @@ -33,6 +38,7 @@ import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.scoreboard.GameScoreboard; +import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Arrow; @@ -44,7 +50,13 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.TimeUnit; public class Moba extends TeamGame @@ -66,6 +78,7 @@ public class Moba extends TeamGame private final BossManager _boss; private final TowerManager _tower; private final CapturePointManager _capturePoint; + private final ArrowKBManager _arrowKb; public Moba(ArcadeManager manager) { @@ -88,13 +101,15 @@ public class Moba extends TeamGame HungerSet = 20; DamageFall = false; + manager.GetCreature().SetDisableCustomDrops(true); + // Instantiate managers // Global managers _shop = registerManager(new MobaShop(this)); _goldManager = registerManager(new GoldManager(this)); registerManager(new HPManager(this)); - registerManager(new TeamDamageManager(this)); + registerManager(new MobaDamageManager(this)); registerManager(new MobaFountain(this)); registerManager(new Recall(this)); @@ -112,6 +127,9 @@ public class Moba extends TeamGame // Minions registerManager(new MinionManager(this)); + // Arrow Knockback + _arrowKb = registerManager(new ArrowKBManager(this)); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -176,6 +194,9 @@ public class Moba extends TeamGame return C.cYellow + " " + suffix + C.Reset; }) + .setUnderNameObjective(C.cRed + "❤") + .setUnderName((perspective, subject) -> + (int) (Math.ceil(subject.getHealth() / 2D))) .register(this); registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) @@ -183,14 +204,14 @@ public class Moba extends TeamGame @Override public void Execute(Player caller, String[] args) { - String kit = ""; + StringBuilder builder = new StringBuilder(); for (String arg : args) { - kit += arg + " "; + builder.append(arg).append(" "); } - kit = kit.trim(); + String kit = builder.toString().trim(); for (Kit kits : _kits) { @@ -223,6 +244,8 @@ public class Moba extends TeamGame { locations.forEach(location -> location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, GetSpectatorLocation())))); } + + SpectatorSpawn = WorldData.GetCustomLocs("CENTER").get(0); } private void writePrepare(Player player, GameScoreboard scoreboard) @@ -259,21 +282,44 @@ public class Moba extends TeamGame private void writeLive(Player player, GameScoreboard scoreboard) { + GameTeam team = GetTeam(player); + boolean alive = IsAlive(player); + scoreboard.writeNewLine(); -// GameTeam team = GetTeam(player); -// boolean blueBottom = team == null || team.GetColor() == ChatColor.BLUE; -// -// // Tower Data -// List lines = new ArrayList<>(); -// GameTeam red = GetTeam(ChatColor.RED); -// GameTeam blue = GetTeam(ChatColor.AQUA); -// -// lines.add("♚"); + // Towers + GameTeam red = GetTeam(ChatColor.RED); + GameTeam blue = GetTeam(ChatColor.AQUA); + String redTitle; + String blueTitle; + + if (alive) + { + boolean playerRed = team.equals(red); + redTitle = playerRed ? "Your Team" : "Enemy Team"; + blueTitle = playerRed ? "Enemy Team" : "Your Team"; + } + else + { + redTitle = "Red Team"; + blueTitle = "Blue Team"; + } + + scoreboard.write(red.GetColor() + C.Bold + redTitle); + scoreboard.write("Base: " + _tower.getDisplayString(red) + _boss.getWitherDisplayString(red)); + scoreboard.write("Beacons: " + _capturePoint.getDisplayString(red)); + + scoreboard.writeNewLine(); + + scoreboard.write(blue.GetColor() + C.Bold + blueTitle); + scoreboard.write("Base: " + _tower.getDisplayString(blue) + _boss.getWitherDisplayString(blue)); + scoreboard.write("Beacons: " + _capturePoint.getDisplayString(blue)); + + scoreboard.writeNewLine(); // Gold - scoreboard.write(C.cGoldB + "Gold"); - if (IsAlive(player)) + scoreboard.write(C.cGoldB + "Your Gold"); + if (alive) { int gold = _goldManager.getGold(player); @@ -553,6 +599,31 @@ public class Moba extends TeamGame return players; } + public boolean isRoleFree(Player player, MobaRole role) + { + GameTeam team = GetTeam(player); + + if (team == null) + { + return false; + } + + for (MobaPlayer mobaPlayer : getTeamData(team)) + { + if (mobaPlayer.getRole() == role) + { + return false; + } + } + + return true; + } + + public CustomScoreboardModule getScoreboardModule() + { + return getModule(CustomScoreboardModule.class); + } + public MobaShop getShop() { return _shop; @@ -577,4 +648,9 @@ public class Moba extends TeamGame { return _boss; } + + public ArrowKBManager getArrowKbManager() + { + return _arrowKb; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 0bd0540ce..59ba0cffa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -46,7 +46,7 @@ public class MobaAI return; } - if (_target == null) + if (_target == null || _target.isDead() || !_target.isValid()) { _target = MobaUtil.getBestEntityTarget(_host, _owner, _entity, _home, _host.WorldData.GetDataLocs(getBoundaryKey())); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index 69ebbaa4c..45035f8c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -9,13 +9,10 @@ import org.bukkit.util.Vector; public class MobaDirectAIMethod implements MobaAIMethod { - private static final float YAW_SNAP_LIMIT = 30F; - @Override public boolean updateMovement(LivingEntity entity, Location goal, float speed) { Location entityLocation = entity.getLocation(); - float entityYaw = entityLocation.getYaw(); // Speed is blocks per second float magnitude = speed / 20F; @@ -25,32 +22,10 @@ public class MobaDirectAIMethod implements MobaAIMethod // From the direction, get the yaw of this direction float directionYaw = UtilAlg.GetYaw(direction); + entityLocation.setYaw(directionYaw); - // Get the absolute yaw offset from the direction - // This can then be used to see how far the entity is - // looking away from the goal - float yawOffset = Math.abs(directionYaw - entityYaw); - - // If the entity is facing too far away from the goal to consider the - // "Head Snapping" of turning the entity too severe - if (yawOffset > YAW_SNAP_LIMIT) - { - // Facing too far right - if (entityYaw > directionYaw) - { - entityYaw -= YAW_SNAP_LIMIT; - } - // Facing too far left - else - { - entityYaw += YAW_SNAP_LIMIT; - } - - // Only alter the entity's yaw - entityLocation.setYaw(entityYaw); - } // If reached the goal - else if (UtilMath.offsetSquared(entityLocation, goal) < 4) + if (UtilMath.offsetSquared(entityLocation, goal) < 4) { return false; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java index 156271af5..f2a0ef23c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -6,6 +6,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.boss.pumpkin.PumpkinBoss; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.world.WorldData; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -74,6 +75,13 @@ public class BossManager implements Listener _pumpkinBoss.cleanup(); } + public String getWitherDisplayString(GameTeam team) + { + WitherBoss boss = getWitherBoss(team); + + return MobaUtil.getColour(boss.getHealthPercentage()) + "♚"; + } + public WitherBoss getWitherBoss(GameTeam team) { return _teamBosses.get(team); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 741b0b15b..08e913ece 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.boss.pumpkin; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; @@ -24,9 +25,11 @@ import nautilus.game.arcade.game.games.moba.ai.MobaAI; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; import org.bukkit.Bukkit; +import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -38,11 +41,14 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffectType; import java.util.HashSet; +import java.util.Iterator; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -50,18 +56,20 @@ import java.util.concurrent.TimeUnit; public class PumpkinBoss extends MobaBoss { - private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(1); - private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(1); + private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); + private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN); private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD); private static final String DAMAGE_REASON = "Pumpkin King"; private static final String CONDITION_REASON = DAMAGE_REASON + " Buff"; - private static final int CONDITION_LENGTH = (int) TimeUnit.MINUTES.toSeconds(3); - private static final int DAMAGE_RADIUS = 3; - private static final int DAMAGE_RANGE = 4; - private static final int DAMAGE_DIRECT = 10; + private static final int CONDITION_LENGTH = 60; + private static final double CONDITION_DAMAGE_FACTOR = 1.5; + private static final int DAMAGE_RADIUS = 2; + private static final int DAMAGE_RANGE = 3; + private static final int DAMAGE_DIRECT = 8; private static final int DAMAGE_DIRECT_RADIUS_SQUARED = 9; + private static final int HEALTH = 400; private static final Material[] BLOCKS = { Material.OBSIDIAN, Material.NETHERRACK, @@ -71,12 +79,14 @@ public class PumpkinBoss extends MobaBoss private MobaAI _ai; private boolean _initialSpawn; private final Set _changed; + private final Set _buffs; public PumpkinBoss(Moba host, Location location) { super(host, location, RESPAWN_TIME); _changed = new HashSet<>(); + _buffs = new HashSet<>(); } @Override @@ -97,6 +107,8 @@ public class PumpkinBoss extends MobaBoss skeleton.setCustomNameVisible(true); skeleton.getEquipment().setHelmet(HELMET); skeleton.getEquipment().setItemInHand(IN_HAND); + skeleton.setMaxHealth(HEALTH); + skeleton.setHealth(HEALTH); UtilEnt.vegetate(skeleton); UtilEnt.setFakeHead(skeleton, true); @@ -104,7 +116,7 @@ public class PumpkinBoss extends MobaBoss skeleton.getWorld().strikeLightningEffect(skeleton.getLocation()); UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10); - _host.Announce(C.cRedB + "The Pumpkin King Has Awoken!", false); + _host.Announce(F.main("Game", C.cRedB + "The Pumpkin King Has Awoken!"), false); for (Player player : Bukkit.getOnlinePlayers()) { @@ -191,27 +203,32 @@ public class PumpkinBoss extends MobaBoss giveBuffs(team); - String base = C.mBody + "killed the " + C.cDRedB + "Pumpkin King"; - _host.Announce(team.GetFormattedName() + " " + base + C.mBody + "! They have been given buffs!", false); - UtilTextMiddle.display(team.GetFormattedName(), base, 10, 40, 10); + _host.Announce(F.main("Game", team.GetFormattedName() + C.mBody + " killed the " + C.cDRedB + DAMAGE_REASON), false); + UtilTextMiddle.display("", team.GetFormattedName() + C.cWhite + " killed the " + C.cDRedB + DAMAGE_REASON, 10, 40, 10); for (Block block : _changed) { _host.getArcadeManager().GetBlockRestore().restore(block); } + event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.EXPLODE, 1, 0.2F); UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, event.getEntity().getEyeLocation(), 1, 1, 1, 0.1F, 3, ViewDist.LONG); } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void entityDamage(CustomDamageEvent event) { - if (!event.GetDamageeEntity().equals(_entity) || event.GetCause() != DamageCause.SUFFOCATION) + if (!event.GetDamageeEntity().equals(_entity)) { return; } - event.SetCancelled("Pumpkin King Suffocation"); + updateDisplay(); + + if (event.GetCause() == DamageCause.SUFFOCATION) + { + event.SetCancelled("Pumpkin King Suffocation"); + } } @EventHandler @@ -224,7 +241,7 @@ public class PumpkinBoss extends MobaBoss if (_ai.getTarget() != null && !UtilPlayer.isSpectator(_ai.getTarget()) && UtilMath.offsetSquared(_entity, _ai.getTarget()) < DAMAGE_DIRECT_RADIUS_SQUARED) { - _host.getArcadeManager().GetDamage().NewDamageEvent(_ai.getTarget(), _entity, null, DamageCause.CUSTOM, DAMAGE_DIRECT, true, true, false, UtilEnt.getName(_entity), DAMAGE_REASON); + _host.getArcadeManager().GetDamage().NewDamageEvent(_ai.getTarget(), _entity, null, DamageCause.CUSTOM, DAMAGE_DIRECT, true, true, false, DAMAGE_REASON, DAMAGE_REASON); // Send a fake hit packet // Magic number 0 means swing item/attack @@ -243,36 +260,90 @@ public class PumpkinBoss extends MobaBoss continue; } - _host.getArcadeManager().GetDamage().NewDamageEvent(entity, _entity, null, DamageCause.CUSTOM, DAMAGE_RANGE, false, true, false, UtilEnt.getName(entity), DAMAGE_REASON); + _host.getArcadeManager().GetDamage().NewDamageEvent(entity, _entity, null, DamageCause.CUSTOM, DAMAGE_RANGE, false, true, false, DAMAGE_REASON, DAMAGE_REASON); UtilAction.velocity(entity, UtilAlg.getTrajectory(_entity, entity).setY(1)); UtilParticle.PlayParticleToAll(ParticleType.FLAME, entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 5, ViewDist.LONG); } } + private void updateDisplay() + { + _entity.setCustomName(MobaUtil.getHealthBar(_entity, 20)); + } + private void giveBuffs(GameTeam team) { ConditionFactory factory = _host.getArcadeManager().GetCondition().Factory(); for (Player player : team.GetPlayers(true)) { - factory.Regen(CONDITION_REASON, player, null, CONDITION_LENGTH, 2, false, true, false); - factory.Strength(CONDITION_REASON, player, null, CONDITION_LENGTH, 1, false, true, false); + factory.Regen(CONDITION_REASON, player, null, CONDITION_LENGTH, 1, false, true, false); UtilParticle.PlayParticleToAll(ParticleType.LAVA, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG); player.playSound(player.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F); + player.sendMessage(F.main("Game", "You feel the power of the Pumpkin King flow through you. Your damage and regeneration are increased!")); + _buffs.add(player); - // Magic number 4 means helmet - PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(HELMET)); + sendFakeHelmet(player); + } + } - for (Player other : Bukkit.getOnlinePlayers()) + @EventHandler + public void updateFakeHelmet(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + { + return; + } + + Iterator iterator = _buffs.iterator(); + + while (iterator.hasNext()) + { + Player player = iterator.next(); + + if (!player.isOnline() || !player.hasPotionEffect(PotionEffectType.REGENERATION)) { - // Don't send wearer their own data - if (other.equals(player)) - { - continue; - } - - UtilPlayer.sendPacket(other, packet); + iterator.remove(); } + + sendFakeHelmet(player); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void damageIncrease(CustomDamageEvent event) + { + if (event.isCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + Player damager = event.GetDamagerPlayer(true); + + if (damager == null || !_buffs.contains(damager)) + { + return; + } + + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, damagee.getLocation().add(0, 0.5, 0), 0.25F, 0.25F, 0.25F, 10, 1, ViewDist.NORMAL); + event.AddMod(CONDITION_REASON, CONDITION_DAMAGE_FACTOR); + } + + private void sendFakeHelmet(Player player) + { + // Magic number 4 means helmet + PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(HELMET)); + + for (Player other : Bukkit.getOnlinePlayers()) + { + // Don't send wearer their own data + if (other.equals(player)) + { + continue; + } + + UtilPlayer.sendPacket(other, packet); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 9d0ce78dd..b70326896 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -1,11 +1,11 @@ package nautilus.game.arcade.game.games.moba.boss.wither; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; 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.UtilTextTop; -import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -34,14 +34,12 @@ public class WitherBoss extends MobaBoss private static final float SPEED_TARGET = 7F; private static final float SPEED_HOME = 9F; private static final int INITIAL_HEALTH = 1750; - private static final int FIRST_TOWER_HEALTH_REDUCTION = 100; - private static final int SECOND_TOWER_HEALTH_REDUCTION = 250; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private GameTeam _team; private MobaAI _ai; - private DisguiseWither _disguise; + private boolean _damageable; public WitherBoss(Moba host, Location location, GameTeam team) { @@ -56,10 +54,13 @@ public class WitherBoss extends MobaBoss { ArmorStand stand = _location.getWorld().spawn(_location, ArmorStand.class); + // Reducing the wither's health to 10% gives a shield like effect. stand.setMaxHealth(INITIAL_HEALTH); - stand.setHealth(INITIAL_HEALTH); + stand.setHealth(INITIAL_HEALTH * 0.1); stand.setGravity(false); + UtilEnt.setBoundingBox(stand, 3, 5); + _disguise = new DisguiseWither(stand); _disguise.setName(_team.GetColor() + _team.GetName() + "\'s Wither"); _disguise.setCustomNameVisible(true); @@ -102,11 +103,18 @@ public class WitherBoss extends MobaBoss event.SetCancelled("Wither Boss"); + // Fire doesn't damage the wither if (event.GetCause() == DamageCause.FIRE || event.GetCause() == DamageCause.FIRE_TICK) { return; } + // If not damageable + if (!_damageable) + { + return; + } + LivingEntity damagee = event.GetDamageeEntity(); Player damager = event.GetDamagerPlayer(true); @@ -147,16 +155,13 @@ public class WitherBoss extends MobaBoss return; } - if (tower.isFirstTower()) + // Here we can remove the shield effect, as the wither is no longer invincible + if (!tower.isFirstTower()) { - _entity.setHealth(_entity.getHealth() - FIRST_TOWER_HEALTH_REDUCTION); + _damageable = true; + _entity.setHealth(INITIAL_HEALTH); + updateDisplay(); } - else - { - _entity.setHealth(_entity.getHealth() - SECOND_TOWER_HEALTH_REDUCTION); - } - - updateDisplay(); } @EventHandler @@ -167,14 +172,19 @@ public class WitherBoss extends MobaBoss return; } - double percent = _entity.getHealth() / _entity.getMaxHealth(); + double percent = getHealthPercentage(); for (Player player : _team.GetPlayers(true)) { - UtilTextTop.displayTextBar(player, percent, _team.GetColor() + "Your Wither"); + UtilTextTop.displayTextBar(player, percent, _team.GetColor() + "Your Wither"); } } + public double getHealthPercentage() + { + return _damageable ? (_entity.getHealth() / _entity.getMaxHealth()) : 1; + } + private void updateDisplay() { _disguise.setName(MobaUtil.getHealthBar(_entity, 40)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java index 787bfe95f..e62652fd3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java @@ -33,8 +33,9 @@ public class WitherSkullProjectile implements IThrown _manager = host.getArcadeManager(); _owner = owner; - WitherSkull skull = shooter.launchProjectile(WitherSkull.class); + WitherSkull skull = shooter.getWorld().spawn(shooter.getLocation().add(0, 2, 0), WitherSkull.class); + skull.setShooter(shooter); skull.setYield(0); skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target))); @@ -58,7 +59,7 @@ public class WitherSkullProjectile implements IThrown // Not team damage if (!_owner.equals(targetTeam)) { - _manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, DAMAGE, true, true, false, UtilEnt.getName(data.getThrower()), "Wither Skull"); + _manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, DAMAGE, true, true, false, "Wither Boss", "Wither Skull"); } Expire(data); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java index 0905cd1b8..05c8d22da 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java @@ -83,7 +83,7 @@ public class MobaFountain implements Listener } else { - _host.getArcadeManager().GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 6, false, true, true, "Fountain", "Fountain"); + _host.getArcadeManager().GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 10, false, true, true, "Fountain", "Fountain"); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/ArrowKBManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/ArrowKBManager.java new file mode 100644 index 000000000..4b4239bbd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/ArrowKBManager.java @@ -0,0 +1,41 @@ +package nautilus.game.arcade.game.games.moba.general; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.metadata.FixedMetadataValue; + +public class ArrowKBManager implements Listener +{ + + private static final String ENTITY_METADATA = "KB"; + private final Moba _host; + + public ArrowKBManager(Moba host) + { + _host = host; + } + + @EventHandler + public void arrowDamage(CustomDamageEvent event) + { + Projectile projectile = event.GetProjectile(); + + if (projectile == null || projectile.getType() != EntityType.ARROW || projectile.hasMetadata(ENTITY_METADATA)) + { + return; + } + + event.SetKnockback(false); + } + + public void allowKnockback(Entity projectile) + { + projectile.setMetadata(ENTITY_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), true)); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java similarity index 78% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java index 78c6cb874..49a7e4c55 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java @@ -1,5 +1,7 @@ package nautilus.game.arcade.game.games.moba.general; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; @@ -10,12 +12,12 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -public class TeamDamageManager implements Listener +public class MobaDamageManager implements Listener { private final Moba _host; - public TeamDamageManager(Moba host) + public MobaDamageManager(Moba host) { _host = host; } @@ -43,6 +45,10 @@ public class TeamDamageManager implements Listener { event.SetCancelled("Team Damage"); } + else + { + _host.getScoreboardModule().refreshAsSubject(damagee); + } } @EventHandler @@ -73,4 +79,14 @@ public class TeamDamageManager implements Listener event.setCancelled(true); } + @EventHandler + public void updateDamageScoreboard(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + _host.getScoreboardModule().refresh(); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index 7cf95af29..79bd7cdb9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.gold; import mineplex.core.common.Rank; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -10,6 +11,9 @@ import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; +import nautilus.game.arcade.game.games.moba.structure.point.CapturePointCaptureEvent; +import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -24,6 +28,10 @@ public class GoldManager implements Listener private static final int GOLD_PER_5 = 20; private static final int GOLD_PER_CAPTURE_5 = 5; + private static final int GOLD_PER_CAPTURE_INITIAL = 25; + private static final int GOLD_PER_FIRST_TOWER = 100; + private static final int GOLD_PER_SECOND_TOWER = 250; + private final Moba _host; @@ -112,14 +120,50 @@ public class GoldManager implements Listener } } + @EventHandler + public void towerDestroy(TowerDestroyEvent event) + { + for (Player player : _host.GetPlayers(true)) + { + // Don't give the gold to the owners + if (_host.GetTeam(player).equals(event.getTower().getOwner())) + { + continue; + } + + addGold(player, event.getTower().isFirstTower() ? GOLD_PER_FIRST_TOWER : GOLD_PER_SECOND_TOWER, "Destroying a tower"); + } + } + + @EventHandler + public void pointCapture(CapturePointCaptureEvent event) + { + GameTeam team = event.getPoint().getOwner(); + + for (Player player : team.GetPlayers(true)) + { + addGold(player, GOLD_PER_CAPTURE_INITIAL, "Capturing a beacon"); + } + } + public int getGold(Player player) { return _playerGold.get(player); } public void addGold(Player player, int amount) + { + addGold(player, amount, null); + } + + public void addGold(Player player, int amount, String reason) { _playerGold.put(player, _playerGold.get(player) + amount); + + if (amount > 20 && reason != null) + { + player.sendMessage(F.main("Game", C.cGold + "+" + amount + " gold (" + reason + ")" + C.cGray + ".")); + } } public void removeGold(Player player, int amount) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 97c682495..ca3ebd0ab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -1,7 +1,12 @@ package nautilus.game.arcade.game.games.moba.kit; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -16,13 +21,18 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; public class HeroSkill extends Perk { @@ -31,7 +41,8 @@ public class HeroSkill extends Perk private ItemStack _cooldownItem; private final int _slot; private final ActionType _actionType; - private final boolean _sneakActivate; + private boolean _sneakActivate; + private boolean _dropItemActivate; protected HeroKit _kit; private long _cooldown; @@ -44,11 +55,6 @@ public class HeroSkill extends Perk } public HeroSkill(String name, String[] perkDesc, ItemStack itemStack, int slot, ActionType actionType) - { - this(name, perkDesc, itemStack, slot, actionType, false); - } - - public HeroSkill(String name, String[] perkDesc, ItemStack itemStack, int slot, ActionType actionType, boolean sneakActivate) { super(name, perkDesc); @@ -56,11 +62,20 @@ public class HeroSkill extends Perk _items.add(itemStack); _slot = slot; _actionType = actionType; - _sneakActivate = sneakActivate; prettifyItems(); } + public void setSneakActivate(boolean activate) + { + _sneakActivate = activate; + } + + public void setDropItemActivate(boolean activate) + { + _dropItemActivate = activate; + } + protected void setCooldown(long cooldown) { _cooldown = cooldown; @@ -149,6 +164,11 @@ public class HeroSkill extends Perk _lastSkill.remove(key); } + @EventHandler + public void interact(PlayerInteractEvent event) + { + } + protected boolean isSkillItem(PlayerInteractEvent event) { if (event.isCancelled()) @@ -209,6 +229,25 @@ public class HeroSkill extends Perk return false; } + @EventHandler + public void dropTrigger(PlayerDropItemEvent event) + { + Player player = event.getPlayer(); + + if (!_dropItemActivate || !hasPerk(player)) + { + return; + } + + // Call interact with a fake PlayerInteractEvent + PlayerInteractEvent interactEvent = new PlayerInteractEvent(event.getPlayer(), Action.RIGHT_CLICK_AIR, player.getInventory().getItem(_slot), null, null); + + // You actually need to setCancelled false here otherwise it remains cancelled by default when the clicked block is null, thanks Bukkit + interactEvent.setCancelled(false); + interact(interactEvent); + } + + public void useSkill(Player player) { _lastSkill.put(player.getUniqueId(), System.currentTimeMillis()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 0ac1d5c5e..c17176547 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.kit.anath; import mineplex.core.common.util.UtilEvent.ActionType; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Material; @@ -18,6 +19,7 @@ public class SkillFireProjectile extends HeroSkill "Fires an Ember at high speed in front of you.", "Any enemies it collides with take damage and are set on fire." }; + private static final int DAMAGE = 5; private static final ItemStack SKILL_ITEM = new ItemStack(Material.BLAZE_ROD); @@ -45,6 +47,7 @@ public class SkillFireProjectile extends HeroSkill Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), _kit.getAmmo()); item.setVelocity(direction); - Manager.GetFire().Add(item, player, 3, 0, 1, 5, MobaConstants.BASIC_ATTACK, false); + ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, item, DAMAGE); + Manager.GetFire().Add(item, player, 3, 0, 1, DAMAGE, MobaConstants.BASIC_ATTACK, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index 5314786c3..73198fdfe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -42,8 +42,10 @@ public class SkillMeteor extends HeroSkill implements IThrown super("Meteor Shower", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); + setDropItemActivate(true); } + @Override @EventHandler public void interact(PlayerInteractEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java index 63a42f160..59fda7a1e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java @@ -71,8 +71,10 @@ public class SkillBuildPainting extends HeroSkill implements IThrown super("The Joy Of Painting", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); + setDropItemActivate(true); } + @Override @EventHandler public void interact(PlayerInteractEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java index df990d0dd..b5f8386bf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java @@ -6,6 +6,7 @@ import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilMath; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; import org.bukkit.Sound; @@ -28,6 +29,7 @@ public class SkillPaint extends HeroSkill implements IThrown "Bob Ross" }; private static final byte[] COLOURS = { 14, 1, 4, 5, 3, 11, 0}; + private static final int DAMAGE = 2; private static final ItemStack SKILL_ITEM = new ItemStack(Material.DIAMOND_BARDING); @@ -55,6 +57,7 @@ public class SkillPaint extends HeroSkill implements IThrown Snowball snowball = player.launchProjectile(Snowball.class); + ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, snowball, DAMAGE); Manager.GetProjectile().AddThrow(snowball, player, this, -1, true, true, true, false, 0.5F); } @@ -67,7 +70,7 @@ public class SkillPaint extends HeroSkill implements IThrown if (target != null) { thrower.playSound(thrower.getLocation(), Sound.LAVA_POP, 1, 1.3F); - Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.PROJECTILE, 2, true, true, false, UtilEnt.getName(thrower), GetName()); + Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.PROJECTILE, DAMAGE, true, true, false, UtilEnt.getName(thrower), GetName()); } for (Block nearby : UtilBlock.getBlocksInRadius(data.getThrown().getLocation(), 2)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java index b3217cd23..6726e478c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -49,9 +49,10 @@ public class DashSkill extends HeroSkill public DashSkill(String name, String[] perkDesc, ItemStack itemStack, int slot) { - super(name, perkDesc, itemStack, slot, ActionType.ANY, true); + super(name, perkDesc, itemStack, slot, ActionType.ANY); _startTime = new HashMap<>(); + setSneakActivate(true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index 35f94cafa..05331f42d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -19,6 +19,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; @@ -44,8 +45,10 @@ public class SkillRally extends HeroSkill super("Rally", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(40000); + setDropItemActivate(true); } + @Override @EventHandler public void interact(PlayerInteractEvent event) { @@ -197,6 +200,12 @@ public class SkillRally extends HeroSkill } } + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + _data.removeIf(rallyData -> rallyData.Owner.equals(event.getEntity())); + } + private Pattern getPattern(GameTeam team) { return team.GetColor() == ChatColor.RED ? new Pattern(DyeColor.WHITE, PatternType.CROSS) : new Pattern(DyeColor.WHITE, PatternType.CIRCLE_MIDDLE); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java index 656679db5..f80d6c6e2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -8,6 +8,7 @@ import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.common.SkillBow; import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; +import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; public class HeroDevon extends HeroKit @@ -36,6 +37,6 @@ public class HeroDevon extends HeroKit super(manager, "Devon", DESCRIPTION, PERKS, IN_HAND, MobaRole.HUNTER); setAmmo(AMMO, 3000); - setMaxAmmo(1); + setMaxAmmo(3); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java index edfb3e95f..eda785059 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java @@ -20,9 +20,10 @@ public class SkillBoost extends HeroSkill public SkillBoost(int slot) { - super("Hunters Boost", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY, true); + super("Hunters Boost", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(10000); + setSneakActivate(true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 76fe165fe..77bc3c242 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -8,11 +8,13 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; @@ -42,8 +44,10 @@ public class SkillInfinity extends HeroSkill super("Infinity", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); + setDropItemActivate(true); } + @Override @EventHandler public void interact(PlayerInteractEvent event) { @@ -85,6 +89,9 @@ public class SkillInfinity extends HeroSkill return; } + Moba moba = (Moba) Manager.GetGame(); + + moba.getArrowKbManager().allowKnockback(event.getProjectile()); _arrows.put(event.getProjectile(), player); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java index d94b7d9ec..b7c658777 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Location; import org.bukkit.Material; @@ -95,6 +96,9 @@ public class SkillTNTArrows extends HeroSkill itemStack.setAmount(arrows); } + Moba moba = (Moba) Manager.GetGame(); + + moba.getArrowKbManager().allowKnockback(event.getProjectile()); _arrows.add((Arrow) event.getProjectile()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index 9e8546707..638a243a0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -32,6 +32,7 @@ public class SkillNinjaBlade extends HeroSkill private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); private static final ItemStack ACTIVE_ITEM = new ItemBuilder(Material.DIAMOND_SWORD) .setTitle(C.cGreenB + "NINJA BLADE") + .setUnbreakable(true) .build(); private Set _active = new HashSet<>(); @@ -41,8 +42,10 @@ public class SkillNinjaBlade extends HeroSkill super("Ninja Blade", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); + setDropItemActivate(true); } + @Override @EventHandler public void interact(PlayerInteractEvent event) { @@ -54,6 +57,7 @@ public class SkillNinjaBlade extends HeroSkill Player player = event.getPlayer(); player.getInventory().setItem(getSlot(), ACTIVE_ITEM); + player.getInventory().setHeldItemSlot(getSlot()); _active.add(player.getUniqueId()); useActiveSkill(() -> _active.remove(player.getUniqueId()), player, 7000); @@ -71,7 +75,9 @@ public class SkillNinjaBlade extends HeroSkill return; } - if (!_active.contains(player.getUniqueId()) || player.getItemInHand() == null || player.getItemInHand().getType() != Material.DIAMOND_SWORD) + ItemStack itemStack = player.getItemInHand(); + + if (!_active.contains(player.getUniqueId()) || itemStack == null || itemStack.getType() != Material.DIAMOND_SWORD || itemStack.getItemMeta() == null || !itemStack.getItemMeta().getDisplayName().equals(ACTIVE_ITEM.getItemMeta().getDisplayName())) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index eeb1c0f57..6d90fd6be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -4,6 +4,7 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; import org.bukkit.Sound; @@ -25,6 +26,7 @@ public class SkillSnowball extends HeroSkill implements IThrown "Fires 3 snowballs, one after another.", "Each snowball deals 3 damage to any enemy it hits." }; + private static final int DAMAGE = 3; private static final ItemStack SKILL_ITEM = new ItemStack(Material.SNOW_BALL); public SkillSnowball(int slot) @@ -57,6 +59,7 @@ public class SkillSnowball extends HeroSkill implements IThrown { Snowball snowball = player.launchProjectile(Snowball.class); + ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, snowball, DAMAGE); Manager.GetProjectile().AddThrow(snowball, player, SkillSnowball.this, -1, true, true, true, false, 0.5F); if (++balls == 3) @@ -75,7 +78,7 @@ public class SkillSnowball extends HeroSkill implements IThrown 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.CUSTOM, 3, true, true, false, UtilEnt.getName(thrower), GetName()); + Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.CUSTOM, DAMAGE, true, true, false, UtilEnt.getName(thrower), GetName()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index decc4b408..514d83dbd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -36,12 +36,12 @@ public class Minion UtilEnt.setBoundingBox(entity, HIT_BOX, HIT_BOX); entity.setCustomNameVisible(true); - updateDisplay(); + updateDisplay(entity.getMaxHealth()); } - public void updateDisplay() + public void updateDisplay(double health) { - _entity.setCustomName(MobaUtil.getHealthBar(_entity, 10)); + _entity.setCustomName(MobaUtil.getHealthBar(_entity, health, 10)); } public LivingEntity getEntity() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 07b9106e3..a2de07ee3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -3,7 +3,7 @@ package nautilus.game.arcade.game.games.moba.minion; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; -import mineplex.core.recharge.Recharge; +import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -16,6 +16,7 @@ import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -29,14 +30,15 @@ import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class MinionWave implements Listener { private static final int MAX_MINIONS_PER_WAVE = 6; private static final int TOO_CLOSE_SQUARED = 9; - private static final int MINION_TOO_CLOSE_SQUARED = 16; private static final int DAMAGE_RANGE_SQUARED = 16; private static final double DAMAGE_AMOUNT = 0.2; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); @@ -49,6 +51,8 @@ public class MinionWave implements Listener private final List _path; private final List _minions; + //private final Map _lastDamage; + public MinionWave(Moba host, MinionManager minionManager, GameTeam owner, List path, Class clazz) { _host = host; @@ -57,6 +61,7 @@ public class MinionWave implements Listener _clazz = clazz; _path = path; _minions = new ArrayList<>(MAX_MINIONS_PER_WAVE); + //_lastDamage = new HashMap<>(MAX_MINIONS_PER_WAVE); UtilServer.RegisterEvents(this); @@ -371,11 +376,24 @@ public class MinionWave implements Listener if (minion != null) { - minion.updateDisplay(); + minion.updateDisplay(minion.getEntity().getHealth() - event.GetDamage()); } } } +// @EventHandler(priority = EventPriority.MONITOR) +// public void damageSound(CustomDamageEvent event) +// { +// LivingEntity damagee = event.GetDamageeEntity(); +// +// if (event.isCancelled() || !isMinion(damagee) || !UtilTime.elapsed(_lastDamage.get(damagee), 2000)) +// { +// return; +// } +// +// damagee.getWorld().playSound(damagee.getLocation(), Sound.ZOMBIE_HURT, 1, 1.4F); +// } + @EventHandler public void entityCombust(EntityCombustEvent event) { @@ -403,6 +421,7 @@ public class MinionWave implements Listener } event.getDrops().clear(); + event.setDroppedExp(0); } public void cleanup() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java index 559fdd4dd..0e0360bfc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java @@ -64,7 +64,7 @@ public class PrepareInformation implements Listener String[] description = mobaPlayer.getRole().getDescription(); // Description is too short - if (description.length > _messageIndex + 2) + if (description.length <= _messageIndex + 1) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java index 2dd066b55..99e01896f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java @@ -30,7 +30,6 @@ public class PrepareManager implements Listener { private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1); - private static final String OWNED_METADATA = "owned"; private final Moba _host; @@ -108,21 +107,21 @@ public class PrepareManager implements Listener MobaRole role = event.getRole(); ClientArmorStand stand = event.getStand(); - if (stand.hasMetadata(OWNED_METADATA)) + if (!_host.isRoleFree(player, role)) { player.sendMessage(F.main("Game", "Another player has already chosen this role.")); event.setCancelled(true); return; } - // Store inside the stand that it is claimed by a player - stand.setMetadata(OWNED_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), true)); - // Show that the kit is claimed. stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + player.getName()); // Store the role of the player _host.getMobaData(player).setRole(role); + + // Update the scoreboard + _host.getScoreboardModule().refreshAsSubject(player); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index c97b92bee..8a1a1acc6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -1,25 +1,48 @@ package nautilus.game.arcade.game.games.moba.structure.point; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Effect; import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; public class CapturePoint { private static final int MAX_RADIUS = 5; - private static final int MAX_PROGRESS = 10; + private static final int MAX_PROGRESS = 5; + private static final int MAX_PROGRESS_NETURAL = 10; + private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); private final Moba _host; + private final String _name; + private final ChatColor _colour; + private final Location _center; private final List _wool; private final List _changed; @@ -29,10 +52,13 @@ public class CapturePoint private GameTeam _owner; private GameTeam _side; private int _progress; + private long _lastInform; - public CapturePoint(Moba host, Location center) + public CapturePoint(Moba host, String name, ChatColor colour, Location center) { _host = host; + _name = name; + _colour = colour; _center = center; _wool = new ArrayList<>(36); _changed = new ArrayList<>(_wool.size()); @@ -117,9 +143,23 @@ public class CapturePoint { return; } + // Players on the point + // Only inform if it has been a while + else if (!_owner.equals(highest) && UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) + { + _lastInform = System.currentTimeMillis(); + + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getLocation(), Sound.GHAST_SCREAM2, 1, 1.2F); + } + + _host.Announce(F.main("Game", "Team " + highest.GetFormattedName() + C.mBody + " is capturing beacon " + _colour + _name + C.mBody + "!"), false); + UtilTextMiddle.display("", "Team " + highest.GetFormattedName() + C.cWhite + " is capturing beacon " + _colour + _name, 0, 30, 10); + } // If it has just reached the maximum progress, set the owner. - if (_owner != null && _owner.equals(highest) && _progress >= MAX_PROGRESS) + if (_owner != null && _owner.equals(highest) && _progress >= (_owner == null ? MAX_PROGRESS_NETURAL : MAX_PROGRESS)) { return; } @@ -143,7 +183,7 @@ public class CapturePoint display(team, true); // Captured - if (_progress >= MAX_PROGRESS) + if (_progress >= (_owner == null ? MAX_PROGRESS_NETURAL : MAX_PROGRESS)) { setOwner(team); } @@ -168,23 +208,36 @@ public class CapturePoint private void setOwner(GameTeam team) { - // Same team - if (_owner != null && _owner.equals(team)) + setBeaconColour(team); + + if (_owner != null) { - return; + // Same team no need to inform + if (_owner.equals(team)) + { + return; + } + } + else + { + // As the point is easier to capture after the initial capture + // We need to adjust the current progress, otherwise it has to go + // from 10 to 0 then to 5 which is unintended + _progress = MAX_PROGRESS; } _owner = team; - setBeaconColour(team); - UtilFirework.playFirework(_center, Type.BURST, team.GetColorBase(), false, false); + _host.Announce(F.main("Game", "Team " + team.GetFormattedName() + C.mBody + " captured beacon " + _colour + _name + C.mBody + "!")); + UtilTextMiddle.display("", "Team " + team.GetFormattedName() + C.cWhite + " captured beacon " + _colour + _name, 0, 30, 10); + UtilFirework.playFirework(_center, Type.BURST, team.GetColorBase(), false, false); UtilServer.CallEvent(new CapturePointCaptureEvent(this)); } private void display(GameTeam team, boolean forward) { - double toChange = Math.ceil(_wool.size() / MAX_PROGRESS) + 1; + double toChange = Math.ceil(_wool.size() / (_owner == null ? MAX_PROGRESS_NETURAL : MAX_PROGRESS)) + 1; int changed = 0; for (Block block : _wool) { @@ -231,6 +284,11 @@ public class CapturePoint _center.getBlock().getRelative(BlockFace.DOWN).setData(colour); } + public ChatColor getColour() + { + return _colour; + } + public GameTeam getOwner() { return _owner; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java index 8534f1b32..ae6697317 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java @@ -1,17 +1,20 @@ package nautilus.game.arcade.game.games.moba.structure.point; +import mineplex.core.common.util.C; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.Map.Entry; public class CapturePointManager implements Listener { @@ -35,11 +38,28 @@ public class CapturePointManager implements Listener return; } - Collection capturePoints = _host.getLocationStartsWith("POINT").values(); - - for (Location location : capturePoints) + for (Entry entry : _host.getLocationStartsWith("POINT").entrySet()) { - _capturePoints.add(new CapturePoint(_host, location)); + String[] split = entry.getKey().split(" "); + + if (split.length < 3) + { + continue; + } + + String name = split[1]; + ChatColor colour; + + try + { + colour = ChatColor.valueOf(split[2]); + } + catch (IllegalArgumentException e) + { + continue; + } + + _capturePoints.add(new CapturePoint(_host, name, colour, entry.getValue())); } } @@ -57,6 +77,30 @@ public class CapturePointManager implements Listener } } + public String getDisplayString(GameTeam team) + { + StringBuilder out = new StringBuilder(); + int owned = 0; + + for (CapturePoint point : _capturePoints) + { + if (point.getOwner() == null || !point.getOwner().equals(team)) + { + continue; + } + + out.append(point.getColour()).append("⚑ "); + owned++; + } + + while (owned++ < 3) + { + out.append(C.cGray).append("⚑ "); + } + + return out.toString().trim(); + } + public List getCapturePoints() { return _capturePoints; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 6d84e1a05..849b57326 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -7,6 +7,7 @@ import mineplex.core.disguise.disguises.DisguiseGuardian; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -15,32 +16,34 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.EnderCrystal; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import java.util.concurrent.TimeUnit; + public class Tower { private static final int DAMAGE = 3; private static final int TARGET_RANGE = 10; public static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; + private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); private final Moba _host; private final Location _location; private final GameTeam _team; + private float _fallbackYaw; private double _health; private int _maxHealth; private boolean _firstTower; + private boolean _dead; + private long _lastInform; private ArmorStand _stand; private DisguiseGuardian _guardian; private EnderCrystal _crystal; - - private boolean _dead; - - private float _fallbackYaw; - private LivingEntity _target; public Tower(Moba host, Location location, GameTeam team, int health, boolean firstTower) @@ -51,6 +54,7 @@ public class Tower _health = health; _maxHealth = health; _firstTower = firstTower; + _lastInform = System.currentTimeMillis(); } public void setup() @@ -82,7 +86,15 @@ public class Tower { if (_target == null) { + // Target just entities LivingEntity target = MobaUtil.getBestEntityTarget(_host, _team, _stand, _crystal.getLocation(), TARGET_RANGE, false); + + if (target == null) + { + // Try targeting players + target = MobaUtil.getBestEntityTarget(_host, _team, _stand, _crystal.getLocation(), TARGET_RANGE, true); + } + _target = target; setLaserTarget(target); } @@ -117,9 +129,7 @@ public class Tower _guardian.setTarget(0); Location standLocation = _stand.getLocation(); - standLocation.setYaw(_fallbackYaw); - - _guardian.getEntity().setLocation(standLocation.getX(), standLocation.getY(), standLocation.getZ(), standLocation.getYaw(), 0); + _guardian.getEntity().setLocation(standLocation.getX(), standLocation.getY(), standLocation.getZ(), _fallbackYaw, 0); } else { @@ -160,6 +170,18 @@ public class Tower _guardian.setName(out); _crystal.setCustomName(out); + + if (UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) + { + _lastInform = System.currentTimeMillis(); + + for (Player player : _team.GetPlayers(true)) + { + player.playSound(player.getLocation(), Sound.ANVIL_LAND, 1, 0.5F); + player.sendMessage(F.main("Game", "Your Tower is under attack!")); + UtilTextMiddle.display("", _team.GetColor() + "Your Tower is under attack!", 0, 30, 10, player); + } + } } private void explode() @@ -221,4 +243,14 @@ public class Tower return _dead; } + public double getHealth() + { + return _health; + } + + public double getMaxHealth() + { + return _maxHealth; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 9dab1ca0d..02ce53665 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -1,5 +1,7 @@ package nautilus.game.arcade.game.games.moba.structure.tower; +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; @@ -10,6 +12,8 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.EnderCrystal; @@ -24,6 +28,8 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.projectiles.ProjectileSource; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -33,16 +39,19 @@ public class TowerManager implements Listener private static final int FIRST_TOWER_HEALTH = 500; private static final int SECOND_TOWER_HEALTH = 1000; + private static final int PROJECTILE_RANGE_SQUARED = 4; private final Moba _host; private final List _towers; + private final Map> _projectilesToCheck; public TowerManager(Moba host) { _host = host; _towers = new ArrayList<>(12); + _projectilesToCheck = new HashMap<>(); } @EventHandler @@ -90,6 +99,21 @@ public class TowerManager implements Listener _towers.add(new Tower(_host, location, gameTeam, health, firstTower)); } + _towers.sort((o1, o2) -> + { + if (o1.isFirstTower()) + { + return Integer.MIN_VALUE; + } + + if (!o2.isFirstTower()) + { + return Integer.MAX_VALUE; + } + + return 0; + }); + _host.CreatureAllowOverride = true; for (Tower tower : _towers) { @@ -166,7 +190,6 @@ public class TowerManager implements Listener Location playerLocation = player.getLocation(); playerLocation.setY(entityLocation.getY()); - // TODO TEMP if (UtilMath.offsetSquared(playerLocation, entityLocation) > Tower.TARGET_RANGE_SQUARED) { return; @@ -198,51 +221,52 @@ public class TowerManager implements Listener if (Recharge.Instance.use(player, "Tower Sound", 500, false, false)) { - player.playSound(tower.getCrystal().getLocation(), Sound.BLAZE_HIT, 1, 0.8F); + playSound(player, tower); } return; } } - public Tower getFirstTower(GameTeam team) + public void addProjectile(Player shooter, Entity entity, double damage) { - for (Tower tower : _towers) - { - if (tower.isFirstTower() && tower.getOwner().equals(team)) - { - return tower; - } - } - - return null; + _projectilesToCheck.put(entity, Pair.create(shooter, damage)); } -// /* -// Hacky work arounds!!!! -// */ -// @EventHandler -// public void updateAnathBlazePowder(UpdateEvent event) -// { -// if (event.getType() != UpdateType.FASTEST) -// { -// return; -// } -// -// for (Tower tower : _towers) -// { -// for (Entity entity : UtilEnt.getAllInRadius(tower.getCrystal().getLocation(), 1.5).keySet()) -// { -// if (entity instanceof Item) -// { -// Item item = (Item) entity; -// if (item.getItemStack().getType() == Material.BLAZE_POWDER) -// { -// -// } -// } -// } -// } -// } + @EventHandler + public void updateProjectiles(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator iterator = _projectilesToCheck.keySet().iterator(); + + while (iterator.hasNext()) + { + Entity entity = iterator.next(); + Pair pair = _projectilesToCheck.get(entity); + GameTeam team = _host.GetTeam(pair.getLeft()); + + for (Tower tower : _towers) + { + if (tower.isDead() || tower.getOwner().equals(team) || UtilMath.offsetSquared(tower.getCrystal(), entity) > PROJECTILE_RANGE_SQUARED) + { + continue; + } + + playSound(pair.getLeft(), tower); + tower.damage(pair.getRight()); + entity.remove(); + iterator.remove(); + } + } + } + + private void playSound(Player player, Tower tower) + { + player.playSound(tower.getCrystal().getLocation(), Sound.BLAZE_HIT, 1, 0.8F); + } public boolean canDamage(Tower tower, GameTeam team) { @@ -276,6 +300,26 @@ public class TowerManager implements Listener return false; } + public String getDisplayString(GameTeam team) + { + StringBuilder out = new StringBuilder(); + + for (Tower tower : _towers) + { + if (!tower.getOwner().equals(team)) + { + continue; + } + + double health = tower.getHealth() / tower.getMaxHealth(); + String colour = tower.isDead() ? C.cGray : MobaUtil.getColour(health); + + out.append(colour).append("♛ "); + } + + return out.toString(); + } + public List getTowers() { return _towers; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java index 3dab8cbf2..f9ca54daa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java @@ -7,6 +7,7 @@ public class MobaConstants public static final String BASIC_ATTACK = "Basic Attack"; public static final String AMMO = "Ammo"; public static final String TEAM_METADATA = "team"; + public static final String SHOOTER_METADATA = "shooter"; // Location Constants public static final String MINION_PATH_START = "WHITE"; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index bb1daef50..411f01463 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -21,7 +21,12 @@ import java.util.Set; public class MobaUtil { - public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayersMore) + public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayers) + { + return getBestEntityTarget(host, owner, source, location, targetRange, targetPlayers, false); + } + + public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayers, boolean targetPlayersMore) { LivingEntity highest = null; double bestDist = 0; @@ -45,7 +50,7 @@ public class MobaUtil // Make players more desirable if (entity instanceof Player) { - if (owner.equals(host.GetTeam((Player) entity))) + if (!targetPlayers || owner.equals(host.GetTeam((Player) entity))) { continue; } @@ -155,26 +160,14 @@ public class MobaUtil public static String getHealthBar(LivingEntity entity, int bars) { - String out = ""; - String colour; - double health = entity.getHealth() / entity.getMaxHealth(); + return getHealthBar(entity, entity.getHealth(), bars); + } - if (health < 0.25) - { - colour = C.cRedB; - } - else if (health < 0.5) - { - colour = C.cGoldB; - } - else if (health < 0.75) - { - colour = C.cYellowB; - } - else - { - colour = C.cGreenB; - } + public static String getHealthBar(LivingEntity entity, double newHealth, int bars) + { + StringBuilder out = new StringBuilder(); + double health = newHealth / entity.getMaxHealth(); + String colour = getColour(health); for (int i = 0; i < bars; i++) { @@ -182,16 +175,32 @@ public class MobaUtil if (cur < health) { - out += colour + "|"; + out.append(colour).append("|"); } else { - out += C.cGrayB + "|"; + out.append(C.cGrayB).append("|"); } } - return out; + return out.toString(); } + public static String getColour(double percentage) + { + if (percentage < 0.25) + { + return C.cRedB; + } + else if (percentage < 0.5) + { + return C.cGoldB; + } + else if (percentage < 0.75) + { + return C.cYellowB; + } + return C.cGreenB; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java index 95ce3bbb5..928a2e919 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java @@ -11,6 +11,9 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Score; import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Team; @@ -20,6 +23,22 @@ import java.util.UUID; import java.util.function.BiConsumer; import java.util.function.BiFunction; +/** + * CustomScoreboardModule allows for the use of per-player scoreboards in an Arcade game. + * Including sidebars, tab-list prefixes, suffixes, undernames and scores.
+ * These scoreboard system is backed by {@link mineplex.core.scoreboard.ScoreboardManager} and is thus optimised + * extremely efficiently, so don't be afraid to call the set methods often as they will not be updated then and there.
+ * Scoreboards are refreshed for all players upon the prepare, live and end state changes. While sidebars are updated every 10 ticks/0.5 seconds.
+ * If you wish to update the scoreboard more frequently than these, the methods: + *

    + *
  • {@link #refresh()}
  • + *
  • {@link #refreshAsPerspective(Player)}
  • + * + *
+ * + * @see mineplex.core.scoreboard.MineplexScoreboard + * @see nautilus.game.arcade.game.games.moba.Moba + */ public class CustomScoreboardModule extends Module { @@ -28,18 +47,28 @@ public class CustomScoreboardModule extends Module private BiConsumer _scoreboardConsumer; private BiFunction _prefixFunction; private BiFunction _suffixFunction; + private BiFunction _tabListFunction; + private String _underNameObjective; + private BiFunction _underNameFunction; public CustomScoreboardModule() { _scoreboard = new HashMap<>(); } + /** + * The use of the boolean UseCustomScoreboard in {@link nautilus.game.arcade.game.Game} is required so the Arcade doesn't + * try and create the scoreboard itself or reference the standard {@link GameScoreboard}, which it does (a lot). + */ @Override protected void setup() { getGame().UseCustomScoreboard = true; } + /** + * Calls {@link #setupScoreboard(Player)} when the players joins, if the game is not in a Lobby state. + */ @EventHandler public void playerJoin(PlayerJoinEvent event) { @@ -54,6 +83,11 @@ public class CustomScoreboardModule extends Module setupScoreboard(player); } + /** + * Removes the player's scoreboard from the {@link #_scoreboard} map. + *
+ * Unregisters the quitting player's entries from all other scoreboards. + */ @EventHandler public void playerQuit(PlayerQuitEvent event) { @@ -67,7 +101,10 @@ public class CustomScoreboardModule extends Module } } - @EventHandler(priority = EventPriority.MONITOR) + /** + * Calls {@link #setupScoreboard(Player)} when the game switches to the prepare state. + */ + @EventHandler(priority = EventPriority.HIGHEST) public void prepare(GameStateChangeEvent event) { if (event.GetState() != GameState.Prepare) @@ -79,14 +116,15 @@ public class CustomScoreboardModule extends Module { setupScoreboard(player); } - - refresh(); } + /** + * Refreshes all player scoreboards upon an in progress state change. + */ @EventHandler(priority = EventPriority.MONITOR) public void live(GameStateChangeEvent event) { - if (event.GetState() != GameState.Live) + if (event.GetState() != GameState.Prepare && event.GetState() != GameState.Live && event.GetState() != GameState.End) { return; } @@ -94,6 +132,9 @@ public class CustomScoreboardModule extends Module refresh(); } + /** + * Calls the draw method every 10 ticks/0.5 seconds. + */ @EventHandler public void update(UpdateEvent event) { @@ -140,6 +181,27 @@ public class CustomScoreboardModule extends Module return this; } + public CustomScoreboardModule setTabList(BiFunction function) + { + _tabListFunction = function; + return this; + } + + public CustomScoreboardModule setUnderNameObjective(String name) + { + _underNameObjective = name; + return this; + } + + public CustomScoreboardModule setUnderName(BiFunction function) + { + _underNameFunction = function; + return this; + } + + /** + * Refreshes all player's scoreboards. + */ public void refresh() { for (CustomArcadeScoreboard scoreboard : _scoreboard.values()) @@ -148,12 +210,43 @@ public class CustomScoreboardModule extends Module } } + /** + * Refreshes an individual player's scoreboard. + * + * @param perspective The player that has the perspective of the scoreboard to be refreshed. + */ + public void refreshAsPerspective(Player perspective) + { + CustomArcadeScoreboard scoreboard = _scoreboard.get(perspective.getUniqueId()); + + if (scoreboard == null) + { + return; + } + + scoreboard.draw(false); + } + + /** + * Refreshes all scoreboards but only where the subject of said scoreboard is the player passed in as the subject parameter. + */ + public void refreshAsSubject(Player subject) + { + for (CustomArcadeScoreboard scoreboard : _scoreboard.values()) + { + scoreboard.draw(subject); + } + } + @Override public void cleanup() { _scoreboard.clear(); } + /** + * An internal class that simply implements the actions set out by {@link CustomScoreboardModule}. + */ class CustomArcadeScoreboard extends GameScoreboard { @@ -162,12 +255,15 @@ public class CustomScoreboardModule extends Module super(getGame(), owner); } - private void setTag(Player subject, String prefix, String suffix) + private void updateTag(Player subject) { Scoreboard handle = getHandle(); String teamName = subject.getName(); Team team = handle.getTeam(teamName); + String prefix = _prefixFunction == null ? null : _prefixFunction.apply(getOwner(), subject); + String suffix = _suffixFunction == null ? null : _suffixFunction.apply(getOwner(), subject); + if (team == null) { team = handle.registerNewTeam(teamName); @@ -190,6 +286,56 @@ public class CustomScoreboardModule extends Module } } + private void updateTabList(Player subject) + { + if (_tabListFunction == null) + { + return; + } + + Scoreboard handle = getHandle(); + Objective objective = handle.getObjective(DisplaySlot.PLAYER_LIST); + int value = _tabListFunction.apply(getOwner(), subject); + + if (objective == null) + { + objective = handle.registerNewObjective("TabList", "dummy"); + objective.setDisplaySlot(DisplaySlot.PLAYER_LIST); + } + + Score score = objective.getScore(subject.getName()); + + if (score.getScore() != value) + { + score.setScore(value); + } + } + + private void updateUnderName(Player subject) + { + if (_underNameFunction == null || _underNameObjective == null) + { + return; + } + + Scoreboard handle = getHandle(); + Objective objective = handle.getObjective(DisplaySlot.BELOW_NAME); + int value = _underNameFunction.apply(getOwner(), subject); + + if (objective == null) + { + objective = handle.registerNewObjective(_underNameObjective, "dummy"); + objective.setDisplaySlot(DisplaySlot.BELOW_NAME); + } + + Score score = objective.getScore(subject.getName()); + + if (score.getScore() != value) + { + score.setScore(value); + } + } + @Override public void draw() { @@ -204,16 +350,20 @@ public class CustomScoreboardModule extends Module } if (!sidebarOnly) { - if (_prefixFunction != null) + for (Player player : Bukkit.getOnlinePlayers()) { - for (Player player : Bukkit.getOnlinePlayers()) - { - setTag(player, _prefixFunction.apply(getOwner(), player), _suffixFunction.apply(getOwner(), player)); - } + draw(player); } } super.draw(); } + + private void draw(Player player) + { + updateTag(player); + updateTabList(player); + updateUnderName(player); + } } From 8a9e113389f75b8f5e5459288ae3742d569fb301 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 31 May 2017 17:09:08 +0100 Subject: [PATCH 077/283] Improvements to the targetting system --- .../core/fallingblock/FallingBlocks.java | 3 +- .../game/arcade/game/games/moba/Moba.java | 3 + .../arcade/game/games/moba/ai/MobaAI.java | 33 +++---- .../moba/ai/goal/MobaDirectAIMethod.java | 2 +- .../arcade/game/games/moba/boss/MobaBoss.java | 47 ++++++++- .../game/games/moba/boss/MobaBossAttack.java | 10 ++ .../games/moba/boss/pumpkin/PumpkinBoss.java | 58 ++++++++--- .../moba/boss/pumpkin/PumpkinBossAI.java | 4 +- .../games/moba/boss/wither/WitherBoss.java | 23 +++-- .../boss/wither/WitherSkullProjectile.java | 83 ---------------- .../wither/attack/BossAttackEarthquake.java | 93 ++++++++++++++++++ .../game/games/moba/gold/GoldManager.java | 2 - .../game/games/moba/minion/MinionWave.java | 34 +++---- .../arcade/game/games/moba/util/MobaUtil.java | 96 ++++++++----------- 14 files changed, 286 insertions(+), 205 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBossAttack.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/fallingblock/FallingBlocks.java b/Plugins/Mineplex.Core/src/mineplex/core/fallingblock/FallingBlocks.java index 46b462c17..b7655b19f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/fallingblock/FallingBlocks.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/fallingblock/FallingBlocks.java @@ -33,7 +33,7 @@ public class FallingBlocks extends MiniPlugin if (vec.getY() < 0) { - vec.setY(vec.getY() * -1); + vec.setY(-vec.getY()); } Spawn(location, type, data, vec); @@ -46,7 +46,6 @@ public class FallingBlocks extends MiniPlugin UtilAction.velocity(fall, velocity, 0.5 + 0.25 * Math.random(), false, 0, 0.4 + 0.20 * Math.random(), 10, false); - fall.setMetadata(METADATA, new FixedMetadataValue(_plugin, "x")); UtilEnt.SetMetadata(fall, METADATA, "x"); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 286854643..e1af99064 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -34,6 +34,7 @@ import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; @@ -49,6 +50,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.metadata.FixedMetadataValue; import java.util.ArrayList; import java.util.Arrays; @@ -362,6 +364,7 @@ public class Moba extends TeamGame for (Player player : GetPlayers(true)) { _playerData.add(new MobaPlayer(player)); + player.setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(Manager.getPlugin(), GetTeam(player).GetName())); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 59ba0cffa..15f4e9e49 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -1,7 +1,5 @@ package nautilus.game.arcade.game.games.moba.ai; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; @@ -10,16 +8,15 @@ import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; +import java.util.List; + public class MobaAI { - private static final int TARGET_RANGE = 15; - private static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; - - private final Moba _host; private final GameTeam _owner; private final float _speedTarget; private final float _speedHome; + private final List _boundaries; private LivingEntity _entity; private LivingEntity _target; @@ -29,26 +26,26 @@ public class MobaAI public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod) { - _host = host; _owner = owner; _speedTarget = speedTarget; _speedHome = speedHome; _entity = entity; _home = home; _aiMethod = aiMethod; + _boundaries = host.WorldData.GetDataLocs(getBoundaryKey()); } public void updateTarget() { // Entity not spawned - if (_entity == null || !_entity.isValid()) + if (_entity == null || _entity.isDead() || !_entity.isValid()) { return; } if (_target == null || _target.isDead() || !_target.isValid()) { - _target = MobaUtil.getBestEntityTarget(_host, _owner, _entity, _home, _host.WorldData.GetDataLocs(getBoundaryKey())); + _target = MobaUtil.getBestEntityTarget(_owner, _entity, _home, _boundaries); if (_target == null) { @@ -56,15 +53,10 @@ public class MobaAI return; } } - else + else if (!MobaUtil.isInBoundary(_owner, _entity, _home, _boundaries, _target)) { - double dist = UtilMath.offsetSquared(_entity, _target); - - if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target)) - { - _target = null; - returnToHome(); - } + _target = null; + returnToHome(); } if (_target != null) @@ -75,7 +67,7 @@ public class MobaAI private void returnToHome() { - _aiMethod.updateMovement(_entity, _home, _speedTarget); + _aiMethod.updateMovement(_entity, _home, _speedHome); } public void setEntity(LivingEntity entity) @@ -88,6 +80,11 @@ public class MobaAI return _target; } + public List getBoundaries() + { + return _boundaries; + } + public String getBoundaryKey() { return _owner.GetColor() == ChatColor.RED ? "ORANGE" : "LIGHT_BLUE"; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index 45035f8c9..d2ad46e97 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -14,7 +14,7 @@ public class MobaDirectAIMethod implements MobaAIMethod { Location entityLocation = entity.getLocation(); - // Speed is blocks per second + // Speed is number of ticks to travel 1 block float magnitude = speed / 20F; // Get the direct vector between the entity and the goal diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index 4158ed179..086858719 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -1,27 +1,38 @@ package nautilus.game.arcade.game.games.moba.boss; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + public abstract class MobaBoss implements Listener { protected final Moba _host; protected LivingEntity _entity; protected Location _location; - protected int _respawnTime; + private int _respawnTime; private long _lastDeath; + private List _attacks; + public MobaBoss(Moba host, Location location) { this(host, location, -1); @@ -33,6 +44,7 @@ public abstract class MobaBoss implements Listener _location = location; _respawnTime = respawnTime; _lastDeath = -1; + _attacks = new ArrayList<>(3); } public void setup() @@ -44,12 +56,36 @@ public abstract class MobaBoss implements Listener public void cleanup() { UtilServer.Unregister(this); + _attacks.forEach(MobaBossAttack::cleanup); + } + + public void addAttack(MobaBossAttack attack) + { + _attacks.add(attack); + } + + @EventHandler + public void updateAttack(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW || getAi().getTarget() == null) + { + return; + } + + MobaBossAttack attack = UtilAlg.Random(_attacks); + + if (attack == null) + { + return; + } + + attack.run(); } @EventHandler public void updateMovement(UpdateEvent event) { - if (event.getType() != UpdateType.FASTEST || _entity == null || !_host.IsLive()) + if (event.getType() != UpdateType.TICK || _entity == null || !_host.IsLive()) { return; } @@ -87,6 +123,13 @@ public abstract class MobaBoss implements Listener public abstract MobaAI getAi(); + public abstract String getName(); + + public Moba getHost() + { + return _host; + } + public LivingEntity getEntity() { return _entity; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBossAttack.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBossAttack.java new file mode 100644 index 000000000..4c91d9f6c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBossAttack.java @@ -0,0 +1,10 @@ +package nautilus.game.arcade.game.games.moba.boss; + +import org.bukkit.event.Listener; + +public interface MobaBossAttack extends Runnable, Listener +{ + + void cleanup(); + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 08e913ece..822b9b70d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -29,7 +29,6 @@ import nautilus.game.arcade.game.games.moba.util.MobaUtil; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; import org.bukkit.Bukkit; -import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -56,6 +55,7 @@ import java.util.concurrent.TimeUnit; public class PumpkinBoss extends MobaBoss { + private static final String NAME = "Pumpkin King"; private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); @@ -70,6 +70,7 @@ public class PumpkinBoss extends MobaBoss private static final int DAMAGE_DIRECT = 8; private static final int DAMAGE_DIRECT_RADIUS_SQUARED = 9; private static final int HEALTH = 400; + private static final int HEALTH_OUT_OF_COMBAT = 10; private static final Material[] BLOCKS = { Material.OBSIDIAN, Material.NETHERRACK, @@ -103,7 +104,7 @@ public class PumpkinBoss extends MobaBoss Skeleton skeleton = UtilVariant.spawnWitherSkeleton(_location); - skeleton.setCustomName(C.cDRedB + "Pumpkin King"); + skeleton.setCustomName(C.cDRedB + NAME); skeleton.setCustomNameVisible(true); skeleton.getEquipment().setHelmet(HELMET); skeleton.getEquipment().setItemInHand(IN_HAND); @@ -115,6 +116,10 @@ public class PumpkinBoss extends MobaBoss skeleton.getWorld().strikeLightningEffect(skeleton.getLocation()); + // preDamage uses getAi() which would have been called in a game long before spawnEntity has + // This is unique to the pumpkin king, so we must manually update the AI's corresponding entity + getAi().setEntity(skeleton); + UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10); _host.Announce(F.main("Game", C.cRedB + "The Pumpkin King Has Awoken!"), false); @@ -147,12 +152,18 @@ public class PumpkinBoss extends MobaBoss { if (_ai == null) { - _ai = new PumpkinBossAI(_host, _entity, _location, AI_METHOD); + _ai = new PumpkinBossAI(_host, _entity, _location, AI_METHOD); } return _ai; } + @Override + public String getName() + { + return NAME; + } + @EventHandler public void updateSpawn(UpdateEvent event) { @@ -176,6 +187,17 @@ public class PumpkinBoss extends MobaBoss } } + @EventHandler(priority = EventPriority.LOWEST) + public void preDamage(CustomDamageEvent event) + { + if (!event.GetDamageeEntity().equals(_entity) || MobaUtil.isInBoundary(null, _entity, _location, getAi().getBoundaries(), event.GetDamagerPlayer(true))) + { + return; + } + + event.SetCancelled("Outside of area"); + } + @Override @EventHandler public void entityDeath(EntityDeathEvent event) @@ -239,19 +261,29 @@ public class PumpkinBoss extends MobaBoss return; } - if (_ai.getTarget() != null && !UtilPlayer.isSpectator(_ai.getTarget()) && UtilMath.offsetSquared(_entity, _ai.getTarget()) < DAMAGE_DIRECT_RADIUS_SQUARED) + LivingEntity target = _ai.getTarget(); + + if (target != null) { - _host.getArcadeManager().GetDamage().NewDamageEvent(_ai.getTarget(), _entity, null, DamageCause.CUSTOM, DAMAGE_DIRECT, true, true, false, DAMAGE_REASON, DAMAGE_REASON); - - // Send a fake hit packet - // Magic number 0 means swing item/attack - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(((CraftLivingEntity) _entity).getHandle(), 0); - - for (Player player : Bukkit.getOnlinePlayers()) + if (UtilMath.offsetSquared(_entity, target) < DAMAGE_DIRECT_RADIUS_SQUARED) { - UtilPlayer.sendPacket(player, packet); + _host.getArcadeManager().GetDamage().NewDamageEvent(target, _entity, null, DamageCause.CUSTOM, DAMAGE_DIRECT, true, true, false, DAMAGE_REASON, DAMAGE_REASON); + + // Send a fake hit packet + // Magic number 0 means swing item/attack + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(((CraftLivingEntity) _entity).getHandle(), 0); + + for (Player player : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(player, packet); + } } } + else + { + _entity.setHealth(Math.min(_entity.getHealth() + HEALTH_OUT_OF_COMBAT, _entity.getMaxHealth())); + updateDisplay(); + } for (LivingEntity entity : UtilEnt.getInRadius(_entity.getLocation(), DAMAGE_RADIUS).keySet()) { @@ -260,7 +292,7 @@ public class PumpkinBoss extends MobaBoss continue; } - _host.getArcadeManager().GetDamage().NewDamageEvent(entity, _entity, null, DamageCause.CUSTOM, DAMAGE_RANGE, false, true, false, DAMAGE_REASON, DAMAGE_REASON); + _host.getArcadeManager().GetDamage().NewDamageEvent(entity, _entity, null, DamageCause.CUSTOM, DAMAGE_RANGE, false, true, false, NAME, DAMAGE_REASON); UtilAction.velocity(entity, UtilAlg.getTrajectory(_entity, entity).setY(1)); UtilParticle.PlayParticleToAll(ParticleType.FLAME, entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 5, ViewDist.LONG); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java index 66cc68a83..6ab78895b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java @@ -9,8 +9,8 @@ import org.bukkit.entity.LivingEntity; public class PumpkinBossAI extends MobaAI { - private static final float SPEED_TARGET = 12F; - private static final float SPEED_HOME = 16F; + private static final float SPEED_TARGET = 5F; + private static final float SPEED_HOME = 3F; public PumpkinBossAI(Moba host, LivingEntity entity, Location home, MobaAIMethod aiMethod) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index b70326896..691ca05d1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -16,6 +16,7 @@ import nautilus.game.arcade.game.games.moba.ai.MobaAI; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import nautilus.game.arcade.game.games.moba.boss.wither.attack.BossAttackEarthquake; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; import nautilus.game.arcade.game.games.moba.util.MobaUtil; @@ -31,8 +32,9 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; public class WitherBoss extends MobaBoss { - private static final float SPEED_TARGET = 7F; - private static final float SPEED_HOME = 9F; + private static final String NAME = "Wither Boss"; + private static final float SPEED_TARGET = 4F; + private static final float SPEED_HOME = 6F; private static final int INITIAL_HEALTH = 1750; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); @@ -47,6 +49,8 @@ public class WitherBoss extends MobaBoss _location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, host.GetSpectatorLocation()))); _team = team; + + addAttack(new BossAttackEarthquake(this)); } @Override @@ -81,15 +85,20 @@ public class WitherBoss extends MobaBoss } @Override - @EventHandler - public void updateMovement(UpdateEvent event) + public String getName() { - super.updateMovement(event); + return NAME; + } - if (event.getType() == UpdateType.SEC && _entity != null && _host.IsLive() && getAi().getTarget() != null) + @EventHandler(priority = EventPriority.LOWEST) + public void preDamage(CustomDamageEvent event) + { + if (!event.GetDamageeEntity().equals(_entity) || MobaUtil.isInBoundary(_team, _entity, _location, getAi().getBoundaries(), event.GetDamagerPlayer(true))) { - new WitherSkullProjectile(_host, _entity, getAi().getTarget(), _team); + return; } + + event.SetCancelled("Outside of area"); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java deleted file mode 100644 index e62652fd3..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java +++ /dev/null @@ -1,83 +0,0 @@ -package nautilus.game.arcade.game.games.moba.boss.wither; - -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.moba.Moba; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.WitherSkull; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; - -public class WitherSkullProjectile implements IThrown -{ - - private static final int DAMAGE = 10; - - private final Moba _host; - private final ArcadeManager _manager; - private final GameTeam _owner; - - public WitherSkullProjectile(Moba host, LivingEntity shooter, LivingEntity target, GameTeam owner) - { - _host = host; - _manager = host.getArcadeManager(); - _owner = owner; - - WitherSkull skull = shooter.getWorld().spawn(shooter.getLocation().add(0, 2, 0), WitherSkull.class); - - skull.setShooter(shooter); - skull.setYield(0); - skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target))); - - _manager.GetProjectile().AddThrow(skull, shooter, this, 2000, true, true, true, false, 0.5F); - } - - @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) - { - if (target == null) - { - Expire(data); - return; - } - - if (target instanceof Player) - { - Player targetPlayer = (Player) target; - GameTeam targetTeam = _host.GetTeam(targetPlayer); - - // Not team damage - if (!_owner.equals(targetTeam)) - { - _manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, DAMAGE, true, true, false, "Wither Boss", "Wither Skull"); - } - - Expire(data); - } - } - - @Override - public void Idle(ProjectileUser data) - { - } - - @Override - public void Expire(ProjectileUser data) - { - Entity thrown = data.getThrown(); - - thrown.getWorld().playSound(thrown.getLocation(), Sound.EXPLODE, 1, 1.6F); - UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, thrown.getLocation(), 0, 0, 0, 0.1F, 1, ViewDist.LONG); - thrown.remove(); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java new file mode 100644 index 000000000..6279b1ffa --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java @@ -0,0 +1,93 @@ +package nautilus.game.arcade.game.games.moba.boss.wither.attack; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilServer; +import nautilus.game.arcade.game.games.moba.boss.MobaBossAttack; +import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import java.util.HashSet; +import java.util.Map.Entry; +import java.util.Set; + +public class BossAttackEarthquake implements MobaBossAttack +{ + + private static final String ATTACK_NAME = "Earthquake"; + private static final int RADIUS = 8; + private static final int DAMAGE = 8; + private static final double FALLING_BLOCK_CHANCE = 0.1; + + private final WitherBoss _boss; + private final Set _entities; + + public BossAttackEarthquake(WitherBoss boss) + { + _boss = boss; + _entities = new HashSet<>(); + + UtilServer.RegisterEvents(this); + } + + @Override + public void run() + { + LivingEntity boss = _boss.getEntity(); + + for (Block block : UtilBlock.getBlocksInRadius(boss.getLocation(), RADIUS)) + { + // Only want blocks that are on the floor + if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > FALLING_BLOCK_CHANCE) + { + continue; + } + + FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().add(0.5, 1, 0.5), block.getType(), block.getData()); + fallingBlock.setHurtEntities(false); + fallingBlock.setDropItem(false); + fallingBlock.setVelocity(UtilAlg.getTrajectory(boss, fallingBlock).multiply(0.25).setY(1.5)); + } + + for (Entry entry : UtilEnt.getInRadius(boss.getLocation(), RADIUS).entrySet()) + { + LivingEntity entity = entry.getKey(); + double dist = entry.getValue(); + + if (MobaUtil.isTeamEntity(entity, _boss.getTeam())) + { + continue; + } + + _boss.getHost().getArcadeManager().GetDamage().NewDamageEvent(entity, boss, null, DamageCause.CUSTOM, DAMAGE * (dist + 0.5), false, true, false, _boss.getName(), ATTACK_NAME); + UtilAction.velocity(entity, UtilAlg.getTrajectory(boss, entity).setY(1)); + } + } + + @Override + public void cleanup() + { + UtilServer.Unregister(this); + } + + @EventHandler + public void entityChangeBlock(EntityChangeBlockEvent event) + { + if (_entities.contains(event.getEntity())) + { + event.setCancelled(true); + event.getEntity().remove(); + _entities.remove(event.getEntity()); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index 79bd7cdb9..c55cf84a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -13,13 +13,11 @@ import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointCaptureEvent; import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import java.util.Collections; import java.util.HashMap; import java.util.Map; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index a2de07ee3..aa0c6bc95 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -28,6 +28,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.scheduler.BukkitRunnable; +import org.jooq.util.derby.sys.Sys; import java.util.ArrayList; import java.util.HashMap; @@ -47,21 +48,20 @@ public class MinionWave implements Listener private final MinionManager _minionManager; private final GameTeam _owner; private final Class _clazz; + private final long _startTime; private final List _path; private final List _minions; - //private final Map _lastDamage; - public MinionWave(Moba host, MinionManager minionManager, GameTeam owner, List path, Class clazz) { _host = host; _minionManager = minionManager; _owner = owner; _clazz = clazz; + _startTime = System.currentTimeMillis(); _path = path; _minions = new ArrayList<>(MAX_MINIONS_PER_WAVE); - //_lastDamage = new HashMap<>(MAX_MINIONS_PER_WAVE); UtilServer.RegisterEvents(this); @@ -135,7 +135,6 @@ public class MinionWave implements Listener // Too close if (UtilMath.offsetSquared(entity.getLocation(), target) < TOO_CLOSE_SQUARED) { - //Bukkit.broadcastMessage("Too close"); continue; } } @@ -146,19 +145,27 @@ public class MinionWave implements Listener if (newTarget == _path.size()) { - //Bukkit.broadcastMessage("Done"); continue; } minion.setTargetIndex(newTarget); minion.setTarget(_path.get(newTarget)); - //Bukkit.broadcastMessage("Advance target " + newTarget); } } + } + + @EventHandler + public void updateUnregister(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } _minions.removeIf(minion -> minion.getEntity() == null || minion.getEntity().isDead() || !minion.getEntity().isValid()); - if (_minions.isEmpty()) + // Only should unregister the wave after all entities have spawned + if (_minions.isEmpty() && UtilTime.elapsed(_startTime, 10000)) { UtilServer.Unregister(this); _minionManager.unregisterWave(this); @@ -381,19 +388,6 @@ public class MinionWave implements Listener } } -// @EventHandler(priority = EventPriority.MONITOR) -// public void damageSound(CustomDamageEvent event) -// { -// LivingEntity damagee = event.GetDamageeEntity(); -// -// if (event.isCancelled() || !isMinion(damagee) || !UtilTime.elapsed(_lastDamage.get(damagee), 2000)) -// { -// return; -// } -// -// damagee.getWorld().playSound(damagee.getLocation(), Sound.ZOMBIE_HURT, 1, 1.4F); -// } - @EventHandler public void entityCombust(EntityCombustEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 411f01463..4242ec20f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -5,6 +5,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import org.bukkit.Bukkit; @@ -13,6 +14,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map.Entry; @@ -22,11 +24,6 @@ public class MobaUtil { public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayers) - { - return getBestEntityTarget(host, owner, source, location, targetRange, targetPlayers, false); - } - - public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayers, boolean targetPlayersMore) { LivingEntity highest = null; double bestDist = 0; @@ -47,18 +44,13 @@ public class MobaUtil continue; } - // Make players more desirable + // Ignore players on the same team if (entity instanceof Player) { if (!targetPlayers || owner.equals(host.GetTeam((Player) entity))) { continue; } - - if (targetPlayersMore) - { - dist += 0.5; - } } if (bestDist < dist) @@ -71,9 +63,34 @@ public class MobaUtil return highest; } - public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location center, List boundaries) + public static boolean isInBoundary(GameTeam owner, LivingEntity source, Location center, List boundaries, LivingEntity target) { - Set ignored = new HashSet<>(); + return getEntitiesInBoundary(owner, source, center, boundaries).contains(target); + } + + public static LivingEntity getBestEntityTarget(GameTeam owner, LivingEntity source, Location center, List boundaries) + { + LivingEntity best = null; + double bestDist = Double.MAX_VALUE; + + for (LivingEntity entity : getEntitiesInBoundary(owner, source, center, boundaries)) + { + double dist = UtilMath.offsetSquared(entity.getLocation(), center); + + if (dist < bestDist) + { + best = entity; + bestDist = dist; + } + } + + return best; + } + + public static Set getEntitiesInBoundary(GameTeam owner, LivingEntity source, Location center, List boundaries) + { + Set entities = new HashSet<>(); + List ignored = new ArrayList<>(); if (owner != null) { @@ -81,15 +98,6 @@ public class MobaUtil ignored.addAll(owner.GetPlayers(true)); } - // Add all spectators to ignored players - for (Player player : Bukkit.getOnlinePlayers()) - { - if (UtilPlayer.isSpectator(player)) - { - ignored.add(player); - } - } - // For each boundary for (Location boundary : boundaries) { @@ -107,55 +115,28 @@ public class MobaUtil // Advance the location checking.add(direction); - LivingEntity highest = null; - double bestDist = 0; - // Check for nearby entities - for (Entry entry : UtilEnt.getInRadius(checking, 2).entrySet()) + for (LivingEntity entity : UtilEnt.getInRadius(checking, 3).keySet()) { - LivingEntity entity = entry.getKey(); - double dist = entry.getValue(); - if (source.equals(entity) || ignored.contains(entity)) { continue; } - if (owner != null) + // Check for team entities + if (owner != null && isTeamEntity(entity, owner)) { - // Check for team entities - if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) - { - continue; - } - - // Check for same team players - if (entity instanceof Player) - { - if (owner.equals(host.GetTeam((Player) entity))) - { - continue; - } - } + continue; } - if (bestDist < dist) - { - highest = entity; - bestDist = dist; - } - } - - if (highest != null) - { - return highest; + entities.add(entity); } checkedDist++; } } - return null; + return entities; } public static String getHealthBar(LivingEntity entity, int bars) @@ -203,4 +184,9 @@ public class MobaUtil return C.cGreenB; } + + public static boolean isTeamEntity(LivingEntity entity, GameTeam team) + { + return entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(team.GetName()); + } } From 5c8e6d84b06f5d948fb12b4c15027bd1bf0c7a12 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 31 May 2017 21:51:04 +0200 Subject: [PATCH 078/283] Add increment command, Questtrackers, change some visuals, allow Quests to have multiple required items --- .../src/mineplex/core/quests/Quest.java | 42 +++---- .../mineplex/core/quests/QuestManager.java | 112 ++++++++++++++++-- .../core/quests/command/GetQuestCommand.java | 16 ++- .../quests/command/IncrementQuestCommand.java | 67 +++++++++++ .../core/quests/command/OpenGuiCommand.java | 1 - .../core/quests/event/QuestBuyEvent.java | 60 ++++++++++ .../quests/repository/QuestRepository.java | 9 ++ .../core/quests/shop/BuyQuestButton.java | 11 +- .../mineplex/core/quests/shop/QuestPage.java | 27 ++++- .../quests/shop/RedeemDeclineQuestButton.java | 4 +- .../src/mineplex/hub/HubManager.java | 2 +- .../nautilus/game/arcade/ArcadeManager.java | 2 +- .../src/nautilus/game/arcade/game/Game.java | 9 +- .../champions/quests/CaptureQuestTracker.java | 2 +- .../champions/quests/FlagQuestTracker.java | 2 +- .../games/draw/quests/GuessQuestTracker.java | 2 +- .../hideseek/quests/DisguiseQuestTracker.java | 2 +- .../arcade/game/games/skyfall/Skyfall.java | 3 +- .../skyfall/quests/RingQuestTracker.java | 2 +- .../quests/PerfectBuildQuestTracker.java | 2 +- .../games/uhc/quests/TameQuestTracker.java | 2 +- .../arcade/quest/ChestOpenQuestTracker.java | 2 +- .../arcade/quest/CollectQuestTracker.java | 2 +- .../arcade/quest/KillEntityQuestTracker.java | 5 +- .../game/arcade/quest/KillQuestTracker.java | 2 +- .../arcade/quest/ParticipateQuestTracker.java | 2 +- .../arcade/quest/PlayGameQuestTracker.java | 2 +- .../game/arcade/quest/QuestTracker.java | 39 ++++-- .../game/arcade/quest/WinQuestTracker.java | 2 +- 29 files changed, 360 insertions(+), 75 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestBuyEvent.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java index a15d604f5..5fe1d89fc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java @@ -34,10 +34,11 @@ public class Quest private GameDisplay _game; private GameCategory _gameCategory; + private boolean _generalGame; private boolean _overworld; private TriggerType _trigger; - private String _item; + private String[] _item; private int _statToComplete; private long _lastCompleted; @@ -46,7 +47,7 @@ public class Quest private int _timesCompleted; - public Quest(int questID, String name, String task, int cost, String reward, QuestRarity rarity, String type, TriggerType trigger, String item, int statToComplete) + public Quest(int questID, String name, String task, int cost, String reward, QuestRarity rarity, String type, TriggerType trigger, String[] item, int statToComplete) { _questID = questID; _questName = name; @@ -68,7 +69,10 @@ public class Quest } catch (IllegalArgumentException e) {} - _overworld = (_game == null && _gameCategory == null); + _generalGame = _type.equalsIgnoreCase("General"); + + if (!_generalGame) + _overworld = (_game == null && _gameCategory == null); } public int getID() @@ -121,7 +125,7 @@ public class Quest return _trigger; } - public String getItem() + public String[] getItem() { return _item; } @@ -188,26 +192,6 @@ public class Quest return _lastCompleted; } - public void reward(InventoryManager inventory, DonationManager donations, Player player, Consumer callback) - { - if (_questReward.contains(":")) - { - if (getRewardName().equalsIgnoreCase("Shards")) - { - donations.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing Quest: " + _questID, Integer.parseInt(_questReward.split(":")[1]), callback); - } - else if (getRewardName().equalsIgnoreCase("Gems")) - { - donations.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing Quest: " + _questID, Integer.parseInt(_questReward.split(":")[1]), callback); - } - else - { - inventory.addItemToInventory(player, getRewardName(), getRewardAmount()); - callback.accept(true); - } - } - } - public String getRewardName() { return _questReward.split(":")[0]; @@ -228,6 +212,11 @@ public class Quest return _timesCompleted; } + public boolean isActive() + { + return _current != 1; + } + public String[] getQuestInfo() { String[] info = new String[]{ @@ -243,6 +232,11 @@ public class Quest return info; } + public boolean isGeneral() + { + return _generalGame; + } + @Override public Quest clone() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index 939c94fad..6ec36cbb9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -6,26 +6,38 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.function.Consumer; + +import net.md_5.bungee.api.ChatColor; import org.apache.commons.lang3.tuple.Triple; +import org.bukkit.Location; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.MiniClientPlugin; -import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Pair; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; -import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; -import mineplex.core.game.GameCategory; -import mineplex.core.game.GameDisplay; import mineplex.core.google.GoogleSheetsManager; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; +import mineplex.core.npc.Npc; +import mineplex.core.npc.NpcManager; import mineplex.core.quests.command.GetQuestCommand; +import mineplex.core.quests.command.IncrementQuestCommand; import mineplex.core.quests.command.OpenGuiCommand; import mineplex.core.quests.repository.QuestRepository; +import mineplex.core.quests.shop.QuestShop; +import mineplex.core.stats.StatsManager; import mineplex.quest.client.RedisQuestSupplier; import mineplex.quest.common.QuestSupplier; import mineplex.serverdata.redis.messaging.PubSubJedisClient; @@ -52,7 +64,12 @@ public class QuestManager extends MiniClientPlugin private QuestSupplier _questSupplier = new RedisQuestSupplier(getPlugin(), new PubSubRouter(new PubSubJedisClient(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection()))); - public QuestManager(InventoryManager inventoryManager, DonationManager donationManager) + private Npc _questNPC; + private boolean _enableNPC; + + private Hologram _hologram; + + public QuestManager(HologramManager hologramManager, InventoryManager inventoryManager, DonationManager donationManager) { super("Quest Manager"); @@ -64,6 +81,25 @@ public class QuestManager extends MiniClientPlugin _inventoryManager = inventoryManager; setupQuests(); + + _questNPC = require(NpcManager.class).getNpcByName("Knight of GWEN"); + if (_questNPC == null) + { + _enableNPC = false; + } + else + { + Location loc = _questNPC.getEntity().getLocation(); + _hologram = new Hologram(hologramManager, loc.clone().add(0, 2.5, 0), ChatColor.GREEN + "" + ChatColor.BOLD + "(QUESTS)"); + _hologram.start(); + _enableNPC = true; + } + } + + @Override + public void disable() + { + _hologram.stop(); } @Override @@ -71,6 +107,7 @@ public class QuestManager extends MiniClientPlugin { addCommand(new OpenGuiCommand(this)); addCommand(new GetQuestCommand(this)); + addCommand(new IncrementQuestCommand(this)); } public void setupQuests() @@ -105,10 +142,39 @@ public class QuestManager extends MiniClientPlugin QuestRarity.getByName(rarity), type, TriggerType.getByName(trigger), - item, + item.split(","), Integer.parseInt(statcompletion))); } } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void openGui(PlayerInteractAtEntityEvent event) + { + if (!_enableNPC) + return; + + Entity entity = event.getRightClicked(); + if (entity.equals(_questNPC.getEntity())) + { + new QuestShop(this, _clients, _donationManager).attemptShopOpen(event.getPlayer()); + } + } + + @EventHandler + public void openGui(EntityDamageByEntityEvent event) + { + if (!_enableNPC) + return; + + if (event.getDamager() instanceof Player) + { + Player player = (Player) event.getDamager(); + if (event.getEntity().equals(_questNPC.getEntity())) + { + new QuestShop(this, _clients, _donationManager).attemptShopOpen(player); + } + } + } @EventHandler public void playerJoin(PlayerJoinEvent event) @@ -176,16 +242,17 @@ public class QuestManager extends MiniClientPlugin if (completed) { quest.setTimesCompleted(quest.getTimesCompleted() + 1); + quest.setLastCompleted(System.currentTimeMillis()); } Get(player).removeQuest(quest.getID()); _repository.resetQuest(_clients.Get(player), quest, completed); } - public void incrementQuest(CoreClient client, Quest quest, int value) + public void incrementQuest(Player player, Quest quest, int value) { quest.increment(value); - _repository.incrementQuest(client, quest, value); + _repository.incrementQuest(_clients.Get(player), quest, value); } public Set getCurrentQuests() @@ -195,12 +262,33 @@ public class QuestManager extends MiniClientPlugin { set.add(quest.getUniqueId()); } -// set.add(2); -// set.add(1); -// set.add(3); -// set.add(0); return set; } + + public void rewardQuest(Player player, Quest quest, Consumer callback) + { + if (quest.getReward().contains(":")) + { + if (quest.getRewardName().equalsIgnoreCase("Shards")) + { + _donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing Quest: " + quest.getID(), Integer.parseInt(quest.getReward().split(":")[1]), callback); + } + else if (quest.getRewardName().equalsIgnoreCase("Gems")) + { + _donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing Quest: " + quest.getID(), Integer.parseInt(quest.getReward().split(":")[1]), callback); + } + else if (quest.getRewardName().equalsIgnoreCase("XP")) + { + require(StatsManager.class).incrementStat(player, "Global.ExpEarned", quest.getRewardAmount()); + callback.accept(true); + } + else + { + _inventoryManager.addItemToInventory(player, quest.getRewardName(), quest.getRewardAmount()); + callback.accept(true); + } + } + } public CoreClientManager getClients() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java index e4d776ebc..488a03eb9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java @@ -27,7 +27,7 @@ public class GetQuestCommand extends CommandBase { if (args.length < 1) { - UtilPlayer.message(caller, F.main("Quest Manager", "You have to define a quest")); + UtilPlayer.message(caller, F.main("Quest Manager", "You have to submit valid arguments")); return; } @@ -37,9 +37,19 @@ public class GetQuestCommand extends CommandBase return; } + Player player = caller; + if (args.length == 2) + { + if (UtilPlayer.searchExact(args[1]) != null) + player = UtilPlayer.searchExact(args[1]); + } + Quest quest = Plugin.getQuestByID(Integer.parseInt(args[0])); - Plugin.addNewQuest(caller, quest); - UtilPlayer.message(caller, F.main("Quest Manager", "Added Quest: " + ChatColor.YELLOW + quest.getName())); + Plugin.addNewQuest(player, quest); + UtilPlayer.message(player, F.main("Quest Manager", "Added Quest: " + ChatColor.YELLOW + quest.getName())); + + if (caller != player) + UtilPlayer.message(caller, F.main("Quest Manager", "You gave the Quest: " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + player.getName())); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java new file mode 100644 index 000000000..d728335aa --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java @@ -0,0 +1,67 @@ +package mineplex.core.quests.command; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.quests.Quest; +import mineplex.core.quests.QuestManager; + +/** + * CompleteQuestCommand + * + * @author xXVevzZXx + */ +public class IncrementQuestCommand extends CommandBase +{ + public IncrementQuestCommand(QuestManager plugin) + { + super(plugin, Rank.ADMIN, "IncrementQuest"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 2) + { + UtilPlayer.message(caller, F.main("Quest Manager", "You have to submit valid arguments")); + return; + } + + Player player = caller; + if (args.length == 3) + { + if (UtilPlayer.searchExact(args[2]) != null) + player = UtilPlayer.searchExact(args[2]); + } + + if (Plugin.Get(player).getQuest(Integer.parseInt(args[0])) == null) + { + UtilPlayer.message(caller, F.main("Quest Manager", "Quest not found")); + return; + } + + int increment = 0; + try + { + increment = Integer.parseInt(args[1]); + } + catch (NumberFormatException e) + { + UtilPlayer.message(caller, F.main("Quest Manager", "You have to submit a valid number")); + return; + } + + Quest quest = Plugin.Get(player).getQuest(Integer.parseInt(args[0])); + + Plugin.incrementQuest(player, quest, increment); + UtilPlayer.message(player, F.main("Quest Manager", "Incremented Quest: " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " by " + increment)); + + if (caller != player) + UtilPlayer.message(caller, F.main("Quest Manager", "You incremented the Quest: " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " for " + ChatColor.YELLOW + player.getName() + ChatColor.GRAY + " by " + increment)); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java index 7daeb4b4f..f110d2305 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java @@ -24,5 +24,4 @@ public class OpenGuiCommand extends CommandBase { new QuestShop(Plugin, Plugin.getClients(), Plugin.getDonations()).attemptShopOpen(caller); } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestBuyEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestBuyEvent.java new file mode 100644 index 000000000..a1cfba344 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestBuyEvent.java @@ -0,0 +1,60 @@ +package mineplex.core.quests.event; + +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.core.quests.Quest; + +/** + * QuestBuyEvent + * + * @author xXVevzZXx + */ +public class QuestBuyEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private boolean _cancelled = false; + + private Quest _quest; + + private String _cancelReason; + + public QuestBuyEvent(Quest quest) + { + _quest = quest; + } + + public Quest getQuest() + { + return _quest; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public void setCancelled(String reason) + { + _cancelled = true; + _cancelReason = reason; + } + + public String getCancelMessage() + { + return _cancelReason; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java index 37733a116..8a5cd8a08 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java @@ -31,9 +31,18 @@ public class QuestRepository extends RepositoryBase private static final String FETCH_QUESTS = "SELECT questId, progress, questCompletion, lastCompleted FROM accountQuest WHERE accountId=?"; + public String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS accountQuest (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, questId INT NOT NULL, progress INT, questCompletion INT, lastCompleted BIGINT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts (id), UNIQUE INDEX questIndex (accountId, questId), INDEX progressIndex (progress), INDEX completionIndex (questCompletion));"; + public QuestRepository() { super(DBPool.getAccount()); + + createTable(); + } + + public void createTable() + { + executeUpdate(CREATE_TABLE); } public void getQuests(CoreClient client, Callback>>> callback) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java index 6267f1980..ac0ad615f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java @@ -9,9 +9,11 @@ import org.bukkit.event.inventory.ClickType; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.quests.Quest; import mineplex.core.quests.QuestManager; +import mineplex.core.quests.event.QuestBuyEvent; import mineplex.core.recharge.Recharge; import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; @@ -62,11 +64,18 @@ public class BuyQuestButton implements IButton { if (!UtilTime.elapsed(_questManager.Get(player).getQuestFromAll(_quest.getID()).getLastCompleted(), 1000*60*60*24)) { - UtilPlayer.message(player, F.main("Quest", "You already completed that Quest!")); + UtilPlayer.message(player, F.main("Quest", "You already completed that Quest today!")); return; } } + QuestBuyEvent event = UtilServer.CallEvent(new QuestBuyEvent(_quest)); + if (event.isCancelled()) + { + UtilPlayer.message(player, F.main("Quest", event.getCancelMessage())); + return; + } + SalesPackageBase salesPackage = new QuestSale(_quest.getName(), Material.PAPER, _quest.getCost()); _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, _page.getDonationManager(), () -> { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java index 13c0fe7b2..adcac183e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java @@ -1,11 +1,14 @@ package mineplex.core.quests.shop; +import java.util.ArrayList; import java.util.Arrays; import org.apache.commons.lang3.ArrayUtils; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; @@ -46,8 +49,10 @@ public class QuestPage extends ShopPageBase @Override protected void buildPage() { + ArrayList playerQuests = _shop.getQuestManager().Get(_player).getQuests(); + int i = 0; - setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " ")); + setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.RESET + "" + ChatColor.BOLD + "Quests to buy")); { int currentSlot = 4; int diff = 0; @@ -65,6 +70,23 @@ public class QuestPage extends ShopPageBase diff++; forward = !forward; + boolean cont = false; + + for (Quest playerQuest : playerQuests) + { + if (playerQuest.isActive()) + { + if (playerQuest.getID() == questID) + { + cont = true; + break; + } + } + } + + if (cont) + continue; + Quest quest = _shop.getQuestManager().getQuestByID(questID); ItemStack item = new ItemStack(Material.PAPER); @@ -106,7 +128,7 @@ public class QuestPage extends ShopPageBase int currentSlot = 4; int diff = 0; boolean forward = true; - for (Quest quest : _shop.getQuestManager().Get(_player).getQuests()) + for (Quest quest : playerQuests) { if (forward) { @@ -129,6 +151,7 @@ public class QuestPage extends ShopPageBase ))); item.setItemMeta(meta); + item.addUnsafeEnchantment(Enchantment.DURABILITY, 1); addButton(i + currentSlot, item, new RedeemDeclineQuestButton(_inventory, _donationManager, _manager, this, quest)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java index 9a5cb36a1..2a254ed94 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java @@ -78,7 +78,7 @@ public class RedeemDeclineQuestButton implements IButton return; } - _quest.reward(_inventory, _donations, player, new Consumer() + _questManager.rewardQuest(player, _quest, new Consumer() { @Override public void accept(Boolean succes) @@ -86,12 +86,12 @@ public class RedeemDeclineQuestButton implements IButton if (succes) { _questManager.resetQuest(player, _quest, true); + player.closeInventory(); UtilPlayer.message(player, F.main("Quest", "You have recieved " + ChatColor.AQUA + _quest.getRewardAmount() + " " + _quest.getRewardName() + " " + ChatColor.GRAY + "for completing: " + ChatColor.YELLOW + _quest.getName())); } else { UtilPlayer.message(player, F.main("Quest", "Something went wrong!")); - } } }); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index f9b628563..5109551d0 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -294,7 +294,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess new EasterEggHunt(plugin, _clientManager); - _questManager = new QuestManager(_inventoryManager, _donationManager); + _questManager = new QuestManager(hologramManager, _inventoryManager, _donationManager); new TemporaryGemHuntersServerSender(_portal); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 35a3b2eb0..3e6d3fa66 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -391,7 +391,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _kitProgressionManager = new KitProgressionManager(getPlugin(), donationManager, clientManager); _progressionKitManager = new ProgressingKitManager(this); _serverUptimeManager = new ServerUptimeManager(this); - _questManager = new QuestManager(_inventoryManager, _donationManager); + _questManager = new QuestManager(hologramManager, _inventoryManager, _donationManager); if (GetHost() != null && !GetHost().isEmpty() && !GetHost().startsWith("COM-")) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index adaaa630d..efa797e1f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -75,6 +75,7 @@ import mineplex.core.lifetimes.ListenerComponent; import mineplex.core.lifetimes.PhasedLifetime; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; +import mineplex.core.quests.event.QuestBuyEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilGameProfile; @@ -351,7 +352,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed public int EloStart = 1000; public boolean CanAddStats = true; - public boolean CanProgressQuests = true; public boolean CanGiveLoot = true; public boolean HideTeamSheep = false; @@ -2081,6 +2081,13 @@ public abstract class Game extends ListenerComponent implements Lifetimed ((CraftEntity) event.getEntity()).getHandle().dead = false; } } + + @EventHandler + public void onQuestBuy(QuestBuyEvent event) + { + if (GetState() == GameState.Live || GetState() == GameState.Prepare || GetState() == GameState.End) + event.setCancelled("You cant buy Quests while you are ingame!"); + } public NautHashMap getDeadBodies() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/CaptureQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/CaptureQuestTracker.java index 3e2e0fd17..9a2f065c5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/CaptureQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/CaptureQuestTracker.java @@ -26,7 +26,7 @@ public class CaptureQuestTracker extends QuestTracker public void capture(CaptureEvent event) { for (Player player : event.getPlayers()) - incrementQuests(player, "Point Capture", 1); + incrementQuests(player, 1, "Point Capture"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/FlagQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/FlagQuestTracker.java index eb4af9e77..92b9be1c2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/FlagQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/quests/FlagQuestTracker.java @@ -24,7 +24,7 @@ public class FlagQuestTracker extends QuestTracker @EventHandler public void captureFlag(PlayerCaptureFlagEvent event) { - incrementQuests(event.GetPlayer(), "Flag Capture", 1); + incrementQuests(event.GetPlayer(), 1, "Flag Capture"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/quests/GuessQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/quests/GuessQuestTracker.java index 4d759661e..786510591 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/quests/GuessQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/quests/GuessQuestTracker.java @@ -30,7 +30,7 @@ public class GuessQuestTracker extends QuestTracker return; if (System.currentTimeMillis() - event.getDrawRound().Time < 8000) - incrementQuests(event.getPlayer(), "Guesses", 1); + incrementQuests(event.getPlayer(), 1, "Guesses"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/quests/DisguiseQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/quests/DisguiseQuestTracker.java index 9b7cab861..494b72154 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/quests/DisguiseQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/quests/DisguiseQuestTracker.java @@ -28,7 +28,7 @@ public class DisguiseQuestTracker extends QuestTracker if (getGame().GetState() != Game.GameState.Live) return; - incrementQuests(event.getPlayer(), "Disguise", 1); + incrementQuests(event.getPlayer(), 1, "Disguise"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java index 5adb26f3b..b5ca174a0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java @@ -337,8 +337,7 @@ public abstract class Skyfall extends Game return; _lowerIsland.refillChests(); - - + Announce(ChatColor.AQUA + "" + ChatColor.BOLD + "Chests on the lower middle Island have been refilled!", true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/quests/RingQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/quests/RingQuestTracker.java index 5ca820dd0..4a8c0445f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/quests/RingQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/quests/RingQuestTracker.java @@ -31,7 +31,7 @@ public class RingQuestTracker extends QuestTracker if (!getGame().IsAlive(event.getPlayer())) return; - incrementQuests(event.getPlayer(), "Booster Rings", 1); + incrementQuests(event.getPlayer(), 1, "Booster Rings", getGame().GetKit(event.getPlayer()).GetName() + "Kit"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/quests/PerfectBuildQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/quests/PerfectBuildQuestTracker.java index 937e97bbd..b26e80bc0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/quests/PerfectBuildQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/quests/PerfectBuildQuestTracker.java @@ -24,6 +24,6 @@ public class PerfectBuildQuestTracker extends QuestTracker @EventHandler public void onPerfectBuild(PerfectBuildEvent event) { - incrementQuests(event.getPlayer(), "Perfect Build", 1); + incrementQuests(event.getPlayer(), 1, "Perfect Build"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/quests/TameQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/quests/TameQuestTracker.java index a8aebc673..e5a3df895 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/quests/TameQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/quests/TameQuestTracker.java @@ -32,7 +32,7 @@ public class TameQuestTracker extends QuestTracker if (event.getEntityType() != EntityType.HORSE) return; - incrementQuests((Player) event.getOwner(), "Tamed Horse", 1); + incrementQuests((Player) event.getOwner(), 1, "Tamed Horse"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java index 98799b6c9..30cbb77d2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java @@ -51,7 +51,7 @@ public class ChestOpenQuestTracker extends QuestTracker locs.add(event.getClickedBlock().getLocation()); - incrementQuests((Player) event.getPlayer(), "Chest", 1); + incrementQuests((Player) event.getPlayer(), 1, "Chest"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java index ea91d9382..d8ad07885 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java @@ -113,7 +113,7 @@ public class CollectQuestTracker extends QuestTracker if (event.getCurrentItem().hasItemMeta()) item = event.getCurrentItem().getItemMeta().getDisplayName(); - incrementQuests((Player) event.getWhoClicked(), ChatColor.stripColor(item), event.getCurrentItem().getAmount()); + incrementQuests((Player) event.getWhoClicked(), event.getCurrentItem().getAmount(), ChatColor.stripColor(item)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillEntityQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillEntityQuestTracker.java index 72c40f5aa..7b99b9198 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillEntityQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillEntityQuestTracker.java @@ -2,15 +2,12 @@ package nautilus.game.arcade.quest; import net.md_5.bungee.api.ChatColor; -import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDeathEvent; import mineplex.core.quests.TriggerType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.Game; @@ -48,7 +45,7 @@ public class KillEntityQuestTracker extends QuestTracker if (lEntity.isCustomNameVisible()) name = lEntity.getCustomName(); - incrementQuests((Player) player, ChatColor.stripColor(name), 1); + incrementQuests((Player) player, 1, ChatColor.stripColor(name), getGame().GetKit(player).GetName() + "Kit"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java index 0dbadffb6..ce071aecd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/KillQuestTracker.java @@ -38,7 +38,7 @@ public class KillQuestTracker extends QuestTracker if (player == null) return; - incrementQuests(player, "Player", 1); + incrementQuests(player, 1, "Player", getGame().GetKit(player).GetName() + "Kit"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ParticipateQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ParticipateQuestTracker.java index a9035ca7a..94af7fffe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ParticipateQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ParticipateQuestTracker.java @@ -31,7 +31,7 @@ public class ParticipateQuestTracker extends QuestTracker return; for (Player player : getGame().GetPlayers(true)) - incrementQuests(player, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), 1); + incrementQuests(player, 1, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), getGame().GetKit(player).GetName() + "Kit"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/PlayGameQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/PlayGameQuestTracker.java index 5cb917107..b8d81a39e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/PlayGameQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/PlayGameQuestTracker.java @@ -31,7 +31,7 @@ public class PlayGameQuestTracker extends QuestTracker return; for (Player player : getGame().GetPlayers(true)) - incrementQuests(player, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), 1); + incrementQuests(player, 1, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), getGame().GetKit(player).GetName() + "Kit"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java index f3f03090e..c34a50efc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java @@ -32,29 +32,52 @@ public class QuestTracker implements Listener public boolean canProgressQuests() { - return getGame().CanProgressQuests; + return getGame().CanAddStats; } public void incrementQuests(Player player, int value) { - incrementQuests(player, "", value); + incrementQuests(player, value, ""); } - public void incrementQuests(Player player, String item, int value) + public void incrementQuests(Player player, int value, String... items) { if (canProgressQuests()) { for (Quest quest : getGame().getArcadeManager().getQuestManager().getAvailableQuests()) { - if (getGame().GetType().getDisplay() != quest.getGame() && getGame().GetType().getDisplay().getGameCategory() != quest.getGameCategory()) - continue; + if (!quest.isGeneral()) + { + if (getGame().GetType().getDisplay() != quest.getGame() && getGame().GetType().getDisplay().getGameCategory() != quest.getGameCategory()) + continue; + } if (quest.getTrigger() != _trigger) continue; - if (!quest.getItem().equalsIgnoreCase("")) + if (!quest.getItem()[0].equalsIgnoreCase("")) { - if (!quest.getItem().equalsIgnoreCase(item)) + boolean cont = true; + for (String questItem : quest.getItem()) + { + for (String str : items) + { + String first = str.replaceAll(" ", ""); + String compare = questItem.replaceAll(" ", ""); + + if (first.equalsIgnoreCase(compare)) + { + cont = false; + break; + } + else + { + cont = true; + } + } + } + + if (cont) continue; } @@ -64,7 +87,7 @@ public class QuestTracker implements Listener Quest toProgress = data.getQuest(quest.getID()); - _game.getArcadeManager().getQuestManager().incrementQuest(_game.getArcadeManager().GetClients().Get(player), toProgress, value); + _game.getArcadeManager().getQuestManager().incrementQuest(player, toProgress, value); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/WinQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/WinQuestTracker.java index 4bcf45ab9..283f405fd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/WinQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/WinQuestTracker.java @@ -32,7 +32,7 @@ public class WinQuestTracker extends QuestTracker for (Player player : getGame().getWinners()) { - incrementQuests(player, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), 1); + incrementQuests(player, 1, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), getGame().GetKit(player).GetName() + "Kit"); } } From 13ad5904878a63cbd7f61e315a8a2b937bb22b47 Mon Sep 17 00:00:00 2001 From: Kenny Goodin Date: Wed, 31 May 2017 15:58:28 -0400 Subject: [PATCH 079/283] Reduce QuestDaemon log spam, add failsafe for when no active quests are loaded --- .../quest/client/RedisQuestSupplier.java | 18 ++++++++++++++---- .../src/mineplex/quest/common/BaseQuest.java | 7 +++++++ .../mineplex/quest/daemon/QuestDaemon.java | 12 ++++++++++++ .../mineplex/quest/daemon/QuestManager.java | 19 ++++++++++++++----- 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java index 128644bb5..a041475b9 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java @@ -27,6 +27,7 @@ public class RedisQuestSupplier implements QuestSupplier { private final JavaPlugin _plugin; + private final String _serverUniqueId; private final PubSubMessager _pubSub; private final ReadWriteLock _lock = new ReentrantReadWriteLock(); @@ -37,13 +38,12 @@ public class RedisQuestSupplier implements QuestSupplier _plugin = plugin; _pubSub = pubSub; - String serverUniqueId = plugin.getConfig().getString("serverstatus.name"); + _serverUniqueId = plugin.getConfig().getString("serverstatus.name"); - // request current active quests, send server unique id so we can send a response just to this server - _pubSub.publish(PubSubChannels.QUEST_REQUEST_BASE, serverUniqueId); + requestActiveQuests(); // update quests sent specifically to this server when it requests them (like on startup) - _pubSub.subscribe(PubSubChannels.QUEST_REQUEST_BASE + serverUniqueId, this::updateQuests); + _pubSub.subscribe(PubSubChannels.QUEST_REQUEST_BASE + _serverUniqueId, this::updateQuests); // update quests when received _pubSub.subscribe(PubSubChannels.QUEST_SUPPLIER_CHANNEL, this::updateQuests); @@ -70,6 +70,12 @@ public class RedisQuestSupplier implements QuestSupplier { return QuestTypeSerializer.QUEST_GSON.fromJson(json, QuestTypeSerializer.QUEST_TYPE); } + + private void requestActiveQuests() + { + // request current active quests, send server unique id so we can send a response just to this server + _pubSub.publish(PubSubChannels.QUEST_REQUEST_BASE, _serverUniqueId); + } @Override public Set get() @@ -77,6 +83,10 @@ public class RedisQuestSupplier implements QuestSupplier _lock.readLock().lock(); try { + if (_quests.isEmpty()) + { + + } return ImmutableSet.copyOf(_quests); } finally diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/BaseQuest.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/BaseQuest.java index 2f5215e75..afc387d3a 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/common/BaseQuest.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/BaseQuest.java @@ -49,4 +49,11 @@ public class BaseQuest implements Quest return _cost != -1; } + @Override + public String toString() + { + return "BaseQuest [uniqueId=" + _uniqueId + ", name=" + _name + ", rarity=" + _rarity + + ", cost=" + _cost + "]"; + } + } diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestDaemon.java b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestDaemon.java index 474684b84..15dbb2d55 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestDaemon.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestDaemon.java @@ -97,6 +97,7 @@ public class QuestDaemon + " instance's next iteration."); log("clearrecentrequests: Clear recently selected quests. This effectively allows " + "any quest to be set to active, even ones selected within the past few days."); + log("getactivequests: Displays the currently active quests."); } else if (command.contains("stop")) { @@ -110,6 +111,10 @@ public class QuestDaemon { clearRecentQuestsCommand(); } + else if (command.contains("getactivequests")) + { + getActiveQuestsCommand(); + } } catch (Throwable t) { @@ -124,6 +129,8 @@ public class QuestDaemon { log("Shutting down QuestDaemon..."); + _alive = false; + System.exit(0); } @@ -140,6 +147,11 @@ public class QuestDaemon log("Cleared recently active quests. This means that any quest can be chosen to be active now, even ones selected within the past few days."); } + + private void getActiveQuestsCommand() + { + _questManager.displayActiveQuests(); + } public static void log(String message) { diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java index eb5aaae50..46686de98 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/daemon/QuestManager.java @@ -79,7 +79,7 @@ public class QuestManager extends Thread if (_activeQuests.size() > 0) { QuestDaemon.log("Active quests loaded from file:"); - _activeQuests.forEach(quest -> QuestDaemon.log(quest.getName())); + _activeQuests.forEach(quest -> QuestDaemon.log(quest.toString())); } // listen for servers requesting active quests on startup @@ -88,6 +88,7 @@ public class QuestManager extends Thread private void handleQuestRequest(String channel, String message) { + QuestDaemon.log("Quests requestesd by server: " + message); // first make sure we have some active quests selected if (_activeQuests.isEmpty()) { @@ -166,9 +167,9 @@ public class QuestManager extends Thread // publish new quests publishActiveQuests(PubSubChannels.QUEST_SUPPLIER_CHANNEL); + + QuestDaemon.log("Done updating active quests."); } - - QuestDaemon.log("Done updating active quests."); // take a small break, important so CPU isn't constantly running Thread.sleep(SLEEP_MILLIS); @@ -183,6 +184,8 @@ public class QuestManager extends Thread private void publishActiveQuests(String channel) { + QuestDaemon.log("publishing active quests to channel: " + channel); + QuestDaemon.log("Active quests: " + serialize(_activeQuests)); _pubSub.publish(channel, serialize(_activeQuests)); } @@ -222,17 +225,23 @@ public class QuestManager extends Thread } } - public void clearActiveQuests() + protected void clearActiveQuests() { _activeQuests.clear(); } - public void clearRecentlyActiveQuests() + protected void clearRecentlyActiveQuests() { _recentlySelectedQuestsRepo.getElements() .forEach(_recentlySelectedQuestsRepo::removeElement); } + protected void displayActiveQuests() + { + QuestDaemon.log("Active quests:"); + _activeQuests.forEach(q -> QuestDaemon.log(q.toString())); + } + private void selectRandomQuests() { if (!_activeQuests.isEmpty()) From 1cf04592da082a7bfea4bf4244f9631c80cfc619 Mon Sep 17 00:00:00 2001 From: Kenny Goodin Date: Wed, 31 May 2017 16:00:00 -0400 Subject: [PATCH 080/283] Whoops, actually add the 'fail-safe' --- .../src/mineplex/quest/client/RedisQuestSupplier.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java index a041475b9..e972b3b11 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java @@ -85,8 +85,9 @@ public class RedisQuestSupplier implements QuestSupplier { if (_quests.isEmpty()) { - + requestActiveQuests(); } + return ImmutableSet.copyOf(_quests); } finally From d7731d330c0d41a4b8f651304c259201fb1891f7 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 1 Jun 2017 00:34:21 +0200 Subject: [PATCH 081/283] Do some visual adjustments, add back button to quest stats menu, remove quest from buy bar after completion --- .../mineplex/core/quests/QuestManager.java | 8 ++++- ...tBuyEvent.java => QuestInteractEvent.java} | 4 +-- .../core/quests/shop/BuyQuestButton.java | 6 ++-- .../mineplex/core/quests/shop/QuestPage.java | 14 +++++++-- .../core/quests/shop/QuestStatsPage.java | 30 ++++++++++++------- .../quests/shop/RedeemDeclineQuestButton.java | 8 +++++ .../src/nautilus/game/arcade/game/Game.java | 6 ++-- 7 files changed, 54 insertions(+), 22 deletions(-) rename Plugins/Mineplex.Core/src/mineplex/core/quests/event/{QuestBuyEvent.java => QuestInteractEvent.java} (90%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index 6ec36cbb9..edcf26733 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -25,6 +25,8 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.Pair; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; import mineplex.core.google.GoogleSheetsManager; import mineplex.core.hologram.Hologram; @@ -90,7 +92,7 @@ public class QuestManager extends MiniClientPlugin else { Location loc = _questNPC.getEntity().getLocation(); - _hologram = new Hologram(hologramManager, loc.clone().add(0, 2.5, 0), ChatColor.GREEN + "" + ChatColor.BOLD + "(QUESTS)"); + _hologram = new Hologram(hologramManager, loc.clone().add(0, 2.8, 0), ChatColor.AQUA + "Quests"); _hologram.start(); _enableNPC = true; } @@ -252,6 +254,10 @@ public class QuestManager extends MiniClientPlugin public void incrementQuest(Player player, Quest quest, int value) { quest.increment(value); + if (quest.isCompleted()) + { + UtilPlayer.message(player, F.main("Quest", "You have completed the Quest: " + ChatColor.YELLOW + quest.getName())); + } _repository.incrementQuest(_clients.Get(player), quest, value); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestBuyEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestInteractEvent.java similarity index 90% rename from Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestBuyEvent.java rename to Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestInteractEvent.java index a1cfba344..2ebc13f8d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestBuyEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/event/QuestInteractEvent.java @@ -11,7 +11,7 @@ import mineplex.core.quests.Quest; * * @author xXVevzZXx */ -public class QuestBuyEvent extends Event +public class QuestInteractEvent extends Event { private static final HandlerList handlers = new HandlerList(); @@ -21,7 +21,7 @@ public class QuestBuyEvent extends Event private String _cancelReason; - public QuestBuyEvent(Quest quest) + public QuestInteractEvent(Quest quest) { _quest = quest; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java index ac0ad615f..2d7364a8c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java @@ -13,7 +13,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.quests.Quest; import mineplex.core.quests.QuestManager; -import mineplex.core.quests.event.QuestBuyEvent; +import mineplex.core.quests.event.QuestInteractEvent; import mineplex.core.recharge.Recharge; import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; @@ -69,14 +69,14 @@ public class BuyQuestButton implements IButton } } - QuestBuyEvent event = UtilServer.CallEvent(new QuestBuyEvent(_quest)); + QuestInteractEvent event = UtilServer.CallEvent(new QuestInteractEvent(_quest)); if (event.isCancelled()) { UtilPlayer.message(player, F.main("Quest", event.getCancelMessage())); return; } - SalesPackageBase salesPackage = new QuestSale(_quest.getName(), Material.PAPER, _quest.getCost()); + SalesPackageBase salesPackage = new QuestSale(ChatColor.YELLOW + "" + ChatColor.BOLD + _quest.getName(), Material.PAPER, _quest.getCost()); _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, _page.getDonationManager(), () -> { _questManager.addNewQuest(player, _quest); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java index adcac183e..44d18dcb3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java @@ -15,6 +15,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; @@ -52,7 +55,7 @@ public class QuestPage extends ShopPageBase ArrayList playerQuests = _shop.getQuestManager().Get(_player).getQuests(); int i = 0; - setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.RESET + "" + ChatColor.BOLD + "Quests to buy")); + setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.RESET + "" + ChatColor.BOLD + "Available Quests")); { int currentSlot = 4; int diff = 0; @@ -74,9 +77,14 @@ public class QuestPage extends ShopPageBase for (Quest playerQuest : playerQuests) { - if (playerQuest.isActive()) + if (playerQuest.getID() == questID) { - if (playerQuest.getID() == questID) + if (!UtilTime.elapsed(playerQuest.getLastCompleted(), 1000*60*60*24)) + { + cont = true; + break; + } + if (playerQuest.isActive()) { cont = true; break; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java index 60b26f201..7fcdce5bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java @@ -33,7 +33,7 @@ public class QuestStatsPage extends ShopPageBase public QuestStatsPage(QuestManager plugin, QuestStatShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, int site) { - super(plugin, shop, clientManager, donationManager, "Quest Stats", player, 4*9); + super(plugin, shop, clientManager, donationManager, "Quest Stats", player, 6*9); _siteIndex = site; @@ -46,8 +46,8 @@ public class QuestStatsPage extends ShopPageBase @Override protected void buildPage() { - int questID = (_siteIndex * 3 * 9); - for (int i = 0; i < 9*3; i++) + int questID = (_siteIndex * 5 * 9); + for (int i = 0; i < 9*5; i++) { Quest quest = _manager.getQuestByID(questID); @@ -76,30 +76,40 @@ public class QuestStatsPage extends ShopPageBase if (_siteIndex != 0) { - addButton(3*9, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Previous Page"), new IButton() + addButton(5*9, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Previous Page"), new IButton() { @Override public void onClick(Player player, ClickType clickType) { - player.closeInventory(); - getQuestStatsShop().openPageForPlayer(player, new QuestStatsPage(_manager, getQuestStatsShop(), _manager.getClients(), _manager.getDonations(), player, _siteIndex - 1)); + _siteIndex--; + buildPage(); } }); } - if (((_siteIndex + 1) * 3 * 9) < _manager.getAvailableQuests().size()) + if (((_siteIndex + 1) * 5 * 9) < _manager.getAvailableQuests().size()) { - addButton((4*9) - 1, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Next Page"), new IButton() + addButton((6*9) - 1, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Next Page"), new IButton() { @Override public void onClick(Player player, ClickType clickType) { - player.closeInventory(); - getQuestStatsShop().openPageForPlayer(player, new QuestStatsPage(_manager, getQuestStatsShop(), _manager.getClients(), _manager.getDonations(), player, _siteIndex + 1)); + _siteIndex++; + buildPage(); } }); } + addButton(5*9 + 4, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Back to Quests"), new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + player.closeInventory(); + new QuestShop(_manager, getClientManager(), getDonationManager()).attemptShopOpen(player); + } + }); + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java index 2a254ed94..42949355b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java @@ -18,6 +18,7 @@ import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.quests.Quest; import mineplex.core.quests.QuestManager; +import mineplex.core.quests.event.QuestInteractEvent; import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; @@ -59,6 +60,13 @@ public class RedeemDeclineQuestButton implements IButton return; } + QuestInteractEvent event = UtilServer.CallEvent(new QuestInteractEvent(_quest)); + if (event.isCancelled()) + { + UtilPlayer.message(player, F.main("Quest", event.getCancelMessage())); + return; + } + if (clickType == ClickType.SHIFT_RIGHT) { if (_quest.isCompleted()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index efa797e1f..5e8c129c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -75,7 +75,7 @@ import mineplex.core.lifetimes.ListenerComponent; import mineplex.core.lifetimes.PhasedLifetime; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; -import mineplex.core.quests.event.QuestBuyEvent; +import mineplex.core.quests.event.QuestInteractEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilGameProfile; @@ -2083,10 +2083,10 @@ public abstract class Game extends ListenerComponent implements Lifetimed } @EventHandler - public void onQuestBuy(QuestBuyEvent event) + public void onQuestBuy(QuestInteractEvent event) { if (GetState() == GameState.Live || GetState() == GameState.Prepare || GetState() == GameState.End) - event.setCancelled("You cant buy Quests while you are ingame!"); + event.setCancelled("You cant interact with Quests while you are ingame!"); } public NautHashMap getDeadBodies() From c34bf77dc98b5b3f79ac499c572770b7309573f3 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 1 Jun 2017 00:55:33 +0100 Subject: [PATCH 082/283] More testing feedback --- .../game/arcade/game/games/moba/Moba.java | 11 +-- .../games/moba/boss/pumpkin/PumpkinBoss.java | 12 ++- .../games/moba/boss/wither/WitherBoss.java | 2 +- .../wither/attack/BossAttackEarthquake.java | 4 +- .../games/moba/kit/dana/SkillPulseHeal.java | 89 ++++++------------- .../games/moba/kit/hattori/HeroHattori.java | 4 +- .../games/moba/kit/hattori/SkillSnowball.java | 2 +- .../arcade/game/games/moba/minion/Minion.java | 15 +++- .../game/games/moba/minion/MinionManager.java | 12 ++- .../game/games/moba/minion/MinionWave.java | 6 +- .../moba/structure/point/CapturePoint.java | 10 +-- .../games/moba/structure/tower/Tower.java | 2 +- 12 files changed, 81 insertions(+), 88 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index e1af99064..366ad48c6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -99,7 +99,7 @@ public class Moba extends TeamGame PrepareFreeze = false; PrepareTime = PREPARE_TIME; DeathOut = false; - DeathSpectateSecs = 10; + DeathSpectateSecs = 12; HungerSet = 20; DamageFall = false; @@ -170,14 +170,15 @@ public class Moba extends TeamGame }) .setSuffix((perspective, subject) -> { - if (!IsAlive(subject)) + GameState state = GetState(); + GameTeam perspectiveTeam = GetTeam(perspective); + GameTeam subjectTeam = GetTeam(subject); + + if (!IsAlive(subject) || subjectTeam == null) { return ""; } - GameState state = GetState(); - GameTeam perspectiveTeam = GetTeam(perspective); - GameTeam subjectTeam = GetTeam(subject); MobaPlayer mobaPlayer = getMobaData(subject); String suffix; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 822b9b70d..0f69e2bdd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -69,8 +69,8 @@ public class PumpkinBoss extends MobaBoss private static final int DAMAGE_RANGE = 3; private static final int DAMAGE_DIRECT = 8; private static final int DAMAGE_DIRECT_RADIUS_SQUARED = 9; - private static final int HEALTH = 400; - private static final int HEALTH_OUT_OF_COMBAT = 10; + private static final int HEALTH = 200; + private static final int HEALTH_OUT_OF_COMBAT = 5; private static final Material[] BLOCKS = { Material.OBSIDIAN, Material.NETHERRACK, @@ -333,9 +333,15 @@ public class PumpkinBoss extends MobaBoss { Player player = iterator.next(); - if (!player.isOnline() || !player.hasPotionEffect(PotionEffectType.REGENERATION)) + if (!player.hasPotionEffect(PotionEffectType.REGENERATION)) { + if (player.isOnline()) + { + player.getInventory().setHelmet(player.getInventory().getHelmet()); + } + iterator.remove(); + continue; } sendFakeHelmet(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 691ca05d1..779bdf9f8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -35,7 +35,7 @@ public class WitherBoss extends MobaBoss private static final String NAME = "Wither Boss"; private static final float SPEED_TARGET = 4F; private static final float SPEED_HOME = 6F; - private static final int INITIAL_HEALTH = 1750; + private static final int INITIAL_HEALTH = 500; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private GameTeam _team; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java index 6279b1ffa..09e6e3cf4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java @@ -26,7 +26,7 @@ public class BossAttackEarthquake implements MobaBossAttack private static final String ATTACK_NAME = "Earthquake"; private static final int RADIUS = 8; - private static final int DAMAGE = 8; + private static final int DAMAGE = 4; private static final double FALLING_BLOCK_CHANCE = 0.1; private final WitherBoss _boss; @@ -56,7 +56,7 @@ public class BossAttackEarthquake implements MobaBossAttack FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().add(0.5, 1, 0.5), block.getType(), block.getData()); fallingBlock.setHurtEntities(false); fallingBlock.setDropItem(false); - fallingBlock.setVelocity(UtilAlg.getTrajectory(boss, fallingBlock).multiply(0.25).setY(1.5)); + fallingBlock.setVelocity(UtilAlg.getTrajectory(boss, fallingBlock).multiply(0.25).setY(0.7 + Math.random())); } for (Entry entry : UtilEnt.getInRadius(boss.getLocation(), RADIUS).entrySet()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java index 5529afd8b..d71fa9ad3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -7,7 +7,6 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; 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.game.games.moba.kit.HeroSkill; @@ -17,13 +16,9 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; -import java.util.HashSet; -import java.util.Set; - public class SkillPulseHeal extends HeroSkill { @@ -33,28 +28,11 @@ public class SkillPulseHeal extends HeroSkill }; private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.INK_SACK, (byte) 10).build(); - private static final ItemStack SKILL_ITEM_TOGGLED = new ItemBuilder(Material.INK_SACK, (byte) 12).build(); - - private Set _toggled = new HashSet<>(); public SkillPulseHeal(int slot) { super("Pulse Heal", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); - addSkillItem(SKILL_ITEM_TOGGLED); - setCooldown(2000); - } - - @Override - public void giveItem(Player player) - { - if (_toggled.contains(player)) - { - player.getInventory().setItem(getSlot(), _items.get(1)); - } - else - { - player.getInventory().setItem(getSlot(), _items.get(0)); - } + setCooldown(8000); } @EventHandler @@ -66,17 +44,20 @@ public class SkillPulseHeal extends HeroSkill } Player player = event.getPlayer(); - - if (_toggled.contains(player)) - { - _toggled.remove(player); - } - else - { - _toggled.add(player); - } - useSkill(player); + + for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) + { + // Don't heal enemies + if (!isTeamDamage(entity, player)) + { + continue; + } + + entity.setHealth(Math.min(entity.getHealth() + 4, entity.getMaxHealth())); + } + + displayPulse(player.getLocation().add(0, 0.5, 0)); } @EventHandler @@ -89,61 +70,41 @@ public class SkillPulseHeal extends HeroSkill for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !Recharge.Instance.use(player, GetName(), 5000, false, false)) + if (!hasPerk(player) || UtilPlayer.isSpectator(player)) { continue; } - Location location = player.getLocation(); - - if (_toggled.contains(player)) + for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) { - for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) + // Don't heal enemies + if (!isTeamDamage(entity, player)) { - // Don't heal self or enemies - if (entity.equals(player) || !isTeamDamage(entity, player)) - { - continue; - } - - entity.setHealth(Math.min(entity.getHealth() + 4, entity.getMaxHealth())); + continue; } - displayPulse(location, false); - } - else - { - player.setHealth(Math.min(player.getHealth() + 4, player.getMaxHealth())); - - displayPulse(location, true); + entity.setHealth(Math.min(entity.getHealth() + 4, entity.getMaxHealth())); } } } - @EventHandler - public void playerQuit(PlayerQuitEvent event) - { - _toggled.remove(event.getPlayer()); - } - - private void displayPulse(Location location, boolean inwards) + private void displayPulse(Location location) { Manager.runSyncTimer(new BukkitRunnable() { double theta = 0; - double radius = inwards ? 5 : 0; + double radius = 0; @Override public void run() { - if (inwards && radius < 0 || !inwards && radius > 5) + if (radius > 5) { cancel(); return; } - double increment = inwards ? -0.2 : 0.2; for (double theta2 = 0; theta2 < 2 * Math.PI; theta2 += Math.PI / 3) { double x = radius * Math.sin(theta + theta2); @@ -151,13 +112,13 @@ public class SkillPulseHeal extends HeroSkill location.add(x, 0.5, z); - UtilParticle.PlayParticleToAll(inwards ? ParticleType.HAPPY_VILLAGER : ParticleType.DRIP_WATER, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); location.subtract(x, 0.5, z); } theta += Math.PI / 100; - radius += increment; + radius += 0.2; } }, 0, 1); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java index 1cec7ac34..d9371bad2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java @@ -18,8 +18,8 @@ public class HeroHattori extends HeroKit private static final Perk[] PERKS = { new PerkDoubleJump("Double Jump", 1, 1, true, 3000, true), - new SkillSnowball(0), - new SkillSword(1), + new SkillSword(0), + new SkillSnowball(1), new SkillNinjaDash(2), new SkillNinjaBlade(3) }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 6d90fd6be..43427a091 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -78,7 +78,7 @@ public class SkillSnowball extends HeroSkill implements IThrown 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.CUSTOM, DAMAGE, true, true, false, UtilEnt.getName(thrower), GetName()); + Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.CUSTOM, DAMAGE, false, true, false, UtilEnt.getName(thrower), GetName()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index 514d83dbd..d8092f1b1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -3,21 +3,29 @@ package nautilus.game.arcade.game.games.moba.minion; import mineplex.core.common.util.UtilEnt; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Zombie; +import org.bukkit.inventory.ItemStack; public class Minion { private static final int HEALTH = 10; private static final float HIT_BOX = 2F; + private static final ItemStack[] SUPER_ARMOUR = { + new ItemStack(Material.IRON_BOOTS), + new ItemStack(Material.IRON_LEGGINGS), + new ItemStack(Material.IRON_CHESTPLATE), + new ItemStack(Material.IRON_HELMET) + }; private final LivingEntity _entity; private Location _target; private int _targetIndex; - public Minion(Location spawn, Class clazz) + public Minion(Location spawn, Class clazz, boolean superMinion) { _target = spawn; @@ -31,6 +39,11 @@ public class Minion ((Zombie) entity).setBaby(true); } + if (superMinion) + { + entity.getEquipment().setArmorContents(SUPER_ARMOUR); + } + UtilEnt.vegetate(entity); UtilEnt.silence(entity, true); UtilEnt.setBoundingBox(entity, HIT_BOX, HIT_BOX); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 6253b9ef9..df717f168 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -11,6 +11,7 @@ import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -77,6 +78,15 @@ public class MinionManager implements Listener { List path = new ArrayList<>(_path); boolean reverse = team.GetColor() == ChatColor.RED; + boolean superMinions = true; + + for (Tower tower : _host.getTowerManager().getTowers()) + { + if (!tower.isDead() && tower.getOwner().equals(team)) + { + superMinions = false; + } + } // If red team, reverse the pat if (reverse) @@ -84,7 +94,7 @@ public class MinionManager implements Listener Collections.reverse(path); } - MinionWave wave = new MinionWave(_host, this, team, path, reverse ? Zombie.class : PigZombie.class); + MinionWave wave = new MinionWave(_host, this, team, path, reverse ? Zombie.class : PigZombie.class, superMinions); _waves.add(wave); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index aa0c6bc95..032221220 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -48,17 +48,19 @@ public class MinionWave implements Listener private final MinionManager _minionManager; private final GameTeam _owner; private final Class _clazz; + private final boolean _superMinions; private final long _startTime; private final List _path; private final List _minions; - public MinionWave(Moba host, MinionManager minionManager, GameTeam owner, List path, Class clazz) + public MinionWave(Moba host, MinionManager minionManager, GameTeam owner, List path, Class clazz, boolean superMinions) { _host = host; _minionManager = minionManager; _owner = owner; _clazz = clazz; + _superMinions = superMinions; _startTime = System.currentTimeMillis(); _path = path; _minions = new ArrayList<>(MAX_MINIONS_PER_WAVE); @@ -85,7 +87,7 @@ public class MinionWave implements Listener { _host.CreatureAllowOverride = true; - Minion minion = new Minion(_path.get(0), _clazz); + Minion minion = new Minion(_path.get(0), _clazz, _superMinions); minion.getEntity().setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), _owner.GetName())); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index 8a1a1acc6..d949be280 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -145,17 +145,17 @@ public class CapturePoint } // Players on the point // Only inform if it has been a while - else if (!_owner.equals(highest) && UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) + else if ((_owner == null || !_owner.equals(highest)) && UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) { _lastInform = System.currentTimeMillis(); for (Player player : Bukkit.getOnlinePlayers()) { - player.playSound(player.getLocation(), Sound.GHAST_SCREAM2, 1, 1.2F); + player.playSound(player.getLocation(), Sound.GHAST_SCREAM2, 1, 1.0F); } _host.Announce(F.main("Game", "Team " + highest.GetFormattedName() + C.mBody + " is capturing beacon " + _colour + _name + C.mBody + "!"), false); - UtilTextMiddle.display("", "Team " + highest.GetFormattedName() + C.cWhite + " is capturing beacon " + _colour + _name, 0, 30, 10); + //UtilTextMiddle.display("", "Team " + highest.GetFormattedName() + C.cWhite + " is capturing beacon " + _colour + _name, 0, 30, 10); } // If it has just reached the maximum progress, set the owner. @@ -228,8 +228,8 @@ public class CapturePoint _owner = team; - _host.Announce(F.main("Game", "Team " + team.GetFormattedName() + C.mBody + " captured beacon " + _colour + _name + C.mBody + "!")); - UtilTextMiddle.display("", "Team " + team.GetFormattedName() + C.cWhite + " captured beacon " + _colour + _name, 0, 30, 10); + _host.Announce(F.main("Game", "Team " + team.GetFormattedName() + C.mBody + " captured the " + _colour + _name + C.mBody + " Beacon!")); + //UtilTextMiddle.display("", "Team " + team.GetFormattedName() + C.cWhite + " captured beacon " + _colour + _name, 0, 30, 10); UtilFirework.playFirework(_center, Type.BURST, team.GetColorBase(), false, false); UtilServer.CallEvent(new CapturePointCaptureEvent(this)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 849b57326..ed5543597 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -179,7 +179,7 @@ public class Tower { player.playSound(player.getLocation(), Sound.ANVIL_LAND, 1, 0.5F); player.sendMessage(F.main("Game", "Your Tower is under attack!")); - UtilTextMiddle.display("", _team.GetColor() + "Your Tower is under attack!", 0, 30, 10, player); + //UtilTextMiddle.display("", _team.GetColor() + "Your Tower is under attack!", 0, 30, 10, player); } } } From 921aaea5bd9ad3aab5df3b66254ad820928ec685 Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 31 May 2017 21:16:58 -0500 Subject: [PATCH 083/283] Disable Toggle check from the plugin side until tomorrow --- .../Mineplex.Core/src/mineplex/core/antihack/AntiHack.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index ea10db00a..97cdfe07c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -408,6 +408,11 @@ public class AntiHack extends MiniPlugin @EventHandler public void onHack(PlayerViolationEvent event) { + if (event.getCheckClass() == Toggle.class) + { + return; + } + if (_ignoredChecks.contains(event.getCheckClass())) return; From 08b89fbb4b394a6875fe8baaa030994f20cb0ac9 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 10 Mar 2017 14:57:30 -0500 Subject: [PATCH 084/283] Change farming shop prices --- .../mineplex/game/clans/shop/ClansShopItem.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java index 636854481..f505ee1f0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java @@ -48,15 +48,15 @@ public enum ClansShopItem REDSTONE(10, 2, Material.REDSTONE, 1), LAPIS_BLOCK(500, 100, Material.LAPIS_BLOCK, 1), // Farming Shop - POTATO_ITEM(15, 3, Material.POTATO_ITEM, 1), - MELON(5, 1, Material.MELON, 1), - BREAD(30, 6, Material.BREAD, 1), - COOKED_BEEF(50, 10, Material.COOKED_BEEF, 1), - GRILLED_PORK(50, 10, Material.GRILLED_PORK, 1), - COOKED_CHICKEN(35, 7, Material.COOKED_CHICKEN, 1), + POTATO_ITEM(15, 8, Material.POTATO_ITEM, 1), + MELON(5, 3, Material.MELON, 1), + BREAD(30, 16, Material.BREAD, 1), + COOKED_BEEF(50, 27, Material.COOKED_BEEF, 1), + GRILLED_PORK(50, 27, Material.GRILLED_PORK, 1), + COOKED_CHICKEN(35, 19, Material.COOKED_CHICKEN, 1), FEATHER(50, 10, Material.FEATHER, 1), - CARROT_ITEM(10, 2, Material.CARROT_ITEM, 1), - MUSHROOM_SOUP(200, 40, Material.MUSHROOM_SOUP, 1), + CARROT_ITEM(10, 5, Material.CARROT_ITEM, 1), + MUSHROOM_SOUP(200, 109, Material.MUSHROOM_SOUP, 1), SUGAR_CANE(15, 3, Material.SUGAR_CANE, 1), PUMPKIN(30, 6, Material.PUMPKIN, 1), STRING(50, 10, Material.STRING, 1), From 1574d93d1b463514db1074f61f34fec9df49a38a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 10 Mar 2017 14:57:43 -0500 Subject: [PATCH 085/283] Re-implement the main clans tutorial --- .../clans/tutorial/tutorials/clans/ClansMainTutorial.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java index 804966bb3..f9d21b850 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java @@ -469,7 +469,7 @@ public class ClansMainTutorial extends Tutorial // } // }); - /*if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier())) + if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier())) { ClanInfo clan = ClansManager.getInstance().getClan(event.getPlayer()); if (clan == null) @@ -481,7 +481,7 @@ public class ClansMainTutorial extends Tutorial UtilPlayer.message(event.getPlayer(), F.main("Clans", "It seems you already have a clan here, so we can skip the tutorial")); } } - else */if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld())) + else if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld())) { Spawn.getInstance().teleport(event.getPlayer(), Spawn.getInstance().getSpawnLocation(), 2); } From 35f2d42d08a472f4b9766f6efe1693d3e918b686 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 10 Mar 2017 14:57:54 -0500 Subject: [PATCH 086/283] Remove height limitations on planting crops --- .../src/mineplex/game/clans/Farming.java | 47 ++----------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Farming.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Farming.java index 1027a2253..78a0fd82c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Farming.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Farming.java @@ -1,33 +1,17 @@ package mineplex.game.clans; -import com.google.common.collect.Sets; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.UtilItem; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.plugin.java.JavaPlugin; -import java.util.Set; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.UtilItem; +import mineplex.core.itemstack.ItemStackFactory; public class Farming extends MiniPlugin { - private static final Set PLANTABLE = Sets.newHashSet( - Material.WHEAT, - Material.SUGAR_CANE_BLOCK, - Material.PUMPKIN_STEM, - Material.MELON_STEM, - Material.COCOA, - Material.CARROT, - Material.POTATO - ); - public Farming(JavaPlugin plugin) { super("Farming", plugin); @@ -50,27 +34,4 @@ public class Farming extends MiniPlugin if (Math.random() > 0.999) event.getBlock().getWorld().dropItemNaturally(dropLocation, ItemStackFactory.Instance.CreateStack(Material.GOLDEN_APPLE)); } - - @EventHandler (ignoreCancelled = true) - public void BlockPlace(BlockPlaceEvent event) - { - if (!PLANTABLE.contains(event.getBlock().getType())) - return; - - double blockY = event.getBlock().getLocation().getY(); - double seaLevel = event.getBlock().getWorld().getSeaLevel(); - - if (blockY < seaLevel - 12) - { - UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot plant " + - F.item(ItemStackFactory.Instance.GetName(event.getPlayer().getItemInHand(), true)) + " this deep underground.")); - event.setCancelled(true); - } - else if (blockY > seaLevel + 24) - { - UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot plant " + - F.item(ItemStackFactory.Instance.GetName(event.getPlayer().getItemInHand(), true)) + " at this altitude.")); - event.setCancelled(true); - } - } -} +} \ No newline at end of file From 48967b4a7496a94561ed4d589c997811cf4cdb04 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 10 Mar 2017 14:59:03 -0500 Subject: [PATCH 087/283] Block exploit allowing clans to make a lot of allies and then add members to disrupt the equation. Additionally, lower the maximum amount of allies per member --- .../src/mineplex/game/clans/clans/ClanInfo.java | 12 +++++++++--- .../src/mineplex/game/clans/clans/ClansUtility.java | 6 ++++++ .../game/clans/clans/commands/ClansCommand.java | 6 ++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java index a07074f98..2d4d42389 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java @@ -11,7 +11,6 @@ import java.util.UUID; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.block.Block; import org.bukkit.entity.Player; import mineplex.core.common.util.C; @@ -208,11 +207,18 @@ public class ClanInfo } public int getAlliesMax() + { + return getAlliesMaxWithMemberCountOf(_memberMap.size()); + } + + public int getAlliesMaxWithMemberCountOf(int memberCount) { if (ssAdmin()) + { return 1000; - - return Math.max(2, 9 - _memberMap.size()); + } + + return Math.max(2, 6 - memberCount); } public BedStatus getBedStatus() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index b1c63970f..a2ecef65e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -1221,6 +1221,12 @@ public class ClansUtility UtilPlayer.message(caller, F.main("Clans", "You cannot invite yourself.")); return; } + + if (clan.getAllies() > clan.getAlliesMaxWithMemberCountOf(clan.getSize() + 1)) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot invite more members until you remove some allies.")); + return; + } // Inform clan.inform(F.name(caller.getName()) + " invited " + F.name(target.getName()) + " to join your Clan.", caller.getName()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 39511c874..adef219f9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -549,6 +549,12 @@ public class ClansCommand extends CommandBase UtilPlayer.message(caller, F.main("Clans", "The clan " + F.elem("Clan " + clan.getName()) + " is full and cannot be joined!")); return; } + + if (clan.getAllies() > clan.getAlliesMaxWithMemberCountOf(clan.getSize() + 1)) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot join " + F.elem("Clan " + clan.getName()) + " until they remove some allies!")); + return; + } ClanJoinEvent event = new ClanJoinEvent(clan, caller); Bukkit.getPluginManager().callEvent(event); From 2e0449000135a948b51abddc4ae2199b94320fec Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 10 Mar 2017 14:59:36 -0500 Subject: [PATCH 088/283] Change nether miniboss rewards to drop crafting materials beyond diamonds and add the ability to drop set pieces --- .../miniboss/bosses/ArcherMiniboss.java | 26 ++++++++++++------- .../nether/miniboss/bosses/GhastMiniboss.java | 12 +++++++-- .../miniboss/bosses/WarriorMiniboss.java | 12 +++++++-- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java index d2a4e938c..2fc0c29c6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java @@ -1,14 +1,8 @@ package mineplex.game.clans.clans.nether.miniboss.bosses; +import java.util.Arrays; import java.util.Random; -import mineplex.core.common.util.UtilMath; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.amplifiers.AmplifierManager; -import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; -import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Arrow; @@ -28,6 +22,13 @@ import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.amplifiers.AmplifierManager; +import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; +import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + /** * Class for running an individual Archer miniboss */ @@ -35,7 +36,10 @@ public class ArcherMiniboss extends NetherMiniBoss { private static final int BARBED_LEVEL = 1; private static final double RUNE_DROP_CHANCE = .02; - private static final int MAX_DIAMOND_DROPS = 5; + private static final int MAX_VALUABLE_DROPS = 5; + private static final Material[] VALUABLE_DROP_TYPES = new Material[] {Material.DIAMOND, Material.GOLD_INGOT, Material.IRON_INGOT, Material.LEATHER}; + private static final Material[] SET_DROP_TYPES = (Material[])Arrays.asList(Material.values()).stream().filter(t -> t.name().contains("HELMET") || t.name().contains("CHESTPLATE") || t.name().contains("LEGGINGS") || t.name().contains("BOOTS")).toArray(); + private static final double SET_DROP_CHANCE = .02; public ArcherMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) { @@ -63,7 +67,7 @@ public class ArcherMiniboss extends NetherMiniBoss @Override public void customDeath(Location deathLocation) { - deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(MAX_DIAMOND_DROPS) + 1)); + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(VALUABLE_DROP_TYPES[UtilMath.r(VALUABLE_DROP_TYPES.length)], UtilMath.r(MAX_VALUABLE_DROPS) + 1)); double runeDropChance = RUNE_DROP_CHANCE; if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) { @@ -74,6 +78,10 @@ public class ArcherMiniboss extends NetherMiniBoss RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)]; deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType)); } + if (new Random().nextDouble() <= SET_DROP_CHANCE) + { + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(SET_DROP_TYPES[UtilMath.r(SET_DROP_TYPES.length)], 1)); + } } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java index 6ff341b58..a6d5a3945 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java @@ -1,5 +1,6 @@ package mineplex.game.clans.clans.nether.miniboss.bosses; +import java.util.Arrays; import java.util.Random; import mineplex.core.common.util.UtilEnt; @@ -32,8 +33,11 @@ public class GhastMiniboss extends NetherMiniBoss private static final long FIREBALL_LAUNCH_RATE = 500; private static final int FIREBALLS_PER_USE = 5; private static final double RUNE_DROP_CHANCE = .02; - private static final int MAX_DIAMOND_DROPS = 5; + private static final int MAX_VALUABLE_DROPS = 5; + private static final Material[] VALUABLE_DROP_TYPES = new Material[] {Material.DIAMOND, Material.GOLD_INGOT, Material.IRON_INGOT, Material.LEATHER}; private static final double MAX_TARGET_RANGE = 25; + private static final Material[] SET_DROP_TYPES = (Material[])Arrays.asList(Material.values()).stream().filter(t -> t.name().contains("HELMET") || t.name().contains("CHESTPLATE") || t.name().contains("LEGGINGS") || t.name().contains("BOOTS")).toArray(); + private static final double SET_DROP_CHANCE = .02; private long _lastFireballUse; private int _fireballsRemaining; @@ -72,7 +76,7 @@ public class GhastMiniboss extends NetherMiniBoss @Override public void customDeath(Location deathLocation) { - deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(MAX_DIAMOND_DROPS) + 1)); + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(VALUABLE_DROP_TYPES[UtilMath.r(VALUABLE_DROP_TYPES.length)], UtilMath.r(MAX_VALUABLE_DROPS) + 1)); double runeDropChance = RUNE_DROP_CHANCE; if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) { @@ -83,6 +87,10 @@ public class GhastMiniboss extends NetherMiniBoss RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)]; deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType)); } + if (new Random().nextDouble() <= SET_DROP_CHANCE) + { + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(SET_DROP_TYPES[UtilMath.r(SET_DROP_TYPES.length)], 1)); + } } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java index 248c9bf64..ee0fc199d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java @@ -1,5 +1,6 @@ package mineplex.game.clans.clans.nether.miniboss.bosses; +import java.util.Arrays; import java.util.Random; import mineplex.core.common.util.UtilAction; @@ -33,7 +34,10 @@ import org.bukkit.potion.PotionEffectType; public class WarriorMiniboss extends NetherMiniBoss { private static final double RUNE_DROP_CHANCE = .02; - private static final int MAX_DIAMOND_DROPS = 5; + private static final int MAX_VALUABLE_DROPS = 5; + private static final Material[] VALUABLE_DROP_TYPES = new Material[] {Material.DIAMOND, Material.GOLD_INGOT, Material.IRON_INGOT, Material.LEATHER}; + private static final Material[] SET_DROP_TYPES = (Material[])Arrays.asList(Material.values()).stream().filter(t -> t.name().contains("HELMET") || t.name().contains("CHESTPLATE") || t.name().contains("LEGGINGS") || t.name().contains("BOOTS")).toArray(); + private static final double SET_DROP_CHANCE = .02; private static final double LEAP_CHANCE = .9; private static final double LEAP_MIN_DIST = 3; private static final double LEAP_MAX_DIST = 16; @@ -66,7 +70,7 @@ public class WarriorMiniboss extends NetherMiniBoss @Override public void customDeath(Location deathLocation) { - deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(Material.DIAMOND, UtilMath.r(MAX_DIAMOND_DROPS) + 1)); + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(VALUABLE_DROP_TYPES[UtilMath.r(VALUABLE_DROP_TYPES.length)], UtilMath.r(MAX_VALUABLE_DROPS) + 1)); double runeDropChance = RUNE_DROP_CHANCE; if (ClansManager.getInstance().getAmplifierManager().hasActiveAmplifier()) { @@ -77,6 +81,10 @@ public class WarriorMiniboss extends NetherMiniBoss RuneAttribute runeType = RuneAttribute.values()[UtilMath.r(RuneAttribute.values().length)]; deathLocation.getWorld().dropItemNaturally(deathLocation, ClansManager.getInstance().getGearManager().getRuneManager().getRune(runeType)); } + if (new Random().nextDouble() <= SET_DROP_CHANCE) + { + deathLocation.getWorld().dropItemNaturally(deathLocation, new ItemStack(SET_DROP_TYPES[UtilMath.r(SET_DROP_TYPES.length)], 1)); + } } @Override From cc1bb3cfe9819ac1cf4d9c83a76e2e35868cd360 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 10 Mar 2017 14:59:54 -0500 Subject: [PATCH 089/283] Make outposts utilize the Clan Banner of their owner --- .../clans/clans/siege/outpost/Outpost.java | 4 +-- .../clans/siege/outpost/OutpostType.java | 26 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index 09ed9dcbc..337c3e402 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -149,7 +149,7 @@ public class Outpost implements Listener _preHologram2.start(); } - _blocks = _type.createBuildQueue(_origin, _ownerClan.Clans); + _blocks = _type.createBuildQueue(_origin, _ownerClan.Clans, _ownerClan); _state = token.OutpostState; @@ -498,7 +498,7 @@ public class Outpost implements Listener _lifetimeLeft.start(); _state = OutpostState.CONSTRUCTING; - _blocks = new LinkedHashMap<>(_buildQueue = _type.createBuildQueue(_origin, _ownerClan.Clans)); + _blocks = new LinkedHashMap<>(_buildQueue = _type.createBuildQueue(_origin, _ownerClan.Clans, _ownerClan)); _ownerClan.inform("Siege", "Your Outpost is now being constructed.", null); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostType.java index 134e6b000..53e4979a6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostType.java @@ -1,27 +1,29 @@ package mineplex.game.clans.clans.siege.outpost; import java.io.File; -import java.io.FileInputStream; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; -import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.banner.Pattern; import mineplex.core.common.block.schematic.Schematic; import mineplex.core.common.block.schematic.UtilSchematic; import mineplex.core.common.util.UtilWorld; +import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.banners.BannerManager; +import mineplex.game.clans.clans.banners.BannerPattern; +import mineplex.game.clans.clans.banners.ClanBanner; import mineplex.game.clans.clans.siege.outpost.build.OutpostBlock; import mineplex.game.clans.clans.siege.outpost.build.OutpostBlockBanner; -import net.minecraft.server.v1_8_R3.NBTTagCompound; public enum OutpostType { MK_I(1, 3, 6) { - public LinkedHashMap createBuildQueue(Location location, ClansManager clans) + public LinkedHashMap createBuildQueue(Location location, ClansManager clans, ClanInfo owner) { LinkedHashMap build = new LinkedHashMap<>(); @@ -232,7 +234,7 @@ public enum OutpostType } }, MK_II(2, 5, 25) { - public LinkedHashMap createBuildQueue(Location location, ClansManager clans) + public LinkedHashMap createBuildQueue(Location location, ClansManager clans, ClanInfo owner) { try { @@ -292,7 +294,7 @@ public enum OutpostType } }, MK_III(3, 5, 25) { - public LinkedHashMap createBuildQueue(Location location, ClansManager clans) + public LinkedHashMap createBuildQueue(Location location, ClansManager clans, ClanInfo owner) { try { @@ -300,6 +302,8 @@ public enum OutpostType File file = new File("schematic" + File.separator + "outpost_mk_III.schematic"); Schematic schematic = UtilSchematic.loadSchematic(file); + BannerManager bm = clans.getBannerManager(); + ClanBanner cb = bm.LoadedBanners.get(owner.getName()); for (int y = 0; y < schematic.getHeight(); y++) { @@ -319,10 +323,16 @@ public enum OutpostType if (Material.getMaterial(schematic.getBlock(x, y, z)).name().contains("BANNER")) { - build.put(UtilWorld.locToStr(loc), new OutpostBlockBanner(build, loc, schematic.getBlock(x, y, z), schematic.getData(x, y, z), DyeColor.RED)); + if (cb == null) + { + continue; + } + build.put(UtilWorld.locToStr(loc), new OutpostBlockBanner(build, loc, schematic.getBlock(x, y, z), schematic.getData(x, y, z), cb.getBaseColor(), (Pattern[]) cb.getPatterns().stream().map(BannerPattern::getBukkitPattern).toArray())); } else + { build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, schematic.getBlock(x, y, z), schematic.getData(x, y, z))); + } } } } @@ -374,7 +384,7 @@ public enum OutpostType return _id; } - public abstract LinkedHashMap createBuildQueue(Location location, ClansManager clans); + public abstract LinkedHashMap createBuildQueue(Location location, ClansManager clans, ClanInfo owner); public abstract Location getCoreLocation(Location location); From b7a566744c006d2d111c5a5b1d1e26d79e352a98 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 10 Mar 2017 15:00:17 -0500 Subject: [PATCH 090/283] Formatting fix --- .../mineplex/game/clans/clans/worldevent/WorldEventType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index 0110ae6c9..d3e39862e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -14,7 +14,7 @@ public enum WorldEventType //SLIME_KING("Slime King", SlimeBoss.class, 30), //KING_OF_THE_HILL("King of The Hill", KingHill.class, 30), //UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30), - IRON_WIZARD("Iron Wizard",GolemBoss.class, 30), + IRON_WIZARD("Iron Wizard", GolemBoss.class, 30), //BROOD_MOTHER("Brood Mother", SpiderBoss.class, 30), SKELETON_KING("Skeleton King", SkeletonBoss.class, 30); From 03d9032f82f59fd081bbda8d5836bb571ea9aa8e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 9 Apr 2017 04:52:23 -0400 Subject: [PATCH 091/283] Add backend system for saving/loading clans mounts with varied stats and skins --- .../src/mineplex/core/common/TriConsumer.java | 54 ++++++ .../core/account/CoreClientManager.java | 2 +- .../game/clans/clans/mounts/Mount.java | 181 ++++++++++++++++++ .../clans/clans/mounts/MountDespawnEvent.java | 34 ++++ .../game/clans/clans/mounts/MountManager.java | 63 ++++++ .../clans/clans/mounts/MountOwnerData.java | 60 ++++++ .../clans/clans/mounts/MountRepository.java | 168 ++++++++++++++++ .../clans/clans/mounts/MountSpawnEvent.java | 34 ++++ .../clans/clans/mounts/MountStatToken.java | 8 + .../game/clans/clans/mounts/MountToken.java | 11 ++ 10 files changed, 614 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/TriConsumer.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountDespawnEvent.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountOwnerData.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountRepository.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountSpawnEvent.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountStatToken.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountToken.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/TriConsumer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/TriConsumer.java new file mode 100644 index 000000000..eca685883 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/TriConsumer.java @@ -0,0 +1,54 @@ +package mineplex.core.common; + +import java.util.Objects; + +/** + * Represents an operation that accepts two input arguments and returns no + * result. This is the three-arity specialization of {@link Consumer}. + * Unlike most other functional interfaces, {@code TriConsumer} is expected + * to operate via side-effects. + * + *

This is a functional interface + * whose functional method is {@link #accept(Object, Object, Object)}. + * + * @param the type of the first argument to the operation + * @param the type of the second argument to the operation + * @param the type of the third argument to the operation + * + * @see Consumer + */ +@FunctionalInterface +public interface TriConsumer +{ + + /** + * Performs this operation on the given arguments. + * + * @param t the first input argument + * @param u the second input argument + * @param v the third input argument + */ + void accept(T t, U u, V v); + + /** + * Returns a composed {@code TriConsumer} that performs, in sequence, this + * operation followed by the {@code after} operation. If performing either + * operation throws an exception, it is relayed to the caller of the + * composed operation. If performing this operation throws an exception, + * the {@code after} operation will not be performed. + * + * @param after the operation to perform after this operation + * @return a composed {@code TriConsumer} that performs in sequence this + * operation followed by the {@code after} operation + * @throws NullPointerException if {@code after} is null + */ + default TriConsumer andThen(TriConsumer after) + { + Objects.requireNonNull(after); + + return (f, s, t) -> { + accept(f, s, t); + after.accept(f, s, t); + }; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index a8bc40c04..94b8c35f7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -175,7 +175,7 @@ public class CoreClientManager extends MiniPlugin } /** - * Get the databse account id for a player. Requires the player is online + * Get the database account id for a player. Requires the player is online * * @param player * @return diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java new file mode 100644 index 000000000..41d66c896 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java @@ -0,0 +1,181 @@ +package mineplex.game.clans.clans.mounts; + +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHorse; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Horse.Color; +import org.bukkit.entity.Horse.Style; +import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.TriConsumer; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; +import net.minecraft.server.v1_8_R3.GenericAttributes; + +public class Mount +{ + private Player _owner; + private CraftHorse _entity; + + public Mount(Player owner, CraftHorse entity) + { + _owner = owner; + _entity = entity; + } + + public void despawn() + { + UtilServer.CallEvent(new MountDespawnEvent(this)); + _entity.remove(); + } + + public static enum SkinType + { + ; + + private final int _id; + private final String _packageName; + private final String _displayName; + private final Color _color; + private final Variant _variant; + private final Style _style; + + private SkinType(int id, String packageName, String displayName, Color color, Variant variant, Style style) + { + _id = id; + _packageName = packageName; + _displayName = displayName; + _color = color; + _variant = variant; + _style = style; + } + + public int getId() + { + return _id; + } + + public String getPackageName() + { + return _packageName; + } + + public String getDisplayName() + { + return _displayName; + } + + public Color getColor() + { + return _color; + } + + public Variant getVariant() + { + return _variant; + } + + public Style getStyle() + { + return _style; + } + + public static SkinType getFromId(int id) + { + for (SkinType type : SkinType.values()) + { + if (type.getId() == id) + { + return type; + } + } + + return null; + } + } + + public static enum MountType + { + HORSE(1, C.cGold + "Horse", (owner, skin, stats) -> + { + CraftHorse horse = (CraftHorse) owner.getWorld().spawnEntity(owner.getLocation(), EntityType.HORSE); + horse.setAdult(); + horse.setAgeLock(true); + horse.setBreed(false); + horse.setVariant(skin.getVariant()); + horse.setColor(skin.getColor()); + horse.setStyle(skin.getStyle()); + horse.setTamed(true); + horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); + horse.setOwner(owner); + horse.setJumpStrength(stats.JumpStrength); + horse.getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(stats.Speed); + horse.setCustomNameVisible(true); + horse.setCustomName(owner.getName() + "'s " + skin.getDisplayName()); + horse.setPassenger(owner); + Mount mount = new Mount(owner, horse); + UtilServer.CallEvent(new MountSpawnEvent(mount)); + }), + STORAGE(2, C.cGold + "Storage", (owner, skin, stats) -> + { + CraftHorse horse = (CraftHorse) owner.getWorld().spawnEntity(owner.getLocation(), EntityType.HORSE); + horse.setAdult(); + horse.setAgeLock(true); + horse.setBreed(false); + horse.setVariant(skin.getVariant()); + horse.setTamed(true); + horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); + horse.setOwner(owner); + horse.setJumpStrength(stats.JumpStrength); + horse.getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(stats.Speed); + horse.setCustomNameVisible(true); + horse.setCustomName(owner.getName() + "'s " + skin.getDisplayName()); + horse.setCarryingChest(true); + horse.setPassenger(owner); + Mount mount = new Mount(owner, horse); + UtilServer.CallEvent(new MountSpawnEvent(mount)); + }) + ; + + private final int _id; + private final String _displayName; + private final TriConsumer _spawnHandler; + + private MountType(int id, String displayName, TriConsumer spawnHandler) + { + _id = id; + _displayName = displayName; + _spawnHandler = spawnHandler; + } + + public int getId() + { + return _id; + } + + public String getDisplayName() + { + return _displayName; + } + + public void spawn(Player owner, SkinType skinType, MountStatToken statToken) + { + _spawnHandler.accept(owner, skinType, statToken); + } + + public static MountType getFromId(int id) + { + for (MountType type : MountType.values()) + { + if (type.getId() == id) + { + return type; + } + } + + return null; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountDespawnEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountDespawnEvent.java new file mode 100644 index 000000000..2641dcb56 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountDespawnEvent.java @@ -0,0 +1,34 @@ +package mineplex.game.clans.clans.mounts; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * Event called before a mount despawns + */ +public class MountDespawnEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final Mount _mount; + + public MountDespawnEvent(Mount mount) + { + _mount = mount; + } + + public Mount getMount() + { + return _mount; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java new file mode 100644 index 000000000..5202606c2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -0,0 +1,63 @@ +package mineplex.game.clans.clans.mounts; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.UUID; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Pair; +import mineplex.game.clans.clans.mounts.Mount.MountType; +import mineplex.game.clans.clans.mounts.Mount.SkinType; +import mineplex.serverdata.Utility; + +public class MountManager extends MiniDbClientPlugin +{ + private static final double[] JUMP_BOUNDS = {0.5, 2}; + private static final double[] SPEED_BOUNDS = {0.1125, 0.3375}; + private static final int[] STRENGTH_BOUNDS = {1, 3}; + + private MountRepository _repository; + + public MountManager(JavaPlugin plugin, CoreClientManager clientManager) + { + super("Clans Mount Manager", plugin, clientManager); + } + + public void giveMount(Player player, MountType type) + { + Pair tokens = Get(player).grantMount(type, SPEED_BOUNDS, JUMP_BOUNDS, STRENGTH_BOUNDS); + _repository.saveMount(ClientManager.getAccountId(player), tokens.getLeft(), tokens.getRight()); + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT am.id, am.mountTypeId, am.mountSkinId, ms.statToken FROM accountClansMounts AS am INNER JOIN clansMountStats AS ms ON ms.mountId = am.id WHERE am.accountId=" + accountId + ";"; + } + + @Override + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException + { + MountOwnerData data = new MountOwnerData(); + while (resultSet.next()) + { + MountToken token = new MountToken(); + token.Id = resultSet.getInt("id"); + token.Type = MountType.getFromId(resultSet.getInt("mountTypeId")); + token.Skin = SkinType.getFromId(resultSet.getInt("mountSkinId")); + MountStatToken statToken = Utility.deserialize(resultSet.getString("statToken"), MountStatToken.class); + data.acceptLoad(token, statToken); + } + Set(uuid, data); + } + + @Override + protected MountOwnerData addPlayer(UUID uuid) + { + return new MountOwnerData(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountOwnerData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountOwnerData.java new file mode 100644 index 000000000..4cc8408ff --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountOwnerData.java @@ -0,0 +1,60 @@ +package mineplex.game.clans.clans.mounts; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import mineplex.core.common.Pair; +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.mounts.Mount.MountType; + +public class MountOwnerData +{ + private Map _mounts = new HashMap<>(); + + public List> getOwnedMounts(boolean onlyInitialized) + { + return _mounts.entrySet().stream().filter(entry -> onlyInitialized ? entry.getKey().Id != -1 : true).map(entry -> Pair.create(entry.getKey(), entry.getValue())).collect(Collectors.toList()); + } + + public boolean ownsMount(MountType type) + { + return _mounts.keySet().stream().anyMatch(token->token.Type == type); + } + + public void acceptLoad(MountToken token, MountStatToken statToken) + { + _mounts.put(token, statToken); + } + + public Pair grantMount(MountType type, double[] speedRange, double[] jumpRange, int[] strengthRange) + { + double speed = UtilMath.random(speedRange[0], speedRange[1]); + double jump = UtilMath.random(jumpRange[0], jumpRange[1]); + int strength = UtilMath.rRange(strengthRange[0], strengthRange[1]); + + MountToken token = new MountToken(); + token.Type = type; + MountStatToken statToken = new MountStatToken(); + statToken.JumpStrength = jump; + statToken.Speed = speed; + statToken.Strength = strength; + _mounts.put(token, statToken); + + return Pair.create(token, statToken); + } + + public int[] revokeMount(MountType type) + { + Integer[] array = _mounts.keySet().stream().filter(token->token.Type == type).map(token->token.Id).toArray(size->new Integer[size]); + _mounts.keySet().removeIf(token->token.Type == type); + int[] returnArray = new int[array.length]; + for (int i = 0; i < returnArray.length; i++) + { + returnArray[i] = array[i]; + } + + return returnArray; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountRepository.java new file mode 100644 index 000000000..03894e819 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountRepository.java @@ -0,0 +1,168 @@ +package mineplex.game.clans.clans.mounts; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.List; + +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.common.Pair; +import mineplex.serverdata.Utility; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; + +/** + * Database repository class for mounts + */ +public class MountRepository extends RepositoryBase +{ + private static final String CREATE_MOUNTS_TABLE = "CREATE TABLE IF NOT EXISTS accountClansMounts (id INT NOT NULL AUTO_INCREMENT," + + "accountId INT NOT NULL," + + "mountTypeId INT NOT NULL," + + "mountSkinId INT NOT NULL," + + "UNIQUE INDEX typeIndex (accountId, mountTypeId)," + + "INDEX skinIndex (mountSkinId)," + + "PRIMARY KEY (id));"; + + private static final String CREATE_MOUNT_STATS_TABLE = "CREATE TABLE IF NOT EXISTS clansMountStats (mountId INT NOT NULL," + + "accountId INT NOT NULL," + + "statToken VARCHAR(20) NOT NULL," + + "PRIMARY KEY (mountId));"; + + private static final String SAVE_MOUNT = "INSERT INTO accountClansMounts (accountId, mountTypeId, mountSkinId) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE mountSkinId=VALUES(mountSkinId);"; + private static final String SAVE_MOUNT_STATS = "INSERT INTO clansMountStats (mountId, statToken) VALUES (?, ?) ON DUPLICATE KEY UPDATE statToken=VALUES(statToken);"; + private static final String DELETE_MOUNT = "DELETE FROM accountClansMounts WHERE id=?;"; + private static final String DELETE_MOUNT_STATS = "DELETE FROM clansMountStats WHERE mountId=?;"; + + private MountManager _mountManager; + + public MountRepository(JavaPlugin plugin, MountManager mountManager) + { + super(DBPool.getAccount()); + _mountManager = mountManager; + } + + /** + * Saves a mount into the database + * @param accountId The owner's account id + * @param token The mount token to save + * @param statToken The stat token to save + */ + public void saveMount(final int accountId, final MountToken token, final MountStatToken statToken) + { + _mountManager.runAsync(() -> + { + try (Connection connection = getConnection();) + { + if (token.Id == -1) + { + executeInsert(connection, SAVE_MOUNT, idResult -> + { + if (idResult.next()) + { + token.Id = idResult.getInt(1); + } + }, null, new ColumnInt("accountId", accountId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin.getId())); + } + else + { + executeUpdate(connection, SAVE_MOUNT, null, new ColumnInt("accountId", accountId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin.getId())); + } + if (token.Id == -1) + { + return; + } + executeUpdate(connection, SAVE_MOUNT_STATS, null, new ColumnInt("mountId", token.Id), new ColumnVarChar("statToken", 20, Utility.serialize(statToken))); + } + catch (SQLException e) + { + e.printStackTrace(); + } + }); + } + + /** + * Saves a list of mounts into the database + * @param accountId The owner's account id + * @param tokens The list of token pairs to save + */ + public void saveMounts(final int accountId, final List> tokens) + { + _mountManager.runAsync(() -> + { + try (Connection connection = getConnection()) + { + for (Pair tokenPair : tokens) + { + MountToken token = tokenPair.getLeft(); + MountStatToken statToken = tokenPair.getRight(); + + if (token.Id == -1) + { + executeInsert(connection, SAVE_MOUNT, idResult -> + { + if (idResult.next()) + { + token.Id = idResult.getInt(1); + } + }, null, new ColumnInt("accountId", accountId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin.getId())); + } + else + { + executeUpdate(connection, SAVE_MOUNT, null, new ColumnInt("accountId", accountId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin.getId())); + } + if (token.Id == -1) + { + continue; + } + executeUpdate(connection, SAVE_MOUNT_STATS, null, new ColumnInt("mountId", token.Id), new ColumnVarChar("statToken", 20, Utility.serialize(statToken))); + } + } + catch (SQLException e) + { + e.printStackTrace(); + } + }); + } + + /** + * Deletes a mount from the database + * @param token The mount to delete + */ + public void deleteMount(final MountToken token) + { + if (token.Id == -1) + { + return; + } + _mountManager.runAsync(() -> + { + executeUpdate(DELETE_MOUNT, new ColumnInt("id", token.Id)); + executeUpdate(DELETE_MOUNT_STATS, new ColumnInt("mountId", token.Id)); + }); + } + + /** + * Deletes an array from the database + * @param ids The mount ids to delete + */ + public void deleteMounts(final int[] ids) + { + if (ids.length <= 0) + { + return; + } + _mountManager.runAsync(() -> + { + String idList = ids[0] + ""; + for (int i = 1; i < ids.length; i++) + { + idList += ("," + ids[i]); + } + executeUpdate(DELETE_MOUNT.replace("id=?;", "id IN (" + idList + ");")); + executeUpdate(DELETE_MOUNT_STATS.replace("mountId=?;", "mountId IN (" + idList + ");")); + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountSpawnEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountSpawnEvent.java new file mode 100644 index 000000000..9d3e788aa --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountSpawnEvent.java @@ -0,0 +1,34 @@ +package mineplex.game.clans.clans.mounts; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * Event called after a mount spawns + */ +public class MountSpawnEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final Mount _mount; + + public MountSpawnEvent(Mount mount) + { + _mount = mount; + } + + public Mount getMount() + { + return _mount; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountStatToken.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountStatToken.java new file mode 100644 index 000000000..63f41c590 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountStatToken.java @@ -0,0 +1,8 @@ +package mineplex.game.clans.clans.mounts; + +public class MountStatToken +{ + public double JumpStrength = 0.7; + public double Speed = .2250; + public int Strength = 1; +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountToken.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountToken.java new file mode 100644 index 000000000..8940344c0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountToken.java @@ -0,0 +1,11 @@ +package mineplex.game.clans.clans.mounts; + +import mineplex.game.clans.clans.mounts.Mount.MountType; +import mineplex.game.clans.clans.mounts.Mount.SkinType; + +public class MountToken +{ + public int Id = -1; + public MountType Type = null; + public SkinType Skin = null; +} \ No newline at end of file From 6d67a4f9f89a684be5f1b3f154ace4fe6534825b Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Apr 2017 05:04:32 -0400 Subject: [PATCH 092/283] Fix null pointer causing console spam (SENTRY ISSUE 223503319) --- .../src/mineplex/game/clans/clans/ClansDisplay.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java index 804690b92..26a95fb7f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java @@ -65,7 +65,7 @@ public class ClansDisplay extends MiniPlugin boolean safe = _clansManager.getClanUtility().isSafe(player); - PlayerEnterTerritoryEvent event = new PlayerEnterTerritoryEvent(player, client.getOwner(), owner, (owner.equals("Wilderness") && !_clansManager.getNetherManager().isInNether(player)) ? false : _clansManager.getClanUtility().getClaim(player.getLocation()).isSafe(player.getLocation()), true); + PlayerEnterTerritoryEvent event = new PlayerEnterTerritoryEvent(player, client.getOwner(), owner, safe, true); UtilServer.getServer().getPluginManager().callEvent(event); From 570355e41b22be75f3d6d4f371d468978a95bc01 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Apr 2017 16:49:47 -0400 Subject: [PATCH 093/283] Fix error runnables not being passed through even when intended to --- .../src/mineplex/serverdata/database/RepositoryBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/RepositoryBase.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/RepositoryBase.java index f5066fea9..996b5ed40 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/RepositoryBase.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/RepositoryBase.java @@ -87,7 +87,7 @@ public abstract class RepositoryBase protected int executeUpdate(String query, Runnable onSQLError, Column...columns) { - return executeInsert(query, null, columns); + return executeInsert(query, null, onSQLError, columns); } /** From 76d5d3e896907b69d7a454dcfed999049c6c0b0f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Apr 2017 16:51:00 -0400 Subject: [PATCH 094/283] More appropriately name fields in the CustomDamageEvent getDamagerPlayer method in order to be more understandable --- .../minecraft/game/core/damage/CustomDamageEvent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java index a4830cb56..83d3d0a0c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java @@ -157,9 +157,9 @@ public class CustomDamageEvent extends Event implements Cancellable return null; } - public Player GetDamagerPlayer(boolean ranged) + public Player GetDamagerPlayer(boolean passthroughRanged) { - if (ranged) + if (passthroughRanged) return _damagerPlayer; else if (_projectile == null) From c6bd00a8112a05ab1b3506d684066369a4c27c04 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Apr 2017 16:52:48 -0400 Subject: [PATCH 095/283] Make UtilEnt#GetMetadata actually return the field assigned to that metadata key and add a method to remove metadata from an entity --- .../src/mineplex/core/common/util/UtilEnt.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 580b337f5..7af6ab2dd 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -1032,7 +1032,12 @@ public class UtilEnt return null; } - return entity.getMetadata(key).get(0); + return entity.getMetadata(key).get(0).value(); + } + + public static void removeMetadata(Entity entity, String key) + { + entity.removeMetadata(key, UtilServer.getPlugin()); } public static void SetItemInHand(LivingEntity entity, ItemStack item) From 8c27c4349dd4b3ebd6156dcb7e3b7af785ba5277 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Apr 2017 16:53:16 -0400 Subject: [PATCH 096/283] Allow horses to be forcibly spawned but prevent them from naturally occurring --- .../game/clans/gameplay/CustomCreatures.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomCreatures.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomCreatures.java index b97ecbc2c..8dfc6ee3a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomCreatures.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomCreatures.java @@ -1,23 +1,18 @@ package mineplex.game.clans.gameplay; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; - -import org.bukkit.Material; import org.bukkit.entity.EntityType; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.inventory.CraftItemEvent; -import org.bukkit.inventory.Recipe; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; public class CustomCreatures implements Listener { private static final EntityType[] DISABLED_CREATURES = { EntityType.WITCH, EntityType.PIG_ZOMBIE, - EntityType.HORSE, EntityType.ENDERMAN }; + EntityType.ENDERMAN }; + + private static final EntityType[] DISABLED_NATURAL = { EntityType.HORSE }; @EventHandler public void onCreatureSpawn(CreatureSpawnEvent event) @@ -26,6 +21,10 @@ public class CustomCreatures implements Listener { event.setCancelled(true); } + if (isDisabledNatural(event.getEntityType()) && event.getSpawnReason() != SpawnReason.CUSTOM) + { + event.setCancelled(true); + } } private boolean isDisabledCreature(EntityType entityType) @@ -40,4 +39,17 @@ public class CustomCreatures implements Listener return false; } -} + + private boolean isDisabledNatural(EntityType entityType) + { + for (EntityType disabledCreature : DISABLED_NATURAL) + { + if (disabledCreature == entityType) + { + return true; + } + } + + return false; + } +} \ No newline at end of file From 264b7f86cfa4a93646f98510a95843ebddbc3c7a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Apr 2017 16:53:38 -0400 Subject: [PATCH 097/283] Implement mounts and remove legacy horse dismount code --- .../game/clans/clans/ClansManager.java | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 989eb95b7..31544c31e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -104,6 +104,7 @@ import mineplex.game.clans.clans.gui.ClanShop; import mineplex.game.clans.clans.invsee.InvseeManager; import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.map.ItemMapManager; +import mineplex.game.clans.clans.mounts.MountManager; import mineplex.game.clans.clans.nameblacklist.ClansBlacklist; import mineplex.game.clans.clans.nether.NetherManager; import mineplex.game.clans.clans.observer.ObserverManager; @@ -472,6 +473,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati _netherManager = new NetherManager(this); _amplifierManager = new AmplifierManager(plugin); + new MountManager(plugin, clientManager, donationManager); + _restartManager = new RestartManager(plugin); } @@ -1387,29 +1390,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati } } - @EventHandler - public void damageHorse(EntityDamageEvent event) - { - if (event.getEntity() instanceof Horse) - { - if (event.getEntity().getPassenger() != null && event.getEntity().getPassenger() instanceof Player) - { - event.getEntity().getPassenger().eject(); - Recharge.Instance.use((Player) event.getEntity().getPassenger(), "Ride Horse", 2 * 20L, false, false); - } - event.getEntity().eject(); - - } - else if(event.getEntity() instanceof Player) - { - if(event.getEntity().getVehicle() != null && event.getEntity().getVehicle() instanceof Horse) - { - Recharge.Instance.use((Player) event.getEntity(), "Ride Horse", 2 * 20L, false, false); - event.getEntity().getVehicle().eject(); - } - } - } - public Pair leftRecently(UUID uniqueId, long time) { if (_clanMemberLeftMap.containsKey(uniqueId) && (System.currentTimeMillis() - _clanMemberLeftMap.get(uniqueId).getRight()) <= time) From 3c4eee910f9e7b6ea9bab6e878d6baef2c35e2e8 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Apr 2017 16:54:27 -0400 Subject: [PATCH 098/283] Finish implementation of Mounts, tidy up mount saving, implement mount GUIs --- .../game/clans/clans/mounts/Mount.java | 107 ++++- .../clans/clans/mounts/MountClaimToken.java | 103 +++++ .../clans/clans/mounts/MountDespawnEvent.java | 9 +- .../game/clans/clans/mounts/MountManager.java | 374 +++++++++++++++++- .../clans/clans/mounts/MountOwnerData.java | 52 ++- .../clans/clans/mounts/MountRepository.java | 36 +- .../clans/clans/mounts/MountStatToken.java | 6 +- .../clans/mounts/gui/MountOverviewPage.java | 157 ++++++++ .../clans/clans/mounts/gui/MountShop.java | 21 + 9 files changed, 806 insertions(+), 59 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountClaimToken.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountShop.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java index 41d66c896..eb248c71e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java @@ -1,5 +1,7 @@ package mineplex.game.clans.clans.mounts; +import java.util.function.Consumer; + import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHorse; import org.bukkit.entity.EntityType; @@ -12,25 +14,68 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.TriConsumer; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import net.minecraft.server.v1_8_R3.GenericAttributes; public class Mount { + private static final long HIT_REGEN_COOLDOWN = 30000; + private Player _owner; private CraftHorse _entity; + private SkinType _skin; + private final int _strength; + private long _lastHit; + private int _hits; - public Mount(Player owner, CraftHorse entity) + public Mount(Player owner, CraftHorse entity, SkinType skin, int strength) { _owner = owner; _entity = entity; + _skin = skin; + _strength = strength; + _lastHit = System.currentTimeMillis(); + _hits = 0; } - public void despawn() + public Player getOwner() { - UtilServer.CallEvent(new MountDespawnEvent(this)); + return _owner; + } + + public CraftHorse getEntity() + { + return _entity; + } + + public void update() + { + if (_skin != null) + { + _skin.onUpdate(_entity); + } + if (UtilTime.elapsed(_lastHit, HIT_REGEN_COOLDOWN) && _hits > 0) + { + _hits--; + _lastHit = System.currentTimeMillis(); + } + } + + public void despawn(boolean forced) + { + UtilServer.CallEvent(new MountDespawnEvent(this, forced)); _entity.remove(); } + public void handleHit() + { + _hits++; + if (_hits == _strength) + { + despawn(true); + } + } + public static enum SkinType { ; @@ -41,8 +86,9 @@ public class Mount private final Color _color; private final Variant _variant; private final Style _style; + private final Consumer _onUpdate; - private SkinType(int id, String packageName, String displayName, Color color, Variant variant, Style style) + private SkinType(int id, String packageName, String displayName, Color color, Variant variant, Style style, Consumer onUpdate) { _id = id; _packageName = packageName; @@ -50,6 +96,7 @@ public class Mount _color = color; _variant = variant; _style = style; + _onUpdate = onUpdate; } public int getId() @@ -82,6 +129,11 @@ public class Mount return _style; } + public void onUpdate(CraftHorse horse) + { + _onUpdate.accept(horse); + } + public static SkinType getFromId(int id) { for (SkinType type : SkinType.values()) @@ -98,55 +150,63 @@ public class Mount public static enum MountType { - HORSE(1, C.cGold + "Horse", (owner, skin, stats) -> + HORSE(1, C.cWhite + "Horse", Material.IRON_BARDING, (owner, skin, stats) -> { CraftHorse horse = (CraftHorse) owner.getWorld().spawnEntity(owner.getLocation(), EntityType.HORSE); horse.setAdult(); horse.setAgeLock(true); horse.setBreed(false); - horse.setVariant(skin.getVariant()); - horse.setColor(skin.getColor()); - horse.setStyle(skin.getStyle()); + if (skin != null) + { + horse.setVariant(skin.getVariant()); + horse.setColor(skin.getColor()); + horse.setStyle(skin.getStyle()); + } horse.setTamed(true); horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); horse.setOwner(owner); - horse.setJumpStrength(stats.JumpStrength); - horse.getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(stats.Speed); + horse.setJumpStrength(MountManager.getJump(stats.JumpStars)); + horse.getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(MountManager.getSpeed(stats.SpeedStars)); horse.setCustomNameVisible(true); - horse.setCustomName(owner.getName() + "'s " + skin.getDisplayName()); - horse.setPassenger(owner); - Mount mount = new Mount(owner, horse); + horse.setCustomName(owner.getName() + "'s " + (skin == null ? "Horse" : skin.getDisplayName())); + //horse.setPassenger(owner); + Mount mount = new Mount(owner, horse, skin, MountManager.getStrength(stats.StrengthStars)); UtilServer.CallEvent(new MountSpawnEvent(mount)); }), - STORAGE(2, C.cGold + "Storage", (owner, skin, stats) -> + DONKEY(2, C.cWhite + "Donkey", Material.GOLD_BARDING, (owner, skin, stats) -> { CraftHorse horse = (CraftHorse) owner.getWorld().spawnEntity(owner.getLocation(), EntityType.HORSE); horse.setAdult(); horse.setAgeLock(true); horse.setBreed(false); - horse.setVariant(skin.getVariant()); + if (skin != null) + { + horse.setVariant(skin.getVariant()); + } horse.setTamed(true); horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); horse.setOwner(owner); - horse.setJumpStrength(stats.JumpStrength); - horse.getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(stats.Speed); + horse.setJumpStrength(MountManager.getJump(stats.JumpStars)); + horse.getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(MountManager.getSpeed(stats.SpeedStars)); horse.setCustomNameVisible(true); - horse.setCustomName(owner.getName() + "'s " + skin.getDisplayName()); + horse.setCustomName(owner.getName() + "'s " + (skin == null ? "Donkey" : skin.getDisplayName())); horse.setCarryingChest(true); - horse.setPassenger(owner); - Mount mount = new Mount(owner, horse); + //horse.setPassenger(owner); + Mount mount = new Mount(owner, horse, skin, MountManager.getStrength(stats.StrengthStars)); UtilServer.CallEvent(new MountSpawnEvent(mount)); }) ; private final int _id; private final String _displayName; + private final Material _displayType; private final TriConsumer _spawnHandler; - private MountType(int id, String displayName, TriConsumer spawnHandler) + private MountType(int id, String displayName, Material displayType, TriConsumer spawnHandler) { _id = id; _displayName = displayName; + _displayType = displayType; _spawnHandler = spawnHandler; } @@ -160,6 +220,11 @@ public class Mount return _displayName; } + public Material getDisplayType() + { + return _displayType; + } + public void spawn(Player owner, SkinType skinType, MountStatToken statToken) { _spawnHandler.accept(owner, skinType, statToken); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountClaimToken.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountClaimToken.java new file mode 100644 index 000000000..63c0b11d6 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountClaimToken.java @@ -0,0 +1,103 @@ +package mineplex.game.clans.clans.mounts; + +import org.bukkit.ChatColor; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.mounts.Mount.MountType; + +public class MountClaimToken +{ + private final String STAR = "✩"; + + public final int JumpStars; + public final int SpeedStars; + public final int StrengthStars; + public final MountType Type; + + public MountClaimToken(int jumpStars, int speedStars, int strengthStars, MountType type) + { + JumpStars = jumpStars; + SpeedStars = speedStars; + StrengthStars = strengthStars; + Type = type; + } + + public ItemStack toItem() + { + ItemBuilder builder = new ItemBuilder(Type.getDisplayType()); + builder.setTitle(Type.getDisplayName() + " Mount Token"); + String strength = C.cYellow; + for (int i = 0; i < StrengthStars; i++) + { + strength += STAR; + } + builder.addLore(C.cPurple + "Strength: " + strength); + String speed = C.cYellow; + for (int i = 0; i < SpeedStars; i++) + { + speed += STAR; + } + builder.addLore(C.cPurple + "Speed: " + speed); + String jump = C.cYellow; + for (int i = 0; i < JumpStars; i++) + { + jump += STAR; + } + builder.addLore(C.cPurple + "Jump: " + jump); + builder.addLore(C.cRed); + builder.addLore(C.cDGreen + "Right-Click While Holding to Consume"); + + return builder.build(); + } + + public static MountClaimToken fromItem(ItemStack item) + { + if (!item.hasItemMeta() || !item.getItemMeta().hasLore()) + { + return null; + } + + MountType type = null; + for (MountType check : MountType.values()) + { + if (check.getDisplayType() == item.getType()) + { + type = check; + break; + } + } + if (type == null) + { + return null; + } + + int strength = -1; + int speed = -1; + int jump = -1; + + for (String lore : item.getItemMeta().getLore()) + { + if (ChatColor.stripColor(lore).startsWith("Strength: ")) + { + strength = ChatColor.stripColor(lore).replace("Strength: ", "").length(); + } + if (ChatColor.stripColor(lore).startsWith("Speed: ")) + { + speed = ChatColor.stripColor(lore).replace("Speed: ", "").length(); + } + if (ChatColor.stripColor(lore).startsWith("Jump: ")) + { + jump = ChatColor.stripColor(lore).replace("Jump: ", "").length(); + } + } + + if (strength <= 0 || speed <= 0 || jump <= 0) + { + return null; + } + + return new MountClaimToken(strength, speed, jump, type); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountDespawnEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountDespawnEvent.java index 2641dcb56..9d4745116 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountDespawnEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountDespawnEvent.java @@ -11,10 +11,12 @@ public class MountDespawnEvent extends Event private static final HandlerList handlers = new HandlerList(); private final Mount _mount; + private final boolean _forced; - public MountDespawnEvent(Mount mount) + public MountDespawnEvent(Mount mount, boolean forced) { _mount = mount; + _forced = forced; } public Mount getMount() @@ -22,6 +24,11 @@ public class MountDespawnEvent extends Event return _mount; } + public boolean isForced() + { + return _forced; + } + public HandlerList getHandlers() { return handlers; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java index 5202606c2..74db30a98 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -2,36 +2,380 @@ package mineplex.game.clans.clans.mounts; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; import java.util.UUID; +import java.util.WeakHashMap; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHorse; +import org.bukkit.entity.Horse; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.HorseInventory; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.command.CommandBase; import mineplex.core.common.Pair; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.donation.DonationManager; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.mounts.Mount.MountType; import mineplex.game.clans.clans.mounts.Mount.SkinType; +import mineplex.game.clans.clans.mounts.gui.MountShop; +import mineplex.game.clans.spawn.Spawn; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.serverdata.Utility; public class MountManager extends MiniDbClientPlugin { - private static final double[] JUMP_BOUNDS = {0.5, 2}; - private static final double[] SPEED_BOUNDS = {0.1125, 0.3375}; - private static final int[] STRENGTH_BOUNDS = {1, 3}; + private static final double[] JUMP_STARS = {1, 1.5, 2}; + private static final double[] SPEED_STARS = {0.2, 0.27, 0.33}; + private static final int[] STRENGTH_STARS = {1, 2, 3}; - private MountRepository _repository; + private static final long SUMMON_WARMUP = 5000; + private static final long FORCED_COOLDOWN = 120 * 1000; + private static final long MAX_TIME_DISMOUNTED = 30000; - public MountManager(JavaPlugin plugin, CoreClientManager clientManager) + private static final int MAX_PER_TYPE = 3; + + private final MountRepository _repository; + private final DonationManager _donationManager; + private final MountShop _shop; + + private final Map _spawnedMounts = new HashMap<>(); + private final Map> _summoning = new WeakHashMap<>(); + + public MountManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) { super("Clans Mount Manager", plugin, clientManager); + + _repository = new MountRepository(plugin, this); + _donationManager = donationManager; + + _shop = new MountShop(this); + + addCommand(new CommandBase(this, Rank.ALL, "mounts", "mount") + { + @Override + public void Execute(Player caller, String[] args) + { + _shop.attemptShopOpen(caller); + } + }); + + addCommand(new CommandBase(this, Rank.ADMIN, "givemount") + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 4) + { + UtilPlayer.message(caller, F.main(getName(), "Usage: /" + _aliasUsed + " , , , ")); + return; + } + + Integer speed = 0; + Integer jump = 0; + Integer strength = 0; + MountType type = null; + + try + { + speed = Integer.parseInt(args[0]); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main(getName(), "Invalid speed!")); + return; + } + + try + { + jump = Integer.parseInt(args[1]); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main(getName(), "Invalid jump!")); + return; + } + + try + { + strength = Integer.parseInt(args[2]); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main(getName(), "Invalid strength!")); + return; + } + + try + { + type = MountType.valueOf(args[3]); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main(getName(), "Invalid type!")); + return; + } + + caller.getInventory().addItem(new MountClaimToken(jump, speed, strength, type).toItem()); + } + }); + } + + public DonationManager getDonationManager() + { + return _donationManager; + } + + public MountRepository getRepository() + { + return _repository; + } + + public boolean summonMount(Player player, MountToken token) + { + if (_summoning.containsKey(player)) + { + return false; + } + if (Spawn.getInstance().isSafe(player.getLocation())) + { + return false; + } + if (!Recharge.Instance.usable(player, "Mount Spawn Delay")) + { + return false; + } + _spawnedMounts.values().stream().filter(mount -> mount.getOwner().getEntityId() == player.getEntityId()).findFirst().ifPresent(mount -> mount.despawn(false)); + _summoning.put(player, Pair.create(System.currentTimeMillis(), token)); + UtilPlayer.message(player, F.main(getName(), "You are now summoning your mount! Please remain still for 5 seconds!")); + return true; } public void giveMount(Player player, MountType type) { - Pair tokens = Get(player).grantMount(type, SPEED_BOUNDS, JUMP_BOUNDS, STRENGTH_BOUNDS); + Pair tokens = Get(player).grantMount(type); _repository.saveMount(ClientManager.getAccountId(player), tokens.getLeft(), tokens.getRight()); } + + public void giveMount(Player player, MountClaimToken token) + { + Pair tokens = Get(player).grantMount(token.Type, token.SpeedStars, token.JumpStars, token.StrengthStars); + _repository.saveMount(ClientManager.getAccountId(player), tokens.getLeft(), tokens.getRight()); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + { + Iterator> mountIterator = _spawnedMounts.entrySet().iterator(); + while (mountIterator.hasNext()) + { + Entry entry = mountIterator.next(); + if (entry.getKey().isDead() || !entry.getKey().isValid()) + { + mountIterator.remove(); + entry.getValue().despawn(false); + continue; + } + if (Spawn.getInstance().isSafe(entry.getKey().getLocation())) + { + mountIterator.remove(); + entry.getValue().despawn(false); + continue; + } + if (entry.getKey().getPassenger() == null) + { + if (UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME") != null) + { + Long dismount = (Long) UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME"); + if (UtilTime.elapsed(dismount.longValue(), MAX_TIME_DISMOUNTED)) + { + mountIterator.remove(); + entry.getValue().despawn(false); + continue; + } + } + else + { + UtilEnt.SetMetadata(entry.getKey(), "DISMOUNT_TIME", System.currentTimeMillis()); + } + } + else + { + UtilEnt.removeMetadata(entry.getKey(), "DISMOUNT_TIME"); + } + entry.getValue().update(); + } + + Iterator>> summoningIterator = _summoning.entrySet().iterator(); + while (summoningIterator.hasNext()) + { + Entry> entry = summoningIterator.next(); + if (UtilTime.elapsed(entry.getValue().getLeft(), SUMMON_WARMUP)) + { + summoningIterator.remove(); + entry.getValue().getRight().Type.spawn(entry.getKey(), entry.getValue().getRight().Skin, Get(entry.getKey()).getStatToken(entry.getValue().getRight())); + continue; + } + if (UtilEnt.hasFlag(entry.getKey(), "MOVED_WHILE_SUMMONING_MOUNT")) + { + summoningIterator.remove(); + UtilEnt.removeFlag(entry.getKey(), "MOVED_WHILE_SUMMONING_MOUNT"); + continue; + } + } + } + } + + @EventHandler + public void onMove(PlayerMoveEvent event) + { + if (_summoning.containsKey(event.getPlayer()) && !UtilEnt.hasFlag(event.getPlayer(), "MOVED_WHILE_SUMMONING_MOUNT")) + { + Block from = event.getFrom().getBlock(); + Block to = event.getTo().getBlock(); + + if (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ()) + { + return; + } + UtilEnt.addFlag(event.getPlayer(), "MOVED_WHILE_SUMMONING_MOUNT"); + } + } + + @EventHandler + public void onSummon(MountSpawnEvent event) + { + _spawnedMounts.put(event.getMount().getEntity(), event.getMount()); + UtilPlayer.message(event.getMount().getOwner(), F.main(getName(), "Your mount has spawned!")); + } + + @EventHandler + public void onDespawn(MountDespawnEvent event) + { + _spawnedMounts.remove(event.getMount().getEntity()); + event.getMount().getEntity().eject(); + event.getMount().getEntity().remove(); + UtilPlayer.message(event.getMount().getOwner(), F.main(getName(), "Your mount has despawned!")); + if (event.isForced()) + { + Recharge.Instance.use(event.getMount().getOwner(), "Mount Spawn Delay", FORCED_COOLDOWN, false, false); + } + } + + @EventHandler + public void onUseToken(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + if (event.getItem() == null) + { + return; + } + MountClaimToken token = MountClaimToken.fromItem(event.getItem()); + if (token == null) + { + return; + } + + event.setCancelled(true); + + if (Get(event.getPlayer()).getAmountOwned(token.Type) >= MAX_PER_TYPE) + { + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have reached the maximum amount of that type of mount!")); + return; + } + + giveMount(event.getPlayer(), token); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have redeemed your mount!")); + event.getPlayer().getInventory().setItemInHand(null); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void handleHits(CustomDamageEvent event) + { + if (event.GetDamageeEntity() == null) + { + return; + } + Mount[] spawned = _spawnedMounts.values().toArray(new Mount[_spawnedMounts.size()]); + for (Mount mount : spawned) + { + if (mount.getEntity().getEntityId() == event.GetDamageeEntity().getEntityId()) + { + if (event.GetDamagerPlayer(true) != null && event.GetDamagerPlayer(true).getEntityId() == mount.getOwner().getEntityId()) + { + event.SetCancelled("Damaging own mount"); + return; + } + event.setDamagee(mount.getOwner()); + mount.handleHit(); + return; + } + if (mount.getOwner().getEntityId() == event.GetDamageeEntity().getEntityId()) + { + mount.handleHit(); + return; + } + } + } + + @EventHandler + public void onEditHorseInventory(InventoryClickEvent event) + { + if (!(event.getClickedInventory() instanceof HorseInventory)) + { + return; + } + + event.setCancelled(true); + } + + @EventHandler + public void mountInteract(PlayerInteractEntityEvent event) + { + if (!(event.getRightClicked() instanceof Horse)) + { + return; + } + Optional opt = _spawnedMounts.entrySet().stream().filter(entry -> entry.getKey().getEntityId() == event.getRightClicked().getEntityId()).map(Entry::getValue).findAny(); + if (!opt.isPresent()) + { + return; + } + if (opt.get().getOwner().getEntityId() == event.getPlayer().getEntityId()) + { + return; + } + + UtilPlayer.message(event.getPlayer(), F.main(getName(), "This is not your Mount!")); + event.setCancelled(true); + } @Override public String getQuery(int accountId, String uuid, String name) @@ -60,4 +404,22 @@ public class MountManager extends MiniDbClientPlugin { return new MountOwnerData(); } + + public static double getSpeed(int stars) + { + stars = Math.min(Math.max(1, stars), 3); + return SPEED_STARS[stars - 1]; + } + + public static double getJump(int stars) + { + stars = Math.min(Math.max(1, stars), 3); + return JUMP_STARS[stars - 1]; + } + + public static int getStrength(int stars) + { + stars = Math.min(Math.max(1, stars), 3); + return STRENGTH_STARS[stars - 1]; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountOwnerData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountOwnerData.java index 4cc8408ff..f962de9a7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountOwnerData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountOwnerData.java @@ -18,9 +18,24 @@ public class MountOwnerData return _mounts.entrySet().stream().filter(entry -> onlyInitialized ? entry.getKey().Id != -1 : true).map(entry -> Pair.create(entry.getKey(), entry.getValue())).collect(Collectors.toList()); } + public List> getOwnedMounts(boolean onlyInitialized, MountType type) + { + return _mounts.entrySet().stream().filter(entry -> (onlyInitialized ? entry.getKey().Id != -1 : true) && type == entry.getKey().Type).map(entry -> Pair.create(entry.getKey(), entry.getValue())).collect(Collectors.toList()); + } + + public MountStatToken getStatToken(MountToken mountToken) + { + return _mounts.get(mountToken); + } + public boolean ownsMount(MountType type) { - return _mounts.keySet().stream().anyMatch(token->token.Type == type); + return getAmountOwned(type) > 0; + } + + public long getAmountOwned(MountType type) + { + return _mounts.keySet().stream().filter(token -> token.Type == type).count(); } public void acceptLoad(MountToken token, MountStatToken statToken) @@ -28,33 +43,38 @@ public class MountOwnerData _mounts.put(token, statToken); } - public Pair grantMount(MountType type, double[] speedRange, double[] jumpRange, int[] strengthRange) + public Pair grantMount(MountType type, int speed, int jump, int strength) { - double speed = UtilMath.random(speedRange[0], speedRange[1]); - double jump = UtilMath.random(jumpRange[0], jumpRange[1]); - int strength = UtilMath.rRange(strengthRange[0], strengthRange[1]); - MountToken token = new MountToken(); token.Type = type; MountStatToken statToken = new MountStatToken(); - statToken.JumpStrength = jump; - statToken.Speed = speed; - statToken.Strength = strength; + statToken.JumpStars = jump; + statToken.SpeedStars = speed; + statToken.StrengthStars = strength; _mounts.put(token, statToken); return Pair.create(token, statToken); } - public int[] revokeMount(MountType type) + public Pair grantMount(MountType type) + { + int speed = UtilMath.rRange(1, 3); + int jump = UtilMath.rRange(1, 3); + int strength = UtilMath.rRange(1, 3); + + return grantMount(type, speed, jump, strength); + } + + public Integer[] removeMounts(MountType type) { Integer[] array = _mounts.keySet().stream().filter(token->token.Type == type).map(token->token.Id).toArray(size->new Integer[size]); _mounts.keySet().removeIf(token->token.Type == type); - int[] returnArray = new int[array.length]; - for (int i = 0; i < returnArray.length; i++) - { - returnArray[i] = array[i]; - } - return returnArray; + return array; + } + + public void removeMount(int id) + { + _mounts.keySet().removeIf(token->token.Id == id); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountRepository.java index 03894e819..821c887d2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountRepository.java @@ -3,6 +3,7 @@ package mineplex.game.clans.clans.mounts; import java.sql.Connection; import java.sql.SQLException; import java.util.List; +import java.util.function.Consumer; import org.bukkit.plugin.java.JavaPlugin; @@ -22,16 +23,16 @@ public class MountRepository extends RepositoryBase + "accountId INT NOT NULL," + "mountTypeId INT NOT NULL," + "mountSkinId INT NOT NULL," - + "UNIQUE INDEX typeIndex (accountId, mountTypeId)," + + "INDEX typeIndex (mountTypeId)," + "INDEX skinIndex (mountSkinId)," + "PRIMARY KEY (id));"; private static final String CREATE_MOUNT_STATS_TABLE = "CREATE TABLE IF NOT EXISTS clansMountStats (mountId INT NOT NULL," - + "accountId INT NOT NULL," + "statToken VARCHAR(20) NOT NULL," + "PRIMARY KEY (mountId));"; - private static final String SAVE_MOUNT = "INSERT INTO accountClansMounts (accountId, mountTypeId, mountSkinId) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE mountSkinId=VALUES(mountSkinId);"; + private static final String INSERT_MOUNT = "INSERT INTO accountClansMounts (accountId, mountTypeId, mountSkinId) VALUES (?, ?, ?);"; + private static final String SAVE_MOUNT = "UPDATE accountClansMounts SET mountSkinId=? WHERE id=?;"; private static final String SAVE_MOUNT_STATS = "INSERT INTO clansMountStats (mountId, statToken) VALUES (?, ?) ON DUPLICATE KEY UPDATE statToken=VALUES(statToken);"; private static final String DELETE_MOUNT = "DELETE FROM accountClansMounts WHERE id=?;"; private static final String DELETE_MOUNT_STATS = "DELETE FROM clansMountStats WHERE mountId=?;"; @@ -58,17 +59,17 @@ public class MountRepository extends RepositoryBase { if (token.Id == -1) { - executeInsert(connection, SAVE_MOUNT, idResult -> + executeInsert(connection, INSERT_MOUNT, idResult -> { if (idResult.next()) { token.Id = idResult.getInt(1); } - }, null, new ColumnInt("accountId", accountId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin.getId())); + }, null, new ColumnInt("accountId", accountId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin == null ? -1 : token.Skin.getId())); } else { - executeUpdate(connection, SAVE_MOUNT, null, new ColumnInt("accountId", accountId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin.getId())); + executeUpdate(connection, SAVE_MOUNT, null, new ColumnInt("mountSkinId", token.Skin == null ? -1 : token.Skin.getId()), new ColumnInt("id", token.Id)); } if (token.Id == -1) { @@ -101,23 +102,23 @@ public class MountRepository extends RepositoryBase if (token.Id == -1) { - executeInsert(connection, SAVE_MOUNT, idResult -> + executeInsert(connection, INSERT_MOUNT, idResult -> { if (idResult.next()) { token.Id = idResult.getInt(1); } - }, null, new ColumnInt("accountId", accountId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin.getId())); + }, null, new ColumnInt("accountId", accountId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin == null ? -1 : token.Skin.getId())); } else { - executeUpdate(connection, SAVE_MOUNT, null, new ColumnInt("accountId", accountId), new ColumnInt("mountTypeId", token.Type.getId()), new ColumnInt("mountSkinId", token.Skin.getId())); + executeUpdate(connection, SAVE_MOUNT, null, new ColumnInt("mountSkinId", token.Skin == null ? -1 : token.Skin.getId()), new ColumnInt("id", token.Id)); } if (token.Id == -1) { continue; } - executeUpdate(connection, SAVE_MOUNT_STATS, null, new ColumnInt("mountId", token.Id), new ColumnVarChar("statToken", 20, Utility.serialize(statToken))); + executeUpdate(connection, SAVE_MOUNT_STATS, null, new ColumnInt("mountId", token.Id), new ColumnVarChar("statToken", 100, Utility.serialize(statToken))); } } catch (SQLException e) @@ -131,7 +132,7 @@ public class MountRepository extends RepositoryBase * Deletes a mount from the database * @param token The mount to delete */ - public void deleteMount(final MountToken token) + public void deleteMount(final MountToken token, final Consumer after) { if (token.Id == -1) { @@ -141,6 +142,13 @@ public class MountRepository extends RepositoryBase { executeUpdate(DELETE_MOUNT, new ColumnInt("id", token.Id)); executeUpdate(DELETE_MOUNT_STATS, new ColumnInt("mountId", token.Id)); + if (after != null) + { + _mountManager.runSync(() -> + { + after.accept(token.Id); + }); + } }); } @@ -148,7 +156,7 @@ public class MountRepository extends RepositoryBase * Deletes an array from the database * @param ids The mount ids to delete */ - public void deleteMounts(final int[] ids) + public void deleteMounts(final int[] ids, final Runnable after) { if (ids.length <= 0) { @@ -163,6 +171,10 @@ public class MountRepository extends RepositoryBase } executeUpdate(DELETE_MOUNT.replace("id=?;", "id IN (" + idList + ");")); executeUpdate(DELETE_MOUNT_STATS.replace("mountId=?;", "mountId IN (" + idList + ");")); + if (after != null) + { + _mountManager.runSync(after); + } }); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountStatToken.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountStatToken.java index 63f41c590..42517042e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountStatToken.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountStatToken.java @@ -2,7 +2,7 @@ package mineplex.game.clans.clans.mounts; public class MountStatToken { - public double JumpStrength = 0.7; - public double Speed = .2250; - public int Strength = 1; + public int JumpStars = 1; + public int SpeedStars = 1; + public int StrengthStars = 1; } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java new file mode 100644 index 000000000..9dfddf0c0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java @@ -0,0 +1,157 @@ +package mineplex.game.clans.clans.mounts.gui; + +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.confirmation.ConfirmationCallback; +import mineplex.core.shop.confirmation.ConfirmationPage; +import mineplex.core.shop.confirmation.ConfirmationProcessor; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.mounts.Mount.MountType; +import mineplex.game.clans.clans.mounts.MountManager; +import mineplex.game.clans.clans.mounts.MountStatToken; +import mineplex.game.clans.clans.mounts.MountToken; + +public class MountOverviewPage extends ShopPageBase +{ + private final String STAR = "✩"; + + public MountOverviewPage(MountManager plugin, MountShop shop, String name, Player player) + { + super(plugin, shop, plugin.getClientManager(), plugin.getDonationManager(), name, player, 27); + + buildPage(); + } + + private ItemStack toItem(MountToken mountToken, MountStatToken statToken, boolean overview) + { + ItemBuilder builder = new ItemBuilder(mountToken.Type.getDisplayType()); + builder.setTitle(mountToken.Type.getDisplayName() + " Mount"); + String strength = C.cYellow; + for (int i = 0; i < statToken.StrengthStars; i++) + { + strength += STAR; + } + builder.addLore(C.cPurple + "Strength: " + strength); + String speed = C.cYellow; + for (int i = 0; i < statToken.SpeedStars; i++) + { + speed += STAR; + } + builder.addLore(C.cPurple + "Speed: " + speed); + String jump = C.cYellow; + for (int i = 0; i < statToken.JumpStars; i++) + { + jump += STAR; + } + builder.addLore(C.cPurple + "Jump: " + jump); + if (overview) + { + builder.addLore(C.cRed); + builder.addLore(C.cDGreen + "Left-Click to Summon"); + builder.addLore(C.cDGreen + "Right-Click to Manage Skin"); + builder.addLore(C.cDRed + "Shift Right-Click to Destroy"); + } + + return builder.build(); + } + + @Override + protected void buildPage() + { + int[] horseSlots = {10, 11, 12}; + List> horses = getPlugin().Get(getPlayer()).getOwnedMounts(true, MountType.HORSE); + int[] donkeySlots = {14, 15, 16}; + List> donkeys = getPlugin().Get(getPlayer()).getOwnedMounts(true, MountType.DONKEY); + + for (int i = 0; i < horseSlots.length; i++) + { + int slot = horseSlots[i]; + ItemStack item = new ItemBuilder(Material.INK_SACK).setData((short)8).setTitle(C.cRed).build(); + IButton button = null; + if (horses.size() > i) + { + Pair tokens = horses.get(i); + item = toItem(tokens.getLeft(), tokens.getRight(), true); + button = new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + if (clickType == ClickType.LEFT) + { + if (!getPlugin().summonMount(player, tokens.getLeft())) + { + playDenySound(player); + } + } + else if (clickType == ClickType.RIGHT) + { + playDenySound(player); + //getShop().openPageForPlayer(player, page); + } + else if (clickType == ClickType.SHIFT_RIGHT) + { + getShop().openPageForPlayer(player, new ConfirmationPage(player, MountOverviewPage.this, new ConfirmationProcessor() + { + @Override + public void init(Inventory inventory) {} + + @Override + public void process(ConfirmationCallback callback) + { + getPlugin().getRepository().deleteMount(tokens.getLeft(), id -> + { + getPlugin().Get(getPlayer()).removeMount(id.intValue()); + callback.resolve("Mount successfully deleted!"); + }); + } + }, toItem(tokens.getLeft(), tokens.getRight(), false))); + } + } + }; + } + addButton(slot, item, button); + } + for (int i = 0; i < donkeySlots.length; i++) + { + int slot = donkeySlots[i]; + ItemStack item = new ItemBuilder(Material.INK_SACK).setData((short)8).setTitle(C.cRed).build(); + IButton button = null; + if (donkeys.size() > i) + { + Pair tokens = donkeys.get(i); + item = toItem(tokens.getLeft(), tokens.getRight(), true); + button = new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + if (clickType == ClickType.LEFT) + { + + } + else if (clickType == ClickType.RIGHT) + { + + } + else if (clickType == ClickType.SHIFT_RIGHT) + { + + } + } + }; + } + addButton(slot, item, button); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountShop.java new file mode 100644 index 000000000..d6dd454d5 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountShop.java @@ -0,0 +1,21 @@ +package mineplex.game.clans.clans.mounts.gui; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.mounts.MountManager; + +public class MountShop extends ShopBase +{ + public MountShop(MountManager plugin) + { + super(plugin, plugin.getClientManager(), plugin.getDonationManager(), "Manage Mounts"); + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return new MountOverviewPage(getPlugin(), this, "Manage Mounts", player); + } +} \ No newline at end of file From 8c911426fd11f42670d59d14e008531b33c10dad Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Apr 2017 17:31:12 -0400 Subject: [PATCH 099/283] Slight UI improvements and made fall damage no longer count towards mount despawn hits --- .../game/clans/clans/mounts/Mount.java | 4 +++ .../game/clans/clans/mounts/MountManager.java | 27 +++++++++++++++++-- .../clans/mounts/gui/MountOverviewPage.java | 26 +++++++++++++++--- .../clans/clans/nether/NetherManager.java | 12 ++++++++- 4 files changed, 63 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java index eb248c71e..e2dbe7adf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java @@ -183,6 +183,10 @@ public class Mount { horse.setVariant(skin.getVariant()); } + else + { + horse.setVariant(Variant.DONKEY); + } horse.setTamed(true); horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); horse.setOwner(owner); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java index 74db30a98..1ca4513bd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -16,6 +16,7 @@ import org.bukkit.entity.Horse; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -38,6 +39,7 @@ import mineplex.core.donation.DonationManager; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.mounts.Mount.MountType; import mineplex.game.clans.clans.mounts.Mount.SkinType; import mineplex.game.clans.clans.mounts.gui.MountShop; @@ -157,14 +159,22 @@ public class MountManager extends MiniDbClientPlugin { if (_summoning.containsKey(player)) { + UtilPlayer.message(player, F.main(getName(), "You are already summoning a mount!")); return false; } if (Spawn.getInstance().isSafe(player.getLocation())) { + UtilPlayer.message(player, F.main(getName(), "You cannot summon a mount in safezones!")); + return false; + } + if (ClansManager.getInstance().getNetherManager().isInNether(player)) + { + UtilPlayer.message(player, F.main(getName(), "You cannot summon a mount in the Nether!")); return false; } if (!Recharge.Instance.usable(player, "Mount Spawn Delay")) { + UtilPlayer.message(player, F.main(getName(), "You cannot summon a mount so soon after your last one was forcibly despawned!")); return false; } _spawnedMounts.values().stream().filter(mount -> mount.getOwner().getEntityId() == player.getEntityId()).findFirst().ifPresent(mount -> mount.despawn(false)); @@ -200,6 +210,12 @@ public class MountManager extends MiniDbClientPlugin entry.getValue().despawn(false); continue; } + if (entry.getValue().getOwner().isDead() || !entry.getValue().getOwner().isValid() || !entry.getValue().getOwner().isOnline()) + { + mountIterator.remove(); + entry.getValue().despawn(false); + continue; + } if (Spawn.getInstance().isSafe(entry.getKey().getLocation())) { mountIterator.remove(); @@ -244,6 +260,7 @@ public class MountManager extends MiniDbClientPlugin { summoningIterator.remove(); UtilEnt.removeFlag(entry.getKey(), "MOVED_WHILE_SUMMONING_MOUNT"); + UtilPlayer.message(entry.getKey(), F.main(getName(), "You have stopped summoning your mount as you have moved!")); continue; } } @@ -334,12 +351,18 @@ public class MountManager extends MiniDbClientPlugin return; } event.setDamagee(mount.getOwner()); - mount.handleHit(); + if (event.GetCause() != DamageCause.FALL) + { + mount.handleHit(); + } return; } if (mount.getOwner().getEntityId() == event.GetDamageeEntity().getEntityId()) { - mount.handleHit(); + if (event.GetCause() != DamageCause.FALL) + { + mount.handleHit(); + } return; } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java index 9dfddf0c0..3dae4f1da 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java @@ -112,6 +112,7 @@ public class MountOverviewPage extends ShopPageBase getPlugin().getRepository().deleteMount(tokens.getLeft(), id -> { getPlugin().Get(getPlayer()).removeMount(id.intValue()); + MountOverviewPage.this.refresh(); callback.resolve("Mount successfully deleted!"); }); } @@ -138,15 +139,34 @@ public class MountOverviewPage extends ShopPageBase { if (clickType == ClickType.LEFT) { - + if (!getPlugin().summonMount(player, tokens.getLeft())) + { + playDenySound(player); + } } else if (clickType == ClickType.RIGHT) { - + playDenySound(player); + //getShop().openPageForPlayer(player, page); } else if (clickType == ClickType.SHIFT_RIGHT) { - + getShop().openPageForPlayer(player, new ConfirmationPage(player, new MountOverviewPage(getPlugin(), getShop(), getName(), getPlayer()), new ConfirmationProcessor() + { + @Override + public void init(Inventory inventory) {} + + @Override + public void process(ConfirmationCallback callback) + { + getPlugin().getRepository().deleteMount(tokens.getLeft(), id -> + { + getPlugin().Get(getPlayer()).removeMount(id.intValue()); + MountOverviewPage.this.refresh(); + callback.resolve("Mount successfully deleted!"); + }); + } + }, toItem(tokens.getLeft(), tokens.getRight(), false))); } } }; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 79f0dab91..80b8bfd38 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -151,7 +151,17 @@ public class NetherManager extends MiniPlugin */ public boolean isInNether(Player player) { - return player.getWorld().equals(_netherWorld); + return isInNether(player.getLocation()); + } + + /** + * Checks if a location is in the nether + * @param location The location to check + * @return Whether the player is in the nether + */ + public boolean isInNether(Location location) + { + return location.getWorld().equals(_netherWorld); } /** From 2f0acc4a00128ade2800f7c5acf059972d23c47e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Apr 2017 20:40:13 -0400 Subject: [PATCH 100/283] Block outposts being spawned in water causing them to break --- .../game/clans/clans/siege/outpost/Outpost.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index 337c3e402..f49712a83 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -8,6 +8,7 @@ import java.util.List; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.block.Block; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -280,6 +281,20 @@ public class Outpost implements Listener return; } + for (Block block : UtilBlock.getBlocksInRadius(event.getClickedBlock().getLocation(), 5)) + { + if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an Outpost that close to water!")); + return; + } + if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an Outpost that close to lava!")); + return; + } + } + _origin.getBlock().setType(Material.AIR); beginConstruction(); } From c78ee51307a120ff1360b78bb4957fe6aac0c414 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 23 Apr 2017 22:20:26 -0400 Subject: [PATCH 101/283] Add method for testing 2d squared distance --- .../src/mineplex/core/common/util/UtilMath.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java index bd9e1600c..90dc0fd6c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java @@ -54,6 +54,23 @@ public class UtilMath return a.subtract(b).length(); } + public static double offset2dSquared(Entity a, Entity b) + { + return offset2dSquared(a.getLocation().toVector(), b.getLocation().toVector()); + } + + public static double offset2dSquared(Location a, Location b) + { + return offset2dSquared(a.toVector(), b.toVector()); + } + + public static double offset2dSquared(Vector a, Vector b) + { + a.setY(0); + b.setY(0); + return a.subtract(b).lengthSquared(); + } + public static double offset(Entity a, Entity b) { return offset(a.getLocation().toVector(), b.getLocation().toVector()); From 98295276881eb642538b7d9b28d2f4e649832869 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 23 Apr 2017 22:20:53 -0400 Subject: [PATCH 102/283] Remove armor stands causing memory leaks --- .../gameplay/safelog/npc/CombatLogNPC.java | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java index 24417d878..e2095eccf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java @@ -10,7 +10,6 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.ArmorStand; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -45,7 +44,6 @@ public class CombatLogNPC private boolean _creative; private LivingEntity _npc; - private ArmorStand _stand; private CraftLivingEntity _lastDamager; @@ -153,13 +151,6 @@ public class CombatLogNPC System.out.println("Despawning"); if (_npc != null) { - if (_stand != null) - { - _stand.setPassenger(null); - _stand.remove(); - _stand = null; - } - _npc.remove(); _npc = null; _hologram.stop(); @@ -210,17 +201,6 @@ public class CombatLogNPC // Disguise DisguisePlayer disguise = new DisguisePlayer(skel, ((CraftPlayer) player).getHandle().getProfile()); _disguiseManager.disguise(disguise, attempted -> inRange.contains(attempted)); - - if (!UtilEnt.isGrounded(player)) - { - ArmorStand stand = player.getWorld().spawn(spawnLoc.clone().subtract(0,1,0), ArmorStand.class); - - stand.setVisible(false); - stand.setPassenger(skel); - stand.setGravity(false); - - _stand = stand; - } return skel; } From 8ea90eb914209ad7e6159c9171b5f7148daf1ea3 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 23 Apr 2017 22:21:37 -0400 Subject: [PATCH 103/283] Prevent breaking banners in zones the player does not have build access in --- .../src/mineplex/game/clans/clans/banners/BannerManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java index 307e1590d..6b5503b3c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java @@ -10,6 +10,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPlaceEvent; @@ -170,7 +171,7 @@ public class BannerManager extends MiniPlugin } } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBreak(BlockBreakEvent event) { if (event.getBlock().getType() == Material.STANDING_BANNER || event.getBlock().getType() == Material.WALL_BANNER) From b14ecdbe4f609f0b36a0dd11fe5e1b9e298d03ab Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 23 Apr 2017 22:22:34 -0400 Subject: [PATCH 104/283] Fix outposts to not break if the clan has blank banner pattern layers --- .../mineplex/game/clans/clans/siege/outpost/OutpostType.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostType.java index 53e4979a6..c14bc04d5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostType.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Objects; import org.bukkit.Location; import org.bukkit.Material; @@ -327,7 +328,7 @@ public enum OutpostType { continue; } - build.put(UtilWorld.locToStr(loc), new OutpostBlockBanner(build, loc, schematic.getBlock(x, y, z), schematic.getData(x, y, z), cb.getBaseColor(), (Pattern[]) cb.getPatterns().stream().map(BannerPattern::getBukkitPattern).toArray())); + build.put(UtilWorld.locToStr(loc), new OutpostBlockBanner(build, loc, schematic.getBlock(x, y, z), schematic.getData(x, y, z), cb.getBaseColor(), cb.getPatterns().stream().map(BannerPattern::getBukkitPattern).filter(Objects::nonNull).toArray(size -> new Pattern[size]))); } else { From cff2ca54146e99c86ecc16b435f2f2ba8b02863b Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 23 Apr 2017 22:23:59 -0400 Subject: [PATCH 105/283] Implement a new worldevent api to better handle events in clans, and begin implementing the api in place of the old --- .../clans/worldevent/WorldEventManager.java | 6 +- .../clans/worldevent/api/BossAbility.java | 109 +++++ .../clans/worldevent/api/BossPassive.java | 48 ++ .../clans/worldevent/api/EventArena.java | 44 ++ .../clans/worldevent/api/EventCreature.java | 410 ++++++++++++++++++ .../api/EventCreatureDeathEvent.java | 31 ++ .../clans/worldevent/api/EventState.java | 8 + .../clans/worldevent/api/WorldEvent.java | 325 ++++++++++++++ .../clans/worldevent/boss/BossWorldEvent.java | 61 +++ 9 files changed, 1039 insertions(+), 3 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/BossAbility.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/BossPassive.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventArena.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreature.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreatureDeathEvent.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventState.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index 3dd3cd94e..d077e32ef 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -113,6 +113,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement } } + //TODO: Move this into the appropriate world events @EventHandler public void onBossDeath(EventCreatureDeathEvent event) { @@ -137,8 +138,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return; } - boolean removed = false; - + boolean removed = _runningEvents.removeIf(e -> e.getState() == EventState.COMPLETE); Iterator iterator = _runningEvents.iterator(); while (iterator.hasNext()) { @@ -341,4 +341,4 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement { return getClans().getDisguiseManager(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/BossAbility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/BossAbility.java new file mode 100644 index 000000000..8ed1186c1 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/BossAbility.java @@ -0,0 +1,109 @@ +package mineplex.game.clans.clans.worldevent.api; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; + +public abstract class BossAbility, Y extends LivingEntity> implements Listener +{ + private T _creature; + private Map _damaged = new HashMap<>(); + + public BossAbility(T creature) + { + _creature = creature; + } + + public abstract boolean canMove(); + + public abstract boolean inProgress(); + + public abstract boolean hasFinished(); + + public abstract void setFinished(); + + public abstract void tick(); + + public boolean canDamage(Entity player) + { + if (_damaged.containsKey(player.getUniqueId())) + { + + if (!UtilTime.elapsed(_damaged.get(player.getUniqueId()), 400)) + { + return false; + } + } + + _damaged.put(player.getUniqueId(), System.currentTimeMillis()); + return true; + } + + public int getCooldown() + { + return 3; + } + + public Y getEntity() + { + return getBoss().getEntity(); + } + + public T getBoss() + { + return _creature; + } + + public Location getLocation() + { + return getEntity().getLocation(); + } + + public Player getTarget() + { + return getTarget(30); + } + + public Player getTarget(double minDistance, double maxDistance) + { + Player target = null; + double dist = 0; + + for (Player player : UtilPlayer.getNearby(getLocation(), maxDistance, true)) + { + if (!player.hasLineOfSight(getEntity())) + { + continue; + } + + double d = player.getLocation().distance(getLocation()); + + if (d < minDistance) + { + continue; + } + + if (target == null || dist > d) + { + target = player; + dist = d; + } + } + + return target; + } + + public Player getTarget(double maxDistance) + { + return getTarget(0, maxDistance); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/BossPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/BossPassive.java new file mode 100644 index 000000000..022d7d103 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/BossPassive.java @@ -0,0 +1,48 @@ +package mineplex.game.clans.clans.worldevent.api; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.Listener; + +public abstract class BossPassive, Y extends LivingEntity> implements Listener +{ + private T _creature; + private final int _cooldown; + + public BossPassive(T creature) + { + this(creature, 30); + } + + public BossPassive(T creature, int cooldown) + { + _creature = creature; + _cooldown = cooldown; + Bukkit.getPluginManager().registerEvents(this, creature.getEvent().getPlugin()); + } + + public abstract boolean isProgressing(); + + public abstract void tick(); + + public int getCooldown() + { + return _cooldown; + } + + public Y getEntity() + { + return getBoss().getEntity(); + } + + public T getBoss() + { + return _creature; + } + + public Location getLocation() + { + return getEntity().getLocation(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventArena.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventArena.java new file mode 100644 index 000000000..3169e9532 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventArena.java @@ -0,0 +1,44 @@ +package mineplex.game.clans.clans.worldevent.api; + +import org.bukkit.Location; + +import mineplex.core.common.util.UtilMath; + +public class EventArena +{ + private final Location _centerLocation; + private final double _radius; + private final double _radiusSquared; + + public EventArena(Location center, double radius) + { + _centerLocation = center; + _radius = radius; + _radiusSquared = Math.pow(radius, 2); + } + + public Location getCenterLocation() + { + return _centerLocation; + } + + public double getRadius() + { + return _radius; + } + + public double getRadiusSquared() + { + return _radiusSquared; + } + + public boolean isInArena(Location checkLocation, boolean flat) + { + if (flat) + { + return UtilMath.offset2dSquared(checkLocation, _centerLocation) <= _radiusSquared; + } + + return UtilMath.offsetSquared(checkLocation, _centerLocation) <= _radiusSquared; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreature.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreature.java new file mode 100644 index 000000000..bf5bf05d9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreature.java @@ -0,0 +1,410 @@ +package mineplex.game.clans.clans.worldevent.api; + +import java.util.UUID; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseInsentient; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.world.ChunkUnloadEvent; + +public abstract class EventCreature implements Listener +{ + private static final boolean DEBUG_MODE = true; + private static final long TELEPORT_HOME_WARMUP = 5000; + private static final long HEALTH_REGEN_COOLDOWN = 1500; + private static final long SAFE_TO_HEALTH_REGEN_COOLDOWN = 15000; + private static final double HEALTH_PER_REGEN = 1.5; + + private WorldEvent _event; + + // Spawn Data + private T _entity; + private Class _entityClass; + private Location _spawnLocation, _lastLocation; + + // Creature Data + private String _name; + private String _displayName; + private boolean _useName; + private double _health; + private double _maxHealth; + private boolean _showHealthName; + private long _teleportHome; + private double _walkRange; + private boolean _healthRegen; + + // Fight Data + private long _lastDamaged; + private UUID _lastDamager; + private long _lastRegen; + + public EventCreature(WorldEvent event, Location spawnLocation, String name, boolean useName, double health, double walkRange, boolean healthRegen, Class entityClass) + { + _event = event; + + _entityClass = entityClass; + _spawnLocation = spawnLocation; + + _name = name; + _displayName = name; + _useName = useName; + _health = health; + _maxHealth = health; + _showHealthName = true; + _teleportHome = -1L; + _walkRange = walkRange; + _healthRegen = healthRegen; + } + + public double getDifficulty() + { + return getEvent().getDifficulty(); + } + + protected void spawnEntity() + { + Location spawnLocation = _entity == null ? _spawnLocation : _entity.getLocation(); + T entity = _spawnLocation.getWorld().spawn(spawnLocation, getEntityClass()); + + setEntity(entity); + updateEntityHealth(); + entity.setRemoveWhenFarAway(false); + spawnCustom(); + updateName(); + } + + protected abstract void spawnCustom(); + + protected void updateEntityHealth() + { + _entity.setMaxHealth(500d); + _entity.setHealth(500d); + } + + protected void updateName() + { + String name = _displayName; + + if (_showHealthName) + { + String healthString = (int) _health + "/" + (int) _maxHealth; + double per =_health / _maxHealth; + if (per > 0.5) healthString = C.cGreen + healthString; + if (per > 0.2) healthString = C.cYellow + healthString; + else healthString = C.cRed + healthString; + + name += " " + C.cWhite + "(" + healthString + C.cWhite + ")"; + } + + DisguiseBase disguise = getEvent().getDisguiseManager().getActiveDisguise(getEntity()); + + if (disguise != null && disguise instanceof DisguiseInsentient) + { + ((DisguiseInsentient) disguise).setName(name); + ((DisguiseInsentient) disguise).setCustomNameVisible(_useName); + } + + _entity.setCustomName(name); + _entity.setCustomNameVisible(_useName); + } + + public void remove() + { + remove(true); + } + + public void remove(boolean removeFromEvent) + { + if (_entity != null) + { + if (getHealth() > 0) + { + _entity.remove(); + } + else + { + _entity.setHealth(0); + _entity.setCustomName(""); + _entity.setCustomNameVisible(false); + } + } + + if (removeFromEvent) + { + _event.removeCreature(this); + } + } + + protected final void die() + { + dieCustom(); + remove(); + } + + public abstract void dieCustom(); + + public WorldEvent getEvent() + { + return _event; + } + + public void setEvent(WorldEvent event) + { + _event = event; + } + + public T getEntity() + { + return _entity; + } + + public void setEntity(T entity) + { + if (_entity != null) _entity.remove(); + + _entity = entity; + } + + public Class getEntityClass() + { + return _entityClass; + } + + public void setEntityClass(Class clazz) + { + _entityClass = clazz; + } + + public double getHealthPercent() + { + return getHealth() / getMaxHealth(); + } + + public Location getSpawnLocation() + { + return _spawnLocation; + } + + public Location getLastKnownLocation() + { + return _lastLocation; + } + + public void setSpawnLocation(Location spawnLocation) + { + _spawnLocation = spawnLocation; + } + + public String getDisplayName() + { + return _displayName; + } + + public String getName() + { + return _name; + } + + public void setName(String name) + { + _displayName = name == null ? _name : name; + updateName(); + } + + public boolean isUseName() + { + return _useName; + } + + public void setUseName(boolean useName) + { + _useName = useName; + updateName(); + } + + public void applyDamage(double damage) + { + setHealth(getHealth() - damage); + } + + public void applyRegen(double regen) + { + setHealth(getHealth() + regen); + } + + public double getHealth() + { + return _health; + } + + public void setHealth(double health) + { + _health = Math.min(health, getMaxHealth()); + + if (_health <= 0) + { + die(); + } + else + { + updateName(); + } + } + + public double getMaxHealth() + { + return _maxHealth; + } + + public void setMaxHealth(double maxHealth) + { + _maxHealth = maxHealth; + } + + public void setShowHealthName(boolean showHealthName) + { + _showHealthName = showHealthName; + updateName(); + } + + /** + * Event listeners + */ + + @EventHandler + public void onChunkUnload(ChunkUnloadEvent event) + { + if (_entity != null && _entity.getLocation().getChunk().equals(event.getChunk())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + if (_entity == null || _entity.isDead() || !_entity.isValid()) + { + if (DEBUG_MODE) + { + System.out.println("Respawning " + getName() + " because it is null or dead"); + } + spawnEntity(); + } + + if (_healthRegen && getHealth() < getMaxHealth() && UtilTime.elapsed(_lastDamaged, SAFE_TO_HEALTH_REGEN_COOLDOWN) && UtilTime.elapsed(_lastRegen, HEALTH_REGEN_COOLDOWN)) + { + _lastRegen = System.currentTimeMillis(); + applyRegen(HEALTH_PER_REGEN); + } + + if (_walkRange != -1 && UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > _walkRange) + { + if (_teleportHome != -1 && System.currentTimeMillis() >= _teleportHome) + { + _entity.teleport(_spawnLocation); + _teleportHome = -1; + } + else + { + _entity.setVelocity(UtilAlg.getTrajectory(_entity.getLocation(), _spawnLocation).normalize().multiply(2)); + if (_teleportHome == -1) + { + _teleportHome = System.currentTimeMillis() + TELEPORT_HOME_WARMUP; + } + } + } + else + { + if (_teleportHome != -1) + { + _teleportHome = -1; + } + } + + _lastLocation = _entity.getLocation(); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onDamage(CustomDamageEvent event) + { + if (_entity == null) + { + return; + } + + if (!event.GetDamageeEntity().equals(_entity)) + { + return; + } + + updateEntityHealth(); + + applyDamage(event.GetDamage()); + updateName(); + + _event.updateLastActive(); + } + + @EventHandler + public void damageType(CustomDamageEvent event) + { + if (_entity == null) + { + return; + } + + if (!event.GetDamageeEntity().equals(_entity)) + { + return; + } + + DamageCause cause = event.GetCause(); + + if (cause == DamageCause.FALL && !getEvent().getCondition().HasCondition(_entity, ConditionType.FALLING, null)) + { + event.SetCancelled("Cancel"); + } + + if (cause == DamageCause.DROWNING || cause == DamageCause.SUFFOCATION) + { + event.SetCancelled("Cancel"); + } + } + + @EventHandler + public void cancelCombust(EntityCombustEvent event) + { + if (_entity == null) + { + return; + } + + if (!event.getEntity().equals(_entity)) + { + return; + } + + event.setCancelled(true); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreatureDeathEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreatureDeathEvent.java new file mode 100644 index 000000000..8141b4745 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreatureDeathEvent.java @@ -0,0 +1,31 @@ +package mineplex.game.clans.clans.worldevent.api; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class EventCreatureDeathEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final EventCreature _creature; + + public EventCreatureDeathEvent(EventCreature creature) + { + _creature = creature; + } + + public EventCreature getCreature() + { + return _creature; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventState.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventState.java new file mode 100644 index 000000000..981470e88 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventState.java @@ -0,0 +1,8 @@ +package mineplex.game.clans.clans.worldevent.api; + +public enum EventState +{ + LOADING, + LIVE, + DEAD +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java new file mode 100644 index 000000000..b3b8bf00a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java @@ -0,0 +1,325 @@ + package mineplex.game.clans.clans.worldevent.api; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; + +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.blockrestore.BlockRestoreMap; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; + +public abstract class WorldEvent implements Listener, ScoreboardElement +{ + // 20 Minutes + private static final int ACTIVE_TIMEOUT = 1200000; + private static final int LOADING_TIMEOUT = 300000; + + private DamageManager _damageManager; + private ConditionManager _conditionManager; + private DisguiseManager _disguiseManager; + private ProjectileManager _projectileManager; + + private String _name; + private EventState _state; + private EventArena _arena; + private Random _random; + private long _timeStarted; + private long _lastActive; + private boolean _announceStart; + + // Creatures + private List> _creatures; + // Block Restore + private BlockRestoreMap _blockRestoreMap; + private double _difficulty = 1; + + public WorldEvent(String name, Location centerLocation, double radius, boolean announceStart, DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager) + { + _disguiseManager = disguiseManager; + _projectileManager = projectileManager; + _damageManager = damageManager; + _conditionManager = conditionManager; + + _name = name; + _state = EventState.LOADING; + _arena = new EventArena(centerLocation, radius); + _random = new Random(); + _announceStart = announceStart; + + _creatures = new ArrayList<>(); + _blockRestoreMap = blockRestore.createMap(); + } + + public String getName() + { + return _name; + } + + public void setName(String name) + { + _name = name; + } + + public EventArena getEventArena() + { + return _arena; + } + + public EventState getState() + { + return _state; + } + + protected void setState(EventState state) + { + _state = state; + } + + public double getDifficulty() + { + return _difficulty; + } + + public void setDifficulty(double difficulty) + { + _difficulty = difficulty; + } + + public Location getCenterLocation() + { + return _arena.getCenterLocation(); + } + + public List> getCreatures() + { + return _creatures; + } + + public void registerCreature(EventCreature creature) + { + UtilServer.getServer().getPluginManager().registerEvents(creature, UtilServer.getPlugin()); + _creatures.add(creature); + } + + public void removeCreature(EventCreature creature) + { + Bukkit.getPluginManager().callEvent(new EventCreatureDeathEvent(creature)); + HandlerList.unregisterAll(creature); + _creatures.remove(creature); + } + + public void clearCreatures() + { + for (EventCreature creature : _creatures) + { + creature.remove(false); + HandlerList.unregisterAll(creature); + } + + _creatures.clear(); + } + + public long getTimeRunning() + { + return System.currentTimeMillis() - _timeStarted; + } + + public long getLastActive() + { + return _lastActive; + } + + public void updateLastActive() + { + _lastActive = System.currentTimeMillis(); + } + + public boolean isInBounds(Location location, boolean flat) + { + return _arena.isInArena(location, flat); + } + + protected Random getRandom() + { + return _random; + } + + public DisguiseManager getDisguiseManager() + { + return _disguiseManager; + } + + public ProjectileManager getProjectileManager() + { + return _projectileManager; + } + + public DamageManager getDamageManager() + { + return _damageManager; + } + + public ConditionManager getCondition() + { + return _conditionManager; + } + + protected BlockRestoreMap getBlockRestoreMap() + { + return _blockRestoreMap; + } + + public void setBlock(Block block, Material material) + { + setBlock(block, material, (byte) 0); + } + + @SuppressWarnings("deprecation") + public void setBlock(Block block, Material material, byte data) + { + setBlock(block, material.getId(), data); + } + + public void setBlock(Block block, int id, byte data) + { + _blockRestoreMap.set(block, id, data); + } + + public void restoreBlocks() + { + _blockRestoreMap.restore(); + } + + public final void start() + { + _timeStarted = System.currentTimeMillis(); + _lastActive = System.currentTimeMillis(); + if (_announceStart) + { + announceStart(); + } + setState(EventState.LIVE); + customStart(); + Bukkit.getPluginManager().registerEvents(this, UtilServer.getPlugin()); + } + + public void announceStart() + { + UtilTextMiddle.display(C.cGreen + getName(), UtilWorld.locToStrClean(getCenterLocation()), 10, 100, 40); + + UtilServer.broadcast(F.main("Event", F.elem(getName()) + " has started at coordinates " + F.elem(UtilWorld.locToStrClean(getCenterLocation())))); + } + + protected abstract void customStart(); + + protected abstract void customTick(); + + public final void cleanup() + { + clearCreatures(); + restoreBlocks(); + customCleanup(); + } + + public abstract void customCleanup(); + + public final void stop() + { + cleanup(); + setState(EventState.DEAD); + customStop(); + HandlerList.unregisterAll(this); + } + + protected abstract void customStop(); + + public int getRandomRange(int min, int max) + { + return min + _random.nextInt(UtilMath.clamp(max - min, min, max)); + } + + public void announceMessage(String message) + { + UtilServer.broadcast(F.main("Event", F.elem(getName()) + ": " + message)); + } + + public void sendMessage(Player player, String message) + { + UtilPlayer.message(player, F.main("Event", F.elem(getName()) + ": " + message)); + } + + @EventHandler + public void tick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + customTick(); + } + + @EventHandler + public void endInactive(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + long diff = System.currentTimeMillis() - getLastActive(); + if (diff > ACTIVE_TIMEOUT) + { + setState(EventState.DEAD); + } + } + + @EventHandler + public void prepareTimeout(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + if (getState() != EventState.LOADING) + { + return; + } + + // Event was preparing for more than 5 minutes + if (getTimeRunning() > LOADING_TIMEOUT) + { + stop(); + } + } + + @Override + public List getLines(ScoreboardManager manager, Player player, List out) + { + return null; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java new file mode 100644 index 000000000..aefbff5f2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java @@ -0,0 +1,61 @@ +package mineplex.game.clans.clans.worldevent.boss; + +import java.util.List; +import java.util.stream.Collectors; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventState; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; + +public abstract class BossWorldEvent extends WorldEvent +{ + private static final double TELEPORT_PAD_RANGE = 1.5; + + private List _teleportFrom; + private List _teleportTo; + + public BossWorldEvent(String name, Location centerLocation, double radius, List teleportFrom, List teleportTo, DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager) + { + super(name, centerLocation, radius, true, disguiseManager, projectileManager, damageManager, blockRestore, conditionManager); + + _teleportFrom = teleportFrom.stream().map(vec -> vec.toLocation(centerLocation.getWorld())).collect(Collectors.toList()); + _teleportTo = teleportFrom.stream().map(vec -> vec.toLocation(centerLocation.getWorld())).collect(Collectors.toList()); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (getState() != EventState.LIVE) + { + return; + } + if (_teleportFrom.isEmpty() || _teleportTo.isEmpty()) + { + return; + } + for (Location from : _teleportFrom) + { + for (Player player : UtilPlayer.getInRadius(from, TELEPORT_PAD_RANGE).keySet()) + { + player.teleport(_teleportTo.get(getRandom().nextInt(_teleportTo.size()))); + sendMessage(player, "You have teleported inside the arena!"); + } + } + } +} \ No newline at end of file From 150f1d1de92b38e5665a7d09a850f80001d9bdcf Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 23 Apr 2017 22:50:14 -0400 Subject: [PATCH 106/283] Add implementation for managing world events --- .../clans/worldevent/WorldEventManager.java | 85 ++++--------------- .../clans/worldevent/WorldEventType.java | 4 +- .../clans/worldevent/api/EventState.java | 3 +- .../clans/worldevent/api/WorldEvent.java | 16 +++- .../clans/worldevent/boss/BossDeathEvent.java | 39 +++++++++ .../clans/worldevent/boss/BossWorldEvent.java | 33 ++++++- 6 files changed, 106 insertions(+), 74 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossDeathEvent.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index d077e32ef..b3f0125e0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -5,10 +5,16 @@ import java.util.LinkedList; import java.util.List; import java.util.Random; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.collect.Lists; + import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.DisguiseManager; import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; @@ -18,28 +24,15 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.regions.ClansRegions; +import mineplex.game.clans.clans.worldevent.api.EventState; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; import mineplex.game.clans.clans.worldevent.command.WorldEventCommand; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; -import mineplex.minecraft.game.core.boss.EventCreatureDeathEvent; -import mineplex.minecraft.game.core.boss.EventState; -import mineplex.minecraft.game.core.boss.WorldEvent; -import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; -import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; -import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; import mineplex.minecraft.game.core.damage.DamageManager; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.plugin.java.JavaPlugin; - -import com.google.common.collect.Lists; - public class WorldEventManager extends MiniPlugin implements ScoreboardElement { - private static final double ARENA_RADIUS = 40; private final List _runningEvents; private Random _random; @@ -63,7 +56,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement _damageManager = damageManager; _lootManager = lootManager; _blockRestore = blockRestore; - _runningEvents = new LinkedList(); + _runningEvents = new LinkedList<>(); _skillFactory = skillFactory; @@ -75,24 +68,21 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement addCommand(new WorldEventCommand(this)); } - // PS: This never gets called @Override public void disable() { for (WorldEvent event : _runningEvents) { - event.cancel(); + event.stop(true); } + _runningEvents.clear(); } public boolean isInEvent(Location location) { for (WorldEvent event : _runningEvents) { - if (UtilMath.offset2d(location, event.getCenterLocation()) <= ARENA_RADIUS) - { - return true; - } + event.isInBounds(location, true); } return false; @@ -103,29 +93,9 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement { if (event.GetSkillName().equalsIgnoreCase("Ice Prison")) { - for (WorldEvent e : _runningEvents) + if (isInEvent(event.GetPlayer().getLocation())) { - if (isInEvent(event.GetPlayer().getLocation())) - { - event.SetCancelled(true); - } - } - } - } - - //TODO: Move this into the appropriate world events - @EventHandler - public void onBossDeath(EventCreatureDeathEvent event) - { - if (event.getCreature() instanceof GolemCreature || event.getCreature() instanceof SkeletonCreature || event.getCreature() instanceof SpiderCreature) - { - Location drop = event.getCreature().getLastKnownLocation(); - if (drop != null) - { - runSyncLater(() -> - { - ClansManager.getInstance().getLootManager().dropRare(drop); - }, 20 * 2); + event.SetCancelled(true); } } } @@ -138,25 +108,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return; } - boolean removed = _runningEvents.removeIf(e -> e.getState() == EventState.COMPLETE); - Iterator iterator = _runningEvents.iterator(); - while (iterator.hasNext()) - { - WorldEvent worldEvent = iterator.next(); - if (worldEvent.getState() == EventState.COMPLETE || worldEvent.getState() == EventState.CANCELLED) - { - HandlerList.unregisterAll(worldEvent); - iterator.remove(); - - // If the event was cancelled, cleanup was already done. - if (worldEvent.getState() == EventState.COMPLETE) - { - worldEvent.cleanup(); - } - - removed = true; - } - } + boolean removed = _runningEvents.removeIf(e -> e.getState() == EventState.STOPPED); if (removed && _runningEvents.size() == 0) { @@ -213,9 +165,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement throw new RuntimeException("WorldEvent may not be null"); } - event.loadMap(); event.start(); - getPlugin().getServer().getPluginManager().registerEvents(event, getPlugin()); _runningEvents.add(event); } @@ -253,8 +203,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement while (iterator.hasNext()) { WorldEvent event = iterator.next(); - if (event.getState() != EventState.COMPLETE) event.cancel(); - HandlerList.unregisterAll(event); + event.stop(true); iterator.remove(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index d3e39862e..790772d5c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -4,8 +4,8 @@ import java.lang.reflect.Constructor; import org.bukkit.Location; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; -import mineplex.minecraft.game.core.boss.WorldEvent; import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; import mineplex.minecraft.game.core.boss.skeletonking.SkeletonBoss; @@ -77,4 +77,4 @@ public enum WorldEventType { return this._name; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventState.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventState.java index 981470e88..bdee54454 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventState.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventState.java @@ -4,5 +4,6 @@ public enum EventState { LOADING, LIVE, - DEAD + STOPPED, + REMOVED } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java index b3b8bf00a..5db224cbd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java @@ -247,9 +247,21 @@ public abstract class WorldEvent implements Listener, ScoreboardElement public abstract void customCleanup(); public final void stop() + { + stop(false); + } + + public final void stop(boolean onDisable) { cleanup(); - setState(EventState.DEAD); + if (onDisable) + { + setState(EventState.REMOVED); + } + else + { + setState(EventState.STOPPED); + } customStop(); HandlerList.unregisterAll(this); } @@ -293,7 +305,7 @@ public abstract class WorldEvent implements Listener, ScoreboardElement long diff = System.currentTimeMillis() - getLastActive(); if (diff > ACTIVE_TIMEOUT) { - setState(EventState.DEAD); + stop(); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossDeathEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossDeathEvent.java new file mode 100644 index 000000000..cca1ab01c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossDeathEvent.java @@ -0,0 +1,39 @@ +package mineplex.game.clans.clans.worldevent.boss; + +import org.bukkit.Location; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class BossDeathEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final BossWorldEvent _event; + private final Location _deathLocation; + + public BossDeathEvent(BossWorldEvent event, Location location) + { + _event = event; + _deathLocation = location; + } + + public BossWorldEvent getEvent() + { + return _event; + } + + public Location getDeathLocation() + { + return _deathLocation; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java index aefbff5f2..9ccb4739c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java @@ -10,19 +10,25 @@ import org.bukkit.util.Vector; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.DisguiseManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; import mineplex.game.clans.clans.worldevent.api.EventState; import mineplex.game.clans.clans.worldevent.api.WorldEvent; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; -public abstract class BossWorldEvent extends WorldEvent +public abstract class BossWorldEvent> extends WorldEvent { private static final double TELEPORT_PAD_RANGE = 1.5; + private static final long DELAY_TILL_DROP_REWARD = 40; + private T _boss; private List _teleportFrom; private List _teleportTo; @@ -34,6 +40,16 @@ public abstract class BossWorldEvent extends WorldEvent _teleportTo = teleportFrom.stream().map(vec -> vec.toLocation(centerLocation.getWorld())).collect(Collectors.toList()); } + public T getBossCreature() + { + return _boss; + } + + public void setBossCreature(T boss) + { + _boss = boss; + } + @EventHandler public void onUpdate(UpdateEvent event) { @@ -58,4 +74,19 @@ public abstract class BossWorldEvent extends WorldEvent } } } + + @EventHandler + public void onBossDeath(EventCreatureDeathEvent event) + { + if (_boss == null) + { + return; + } + if (event.getCreature().equals(_boss)) + { + Location drop = event.getCreature().getLastKnownLocation(); + UtilServer.CallEvent(new BossDeathEvent(this, drop)); + ClansManager.getInstance().runSyncLater(() -> ClansManager.getInstance().getLootManager().dropRare(drop), DELAY_TILL_DROP_REWARD); + } + } } \ No newline at end of file From 3ea378110c1afa1e20fc348860db2b2f7bba3871 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 23 Apr 2017 22:50:40 -0400 Subject: [PATCH 107/283] Convert nether listener to spawn boss portals with the new boss event system --- .../game/clans/clans/nether/NetherManager.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 80b8bfd38..e102990e2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -52,11 +52,8 @@ import mineplex.game.clans.clans.nether.command.ForceTeleportCommand; import mineplex.game.clans.clans.nether.command.PortalCommand; import mineplex.game.clans.clans.nether.data.ClaimData; import mineplex.game.clans.clans.nether.miniboss.NetherMinibossManager; +import mineplex.game.clans.clans.worldevent.boss.BossDeathEvent; import mineplex.game.clans.spawn.Spawn; -import mineplex.minecraft.game.core.boss.EventCreatureDeathEvent; -import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature; -import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; -import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature; /** * Manager for all nether features @@ -565,11 +562,8 @@ public class NetherManager extends MiniPlugin } @EventHandler - public void onBossDeath(EventCreatureDeathEvent event) + public void onBossDeath(BossDeathEvent event) { - if (event.getCreature() instanceof GolemCreature || event.getCreature() instanceof SkeletonCreature || event.getCreature() instanceof SpiderCreature) - { - spawnBossPortal(event.getCreature().getEvent().getCenterLocation().clone().subtract(0, 1, 0)); - } + spawnBossPortal(event.getEvent().getCenterLocation().clone().subtract(0, 1, 0)); } } \ No newline at end of file From b0297e404ce7cfac9fc81995e763dade48915140 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 23 Apr 2017 22:51:18 -0400 Subject: [PATCH 108/283] Deactivate events lacking implementation --- .../game/clans/clans/worldevent/WorldEventType.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index 790772d5c..6ada84c5e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -6,17 +6,16 @@ import org.bukkit.Location; import mineplex.game.clans.clans.worldevent.api.WorldEvent; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; -import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; -import mineplex.minecraft.game.core.boss.skeletonking.SkeletonBoss; public enum WorldEventType { //SLIME_KING("Slime King", SlimeBoss.class, 30), //KING_OF_THE_HILL("King of The Hill", KingHill.class, 30), //UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30), - IRON_WIZARD("Iron Wizard", GolemBoss.class, 30), + //IRON_WIZARD("Iron Wizard", GolemBoss.class, 30), //BROOD_MOTHER("Brood Mother", SpiderBoss.class, 30), - SKELETON_KING("Skeleton King", SkeletonBoss.class, 30); + //SKELETON_KING("Skeleton King", SkeletonBoss.class, 30) + ; private String _name; private Class _clazz; From a17b0c95bf236163ec96e45ae7be061d21e79938 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 29 Apr 2017 00:26:16 -0400 Subject: [PATCH 109/283] Update existing command and api classes to support new worldevent changes --- .../game/clans/clans/worldevent/api/BossPassive.java | 4 +++- .../game/clans/clans/worldevent/api/EventCreature.java | 2 +- .../game/clans/clans/worldevent/command/ClearCommand.java | 8 +------- .../clans/clans/worldevent/command/RandomCommand.java | 3 +-- .../game/clans/clans/worldevent/command/StartCommand.java | 4 ++-- .../clans/clans/worldevent/command/WorldEventCommand.java | 3 +-- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/BossPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/BossPassive.java index 022d7d103..c2387ea0d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/BossPassive.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/BossPassive.java @@ -5,6 +5,8 @@ import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Listener; +import mineplex.core.common.util.UtilServer; + public abstract class BossPassive, Y extends LivingEntity> implements Listener { private T _creature; @@ -19,7 +21,7 @@ public abstract class BossPassive, Y extends LivingEn { _creature = creature; _cooldown = cooldown; - Bukkit.getPluginManager().registerEvents(this, creature.getEvent().getPlugin()); + Bukkit.getPluginManager().registerEvents(this, UtilServer.getPlugin()); } public abstract boolean isProgressing(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreature.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreature.java index bf5bf05d9..dd11c7b79 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreature.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreature.java @@ -24,7 +24,7 @@ import org.bukkit.event.world.ChunkUnloadEvent; public abstract class EventCreature implements Listener { - private static final boolean DEBUG_MODE = true; + protected static final boolean DEBUG_MODE = true; private static final long TELEPORT_HOME_WARMUP = 5000; private static final long HEALTH_REGEN_COOLDOWN = 1500; private static final long SAFE_TO_HEALTH_REGEN_COOLDOWN = 15000; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java index 4439d2502..58c63968a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java @@ -8,12 +8,6 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.worldevent.WorldEventManager; -/** - * ClearCommand - * - * @author Shaun Bennett - * @since 6/9/2015 - */ public class ClearCommand extends CommandBase { public ClearCommand(WorldEventManager plugin) @@ -27,4 +21,4 @@ public class ClearCommand extends CommandBase Plugin.clearEvents(); UtilPlayer.message(caller, F.main(Plugin.getName(), "All world events cleared!")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java index ef9c08af2..1c74e7e5b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java @@ -8,7 +8,6 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.worldevent.WorldEventManager; import mineplex.game.clans.clans.worldevent.WorldEventType; -import mineplex.minecraft.game.core.boss.WorldEvent; /** * Command for spawning a random world event in the world. @@ -33,4 +32,4 @@ public class RandomCommand extends CommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not start World Event")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java index e95f7fa48..1db7667de 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java @@ -9,7 +9,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.worldevent.WorldEventManager; import mineplex.game.clans.clans.worldevent.WorldEventType; -import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; public class StartCommand extends CommandBase { @@ -56,4 +56,4 @@ public class StartCommand extends CommandBase } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java index e52b389b3..02b3974cf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java @@ -26,5 +26,4 @@ public class WorldEventCommand extends MultiCommandBase UtilPlayer.message(caller, F.help("/" + _aliasUsed + " clear", "Clears all World Events", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/" + _aliasUsed + " random", "Starts a random World Event", Rank.ADMIN)); } -} - +} \ No newline at end of file From 77f13f9b4c329fd2769c828a41f6ee450b2986f3 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 29 Apr 2017 00:27:18 -0400 Subject: [PATCH 110/283] Slightly improve boss worldevent api --- .../game/clans/clans/worldevent/boss/BossDeathEvent.java | 6 +++--- .../game/clans/clans/worldevent/boss/BossWorldEvent.java | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossDeathEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossDeathEvent.java index cca1ab01c..caf9109b3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossDeathEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossDeathEvent.java @@ -8,16 +8,16 @@ public class BossDeathEvent extends Event { private static final HandlerList handlers = new HandlerList(); - private final BossWorldEvent _event; + private final BossWorldEvent _event; private final Location _deathLocation; - public BossDeathEvent(BossWorldEvent event, Location location) + public BossDeathEvent(BossWorldEvent event, Location location) { _event = event; _deathLocation = location; } - public BossWorldEvent getEvent() + public BossWorldEvent getEvent() { return _event; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java index 9ccb4739c..fcc770b43 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java @@ -40,6 +40,8 @@ public abstract class BossWorldEvent> extends WorldEv _teleportTo = teleportFrom.stream().map(vec -> vec.toLocation(centerLocation.getWorld())).collect(Collectors.toList()); } + public abstract String getDeathMessage(); + public T getBossCreature() { return _boss; From 4e58fa1e6c27d0fdfec071e0f121c5c20930c3fd Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 29 Apr 2017 00:27:46 -0400 Subject: [PATCH 111/283] Implement an arena manager for the specific bosses on the map --- .../clans/worldevent/WorldEventManager.java | 9 ++++ .../boss/BossArenaLocationFinder.java | 46 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossArenaLocationFinder.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index b3f0125e0..b3b3c5988 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -16,6 +16,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilWorld; import mineplex.core.disguise.DisguiseManager; import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; @@ -26,6 +27,7 @@ import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.worldevent.api.EventState; import mineplex.game.clans.clans.worldevent.api.WorldEvent; +import mineplex.game.clans.clans.worldevent.boss.BossArenaLocationFinder; import mineplex.game.clans.clans.worldevent.command.WorldEventCommand; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; @@ -38,6 +40,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement private Random _random; private ClansManager _clansManager; private EventTerrainFinder _terrainFinder; + private BossArenaLocationFinder _bossFinder; private DamageManager _damageManager; private LootManager _lootManager; private BlockRestore _blockRestore; @@ -52,6 +55,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement _random = new Random(); _terrainFinder = new EventTerrainFinder(clansManager); + _bossFinder = new BossArenaLocationFinder(UtilWorld.getWorld("world")); _clansManager = clansManager; _damageManager = damageManager; _lootManager = lootManager; @@ -230,6 +234,11 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return _terrainFinder; } + public BossArenaLocationFinder getBossArenaLocationFinder() + { + return _bossFinder; + } + private void updateNextEventTime() { // 45 Minutes + (0 - 15 Minutes) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossArenaLocationFinder.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossArenaLocationFinder.java new file mode 100644 index 000000000..2ed0146e7 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossArenaLocationFinder.java @@ -0,0 +1,46 @@ +package mineplex.game.clans.clans.worldevent.boss; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.util.Vector; + +import mineplex.core.common.Pair; + +public class BossArenaLocationFinder +{ + private World _world; + + public BossArenaLocationFinder(World world) + { + _world = world; + } + + public Location getIronWizardCenter() + { + return new Location(_world, 0, 0, 0); + } + + public Pair, List> getIronWizardPads() + { + List in = new ArrayList<>(); + List out = new ArrayList<>(); + + return Pair.create(in, out); + } + + public Location getSkeletonKingCenter() + { + return new Location(_world, 0, 0, 0); + } + + public Pair, List> getSkeletonKingPads() + { + List in = new ArrayList<>(); + List out = new ArrayList<>(); + + return Pair.create(in, out); + } +} \ No newline at end of file From 03149fc49b3d5caa239bb5910036dd1d0a388249 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 29 Apr 2017 00:28:22 -0400 Subject: [PATCH 112/283] Implement the iron wizard boss with tidied up code and the new world event api --- .../worldevent/boss/ironwizard/GolemBoss.java | 47 ++ .../boss/ironwizard/GolemCreature.java | 596 ++++++++++++++++++ .../ironwizard/abilities/BlockHailBlock.java | 88 +++ .../ironwizard/abilities/GolemBlockHail.java | 475 ++++++++++++++ .../ironwizard/abilities/GolemBlockShot.java | 442 +++++++++++++ .../ironwizard/abilities/GolemCaveIn.java | 336 ++++++++++ .../abilities/GolemDeadlyTremor.java | 89 +++ .../ironwizard/abilities/GolemEarthquake.java | 168 +++++ .../abilities/GolemExplodingAura.java | 400 ++++++++++++ .../abilities/GolemExplosiveBlock.java | 590 +++++++++++++++++ .../ironwizard/abilities/GolemIronHook.java | 163 +++++ .../abilities/GolemMeleeAttack.java | 90 +++ .../ironwizard/abilities/GolemRumble.java | 238 +++++++ .../ironwizard/abilities/GolemRupture.java | 367 +++++++++++ .../boss/ironwizard/abilities/GolemSlam.java | 271 ++++++++ .../boss/ironwizard/abilities/GolemSpike.java | 104 +++ .../abilities/GolemWallExplode.java | 419 ++++++++++++ .../ironwizard/abilities/GroundSpike.java | 122 ++++ .../boss/ironwizard/abilities/IronHook.java | 54 ++ 19 files changed, 5059 insertions(+) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemCreature.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/BlockHailBlock.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemBlockHail.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemBlockShot.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemCaveIn.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemDeadlyTremor.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemEarthquake.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemExplodingAura.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemExplosiveBlock.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemIronHook.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemMeleeAttack.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemRumble.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemRupture.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemSlam.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemSpike.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemWallExplode.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GroundSpike.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/IronHook.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java new file mode 100644 index 000000000..23c90c70f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java @@ -0,0 +1,47 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard; + +import org.bukkit.Bukkit; +import org.bukkit.Location; + +import mineplex.core.common.util.F; +import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.clans.worldevent.boss.BossWorldEvent; + +public class GolemBoss extends BossWorldEvent +{ + public GolemBoss(WorldEventManager manager) + { + super("Iron Wizard", manager.getBossArenaLocationFinder().getIronWizardCenter(), 30, manager.getBossArenaLocationFinder().getIronWizardPads().getLeft(), manager.getBossArenaLocationFinder().getIronWizardPads().getRight(), manager.getDisguiseManager(), manager.getClans().getProjectile(), manager.getClans().getDamageManager(), manager.getBlockRestore(), manager.getClans().getCondition()); + } + + @Override + protected void customStart() + { + Bukkit.broadcastMessage(F.main(getName(), "The mighty " + getName() + " challenges you to face him!")); + spawnGolem(getCenterLocation()); + announceStart(); + } + + @Override + public String getDeathMessage() + { + return F.main(getName(), "The mighty " + getName() + " has fallen!"); + } + + private GolemCreature spawnGolem(Location location) + { + GolemCreature golemCreature = new GolemCreature(this, location, 3000); + registerCreature(golemCreature); + setBossCreature(golemCreature); + return golemCreature; + } + + @Override + protected void customTick() {} + + @Override + public void customCleanup() {} + + @Override + protected void customStop() {} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemCreature.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemCreature.java new file mode 100644 index 000000000..540c7cea0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemCreature.java @@ -0,0 +1,596 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Random; + +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +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.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities.GolemBlockHail; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities.GolemBlockShot; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities.GolemDeadlyTremor; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities.GolemEarthquake; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities.GolemExplodingAura; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities.GolemIronHook; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities.GolemMeleeAttack; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities.GolemRupture; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities.GolemSlam; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities.GolemSpike; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class GolemCreature extends EventCreature +{ + private int _lastAbility; + private long _lastWalked; + private Location _standing; + private long _spawnDelay = System.currentTimeMillis(); + private long _reverseWalk; + private Map>, Class[]> _preferredCombos = new HashMap<>(); + private Class> _lastAttack; + private boolean _usedFinalAttack; + private List> _currentAbilities = new ArrayList<>(); + private double _canDeadlyTremor = 225; + private Vector _afkWalk = new Vector(); + private long _lastSlam; + + public GolemCreature(GolemBoss boss, Location location, double maxHealth) + { + super(boss, location, "Iron Wizard", true, 3000, 30, true, IronGolem.class); + + spawnEntity(); + + _preferredCombos.put(GolemEarthquake.class, new Class[] + { + GolemBlockHail.class, GolemRupture.class + }); + _preferredCombos.put(GolemMeleeAttack.class, new Class[] + { + GolemEarthquake.class, GolemRupture.class + }); + _preferredCombos.put(GolemDeadlyTremor.class, new Class[] + { + GolemMeleeAttack.class + }); + _preferredCombos.put(GolemBlockShot.class, new Class[] + { + GolemEarthquake.class + }); + _preferredCombos.put(GolemRupture.class, new Class[] + { + GolemBlockShot.class + }); + _preferredCombos.put(GolemBlockHail.class, new Class[] + { + GolemDeadlyTremor.class + }); + } + + private boolean hasFurther(Map distances, double range) + { + for (Player player : distances.keySet()) + { + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + Double dist = distances.get(player); + if (dist >= range) + { + return true; + } + } + + return false; + } + + @Override + protected void spawnCustom() + { + UtilEnt.vegetate(getEntity()); + _standing = getEntity().getLocation(); + } + + @SuppressWarnings("unchecked") + @EventHandler + public void abilityTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (!UtilTime.elapsed(_spawnDelay, 5000)) + { + _standing = getEntity().getLocation(); + return; + } + + Iterator> itel = _currentAbilities.iterator(); + boolean canDoNew = _currentAbilities.size() < 3; + + while (itel.hasNext()) + { + BossAbility ability = itel.next(); + + if (ability.hasFinished()) + { + itel.remove(); + ability.setFinished(); + _lastAbility = 20; + + HandlerList.unregisterAll(ability); + System.out.print("Unregistered golem ability " + ability.getClass().getSimpleName()); + } + else if (!ability.inProgress()) + { + canDoNew = false; + } + } + + if (_lastAbility-- <= 0 && canDoNew && UtilBlock.solid(getEntity().getLocation().getBlock().getRelative(BlockFace.DOWN))) + { + Map>, Integer> weight = new HashMap<>(); + Map dist = new HashMap<>(); + + for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true)) + { + if (player.hasLineOfSight(getEntity())) + { + dist.put(player, player.getLocation().distance(getEntity().getLocation())); + } + } + + if (!dist.isEmpty()) + { + double hp = getHealthPercent(); + + { // Melee + List players = getPlayers(dist, UtilMath.r(10) == 0 ? 4 : 3); + + if (!players.isEmpty()) + { + if (players.size() >= 4) + { + weight.put(GolemEarthquake.class, 999); + } + else + { + weight.put(GolemMeleeAttack.class, 999); + } + } + } + + if (hasFurther(dist, 15)) + { // Iron Hook + weight.put(GolemIronHook.class, 6); //6 + } + + if (hp < 0.7) + { // Earthquake + List players = getPlayers(dist, 10); + + double score = 0; + + for (Player player : players) + { + score += (8 - dist.get(player)) / 2; + } + + if (players.size() >= 3) + { + score += 7; + } + + if (score > 0) + { + weight.put(GolemEarthquake.class, (int) Math.ceil(score)); + } + } + + { // Wall explode + if (!getPlayers(dist, 20).isEmpty() && getPlayers(dist, 4).isEmpty()) + { + weight.put(GolemSpike.class, 8); + } + } + + { // Block Shot + List players = getPlayers(dist, 30); + + for (Player player : players) + { + if (dist.get(player) > 4) + { + weight.put(GolemBlockShot.class, 6); + break; + } + } + } + + { // Rupture + List players = getPlayers(dist, 30); + + if (!players.isEmpty()) + { + weight.put(GolemRupture.class, (int) Math.min(5, dist.get(players.get(0)))); + } + } + + { // Slam + List players = getPlayers(dist, 30); + + if (!players.isEmpty() && UtilTime.elapsed(_lastSlam, 20000)) + { + weight.put(GolemSlam.class, 6); + } + } + + if (_canDeadlyTremor <= 0) // Deadly Tremor + { + List players = getPlayers(dist, 80); + + for (BossAbility ability : _currentAbilities) + { + if (ability instanceof GolemExplodingAura) + { + players.clear(); + } + } + + if (!players.isEmpty()) + { + weight.put(GolemDeadlyTremor.class, (int) 30); + } + } + + {// Block Hail + List players = getPlayers(dist, 30); + + if (!players.isEmpty()) + { + int we = _lastAttack == GolemEarthquake.class ? 20 : UtilMath.r(15) - 2; + + if (we > 0) + { + weight.put(GolemBlockHail.class, we); + } + } + } + + if (!_usedFinalAttack && getHealth() < 90) + { + _usedFinalAttack = true; + weight.clear(); + + weight.put(GolemExplodingAura.class, 999); + } + + if (_lastAttack != null && _preferredCombos.containsKey(_lastAttack)) + { + weight.remove(_lastAttack); + + for (Class c : _preferredCombos.get(_lastAttack)) + { + if (weight.containsKey(c)) + { + weight.put((Class>)c, weight.get(c) * 4); + } + } + } + + for (BossAbility ability : _currentAbilities) + { + weight.remove(ability.getClass()); + } + + BossAbility ability = null; + + if (!weight.isEmpty()) + { + int i = 0; + + for (Integer entry : weight.values()) + { + i += entry; + } + + for (int a = 0; a < 10; a++) + { + int luckyNumber = UtilMath.r(i); + + for (Entry>, Integer> entry : weight.entrySet()) + { + luckyNumber -= entry.getValue(); + + if (luckyNumber <= 0) + { + try + { + ability = entry.getKey().getConstructor(GolemCreature.class).newInstance(this); + + if (ability.getTarget() == null) + { + ability = null; + } + else + { + break; + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + break; + } + } + } + } + + if (ability != null && ability.getTarget() != null) + { + _lastAttack = (Class>) ability.getClass(); + + if (ability instanceof GolemDeadlyTremor) + { + _canDeadlyTremor = 225; + } + else if (ability instanceof GolemSlam) + { + _lastSlam = System.currentTimeMillis(); + } + + Bukkit.getPluginManager().registerEvents(ability, UtilServer.getPlugin()); + + if (DEBUG_MODE) + { + System.out.print("Golem boss is using " + ability.getClass().getSimpleName()); + } + + _currentAbilities.add(ability); + } + + _lastAbility = 10; + } + + _lastAttack = null; + } + + boolean canMove = true; + + for (BossAbility ability : _currentAbilities) + { + try + { + ability.tick(); + } + catch (Exception e) + { + e.printStackTrace(); //Keeps the boss from getting stuck if one of the moves throws an error in progression + } + + if (!ability.canMove()) + { + canMove = false; + } + } + + if (canMove) + { + Player target = null; + double dist = 0; + + for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true)) + { + if (!player.hasLineOfSight(getEntity())) + { + continue; + } + + double d = player.getLocation().distance(getEntity().getLocation()); + + if (d > 1.5 && (d < 7 || d > 15) && (target == null || (d < 50 && dist > d))) + { + target = player; + dist = d; + } + } + + Vector vec = null; + boolean superWalk = false; + + if (target != null) + { + vec = target.getLocation().subtract(getEntity().getLocation()).toVector(); + vec.setY(getEntity().getLocation().getY()); + + double len = vec.length(); + + vec.setX(vec.getX() * (UtilMath.random.nextDouble() / 3D)); + vec.setZ(vec.getZ() * (UtilMath.random.nextDouble() / 3D)); + + vec.multiply(len); + + if (target != null && dist < 8) + { + vec.multiply(-1); + superWalk = true; + } + + if (!UtilAlg.HasSight(getEntity().getLocation(), + getEntity().getLocation().add(vec.clone().normalize().multiply(2)))) + { + _reverseWalk = System.currentTimeMillis(); + } + + if (!UtilTime.elapsed(_reverseWalk, 4000)) + { + vec.multiply(-1); + } + + } + else if (!UtilTime.elapsed(_lastWalked, 7000)) + { + vec = _afkWalk; + } + else if (UtilTime.elapsed(_lastWalked, 12000)) + { + _afkWalk = new Vector(); + + for (int i = 0; i < 10; i++) + { + Vector vector = new Vector(UtilMath.r(20) - 10, 0, UtilMath.r(20) - 10); + + if (UtilAlg.HasSight(getEntity().getLocation(), + getEntity().getLocation().add(vector.clone().normalize().multiply(2)))) + { + vec = _afkWalk = vector; + break; + } + } + + _lastWalked = System.currentTimeMillis(); + } + + if (vec != null) + { + { + UtilEnt.CreatureMoveFast(getEntity(), getEntity().getLocation().add(vec), + (target != null ? 1.8F : 1.1F) + (superWalk ? 0.4F : 0)); + } + } + + _standing = getEntity().getLocation(); + } + else + { + Location l = getEntity().getLocation(); + + _standing.setYaw(l.getYaw()); + _standing.setPitch(l.getPitch()); + _standing.setY(l.getY()); + + getEntity().teleport(_standing); + } + } + + private List getPlayers(final Map map, double maxDist) + { + List list = new ArrayList(); + + for (Player p : map.keySet()) + { + if (map.get(p) <= maxDist) + { + list.add(p); + } + } + + Collections.sort(list, (o1, o2) -> + { + return Double.compare(map.get(o2), map.get(o1)); + }); + + return list; + } + + @EventHandler + public void onGolemDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(getEntity())) + { + event.AddKnockback("Heavy Golem", 0.3); + } + } + + @EventHandler + public void onRangedAttack(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(getEntity())) + { + if (event.GetDamageePlayer() != null) + { + if (event.GetProjectile() != null && event.GetProjectile() instanceof Arrow) + { + if (new Random().nextDouble() <= .5) + { + event.SetCancelled("Iron Skin Reflection"); + getEntity().getWorld().playSound(getEntity().getLocation(), Sound.ZOMBIE_METAL, 0.5f, 1.6f); + return; + } + } + + double dist = event.GetDamageePlayer().getLocation().distance(getEntity().getLocation()); + + double maxRange = _usedFinalAttack ? 20 : 45; + + double modifier = (maxRange - dist) / maxRange; + + if (modifier > 0) + { + event.AddMod("Ranged Resistance", 1 - modifier); + } + else + { + event.SetCancelled("Range too far"); + } + } + } + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + for (BossAbility ability : _currentAbilities) + { + ability.setFinished(); + HandlerList.unregisterAll(ability); + } + + _currentAbilities.clear(); + } + + @Override + public void setHealth(double health) + { + _canDeadlyTremor -= getHealth() - health; + super.setHealth(health); + if (getHealth() <= 100 && !_usedFinalAttack) + { + endAbility(); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/BlockHailBlock.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/BlockHailBlock.java new file mode 100644 index 000000000..d837321c9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/BlockHailBlock.java @@ -0,0 +1,88 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.IronGolem; + +import mineplex.core.common.util.UtilEnt; +import net.minecraft.server.v1_8_R3.DataWatcher; +import net.minecraft.server.v1_8_R3.Entity; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; + +public class BlockHailBlock +{ + private int _block = UtilEnt.getNewEntityId(); + private int _silverfish = UtilEnt.getNewEntityId(); + private Location _location; + private Material _mat; + + public BlockHailBlock(Location loc, Material mat) + { + _location = loc; + _mat = mat; + } + + public PacketPlayOutEntityDestroy getDestroyPacket() + { + return new PacketPlayOutEntityDestroy(new int[] + { + _silverfish, _block + }); + } + + public Location getLocation() + { + return _location; + } + + public Material getMaterial() + { + return _mat; + } + + @SuppressWarnings("deprecation") + public Packet[] getSpawnPackets(IronGolem entity) + { + Packet[] packets = new Packet[3]; + + PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving(); + + DataWatcher watcher = new DataWatcher(null); + watcher.a(0, (byte) 32, Entity.META_ENTITYDATA, (byte) 0); + watcher.a(1, 0, Entity.META_AIR, 0); + + packet1.a = _silverfish; + packet1.b = EntityType.SILVERFISH.getTypeId(); + packet1.c = (int) Math.floor(_location.getX() * 32); + packet1.d = (int) Math.floor(_location.getY() * 32); + packet1.e = (int) Math.floor(_location.getZ() * 32); + packet1.l = watcher; + + packets[0] = packet1; + + PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(((CraftEntity) entity).getHandle(), 70, _mat.getId()); + + packet2.a = _block; + + packet2.b = (int) Math.floor(_location.getX() * 32); + packet2.c = (int) Math.floor(entity.getLocation().getY() * 32); + packet2.d = (int) Math.floor(_location.getZ() * 32); + + packets[1] = packet2; + + PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity(); + + packet3.b = _block; + packet3.c = _silverfish; + + packets[2] = packet3; + + return packets; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemBlockHail.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemBlockHail.java new file mode 100644 index 000000000..99c437774 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemBlockHail.java @@ -0,0 +1,475 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftIronGolem; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; +import net.minecraft.server.v1_8_R3.EntityIronGolem; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MovingObjectPosition; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_8_R3.Vec3D; + +public class GolemBlockHail extends BossAbility +{ + private int _currentBlock; + private int _currentLevel; + private List _fallingBlocks = new ArrayList<>(); + private Map> _floatingBlocks = new HashMap<>(); + private Map _blocks = new HashMap<>(); + private int _levelToReach; + private boolean _spawned; + private List _spawnLocs = new ArrayList<>(); + private Player _target; + private Location _center; + private int _ticks; + + public GolemBlockHail(GolemCreature creature) + { + super(creature); + + _center = getLocation(); + + if (creature.getHealthPercent() > 0.75) + { + _levelToReach = 1; + } + else if (creature.getHealthPercent() > 0.5) + { + _levelToReach = 2; + } + else + { + _levelToReach = 3; + } + + _target = getTarget(); + } + + @Override + public Player getTarget() + { + Player target = null; + double dist = 0; + + if (inProgress()) + { + for (Player player : UtilPlayer.getNearby(_center, 40, true)) + { + if (!player.hasLineOfSight(getEntity())) + { + continue; + } + + if (target != null && _blocks.containsKey(player.getName()) && _blocks.get(player.getName()) > 8) + { + continue; + } + + double d = player.getLocation().distance(_center); + + if (target == null || dist > d) + { + target = player; + dist = d; + } + } + } + + return target; + } + + @Override + public boolean canMove() + { + return _spawned && _floatingBlocks.isEmpty(); + } + + @Override + public boolean hasFinished() + { + return _target == null || !_target.isValid() || ((_fallingBlocks.isEmpty() && _spawned) && _ticks >= 8 * 9) + || _center.distance(_target.getLocation()) > 100; + } + + @SuppressWarnings("deprecation") + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator fallingIterator = _fallingBlocks.iterator(); + + while (fallingIterator.hasNext()) + { + FallingBlock cur = fallingIterator.next(); + + if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + fallingIterator.remove(); + + Block block = cur.getLocation().getBlock(); + block.setTypeIdAndData(0, (byte) 0, true); + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + // Expire + if (cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + cur.remove(); + continue; + } + + cur.remove(); + continue; + } + + double distanceToEntity = 0.0D; + LivingEntity victim = null; + + net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) cur).getHandle(); + Vec3D vec3d = new Vec3D(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + Vec3D vec3d1 = new Vec3D(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, + nmsEntity.locZ + nmsEntity.motZ); + + MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); + vec3d = new Vec3D(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + vec3d1 = new Vec3D(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + if (finalObjectPosition != null) + { + vec3d1 = new Vec3D(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c); + } + + for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(), + ((CraftEntity) cur).getHandle().getBoundingBox().a(((CraftEntity) cur).getHandle().motX, + ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) + { + Entity bukkitEntity = ((net.minecraft.server.v1_8_R3.Entity) entity).getBukkitEntity(); + + if (bukkitEntity instanceof LivingEntity) + { + LivingEntity ent = (LivingEntity) bukkitEntity; + + // Avoid Self + if (ent.equals(getEntity())) + continue; + + // Creative or Spec + if (ent instanceof Player) + if (((Player) ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + continue; + + // float f1 = (float)(nmsEntity.boundingBox.a() * 0.6f); + AxisAlignedBB axisalignedbb1 = ((CraftEntity) ent).getHandle().getBoundingBox().grow(1F, 1F, 1F); + MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); + + if (entityCollisionPosition != null) + { + double d1 = vec3d.distanceSquared(entityCollisionPosition.pos); + if ((d1 < distanceToEntity) || (distanceToEntity == 0.0D)) + { + victim = ent; + distanceToEntity = d1; + } + } + } + } + + if (victim != null) + { + cur.getWorld().playEffect(victim.getEyeLocation().subtract(0, 0.5, 0), Effect.STEP_SOUND, cur.getBlockId()); + { + getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null, + DamageCause.CONTACT, 10 * getBoss().getDifficulty(), true, true, false, "Iron Wizard Block Hail", + "Iron Wizard Block Hail"); + } + + if (victim instanceof Player) + { + getBoss().getEvent().getCondition().Factory().Slow("Iron Wizard Block Hail", (LivingEntity) victim, + getEntity(), 3, 2, false, false, false, false); + } + + fallingIterator.remove(); + cur.remove(); + } + else if (finalObjectPosition != null) + { + Block block = cur.getWorld().getBlockAt(((int) finalObjectPosition.pos.a), ((int) finalObjectPosition.pos.b), ((int) finalObjectPosition.pos.c)); + + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) + { + nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); + nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); + nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); + float f2 = MathHelper.sqrt( + nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ); + nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; + nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; + nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; + + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + fallingIterator.remove(); + cur.remove(); + } + } + else + { + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), + cur.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, + UtilServer.getPlayers()); + } + } + } + + @Override + public void setFinished() + { + for (List floatingBlocks : _floatingBlocks.values()) + { + for (BlockHailBlock falling : floatingBlocks) + { + PacketPlayOutEntityDestroy packet = falling.getDestroyPacket(); + + for (Player player : UtilServer.getPlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + } + } + + for (FallingBlock block : _fallingBlocks) + { + block.remove(); + } + } + + @SuppressWarnings("deprecation") + @Override + public void tick() + { + if (inProgress()) + { + for (Player player : UtilPlayer.getNearby(_center, 5, true)) + { + Location loc = player.getLocation(); + + if (Math.abs(loc.getY() - (_center.getY() + 1)) <= 1) + { + loc.setY(_center.getY()); + + if (loc.distance(_center) < 2.8 + (_currentLevel * 0.75)) + { + if (canDamage(player)) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, + DamageCause.CONTACT, 10 * getBoss().getDifficulty(), true, true, false, + "Iron Wizard Protection", "Iron Wizard Protection"); + + loc.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.OBSIDIAN.getId()); + loc.getWorld().playEffect(player.getEyeLocation(), Effect.STEP_SOUND, Material.OBSIDIAN.getId()); + } + } + } + } + } + + if (!_spawned) + { + if (_currentBlock >= _spawnLocs.size()) + { + + if (_currentLevel + 1 <= _levelToReach) + { + _currentLevel++; + _currentBlock = 0; + + _spawnLocs = UtilShapes.getDistancedCircle(_center.clone().add(0, 2.8 + (_currentLevel * 0.75), 0), 1.3, + 1 + (_currentLevel * 1.3)); + + for (int i = UtilMath.r(_spawnLocs.size()); i > 0; i--) + { + _spawnLocs.add(_spawnLocs.remove(0)); + } + } + } + + if (_currentBlock < _spawnLocs.size()) + { + if (_ticks % 2 == 0) + { + IronGolem entity = getEntity(); + + Location loc = _spawnLocs.get(_currentBlock++); + + List floatingBlocks = new ArrayList<>(); + + if (_floatingBlocks.containsKey(_currentLevel)) + { + floatingBlocks = _floatingBlocks.get(_currentLevel); + } + else + { + _floatingBlocks.put(_currentLevel, floatingBlocks); + } + + if (loc.getBlock().getType() == Material.AIR && UtilAlg.HasSight(entity.getLocation(), loc)) + { + + BlockHailBlock floating = new BlockHailBlock(loc, Material.STONE); + UtilEnt.CreatureLook(entity, _target); + + floatingBlocks.add(floating); + + Packet[] packets = floating.getSpawnPackets(entity); + + for (Player player : UtilPlayer.getNearby(loc, 100)) + { + UtilPlayer.sendPacket(player, packets); + } + + entity.getWorld().playSound(entity.getLocation(), Sound.DIG_GRASS, 3, 0.9F); + } + + if (_floatingBlocks.size() % 2 == 0) + { + Collections.reverse(floatingBlocks); + } + } + } + else + { + _spawned = true; + _ticks = -20; + } + } + else if (_ticks > 0 && _ticks % 2 == 0 && !_floatingBlocks.isEmpty()) + { + IronGolem entity = getEntity(); + + if (_ticks % 16 == 0) + { + _target = getTarget(); + + if (_target == null) + return; + } + + EntityIronGolem golem = ((CraftIronGolem) entity).getHandle(); + + golem.world.broadcastEntityEffect(golem, (byte) 4); + UtilEnt.CreatureLook(entity, _target); + + BlockHailBlock floatingBlock = null; + + for (int i = 1; i <= _currentLevel; i++) + { + if (_floatingBlocks.containsKey(i) && !_floatingBlocks.get(i).isEmpty()) + { + floatingBlock = _floatingBlocks.get(i).remove(0); + + if (_floatingBlocks.get(i).isEmpty()) + { + _floatingBlocks.remove(i); + } + + break; + } + } + + PacketPlayOutEntityDestroy packet = floatingBlock.getDestroyPacket(); + + for (Player player : UtilServer.getPlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + + Location loc = floatingBlock.getLocation(); + + FallingBlock b = loc.getWorld().spawnFallingBlock(loc, floatingBlock.getMaterial(), (byte) 0); + b.setDropItem(false); + + Vector vec = UtilAlg.calculateVelocity(loc.toVector(), + _target.getLocation().toVector().add(new Vector(UtilMath.r(6 + (_currentLevel * 2)) - (2 + _currentLevel), 0, + UtilMath.r(6 + (_currentLevel * 2)) - (2 + _currentLevel))), + 6); + + b.setVelocity(vec); + + _fallingBlocks.add(b); + + entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_THROW, 3, 0.9F); + + _blocks.put(_target.getName(), _blocks.containsKey(_target.getName()) ? _blocks.get(_target.getName()) + 1 : 1); + } + + List points = new ArrayList<>(); + + for (int i = _currentLevel; i <= _currentLevel; i++) + { + points.addAll(UtilShapes.getDistancedCircle(_center.clone().add(0, 3.3 + (i * 0.75), 0), 0.3, 1 + (i * 1.3))); + } + + for (int i = 0; i < points.size(); i++) + { + if (_spawned || i < _ticks) + { + Location loc = points.get(i); + + UtilParticle.PlayParticle( + ParticleType.BLOCK_DUST.getParticle(_spawned && i < _ticks ? Material.STONE : Material.DIRT, 0), loc, 0, + 0, 0, 0, 0, UtilParticle.ViewDist.LONG, UtilServer.getPlayers()); + } + } + + _ticks++; + } + + @Override + public boolean inProgress() + { + return !_spawned || !_floatingBlocks.isEmpty(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemBlockShot.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemBlockShot.java new file mode 100644 index 000000000..4f652b4a8 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemBlockShot.java @@ -0,0 +1,442 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftIronGolem; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; +import net.minecraft.server.v1_8_R3.EntityIronGolem; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MovingObjectPosition; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityVelocity; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; +import net.minecraft.server.v1_8_R3.Vec3D; + +public class GolemBlockShot extends BossAbility +{ + private Map _blockLoc = new HashMap<>(); + private Map _blockType = new HashMap<>(); + private List _current = new ArrayList<>(); + private Map _preshoot = new HashMap<>(); + private Player _target; + private Map _targetBlock = new HashMap<>(); + private Map _shotAt = new HashMap<>(); + private int _thrown; + private int _tick; + private int _toThrow; + + public GolemBlockShot(GolemCreature creature) + { + super(creature); + + if (creature.getHealthPercent() > 0.75) + { + _toThrow = 3; + } + else if (creature.getHealthPercent() > 0.5) + { + _toThrow = 6; + } + else + { + _toThrow = 9; + } + + _target = getTarget(); + } + + @Override + public boolean canMove() + { + return _current.isEmpty() && _thrown == _toThrow; + } + + @Override + public Player getTarget() + { + Player target = null; + double dist = 0; + + Location loc1 = getLocation(); + Location loc2 = loc1.clone().add(loc1.getDirection().setY(0).normalize()); + + List players = UtilPlayer.getNearby(getLocation(), 40, true); + + for (Player player : players) + { + if (_shotAt.containsKey(player.getUniqueId()) && _shotAt.get(player.getUniqueId()) >= 3) + { + continue; + } + + double dist1 = player.getLocation().distance(loc1); + double dist2 = player.getLocation().distance(loc2); + + double dist3 = dist1 - dist2; + + if (dist3 < 0.6 || dist1 > 30 || (target != null && dist3 < dist)) + { + continue; + } + + if (!player.hasLineOfSight(getEntity())) + { + continue; + } + + target = player; + dist = dist3; + } + + return target; + } + + @Override + public boolean hasFinished() + { + return _current.isEmpty() && _preshoot.isEmpty() && (_target == null || _thrown >= _toThrow); + } + + @SuppressWarnings("deprecation") + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator fallingIterator = _current.iterator(); + + while (fallingIterator.hasNext()) + { + FallingBlock cur = fallingIterator.next(); + + if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + fallingIterator.remove(); + + Block block = cur.getLocation().getBlock(); + block.setTypeIdAndData(0, (byte) 0, true); + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + // Expire + if (cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + cur.remove(); + continue; + } + + cur.remove(); + continue; + } + + double distanceToEntity = 0.0D; + LivingEntity victim = null; + + net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) cur).getHandle(); + Vec3D vec3d = new Vec3D(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + Vec3D vec3d1 = new Vec3D(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, + nmsEntity.locZ + nmsEntity.motZ); + + MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); + vec3d = new Vec3D(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + vec3d1 = new Vec3D(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + if (finalObjectPosition != null) + { + vec3d1 = new Vec3D(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c); + } + + for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(), + ((CraftEntity) cur).getHandle().getBoundingBox().a(((CraftEntity) cur).getHandle().motX, + ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) + { + Entity bukkitEntity = ((net.minecraft.server.v1_8_R3.Entity) entity).getBukkitEntity(); + + if (bukkitEntity instanceof LivingEntity) + { + LivingEntity ent = (LivingEntity) bukkitEntity; + + // Avoid Self + if (ent.equals(getEntity())) + continue; + + // Creative or Spec + if (ent instanceof Player) + if (((Player) ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + continue; + + // float f1 = (float)(nmsEntity.boundingBox.a() * 0.6f); + AxisAlignedBB axisalignedbb1 = ((CraftEntity) ent).getHandle().getBoundingBox().grow(1F, 1F, 1F); + MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); + + if (entityCollisionPosition != null) + { + double d1 = vec3d.distanceSquared(entityCollisionPosition.pos); + if ((d1 < distanceToEntity) || (distanceToEntity == 0.0D)) + { + victim = ent; + distanceToEntity = d1; + } + } + } + } + + if (victim != null) + { + cur.getWorld().playEffect(victim.getEyeLocation().subtract(0, 0.5, 0), Effect.STEP_SOUND, cur.getBlockId()); + + getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null, + DamageCause.CONTACT, 10 * getBoss().getDifficulty(), true, true, false, "Iron Wizard Block Shot", + "Iron Wizard Block Shot"); + + cur.remove(); + fallingIterator.remove(); + + Vector vec = UtilAlg.getTrajectory(getEntity(), victim); + vec.setY(0).normalize(); + + double strength = 1; + + if (!(victim instanceof Player) || !((Player) victim).isBlocking()) + { + strength = 1.3; + } + + UtilAction.velocity(victim, vec, strength, true, 0, 0.2, 1, true); + } + else if (finalObjectPosition != null) + { + Block block = cur.getWorld().getBlockAt(((int) finalObjectPosition.pos.a), ((int) finalObjectPosition.pos.b), ((int) finalObjectPosition.pos.c)); + + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) + { + nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); + nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); + nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); + float f2 = MathHelper.sqrt( + nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ); + nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; + nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; + nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; + + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + cur.remove(); + fallingIterator.remove(); + } + } + else + { + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), + cur.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, + UtilServer.getPlayers()); + } + } + } + + @Override + public void setFinished() + { + for (FallingBlock falling : _current) + { + falling.remove(); + } + + int[] ids = new int[_preshoot.size()]; + + int a = 0; + for (int id : _preshoot.keySet()) + { + ids[a++] = id; + } + + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ids); + + for (Player player : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + } + + @SuppressWarnings("deprecation") + @Override + public void tick() + { + if (_target == null || _target.getLocation().distance(getLocation()) > 30 || !_target.hasLineOfSight(getEntity())) + { + _target = getTarget(); + } + + Entity entity = getEntity(); + + if (_tick++ % 16 == 0 && _target != null && _thrown < _toThrow) + { + _thrown++; + + UtilEnt.CreatureLook(entity, _target); + EntityIronGolem golem = ((CraftIronGolem) entity).getHandle(); + + golem.world.broadcastEntityEffect(golem, (byte) 4); + + entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_THROW, 2, 1); + + Location loc = entity.getLocation(); + loc.setYaw(loc.getYaw() + (UtilMath.r(150) - 75)); + loc.add(loc.getDirection().setY(0).normalize()); + + Block block = loc.getBlock(); + + if (block.getType() == Material.AIR) + { + block = block.getRelative(BlockFace.DOWN); + } + + Material mat = block.getType(); + + if (!UtilBlock.solid(block)) + { + mat = Material.STONE; + } + + int id = UtilEnt.getNewEntityId(); + + _preshoot.put(id, System.currentTimeMillis()); + _blockType.put(id, mat); + _blockLoc.put(id, loc.clone().add(0, 0.6, 0)); + _targetBlock.put(id, _target); + + PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity(((CraftEntity) entity).getHandle(), 70, mat.getId()); + + packet.a = id; + + packet.b = (int) Math.floor(loc.getX() * 32); + packet.c = (int) Math.floor(loc.getY() * 32); + packet.d = (int) Math.floor(loc.getZ() * 32); + + packet.g = (int) ((0.45) * 8000); + + PacketPlayOutEntityVelocity packet2 = new PacketPlayOutEntityVelocity(id, 0, 0.45D, 0); + + for (Player player : UtilPlayer.getNearby(loc, 70)) + { + UtilPlayer.sendPacket(player, packet, packet2); + } + + _shotAt.put(_target.getUniqueId(), + (_shotAt.containsKey(_target.getUniqueId()) ? _shotAt.get(_target.getUniqueId()) : 0) + 1); + + _target = getTarget(); + } + else + { + Iterator> itel = _preshoot.entrySet().iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + if (UtilTime.elapsed(entry.getValue(), 920)) + { + itel.remove(); + + int id = entry.getKey(); + + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[] + { + id + }); + + for (Player player : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + + Location loc = _blockLoc.get(id); + FallingBlock falling = loc.getWorld().spawnFallingBlock(loc, _blockType.get(id), (byte) 0); + falling.setDropItem(false); + + _current.add(falling); + + Player target = _targetBlock.get(id); + + UtilEnt.CreatureLook(entity, target); + EntityIronGolem golem = ((CraftIronGolem) entity).getHandle(); + + golem.world.broadcastEntityEffect(golem, (byte) 4); + + entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_THROW, 2, 1.2F); + entity.getWorld().playEffect(falling.getLocation(), Effect.STEP_SOUND, falling.getBlockId()); + + Location l = falling.getLocation(); + l.setY(entity.getLocation().getY()); + + Location loc1 = target.getEyeLocation(); + + if (loc1.getY() - l.getY() > 1) + { + loc1.setY(l.getY() + 1); + } + + int dist = (int) Math.ceil(loc1.toVector().setY(0).distance(l.toVector().setY(0))); + + Vector vector = UtilAlg.calculateVelocity(l.toVector(), loc1.toVector(), dist / 13); + + falling.setVelocity(vector); + } + } + } + + if (_thrown >= 3 && !UtilPlayer.getNearby(getLocation(), 10, true).isEmpty()) + { + _thrown = 99; + } + } + + @Override + public boolean inProgress() + { + return _thrown < _toThrow || !_current.isEmpty(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemCaveIn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemCaveIn.java new file mode 100644 index 000000000..5656844ad --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemCaveIn.java @@ -0,0 +1,336 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MovingObjectPosition; +import net.minecraft.server.v1_8_R3.Vec3D; + +public class GolemCaveIn extends BossAbility +{ + private List _blocks = new ArrayList<>(); + private List _fallingBlocks = new ArrayList<>(); + private int _tick; + + public GolemCaveIn(GolemCreature creature) + { + super(creature); + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public Player getTarget() + { + if (getTarget(4) == null) + { + return getTarget(40); + } + + return null; + } + + @Override + public boolean hasFinished() + { + return _tick > 60 && _fallingBlocks.isEmpty(); + } + + @SuppressWarnings("deprecation") + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator fallingIterator = _fallingBlocks.iterator(); + + while (fallingIterator.hasNext()) + { + FallingBlock cur = fallingIterator.next(); + + if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + fallingIterator.remove(); + + Block block = cur.getLocation().getBlock(); + block.setTypeIdAndData(0, (byte) 0, true); + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + // Expire + if (cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + cur.remove(); + continue; + } + + cur.remove(); + continue; + } + + double distanceToEntity = 0.0D; + LivingEntity victim = null; + + net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) cur).getHandle(); + Vec3D vec3d = new Vec3D(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + Vec3D vec3d1 = new Vec3D(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, + nmsEntity.locZ + nmsEntity.motZ); + + MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); + vec3d = new Vec3D(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + vec3d1 = new Vec3D(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + if (finalObjectPosition != null) + { + vec3d1 = new Vec3D(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c); + } + + for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(), + ((CraftEntity) cur).getHandle().getBoundingBox().a(((CraftEntity) cur).getHandle().motX, + ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) + { + Entity bukkitEntity = ((net.minecraft.server.v1_8_R3.Entity) entity).getBukkitEntity(); + + if (bukkitEntity instanceof LivingEntity) + { + LivingEntity ent = (LivingEntity) bukkitEntity; + + // Avoid Self + if (ent.equals(getEntity())) + continue; + + // Creative or Spec + if (ent instanceof Player) + if (((Player) ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + continue; + + // float f1 = (float)(nmsEntity.boundingBox.a() * 0.6f); + AxisAlignedBB axisalignedbb1 = ((CraftEntity) ent).getHandle().getBoundingBox().grow(1F, 1F, 1F); + MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); + + if (entityCollisionPosition != null) + { + double d1 = vec3d.distanceSquared(entityCollisionPosition.pos); + if ((d1 < distanceToEntity) || (distanceToEntity == 0.0D)) + { + victim = ent; + distanceToEntity = d1; + } + } + } + } + + if (victim != null) + { + cur.getWorld().playEffect(victim.getEyeLocation().subtract(0, 0.5, 0), Effect.STEP_SOUND, cur.getBlockId()); + + if (canDamage(victim)) + { + getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null, + DamageCause.CONTACT, 10 * getBoss().getDifficulty(), true, true, false, "Iron Wizard Cave In", + "Iron Wizard Cave In"); + } + + cur.remove(); + fallingIterator.remove(); + } + else if (finalObjectPosition != null) + { + Block block = cur.getWorld().getBlockAt(((int) finalObjectPosition.pos.a), ((int) finalObjectPosition.pos.b), ((int) finalObjectPosition.pos.c)); + + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) + { + nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); + nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); + nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); + float f2 = MathHelper.sqrt( + nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ); + nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; + nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; + nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; + + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + cur.remove(); + fallingIterator.remove(); + } + } + else + { + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), + cur.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, + UtilServer.getPlayers()); + } + } + } + + @SuppressWarnings("deprecation") + @Override + public void setFinished() + { + for (FallingBlock block : _fallingBlocks) + { + block.remove(); + } + + for (Block block : _blocks) + { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); + block.setType(Material.AIR); + } + } + + @SuppressWarnings("deprecation") + @Override + public void tick() + { + if (_tick++ == 0) + { + Location l = getLocation(); + + List blocks = UtilShapes.getSphereBlocks(l, 3, 3, true); + + for (Location loc : blocks) + { + if (loc.getBlockY() >= l.getBlockY()) + { + Block b = loc.getBlock(); + + if (b.getType() == Material.AIR) + { + _blocks.add(b); + + loc.setY(l.getY() - 1); + + b.setType(loc.getBlock().getType()); + + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, loc.getBlock().getTypeId()); + } + } + } + } + + if (_tick % 5 == 0) + + { + for (Player player : UtilPlayer.getNearby(getLocation(), 2.5, true)) + { + player.teleport(player.getLocation().add(0, 4, 0)); + UtilAction.velocity(player, new Vector(UtilMath.r(10) - 5, 3, UtilMath.r(10) - 5).normalize()); + } + } + + if (_tick < 200) + + { + Location loc = getLocation(); + loc.setY(loc.getY() + 4); + + for (int i = 0; i < 30; i++) + { + loc.setY(loc.getY() + 1); + Block b = loc.getBlock(); + + if (UtilBlock.solid(b)) + { + break; + } + } + + if (!UtilBlock.solid(loc.getBlock())) + { + return; + } + + List players = UtilPlayer.getNearby(getLocation(), 50, true); + + for (int i = 0; i < players.size() * 2; i++) + { + int dist = UtilMath.r(10); + + if (dist < 3) + { + dist = 2; + } + else if (dist < 5) + { + dist = 5; + } + else + { + dist = 10; + } + + Location l = players.get(UtilMath.r(players.size())).getLocation().add(UtilMath.r(dist * 2) - dist, 0, + UtilMath.r(dist * 2) - dist); + l.setY(loc.getY()); + + Block b = l.getBlock(); + l.subtract(0, 1, 0); + + if (UtilBlock.solid(b)) + { + if (l.getBlock().getType() == Material.AIR) + { + if (UtilAlg.HasSight(l, getLocation().add(0, 4, 0))) + { + FallingBlock block = b.getWorld().spawnFallingBlock(b.getLocation().add(0.5, -1, 0.5), b.getTypeId(), + b.getData()); + + block.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, block.getBlockId()); + block.setDropItem(false); + + _fallingBlocks.add(block); + } + } + } + } + } + + } + + @Override + public boolean inProgress() + { + return true; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemDeadlyTremor.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemDeadlyTremor.java new file mode 100644 index 000000000..d9934e3c9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemDeadlyTremor.java @@ -0,0 +1,89 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import org.bukkit.Effect; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; + +public class GolemDeadlyTremor extends BossAbility +{ + private static final long ATTACK_DURATION = 10000; + private long _start; + + public GolemDeadlyTremor(GolemCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, ATTACK_DURATION); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - ATTACK_DURATION; + } + + @Override + public void tick() + { + for (Player player : UtilPlayer.getInRadius(getLocation(), 30).keySet()) + { + player.playSound(player.getLocation(), Sound.MINECART_BASE, 0.2f, 0.2f); + + if (UtilEnt.isGrounded(player)) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getBoss().getEntity(), null, DamageCause.CUSTOM, (1 + 2 * Math.random()) * getBoss().getDifficulty(), false, false, false, getBoss().getEntity().getName(), "Deadly Tremor"); + + if (Recharge.Instance.use(player, "Deadly Tremor Hit", 400, false, false)) + { + UtilAction.velocity(player, new Vector(Math.random() - 0.5, Math.random() * 0.2, Math.random() - 0.5), + Math.random() * 1 + 1, false, 0, 0.1 + Math.random() * 0.2, 2, true); + } + } + + for (Block block : UtilBlock.getInRadius(player.getLocation(), 5).keySet()) + { + if (Math.random() < 0.98) + continue; + + if (!UtilBlock.solid(block)) + continue; + + if (!UtilBlock.airFoliage(block.getRelative(BlockFace.UP))) + continue; + + player.playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemEarthquake.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemEarthquake.java new file mode 100644 index 000000000..ae4563a0a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemEarthquake.java @@ -0,0 +1,168 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilServer; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; + +public class GolemEarthquake extends BossAbility +{ + private Location _center; + private float _range; + private int _tick; + private List _damaged = new ArrayList<>(); + private boolean _earthquake; + + public GolemEarthquake(GolemCreature creature) + { + super(creature); + _center = getLocation(); + } + + @Override + public boolean canMove() + { + return !UtilEnt.isGrounded(getEntity()) && _tick > 1; + } + + @Override + public Player getTarget() + { + return getTarget(7); + } + + @Override + public boolean hasFinished() + { + return _range > 19; + } + + @Override + public void setFinished() + { + } + + @Override + public void tick() + { + Entity entity = getEntity(); + + if (_tick == 0) + { + entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_THROW, 4, 0); + + entity.setVelocity(new Vector(0, 1, 0)); + } + else if (!_earthquake) + { + _earthquake = _tick > 10 && UtilEnt.isGrounded(entity); + } + + if (_earthquake) + { + _range += 0.7; + + for (float range = _range - 2; range <= _range; range++) + { + if (range <= 0) + { + continue; + } + + for (int x = -1; x <= 1; x++) + { + for (int z = -1; z <= 1; z++) + { + if ((x != 0) == (z != 0)) + { + continue; + } + + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.DIRT, 0), + _center.clone().add(x * range, 0.1, z * range), (x != 0) ? 0 : (range / 2), 0.1F, + (z != 0) ? 0 : (range / 2), 0, (int) (range * 4), UtilParticle.ViewDist.NORMAL, + UtilServer.getPlayers()); + } + } + } + + _center.getWorld().playSound(_center, Sound.DIG_STONE, 2, 0.8F); + + HashSet toDamage = new HashSet(); + + Location cornerA = _center.clone().add(-_range, -1, -_range); + Location cornerB = _center.clone().add(_range, 1, _range); + Location cornerA1 = _center.clone().add(-(_range - 1.5), -1, -(_range - 1.5)); + Location cornerB1 = _center.clone().add(_range - 1.5, 1, _range - 1.5); + + for (Player player : Bukkit.getOnlinePlayers()) + { + Location pLoc = player.getLocation(); + + if (_damaged.contains(player.getUniqueId())) + { + continue; + } + + if (!UtilAlg.inBoundingBox(pLoc, cornerA, cornerB)) + { + continue; + } + + if (UtilAlg.inBoundingBox(pLoc, cornerA1, cornerB1)) + { + continue; + } + + toDamage.add(player); + } + + for (Player player : toDamage) + { + _damaged.add(player.getUniqueId()); + + getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) player, getEntity(), null, + DamageCause.CONTACT, 14 * getBoss().getDifficulty(), false, true, false, "Iron Wizard Earthquake", + "Iron Wizard Earthquake"); + + getBoss().getEvent().getCondition().Factory().Slow("Earthquake", (LivingEntity) player, getEntity(), 3, 1, false, + false, false, false); + + // Velocity + UtilAction.velocity(player, UtilAlg.getTrajectory2d(getLocation().toVector(), player.getLocation().toVector()), + 1.8, true, 0, 0.5, 0.5, true); + + // Condition + getBoss().getEvent().getCondition().Factory().Falling("Earthquake", player, getEntity(), 10, false, true); + } + } + + _tick++; + } + + @Override + public boolean inProgress() + { + return !_earthquake; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemExplodingAura.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemExplodingAura.java new file mode 100644 index 000000000..ff9fe2c67 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemExplodingAura.java @@ -0,0 +1,400 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; +import net.minecraft.server.v1_8_R3.DataWatcher; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MovingObjectPosition; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_8_R3.Vec3D; + +public class GolemExplodingAura extends BossAbility +{ + private Map _blocks = new HashMap<>(); + private Map _blocksLoc = new HashMap<>(); + private List _fallingBlocks = new ArrayList<>(); + private Map _blockMaterial = new HashMap<>(); + private int _tick; + + public GolemExplodingAura(GolemCreature creature) + { + super(creature); + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean hasFinished() + { + return _tick > 20 * 30 && _blocks.isEmpty() && _fallingBlocks.isEmpty(); + } + + @Override + public void setFinished() + { + for (FallingBlock block : _fallingBlocks) + { + block.remove(); + } + + int[] ids = new int[_blocks.size() * 2]; + + int i = 0; + + for (Entry id : _blocks.entrySet()) + { + ids[i] = id.getKey(); + ids[i + 1] = id.getValue(); + + i += 2; + } + + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ids); + + for (Player player : UtilServer.getPlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + } + + @SuppressWarnings("deprecation") + @Override + public void tick() + { + if (_tick < 25 * 25 && getBoss().getHealth() > 30) + { + double angle = (2 * Math.PI) / UtilMath.random.nextDouble(); + double x = 1.7 * Math.cos(angle); + double z = 1.7 * Math.sin(angle); + + Location loc = getLocation().add(x, 1 + (UtilMath.random.nextDouble() * 1.6), z); + + loc.getWorld().playEffect(loc, Effect.STEP_SOUND, Material.DIRT.getId()); + + for (Player player : UtilPlayer.getNearby(getLocation(), 3, true)) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, DamageCause.CONTACT, + 6 * getBoss().getDifficulty(), true, true, false, "Iron Wizard Protection", "Iron Wizard Protection"); + UtilAction.velocity(player, UtilAlg.getTrajectory(getEntity(), player), 1, true, 0.3, 0, 0.3, false); + } + } + + if (_tick < 20 * 30) + { + int key = UtilEnt.getNewEntityId(); + int value = UtilEnt.getNewEntityId(); + + Location loc = null; + + for (int i = 0; i < 30; i++) + { + double angle = (2 * Math.PI) / UtilMath.random.nextDouble(); + double x = 1.7 * Math.cos(angle); + double z = 1.7 * Math.sin(angle); + + loc = getLocation().add(x, 1 + (UtilMath.random.nextDouble() * 1.6), z); + boolean found = false; + + for (Location l : _blocksLoc.values()) + { + if (l.distance(loc) < 0.3) + { + found = true; + break; + } + } + + if (found) + { + loc = null; + } + else + { + break; + } + } + + if (loc != null) + { + _blocks.put(key, value); + _blocksLoc.put(key, loc); + _blockMaterial.put(key, UtilMath.random.nextBoolean() ? Material.DIRT : Material.STONE); + + Packet[] packets = new Packet[3]; + + PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving(); + + DataWatcher watcher = new DataWatcher(null); + watcher.a(0, (byte) 32, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0); + watcher.a(1, 0, net.minecraft.server.v1_8_R3.Entity.META_AIR, 0); + + packet1.a = key; + packet1.b = EntityType.SILVERFISH.getTypeId(); + packet1.c = (int) Math.floor(loc.getX() * 32); + packet1.d = (int) Math.floor((loc.getY() - 0.125) * 32); + packet1.e = (int) Math.floor(loc.getZ() * 32); + packet1.l = watcher; + + packets[0] = packet1; + + PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(((CraftEntity) getEntity()).getHandle(), 70, + _blockMaterial.get(key).getId()); + + packet2.a = value; + + packet2.b = (int) Math.floor(loc.getX() * 32); + packet2.c = (int) Math.floor(loc.getY() * 32); + packet2.d = (int) Math.floor(loc.getZ() * 32); + + packets[1] = packet2; + + PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity(); + + packet3.b = value; + packet3.c = key; + + packets[2] = packet3; + + for (Player player : UtilPlayer.getNearby(getLocation(), 70)) + { + UtilPlayer.sendPacket(player, packets); + } + } + } + + if (_tick % 25 == 0) + { + for (int i = 0; i < 3; i++) + getLocation().getWorld().playSound(getLocation(), Sound.DIG_GRASS, 3, 2); + + for (int key : new ArrayList(_blocksLoc.keySet())) + { + + PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(new int[] + { + key, _blocks.remove(key) + }); + + for (Player player : UtilServer.getPlayers()) + { + UtilPlayer.sendPacket(player, destroyPacket); + } + + Location loc = _blocksLoc.remove(key); + + FallingBlock falling = loc.getWorld().spawnFallingBlock(loc, _blockMaterial.remove(key), (byte) 0); + + _fallingBlocks.add(falling); + + Vector vec = UtilAlg.getTrajectory(getLocation().add(0, 1, 0), loc); + + vec.setY(Math.max(0.05, vec.getY())); + + falling.setVelocity(vec); + + loc.getWorld().playEffect(loc, Effect.STEP_SOUND, Material.DIRT.getId()); + } + } + + _tick++; + } + + @SuppressWarnings("deprecation") + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator fallingIterator = _fallingBlocks.iterator(); + + while (fallingIterator.hasNext()) + { + FallingBlock cur = fallingIterator.next(); + + if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + fallingIterator.remove(); + + Block block = cur.getLocation().getBlock(); + block.setTypeIdAndData(0, (byte) 0, true); + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + // Expire + if (cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + cur.remove(); + continue; + } + + cur.remove(); + continue; + } + + double distanceToEntity = 0.0D; + LivingEntity victim = null; + + net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) cur).getHandle(); + Vec3D vec3d = new Vec3D(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + Vec3D vec3d1 = new Vec3D(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, + nmsEntity.locZ + nmsEntity.motZ); + + MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); + vec3d = new Vec3D(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + vec3d1 = new Vec3D(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + if (finalObjectPosition != null) + { + vec3d1 = new Vec3D(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c); + } + + for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(), + ((CraftEntity) cur).getHandle().getBoundingBox().a(((CraftEntity) cur).getHandle().motX, + ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) + { + Entity bukkitEntity = ((net.minecraft.server.v1_8_R3.Entity) entity).getBukkitEntity(); + + if (bukkitEntity instanceof LivingEntity) + { + LivingEntity ent = (LivingEntity) bukkitEntity; + + // Avoid Self + if (ent.equals(getEntity())) + { + continue; + } + + // Creative or Spec + if (ent instanceof Player) + { + if (((Player) ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + { + continue; + } + } + + AxisAlignedBB axisalignedbb1 = ((CraftEntity) ent).getHandle().getBoundingBox().grow(1F, 1F, 1F); + MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); + + if (entityCollisionPosition != null) + { + double d1 = vec3d.distanceSquared(entityCollisionPosition.pos); + if ((d1 < distanceToEntity) || (distanceToEntity == 0.0D)) + { + victim = ent; + distanceToEntity = d1; + } + } + } + } + + if (victim != null) + { + cur.getWorld().playEffect(victim.getEyeLocation().subtract(0, 0.5, 0), Effect.STEP_SOUND, cur.getBlockId()); + + { + getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null, + DamageCause.CONTACT, 6 * getBoss().getDifficulty(), true, true, false, "Blocky Iron Wizard Aura", + "Blocky Iron Wizard Aura"); + } + + fallingIterator.remove(); + cur.remove(); + + Vector vec = UtilAlg.getTrajectory(getEntity(), victim); + vec.setY(0).normalize(); + + double strength = 1; + + if (!(victim instanceof Player) || !((Player) victim).isBlocking()) + { + strength = 1.3; + } + + UtilAction.velocity(victim, vec, strength, true, 0, 0.2, 1, true); + } + else if (finalObjectPosition != null) + { + Block block = cur.getWorld().getBlockAt(((int) finalObjectPosition.pos.a), ((int) finalObjectPosition.pos.b), ((int) finalObjectPosition.pos.c)); + + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) + { + nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); + nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); + nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); + float f2 = MathHelper.sqrt( + nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ); + nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; + nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; + nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; + + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + fallingIterator.remove(); + cur.remove(); + } + } + else + { + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), + cur.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, + UtilServer.getPlayers()); + } + } + } + + @Override + public boolean inProgress() + { + return false; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemExplosiveBlock.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemExplosiveBlock.java new file mode 100644 index 000000000..fd76b19e0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemExplosiveBlock.java @@ -0,0 +1,590 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftIronGolem; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +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.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; +import net.minecraft.server.v1_8_R3.DataWatcher; +import net.minecraft.server.v1_8_R3.EntityIronGolem; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MovingObjectPosition; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_8_R3.Vec3D; + +public class GolemExplosiveBlock extends BossAbility +{ + private Map _blocksLocation = new HashMap<>(); + private Location _center; + private int _explosionsLeft; + private FallingBlock _fallingBlock; + private Map _fallingBlocks = new HashMap<>(); + private List _items = new ArrayList<>(); + private int _strength; + private Player _target; + private int _tick; + + public GolemExplosiveBlock(GolemCreature creature, int strength) + { + super(creature); + + _strength = strength; + _center = getLocation().add(0, 3, 0); + _target = getTarget(); + + if (_target != null) + { + UtilEnt.CreatureLook(getEntity(), _target); + } + } + + @Override + public boolean canMove() + { + return _fallingBlock != null; + } + + private int clamp(int value) + { + if (value < -127) + { + return -127; + } + + if (value > 127) + { + return 127; + } + + return value; + } + + @Override + public Player getTarget() + { + HashMap locs = new HashMap(); + + for (Player player : UtilServer.getPlayers()) + { + double dist = player.getLocation().distance(_center); + + if (dist < 30) + { + double score = (dist > 10 ? 30 - dist : 10); + + for (Player p : UtilServer.getPlayers()) + { + if (player.getLocation().distance(p.getLocation()) < 4) + { + score += 7; + } + } + + if (player.hasLineOfSight(getEntity())) + { + score += 10; + } + + locs.put(player, score); + } + } + + Player lowest = null; + + for (Entry entry : locs.entrySet()) + { + if (lowest == null || locs.get(lowest) > locs.get(entry.getKey())) + { + lowest = entry.getKey(); + } + } + + return lowest; + } + + @Override + public boolean hasFinished() + { + return _target == null || (_fallingBlock != null && !_fallingBlock.isValid() && _explosionsLeft == 0); + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(getEntity())) + { + if (_tick >= 40 + (40 * _strength) && _tick <= 50 + (40 * _strength)) + { + event.SetCancelled("Iron Wizard charging bomb"); + } + + event.SetKnockback(false); + } + } + + public void onExplode(final Location loc) + { + for (int i = 0; i < _strength * 2; i++) + { + if (i == 0) + { + onSubExplode(loc); + } + else + { + _explosionsLeft++; + + Bukkit.getScheduler().scheduleSyncDelayedTask(UtilServer.getPlugin(), () -> + { + onSubExplode(loc); + _explosionsLeft--; + }, 2 * i); + } + } + } + + public void onSubExplode(Location loc) + { + for (int i = 0; i < 2; i++) + { + Location l = loc.clone().add(UtilMath.r(_strength * 4) - (_strength * 2), UtilMath.r(_strength * 2), + UtilMath.r(_strength * 4) - (_strength * 2)); + + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, l, _strength * 3, 1, _strength * 3, 0, _strength * 4, + ViewDist.LONG, UtilServer.getPlayers()); + } + } + + @SuppressWarnings("deprecation") + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_fallingBlock == null) + { + return; + } + + if (_fallingBlock.isDead() + || !_fallingBlock.isValid() + || _fallingBlock.getTicksLived() > 400 + || !_fallingBlock.getWorld().isChunkLoaded(_fallingBlock.getLocation().getBlockX() >> 4, + _fallingBlock.getLocation().getBlockZ() >> 4)) + { + Block block = _fallingBlock.getLocation().getBlock(); + block.setTypeIdAndData(0, (byte) 0, true); + _fallingBlock.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _fallingBlock.getBlockId()); + + // Expire + if (_fallingBlock.getTicksLived() > 400 + || !_fallingBlock.getWorld().isChunkLoaded(_fallingBlock.getLocation().getBlockX() >> 4, + _fallingBlock.getLocation().getBlockZ() >> 4)) + { + _fallingBlock.remove(); + return; + } + + _fallingBlock.remove(); + return; + } + + double distanceToEntity = 0.0D; + LivingEntity victim = null; + + net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) _fallingBlock).getHandle(); + Vec3D vec3d = new Vec3D(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + Vec3D vec3d1 = new Vec3D(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); + vec3d = new Vec3D(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + vec3d1 = new Vec3D(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + if (finalObjectPosition != null) + { + vec3d1 = new Vec3D(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c); + } + + for (Object entity : ((CraftWorld) _fallingBlock.getWorld()).getHandle().getEntities( + ((CraftEntity) _fallingBlock).getHandle(), + ((CraftEntity) _fallingBlock).getHandle().getBoundingBox().a(((CraftEntity) _fallingBlock).getHandle().motX, + ((CraftEntity) _fallingBlock).getHandle().motY, ((CraftEntity) _fallingBlock).getHandle().motZ).grow(2, + 2, 2))) + { + Entity bukkitEntity = ((net.minecraft.server.v1_8_R3.Entity) entity).getBukkitEntity(); + + if (bukkitEntity instanceof LivingEntity) + { + LivingEntity ent = (LivingEntity) bukkitEntity; + + // Avoid Self + if (ent.equals(getEntity())) + { + continue; + } + + // Creative or Spec + if (ent instanceof Player) + { + if (((Player) ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + { + continue; + } + } + + // float f1 = (float)(nmsEntity.boundingBox.a() * 0.6f); + AxisAlignedBB axisalignedbb1 = ((CraftEntity) ent).getHandle().getBoundingBox().grow(1F, 1F, 1F); + MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); + + if (entityCollisionPosition != null) + { + double d1 = vec3d.distanceSquared(entityCollisionPosition.pos); + if ((d1 < distanceToEntity) || (distanceToEntity == 0.0D)) + { + victim = ent; + distanceToEntity = d1; + } + } + } + } + + if (victim != null) + { + onExplode(victim.getEyeLocation()); + + _fallingBlock.remove(); + } + else if (finalObjectPosition != null) + { + Block block = _fallingBlock.getWorld() + .getBlockAt(((int) finalObjectPosition.pos.a), ((int) finalObjectPosition.pos.b), ((int) finalObjectPosition.pos.c)); + + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) + { + nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); + nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); + nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); + float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ + * nmsEntity.motZ); + nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; + nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; + nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; + + onExplode(block.getLocation().add(0.5, 0.5, 0.5)); + + _fallingBlock.remove(); + } + } + else + { + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), + _fallingBlock.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, + UtilServer.getPlayers()); + } + } + + @Override + public void setFinished() + { + int[] ids = new int[_fallingBlocks.size() * 2]; + + int index = 0; + + for (Entry entry : _fallingBlocks.entrySet()) + { + ids[index] = entry.getKey(); + ids[index + 1] = entry.getValue(); + index += 2; + } + + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ids); + + for (Player player : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + + for (Item item : _items) + { + item.remove(); + } + + if (_fallingBlock != null) + { + _fallingBlock.remove(); + } + } + + @SuppressWarnings("deprecation") + @Override + public void tick() + { + IronGolem entity = getEntity(); + + Iterator itel = _items.iterator(); + + while (itel.hasNext()) + { + Item item = itel.next(); + + Vector vec = item.getVelocity(); + Location loc = item.getLocation(); + + if (item.getTicksLived() > 100 || vec.getY() <= 0 || loc.distance(_center) > loc.add(vec).distance(_center) + || UtilEnt.isGrounded(item)) + { + itel.remove(); + } + } + + // This spawns a floating block + if (_tick >= 20 && _tick % 60 == 0 && _fallingBlocks.size() < _strength) + { + int id = UtilEnt.getNewEntityId(); + int id2 = UtilEnt.getNewEntityId(); + + _fallingBlocks.put(id, id2); + _blocksLocation.put(id, _center.toVector()); + + Packet[] packets = new Packet[3]; + + PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving(); + + DataWatcher watcher = new DataWatcher(null); + watcher.a(0, (byte) 32, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0); + watcher.a(1, 0, net.minecraft.server.v1_8_R3.Entity.META_AIR, 0); + + packet1.a = id; + packet1.b = EntityType.SILVERFISH.getTypeId(); + packet1.c = (int) Math.floor(_center.getX() * 32); + packet1.d = (int) Math.floor((_center.getY() - 0.125) * 32); + packet1.e = (int) Math.floor(_center.getZ() * 32); + packet1.l = watcher; + + packets[0] = packet1; + + PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(((CraftEntity) entity).getHandle(), 70, + Material.DIRT.getId()); + + packet2.a = id2; + + packet2.b = (int) Math.floor(_center.getX() * 32); + packet2.c = (int) Math.floor(_center.getY() * 32); + packet2.d = (int) Math.floor(_center.getZ() * 32); + + packets[1] = packet2; + + PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity(); + + packet3.b = id2; + packet3.c = id; + + packets[2] = packet3; + + for (Player player : UtilServer.getPlayers()) + { + if (player.getLocation().distance(_center) < 80) + { + UtilPlayer.sendPacket(player, packets); + } + } + } + + // This spawns a item that flies above the golem's head and disappears + if (UtilMath.r(6) == 0 && _tick < 40 + (_strength * 40)) + { + double angle = ((2 * Math.PI) / 30) * UtilMath.r(30); + double x = 5 * Math.cos(angle); + double z = 5 * Math.sin(angle); + Location loc = _center.clone().add(x, -3, z); + + Material mat = null; + + switch (UtilMath.r(3)) + { + case 0: + mat = Material.DIRT; + break; + case 1: + mat = Material.STONE; + break; + case 2: + mat = Material.COBBLESTONE; + break; + default: + break; + } + + Item item = loc.getWorld().dropItem(loc, new ItemBuilder(mat).setTitle(System.currentTimeMillis() + "").build()); + + item.setPickupDelay(999999); + + Vector vec = UtilAlg.getTrajectory(_center, item.getLocation()); + + vec.normalize().multiply(5); + + item.setVelocity(vec); + + // TODO Fix velocity + + _items.add(item); + } + + // 10 being when items no longer fly in, 0 being when its shot. + int ticksTillFired = (60 + (40 * _strength)) - _tick; + + if (ticksTillFired > 20) + { + int strength = (int) Math.floor(_tick / 20D); + + int nine = 8 - strength; + + if (_tick % nine == 0) + { + _center.getWorld().playSound(_center, Sound.DIG_GRASS, strength + 1, 1F); + } + } + else if (ticksTillFired < 0) + { + if (_tick % 3 == 0) + { + _center.getWorld().playSound(_fallingBlock.getLocation(), Sound.WOOD_CLICK, _strength + 1, 0.4F); + } + } + + // The location the falling blocks need to stick by + Vector blockCenter = _center.toVector(); + + if (ticksTillFired >= 0 && ticksTillFired <= 20) + { + Vector vec = entity.getLocation().add(entity.getLocation().getDirection().setY(0).normalize().multiply(1.2)) + .add(0, 1, 0).toVector(); + + blockCenter = UtilAlg.getTrajectory(_center.toVector(), blockCenter); + vec.multiply(ticksTillFired / 10D); + + _center.getWorld().playSound(_center, Sound.DIG_SNOW, _strength + 1, 0); + } + else if (_fallingBlock != null) + { + blockCenter = _fallingBlock.getLocation().add(0, 0.5, 0).toVector(); + } + + // Move the fake floating blocks + for (Entry entry : _fallingBlocks.entrySet()) + { + int id = entry.getKey(); + Vector vec = _blocksLocation.get(id); + + int x = clamp((int) ((blockCenter.getX() - vec.getX()) * 32) + (UtilMath.r(8) - 4)); + int y = clamp((int) ((blockCenter.getY() - vec.getY()) * 32) + (UtilMath.r(8) - 4)); + int z = clamp((int) ((blockCenter.getZ() - vec.getZ()) * 32) + (UtilMath.r(8) - 4)); + + vec.add(new Vector(x, y, z)); + + PacketPlayOutEntity.PacketPlayOutRelEntityMove packet = new PacketPlayOutEntity.PacketPlayOutRelEntityMove(); + + packet.a = id; + + packet.b = (byte) x; + packet.c = (byte) y; + packet.d = (byte) z; + + for (Player player : UtilServer.getPlayers()) + { + if (player.getLocation().distance(_center) < 70) + { + UtilPlayer.sendPacket(player, packet); + + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), + vec.toLocation(_center.getWorld()), 0.7F, 0.7F, 0.7F, 0, 11, ViewDist.NORMAL, player); + } + } + } + + if (ticksTillFired == 0) + { + int id = _fallingBlocks.keySet().iterator().next(); + + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[] + { + id, _fallingBlocks.get(id) + }); + + for (Player player : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + + _fallingBlocks.remove(id); + + _fallingBlock = _center.getWorld().spawnFallingBlock(_blocksLocation.get(id).toLocation(_center.getWorld()), + Material.STONE, (byte) 0); + + Vector vec1 = _fallingBlock.getLocation().toVector(); + Vector vec2 = _target.getLocation().toVector(); + + Vector vec = UtilAlg.calculateVelocity(vec1, vec2, (int) (vec1.distanceSquared(vec2) / 4)); + + _fallingBlock.setVelocity(vec); + + EntityIronGolem golem = ((CraftIronGolem) entity).getHandle(); + + golem.world.broadcastEntityEffect(golem, (byte) 4); + } + + _tick++; + } + + @Override + public boolean inProgress() + { + return false; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemIronHook.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemIronHook.java new file mode 100644 index 000000000..18c94e4cd --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemIronHook.java @@ -0,0 +1,163 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Sound; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; + +public class GolemIronHook extends BossAbility +{ + private static final Integer MAX_TARGETS = 3; + private boolean _shot, _complete; + + private List _hooks = new ArrayList<>(); + + public GolemIronHook(GolemCreature creature) + { + super(creature); + _shot = false; + _complete = false; + } + + private int getPosition(Player toAdd, List ordered, Map distances) + { + int position = ordered.size(); + int index = 0; + for (Player player : ordered) + { + if (distances.get(player) < distances.get(toAdd)) + { + position = index; + } + index++; + } + + return position; + } + + private void shoot() + { + IronGolem wizard = getBoss().getEntity(); + List selections = new LinkedList<>(); + List targeted = new ArrayList<>(); + + Map near = UtilPlayer.getInRadius(wizard.getLocation(), 40D); + + for (Player nearby : near.keySet()) + { + if (nearby.getGameMode() == GameMode.CREATIVE || nearby.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + if (selections.isEmpty()) + { + selections.add(nearby); + } + else + { + selections.add(getPosition(nearby, selections, near), nearby); + } + } + + for (int i = 0; i < MAX_TARGETS; i++) + { + if (i < selections.size()) + { + targeted.add(selections.get(i)); + } + } + + if (targeted.isEmpty()) + { + _complete = true; + setFinished(); + return; + } + + for (Player target : targeted) + { + Item item = wizard.getWorld().dropItem(wizard.getEyeLocation().add(UtilAlg.getTrajectory(wizard, target)), ItemStackFactory.Instance.CreateStack(131)); + UtilAction.velocity(item, UtilAlg.getTrajectory(wizard, target).normalize(), + 2, false, 0, 0.2, 20, false); + + getBoss().getEvent().getProjectileManager().AddThrow(item, getBoss().getEntity(), new IronHook(getBoss().getEvent()), -1, true, true, true, true, + Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, UpdateType.TICK, 1f); + + item.getWorld().playSound(item.getLocation(), Sound.IRONGOLEM_THROW, 2f, 0.8f); + _hooks.add(item); + } + } + + @Override + public int getCooldown() + { + return 10; + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return _complete; + } + + @Override + public void setFinished() + { + for (Item hook : _hooks) + { + if (!hook.isDead() && hook.isValid()) + { + getBoss().getEvent().getProjectileManager().deleteThrown(hook); + hook.remove(); + } + } + + _hooks.clear(); + } + + @Override + public void tick() + { + if (_shot) + { + return; + } + shoot(); + _shot = true; + Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () -> + { + _complete = true; + setFinished(); + }, 2 * 20); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemMeleeAttack.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemMeleeAttack.java new file mode 100644 index 000000000..a045429dc --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemMeleeAttack.java @@ -0,0 +1,90 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftIronGolem; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_8_R3.EntityIronGolem; + +public class GolemMeleeAttack extends BossAbility +{ + private boolean _attacked; + + public GolemMeleeAttack(GolemCreature creature) + { + super(creature); + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public int getCooldown() + { + return 20; + } + + @Override + public Player getTarget() + { + return getTarget(4); + } + + @Override + public boolean hasFinished() + { + return _attacked; + } + + @Override + public void setFinished() {} + + @Override + public void tick() + { + _attacked = true; + + for (Player target : UtilPlayer.getNearby(getLocation(), 4, true)) + { + if (target.getVelocity().length() > 0.5) + { + continue; + } + + UtilEnt.CreatureLook(getEntity(), target); + + getBoss().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK, + 10 * getBoss().getDifficulty(), false, true, false, "Iron Wizard Melee Attack", "Iron Wizard Melee Attack"); + + Vector vec = getLocation().getDirection(); + vec.setY(0).normalize().setY(0.5).multiply(2.4); + + UtilAction.velocity(target, vec); + + getBoss().getEvent().getCondition().Factory().Falling("Iron Wizard Throw", target, getEntity(), 3, false, false); + + target.getWorld().playSound(target.getLocation(), Sound.IRONGOLEM_THROW, 3, 0.9F); + + EntityIronGolem golem = ((CraftIronGolem) getEntity()).getHandle(); + + golem.world.broadcastEntityEffect(golem, (byte) 4); + } + } + + @Override + public boolean inProgress() + { + return _attacked; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemRumble.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemRumble.java new file mode 100644 index 000000000..d9cb7cc70 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemRumble.java @@ -0,0 +1,238 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftIronGolem; +import org.bukkit.entity.Damageable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_8_R3.EntityIronGolem; + +/** + * Rumble is where the golem picks a target then starts playing a animation for a second where its obviously preparing to use it. + * Copy this from Wizards + */ +public class GolemRumble extends BossAbility +{ + private Location _loc; + private int _ticks; + private int _travelled; + private Vector _vec; + private int _width = 1; + private Location _target; + + public GolemRumble(GolemCreature creature) + { + super(creature); + + Player target = getTarget(); + + if (target != null) + { + _target = target.getLocation(); + + UtilEnt.CreatureLook(getEntity(), _target); + } + } + + @Override + public boolean canMove() + { + return _ticks >= 20; + } + + @Override + public boolean hasFinished() + { + return _travelled > 35; + } + + @Override + public void setFinished() {} + + @SuppressWarnings("deprecation") + @Override + public void tick() + { + if (_ticks++ < 14) + { + IronGolem entity = getEntity(); + EntityIronGolem golem = ((CraftIronGolem) entity).getHandle(); + + golem.world.broadcastEntityEffect(golem, (byte) 4); + + if (_ticks % 2 == 0) + { + entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_THROW, 3, 2F); + } + } + else if (_ticks % 2 == 0) + { + int oldWidth = _width; + + if ((_width <= 3 || _ticks % 4 == 0) && _width <= 6) + { + _width++; + } + + Location newLoc; + boolean validBlock = false; + List current = new ArrayList<>(); + + if (_vec == null) + { + _vec = _target.subtract(getLocation()).toVector().setY(0).normalize(); + _loc = getLocation().subtract(0, 1, 0).getBlock().getLocation().add(0, 0.99, 0); + newLoc = _loc; + current.add(_loc.getBlock()); + + validBlock = true; + } + else + { // Move rumble + newLoc = _loc.clone().add(_vec); + + // Check if the rumble needs to go up or drop a block or two + for (int y : new int[] {0, 1, -1}) + { + for (int a = 1; a <= 2; a++) + { + Block b = newLoc.clone().add(_vec.clone().multiply(a)).getBlock().getRelative(0, y, 0); + + if (UtilBlock.solid(b) && !UtilBlock.solid(b.getRelative(0, 1, 0))) + { + validBlock = true; + newLoc.add(0, y, 0); + + break; + } + } + + if (validBlock) + { + break; + } + } + + for (int width = -_width; width <= _width; width++) + { + if (Math.abs(width) <= oldWidth) + { + Block b = _loc.clone().add(UtilAlg.getRight(_vec).multiply(width)).getBlock(); + + if (!current.contains(b)) + { + current.add(b); + } + } + + if (validBlock) + { + Block b = newLoc.clone().add(UtilAlg.getRight(_vec).multiply(width)).getBlock(); + + if (!current.contains(b)) + { + current.add(b); + + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getTypeId()); + } + } + } + } + + UtilEnt.CreatureLook(getEntity(), _loc); + + for (Entity entity : getEntity().getWorld().getEntities()) + { + if (entity instanceof Damageable && !UtilPlayer.isSpectator(entity) && entity != getEntity()) + { + Block b = entity.getLocation().getBlock(); + boolean canDamage = false; + + for (int y = -1; y <= 0; y++) + { + if (current.contains(b.getRelative(0, y, 0))) + { + canDamage = true; + break; + } + } + + if (!canDamage) + { + continue; + } + + if (canDamage(entity)) + { + getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) entity, getEntity(), null, + DamageCause.CONTACT, 8 * getBoss().getDifficulty(), false, true, false, "Iron Wizard Rumble", + "Iron Wizard Rumble"); + } + + UtilAction.velocity(entity, _vec.clone(), 1.5, true, 0, 0.2, 1, true); + + if (entity instanceof Player) + { + getBoss().getEvent().getCondition().Factory().Slow("Rumble", (LivingEntity) entity, getEntity(), 3, 1, + false, false, false, false); + } + } + } + + if (_travelled++ > 35 || !validBlock) + { + _travelled = 100; + } + + _loc = newLoc; + } + } + + public Player getTarget() + { + Player target = null; + double dist = 0; + + for (Player player : UtilPlayer.getNearby(getLocation(), 30, true)) + { + if (!player.hasLineOfSight(getEntity())) + { + continue; + } + + double d = player.getLocation().distance(getLocation()); + + if (d > 2 && (target == null || dist > d)) + { + target = player; + dist = d; + } + } + + return target; + } + + @Override + public boolean inProgress() + { + return _ticks < 14; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemRupture.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemRupture.java new file mode 100644 index 000000000..2ecf4c46b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemRupture.java @@ -0,0 +1,367 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftIronGolem; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.inventory.InventoryPickupItemEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.Pair; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +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.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_8_R3.EntityIronGolem; + +public class GolemRupture extends BossAbility +{ + private List> _ruptures = new ArrayList<>(); + private Map _ruptureTime = new HashMap<>(); + private List _targetted = new ArrayList<>(); + private int _rupturesLeft; + private int _tick; + private List _items = new ArrayList<>(); + private int _ticksFinished; + + public GolemRupture(GolemCreature creature) + { + super(creature); + + if (creature.getHealthPercent() > 0.75) + { + _rupturesLeft = 2; + } + else if (creature.getHealthPercent() > 0.5) + { + _rupturesLeft = 5; + } + else + { + _rupturesLeft = 10; + } + } + + @Override + public boolean canMove() + { + return false; + } + + @EventHandler + public void HopperPickup(InventoryPickupItemEvent event) + { + if (_items.contains(event.getItem())) + { + event.setCancelled(true); + } + } + + @SuppressWarnings("deprecation") + @EventHandler + public void ItemDestroy(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_items.isEmpty()) + { + return; + } + + Iterator itemIterator = _items.iterator(); + + while (itemIterator.hasNext()) + { + Item item = itemIterator.next(); + + if (item.isDead() || !item.isValid()) + { + item.remove(); + itemIterator.remove(); + } + else if (UtilEnt.isGrounded(item) || item.getTicksLived() > 60) + { + item.getWorld().playEffect(item.getLocation(), Effect.STEP_SOUND, item.getItemStack().getTypeId()); + item.remove(); + itemIterator.remove(); + } + } + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return _rupturesLeft <= 0 && _ruptures.isEmpty() && --_ticksFinished <= 0; + } + + @Override + public void setFinished() + { + for (Item item : _items) + { + item.remove(); + } + } + + @Override + public void tick() + { + Iterator> itel = _ruptures.iterator(); + + while (itel.hasNext()) + { + Pair pair = itel.next(); + + if (pair.getLeft().distance(pair.getRight()) > 0) + { + Vector vec = pair.getRight().toVector().subtract(pair.getLeft().toVector()); + + if (vec.length() > 1) + { + vec = vec.normalize(); + } + + pair.getLeft().add(vec); + } + + if (pair.getLeft().distance(pair.getRight()) < 0.1) + { + if (!_ruptureTime.containsKey(pair.getLeft())) + { + _ruptureTime.put(pair.getLeft(), System.currentTimeMillis()); + } + else if (UtilTime.elapsed(_ruptureTime.get(pair.getLeft()), 150)) + { + itel.remove(); + + explodeRupture(pair.getLeft()); + } + } + } + + if (_tick % 10 == 0 && _rupturesLeft > 0) + { + _rupturesLeft--; + + Location loc = getLocation().add(UtilMath.random.nextFloat() - 0.5, 0, UtilMath.random.nextFloat() - 0.5); + + loc.setY(loc.getBlockY()); + + for (int y = 0; y > -3; y--) + { + if (!UtilBlock.airFoliage(loc.getBlock().getRelative(0, y, 0))) + { + loc.setY(loc.getY() + y); + break; + } + } + + Player player = getTarget(); + + if (player != null) + { + _targetted.add(player.getName()); + + Location target = player.getLocation(); + target.setY(loc.getY()); + + _ruptures.add(Pair.create(loc, target)); + + UtilEnt.CreatureLook(getEntity(), player.getLocation()); + + EntityIronGolem golem = ((CraftIronGolem) getEntity()).getHandle(); + + golem.world.broadcastEntityEffect(golem, (byte) 4); + } + else + { + _rupturesLeft = 0; + } + } + + for (Pair pair : _ruptures) + { + pair.getLeft().getWorld().playSound(pair.getLeft(), Sound.DIG_GRAVEL, 2.5F, 0.9F); + + { + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.DIRT, 0), + pair.getLeft().clone().add(0, 1.1, 0), 1F, 0, 1F, 0, 70, ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + + _tick++; + } + + @Override + public Player getTarget() + { + Player target = null; + double dist = 0; + + for (Player player : UtilPlayer.getNearby(getLocation(), 30, true)) + { + if (!player.hasLineOfSight(getEntity())) + { + continue; + } + + if (_targetted.contains(player.getName())) + { + continue; + } + + double d = player.getLocation().distance(getLocation()); + + if (d < 7) + { + continue; + } + + boolean valid = true; + + for (Pair loc : _ruptures) + { + if (loc.getRight().distance(player.getLocation()) < 1.5) + { + valid = false; + break; + } + } + + if (!valid) + { + continue; + } + + if (target == null || dist > d) + { + target = player; + dist = d; + } + } + + return target; + } + + @SuppressWarnings("deprecation") + private void explodeRupture(Location loc) + { + loc.add(0, 1.1, 0); + loc.setX(loc.getBlockX() + 0.5); + loc.setZ(loc.getBlockZ() + 0.5); + + // Fling + HashMap targets = UtilEnt.getInRadius(loc, 3.5); + for (LivingEntity cur : targets.keySet()) + { + // Velocity + UtilAction.velocity(cur, + UtilAlg.getTrajectory2d(loc.toVector().add(new Vector(0.5, 0, 0.5)), cur.getLocation().toVector()), + 0.8 + 0.8 * targets.get(cur), true, 0, 0.4 + 1.0 * targets.get(cur), 1.4, true); + + // Condition + getBoss().getEvent().getCondition().Factory().Falling("Rupture", cur, getEntity(), 10, false, true); + + // Damage Event + getBoss().getEvent().getDamageManager().NewDamageEvent(cur, getEntity(), null, DamageCause.CUSTOM, + 8 * getBoss().getDifficulty(), false, true, false, "Iron Wizard", "Rupture"); + } + + List blocks = new ArrayList<>(); + + for (int x = -3; x <= 3; x++) + { + for (int z = -3; z <= 3; z++) + { + for (int y = 0; y <= 1; y++) + { + for (int i = 0; i < 2; i++) + { + if (Math.sqrt(x * x + z * z + y * y) <= 3) + { + blocks.add(loc.clone().add(x, y, z).getBlock()); + } + } + } + } + } + + Collections.shuffle(blocks); + + // Blocks + int done = 0; + Iterator itel = blocks.iterator(); + + while (done < 30 && itel.hasNext()) + { + Block block = itel.next(); + + Vector vec = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5).normalize(); + + if (!UtilBlock.airFoliage(block)) + { + continue; + } + + // Add Directional + vec.add(UtilAlg.getTrajectory(loc.getBlock().getLocation(), block.getLocation().add(0.5, 0, 0.5))); + + // Add Up + vec.add(new Vector(0, 1.6, 0)); + + vec.normalize(); + + // Scale + vec.multiply(0.1 + 0.3 * Math.random() + 0.6); + + // Block! + Item item = loc.getWorld().dropItem(block.getLocation().add(0.5, 0, 0.5), new ItemStack(Material.DIRT, 0)); + item.setVelocity(vec); + item.setPickupDelay(50000); + _items.add(item); + + // Effect + loc.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.STONE.getId()); + + done++; + } + + _ticksFinished = 20; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemSlam.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemSlam.java new file mode 100644 index 000000000..c4a5a01ab --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemSlam.java @@ -0,0 +1,271 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.inventory.InventoryPickupItemEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; + +public class GolemSlam extends BossAbility +{ + private List _items = new ArrayList<>(); + private int _ticksFinished; + private int _stage; + private Vector _target; + private int _ticksJumped; + + public GolemSlam(GolemCreature creature) + { + super(creature); + + Player target = getTarget(); + + if (target != null) + { + _target = UtilAlg.calculateVelocity(getLocation().toVector(), + target.getLocation().toVector().setY(getLocation().getY()), 2, getEntity()); + } + } + + @Override + public boolean canMove() + { + return !UtilEnt.isGrounded(getEntity()) && _stage == 1; + } + + @Override + public boolean hasFinished() + { + return _stage == 2 && --_ticksFinished <= 0; + } + + @Override + public void setFinished() + { + for (Item item : _items) + { + item.remove(); + } + } + + @Override + public void tick() + { + Entity entity = getEntity(); + + if (_stage == 0) + { + UtilEnt.CreatureLook(getEntity(), getLocation().add(_target)); + + entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_THROW, 4, 0); + + entity.setVelocity(_target); + _stage++; + } + else if (_stage == 1) + { + _ticksJumped++; + + if (_ticksJumped > 4 && getLocation().subtract(0, 0.2, 0).getBlock().getType() != Material.AIR) + { + explodeRupture(getLocation()); + + _stage = 2; + } + } + } + + @EventHandler + public void HopperPickup(InventoryPickupItemEvent event) + { + if (_items.contains(event.getItem())) + { + event.setCancelled(true); + } + } + + @SuppressWarnings("deprecation") + @EventHandler + public void ItemDestroy(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_items.isEmpty()) + { + return; + } + + Iterator itemIterator = _items.iterator(); + + while (itemIterator.hasNext()) + { + Item item = itemIterator.next(); + + if (item.isDead() || !item.isValid()) + { + item.remove(); + itemIterator.remove(); + } + else if (UtilEnt.isGrounded(item) || item.getTicksLived() > 60) + { + item.getWorld().playEffect(item.getLocation(), Effect.STEP_SOUND, item.getItemStack().getTypeId()); + item.remove(); + itemIterator.remove(); + } + } + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public Player getTarget() + { + Player target = null; + double dist = 0; + + for (Player player : UtilPlayer.getNearby(getLocation(), 30, true)) + { + if (!player.hasLineOfSight(getEntity())) + { + continue; + } + + double d = player.getLocation().distance(getLocation()); + + if (d < 10) + { + continue; + } + + if (target == null || dist > d) + { + target = player; + dist = d; + } + } + + return target; + } + + @SuppressWarnings("deprecation") + private void explodeRupture(Location loc) + { + loc.add(0, 1.1, 0); + loc.setX(loc.getBlockX() + 0.5); + loc.setZ(loc.getBlockZ() + 0.5); + + // Fling + Map targets = UtilEnt.getInRadius(loc, 3.5); + for (LivingEntity cur : targets.keySet()) + { + if (cur.equals(getEntity())) + { + continue; + } + + // Velocity + UtilAction.velocity(cur, + UtilAlg.getTrajectory2d(loc.toVector().add(new Vector(0.5, 0, 0.5)), cur.getLocation().toVector()), + 0.8 + 0.8 * targets.get(cur), true, 0, 0.4 + 1.0 * targets.get(cur), 1.4, true); + + // Condition + getBoss().getEvent().getCondition().Factory().Falling("Rupture", cur, getEntity(), 10, false, true); + + // Damage Event + getBoss().getEvent().getDamageManager().NewDamageEvent(cur, getEntity(), null, DamageCause.CUSTOM, + 8 * getBoss().getDifficulty(), false, true, false, "Iron Wizard", "Rupture"); + } + + List blocks = new ArrayList(); + + for (int x = -3; x <= 3; x++) + { + for (int z = -3; z <= 3; z++) + { + for (int y = 0; y <= 1; y++) + { + for (int i = 0; i < 2; i++) + { + if (Math.sqrt(x * x + z * z + y * y) <= 3) + { + blocks.add(loc.clone().add(x, y, z).getBlock()); + } + } + } + } + } + + Collections.shuffle(blocks); + + // Blocks + int done = 0; + Iterator itel = blocks.iterator(); + + while (done < 30 && itel.hasNext()) + { + Block block = itel.next(); + + Vector vec = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5).normalize(); + + if (!UtilBlock.airFoliage(block)) + continue; + + // Add Directional + vec.add(UtilAlg.getTrajectory(loc.getBlock().getLocation(), block.getLocation().add(0.5, 0, 0.5))); + + // Add Up + vec.add(new Vector(0, 1.6, 0)); + + vec.normalize(); + + // Scale + vec.multiply(0.1 + 0.3 * Math.random() + 0.6); + + // Block! + Item item = loc.getWorld().dropItem(block.getLocation().add(0.5, 0, 0.5), new ItemStack(Material.DIRT, 0)); + item.setVelocity(vec); + item.setPickupDelay(50000); + _items.add(item); + + // Effect + loc.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.DIRT.getId()); + + done++; + } + + _ticksFinished = 20; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemSpike.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemSpike.java new file mode 100644 index 000000000..4f5dad106 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemSpike.java @@ -0,0 +1,104 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import org.bukkit.Sound; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; + +public class GolemSpike extends BossAbility +{ + private static final int SPIKE_HEIGHT = 2; + private static final long ATTACK_DURATION = 1000 + (500 * SPIKE_HEIGHT * 2); + private static final long SPIKE_REMAIN = 1000; + private long _start; + private List _spikes; + + public GolemSpike(GolemCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + _spikes = new ArrayList<>(); + } + + @Override + public int getCooldown() + { + return 15; + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, ATTACK_DURATION) && _spikes.isEmpty(); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - ATTACK_DURATION; + for (GroundSpike spike : _spikes) + { + spike.finish(); + } + _spikes.clear(); + } + + @Override + public void tick() + { + if (_spikes.isEmpty()) + { + for (Player player : UtilPlayer.getInRadius(getLocation(), 20).keySet()) + { + if (UtilEnt.isGrounded(player)) + { + player.playSound(player.getLocation(), Sound.STEP_STONE, 0.2f, 0.2f); + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getBoss().getEntity(), null, DamageCause.CUSTOM, 5 * getBoss().getDifficulty(), false, false, false, getBoss().getEntity().getName(), "Stone Spike"); + player.teleport(player.getLocation().add(0, SPIKE_HEIGHT, 0)); + UtilAction.velocity(player, player.getLocation().toVector().normalize().add(new Vector(0, 0.02, 0)).normalize()); + _spikes.add(new GroundSpike(player.getLocation().getBlock(), player.getLocation().getBlock().getRelative(0, -1, 0).getType(), new Random().nextInt(SPIKE_HEIGHT) + 2, SPIKE_REMAIN)); + } + } + } + else + { + List toRemove = new ArrayList<>(); + for (GroundSpike spike : _spikes) + { + spike.tick(); + if (spike.isFinished()) + { + toRemove.add(spike); + } + } + for (GroundSpike remove : toRemove) + { + _spikes.remove(remove); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemWallExplode.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemWallExplode.java new file mode 100644 index 000000000..aaebec6d4 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GolemWallExplode.java @@ -0,0 +1,419 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemCreature; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MovingObjectPosition; +import net.minecraft.server.v1_8_R3.Vec3D; + +public class GolemWallExplode extends BossAbility +{ + private Map> _blockWalls = new HashMap<>(); + private List _dontTarget = new ArrayList<>(); + private List _fallingBlocks = new ArrayList<>(); + private int _maxTimes = UtilMath.r(2) + 1; + private int _tick; + private int _timesDone; + private Map _wallTimers = new HashMap<>(); + + public GolemWallExplode(GolemCreature creature) + { + super(creature); + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public int getCooldown() + { + return 20; + } + + private float getMod(int div) + { + return UtilMath.random.nextFloat() / div; + } + + @Override + public Player getTarget() + { + for (Player player : UtilPlayer.getNearby(getLocation(), 15, true)) + { + if (_dontTarget.contains(player.getName())) + { + continue; + } + + if (player.getLocation().distance(getLocation()) <= 4) + { + continue; + } + + return player; + } + + return null; + } + + @Override + public boolean hasFinished() + { + return _wallTimers.isEmpty() && _fallingBlocks.isEmpty() && _timesDone >= _maxTimes; + } + + @SuppressWarnings("deprecation") + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator fallingIterator = _fallingBlocks.iterator(); + + while (fallingIterator.hasNext()) + { + FallingBlock cur = fallingIterator.next(); + + if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + fallingIterator.remove(); + + Block block = cur.getLocation().getBlock(); + block.setTypeIdAndData(0, (byte) 0, true); + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + + // Expire + if (cur.getTicksLived() > 400 + || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + { + cur.remove(); + continue; + } + + cur.remove(); + continue; + } + + double distanceToEntity = 0.0D; + LivingEntity victim = null; + + net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) cur).getHandle(); + Vec3D vec3d = new Vec3D(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + Vec3D vec3d1 = new Vec3D(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, + nmsEntity.locZ + nmsEntity.motZ); + + MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); + vec3d = new Vec3D(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); + vec3d1 = new Vec3D(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ); + + if (finalObjectPosition != null) + { + vec3d1 = new Vec3D(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c); + } + + for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(), + ((CraftEntity) cur).getHandle().getBoundingBox().a(((CraftEntity) cur).getHandle().motX, + ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) + { + Entity bukkitEntity = ((net.minecraft.server.v1_8_R3.Entity) entity).getBukkitEntity(); + + if (bukkitEntity instanceof LivingEntity) + { + LivingEntity ent = (LivingEntity) bukkitEntity; + + // Avoid Self + if (ent.equals(getEntity())) + continue; + + // Creative or Spec + if (ent instanceof Player) + if (((Player) ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent)) + continue; + + // float f1 = (float)(nmsEntity.boundingBox.a() * 0.6f); + AxisAlignedBB axisalignedbb1 = ((CraftEntity) ent).getHandle().getBoundingBox().grow(1F, 1F, 1F); + MovingObjectPosition entityCollisionPosition = axisalignedbb1.a(vec3d, vec3d1); + + if (entityCollisionPosition != null) + { + double d1 = vec3d.distanceSquared(entityCollisionPosition.pos); + if ((d1 < distanceToEntity) || (distanceToEntity == 0.0D)) + { + victim = ent; + distanceToEntity = d1; + } + } + } + } + + if (victim != null) + { + cur.getWorld().playEffect(victim.getEyeLocation().subtract(0, 0.5, 0), Effect.STEP_SOUND, cur.getBlockId()); + + if (canDamage(victim)) + { + getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null, + DamageCause.CONTACT, 10 * getBoss().getDifficulty(), true, true, false, "Iron Wizard Wall Explosion", + "Iron Wizard Wall Explosion"); + } + + cur.remove(); + fallingIterator.remove(); + + Vector vec = cur.getVelocity(); + + UtilAction.velocity(victim, vec, 1.5, true, 0, 0.2, 1, true); + } + else if (finalObjectPosition != null) + { + Block block = cur.getWorld().getBlockAt(((int) finalObjectPosition.pos.a), ((int) finalObjectPosition.pos.b), ((int) finalObjectPosition.pos.c)); + + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) + { + nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); + nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); + nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); + float f2 = MathHelper.sqrt( + nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ); + nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; + nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; + nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; + + cur.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, cur.getBlockId()); + cur.remove(); + fallingIterator.remove(); + } + } + else + { + UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), + cur.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, + UtilServer.getPlayers()); + } + } + } + + @Override + public void setFinished() + { + for (FallingBlock block : _fallingBlocks) + { + block.remove(); + } + + for (List list : _blockWalls.values()) + { + for (Block b : list) + { + b.setType(Material.AIR); + } + } + } + + @SuppressWarnings("deprecation") + @Override + public void tick() + { + if (_tick++ % 30 == 0 && _timesDone < _maxTimes) + { + _dontTarget.clear(); + + _timesDone++; + + for (int i = 0; i < 10; i++) + { + Player target = getTarget(); + + if (target == null) + { + if (_dontTarget.isEmpty()) + { + _timesDone = _maxTimes; + } + } + else + { + _dontTarget.add(target.getName()); + + UtilEnt.CreatureLook(getEntity(), target); + + BlockFace face = UtilShapes.getFacing(getLocation().getYaw()); + + if (_wallTimers.containsKey(face)) + { + continue; + } + + ArrayList blocks = new ArrayList(); + + Location loc = getLocation().getBlock().getLocation().add(0.5, 0, 0.5); + + int mul = (face.getModX() != 0 && face.getModZ() != 0) ? 2 : 3; + + loc.add(face.getModX() * mul, 0, face.getModZ() * mul); + + Block b = loc.getBlock(); + + BlockFace sideFace = UtilShapes.getSideBlockFaces(face, true)[0]; + boolean invalid = false; + + for (int mult = -3; mult <= 3; mult++) + { + Block block = b; + + if (Math.abs(mult) < 3) + { + block = block.getRelative(face); + } + + block = block.getRelative(sideFace, mult); + + if (Math.abs(mult) == 3 && face.getModX() != 0 && face.getModZ() != 0) + { + block = block.getRelative(UtilShapes.getSideBlockFaces(face, false)[mult < 0 ? 0 : 1]); + } + + if (!UtilAlg.HasSight(getLocation(), block.getLocation())) + { + invalid = true; + break; + } + + Block under = block.getRelative(0, -1, 0); + + if (!UtilBlock.solid(under)) + { + continue; + } + + for (int y = 0; y <= 1; y++) + { + block = block.getRelative(0, y, 0); + + if (block.getType() != Material.AIR) + { + invalid = true; + break; + } + + blocks.add(block); + } + + if (invalid) + { + break; + } + } + + if (invalid) + { + continue; + } + + for (Block block : blocks) + { + block.setType(block.getWorld().getBlockAt(block.getX(), b.getY() - 1, block.getZ()).getType()); + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); + } + + _blockWalls.put(face, blocks); + _wallTimers.put(face, System.currentTimeMillis()); + break; + } + } + } + + Iterator>> itel = _blockWalls.entrySet().iterator(); + boolean doExplode = false; + + while (itel.hasNext()) + { + Entry> entry = itel.next(); + BlockFace face = entry.getKey(); + + if (UtilTime.elapsed(_wallTimers.get(face), 1000)) + { + doExplode = true; + itel.remove(); + _wallTimers.remove(face); + + for (Block b : entry.getValue()) + { + FallingBlock block = getEntity().getWorld().spawnFallingBlock(b.getLocation().add(0.5, 0, 0.5), b.getType(), + (byte) 0); + + block.setDropItem(false); + + int index = entry.getValue().indexOf(b); + + BlockFace f = index == 8 || index == 9 ? BlockFace.SELF + : UtilShapes.getSideBlockFaces(face, true)[index > 6 ? 0 : 1]; + + block.setVelocity(new Vector((face.getModX() * 0.6) + (f.getModX() * (0.05 + getMod(10))), 0.2 + getMod(15), + (face.getModZ() * 0.6) + (f.getModZ() * (0.05 + getMod(10))))); + + _fallingBlocks.add(block); + + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getTypeId()); + b.setType(Material.AIR); + } + } + } + + if (doExplode) + { + onUpdate(new UpdateEvent(UpdateType.TICK)); + } + } + + @Override + public boolean inProgress() + { + return false; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GroundSpike.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GroundSpike.java new file mode 100644 index 000000000..40d2989e3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/GroundSpike.java @@ -0,0 +1,122 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import java.util.LinkedList; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; + +public class GroundSpike +{ + private Block _initial; + private Material _type; + private int _max, _height; + private long _lastTick, _remain; + private LinkedList _blocks; + private boolean _shrinking, _finished; + + public GroundSpike(Block first, Material type, int maxHeight, long remainDuration) + { + _initial = first; + _type = type; + _height = 0; + _max = maxHeight; + _remain = remainDuration; + _lastTick = System.currentTimeMillis(); + _blocks = new LinkedList<>(); + _shrinking = false; + _finished = false; + } + + @SuppressWarnings("deprecation") + private void raise() + { + if ((_height + 1) < _max) + { + _lastTick = System.currentTimeMillis(); + Block b = _initial.getRelative(0, _height, 0); + for (Player player : UtilServer.getPlayers()) + { + player.sendBlockChange(b.getLocation(), _type, (byte)0); + } + _blocks.add(b); + _height++; + } + else + { + if (UtilTime.elapsed(_lastTick, _remain)) + { + _shrinking = true; + lower(); + } + } + } + + @SuppressWarnings("deprecation") + private void lower() + { + _height = Math.min(_blocks.size() - 1, _height); + if ((_height - 1) >= 0) + { + _lastTick = System.currentTimeMillis(); + for (Player player : UtilServer.getPlayers()) + { + player.sendBlockChange(_blocks.get(_height).getLocation(), Material.AIR, (byte)0); + } + _blocks.remove(_height); + _height--; + } + else + { + finish(); + } + } + + public boolean isFinished() + { + if (!_blocks.isEmpty()) + { + return false; + } + + return _finished; + } + + @SuppressWarnings("deprecation") + public void finish() + { + _finished = true; + for (Block block : _blocks) + { + for (Player player : UtilServer.getPlayers()) + { + player.sendBlockChange(block.getLocation(), Material.AIR, (byte)0); + } + } + _blocks.clear(); + } + + public void tick() + { + if (isFinished()) + { + return; + } + if (!UtilTime.elapsed(_lastTick, 500)) + { + return; + } + + if (_shrinking) + { + lower(); + } + else + { + raise(); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/IronHook.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/IronHook.java new file mode 100644 index 000000000..73ddfce16 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/abilities/IronHook.java @@ -0,0 +1,54 @@ +package mineplex.game.clans.clans.worldevent.boss.ironwizard.abilities; + +import org.bukkit.block.Block; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; + +public class IronHook implements IThrown +{ + private WorldEvent _host; + + public IronHook(WorldEvent event) + { + _host = event; + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + data.getThrown().remove(); + + if (!(data.getThrower() instanceof IronGolem)) + return; + + IronGolem wizard = (IronGolem)data.getThrower(); + + if (target == null) + return; + + UtilAction.velocity(target, UtilAlg.getTrajectory(target.getLocation(), wizard.getLocation()), 5, false, 0, 0.7, 1.2, true); + + _host.getCondition().Factory().Falling("Iron Hook", target, wizard, 10, false, true); + + _host.getDamageManager().NewDamageEvent(target, wizard, null, DamageCause.CUSTOM, 5, false, true, false, wizard.getName(), "Iron Hook"); + } + + @Override + public void Idle(ProjectileUser data) + { + data.getThrown().remove(); + } + + @Override + public void Expire(ProjectileUser data) + { + data.getThrown().remove(); + } +} \ No newline at end of file From 21759c35c99ef63570bf4f925abc6a4f0e91bfae Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 23:20:02 -0400 Subject: [PATCH 113/283] Added boxes to clans and used lambda for mount gui --- .../game/clans/clans/ClansManager.java | 3 + .../game/clans/clans/boxes/BoxManager.java | 236 ++++++++++++++++++ .../clans/clans/boxes/BoxOverviewPage.java | 45 ++++ .../game/clans/clans/boxes/BoxShop.java | 21 ++ .../game/clans/clans/mounts/MountManager.java | 5 +- .../clans/mounts/gui/MountOverviewPage.java | 104 ++++---- 6 files changed, 355 insertions(+), 59 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxShop.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 31544c31e..266558b6e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -90,6 +90,7 @@ 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.boxes.BoxManager; import mineplex.game.clans.clans.commands.ClanManagementCommand; import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand; @@ -475,6 +476,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati new MountManager(plugin, clientManager, donationManager); + new BoxManager(plugin); + _restartManager = new RestartManager(plugin); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java new file mode 100644 index 000000000..2f2726480 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java @@ -0,0 +1,236 @@ +package mineplex.game.clans.clans.boxes; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.inventory.CraftItemEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Pair; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.ClansManager; + +public class BoxManager extends MiniPlugin +{ + public BoxManager(JavaPlugin plugin) + { + super("Box Manager", plugin); + + final BoxShop shop = new BoxShop(this); + + addCommand(new CommandBase(this, Rank.ALL, "boxes", "box") + { + @Override + public void Execute(Player caller, String[] args) + { + shop.attemptShopOpen(caller); + } + }); + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void onCraftWithDye(PrepareItemCraftEvent event) + { + if (event.getInventory().getResult() == null) + { + return; + } + if (event.getInventory().getResult().getType() == Material.LAPIS_BLOCK) + { + for (ItemStack item : event.getInventory().getMatrix()) + { + if (item == null) + { + continue; + } + if (item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equals(C.cGold + "Dye")) + { + event.getInventory().setResult(null); + return; + } + } + } + for (ItemStack item : event.getInventory().getMatrix()) + { + if (item == null) + { + continue; + } + if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName() || !item.getItemMeta().getDisplayName().equals(C.cGold + "Dye")) + { + event.getInventory().setResult(null); + } + } + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void onCraftWithDye(CraftItemEvent event) + { + if (event.getInventory().getResult() == null) + { + return; + } + if (event.getInventory().getResult().getType() == Material.LAPIS_BLOCK) + { + for (ItemStack item : event.getInventory().getMatrix()) + { + if (item == null) + { + continue; + } + if (item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equals(C.cGold + "Dye")) + { + event.setCancelled(true); + return; + } + } + } + for (ItemStack item : event.getInventory().getMatrix()) + { + if (item == null) + { + continue; + } + if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName() || !item.getItemMeta().getDisplayName().equals(C.cGold + "Dye")) + { + event.setCancelled(true); + return; + } + } + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void onPlaceDyeInAnvil(InventoryClickEvent event) + { + if (!(event.getWhoClicked() instanceof Player)) + { + return; + } + if (!event.getInventory().getType().equals(InventoryType.ANVIL)) + { + return; + } + if (!(event.getCursor() != null && event.getCursor().hasItemMeta() && event.getCursor().getItemMeta().hasDisplayName() && event.getCursor().getItemMeta().getDisplayName().equals(C.cGold + "Dye")) && !(event.getCurrentItem() != null && event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasDisplayName() && event.getCurrentItem().getItemMeta().getDisplayName().equals(C.cGold + "Dye"))) + { + return; + } + event.setCancelled(true); + } + + public static enum BoxType + { + @SuppressWarnings("deprecation") + BUILDER_BOX("Clans Builder Box", C.cGold + "Builder's Box", Material.GLOWSTONE, player -> + { + Map, ItemStack> replace = new HashMap<>(); + replace.put(Pair.create(Material.STONE, (byte)0), new ItemStack(Material.STAINED_CLAY)); + replace.put(Pair.create(Material.GLASS, (byte)0), new ItemStack(Material.STAINED_GLASS)); + replace.put(Pair.create(Material.THIN_GLASS, (byte)0), new ItemStack(Material.STAINED_GLASS_PANE)); + + for (int slot = 0; slot < player.getInventory().getSize(); slot++) + { + ItemStack item = player.getInventory().getItem(slot); + if (item == null) + { + continue; + } + ItemStack after = replace.get(Pair.create(item.getType(), item.getData().getData())); + if (after != null) + { + after.setAmount(item.getAmount()); + player.getInventory().setItem(slot, after); + } + } + + UtilPlayer.message(player, F.main("Builder's Box", "You have redeemed your box contents!")); + }), + @SuppressWarnings("deprecation") + DYE_BOX("Clans Dye Box", C.cGreen + "Dye Box", Material.INK_SACK, DyeColor.RED.getDyeData(), player -> + { + List commonColors = Arrays.asList(DyeColor.values()).stream().filter(c -> c != DyeColor.BLACK && c != DyeColor.WHITE).collect(Collectors.toList()); + List rareColors = Arrays.asList(DyeColor.WHITE, DyeColor.BLACK); + for (int i = 0; i < 6; i++) + { + DyeColor color = null; + if (Math.random() <= 0.40) + { + color = rareColors.get(UtilMath.r(rareColors.size())); + } + else + { + color = rareColors.get(UtilMath.r(commonColors.size())); + } + + player.getInventory().addItem(new ItemBuilder(Material.INK_SACK).setData(color.getDyeData()).setTitle(C.cGold + "Dye").build()); + } + UtilPlayer.message(player, F.main("Dye Box", "You have redeemed your box contents!")); + }), + ; + + private String _itemName, _displayName; + private ItemBuilder _displayBuilder; + private Consumer _itemGenerator; + + private BoxType(String itemName, String displayName, Material displayMaterial, Consumer itemGenerator) + { + _itemName = itemName; + _displayName = displayName; + _displayBuilder = new ItemBuilder(displayMaterial).setTitle(displayName).addLore(C.cRed); + _itemGenerator = itemGenerator; + } + + private BoxType(String itemName, String displayName, Material displayMaterial, short data, Consumer itemGenerator) + { + _itemName = itemName; + _displayName = displayName; + _displayBuilder = new ItemBuilder(displayMaterial).setData(data).setTitle(displayName).addLore(C.cRed); + _itemGenerator = itemGenerator; + } + + public String getItemName() + { + return _itemName; + } + + public String getDisplayName() + { + return _displayName; + } + + public ItemStack getDisplayItem(int owned) + { + ItemBuilder newBuilder = new ItemBuilder(_displayBuilder.build()); + if (owned > 0) + { + newBuilder.setGlow(true); + } + return newBuilder.addLore(C.cGreenB + "Owned: " + C.cWhite + owned).build(); + } + + public void generateRewards(Player player) + { + ClansManager.getInstance().getInventoryManager().addItemToInventory(player, getItemName(), -1); + _itemGenerator.accept(player); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java new file mode 100644 index 000000000..ca1ca7d6f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java @@ -0,0 +1,45 @@ +package mineplex.game.clans.clans.boxes; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.boxes.BoxManager.BoxType; + +public class BoxOverviewPage extends ShopPageBase +{ + public BoxOverviewPage(BoxManager plugin, BoxShop shop, String name, Player player) + { + super(plugin, shop, ClansManager.getInstance().getClientManager(), ClansManager.getInstance().getDonationManager(), name, player, 9); + + buildPage(); + } + + @Override + protected void buildPage() + { + int[] slots = {3, 5}; + for (int i = 0; i < BoxType.values().length && i < slots.length; i++) + { + BoxType type = BoxType.values()[i]; + int slot = slots[i]; + final int owns = ClansManager.getInstance().getInventoryManager().Get(getPlayer()).getItemCount(type.getItemName()); + IButton button = (player, clickType) -> + { + if (owns < 1) + { + playDenySound(player); + } + else + { + player.closeInventory(); + player.playSound(player.getLocation(), Sound.CHEST_OPEN, 1f, 1f); + type.generateRewards(player); + } + }; + addButton(slot, type.getDisplayItem(owns), button); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxShop.java new file mode 100644 index 000000000..bc7e8a852 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxShop.java @@ -0,0 +1,21 @@ +package mineplex.game.clans.clans.boxes; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ClansManager; + +public class BoxShop extends ShopBase +{ + public BoxShop(BoxManager plugin) + { + super(plugin, ClansManager.getInstance().getClientManager(), ClansManager.getInstance().getDonationManager(), "Your Boxes"); + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return new BoxOverviewPage(getPlugin(), this, "Your Boxes", player); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java index 1ca4513bd..31875f5ba 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -61,7 +61,6 @@ public class MountManager extends MiniDbClientPlugin private final MountRepository _repository; private final DonationManager _donationManager; - private final MountShop _shop; private final Map _spawnedMounts = new HashMap<>(); private final Map> _summoning = new WeakHashMap<>(); @@ -73,14 +72,14 @@ public class MountManager extends MiniDbClientPlugin _repository = new MountRepository(plugin, this); _donationManager = donationManager; - _shop = new MountShop(this); + final MountShop shop = new MountShop(this); addCommand(new CommandBase(this, Rank.ALL, "mounts", "mount") { @Override public void Execute(Player caller, String[] args) { - _shop.attemptShopOpen(caller); + shop.attemptShopOpen(caller); } }); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java index 3dae4f1da..6e9b9fbad 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java @@ -82,42 +82,38 @@ public class MountOverviewPage extends ShopPageBase { Pair tokens = horses.get(i); item = toItem(tokens.getLeft(), tokens.getRight(), true); - button = new IButton() + button = (player, clickType) -> { - @Override - public void onClick(Player player, ClickType clickType) + if (clickType == ClickType.LEFT) { - if (clickType == ClickType.LEFT) - { - if (!getPlugin().summonMount(player, tokens.getLeft())) - { - playDenySound(player); - } - } - else if (clickType == ClickType.RIGHT) + if (!getPlugin().summonMount(player, tokens.getLeft())) { playDenySound(player); - //getShop().openPageForPlayer(player, page); } - else if (clickType == ClickType.SHIFT_RIGHT) + } + else if (clickType == ClickType.RIGHT) + { + playDenySound(player); + //getShop().openPageForPlayer(player, page); + } + else if (clickType == ClickType.SHIFT_RIGHT) + { + getShop().openPageForPlayer(player, new ConfirmationPage(player, MountOverviewPage.this, new ConfirmationProcessor() { - getShop().openPageForPlayer(player, new ConfirmationPage(player, MountOverviewPage.this, new ConfirmationProcessor() - { - @Override - public void init(Inventory inventory) {} + @Override + public void init(Inventory inventory) {} - @Override - public void process(ConfirmationCallback callback) + @Override + public void process(ConfirmationCallback callback) + { + getPlugin().getRepository().deleteMount(tokens.getLeft(), id -> { - getPlugin().getRepository().deleteMount(tokens.getLeft(), id -> - { - getPlugin().Get(getPlayer()).removeMount(id.intValue()); - MountOverviewPage.this.refresh(); - callback.resolve("Mount successfully deleted!"); - }); - } - }, toItem(tokens.getLeft(), tokens.getRight(), false))); - } + getPlugin().Get(getPlayer()).removeMount(id.intValue()); + MountOverviewPage.this.refresh(); + callback.resolve("Mount successfully deleted!"); + }); + } + }, toItem(tokens.getLeft(), tokens.getRight(), false))); } }; } @@ -132,42 +128,38 @@ public class MountOverviewPage extends ShopPageBase { Pair tokens = donkeys.get(i); item = toItem(tokens.getLeft(), tokens.getRight(), true); - button = new IButton() + button = (player, clickType) -> { - @Override - public void onClick(Player player, ClickType clickType) + if (clickType == ClickType.LEFT) { - if (clickType == ClickType.LEFT) - { - if (!getPlugin().summonMount(player, tokens.getLeft())) - { - playDenySound(player); - } - } - else if (clickType == ClickType.RIGHT) + if (!getPlugin().summonMount(player, tokens.getLeft())) { playDenySound(player); - //getShop().openPageForPlayer(player, page); } - else if (clickType == ClickType.SHIFT_RIGHT) + } + else if (clickType == ClickType.RIGHT) + { + playDenySound(player); + //getShop().openPageForPlayer(player, page); + } + else if (clickType == ClickType.SHIFT_RIGHT) + { + getShop().openPageForPlayer(player, new ConfirmationPage(player, new MountOverviewPage(getPlugin(), getShop(), getName(), getPlayer()), new ConfirmationProcessor() { - getShop().openPageForPlayer(player, new ConfirmationPage(player, new MountOverviewPage(getPlugin(), getShop(), getName(), getPlayer()), new ConfirmationProcessor() - { - @Override - public void init(Inventory inventory) {} + @Override + public void init(Inventory inventory) {} - @Override - public void process(ConfirmationCallback callback) + @Override + public void process(ConfirmationCallback callback) + { + getPlugin().getRepository().deleteMount(tokens.getLeft(), id -> { - getPlugin().getRepository().deleteMount(tokens.getLeft(), id -> - { - getPlugin().Get(getPlayer()).removeMount(id.intValue()); - MountOverviewPage.this.refresh(); - callback.resolve("Mount successfully deleted!"); - }); - } - }, toItem(tokens.getLeft(), tokens.getRight(), false))); - } + getPlugin().Get(getPlayer()).removeMount(id.intValue()); + MountOverviewPage.this.refresh(); + callback.resolve("Mount successfully deleted!"); + }); + } + }, toItem(tokens.getLeft(), tokens.getRight(), false))); } }; } From b1b12babf0d47d137fee4b73c18d8692be6e145c Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 May 2017 23:41:48 -0400 Subject: [PATCH 114/283] Slight fixes to boxes --- .../src/mineplex/game/clans/clans/boxes/BoxManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java index 2f2726480..bc1439c65 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java @@ -154,7 +154,7 @@ public class BoxManager extends MiniPlugin { continue; } - ItemStack after = replace.get(Pair.create(item.getType(), item.getData().getData())); + ItemStack after = new ItemBuilder(replace.get(Pair.create(item.getType(), item.getData().getData()))).setData(DyeColor.values()[UtilMath.r(DyeColor.values().length)].getWoolData()).build(); if (after != null) { after.setAmount(item.getAmount()); @@ -178,7 +178,7 @@ public class BoxManager extends MiniPlugin } else { - color = rareColors.get(UtilMath.r(commonColors.size())); + color = commonColors.get(UtilMath.r(commonColors.size())); } player.getInventory().addItem(new ItemBuilder(Material.INK_SACK).setData(color.getDyeData()).setTitle(C.cGold + "Dye").build()); From 9fcf718e65d6b51c81a552c8cf74e97837ef9e09 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 8 May 2017 23:21:19 -0400 Subject: [PATCH 115/283] Tweak dye boxes --- .../game/clans/clans/boxes/BoxManager.java | 39 ++-- .../clans/clans/boxes/BoxOverviewPage.java | 6 +- .../clans/boxes/extra/DyeBoxSpinner.java | 169 ++++++++++++++++++ .../game/clans/clans/map/ItemMapRenderer.java | 22 +-- 4 files changed, 198 insertions(+), 38 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/DyeBoxSpinner.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java index bc1439c65..cef70aa3b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java @@ -1,11 +1,8 @@ package mineplex.game.clans.clans.boxes; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.function.Consumer; -import java.util.stream.Collectors; import org.bukkit.DyeColor; import org.bukkit.Material; @@ -16,6 +13,7 @@ import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; @@ -29,6 +27,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemBuilder; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.boxes.extra.DyeBoxSpinner; public class BoxManager extends MiniPlugin { @@ -137,6 +136,19 @@ public class BoxManager extends MiniPlugin event.setCancelled(true); } + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (event.getItem() == null || !event.getItem().hasItemMeta() || !event.getItem().getItemMeta().hasDisplayName()) + { + return; + } + if (event.getItem().getItemMeta().getDisplayName().equals(C.cGold + "Dye")) + { + event.setCancelled(true); + } + } + public static enum BoxType { @SuppressWarnings("deprecation") @@ -165,26 +177,7 @@ public class BoxManager extends MiniPlugin UtilPlayer.message(player, F.main("Builder's Box", "You have redeemed your box contents!")); }), @SuppressWarnings("deprecation") - DYE_BOX("Clans Dye Box", C.cGreen + "Dye Box", Material.INK_SACK, DyeColor.RED.getDyeData(), player -> - { - List commonColors = Arrays.asList(DyeColor.values()).stream().filter(c -> c != DyeColor.BLACK && c != DyeColor.WHITE).collect(Collectors.toList()); - List rareColors = Arrays.asList(DyeColor.WHITE, DyeColor.BLACK); - for (int i = 0; i < 6; i++) - { - DyeColor color = null; - if (Math.random() <= 0.40) - { - color = rareColors.get(UtilMath.r(rareColors.size())); - } - else - { - color = commonColors.get(UtilMath.r(commonColors.size())); - } - - player.getInventory().addItem(new ItemBuilder(Material.INK_SACK).setData(color.getDyeData()).setTitle(C.cGold + "Dye").build()); - } - UtilPlayer.message(player, F.main("Dye Box", "You have redeemed your box contents!")); - }), + DYE_BOX("Clans Dye Box", C.cGreen + "Dye Box", Material.INK_SACK, DyeColor.RED.getDyeData(), DyeBoxSpinner::createSpinner), ; private String _itemName, _displayName; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java index ca1ca7d6f..76f74bb39 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java @@ -3,6 +3,7 @@ package mineplex.game.clans.clans.boxes; import org.bukkit.Sound; import org.bukkit.entity.Player; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.IButton; import mineplex.core.shop.page.ShopPageBase; import mineplex.game.clans.clans.ClansManager; @@ -36,7 +37,10 @@ public class BoxOverviewPage extends ShopPageBase { player.closeInventory(); player.playSound(player.getLocation(), Sound.CHEST_OPEN, 1f, 1f); - type.generateRewards(player); + if (Recharge.Instance.use(player, "Clans Box Click", 1000, false, false)) + { + type.generateRewards(player); + } } }; addButton(slot, type.getDisplayItem(owns), button); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/DyeBoxSpinner.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/DyeBoxSpinner.java new file mode 100644 index 000000000..03f5d5ead --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/DyeBoxSpinner.java @@ -0,0 +1,169 @@ +package mineplex.game.clans.clans.boxes.extra; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import org.bukkit.Bukkit; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class DyeBoxSpinner implements Listener +{ + private Player _player; + private Inventory _inv; + private int _step; + private List _items; + + private boolean _givenRewards = false; + + private DyeBoxSpinner(Player player) + { + _player = player; + _inv = Bukkit.createInventory(player, 27, "Dye Box"); + _step = 0; + _items = new ArrayList<>(); + buildGUI(); + generateRewards(); + player.openInventory(_inv); + Bukkit.getPluginManager().registerEvents(this, UtilServer.getPlugin()); + } + + /** + * Upper and lower bounds are inclusive + */ + private int getRandom(int max, int min) + { + return UtilMath.r(max - min + 1) + min; + } + + @SuppressWarnings("deprecation") + private void buildGUI() + { + ItemStack border = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short)DyeColor.GRAY.getWoolData()).setTitle(C.cRed + " ").build(); + ItemStack fill = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short)DyeColor.BLACK.getWoolData()).setTitle(C.cRed + " ").build(); + for (int i = 0; i < 27; i++) + { + if (i < 9 || i > 17) + { + _inv.setItem(i, border); + } + else + { + _inv.setItem(i, fill); + } + } + } + + @SuppressWarnings("deprecation") + private void generateRewards() + { + List commonColors = Arrays.asList(DyeColor.values()).stream().filter(c -> c != DyeColor.BLACK && c != DyeColor.WHITE).collect(Collectors.toList()); + List rareColors = Arrays.asList(DyeColor.WHITE, DyeColor.BLACK); + for (int i = 1; i <= getRandom(9, 5); i++) + { + DyeColor color = null; + if (Math.random() <= 0.05) + { + color = rareColors.get(UtilMath.r(rareColors.size())); + } + else + { + color = commonColors.get(UtilMath.r(commonColors.size())); + } + + _items.add(new ItemBuilder(Material.INK_SACK).setData(color.getDyeData()).setTitle(C.cGold + "Dye").build()); + } + } + + private void giveRewards() + { + if (_givenRewards) + { + return; + } + _givenRewards = true; + _player.closeInventory(); + _items.forEach(_player.getInventory()::addItem); + UtilPlayer.message(_player, F.main("Dye Box", "You have redeemed your box contents!")); + } + + @SuppressWarnings("deprecation") + private void progress() + { + if (_step == 0) + { + _step++; + return; + } + if (_step < 10) + { + int slot = 18 - _step; + if (Math.max(18, slot) - Math.min(18, slot) <= _items.size()) + { + _inv.setItem(slot, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short)DyeColor.LIME.getWoolData()).setTitle(C.cRed + " ").build()); + } + _step++; + return; + } + if (_step == 10) + { + int slot = 17; + for (int i = 0; i < _items.size(); i++) + { + _inv.setItem(slot, _items.get(i)); + slot--; + } + _step++; + return; + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.FASTEST) + { + if (_player.getOpenInventory() == null || _player.getOpenInventory().getTopInventory() == null || !_player.getOpenInventory().getTopInventory().getName().equals("Dye Box")) + { + HandlerList.unregisterAll(this); + giveRewards(); + } + } + if (event.getType() == UpdateType.SEC) + { + progress(); + } + } + + @EventHandler + public void onClick(InventoryClickEvent event) + { + if (event.getWhoClicked().getEntityId() == _player.getEntityId()) + { + event.setCancelled(true); + } + } + + public static void createSpinner(Player player) + { + new DyeBoxSpinner(player); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java index 69835e4ae..07ac8f1cf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java @@ -1,20 +1,6 @@ package mineplex.game.clans.clans.map; import java.awt.Color; -import java.util.List; - -import mineplex.core.common.util.UtilTime; -import mineplex.core.recharge.Recharge; -import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.ClansUtility; -import mineplex.game.clans.clans.worldevent.WorldEventManager; -import mineplex.game.clans.tutorial.TutorialManager; -import mineplex.game.clans.tutorial.TutorialRegion; -import mineplex.game.clans.tutorial.TutorialType; -import mineplex.game.clans.tutorial.map.TutorialMapManager; -import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial; -import mineplex.minecraft.game.core.boss.EventState; -import mineplex.minecraft.game.core.boss.WorldEvent; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -26,6 +12,14 @@ import org.bukkit.map.MapPalette; import org.bukkit.map.MapRenderer; import org.bukkit.map.MapView; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansUtility; +import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.clans.worldevent.api.EventState; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; +import mineplex.game.clans.tutorial.TutorialManager; + public class ItemMapRenderer extends MapRenderer { private ItemMapManager _manager; From fdd48b51d44bdbcb8086ad41e47033b69d1b0b0d Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 14 May 2017 00:36:14 -0400 Subject: [PATCH 116/283] Start work on raids --- .../clans/worldevent/raid/RaidManager.java | 13 + .../clans/worldevent/raid/WorldData.java | 507 ++++++++++++++++++ 2 files changed, 520 insertions(+) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java new file mode 100644 index 000000000..1e406352a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java @@ -0,0 +1,13 @@ +package mineplex.game.clans.clans.worldevent.raid; + +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; + +public class RaidManager extends MiniPlugin +{ + public RaidManager(JavaPlugin plugin) + { + super("Raid Manager", plugin); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java new file mode 100644 index 000000000..9aa91a1d4 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java @@ -0,0 +1,507 @@ +package mineplex.game.clans.clans.worldevent.raid; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.bukkit.Difficulty; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.WorldCreator; +import org.spigotmc.SpigotConfig; + +import com.mineplex.spigot.ChunkPreLoadEvent; + +import mineplex.core.common.api.enderchest.EnderchestWorldLoader; +import mineplex.core.common.timing.TimingManager; +import mineplex.core.common.util.FileUtil; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.WorldUtil; +import mineplex.core.common.util.ZipUtil; +import mineplex.core.common.util.worldgen.WorldGenCleanRoom; + +public class WorldData +{ + public int Id = -1; + + public String RaidName; + + public String File = null; + public String Folder = null; + + public World World; + public int MinX = 0; + public int MinZ = 0; + public int MaxX = 0; + public int MaxZ = 0; + + public int MinY = -1; + public int MaxY = 256; + + public Map> SpawnLocs = new LinkedHashMap<>(); + private Map> DataLocs = new LinkedHashMap<>(); + private Map> CustomLocs = new LinkedHashMap<>(); + private final Map _dataEntries = new LinkedHashMap<>(); + + public WorldData(String raidName) + { + Initialize(); + + Id = getNewId(); + } + + public void Initialize() + { + GetFile(); + + UtilServer.runAsync(() -> + { + WorldData.this.UnzipWorld(); + UtilServer.runSync(() -> + { + TimingManager.start("WorldData loading world."); + + WorldCreator creator = new WorldCreator(GetFolder()); + creator.generator(new WorldGenCleanRoom()); + World = WorldUtil.LoadWorld(creator); + + + TimingManager.stop("WorldData loading world."); + + World.setDifficulty(Difficulty.HARD); + World.setGameRuleValue("showDeathMessages", "false"); + + TimingManager.start("WorldData loading WorldConfig."); + //Load World Data + WorldData.this.LoadWorldConfig(); + TimingManager.stop("WorldData loading WorldConfig."); + }); + }); + } + + protected String GetFile() + { + if (File == null) + { + GameType game = null; + int gameRandom = UtilMath.r(Host.GetFiles().size()); + int i = 0; + for(GameType type : Host.GetFiles().keySet()) + { + if(i == gameRandom) + { + game = type; + break; + } + i++; + } + Game = game; + int map; + try + { + map = UtilMath.r(Host.GetFiles().get(game).size()); + } catch (IllegalArgumentException e) + { + System.out.println("No maps found!"); + return null; + } + File = Host.GetFiles().get(game).get(map); + + //Don't allow repeat maps. + if (Host.GetFiles().get(game).size() > 1) + { + while (File.equals(Host.Manager.GetGameCreationManager().GetLastMap())) + { + GameType _game = null; + int _gameRandom = UtilMath.r(Host.GetFiles().size()); + int _i = 0; + for(GameType _type : Host.GetFiles().keySet()) + { + if(_i == _gameRandom) + { + _game = _type; + break; + } + _i++; + } + int _map = UtilMath.r(Host.GetFiles().get(game).size()); + File = Host.GetFiles().get(_game).get(_map); + } + } + } + + Host.Manager.GetGameCreationManager().SetLastMap(File); + + return File; + } + + public String GetFolder() + { + if (Folder == null) + { + Folder = RaidName + Id + "_" + GetGame().GetName() + "_" + GetFile(); + } + return Folder; + } + + protected void UnzipWorld() + { + TimingManager.start("UnzipWorld creating folders"); + String folder = GetFolder(); + new File(folder).mkdir(); + new File(folder + java.io.File.separator + "region").mkdir(); + new File(folder + java.io.File.separator + "data").mkdir(); + TimingManager.stop("UnzipWorld creating folders"); + + TimingManager.start("UnzipWorld UnzipToDirectory"); + ZipUtil.UnzipToDirectory("../../update/maps/" + GetGame().GetName() + "/" + GetFile() + ".zip", folder); + TimingManager.stop("UnzipWorld UnzipToDirectory"); + } + + public void LoadWorldConfig() + { + //Load Track Data + String line = null; + + try + { + FileInputStream fstream = new FileInputStream(GetFolder() + java.io.File.separator + "WorldConfig.dat"); + DataInputStream in = new DataInputStream(fstream); + BufferedReader br = new BufferedReader(new InputStreamReader(in)); + + List currentTeam = null; + List currentData = null; + + int currentDirection = 0; + + while ((line = br.readLine()) != null) + { + String[] tokens = line.split(":"); + + if (tokens.length < 2) + continue; + + if (tokens[0].length() == 0) + continue; + + //Name & Author + if (tokens[0].equalsIgnoreCase("MAP_NAME")) + { + MapName = tokens[1]; + } + else if (tokens[0].equalsIgnoreCase("MAP_AUTHOR")) + { + MapAuthor = tokens[1]; + } + + //Spawn Locations + else if (tokens[0].equalsIgnoreCase("TEAM_NAME")) + { + SpawnLocs.put(tokens[1], new ArrayList()); + currentTeam = SpawnLocs.get(tokens[1]); + currentDirection = 0; + } + else if (tokens[0].equalsIgnoreCase("TEAM_DIRECTION")) + { + currentDirection = Integer.parseInt(tokens[1]); + } + else if (tokens[0].equalsIgnoreCase("TEAM_SPAWNS")) + { + for (int i=1 ; i()); + currentData = DataLocs.get(tokens[1]); + } + else if (tokens[0].equalsIgnoreCase("DATA_LOCS")) + { + for (int i=1 ; i()); + currentData = CustomLocs.get(tokens[1]); + } + else if (tokens[0].equalsIgnoreCase("CUSTOM_LOCS")) + { + for (int i=1 ; i= MinX >> 4 && x <= MaxX >> 4 && z >= MinZ >> 4 && z <= MaxZ >> 4) + { + return; + } + + event.setCancelled(true); + } + + public int getNewId() + { + File file = new File(RaidName + "RaidId.dat"); + + int id = 0; + + //Write If Blank + if (!file.exists()) + { + try ( + FileWriter fstream = new FileWriter(file); + BufferedWriter out = new BufferedWriter(fstream); + ) + { + out.write("0"); + } + catch (Exception e) + { + System.out.println("Error: Raid World GetId Write Exception"); + } + } + else + { + try ( + FileInputStream fstream = new FileInputStream(file); + DataInputStream in = new DataInputStream(fstream); + BufferedReader br = new BufferedReader(new InputStreamReader(in)); + ) + { + String line = br.readLine(); + + id = Integer.parseInt(line); + } + catch (Exception e) + { + System.out.println("Error: Raid World GetId Read Exception"); + } + } + + try ( + FileWriter fstream = new FileWriter(file); + BufferedWriter out = new BufferedWriter(fstream); + ) + { + out.write("" + (id + 1)); + } + catch (Exception e) + { + System.out.println("Error: Game World GetId Re-Write Exception"); + } + + return id; + } + + public List getDataLocs(String data) + { + if (!DataLocs.containsKey(data)) + { + return new ArrayList(); + } + + return DataLocs.get(data); + } + + public List getCustomLocs(String id) + { + if (!CustomLocs.containsKey(id)) + { + return new ArrayList<>(); + } + + return CustomLocs.get(id); + } + + public Map> getAllCustomLocs() + { + return CustomLocs; + } + + public Map> getAllDataLocs() + { + return DataLocs; + } + + public Location getRandomXZ() + { + Location loc = new Location(World, 0, 250, 0); + + int xVar = MaxX - MinX; + int zVar = MaxZ - MinZ; + + loc.setX(MinX + UtilMath.r(xVar)); + loc.setZ(MinZ + UtilMath.r(zVar)); + + return loc; + } + + public String get(String key) + { + return _dataEntries.get(key); + } +} \ No newline at end of file From e94201409b7dcb46ace232e229877614d4d1ebec Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 1 Jun 2017 02:15:43 -0400 Subject: [PATCH 117/283] Finalize raid system and implement Charles Witherton Raid --- .../mineplex/core/common/util/UtilMath.java | 32 ++ .../mineplex/core/common/util/UtilPlayer.java | 24 +- .../clans/worldevent/WorldEventManager.java | 12 + .../clans/worldevent/api/WorldEvent.java | 8 +- .../clans/worldevent/boss/BossWorldEvent.java | 2 + .../worldevent/boss/ironwizard/GolemBoss.java | 2 +- .../clans/worldevent/raid/RaidAltar.java | 197 +++++++++++++ .../clans/worldevent/raid/RaidChallenge.java | 62 ++++ .../clans/worldevent/raid/RaidCreature.java | 16 + .../clans/worldevent/raid/RaidManager.java | 146 ++++++++++ .../clans/clans/worldevent/raid/RaidType.java | 27 ++ .../clans/worldevent/raid/RaidWorldEvent.java | 273 ++++++++++++++++++ .../clans/worldevent/raid/WorldData.java | 199 ++++++------- .../raid/command/StartRaidCommand.java | 42 +++ .../worldevent/raid/wither/WitherRaid.java | 100 +++++++ .../wither/challenge/five/ChallengeFive.java | 164 +++++++++++ .../raid/wither/challenge/five/IronGate.java | 82 ++++++ .../wither/challenge/four/ChallengeFour.java | 139 +++++++++ .../raid/wither/challenge/four/FakeBlock.java | 37 +++ .../wither/challenge/one/ChallengeOne.java | 104 +++++++ .../challenge/seven/ChallengeSeven.java | 161 +++++++++++ .../wither/challenge/six/ChallengeSix.java | 94 ++++++ .../challenge/three/ChallengeThree.java | 125 ++++++++ .../challenge/three/ChallengeTorch.java | 42 +++ .../wither/challenge/two/ChallengeTwo.java | 72 +++++ .../creature/archer/ArcherShooting.java | 94 ++++++ .../creature/archer/DecayingArcher.java | 65 +++++ .../wither/creature/corpse/CorpsePassive.java | 43 +++ .../creature/corpse/ReanimatedCorpse.java | 67 +++++ .../raid/wither/creature/giant/Goliath.java | 59 ++++ .../wither/creature/giant/GoliathPassive.java | 60 ++++ .../wither/creature/mage/KnightPassive.java | 67 +++++ .../raid/wither/creature/mage/MageBlink.java | 67 +++++ .../raid/wither/creature/mage/MageBolt.java | 86 ++++++ .../raid/wither/creature/mage/MageSummon.java | 80 +++++ .../wither/creature/mage/UndeadKnight.java | 71 +++++ .../raid/wither/creature/mage/UndeadMage.java | 171 +++++++++++ .../wither/creature/magma/BlazeMinion.java | 45 +++ .../raid/wither/creature/magma/Cataclysm.java | 58 ++++ .../raid/wither/creature/magma/HeatingUp.java | 74 +++++ .../creature/magma/InfernalMinions.java | 44 +++ .../raid/wither/creature/magma/Magmus.java | 70 +++++ .../wither/creature/magma/MagmusPassive.java | 56 ++++ .../wither/creature/magma/UndeadAlly.java | 31 ++ .../creature/silverfish/PitSwarmer.java | 59 ++++ .../creature/silverfish/SwarmerPassive.java | 49 ++++ .../wither/creature/wither/BlackHole.java | 118 ++++++++ .../wither/creature/wither/CharlesSkulls.java | 189 ++++++++++++ .../creature/wither/CharlesWitherton.java | 95 ++++++ .../raid/wither/creature/wither/Decay.java | 79 +++++ .../raid/wither/creature/wither/Flight.java | 62 ++++ .../raid/wither/creature/wither/LifeSap.java | 116 ++++++++ .../wither/creature/wither/MiniCharles.java | 73 +++++ .../creature/wither/MiniCharlesSkulls.java | 117 ++++++++ .../wither/creature/wither/SummonCorpse.java | 52 ++++ .../wither/creature/wither/SummonMinions.java | 51 ++++ .../wither/creature/wither/SummonUndead.java | 52 ++++ .../wither/creature/wither/WitherWave.java | 91 ++++++ .../game/clans/gameplay/safelog/SafeLog.java | 6 + .../game/clans/items/rares/RunedPickaxe.java | 21 +- .../game/clans/restart/RestartManager.java | 5 +- 61 files changed, 4580 insertions(+), 125 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidChallenge.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidCreature.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidType.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/command/StartRaidCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/six/ChallengeSix.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/two/ChallengeTwo.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/ArcherShooting.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/DecayingArcher.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/CorpsePassive.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/ReanimatedCorpse.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/Goliath.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/GoliathPassive.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/KnightPassive.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBlink.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBolt.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageSummon.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadKnight.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadMage.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/BlazeMinion.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Cataclysm.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/InfernalMinions.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusPassive.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/UndeadAlly.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/PitSwarmer.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/SwarmerPassive.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/BlackHole.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesSkulls.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Decay.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Flight.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/LifeSap.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharlesSkulls.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonCorpse.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonMinions.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonUndead.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/WitherWave.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java index 90dc0fd6c..5e37e0ac5 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java @@ -300,4 +300,36 @@ public class UtilMath { return n - ((int) ((int) n)); } + + public static int getMax(int... ints) + { + if (ints.length < 1) + { + return -1; + } + int max = ints[0]; + + for (int i = 1; i < ints.length; i++) + { + max = Math.max(max, ints[i]); + } + + return max; + } + + public static int getMin(int... ints) + { + if (ints.length < 1) + { + return -1; + } + int min = ints[0]; + + for (int i = 1; i < ints.length; i++) + { + min = Math.min(min, ints[i]); + } + + return min; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 19b7b6059..0bb9502f6 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -595,8 +595,13 @@ public class UtilPlayer return nearbyMap; } - + public static Player getClosest(Location loc, Collection ignore) + { + return getClosest(loc, -1, ignore); + } + + public static Player getClosest(Location loc, double maxDist, Collection ignore) { Player best = null; double bestDist = 0; @@ -613,6 +618,11 @@ public class UtilPlayer continue; double dist = UtilMath.offset(cur.getLocation(), loc); + + if (maxDist > 0 && dist > maxDist) + { + continue; + } if (best == null || dist < bestDist) { @@ -623,8 +633,13 @@ public class UtilPlayer return best; } - + public static Player getClosest(Location loc, Entity... ignore) + { + return getClosest(loc, -1, ignore); + } + + public static Player getClosest(Location loc, double maxDist, Entity... ignore) { Player best = null; double bestDist = 0; @@ -655,6 +670,11 @@ public class UtilPlayer } double dist = UtilMath.offset(cur.getLocation(), loc); + + if (maxDist > 0 && dist > maxDist) + { + continue; + } if (best == null || dist < bestDist) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index b3b3c5988..a7c44b7a6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -29,6 +29,7 @@ import mineplex.game.clans.clans.worldevent.api.EventState; import mineplex.game.clans.clans.worldevent.api.WorldEvent; import mineplex.game.clans.clans.worldevent.boss.BossArenaLocationFinder; import mineplex.game.clans.clans.worldevent.command.WorldEventCommand; +import mineplex.game.clans.clans.worldevent.raid.RaidManager; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.core.damage.DamageManager; @@ -49,6 +50,8 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement private long _nextEventStart; + private RaidManager _raidManager; + public WorldEventManager(JavaPlugin plugin, ClansManager clansManager, DamageManager damageManager, LootManager lootManager, BlockRestore blockRestore, ClansRegions clansRegions, SkillFactory skillFactory) { super("World Event", plugin); @@ -64,6 +67,8 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement _skillFactory = skillFactory; + _raidManager = new RaidManager(plugin); + updateNextEventTime(); } @@ -80,6 +85,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement event.stop(true); } _runningEvents.clear(); + _raidManager.onDisable(); } public boolean isInEvent(Location location) @@ -185,6 +191,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return null; } + public WorldEvent startEventFromType(WorldEventType eventType) { if (eventType != null) @@ -239,6 +246,11 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return _bossFinder; } + public RaidManager getRaidManager() + { + return _raidManager; + } + private void updateNextEventTime() { // 45 Minutes + (0 - 15 Minutes) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java index 5db224cbd..a0e662bc4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java @@ -237,14 +237,14 @@ public abstract class WorldEvent implements Listener, ScoreboardElement protected abstract void customTick(); - public final void cleanup() + public final void cleanup(boolean onDisable) { clearCreatures(); restoreBlocks(); - customCleanup(); + customCleanup(onDisable); } - public abstract void customCleanup(); + public abstract void customCleanup(boolean onDisable); public final void stop() { @@ -253,7 +253,7 @@ public abstract class WorldEvent implements Listener, ScoreboardElement public final void stop(boolean onDisable) { - cleanup(); + cleanup(onDisable); if (onDisable) { setState(EventState.REMOVED); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java index fcc770b43..dd34361c2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java @@ -3,6 +3,7 @@ package mineplex.game.clans.clans.worldevent.boss; import java.util.List; import java.util.stream.Collectors; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -89,6 +90,7 @@ public abstract class BossWorldEvent> extends WorldEv Location drop = event.getCreature().getLastKnownLocation(); UtilServer.CallEvent(new BossDeathEvent(this, drop)); ClansManager.getInstance().runSyncLater(() -> ClansManager.getInstance().getLootManager().dropRare(drop), DELAY_TILL_DROP_REWARD); + Bukkit.broadcastMessage(getDeathMessage()); } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java index 23c90c70f..cf729c0ea 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java @@ -40,7 +40,7 @@ public class GolemBoss extends BossWorldEvent protected void customTick() {} @Override - public void customCleanup() {} + public void customCleanup(boolean onDisable) {} @Override protected void customStop() {} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java new file mode 100644 index 000000000..e185d68e0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java @@ -0,0 +1,197 @@ +package mineplex.game.clans.clans.worldevent.raid; + +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ClansManager; + +public class RaidAltar +{ + private Block _altarBlock; + private RaidType _type; + private List _requiredItems; + + public RaidAltar(Block altarBlock, RaidType type, List requiredItems) + { + _altarBlock = altarBlock; + _type = type; + _requiredItems = requiredItems; + } + + @SuppressWarnings("deprecation") + private boolean has(Player player, Material type, String itemName, List lore, Byte data, Integer amount) + { + int count = 0; + for (ItemStack item : player.getInventory().getContents()) + { + boolean rejected = false; + if (item == null || item.getType() == Material.AIR) + { + continue; + } + if (type != null && item.getType() != type) + { + rejected = true; + } + if (itemName != null && (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName() || !item.getItemMeta().getDisplayName().equals(itemName))) + { + rejected = true; + } + if (lore != null) + { + if (!item.hasItemMeta() || !item.getItemMeta().hasLore()) + { + rejected = true; + } + else + { + List itemLore = item.getItemMeta().getLore(); + if (itemLore.size() != lore.size()) + { + rejected = true; + } + else + { + for (int i = 0; i < lore.size(); i++) + { + if (!itemLore.get(i).equals(lore.get(i))) + { + rejected = true; + } + } + } + } + } + if (data != null) + { + if (item.getData().getData() != data.byteValue()) + { + rejected = true; + } + } + + if (!rejected) + { + count++; + } + } + + if (amount != null) + { + return count >= amount.intValue(); + } + else + { + return count > 0; + } + } + + @SuppressWarnings("deprecation") + private void remove(Player player, Material type, String itemName, List lore, Byte data, int amount) + { + int removed = 0; + for (int i = 0; i < player.getInventory().getContents().length; i++) + { + ItemStack item = player.getInventory().getContents()[i]; + if (removed >= amount) + { + return; + } + boolean rejected = false; + if (item == null || item.getType() == Material.AIR) + { + continue; + } + if (type != null && item.getType() != type) + { + rejected = true; + } + if (itemName != null && (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName() || !item.getItemMeta().getDisplayName().equals(itemName))) + { + rejected = true; + } + if (lore != null) + { + if (!item.hasItemMeta() || !item.getItemMeta().hasLore()) + { + rejected = true; + } + else + { + List itemLore = item.getItemMeta().getLore(); + if (itemLore.size() != lore.size()) + { + rejected = true; + } + else + { + for (int index = 0; index < lore.size(); index++) + { + if (!itemLore.get(index).equals(lore.get(index))) + { + rejected = true; + } + } + } + } + } + if (data != null) + { + if (item.getData().getData() != data.byteValue()) + { + rejected = true; + } + } + + if (!rejected) + { + if (item.getAmount() > (amount - removed)) + { + item.setAmount(item.getAmount() - (amount - removed)); + } + else + { + player.getInventory().setItem(i, null); + } + } + } + + player.updateInventory(); + } + + @SuppressWarnings("deprecation") + public boolean handleInteract(Player player, Block block) + { + if (_altarBlock.equals(block)) + { + for (ItemStack required : _requiredItems) + { + String displayName = ((required.hasItemMeta() && required.getItemMeta().hasDisplayName()) ? required.getItemMeta().getDisplayName() : null); + List lore = ((required.hasItemMeta() && required.getItemMeta().hasLore()) ? required.getItemMeta().getLore() : null); + if (!has(player, required.getType(), displayName, lore, required.getData().getData(), required.getAmount())) + { + UtilPlayer.message(player, F.main(_type.getRaidName() + " Raid", "You do not have the required summoning items for this raid!")); + return true; + } + } + if (ClansManager.getInstance().getWorldEvent().getRaidManager().startRaid(player, _type)) + { + for (ItemStack required : _requiredItems) + { + String displayName = ((required.hasItemMeta() && required.getItemMeta().hasDisplayName()) ? required.getItemMeta().getDisplayName() : null); + List lore = ((required.hasItemMeta() && required.getItemMeta().hasLore()) ? required.getItemMeta().getLore() : null); + remove(player, required.getType(), displayName, lore, required.getData().getData(), required.getAmount()); + } + } + return true; + } + + return false; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidChallenge.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidChallenge.java new file mode 100644 index 000000000..896440803 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidChallenge.java @@ -0,0 +1,62 @@ +package mineplex.game.clans.clans.worldevent.raid; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; + +public abstract class RaidChallenge implements Listener +{ + private T _raid; + private String _name; + private boolean _completed; + + public RaidChallenge(T raid, String name) + { + _raid = raid; + _name = name; + _completed = false; + } + + public abstract void customStart(); + public abstract void customComplete(); + + public T getRaid() + { + return _raid; + } + + public String getName() + { + return _name; + } + + public boolean isComplete() + { + return _completed; + } + + public void start() + { + customStart(); + UtilServer.RegisterEvents(this); + UtilTextMiddle.display("", getName(), getRaid().getPlayers().toArray(new Player[getRaid().getPlayers().size()])); + } + + public void complete() + { + complete(false); + } + + public void complete(boolean onDisable) + { + if (!onDisable) + { + customComplete(); + } + HandlerList.unregisterAll(this); + _completed = true; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidCreature.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidCreature.java new file mode 100644 index 000000000..7d18b0fdc --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidCreature.java @@ -0,0 +1,16 @@ +package mineplex.game.clans.clans.worldevent.raid; + +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; + +import mineplex.game.clans.clans.worldevent.api.EventCreature; + +public abstract class RaidCreature extends EventCreature +{ + public RaidCreature(RaidWorldEvent event, Location spawnLocation, String name, boolean useName, double health, double walkRange, boolean healthRegen, Class entityClass) + { + super(event, spawnLocation, name, useName, health, walkRange, healthRegen, entityClass); + } + + public abstract void handleDeath(Location location); +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java index 1e406352a..a74b712a5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java @@ -1,13 +1,159 @@ package mineplex.game.clans.clans.worldevent.raid; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Consumer; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitTask; import mineplex.core.MiniPlugin; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.utils.UtilScheduler; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.worldevent.raid.command.StartRaidCommand; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; public class RaidManager extends MiniPlugin { + private static final int MAX_PARTICIPANTS = 10; + + private Set _raids = new HashSet<>(); + private List _altars = new ArrayList<>(); + public RaidManager(JavaPlugin plugin) { super("Raid Manager", plugin); + + addCommand(new StartRaidCommand(this)); + } + + @Override + public void disable() + { + _raids.forEach(raid -> raid.stop(true)); + _raids.clear(); + } + + public DisguiseManager getDisguiseManager() + { + return ClansManager.getInstance().getDisguiseManager(); + } + + public ProjectileManager getProjectileManager() + { + return ClansManager.getInstance().getProjectile(); + } + + public DamageManager getDamageManager() + { + return ClansManager.getInstance().getDamageManager(); + } + + public BlockRestore getBlockRestore() + { + return ClansManager.getInstance().getBlockRestore(); + } + + public ConditionManager getConditionManager() + { + return ClansManager.getInstance().getCondition(); + } + + public int getActiveRaids() + { + return _raids.size(); + } + + public boolean isInRaid(Location loc) + { + for (RaidWorldEvent event : _raids) + { + if (event.WorldData.World.equals(loc.getWorld())) + { + return true; + } + } + + return false; + } + + public boolean startRaid(Player player, RaidType type) + { + if (_raids.size() >= 5) + { + UtilPlayer.message(player, F.main(type.getRaidName() + " Raid", "There are currently too many ongoing raids to start a new one!")); + return false; + } + Set inside = UtilPlayer.getInRadius(player.getLocation(), 4).keySet(); + if (inside.size() > MAX_PARTICIPANTS) + { + UtilPlayer.message(player, F.main(type.getRaidName() + " Raid", "You cannot start a raid with more than " + MAX_PARTICIPANTS + " participants!")); + return false; + } + inside.forEach(in -> UtilPlayer.message(in, F.main(type.getRaidName() + " Raid", "Summoning ancient power..."))); + createNewRaid(type, raid -> inside.forEach(in -> + { + raid.addPlayer(player); + player.getWorld().strikeLightningEffect(player.getLocation()); + })); + return true; + } + + public void createNewRaid(RaidType type, Consumer raidConsumer) + { + final WorldData data = new WorldData(type.getRaidName()); + BukkitTask task = UtilScheduler.runEvery(UpdateType.TICK, () -> + { + if (data.Loaded) + { + try + { + RaidWorldEvent event = type.getClazz().getConstructor(WorldData.class, RaidManager.class).newInstance(data, this); + raidConsumer.accept(event); + event.start(); + } + catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) + { + UtilServer.runSyncLater(data::uninitialize, 120); + e.printStackTrace(); + } + while (data.LoadChecker == null) {} + data.LoadChecker.cancel(); + } + }); + data.LoadChecker = task; + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!event.hasBlock()) + { + return; + } + + for (RaidAltar altar : _altars) + { + if (altar.handleInteract(event.getPlayer(), event.getClickedBlock())) + { + event.setCancelled(true); + return; + } + } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidType.java new file mode 100644 index 000000000..ab655304c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidType.java @@ -0,0 +1,27 @@ +package mineplex.game.clans.clans.worldevent.raid; + +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public enum RaidType +{ + CHARLES_WITHERTON("Charles Witherton", WitherRaid.class); + + private String _raidName; + private Class _clazz; + + private RaidType(String raidName, Class clazz) + { + _raidName = raidName; + _clazz = clazz; + } + + public String getRaidName() + { + return _raidName; + } + + public Class getClazz() + { + return _clazz; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java new file mode 100644 index 000000000..09b0fefae --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java @@ -0,0 +1,273 @@ +package mineplex.game.clans.clans.worldevent.raid; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.world.ChunkUnloadEvent; + +import mineplex.core.common.util.F; +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.UtilTime.TimeUnit; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; +import mineplex.game.clans.clans.worldevent.api.EventState; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; +import mineplex.game.clans.spawn.Spawn; + +public abstract class RaidWorldEvent extends WorldEvent +{ + private static int nextId = 0; + + protected RaidManager Manager; + protected WorldData WorldData; + + protected final int Id; + + protected List Players = new ArrayList<>(); + + protected long _forceEnd = -1; + + public RaidWorldEvent(String name, WorldData data, RaidManager manager) + { + super(name, new Location(data.World, data.MinX + ((data.MaxX - data.MinX) / 2), data.MinY + ((data.MaxY - data.MinY) / 2), data.MinZ + ((data.MaxZ - data.MinZ) / 2)), UtilMath.getMax((data.MaxX - data.MinX) / 2, (data.MaxY - data.MinY) / 2, (data.MaxZ - data.MinZ) / 2), false, manager.getDisguiseManager(), manager.getProjectileManager(), manager.getDamageManager(), manager.getBlockRestore(), manager.getConditionManager()); + + Id = nextId++; + Manager = manager; + WorldData = data; + + loadNecessaryChunks(); + customLoad(); + } + + protected abstract void customLoad(); + + protected abstract void afterTeleportIn(); + + private void loadNecessaryChunks() + { + int minX = WorldData.MinX >> 4; + int minZ = WorldData.MinZ >> 4; + int maxX = WorldData.MaxX >> 4; + int maxZ = WorldData.MaxZ >> 4; + + for (int x = minX; x <= maxX; x++) + { + for (int z = minZ; z <= maxZ; z++) + { + WorldData.World.getChunkAt(x, z); + } + } + } + + public mineplex.game.clans.clans.worldevent.raid.WorldData getWorldData() + { + return WorldData; + } + + public List getPlayers() + { + return Players; + } + + public int getId() + { + return Id; + } + + @Override + public void customStart() + { + _forceEnd = System.currentTimeMillis() + UtilTime.convert(90, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + int spawnIndex = 0; + List spawns = WorldData.SpawnLocs.get("Red"); + for (Player player : Players) + { + if (spawnIndex >= spawns.size()) + { + spawnIndex = 0; + } + player.teleport(spawns.get(spawnIndex)); + spawnIndex++; + } + afterTeleportIn(); + } + + @Override + public void customCleanup(boolean onDisable) + { + Players.forEach(player -> player.teleport(Spawn.getNorthSpawn())); + Players.clear(); + if (onDisable) + { + WorldData.uninitialize(); + } + else + { + UtilServer.runSyncLater(WorldData::uninitialize, 120); + } + } + + public void addPlayer(Player player) + { + Players.add(player); + } + + public void setForceEnd(long end) + { + _forceEnd = end; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (getState() != EventState.LIVE) + { + return; + } + if (Players.isEmpty()) + { + stop(); + } + else + { + updateLastActive(); + } + if (_forceEnd != -1 && System.currentTimeMillis() >= _forceEnd) + { + stop(); + } + } + + @EventHandler + public void onCreatureDeath(EventCreatureDeathEvent event) + { + if (!event.getCreature().getEvent().getName().equals(getName())) + { + return; + } + RaidWorldEvent worldEvent = (RaidWorldEvent) event.getCreature().getEvent(); + if (worldEvent.Id != Id) + { + return; + } + if (event.getCreature() instanceof RaidCreature) + { + ((RaidCreature)event.getCreature()).handleDeath(event.getCreature().getLastKnownLocation()); + } + } + + @EventHandler + public void onChunkUnload(ChunkUnloadEvent event) + { + if (getState() == EventState.STOPPED || this.getState() == EventState.REMOVED) + { + return; + } + if (!event.getWorld().equals(WorldData.World)) + { + return; + } + event.setCancelled(true); + } + + @EventHandler + public void breakBlock(BlockBreakEvent event) + { + Block block = event.getBlock(); + Player player = event.getPlayer(); + + if (player.getGameMode() == GameMode.CREATIVE) + { + return; + } + + if (!block.getWorld().equals(WorldData.World)) + { + return; + } + + event.setCancelled(true); + UtilPlayer.message(player, F.main(getName(), "You cannot build here!")); + } + + @EventHandler + public void placeBlock(BlockPlaceEvent event) + { + Block block = event.getBlock(); + Player player = event.getPlayer(); + + if (player.getGameMode() == GameMode.CREATIVE) + { + return; + } + + if (!block.getWorld().equals(WorldData.World)) + { + return; + } + + event.setCancelled(true); + UtilPlayer.message(player, F.main(getName(), "You cannot build here!")); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onQuit(PlayerQuitEvent event) + { + if (Players.remove(event.getPlayer())) + { + event.getPlayer().teleport(Spawn.getNorthSpawn()); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDie(PlayerDeathEvent event) + { + if (Players.remove(event.getEntity())) + { + UtilServer.runSyncLater(() -> event.getEntity().teleport(Spawn.getNorthSpawn()), 5); + } + } + + @EventHandler + public void onTpHome(ClansCommandExecutedEvent event) + { + if (event.getCommand().equalsIgnoreCase("tphome") || event.getCommand().equalsIgnoreCase("stuck")) + { + if (Players.contains(event.getPlayer())) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport while in a raid!")); + } + } + } + + @Override + public boolean equals(Object object) + { + if (!(object instanceof RaidWorldEvent)) + { + return false; + } + + return ((RaidWorldEvent)object).getId() == getId(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java index 9aa91a1d4..4eee372c0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java @@ -8,7 +8,6 @@ import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -17,11 +16,8 @@ import org.bukkit.Difficulty; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.WorldCreator; -import org.spigotmc.SpigotConfig; +import org.bukkit.scheduler.BukkitTask; -import com.mineplex.spigot.ChunkPreLoadEvent; - -import mineplex.core.common.api.enderchest.EnderchestWorldLoader; import mineplex.core.common.timing.TimingManager; import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.MapUtil; @@ -37,6 +33,10 @@ public class WorldData public String RaidName; + public boolean Loaded = false; + + protected BukkitTask LoadChecker = null; + public String File = null; public String Folder = null; @@ -56,27 +56,82 @@ public class WorldData public WorldData(String raidName) { - Initialize(); + initialize(); Id = getNewId(); + RaidName = raidName; } - public void Initialize() + private List loadFiles() { - GetFile(); + TimingManager.start("RaidManager LoadFiles"); + + File folder = new File(".." + java.io.File.separatorChar + ".." + java.io.File.separatorChar + "update" + java.io.File.separatorChar + + "maps" + java.io.File.separatorChar + "Clans" + java.io.File.separatorChar + "Raids" + java.io.File.separatorChar + RaidName); + System.out.println(folder.getAbsolutePath() + " -=-=-=-=-="); + if (!folder.exists()) + { + folder.mkdirs(); + } + + List maps = new ArrayList<>(); + + System.out.println("Searching Maps in: " + folder); + + if (folder.listFiles() != null) + { + for (File file : folder.listFiles()) + { + if (!file.isFile()) + { + System.out.println(file.getName() + " is not a file!"); + continue; + } + + String name = file.getName(); + + if (name.length() < 5) + { + continue; + } + + name = name.substring(name.length() - 4, name.length()); + + if (!name.equals(".zip")) + { + System.out.println(file.getName() + " is not a zip."); + continue; + } + + maps.add(file.getName().substring(0, file.getName().length() - 4)); + } + } + + for (String map : maps) + { + System.out.println("Found Map: " + map); + } + + TimingManager.stop("RaidManager LoadFiles"); + + return maps; + } + + public void initialize() + { + getFile(); UtilServer.runAsync(() -> { - WorldData.this.UnzipWorld(); + WorldData.this.unzipWorld(); UtilServer.runSync(() -> { TimingManager.start("WorldData loading world."); - WorldCreator creator = new WorldCreator(GetFolder()); + WorldCreator creator = new WorldCreator(getFolder()); creator.generator(new WorldGenCleanRoom()); World = WorldUtil.LoadWorld(creator); - TimingManager.stop("WorldData loading world."); World.setDifficulty(Difficulty.HARD); @@ -84,99 +139,63 @@ public class WorldData TimingManager.start("WorldData loading WorldConfig."); //Load World Data - WorldData.this.LoadWorldConfig(); + WorldData.this.loadWorldConfig(); TimingManager.stop("WorldData loading WorldConfig."); }); }); } - protected String GetFile() + protected String getFile() { if (File == null) { - GameType game = null; - int gameRandom = UtilMath.r(Host.GetFiles().size()); - int i = 0; - for(GameType type : Host.GetFiles().keySet()) - { - if(i == gameRandom) - { - game = type; - break; - } - i++; - } - Game = game; int map; try { - map = UtilMath.r(Host.GetFiles().get(game).size()); - } catch (IllegalArgumentException e) + map = UtilMath.r(loadFiles().size()); + } + catch (IllegalArgumentException e) { System.out.println("No maps found!"); return null; } - File = Host.GetFiles().get(game).get(map); - - //Don't allow repeat maps. - if (Host.GetFiles().get(game).size() > 1) - { - while (File.equals(Host.Manager.GetGameCreationManager().GetLastMap())) - { - GameType _game = null; - int _gameRandom = UtilMath.r(Host.GetFiles().size()); - int _i = 0; - for(GameType _type : Host.GetFiles().keySet()) - { - if(_i == _gameRandom) - { - _game = _type; - break; - } - _i++; - } - int _map = UtilMath.r(Host.GetFiles().get(game).size()); - File = Host.GetFiles().get(_game).get(_map); - } - } + File = loadFiles().get(map); } - - Host.Manager.GetGameCreationManager().SetLastMap(File); return File; } - public String GetFolder() + public String getFolder() { if (Folder == null) { - Folder = RaidName + Id + "_" + GetGame().GetName() + "_" + GetFile(); + Folder = RaidName + Id + "_" + getFile(); } return Folder; } - protected void UnzipWorld() + protected void unzipWorld() { TimingManager.start("UnzipWorld creating folders"); - String folder = GetFolder(); + String folder = getFolder(); new File(folder).mkdir(); new File(folder + java.io.File.separator + "region").mkdir(); new File(folder + java.io.File.separator + "data").mkdir(); TimingManager.stop("UnzipWorld creating folders"); TimingManager.start("UnzipWorld UnzipToDirectory"); - ZipUtil.UnzipToDirectory("../../update/maps/" + GetGame().GetName() + "/" + GetFile() + ".zip", folder); + ZipUtil.UnzipToDirectory("../../update/maps/Clans/Raids/" + RaidName + "/" + getFile() + ".zip", folder); TimingManager.stop("UnzipWorld UnzipToDirectory"); } - public void LoadWorldConfig() + public void loadWorldConfig() { //Load Track Data String line = null; try { - FileInputStream fstream = new FileInputStream(GetFolder() + java.io.File.separator + "WorldConfig.dat"); + FileInputStream fstream = new FileInputStream(getFolder() + java.io.File.separator + "WorldConfig.dat"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); @@ -195,20 +214,10 @@ public class WorldData if (tokens[0].length() == 0) continue; - //Name & Author - if (tokens[0].equalsIgnoreCase("MAP_NAME")) - { - MapName = tokens[1]; - } - else if (tokens[0].equalsIgnoreCase("MAP_AUTHOR")) - { - MapAuthor = tokens[1]; - } - //Spawn Locations - else if (tokens[0].equalsIgnoreCase("TEAM_NAME")) + if (tokens[0].equalsIgnoreCase("TEAM_NAME")) { - SpawnLocs.put(tokens[1], new ArrayList()); + SpawnLocs.put(tokens[1], new ArrayList<>()); currentTeam = SpawnLocs.get(tokens[1]); currentDirection = 0; } @@ -218,9 +227,9 @@ public class WorldData } else if (tokens[0].equalsIgnoreCase("TEAM_SPAWNS")) { - for (int i=1 ; i()); + DataLocs.put(tokens[1], new ArrayList<>()); currentData = DataLocs.get(tokens[1]); } else if (tokens[0].equalsIgnoreCase("DATA_LOCS")) { - for (int i=1 ; i()); + CustomLocs.put(tokens[1], new ArrayList<>()); currentData = CustomLocs.get(tokens[1]); } else if (tokens[0].equalsIgnoreCase("CUSTOM_LOCS")) { - for (int i=1 ; i= MinX >> 4 && x <= MaxX >> 4 && z >= MinZ >> 4 && z <= MaxZ >> 4) - { - return; - } - - event.setCancelled(true); - } public int getNewId() { @@ -461,7 +446,7 @@ public class WorldData { if (!DataLocs.containsKey(data)) { - return new ArrayList(); + return new ArrayList<>(); } return DataLocs.get(data); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/command/StartRaidCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/command/StartRaidCommand.java new file mode 100644 index 000000000..5701d38a2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/command/StartRaidCommand.java @@ -0,0 +1,42 @@ +package mineplex.game.clans.clans.worldevent.raid.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.worldevent.raid.RaidManager; +import mineplex.game.clans.clans.worldevent.raid.RaidType; + +public class StartRaidCommand extends CommandBase +{ + public StartRaidCommand(RaidManager plugin) + { + super(plugin, Rank.ADMIN, "startraid"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /startraid ")); + return; + } + try + { + RaidType type = RaidType.valueOf(args[0]); + Plugin.startRaid(caller, type); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "That is not an existing raid type. Raids:")); + for (RaidType type : RaidType.values()) + { + UtilPlayer.message(caller, C.cGray + " - " + C.cYellow + type.name()); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java new file mode 100644 index 000000000..db88e0286 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java @@ -0,0 +1,100 @@ +package mineplex.game.clans.clans.worldevent.raid.wither; + +import java.lang.reflect.InvocationTargetException; +import java.util.LinkedList; +import java.util.List; + +import org.bukkit.Location; + +import mineplex.game.clans.clans.worldevent.api.EventState; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.RaidManager; +import mineplex.game.clans.clans.worldevent.raid.RaidType; +import mineplex.game.clans.clans.worldevent.raid.RaidWorldEvent; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.five.ChallengeFive; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.four.ChallengeFour; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.one.ChallengeOne; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.seven.ChallengeSeven; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.three.ChallengeThree; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.two.ChallengeTwo; + +public class WitherRaid extends RaidWorldEvent +{ + private final List>> _challenges = new LinkedList<>(); + private RaidChallenge _currentChallenge; + + public WitherRaid(mineplex.game.clans.clans.worldevent.raid.WorldData data, RaidManager manager) + { + super(RaidType.CHARLES_WITHERTON.getRaidName(), data, manager); + } + + private void nextChallenge() + { + _currentChallenge = null; + + if (_challenges.isEmpty()) + { + return; + } + + Class> clazz = _challenges.remove(0); + try + { + _currentChallenge = clazz.getConstructor(WitherRaid.class).newInstance(this); + _currentChallenge.start(); + } + catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + + private void teleportToAltar() + { + Location altar = WorldData.getCustomLocs("MAIN_ALTAR").get(0); + Players.forEach(player -> player.teleport(altar)); + } + + @Override + protected void customLoad() + { + WorldData.World.setGameRuleValue("doDaylightCycle", "false"); + WorldData.World.setTime(14000); + _challenges.add(ChallengeOne.class); + _challenges.add(ChallengeTwo.class); + _challenges.add(ChallengeThree.class); + _challenges.add(ChallengeFour.class); + _challenges.add(ChallengeFive.class); + _challenges.add(ChallengeSix.class); + _challenges.add(ChallengeSeven.class); + } + + @Override + protected void afterTeleportIn() + { + nextChallenge(); + } + + @Override + protected void customTick() + { + if (_currentChallenge != null) + { + if (_currentChallenge.isComplete()) + { + teleportToAltar(); + nextChallenge(); + } + } + } + + @Override + protected void customStop() + { + if (_currentChallenge != null) + { + _currentChallenge.complete(getState() == EventState.REMOVED); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java new file mode 100644 index 000000000..dab6871b4 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java @@ -0,0 +1,164 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.five; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.archer.DecayingArcher; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.corpse.ReanimatedCorpse; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.giant.Goliath; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadKnight; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; + +public class ChallengeFive extends RaidChallenge +{ + private Location _altar; + private boolean _teleported = false; + private LinkedList _gates = new LinkedList<>(); + private Goliath _goliath; + + public ChallengeFive(WitherRaid raid) + { + super(raid, "Rapid Escape"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + } + + private void teleportIn() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Run!")); + player.teleport(getRaid().getWorldData().getCustomLocs("C_FIVE_ENTER").get(0)); + }); + } + + @Override + public void customStart() + { + int i = 1; + while (getRaid().getWorldData().getAllCustomLocs().containsKey("C_FIVE_G" + i)) + { + List> creatures = new ArrayList<>(); + for (Location loc : getRaid().getWorldData().getCustomLocs("C_FIVE_G" + i + "G")) + { + int type = UtilMath.r(3) + 1; + if (type == 1) + { + UndeadKnight knight = new UndeadKnight(this, loc); + getRaid().registerCreature(knight); + creatures.add(knight); + } + if (type == 2) + { + ReanimatedCorpse corpse = new ReanimatedCorpse(this, loc); + getRaid().registerCreature(corpse); + creatures.add(corpse); + } + if (type == 3) + { + DecayingArcher archer = new DecayingArcher(this, loc); + getRaid().registerCreature(archer); + creatures.add(archer); + } + } + _gates.add(new IronGate(this, getRaid().getWorldData().getCustomLocs("C_FIVE_G" + i), creatures)); + i++; + } + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Use the third gate!"))); + } + + @SuppressWarnings("deprecation") + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "You made it!")); + player.teleport(_altar); + }); + getRaid().getWorldData().getCustomLocs("GATE_THREE").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); + Block gate = getRaid().getWorldData().getCustomLocs("GATE_FOUR").get(0).getBlock(); + gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); + gate.setType(Material.SKULL); + gate.setData((byte)1); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + for (Player player : getRaid().getPlayers()) + { + if (UtilMath.offset(player.getLocation(), getRaid().getWorldData().getCustomLocs("C_FIVE_EXIT").get(0)) <= 3) + { + complete(); + return; + } + } + } + if (event.getType() == UpdateType.TICK) + { + if (!_gates.isEmpty() && _teleported) + { + IronGate gate = _gates.peek(); + if (UtilMath.offset2d(_goliath.getEntity().getLocation(), gate.getCenter()) > 5) + { + Location to = gate.getCenter().clone(); + to.setY(_goliath.getEntity().getLocation().getY()); + _goliath.getEntity().setVelocity(UtilAlg.getTrajectory(_goliath.getEntity().getLocation(), to).normalize().multiply(0.5)); + } + if (gate.update()) + { + _gates.poll(); + } + } + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!event.hasBlock()) + { + return; + } + + Block clicked = event.getClickedBlock(); + if (!_teleported) + { + if (clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_THREE").get(0).getBlock()) || clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_THREE").get(0).getBlock().getRelative(BlockFace.DOWN))) + { + _teleported = true; + teleportIn(); + } + } + } + + @EventHandler + public void onIcePrison(SkillTriggerEvent event) + { + if (getRaid().getPlayers().contains(event.GetPlayer()) && _teleported && (event.GetSkillName().equals("Ice Prison") || event.GetSkillName().equals("Fissure"))) + { + event.SetCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java new file mode 100644 index 000000000..d9940e37c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java @@ -0,0 +1,82 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.five; + +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; + +import mineplex.game.clans.clans.worldevent.api.EventCreature; + +public class IronGate +{ + private ChallengeFive _challenge; + private List _corners; + private List> _guardians; + + public IronGate(ChallengeFive challenge, List corners, List> guardians) + { + _challenge = challenge; + _corners = corners; + _guardians = guardians; + } + + private void open() + { + Location pos1 = _corners.get(0); + Location pos2 = _corners.get(1); + int minX = Math.min(pos1.getBlockX(), pos2.getBlockX()); + int maxX = Math.max(pos1.getBlockX(), pos2.getBlockX()); + int minY = Math.min(pos1.getBlockY(), pos2.getBlockY()); + int maxY = Math.max(pos1.getBlockY(), pos2.getBlockY()) + 3; + int minZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ()); + int maxZ = Math.max(pos1.getBlockZ(), pos2.getBlockZ()); + + for (int x = minX; x <= maxX; x++) + { + for (int y = minY; y <= maxY; y++) + { + for (int z = minZ; z <= maxZ; z++) + { + Block block = _challenge.getRaid().getWorldData().World.getBlockAt(x, y, z); + if (block.getType() == Material.IRON_FENCE) + { + block.setType(Material.AIR); + } + } + } + } + } + + public Location getCenter() + { + Location pos1 = _corners.get(0); + Location pos2 = _corners.get(1); + int minX = Math.min(pos1.getBlockX(), pos2.getBlockX()); + int maxX = Math.max(pos1.getBlockX(), pos2.getBlockX()); + int minY = Math.min(pos1.getBlockY(), pos2.getBlockY()); + int maxY = Math.max(pos1.getBlockY(), pos2.getBlockY()) + 3; + int minZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ()); + int maxZ = Math.max(pos1.getBlockZ(), pos2.getBlockZ()); + + return new Location(_challenge.getRaid().getWorldData().World, minX + ((maxX - minX) / 2), minY + ((maxY - minY) / 2), minZ + ((maxZ - minZ) / 2)); + } + + public boolean update() + { + int alive = 0; + for (EventCreature guardian : _guardians) + { + if (guardian.getHealth() > 0) + { + alive++; + } + } + if (alive < 0) + { + open(); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java new file mode 100644 index 000000000..7112c0885 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java @@ -0,0 +1,139 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.four; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.silverfish.PitSwarmer; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; + +public class ChallengeFour extends RaidChallenge +{ + private Location _altar; + private boolean _teleported = false; + private List _blocks = new ArrayList<>(); + + public ChallengeFour(WitherRaid raid) + { + super(raid, "Infested Pits"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + } + + private void teleportIn() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Complete the parkour!")); + player.teleport(getRaid().getWorldData().getCustomLocs("C_FOUR_ENTER").get(0)); + }); + Location pos1 = getRaid().getWorldData().getCustomLocs("C_FOUR_SF").get(0); + Location pos2 = getRaid().getWorldData().getCustomLocs("C_FOUR_SF").get(1); + int minX = Math.min(pos1.getBlockX(), pos2.getBlockX()); + int maxX = Math.max(pos1.getBlockX(), pos2.getBlockX()); + int minY = Math.min(pos1.getBlockY(), pos2.getBlockY()); + int maxY = Math.max(pos1.getBlockY(), pos2.getBlockY()); + int minZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ()); + int maxZ = Math.max(pos1.getBlockZ(), pos2.getBlockZ()); + + for (int x = minX; x <= maxX; x++) + { + for (int y = minY; y <= maxY; y++) + { + for (int z = minZ; z <= maxZ; z++) + { + Block block = getRaid().getWorldData().World.getBlockAt(x, y, z); + getRaid().registerCreature(new PitSwarmer(this, block.getLocation())); + } + } + } + } + + @Override + public void customStart() + { + for (Location loc : getRaid().getWorldData().getCustomLocs("C_FOUR_FB")) + { + loc.getBlock().setType(Material.NETHER_BRICK); + } + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Use the second gate!"))); + } + + @SuppressWarnings("deprecation") + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Excellent jumping!")); + player.teleport(_altar); + }); + getRaid().getWorldData().getCustomLocs("GATE_TWO").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); + Block gate = getRaid().getWorldData().getCustomLocs("GATE_THREE").get(0).getBlock(); + gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); + gate.setType(Material.SKULL); + gate.setData((byte)1); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + for (Player player : getRaid().getPlayers()) + { + if (UtilMath.offset(player.getLocation(), getRaid().getWorldData().getCustomLocs("C_FOUR_EXIT").get(0)) <= 3) + { + complete(); + return; + } + } + } + if (event.getType() == UpdateType.TICK) + { + _blocks.forEach(FakeBlock::update); + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!event.hasBlock()) + { + return; + } + + Block clicked = event.getClickedBlock(); + if (!_teleported) + { + if (clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_TWO").get(0).getBlock()) || clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_TWO").get(0).getBlock().getRelative(BlockFace.DOWN))) + { + _teleported = true; + teleportIn(); + } + } + } + + @EventHandler + public void onIcePrison(SkillTriggerEvent event) + { + if (getRaid().getPlayers().contains(event.GetPlayer()) && _teleported) + { + event.SetCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java new file mode 100644 index 000000000..371bec25e --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java @@ -0,0 +1,37 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.four; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; + +public class FakeBlock +{ + private ChallengeFour _challenge; + private Block _block; + + public FakeBlock(ChallengeFour challenge, Block block) + { + _challenge = challenge; + _block = block; + _block.setType(Material.NETHER_BRICK); + } + + public void update() + { + boolean aired = false; + for (Player player : _challenge.getRaid().getPlayers()) + { + if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).equals(_block)) + { + _block.setType(Material.AIR); + aired = true; + } + } + + if (!aired) + { + _block.setType(Material.NETHER_BRICK); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java new file mode 100644 index 000000000..1edc07d61 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java @@ -0,0 +1,104 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.one; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class ChallengeOne extends RaidChallenge +{ + private Location _altar; + private Player _trigger; + + public ChallengeOne(WitherRaid raid) + { + super(raid, "Entering Hell"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + } + + private void sealDoor() + { + Location doorBase1 = getRaid().getWorldData().getCustomLocs("C_ONE_TRAP").get(0); + Location doorBase2 = getRaid().getWorldData().getCustomLocs("C_ONE_TRAP").get(1); + int minX = Math.min(doorBase1.getBlockX(), doorBase2.getBlockX()); + int maxX = Math.max(doorBase1.getBlockX(), doorBase2.getBlockX()); + int minY = Math.min(doorBase1.getBlockY(), doorBase2.getBlockY()); + int maxY = Math.max(doorBase1.getBlockY(), doorBase2.getBlockY()) + 1; + int minZ = Math.min(doorBase1.getBlockZ(), doorBase2.getBlockZ()); + int maxZ = Math.max(doorBase1.getBlockZ(), doorBase2.getBlockZ()); + + for (int x = minX; x <= maxX; x++) + { + for (int y = minY; y <= maxY; y++) + { + for (int z = minZ; z <= maxZ; z++) + { + Block block = getRaid().getWorldData().World.getBlockAt(x, y, z); + block.setType(Material.NETHER_BRICK); + } + } + } + } + + private void setupStoneBrickTraps() + { + for (Location loc : getRaid().getWorldData().getCustomLocs("C_ONE_SBT")) + { + Block b = loc.getBlock(); + b.setType(Material.SMOOTH_BRICK); + b.getRelative(BlockFace.UP).setType(Material.SMOOTH_BRICK); + } + } + + @Override + public void customStart() + { + setupStoneBrickTraps(); + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Enter the Altar Room"))); + } + + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> + { + player.getWorld().strikeLightningEffect(player.getLocation()); + if (_trigger != null) + { + if (UtilMath.offset(player.getLocation(), _altar) >= 17) + { + player.teleport(_trigger); + } + } + }); + sealDoor(); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + for (Player player : getRaid().getPlayers()) + { + if (UtilMath.offset(player.getLocation(), _altar) <= 5) + { + _trigger = player; + complete(); + return; + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java new file mode 100644 index 000000000..9fadaa068 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java @@ -0,0 +1,161 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.seven; + +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilShapes; +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 mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadKnight; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.wither.CharlesWitherton; + +public class ChallengeSeven extends RaidChallenge +{ + private Location _altar; + private boolean _teleported = false; + private boolean _bottomLayer = false; + private CharlesWitherton _charlie; + private long _lastKnightRespawn; + + public ChallengeSeven(WitherRaid raid) + { + super(raid, "The Final Battle"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + } + + private void teleportToBottom() + { + _charlie.getEntity().teleport(getRaid().getWorldData().getCustomLocs("C_SEVEN_RWC").get(0)); + for (Player player : getRaid().getPlayers()) + { + player.teleport(getRaid().getWorldData().getCustomLocs("C_SEVEN_RWC").get(0)); + } + } + + private void teleportIn() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName(), "GUARDS! ATTACK!")); + player.teleport(getRaid().getWorldData().getCustomLocs("C_SEVEN_ENTER").get(0)); + }); + for (Location loc : getRaid().getWorldData().getCustomLocs("C_SEVEN_UK")) + { + getRaid().registerCreature(new UndeadKnight(this, loc)); + } + _lastKnightRespawn = System.currentTimeMillis(); + _charlie = new CharlesWitherton(this, getRaid().getWorldData().getCustomLocs("C_SEVEN_CHARLES").get(0)); + getRaid().registerCreature(_charlie); + for (Location loc : getRaid().getWorldData().getCustomLocs("C_SEVEN_UK")) + { + getRaid().registerCreature(new UndeadKnight(this, loc)); + } + } + + @Override + public void customStart() + { + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Use the final gate!"))); + } + + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "The evil reign of Charles Witherton is over! You will be returned to spawn in 2 minutes!")); + player.teleport(_altar); + }); + List anim = UtilShapes.getCircle(_altar.clone().add(0, 2, 0), true, 3); + int emeralds = UtilMath.rRange((int)Math.ceil(45 / anim.size()), (int)Math.ceil(80 / anim.size())); + for (Location drop : anim) + { + ClansManager.getInstance().getLootManager().dropRare(drop); + drop.getWorld().dropItem(drop, new ItemStack(Material.EMERALD, emeralds)); + } + getRaid().getWorldData().getCustomLocs("GATE_FIVE").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); + getRaid().setForceEnd(System.currentTimeMillis() + UtilTime.convert(2, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + } + + @EventHandler + public void onDeath(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof CharlesWitherton) + { + if (((WitherRaid)event.getCreature().getEvent()).getId() == getRaid().getId()) + { + complete(); + } + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!event.hasBlock()) + { + return; + } + + Block clicked = event.getClickedBlock(); + if (!_teleported) + { + if (clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_FIVE").get(0).getBlock()) || clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_FIVE").get(0).getBlock().getRelative(BlockFace.DOWN))) + { + _teleported = true; + teleportIn(); + } + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + if (_teleported && !_bottomLayer && _charlie != null) + { + if (_charlie.getHealthPercent() <= 0.75) + { + _bottomLayer = true; + teleportToBottom(); + return; + } + + if (UtilTime.elapsed(_lastKnightRespawn, 30000)) + { + _lastKnightRespawn = System.currentTimeMillis(); + long knights = getRaid().getCreatures().stream().filter(UndeadKnight.class::isInstance).count(); + int total = getRaid().getWorldData().getCustomLocs("C_SEVEN_UK").size(); + if (knights < total) + { + long needed = total - knights; + for (int i = 0; i < needed; i++) + { + Location loc = getRaid().getWorldData().getCustomLocs("C_SEVEN_UK").get(i); + getRaid().registerCreature(new UndeadKnight(this, loc)); + } + } + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/six/ChallengeSix.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/six/ChallengeSix.java new file mode 100644 index 000000000..46d3526b3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/six/ChallengeSix.java @@ -0,0 +1,94 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.six; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.magma.Magmus; + +public class ChallengeSix extends RaidChallenge +{ + private Location _altar; + private boolean _teleported = false; + + public ChallengeSix(WitherRaid raid) + { + super(raid, "Fiery Gates"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + } + + private void teleportIn() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Slay the gatekeeper or perish!")); + player.teleport(getRaid().getWorldData().getCustomLocs("C_SIX_ENTER").get(0)); + }); + getRaid().registerCreature(new Magmus(this, getRaid().getWorldData().getCustomLocs("C_SIX_MCS").get(0))); + } + + @Override + public void customStart() + { + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Use the fourth gate!"))); + } + + @SuppressWarnings("deprecation") + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Your final battle awaits!")); + player.teleport(_altar); + }); + getRaid().getWorldData().getCustomLocs("GATE_FOUR").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); + Block gate = getRaid().getWorldData().getCustomLocs("GATE_FIVE").get(0).getBlock(); + gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); + gate.setType(Material.SKULL); + gate.setData((byte)1); + _altar.getWorld().dropItem(_altar.clone().add(0, 2, 0), new ItemStack(Material.EMERALD, UtilMath.rRange(15, 20))); + } + + @EventHandler + public void onDeath(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof Magmus) + { + if (((WitherRaid)event.getCreature().getEvent()).getId() == getRaid().getId()) + { + complete(); + } + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!event.hasBlock()) + { + return; + } + + Block clicked = event.getClickedBlock(); + if (!_teleported) + { + if (clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_FOUR").get(0).getBlock()) || clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_FOUR").get(0).getBlock().getRelative(BlockFace.DOWN))) + { + _teleported = true; + teleportIn(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java new file mode 100644 index 000000000..99daf36c0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java @@ -0,0 +1,125 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.three; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.archer.DecayingArcher; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.corpse.ReanimatedCorpse; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadMage; + +public class ChallengeThree extends RaidChallenge +{ + private Location _altar; + private boolean _teleported = false; + private List _torches = new ArrayList<>(); + protected int LitTorches; + private long _lastSpawn; + + public ChallengeThree(WitherRaid raid) + { + super(raid, "Light The Fires"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + LitTorches = 0; + } + + private void teleportIn() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Light the torches!")); + player.teleport(getRaid().getWorldData().getCustomLocs("C_THREE_ENTER").get(0)); + }); + getRaid().registerCreature(new UndeadMage(this, getRaid().getWorldData().getCustomLocs("C_THREE_UM").get(0), true, getRaid().getWorldData().getCustomLocs("C_THREE_UMS"), getRaid().getWorldData().getCustomLocs("C_THREE_UMT"))); + } + + @Override + public void customStart() + { + for (Location loc : getRaid().getWorldData().getCustomLocs("C_THREE_TORCH")) + { + loc.getBlock().setType(Material.NETHERRACK); + _torches.add(new ChallengeTorch(this, loc.getBlock())); + } + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Use the first gate!"))); + } + + @SuppressWarnings("deprecation") + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "The Torches are lit!")); + player.teleport(_altar); + }); + getRaid().getWorldData().getCustomLocs("GATE_ONE").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); + Block gate = getRaid().getWorldData().getCustomLocs("GATE_TWO").get(0).getBlock(); + gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); + gate.setType(Material.SKULL); + gate.setData((byte)1); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + if (LitTorches >= 4) + { + complete(); + } + } + if (event.getType() == UpdateType.TICK) + { + _torches.forEach(ChallengeTorch::update); + if (UtilTime.elapsed(_lastSpawn, 7000) && _teleported) + { + _lastSpawn = System.currentTimeMillis(); + getRaid().getWorldData().getCustomLocs("C_THREE_RC").forEach(loc -> + { + getRaid().registerCreature(new ReanimatedCorpse(this, loc)); + }); + getRaid().getWorldData().getCustomLocs("C_THREE_DA").forEach(loc -> + { + getRaid().registerCreature(new DecayingArcher(this, loc)); + }); + } + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!event.hasBlock()) + { + return; + } + + Block clicked = event.getClickedBlock(); + if (!_teleported) + { + if (clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_ONE").get(0).getBlock()) || clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_ONE").get(0).getBlock().getRelative(BlockFace.DOWN))) + { + _lastSpawn = System.currentTimeMillis(); + _teleported = true; + teleportIn(); + } + } + _torches.forEach(torch -> torch.handleInteract(clicked)); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java new file mode 100644 index 000000000..08482b694 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java @@ -0,0 +1,42 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.three; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; + +public class ChallengeTorch +{ + private ChallengeThree _challenge; + private Block _block; + private long _extinguish; + + public ChallengeTorch(ChallengeThree challenge, Block block) + { + _challenge = challenge; + _block = block; + _extinguish = -1; + } + + public void handleInteract(Block block) + { + if (block.equals(_block)) + { + _challenge.LitTorches++; + _extinguish = System.currentTimeMillis() + 3000; + _block.getRelative(BlockFace.UP).setType(Material.FIRE); + } + } + + public void update() + { + if (_extinguish != -1 && !_challenge.isComplete()) + { + if (_extinguish < System.currentTimeMillis()) + { + _extinguish = -1; + _challenge.LitTorches--; + _block.getRelative(BlockFace.UP).setType(Material.AIR); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/two/ChallengeTwo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/two/ChallengeTwo.java new file mode 100644 index 000000000..a18665263 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/two/ChallengeTwo.java @@ -0,0 +1,72 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.two; + +import org.bukkit.DyeColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadKnight; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadMage; + +public class ChallengeTwo extends RaidChallenge +{ + private Location _altar; + + public ChallengeTwo(WitherRaid raid) + { + super(raid, "Undead Encounter"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + } + + private void openStoneBrickTraps() + { + for (Location loc : getRaid().getWorldData().getCustomLocs("C_ONE_SBT")) + { + Block b = loc.getBlock(); + b.setType(Material.AIR); + b.getRelative(BlockFace.UP).setType(Material.AIR); + getRaid().registerCreature(new UndeadKnight(this, loc)); + } + } + + @SuppressWarnings("deprecation") + @Override + public void customStart() + { + openStoneBrickTraps(); + _altar.getBlock().getRelative(BlockFace.DOWN).setData(DyeColor.BLACK.getWoolData()); + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main("Undead Mage", "MINIONS, ATTACK!"))); + getRaid().registerCreature(new UndeadMage(this, _altar, false, getRaid().getWorldData().getCustomLocs("C_ONE_SBT"), getRaid().getWorldData().getCustomLocs("C_TWO_MTP"))); + } + + @SuppressWarnings("deprecation") + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "The Undead Mage has fallen!"))); + Block gate = getRaid().getWorldData().getCustomLocs("GATE_ONE").get(0).getBlock(); + gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); + gate.setType(Material.SKULL); + gate.setData((byte)1); + } + + @EventHandler + public void onDeath(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof UndeadMage) + { + if (((WitherRaid)event.getCreature().getEvent()).getId() == getRaid().getId()) + { + complete(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/ArcherShooting.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/ArcherShooting.java new file mode 100644 index 000000000..de8ded9ec --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/ArcherShooting.java @@ -0,0 +1,94 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.archer; + +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class ArcherShooting extends BossAbility +{ + private long _lastShoot; + private long _lastRope; + + public ArcherShooting(DecayingArcher creature) + { + super(creature); + + _lastShoot = System.currentTimeMillis(); + _lastRope = System.currentTimeMillis(); + } + + @Override + public void tick() + { + if (getEntity().getTarget() != null) + { + if (UtilTime.elapsed(_lastRope, 10000)) + { + _lastRope = System.currentTimeMillis(); + UtilEnt.LookAt(getEntity(), getEntity().getTarget().getEyeLocation()); + UtilEnt.addFlag(getEntity().launchProjectile(Arrow.class), "ROPED_ARROW"); + return; + } + if (UtilTime.elapsed(_lastShoot, 2000)) + { + _lastShoot = System.currentTimeMillis(); + UtilEnt.LookAt(getEntity(), getEntity().getTarget().getEyeLocation()); + getEntity().launchProjectile(Arrow.class); + } + } + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE) == null) + { + return; + } + LivingEntity ent = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + if (ent.getEntityId() == getEntity().getEntityId()) + { + if (event.GetCause() != DamageCause.PROJECTILE) + { + event.SetCancelled("Archer Only"); + return; + } + if (UtilEnt.hasFlag(event.GetProjectile(), "ROPED_ARROW")) + { + ent.setVelocity(UtilAlg.getTrajectory(ent, event.GetDamageeEntity()).normalize()); + event.AddMod("Roped Arrow", -event.GetDamage()); + return; + } + event.AddMod("Ranged Attack", 2 - event.GetDamage()); + } + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return false; + } + + @Override + public void setFinished() {} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/DecayingArcher.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/DecayingArcher.java new file mode 100644 index 000000000..13e5bfd46 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/DecayingArcher.java @@ -0,0 +1,65 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.archer; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class DecayingArcher extends EventCreature +{ + private RaidChallenge _challenge; + private ArcherShooting _passive; + + public DecayingArcher(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Decaying Archer", true, 10, 100, true, Zombie.class); + + _challenge = challenge; + spawnEntity(); + _passive = new ArcherShooting(this); + } + + @Override + protected void spawnCustom() + { + getEntity().getEquipment().setItemInHand(new ItemStack(Material.BOW)); + getEntity().getEquipment().setItemInHandDropChance(0f); + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/CorpsePassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/CorpsePassive.java new file mode 100644 index 000000000..f08d0ed32 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/CorpsePassive.java @@ -0,0 +1,43 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.corpse; + +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; + +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class CorpsePassive extends BossPassive +{ + public CorpsePassive(ReanimatedCorpse creature) + { + super(creature); + } + + @Override + public int getCooldown() + { + return 0; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() {} + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamagerEntity(false) == null) + { + return; + } + if (event.GetDamagerEntity(false).getEntityId() == getEntity().getEntityId()) + { + event.AddMod("Corpse Attack", 1 - event.GetDamage()); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/ReanimatedCorpse.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/ReanimatedCorpse.java new file mode 100644 index 000000000..debf12fa7 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/ReanimatedCorpse.java @@ -0,0 +1,67 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.corpse; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class ReanimatedCorpse extends EventCreature +{ + private static final Material[] SWORDS = {Material.WOOD_SWORD, Material.STONE_SWORD, Material.GOLD_SWORD, Material.IRON_SWORD, Material.DIAMOND_SWORD}; + private RaidChallenge _challenge; + private CorpsePassive _passive; + + public ReanimatedCorpse(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Reanimated Corpse", true, 15, 100, true, Zombie.class); + + _challenge = challenge; + spawnEntity(); + _passive = new CorpsePassive(this); + } + + @Override + protected void spawnCustom() + { + getEntity().getEquipment().setItemInHand(new ItemStack(UtilMath.randomElement(SWORDS))); + getEntity().getEquipment().setItemInHandDropChance(0f); + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/Goliath.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/Goliath.java new file mode 100644 index 000000000..d5de7b8c2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/Goliath.java @@ -0,0 +1,59 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.giant; + +import org.bukkit.Location; +import org.bukkit.entity.Giant; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class Goliath extends EventCreature +{ + private RaidChallenge _challenge; + private GoliathPassive _passive; + + public Goliath(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Goliath", true, 5000, 500, true, Giant.class); + + _challenge = challenge; + spawnEntity(); + _passive = new GoliathPassive(this); + } + + @Override + protected void spawnCustom() {} + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/GoliathPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/GoliathPassive.java new file mode 100644 index 000000000..1551a9fc9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/GoliathPassive.java @@ -0,0 +1,60 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.giant; + +import org.bukkit.entity.Giant; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class GoliathPassive extends BossPassive +{ + public GoliathPassive(Goliath creature) + { + super(creature); + } + + @Override + public int getCooldown() + { + return 0; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + for (Player player : ((WitherRaid)getBoss().getEvent()).getPlayers()) + { + if (UtilPlayer.isSpectator(player) || player.isDead() || !player.isValid()) + { + continue; + } + if (UtilMath.offset(getEntity(), player) <= 7) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, DamageCause.ENTITY_ATTACK, 100, false, true, true, getEntity().getName(), "Smash"); + } + } + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity() != null) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + event.SetCancelled("Giant Invulnerability"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/KnightPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/KnightPassive.java new file mode 100644 index 000000000..207184797 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/KnightPassive.java @@ -0,0 +1,67 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; + +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; + +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class KnightPassive extends BossPassive +{ + private long _lastUsed; + + public KnightPassive(UndeadKnight creature) + { + super(creature); + + _lastUsed = System.currentTimeMillis(); + } + + @Override + public int getCooldown() + { + return 12; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() {} + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamagerEntity(false) == null) + { + return; + } + if (event.GetDamagerEntity(false).getEntityId() == getEntity().getEntityId()) + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + _lastUsed = System.currentTimeMillis(); + event.AddMod("Hilt Smash", 1 - event.GetDamage()); + getBoss().getEvent().getCondition().Factory().Slow("Hilt Smash", event.GetDamageeEntity(), event.GetDamagerEntity(false), 2, 1, false, true, false, true); + } + else + { + event.AddMod("Knight Attack", 1 - event.GetDamage()); + } + } + } + + @EventHandler + public void onShoot(EntityShootBowEvent event) + { + if (event.getEntity().getEntityId() == getEntity().getEntityId()) + { + event.setCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBlink.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBlink.java new file mode 100644 index 000000000..2974f216d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBlink.java @@ -0,0 +1,67 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; + +import java.util.List; +import java.util.stream.Collectors; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; + +import mineplex.core.common.util.UtilMath; +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.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; + +public class MageBlink extends BossPassive +{ + private List _spots; + private long _lastUsed; + + public MageBlink(UndeadMage creature, List teleportSpots) + { + super(creature); + + _spots = teleportSpots; + _lastUsed = System.currentTimeMillis(); + } + + @Override + public int getCooldown() + { + return 7; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + _lastUsed = System.currentTimeMillis(); + List tp = null; + if (_spots != null) + { + tp = _spots.stream().filter(spot -> UtilMath.offset(getLocation(), spot) <= 10).collect(Collectors.toList()); + } + else + { + tp = getBoss().getPlayers(UtilPlayer.getInRadius(getLocation(), 10), 10).stream().map(Player::getLocation).collect(Collectors.toList()); + } + if (tp != null && !tp.isEmpty()) + { + Location to = UtilMath.randomElement(tp); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, to, null, 0, 2, ViewDist.MAX); + getEntity().teleport(to); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBolt.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBolt.java new file mode 100644 index 000000000..bff678973 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBolt.java @@ -0,0 +1,86 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +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.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; + +public class MageBolt extends BossPassive +{ + private static final double RANGE = 10; + private long _lastUsed; + + public MageBolt(UndeadMage creature) + { + super(creature); + _lastUsed = System.currentTimeMillis(); + } + + private void shootBolt(Player target) + { + double curRange = 0; + boolean canHit = true; + + while (curRange <= RANGE) + { + Location newTarget = getEntity().getEyeLocation().add(UtilAlg.getTrajectory(getEntity(), target).multiply(curRange)); + + if (!UtilBlock.airFoliage(newTarget.getBlock())) + { + canHit = false; + break; + } + if (UtilMath.offset(newTarget, target.getLocation()) <= 0.9) + { + break; + } + + curRange += 0.2; + + UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, newTarget, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); + } + + if (canHit) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.CUSTOM, 2.5, true, true, false, getEntity().getName(), "Mystical Energy"); + } + } + + @Override + public int getCooldown() + { + return 3; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + Player target = UtilMath.randomElement(getBoss().getPlayers(UtilPlayer.getInRadius(getLocation(), RANGE), RANGE)); + if (target != null) + { + _lastUsed = System.currentTimeMillis(); + shootBolt(target); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageSummon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageSummon.java new file mode 100644 index 000000000..09bb949e9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageSummon.java @@ -0,0 +1,80 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; + +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.entity.Skeleton; + +import mineplex.core.common.util.UtilMath; +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.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class MageSummon extends BossPassive +{ + private final int MAX_KNIGHTS; + private static final int KNIGHTS_PER_USE = 6; + private long _lastUsed; + private List _spawnLocations; + + public MageSummon(UndeadMage creature, List spawnLocations) + { + super(creature); + + _lastUsed = System.currentTimeMillis(); + MAX_KNIGHTS = spawnLocations.size(); + _spawnLocations = spawnLocations; + } + + private void spawnKnight() + { + Location spawn = null; + if (_spawnLocations != null) + { + spawn = UtilMath.randomElement(_spawnLocations); + } + else + { + spawn = getLocation(); + } + getBoss().getEvent().registerCreature(new UndeadKnight(getBoss().getChallenge(), spawn)); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getLocation(), null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, getLocation(), null, 0, 2, ViewDist.MAX); + } + + @Override + public int getCooldown() + { + return 30; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (!UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + return; + } + long amount = ((WitherRaid)getBoss().getEvent()).getCreatures().stream().filter(UndeadKnight.class::isInstance).count(); + if (amount < MAX_KNIGHTS) + { + _lastUsed = System.currentTimeMillis(); + long spawnAmount = Math.min(MAX_KNIGHTS - amount, KNIGHTS_PER_USE); + for (int i = 0; i < spawnAmount; i++) + { + spawnKnight(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadKnight.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadKnight.java new file mode 100644 index 000000000..62456eda6 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadKnight.java @@ -0,0 +1,71 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class UndeadKnight extends EventCreature +{ + private RaidChallenge _challenge; + private KnightPassive _passive; + + public UndeadKnight(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Undead Knight", true, 25, 100, true, Skeleton.class); + + _challenge = challenge; + spawnEntity(); + _passive = new KnightPassive(this); + } + + @Override + protected void spawnCustom() + { + getEntity().getEquipment().setItemInHand(new ItemStack(Material.STONE_SWORD)); + getEntity().getEquipment().setItemInHandDropChance(0f); + getEntity().getEquipment().setHelmet(new ItemBuilder(Material.CHAINMAIL_HELMET).setUnbreakable(true).build()); + getEntity().getEquipment().setHelmetDropChance(0f); + getEntity().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100000000, 0)); + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadMage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadMage.java new file mode 100644 index 000000000..428bfa30f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadMage.java @@ -0,0 +1,171 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.RaidCreature; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class UndeadMage extends RaidCreature +{ + private RaidChallenge _challenge; + private List> _abilities; + private boolean _invuln; + + public UndeadMage(RaidChallenge challenge, Location location, boolean invulnerable, List spawnLocations, List blinkLocations) + { + super(challenge.getRaid(), location, "Undead Mage", true, 200, 5, true, Skeleton.class); + + _challenge = challenge; + _invuln = invulnerable; + spawnEntity(); + _abilities = new ArrayList<>(); + _abilities.add(new MageSummon(this, spawnLocations)); + _abilities.add(new MageBlink(this, blinkLocations)); + _abilities.add(new MageBolt(this)); + } + + @Override + protected void spawnCustom() + { + UtilEnt.vegetate(getEntity()); + getEntity().setSkeletonType(SkeletonType.WITHER); + getEntity().getEquipment().setItemInHand(new ItemStack(Material.RECORD_6)); //Meridian Scepter + getEntity().getEquipment().setItemInHandDropChance(0f); + getEntity().getEquipment().setHelmet(new ItemBuilder(Material.GOLD_HELMET).setUnbreakable(true).build()); + getEntity().getEquipment().setChestplate(new ItemBuilder(Material.GOLD_CHESTPLATE).setUnbreakable(true).build()); + getEntity().getEquipment().setLeggings(new ItemBuilder(Material.GOLD_LEGGINGS).setUnbreakable(true).build()); + getEntity().getEquipment().setBoots(new ItemBuilder(Material.GOLD_BOOTS).setUnbreakable(true).build()); + getEntity().getEquipment().setHelmetDropChance(0f); + getEntity().getEquipment().setChestplateDropChance(0f); + getEntity().getEquipment().setLeggingsDropChance(0f); + getEntity().getEquipment().setBootsDropChance(0f); + } + + public RaidChallenge getChallenge() + { + return _challenge; + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + for (BossPassive ability : _abilities) + { + HandlerList.unregisterAll(ability); + } + _abilities.clear(); + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _abilities.forEach(BossPassive::tick); + } + + protected List getPlayers(Map map, double maxDist) + { + return getPlayers(map, 0, maxDist); + } + + protected List getPlayers(final Map map, double minDist, double maxDist) + { + List list = new ArrayList<>(); + + for (Player p : map.keySet()) + { + if (!_challenge.getRaid().getPlayers().contains(p)) + { + continue; + } + if (map.get(p) >= minDist && map.get(p) <= maxDist) + { + list.add(p); + } + } + + Collections.sort(list, (o1, o2) -> + { + return Double.compare(map.get(o2), map.get(o1)); + }); + + return list; + } + + @EventHandler + public void onSkeletonDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + event.SetKnockback(false); + if (_invuln) + { + event.SetCancelled("Challenge Invulnerability"); + } + } + } + + @EventHandler + public void noFallDamage(CustomDamageEvent event) + { + if (getEntity() == null) + { + return; + } + + if (event.GetDamageeEntity().getEntityId() != getEntity().getEntityId()) + { + return; + } + + DamageCause cause = event.GetCause(); + + if (cause == DamageCause.FALL) + { + event.SetCancelled("Boss Invulnerability"); + } + } + + @Override + public void handleDeath(Location location) + { + location.getWorld().dropItem(location.clone().add(0, 1, 0), new ItemStack(Material.EMERALD, UtilMath.rRange(10, 20))); + location.getWorld().dropItem(location.clone().add(0, 1, 0), new ItemStack(UtilMath.randomElement(new Material[] {Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS}))); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/BlazeMinion.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/BlazeMinion.java new file mode 100644 index 000000000..63783d8de --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/BlazeMinion.java @@ -0,0 +1,45 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import org.bukkit.Location; +import org.bukkit.entity.Blaze; +import org.bukkit.event.EventHandler; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class BlazeMinion extends EventCreature +{ + private RaidChallenge _challenge; + + public BlazeMinion(RaidChallenge challenge, Location spawnLocation) + { + super(challenge.getRaid(), spawnLocation, "Blaze Minion", true, 20, 500, true, Blaze.class); + + _challenge = challenge; + spawnEntity(); + } + + @Override + protected void spawnCustom() {} + + @Override + public void dieCustom() {} + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Cataclysm.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Cataclysm.java new file mode 100644 index 000000000..0ca7625e4 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Cataclysm.java @@ -0,0 +1,58 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; + +public abstract class Cataclysm implements Listener +{ + protected ChallengeSix Challenge; + protected Magmus Magmus; + + public Cataclysm(ChallengeSix challenge, Magmus magmus) + { + Challenge = challenge; + Magmus = magmus; + + challenge.getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(challenge.getRaid().getName() + " Raid", getAnnouncement()))); + onStart(); + UtilServer.RegisterEvents(this); + } + + protected abstract String getAnnouncement(); + + protected abstract void onStart(); + + protected abstract void onEnd(); + + protected abstract void tick(); + + protected void end() + { + onEnd(); + HandlerList.unregisterAll(this); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + { + if (Challenge.isComplete()) + { + end(); + } + else + { + tick(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java new file mode 100644 index 000000000..306b3e17b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java @@ -0,0 +1,74 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import org.bukkit.DyeColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; + +public class HeatingUp extends Cataclysm +{ + private Location _center; + private int _ticks; + + public HeatingUp(ChallengeSix challenge, Magmus magmus) + { + super(challenge, magmus); + } + + @Override + protected String getAnnouncement() + { + return "The room is heating up! Quickly, head to a safe location!"; + } + + @SuppressWarnings("deprecation") + @Override + protected void onStart() + { + _center = Challenge.getRaid().getWorldData().getCustomLocs("C_SIX_C1S").get(0); + for (int x = -1; x <= 1; x++) + { + for (int z = -1; z <= 1; z++) + { + _center.getBlock().getRelative(x, -1, z).setTypeIdAndData(Material.STAINED_GLASS.getId(), DyeColor.GREEN.getWoolData(), true); + } + } + } + + @Override + protected void onEnd() + { + for (int x = -1; x <= 1; x++) + { + for (int z = -1; z <= 1; z++) + { + _center.getBlock().getRelative(x, -1, z).setType(Material.STONE); + } + } + } + + @Override + protected void tick() + { + _ticks++; + if (_ticks > (20 * 10)) + { + for (Player player : Challenge.getRaid().getPlayers()) + { + if (UtilMath.offset(player.getLocation(), _center) > 1) + { + player.setFireTicks(1); + Challenge.getRaid().getDamageManager().NewDamageEvent(player, Magmus.getEntity(), null, DamageCause.FIRE, 1, false, true, true, Magmus.getEntity().getName(), "Heat Room"); + } + } + } + if (_ticks > (20 * 30)) + { + end(); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/InfernalMinions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/InfernalMinions.java new file mode 100644 index 000000000..b892e1332 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/InfernalMinions.java @@ -0,0 +1,44 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import org.bukkit.Location; + +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadKnight; + +public class InfernalMinions extends Cataclysm +{ + public InfernalMinions(ChallengeSix challenge, Magmus magmus) + { + super(challenge, magmus); + } + + @Override + protected String getAnnouncement() + { + return "Infernal minions have flocked to Magmus' aid!"; + } + + @Override + protected void onStart() + { + for (Location loc : Challenge.getRaid().getWorldData().getCustomLocs("C_SIX_C2M")) + { + if (UtilMath.r(2) == 1) + { + Challenge.getRaid().registerCreature(new UndeadKnight(Challenge, loc)); + } + else + { + Challenge.getRaid().registerCreature(new BlazeMinion(Challenge, loc)); + } + } + end(); + } + + @Override + protected void onEnd() {} + + @Override + protected void tick() {} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java new file mode 100644 index 000000000..746027618 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java @@ -0,0 +1,70 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import org.bukkit.Location; +import org.bukkit.entity.MagmaCube; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; + +public class Magmus extends EventCreature +{ + private ChallengeSix _challenge; + private MagmusPassive _passive; + + public Magmus(ChallengeSix challenge, Location location) + { + super(challenge.getRaid(), location, "Gatekeeper Magmus", true, 2000, 500, true, MagmaCube.class); + + _challenge = challenge; + spawnEntity(); + _passive = new MagmusPassive(this); + } + + protected ChallengeSix getChallenge() + { + return _challenge; + } + + @Override + protected void spawnCustom() + { + UtilEnt.vegetate(getEntity()); + getEntity().setSize(17); + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + getEntity().teleport(getSpawnLocation()); + + _passive.tick(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusPassive.java new file mode 100644 index 000000000..f7fa43922 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusPassive.java @@ -0,0 +1,56 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.entity.MagmaCube; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; + +public class MagmusPassive extends BossPassive +{ + private long _lastUse; + private List> _cataclysms = new ArrayList<>(); + + public MagmusPassive(Magmus creature) + { + super(creature); + _lastUse = System.currentTimeMillis(); + _cataclysms.add(HeatingUp.class); + _cataclysms.add(InfernalMinions.class); + _cataclysms.add(UndeadAlly.class); + } + + @Override + public int getCooldown() + { + return 30; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastUse, getCooldown() * 1000)) + { + _lastUse = System.currentTimeMillis(); + try + { + UtilMath.randomElement(_cataclysms).getConstructor(ChallengeSix.class, Magmus.class).newInstance(getBoss().getChallenge(), getBoss()); + } + catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/UndeadAlly.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/UndeadAlly.java new file mode 100644 index 000000000..06730bf2b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/UndeadAlly.java @@ -0,0 +1,31 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadMage; + +public class UndeadAlly extends Cataclysm +{ + public UndeadAlly(ChallengeSix challenge, Magmus magmus) + { + super(challenge, magmus); + } + + @Override + protected String getAnnouncement() + { + return "Magmus has summoned an undead ally!"; + } + + @Override + protected void onStart() + { + Challenge.getRaid().registerCreature(new UndeadMage(Challenge, Challenge.getRaid().getWorldData().getCustomLocs("C_SIX_C3S").get(0), false, null, null)); + end(); + } + + @Override + protected void onEnd() {} + + @Override + protected void tick() {} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/PitSwarmer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/PitSwarmer.java new file mode 100644 index 000000000..17fc0b66a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/PitSwarmer.java @@ -0,0 +1,59 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.silverfish; + +import org.bukkit.Location; +import org.bukkit.entity.Silverfish; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class PitSwarmer extends EventCreature +{ + private RaidChallenge _challenge; + private SwarmerPassive _passive; + + public PitSwarmer(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Pit Swarmer", true, 1, 100, true, Silverfish.class); + + _challenge = challenge; + spawnEntity(); + _passive = new SwarmerPassive(this); + } + + @Override + protected void spawnCustom() {} + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/SwarmerPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/SwarmerPassive.java new file mode 100644 index 000000000..58a8f7e99 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/SwarmerPassive.java @@ -0,0 +1,49 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.silverfish; + +import org.bukkit.entity.Silverfish; +import org.bukkit.event.EventHandler; + +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class SwarmerPassive extends BossPassive +{ + public SwarmerPassive(PitSwarmer creature) + { + super(creature); + } + + @Override + public int getCooldown() + { + return 0; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() {} + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamagerEntity(false) != null) + { + if (event.GetDamagerEntity(false).getEntityId() == getEntity().getEntityId()) + { + event.AddMod("Swarm Attack", 1 - event.GetDamage()); + } + } + if (event.GetDamageeEntity() != null) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + event.SetCancelled("Swarm Invulnerability"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/BlackHole.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/BlackHole.java new file mode 100644 index 000000000..0431a4b15 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/BlackHole.java @@ -0,0 +1,118 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +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.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class BlackHole extends BossPassive +{ + private static final double RANGE = 15; + private long _lastUsed; + private int _chargeTicks; + + public BlackHole(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + _chargeTicks = -1; + } + + private void pull() + { + for (Player entity : UtilPlayer.getInRadius(getLocation(), RANGE).keySet()) + { + UtilAction.velocity(entity, UtilAlg.getTrajectory(entity, getEntity()), 0.3, false, 0, 0, 1, true); + } + for (int i = 0; i < 6; i++) + { + Vector random = new Vector(Math.random() * 4 - 2, Math.random() * 4 - 2, Math.random() * 4 - 2); + + Location origin = getLocation().add(0, 1.3, 0); + origin.add(getLocation().getDirection().multiply(10)); + origin.add(random); + + Vector vel = UtilAlg.getTrajectory(origin, getLocation().add(0, 1.3, 0)); + vel.multiply(7); + + UtilParticle.PlayParticle(ParticleType.MAGIC_CRIT, + origin, + (float)vel.getX(), + (float)vel.getY(), + (float)vel.getZ(), + 1, 0, ViewDist.LONG, UtilServer.getPlayers()); + } + } + + private void throwUp() + { + Map near = UtilPlayer.getInRadius(getLocation(), RANGE); + for (Entry thr : near.entrySet()) + { + Vector vel = new Vector(0, Math.min(7.5, Math.max(5 / thr.getValue(), 4)), 0); + thr.getKey().setVelocity(vel); + } + } + + @Override + public int getCooldown() + { + return 60; + } + + @Override + public boolean isProgressing() + { + return _chargeTicks != -1; + } + + @Override + public void tick() + { + if (_chargeTicks != -1) + { + _chargeTicks++; + if (_chargeTicks >= (20 * 5)) + { + _lastUsed = System.currentTimeMillis(); + _chargeTicks = -1; + throwUp(); + } + else + { + pull(); + } + return; + } + if (getBoss().getHealthPercent() <= 0.25) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + _chargeTicks = 0; + ((WitherRaid)getBoss().getEvent()).getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getBoss().getEvent().getName() + " Raid", "He's charging up Decay! Run away!"))); + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesSkulls.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesSkulls.java new file mode 100644 index 000000000..eccb7ab13 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesSkulls.java @@ -0,0 +1,189 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +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.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossAbility; + +public class CharlesSkulls extends BossAbility +{ + private long _lastUnguided; + private long _lastGuided; + private long _lastBombard; + private Map _guidedSkulls; + + public CharlesSkulls(CharlesWitherton creature) + { + super(creature); + + _lastUnguided = System.currentTimeMillis(); + _lastGuided = System.currentTimeMillis(); + _lastBombard = -1; + } + + @Override + public void tick() + { + if (getBoss().getHealthPercent() <= 0.75) + { + if (_lastBombard == -1) + { + _lastBombard = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastBombard, 25000)) + { + Player target = UtilPlayer.getClosest(getLocation()); + if (target != null) + { + _lastBombard = System.currentTimeMillis(); + UtilEnt.LookAt(getEntity(), target.getEyeLocation()); + for (int i = 0; i < 15; i++) + { + UtilEnt.addFlag(getEntity().launchProjectile(WitherSkull.class), "BOMBARD"); + } + return; + } + } + } + } + if (UtilTime.elapsed(_lastUnguided, 10000)) + { + Player target = UtilPlayer.getClosest(getLocation()); + if (target != null) + { + _lastUnguided = System.currentTimeMillis(); + UtilEnt.LookAt(getEntity(), target.getEyeLocation()); + getEntity().launchProjectile(WitherSkull.class); + return; + } + } + if (UtilTime.elapsed(_lastGuided, 5000)) + { + Player target = UtilPlayer.getClosest(getLocation()); + if (target != null) + { + _lastGuided = System.currentTimeMillis(); + UtilEnt.LookAt(getEntity(), target.getEyeLocation()); + WitherSkull skull = getEntity().launchProjectile(WitherSkull.class); + UtilEnt.addFlag(skull, "GUIDED"); + _guidedSkulls.put(skull, target); + } + } + + Iterator> iterator = _guidedSkulls.entrySet().iterator(); + while (iterator.hasNext()) + { + Entry entry = iterator.next(); + if (!entry.getKey().isValid() || entry.getKey().isDead()) + { + iterator.remove(); + continue; + } + Vector velocity = UtilAlg.getTrajectory(entry.getKey(), entry.getValue()); + entry.getKey().setDirection(velocity); + entry.getKey().setVelocity(velocity.multiply(0.6)); + } + } + + @EventHandler + public void onExplode(EntityExplodeEvent event) + { + if (event.getEntity().getEntityId() == getEntity().getEntityId()) + { + event.blockList().clear(); + return; + } + if (event.getEntity() instanceof WitherSkull) + { + WitherSkull skull = (WitherSkull) event.getEntity(); + if (skull.getShooter() instanceof Wither && ((Wither)skull.getShooter()).getEntityId() == getEntity().getEntityId()) + { + event.blockList().clear(); + return; + } + } + } + + @EventHandler + public void onSkullHit(ProjectileHitEvent event) + { + if (event.getEntity() instanceof WitherSkull) + { + WitherSkull skull = (WitherSkull) event.getEntity(); + if (skull.getShooter() instanceof Wither && ((Wither)skull.getShooter()).getEntityId() == getEntity().getEntityId()) + { + UtilParticle.PlayParticle(ParticleType.EXPLODE, skull.getLocation(), null, 0, 2, ViewDist.MAX, UtilServer.getPlayers()); + skull.getWorld().playSound(skull.getLocation(), Sound.EXPLODE, 10, 0); + if (UtilEnt.hasFlag(skull, "GUIDED")) + { + Player hit = UtilPlayer.getClosest(skull.getLocation(), 0.5); + if (hit != null) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(hit, getEntity(), skull, DamageCause.PROJECTILE, 2, true, true, false, getEntity().getName(), "Guided Skull"); + } + } + else if (UtilEnt.hasFlag(skull, "BOMBARD")) + { + Player hit = UtilPlayer.getClosest(skull.getLocation(), 0.5); + if (hit != null) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(hit, getEntity(), skull, DamageCause.PROJECTILE, 2, true, true, false, getEntity().getName(), "Bombardment"); + } + } + else + { + Player hit = UtilPlayer.getClosest(skull.getLocation(), 0.5); + if (hit != null) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(hit, getEntity(), skull, DamageCause.PROJECTILE, 4, true, true, false, getEntity().getName(), "Wither Skull"); + getBoss().getEvent().getCondition().Factory().Wither("Wither Skull", hit, getEntity(), 3, 0, false, true, false); + } + } + skull.remove(); + } + } + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return false; + } + + @Override + public void setFinished() {} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java new file mode 100644 index 000000000..e86a246fc --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java @@ -0,0 +1,95 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.entity.Wither; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class CharlesWitherton extends EventCreature +{ + private RaidChallenge _challenge; + private CharlesSkulls _passive; + private List> _abilities = new ArrayList<>(); + + protected boolean Flying = false; + + public CharlesWitherton(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Charles Witherton", true, 5000, 15000, true, Wither.class); + + _challenge = challenge; + spawnEntity(); + _passive = new CharlesSkulls(this); + _abilities.add(new LifeSap(this)); + _abilities.add(new Flight(this)); + _abilities.add(new Decay(this)); + _abilities.add(new WitherWave(this)); + _abilities.add(new SummonUndead(this)); + _abilities.add(new SummonCorpse(this)); + _abilities.add(new BlackHole(this)); + _abilities.add(new SummonMinions(this)); + } + + protected RaidChallenge getChallenge() + { + return _challenge; + } + + protected List getCustomLocs(String id) + { + return _challenge.getRaid().getWorldData().getCustomLocs(id); + } + + @Override + protected void spawnCustom() + { + UtilEnt.vegetate(getEntity()); + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + for (BossPassive ability : _abilities) + { + HandlerList.unregisterAll(ability); + } + _abilities.clear(); + _passive.setFinished(); + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + _abilities.forEach(BossPassive::tick); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Decay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Decay.java new file mode 100644 index 000000000..b7271831b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Decay.java @@ -0,0 +1,79 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.F; +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.UtilPlayer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class Decay extends BossPassive +{ + private static final double RANGE = 28; + private long _lastUsed; + private int _chargeTicks; + + public Decay(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + _chargeTicks = -1; + } + + @Override + public int getCooldown() + { + return 300; + } + + @Override + public boolean isProgressing() + { + return _chargeTicks != -1; + } + + @Override + public void tick() + { + if (_chargeTicks != -1) + { + _chargeTicks++; + if (_chargeTicks >= (20 * 5)) + { + _lastUsed = System.currentTimeMillis(); + _chargeTicks = -1; + for (Player player : UtilPlayer.getInRadius(getLocation(), RANGE).keySet()) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, DamageCause.WITHER, 1000, false, true, true, getEntity().getName(), "Decay"); + } + } + else + { + getEntity().teleport(getBoss().getCustomLocs("C_SEVEN_RWC").get(0)); + for (Location loc : UtilShapes.getSphereBlocks(getEntity().getEyeLocation(), 2, 2, true)) + { + UtilParticle.playColoredParticleToAll(Color.RED, ParticleType.RED_DUST, loc, 2, ViewDist.MAX); + UtilParticle.playColoredParticleToAll(Color.BLACK, ParticleType.RED_DUST, loc, 2, ViewDist.MAX); + } + } + return; + } + if (getBoss().getHealthPercent() <= 0.5) + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + _chargeTicks = 0; + ((WitherRaid)getBoss().getEvent()).getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getBoss().getEvent().getName() + " Raid", "He's charging up Decay! Run away!"))); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Flight.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Flight.java new file mode 100644 index 000000000..bb1cafc24 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Flight.java @@ -0,0 +1,62 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.entity.Wither; + +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; + +public class Flight extends BossPassive +{ + private long _lastUsed; + private int _flyingTicks; + + public Flight(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + _flyingTicks = -1; + } + + @Override + public int getCooldown() + { + return 200; + } + + @Override + public boolean isProgressing() + { + return _flyingTicks != -1; + } + + @Override + public void tick() + { + if (_flyingTicks != -1) + { + _flyingTicks++; + if (_flyingTicks >= (20 * 20)) + { + _lastUsed = System.currentTimeMillis(); + _flyingTicks = -1; + getBoss().Flying = false; + } + return; + } + if (getBoss().getHealthPercent() <= 0.75) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + getBoss().Flying = true; + _flyingTicks = 0; + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/LifeSap.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/LifeSap.java new file mode 100644 index 000000000..5afeb2e8d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/LifeSap.java @@ -0,0 +1,116 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +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.UtilPlayer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; + +public class LifeSap extends BossPassive +{ + private static final double RANGE = 20; + private long _lastUsed; + private int _chargeTicks; + + public LifeSap(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + _chargeTicks = -1; + } + + private void shootBeam(Player target) + { + double curRange = 0; + boolean canHit = true; + + while (curRange <= RANGE) + { + Location newTarget = getEntity().getEyeLocation().add(UtilAlg.getTrajectory(getEntity(), target).multiply(curRange)); + + if (!UtilBlock.airFoliage(newTarget.getBlock())) + { + canHit = false; + break; + } + if (UtilMath.offset(newTarget, target.getLocation()) <= 0.9) + { + break; + } + + curRange += 0.2; + + UtilParticle.playColoredParticleToAll(Color.RED, ParticleType.RED_DUST, newTarget, 5, ViewDist.MAX); + } + + if (canHit) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.CUSTOM, 2.5, true, true, false, getEntity().getName(), "Mystical Energy"); + getBoss().setHealth(getBoss().getHealth() + 200); + } + } + + @Override + public int getCooldown() + { + return 60; + } + + @Override + public boolean isProgressing() + { + return _chargeTicks != -1; + } + + @Override + public void tick() + { + if (_chargeTicks != -1) + { + _chargeTicks++; + if (_chargeTicks >= (20 * 4)) + { + _lastUsed = System.currentTimeMillis(); + _chargeTicks = -1; + Player target = UtilPlayer.getClosest(getLocation(), RANGE); + if (target != null) + { + shootBeam(target); + } + } + else + { + for (Location loc : UtilShapes.getCircle(getEntity().getEyeLocation(), true, 1.5)) + { + UtilParticle.playColoredParticleToAll(Color.RED, ParticleType.RED_DUST, loc, 2, ViewDist.MAX); + } + } + return; + } + if (getBoss().getHealthPercent() <= 0.75) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + _chargeTicks = 0; + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java new file mode 100644 index 000000000..5f4d86651 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java @@ -0,0 +1,73 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.Location; +import org.bukkit.entity.Wither; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class MiniCharles extends EventCreature +{ + private RaidChallenge _challenge; + private MiniCharlesSkulls _passive; + private int _liveTicks; + + protected boolean Flying = false; + + public MiniCharles(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Charles' Minion", true, 50, 15000, true, Wither.class); + + _challenge = challenge; + spawnEntity(); + _passive = new MiniCharlesSkulls(this); + } + + @Override + protected void spawnCustom() + { + UtilEnt.vegetate(getEntity()); + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + _passive.setFinished(); + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + + _liveTicks++; + if (_liveTicks > (20 * 15)) + { + remove(); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharlesSkulls.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharlesSkulls.java new file mode 100644 index 000000000..135decf8a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharlesSkulls.java @@ -0,0 +1,117 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.ProjectileHitEvent; + +import mineplex.core.common.util.UtilEnt; +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.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossAbility; + +public class MiniCharlesSkulls extends BossAbility +{ + private long _lastUnguided; + private List _shot = new ArrayList<>(); + + public MiniCharlesSkulls(MiniCharles creature) + { + super(creature); + + _lastUnguided = System.currentTimeMillis(); + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastUnguided, 10000)) + { + Player target = UtilPlayer.getClosest(getLocation()); + if (target != null) + { + _lastUnguided = System.currentTimeMillis(); + UtilEnt.LookAt(getEntity(), target.getEyeLocation()); + _shot.add(getEntity().launchProjectile(WitherSkull.class)); + return; + } + } + } + + @EventHandler + public void onExplode(EntityExplodeEvent event) + { + if (event.getEntity().getEntityId() == getEntity().getEntityId()) + { + event.blockList().clear(); + return; + } + if (event.getEntity() instanceof WitherSkull) + { + WitherSkull skull = (WitherSkull) event.getEntity(); + if (skull.getShooter() instanceof Wither && ((Wither)skull.getShooter()).getEntityId() == getEntity().getEntityId()) + { + event.blockList().clear(); + return; + } + } + } + + @EventHandler + public void onSkullHit(ProjectileHitEvent event) + { + if (event.getEntity() instanceof WitherSkull) + { + WitherSkull skull = (WitherSkull) event.getEntity(); + if (skull.getShooter() instanceof Wither && ((Wither)skull.getShooter()).getEntityId() == getEntity().getEntityId()) + { + _shot.remove(skull); + UtilParticle.PlayParticle(ParticleType.EXPLODE, skull.getLocation(), null, 0, 2, ViewDist.MAX, UtilServer.getPlayers()); + skull.getWorld().playSound(skull.getLocation(), Sound.EXPLODE, 10, 0); + Player hit = UtilPlayer.getClosest(skull.getLocation(), 0.5); + if (hit != null) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(hit, getEntity(), skull, DamageCause.PROJECTILE, 4, true, true, false, getEntity().getName(), "Wither Skull"); + getBoss().getEvent().getCondition().Factory().Wither("Wither Skull", hit, getEntity(), 3, 0, false, true, false); + } + skull.remove(); + } + } + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return false; + } + + @Override + public void setFinished() + { + _shot.forEach(WitherSkull::remove); + _shot.clear(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonCorpse.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonCorpse.java new file mode 100644 index 000000000..0471b69e2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonCorpse.java @@ -0,0 +1,52 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.entity.Wither; + +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.corpse.ReanimatedCorpse; + +public class SummonCorpse extends BossPassive +{ + private long _lastUsed; + + public SummonCorpse(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + } + + @Override + public int getCooldown() + { + return 30; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (getBoss().getHealthPercent() <= 0.50) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + for (int i = 0; i < 6; i++) + { + getBoss().getEvent().registerCreature(new ReanimatedCorpse(getBoss().getChallenge(), getLocation())); + } + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonMinions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonMinions.java new file mode 100644 index 000000000..b40618cfd --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonMinions.java @@ -0,0 +1,51 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.entity.Wither; + +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; + +public class SummonMinions extends BossPassive +{ + private long _lastUsed; + + public SummonMinions(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + } + + @Override + public int getCooldown() + { + return 60; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (getBoss().getHealthPercent() <= 0.25) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + for (int i = 0; i < 2; i++) + { + getBoss().getEvent().registerCreature(new MiniCharles(getBoss().getChallenge(), getLocation())); + } + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonUndead.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonUndead.java new file mode 100644 index 000000000..dd855ea63 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonUndead.java @@ -0,0 +1,52 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.entity.Wither; + +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadKnight; + +public class SummonUndead extends BossPassive +{ + private long _lastUsed; + + public SummonUndead(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + } + + @Override + public int getCooldown() + { + return 60; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (getBoss().getHealthPercent() <= 0.50) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + for (int i = 0; i < 6; i++) + { + getBoss().getEvent().registerCreature(new UndeadKnight(getBoss().getChallenge(), getLocation())); + } + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/WitherWave.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/WitherWave.java new file mode 100644 index 000000000..ae7fea54c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/WitherWave.java @@ -0,0 +1,91 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; + +import mineplex.core.common.util.F; +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.UtilPlayer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class WitherWave extends BossPassive +{ + private static final double RANGE = 10; + private long _lastUsed; + private int _chargeTicks; + + public WitherWave(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + _chargeTicks = -1; + } + + @Override + public int getCooldown() + { + return 60; + } + + @Override + public boolean isProgressing() + { + return _chargeTicks != -1; + } + + @Override + public void tick() + { + if (_chargeTicks != -1) + { + _chargeTicks++; + if (_chargeTicks >= (20 * 5)) + { + for (Location loc : UtilShapes.getSphereBlocks(getLocation(), RANGE / 2, RANGE / 2, false)) + { + UtilParticle.playColoredParticleToAll(Color.GRAY, ParticleType.RED_DUST, loc, 2, ViewDist.MAX); + } + for (Player player : UtilPlayer.getInRadius(getLocation(), RANGE).keySet()) + { + getBoss().getEvent().getCondition().Factory().Wither("Wither Wave", player, getEntity(), 5, 1, false, true, false); + } + if (_chargeTicks >= (20 * 10)) + { + _lastUsed = System.currentTimeMillis(); + _chargeTicks = -1; + } + } + else + { + getEntity().teleport(getLocation()); + for (Location loc : UtilShapes.getSphereBlocks(getEntity().getEyeLocation(), 2, 2, true)) + { + UtilParticle.playColoredParticleToAll(Color.GRAY, ParticleType.RED_DUST, loc, 2, ViewDist.MAX); + } + } + return; + } + if (getBoss().getHealthPercent() <= 0.5) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + _chargeTicks = 0; + ((WitherRaid)getBoss().getEvent()).getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getBoss().getEvent().getName() + " Raid", "He's charging up Decay! Run away!"))); + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java index 44efed198..481abf910 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java @@ -24,6 +24,7 @@ import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ban.ClansBanManager; +import mineplex.game.clans.clans.worldevent.raid.RaidManager; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import mineplex.game.clans.restart.RestartManager; @@ -75,6 +76,11 @@ public class SafeLog extends MiniPlugin isSafeLog = true; } + if (Managers.get(RaidManager.class).isInRaid(player.getLocation())) + { + isSafeLog = true; + } + if (!isSafeLog) { if (!_clansManager.getIncognitoManager().Get(player).Status) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java index 70837d017..33e26bbb0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java @@ -1,11 +1,8 @@ package mineplex.game.clans.items.rares; -import java.util.HashSet; - import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -39,9 +36,8 @@ public class RunedPickaxe extends RareItem static { - UtilServer.RegisterEvents(new Listener() { - - @SuppressWarnings("deprecation") + UtilServer.RegisterEvents(new Listener() + { @EventHandler public void update(UpdateEvent event) { @@ -105,6 +101,9 @@ public class RunedPickaxe extends RareItem if (ClansManager.getInstance().getNetherManager().getNetherWorld().equals(event.getBlock().getWorld())) return; + if (ClansManager.getInstance().getWorldEvent().getRaidManager().isInRaid(event.getBlock().getLocation())) + return; + if (ClansManager.getInstance().getBlockRestore().contains(event.getBlock())) return; @@ -119,7 +118,7 @@ public class RunedPickaxe extends RareItem } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void blockDamage(BlockBreakEvent event) + public void blockBreak(BlockBreakEvent event) { PlayerGear gear = ClansManager.getInstance().getGearManager().getPlayerGear(event.getPlayer()); @@ -136,6 +135,9 @@ public class RunedPickaxe extends RareItem if (ClansManager.getInstance().getBlockRestore().contains(event.getBlock())) return; + if (ClansManager.getInstance().getWorldEvent().getRaidManager().isInRaid(event.getBlock().getLocation())) + return; + if (!pick._enabled) { event.setCancelled(true); @@ -168,6 +170,5 @@ public class RunedPickaxe extends RareItem } super.onInteract(event); - } - -} + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java index 52571a49a..572534b0d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java @@ -11,7 +11,6 @@ import org.bukkit.event.player.PlayerLoginEvent.Result; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -94,6 +93,10 @@ public class RestartManager extends MiniPlugin { return false; } + if (ClansManager.getInstance().getWorldEvent().getRaidManager().getActiveRaids() > 0) + { + return false; + } return true; } From 3c5f8bf72dfbaa00106089eb2f7971e18d67cf31 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 1 Jun 2017 20:15:39 +0200 Subject: [PATCH 118/283] add names to quests in the stats gui, add different reward colors, properly remove "next Page" and "Previous Page" buttons from stats page --- .../src/mineplex/core/quests/QuestManager.java | 4 ++++ .../mineplex/core/quests/shop/BuyQuestButton.java | 6 ++++-- .../mineplex/core/quests/shop/QuestStatsPage.java | 15 +++++++++++---- .../quests/shop/RedeemDeclineQuestButton.java | 11 ++--------- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index edcf26733..6fd3f9c4a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -275,13 +275,16 @@ public class QuestManager extends MiniClientPlugin { if (quest.getReward().contains(":")) { + ChatColor color = ChatColor.YELLOW; if (quest.getRewardName().equalsIgnoreCase("Shards")) { _donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing Quest: " + quest.getID(), Integer.parseInt(quest.getReward().split(":")[1]), callback); + color = ChatColor.AQUA; } else if (quest.getRewardName().equalsIgnoreCase("Gems")) { _donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing Quest: " + quest.getID(), Integer.parseInt(quest.getReward().split(":")[1]), callback); + color = ChatColor.GREEN; } else if (quest.getRewardName().equalsIgnoreCase("XP")) { @@ -293,6 +296,7 @@ public class QuestManager extends MiniClientPlugin _inventoryManager.addItemToInventory(player, quest.getRewardName(), quest.getRewardAmount()); callback.accept(true); } + UtilPlayer.message(player, F.main("Quest", "You have recieved " + color + quest.getRewardAmount() + " " + quest.getRewardName() + " " + ChatColor.GRAY + "for completing: " + ChatColor.YELLOW + quest.getName())); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java index 2d7364a8c..b9d8ebd28 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java @@ -27,6 +27,8 @@ import mineplex.core.shop.item.SalesPackageProcessor; */ public class BuyQuestButton implements IButton { + private final static int MAX_QUESTS = 5; + private QuestManager _questManager; private QuestPage _page; @@ -54,9 +56,9 @@ public class BuyQuestButton implements IButton return; } - if (_questManager.Get(player).getQuests().size() >= 3) + if (_questManager.Get(player).getQuests().size() >= MAX_QUESTS) { - UtilPlayer.message(player, F.main("Quest", "You can't own more than 3 active quests at once!")); + UtilPlayer.message(player, F.main("Quest", "You can't own more than " + MAX_QUESTS + " active quests at once!")); return; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java index 7fcdce5bc..ce9c3016c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java @@ -46,16 +46,23 @@ public class QuestStatsPage extends ShopPageBase @Override protected void buildPage() { + removeButton(5*9); + removeButton((6*9) - 1); + int questID = (_siteIndex * 5 * 9); for (int i = 0; i < 9*5; i++) { Quest quest = _manager.getQuestByID(questID); if (quest == null) - break; + { + setItem(i, null); + questID++; + continue; + } QuestClientData data = _manager.Get(getPlayer()); - ItemStack item = ItemStackFactory.Instance.CreateStack(Material.WOOL, DyeColor.GRAY.getWoolData(), 1, ChatColor.RED + "Quest not acquired"); + ItemStack item = ItemStackFactory.Instance.CreateStack(Material.WOOL, DyeColor.GRAY.getWoolData(), 1, ChatColor.YELLOW + quest.getName()); if (data.hasQuestFromAll(quest)) { @@ -74,7 +81,7 @@ public class QuestStatsPage extends ShopPageBase questID++; } - if (_siteIndex != 0) + if (_siteIndex > 0) { addButton(5*9, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Previous Page"), new IButton() { @@ -87,7 +94,7 @@ public class QuestStatsPage extends ShopPageBase }); } - if (((_siteIndex + 1) * 5 * 9) < _manager.getAvailableQuests().size()) + if (((_siteIndex + 1) * 5 * 9) <= _manager.getAvailableQuests().size()) { addButton((6*9) - 1, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Next Page"), new IButton() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java index 42949355b..f8b49a27e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java @@ -95,19 +95,12 @@ public class RedeemDeclineQuestButton implements IButton { _questManager.resetQuest(player, _quest, true); player.closeInventory(); - UtilPlayer.message(player, F.main("Quest", "You have recieved " + ChatColor.AQUA + _quest.getRewardAmount() + " " + _quest.getRewardName() + " " + ChatColor.GRAY + "for completing: " + ChatColor.YELLOW + _quest.getName())); - } - else - { - UtilPlayer.message(player, F.main("Quest", "Something went wrong!")); } } - }); - + }); } player.closeInventory(); - new QuestShop(_questManager, _questManager.getClients(), _donations).attemptShopOpen(player); - + new QuestShop(_questManager, _questManager.getClients(), _donations).attemptShopOpen(player); } } From 2f1f7a1e7d276383f8e230d2d2ef0866690035ed Mon Sep 17 00:00:00 2001 From: Kenny Goodin Date: Thu, 1 Jun 2017 14:59:22 -0400 Subject: [PATCH 119/283] Debug quest supplier --- .../src/mineplex/quest/client/RedisQuestSupplier.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java index e972b3b11..db5320f45 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java @@ -57,6 +57,9 @@ public class RedisQuestSupplier implements QuestSupplier _quests.clear(); _quests.addAll(deserialize(message)); + System.out.println("[QUEST-SUPPLIER] Quest update received from daemon, active quests: "); + _quests.forEach(q -> System.out.println("[QUEST-SUPPLIER] " + q.toString())); + // notify _plugin.getServer().getPluginManager().callEvent(new QuestsUpdatedEvent(get())); } @@ -73,6 +76,7 @@ public class RedisQuestSupplier implements QuestSupplier private void requestActiveQuests() { + System.out.println("[QUEST-SUPPLIER] Requesting active quests from QuestDaemon"); // request current active quests, send server unique id so we can send a response just to this server _pubSub.publish(PubSubChannels.QUEST_REQUEST_BASE, _serverUniqueId); } From 9b64f5da66234a576663390b2a325c1f8ca49eaf Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 1 Jun 2017 20:59:35 +0200 Subject: [PATCH 120/283] change quest name to "Mineplex Mission" --- .../src/mineplex/core/quests/Quest.java | 8 +--- .../mineplex/core/quests/QuestManager.java | 13 ++++--- .../core/quests/command/GetQuestCommand.java | 10 ++--- .../quests/command/IncrementQuestCommand.java | 12 +++--- .../core/quests/command/OpenGuiCommand.java | 2 +- .../core/quests/shop/BuyQuestButton.java | 12 +++--- .../mineplex/core/quests/shop/QuestPage.java | 13 +++---- .../mineplex/core/quests/shop/QuestShop.java | 2 +- .../core/quests/shop/QuestStatShop.java | 2 +- .../core/quests/shop/QuestStatsButton.java | 37 ------------------- .../core/quests/shop/QuestStatsPage.java | 4 +- .../quests/shop/RedeemDeclineQuestButton.java | 19 ++++------ .../src/nautilus/game/arcade/game/Game.java | 3 +- 13 files changed, 44 insertions(+), 93 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsButton.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java index 5fe1d89fc..965251fe4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java @@ -1,15 +1,9 @@ package mineplex.core.quests; -import java.util.function.Consumer; - import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.donation.DonationManager; import mineplex.core.game.GameCategory; import mineplex.core.game.GameDisplay; -import mineplex.core.inventory.InventoryManager; /** * Quest @@ -223,7 +217,7 @@ public class Quest ChatColor.LIGHT_PURPLE + getTask(), "", ChatColor.GRAY + "Reward: " + ChatColor.AQUA + getRewardAmount() + " " + getRewardName(), "", ChatColor.GRAY + "Progress: " - + (_current == -1 ? ChatColor.RED + "Not in your Quest Inventory" : + + (_current == -1 ? ChatColor.RED + "Not in your " + QuestManager.QUEST_NAME + " Inventory" : (isCompleted() ? ChatColor.GREEN + "Completed!" : ChatColor.YELLOW + "" + getProgress() + ChatColor.GRAY + "/" + ChatColor.YELLOW + getStatToComplete())), "", diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index 6fd3f9c4a..018c54b47 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -53,6 +53,8 @@ import mineplex.serverdata.servers.ServerManager; */ public class QuestManager extends MiniClientPlugin { + public static final String QUEST_NAME = "Mineplex Mission"; + private static final String GOOGLE_SHEET = "QUESTS_SHEET"; private static final String GOOGLE_TABLE = "Quests"; @@ -92,7 +94,7 @@ public class QuestManager extends MiniClientPlugin else { Location loc = _questNPC.getEntity().getLocation(); - _hologram = new Hologram(hologramManager, loc.clone().add(0, 2.8, 0), ChatColor.AQUA + "Quests"); + _hologram = new Hologram(hologramManager, loc.clone().add(0, 2.8, 0), ChatColor.AQUA + QUEST_NAME + "s"); _hologram.start(); _enableNPC = true; } @@ -256,7 +258,7 @@ public class QuestManager extends MiniClientPlugin quest.increment(value); if (quest.isCompleted()) { - UtilPlayer.message(player, F.main("Quest", "You have completed the Quest: " + ChatColor.YELLOW + quest.getName())); + UtilPlayer.message(player, F.main(QUEST_NAME, "You have completed the " + QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName())); } _repository.incrementQuest(_clients.Get(player), quest, value); } @@ -278,12 +280,12 @@ public class QuestManager extends MiniClientPlugin ChatColor color = ChatColor.YELLOW; if (quest.getRewardName().equalsIgnoreCase("Shards")) { - _donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing Quest: " + quest.getID(), Integer.parseInt(quest.getReward().split(":")[1]), callback); + _donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing " + QUEST_NAME + ": " + quest.getID(), Integer.parseInt(quest.getReward().split(":")[1]), callback); color = ChatColor.AQUA; } else if (quest.getRewardName().equalsIgnoreCase("Gems")) { - _donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing Quest: " + quest.getID(), Integer.parseInt(quest.getReward().split(":")[1]), callback); + _donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Completing " + QUEST_NAME + ": " + quest.getID(), Integer.parseInt(quest.getReward().split(":")[1]), callback); color = ChatColor.GREEN; } else if (quest.getRewardName().equalsIgnoreCase("XP")) @@ -296,7 +298,7 @@ public class QuestManager extends MiniClientPlugin _inventoryManager.addItemToInventory(player, quest.getRewardName(), quest.getRewardAmount()); callback.accept(true); } - UtilPlayer.message(player, F.main("Quest", "You have recieved " + color + quest.getRewardAmount() + " " + quest.getRewardName() + " " + ChatColor.GRAY + "for completing: " + ChatColor.YELLOW + quest.getName())); + UtilPlayer.message(player, F.main(QUEST_NAME, "You have recieved " + color + quest.getRewardAmount() + " " + quest.getRewardName() + " " + ChatColor.GRAY + "for completing: " + ChatColor.YELLOW + quest.getName())); } } @@ -325,5 +327,4 @@ public class QuestManager extends MiniClientPlugin { return _availableQuests; } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java index 488a03eb9..1b7fe9cc8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java @@ -19,7 +19,7 @@ public class GetQuestCommand extends CommandBase { public GetQuestCommand(QuestManager plugin) { - super(plugin, Rank.ADMIN, "GetQuest"); + super(plugin, Rank.ADMIN, "GetMineplexMission"); } @Override @@ -27,13 +27,13 @@ public class GetQuestCommand extends CommandBase { if (args.length < 1) { - UtilPlayer.message(caller, F.main("Quest Manager", "You have to submit valid arguments")); + UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You have to submit valid arguments")); return; } if (Plugin.getQuestByID(Integer.parseInt(args[0])) == null) { - UtilPlayer.message(caller, F.main("Quest Manager", "Quest not found")); + UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, QuestManager.QUEST_NAME + " not found")); return; } @@ -47,9 +47,9 @@ public class GetQuestCommand extends CommandBase Quest quest = Plugin.getQuestByID(Integer.parseInt(args[0])); Plugin.addNewQuest(player, quest); - UtilPlayer.message(player, F.main("Quest Manager", "Added Quest: " + ChatColor.YELLOW + quest.getName())); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName())); if (caller != player) - UtilPlayer.message(caller, F.main("Quest Manager", "You gave the Quest: " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + player.getName())); + UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + player.getName())); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java index d728335aa..0ebb57fb3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java @@ -19,7 +19,7 @@ public class IncrementQuestCommand extends CommandBase { public IncrementQuestCommand(QuestManager plugin) { - super(plugin, Rank.ADMIN, "IncrementQuest"); + super(plugin, Rank.ADMIN, "IncrementMineplexMission"); } @Override @@ -27,7 +27,7 @@ public class IncrementQuestCommand extends CommandBase { if (args.length < 2) { - UtilPlayer.message(caller, F.main("Quest Manager", "You have to submit valid arguments")); + UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You have to submit valid arguments")); return; } @@ -40,7 +40,7 @@ public class IncrementQuestCommand extends CommandBase if (Plugin.Get(player).getQuest(Integer.parseInt(args[0])) == null) { - UtilPlayer.message(caller, F.main("Quest Manager", "Quest not found")); + UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, QuestManager.QUEST_NAME + " not found")); return; } @@ -51,17 +51,17 @@ public class IncrementQuestCommand extends CommandBase } catch (NumberFormatException e) { - UtilPlayer.message(caller, F.main("Quest Manager", "You have to submit a valid number")); + UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You have to submit a valid number")); return; } Quest quest = Plugin.Get(player).getQuest(Integer.parseInt(args[0])); Plugin.incrementQuest(player, quest, increment); - UtilPlayer.message(player, F.main("Quest Manager", "Incremented Quest: " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " by " + increment)); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Incremented " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " by " + increment)); if (caller != player) - UtilPlayer.message(caller, F.main("Quest Manager", "You incremented the Quest: " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " for " + ChatColor.YELLOW + player.getName() + ChatColor.GRAY + " by " + increment)); + UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You incremented the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " for " + ChatColor.YELLOW + player.getName() + ChatColor.GRAY + " by " + increment)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java index f110d2305..bf5834577 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java @@ -16,7 +16,7 @@ public class OpenGuiCommand extends CommandBase { public OpenGuiCommand(QuestManager plugin) { - super(plugin, Rank.ALL, "Quests"); + super(plugin, Rank.ALL, "MineplexMissions"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java index b9d8ebd28..b1f70eea1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java @@ -45,20 +45,20 @@ public class BuyQuestButton implements IButton @Override public void onClick(Player player, ClickType clickType) { - if (!Recharge.Instance.use(player, "Buy Quest", 1000, false, false)) + if (!Recharge.Instance.use(player, "Buy Mineplex Mission", 1000, false, false)) { return; } if (_questManager.Get(player).hasQuest(_quest)) { - UtilPlayer.message(player, F.main("Quest", "You already own that Quest!")); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You already own that " + QuestManager.QUEST_NAME + "!")); return; } if (_questManager.Get(player).getQuests().size() >= MAX_QUESTS) { - UtilPlayer.message(player, F.main("Quest", "You can't own more than " + MAX_QUESTS + " active quests at once!")); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You can't own more than " + MAX_QUESTS + " active " + QuestManager.QUEST_NAME + " at once!")); return; } @@ -66,7 +66,7 @@ public class BuyQuestButton implements IButton { if (!UtilTime.elapsed(_questManager.Get(player).getQuestFromAll(_quest.getID()).getLastCompleted(), 1000*60*60*24)) { - UtilPlayer.message(player, F.main("Quest", "You already completed that Quest today!")); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You already completed that " + QuestManager.QUEST_NAME + " today!")); return; } } @@ -74,7 +74,7 @@ public class BuyQuestButton implements IButton QuestInteractEvent event = UtilServer.CallEvent(new QuestInteractEvent(_quest)); if (event.isCancelled()) { - UtilPlayer.message(player, F.main("Quest", event.getCancelMessage())); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, event.getCancelMessage())); return; } @@ -82,7 +82,7 @@ public class BuyQuestButton implements IButton _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, _page.getDonationManager(), () -> { _questManager.addNewQuest(player, _quest); - UtilPlayer.message(player, F.main("Quest", "You have bought: " + ChatColor.YELLOW + _quest.getName())); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You have bought: " + ChatColor.YELLOW + _quest.getName())); player.closeInventory(); new QuestShop(_questManager, _questManager.getClients(), _questManager.getDonations()).attemptShopOpen(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java index 44d18dcb3..ae90e3def 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java @@ -8,15 +8,12 @@ import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; -import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; @@ -39,7 +36,7 @@ public class QuestPage extends ShopPageBase public QuestPage(QuestManager plugin, QuestShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) { - super(plugin, shop, clientManager, donationManager, "Quest Page", player, 27); + super(plugin, shop, clientManager, donationManager, QuestManager.QUEST_NAME + " Page", player, 27); _questShop = shop; _manager = plugin; @@ -55,7 +52,7 @@ public class QuestPage extends ShopPageBase ArrayList playerQuests = _shop.getQuestManager().Get(_player).getQuests(); int i = 0; - setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.RESET + "" + ChatColor.BOLD + "Available Quests")); + setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.RESET + "" + ChatColor.BOLD + "Available " + QuestManager.QUEST_NAME + "s")); { int currentSlot = 4; int diff = 0; @@ -108,7 +105,7 @@ public class QuestPage extends ShopPageBase "", quest.getRarity().getColor() + "" + ChatColor.BOLD + quest.getRarity().toString(), "", - ChatColor.GREEN + "Click to buy Quest!" + ChatColor.GREEN + "Click to buy " + QuestManager.QUEST_NAME + "!" )); item.setItemMeta(meta); @@ -122,7 +119,7 @@ public class QuestPage extends ShopPageBase i++; } i = 9*2; - addButton(i, ItemStackFactory.Instance.CreateStack(Material.EMPTY_MAP, (byte) 0, 1, ChatColor.RESET + "" + ChatColor.BOLD + "Quest Stats"), new IButton() + addButton(i, ItemStackFactory.Instance.CreateStack(Material.EMPTY_MAP, (byte) 0, 1, ChatColor.RESET + "" + ChatColor.BOLD + QuestManager.QUEST_NAME + " Stats"), new IButton() { @Override public void onClick(Player player, ClickType clickType) @@ -161,7 +158,7 @@ public class QuestPage extends ShopPageBase item.setItemMeta(meta); item.addUnsafeEnchantment(Enchantment.DURABILITY, 1); - addButton(i + currentSlot, item, new RedeemDeclineQuestButton(_inventory, _donationManager, _manager, this, quest)); + addButton(i + currentSlot, item, new RedeemDeclineQuestButton(_donationManager, _manager, quest)); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestShop.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestShop.java index 10219c8b5..13d6e6a43 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestShop.java @@ -17,7 +17,7 @@ public class QuestShop extends ShopBase { public QuestShop(QuestManager plugin, CoreClientManager clientManager, DonationManager donationManager) { - super(plugin, clientManager, donationManager, "Quest Shop"); + super(plugin, clientManager, donationManager, QuestManager.QUEST_NAME + " Shop"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatShop.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatShop.java index 44d99a1c7..2c805b10c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatShop.java @@ -18,7 +18,7 @@ public class QuestStatShop extends ShopBase public QuestStatShop(QuestManager plugin, CoreClientManager clientManager, DonationManager donationManager) { - super(plugin, clientManager, donationManager, "Quest Stats"); + super(plugin, clientManager, donationManager, QuestManager.QUEST_NAME + " Stats"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsButton.java deleted file mode 100644 index f833691e6..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsButton.java +++ /dev/null @@ -1,37 +0,0 @@ -package mineplex.core.quests.shop; - -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import mineplex.core.quests.Quest; -import mineplex.core.quests.QuestManager; -import mineplex.core.shop.item.IButton; - -/** - * QuestStatsButton - * - * @author xXVevzZXx - */ -public class QuestStatsButton implements IButton -{ - - private QuestManager _questManager; - - private QuestPage _page; - - private Quest _quest; - - public QuestStatsButton(QuestManager questManager, QuestPage page, Quest quest) - { - _questManager = questManager; - _quest = quest; - _page = page; - } - - @Override - public void onClick(Player player, ClickType clickType) - { - - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java index ce9c3016c..b2b2904a7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestStatsPage.java @@ -33,7 +33,7 @@ public class QuestStatsPage extends ShopPageBase public QuestStatsPage(QuestManager plugin, QuestStatShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, int site) { - super(plugin, shop, clientManager, donationManager, "Quest Stats", player, 6*9); + super(plugin, shop, clientManager, donationManager, QuestManager.QUEST_NAME + " Stats", player, 6*9); _siteIndex = site; @@ -107,7 +107,7 @@ public class QuestStatsPage extends ShopPageBase }); } - addButton(5*9 + 4, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Back to Quests"), new IButton() + addButton(5*9 + 4, ItemStackFactory.Instance.CreateStack(Material.SIGN, (byte) 0, 1, ChatColor.YELLOW + "Back to " + QuestManager.QUEST_NAME + "s"), new IButton() { @Override public void onClick(Player player, ClickType clickType) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java index f8b49a27e..19bbef7d9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java @@ -31,39 +31,34 @@ public class RedeemDeclineQuestButton implements IButton { private QuestManager _questManager; private DonationManager _donations; - private InventoryManager _inventory; - - private QuestPage _page; private Quest _quest; - public RedeemDeclineQuestButton(InventoryManager inventory, DonationManager donations, QuestManager questManager, QuestPage page, Quest quest) + public RedeemDeclineQuestButton(DonationManager donations, QuestManager questManager, Quest quest) { _questManager = questManager; _donations = donations; - _inventory = inventory; _quest = quest; - _page = page; } @Override public void onClick(Player player, ClickType clickType) { - if (!Recharge.Instance.use(player, "Decline Quest", 1000, false, false)) + if (!Recharge.Instance.use(player, "Decline Mineplex Mission", 1000, false, false)) { return; } if (!_questManager.Get(player).hasQuest(_quest)) { - UtilPlayer.message(player, F.main("Quest", "You don't own that Quest!")); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You don't own that " + QuestManager.QUEST_NAME + "!")); return; } QuestInteractEvent event = UtilServer.CallEvent(new QuestInteractEvent(_quest)); if (event.isCancelled()) { - UtilPlayer.message(player, F.main("Quest", event.getCancelMessage())); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, event.getCancelMessage())); return; } @@ -71,18 +66,18 @@ public class RedeemDeclineQuestButton implements IButton { if (_quest.isCompleted()) { - UtilPlayer.message(player, F.main("Quest", "You can't cancel a completed Quest!")); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You can't cancel a completed " + QuestManager.QUEST_NAME + "!")); return; } _questManager.resetQuest(player, _quest, false); - UtilPlayer.message(player, F.main("Quest", "You have cancelled that Quest!")); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You have cancelled that " + QuestManager.QUEST_NAME + "!")); } if (clickType == ClickType.LEFT) { if (!_quest.isCompleted()) { - UtilPlayer.message(player, F.main("Quest", "You haven't completed that Quest yet!")); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You haven't completed that " + QuestManager.QUEST_NAME + " yet!")); return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 259e84a0b..be505ed11 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -18,6 +18,7 @@ import mineplex.core.lifetimes.ListenerComponent; import mineplex.core.lifetimes.PhasedLifetime; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; +import mineplex.core.quests.QuestManager; import mineplex.core.quests.event.QuestInteractEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -2049,7 +2050,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public void onQuestBuy(QuestInteractEvent event) { if (GetState() == GameState.Live || GetState() == GameState.Prepare || GetState() == GameState.End) - event.setCancelled("You cant interact with Quests while you are ingame!"); + event.setCancelled("You cant interact with " + QuestManager.QUEST_NAME + "s while you are ingame!"); } public NautHashMap getDeadBodies() From b823fc62c9d3d21a995995e0949053e1cdc73610 Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 2 Jun 2017 00:03:34 +0200 Subject: [PATCH 121/283] Fix quests not disappearing after completing --- .../src/mineplex/core/quests/Quest.java | 2 +- .../mineplex/core/quests/shop/QuestPage.java | 33 +++++-------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java index 965251fe4..d5a24a69e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java @@ -208,7 +208,7 @@ public class Quest public boolean isActive() { - return _current != 1; + return _current != -1; } public String[] getQuestInfo() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java index ae90e3def..8dd619e51 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java @@ -16,7 +16,6 @@ import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; -import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.quests.Quest; import mineplex.core.quests.QuestManager; @@ -32,7 +31,6 @@ public class QuestPage extends ShopPageBase { private QuestShop _questShop; private QuestManager _manager; - private InventoryManager _inventory; public QuestPage(QuestManager plugin, QuestShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) { @@ -41,16 +39,12 @@ public class QuestPage extends ShopPageBase _questShop = shop; _manager = plugin; - _inventory = plugin.getInventoryManager(); - buildPage(); } @Override protected void buildPage() { - ArrayList playerQuests = _shop.getQuestManager().Get(_player).getQuests(); - int i = 0; setItem(i, ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.RESET + "" + ChatColor.BOLD + "Available " + QuestManager.QUEST_NAME + "s")); { @@ -70,28 +64,19 @@ public class QuestPage extends ShopPageBase diff++; forward = !forward; - boolean cont = false; - - for (Quest playerQuest : playerQuests) + Quest playerQuest = _shop.getQuestManager().Get(_player).getQuestFromAll(questID); + if (playerQuest != null) { - if (playerQuest.getID() == questID) + if (!UtilTime.elapsed(playerQuest.getLastCompleted(), 1000*60*60*24)) { - if (!UtilTime.elapsed(playerQuest.getLastCompleted(), 1000*60*60*24)) - { - cont = true; - break; - } - if (playerQuest.isActive()) - { - cont = true; - break; - } + continue; + } + if (playerQuest.isActive()) + { + continue; } } - if (cont) - continue; - Quest quest = _shop.getQuestManager().getQuestByID(questID); ItemStack item = new ItemStack(Material.PAPER); @@ -133,7 +118,7 @@ public class QuestPage extends ShopPageBase int currentSlot = 4; int diff = 0; boolean forward = true; - for (Quest quest : playerQuests) + for (Quest quest : _shop.getQuestManager().Get(_player).getQuests()) { if (forward) { From 60a696a82e82d41e4dfb6fee5ba2990beccfa451 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 1 Jun 2017 17:25:30 -0500 Subject: [PATCH 122/283] Subscribe to response channel before requesting quests --- .../src/mineplex/quest/client/RedisQuestSupplier.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java index db5320f45..9d5fe025f 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java @@ -40,13 +40,13 @@ public class RedisQuestSupplier implements QuestSupplier _serverUniqueId = plugin.getConfig().getString("serverstatus.name"); - requestActiveQuests(); - // update quests sent specifically to this server when it requests them (like on startup) _pubSub.subscribe(PubSubChannels.QUEST_REQUEST_BASE + _serverUniqueId, this::updateQuests); // update quests when received _pubSub.subscribe(PubSubChannels.QUEST_SUPPLIER_CHANNEL, this::updateQuests); + + requestActiveQuests(); } private void updateQuests(String channel, String message) From cea9b00b68e5fb2e028d51c27f93d1f908180123 Mon Sep 17 00:00:00 2001 From: Kenny Goodin Date: Thu, 1 Jun 2017 18:27:02 -0400 Subject: [PATCH 123/283] Subscribe to quest request channel before requesting from daemon --- .../src/mineplex/quest/client/RedisQuestSupplier.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java index 9d5fe025f..14ee201eb 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java @@ -43,6 +43,8 @@ public class RedisQuestSupplier implements QuestSupplier // update quests sent specifically to this server when it requests them (like on startup) _pubSub.subscribe(PubSubChannels.QUEST_REQUEST_BASE + _serverUniqueId, this::updateQuests); + requestActiveQuests(); + // update quests when received _pubSub.subscribe(PubSubChannels.QUEST_SUPPLIER_CHANNEL, this::updateQuests); @@ -86,12 +88,7 @@ public class RedisQuestSupplier implements QuestSupplier { _lock.readLock().lock(); try - { - if (_quests.isEmpty()) - { - requestActiveQuests(); - } - + { return ImmutableSet.copyOf(_quests); } finally From b6a1a3a054ca23f83a3f6113c37fd2764ca50c2f Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 1 Jun 2017 17:29:42 -0500 Subject: [PATCH 124/283] Only request quests once on startup --- .../src/mineplex/quest/client/RedisQuestSupplier.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java index 14ee201eb..127862a66 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/client/RedisQuestSupplier.java @@ -47,8 +47,6 @@ public class RedisQuestSupplier implements QuestSupplier // update quests when received _pubSub.subscribe(PubSubChannels.QUEST_SUPPLIER_CHANNEL, this::updateQuests); - - requestActiveQuests(); } private void updateQuests(String channel, String message) From 0c6fcba21f8cb3f54f85cd3328de2c6d0b4c4380 Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 2 Jun 2017 02:00:20 +0200 Subject: [PATCH 125/283] Improve NPC visuals --- .../mineplex/core/quests/QuestClientData.java | 14 +++ .../mineplex/core/quests/QuestManager.java | 100 ++++++++++++++++-- .../core/quests/command/OpenGuiCommand.java | 2 +- 3 files changed, 104 insertions(+), 12 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java index 11c7ea556..74adc76e2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestClientData.java @@ -2,6 +2,8 @@ package mineplex.core.quests; import java.util.ArrayList; +import mineplex.core.hologram.Hologram; + /** * QuestClientData * @@ -11,6 +13,8 @@ public class QuestClientData { private ArrayList _quests = new ArrayList<>(); + private Hologram _hologram; + public void addQuest(Quest quest) { _quests.add(quest); @@ -77,4 +81,14 @@ public class QuestClientData { return _quests; } + + public Hologram getHologram() + { + return _hologram; + } + + public void setHologram(Hologram hologram) + { + _hologram = hologram; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index 018c54b47..f14b91ac1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -11,9 +11,9 @@ import java.util.function.Consumer; import net.md_5.bungee.api.ChatColor; import org.apache.commons.lang3.tuple.Triple; -import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -24,9 +24,12 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Pair; import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; import mineplex.core.google.GoogleSheetsManager; import mineplex.core.hologram.Hologram; @@ -40,6 +43,8 @@ import mineplex.core.quests.command.OpenGuiCommand; import mineplex.core.quests.repository.QuestRepository; import mineplex.core.quests.shop.QuestShop; import mineplex.core.stats.StatsManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.quest.client.RedisQuestSupplier; import mineplex.quest.common.QuestSupplier; import mineplex.serverdata.redis.messaging.PubSubJedisClient; @@ -70,8 +75,8 @@ public class QuestManager extends MiniClientPlugin private Npc _questNPC; private boolean _enableNPC; - - private Hologram _hologram; + private HologramManager _hologramManager; + private boolean _visualTick; public QuestManager(HologramManager hologramManager, InventoryManager inventoryManager, DonationManager donationManager) { @@ -83,27 +88,94 @@ public class QuestManager extends MiniClientPlugin _availableQuests = new ArrayList<>(); _donationManager = donationManager; _inventoryManager = inventoryManager; + _hologramManager = hologramManager; setupQuests(); - _questNPC = require(NpcManager.class).getNpcByName("Knight of GWEN"); + _questNPC = require(NpcManager.class).getNpcByName("Mineplex Missions"); if (_questNPC == null) { _enableNPC = false; } else { - Location loc = _questNPC.getEntity().getLocation(); - _hologram = new Hologram(hologramManager, loc.clone().add(0, 2.8, 0), ChatColor.AQUA + QUEST_NAME + "s"); - _hologram.start(); + Slime slime = (Slime) _questNPC.getEntity(); + slime.setSize(3); _enableNPC = true; } } - - @Override - public void disable() + + @EventHandler + public void updateCreeper(UpdateEvent event) { - _hologram.stop(); + if (event.getType() != UpdateType.FASTER || !_enableNPC) + return; + + for (Player player : UtilServer.getPlayers()) + { + String prefix = _visualTick ? C.cAqua : C.cDAqua; + updateSlimeVisual(player, prefix); + } + + _visualTick = !_visualTick; + } + + + + public void updateSlimeVisual(Player player , String rewardPrefix) + { + if (!_enableNPC) + return; + + int availableQuests = 5; + + for (int questid : getCurrentQuests()) + { + if (Get(player).getQuestFromAll(questid) == null) + continue; + + Quest quest = Get(player).getQuestFromAll(questid); + + if (quest.isActive()) + availableQuests--; + + if (!UtilTime.elapsed(quest.getLastCompleted(), 1000*60*60*24)) + availableQuests--; + } + + Hologram hologram; + + QuestClientData client = Get(player); + + if (client.getHologram() == null) + { + double yAdd = 2.3; + if(!UtilPlayer.is1_9(player)) + { + yAdd = 2.45; + } + hologram = new Hologram(_hologramManager, _questNPC.getLocation().clone().add(0, yAdd, 0), ""); + hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST); + hologram.addPlayer(player); + client.setHologram(hologram); + hologram.start(); + } + else + { + hologram = client.getHologram(); + } + + if (availableQuests > 0) + { + // Hologram + String text = rewardPrefix + availableQuests + " Mission" + (availableQuests > 1 ? "s" : "") + " Available"; + hologram.setText(text); + } + else + { + String text = C.cGray + "No Missions Available"; + hologram.setText(text); + } } @Override @@ -323,6 +395,12 @@ public class QuestManager extends MiniClientPlugin return new QuestClientData(); } + @Override + public void saveData(String name, int accountId) + { + Get(name).getHologram().stop(); + } + public ArrayList getAvailableQuests() { return _availableQuests; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java index bf5834577..df0f68f2c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java @@ -16,7 +16,7 @@ public class OpenGuiCommand extends CommandBase { public OpenGuiCommand(QuestManager plugin) { - super(plugin, Rank.ALL, "MineplexMissions"); + super(plugin, Rank.ALL, "Missions"); } @Override From 4b54232514895cc808b9d575b4ead56d69f5a7fe Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 2 Jun 2017 02:21:13 +0200 Subject: [PATCH 126/283] make slime not go small --- .../Mineplex.Core/src/mineplex/core/quests/QuestManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index f14b91ac1..63261a122 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -110,6 +110,9 @@ public class QuestManager extends MiniClientPlugin { if (event.getType() != UpdateType.FASTER || !_enableNPC) return; + + Slime slime = (Slime)_questNPC.getEntity(); + slime.setSize(3); for (Player player : UtilServer.getPlayers()) { From 73897e407bed20073767c8993e89522d9f20bb28 Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 2 Jun 2017 03:41:06 +0200 Subject: [PATCH 127/283] Add fix for new game lobbies --- .../src/mineplex/core/bonuses/BonusManager.java | 5 +++++ .../src/mineplex/core/quests/QuestManager.java | 7 ++++++- .../Mineplex.Hub/src/mineplex/hub/HubManager.java | 2 +- .../src/nautilus/game/arcade/ArcadeManager.java | 2 +- .../game/arcade/managers/lobby/LobbyManager.java | 13 ++++++++++++- .../lobby/current/NewGameLobbyManager.java | 15 +++++++++++++-- .../lobby/legacy/LegacyGameLobbyManager.java | 2 +- 7 files changed, 39 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 06f1d69b4..f135c63e7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -1261,4 +1261,9 @@ public class BonusManager extends MiniClientPlugin implements I { _carlLocation = carlLocation; } + + public Npc getCarl() + { + return _carlNpc; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index 63261a122..26741b195 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -11,6 +11,7 @@ import java.util.function.Consumer; import net.md_5.bungee.api.ChatColor; import org.apache.commons.lang3.tuple.Triple; +import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Slime; @@ -78,7 +79,7 @@ public class QuestManager extends MiniClientPlugin private HologramManager _hologramManager; private boolean _visualTick; - public QuestManager(HologramManager hologramManager, InventoryManager inventoryManager, DonationManager donationManager) + public QuestManager(HologramManager hologramManager, Location npc, InventoryManager inventoryManager, DonationManager donationManager) { super("Quest Manager"); @@ -101,6 +102,10 @@ public class QuestManager extends MiniClientPlugin { Slime slime = (Slime) _questNPC.getEntity(); slime.setSize(3); + if (npc != null) + { + _questNPC.setLocation(npc); + } _enableNPC = true; } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 5109551d0..070cd582a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -294,7 +294,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess new EasterEggHunt(plugin, _clientManager); - _questManager = new QuestManager(hologramManager, _inventoryManager, _donationManager); + _questManager = new QuestManager(hologramManager, null, _inventoryManager, _donationManager); new TemporaryGemHuntersServerSender(_portal); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index a79a7a7bb..7a0616ff1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -391,7 +391,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _kitProgressionManager = new KitProgressionManager(getPlugin(), donationManager, clientManager); _progressionKitManager = new ProgressingKitManager(this); _serverUptimeManager = new ServerUptimeManager(this); - _questManager = new QuestManager(hologramManager, _inventoryManager, _donationManager); + _questManager = new QuestManager(hologramManager, _gameLobbyManager.getMissions(), _inventoryManager, _donationManager); if (GetHost() != null && !GetHost().isEmpty() && !GetHost().startsWith("COM-")) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java index 72f1dc35f..3b9d09168 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java @@ -83,12 +83,13 @@ public abstract class LobbyManager implements Listener private Location _kitText; private Location _teamText; private Location _carl; + private Location _missions; private Location _spawn; private Location _ampStand; private boolean _colorTick = false; private boolean _generatePodiums = false; - public LobbyManager(ArcadeManager manager, Location carl, Location spawn, Location ampStand) + public LobbyManager(ArcadeManager manager, Location missions, Location carl, Location spawn, Location ampStand) { _manager = manager; @@ -892,4 +893,14 @@ public abstract class LobbyManager implements Listener { return _generatePodiums; } + + public Location getMissions() + { + return _missions; + } + + public void setMissions(Location loc) + { + _missions = loc; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/current/NewGameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/current/NewGameLobbyManager.java index 11b970117..e813e21bd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/current/NewGameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/current/NewGameLobbyManager.java @@ -58,6 +58,7 @@ public class NewGameLobbyManager extends LobbyManager public enum DataLoc { CARL, + MISSIONS, AMP, SPAWN,; } @@ -70,7 +71,7 @@ public class NewGameLobbyManager extends LobbyManager public NewGameLobbyManager(ArcadeManager manager) { - super(manager, null, null, null); + super(manager, null, null, null, null); _run = CONFIG.exists(); if (_run) @@ -519,7 +520,7 @@ public class NewGameLobbyManager extends LobbyManager continue; } - if (!lastName.equalsIgnoreCase("SPAWN") || lastName.equalsIgnoreCase("CARL")) + if (!lastName.equalsIgnoreCase("SPAWN") || lastName.equalsIgnoreCase("CARL") || lastName.equalsIgnoreCase("MISSIONS")) { loc.subtract(0, 0.5, 0); } @@ -557,6 +558,16 @@ public class NewGameLobbyManager extends LobbyManager setCarl(carl); } + + Location missions = _singleLocs.get(DataLoc.MISSIONS.name()); + if (missions != null) + { + missions.add(0, 0.5, 0); + float yaw = UtilAlg.GetYaw(UtilAlg.getTrajectory2d(missions, getSpawn())); + missions.setYaw(yaw); + + setMissions(missions); + } Location amp = _singleLocs.get(DataLoc.AMP.name()); if (amp != null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/legacy/LegacyGameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/legacy/LegacyGameLobbyManager.java index 2d988d0d5..9b275c0bd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/legacy/LegacyGameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/legacy/LegacyGameLobbyManager.java @@ -39,7 +39,7 @@ public class LegacyGameLobbyManager extends LobbyManager public LegacyGameLobbyManager(ArcadeManager manager) { - super(manager, null, null, new Location(UtilWorld.getWorld("world"), 0, 102.5, -15)); + super(manager, null, null, null, new Location(UtilWorld.getWorld("world"), 0, 102.5, -15)); setSpawn(new Location(WORLD, 0, 104, 0, 0, 0)); From 414573c18ded0abee994d3ea45267609440b05e4 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Thu, 1 Jun 2017 12:41:49 -0400 Subject: [PATCH 128/283] Make Carl more robust, print better warnings when he breaks --- .../mineplex/core/bonuses/BonusManager.java | 29 +++++++++++-------- .../gui/buttons/PowerPlayClubButton.java | 2 +- .../src/mineplex/core/gui/SimpleGui.java | 23 ++++++++++----- .../src/mineplex/core/npc/Npc.java | 6 ++++ .../powerplayclub/PowerPlayClubRewards.java | 24 +++++++++++++-- 5 files changed, 61 insertions(+), 23 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index f135c63e7..2bdd967f5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -941,12 +941,7 @@ public class BonusManager extends MiniClientPlugin implements I if (!_enabled) return; - Entity entity = event.getRightClicked(); - if (entity.equals(_carlNpc.getEntity())) - { - updateDailyStreak(event.getPlayer()); - new BonusGui(_plugin, event.getPlayer(), this, _rewardManager, _facebookManager, _youtubeManager, _thankManager, _playWireManager).openInventory(); - } + attemptOpenCarlGUI(event.getPlayer(), event.getRightClicked()); } @EventHandler @@ -957,12 +952,22 @@ public class BonusManager extends MiniClientPlugin implements I if (event.getDamager() instanceof Player) { - Player player = (Player) event.getDamager(); - if (event.getEntity().equals(_carlNpc.getEntity())) - { - updateDailyStreak(player); - new BonusGui(_plugin, player, this, _rewardManager, _facebookManager, _youtubeManager, _thankManager, _playWireManager).openInventory(); - } + attemptOpenCarlGUI((Player) event.getDamager(), event.getEntity()); + } + } + + private void attemptOpenCarlGUI(Player player, Entity entity) + { + if (_carlNpc == null || _carlNpc.getEntity() == null) + { + System.err.println("Carl is missing! (carlNpc=" + _carlNpc + ")"); + return; + } + + if (entity.equals(_carlNpc.getEntity())) + { + updateDailyStreak(player); + new BonusGui(_plugin, player, this, _rewardManager, _facebookManager, _youtubeManager, _thankManager, _playWireManager).openInventory(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java index d1282cc18..9af639e86 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java @@ -127,7 +127,7 @@ public class PowerPlayClubButton implements GuiItem itemName = C.cRedB + "Power Play Club"; lore.add(C.cYellow + YearMonth.now().getMonth().getDisplayName(TextStyle.FULL, Locale.US) + "'s Cosmetic"); - lore.add(C.cWhite + " " + PowerPlayClubRewards.rewards().get(YearMonth.now()).getPrizeName()); + lore.add(C.cWhite + " " + PowerPlayClubRewards.getReward(YearMonth.now()).getPrizeName()); lore.add(" "); lore.addAll(buildOtherRewardsLore(1)); lore.add(C.cRed + "Get Power Play Club months at"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java index 0029d1864..65e341389 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/SimpleGui.java @@ -82,16 +82,23 @@ public class SimpleGui implements ItemRefresher, Listener { Validate.isTrue(i >= 0 && i < _size, "Tried to add a gui item outside of inventory range"); - GuiItem oldItem = getItem(i); - if (oldItem != null) oldItem.close(); - - if (item != null) + try { - _items[i] = item; - item.setup(); - } + GuiItem oldItem = getItem(i); + if (oldItem != null) oldItem.close(); - refreshItem(i); + if (item != null) + { + _items[i] = item; + item.setup(); + } + + refreshItem(i); + } catch (Exception ex) + { + System.err.println("Failed to add item " + item + " to GUI " + this + ": "); + ex.printStackTrace(); + } } public GuiItem getItem(int i) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java index ff1d19ffa..59abe10de 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java @@ -188,4 +188,10 @@ public class Npc { _location = location; } + + @Override + public String toString() + { + return "NPC[entity=" + _entity + "]"; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 02388b67c..ee5b45eba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -8,10 +8,10 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -import org.bukkit.entity.Player; - import com.google.common.collect.ImmutableMap; +import org.bukkit.entity.Player; + import mineplex.core.Managers; import mineplex.core.common.util.BukkitFuture; import mineplex.core.common.util.F; @@ -49,6 +49,15 @@ public class PowerPlayClubRewards void reward(Player player); } + private static final PowerPlayClubItem MISSING = new PowerPlayClubItem() + { + @Override + public String getPrizeName() { return ""; } + + @Override + public void reward(Player player) { } + }; + private static class UnknownSalesPackageItem implements PowerPlayClubItem { private static final DonationManager _donationManager = Managers.require(DonationManager.class); @@ -112,6 +121,17 @@ public class PowerPlayClubRewards return rewards; } + public static PowerPlayClubItem getReward(YearMonth month) + { + if (rewards.containsKey(month)) + { + return rewards.get(month); + } else + { + System.err.println("PowerPlayClub item for " + month + " is missing!"); + return MISSING; + } + } public static void giveAllItems(Player player, InventoryManager inventoryManager, PowerPlayClubRepository repo) { From abaaaebd43409602018a334ed2532e058350cf0d Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Thu, 1 Jun 2017 12:43:05 -0400 Subject: [PATCH 129/283] Use "Coming soon!" instead of empty string --- .../core/powerplayclub/PowerPlayClubRewards.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index ee5b45eba..0c68ff1fd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -8,10 +8,10 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -import com.google.common.collect.ImmutableMap; - import org.bukkit.entity.Player; +import com.google.common.collect.ImmutableMap; + import mineplex.core.Managers; import mineplex.core.common.util.BukkitFuture; import mineplex.core.common.util.F; @@ -52,7 +52,7 @@ public class PowerPlayClubRewards private static final PowerPlayClubItem MISSING = new PowerPlayClubItem() { @Override - public String getPrizeName() { return ""; } + public String getPrizeName() { return "Coming soon!"; } @Override public void reward(Player player) { } @@ -123,14 +123,7 @@ public class PowerPlayClubRewards public static PowerPlayClubItem getReward(YearMonth month) { - if (rewards.containsKey(month)) - { - return rewards.get(month); - } else - { - System.err.println("PowerPlayClub item for " + month + " is missing!"); - return MISSING; - } + return rewards.getOrDefault(month, MISSING); } public static void giveAllItems(Player player, InventoryManager inventoryManager, PowerPlayClubRepository repo) From 62d15eeee1ceb4d87e49b2f628b2013a2a3b54b5 Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Fri, 2 Jun 2017 03:33:04 -0400 Subject: [PATCH 130/283] Make podium generation setting based on map rather than hardcoded server group --- .../src/nautilus/game/arcade/managers/lobby/LobbyManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java index 3b9d09168..635a7a0f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java @@ -53,6 +53,7 @@ import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.scoreboard.Team; +import java.io.File; import java.util.Map; /** @@ -117,7 +118,7 @@ public abstract class LobbyManager implements Listener _serverName = _serverName.substring(0, Math.min(16, _serverName.length())); _serverGroup = _manager.GetServerConfig().ServerGroup; - _generatePodiums = _serverGroup.equalsIgnoreCase("MiniGames") || manager.GetHost() != null; + _generatePodiums = new File("world/GENPODIUMS.dat").exists() || manager.GetHost() != null; if (_generatePodiums) { From 844052c0c6c5972223fd016b9e24c4a126c21a6e Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 2 Jun 2017 13:22:12 +0200 Subject: [PATCH 131/283] Async db calls... --- .../quests/repository/QuestRepository.java | 95 ++++++++++++++----- 1 file changed, 69 insertions(+), 26 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java index 8a5cd8a08..4592781c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java @@ -9,6 +9,7 @@ import org.apache.commons.lang3.tuple.Triple; import mineplex.core.account.CoreClient; import mineplex.core.common.Pair; import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UtilServer; import mineplex.core.quests.Quest; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; @@ -42,56 +43,98 @@ public class QuestRepository extends RepositoryBase public void createTable() { - executeUpdate(CREATE_TABLE); + UtilServer.runAsync(new Runnable() + { + @Override + public void run() + { + executeUpdate(CREATE_TABLE); + } + }); } public void getQuests(CoreClient client, Callback>>> callback) { - executeQuery(FETCH_QUESTS, new ResultSetCallable() - { + UtilServer.runAsync(new Runnable() + { @Override - public void processResultSet(ResultSet resultSet) throws SQLException + public void run() { - ArrayList>> list = new ArrayList<>(); - while (resultSet.next()) - { - list.add(Pair.create(resultSet.getInt(1), Triple.of(resultSet.getInt(2), resultSet.getLong(4), resultSet.getInt(3)))); - } - callback.run(list); + executeQuery(FETCH_QUESTS, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + ArrayList>> list = new ArrayList<>(); + while (resultSet.next()) + { + list.add(Pair.create(resultSet.getInt(1), Triple.of(resultSet.getInt(2), resultSet.getLong(4), resultSet.getInt(3)))); + } + callback.run(list); + } + } ,new ColumnInt("accountId", client.getAccountId())); } - } ,new ColumnInt("accountId", client.getAccountId())); + }); } public void resetQuest(CoreClient client, Quest quest, boolean completed) { - if (completed) + UtilServer.runAsync(new Runnable() { - executeUpdate(COMPLETE_QUEST, new ColumnLong("lastCompleted", System.currentTimeMillis()), new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); - } - else - { - executeUpdate(RESET_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); - } + @Override + public void run() + { + if (completed) + { + executeUpdate(COMPLETE_QUEST, new ColumnLong("lastCompleted", System.currentTimeMillis()), new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + } + else + { + executeUpdate(RESET_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + } + } + }); } public void addQuest(CoreClient client, Quest quest) { - executeUpdate(START_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + UtilServer.runAsync(new Runnable() + { + @Override + public void run() + { + executeUpdate(START_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + } + }); } public void addNew(CoreClient client, Quest quest) { - executeInsert(INSTERT_NEW_QUEST, null, - new ColumnInt("accountId", client.getAccountId()), - new ColumnInt("questId", quest.getID()), - new ColumnInt("progress", 0), - new ColumnInt("questCompletion", 0), - new ColumnLong("lastCompleted", (long) 0)); + UtilServer.runAsync(new Runnable() + { + @Override + public void run() + { + executeInsert(INSTERT_NEW_QUEST, null, + new ColumnInt("accountId", client.getAccountId()), + new ColumnInt("questId", quest.getID()), + new ColumnInt("progress", 0), + new ColumnInt("questCompletion", 0), + new ColumnLong("lastCompleted", (long) 0)); + } + }); } public void incrementQuest(CoreClient client, Quest quest, int value) { - executeUpdate(INCREMENT_QUEST, new ColumnInt("progress", value), new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + UtilServer.runAsync(new Runnable() + { + @Override + public void run() + { + executeUpdate(INCREMENT_QUEST, new ColumnInt("progress", value), new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + } + }); } } From 7e05cbfa877e20b847d060f8e0eab71dd2d13144 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 2 Jun 2017 18:43:07 +0100 Subject: [PATCH 132/283] Biff --- .../game/arcade/game/games/moba/Moba.java | 2 +- .../arcade/game/games/moba/kit/HeroSkill.java | 19 +-- .../moba/kit/anath/SkillFireProjectile.java | 2 +- .../game/games/moba/kit/biff/HeroBiff.java | 30 ++++ .../games/moba/kit/biff/SkillBiffDash.java | 142 ++++++++++++++++++ .../game/games/moba/kit/biff/SkillLeash.java | 112 ++++++++++++++ .../games/moba/kit/biff/SkillWarHorse.java | 108 +++++++++++++ .../games/moba/kit/dana/SkillPulseHeal.java | 31 ---- .../game/games/moba/kit/dana/SkillRally.java | 3 +- .../games/moba/kit/devon/SkillInfinity.java | 2 + .../moba/kit/hattori/SkillNinjaBlade.java | 70 +++++++-- .../moba/kit/hattori/SkillNinjaDash.java | 2 +- .../games/moba/kit/hattori/SkillSnowball.java | 2 +- .../game/games/moba/minion/MinionManager.java | 32 +++- .../moba/structure/point/CapturePoint.java | 2 +- .../games/moba/structure/tower/Tower.java | 7 + .../moba/structure/tower/TowerManager.java | 2 +- 17 files changed, 501 insertions(+), 67 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 366ad48c6..12d2f38ff 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -174,7 +174,7 @@ public class Moba extends TeamGame GameTeam perspectiveTeam = GetTeam(perspective); GameTeam subjectTeam = GetTeam(subject); - if (!IsAlive(subject) || subjectTeam == null) + if (!IsAlive(subject) || perspectiveTeam == null || subjectTeam == null) { return ""; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index ca3ebd0ab..5d0dcddd9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -12,8 +12,8 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; -import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; @@ -248,7 +248,7 @@ public class HeroSkill extends Perk } - public void useSkill(Player player) + public void useSkill(Player player) { _lastSkill.put(player.getUniqueId(), System.currentTimeMillis()); if (_cooldown > 0 && !UtilPlayer.isSpectator(player)) @@ -358,24 +358,15 @@ public class HeroSkill extends Perk protected boolean isTeamDamage(LivingEntity damagee, LivingEntity damager) { - if (!(damagee instanceof Player) || !(damager instanceof Player)) + if (!(damager instanceof Player)) { return false; } - Player damageePlayer = (Player) damagee; - Player damagerPlayer = (Player) damager; + GameTeam team = Manager.GetGame().GetTeam((Player) damager); - Game game = Manager.GetGame(); - GameTeam damageeTeam = game.GetTeam(damageePlayer); - GameTeam damagerTeam = game.GetTeam(damagerPlayer); + return team != null && MobaUtil.isTeamEntity(damagee, team); - if (damageeTeam == null || damagerTeam == null) - { - return false; - } - - return damageeTeam.equals(damagerTeam); } public int getSlot() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index c17176547..74591c991 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -25,7 +25,7 @@ public class SkillFireProjectile extends HeroSkill public SkillFireProjectile(int slot) { - super("Fire Item", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + super("Flame Wand", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java new file mode 100644 index 000000000..7be9bc451 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.moba.kit.biff; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroBiff extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new SkillSword(0), + new SkillLeash(1), + new SkillBiffDash(2) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); + + public HeroBiff(ArcadeManager manager) + { + super(manager, "Biff", DESCRIPTION, PERKS, IN_HAND, MobaRole.WARRIOR); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java new file mode 100644 index 000000000..15fd2c677 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java @@ -0,0 +1,142 @@ +package nautilus.game.arcade.game.games.moba.kit.biff; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +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.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class SkillBiffDash extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving fire behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + private final Map _active = new HashMap<>(); + + public SkillBiffDash(int slot) + { + super("Battle Leap", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(11000); + setSneakActivate(true); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @EventHandler + public void toggleSneak(PlayerToggleSneakEvent event) + { + if (!isSkillSneak(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @Override + public void useSkill(Player player) + { + if (_active.containsKey(player)) + { + return; + } + + Vector direction = player.getLocation().getDirection().setY(1); + + UtilAction.velocity(player, direction); + + player.getWorld().playSound(player.getLocation(), Sound.IRONGOLEM_THROW, 1, 1F); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, player.getLocation().add(0, 0.4, 0), 0.25F, 0.25F, 0.25F, 0.1F, 10, ViewDist.LONG); + + _active.put(player, System.currentTimeMillis()); + } + + @EventHandler + public void landed(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + Iterator iterator = _active.keySet().iterator(); + + while (iterator.hasNext()) + { + Player player = iterator.next(); + long start = _active.get(player); + + if (!player.isOnline()) + { + iterator.remove(); + } + + // They haven't just activated it + if (!UtilTime.elapsed(start, 1000) || !UtilEnt.isGrounded(player)) + { + continue; + } + + for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) + { + if (isTeamDamage(player, entity)) + { + continue; + } + + Block block = entity.getLocation().getBlock().getRelative(BlockFace.DOWN); + entity.getWorld().playEffect(block.getLocation().add(0.5, 0.5, 0.5), Effect.STEP_SOUND, block.getType(), block.getData()); + + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 4, false, true, false, UtilEnt.getName(player), GetName()); + UtilAction.velocity(entity, new Vector(0, 0.6 + Math.random() / 2, 0)); + } + } + } + + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + _active.remove(event.getEntity()); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java new file mode 100644 index 000000000..cead3d877 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -0,0 +1,112 @@ +package nautilus.game.arcade.game.games.moba.kit.biff; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffectType; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +public class SkillLeash extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.LEASH); + + private final Map> _leashed = new HashMap<>(); + + public SkillLeash(int slot) + { + super("Tether", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + setCooldown(12000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + useSkill(player); + + List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 3); + + _leashed.put(player, nearbyPlayers); + + for (Player nearby : nearbyPlayers) + { + if (isTeamDamage(nearby, player)) + { + continue; + } + + nearby.setLeashHolder(player); + nearby.setPullWhileLeashed(false); + nearby.setShouldBreakLeash(false); + nearby.sendMessage(F.main("Game", F.name(player.getName()) + " leashed you.")); + Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 0, false, true, true, false); + } + + useActiveSkill(() -> + { + for (Player leashed : _leashed.remove(player)) + { + removeEffect(leashed); + } + + }, player, 5000); + } + + @EventHandler + public void updateLeashed(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (Entry> entry : _leashed.entrySet()) + { + Iterator iterator = entry.getValue().iterator(); + + while (iterator.hasNext()) + { + Player leashed = iterator.next(); + + if (UtilMath.offsetSquared(entry.getKey(), leashed) < 25) + { + continue; + } + + removeEffect(leashed); + iterator.remove(); + } + } + } + + private void removeEffect(Player player) + { + player.setLeashHolder(null); + player.removePotionEffect(PotionEffectType.SLOW); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java new file mode 100644 index 000000000..ec8a428d2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -0,0 +1,108 @@ +package nautilus.game.arcade.game.games.moba.kit.biff; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class SkillWarHorse extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + private static final ItemStack HORSE_ARMOUR = new ItemStack(Material.IRON_BARDING); + + private final Set _data = new HashSet<>(); + + public SkillWarHorse(int slot) + { + super("Cavalry Charge", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + setCooldown(45000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + for (WarHorseData data : _data) + { + if (data.Owner.equals(player)) + { + return; + } + } + + Manager.GetGame().CreatureAllowOverride = true; + + Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); + + UtilEnt.vegetate(horse); + horse.setJumpStrength(0); + horse.setDomestication(horse.getMaxDomestication()); + horse.getInventory().setArmor(HORSE_ARMOUR); + horse.setPassenger(player); + + Manager.GetGame().CreatureAllowOverride = false; + + _data.add(new WarHorseData(player, horse)); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator iterator = _data.iterator(); + + while (iterator.hasNext()) + { + WarHorseData data = iterator.next(); + + if (UtilTime.elapsed(data.Start, 6000) + { + data.Horse.remove(); + iterator.remove(); + } + else if () + } + } + + private class WarHorseData + { + public Player Owner; + public Horse Horse; + public long Start; + + WarHorseData(Player owner, Horse horse) + { + Owner = owner; + Horse = horse; + Start = System.currentTimeMillis(); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java index d71fa9ad3..5c17f5fdf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -5,10 +5,7 @@ import mineplex.core.common.util.UtilEvent.ActionType; 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.UtilPlayer; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Location; import org.bukkit.Material; @@ -60,34 +57,6 @@ public class SkillPulseHeal extends HeroSkill displayPulse(player.getLocation().add(0, 0.5, 0)); } - @EventHandler - public void updatePulse(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - { - return; - } - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!hasPerk(player) || UtilPlayer.isSpectator(player)) - { - continue; - } - - for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) - { - // Don't heal enemies - if (!isTeamDamage(entity, player)) - { - continue; - } - - entity.setHealth(Math.min(entity.getHealth() + 4, entity.getMaxHealth())); - } - } - } - private void displayPulse(Location location) { Manager.runSyncTimer(new BukkitRunnable() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index 05331f42d..a1cba5e67 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -68,8 +68,7 @@ public class SkillRally extends HeroSkill } } - vector.setY(Math.min(vector.getY(), 1)); - vector.setY(Math.max(vector.getY(), 1.5)); + vector.setY(1.5); UtilAction.velocity(player, vector); _data.add(new RallyData(player)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 77bc3c242..3935b4ec6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -64,6 +64,8 @@ public class SkillInfinity extends HeroSkill return; } + // Give 1 arrow just incase the player didn't have one + _kit.giveAmmo(player, 1); bow.addEnchantment(Enchantment.ARROW_INFINITE, 1); _active.add(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index 638a243a0..d4d240265 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -6,10 +6,10 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.recharge.Recharge; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; +import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Entity; @@ -17,9 +17,10 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; -import java.util.HashSet; -import java.util.Set; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; public class SkillNinjaBlade extends HeroSkill @@ -34,12 +35,14 @@ public class SkillNinjaBlade extends HeroSkill .setTitle(C.cGreenB + "NINJA BLADE") .setUnbreakable(true) .build(); + private static final int ACTIVE_SLOT = 0; + private static final int BASE_DAMAGE_INCREASE = 4; - private Set _active = new HashSet<>(); + private Map _active = new HashMap<>(); public SkillNinjaBlade(int slot) { - super("Ninja Blade", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + super("Ender Blade", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); setDropItemActivate(true); @@ -55,12 +58,55 @@ public class SkillNinjaBlade extends HeroSkill } Player player = event.getPlayer(); + PlayerInventory inventory = player.getInventory(); - player.getInventory().setItem(getSlot(), ACTIVE_ITEM); - player.getInventory().setHeldItemSlot(getSlot()); - _active.add(player.getUniqueId()); + inventory.setItem(ACTIVE_SLOT, ACTIVE_ITEM); + inventory.setHeldItemSlot(ACTIVE_SLOT); - useActiveSkill(() -> _active.remove(player.getUniqueId()), player, 7000); + int damage = BASE_DAMAGE_INCREASE; + ItemStack sword = inventory.getItem(ACTIVE_SLOT); + + if (sword == null) + { + return; + } + + Material material = sword.getType(); + + // Increase damage based on the sword they had previously + switch (material) + { + case WOOD_SWORD: + damage += 2; + break; + case STONE_SWORD: + damage += 3; + break; + case GOLD_SWORD: + case IRON_SWORD: + damage += 4; + break; + case DIAMOND_SWORD: + damage += 5; + break; + } + + _active.put(player.getUniqueId(), damage); + + useActiveSkill(() -> + { + + _active.remove(player.getUniqueId()); + + for (Perk perk : Kit.GetPerks()) + { + if (perk instanceof SkillSword) + { + ((SkillSword) perk).giveItem(player); + } + } + + }, player, 7000); } @EventHandler @@ -77,14 +123,14 @@ public class SkillNinjaBlade extends HeroSkill ItemStack itemStack = player.getItemInHand(); - if (!_active.contains(player.getUniqueId()) || itemStack == null || itemStack.getType() != Material.DIAMOND_SWORD || itemStack.getItemMeta() == null || !itemStack.getItemMeta().getDisplayName().equals(ACTIVE_ITEM.getItemMeta().getDisplayName())) + if (!_active.containsKey(player.getUniqueId()) || itemStack == null || itemStack.getType() != Material.DIAMOND_SWORD || itemStack.getItemMeta() == null || !itemStack.getItemMeta().getDisplayName().equals(ACTIVE_ITEM.getItemMeta().getDisplayName())) { return; } UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, entity.getLocation().add(0, 1, 0), 1F, 1F, 1F, 0.1F, 50, ViewDist.LONG); entity.getWorld().playSound(entity.getLocation(), Sound.EXPLODE, 2, 0.5F); - event.AddMod(GetName(), 4); + event.AddMod(GetName(), _active.get(player.getUniqueId())); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java index 93439e6ca..0b886a430 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java @@ -37,7 +37,7 @@ public class SkillNinjaDash extends DashSkill public SkillNinjaDash(int slot) { - super("Dash", DESCRIPTION, SKILL_ITEM, slot); + super("Ninja Dash", DESCRIPTION, SKILL_ITEM, slot); setCooldown(7000); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 43427a091..5b80853d6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -31,7 +31,7 @@ public class SkillSnowball extends HeroSkill implements IThrown public SkillSnowball(int slot) { - super("Snowball", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + super("Shuriken", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(1000); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index df717f168..6c6104a45 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.minion; import mineplex.core.common.Rank; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; @@ -12,6 +13,7 @@ import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -21,7 +23,11 @@ import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import java.util.concurrent.TimeUnit; public class MinionManager implements Listener @@ -82,9 +88,10 @@ public class MinionManager implements Listener for (Tower tower : _host.getTowerManager().getTowers()) { - if (!tower.isDead() && tower.getOwner().equals(team)) + if (!tower.isDead() && !tower.getOwner().equals(team)) { superMinions = false; + break; } } @@ -100,6 +107,27 @@ public class MinionManager implements Listener } } + @EventHandler + public void towerDestroy(TowerDestroyEvent event) + { + Tower tower = event.getTower(); + + if (tower.isFirstTower()) + { + return; + } + + for (GameTeam team : _host.GetTeamList()) + { + if (team.equals(tower.getOwner())) + { + continue; + } + + _host.Announce(F.main("Game", team.GetFormattedName() + "'s " + C.mBody + "minions are now " + C.cYellowB + "Super-Charged" + C.mBody + "!"), false); + } + } + public void setEnabled(boolean enabled) { _enabled = enabled; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index d949be280..e68722aa2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -154,7 +154,7 @@ public class CapturePoint player.playSound(player.getLocation(), Sound.GHAST_SCREAM2, 1, 1.0F); } - _host.Announce(F.main("Game", "Team " + highest.GetFormattedName() + C.mBody + " is capturing beacon " + _colour + _name + C.mBody + "!"), false); + _host.Announce(F.main("Game", "Team " + highest.GetFormattedName() + C.mBody + " is capturing the " + _colour + _name + C.mBody + "Beacon!"), false); //UtilTextMiddle.display("", "Team " + highest.GetFormattedName() + C.cWhite + " is capturing beacon " + _colour + _name, 0, 30, 10); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index ed5543597..48bddbc19 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -150,6 +150,13 @@ public class Tower // Boom! explode(); + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getLocation(), Sound.BLAZE_BREATH, 1, 0.4F); + } + + _host.Announce(F.main("Game", _team.GetFormattedName() + C.mBody + " has lost a tower!"), false); + // Nullify everything and remove all entities _target = null; setLaserTarget(null); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 02ce53665..22831e831 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -12,7 +12,6 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Sound; @@ -192,6 +191,7 @@ public class TowerManager implements Listener if (UtilMath.offsetSquared(playerLocation, entityLocation) > Tower.TARGET_RANGE_SQUARED) { + event.setCancelled(true); return; } } From 674253c89afdba267ee23bf2ab355ab186e64f05 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 3 Jun 2017 14:53:33 +0100 Subject: [PATCH 133/283] Gen Hunters Title --- .../core/titles/tracks/TrackManager.java | 2 + .../tracks/standard/GemHuntersTrack.java | 51 +++++++++++-------- .../src/mineplex/gemhunters/GemHunters.java | 4 ++ .../gemhunters/economy/CashOutModule.java | 9 +++- .../gemhunters/economy/EconomyModule.java | 15 +++--- 5 files changed, 48 insertions(+), 33 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java index eddb79bf6..05c6833d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java @@ -9,6 +9,7 @@ import java.util.function.Consumer; import mineplex.core.titles.tracks.award.AlienInvasionTrack; import mineplex.core.titles.tracks.award.AprilFools2017Track; +import mineplex.core.titles.tracks.standard.GemHuntersTrack; import net.md_5.bungee.api.ChatColor; import org.bukkit.Bukkit; @@ -79,6 +80,7 @@ public class TrackManager extends MiniPlugin // registerTrack(new SurvivorTrack()); registerTrack(new LevelerTrack()); registerTrack(new PerfectionistTrack()); + registerTrack(new GemHuntersTrack()); // Awarded tracks registerTrack(new Bridges2017Track()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemHuntersTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemHuntersTrack.java index ea7b1490f..e247ee9da 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemHuntersTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemHuntersTrack.java @@ -14,39 +14,46 @@ public class GemHuntersTrack extends Track getRequirements() .addTier(new TrackTier( - "Gem Beggar", - "Gain 1,000 Gem Points", + "Beggar", + "Gain 1,000 Gems in Gem Hunters", this::getStat, 1000, new TrackFormat(ChatColor.GRAY) )) .addTier(new TrackTier( - "Respectable Gem Miner", - "Gain 25,000 Gem Points", + "Poor", + "Gain 5,000 Gems in Gem Hunters", this::getStat, - 25000, - new TrackFormat(ChatColor.LIGHT_PURPLE) + 5000, + new TrackFormat(ChatColor.AQUA) )) .addTier(new TrackTier( "Middle Class", - "Gain 50,000 Gem Points", + "Gain 7,500 Gems in Gem Hunters", + this::getStat, + 7500, + new TrackFormat(ChatColor.GREEN) + )) + .addTier(new TrackTier( + "Wealthy", + "Gain 10,000 Gems in Gem Hunters", + this::getStat, + 10000, + new TrackFormat(ChatColor.DARK_GREEN) + )) + .addTier(new TrackTier( + "Loaded", + "Gain 25,000 Gems in Gem Hunters", + this::getStat, + 25000, + new TrackFormat(ChatColor.GOLD) + )) + .addTier(new TrackTier( + "Millionaire", + "Gain 50,000 Gems in Gem Hunters", this::getStat, 50000, - new TrackFormat(ChatColor.BLUE, null) - )) - .addTier(new TrackTier( - "Gems, Gems, Gems", - "Gain 75,000 Gem Points", - this::getStat, - 75000, - new TrackFormat(ChatColor.GREEN, null) - )) - .addTier(new TrackTier( - "Gem McScrooge", - "Gain 100,000 Gem Points", - this::getStat, - 100000, - new TrackFormat(ChatColor.RED, ChatColor.RED) + new TrackFormat(ChatColor.GOLD, ChatColor.YELLOW) )); getRequirements() diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index 21104db46..463ba8d28 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -1,5 +1,7 @@ package mineplex.gemhunters; +import mineplex.core.titles.Titles; +import mineplex.core.titles.tracks.TrackManager; import net.minecraft.server.v1_8_R3.MinecraftServer; import org.bukkit.Bukkit; @@ -269,6 +271,8 @@ public class GemHunters extends JavaPlugin // Tutorials TextTutorialManager tutorialManager = new TextTutorialManager(this, donationManager, new TaskManager(this, clientManager)); tutorialManager.addTutorial(new GemHuntersTutorial()); + + require(Titles.class).forceDisable(); // Now we finally get to enable the Gem Hunters modules // Though if any other module needs one of these it will be generated in diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java index c4d3b75d8..117327538 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java @@ -11,6 +11,8 @@ import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; import mineplex.core.portal.Portal; import mineplex.core.recharge.Recharge; +import mineplex.core.titles.tracks.TrackManager; +import mineplex.core.titles.tracks.standard.GemHuntersTrack; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.gemhunters.economy.command.CashOutItemCommand; @@ -44,7 +46,8 @@ public class CashOutModule extends MiniPlugin private static final int CASH_OUT_MAX_MOVE_DISTANCE_SQUARED = 4; private final DonationManager _donation; - + private final TrackManager _track; + private final Map _sessions; private final Set _aboutToCashOut; @@ -53,7 +56,8 @@ public class CashOutModule extends MiniPlugin super("Cash Out"); _donation = require(DonationManager.class); - + _track = require(TrackManager.class); + _sessions = new HashMap<>(); _aboutToCashOut = new HashSet<>(); } @@ -147,6 +151,7 @@ public class CashOutModule extends MiniPlugin _aboutToCashOut.add(player.getUniqueId()); + _track.getTrack(GemHuntersTrack.class).incrementFor(player, completeEvent.getGems()); _donation.rewardCurrencyUntilSuccess(GlobalCurrency.GEM, player, "Earned", completeEvent.getGems()); session.endSession(); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java index e9df24620..9fac54ea7 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java @@ -1,13 +1,5 @@ package mineplex.gemhunters.economy; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.PlayerDeathEvent; - import mineplex.core.MiniClientPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.common.currency.GlobalCurrency; @@ -15,11 +7,16 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; import mineplex.core.donation.DonationManager; import mineplex.core.donation.Donor; -import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent; import mineplex.gemhunters.economy.command.GiveGemsCommand; import mineplex.gemhunters.economy.event.PlayerCashOutCompleteEvent; import mineplex.gemhunters.economy.event.PlayerEarnGemsEvent; import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.PlayerDeathEvent; + +import java.util.UUID; @ReflectivelyCreateMiniPlugin public class EconomyModule extends MiniClientPlugin From e094446be49d09044bfda862c6af320a2336df6f Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 3 Jun 2017 15:33:26 +0100 Subject: [PATCH 134/283] Add biff to the hero list --- .../src/nautilus/game/arcade/game/games/moba/Moba.java | 2 ++ .../game/arcade/game/games/moba/kit/biff/SkillWarHorse.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 12d2f38ff..b0a0fb4f1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -22,6 +22,7 @@ import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.KitPlayer; import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath; +import nautilus.game.arcade.game.games.moba.kit.biff.HeroBiff; import nautilus.game.arcade.game.games.moba.kit.bob.HeroBob; import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana; import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; @@ -91,6 +92,7 @@ public class Moba extends TeamGame new HeroDevon(Manager), new HeroAnath(Manager), new HeroDana(Manager), + new HeroBiff(Manager), new HeroBob(Manager) }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index ec8a428d2..f1089f02f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -83,12 +83,12 @@ public class SkillWarHorse extends HeroSkill { WarHorseData data = iterator.next(); - if (UtilTime.elapsed(data.Start, 6000) + if (UtilTime.elapsed(data.Start, 6000)) { data.Horse.remove(); iterator.remove(); } - else if () + //else if () } } From 347cddccc01713576e960990e8b32dfd7ceba1d8 Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 28 Dec 2016 13:37:02 -0700 Subject: [PATCH 135/283] Use UUID in enjin commands instead of name --- .../core/account/CoreClientManager.java | 48 ++++++++++++++ .../src/mineplex/enjinTranslator/Enjin.java | 66 +++++-------------- 2 files changed, 65 insertions(+), 49 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index a8bc40c04..0c096b119 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -31,6 +31,7 @@ import com.google.common.collect.Sets; import com.google.gson.Gson; import mineplex.cache.player.PlayerCache; +import mineplex.cache.player.PlayerInfo; import mineplex.core.MiniPlugin; import mineplex.core.account.command.TestRank; import mineplex.core.account.command.UpdateRank; @@ -260,6 +261,53 @@ public class CoreClientManager extends MiniPlugin loadClientByName(playerName, client -> runnable.run()); } + public void loadClientByUUID(UUID uuid, Consumer loadedClient) + { + runAsync(() -> + { + AtomicReference loaded = new AtomicReference<>(); + try + { + Gson gson = new Gson(); + + String response = _repository.getClientByUUID(uuid); + + ClientToken token = gson.fromJson(response, ClientToken.class); + if (token.Name == null || token.Rank == null) + { + loaded.set(null); + return; + } + + CoreClient client = Add(token.Name, uuid); + client.SetRank(Rank.valueOf(token.Rank), false); + client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName())); + + Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); + + if (client.getAccountId() > 0) + { + PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); + + if (playerInfo != null) + { + PlayerCache.getInstance().updateAccountId(uuid, client.getAccountId()); + } + } + + loaded.set(client); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + finally + { + UtilTasks.onMainThread(() -> loadedClient.accept(loaded.get())).run(); + } + }); + } + public void loadClientByName(String playerName, Consumer loadedClient) { runAsync(() -> diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index f9bf43da3..b36ab85d8 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -2,17 +2,13 @@ package mineplex.enjinTranslator; import java.text.SimpleDateFormat; import java.time.LocalDate; -import java.util.AbstractMap; import java.util.Date; -import java.util.Iterator; -import java.util.Map.Entry; import java.util.UUID; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; @@ -20,15 +16,12 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; -import mineplex.core.common.util.NautHashMap; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.powerplayclub.PowerPlayClubRepository; import mineplex.core.punish.Category; import mineplex.core.punish.Punish; import mineplex.core.server.util.TransactionResponse; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.enjinTranslator.purchase.PurchaseManager; public class Enjin extends MiniPlugin implements CommandExecutor @@ -40,7 +33,6 @@ public class Enjin extends MiniPlugin implements CommandExecutor private PowerPlayClubRepository _powerPlayClubRepository; private Punish _punish; - private NautHashMap> _cachedUUIDs = new NautHashMap>(); private static Object _commandLock = new Object(); public long _lastPoll = System.currentTimeMillis() - 120000; @@ -63,21 +55,6 @@ public class Enjin extends MiniPlugin implements CommandExecutor plugin.getCommand("pull").setExecutor(this); } - @EventHandler - public void expireCachedUUIDs(UpdateEvent event) - { - if (event.getType() != UpdateType.MIN_01) - return; - - for (Iterator>> iterator = _cachedUUIDs.entrySet().iterator(); iterator.hasNext(); ) - { - Entry> entry = iterator.next(); - - if (System.currentTimeMillis() > entry.getValue().getValue()) - iterator.remove(); - } - } - @Override public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) { @@ -90,35 +67,26 @@ public class Enjin extends MiniPlugin implements CommandExecutor if (label.equalsIgnoreCase("enjin_mineplex")) { - final String name = args[1]; + final UUID uuid; + try + { + uuid = UUID.fromString(args[1]); + } + catch (IllegalArgumentException e) + { + System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + args[1] + "; invalid UUID."); + return true; + } - _clientManager.loadClientByName(name, client -> + _clientManager.loadClientByUUID(uuid, client -> { if (client == null) { - System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + ", isn't in our database."); + System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + uuid + ", isn't in our database."); } else { - UUID uuid = null; - - if (_cachedUUIDs.containsKey(name)) - uuid = _cachedUUIDs.get(name).getKey(); - else - { - // Fails if not in DB and if duplicate. - uuid = _clientManager.loadUUIDFromDB(name); - } - - if (uuid == null) - { - System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + ", no UUID."); - return; - } - - final UUID playerUUID = uuid; - - _cachedUUIDs.put(name, new AbstractMap.SimpleEntry(playerUUID, System.currentTimeMillis() + 240000)); + final String name = client.getName(); if (args[0].equalsIgnoreCase("chargeback")) { @@ -129,15 +97,15 @@ public class Enjin extends MiniPlugin implements CommandExecutor if (!checkForClansPurchase(args, name, client)) { - if (!checkForBoosterPurchase(args, name, playerUUID, client)) + if (!checkForBoosterPurchase(args, name, uuid, client)) { - if (!checkForCoinPurchase(args, name, playerUUID, client)) + if (!checkForCoinPurchase(args, name, uuid, client)) { - if (!checkForRankPurchase(args, name, playerUUID, client)) + if (!checkForRankPurchase(args, name, uuid, client)) { if (!checkForPurchase(args, name, client)) { - if (!checkForPowerPlayClub(args, name, playerUUID, client)) + if (!checkForPowerPlayClub(args, name, uuid, client)) { StringBuilder sb = new StringBuilder(); From a3fd81f7637b8e226e13ec76a26cd7a00fb95853 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 4 Jun 2017 10:52:43 +0100 Subject: [PATCH 136/283] Fix Biff's skills not cleaning up --- .../games/moba/kit/biff/SkillBiffDash.java | 6 +++- .../game/games/moba/kit/biff/SkillLeash.java | 31 +++++++++---------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java index 15fd2c677..a18f97d51 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java @@ -81,6 +81,8 @@ public class SkillBiffDash extends HeroSkill return; } + super.useSkill(player); + Vector direction = player.getLocation().getDirection().setY(1); UtilAction.velocity(player, direction); @@ -111,7 +113,7 @@ public class SkillBiffDash extends HeroSkill iterator.remove(); } - // They haven't just activated it + // They have just activated it if (!UtilTime.elapsed(start, 1000) || !UtilEnt.isGrounded(player)) { continue; @@ -130,6 +132,8 @@ public class SkillBiffDash extends HeroSkill Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 4, false, true, false, UtilEnt.getName(player), GetName()); UtilAction.velocity(entity, new Vector(0, 0.6 + Math.random() / 2, 0)); } + + iterator.remove(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java index cead3d877..32d7f07c6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -47,34 +47,33 @@ public class SkillLeash extends HeroSkill } Player player = event.getPlayer(); - useSkill(player); List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 3); - _leashed.put(player, nearbyPlayers); + nearbyPlayers.removeIf(other -> isTeamDamage(other, player)); + + if (!nearbyPlayers.isEmpty()) + { + _leashed.put(player, nearbyPlayers); + + useActiveSkill(() -> + { + for (Player leashed : _leashed.remove(player)) + { + removeEffect(leashed); + } + + }, player, 5000); + } for (Player nearby : nearbyPlayers) { - if (isTeamDamage(nearby, player)) - { - continue; - } - nearby.setLeashHolder(player); nearby.setPullWhileLeashed(false); nearby.setShouldBreakLeash(false); nearby.sendMessage(F.main("Game", F.name(player.getName()) + " leashed you.")); Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 0, false, true, true, false); } - - useActiveSkill(() -> - { - for (Player leashed : _leashed.remove(player)) - { - removeEffect(leashed); - } - - }, player, 5000); } @EventHandler From 629ced569c72d96afee2087196fbf4342a8a3812 Mon Sep 17 00:00:00 2001 From: cnr Date: Mon, 5 Jun 2017 11:52:38 -0500 Subject: [PATCH 137/283] Fix treasure location comparison between worlds --- .../src/mineplex/core/treasure/TreasureLocation.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java index 264da1eae..b3fdc3e2a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java @@ -363,6 +363,10 @@ public class TreasureLocation implements Listener { return; } + if (_currentTreasure.getCenterBlock().getWorld() != event.getTo().getWorld()) + { + return; + } double toDistanceFromCenter = _currentTreasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5).distanceSquared(event.getTo()); if (toDistanceFromCenter <= 16) { From 4a91d2821bc7546e25f85ebbdbcd9c5d89b2cbdb Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 5 Jun 2017 20:57:30 +0100 Subject: [PATCH 138/283] Achievements --- .../core/achievement/Achievement.java | 26 ++++++++- .../core/achievement/AchievementCategory.java | 6 ++- .../src/mineplex/core/game/GameDisplay.java | 2 + .../mineplex/core/titles/tracks/Track.java | 2 +- .../tracks/standard/GemHuntersTrack.java | 9 ++++ .../src/mineplex/gemhunters/GemHunters.java | 1 + .../gemhunters/death/DeathModule.java | 53 +++++++++++-------- .../gemhunters/economy/CashOutModule.java | 23 +++++--- .../mineplex/gemhunters/loot/LootModule.java | 6 ++- .../gemhunters/quest/QuestModule.java | 7 ++- 10 files changed, 100 insertions(+), 35 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 1d1dd47c4..f9820de1b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -1201,7 +1201,31 @@ public enum Achievement new String[]{"Skyfall.SupplyDropsOpened"}, new String[]{"Be the first to open 20 Supply Drops"}, new int[]{20}, - AchievementCategory.SKYFALL); + AchievementCategory.SKYFALL), + + GEM_HUNTERS_KILLS("Gem Killer", 5000, + new String[]{"Gem Hunters.Kills"}, + new String[]{"+1 for each kill"}, + new int[]{10,25,50,100,1000}, + AchievementCategory.GEM_HUNTERS), + + GEM_HUNTERS_GEMS_EARNED("Gem Millionaire", 5000, + new String[]{"Gem Hunters.GemsEarned"}, + new String[]{"+1 for each Gem cashed out"}, + new int[]{1000,2500,5000,10000,100000}, + AchievementCategory.GEM_HUNTERS), + + GEM_HUNTERS_QUESTS("Quest Complete", 5000, + new String[]{"Gem Hunters.QuestsOpened"}, + new String[]{"+1 for each quest completed"}, + new int[]{10,25,50,100,1000}, + AchievementCategory.GEM_HUNTERS), + + GEM_HUNTERS_CHESTS_OPENED("Loot Get!", 5000, + new String[]{"Gem Hunters.ChestsOpened"}, + new String[]{"+1 for each chest opened"}, + new int[]{50,100,200,400,1000}, + AchievementCategory.GEM_HUNTERS); private String _name; private String[] _desc; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 3a2d752df..a1ebeb4f8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -213,7 +213,11 @@ public enum AchievementCategory StatDisplay.fromGame("Wins", GameDisplay.SkyfallTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SkyfallTeams, "Wins", "Losses"), StatDisplay.fromGame("Kills", GameDisplay.SkyfallTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SkyfallTeams, "Deaths"), StatDisplay.fromGame("Gems Earned", GameDisplay.SkyfallTeams, "GemsEarned"), null, StatDisplay.fromGame("Booster Rings", GameDisplay.SkyfallTeams, "Rings")}, - Material.DIAMOND_BOOTS, 0, GameCategory.SURVIVAL, null, false, GameDisplay.Skyfall.getGameId(), GameDisplay.SkyfallTeams.getGameId()); + Material.DIAMOND_BOOTS, 0, GameCategory.SURVIVAL, null, false, GameDisplay.Skyfall.getGameId(), GameDisplay.SkyfallTeams.getGameId()), + + GEM_HUNTERS("Gem Hunters", null, + new StatDisplay[] {StatDisplay.KILLS, StatDisplay.GEMS_EARNED, StatDisplay.fromGame("Quests Complete", GameDisplay.GemHunters, "QuestsCompleted"), StatDisplay.fromGame("Chests Opened", GameDisplay.GemHunters, "ChestsOpened")}, + Material.EMERALD, 0, GameCategory.SURVIVAL, null, false, GameDisplay.GemHunters.getGameId()); private String _name; private String[] _statsToPull; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 6f6f38241..e238880ed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -104,6 +104,8 @@ public enum GameDisplay AlienInvasion("Alien Invasion", Material.ENDER_STONE, (byte) 0, GameCategory.EVENT, 69, false), + GemHunters("Gem Hunters", Material.EMERALD, (byte) 0, GameCategory.SURVIVAL, 71, false), + Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999, false), Brawl("Brawl", Material.DIAMOND, (byte) 0, GameCategory.EVENT, 998, false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/Track.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/Track.java index bb436bd21..d7db74382 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/Track.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/Track.java @@ -78,7 +78,7 @@ public class Track implements Listener return this._trackRequirements; } - public final String getStatName() + public String getStatName() { return "track." + _id; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemHuntersTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemHuntersTrack.java index e247ee9da..21fffdd87 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemHuntersTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemHuntersTrack.java @@ -59,4 +59,13 @@ public class GemHuntersTrack extends Track getRequirements() .withRequirement(1, "Gem Earned in Gem Hunters"); } + + /** + * Overriding this means we can hit two birds with one stat. + */ + @Override + public String getStatName() + { + return "Gem Hunters.GemsEarned"; + } } diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index 463ba8d28..ce821a7a5 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -188,6 +188,7 @@ public class GemHunters extends JavaPlugin // Creatures Creature creature = new Creature(this); + creature.SetDisableCustomDrops(true); // The old classic Damage Manager DamageManager damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager, new ConditionManager(this)); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/DeathModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/DeathModule.java index 4f9baa634..2d75e67d9 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/DeathModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/DeathModule.java @@ -1,11 +1,20 @@ package mineplex.gemhunters.death; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - +import com.google.common.collect.Sets; +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.stats.StatsManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent; +import mineplex.gemhunters.playerstatus.PlayerStatusModule; +import mineplex.gemhunters.playerstatus.PlayerStatusType; +import mineplex.gemhunters.spawn.SpawnModule; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; @@ -13,7 +22,6 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -22,25 +30,14 @@ import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; -import com.google.common.collect.Sets; - -import mineplex.core.MiniPlugin; -import mineplex.core.ReflectivelyCreateMiniPlugin; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent; -import mineplex.gemhunters.playerstatus.PlayerStatusModule; -import mineplex.gemhunters.playerstatus.PlayerStatusType; -import mineplex.gemhunters.spawn.SpawnModule; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; /** * This module handles anything to do with a players death @@ -56,6 +53,7 @@ public class DeathModule extends MiniPlugin private static final int DEATH_ANIMATION_COUNTDOWN = 2000; private final PlayerStatusModule _playerStatus; + private final StatsManager _stats; private final SpawnModule _spawn; private final Map _toRemove; @@ -65,6 +63,7 @@ public class DeathModule extends MiniPlugin super("Death"); _playerStatus = require(PlayerStatusModule.class); + _stats = require(StatsManager.class); _spawn = require(SpawnModule.class); _toRemove = new HashMap<>(); @@ -80,6 +79,14 @@ public class DeathModule extends MiniPlugin player.setFoodLevel(20); player.setExhaustion(0); + // Record the stats + Player killer = player.getKiller(); + + if (killer != null) + { + _stats.incrementStat(player, "Gem Hunters.Kills", 1); + } + startAnimation(player); _toRemove.put(player.getUniqueId(), System.currentTimeMillis()); } diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java index 117327538..a28cbb327 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java @@ -3,16 +3,20 @@ package mineplex.gemhunters.economy; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; import mineplex.core.portal.Portal; import mineplex.core.recharge.Recharge; -import mineplex.core.titles.tracks.TrackManager; -import mineplex.core.titles.tracks.standard.GemHuntersTrack; +import mineplex.core.stats.StatsManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.gemhunters.economy.command.CashOutItemCommand; @@ -32,7 +36,12 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import java.text.DecimalFormat; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; @ReflectivelyCreateMiniPlugin public class CashOutModule extends MiniPlugin @@ -46,7 +55,7 @@ public class CashOutModule extends MiniPlugin private static final int CASH_OUT_MAX_MOVE_DISTANCE_SQUARED = 4; private final DonationManager _donation; - private final TrackManager _track; + private final StatsManager _stats; private final Map _sessions; private final Set _aboutToCashOut; @@ -56,7 +65,7 @@ public class CashOutModule extends MiniPlugin super("Cash Out"); _donation = require(DonationManager.class); - _track = require(TrackManager.class); + _stats = require(StatsManager.class); _sessions = new HashMap<>(); _aboutToCashOut = new HashSet<>(); @@ -151,7 +160,7 @@ public class CashOutModule extends MiniPlugin _aboutToCashOut.add(player.getUniqueId()); - _track.getTrack(GemHuntersTrack.class).incrementFor(player, completeEvent.getGems()); + _stats.incrementStat(player, "Gem Hunters.GemsEarned", completeEvent.getGems()); _donation.rewardCurrencyUntilSuccess(GlobalCurrency.GEM, player, "Earned", completeEvent.getGems()); session.endSession(); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java index dbff05dc6..b759af50b 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java @@ -5,6 +5,7 @@ import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.google.GoogleSheetsManager; +import mineplex.core.stats.StatsManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.gemhunters.economy.EconomyModule; @@ -58,6 +59,7 @@ public class LootModule extends MiniPlugin private final EconomyModule _economy; private final GoogleSheetsManager _sheets; private final SafezoneModule _safezone; + private final StatsManager _stats; private final WorldDataModule _worldData; private final Map> _chestLoot; @@ -73,6 +75,7 @@ public class LootModule extends MiniPlugin _economy = require(EconomyModule.class); _sheets = require(GoogleSheetsManager.class); _safezone = require(SafezoneModule.class); + _stats = require(StatsManager.class); _worldData = require(WorldDataModule.class); _chestLoot = new HashMap<>(); _chestProperties = new HashMap<>(); @@ -453,7 +456,8 @@ public class LootModule extends MiniPlugin event.setCancelled(true); return; } - + + _stats.incrementStat(player, "Gem Hunters.ChestsOpened", 1); fillChest(player, block, key); } diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java index da43ba06c..de1c5b612 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java @@ -5,6 +5,7 @@ import java.util.UUID; import java.util.concurrent.TimeUnit; import mineplex.core.common.util.*; +import mineplex.core.stats.StatsManager; import net.md_5.bungee.api.ChatColor; import org.bukkit.Bukkit; @@ -87,6 +88,7 @@ public class QuestModule extends MiniClientPlugin }; private final EconomyModule _economy; + private final StatsManager _stats; private final WorldDataModule _worldData; private QuestModule() @@ -94,6 +96,7 @@ public class QuestModule extends MiniClientPlugin super("Quest"); _economy = require(EconomyModule.class); + _stats = require(StatsManager.class); _worldData = require(WorldDataModule.class); Menu menu = new QuestUI(this); @@ -311,7 +314,9 @@ public class QuestModule extends MiniClientPlugin } player.sendMessage(F.main(_moduleName, "Completed " + F.name(quest.getName()) + ".")); - + + _stats.incrementStat(player, "Gem Hunters.Quests Completed", 1); + QuestPlayerData playerData = Get(player); playerData.getActiveQuests().remove(Integer.valueOf(quest.getId())); playerData.getCompletedQuests().add(quest.getId()); From a63399943d708b9070a1da132d493fd29e7c09c2 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 6 Jun 2017 19:28:41 +0100 Subject: [PATCH 139/283] Leaderboards and UFO world event --- .../core/achievement/AchievementCategory.java | 2 +- .../tracks/standard/GemHuntersTrack.java | 2 +- .../games/castleassault/data/TeamKing.java | 127 +---------- .../src/mineplex/gemhunters/GemHunters.java | 23 +- .../gemhunters/death/DeathModule.java | 2 +- .../gemhunters/economy/CashOutModule.java | 6 +- .../gemhunters/quest/QuestModule.java | 2 +- .../gemhunters/safezone/SafezoneModule.java | 2 +- .../gemhunters/world/Leaderboards.java | 33 +++ .../worldevent/WorldEventModule.java | 4 +- .../gemhunters/worldevent/WorldEventType.java | 5 +- .../worldevent/ufo/UFOWorldEvent.java | 204 ++++++++++++++++++ 12 files changed, 265 insertions(+), 147 deletions(-) create mode 100644 Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/Leaderboards.java create mode 100644 Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/ufo/UFOWorldEvent.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index a1ebeb4f8..f0273f3e1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -216,7 +216,7 @@ public enum AchievementCategory Material.DIAMOND_BOOTS, 0, GameCategory.SURVIVAL, null, false, GameDisplay.Skyfall.getGameId(), GameDisplay.SkyfallTeams.getGameId()), GEM_HUNTERS("Gem Hunters", null, - new StatDisplay[] {StatDisplay.KILLS, StatDisplay.GEMS_EARNED, StatDisplay.fromGame("Quests Complete", GameDisplay.GemHunters, "QuestsCompleted"), StatDisplay.fromGame("Chests Opened", GameDisplay.GemHunters, "ChestsOpened")}, + new StatDisplay[] {StatDisplay.KILLS, StatDisplay.GEMS_EARNED, StatDisplay.fromGame("Quests Completed", GameDisplay.GemHunters, "QuestsCompleted"), StatDisplay.fromGame("Chests Opened", GameDisplay.GemHunters, "ChestsOpened")}, Material.EMERALD, 0, GameCategory.SURVIVAL, null, false, GameDisplay.GemHunters.getGameId()); private String _name; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemHuntersTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemHuntersTrack.java index 21fffdd87..27d7bbcd1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemHuntersTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemHuntersTrack.java @@ -10,7 +10,7 @@ public class GemHuntersTrack extends Track public GemHuntersTrack() { - super("gem-hunters-gems", "Gem Hunter Millionaire", "This track is unlocked by earning gems in Gem Hunters"); + super("gem-hunters-gems", "GH Millionaire", "This track is unlocked by earning gems in Gem Hunters"); getRequirements() .addTier(new TrackTier( diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/TeamKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/TeamKing.java index e8fd92f4e..5399b38ae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/TeamKing.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/TeamKing.java @@ -1,4 +1,3 @@ -<<<<<<< HEAD package nautilus.game.arcade.game.games.castleassault.data; import org.bukkit.Location; @@ -126,128 +125,4 @@ public class TeamKing return true; } -} -======= -package nautilus.game.arcade.game.games.castleassault.data; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Zombie; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilTime; -import mineplex.core.itemstack.ItemBuilder; -import nautilus.game.arcade.game.GameTeam; - -public class TeamKing -{ - private static final int MAX_HEALTH = 600; - private Location _loc; - private String _name; - private GameTeam _owner; - private Zombie _entity; - private int _health; - private String _lastDamager; - private long _lastDamage; - - public TeamKing(GameTeam owner, String name, Location loc) - { - _owner = owner; - _loc = loc; - _name = name; - _health = MAX_HEALTH; - _entity = (Zombie) loc.getWorld().spawnEntity(loc, EntityType.ZOMBIE); - UtilEnt.vegetate(_entity, true); - _entity.getEquipment().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setUnbreakable(true).build()); - _entity.getEquipment().setChestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).setUnbreakable(true).build()); - _entity.getEquipment().setLeggings(new ItemBuilder(Material.DIAMOND_LEGGINGS).setUnbreakable(true).build()); - _entity.getEquipment().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setUnbreakable(true).build()); - _entity.setRemoveWhenFarAway(false); - _entity.setCustomName(owner.GetColor() + name); - } - - public GameTeam getOwner() - { - return _owner; - } - - public Location getLocation() - { - return _loc; - } - - public String getName(boolean bold) - { - return _owner.GetColor() + (bold ? C.Bold : "") + _name; - } - - public String getLastDamager() - { - return _lastDamager; - } - - public int getHealth() - { - return Math.max(_health, 0); - } - - public boolean isDead() - { - return getHealth() <= 0; - } - - public void update(boolean beaconsAlive) - { - _entity.teleport(_loc); - for (int y = 0; y <= 4; y++) - { - for (int x = -4; x <= 4; x++) - { - for (int z = -4; z <= 4; z++) - { - Block block = _loc.clone().add(x, y, z).getBlock(); - if ((block.getType() != Material.IRON_FENCE && block.getType() != Material.IRON_BLOCK) || !beaconsAlive) - { - block.setType(Material.AIR); - } - if (beaconsAlive) - { - if (x == -4 || x == 4 || z == -4 || z == 4) - { - if (y != 4) - { - block.setType(Material.IRON_FENCE); - } - } - if (y == 4) - { - block.setType(Material.IRON_BLOCK); - } - } - } - } - } - } - - public boolean handleDamage(String player, double damage) - { - if (!UtilTime.elapsed(_lastDamage, 400)) - { - return false; - } - _lastDamager = player; - _lastDamage = System.currentTimeMillis(); - - int dmg = (int)Math.ceil(damage); - - _health -= dmg; - - UtilEnt.PlayDamageSound(_entity); - - return true; - } -} ->>>>>>> refs/remotes/origin/update/gem-hunters-11-5 +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index ce821a7a5..9b8256d80 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -1,15 +1,5 @@ package mineplex.gemhunters; -import mineplex.core.titles.Titles; -import mineplex.core.titles.tracks.TrackManager; -import net.minecraft.server.v1_8_R3.MinecraftServer; - -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.plugin.java.JavaPlugin; -import org.spigotmc.SpigotConfig; - import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; import mineplex.core.TimingsFix; @@ -67,6 +57,7 @@ import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.texttutorial.TextTutorialManager; import mineplex.core.thank.ThankManager; +import mineplex.core.titles.Titles; import mineplex.core.twofactor.TwoFactorAuth; import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; @@ -94,6 +85,7 @@ import mineplex.gemhunters.spawn.SpawnModule; import mineplex.gemhunters.supplydrop.SupplyDropModule; import mineplex.gemhunters.tutorial.GemHuntersTutorial; import mineplex.gemhunters.world.DebugListeners; +import mineplex.gemhunters.world.Leaderboards; import mineplex.gemhunters.world.TimeCycle; import mineplex.gemhunters.world.UndergroundMobs; import mineplex.gemhunters.world.WorldListeners; @@ -101,6 +93,12 @@ import mineplex.gemhunters.worldevent.WorldEventModule; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.plugin.java.JavaPlugin; +import org.spigotmc.SpigotConfig; import static mineplex.core.Managers.require; @@ -274,7 +272,7 @@ public class GemHunters extends JavaPlugin tutorialManager.addTutorial(new GemHuntersTutorial()); require(Titles.class).forceDisable(); - + // Now we finally get to enable the Gem Hunters modules // Though if any other module needs one of these it will be generated in // order, however they are all here just for good measure. @@ -306,7 +304,8 @@ public class GemHunters extends JavaPlugin new WorldListeners(this); new TimeCycle(this); new UndergroundMobs(this); - new DebugListeners(this); + new DebugListeners(this); + new Leaderboards(); // UpdateEvent!!! new Updater(this); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/DeathModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/DeathModule.java index 2d75e67d9..367f5f5e8 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/DeathModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/DeathModule.java @@ -84,7 +84,7 @@ public class DeathModule extends MiniPlugin if (killer != null) { - _stats.incrementStat(player, "Gem Hunters.Kills", 1); + _stats.incrementStat(killer, "Gem Hunters.Kills", 1); } startAnimation(player); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java index a28cbb327..54d2321af 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java @@ -160,7 +160,11 @@ public class CashOutModule extends MiniPlugin _aboutToCashOut.add(player.getUniqueId()); - _stats.incrementStat(player, "Gem Hunters.GemsEarned", completeEvent.getGems()); + if (completeEvent.getGems() != EconomyModule.GEM_START_COST) + { + _stats.incrementStat(player, "Gem Hunters.GemsEarned", completeEvent.getGems()); + } + _donation.rewardCurrencyUntilSuccess(GlobalCurrency.GEM, player, "Earned", completeEvent.getGems()); session.endSession(); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java index de1c5b612..305b1f9c8 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java @@ -315,7 +315,7 @@ public class QuestModule extends MiniClientPlugin player.sendMessage(F.main(_moduleName, "Completed " + F.name(quest.getName()) + ".")); - _stats.incrementStat(player, "Gem Hunters.Quests Completed", 1); + _stats.incrementStat(player, "Gem Hunters.QuestsCompleted", 1); QuestPlayerData playerData = Get(player); playerData.getActiveQuests().remove(Integer.valueOf(quest.getId())); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/safezone/SafezoneModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/safezone/SafezoneModule.java index 9490d1231..22dc510c5 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/safezone/SafezoneModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/safezone/SafezoneModule.java @@ -217,7 +217,7 @@ public class SafezoneModule extends MiniPlugin @EventHandler public void flintAndSteelInteract(PlayerInteractEvent event) { - if (event.getItem() == null || event.getItem().getType() != Material.FLINT_AND_STEEL) + if (event.getItem() == null || event.getItem().getType() != Material.FLINT_AND_STEEL || event.getClickedBlock() == null || !isInSafeZone(event.getClickedBlock().getLocation())) { return; } diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/Leaderboards.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/Leaderboards.java new file mode 100644 index 000000000..5ef1793f0 --- /dev/null +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/Leaderboards.java @@ -0,0 +1,33 @@ +package mineplex.gemhunters.world; + +import mineplex.core.Managers; +import mineplex.core.common.Pair; +import mineplex.core.common.util.UtilServer; +import mineplex.core.leaderboard.Leaderboard; +import mineplex.core.leaderboard.LeaderboardManager; +import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; + +public class Leaderboards +{ + + private final LeaderboardManager _manager; + private final WorldDataModule _worldData; + + public Leaderboards() + { + _manager = Managers.require(LeaderboardManager.class); + _worldData = Managers.require(WorldDataModule.class); + + // Make sure the world is loaded + UtilServer.runSyncLater(this::createLeaderboards, 20); + } + + private void createLeaderboards() + { + _manager.registerLeaderboard("TOP_GEM_HUNTERS_KILLS", new Leaderboard("Top Kills", Pair.create("Kill", "Kills"), new String[] {"Gem Hunters.Kills"}, LeaderboardSQLType.ALL, _worldData.getCustomLocation("TOP_KILLS").get(0), 10)); + _manager.registerLeaderboard("TOP_GEM_HUNTERS_DAILY_KILLS", new Leaderboard("Top Daily Kills", Pair.create("Kill", "Kills"), new String[] {"Gem Hunters.Kills"}, LeaderboardSQLType.DAILY, _worldData.getCustomLocation("TOP_DAILY_KILLS").get(0), 10)); + _manager.registerLeaderboard("TOP_GEM_HUNTERS_GEMS", new Leaderboard("Top Gems Cashed Out", Pair.create("Gem", "Gems"), new String[] {"Gem Hunters.GemsEarned"}, LeaderboardSQLType.ALL, _worldData.getCustomLocation("TOP_GEMS").get(0), 10)); + _manager.registerLeaderboard("TOP_GEM_HUNTERS_DAILY_GEMS", new Leaderboard("Top Daily Gems Cashed Out", Pair.create("Gem", "Gems"), new String[] {"Gem Hunters.GemsEarned"}, LeaderboardSQLType.DAILY, _worldData.getCustomLocation("TOP_DAILY_GEMS").get(0), 10)); + } +} + diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java index 2e16bbab7..cc81c84cc 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import mineplex.gemhunters.worldevent.ufo.UFOWorldEvent; import org.bukkit.event.EventHandler; import mineplex.core.MiniPlugin; @@ -45,7 +46,8 @@ public class WorldEventModule extends MiniPlugin new BlizzardWorldEvent(), //new NetherPortalWorldEvent(), new WitherWorldEvent(), - new GwenMartWorldEvent() + new GwenMartWorldEvent(), + new UFOWorldEvent() ); } diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventType.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventType.java index 670084763..32dbd527c 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventType.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventType.java @@ -8,14 +8,15 @@ public enum WorldEventType NETHER("Dark Portal", WorldEventPriority.TRIGGERED), WITHER("Wither Temple", WorldEventPriority.TRIGGERED), GWEN_MART("Gwen-Mart Mega Sale", WorldEventPriority.GLOBAL), - + UFO("UFO", WorldEventPriority.GLOBAL), + ; private String _name; private WorldEventPriority _priority; private long _last; - private WorldEventType(String name, WorldEventPriority priority) + WorldEventType(String name, WorldEventPriority priority) { _name = name; _priority = priority; diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/ufo/UFOWorldEvent.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/ufo/UFOWorldEvent.java new file mode 100644 index 000000000..871edf360 --- /dev/null +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/ufo/UFOWorldEvent.java @@ -0,0 +1,204 @@ +package mineplex.gemhunters.worldevent.ufo; + +import mineplex.core.Managers; +import mineplex.core.common.block.schematic.Schematic; +import mineplex.core.common.block.schematic.SchematicData; +import mineplex.core.common.block.schematic.UtilSchematic; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilTime; +import mineplex.core.utils.UtilVariant; +import mineplex.gemhunters.economy.EconomyModule; +import mineplex.gemhunters.loot.LootModule; +import mineplex.gemhunters.loot.rewards.LootChestReward; +import mineplex.gemhunters.worldevent.WorldEvent; +import mineplex.gemhunters.worldevent.WorldEventState; +import mineplex.gemhunters.worldevent.WorldEventType; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.BlockVector; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +public class UFOWorldEvent extends WorldEvent +{ + + private static final String SCHEMATIC_PATH = ".." + File.separator + ".." + File.separator + "update" + File.separator + "files" + File.separator + "UFO.schematic"; + private static final long MAX_TIME = TimeUnit.MINUTES.toMillis(10); + private static final ItemStack HELMET = new ItemStack(Material.GLASS); + private static final ItemStack SWORD = new ItemStack(Material.STONE_SWORD); + private static final ItemStack SWORD_LEADER = new ItemStack(Material.IRON_SWORD); + private static final long CASH_OUT_DELAY = TimeUnit.MINUTES.toMillis(10); + + private final EconomyModule _economy; + private final LootModule _loot; + + private Skeleton _leader; + private Set _skeletons; + private Set _ufoBlocks; + + public UFOWorldEvent() + { + super(WorldEventType.UFO); + + _economy = Managers.require(EconomyModule.class); + _loot = Managers.require(LootModule.class); + + _skeletons = new HashSet<>(); + _ufoBlocks = new HashSet<>(); + } + + @Override + public void onStart() + { + Location location = UtilAlg.Random(_worldData.getCustomLocation("NETHER_PORTAL")).clone().subtract(5, -10, 5); + Schematic schematic; + + try + { + schematic = UtilSchematic.loadSchematic(new File(SCHEMATIC_PATH)); + } + catch (IOException e) + { + e.printStackTrace(); + return; + } + + SchematicData data = schematic.paste(location, false, false, false); + + for (BlockVector vector : data.getBlocks()) + { + Location block = location.add(vector); + + _ufoBlocks.add(block.getBlock()); + + location.subtract(vector); + } + + _leader = UtilVariant.spawnWitherSkeleton(location); + _leader.setMaxHealth(200); + _leader.setHealth(_leader.getMaxHealth()); + _leader.getEquipment().setItemInHand(SWORD_LEADER); + _leader.setCustomName(C.cDGreenB + "Alien Leader"); + prepareSkeleton(_leader); + + for (int i = 0; i < 10; i++) + { + Skeleton skeleton = _leader.getWorld().spawn(location, Skeleton.class); + skeleton.getEquipment().setItemInHand(SWORD); + skeleton.setCustomName(C.cGreenB + "Alien"); + prepareSkeleton(skeleton); + _skeletons.add(skeleton); + } + + setEventState(WorldEventState.LIVE); + } + + private void prepareSkeleton(Skeleton skeleton) + { + skeleton.getEquipment().setHelmet(HELMET); + skeleton.setRemoveWhenFarAway(false); + skeleton.setCustomNameVisible(true); + } + + @EventHandler + public void entityDeath(EntityDeathEvent event) + { + LivingEntity entity = event.getEntity(); + + if (_skeletons.remove(entity)) + { + event.getDrops().clear(); + event.setDroppedExp(0); + + Player killer = entity.getKiller(); + + if (killer != null) + { + _economy.addToStore(killer, "Killing an Alien", 10); + } + } + + if (_leader != null && _leader.equals(entity)) + { + Player killer = _leader.getKiller(); + + if (killer != null) + { + ItemStack itemStack = SkinData.OMEGA_CHEST.getSkull(C.cAqua + "Omega Chest", new ArrayList<>()); + LootChestReward reward = new LootChestReward(CASH_OUT_DELAY, itemStack, "Omega", 1); + _leader.getWorld().dropItemNaturally(_leader.getEyeLocation(), itemStack); + _loot.addItemReward(reward); + _economy.addToStore(killer, "Killing The Alien Leader", 1000); + } + } + } + + @EventHandler + public void entityDamage(EntityCombustEvent event) + { + Entity entity = event.getEntity(); + + if (entity.equals(_leader) || _skeletons.contains(entity)) + { + event.setCancelled(true); + } + } + + @Override + public boolean checkToEnd() + { + return _leader.isDead() || UtilTime.elapsed(_start, MAX_TIME); + } + + @Override + public void onEnd() + { + _leader.remove(); + + for (Skeleton skeleton : _skeletons) + { + skeleton.remove(); + } + + _skeletons.clear(); + + for (Block block : _ufoBlocks) + { + block.setType(Material.AIR); + } + + _ufoBlocks.clear(); + } + + @Override + public Location[] getEventLocations() + { + return new Location[]{_leader.getLocation()}; + } + + @Override + public double getProgress() + { + return _leader.getHealth() / _leader.getMaxHealth(); + } +} From a800fee08ce341b35bd9dfa63d76cc28406efb7b Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 6 Jun 2017 22:59:40 +0100 Subject: [PATCH 140/283] Testing session changes --- .../games/moba/boss/pumpkin/PumpkinBoss.java | 10 ++--- .../game/games/moba/kit/biff/HeroBiff.java | 3 +- .../games/moba/kit/biff/SkillBiffDash.java | 13 +++--- .../game/games/moba/kit/biff/SkillLeash.java | 40 +++++++++++-------- .../games/moba/kit/biff/SkillWarHorse.java | 16 +++++++- .../moba/kit/hattori/SkillNinjaBlade.java | 2 +- .../game/games/moba/minion/MinionManager.java | 30 +++++++++----- .../game/games/moba/minion/MinionWave.java | 13 +++--- .../moba/structure/point/CapturePoint.java | 2 +- 9 files changed, 79 insertions(+), 50 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 0f69e2bdd..ce850e828 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -66,11 +66,11 @@ public class PumpkinBoss extends MobaBoss private static final int CONDITION_LENGTH = 60; private static final double CONDITION_DAMAGE_FACTOR = 1.5; private static final int DAMAGE_RADIUS = 2; - private static final int DAMAGE_RANGE = 3; - private static final int DAMAGE_DIRECT = 8; + private static final int DAMAGE_RANGE = 2; + private static final int DAMAGE_DIRECT = 6; private static final int DAMAGE_DIRECT_RADIUS_SQUARED = 9; - private static final int HEALTH = 200; - private static final int HEALTH_OUT_OF_COMBAT = 5; + private static final int HEALTH = 100; + private static final int HEALTH_OUT_OF_COMBAT = 2; private static final Material[] BLOCKS = { Material.OBSIDIAN, Material.NETHERRACK, @@ -128,7 +128,7 @@ public class PumpkinBoss extends MobaBoss player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 0.4F); } - for (Entry entry : UtilBlock.getInRadius(skeleton.getLocation(), 20).entrySet()) + for (Entry entry : UtilBlock.getInRadius(skeleton.getLocation(), 12).entrySet()) { Block block = entry.getKey(); double setChance = entry.getValue(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java index 7be9bc451..fe65df976 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java @@ -18,7 +18,8 @@ public class HeroBiff extends HeroKit private static final Perk[] PERKS = { new SkillSword(0), new SkillLeash(1), - new SkillBiffDash(2) + new SkillBiffDash(2), + new SkillWarHorse(3) }; private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java index a18f97d51..907d5f7fd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.kit.biff; import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle; @@ -11,10 +12,9 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Effect; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -88,7 +88,7 @@ public class SkillBiffDash extends HeroSkill UtilAction.velocity(player, direction); player.getWorld().playSound(player.getLocation(), Sound.IRONGOLEM_THROW, 1, 1F); - UtilParticle.PlayParticleToAll(ParticleType.CLOUD, player.getLocation().add(0, 0.4, 0), 0.25F, 0.25F, 0.25F, 0.1F, 10, ViewDist.LONG); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, player.getLocation().add(0, 0.6, 0), 0.5F, 0.5F, 0.5F, 0.1F, 15, ViewDist.LONG); _active.put(player, System.currentTimeMillis()); } @@ -126,8 +126,11 @@ public class SkillBiffDash extends HeroSkill continue; } - Block block = entity.getLocation().getBlock().getRelative(BlockFace.DOWN); - entity.getWorld().playEffect(block.getLocation().add(0.5, 0.5, 0.5), Effect.STEP_SOUND, block.getType(), block.getData()); + for (int i = 0; i < 5; i++) + { + Location location = UtilAlg.getRandomLocation(entity.getEyeLocation(), 3); + entity.getWorld().playEffect(location, Effect.STEP_SOUND, Material.GRASS, 0); + } Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 4, false, true, false, UtilEnt.getName(player), GetName()); UtilAction.velocity(entity, new Vector(0, 0.6 + Math.random() / 2, 0)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java index 32d7f07c6..7db008510 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -41,39 +41,45 @@ public class SkillLeash extends HeroSkill @EventHandler public void interact(PlayerInteractEvent event) { - if (!isSkillItem(event)) + Player player = event.getPlayer(); + + if (!isSkillItem(event) || _leashed.containsKey(player)) { return; } - Player player = event.getPlayer(); - - List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 3); - + List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 5); nearbyPlayers.removeIf(other -> isTeamDamage(other, player)); - if (!nearbyPlayers.isEmpty()) + if (nearbyPlayers.isEmpty()) { - _leashed.put(player, nearbyPlayers); - - useActiveSkill(() -> - { - for (Player leashed : _leashed.remove(player)) - { - removeEffect(leashed); - } - - }, player, 5000); + return; } + _leashed.put(player, nearbyPlayers); + + StringBuilder builder = new StringBuilder(F.main("Game", "You leashed ")); + for (Player nearby : nearbyPlayers) { nearby.setLeashHolder(player); nearby.setPullWhileLeashed(false); nearby.setShouldBreakLeash(false); - nearby.sendMessage(F.main("Game", F.name(player.getName()) + " leashed you.")); + nearby.sendMessage(F.main("Game", F.name(nearby.getName()) + " leashed you.")); + builder.append(F.name(player.getName())).append(", "); Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 0, false, true, true, false); } + + player.sendMessage(builder.toString()); + + useActiveSkill(() -> + { + for (Player leashed : _leashed.remove(player)) + { + removeEffect(leashed); + } + + }, player, 5000); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index f1089f02f..7aabbcea9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -6,12 +6,15 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Horse; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; import java.util.HashSet; import java.util.Iterator; @@ -33,7 +36,9 @@ public class SkillWarHorse extends HeroSkill public SkillWarHorse(int slot) { super("Cavalry Charge", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + setCooldown(45000); + setDropItemActivate(true); } @EventHandler @@ -60,9 +65,12 @@ public class SkillWarHorse extends HeroSkill UtilEnt.vegetate(horse); horse.setJumpStrength(0); + horse.setMaxDomestication(1); horse.setDomestication(horse.getMaxDomestication()); horse.getInventory().setArmor(HORSE_ARMOUR); + horse.setOwner(player); horse.setPassenger(player); + horse.setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(Manager.getPlugin(), Manager.GetGame().GetTeam(player).GetName())); Manager.GetGame().CreatureAllowOverride = false; @@ -88,7 +96,13 @@ public class SkillWarHorse extends HeroSkill data.Horse.remove(); iterator.remove(); } - //else if () + else + { + Player player = data.Owner; + Location target = player.getLocation().getDirection().multiply(3).toLocation(player.getWorld()); + + UtilEnt.CreatureMoveFast(data.Horse, target, 3F); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index d4d240265..9a9ebe0a8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -32,7 +32,7 @@ public class SkillNinjaBlade extends HeroSkill }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); private static final ItemStack ACTIVE_ITEM = new ItemBuilder(Material.DIAMOND_SWORD) - .setTitle(C.cGreenB + "NINJA BLADE") + .setTitle(C.cGreenB + "ENDER BLADE") .setUnbreakable(true) .build(); private static final int ACTIVE_SLOT = 0; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 6c6104a45..1d90780a7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -17,6 +17,9 @@ import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Sign; import org.bukkit.entity.PigZombie; import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; @@ -162,21 +165,26 @@ public class MinionManager implements Listener ArrayList path = new ArrayList<>(_host.WorldData.GetDataLocs(MobaConstants.MINION_PATH)); ArrayList organisedPath = new ArrayList<>(path.size()); - while (organisedPath.size() != path.size()) + while (!path.isEmpty()) { - Location closest = UtilAlg.findClosest(start, path); + Location dataPoint = UtilAlg.findClosest(start, path); - if (closest == null) - { - // Rra rro Shaggy - continue; - } - - organisedPath.add(closest); - start = closest; + organisedPath.add(dataPoint); + path.remove(dataPoint); + start = dataPoint; } // Step 3 - Put the ordered path inside the map - _path = path; + _path = organisedPath; + +// int i = 0; +// for (Location location : _path) +// { +// Block block = location.getBlock(); +// block.setType(Material.SIGN_POST); +// Sign sign = (Sign) block.getState(); +// sign.setLine(0, "P" + i++); +// sign.update(); +// } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 032221220..a00dcfa24 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -235,19 +235,16 @@ public class MinionWave implements Listener { for (MobaBoss boss : _host.getBossManager().getBosses()) { - if (boss.isDead()) + if (boss.isDead() || !(boss instanceof WitherBoss)) { continue; } - if (boss instanceof WitherBoss) - { - WitherBoss witherBoss = (WitherBoss) boss; + WitherBoss witherBoss = (WitherBoss) boss; - if (witherBoss.getTeam().equals(_owner)) - { - continue; - } + if (witherBoss.getTeam().equals(_owner)) + { + continue; } Location location = boss.getEntity().getLocation(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index e68722aa2..25bb5599c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -154,7 +154,7 @@ public class CapturePoint player.playSound(player.getLocation(), Sound.GHAST_SCREAM2, 1, 1.0F); } - _host.Announce(F.main("Game", "Team " + highest.GetFormattedName() + C.mBody + " is capturing the " + _colour + _name + C.mBody + "Beacon!"), false); + _host.Announce(F.main("Game", "Team " + highest.GetFormattedName() + C.mBody + " is capturing the " + _colour + _name + C.mBody + " Beacon!"), false); //UtilTextMiddle.display("", "Team " + highest.GetFormattedName() + C.cWhite + " is capturing beacon " + _colour + _name, 0, 30, 10); } From 697d4a11ed92984139a29a41fbb8a0d938cc2d5e Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 6 Jun 2017 23:00:17 +0100 Subject: [PATCH 141/283] Fix the Quest achievement looking for the wrong stat --- .../src/mineplex/core/achievement/Achievement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index f9820de1b..90872f27c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -1216,7 +1216,7 @@ public enum Achievement AchievementCategory.GEM_HUNTERS), GEM_HUNTERS_QUESTS("Quest Complete", 5000, - new String[]{"Gem Hunters.QuestsOpened"}, + new String[]{"Gem Hunters.QuestsCompleted"}, new String[]{"+1 for each quest completed"}, new int[]{10,25,50,100,1000}, AchievementCategory.GEM_HUNTERS), From 83f6b4fa1d7b1078938b8f23e68548e8f5a81773 Mon Sep 17 00:00:00 2001 From: Kenny Goodin Date: Tue, 6 Jun 2017 22:27:41 -0400 Subject: [PATCH 142/283] Fill in actual quest rarity weights --- .../src/mineplex/quest/common/QuestRarity.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Plugins/mineplex-questmanager/src/mineplex/quest/common/QuestRarity.java b/Plugins/mineplex-questmanager/src/mineplex/quest/common/QuestRarity.java index b5d85b0e9..4ef625ee0 100644 --- a/Plugins/mineplex-questmanager/src/mineplex/quest/common/QuestRarity.java +++ b/Plugins/mineplex-questmanager/src/mineplex/quest/common/QuestRarity.java @@ -5,9 +5,8 @@ package mineplex.quest.common; */ public enum QuestRarity { - // TODO fill in actual weights - COMMON(0.5), - RARE(0.3), + COMMON(1.0), + RARE(0.5), LEGENDARY(0.1) ; From 7cc7769378087138b571728158889f91063bfe9d Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 7 Jun 2017 18:26:56 -0500 Subject: [PATCH 143/283] Send gem hunters players to normal hub upon cashout --- .../src/mineplex/gemhunters/economy/CashOutModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java index c4d3b75d8..fc5ceff19 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java @@ -158,7 +158,7 @@ public class CashOutModule extends MiniPlugin } else { - Portal.getInstance().sendPlayerToGenericServer(player, GenericServer.BETA_HUB, Intent.FORCE_TRANSFER); + Portal.getInstance().sendPlayerToGenericServer(player, GenericServer.HUB, Intent.FORCE_TRANSFER); runSyncLater(() -> { From 044927252c54ad457e12105ca09b1e4daba87289 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jun 2017 01:55:07 +0100 Subject: [PATCH 144/283] More changes! --- .../mineplex/core/itemstack/ItemBuilder.java | 68 ++++++--- .../game/arcade/game/games/moba/Moba.java | 15 +- .../game/arcade/game/games/moba/MobaRole.java | 41 +----- .../arcade/game/games/moba/buff/Buff.java | 20 +++ .../game/games/moba/buff/BuffManager.java | 16 +++ .../moba/buff/buffs/BuffPumpkinKing.java | 20 +++ .../games/moba/general/EnderPearlManager.java | 100 +++++++++++++ .../arcade/game/games/moba/kit/HeroKit.java | 44 ++++-- .../arcade/game/games/moba/kit/HeroSkill.java | 21 ++- .../games/moba/kit/anath/SkillMeteor.java | 15 +- .../games/moba/kit/biff/SkillBiffDash.java | 7 +- .../game/games/moba/kit/biff/SkillLeash.java | 25 ++-- .../games/moba/kit/biff/SkillWarHorse.java | 7 +- .../moba/kit/bob/SkillBuildPainting.java | 1 + .../games/moba/kit/common/LeashedEntity.java | 76 ++++++++++ .../game/games/moba/kit/dana/SkillRally.java | 1 + .../games/moba/kit/devon/SkillInfinity.java | 2 +- .../games/moba/kit/devon/SkillTNTArrows.java | 2 +- .../moba/kit/hattori/SkillNinjaBlade.java | 16 ++- .../game/games/moba/minion/MinionWave.java | 5 +- .../moba/prepare/PrepareInformation.java | 109 --------------- .../games/moba/prepare/PrepareManager.java | 35 +++-- .../games/moba/prepare/PrepareSelection.java | 10 +- .../arcade/game/games/moba/shop/MobaItem.java | 2 + .../arcade/game/games/moba/shop/MobaShop.java | 132 ++++++++++++++++-- .../games/moba/shop/MobaShopCategory.java | 59 +++++++- .../games/moba/shop/MobaShopCategoryMenu.java | 10 +- .../game/games/moba/shop/MobaShopMenu.java | 30 ++++ .../moba/shop/assassin/MobaAssassinShop.java | 1 + .../moba/shop/hunter/MobaHunterShop.java | 1 + .../games/moba/shop/mage/MobaMageShop.java | 62 ++++---- .../moba/shop/warrior/MobaWarriorShop.java | 113 +++++++-------- .../moba/structure/tower/TowerManager.java | 88 +++++++----- .../arcade/game/games/moba/util/MobaUtil.java | 7 + .../mineplex/gemhunters/loot/LootModule.java | 1 + 35 files changed, 811 insertions(+), 351 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/EnderPearlManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java index 603f5e150..8a07b03fa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java @@ -1,13 +1,7 @@ package mineplex.core.itemstack; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -21,10 +15,18 @@ import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.FireworkEffectMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.potion.PotionEffect; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilInv; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; public class ItemBuilder { @@ -53,14 +55,15 @@ public class ItemBuilder private Color _color; private short _data; private short _durability; - private final HashMap _enchants = new HashMap(); - private final List _lore = new ArrayList(); + private final Map _enchants = new HashMap<>(); + private final List _lore = new ArrayList<>(); private Material _mat; private String _title = null; private boolean _unbreakable; private boolean _glow; private String _playerHeadName = null; - private HashSet _itemFlags = new HashSet(); + private Set _itemFlags = new HashSet<>(); + private List _potionEffects = new ArrayList<>(); public ItemBuilder(ItemStack item) { @@ -86,6 +89,13 @@ public class ItemBuilder { setColor(((LeatherArmorMeta) meta).getColor()); } + else if (meta instanceof PotionMeta) + { + for (PotionEffect effect : ((PotionMeta) meta).getCustomEffects()) + { + addPotionEffect(effect); + } + } _itemFlags.addAll(meta.getItemFlags()); @@ -124,7 +134,7 @@ public class ItemBuilder return this; } - public HashSet getItemFlags() + public Set getItemFlags() { return _itemFlags; } @@ -279,6 +289,22 @@ public class ItemBuilder { ((BannerMeta) meta).setBaseColor(DyeColor.getByColor(_color)); } + else if (meta instanceof PotionMeta) + { + PotionMeta potionMeta = (PotionMeta) meta; + + for (PotionEffect effect : _potionEffects) + { + potionMeta.addCustomEffect(effect, true); + } + + if (!_potionEffects.isEmpty()) + { + potionMeta.setMainEffect(_potionEffects.get(0).getType()); + } + + meta = potionMeta; + } meta.addItemFlags(getItemFlags().toArray(new ItemFlag[0])); meta.spigot().setUnbreakable(isUnbreakable()); @@ -307,7 +333,7 @@ public class ItemBuilder } newBuilder.setColor(_color); - // newBuilder.potion = potion; + newBuilder.setDurability(_durability); newBuilder.setData(_data); @@ -321,11 +347,16 @@ public class ItemBuilder newBuilder.setItemFlags(_itemFlags); newBuilder.setPlayerHead(_playerHeadName); + + for (PotionEffect potionEffect : _potionEffects) + { + newBuilder.addPotionEffect(potionEffect); + } return newBuilder; } - public HashMap getAllEnchantments() + public Map getAllEnchantments() { return _enchants; } @@ -452,4 +483,9 @@ public class ItemBuilder return this; } + public ItemBuilder addPotionEffect(PotionEffect effect) + { + _potionEffects.add(effect); + return this; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index b0a0fb4f1..393901b58 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -17,6 +17,7 @@ import nautilus.game.arcade.game.games.moba.boss.BossManager; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.general.ArrowKBManager; +import nautilus.game.arcade.game.games.moba.general.EnderPearlManager; import nautilus.game.arcade.game.games.moba.general.MobaDamageManager; import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.HeroKit; @@ -36,6 +37,7 @@ import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; @@ -134,6 +136,9 @@ public class Moba extends TeamGame // Arrow Knockback _arrowKb = registerManager(new ArrowKBManager(this)); + // Ender Pearls + registerManager(new EnderPearlManager()); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -186,18 +191,18 @@ public class Moba extends TeamGame if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam)) { - suffix = "Unknown"; + suffix = C.cYellow + " Unknown"; } else if (mobaPlayer.getKit() == null) { - suffix = "Selecting"; + suffix = C.cYellow + " Selecting"; } else { - suffix = mobaPlayer.getKit().GetName(); + suffix = mobaPlayer.getRole().getChatColor() + " " + mobaPlayer.getKit().GetName(); } - return C.cYellow + " " + suffix + C.Reset; + return suffix + C.Reset; }) .setUnderNameObjective(C.cRed + "❤") .setUnderName((perspective, subject) -> @@ -367,7 +372,7 @@ public class Moba extends TeamGame for (Player player : GetPlayers(true)) { _playerData.add(new MobaPlayer(player)); - player.setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(Manager.getPlugin(), GetTeam(player).GetName())); + MobaUtil.setTeamEntity(player, GetTeam(player)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index 70baf4c97..014d12a4d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,50 +1,24 @@ package nautilus.game.arcade.game.games.moba; -import mineplex.core.common.util.C; import org.bukkit.ChatColor; import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", new String[] - { - - "You are playing", - "the " + C.cAqua + "Assassin" + C.cWhite + " role this game", - - }, Color.BLUE, ChatColor.AQUA), - HUNTER("Hunter", new String[] - { - "You are playing", - "the " + C.cGreen + "Hunter" + C.cWhite + " role this game", - - }, Color.LIME, ChatColor.GREEN), - MAGE("Mage", new String[] - { - - "You are playing", - "the " + C.cRed + "Mage" + C.cWhite + " role this game", - - }, Color.RED, ChatColor.RED), - WARRIOR("Warrior", new String[] - { - - "You are playing", - "the " + C.cGold + "Warrior" + C.cWhite + " role this game", - - }, Color.YELLOW, ChatColor.GOLD), + ASSASSIN("Assassin", Color.GRAY, ChatColor.DARK_GRAY), + HUNTER("Hunter", Color.LIME, ChatColor.GREEN), + MAGE("Mage", Color.PURPLE, ChatColor.DARK_PURPLE), + WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD), ; private final String _name; - private final String[] _description; private final Color _color; private final ChatColor _chatColor; - MobaRole(String name, String[] description, Color color, ChatColor chatColor) + MobaRole(String name, Color color, ChatColor chatColor) { _name = name; - _description = description; _color = color; _chatColor = chatColor; } @@ -54,11 +28,6 @@ public enum MobaRole return _name; } - public String[] getDescription() - { - return _description; - } - public Color getColor() { return _color; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java new file mode 100644 index 000000000..e986996c0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java @@ -0,0 +1,20 @@ +package nautilus.game.arcade.game.games.moba.buff; + +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +public abstract class Buff +{ + + private final LivingEntity _entity; + + public Buff(LivingEntity entity) + { + _entity = entity; + } + + public abstract void onApply(Player player); + + public abstract void onUpdate(UpdateEvent event); +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java new file mode 100644 index 000000000..23e59140c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java @@ -0,0 +1,16 @@ +package nautilus.game.arcade.game.games.moba.buff; + +import mineplex.minecraft.game.core.condition.Condition; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.event.Listener; + +public class BuffManager implements Listener +{ + + private final Moba _host; + + public BuffManager(Moba host) + { + _host = host; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java new file mode 100644 index 000000000..d72217b09 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java @@ -0,0 +1,20 @@ +package nautilus.game.arcade.game.games.moba.buff.buffs; + +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.buff.Buff; +import org.bukkit.entity.LivingEntity; + +public class BuffPumpkinKing extends Buff +{ + + public BuffPumpkinKing(LivingEntity entity) + { + super(entity); + } + + @Override + public void onUpdate(UpdateEvent event) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/EnderPearlManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/EnderPearlManager.java new file mode 100644 index 000000000..4daeedeed --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/EnderPearlManager.java @@ -0,0 +1,100 @@ +package nautilus.game.arcade.game.games.moba.general; + +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.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; +import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.projectiles.ProjectileSource; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class EnderPearlManager implements Listener +{ + + private static final int MAX_TICKS = 2 * 20; + private final Map _pearls; + + public EnderPearlManager() + { + _pearls = new HashMap<>(); + } + + @EventHandler + public void projectileLaunch(ProjectileLaunchEvent event) + { + Projectile entity = event.getEntity(); + + if (!(entity instanceof EnderPearl) || !(entity.getShooter() instanceof Player)) + { + return; + } + + Player shooter = (Player) event.getEntity().getShooter(); + + _pearls.put(shooter, event.getEntity()); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator iterator = _pearls.keySet().iterator(); + + while (iterator.hasNext()) + { + Player shooter = iterator.next(); + Projectile entity = _pearls.get(shooter); + + if (UtilPlayer.isSpectator(shooter)) + { + iterator.remove(); + entity.remove(); + } + else if (entity.getTicksLived() > MAX_TICKS) + { + teleport(shooter, entity); + entity.remove(); + iterator.remove(); + } + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, entity.getLocation(), 0, 0, 0, 0.1F, 3, ViewDist.LONG); + } + } + + @EventHandler + public void projectileHit(ProjectileHitEvent event) + { + ProjectileSource source = event.getEntity().getShooter(); + + if (_pearls.remove(source) != null) + { + teleport((Player) source, event.getEntity()); + } + } + + private void teleport(Player shooter, Projectile entity) + { + Location toTeleport = entity.getLocation(); + Location playerLocation = shooter.getLocation(); + toTeleport.setYaw(playerLocation.getYaw()); + toTeleport.setPitch(playerLocation.getPitch()); + + shooter.teleport(toTeleport); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 04ebb87b0..ab3f56ad7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -1,6 +1,11 @@ package nautilus.game.arcade.game.games.moba.kit; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -160,28 +165,43 @@ public class HeroKit extends Kit inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(RECALL_SLOT, RECALL_ITEM); - // Give armour - List items = ((Moba) Manager.GetGame()).getShop().getOwnedItems(player); + Moba game = (Moba) Manager.GetGame(); + List items = game.getShop().getOwnedItems(player); for (MobaItem item : items) { - ItemStack armour = item.getItem(); + ItemStack itemstack = item.getItem(); - if (UtilItem.isHelmet(armour)) + // Give armour + if (UtilItem.isHelmet(itemstack)) { - inventory.setHelmet(armour); + inventory.setHelmet(itemstack); } - else if (UtilItem.isChestplate(armour)) + else if (UtilItem.isChestplate(itemstack)) { - inventory.setChestplate(armour); + inventory.setChestplate(itemstack); } - else if (UtilItem.isLeggings(armour)) + else if (UtilItem.isLeggings(itemstack)) { - inventory.setLeggings(armour); + inventory.setLeggings(itemstack); } - else if (UtilItem.isBoots(armour)) + else if (UtilItem.isBoots(itemstack)) { - inventory.setBoots(armour); + inventory.setBoots(itemstack); + } + + // Give consumable items + else if (!UtilItem.isSword(itemstack) && !UtilGear.isBow(itemstack)) + { + // Keep moving left from the ammo slot until a free slot is available + for (int i = AMMO_SLOT - 1; i >= GetPerks().length - 1; i--) + { + if (inventory.getItem(i) == null) + { + inventory.setItem(i, itemstack); + break; + } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 5d0dcddd9..53e5cf73b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -13,10 +13,12 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -248,7 +250,7 @@ public class HeroSkill extends Perk } - public void useSkill(Player player) + public void useSkill(Player player) { _lastSkill.put(player.getUniqueId(), System.currentTimeMillis()); if (_cooldown > 0 && !UtilPlayer.isSpectator(player)) @@ -257,6 +259,21 @@ public class HeroSkill extends Perk } } + protected void broadcast(Player player) + { + Moba game = (Moba) Manager.GetGame(); + GameTeam team = game.GetTeam(player); + HeroKit kit = game.getMobaData(player).getKit(); + + if (team == null || kit == null) + { + return; + } + + game.Announce(team.GetColor() + C.Bold + player.getName() + " " + kit.getRole().getChatColor() + kit.GetName() + C.cWhiteB + " activated their " + team.GetColor() + C.Bold + GetName() + C.cWhiteB + ".", false); + player.getWorld().playSound(player.getLocation(), Sound.NOTE_PLING, 10, 0.5F); + } + @EventHandler public void updateCooldowns(UpdateEvent event) { @@ -269,7 +286,7 @@ public class HeroSkill extends Perk for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !_lastSkill.containsKey(player.getUniqueId())) + if (!hasPerk(player) || !_lastSkill.containsKey(player.getUniqueId())) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index 73198fdfe..d91b18850 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -7,7 +7,6 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; -import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; @@ -15,7 +14,11 @@ import nautilus.game.arcade.kit.perks.data.MeteorShowerData; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.entity.*; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LargeFireball; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityChangeBlockEvent; @@ -56,9 +59,12 @@ public class SkillMeteor extends HeroSkill implements IThrown Player player = event.getPlayer(); - if (!Recharge.Instance.use(player, GetName() + " Trigger", 10000, false, false)) + for (MeteorShowerData data : _data) { - return; + if (data.Shooter.equals(player)) + { + return; + } } FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.NETHERRACK, (byte) 0); @@ -66,6 +72,7 @@ public class SkillMeteor extends HeroSkill implements IThrown Manager.GetProjectile().AddThrow(block, player, this, 2000, true, true, true, false, 0.5F); + broadcast(player); useActiveSkill(player, 7000); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java index 907d5f7fd..2bd3d292d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java @@ -126,12 +126,7 @@ public class SkillBiffDash extends HeroSkill continue; } - for (int i = 0; i < 5; i++) - { - Location location = UtilAlg.getRandomLocation(entity.getEyeLocation(), 3); - entity.getWorld().playEffect(location, Effect.STEP_SOUND, Material.GRASS, 0); - } - + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, player.getLocation().add(0, 0.6, 0), 0.5F, 0.5F, 0.5F, 0.1F, 15, ViewDist.LONG); Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 4, false, true, false, UtilEnt.getName(player), GetName()); UtilAction.velocity(entity, new Vector(0, 0.6 + Math.random() / 2, 0)); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java index 7db008510..65da2dceb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.common.LeashedEntity; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -14,6 +15,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -30,7 +32,7 @@ public class SkillLeash extends HeroSkill private static final ItemStack SKILL_ITEM = new ItemStack(Material.LEASH); - private final Map> _leashed = new HashMap<>(); + private final Map> _leashed = new HashMap<>(); public SkillLeash(int slot) { @@ -56,7 +58,7 @@ public class SkillLeash extends HeroSkill return; } - _leashed.put(player, nearbyPlayers); + List leashedEntities = new ArrayList<>(nearbyPlayers.size()); StringBuilder builder = new StringBuilder(F.main("Game", "You leashed ")); @@ -68,13 +70,16 @@ public class SkillLeash extends HeroSkill nearby.sendMessage(F.main("Game", F.name(nearby.getName()) + " leashed you.")); builder.append(F.name(player.getName())).append(", "); Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 0, false, true, true, false); + leashedEntities.add(new LeashedEntity(Manager, nearby, player)); } + _leashed.put(player, leashedEntities); + player.sendMessage(builder.toString()); useActiveSkill(() -> { - for (Player leashed : _leashed.remove(player)) + for (LeashedEntity leashed : _leashed.remove(player)) { removeEffect(leashed); } @@ -90,15 +95,15 @@ public class SkillLeash extends HeroSkill return; } - for (Entry> entry : _leashed.entrySet()) + for (Entry> entry : _leashed.entrySet()) { - Iterator iterator = entry.getValue().iterator(); + Iterator iterator = entry.getValue().iterator(); while (iterator.hasNext()) { - Player leashed = iterator.next(); + LeashedEntity leashed = iterator.next(); - if (UtilMath.offsetSquared(entry.getKey(), leashed) < 25) + if (UtilMath.offsetSquared(entry.getKey(), leashed.getHost()) < 25) { continue; } @@ -109,9 +114,9 @@ public class SkillLeash extends HeroSkill } } - private void removeEffect(Player player) + private void removeEffect(LeashedEntity entity) { - player.setLeashHolder(null); - player.removePotionEffect(PotionEffectType.SLOW); + entity.getHost().removePotionEffect(PotionEffectType.SLOW); + entity.remove(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index 7aabbcea9..d4a141fca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.biff; +import mineplex.core.Managers; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilTime; @@ -7,6 +8,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Horse; @@ -63,18 +65,19 @@ public class SkillWarHorse extends HeroSkill Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); - UtilEnt.vegetate(horse); horse.setJumpStrength(0); horse.setMaxDomestication(1); horse.setDomestication(horse.getMaxDomestication()); horse.getInventory().setArmor(HORSE_ARMOUR); horse.setOwner(player); horse.setPassenger(player); - horse.setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(Manager.getPlugin(), Manager.GetGame().GetTeam(player).GetName())); + MobaUtil.setTeamEntity(horse, Manager.GetGame().GetTeam(player)); Manager.GetGame().CreatureAllowOverride = false; _data.add(new WarHorseData(player, horse)); + + broadcast(player); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java index 59fda7a1e..862caa9f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java @@ -91,6 +91,7 @@ public class SkillBuildPainting extends HeroSkill implements IThrown } useActiveSkill(player, 4000); + broadcast(player); Set blocks = new HashSet<>(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java new file mode 100644 index 000000000..6c3bfb0e6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java @@ -0,0 +1,76 @@ +package nautilus.game.arcade.game.games.moba.kit.common; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class LeashedEntity implements Listener +{ + + private final LivingEntity _host; + private final Zombie _fakeLeash; + + public LeashedEntity(ArcadeManager manager, LivingEntity host, LivingEntity leasher) + { + manager.GetGame().CreatureAllowOverride = true; + + _host = host; + _fakeLeash = host.getWorld().spawn(host.getLocation(), Zombie.class); + UtilEnt.vegetate(_fakeLeash); + UtilEnt.silence(_fakeLeash, true); + _fakeLeash.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false)); + _fakeLeash.setBaby(true); + _fakeLeash.setLeashHolder(leasher); + + manager.GetGame().CreatureAllowOverride = false; + + UtilServer.RegisterEvents(this); + } + + public void remove() + { + _fakeLeash.setLeashHolder(null); + _fakeLeash.remove(); + UtilServer.Unregister(this); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Location location = _host.getLocation(); + ((CraftLivingEntity) _fakeLeash).getHandle().setPosition(location.getX(), location.getY() + 0.8, location.getZ()); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void fakeLeashDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(_fakeLeash) && event.GetCause() == DamageCause.ENTITY_ATTACK) + { + event.setDamagee(_host); + event.SetIgnoreRate(false); + } + } + + public LivingEntity getHost() + { + return _host; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index a1cba5e67..d1d302a78 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -72,6 +72,7 @@ public class SkillRally extends HeroSkill UtilAction.velocity(player, vector); _data.add(new RallyData(player)); + broadcast(player); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 3935b4ec6..24f975e58 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -14,7 +14,6 @@ import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; @@ -69,6 +68,7 @@ public class SkillInfinity extends HeroSkill bow.addEnchantment(Enchantment.ARROW_INFINITE, 1); _active.add(player); + broadcast(player); useActiveSkill(() -> { bow.removeEnchantment(Enchantment.ARROW_INFINITE); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java index b7c658777..94d7b02a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java @@ -62,7 +62,7 @@ public class SkillTNTArrows extends HeroSkill Player player = event.getPlayer(); _playerArrows.put(player, 3); - player.getItemInHand().addEnchantment(UtilInv.getDullEnchantment(), 1); + UtilInv.addDullEnchantment(player.getItemInHand()); player.getItemInHand().setAmount(3); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index 9a9ebe0a8..4f775fa8d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.kit.hattori; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; @@ -52,7 +53,7 @@ public class SkillNinjaBlade extends HeroSkill @EventHandler public void interact(PlayerInteractEvent event) { - if (!isSkillItem(event)) + if (!isSkillItem(event) || _active.containsKey(event.getPlayer().getUniqueId())) { return; } @@ -93,9 +94,20 @@ public class SkillNinjaBlade extends HeroSkill _active.put(player.getUniqueId(), damage); + int i = 0; + for (ItemStack itemStack : inventory.getContents()) + { + if (!itemStack.equals(ACTIVE_ITEM) && UtilItem.isSword(itemStack)) + { + inventory.setItem(i, null); + } + + i++; + } + + broadcast(player); useActiveSkill(() -> { - _active.remove(player.getUniqueId()); for (Perk perk : Kit.GetPerks()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index a00dcfa24..edb5c9917 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -15,6 +15,7 @@ import nautilus.game.arcade.game.games.moba.boss.MobaBoss; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Entity; @@ -88,9 +89,7 @@ public class MinionWave implements Listener _host.CreatureAllowOverride = true; Minion minion = new Minion(_path.get(0), _clazz, _superMinions); - - minion.getEntity().setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), _owner.GetName())); - + MobaUtil.setTeamEntity(minion.getEntity(), _owner); _minions.add(minion); _host.CreatureAllowOverride = false; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java deleted file mode 100644 index 0e0360bfc..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java +++ /dev/null @@ -1,109 +0,0 @@ -package nautilus.game.arcade.game.games.moba.prepare; - -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.MobaPlayer; -import nautilus.game.arcade.game.games.moba.MobaRole; -import org.bukkit.Location; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerMoveEvent; - -import java.util.concurrent.TimeUnit; - -public class PrepareInformation implements Listener -{ - - private static final long MESSAGE_TIME = TimeUnit.SECONDS.toMillis(3); - private static final int MESSAGE_TIME_TICKS = (int) (MESSAGE_TIME / 50D + 5); - - private final Moba _host; - - private long _lastMessage; - private int _messageIndex; - - public PrepareInformation(Moba host) - { - _host = host; - - // How long should the prepare time be. - int longestDescription = 0; - for (MobaRole role : MobaRole.values()) - { - int length = role.getDescription().length; - - if (length > longestDescription) - { - longestDescription = length; - } - } - - // Modify the prepare time - _host.PrepareTime = longestDescription * MESSAGE_TIME + 1000; - - UtilServer.RegisterEvents(this); - } - - @EventHandler - public void updateMessages(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST || !UtilTime.elapsed(_lastMessage, MESSAGE_TIME)) - { - return; - } - - for (MobaPlayer mobaPlayer : _host.getMobaData()) - { - String[] description = mobaPlayer.getRole().getDescription(); - - // Description is too short - if (description.length <= _messageIndex + 1) - { - continue; - } - - UtilTextMiddle.display(description[_messageIndex], description[_messageIndex + 1], 0, MESSAGE_TIME_TICKS, 0, mobaPlayer.getPlayer()); - } - - _messageIndex++; - _lastMessage = System.currentTimeMillis(); - } - - @EventHandler - public void playerMove(PlayerMoveEvent event) - { - if (UtilPlayer.isSpectator(event.getPlayer())) - { - return; - } - - Location to = event.getTo(); - Location from = event.getFrom(); - - // Player hasn't moved along the X or Z axis - if (to.getX() == from.getX() && to.getZ() == from.getZ()) - { - return; - } - - event.setTo(from); - } - - @EventHandler - public void live(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - { - return; - } - - UtilServer.Unregister(this); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java index 99e01896f..eacc7cdd0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java @@ -14,15 +14,12 @@ import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent; -import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.metadata.FixedMetadataValue; import java.util.concurrent.TimeUnit; @@ -30,10 +27,12 @@ public class PrepareManager implements Listener { private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1); + private static final long POST_SELECTION_PREPARE_TIME = TimeUnit.SECONDS.toMillis(5); + private static final int MAX_DISTANCE_WITHOUT_SELECTION_SQUARED = 400; private final Moba _host; - private boolean _informationStage; + private boolean _postPrepareStage; public PrepareManager(Moba host) { @@ -43,7 +42,7 @@ public class PrepareManager implements Listener @EventHandler(priority = EventPriority.LOW) public void updatePrepare(UpdateEvent event) { - if (event.getType() != UpdateType.SEC || _host.GetState() != GameState.Prepare || _informationStage) + if (event.getType() != UpdateType.SEC || _host.GetState() != GameState.Prepare || _postPrepareStage) { return; } @@ -61,7 +60,7 @@ public class PrepareManager implements Listener } } - _informationStage = true; + _postPrepareStage = true; _host.AnnounceGame(); _host.StartPrepareCountdown(); @@ -95,9 +94,29 @@ public class PrepareManager implements Listener _host.SetStateTime(System.currentTimeMillis()); _host.getArcadeManager().GetChat().Silence(-1, false); + _host.PrepareTime = POST_SELECTION_PREPARE_TIME; + _host.PrepareFreeze = true; + } - // Start the pregame role information - new PrepareInformation(_host); + @EventHandler + public void updateNearSpawn(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW || _host.GetState() != GameState.Prepare) + { + return; + } + + for (MobaPlayer mobaPlayer : _host.getMobaData()) + { + Player player = mobaPlayer.getPlayer(); + GameTeam team = _host.GetTeam(player); + + if (UtilMath.offsetSquared(player.getLocation(), team.GetSpawns().get(0)) > MAX_DISTANCE_WITHOUT_SELECTION_SQUARED && (mobaPlayer.getRole() == null || mobaPlayer.getKit() == null)) + { + player.sendMessage(F.main("Game", "You haven't finished selecting your hero.")); + team.SpawnTeleport(player); + } + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index 0d5f125c0..23f01e5e9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -73,7 +73,7 @@ public class PrepareSelection implements Listener, IPacketHandler UtilServer.runSyncLater(() -> { - for (Player player : _host.GetPlayers(true)) + for (Player player : team.GetPlayers(true)) { displayRoleInformation(player); } @@ -235,12 +235,18 @@ public class PrepareSelection implements Listener, IPacketHandler private void displayRoleInformation(Player player) { - UtilTextMiddle.display(C.cYellowB + "Role", "Select the role you would like to play", 10, 40, 10, player); + String base = "Select the role you would like to play!"; + + UtilTextMiddle.display(C.cYellowB + "Role", base, 10, 40, 10, player); + player.sendMessage(F.main("Game", base)); } private void displayKitInformation(Player player, MobaRole role) { + String base = "Select your " + role.getChatColor() + "Hero"; + UtilTextMiddle.display(role.getChatColor() + role.getName(), "Select your " + role.getChatColor() + "Hero", 10, 40, 10, player); + player.sendMessage(F.main("Game", base + C.mBody + "!")); } // Unregister diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java index 576bc305c..a4f9f78ac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java @@ -2,7 +2,9 @@ package nautilus.game.arcade.game.games.moba.shop; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.leaderboard.Leaderboard; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; import java.util.ArrayList; import java.util.Collections; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index c244dba1c..2c0ba235b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -1,6 +1,11 @@ package nautilus.game.arcade.game.games.moba.shop; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatComponent; @@ -21,7 +26,9 @@ import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop; import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop; import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import nautilus.game.arcade.kit.Kit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -29,9 +36,14 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.HashMap; @@ -42,6 +54,11 @@ import java.util.Map.Entry; public class MobaShop implements Listener { + private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT) + .setTitle(C.cGold + "Open Gold Upgrades") + .addLore("Click to open the Gold Upgrades", "shop while you are respawning.") + .build(); + private final Moba _host; private final Map _entities; private final Map _roleMenus; @@ -84,6 +101,7 @@ public class MobaShop implements Listener UtilEnt.vegetate(villager); UtilEnt.silence(villager, true); UtilEnt.CreatureForceLook(villager, 0, UtilAlg.GetYaw(UtilAlg.getTrajectory(villager.getLocation(), _host.GetSpectatorLocation()))); + ((CraftLivingEntity) villager).getHandle().k = false; _entities.put(villager, location); } @@ -92,7 +110,7 @@ public class MobaShop implements Listener public void openShop(MobaPlayer player) { - if (UtilPlayer.isSpectator(player.getPlayer()) || _host.GetState() != GameState.Live) + if (_host.GetState() != GameState.Live) { return; } @@ -153,7 +171,7 @@ public class MobaShop implements Listener private void npcInteract(Entity clicked, Entity clicker) { - if (!(clicker instanceof Player)) + if (!(clicker instanceof Player) || UtilPlayer.isSpectator(clicker)) { return; } @@ -183,6 +201,11 @@ public class MobaShop implements Listener List owned = _upgrades.get(player); MobaShopCategory category = getCategory(item); + if (category == null) + { + return; + } + if (!category.isAllowingMultiple()) { owned.removeIf(previousItem -> getCategory(previousItem) == category); @@ -191,6 +214,14 @@ public class MobaShop implements Listener player.sendMessage(F.main("Game", "Purchased " + F.greenElem(item.getItem().getItemMeta().getDisplayName()) + ".")); _host.getGoldManager().removeGold(player, item.getCost()); owned.add(item); + category.purchase(player); + + // This would happen when the player is respawning and is purchasing upgrades + // In this case giving them the item is not needed + if (UtilPlayer.isSpectator(player)) + { + return; + } // 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, // Prevents infinite speed @@ -236,6 +267,82 @@ public class MobaShop implements Listener return null; } + /* + Allow players to access the shop while dead. + */ + + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + final Player player = event.getEntity(); + + _host.getArcadeManager().runSyncLater(() -> + { + // Certain categories such as consumables drop on death so here we remove them from upgrades + List owned = _upgrades.get(player); + + if (owned != null) + { + owned.removeIf(item -> + { + MobaShopCategory category = getCategory(item); + return category == null || category.isDroppingOnDeath(); + }); + + // Reset the max amount of purchasable items + MobaPlayer mobaPlayer = _host.getMobaData(player); + + if (mobaPlayer == null || mobaPlayer.getRole() == null) + { + return; + } + + _roleMenus.get(mobaPlayer.getRole()).getCategories().forEach(category -> category.onDeath(player)); + } + + // Give the player their kit items + Kit kit = _host.GetKit(player); + + if (kit == null) + { + return; + } + + kit.GiveItems(player); + player.getInventory().setItem(8, SHOP_ITEM); + }, 1); + } + + @EventHandler + public void interactShopItem(PlayerInteractEvent event) + { + if (event.getItem() == null || !event.getItem().isSimilar(SHOP_ITEM)) + { + return; + } + + MobaPlayer mobaPlayer = _host.getMobaData(event.getPlayer()); + + if (mobaPlayer == null) + { + return; + } + + openShop(mobaPlayer); + } + + /* + Remove empty potions + */ + @EventHandler + public void removeEmptyPotions(PlayerItemConsumeEvent event) + { + if (event.getItem().getType() == Material.POTION) + { + _host.getArcadeManager().runSyncLater(() -> event.getPlayer().setItemInHand(null), 1); + } + } + /* Handle MobaItem events */ @@ -294,9 +401,14 @@ public class MobaShop implements Listener } } - @EventHandler + @EventHandler(priority = EventPriority.HIGH) public void damage(CustomDamageEvent event) { + if (event.isCancelled()) + { + return; + } + Player damagee = event.GetDamageePlayer(); Player damager = event.GetDamagerPlayer(true); @@ -396,9 +508,14 @@ public class MobaShop implements Listener } } - @EventHandler + @EventHandler(priority = EventPriority.HIGH) public void conditionApply(ConditionApplyEvent event) { + if (event.isCancelled()) + { + return; + } + LivingEntity entity = event.GetCondition().GetEnt(); if (!(entity instanceof Player)) @@ -409,11 +526,6 @@ public class MobaShop implements Listener Player player = (Player) entity; List items = _upgrades.get(player); - if (_upgrades == null) - { - return; - } - for (MobaItem item : items) { if (item.getEffects() == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java index 224433e3f..a978f4545 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java @@ -1,8 +1,12 @@ package nautilus.game.arcade.game.games.moba.shop; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.UUID; public class MobaShopCategory { @@ -10,13 +14,17 @@ public class MobaShopCategory private final String _name; private final List _items; private final ItemStack _menuItem; - private boolean _allowMultiple; + private final Map _purchased; + private int _max; + private boolean _dropOnDeath; public MobaShopCategory(String name, List items, ItemStack menuItem) { _name = name; _items = items; _menuItem = menuItem; + _max = Integer.MAX_VALUE; + _purchased = new HashMap<>(); } public String getName() @@ -34,14 +42,57 @@ public class MobaShopCategory return _menuItem; } - public MobaShopCategory allowMultiple(boolean allow) + public void purchase(Player player) { - _allowMultiple = allow; + UUID key = player.getUniqueId(); + + if (!_purchased.containsKey(key)) + { + _purchased.put(key, 1); + } + else + { + _purchased.put(key, _purchased.get(key) + 1); + } + } + + public void onDeath(Player player) + { + if (isDroppingOnDeath()) + { + _purchased.remove(player.getUniqueId()); + } + } + + public int getPurchased(Player player) + { + return _purchased.getOrDefault(player.getUniqueId(), 0); + } + + public MobaShopCategory setMax(int max) + { + _max = max; return this; } + public int getMax() + { + return _max; + } + + public MobaShopCategory dropOnDeath() + { + _dropOnDeath = true; + return this; + } + + public boolean isDroppingOnDeath() + { + return _dropOnDeath; + } + public boolean isAllowingMultiple() { - return _allowMultiple; + return _max < Integer.MAX_VALUE; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java index f6ca8ac51..7c7c3aba5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -47,6 +47,7 @@ public class MobaShopCategoryMenu extends Menu ItemBuilder builder = new ItemBuilder(item.getItem()); boolean owns = _shop.ownsItem(player, item); boolean canPurchase = _host.getGoldManager().hasGold(player, item.getCost()); + boolean maxed = _category.getPurchased(player) == _category.getMax(); int gold = _host.getGoldManager().getGold(player); builder.setTitle((canPurchase ? C.cGreen : C.cRed) + item.getItem().getItemMeta().getDisplayName()); @@ -61,7 +62,11 @@ public class MobaShopCategoryMenu extends Menu { builder.addLore(C.cWhite + "Cost: " + C.cGold + item.getCost(), C.cWhite + "Your Gold: " + C.cGold + gold, ""); - if (canPurchase) + if (maxed) + { + builder.addLore(C.cRed + "You have already purchased the maximum amount", C.cRed + "of upgrades from this category."); + } + else if (canPurchase) { builder.addLore(C.cGreen + "Click to purchase."); } @@ -100,8 +105,9 @@ public class MobaShopCategoryMenu extends Menu { boolean owns = _shop.ownsItem(player, _item); boolean canPurchase = _host.getGoldManager().hasGold(player, _item.getCost()); + boolean maxed = _category.getPurchased(player) == _category.getMax(); - if (!owns && canPurchase) + if (!owns && canPurchase && !maxed) { player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 1.6F); _shop.purchaseItem(player, _item); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java index af128575b..db0c94fa3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java @@ -8,16 +8,41 @@ import mineplex.core.menu.Menu; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaRole; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class MobaShopMenu extends Menu { + private static final MobaShopCategory CONSUMABLES = new MobaShopCategory("Consumables", Arrays.asList( + new MobaItem(new ItemBuilder(Material.POTION) + .setTitle(C.cGreenB + "Small Health Potion") + .addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0)) + .build(), 100), + new MobaItem(new ItemBuilder(Material.POTION) + .setTitle(C.cYellowB + "Large Health Potion") + .addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1)) + .build(), 200), + new MobaItem(new ItemBuilder(Material.POTION) + .setTitle(C.cYellowB + "Power Potion") + .addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 90 * 20, 0)) + .build(), 1000), + new MobaItem(new ItemBuilder(Material.POTION) + .setTitle(C.cYellowB + "Speed Potion") + .addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 180 * 20, 0)) + .build(), 500), + new MobaItem(new ItemBuilder(Material.ENDER_PEARL) + .setTitle(C.cYellowB + "Ender Pearl") + .build(), 750) + ), new ItemStack(Material.POTION)).dropOnDeath().setMax(3); private static final int SLOTS = 27; private final Moba _host; @@ -38,6 +63,11 @@ public class MobaShopMenu extends Menu _categories.add(category); } + protected void addConsumables() + { + _categories.add(CONSUMABLES); + } + @Override protected Button[] setUp(Player player) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java index 9d3a43a7a..5ba6f17f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java @@ -124,5 +124,6 @@ public class MobaAssassinShop extends MobaShopMenu addCategory(CHESTPLATE); addCategory(LEGGINGS); addCategory(BOOTS); + addConsumables(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java index 06b6fdaf7..2723bdf3e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java @@ -203,5 +203,6 @@ public class MobaHunterShop extends MobaShopMenu addCategory(CHESTPLATE); addCategory(LEGGINGS); addCategory(BOOTS); + addConsumables(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java index 15103bdcd..e8b5a38b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java @@ -20,34 +20,41 @@ import java.util.Arrays; public class MobaMageShop extends MobaShopMenu { + // Dark Purple + private static final Color ABILITY_DAMAGE_COLOUR = Color.fromBGR(181, 7, 123); + // Purple + private static final Color COOLDOWN_COLOUR = Color.PURPLE; + // Light Purple + private static final Color BASIC_DAMAGE_COLOUR = Color.fromBGR(254, 89, 200); + private static final MobaShopCategory HELMET = new MobaShopCategory("Helmet", Arrays.asList( new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Leather Cap") .build(), 200), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Adept's Cap") - .setColor(Color.BLACK) - .build(), 500) + .setColor(ABILITY_DAMAGE_COLOUR) + .build(), 750) .addEffects( new MobaAbilityDamageEffect("Adept's Cap", 0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Helm of Focus") - .setColor(Color.PURPLE) - .build(), 500) + .setColor(COOLDOWN_COLOUR) + .build(), 750) .addEffects( new MobaCDREffect(0.03) ), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Battle Mage Cap") - .setColor(Color.YELLOW) - .build(), 500) + .setColor(BASIC_DAMAGE_COLOUR) + .build(), 750) .addEffects( new MobaBasicAttackDamageEffect("Battle Mage Cap", 0.03) ), new MobaItem(new ItemBuilder(Material.GOLD_HELMET) .setTitle(C.cYellow + "Golden Helmet") - .build(), 750) + .build(), 1000) ), new ItemStack(Material.LEATHER_HELMET)); private static final MobaShopCategory CHESTPLATE = new MobaShopCategory("Chestplate", Arrays.asList( @@ -56,28 +63,28 @@ public class MobaMageShop extends MobaShopMenu .build(), 400), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) .setTitle(C.cGreen + "Adept's Chestplate") - .setColor(Color.BLACK) - .build(), 1250) + .setColor(ABILITY_DAMAGE_COLOUR) + .build(), 1500) .addEffects( new MobaAbilityDamageEffect("Adept's Chestplate", 0.15) ), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) .setTitle(C.cGreen + "Chestplate of Focus") - .setColor(Color.PURPLE) - .build(), 1000) + .setColor(COOLDOWN_COLOUR) + .build(), 1250) .addEffects( new MobaCDREffect(0.1) ), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) .setTitle(C.cGreen + "Battle Mage Chestplate") - .setColor(Color.YELLOW) - .build(), 1000) + .setColor(BASIC_DAMAGE_COLOUR) + .build(), 1250) .addEffects( new MobaBasicAttackDamageEffect("Battle Mage Chestplate", 0.1) ), new MobaItem(new ItemBuilder(Material.GOLD_CHESTPLATE) .setTitle(C.cYellow + "Golden Chestplate") - .build(), 1000) + .build(), 1250) ), new ItemStack(Material.LEATHER_CHESTPLATE)); private static final MobaShopCategory LEGGINGS = new MobaShopCategory("Leggings", Arrays.asList( @@ -86,22 +93,22 @@ public class MobaMageShop extends MobaShopMenu .build(), 400), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) .setTitle(C.cGreen + "Adept's Leggings") - .setColor(Color.BLACK) - .build(), 750) + .setColor(ABILITY_DAMAGE_COLOUR) + .build(), 1000) .addEffects( new MobaAbilityDamageEffect("Adept's Leggings", 0.1) ), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) .setTitle(C.cGreen + "Leggings of Focus") - .setColor(Color.PURPLE) - .build(), 750) + .setColor(COOLDOWN_COLOUR) + .build(), 1000) .addEffects( new MobaCDREffect(0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) .setTitle(C.cGreen + "Battle Mage Leggings") - .setColor(Color.YELLOW) - .build(), 750) + .setColor(BASIC_DAMAGE_COLOUR) + .build(), 1000) .addEffects( new MobaBasicAttackDamageEffect("Battle Mage Leggings", 0.05) ), @@ -116,28 +123,28 @@ public class MobaMageShop extends MobaShopMenu .build(), 200), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Adept's Boots") - .setColor(Color.BLACK) - .build(), 500) + .setColor(ABILITY_DAMAGE_COLOUR) + .build(), 750) .addEffects( new MobaAbilityDamageEffect("Adept's Boots", 0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Boots of Focus") - .setColor(Color.PURPLE) - .build(), 500) + .setColor(COOLDOWN_COLOUR) + .build(), 750) .addEffects( new MobaCDREffect(0.03) ), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Battle Mage Boots") - .setColor(Color.YELLOW) - .build(), 500) + .setColor(BASIC_DAMAGE_COLOUR) + .build(), 750) .addEffects( new MobaBasicAttackDamageEffect("Battle Mage Boots", 0.03) ), new MobaItem(new ItemBuilder(Material.GOLD_BOOTS) .setTitle(C.cYellow + "Golden Boots") - .build(), 750) + .build(), 1000) ), new ItemStack(Material.LEATHER_BOOTS)); public MobaMageShop(Moba host, MobaShop shop) @@ -148,5 +155,6 @@ public class MobaMageShop extends MobaShopMenu addCategory(CHESTPLATE); addCategory(LEGGINGS); addCategory(BOOTS); + addConsumables(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java index 03bc1f529..2d0ca6f60 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java @@ -48,13 +48,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaHPRegenEffect(0.03) ), - new MobaItem(new ItemBuilder(Material.IRON_HELMET) - .setTitle(C.cYellowB + "Superior Archer's Bane") - .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) - .build(), 750) - .addEffects( - new MobaHPRegenEffect(0.05) - ), +// new MobaItem(new ItemBuilder(Material.IRON_HELMET) +// .setTitle(C.cYellowB + "Superior Archer's Bane") +// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) +// .build(), 750) +// .addEffects( +// new MobaHPRegenEffect(0.05) +// ), new MobaItem(new ItemBuilder(Material.IRON_HELMET) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) @@ -62,13 +62,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaHPRegenEffect(0.03) ), - new MobaItem(new ItemBuilder(Material.IRON_HELMET) - .setTitle(C.cYellowB + "Superior Brawler's Plate") - .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) - .build(), 750) - .addEffects( - new MobaHPRegenEffect(0.05) - ), +// new MobaItem(new ItemBuilder(Material.IRON_HELMET) +// .setTitle(C.cYellowB + "Superior Brawler's Plate") +// .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) +// .build(), 750) +// .addEffects( +// new MobaHPRegenEffect(0.05) +// ), new MobaItem(new ItemBuilder(Material.DIAMOND_HELMET) .setTitle(C.cDRedB + "Prince's Plate") .build(), 2000) @@ -85,13 +85,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaTotalHealthEffect(2) ), - new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) - .setTitle(C.cYellowB + "Superior Archer's Bane") - .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) - .build(), 1000) - .addEffects( - new MobaTotalHealthEffect(4) - ), +// new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) +// .setTitle(C.cYellowB + "Superior Archer's Bane") +// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) +// .build(), 1000) +// .addEffects( +// new MobaTotalHealthEffect(4) +// ), new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) @@ -99,13 +99,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaTotalHealthEffect(2) ), - new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) - .setTitle(C.cYellowB + "Superior Brawler's Plate") - .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) - .build(), 1000) - .addEffects( - new MobaTotalHealthEffect(4) - ), +// new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) +// .setTitle(C.cYellowB + "Superior Brawler's Plate") +// .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) +// .build(), 1000) +// .addEffects( +// new MobaTotalHealthEffect(4) +// ), new MobaItem(new ItemBuilder(Material.DIAMOND_CHESTPLATE) .setTitle(C.cDRedB + "Prince's Plate") .build(), 2500) @@ -122,13 +122,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaCDREffect(0.05) ), - new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) - .setTitle(C.cYellowB + "Superior Archer's Bane") - .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) - .build(), 1000) - .addEffects( - new MobaCDREffect(0.07) - ), +// new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) +// .setTitle(C.cYellowB + "Superior Archer's Bane") +// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) +// .build(), 1000) +// .addEffects( +// new MobaCDREffect(0.07) +// ), new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) @@ -136,13 +136,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaCDREffect(0.05) ), - new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) - .setTitle(C.cYellowB + "Superior Brawler's Plate") - .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) - .build(), 1000) - .addEffects( - new MobaCDREffect(0.07) - ), +// new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) +// .setTitle(C.cYellowB + "Superior Brawler's Plate") +// .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) +// .build(), 1000) +// .addEffects( +// new MobaCDREffect(0.07) +// ), new MobaItem(new ItemBuilder(Material.DIAMOND_LEGGINGS) .setTitle(C.cDRedB + "Prince's Plate") .build(), 2500) @@ -159,13 +159,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaSpeedEffect(0.04) ), - new MobaItem(new ItemBuilder(Material.IRON_BOOTS) - .setTitle(C.cYellowB + "Superior Archer's Bane") - .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) - .build(), 750) - .addEffects( - new MobaSpeedEffect(0.06) - ), +// new MobaItem(new ItemBuilder(Material.IRON_BOOTS) +// .setTitle(C.cYellowB + "Superior Archer's Bane") +// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) +// .build(), 750) +// .addEffects( +// new MobaSpeedEffect(0.06) +// ), new MobaItem(new ItemBuilder(Material.IRON_BOOTS) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) @@ -173,13 +173,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaSpeedEffect(0.04) ), - new MobaItem(new ItemBuilder(Material.IRON_BOOTS) - .setTitle(C.cYellowB + "Superior Brawler's Plate") - .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) - .build(), 750) - .addEffects( - new MobaSpeedEffect(0.06) - ), +// new MobaItem(new ItemBuilder(Material.IRON_BOOTS) +// .setTitle(C.cYellowB + "Superior Brawler's Plate") +// .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) +// .build(), 750) +// .addEffects( +// new MobaSpeedEffect(0.06) +// ), new MobaItem(new ItemBuilder(Material.DIAMOND_BOOTS) .setTitle(C.cDRedB + "Prince's Plate") .build(), 2000) @@ -197,5 +197,6 @@ public class MobaWarriorShop extends MobaShopMenu addCategory(CHESTPLATE); addCategory(LEGGINGS); addCategory(BOOTS); + addConsumables(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 22831e831..6efb7e551 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.structure.tower; import mineplex.core.common.Pair; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; @@ -147,6 +148,7 @@ public class TowerManager implements Listener { if (tower.getStand().equals(event.GetDamageeEntity())) { + tower.getStand().setFireTicks(0); event.SetCancelled("Tower Guardian"); } } @@ -169,31 +171,36 @@ public class TowerManager implements Listener return; } - Entity entity = event.getDamager(); + Entity damager = event.getDamager(); Player player = null; + Tower tower = null; - if (entity instanceof Player) + for (Tower other : _towers) { - player = (Player) entity; + if (other.getCrystal().equals(event.getEntity())) + { + tower = other; + break; + } } - else if (entity instanceof Projectile) + + if (tower == null) { - Projectile projectile = (Projectile) entity; + return; + } + + if (damager instanceof Player) + { + player = (Player) damager; + } + else if (damager instanceof Projectile) + { + Projectile projectile = (Projectile) damager; ProjectileSource source = projectile.getShooter(); if (source instanceof Player) { player = (Player) source; - - Location entityLocation = event.getEntity().getLocation(); - Location playerLocation = player.getLocation(); - playerLocation.setY(entityLocation.getY()); - - if (UtilMath.offsetSquared(playerLocation, entityLocation) > Tower.TARGET_RANGE_SQUARED) - { - event.setCancelled(true); - return; - } } } @@ -204,26 +211,16 @@ public class TowerManager implements Listener GameTeam team = _host.GetTeam(player); - if (UtilPlayer.isSpectator(player) || team == null) + if (UtilPlayer.isSpectator(player) || team == null || !canDamage(tower, team) || shouldCancelDamage(tower, player)) { return; } - for (Tower tower : _towers) + tower.damage(event.getDamage()); + + if (Recharge.Instance.use(player, "Tower Sound", 500, false, false)) { - if (!event.getEntity().equals(tower.getCrystal()) || !canDamage(tower, team)) - { - continue; - } - - event.setCancelled(true); - tower.damage(event.getDamage()); - - if (Recharge.Instance.use(player, "Tower Sound", 500, false, false)) - { - playSound(player, tower); - } - return; + playSound(player, tower); } } @@ -246,7 +243,8 @@ public class TowerManager implements Listener { Entity entity = iterator.next(); Pair pair = _projectilesToCheck.get(entity); - GameTeam team = _host.GetTeam(pair.getLeft()); + Player player = pair.getLeft(); + GameTeam team = _host.GetTeam(player); for (Tower tower : _towers) { @@ -255,14 +253,38 @@ public class TowerManager implements Listener continue; } - playSound(pair.getLeft(), tower); - tower.damage(pair.getRight()); + if (!shouldCancelDamage(tower, player)) + { + playSound(player, tower); + tower.damage(pair.getRight()); + } + entity.remove(); iterator.remove(); } } } + private boolean shouldCancelDamage(Tower tower, Player shooter) + { + Location entityLocation = tower.getCrystal().getLocation(); + Location playerLocation = shooter.getLocation(); + playerLocation.setY(entityLocation.getY()); + + if (UtilMath.offsetSquared(playerLocation, entityLocation) > Tower.TARGET_RANGE_SQUARED) + { + shooter.playSound(shooter.getLocation(), Sound.NOTE_PLING, 1, 0.9F); + if (Recharge.Instance.use(shooter, "Tower Cancel Inform", 2000, false, false)) + { + shooter.sendMessage(F.main("Game", "You cannot damage the enemy tower while outside of the circle! Step inside the circle to deal damage to it.")); + } + + return true; + } + + return false; + } + private void playSound(Player player, Tower tower) { player.playSound(tower.getCrystal().getLocation(), Sound.BLAZE_HIT, 1, 0.8F); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 4242ec20f..46c3eac2f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -5,6 +5,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; @@ -12,6 +13,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; import java.util.ArrayList; @@ -185,6 +187,11 @@ public class MobaUtil return C.cGreenB; } + public static void setTeamEntity(LivingEntity entity, GameTeam team) + { + entity.setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(UtilServer.getPlugin(), team.GetName())); + } + public static boolean isTeamEntity(LivingEntity entity, GameTeam team) { return entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(team.GetName()); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java index dbff05dc6..0d0487a8d 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java @@ -28,6 +28,7 @@ import org.bukkit.block.BlockState; import org.bukkit.block.Chest; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; From b59e57dfb61cca09a568b40692abb9e854482a5c Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jun 2017 02:10:24 +0100 Subject: [PATCH 145/283] Fixed Players not being given their Gem Hunters rewards for the final time! --- .../mineplex/gemhunters/loot/LootModule.java | 20 ++++++++++++++++--- .../loot/rewards/LootItemReward.java | 3 ++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java index b759af50b..3b7a7c822 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java @@ -29,6 +29,8 @@ import org.bukkit.block.BlockState; import org.bukkit.block.Chest; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; @@ -479,10 +481,10 @@ public class LootModule extends MiniPlugin handleRewardItem((Player) event.getWhoClicked(), itemStack); } - @EventHandler + @EventHandler(priority = EventPriority.HIGH) public void pickupItem(PlayerPickupItemEvent event) { - if (event.getItem() == null) + if (event.getItem() == null || event.isCancelled()) { return; } @@ -626,7 +628,7 @@ public class LootModule extends MiniPlugin { LootItemReward reward = iterator.next(); - if (player.equals(reward.getPlayer()) && player.getInventory().contains(reward.getItemStack())) + if (reward.getPlayer() != null && player.equals(reward.getPlayer())) { reward.success(); iterator.remove(); @@ -634,6 +636,18 @@ public class LootModule extends MiniPlugin } } + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + for (LootItemReward reward : _itemRewards) + { + if (reward.getPlayer().equals(event.getEntity())) + { + reward.death(event); + } + } + } + public final Set getShownPlayers() { return _shownPlayers; diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootItemReward.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootItemReward.java index f0ec11991..49acb3858 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootItemReward.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootItemReward.java @@ -38,7 +38,7 @@ public abstract class LootItemReward public final void collectItem(Player player) { - if (player.equals(_player)) + if (_player != null && player.equals(_player)) { return; } @@ -73,6 +73,7 @@ public abstract class LootItemReward public final void death(PlayerDeathEvent event) { + _player = null; } public boolean isFirstPickup() From 1d64bb63c43e69cbf39d8b60f51586b9b672393f Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jun 2017 02:18:57 +0100 Subject: [PATCH 146/283] Add a check to prevent a possible duplication bug --- .../mineplex/gemhunters/loot/LootModule.java | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java index 3b7a7c822..9aa42e3ac 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java @@ -2,8 +2,14 @@ package mineplex.gemhunters.loot; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; -import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.google.GoogleSheetsManager; import mineplex.core.stats.StatsManager; import mineplex.core.updater.UpdateType; @@ -15,7 +21,11 @@ import mineplex.gemhunters.loot.command.UpdateLootCommand; import mineplex.gemhunters.loot.deserialisers.ChestPropertiesDeserialiser; import mineplex.gemhunters.loot.deserialisers.LootItemDeserialiser; import mineplex.gemhunters.loot.event.PlayerChestOpenEvent; -import mineplex.gemhunters.loot.rewards.*; +import mineplex.gemhunters.loot.rewards.LootChestReward; +import mineplex.gemhunters.loot.rewards.LootGadgetReward; +import mineplex.gemhunters.loot.rewards.LootItemReward; +import mineplex.gemhunters.loot.rewards.LootRankReward; +import mineplex.gemhunters.loot.rewards.LootShardReward; import mineplex.gemhunters.safezone.SafezoneModule; import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent; import mineplex.gemhunters.world.WorldDataModule; @@ -27,6 +37,8 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.block.Chest; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -37,7 +49,13 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import java.util.concurrent.TimeUnit; @ReflectivelyCreateMiniPlugin @@ -632,6 +650,19 @@ public class LootModule extends MiniPlugin { reward.success(); iterator.remove(); + + for (Entity entity : reward.getPlayer().getWorld().getEntities()) + { + if (entity instanceof Item) + { + Item item = (Item) entity; + + if (item.getItemStack().getType() == reward.getItemStack().getType()) + { + entity.remove(); + } + } + } } } } From 4628af6e81360948d82ff447757a40f003a4f143 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 7 Jun 2017 23:52:13 -0400 Subject: [PATCH 147/283] Call treasure start event after teleporting the player --- .../core/treasure/TreasureLocation.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java index b3fdc3e2a..33401bf40 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java @@ -176,22 +176,21 @@ public class TreasureLocation implements Listener Treasure treasure = new Treasure(_treasureManager, player, rewards, treasureType.getRewardType(), _chestBlock, _chestSpawns, treasureType, _treasureManager.getBlockRestore(), _hologramManager, _statusManager); _currentTreasure = treasure; - TreasureStartEvent startEvent = new TreasureStartEvent(player, treasure, Arrays.asList(rewards)); - UtilServer.CallEvent(startEvent); - - UtilTextMiddle.display(treasureType.getName(), "Choose " + rewards.length + " " + UtilText.plural("Chest", rewards.length) + " To Open", 20, 180, 20, player); - UtilPlayer.message(player, F.main("Treasure", "Choose " + rewards.length + " " + UtilText.plural("Chest", rewards.length) + " To Open")); - - Location teleportLocation = treasure.getCenterBlock().getLocation().add(0.5, 0, 0.5); - teleportLocation.setPitch(player.getLocation().getPitch()); - teleportLocation.setYaw(player.getLocation().getYaw()); - for (Entity entity : player.getNearbyEntities(3, 3, 3)) { UtilAction.velocity(entity, UtilAlg.getTrajectory(entity.getLocation(), treasure.getCenterBlock().getLocation()).multiply(-1), 1.5, true, 0.8, 0, 1.0, true); } + Location teleportLocation = treasure.getCenterBlock().getLocation().add(0.5, 0, 0.5); + teleportLocation.setPitch(player.getLocation().getPitch()); + teleportLocation.setYaw(player.getLocation().getYaw()); + player.teleport(teleportLocation); + TreasureStartEvent startEvent = new TreasureStartEvent(player, treasure, Arrays.asList(rewards)); + UtilServer.CallEvent(startEvent); + + UtilTextMiddle.display(treasureType.getName(), "Choose " + rewards.length + " " + UtilText.plural("Chest", rewards.length) + " To Open", 20, 180, 20, player); + UtilPlayer.message(player, F.main("Treasure", "Choose " + rewards.length + " " + UtilText.plural("Chest", rewards.length) + " To Open")); _treasureManager.addOpenStat(player, treasureType); } From 8138b5d241015b0499d204e0d66139ca6d91eea8 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 7 Jun 2017 23:54:03 -0400 Subject: [PATCH 148/283] Fix Bob Ross morph carpets not disappearing --- .../gadget/gadgets/morph/MorphBobRoss.java | 166 +++++++----------- 1 file changed, 60 insertions(+), 106 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java index 7217d82c6..5b1984ba5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java @@ -5,11 +5,9 @@ import java.time.YearMonth; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.TimeUnit; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; @@ -21,12 +19,16 @@ import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; +import mineplex.core.treasure.event.TreasureFinishEvent; +import mineplex.core.treasure.event.TreasureStartEvent; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -48,17 +50,14 @@ import mineplex.core.utils.UtilGameProfile; */ public class MorphBobRoss extends MorphGadget { + /** Radius within which painting is not allowed near treasure chests */ + private static final int TREASURE_RADIUS = 4; + /** The inventory slot in which the paint brush is placed */ private static final int PAINT_BRUSH_SLOT = 2; - /** Max # of blocks that can be destroyed every quarter second, per player */ - private static final int DESTROY_LIMIT = 4; - - /** The # of seconds for which paint blocks exist */ - private static final int PAINT_SECONDS = 30; - - /** The # of minutes after which the code will stop trying to remove paint */ - private static final int PAINT_EXPIRE = 10; + /** The # of milliseconds for which paint blocks exist */ + private static final long PAINT_MILLISECONDS = 30000; /** Height above a player's location at which quotes are to be displayed */ private static final double QUOTE_HEIGHT = 2.25; @@ -196,10 +195,11 @@ public class MorphBobRoss extends MorphGadget /** Map of items in players' inventories */ private final Map _inventoryItems = new HashMap<>(); - private final Map _paintColors = new HashMap<>(); + /** Colors that are being used by painting players */ + private final Map _paintColors = new HashMap<>(); - /** Blocks that have been painted */ - private final List _paintBlocks = new ArrayList<>(); + /** Locations at which treasure is currently being opened */ + private final Map _openingTreasure = new HashMap<>(); private final HologramManager _holograms; @@ -277,6 +277,7 @@ public class MorphBobRoss extends MorphGadget { if (Recharge.Instance.use(event.getPlayer(), COLOR_KEY, COLOR_COOLDOWN, false, false)) { + changePaintColor(event.getPlayer(), true); } } @@ -284,6 +285,7 @@ public class MorphBobRoss extends MorphGadget { if (Recharge.Instance.use(event.getPlayer(), COLOR_KEY, COLOR_COOLDOWN, false, false)) { + changePaintColor(event.getPlayer(), false); } } @@ -296,40 +298,7 @@ public class MorphBobRoss extends MorphGadget @EventHandler public void updateEvent(UpdateEvent event) { - if (event.getType() == UpdateType.FASTER) // do paint removal - { - int limit = 0; - int offset = 0; - - // destroy paint blocks that are too old - while (!_paintBlocks.isEmpty() - && offset < _paintBlocks.size() - && _paintBlocks.get(offset).time < System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(PAINT_SECONDS) - && limit < DESTROY_LIMIT * getActive().size()) - { - Block block = _paintBlocks.get(offset).block; - - if (block.getType() == Material.CARPET) - { - _paintBlocks.remove(offset); - block.setType(Material.AIR); - limit++; - } - else - { - // stop trying to remove paint after a certain amount of time - if (_paintBlocks.get(offset).time > System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(PAINT_EXPIRE)) - { - _paintBlocks.remove(offset); - } - else - { - offset++; - } - } - } - } - else if (event.getType() == UpdateType.TICK) // do quote displaying + if (event.getType() == UpdateType.TICK) // do quote displaying { for (Player player : getActive()) { @@ -377,10 +346,12 @@ public class MorphBobRoss extends MorphGadget if (item.getType() == Material.STICK && player.getItemInHand().equals(item)) { + togglePainting(player); } else if (!player.getItemInHand().equals(item) && item.getType() != Material.STICK) { + togglePainting(player); } } @@ -401,6 +372,14 @@ public class MorphBobRoss extends MorphGadget return; } + for (Location location : _openingTreasure.values()) + { + if (location.toVector().isInSphere(event.getPlayer().getLocation().toVector(), TREASURE_RADIUS)) + { + return; + } + } + // check if the player has been issued a paintbrush if (_inventoryItems.containsKey(player.getUniqueId())) { @@ -419,28 +398,15 @@ public class MorphBobRoss extends MorphGadget // check that there is room to paint and that the block below is solid and not more paint. if ((block.isEmpty() || carpet) && UtilBlock.fullSolid(down) && !UtilBlock.bottomSlab(down)) { - int index; - PaintedBlock blk = new PaintedBlock(block); - - if (carpet) // if block is a carpet + // if the block is a non-paint carpet + if (carpet && !Manager.getBlockRestore().contains(block)) { - // remove old paint if it was painted - if ((index = _paintBlocks.indexOf(blk)) != -1) - { - _paintBlocks.remove(index); - } - else // if it's non-paint carpet - { - return; // don't paint - } + return; // don't paint } // mark block as painted - _paintBlocks.add(blk); - - // actually paint block - block.setType(Material.CARPET); - block.setData((byte) (15 - item.getData().getData())); + Manager.getBlockRestore().add(block, Material.CARPET.getId(), (byte) (15 - item.getData().getData()), + block.getTypeId(), block.getData(), PAINT_MILLISECONDS); } } } @@ -456,6 +422,7 @@ public class MorphBobRoss extends MorphGadget UUID uuid = event.getPlayer().getUniqueId(); _inventoryItems.remove(uuid); _paintColors.remove(uuid); + } } @@ -466,6 +433,7 @@ public class MorphBobRoss extends MorphGadget */ private void changePaintColor(Player player, boolean reverse) { + ItemStack item = _inventoryItems.remove(player.getUniqueId()); byte data = selectPaintColor(player, reverse); @@ -483,22 +451,27 @@ public class MorphBobRoss extends MorphGadget */ private void togglePainting(Player player) { + ItemStack item = _inventoryItems.remove(player.getUniqueId()); ItemStack newItem; if (item.getType() == Material.STICK) { - byte data = selectPaintColor(player, false); + byte data; + if (!_paintColors.containsKey(player.getUniqueId())) + { + data = selectPaintColor(player, false); + } + else + { + data = COLOR_ORDER[_paintColors.get(player.getUniqueId())]; + } + newItem = ItemStackFactory.Instance.CreateStack(Material.INK_SACK, data, 1, PAINT_COLORS[data] + " " + PAINT_BRUSHES[ThreadLocalRandom.current().nextInt(0, PAINT_BRUSHES.length)]); } else { - if (_paintColors.containsKey(player.getUniqueId())) - { - _paintColors.remove(player.getUniqueId()); - } - newItem = ItemStackFactory.Instance.CreateStack(Material.STICK, (byte) 0, 1, BRUSH_NAME); } @@ -521,11 +494,11 @@ public class MorphBobRoss extends MorphGadget { UUID uuid = player.getUniqueId(); - int value; + byte value; if (!_paintColors.containsKey(uuid)) { - value = ThreadLocalRandom.current().nextInt(0, 16); + value = (byte) ThreadLocalRandom.current().nextInt(0, 16); _paintColors.put(uuid, value); } else @@ -588,43 +561,24 @@ public class MorphBobRoss extends MorphGadget } /** - * Data class holding information on blocks which have been painted + * Disable painting in the area around treasure being opened. */ - private class PaintedBlock + @EventHandler(priority = EventPriority.LOW) + public void disableOnTreasureStart(TreasureStartEvent event) { - /** The time at which the block was painted */ - long time; + _openingTreasure.put(event.getPlayer().getUniqueId(), event.getPlayer().getLocation()); + Manager.getBlockRestore().restoreBlockAround(Material.CARPET, event.getPlayer().getLocation(), TREASURE_RADIUS); + } - /** The block which was painted */ - Block block; - - /** - * Construct a PaintedBlock - * - * @param block The block which has been painted. - */ - public PaintedBlock(Block block) + /** + * Enable painting in the area around treasure no longer being opened. + */ + @EventHandler(priority = EventPriority.HIGH) + public void enableOnTreasureFinish(TreasureFinishEvent event) + { + if (_openingTreasure.containsKey(event.getPlayer().getUniqueId())) { - this.block = block; - this.time = System.currentTimeMillis(); - } - - /** - * Overrides default equals behavior to have comparisons between - * multiple {@link PaintedBlock} objects match comparisons between - * their contained {@link PaintedBlock#block} fields. - */ - @Override - public boolean equals(Object o) - { - if (o instanceof PaintedBlock) - { - return block.equals(((PaintedBlock) o).block); - } - else - { - return super.equals(o); - } + _openingTreasure.remove(event.getPlayer().getUniqueId()); } } } From 9844ca338a5c4ba7572c1ac150a10fbde4fdc23b Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jun 2017 16:09:32 +0100 Subject: [PATCH 149/283] Complete Biff --- .../game/core/damage/CustomDamageEvent.java | 2 +- .../game/arcade/game/games/moba/Moba.java | 12 +- .../games/moba/boss/pumpkin/PumpkinBoss.java | 108 +++--------------- .../arcade/game/games/moba/buff/Buff.java | 51 +++++++-- .../game/games/moba/buff/BuffManager.java | 65 ++++++++++- .../moba/buff/buffs/BuffPumpkinKing.java | 94 ++++++++++++++- .../games/moba/buff/buffs/BuffRooting.java | 78 +++++++++++++ .../games/moba/kit/biff/SkillBiffDash.java | 16 ++- .../game/games/moba/kit/biff/SkillLeash.java | 5 +- .../games/moba/kit/biff/SkillWarHorse.java | 51 +++++++-- .../games/moba/kit/common/LeashedEntity.java | 13 ++- .../games/moba/kit/devon/SkillInfinity.java | 2 +- .../moba/kit/hattori/SkillNinjaBlade.java | 2 +- 13 files changed, 367 insertions(+), 132 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffRooting.java diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java index a4830cb56..6b4b9fde8 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java @@ -100,7 +100,7 @@ public class CustomDamageEvent extends Event implements Cancellable public void AddMod(String source, double mod) { - AddMod(source, new String(), mod, false); + AddMod(source, "", mod, false); } public void AddMod(String source, String reason, double mod, boolean useAttackName) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 393901b58..e1f9bcc3e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -15,6 +15,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.boss.BossManager; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; +import nautilus.game.arcade.game.games.moba.buff.BuffManager; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.general.ArrowKBManager; import nautilus.game.arcade.game.games.moba.general.EnderPearlManager; @@ -36,7 +37,6 @@ import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; -import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; @@ -53,7 +53,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.metadata.FixedMetadataValue; import java.util.ArrayList; import java.util.Arrays; @@ -84,6 +83,7 @@ public class Moba extends TeamGame private final TowerManager _tower; private final CapturePointManager _capturePoint; private final ArrowKBManager _arrowKb; + private final BuffManager _buffs; public Moba(ArcadeManager manager) { @@ -139,6 +139,9 @@ public class Moba extends TeamGame // Ender Pearls registerManager(new EnderPearlManager()); + // Buffs + _buffs = registerManager(new BuffManager()); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -664,4 +667,9 @@ public class Moba extends TeamGame { return _arrowKb; } + + public BuffManager getBuffManager() + { + return _buffs; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index ce850e828..e0ec6c8fb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -17,7 +17,6 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilVariant; -import mineplex.minecraft.game.core.condition.ConditionFactory; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; @@ -25,9 +24,10 @@ import nautilus.game.arcade.game.games.moba.ai.MobaAI; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import nautilus.game.arcade.game.games.moba.buff.BuffManager; +import nautilus.game.arcade.game.games.moba.buff.buffs.BuffPumpkinKing; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -35,7 +35,6 @@ import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; @@ -44,10 +43,8 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffectType; import java.util.HashSet; -import java.util.Iterator; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -62,9 +59,6 @@ public class PumpkinBoss extends MobaBoss private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN); private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD); private static final String DAMAGE_REASON = "Pumpkin King"; - private static final String CONDITION_REASON = DAMAGE_REASON + " Buff"; - private static final int CONDITION_LENGTH = 60; - private static final double CONDITION_DAMAGE_FACTOR = 1.5; private static final int DAMAGE_RADIUS = 2; private static final int DAMAGE_RANGE = 2; private static final int DAMAGE_DIRECT = 6; @@ -80,14 +74,12 @@ public class PumpkinBoss extends MobaBoss private MobaAI _ai; private boolean _initialSpawn; private final Set _changed; - private final Set _buffs; public PumpkinBoss(Moba host, Location location) { super(host, location, RESPAWN_TIME); _changed = new HashSet<>(); - _buffs = new HashSet<>(); } @Override @@ -223,8 +215,6 @@ public class PumpkinBoss extends MobaBoss return; } - giveBuffs(team); - _host.Announce(F.main("Game", team.GetFormattedName() + C.mBody + " killed the " + C.cDRedB + DAMAGE_REASON), false); UtilTextMiddle.display("", team.GetFormattedName() + C.cWhite + " killed the " + C.cDRedB + DAMAGE_REASON, 10, 40, 10); @@ -235,6 +225,18 @@ public class PumpkinBoss extends MobaBoss event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.EXPLODE, 1, 0.2F); UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, event.getEntity().getEyeLocation(), 1, 1, 1, 0.1F, 3, ViewDist.LONG); + + // Give the team members the buff + BuffManager buffManager = _host.getBuffManager(); + for (Player teamMember : team.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(teamMember)) + { + continue; + } + + buffManager.apply(new BuffPumpkinKing(_host, teamMember)); + } } @EventHandler(priority = EventPriority.HIGHEST) @@ -302,86 +304,4 @@ public class PumpkinBoss extends MobaBoss { _entity.setCustomName(MobaUtil.getHealthBar(_entity, 20)); } - - private void giveBuffs(GameTeam team) - { - ConditionFactory factory = _host.getArcadeManager().GetCondition().Factory(); - - for (Player player : team.GetPlayers(true)) - { - factory.Regen(CONDITION_REASON, player, null, CONDITION_LENGTH, 1, false, true, false); - UtilParticle.PlayParticleToAll(ParticleType.LAVA, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG); - player.playSound(player.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F); - player.sendMessage(F.main("Game", "You feel the power of the Pumpkin King flow through you. Your damage and regeneration are increased!")); - _buffs.add(player); - - sendFakeHelmet(player); - } - } - - @EventHandler - public void updateFakeHelmet(UpdateEvent event) - { - if (event.getType() != UpdateType.SLOW) - { - return; - } - - Iterator iterator = _buffs.iterator(); - - while (iterator.hasNext()) - { - Player player = iterator.next(); - - if (!player.hasPotionEffect(PotionEffectType.REGENERATION)) - { - if (player.isOnline()) - { - player.getInventory().setHelmet(player.getInventory().getHelmet()); - } - - iterator.remove(); - continue; - } - - sendFakeHelmet(player); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void damageIncrease(CustomDamageEvent event) - { - if (event.isCancelled()) - { - return; - } - - LivingEntity damagee = event.GetDamageeEntity(); - Player damager = event.GetDamagerPlayer(true); - - if (damager == null || !_buffs.contains(damager)) - { - return; - } - - UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, damagee.getLocation().add(0, 0.5, 0), 0.25F, 0.25F, 0.25F, 10, 1, ViewDist.NORMAL); - event.AddMod(CONDITION_REASON, CONDITION_DAMAGE_FACTOR); - } - - private void sendFakeHelmet(Player player) - { - // Magic number 4 means helmet - PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(HELMET)); - - for (Player other : Bukkit.getOnlinePlayers()) - { - // Don't send wearer their own data - if (other.equals(player)) - { - continue; - } - - UtilPlayer.sendPacket(other, packet); - } - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java index e986996c0..0e9949db2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java @@ -1,20 +1,57 @@ package nautilus.game.arcade.game.games.moba.buff; -import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.common.util.UtilServer; +import nautilus.game.arcade.game.games.moba.Moba; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; +import org.bukkit.event.Listener; -public abstract class Buff +public abstract class Buff implements Listener { - private final LivingEntity _entity; + protected final Moba _host; + protected final BuffManager _manager; + protected final T _entity; + private final long _duration; - public Buff(LivingEntity entity) + private long _start; + + public Buff(Moba host, T entity, long duration) { + _host = host; + _manager = host.getBuffManager(); _entity = entity; + _duration = duration; } - public abstract void onApply(Player player); + public abstract void onApply(); - public abstract void onUpdate(UpdateEvent event); + public abstract void onExpire(); + + final void apply() + { + _start = System.currentTimeMillis(); + UtilServer.RegisterEvents(this); + onApply(); + } + + final void expire() + { + UtilServer.Unregister(this); + onExpire(); + } + + public final T getEntity() + { + return _entity; + } + + public final long getDuration() + { + return _duration; + } + + public final long getStart() + { + return _start; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java index 23e59140c..341ce035c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java @@ -1,16 +1,71 @@ package nautilus.game.arcade.game.games.moba.buff; -import mineplex.minecraft.game.core.condition.Condition; -import nautilus.game.arcade.game.games.moba.Moba; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + public class BuffManager implements Listener { - private final Moba _host; + private final Map>> _buffs; - public BuffManager(Moba host) + public BuffManager() { - _host = host; + _buffs = new HashMap<>(); + } + + public void apply(Buff buff) + { + _buffs.putIfAbsent(buff.getEntity(), new ArrayList<>(3)); + _buffs.get(buff.getEntity()).add(buff); + buff.apply(); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + Iterator iterator = _buffs.keySet().iterator(); + + while (iterator.hasNext()) + { + LivingEntity entity = iterator.next(); + List> buffs = _buffs.get(entity); + + if (entity.isDead() || !entity.isValid() || UtilPlayer.isSpectator(entity) || entity instanceof Player && !((Player) entity).isOnline()) + { + buffs.forEach(Buff::expire); + iterator.remove(); + continue; + } + + Iterator> buffIterator = buffs.iterator(); + + while (buffIterator.hasNext()) + { + Buff buff = buffIterator.next(); + + if (UtilTime.elapsed(buff.getStart(), buff.getDuration())) + { + buff.expire(); + buffIterator.remove(); + } + } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java index d72217b09..13868ec67 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java @@ -1,20 +1,104 @@ package nautilus.game.arcade.game.games.moba.buff.buffs; +import mineplex.core.common.util.F; +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.UtilPlayer; +import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.buff.Buff; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; -public class BuffPumpkinKing extends Buff +import java.util.concurrent.TimeUnit; + +public class BuffPumpkinKing extends Buff { - public BuffPumpkinKing(LivingEntity entity) + private static final long DURATION = TimeUnit.MINUTES.toMillis(1); + private static final String DAMAGE_REASON = "Pumpkin King Buff"; + private static final double DAMAGE_FACTOR = 1.5; + private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN); + + public BuffPumpkinKing(Moba host, Player entity) { - super(entity); + super(host, entity, DURATION); } @Override - public void onUpdate(UpdateEvent event) + public void onApply() { - + _entity.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60 * 20, 1)); + UtilParticle.PlayParticleToAll(ParticleType.LAVA, _entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG); + _entity.playSound(_entity.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F); + _entity.sendMessage(F.main("Game", "You feel the power of the Pumpkin King flow through you. Your damage and regeneration are increased!")); } + + @Override + public void onExpire() + { + sendFakeHelmet(_entity, _entity.getInventory().getHelmet()); + } + + @EventHandler + public void updateFakeHelmet(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + { + return; + } + + sendFakeHelmet(_entity, HELMET); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void damageIncrease(CustomDamageEvent event) + { + if (event.isCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + Player damager = event.GetDamagerPlayer(true); + + if (damager == null || !damager.equals(_entity)) + { + return; + } + + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, damagee.getLocation().add(0, 0.5, 0), 0.25F, 0.25F, 0.25F, 0.1F, 10, ViewDist.NORMAL); + event.AddMod(DAMAGE_REASON, DAMAGE_FACTOR); + } + + private void sendFakeHelmet(Player player, ItemStack itemStack) + { + // Magic number 4 means helmet + PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(itemStack)); + + for (Player other : Bukkit.getOnlinePlayers()) + { + // Don't send wearer their own data + if (other.equals(player)) + { + continue; + } + + UtilPlayer.sendPacket(other, packet); + } + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffRooting.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffRooting.java new file mode 100644 index 000000000..8c4e862dc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffRooting.java @@ -0,0 +1,78 @@ +package nautilus.game.arcade.game.games.moba.buff.buffs; + +import mineplex.core.common.events.EntityVelocityChangeEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +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.UtilTextMiddle; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.buff.Buff; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerMoveEvent; + +public class BuffRooting extends Buff +{ + + public BuffRooting(Moba host, Player entity, long duration) + { + super(host, entity, duration); + } + + @Override + public void onApply() + { + UtilAction.zeroVelocity(_entity); + UtilTextMiddle.display("", C.cRed + "Rooted", 10, 20, 10, (Player) _entity); + } + + @Override + public void onExpire() + { + + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, _entity.getLocation().add(0, 0.5, 0), 0.5F, 0.2F, 0.5F, 0.1F, 5, ViewDist.LONG); + } + + @EventHandler + public void velocityApply(EntityVelocityChangeEvent event) + { + if (event.getEntity().equals(_entity)) + { + event.setCancelled(true); + } + } + + @EventHandler + public void move(PlayerMoveEvent event) + { + if (!event.getPlayer().equals(_entity)) + { + return; + } + + Location from = event.getFrom(); + Location to = event.getTo(); + + if (from.getX() == to.getX() && from.getZ() == to.getZ()) + { + return; + } + + event.setTo(from); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java index 2bd3d292d..6fa9c4ac4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.kit.biff; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle; @@ -15,6 +16,8 @@ import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -114,11 +117,22 @@ public class SkillBiffDash extends HeroSkill } // They have just activated it - if (!UtilTime.elapsed(start, 1000) || !UtilEnt.isGrounded(player)) + if (!UtilTime.elapsed(start, 1000) || player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) { continue; } + for (Block block : UtilBlock.getBlocksInRadius(player.getLocation(), 5)) + { + if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > 0.5) + { + continue; + } + + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); + } + + for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) { if (isTeamDamage(player, entity)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java index 65da2dceb..a89c426be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.biff; +import mineplex.core.common.events.EntityVelocityChangeEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilMath; @@ -50,7 +51,7 @@ public class SkillLeash extends HeroSkill return; } - List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 5); + List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 4); nearbyPlayers.removeIf(other -> isTeamDamage(other, player)); if (nearbyPlayers.isEmpty()) @@ -69,7 +70,7 @@ public class SkillLeash extends HeroSkill nearby.setShouldBreakLeash(false); nearby.sendMessage(F.main("Game", F.name(nearby.getName()) + " leashed you.")); builder.append(F.name(player.getName())).append(", "); - Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 0, false, true, true, false); + Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 1, false, true, true, false); leashedEntities.add(new LeashedEntity(Manager, nearby, player)); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index d4a141fca..60e552d65 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -1,22 +1,29 @@ package nautilus.game.arcade.game.games.moba.kit.biff; -import mineplex.core.Managers; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; +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.UtilPlayer; import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.buff.BuffManager; +import nautilus.game.arcade.game.games.moba.buff.buffs.BuffRooting; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.game.games.moba.util.MobaUtil; -import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Horse; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; import java.util.HashSet; import java.util.Iterator; @@ -32,6 +39,7 @@ public class SkillWarHorse extends HeroSkill private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); private static final ItemStack HORSE_ARMOUR = new ItemStack(Material.IRON_BARDING); + private static final ItemStack SADDLE = new ItemStack(Material.SADDLE); private final Set _data = new HashSet<>(); @@ -65,10 +73,16 @@ public class SkillWarHorse extends HeroSkill Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); - horse.setJumpStrength(0); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, horse.getLocation().add(0, 1, 0), 1, 1, 1, 0.1F, 50, ViewDist.LONG); + horse.getWorld().strikeLightningEffect(horse.getLocation()); + horse.getWorld().playSound(horse.getLocation(), Sound.HORSE_DEATH, 1, 1.1F); + horse.setHealth(20); + horse.setMaxHealth(horse.getHealth()); + horse.setJumpStrength(1); horse.setMaxDomestication(1); horse.setDomestication(horse.getMaxDomestication()); horse.getInventory().setArmor(HORSE_ARMOUR); + horse.getInventory().setSaddle(SADDLE); horse.setOwner(player); horse.setPassenger(player); MobaUtil.setTeamEntity(horse, Manager.GetGame().GetTeam(player)); @@ -78,12 +92,13 @@ public class SkillWarHorse extends HeroSkill _data.add(new WarHorseData(player, horse)); broadcast(player); + useActiveSkill(player, 6000); } @EventHandler public void update(UpdateEvent event) { - if (event.getType() != UpdateType.TICK) + if (event.getType() != UpdateType.FASTER) { return; } @@ -93,18 +108,32 @@ public class SkillWarHorse extends HeroSkill while (iterator.hasNext()) { WarHorseData data = iterator.next(); + Player owner = data.Owner; + Horse horse = data.Horse; - if (UtilTime.elapsed(data.Start, 6000)) + if (UtilTime.elapsed(data.Start, 6000) || horse.isDead() || !horse.isValid()) { - data.Horse.remove(); + horse.getWorld().playSound(horse.getLocation(), Sound.HORSE_BREATHE, 1, 1.1F); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, horse.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 50, ViewDist.LONG); + horse.remove(); iterator.remove(); } else { - Player player = data.Owner; - Location target = player.getLocation().getDirection().multiply(3).toLocation(player.getWorld()); + Moba game = (Moba) Manager.GetGame(); + BuffManager buffManager = game.getBuffManager(); - UtilEnt.CreatureMoveFast(data.Horse, target, 3F); + for (Player player : UtilPlayer.getNearby(horse.getLocation(), 5)) + { + if (isTeamDamage(owner, player) || !Recharge.Instance.use(player, GetName() + "Rooting", 2000, false, false)) + { + continue; + } + + owner.sendMessage(F.main("Game", "You hit " + F.name(player.getName()) + ".")); + Manager.GetDamage().NewDamageEvent(player, owner, null, DamageCause.CUSTOM, 10, false, true, false, UtilEnt.getName(owner), GetName()); + buffManager.apply(new BuffRooting(game, player, 1000)); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java index 6c3bfb0e6..b0100b73d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java @@ -13,6 +13,7 @@ import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -32,7 +33,6 @@ public class LeashedEntity implements Listener UtilEnt.vegetate(_fakeLeash); UtilEnt.silence(_fakeLeash, true); _fakeLeash.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false)); - _fakeLeash.setBaby(true); _fakeLeash.setLeashHolder(leasher); manager.GetGame().CreatureAllowOverride = false; @@ -56,7 +56,7 @@ public class LeashedEntity implements Listener } Location location = _host.getLocation(); - ((CraftLivingEntity) _fakeLeash).getHandle().setPosition(location.getX(), location.getY() + 0.8, location.getZ()); + ((CraftLivingEntity) _fakeLeash).getHandle().setPosition(location.getX(), location.getY(), location.getZ()); } @EventHandler(priority = EventPriority.LOWEST) @@ -69,6 +69,15 @@ public class LeashedEntity implements Listener } } + @EventHandler + public void fakeLeashFire(EntityCombustEvent event) + { + if (event.getEntity().equals(_fakeLeash)) + { + event.setCancelled(true); + } + } + public LivingEntity getHost() { return _host; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 24f975e58..6097e9a28 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -50,7 +50,7 @@ public class SkillInfinity extends HeroSkill @EventHandler public void interact(PlayerInteractEvent event) { - if (!isSkillItem(event)) + if (!isSkillItem(event) || _active.contains(event.getPlayer())) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index 4f775fa8d..d0f8bf1f4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -97,7 +97,7 @@ public class SkillNinjaBlade extends HeroSkill int i = 0; for (ItemStack itemStack : inventory.getContents()) { - if (!itemStack.equals(ACTIVE_ITEM) && UtilItem.isSword(itemStack)) + if (itemStack != null && !itemStack.equals(ACTIVE_ITEM) && UtilItem.isSword(itemStack)) { inventory.setItem(i, null); } From 4fb4c2c865cdb3ee92026d79707f473c20e783fe Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jun 2017 16:11:25 +0100 Subject: [PATCH 150/283] Fix merge imports --- .../src/mineplex/gemhunters/loot/LootModule.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java index 3b18690ce..9aa42e3ac 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java @@ -41,10 +41,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -<<<<<<< HEAD -======= import org.bukkit.event.EventPriority; ->>>>>>> refs/remotes/origin/develop import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; From e94ab9598a944370831ec47880cd1981848e7fd0 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jun 2017 22:43:50 +0100 Subject: [PATCH 151/283] New Heroes --- .../game/arcade/game/games/moba/Moba.java | 4 + .../games/moba/boss/wither/WitherBoss.java | 2 +- .../game/games/moba/buff/BuffManager.java | 5 + .../arcade/game/games/moba/kit/HeroKit.java | 11 +- .../arcade/game/games/moba/kit/HeroSkill.java | 2 +- .../game/games/moba/kit/anath/HeroAnath.java | 8 +- .../moba/kit/anath/SkillFireProjectile.java | 56 +++++- .../games/moba/kit/anath/SkillMeteor.java | 4 +- .../game/games/moba/kit/biff/HeroBiff.java | 10 +- .../game/games/moba/kit/biff/SkillLeash.java | 14 +- .../games/moba/kit/biff/SkillWarHorse.java | 4 +- .../game/games/moba/kit/bob/HeroBob.java | 8 +- .../game/games/moba/kit/dana/HeroDana.java | 10 +- .../game/games/moba/kit/devon/HeroDevon.java | 9 +- .../games/moba/kit/hattori/HeroHattori.java | 11 +- .../game/games/moba/kit/hp/HPManager.java | 17 +- .../games/moba/kit/hp/MobaHPRegenEvent.java | 16 +- .../games/moba/kit/larissa/HeroLarissa.java | 35 ++++ .../games/moba/kit/larissa/SkillAOEHeal.java | 182 ++++++++++++++++++ .../moba/kit/larissa/SkillAquaCannon.java | 76 ++++++++ .../moba/kit/larissa/SkillStormHeal.java | 133 +++++++++++++ .../moba/kit/larissa/SkillWaterDash.java | 57 ++++++ .../arcade/game/games/moba/shop/MobaShop.java | 58 +----- .../moba/structure/tower/TowerManager.java | 24 +++ 24 files changed, 629 insertions(+), 127 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index e1f9bcc3e..aade9ac0d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -30,6 +30,7 @@ import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana; import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.kit.hp.HPManager; +import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa; import nautilus.game.arcade.game.games.moba.minion.MinionManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; @@ -95,9 +96,11 @@ public class Moba extends TeamGame new HeroAnath(Manager), new HeroDana(Manager), new HeroBiff(Manager), + new HeroLarissa(Manager), new HeroBob(Manager) }; + AllowParticles = false; DontAllowOverfill = true; PrepareAutoAnnounce = false; PrepareFreeze = false; @@ -107,6 +110,7 @@ public class Moba extends TeamGame HungerSet = 20; DamageFall = false; + manager.getCosmeticManager().setHideParticles(true); manager.GetCreature().SetDisableCustomDrops(true); // Instantiate managers diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 779bdf9f8..41b4a242c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -35,7 +35,7 @@ public class WitherBoss extends MobaBoss private static final String NAME = "Wither Boss"; private static final float SPEED_TARGET = 4F; private static final float SPEED_HOME = 6F; - private static final int INITIAL_HEALTH = 500; + private static final int INITIAL_HEALTH = 125; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private GameTeam _team; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java index 341ce035c..25ba3d101 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java @@ -27,6 +27,11 @@ public class BuffManager implements Listener public void apply(Buff buff) { + if (UtilPlayer.isSpectator(buff.getEntity())) + { + return; + } + _buffs.putIfAbsent(buff.getEntity(), new ArrayList<>(3)); _buffs.get(buff.getEntity()).add(buff); buff.apply(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index ab3f56ad7..efd7abfe5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -41,12 +41,16 @@ public class HeroKit extends Kit .setTitle(C.cGreenB + "Recall to your Base") .addLore("Clicking this item will teleport you back to your", "base after " + F.time("5") + " seconds.", "Taking damage or moving will cancel", "your teleport.") .build(); + private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT) + .setTitle(C.cGold + "Open Gold Upgrades") + .addLore("Click to open the Gold Upgrades", "shop while you are respawning.") + .build(); private boolean _visible = true; - public HeroKit(ArcadeManager manager, String name, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand, MobaRole role) + public HeroKit(ArcadeManager manager, String name, Perk[] kitPerks, MobaRole role) { - super(manager, name, KitAvailability.Free, kitDesc, kitPerks, null, itemInHand); + super(manager, name, KitAvailability.Free, new String[0], kitPerks, null, null); _role = role; _maxAmmo = 64; @@ -163,7 +167,8 @@ public class HeroKit extends Kit // Give standard items inventory.setItem(AMMO_SLOT, _ammo); - inventory.setItem(RECALL_SLOT, RECALL_ITEM); + //inventory.setItem(RECALL_SLOT, RECALL_ITEM); + inventory.setItem(RECALL_SLOT, SHOP_ITEM); Moba game = (Moba) Manager.GetGame(); List items = game.getShop().getOwnedItems(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 53e5cf73b..6239445ea 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -286,7 +286,7 @@ public class HeroSkill extends Perk for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!hasPerk(player) || !_lastSkill.containsKey(player.getUniqueId())) + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !_lastSkill.containsKey(player.getUniqueId())) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java index b7f805b65..59e33556d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java @@ -12,10 +12,6 @@ import org.bukkit.inventory.ItemStack; public class HeroAnath extends HeroKit { - private static final String[] DESCRIPTION = { - "Something something" - }; - private static final Perk[] PERKS = { new SkillFireProjectile(0), new SkillBurnBeam(1), @@ -23,15 +19,13 @@ public class HeroAnath extends HeroKit new SkillMeteor(3) }; - private static final ItemStack IN_HAND = new ItemStack(Material.BLAZE_ROD); - private static final ItemStack AMMO = new ItemBuilder(Material.BLAZE_POWDER) .setTitle(C.cYellowB + "Embers") .build(); public HeroAnath(ArcadeManager manager) { - super(manager, "Anath", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); + super(manager, "Anath", PERKS, MobaRole.MAGE); setAmmo(AMMO, 1000); setMaxAmmo(4); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 74591c991..4d8d69b35 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -1,17 +1,25 @@ package nautilus.game.arcade.game.games.moba.kit.anath; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Material; -import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.SmallFireball; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import java.util.ArrayList; +import java.util.List; + public class SkillFireProjectile extends HeroSkill { @@ -20,9 +28,10 @@ public class SkillFireProjectile extends HeroSkill "Any enemies it collides with take damage and are set on fire." }; private static final int DAMAGE = 5; - private static final ItemStack SKILL_ITEM = new ItemStack(Material.BLAZE_ROD); + private final List _fireballs = new ArrayList<>(); + public SkillFireProjectile(int slot) { super("Flame Wand", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); @@ -44,10 +53,43 @@ public class SkillFireProjectile extends HeroSkill } Vector direction = player.getLocation().getDirection().multiply(1.25); - Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), _kit.getAmmo()); - item.setVelocity(direction); - ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, item, DAMAGE); - Manager.GetFire().Add(item, player, 3, 0, 1, DAMAGE, MobaConstants.BASIC_ATTACK, false); + SmallFireball fireball = player.getWorld().spawn(player.getEyeLocation().add(direction), SmallFireball.class); + fireball.setShooter(player); + fireball.setVelocity(direction); + _fireballs.add(fireball); + + ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, fireball, DAMAGE); + } + + @EventHandler + public void fireballPrevention(CustomDamageEvent event) + { + if (event.GetProjectile() != null && _fireballs.contains(event.GetProjectile())) + { + event.SetCancelled("Fireball Damage"); + } + } + + @EventHandler + public void projectileHit(ProjectileHitEvent event) + { + Projectile entity = event.getEntity(); + + if (!_fireballs.contains(entity)) + { + return; + } + + Player player = (Player) entity.getShooter(); + + for (LivingEntity nearby : UtilEnt.getInRadius(entity.getLocation(), 1.5).keySet()) + { + nearby.setFireTicks(40); + Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, DAMAGE, true, true, false, player.getName(), GetName()); + } + + _fireballs.remove(entity); + entity.remove(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index d91b18850..2b7cd0523 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -9,6 +9,7 @@ import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.kit.perks.data.MeteorShowerData; import org.bukkit.Location; @@ -99,6 +100,7 @@ public class SkillMeteor extends HeroSkill implements IThrown for (MeteorShowerData data : _data) { Location location = data.Target; + GameTeam team = Manager.GetGame().GetTeam(data.Shooter); for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 100) { @@ -107,7 +109,7 @@ public class SkillMeteor extends HeroSkill implements IThrown location.add(x, 0.25, z); - UtilParticle.PlayParticleToAll(ParticleType.FLAME, location, 0, 0, 0, 0.001F, 1, ViewDist.LONG); + UtilParticle.playColoredParticleToAll(team.GetColorBase(), ParticleType.RED_DUST, location, 1, ViewDist.LONG); location.subtract(x, 0.25, z); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java index fe65df976..78314c186 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java @@ -5,16 +5,10 @@ import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; import nautilus.game.arcade.kit.Perk; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; public class HeroBiff extends HeroKit { - private static final String[] DESCRIPTION = { - "Something something" - }; - private static final Perk[] PERKS = { new SkillSword(0), new SkillLeash(1), @@ -22,10 +16,8 @@ public class HeroBiff extends HeroKit new SkillWarHorse(3) }; - private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); - public HeroBiff(ArcadeManager manager) { - super(manager, "Biff", DESCRIPTION, PERKS, IN_HAND, MobaRole.WARRIOR); + super(manager, "Biff", PERKS, MobaRole.WARRIOR); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java index a89c426be..5c9e28f4d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.kit.biff; import mineplex.core.common.events.EntityVelocityChangeEvent; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -10,6 +11,7 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.kit.common.LeashedEntity; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; @@ -51,11 +53,12 @@ public class SkillLeash extends HeroSkill return; } - List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 4); + List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 8); nearbyPlayers.removeIf(other -> isTeamDamage(other, player)); if (nearbyPlayers.isEmpty()) { + player.sendMessage(F.main("Game", "There was no one in range to leash.")); return; } @@ -68,14 +71,17 @@ public class SkillLeash extends HeroSkill nearby.setLeashHolder(player); nearby.setPullWhileLeashed(false); nearby.setShouldBreakLeash(false); - nearby.sendMessage(F.main("Game", F.name(nearby.getName()) + " leashed you.")); - builder.append(F.name(player.getName())).append(", "); + nearby.sendMessage(F.main("Game", F.name(player.getName()) + " leashed you.")); + nearby.playSound(nearby.getLocation(), Sound.DOOR_CLOSE, 1, 1); + builder.append(F.name(nearby.getName())).append(", "); + UtilAction.zeroVelocity(nearby); Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 1, false, true, true, false); leashedEntities.add(new LeashedEntity(Manager, nearby, player)); } _leashed.put(player, leashedEntities); + player.playSound(player.getLocation(), Sound.DOOR_CLOSE, 1, 1); player.sendMessage(builder.toString()); useActiveSkill(() -> @@ -104,7 +110,7 @@ public class SkillLeash extends HeroSkill { LeashedEntity leashed = iterator.next(); - if (UtilMath.offsetSquared(entry.getKey(), leashed.getHost()) < 25) + if (!UtilPlayer.isSpectator(entry.getKey()) && UtilMath.offsetSquared(entry.getKey(), leashed.getHost()) < 100) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index 60e552d65..27784b829 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -92,7 +92,7 @@ public class SkillWarHorse extends HeroSkill _data.add(new WarHorseData(player, horse)); broadcast(player); - useActiveSkill(player, 6000); + useActiveSkill(player, 5500); } @EventHandler @@ -111,7 +111,7 @@ public class SkillWarHorse extends HeroSkill Player owner = data.Owner; Horse horse = data.Horse; - if (UtilTime.elapsed(data.Start, 6000) || horse.isDead() || !horse.isValid()) + if (UtilTime.elapsed(data.Start, 6000) || UtilPlayer.isSpectator(owner) || horse.isDead() || !horse.isValid()) { horse.getWorld().playSound(horse.getLocation(), Sound.HORSE_BREATHE, 1, 1.1F); UtilParticle.PlayParticleToAll(ParticleType.CLOUD, horse.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 50, ViewDist.LONG); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java index 89b56fa7f..8c851c98b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java @@ -12,10 +12,6 @@ import org.bukkit.inventory.ItemStack; public class HeroBob extends HeroKit { - private static final String[] DESCRIPTION = { - "Something something" - }; - private static final Perk[] PERKS = { new SkillPaint(0), new SkillHappyTrees(1), @@ -23,15 +19,13 @@ public class HeroBob extends HeroKit new SkillBuildPainting(3) }; - private static final ItemStack IN_HAND = new ItemStack(Material.PAINTING); - private static final ItemStack AMMO = new ItemBuilder(Material.SNOW_BALL) .setTitle(C.cYellowB + "Titanium Hwhite") .build(); public HeroBob(ArcadeManager manager) { - super(manager, "Bob Ross", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); + super(manager, "Bob Ross", PERKS, MobaRole.MAGE); setAmmo(AMMO, 500); setMaxAmmo(8); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java index ce24c96b5..e6e0f1e8b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java @@ -5,16 +5,10 @@ import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; import nautilus.game.arcade.kit.Perk; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; public class HeroDana extends HeroKit { - private static final String[] DESCRIPTION = { - "Something something" - }; - private static final Perk[] PERKS = { new SkillSword(0), new SkillPulseHeal(1), @@ -22,10 +16,8 @@ public class HeroDana extends HeroKit new SkillRally(3), }; - private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); - public HeroDana(ArcadeManager manager) { - super(manager, "Dana", DESCRIPTION, PERKS, IN_HAND, MobaRole.WARRIOR); + super(manager, "Dana", PERKS, MobaRole.WARRIOR); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java index f80d6c6e2..c50db2648 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -8,16 +8,11 @@ import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.common.SkillBow; import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; -import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; public class HeroDevon extends HeroKit { - private static final String[] DESCRIPTION = { - "Something something" - }; - private static final Perk[] PERKS = { new SkillBow(0), new SkillTNTArrows(1), @@ -25,8 +20,6 @@ public class HeroDevon extends HeroKit new SkillInfinity(3) }; - private static final ItemStack IN_HAND = new ItemStack(Material.BOW); - private static final ItemStack AMMO = new ItemBuilder(Material.ARROW) .setTitle(C.cYellowB + "Hunting Arrow") .setUnbreakable(true) @@ -34,7 +27,7 @@ public class HeroDevon extends HeroKit public HeroDevon(ArcadeManager manager) { - super(manager, "Devon", DESCRIPTION, PERKS, IN_HAND, MobaRole.HUNTER); + super(manager, "Devon", PERKS, MobaRole.HUNTER); setAmmo(AMMO, 3000); setMaxAmmo(3); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java index d9371bad2..284a78e01 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java @@ -6,16 +6,10 @@ import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.PerkDoubleJump; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; public class HeroHattori extends HeroKit { - private static final String[] DESCRIPTION = { - "Something something" - }; - private static final Perk[] PERKS = { new PerkDoubleJump("Double Jump", 1, 1, true, 3000, true), new SkillSword(0), @@ -24,11 +18,8 @@ public class HeroHattori extends HeroKit new SkillNinjaBlade(3) }; - private static final ItemStack IN_HAND = new ItemStack(Material.NETHER_STAR); - - public HeroHattori(ArcadeManager manager) { - super(manager, "Hattori", DESCRIPTION, PERKS, IN_HAND, MobaRole.ASSASSIN); + super(manager, "Hattori", PERKS, MobaRole.ASSASSIN); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java index 298c46afa..a23c4d4ac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java @@ -10,12 +10,13 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.potion.PotionEffectType; public class HPManager implements Listener { // Health per 5 seconds. - private static final double HP5 = 0.33; + private static final double HP5 = 0.66; private final Moba _host; @@ -42,6 +43,11 @@ public class HPManager implements Listener MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5); UtilServer.CallEvent(regenEvent); + if (regenEvent.isCancelled()) + { + continue; + } + player.setHealth(Math.min(player.getMaxHealth(), player.getHealth() + regenEvent.getHealth())); } } @@ -54,4 +60,13 @@ public class HPManager implements Listener event.setCancelled(true); } } + + @EventHandler + public void preventRegenerationWither(MobaHPRegenEvent event) + { + if (event.getPlayer().hasPotionEffect(PotionEffectType.WITHER)) + { + event.setCancelled(true); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java index 770d2acfc..793c170ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java @@ -1,16 +1,18 @@ package nautilus.game.arcade.game.games.moba.kit.hp; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; -public class MobaHPRegenEvent extends PlayerEvent +public class MobaHPRegenEvent extends PlayerEvent implements Cancellable { private static final HandlerList _handlers = new HandlerList(); private final double _initialHealth; private double _health; + private boolean _cancel; public MobaHPRegenEvent(Player who, double health) { @@ -35,6 +37,18 @@ public class MobaHPRegenEvent extends PlayerEvent return _health; } + @Override + public boolean isCancelled() + { + return _cancel; + } + + @Override + public void setCancelled(boolean b) + { + _cancel = b; + } + public static HandlerList getHandlerList() { return _handlers; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java new file mode 100644 index 000000000..f208d672b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java @@ -0,0 +1,35 @@ +package nautilus.game.arcade.game.games.moba.kit.larissa; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroLarissa extends HeroKit +{ + + private static final Perk[] PERKS = { + new SkillAquaCannon(0), + new SkillAOEHeal(1), + new SkillWaterDash(2), + new SkillStormHeal(3) + }; + + private static final ItemStack AMMO = new ItemBuilder(Material.INK_SACK, (byte) 4) + .setTitle(C.cYellowB + "Water Stone") + .setUnbreakable(true) + .build(); + + public HeroLarissa(ArcadeManager manager) + { + super(manager, "Larissa", PERKS, MobaRole.MAGE); + + setAmmo(AMMO, 3000); + setMaxAmmo(5); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java new file mode 100644 index 000000000..9b7ff9c76 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java @@ -0,0 +1,182 @@ +package nautilus.game.arcade.game.games.moba.kit.larissa; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilFirework; +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.UtilTime; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaParticles; +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +public class SkillAOEHeal extends HeroSkill implements IThrown +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + private static final long DURATION = TimeUnit.SECONDS.toMillis(6); + private static final int RADIUS = 3; + private static final int HEALTH_PER_SECOND = 4; + private static final int DAMAGE_PER_SECOND = 2; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.WATER_BUCKET); + private static final ItemStack THROWN_ITEM = new ItemStack(Material.WATER_BUCKET); + + private final Set _data = new HashSet<>(); + + public SkillAOEHeal(int slot) + { + super("Dancing Fountain", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(14000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + Vector direction = player.getLocation().getDirection(); + Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), THROWN_ITEM); + item.setVelocity(direction); + + useSkill(player); + Manager.GetProjectile().AddThrow(item, player, this, 1000, true, true, true, false, 1F); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + deployAoe((Player) data.getThrower(), data.getThrown(), data.getThrown().getLocation()); + } + + @Override + public void Idle(ProjectileUser data) + { + } + + @Override + public void Expire(ProjectileUser data) + { + deployAoe((Player) data.getThrower(), data.getThrown(), data.getThrown().getLocation()); + } + + @EventHandler + public void updateAOE(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator iterator = _data.iterator(); + + while (iterator.hasNext()) + { + AOEHealData data = iterator.next(); + Player owner = data.Owner; + GameTeam team = Manager.GetGame().GetTeam(owner); + + if (UtilTime.elapsed(data.Start, DURATION)) + { + iterator.remove(); + } + else if (UtilTime.elapsed(data.LastHeal, 1000)) + { + data.LastHeal = System.currentTimeMillis(); + + for (LivingEntity entity : UtilEnt.getInRadius(data.Center, RADIUS).keySet()) + { + if (isTeamDamage(entity, owner)) + { + MobaParticles.healing(entity, HEALTH_PER_SECOND); + entity.setHealth(Math.min(entity.getHealth() + HEALTH_PER_SECOND, entity.getMaxHealth())); + } + else + { + Manager.GetDamage().NewDamageEvent(entity, owner, null, DamageCause.CUSTOM, DAMAGE_PER_SECOND, true, true, false, owner.getName(), GetName()); + } + } + } + + UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, data.Center, RADIUS - 0.5F, 0.2F, RADIUS - 0.5F, 0.1F, 5, ViewDist.LONG); + + for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 15) + { + double x = RADIUS * Math.cos(theta); + double z = RADIUS * Math.sin(theta); + + data.Center.add(x, 0, z); + + UtilParticle.playColoredParticleToAll(team.GetColorBase(), ParticleType.RED_DUST, data.Center, 1, ViewDist.LONG); + + data.Center.subtract(x, 0, z); + } + } + } + + private void deployAoe(Player thrower, Entity item, Location location) + { + GameTeam team = Manager.GetGame().GetTeam(thrower); + + if (team == null) + { + return; + } + + UtilFirework.playFirework(location, FireworkEffect.builder().with(Type.BURST).withColor(team.GetColorBase()).withFade(Color.WHITE).withFlicker().build()); + thrower.getWorld().playSound(location, Sound.SPLASH2, 1, 1); + item.remove(); + _data.add(new AOEHealData(thrower, location)); + } + + private class AOEHealData + { + + Player Owner; + Location Center; + long Start; + long LastHeal; + + AOEHealData(Player owner, Location center) + { + Owner = owner; + Center = center; + Start = System.currentTimeMillis(); + LastHeal = Start; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java new file mode 100644 index 000000000..4e1a2bdca --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java @@ -0,0 +1,76 @@ +package nautilus.game.arcade.game.games.moba.kit.larissa; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +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.UtilServer; +import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +public class SkillAquaCannon extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + private static final int DAMAGE = 6; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.DIAMOND_HOE); + + public SkillAquaCannon(int slot) + { + super("Aqua Cannon", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + if (!_kit.useAmmo(player, 1)) + { + return; + } + + TowerManager towerManager = ((Moba) Manager.GetGame()).getTowerManager(); + Vector direction = player.getLocation().getDirection(); + + LineParticle lineParticle = new LineParticle(player.getLocation().add(0, 1.7, 0), direction, 0.2, 10, ParticleType.DRIP_WATER, UtilServer.getPlayers()); + + while (!lineParticle.update() && towerManager.damageTowerAt(lineParticle.getLastLocation(), player, DAMAGE) == null) + { + for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 2).keySet()) + { + if (isTeamDamage(entity, player)) + { + continue; + } + + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, DAMAGE, true, false, false, player.getName(), GetName()); + break; + } + } + + player.getWorld().playSound(lineParticle.getLastLocation(), Sound.BLAZE_HIT, 1, 1.4F); + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, lineParticle.getLastLocation(), 0, 0, 0, 0.2F, 10, ViewDist.LONG); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java new file mode 100644 index 000000000..34adb0612 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java @@ -0,0 +1,133 @@ +package nautilus.game.arcade.game.games.moba.kit.larissa; + +import mineplex.core.Managers; +import mineplex.core.common.util.UtilEvent.ActionType; +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.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +public class SkillStormHeal extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + private static final long DURATION = TimeUnit.SECONDS.toMillis(7); + private static final int HEALTH_PER_SECOND = 2; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + + private final Map _active = new HashMap<>(); + + public SkillStormHeal(int slot) + { + super("Storm's Blessing", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(60000); + setDropItemActivate(true); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event) || _active.containsKey(event.getPlayer())) + { + return; + } + + Player player = event.getPlayer(); + + for (Player teamMember : Manager.GetGame().GetTeam(player).GetPlayers(true)) + { + teamMember.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, (int) (DURATION / 50D), 0)); + } + + _active.put(player, System.currentTimeMillis()); + broadcast(player); + useActiveSkill(player, DURATION - 500); + } + + @EventHandler + public void updateHeal(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + _active.forEach((player, start) -> + { + GameTeam team = Manager.GetGame().GetTeam(player); + + if (team == null) + { + return; + } + + for (Player teamMember : team.GetPlayers(true)) + { + teamMember.setHealth(Math.min(teamMember.getHealth() + HEALTH_PER_SECOND, teamMember.getMaxHealth())); + } + }); + } + + @EventHandler + public void updateParticles(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + Iterator iterator = _active.keySet().iterator(); + + while (iterator.hasNext()) + { + Player player = iterator.next(); + + if (UtilTime.elapsed(_active.get(player), DURATION)) + { + iterator.remove(); + } + + GameTeam team = Manager.GetGame().GetTeam(player); + + if (team == null) + { + return; + } + + for (Player teamMember : team.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(teamMember)) + { + continue; + } + + Location location = teamMember.getLocation().add(0, 3, 0); + + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, location, 0.5F, 0.2F, 0.5F, 0.001F, 12, ViewDist.LONG); + UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, location.subtract(0, 0.2, 0), 0.4F, 0.1F, 0.4F, 0.1F, 2, ViewDist.LONG); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java new file mode 100644 index 000000000..85d9f93ee --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java @@ -0,0 +1,57 @@ +package nautilus.game.arcade.game.games.moba.kit.larissa; + +import mineplex.core.common.util.UtilBlock; +import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.inventory.ItemStack; + +public class SkillWaterDash extends DashSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving water behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillWaterDash(int slot) + { + super("Water Dash", DESCRIPTION, SKILL_ITEM, slot); + + setCooldown(10000); + + _collide = false; + _velocityTime = 600; + _velocityStopOnEnd = true; + _horizontial = true; + } + + @Override + public void dashTick(Player player) + { + Block block = player.getLocation().getBlock(); + + while (!UtilBlock.solid(block)) + { + block = block.getRelative(BlockFace.DOWN); + } + + Block fBlock = block; + Manager.runSyncLater(() -> Manager.GetBlockRestore().add(fBlock.getRelative(BlockFace.UP), Material.WATER.getId(), (byte) 0, 7000), 10); + } + + @EventHandler + public void onBlockFromTo(BlockFromToEvent event) + { + if (event.getBlock().isLiquid() || event.getToBlock().isLiquid()) + { + event.setCancelled(true); + } + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 2c0ba235b..1538a04e4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -54,11 +54,6 @@ import java.util.Map.Entry; public class MobaShop implements Listener { - private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT) - .setTitle(C.cGold + "Open Gold Upgrades") - .addLore("Click to open the Gold Upgrades", "shop while you are respawning.") - .build(); - private final Moba _host; private final Map _entities; private final Map _roleMenus; @@ -216,13 +211,6 @@ public class MobaShop implements Listener owned.add(item); category.purchase(player); - // This would happen when the player is respawning and is purchasing upgrades - // In this case giving them the item is not needed - if (UtilPlayer.isSpectator(player)) - { - return; - } - // 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, // Prevents infinite speed player.setWalkSpeed(0.2F); @@ -268,55 +256,13 @@ public class MobaShop implements Listener } /* - Allow players to access the shop while dead. + Allow players to access the shop through an item */ - @EventHandler - public void playerDeath(PlayerDeathEvent event) - { - final Player player = event.getEntity(); - - _host.getArcadeManager().runSyncLater(() -> - { - // Certain categories such as consumables drop on death so here we remove them from upgrades - List owned = _upgrades.get(player); - - if (owned != null) - { - owned.removeIf(item -> - { - MobaShopCategory category = getCategory(item); - return category == null || category.isDroppingOnDeath(); - }); - - // Reset the max amount of purchasable items - MobaPlayer mobaPlayer = _host.getMobaData(player); - - if (mobaPlayer == null || mobaPlayer.getRole() == null) - { - return; - } - - _roleMenus.get(mobaPlayer.getRole()).getCategories().forEach(category -> category.onDeath(player)); - } - - // Give the player their kit items - Kit kit = _host.GetKit(player); - - if (kit == null) - { - return; - } - - kit.GiveItems(player); - player.getInventory().setItem(8, SHOP_ITEM); - }, 1); - } - @EventHandler public void interactShopItem(PlayerInteractEvent event) { - if (event.getItem() == null || !event.getItem().isSimilar(SHOP_ITEM)) + if (event.getItem() == null || event.getItem().getType() != Material.GOLD_INGOT) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 6efb7e551..a8a8319db 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -265,6 +265,30 @@ public class TowerManager implements Listener } } + public Tower damageTowerAt(Location location, Player shooter, double damage) + { + GameTeam team = _host.GetTeam(shooter); + + if (team == null) + { + return null; + } + + for (Tower tower : _towers) + { + if (tower.isDead() || tower.getOwner().equals(team) || UtilMath.offsetSquared(tower.getCrystal().getLocation(), location) > PROJECTILE_RANGE_SQUARED) + { + continue; + } + + playSound(shooter, tower); + tower.damage(damage); + return tower; + } + + return null; + } + private boolean shouldCancelDamage(Tower tower, Player shooter) { Location entityLocation = tower.getCrystal().getLocation(); From 79b983536d05bf1a81ed70d31cddcd2e6e5d802f Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jun 2017 22:55:17 +0100 Subject: [PATCH 152/283] While Withered, prevent regeneration --- .../games/moba/kit/bob/SkillHappyTrees.java | 3 ++- .../games/moba/kit/dana/SkillPulseHeal.java | 3 ++- .../game/games/moba/kit/hp/HPManager.java | 15 ++++++++++++++ .../games/moba/kit/larissa/SkillAOEHeal.java | 3 ++- .../moba/kit/larissa/SkillStormHeal.java | 3 ++- .../arcade/game/games/moba/util/MobaUtil.java | 20 ++++++++++++++++--- 6 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java index 801f63ba4..f5e0fbc4b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java @@ -8,6 +8,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.util.MobaParticles; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -152,7 +153,7 @@ public class SkillHappyTrees extends HeroSkill continue; } - entity.setHealth(Math.min(entity.getHealth() + 2, entity.getMaxHealth())); + MobaUtil.heal(entity, 2); MobaParticles.healing(entity, 1); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java index 5c17f5fdf..358db05c1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.LivingEntity; @@ -51,7 +52,7 @@ public class SkillPulseHeal extends HeroSkill continue; } - entity.setHealth(Math.min(entity.getHealth() + 4, entity.getMaxHealth())); + MobaUtil.heal(entity, 4); } displayPulse(player.getLocation().add(0, 0.5, 0)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java index a23c4d4ac..7f91b073d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java @@ -10,6 +10,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.potion.PotionEffectType; public class HPManager implements Listener @@ -17,6 +18,7 @@ public class HPManager implements Listener // Health per 5 seconds. private static final double HP5 = 0.66; + private static final double HP_KILL_FACTOR = 0.25; private final Moba _host; @@ -52,6 +54,19 @@ public class HPManager implements Listener } } + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + Player killer = event.getEntity().getKiller(); + + if (killer == null) + { + return; + } + + killer.setHealth(Math.min(killer.getHealth() + killer.getMaxHealth() * HP_KILL_FACTOR, killer.getMaxHealth())); + } + @EventHandler public void preventHungerRegeneration(EntityRegainHealthEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java index 9b7ff9c76..ebda5b79a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java @@ -14,6 +14,7 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.util.MobaParticles; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -123,7 +124,7 @@ public class SkillAOEHeal extends HeroSkill implements IThrown if (isTeamDamage(entity, owner)) { MobaParticles.healing(entity, HEALTH_PER_SECOND); - entity.setHealth(Math.min(entity.getHealth() + HEALTH_PER_SECOND, entity.getMaxHealth())); + MobaUtil.heal(entity, HEALTH_PER_SECOND); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java index 34adb0612..9c2fbbaca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java @@ -11,6 +11,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -85,7 +86,7 @@ public class SkillStormHeal extends HeroSkill for (Player teamMember : team.GetPlayers(true)) { - teamMember.setHealth(Math.min(teamMember.getHealth() + HEALTH_PER_SECOND, teamMember.getMaxHealth())); + MobaUtil.heal(teamMember, HEALTH_PER_SECOND); } }); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 46c3eac2f..97bb33361 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -4,12 +4,10 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import org.bukkit.Bukkit; +import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -196,4 +194,20 @@ public class MobaUtil { return entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(team.GetName()); } + + public static void heal(LivingEntity entity, double health) + { + if (entity instanceof Player) + { + MobaHPRegenEvent regenEvent = new MobaHPRegenEvent((Player) entity, health); + UtilServer.CallEvent(regenEvent); + + if (regenEvent.isCancelled()) + { + return; + } + } + + entity.setHealth(Math.min(entity.getHealth() + health, entity.getMaxHealth())); + } } From 3c3cffb0015b042423a3961cbd11a7c2336b8e15 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 8 Jun 2017 18:53:37 -0500 Subject: [PATCH 153/283] Add MAPPER rank and modify BUILDER description --- .../Mineplex.Core.Common/src/mineplex/core/common/Rank.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 43fdbacdc..4379ab64b 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -24,7 +24,8 @@ public enum Rank MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), HELPER("Trainee", "train", ChatColor.GOLD, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 24, DyeColor.ORANGE), MAPLEAD("MapLead", "mapl", ChatColor.BLUE, "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders.", 25, DyeColor.BLUE), - MAPDEV("Builder", "mapd", ChatColor.BLUE, "Builders are members of the Mineplex Build Team. \nThey create many of the maps used across Mineplex.", 26, DyeColor.BLUE), + MAPPER("Mapper", "mapp", ChatColor.BLUE, "These senior staff members work closely with the development and design teams to build new maps for new and old content!", 26, DyeColor.BLUE), + MAPDEV("Builder", "mapd", ChatColor.BLUE, "These creative staff members help build maps for your favorite games!", 26, DyeColor.BLUE), MEDIA("Media", "media", ChatColor.BLUE, "The Media rank is given to talented artists who are\n endorsed to create content for Mineplex.", -1, DyeColor.BLUE), EVENT("Event", "evnt", ChatColor.WHITE, "A member of the official Mineplex Events team!", -1, DyeColor.WHITE), From ecd9812f0c35545b34921680a27b6d1cdf55a966 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 8 Jun 2017 20:12:44 -0400 Subject: [PATCH 154/283] Properly return empty value in ItemStackFactory --- .../src/mineplex/core/itemstack/ItemStackFactory.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java index 8ca03762a..6cff9e3ba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java @@ -1000,10 +1000,10 @@ public class ItemStackFactory extends MiniPlugin ItemMeta meta = stack.getItemMeta(); if (meta == null) - return 0; + return empty; if (meta.getLore() == null) - return 0; + return empty; for (String cur : meta.getLore()) if (cur.contains(var)) @@ -1021,7 +1021,7 @@ public class ItemStackFactory extends MiniPlugin } - return 0; + return empty; } public void SetLoreVar(ItemStack stack, String var, String value) From 986d4f3dcceb25d3c2c5efd3c6bbf26095fba125 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 8 Jun 2017 20:15:41 -0400 Subject: [PATCH 155/283] Properly restrict moderation staff testrank access --- .../src/mineplex/core/account/command/TestRank.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/TestRank.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/TestRank.java index e4ab7147e..e4ed2e7b8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/TestRank.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/TestRank.java @@ -64,7 +64,7 @@ public class TestRank extends CommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Invalid rank!")); return; } - if (Plugin.Get(caller).GetRank(true) == Rank.SNR_MODERATOR) + if (!Plugin.Get(caller).GetRank(true).has(Rank.JNR_DEV)) { if (tempRank.has(Rank.TWITCH)) { From e7174a0e4e1eff47a3f695d41e4db076742d89ef Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 8 Jun 2017 20:19:12 -0400 Subject: [PATCH 156/283] Add an item unbreakable checker to UtilItem --- .../src/mineplex/core/common/util/UtilItem.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index 3f933517b..47fd7594c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -1158,6 +1158,16 @@ public class UtilItem return i; } + public static boolean isUnbreakable(ItemStack i) + { + if (i == null) + { + return false; + } + + return i.getItemMeta().spigot().isUnbreakable(); + } + /** * From 87966ddedd010f6a2b444beded8d7ce75fde7a20 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 8 Jun 2017 20:20:10 -0400 Subject: [PATCH 157/283] Season 3 --- Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 8bddf656b..50d1d76e4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -79,7 +79,7 @@ import static mineplex.core.Managers.require; public class Clans extends JavaPlugin { - public static final String MAP = "Season 2"; + public static final String MAP = "Season 3"; // Modules private CoreClientManager _clientManager; From d226a4e71063892f741481d9c4f8458456333886 Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 9 Jun 2017 00:14:49 -0500 Subject: [PATCH 158/283] Remove Gem Fountain and open brawl on weekends --- .../core/brawl/fountain/BlockProgressBar.java | 57 ---- .../brawl/fountain/BrawlShopProvider.java | 11 - .../core/brawl/fountain/Fountain.java | 258 ------------------ .../core/brawl/fountain/FountainManager.java | 123 --------- .../fountain/GemFountainSalesPackage.java | 20 -- .../brawl/fountain/command/AddCommand.java | 69 ----- .../fountain/command/FountainCommand.java | 27 -- .../brawl/fountain/command/GuiCommand.java | 26 -- .../brawl/fountain/command/ResetCommand.java | 26 -- .../core/brawl/fountain/gui/FountainPage.java | 92 ------- .../core/brawl/fountain/gui/FountainShop.java | 48 ---- .../gui/button/FountainAddButton.java | 38 --- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 4 +- .../hub/brawl/fountain/FountainManager.java | 75 +++++ .../mineplex/hub/server/ServerManager.java | 5 +- 15 files changed, 79 insertions(+), 800 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/BlockProgressBar.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/BrawlShopProvider.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/GemFountainSalesPackage.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/FountainCommand.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/GuiCommand.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/ResetCommand.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainPage.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainShop.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/brawl/fountain/FountainManager.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/BlockProgressBar.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/BlockProgressBar.java deleted file mode 100644 index d18cc45ec..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/BlockProgressBar.java +++ /dev/null @@ -1,57 +0,0 @@ -package mineplex.core.brawl.fountain; - -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; - -/** - * This class handled filling a vertical area with a specific block based off a percent - * - * @author Shaun Bennett - */ -public class BlockProgressBar -{ - // Starting block for the block fill - private final Block _startBlock; - // Direction the blockfill takes place in - private final BlockFace _direction; - // Blocks in order from lowest to highes - private final Block[] _blocks; - // Material used to fill the blocks - private final Material _material; - - public BlockProgressBar(Block startBlock, Material material, BlockFace direction) - { - _startBlock = startBlock; - _material = material; - _direction = direction; - - // Add blocks to array - int i; - Block curr; - Block[] blocks = new Block[100]; // max of 100 to prevent blocking - for (i = 0, curr = startBlock; (curr.getType() == Material.AIR || curr.getType() == material) && i < blocks.length; i++) - { - blocks[i] = curr; - curr = curr.getRelative(direction); - } - - _blocks = new Block[i]; - System.arraycopy(blocks, 0, _blocks, 0, i); - } - - // Update the blockfill based on fill percent - public void update(double percent) - { - double percentPerBlock = 1D / _blocks.length; - double check = 0; - - for (int i = 0; i < _blocks.length; i++) - { - _blocks[i].setType(percent > check ? _material : Material.AIR); - - check += percentPerBlock; - } - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/BrawlShopProvider.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/BrawlShopProvider.java deleted file mode 100644 index 89635b062..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/BrawlShopProvider.java +++ /dev/null @@ -1,11 +0,0 @@ -package mineplex.core.brawl.fountain; - -import mineplex.core.shop.ShopBase; - -/** - * @author Shaun Bennett - */ -public interface BrawlShopProvider -{ - public ShopBase getBrawlShop(); -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java deleted file mode 100644 index 90673463c..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java +++ /dev/null @@ -1,258 +0,0 @@ -package mineplex.core.brawl.fountain; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.brawl.fountain.gui.FountainShop; -import mineplex.core.common.SortedSchematicLoader; -import mineplex.core.common.block.schematic.UtilSchematic; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilText; -import mineplex.core.donation.DonationManager; -import mineplex.core.hologram.Hologram; -import mineplex.core.hologram.HologramManager; -import mineplex.core.stats.StatsManager; -import mineplex.serverdata.Region; -import mineplex.serverdata.redis.counter.GoalCounter; -import mineplex.serverdata.redis.counter.GoalCounterListener; -import mineplex.serverdata.servers.ConnectionData; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.TimeZone; - -/** - * Represents a fountain that players can add gems to, with a reward for reaching specific goals - * @author Shaun Bennett - */ -public class Fountain implements GoalCounterListener -{ - // Manager Injections - private final HologramManager _hologramManager; - private final StatsManager _statsManager; - - private boolean _brawlActive; - private final String _name; - private final String _dataKey; - private final Location _location; - private final Hologram _hologram; - private final GoalCounter _counter; -// private final BlockProgressBar _blockProgressBar; - private final SortedSchematicLoader _schematicLoader; - - private final FountainShop _shop; - - public Fountain(ConnectionData writeConnection, ConnectionData readConnection, Region region, Location location, Location pasteLocation, String name, String dataKey, long goal, FountainManager fountainManager, - CoreClientManager clientManager, DonationManager donationManager, HologramManager hologramManager, - StatsManager statsManager) - { - _hologramManager = hologramManager; - _statsManager = statsManager; - - _name = name; - _dataKey = dataKey; - _location = location; - _hologram = new Hologram(hologramManager, new Location(location.getWorld(), -23, 75, 3), name).start(); - _counter = new GoalCounter(writeConnection, readConnection, region, dataKey, goal); - _counter.addListener(this); - _brawlActive = false; -// _blockProgressBar = new BlockProgressBar(_lavaLocation.getBlock(), Material.LAVA, BlockFace.UP); - _schematicLoader = new SortedSchematicLoader<>(pasteLocation); - loadSchematics(); - - _shop = new FountainShop(this, fountainManager, clientManager, donationManager); - - updateVisuals(); - } - - private void loadSchematics() - { - try - { - _schematicLoader.addSchematic(0.0, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain0.schematic"))); - _schematicLoader.addSchematic(0.2, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain20.schematic"))); - _schematicLoader.addSchematic(0.4, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain40.schematic"))); - _schematicLoader.addSchematic(0.6, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain60.schematic"))); - _schematicLoader.addSchematic(0.8, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain80.schematic"))); - _schematicLoader.addSchematic(1.0, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain100.schematic"))); - _schematicLoader.addSchematic(2.0, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain200.schematic"))); - _schematicLoader.addSchematic(3.0, UtilSchematic.loadSchematic(new File("../../update/schematic/fountain300.schematic"))); - } - catch (IOException e) - { - System.err.println("Failed to load Gem Fountain Schematics"); - e.printStackTrace(); - } - } - - protected void updateVisuals() - { - double fillPercent = getFillPercent(); - - if (isBrawlActive()) - { - ArrayList text = new ArrayList<>(); - if (fillPercent >= 1) - { - text.add(C.cRed + C.Bold + "Weekend Brawl is Active!"); - if (fillPercent >= 2) - { - text.add("Bonus Reward Unlocked:"); - if (fillPercent >= 3) - { - text.add(C.cGreen + "3X Experience in Brawl"); - } - else - { - text.add(C.cGreen + "2X Experience in Brawl"); - } - } - text.add(" "); - text.add("Speak to the Fountain Keeper to Join!"); - } - else - { - text.add(C.cRed + "Brawl goal was not met"); - text.add("Come back next week"); - } - - _hologram.setText(text.toArray(new String[text.size()])); - //_schematicLoader.update(fillPercent); - } - else - { - double flatPercent = fillPercent - (int) fillPercent; - - String fillColor; - String emptyColor; - String goalMessage; - - if (fillPercent < 1) - { - fillColor = C.cGreen; - emptyColor = C.cRed; - goalMessage = "100% to Unlock Weekend Brawl"; - } else if (fillPercent < 2) - { - fillColor = C.cYellow; - emptyColor = C.cGreen; - goalMessage = "200% to Unlock 2x XP for Weekend Brawl"; - } else if (fillPercent < 3) - { - fillColor = C.cAqua; - emptyColor = C.cYellow; - goalMessage = "300% to Unlock 3x XP for Weekend Brawl"; - } else - { - fillColor = C.cAqua; - emptyColor = C.cYellow; - goalMessage = "All Rewards Unlocked!"; - flatPercent = 1; - } - - int intPercent = (int) (fillPercent * 100); - String progressBar = UtilText.getProgress(null, flatPercent, null, false, 30, emptyColor, fillColor); - _hologram.setText(_name + C.Reset + " " + intPercent + "%", goalMessage, progressBar); - _schematicLoader.update(fillPercent); - } - } - - public void increment(Player player, long amount, Callback callback) - { - _statsManager.incrementStat(player, getStatName(), amount); - _statsManager.runAsync(() -> { - long count = _counter.addAndGet(amount); - _statsManager.runSync(() -> { - updateVisuals(); - if (callback != null) callback.run(count); - }); - }); - } - - public long getAmountAdded(Player player) - { - return _statsManager.Get(player).getStat(getStatName()); - } - - private final String getStatName() - { - return "Global.Fountain." + getDataKey(); - } - - public String getName() - { - return _name; - } - - public String getDataKey() - { - return _dataKey; - } - - public void openShop(Player player) - { - _shop.attemptShopOpen(player); - } - - public double getFillPercent() - { - return Math.min(3, _counter.getFillPercent()); - } - - public long getCount() - { - return _counter.getCount(); - } - - public void reset() - { - _counter.reset(); - updateVisuals(); - } - - @Override - public void onMilestone(GoalCounter counter, int milestone) - { - switch (milestone) - { - case 1: - Bukkit.broadcastMessage(F.main("Fountain", "The Gem Fountain has reached 100%! Brawl Game unlocked this week")); - break; - case 2: - Bukkit.broadcastMessage(F.main("Fountain", "The Gem Fountain has reached 200%! 2x XP enabled for Brawl!")); - break; - case 3: - Bukkit.broadcastMessage(F.main("Fountain", "The Gem Fountain has reached 300%! 3x XP enabled for Brawl!")); - break; - } - } - - public void updateBrawlActive() - { - Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("PST")); - int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); - if (dayOfWeek == Calendar.FRIDAY || dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) - { - _brawlActive = true; - } - else - { - _brawlActive = false; - } - } - - public void updateCounter() - { - _counter.updateCount(); - } - - public boolean isBrawlActive() - { - return _brawlActive; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java deleted file mode 100644 index e7c009f3f..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java +++ /dev/null @@ -1,123 +0,0 @@ -package mineplex.core.brawl.fountain; - -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.brawl.fountain.command.FountainCommand; -import mineplex.core.common.util.C; -import mineplex.core.donation.DonationManager; -import mineplex.core.hologram.HologramManager; -import mineplex.core.locations.LocationConstants; -import mineplex.core.stats.StatsManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.serverdata.Region; -import mineplex.serverdata.servers.ConnectionData; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import org.bukkit.plugin.java.JavaPlugin; - -/** - * @author Shaun Bennett - */ -public class FountainManager extends MiniPlugin -{ - private HologramManager _hologramManager; - private StatsManager _statsManager; - private DonationManager _donationManager; - // used so we can inject the brawl shop (only on hub) into fountain code - private BrawlShopProvider _brawlShopProvider; - - private Fountain _gemFountain; - - public FountainManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, HologramManager hologramManager, StatsManager statsManager, BrawlShopProvider shopProvider) - { - super("Counter", plugin); - - _hologramManager = hologramManager; - _statsManager = statsManager; - _donationManager = donationManager; - _brawlShopProvider = shopProvider; - - World world = Bukkit.getWorlds().get(0);//-43.5, 66, -38.5 - - int goal = 35000000;//!new File("eu.dat").exists() ? 200000000 : 20000000; - _gemFountain = new Fountain(new ConnectionData("10.3.203.80", 6379, ConnectionData.ConnectionType.MASTER, "USRedis"), - new ConnectionData("10.3.203.80", 6377, ConnectionData.ConnectionType.SLAVE, "USRedis"), Region.ALL, - LocationConstants.FOUNTAIN_LOCATION, LocationConstants.FOUNTAIN_SCHEMATIC, - C.cGreen + "Gem Fountain", "GemFountain_01", goal, this, clientManager, donationManager, _hologramManager, _statsManager); - } - - @Override - public void addCommands() - { - addCommand(new FountainCommand(this)); - } - - @EventHandler - public void updateFountainCount(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - _gemFountain.updateBrawlActive(); - _gemFountain.updateVisuals(); - } - - @EventHandler - public void updateCounter(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC_05) - return; - - runAsync(_gemFountain::updateCounter); - } - - @EventHandler - public void onInteractAtEntity(PlayerInteractAtEntityEvent event) - { - Entity entity = event.getRightClicked(); - if (entity.getCustomName() != null && entity.isCustomNameVisible()) - { - if (entity.getCustomName().contains("Weekend Brawl") && getBrawlShopProvider() != null) - { - getBrawlShopProvider().getBrawlShop().attemptShopOpen(event.getPlayer()); - } - } - } - - @EventHandler - public void onDamage(EntityDamageByEntityEvent event) - { - if (!(event.getDamager() instanceof Player)) - return; - - Entity entity = event.getEntity(); - if (entity.getCustomName() != null && entity.isCustomNameVisible()) - { - if (entity.getCustomName().contains("Weekend Brawl") && getBrawlShopProvider() != null) - { - getBrawlShopProvider().getBrawlShop().attemptShopOpen(((Player) event.getDamager())); - } - } - } - - public Fountain getGemFountain() - { - return _gemFountain; - } - - public DonationManager getDonationManager() - { - return _donationManager; - } - - public BrawlShopProvider getBrawlShopProvider() - { - return _brawlShopProvider; - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/GemFountainSalesPackage.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/GemFountainSalesPackage.java deleted file mode 100644 index d0ba3e882..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/GemFountainSalesPackage.java +++ /dev/null @@ -1,20 +0,0 @@ -package mineplex.core.brawl.fountain; - -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.shop.item.SalesPackageBase; -import org.bukkit.Material; - -/** - * @author Shaun Bennett - */ -public class GemFountainSalesPackage extends SalesPackageBase -{ - public GemFountainSalesPackage(int gems) - { - super("Add " + gems + " Gems", Material.EMERALD, (byte) 0, new String[] {}, gems, 1); - - CurrencyCostMap.put(GlobalCurrency.GEM, gems); - KnownPackage = false; - OneTimePurchaseOnly = false; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java deleted file mode 100644 index bebc34341..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java +++ /dev/null @@ -1,69 +0,0 @@ -package mineplex.core.brawl.fountain.command; - -import java.util.function.Consumer; - -import mineplex.core.brawl.fountain.FountainManager; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.server.util.TransactionResponse; - -import org.bukkit.entity.Player; - -/** - * Command to add gems to the fountain - * - * @author Shaun Bennett - */ -public class AddCommand extends CommandBase -{ - public AddCommand(FountainManager plugin) - { - super(plugin, Rank.DEVELOPER, "add"); - } - - @Override - public void Execute(Player caller, String[] args) - { - if (args == null || args.length != 1) - { - help(caller); - return; - } - - try - { - int amount = Integer.parseInt(args[0]); - - Plugin.getDonationManager().purchaseUnknownSalesPackage(caller, "GemFountain.Add", GlobalCurrency.GEM, amount, false, - result -> - { - if (result == TransactionResponse.Success) - { - Plugin.getGemFountain().increment(caller, amount, null); - UtilPlayer.message(caller, F.main("Fountain", "Added " + F.elem(amount) + " to the fountain!")); - } - else if (result == TransactionResponse.InsufficientFunds) - { - UtilPlayer.message(caller, F.main("Fountain", "You do not have enough gems!")); - } - else - { - UtilPlayer.message(caller, F.main("Fountain", "There was an error processing your request!")); - } - }); - } - catch (NumberFormatException ex) - { - help(caller); - } - } - - private void help(Player player) - { - UtilPlayer.message(player, F.help("/fountain add", "", Rank.DEVELOPER)); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/FountainCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/FountainCommand.java deleted file mode 100644 index 555ad39d2..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/FountainCommand.java +++ /dev/null @@ -1,27 +0,0 @@ -package mineplex.core.brawl.fountain.command; - -import mineplex.core.brawl.fountain.FountainManager; -import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; -import org.bukkit.entity.Player; - -/** - * @author Shaun Bennett - */ -public class FountainCommand extends MultiCommandBase -{ - public FountainCommand(FountainManager plugin) - { - super(plugin, Rank.DEVELOPER, "fountain"); - - AddCommand(new AddCommand(plugin)); - AddCommand(new GuiCommand(plugin)); - AddCommand(new ResetCommand(plugin)); - } - - @Override - protected void Help(Player caller, String[] args) - { - - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/GuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/GuiCommand.java deleted file mode 100644 index 2a6b1d667..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/GuiCommand.java +++ /dev/null @@ -1,26 +0,0 @@ -package mineplex.core.brawl.fountain.command; - -import mineplex.core.brawl.fountain.FountainManager; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import org.bukkit.entity.Player; - -/** - * Command to open the fountain gui without speaking to the fountain keeper - * @author Shaun Bennett - */ -public class GuiCommand extends CommandBase -{ - public GuiCommand(FountainManager plugin) - { - super(plugin, Rank.DEVELOPER, "gui"); - } - - @Override - public void Execute(Player caller, String[] args) - { - Plugin.getGemFountain().openShop(caller); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/ResetCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/ResetCommand.java deleted file mode 100644 index 4589eb2a4..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/ResetCommand.java +++ /dev/null @@ -1,26 +0,0 @@ -package mineplex.core.brawl.fountain.command; - -import mineplex.core.brawl.fountain.FountainManager; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import org.bukkit.entity.Player; - -/** - * Command to reset the fountain - * @author Shaun Bennett - */ -public class ResetCommand extends CommandBase -{ - public ResetCommand(FountainManager plugin) - { - super(plugin, Rank.DEVELOPER, "reset"); - } - - @Override - public void Execute(Player caller, String[] args) - { - Plugin.getGemFountain().reset(); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainPage.java deleted file mode 100644 index dc3fb9c64..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainPage.java +++ /dev/null @@ -1,92 +0,0 @@ -package mineplex.core.brawl.fountain.gui; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.brawl.fountain.Fountain; -import mineplex.core.brawl.fountain.FountainManager; -import mineplex.core.brawl.fountain.gui.button.FountainAddButton; -import mineplex.core.common.MaterialData; -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.C; -import mineplex.core.donation.DonationManager; -import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ShopPageBase; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -/** - * @author Shaun Bennett - */ -public class FountainPage extends ShopPageBase -{ - private final MaterialData EMPTY_XP = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 7); - private final MaterialData XP = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 5); - private final MaterialData EMPTY_XP100 = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 5); - private final MaterialData XP100 = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 4); - private final MaterialData EMPTY_XP200 = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 4); - private final MaterialData XP200 = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 3); - private final int[] XP_SLOTS = { 2, 3, 4, 5, 6 }; - - private Fountain _fountain; - - public FountainPage(FountainManager plugin, FountainShop shop, CoreClientManager clientManager, DonationManager donationManager, Fountain fountain, Player player) - { - super(plugin, shop, clientManager, donationManager, "Fountain Keeper", player, 27); - - _fountain = fountain; - - buildPage(); - } - - @Override - protected void buildPage() - { - // Experience Bar - long added = _fountain.getAmountAdded(getPlayer()); - final double fillPercent = _fountain.getFillPercent(); - String title = ((int)(fillPercent * 100)) + "% Complete"; - boolean canAdd = fillPercent < 3; - - String unlockMessage; - if (fillPercent < 1) unlockMessage = "Reach 100% to unlock Weekend Brawl Game"; - else if (fillPercent < 2) unlockMessage = "Reach 200% to unlock 2x XP in Brawl"; - else if (fillPercent < 3) unlockMessage = "Reach 300% to unlock 3x XP in Brawl"; - else unlockMessage = "All rewards unlocked!"; - - String[] lore = new String[] { - " ", - C.cWhite + unlockMessage, - " ", - C.cWhite + "You have added " + C.cGreen + added + " Gems"}; - - final double percentForEach = 1D / XP_SLOTS.length; - double check = percentForEach; - - double flatPercent = fillPercent == 3 ? 1 : fillPercent - ((int) fillPercent); - for (int i = 0; i < XP_SLOTS.length; i++) - { - MaterialData data; - if (fillPercent < 1) data = flatPercent >= check ? XP : EMPTY_XP; - else if (fillPercent < 2) data = flatPercent >= check ? XP100 : EMPTY_XP100; - else data = flatPercent >= check ? XP200 : EMPTY_XP200; - ShopItem shopItem = new ShopItem(data.getMaterial(), data.getData(), title, - lore, 1, false, false); - - setItem(XP_SLOTS[i], shopItem); - check += percentForEach; - } - - if (canAdd) - { - int playerGems = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.GEM); - ShopItem add1 = new ShopItem(Material.EMERALD, "Add 100 Gems", new String[]{}, 1, playerGems < 100, false); - ShopItem add2 = new ShopItem(Material.EMERALD, "Add 1,000 Gems", new String[]{}, 64, playerGems < 1000, false); - ShopItem add3 = new ShopItem(Material.EMERALD_BLOCK, "Add 10,000 Gems", new String[]{}, 1, playerGems < 10000, false); - ShopItem add4 = new ShopItem(Material.EMERALD_BLOCK, "Add 100,000 Gems", new String[]{}, 64, playerGems < 100000, false); - // Buttons - addButton(19, add1, new FountainAddButton(this, 100)); - addButton(21, add2, new FountainAddButton(this, 1000)); - addButton(23, add3, new FountainAddButton(this, 10000)); - addButton(25, add4, new FountainAddButton(this, 100000)); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainShop.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainShop.java deleted file mode 100644 index a8cade6e4..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainShop.java +++ /dev/null @@ -1,48 +0,0 @@ -package mineplex.core.brawl.fountain.gui; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.brawl.fountain.Fountain; -import mineplex.core.brawl.fountain.FountainManager; -import mineplex.core.donation.DonationManager; -import mineplex.core.shop.ShopBase; -import mineplex.core.shop.page.ShopPageBase; -import org.bukkit.entity.Player; - -/** - * @author Shaun Bennett - */ -public class FountainShop extends ShopBase -{ - private final Fountain _fountain; - - public FountainShop(Fountain fountain, FountainManager plugin, CoreClientManager clientManager, DonationManager donationManager) - { - super(plugin, clientManager, donationManager, "Fountain Keeper"); - - _fountain = fountain; - } - - @Override - protected ShopPageBase> buildPagesFor(Player player) - { - return new FountainPage(getPlugin(), this, getClientManager(), getDonationManager(), _fountain, player); - } - - public Fountain getFountain() - { - return _fountain; - } - - @Override - public boolean attemptShopOpen(Player player) - { - if (_fountain.isBrawlActive() && getPlugin().getBrawlShopProvider() != null) - { - return getPlugin().getBrawlShopProvider().getBrawlShop().attemptShopOpen(player); - } - else - { - return super.attemptShopOpen(player); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java deleted file mode 100644 index 3dcc6ebd7..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/button/FountainAddButton.java +++ /dev/null @@ -1,38 +0,0 @@ -package mineplex.core.brawl.fountain.gui.button; - -import mineplex.core.brawl.fountain.GemFountainSalesPackage; -import mineplex.core.brawl.fountain.gui.FountainPage; -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.shop.confirmation.ConfirmationPage; -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.item.SalesPackageBase; -import mineplex.core.shop.item.SalesPackageProcessor; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -/** - * @author Shaun Bennett - */ -public class FountainAddButton implements IButton -{ - private final FountainPage _page; - private final int _gems; - private final SalesPackageBase _salesPackage; - - public FountainAddButton(FountainPage page, int gems) - { - _page = page; - _gems = gems; - _salesPackage = new GemFountainSalesPackage(gems); - } - - @Override - public void onClick(Player player, ClickType clickType) - { - _page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, _salesPackage, _page.getDonationManager(), () -> - { - _page.getPlugin().getGemFountain().increment(player, _gems, null); - _page.refresh(); - }), _salesPackage.buildIcon())); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index a4b0a0b88..6c22d7cbb 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -16,7 +16,7 @@ import mineplex.core.antihack.guardians.GuardianManager; import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.boosters.BoosterManager; -import mineplex.core.brawl.fountain.FountainManager; +import mineplex.hub.brawl.fountain.FountainManager; import mineplex.core.chat.Chat; import mineplex.core.chatsnap.SnapshotManager; import mineplex.core.chatsnap.SnapshotPlugin; @@ -188,7 +188,7 @@ public class Hub extends JavaPlugin implements IRelation QueueManager queueManager = new QueueManager(this, clientManager, donationManager, eloManager, partyManager); ServerManager serverManager = new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, queueManager, boosterManager); - new FountainManager(this, clientManager, donationManager, hologramManager, statsManager, serverManager); + new FountainManager(this, serverManager); Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/brawl/fountain/FountainManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/brawl/fountain/FountainManager.java new file mode 100644 index 000000000..22845867e --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/brawl/fountain/FountainManager.java @@ -0,0 +1,75 @@ +package mineplex.hub.brawl.fountain; + +import java.util.Calendar; +import java.util.TimeZone; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.F; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.server.ServerManager; + +public class FountainManager extends MiniPlugin +{ + private final ServerManager _serverManager; + private boolean _brawlActive = false; + + public FountainManager(JavaPlugin plugin, ServerManager serverManager) + { + super("Counter", plugin); + _serverManager = serverManager; + } + + @EventHandler + public void updateFountainCount(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + updateBrawlActive(); + } + + public void updateBrawlActive() + { + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("PST")); + int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); + _brawlActive = dayOfWeek == Calendar.FRIDAY || dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY; + } + + @EventHandler + public void onInteractAtEntity(PlayerInteractAtEntityEvent event) + { + tryBrawl(event.getPlayer(), event.getRightClicked()); + } + + @EventHandler + public void onDamage(EntityDamageByEntityEvent event) + { + tryBrawl((Player)event.getDamager(), event.getEntity()); + } + + private void tryBrawl(Player player, Entity entity) + { + if (entity.getCustomName() != null && entity.isCustomNameVisible()) + { + if (entity.getCustomName().contains("Weekend Brawl")) + { + if (_brawlActive) + { + _serverManager.getBrawlShop().attemptShopOpen(player); + } + else + { + player.sendMessage(F.main("BRAWL", "Come back this weekend to play Weekend Brawl!")); + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index cc37b55a6..f833f0200 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -29,7 +29,6 @@ import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.boosters.BoosterManager; -import mineplex.core.brawl.fountain.BrawlShopProvider; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -62,7 +61,7 @@ import mineplex.serverdata.Region; import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.data.ServerGroup; -public class ServerManager extends MiniPlugin implements BrawlShopProvider +public class ServerManager extends MiniPlugin { private static final Long FREE_PORTAL_TIMER = -1L; private static final Long BETA_PORTAL_TIMER = 120000L; @@ -858,7 +857,7 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider public ShopBase getBrawlShop() { - return _serverNpcShopMap.get("Weekend Brawl"); + return _serverNpcShopMap.get("BRAWL"); } public ShopBase getBawkShop() From 68084c5cf0d9783670c3997613eeb42f9286f353 Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 9 Jun 2017 02:43:34 -0500 Subject: [PATCH 159/283] Insert linebreaks in mapper + mapdev descriptions --- .../Mineplex.Core.Common/src/mineplex/core/common/Rank.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 4379ab64b..3041395bf 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -24,8 +24,8 @@ public enum Rank MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), HELPER("Trainee", "train", ChatColor.GOLD, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 24, DyeColor.ORANGE), MAPLEAD("MapLead", "mapl", ChatColor.BLUE, "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders.", 25, DyeColor.BLUE), - MAPPER("Mapper", "mapp", ChatColor.BLUE, "These senior staff members work closely with the development and design teams to build new maps for new and old content!", 26, DyeColor.BLUE), - MAPDEV("Builder", "mapd", ChatColor.BLUE, "These creative staff members help build maps for your favorite games!", 26, DyeColor.BLUE), + MAPPER("Mapper", "mapp", ChatColor.BLUE, "These senior staff members work closely with \nthe development and design teams to build new \nmaps for new and old content!", 26, DyeColor.BLUE), + MAPDEV("Builder", "mapd", ChatColor.BLUE, "These creative staff members help \nbuild maps for your favorite games!", 26, DyeColor.BLUE), MEDIA("Media", "media", ChatColor.BLUE, "The Media rank is given to talented artists who are\n endorsed to create content for Mineplex.", -1, DyeColor.BLUE), EVENT("Event", "evnt", ChatColor.WHITE, "A member of the official Mineplex Events team!", -1, DyeColor.WHITE), From ac52903b7d02ba839cbe0e76d7c7291aee282bcc Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 9 Jun 2017 13:10:11 +0100 Subject: [PATCH 160/283] QOL changes --- .../core/common/util/UtilParticle.java | 4 +- .../game/arcade/game/games/moba/Moba.java | 2 + .../arcade/game/games/moba/kit/HeroSkill.java | 3 +- .../moba/kit/anath/SkillFireProjectile.java | 15 +- .../games/moba/kit/anath/SkillMeteor.java | 10 +- .../games/moba/kit/bardolf/HeroBardolf.java | 286 ++++++++++++++++++ .../games/moba/kit/bardolf/SkillFullMoon.java | 109 +++++++ .../moba/kit/bardolf/SkillSummonWolf.java | 96 ++++++ .../moba/kit/bardolf/SkillWolfPounce.java | 168 ++++++++++ .../games/moba/kit/larissa/SkillAOEHeal.java | 7 +- 10 files changed, 689 insertions(+), 11 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java index 7b85b4971..a87bb2565 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java @@ -258,11 +258,9 @@ public class UtilParticle } } - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleType.particle, displayFar, + return new PacketPlayOutWorldParticles(particleType.particle, displayFar, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, details); - - return packet; } public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index aade9ac0d..211416885 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -24,6 +24,7 @@ import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.KitPlayer; import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath; +import nautilus.game.arcade.game.games.moba.kit.bardolf.HeroBardolf; import nautilus.game.arcade.game.games.moba.kit.biff.HeroBiff; import nautilus.game.arcade.game.games.moba.kit.bob.HeroBob; import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana; @@ -97,6 +98,7 @@ public class Moba extends TeamGame new HeroDana(Manager), new HeroBiff(Manager), new HeroLarissa(Manager), + new HeroBardolf(Manager), new HeroBob(Manager) }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 6239445ea..5b86d95a4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -64,8 +64,6 @@ public class HeroSkill extends Perk _items.add(itemStack); _slot = slot; _actionType = actionType; - - prettifyItems(); } public void setSneakActivate(boolean activate) @@ -136,6 +134,7 @@ public class HeroSkill extends Perk super.SetHost(kit); _kit = (HeroKit) kit; + prettifyItems(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 4d8d69b35..401693e05 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -6,6 +6,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; @@ -19,6 +20,7 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.List; +import java.util.Set; public class SkillFireProjectile extends HeroSkill { @@ -82,9 +84,20 @@ public class SkillFireProjectile extends HeroSkill } Player player = (Player) entity.getShooter(); + Set entities = UtilEnt.getInRadius(entity.getLocation(), 1.5).keySet(); - for (LivingEntity nearby : UtilEnt.getInRadius(entity.getLocation(), 1.5).keySet()) + if (!entities.isEmpty()) { + player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 1.2F); + } + + for (LivingEntity nearby : entities) + { + if (isTeamDamage(nearby, player)) + { + continue; + } + nearby.setFireTicks(40); Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, DAMAGE, true, true, false, player.getName(), GetName()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index 2b7cd0523..f2d90f7a7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -2,9 +2,10 @@ package nautilus.game.arcade.game.games.moba.kit.anath; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; -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.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.updater.UpdateType; @@ -12,6 +13,7 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.kit.perks.data.MeteorShowerData; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -28,6 +30,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; +import java.awt.*; import java.util.HashSet; import java.util.Set; @@ -101,6 +104,7 @@ public class SkillMeteor extends HeroSkill implements IThrown { Location location = data.Target; GameTeam team = Manager.GetGame().GetTeam(data.Shooter); + DustSpellColor colour = new DustSpellColor(team.GetColor() == ChatColor.RED ? Color.RED : Color.CYAN); for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 100) { @@ -109,7 +113,7 @@ public class SkillMeteor extends HeroSkill implements IThrown location.add(x, 0.25, z); - UtilParticle.playColoredParticleToAll(team.GetColorBase(), ParticleType.RED_DUST, location, 1, ViewDist.LONG); + new ColoredParticle(ParticleType.RED_DUST, colour, location).display(ViewDist.LONG); location.subtract(x, 0.25, z); } @@ -122,7 +126,7 @@ public class SkillMeteor extends HeroSkill implements IThrown } nearby.setFireTicks(20); - Manager.GetDamage().NewDamageEvent(nearby, data.Shooter, null, DamageCause.CUSTOM, 2, true, true, false, UtilEnt.getName(data.Shooter), GetName()); + Manager.GetDamage().NewDamageEvent(nearby, data.Shooter, null, DamageCause.CUSTOM, 2, true, true, false, UtilEnt.getName(data.Shooter), GetName()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java new file mode 100644 index 000000000..e338d5313 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java @@ -0,0 +1,286 @@ +package nautilus.game.arcade.game.games.moba.kit.bardolf; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class HeroBardolf extends HeroKit +{ + + private static final int MAX_DIST_SQUARED = 400; + + private final List _data; + + private static final Perk[] PERKS = { + new SkillSword(0), + new SkillSummonWolf(1), + new SkillWolfPounce(2), + new SkillFullMoon(3) + }; + + public HeroBardolf(ArcadeManager manager) + { + super(manager, "Bardolf", PERKS, MobaRole.ASSASSIN); + + _data = new ArrayList<>(2); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _data.removeIf(data -> data.getOwner().equals(event.getPlayer())); + } + + @EventHandler + public void updateWolves(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || !Manager.GetGame().IsLive()) + { + return; + } + + for (WolfData data : _data) + { + data.getWolves().removeIf(wolf -> wolf.isDead() || !wolf.isValid()); + + data.getWolves().forEach(wolf -> + { + if (data.getOverrideTarget().containsKey(wolf)) + { + UtilEnt.CreatureMoveFast(wolf, data.getOverrideTarget().get(wolf), data.isUltmate() ? 3F : 2F); + return; + } + + double ownerOffset = UtilMath.offsetSquared(data.getOwner(), wolf); + + if (wolf.getTarget() != null) + { + LivingEntity target = wolf.getTarget(); + + if (UtilPlayer.isSpectator(target) || target.isDead() || !target.isValid()) + { + wolf.setTarget(null); + return; + } + + UtilEnt.CreatureMoveFast(wolf, wolf.getTarget().getLocation(), data.isUltmate() ? 3F : 2F); + + if (UtilMath.offsetSquared(wolf.getTarget(), wolf) < 9) + { + Manager.GetDamage().NewDamageEvent(wolf.getTarget(), data.getOwner(), null, DamageCause.CUSTOM, 2, true, false, false, data.getOwner().getName(), "Wolf"); + } + } + else if (ownerOffset > MAX_DIST_SQUARED) + { + wolf.teleport(data.getOwner()); + } + else if (ownerOffset > 4) + { + UtilEnt.CreatureMoveFast(wolf, data.getOwner().getLocation(), data.isUltmate() ? 3F : 2F); + } + }); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void updateTarget(CustomDamageEvent event) + { + if (event.isCancelled()) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + WolfData data = getWolfData(damager); + + if (damager == null || data == null) + { + return; + } + + for (Wolf wolf : data.getWolves()) + { + wolf.setTarget(event.GetDamageeEntity()); + } + } + + @EventHandler + public void preventTeamDamage(CustomDamageEvent event) + { + if (event.isCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(true); + WolfData data = getWolfData(damagee); + + if (data == null || !(damager instanceof Player)) + { + return; + } + GameTeam team = Manager.GetGame().GetTeam((Player) damager); + + if (team != null && MobaUtil.isTeamEntity(damagee, team)) + { + event.SetCancelled("Team Wolf"); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void entityDeath(EntityDeathEvent event) + { + for (WolfData data : _data) + { + if (data.getWolves().contains(event.getEntity())) + { + event.setDroppedExp(0); + event.getDrops().clear(); + } + } + } + + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + WolfData data = getWolfData(event.getEntity()); + + if (data == null) + { + return; + } + + data.getWolves().forEach(Entity::remove); + } + + public WolfData getWolfData(Player player) + { + if (player == null) + { + return null; + } + + for (WolfData data : _data) + { + if (data.getOwner().equals(player)) + { + return data; + } + } + + if (Manager.GetGame().GetKit(player).equals(this)) + { + WolfData data = new WolfData(player); + _data.add(data); + return data; + } + + return null; + } + + public WolfData getWolfData(LivingEntity entity) + { + if (entity == null) + { + return null; + } + + for (WolfData data : _data) + { + if (data.getOwner().equals(entity)) + { + return data; + } + + for (Wolf wolf : data.getWolves()) + { + if (wolf.equals(entity)) + { + return data; + } + } + } + + return null; + } + + class WolfData + { + + private Player _owner; + private List _wolves; + private final Map _overrideTarget; + private boolean _ultimate; + private float _lastSpeedIncrease; + + WolfData(Player owner) + { + _owner = owner; + _wolves = new ArrayList<>(5); + _overrideTarget = new HashMap<>(5); + } + + public Player getOwner() + { + return _owner; + } + + public List getWolves() + { + return _wolves; + } + + public Map getOverrideTarget() + { + return _overrideTarget; + } + + public void setUltimate(boolean ultimate) + { + _ultimate = ultimate; + } + + public boolean isUltmate() + { + return _ultimate; + } + + public void setLastSpeedIncrease(float increase) + { + _lastSpeedIncrease = increase; + } + + public float getLastSpeedIncrease() + { + return _lastSpeedIncrease; + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java new file mode 100644 index 000000000..7e74745d8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java @@ -0,0 +1,109 @@ +package nautilus.game.arcade.game.games.moba.kit.bardolf; + +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.bardolf.HeroBardolf.WolfData; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +public class SkillFullMoon extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + private static final long DURATION = TimeUnit.SECONDS.toMillis(10); + private static final int HEALTH = 20; + private static final float SPEED_FACTOR = 0.05F; + + private final Set _active = new HashSet<>(); + + public SkillFullMoon(int slot) + { + super("Full Moon", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(60000); + setDropItemActivate(true); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!isSkillItem(event) || _active.contains(player)) + { + return; + } + + WolfData data = ((HeroBardolf) Kit).getWolfData(player); + + if (data == null) + { + return; + } + _active.add(player); + Manager.GetGame().WorldTimeSet = 18000; + player.getWorld().strikeLightningEffect(player.getLocation()); + data.setUltimate(true); + + float speedIncrease = (float) data.getWolves().size() * SPEED_FACTOR; + data.setLastSpeedIncrease(speedIncrease); + + player.setWalkSpeed(player.getWalkSpeed() + speedIncrease); + for (Wolf wolf : data.getWolves()) + { + wolf.setMaxHealth(HEALTH); + wolf.setHealth(wolf.getMaxHealth()); + wolf.setTamed(false); + wolf.setAngry(true); + wolf.getWorld().playSound(wolf.getLocation(), Sound.WOLF_GROWL, 1, 1); + } + + useActiveSkill(() -> + { + _active.remove(player); + Manager.GetGame().WorldTimeSet = 12000; + data.setUltimate(false); + player.setWalkSpeed(player.getWalkSpeed() - data.getLastSpeedIncrease()); + + for (Wolf wolf : data.getWolves()) + { + wolf.setHealth(0); + } + + }, player, DURATION); + } + + @EventHandler + public void damagePlayer(CustomDamageEvent event) + { + LivingEntity damagerEntity = event.GetDamagerEntity(true); + Player damagerPlayer = event.GetDamagerPlayer(true); + WolfData data = ((HeroBardolf) Kit).getWolfData(damagerEntity); + + if (data == null) + { + return; + } + + // Player Damage + if (damagerPlayer != null && _active.contains(damagerPlayer)) + { + event.AddMod(GetName(), data.getWolves().size()); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java new file mode 100644 index 000000000..40138bf8f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java @@ -0,0 +1,96 @@ +package nautilus.game.arcade.game.games.moba.kit.bardolf; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.SpigotUtil; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.bardolf.HeroBardolf.WolfData; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +public class SkillSummonWolf extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.BONE); + private static final int MAX_WOLVES = 5; + private static final int HEALTH = 6; + + public SkillSummonWolf(int slot) + { + super("Summon Wolf", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + setCooldown(1000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!isSkillItem(event)) + { + return; + } + + WolfData data = ((HeroBardolf) Kit).getWolfData(player); + + if (data == null) + { + return; + } + else if (data.getWolves().size() == MAX_WOLVES) + { + player.sendMessage(F.main("Game", "You have already summoned the maximum amount of wolves.")); + return; + } + else if (data.isUltmate()) + { + player.sendMessage(F.main("Game", "You cannot summon new wolves right now.")); + return; + } + + Game game = Manager.GetGame(); + GameTeam team = game.GetTeam(player); + + if (team == null) + { + return; + } + + game.CreatureAllowOverride = true; + + Wolf wolf = player.getWorld().spawn(player.getLocation(), Wolf.class); + DyeColor dyeColor = team.GetColor() == ChatColor.RED ? DyeColor.RED : DyeColor.BLUE; + + wolf.setCollarColor(dyeColor); + wolf.setTamed(true); + SpigotUtil.setOldOwner_RemoveMeWhenSpigotFixesThis(wolf, player); + wolf.setOwner(player); + wolf.setHealth(HEALTH); + wolf.setMaxHealth(HEALTH); + UtilEnt.vegetate(wolf); + MobaUtil.setTeamEntity(wolf, team); + + player.getWorld().playSound(player.getLocation(), Sound.WOLF_BARK, 1, 1.1F); + + data.getWolves().add(wolf); + + game.CreatureAllowOverride = false; + + useSkill(player); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java new file mode 100644 index 000000000..20e1444dc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java @@ -0,0 +1,168 @@ +package nautilus.game.arcade.game.games.moba.kit.bardolf; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +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.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.bardolf.HeroBardolf.WolfData; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +public class SkillWolfPounce extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving fire behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + private static final int COOLDOWN = 7000; + + private final Set _data = new HashSet<>(2); + + public SkillWolfPounce(int slot) + { + super("Wolf Pounce", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(COOLDOWN); + setSneakActivate(true); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _data.removeIf(data -> data.Leader.equals(event.getPlayer())); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @EventHandler + public void toggleSneak(PlayerToggleSneakEvent event) + { + if (!isSkillSneak(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @Override + public void useSkill(Player player) + { + super.useSkill(player); + + WolfData data = ((HeroBardolf) Kit).getWolfData(player); + + if (data == null) + { + return; + } + + for (Wolf wolf : data.getWolves()) + { + data.getOverrideTarget().put(wolf, player.getLocation()); + } + + Vector direction = player.getLocation().getDirection(); + direction.setY(Math.max(0.8, direction.getY())); + _data.add(new PounceData(player, data, direction)); + + UtilAction.velocity(player, direction); + + player.getWorld().playSound(player.getLocation(), Sound.WOLF_BARK, 2, 1F); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, player.getLocation().add(0, 0.6, 0), 0.5F, 0.5F, 0.5F, 0.1F, 15, ViewDist.LONG); + } + + @EventHandler + public void updateWolves(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + Iterator iterator = _data.iterator(); + + while (iterator.hasNext()) + { + PounceData data = iterator.next(); + + for (Wolf wolf : data.WolfData.getWolves()) + { + // Wolf has already leaped + if (data.LeapedWolves.contains(wolf) || UtilMath.offsetSquared(data.Target, wolf.getLocation()) > 4) + { + continue; + } + + data.LeapedWolves.add(wolf); + wolf.setVelocity(data.Direction); + wolf.getWorld().playSound(wolf.getLocation(), Sound.WOLF_WHINE, 1, 1.5F); + data.WolfData.getOverrideTarget().remove(wolf); + } + + if (UtilTime.elapsed(data.Time, COOLDOWN - 500)) + { + iterator.remove(); + data.WolfData.getOverrideTarget().clear(); + } + } + } + + private class PounceData + { + + Player Leader; + WolfData WolfData; + Location Target; + Vector Direction; + long Time; + List LeapedWolves; + + PounceData(Player leader, WolfData wolfData, Vector direction) + { + Leader = leader; + WolfData = wolfData; + Target = leader.getLocation(); + Direction = direction.multiply(1.5); + Time = System.currentTimeMillis(); + LeapedWolves = new ArrayList<>(5); + } + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java index ebda5b79a..15a6fe9f8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java @@ -7,6 +7,8 @@ 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.UtilTime; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.updater.UpdateType; @@ -15,7 +17,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.util.MobaParticles; import nautilus.game.arcade.game.games.moba.util.MobaUtil; -import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Type; @@ -110,6 +112,7 @@ public class SkillAOEHeal extends HeroSkill implements IThrown AOEHealData data = iterator.next(); Player owner = data.Owner; GameTeam team = Manager.GetGame().GetTeam(owner); + DustSpellColor colour = new DustSpellColor(team.GetColor() == ChatColor.RED ? java.awt.Color.RED : java.awt.Color.CYAN); if (UtilTime.elapsed(data.Start, DURATION)) { @@ -142,7 +145,7 @@ public class SkillAOEHeal extends HeroSkill implements IThrown data.Center.add(x, 0, z); - UtilParticle.playColoredParticleToAll(team.GetColorBase(), ParticleType.RED_DUST, data.Center, 1, ViewDist.LONG); + new ColoredParticle(ParticleType.RED_DUST, colour, data.Center).display(ViewDist.LONG); data.Center.subtract(x, 0, z); } From c8340730adf40090681a471938cb0c10ebd79c89 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 11 Jun 2017 00:00:28 +0100 Subject: [PATCH 161/283] Improve Bardolfs wolves --- .../arcade/game/games/moba/kit/HeroSkill.java | 5 + .../games/moba/kit/bardolf/HeroBardolf.java | 15 +- .../moba/kit/bardolf/SkillSummonWolf.java | 4 +- .../game/games/moba/kit/common/DashSkill.java | 2 +- .../games/moba/kit/devon/SkillTNTArrows.java | 13 +- .../games/moba/kit/rowena/HeroRowena.java | 34 ++++ .../moba/kit/rowena/SkillCombatDash.java | 40 +++++ .../moba/kit/rowena/SkillLightArrows.java | 154 ++++++++++++++++++ .../arcade/game/games/moba/shop/MobaShop.java | 16 +- .../arcade/game/games/moba/util/MobaUtil.java | 17 ++ 10 files changed, 276 insertions(+), 24 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 5b86d95a4..a813cd146 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -103,6 +103,11 @@ public class HeroSkill extends Perk action += "/Sneak"; } + if (_dropItemActivate) + { + action += "/Drop Item"; + } + List items = new ArrayList<>(2); for (ItemStack itemStack : _items) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java index e338d5313..b356195c6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.moba.kit.bardolf; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -33,7 +34,7 @@ import java.util.Map; public class HeroBardolf extends HeroKit { - private static final int MAX_DIST_SQUARED = 400; + private static final int MAX_DIST_SQUARED = 100; private final List _data; @@ -73,7 +74,7 @@ public class HeroBardolf extends HeroKit { if (data.getOverrideTarget().containsKey(wolf)) { - UtilEnt.CreatureMoveFast(wolf, data.getOverrideTarget().get(wolf), data.isUltmate() ? 3F : 2F); + UtilEnt.CreatureMoveFast(wolf, data.getOverrideTarget().get(wolf), data.isUltimate() ? 2F : 1.5F); return; } @@ -89,11 +90,11 @@ public class HeroBardolf extends HeroKit return; } - UtilEnt.CreatureMoveFast(wolf, wolf.getTarget().getLocation(), data.isUltmate() ? 3F : 2F); + UtilEnt.CreatureMoveFast(wolf, wolf.getTarget().getLocation(), data.isUltimate() ? 2F : 1.5F); - if (UtilMath.offsetSquared(wolf.getTarget(), wolf) < 9) + if (UtilMath.offsetSquared(wolf.getTarget(), wolf) < 9 && Recharge.Instance.use(data.getOwner(), "Wolf" + wolf.getTarget().getUniqueId(), 500, false, false)) { - Manager.GetDamage().NewDamageEvent(wolf.getTarget(), data.getOwner(), null, DamageCause.CUSTOM, 2, true, false, false, data.getOwner().getName(), "Wolf"); + Manager.GetDamage().NewDamageEvent(wolf.getTarget(), data.getOwner(), null, DamageCause.CUSTOM, 2, true, true, false, data.getOwner().getName(), "Wolf"); } } else if (ownerOffset > MAX_DIST_SQUARED) @@ -102,7 +103,7 @@ public class HeroBardolf extends HeroKit } else if (ownerOffset > 4) { - UtilEnt.CreatureMoveFast(wolf, data.getOwner().getLocation(), data.isUltmate() ? 3F : 2F); + UtilEnt.CreatureMoveFast(wolf, data.getOwner().getLocation(), data.isUltimate() ? 2F : 1.5F); } }); } @@ -267,7 +268,7 @@ public class HeroBardolf extends HeroKit _ultimate = ultimate; } - public boolean isUltmate() + public boolean isUltimate() { return _ultimate; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java index 40138bf8f..39e7a95ec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java @@ -33,7 +33,7 @@ public class SkillSummonWolf extends HeroSkill public SkillSummonWolf(int slot) { super("Summon Wolf", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); - setCooldown(1000); + setCooldown(5000); } @EventHandler @@ -57,7 +57,7 @@ public class SkillSummonWolf extends HeroSkill player.sendMessage(F.main("Game", "You have already summoned the maximum amount of wolves.")); return; } - else if (data.isUltmate()) + else if (data.isUltimate()) { player.sendMessage(F.main("Game", "You cannot summon new wolves right now.")); return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java index 6726e478c..7d8899320 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -182,7 +182,7 @@ public class DashSkill extends HeroSkill continue; } - if (_collideOnce && !Recharge.Instance.use(player, GetName() + player.getName() + entity.getUniqueId(), 500, false, false)) + if (_collideOnce && !Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false)) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java index 94d7b02a5..9149558ce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java @@ -9,10 +9,10 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -126,16 +126,7 @@ public class SkillTNTArrows extends HeroSkill location.getWorld().playSound(location, Sound.EXPLODE, 1, 0.9F); UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); - double damage = 10; - - // Scale damage with the damage on the player's bow - ItemStack itemStack = player.getInventory().getItem(0); - - // Player has a bow - if (itemStack != null && itemStack.getType() == Material.BOW) - { - damage += damage * itemStack.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) * 0.25; - } + double damage = MobaUtil.scaleDamageWithBow(player.getInventory().getItem(0),5); for (Entry entry : UtilEnt.getInRadius(location, 5).entrySet()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java new file mode 100644 index 000000000..81de69740 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.game.games.moba.kit.rowena; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.common.SkillBow; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroRowena extends HeroKit +{ + + private static final Perk[] PERKS = { + new SkillBow(0), + new SkillLightArrows(1), + new SkillCombatDash(2) + }; + + private static final ItemStack AMMO = new ItemBuilder(Material.ARROW) + .setTitle(C.cYellowB + "Hunting Arrow") + .setUnbreakable(true) + .build(); + + public HeroRowena(ArcadeManager manager) + { + super(manager, "Rowena", PERKS, MobaRole.HUNTER); + + setAmmo(AMMO, 2000); + setMaxAmmo(2); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java new file mode 100644 index 000000000..7a1db55a7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.moba.kit.rowena; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class SkillCombatDash extends DashSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving fire behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillCombatDash(int slot) + { + super("Combat Slide", DESCRIPTION, SKILL_ITEM, slot); + + setCooldown(8000); + + _collide = false; + _velocityTime = 400; + _velocityStopOnEnd = true; + _velocityMagnitude = 1.5; + _horizontial = true; + } + + @Override + public void preDash(Player player) + { + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.001F, 20, ViewDist.LONG); + player.getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1, 1); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java new file mode 100644 index 000000000..fe7221e1a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java @@ -0,0 +1,154 @@ +package nautilus.game.arcade.game.games.moba.kit.rowena; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +public class SkillLightArrows extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Your next 3 arrows are infused with TNT.", + "They explode on contact dealing damage and knockback." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.GOLD_NUGGET); + + private final Map _playerArrows = new HashMap<>(); + private final Map> _arrows = new HashMap<>(); + + public SkillLightArrows(int slot) + { + super("Light Arrows", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(12000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + _playerArrows.put(player, 5); + UtilInv.addDullEnchantment(player.getItemInHand()); + player.getItemInHand().setAmount(5); + } + + @EventHandler + public void shootArrow(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.getEntity(); + + if (!hasPerk(player) || !_playerArrows.containsKey(player)) + { + return; + } + + ItemStack itemStack = player.getInventory().getItem(getSlot()); + int arrows = _playerArrows.get(player); + + if (arrows == 1) + { + _playerArrows.remove(player); + useSkill(player); + } + else + { + arrows--; + _playerArrows.put(player, arrows); + itemStack.setAmount(arrows); + } + + event.getProjectile().remove(); + + _arrows.putIfAbsent(player, new HashSet<>()); + _arrows.get(player).add(new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.4, 20, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers())); + } + + @EventHandler + public void updateArrows(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Entry> entry : _arrows.entrySet()) + { + Player player = entry.getKey(); + Iterator iterator = entry.getValue().iterator(); + double damage = MobaUtil.scaleDamageWithBow(player.getInventory().getItem(0), 0); + + while (iterator.hasNext()) + { + LineParticle lineParticle = iterator.next(); + + if (!lineParticle.update()) + { + for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 1.5).keySet()) + { + if (Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false)) + { + player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 0.8F); + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName()); + } + } + } + else + { + iterator.remove(); + } + } + } + } + + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + _playerArrows.remove(event.getEntity()); + _arrows.remove(event.getEntity()); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _playerArrows.remove(event.getPlayer()); + _arrows.remove(event.getPlayer()); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 1538a04e4..fb75fd78a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -5,7 +5,6 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatComponent; @@ -26,7 +25,6 @@ import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop; import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop; import nautilus.game.arcade.game.games.moba.util.MobaConstants; -import nautilus.game.arcade.kit.Kit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; @@ -43,7 +41,6 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; -import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.HashMap; @@ -255,6 +252,19 @@ public class MobaShop implements Listener return null; } + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + List owned = _upgrades.get(event.getEntity()); + + owned.removeIf(item -> + { + MobaShopCategory category = getCategory(item); + + return category == null || category.isDroppingOnDeath(); + }); + } + /* Allow players to access the shop through an item */ diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 97bb33361..08c3923e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -9,8 +9,11 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; @@ -210,4 +213,18 @@ public class MobaUtil entity.setHealth(Math.min(entity.getHealth() + health, entity.getMaxHealth())); } + + public static double scaleDamageWithBow(ItemStack itemStack, double initialDamage) + { + // Set a base damage + initialDamage += 5; + + // Scale damage with the damage on the player's bow + if (itemStack != null && itemStack.getType() == Material.BOW) + { + initialDamage += initialDamage * itemStack.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) * 0.25; + } + + return initialDamage; + } } From a268b0dfff9707277319d74beb627f7ed868717b Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 12 Jun 2017 00:59:31 -0400 Subject: [PATCH 162/283] Fix freeze broadcasting to entire server unintentionally --- .../src/mineplex/game/clans/clans/ban/ClansBanManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java index 8b3d18877..ab8e38228 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java @@ -266,7 +266,7 @@ public class ClansBanManager extends MiniPlugin player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, -10)); for (Player alert : UtilServer.GetPlayers()) { - if (_clientManager.Get(staff).GetRank().has(null, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false)) + if (_clientManager.Get(alert).GetRank().has(null, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false)) { UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been frozen by " + F.elem(staff.getName()) + "!")); } @@ -287,7 +287,7 @@ public class ClansBanManager extends MiniPlugin player.removePotionEffect(PotionEffectType.JUMP); for (Player alert : UtilServer.GetPlayers()) { - if (_clientManager.Get(staff).GetRank().has(null, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false)) + if (_clientManager.Get(alert).GetRank().has(null, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false)) { UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been unfrozen by " + F.elem(staff.getName()) + "!")); continue; From 8ee5faf4d954dd5d50f7d82a85c0ea1bceb94895 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 12 Jun 2017 01:00:09 -0400 Subject: [PATCH 163/283] Change boxes more --- .../game/clans/clans/boxes/BoxManager.java | 63 +++++------ .../clans/clans/boxes/BoxOverviewPage.java | 2 +- .../clans/boxes/extra/BuilderBoxVerifier.java | 104 ++++++++++++++++++ .../clans/boxes/extra/DyeBoxSpinner.java | 7 +- 4 files changed, 138 insertions(+), 38 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxVerifier.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java index cef70aa3b..54b62deac 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java @@ -1,7 +1,5 @@ package mineplex.game.clans.clans.boxes; -import java.util.HashMap; -import java.util.Map; import java.util.function.Consumer; import org.bukkit.DyeColor; @@ -17,26 +15,27 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.command.CommandBase; -import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemBuilder; -import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.boxes.extra.BuilderBoxVerifier; import mineplex.game.clans.clans.boxes.extra.DyeBoxSpinner; public class BoxManager extends MiniPlugin { + private BuilderBoxVerifier _builderVerifier; + public BoxManager(JavaPlugin plugin) { super("Box Manager", plugin); final BoxShop shop = new BoxShop(this); + _builderVerifier = new BuilderBoxVerifier(this, shop); + addCommand(new CommandBase(this, Rank.ALL, "boxes", "box") { @Override @@ -68,6 +67,12 @@ public class BoxManager extends MiniPlugin return; } } + return; + } + if (event.getInventory().getResult().getType() == Material.INK_SACK) + { + event.getInventory().setResult(null); + return; } for (ItemStack item : event.getInventory().getMatrix()) { @@ -75,6 +80,10 @@ public class BoxManager extends MiniPlugin { continue; } + if (item.getType() != Material.INK_SACK) + { + continue; + } if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName() || !item.getItemMeta().getDisplayName().equals(C.cGold + "Dye")) { event.getInventory().setResult(null); @@ -103,6 +112,12 @@ public class BoxManager extends MiniPlugin return; } } + return; + } + if (event.getInventory().getResult().getType() == Material.INK_SACK) + { + event.setCancelled(true); + return; } for (ItemStack item : event.getInventory().getMatrix()) { @@ -110,10 +125,13 @@ public class BoxManager extends MiniPlugin { continue; } + if (item.getType() != Material.INK_SACK) + { + continue; + } if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName() || !item.getItemMeta().getDisplayName().equals(C.cGold + "Dye")) { event.setCancelled(true); - return; } } } @@ -151,31 +169,7 @@ public class BoxManager extends MiniPlugin public static enum BoxType { - @SuppressWarnings("deprecation") - BUILDER_BOX("Clans Builder Box", C.cGold + "Builder's Box", Material.GLOWSTONE, player -> - { - Map, ItemStack> replace = new HashMap<>(); - replace.put(Pair.create(Material.STONE, (byte)0), new ItemStack(Material.STAINED_CLAY)); - replace.put(Pair.create(Material.GLASS, (byte)0), new ItemStack(Material.STAINED_GLASS)); - replace.put(Pair.create(Material.THIN_GLASS, (byte)0), new ItemStack(Material.STAINED_GLASS_PANE)); - - for (int slot = 0; slot < player.getInventory().getSize(); slot++) - { - ItemStack item = player.getInventory().getItem(slot); - if (item == null) - { - continue; - } - ItemStack after = new ItemBuilder(replace.get(Pair.create(item.getType(), item.getData().getData()))).setData(DyeColor.values()[UtilMath.r(DyeColor.values().length)].getWoolData()).build(); - if (after != null) - { - after.setAmount(item.getAmount()); - player.getInventory().setItem(slot, after); - } - } - - UtilPlayer.message(player, F.main("Builder's Box", "You have redeemed your box contents!")); - }), + BUILDER_BOX("Clans Builder Box", C.cGold + "Builder's Box", Material.GLOWSTONE, Managers.get(BoxManager.class)._builderVerifier::showVerifier), @SuppressWarnings("deprecation") DYE_BOX("Clans Dye Box", C.cGreen + "Dye Box", Material.INK_SACK, DyeColor.RED.getDyeData(), DyeBoxSpinner::createSpinner), ; @@ -220,9 +214,8 @@ public class BoxManager extends MiniPlugin return newBuilder.addLore(C.cGreenB + "Owned: " + C.cWhite + owned).build(); } - public void generateRewards(Player player) + public void onUse(Player player) { - ClansManager.getInstance().getInventoryManager().addItemToInventory(player, getItemName(), -1); _itemGenerator.accept(player); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java index 76f74bb39..bd17da0de 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxOverviewPage.java @@ -39,7 +39,7 @@ public class BoxOverviewPage extends ShopPageBase player.playSound(player.getLocation(), Sound.CHEST_OPEN, 1f, 1f); if (Recharge.Instance.use(player, "Clans Box Click", 1000, false, false)) { - type.generateRewards(player); + type.onUse(player); } } }; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxVerifier.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxVerifier.java new file mode 100644 index 000000000..9bde6ee83 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxVerifier.java @@ -0,0 +1,104 @@ +package mineplex.game.clans.clans.boxes.extra; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.confirmation.ConfirmationCallback; +import mineplex.core.shop.confirmation.ConfirmationPage; +import mineplex.core.shop.confirmation.ConfirmationProcessor; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.boxes.BoxManager; +import mineplex.game.clans.clans.boxes.BoxManager.BoxType; +import mineplex.game.clans.clans.boxes.BoxShop; + +public class BuilderBoxVerifier +{ + private BoxManager _manager; + private BoxShop _shop; + + public BuilderBoxVerifier(BoxManager manager, BoxShop shop) + { + _manager = manager; + _shop = shop; + } + + public void showVerifier(Player player) + { + _shop.openPageForPlayer(player, new ConfirmationPage(player, _manager, _shop, Managers.get(CoreClientManager.class), Managers.get(DonationManager.class), new ConfirmationProcessor() + { + @Override + public void init(Inventory inventory) {} + + @SuppressWarnings("deprecation") + @Override + public void process(ConfirmationCallback callback) + { + ClansManager.getInstance().getInventoryManager().addItemToInventory(player, BoxType.BUILDER_BOX.getItemName(), -1); + + Map, ItemStack> replace = new HashMap<>(); + replace.put(Pair.create(Material.STONE, (byte)0), new ItemStack(Material.STAINED_CLAY)); + replace.put(Pair.create(Material.GLASS, (byte)0), new ItemStack(Material.STAINED_GLASS)); + replace.put(Pair.create(Material.THIN_GLASS, (byte)0), new ItemStack(Material.STAINED_GLASS_PANE)); + replace.put(Pair.create(Material.WOOL, (byte)0), new ItemStack(Material.WOOL)); + replace.put(Pair.create(Material.CARPET, (byte)0), new ItemStack(Material.CARPET)); + replace.put(Pair.create(Material.RED_ROSE, (byte)0), new ItemStack(Material.RED_ROSE)); + replace.put(Pair.create(Material.RED_ROSE, (byte)1), new ItemStack(Material.RED_ROSE)); + replace.put(Pair.create(Material.RED_ROSE, (byte)2), new ItemStack(Material.RED_ROSE)); + replace.put(Pair.create(Material.RED_ROSE, (byte)3), new ItemStack(Material.RED_ROSE)); + replace.put(Pair.create(Material.RED_ROSE, (byte)4), new ItemStack(Material.RED_ROSE)); + replace.put(Pair.create(Material.RED_ROSE, (byte)5), new ItemStack(Material.RED_ROSE)); + replace.put(Pair.create(Material.RED_ROSE, (byte)6), new ItemStack(Material.RED_ROSE)); + replace.put(Pair.create(Material.RED_ROSE, (byte)7), new ItemStack(Material.RED_ROSE)); + replace.put(Pair.create(Material.RED_ROSE, (byte)8), new ItemStack(Material.RED_ROSE)); + replace.put(Pair.create(Material.COBBLE_WALL, (byte)0), new ItemStack(Material.COBBLE_WALL)); + + for (int slot = 0; slot < player.getInventory().getSize(); slot++) + { + ItemStack item = player.getInventory().getItem(slot); + if (item == null) + { + continue; + } + Pair pair = Pair.create(item.getType(), item.getData().getData()); + if (!replace.containsKey(pair)) + { + continue; + } + ItemBuilder after = new ItemBuilder(replace.get(pair)); + if (after.getType() == Material.RED_ROSE) + { + after.setData((short)UtilMath.r(9)); + } + else if (after.getType() == Material.COBBLE_WALL) + { + after.setData((short)1); + } + else + { + after.setData(UtilMath.randomElement(DyeColor.values()).getWoolData()); + } + after.setAmount(item.getAmount()); + player.getInventory().setItem(slot, after.build()); + } + callback.resolve("You have redeemed your box!"); + + UtilPlayer.message(player, F.main("Builder's Box", "You have redeemed your box!")); + } + }, new ItemBuilder(Material.BARRIER).setTitle(C.cDRedB + "WARNING").setLore(C.cRedB + "ALL " + C.cRed + "compatible items", C.cRed + "in your inventory", C.cRed + "will be converted!").build())); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/DyeBoxSpinner.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/DyeBoxSpinner.java index 03f5d5ead..0186f6b56 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/DyeBoxSpinner.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/DyeBoxSpinner.java @@ -24,6 +24,8 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.boxes.BoxManager.BoxType; public class DyeBoxSpinner implements Listener { @@ -82,11 +84,11 @@ public class DyeBoxSpinner implements Listener DyeColor color = null; if (Math.random() <= 0.05) { - color = rareColors.get(UtilMath.r(rareColors.size())); + color = UtilMath.randomElement(rareColors); } else { - color = commonColors.get(UtilMath.r(commonColors.size())); + color = UtilMath.randomElement(commonColors); } _items.add(new ItemBuilder(Material.INK_SACK).setData(color.getDyeData()).setTitle(C.cGold + "Dye").build()); @@ -164,6 +166,7 @@ public class DyeBoxSpinner implements Listener public static void createSpinner(Player player) { + ClansManager.getInstance().getInventoryManager().addItemToInventory(player, BoxType.DYE_BOX.getItemName(), -1); new DyeBoxSpinner(player); } } \ No newline at end of file From ece14613844e7b62fb3914b69043097034ee303b Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 12 Jun 2017 01:01:24 -0400 Subject: [PATCH 164/283] Tidy up mounts and implement the mount skins --- .../game/clans/clans/mounts/Mount.java | 132 +++++++++++++++- .../game/clans/clans/mounts/MountManager.java | 147 ++++++++++++++---- .../clans/clans/mounts/MountOwnerData.java | 4 +- .../clans/mounts/gui/MountOverviewPage.java | 13 +- .../clans/clans/mounts/gui/MountSkinPage.java | 142 +++++++++++++++++ 5 files changed, 389 insertions(+), 49 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountSkinPage.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java index e2dbe7adf..093631e9b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/Mount.java @@ -2,6 +2,8 @@ package mineplex.game.clans.clans.mounts; import java.util.function.Consumer; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHorse; import org.bukkit.entity.EntityType; @@ -13,8 +15,16 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.TriConsumer; import mineplex.core.common.util.C; +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.UtilServer; import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseCow; +import mineplex.core.disguise.disguises.DisguiseSheep; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.ClansManager; import net.minecraft.server.v1_8_R3.GenericAttributes; public class Mount @@ -64,6 +74,16 @@ public class Mount public void despawn(boolean forced) { UtilServer.CallEvent(new MountDespawnEvent(this, forced)); + _entity.getInventory().setSaddle(null); + _entity.getInventory().setArmor(null); + for (ItemStack item : _entity.getInventory().getContents()) + { + if (item == null || item.getType() == Material.AIR) + { + continue; + } + _entity.getWorld().dropItem(_entity.getLocation(), item); + } _entity.remove(); } @@ -78,25 +98,108 @@ public class Mount public static enum SkinType { + INFERNAL_HORROR(1, "Clans Infernal Horror Mount Skin", C.cRed + "Infernal Horror", Material.BONE, Color.BLACK, Variant.SKELETON_HORSE, Style.BLACK_DOTS, horse -> {}, horse -> + { + UtilParticle.PlayParticleToAll(ParticleType.FLAME, horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0, 2,ViewDist.NORMAL); + }, MountType.HORSE), + GLACIAL_STEED(2, "Clans Glacial Steed Mount Skin", C.cGray + "Glacial Steed", Material.SNOW_BALL, Color.WHITE, Variant.HORSE, Style.WHITE, horse -> {}, horse -> + { + UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0.1f, 4, ViewDist.NORMAL); + }, MountType.HORSE), + ZOMBIE_HORSE(3, "Clans Zombie Horse Mount Skin", C.cDGray + "Zombie Horse", Material.ROTTEN_FLESH, Color.BLACK, Variant.UNDEAD_HORSE, Style.BLACK_DOTS, horse -> {}, horse -> + { + UtilParticle.PlayParticleToAll(ParticleType.FOOTSTEP, horse.getLocation(), + null, 0, 1, ViewDist.NORMAL); + }, MountType.HORSE), + @SuppressWarnings("deprecation") + RAINBOW_SHEEP(4, "Clans Rainbow Sheep Mount Skin", C.cGreen + "Rainbow " + C.cAqua + "Sheep", new ItemBuilder(Material.WOOL).setData(DyeColor.RED.getWoolData()).build(),Color.WHITE, Variant.HORSE, Style.NONE, horse -> + { + DisguiseSheep disguise = new DisguiseSheep(horse); + disguise.setName(horse.getCustomName()); + ClansManager.getInstance().getDisguiseManager().disguise(disguise); + }, horse -> + { + DisguiseBase base = ClansManager.getInstance().getDisguiseManager().getActiveDisguise(horse); + if (base == null || !(base instanceof DisguiseSheep)) + { + return; + } + + DisguiseSheep sheep = (DisguiseSheep)base; + + if (horse.getTicksLived() % 4 == 0) sheep.setColor(DyeColor.RED); + else if (horse.getTicksLived() % 4 == 1) sheep.setColor(DyeColor.YELLOW); + else if (horse.getTicksLived() % 4 == 2) sheep.setColor(DyeColor.GREEN); + else if (horse.getTicksLived() % 4 == 3) sheep.setColor(DyeColor.BLUE); + }, MountType.HORSE), + ROYAL_STEED(5, "Clans Royal Steed Mount Skin", C.cGold + "Royal Steed", Material.DIAMOND_BARDING, Color.WHITE, Variant.HORSE, Style.WHITE, horse -> + { + horse.getInventory().setArmor(new ItemBuilder(Material.DIAMOND_BARDING).setTitle(C.cGoldB + "Royal Armor").build()); + }, horse -> + { + UtilParticle.PlayParticleToAll(ParticleType.BLOCK_DUST.getParticle(Material.GOLD_BLOCK, 0), horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0, 3, ViewDist.NORMAL); + }, MountType.HORSE), + ROYAL_GUARD_STEED(6, "Clans Royal Guard Steed Mount Skin", C.cGray + "Royal Guard's Steed", Material.GOLD_BARDING, Color.BLACK, Variant.HORSE, Style.NONE, horse -> + { + horse.getInventory().setArmor(new ItemBuilder(Material.GOLD_BARDING).setTitle(C.cGoldB + "Guardian Armor").build()); + }, horse -> + { + UtilParticle.PlayParticleToAll(ParticleType.BLOCK_DUST.getParticle(Material.IRON_BLOCK, 0), horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0, 3, ViewDist.NORMAL); + }, MountType.HORSE), + KNIGHT_STEED(7, "Clans Knight Steed Mount Skin", C.cDRed + "Knight's Steed", Material.IRON_BARDING, Color.GRAY, Variant.HORSE, Style.NONE, horse -> + { + horse.getInventory().setArmor(new ItemBuilder(Material.IRON_BARDING).setTitle(C.cGoldB + "Knightly Armor").build()); + }, horse -> + { + UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.APPLE, 0), horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0, 3, ViewDist.NORMAL); + }, MountType.HORSE), + COW(8, "Clans Cow Mount Skin", C.cWhite + "Cow", Material.MILK_BUCKET, Color.WHITE, Variant.HORSE, Style.NONE, horse -> + { + DisguiseCow disguise = new DisguiseCow(horse); + disguise.setName(horse.getCustomName()); + ClansManager.getInstance().getDisguiseManager().disguise(disguise); + }, horse -> {}, MountType.HORSE), + SHEEP(9, "Clans Sheep Mount Skin", C.cWhite + "Sheep", Material.WOOL, Color.WHITE, Variant.HORSE, Style.NONE, horse -> + { + DisguiseSheep disguise = new DisguiseSheep(horse); + disguise.setName(horse.getCustomName()); + ClansManager.getInstance().getDisguiseManager().disguise(disguise); + }, horse -> {}, MountType.HORSE), + TRUSTY_MULE(10, "Clans Trusty Mule Mount Skin", C.cBlue + "Trusty Mule", Material.APPLE, Color.BROWN, Variant.MULE, Style.NONE, horse -> {}, horse -> {}, MountType.DONKEY) ; private final int _id; private final String _packageName; private final String _displayName; + private final ItemStack _baseDisplayItem; private final Color _color; private final Variant _variant; private final Style _style; - private final Consumer _onUpdate; + private final Consumer _onSpawn, _onUpdate; + private final MountType[] _possibleTypes; - private SkinType(int id, String packageName, String displayName, Color color, Variant variant, Style style, Consumer onUpdate) + private SkinType(int id, String packageName, String displayName, Material displayType, Color color, Variant variant, Style style, Consumer onSpawn, Consumer onUpdate, MountType... possibleTypes) + { + this(id, packageName, displayName, new ItemStack(displayType), color, variant, style, onSpawn, onUpdate, possibleTypes); + } + + private SkinType(int id, String packageName, String displayName, ItemStack baseDisplayItem, Color color, Variant variant, Style style, Consumer onSpawn, Consumer onUpdate, MountType... possibleTypes) { _id = id; _packageName = packageName; _displayName = displayName; + _baseDisplayItem = baseDisplayItem; _color = color; _variant = variant; _style = style; + _onSpawn = onSpawn; _onUpdate = onUpdate; + _possibleTypes = possibleTypes; } public int getId() @@ -114,6 +217,11 @@ public class Mount return _displayName; } + public ItemStack getBaseDisplay() + { + return _baseDisplayItem; + } + public Color getColor() { return _color; @@ -129,11 +237,21 @@ public class Mount return _style; } + public void onSpawn(CraftHorse horse) + { + _onSpawn.accept(horse); + } + public void onUpdate(CraftHorse horse) { _onUpdate.accept(horse); } + public MountType[] getPossibleTypes() + { + return _possibleTypes; + } + public static SkinType getFromId(int id) { for (SkinType type : SkinType.values()) @@ -156,19 +274,20 @@ public class Mount horse.setAdult(); horse.setAgeLock(true); horse.setBreed(false); + horse.setCustomNameVisible(true); + horse.setCustomName(owner.getName() + "'s " + (skin == null ? "Horse" : ChatColor.stripColor(skin.getDisplayName()))); if (skin != null) { horse.setVariant(skin.getVariant()); horse.setColor(skin.getColor()); horse.setStyle(skin.getStyle()); + skin.onSpawn(horse); } horse.setTamed(true); horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); horse.setOwner(owner); horse.setJumpStrength(MountManager.getJump(stats.JumpStars)); horse.getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(MountManager.getSpeed(stats.SpeedStars)); - horse.setCustomNameVisible(true); - horse.setCustomName(owner.getName() + "'s " + (skin == null ? "Horse" : skin.getDisplayName())); //horse.setPassenger(owner); Mount mount = new Mount(owner, horse, skin, MountManager.getStrength(stats.StrengthStars)); UtilServer.CallEvent(new MountSpawnEvent(mount)); @@ -179,9 +298,12 @@ public class Mount horse.setAdult(); horse.setAgeLock(true); horse.setBreed(false); + horse.setCustomNameVisible(true); + horse.setCustomName(owner.getName() + "'s " + (skin == null ? "Donkey" : ChatColor.stripColor(skin.getDisplayName()))); if (skin != null) { horse.setVariant(skin.getVariant()); + skin.onSpawn(horse); } else { @@ -192,8 +314,6 @@ public class Mount horse.setOwner(owner); horse.setJumpStrength(MountManager.getJump(stats.JumpStars)); horse.getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(MountManager.getSpeed(stats.SpeedStars)); - horse.setCustomNameVisible(true); - horse.setCustomName(owner.getName() + "'s " + (skin == null ? "Donkey" : skin.getDisplayName())); horse.setCarryingChest(true); //horse.setPassenger(owner); Mount mount = new Mount(owner, horse, skin, MountManager.getStrength(stats.StrengthStars)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java index 31875f5ba..bf5ae510b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -6,7 +6,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; -import java.util.Optional; import java.util.UUID; import java.util.WeakHashMap; @@ -90,7 +89,7 @@ public class MountManager extends MiniDbClientPlugin { if (args.length < 4) { - UtilPlayer.message(caller, F.main(getName(), "Usage: /" + _aliasUsed + " , , , ")); + UtilPlayer.message(caller, F.main(getName(), "Usage: /" + _aliasUsed + " ")); return; } @@ -154,6 +153,14 @@ public class MountManager extends MiniDbClientPlugin return _repository; } + @Override + public void disable() + { + _summoning.clear(); + _spawnedMounts.keySet().forEach(CraftHorse::remove); + _spawnedMounts.clear(); + } + public boolean summonMount(Player player, MountToken token) { if (_summoning.containsKey(player)) @@ -171,6 +178,11 @@ public class MountManager extends MiniDbClientPlugin UtilPlayer.message(player, F.main(getName(), "You cannot summon a mount in the Nether!")); return false; } + if (ClansManager.getInstance().getWorldEvent().getRaidManager().isInRaid(player.getLocation())) + { + UtilPlayer.message(player, F.main(getName(), "You cannot summon a mount inside a raid!")); + return false; + } if (!Recharge.Instance.usable(player, "Mount Spawn Delay")) { UtilPlayer.message(player, F.main(getName(), "You cannot summon a mount so soon after your last one was forcibly despawned!")); @@ -194,6 +206,23 @@ public class MountManager extends MiniDbClientPlugin _repository.saveMount(ClientManager.getAccountId(player), tokens.getLeft(), tokens.getRight()); } + public void removeMountToken(Player player, MountToken token, Runnable after) + { + getRepository().deleteMount(token, id -> + { + Get(player).removeMount(id.intValue()); + Pair summonPair = _summoning.get(player); + if (summonPair != null) + { + if (summonPair.getRight().Id == id) + { + UtilEnt.addFlag(player, "REMOVED_MOUNT_TOKEN"); + } + } + after.run(); + }); + } + @EventHandler public void onUpdate(UpdateEvent event) { @@ -221,6 +250,18 @@ public class MountManager extends MiniDbClientPlugin entry.getValue().despawn(false); continue; } + if (ClansManager.getInstance().getNetherManager().isInNether(entry.getKey().getLocation())) + { + mountIterator.remove(); + entry.getValue().despawn(false); + continue; + } + if (ClansManager.getInstance().getWorldEvent().getRaidManager().isInRaid(entry.getKey().getLocation())) + { + mountIterator.remove(); + entry.getValue().despawn(false); + continue; + } if (entry.getKey().getPassenger() == null) { if (UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME") != null) @@ -249,9 +290,31 @@ public class MountManager extends MiniDbClientPlugin while (summoningIterator.hasNext()) { Entry> entry = summoningIterator.next(); + if (UtilEnt.hasFlag(entry.getKey(), "REMOVED_MOUNT_TOKEN")) + { + summoningIterator.remove(); + UtilEnt.removeFlag(entry.getKey(), "REMOVED_MOUNT_TOKEN"); + continue; + } if (UtilTime.elapsed(entry.getValue().getLeft(), SUMMON_WARMUP)) { summoningIterator.remove(); + if (entry.getKey().isDead() || !entry.getKey().isValid() || !entry.getKey().isOnline()) + { + continue; + } + if (Spawn.getInstance().isSafe(entry.getKey().getLocation())) + { + continue; + } + if (ClansManager.getInstance().getNetherManager().isInNether(entry.getKey().getLocation())) + { + continue; + } + if (ClansManager.getInstance().getWorldEvent().getRaidManager().isInRaid(entry.getKey().getLocation())) + { + continue; + } entry.getValue().getRight().Type.spawn(entry.getKey(), entry.getValue().getRight().Skin, Get(entry.getKey()).getStatToken(entry.getValue().getRight())); continue; } @@ -333,37 +396,49 @@ public class MountManager extends MiniDbClientPlugin } @EventHandler(priority = EventPriority.LOWEST) - public void handleHits(CustomDamageEvent event) + public void handleHorseHits(CustomDamageEvent event) { - if (event.GetDamageeEntity() == null) + if (event.GetDamageeEntity() == null || !(event.GetDamageeEntity() instanceof Horse)) { return; } - Mount[] spawned = _spawnedMounts.values().toArray(new Mount[_spawnedMounts.size()]); - for (Mount mount : spawned) + Mount mount = _spawnedMounts.get(event.GetDamageeEntity()); + if (mount == null) { - if (mount.getEntity().getEntityId() == event.GetDamageeEntity().getEntityId()) - { - if (event.GetDamagerPlayer(true) != null && event.GetDamagerPlayer(true).getEntityId() == mount.getOwner().getEntityId()) - { - event.SetCancelled("Damaging own mount"); - return; - } - event.setDamagee(mount.getOwner()); - if (event.GetCause() != DamageCause.FALL) - { - mount.handleHit(); - } - return; - } - if (mount.getOwner().getEntityId() == event.GetDamageeEntity().getEntityId()) - { - if (event.GetCause() != DamageCause.FALL) - { - mount.handleHit(); - } - return; - } + return; + } + if (event.GetDamagerPlayer(true) != null && event.GetDamagerPlayer(true).getEntityId() == mount.getOwner().getEntityId()) + { + event.SetCancelled("Damaging own mount"); + mount.despawn(false); + return; + } + event.setDamagee(mount.getOwner()); + if (event.GetCause() != DamageCause.FALL) + { + mount.handleHit(); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void handleRiderHits(CustomDamageEvent event) + { + if (event.GetDamageePlayer() == null || event.GetDamageePlayer().getVehicle() == null || !(event.GetDamageePlayer().getVehicle() instanceof Horse)) + { + return; + } + if (event.GetDamagerPlayer(true) != null && event.GetDamagerPlayer(true).getEntityId() == event.GetDamageePlayer().getEntityId()) + { + return; + } + Mount mount = _spawnedMounts.get(event.GetDamageePlayer().getVehicle()); + if (mount == null) + { + return; + } + if (event.GetCause() != DamageCause.FALL) + { + mount.handleHit(); } } @@ -374,8 +449,14 @@ public class MountManager extends MiniDbClientPlugin { return; } - - event.setCancelled(true); + if (!_spawnedMounts.containsKey(event.getClickedInventory().getHolder())) + { + return; + } + if (event.getSlot() == 0 || event.getSlot() == 1) + { + event.setCancelled(true); + } } @EventHandler @@ -385,12 +466,12 @@ public class MountManager extends MiniDbClientPlugin { return; } - Optional opt = _spawnedMounts.entrySet().stream().filter(entry -> entry.getKey().getEntityId() == event.getRightClicked().getEntityId()).map(Entry::getValue).findAny(); - if (!opt.isPresent()) + Mount mount = _spawnedMounts.get(event.getRightClicked()); + if (mount == null) { return; } - if (opt.get().getOwner().getEntityId() == event.getPlayer().getEntityId()) + if (mount.getOwner().getEntityId() == event.getPlayer().getEntityId()) { return; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountOwnerData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountOwnerData.java index f962de9a7..9fdf52455 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountOwnerData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountOwnerData.java @@ -1,6 +1,6 @@ package mineplex.game.clans.clans.mounts; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -11,7 +11,7 @@ import mineplex.game.clans.clans.mounts.Mount.MountType; public class MountOwnerData { - private Map _mounts = new HashMap<>(); + private Map _mounts = new LinkedHashMap<>(); public List> getOwnedMounts(boolean onlyInitialized) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java index 6e9b9fbad..e3e1021ca 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountOverviewPage.java @@ -36,6 +36,7 @@ public class MountOverviewPage extends ShopPageBase { ItemBuilder builder = new ItemBuilder(mountToken.Type.getDisplayType()); builder.setTitle(mountToken.Type.getDisplayName() + " Mount"); + builder.addLore(C.cPurple + "Skin: " + (mountToken.Skin == null ? C.cYellow + "Default" : mountToken.Skin.getDisplayName())); String strength = C.cYellow; for (int i = 0; i < statToken.StrengthStars; i++) { @@ -93,8 +94,7 @@ public class MountOverviewPage extends ShopPageBase } else if (clickType == ClickType.RIGHT) { - playDenySound(player); - //getShop().openPageForPlayer(player, page); + getShop().openPageForPlayer(player, new MountSkinPage(this, player, tokens.getLeft())); } else if (clickType == ClickType.SHIFT_RIGHT) { @@ -106,9 +106,8 @@ public class MountOverviewPage extends ShopPageBase @Override public void process(ConfirmationCallback callback) { - getPlugin().getRepository().deleteMount(tokens.getLeft(), id -> + getPlugin().removeMountToken(player, tokens.getLeft(), () -> { - getPlugin().Get(getPlayer()).removeMount(id.intValue()); MountOverviewPage.this.refresh(); callback.resolve("Mount successfully deleted!"); }); @@ -139,8 +138,7 @@ public class MountOverviewPage extends ShopPageBase } else if (clickType == ClickType.RIGHT) { - playDenySound(player); - //getShop().openPageForPlayer(player, page); + getShop().openPageForPlayer(player, new MountSkinPage(this, player, tokens.getLeft())); } else if (clickType == ClickType.SHIFT_RIGHT) { @@ -152,9 +150,8 @@ public class MountOverviewPage extends ShopPageBase @Override public void process(ConfirmationCallback callback) { - getPlugin().getRepository().deleteMount(tokens.getLeft(), id -> + getPlugin().removeMountToken(player, tokens.getLeft(), () -> { - getPlugin().Get(getPlayer()).removeMount(id.intValue()); MountOverviewPage.this.refresh(); callback.resolve("Mount successfully deleted!"); }); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountSkinPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountSkinPage.java new file mode 100644 index 000000000..64498e6c1 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountSkinPage.java @@ -0,0 +1,142 @@ +package mineplex.game.clans.clans.mounts.gui; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.mounts.Mount.SkinType; +import mineplex.game.clans.clans.mounts.MountManager; +import mineplex.game.clans.clans.mounts.MountToken; + +public class MountSkinPage extends ShopPageBase +{ + private MountOverviewPage _overview; + private MountToken _token; + + public MountSkinPage(MountOverviewPage overview, Player player, MountToken token) + { + super(overview.getPlugin(), overview.getShop(), overview.getClientManager(), overview.getDonationManager(), "Skin Management", player, 54); + + _overview = overview; + _token = token; + buildPage(); + } + + private List getAllowed() + { + List allowed = new LinkedList<>(); + + for (SkinType type : SkinType.values()) + { + if (Arrays.asList(type.getPossibleTypes()).contains(_token.Type)) + { + allowed.add(type); + } + } + + return allowed; + } + + private boolean hasUnlocked(Player player, SkinType type) + { + if (getClientManager().Get(player).GetRank().has(Rank.ADMIN)) + { + return true; + } + + return getDonationManager().Get(player).ownsUnknownSalesPackage(type.getPackageName()); + } + + private boolean hasUnlocked(SkinType type) + { + return hasUnlocked(getPlayer(), type); + } + + private ItemStack buildResetItem() + { + ItemBuilder builder = new ItemBuilder(Material.WATER_BUCKET); + + builder.setTitle(C.cYellow + "Default Skin"); + if (_token.Skin == null) + { + builder.setLore(C.cRed, C.cGreenB + "SELECTED"); + } + + return builder.build(); + } + + private ItemStack buildSkinItem(SkinType type) + { + ItemBuilder builder = new ItemBuilder(type.getBaseDisplay()); + + builder.setTitle(type.getDisplayName()); + builder.setLore(C.cRed); + if (_token.Skin == type) + { + builder.addLore(C.cGreenB + "SELECTED"); + } + else if (hasUnlocked(type)) + { + builder.addLore(C.cGreenB + "UNLOCKED"); + } + else + { + builder.addLore(C.cGray + "Available at http://www.mineplex.com/shop"); + builder.addLore(C.cRedB + "LOCKED"); + } + + return builder.build(); + } + + @Override + protected void buildPage() + { + addButton(0, new ItemBuilder(Material.BED).setTitle(C.cGreen + "Back").build(), (player, clickType) -> + { + _overview.refresh(); + getShop().openPageForPlayer(player, _overview); + }); + addButton(13, buildResetItem(), (player, clickType) -> + { + if (_token.Skin == null) + { + playDenySound(player); + } + else + { + playAcceptSound(player); + _token.Skin = null; + getPlugin().getRepository().saveMount(getClientManager().Get(player).getAccountId(), _token, getPlugin().Get(player).getStatToken(_token)); + refresh(); + } + }); + int[] skinSlots = {20, 21, 22, 23, 24, 29, 30, 31, 32, 33, 38, 39, 40, 41, 42}; + List allowed = getAllowed(); + for (int i = 0; i < skinSlots.length && i < allowed.size(); i++) + { + SkinType type = allowed.get(i); + addButton(skinSlots[i], buildSkinItem(type), (player, clickType) -> + { + if (hasUnlocked(player, type) && _token.Skin != type) + { + playAcceptSound(player); + _token.Skin = type; + getPlugin().getRepository().saveMount(getClientManager().Get(player).getAccountId(), _token, getPlugin().Get(player).getStatToken(_token)); + refresh(); + } + else + { + playDenySound(player); + } + }); + } + } +} \ No newline at end of file From f1b9a99576887a60b7dfdaf5a66c31eed747849f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 12 Jun 2017 01:01:48 -0400 Subject: [PATCH 165/283] Make mounts disable when server does --- .../src/mineplex/game/clans/clans/ClansManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 266558b6e..cda5d8645 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -1226,6 +1226,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _safeLog.onDisable(); _restartManager.onDisable(); _observerManager.onDisable(); + Managers.get(MountManager.class).onDisable(); } @EventHandler(priority = EventPriority.HIGHEST) From c265b235be1975a96c691e092d7afd7739af6e25 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 12 Jun 2017 01:02:04 -0400 Subject: [PATCH 166/283] Tidy up ClansAdmin Commands --- .../mineplex/game/clans/clans/ClansAdmin.java | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java index 3b8c45896..fcc116670 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java @@ -372,15 +372,11 @@ public class ClansAdmin } else { - Clans.getClanDataAccess().war(clan, clanAgainst, value, new Callback() + Clans.getClanDataAccess().war(clan, clanAgainst, value, data -> { - @Override - public void run(ClanWarData data) - { - UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(data.getClanB()))); - Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); - Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); - } + UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(data.getClanB()))); + Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); }); } } @@ -401,15 +397,11 @@ public class ClansAdmin } else { - Clans.getClanDataAccess().war(clan, clanAgainst, value, new Callback() + Clans.getClanDataAccess().war(clan, clanAgainst, value, data -> { - @Override - public void run(ClanWarData data) - { - UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(data.getClanB()))); - Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); - Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); - } + UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(data.getClanB()))); + Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); + Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!")); }); } } From 3d88c2c9a55ca8b3e265625462805560a21fefa6 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 12 Jun 2017 01:02:38 -0400 Subject: [PATCH 167/283] Block territory claiming and setting clan homes in the nether --- .../game/clans/clans/nether/NetherManager.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index e102990e2..58686ec12 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -500,13 +500,19 @@ public class NetherManager extends MiniPlugin @EventHandler public void onTpHome(ClansCommandExecutedEvent event) { + if (!isInNether(event.getPlayer())) + { + return; + } if (event.getCommand().equalsIgnoreCase("tphome") || event.getCommand().equalsIgnoreCase("stuck")) { - if (isInNether(event.getPlayer())) - { - event.setCancelled(true); - UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport while in " + F.clansNether("The Nether") + "!")); - } + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport while in " + F.clansNether("The Nether") + "!")); + } + if (event.getCommand().equalsIgnoreCase("claim") || event.getCommand().equalsIgnoreCase("unclaim") || event.getCommand().equalsIgnoreCase("unclaimall") || event.getCommand().equalsIgnoreCase("homeset")) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot manage your clan's territory while in " + F.clansNether("The Nether") + "!")); } } From d2d3b88651f592c1efc4b202ff7d58dd50afc915 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 12 Jun 2017 01:03:15 -0400 Subject: [PATCH 168/283] Improve siege weapons --- .../game/clans/clans/siege/SiegeManager.java | 57 ++++++ .../clans/clans/siege/outpost/Outpost.java | 167 ++++++++++++++---- .../clans/siege/outpost/OutpostManager.java | 17 +- .../repository/tokens/SiegeWeaponToken.java | 8 +- .../clans/clans/siege/weapon/SiegeWeapon.java | 4 + .../clans/siege/weapon/projectile/Crater.java | 4 +- .../weapon/projectile/WeaponProjectile.java | 7 - 7 files changed, 216 insertions(+), 48 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index ab406664c..38ce9f2fc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -10,6 +10,7 @@ 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.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; @@ -217,6 +218,16 @@ public class SiegeManager extends MiniPlugin { event.setCancelled(true); + int health = ItemStackFactory.Instance.GetLoreVar(event.getPlayer().getItemInHand(), "Health", 0); + if (health != 0) + { + if (trySpawnCannon(event.getPlayer(), event.getBlock().getLocation())) + { + event.getPlayer().setItemInHand(UtilInv.decrement(event.getPlayer().getItemInHand())); + } + return; + } + if (trySpawnCannon(event.getPlayer(), event.getBlock().getLocation())) { event.getPlayer().setItemInHand(UtilInv.decrement(event.getPlayer().getItemInHand())); @@ -236,6 +247,46 @@ public class SiegeManager extends MiniPlugin // } } + public boolean trySpawnCannon(Player player, Location location, int health) + { + if (_clansManager.getNetherManager().isInNether(player)) + { + _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + "."); + + return false; + } + if (_clansManager.getWorldEvent().getRaidManager().isInRaid(player.getLocation())) + { + _clansManager.message(player, "You are not allowed to place this in a raid."); + + return false; + } + + if (!_clansManager.isInClan(player)) + { + UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place a Cannon.")); + return false; + } + + if (_clansManager.hasTimer(player)) + { + UtilPlayer.message(player, F.main("Clans", "You cannot place a Cannon whilst protected from pvp.")); + return false; + } + + ClanTerritory claim = _clansManager.getClanUtility().getClaim(location); + + if (claim != null && !claim.Owner.equals(_clansManager.getClan(player).getName())) + { + UtilPlayer.message(player, F.main("Clans", "You must place a Cannon in the Wilderness or your own Territory.")); + return false; + } + + spawnCannon(player, location).setHealth(health); + + return true; + } + public boolean trySpawnCannon(Player player, Location location) { if (_clansManager.getNetherManager().isInNether(player)) @@ -244,6 +295,12 @@ public class SiegeManager extends MiniPlugin return false; } + if (_clansManager.getWorldEvent().getRaidManager().isInRaid(player.getLocation())) + { + _clansManager.message(player, "You are not allowed to place this in a raid."); + + return false; + } if (!_clansManager.isInClan(player)) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index f49712a83..c20834e30 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -64,11 +64,13 @@ import net.minecraft.server.v1_8_R3.AxisAlignedBB; public class Outpost implements Listener { - protected static final long MAX_LIFETIME = 30 * 60 * 1000; // 30 minutes + protected static final long MAX_LIFETIME = 45 * 60 * 1000; // 30 minutes public static final ItemStack OUTPOST_ITEM = new ItemBuilder(Material.BEACON, 1).setRawTitle(C.Reset + C.cBlue + "Outpost").build(); public static final long PREP_TIME = 2 * 60 * 1000; + private static final int MAX_HEALTH = 100; + private OutpostManager _outpostManager; private final int _uniqueId; @@ -104,10 +106,18 @@ public class Outpost implements Listener private Hologram _lifetimeLeft; + private int _health; + + private long _lastDamage; + + private long _lastRegen; + public Outpost(OutpostManager outpostManager, OutpostToken token) { _outpostManager = outpostManager; + _health = MAX_HEALTH; + _uniqueId = token.UniqueId; _ownerClan = token.OwnerClan; @@ -138,7 +148,36 @@ public class Outpost implements Listener return; if (clickType == ClickType.LEFT || clickType == ClickType.SHIFT_LEFT) - kill(); + { + if (_outpostManager.getClansManager().hasTimer(player)) + { + UtilPlayer.message(player, F.main("Clans", "You cannot destroy an Outpost whilst protected from PvP.")); + return; + } + if (!UtilTime.elapsed(_lastDamage, 5000)) + { + return; + } + if (_health <= 2) + { + UtilPlayer.message(player, F.main("Clans", "You have destroyed " + F.elem(_ownerClan.getName()) + "'s Outpost!")); + + _core.getBlock().setType(Material.AIR); + + _ownerClan.inform("Your Outpost has been destroyed!", null); + UtilTextMiddle.display("Siege", "Your Outpost has been destroyed", 20, 100, 20, _ownerClan.getOnlinePlayersArray()); + + if (getState() == OutpostState.AWAITING) + cleanup(); + else + kill(); + + return; + } + + _lastDamage = System.currentTimeMillis(); + _health -= 2; + } } }); @@ -166,6 +205,8 @@ public class Outpost implements Listener { _outpostManager = outpostManager; + _health = MAX_HEALTH; + _uniqueId = outpostManager.getSiegeManager().randomId(); _ownerClan = clan; @@ -211,7 +252,36 @@ public class Outpost implements Listener return; if (clickType == ClickType.LEFT || clickType == ClickType.SHIFT_LEFT) - kill(); + { + if (_outpostManager.getClansManager().hasTimer(player)) + { + UtilPlayer.message(player, F.main("Clans", "You cannot destroy an Outpost whilst protected from PvP.")); + return; + } + if (!UtilTime.elapsed(_lastDamage, 5000)) + { + return; + } + if (_health <= 2) + { + UtilPlayer.message(player, F.main("Clans", "You have destroyed " + F.elem(_ownerClan.getName()) + "'s Outpost!")); + + _core.getBlock().setType(Material.AIR); + + _ownerClan.inform("Your Outpost has been destroyed!", null); + UtilTextMiddle.display("Siege", "Your Outpost has been destroyed", 20, 100, 20, _ownerClan.getOnlinePlayersArray()); + + if (getState() == OutpostState.AWAITING) + cleanup(); + else + kill(); + + return; + } + + _lastDamage = System.currentTimeMillis(); + _health -= 2; + } } }); } @@ -306,26 +376,35 @@ public class Outpost implements Listener { if (event.getBlock().getLocation().equals(_core) && getState() == OutpostState.LIVE) { - - if(_outpostManager.getClansManager().hasTimer(event.getPlayer())) + event.setCancelled(true); + if (_outpostManager.getClansManager().hasTimer(event.getPlayer())) { UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy an Outpost whilst protected from PvP.")); - event.setCancelled(true); return; } - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have destroyed " + F.elem(_ownerClan.getName()) + "'s Outpost!")); + if (!UtilTime.elapsed(_lastDamage, 5000)) + { + return; + } + if (_health <= 2) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have destroyed " + F.elem(_ownerClan.getName()) + "'s Outpost!")); + + _core.getBlock().setType(Material.AIR); + + _ownerClan.inform("Your Outpost has been destroyed!", null); + UtilTextMiddle.display("Siege", "Your Outpost has been destroyed", 20, 100, 20, _ownerClan.getOnlinePlayersArray()); + + if (getState() == OutpostState.AWAITING) + cleanup(); + else + kill(); + + return; + } - _core.getBlock().setType(Material.AIR); - - _ownerClan.inform("Your Outpost has been destroyed!", null); - UtilTextMiddle.display("Siege", "Your Outpost has been destroyed", 20, 100, 20, _ownerClan.getOnlinePlayersArray()); - - if (getState() == OutpostState.AWAITING) - cleanup(); - else - kill(); - - event.setCancelled(true); + _lastDamage = System.currentTimeMillis(); + _health -= 2; } } @@ -344,20 +423,35 @@ public class Outpost implements Listener if (event.getBlock().getLocation().equals(_core) && getState() == OutpostState.LIVE) { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have destroyed " + F.elem(_ownerClan.getName()) + "'s Outpost!")); - - _core.getBlock().setType(Material.AIR); - - _ownerClan.inform("Your Outpost has been destroyed!", null); - UtilTextMiddle.display("Siege", "Your Outpost has been destroyed", 20, 100, 20, _ownerClan.getOnlinePlayersArray()); - - if (getState() == OutpostState.AWAITING) - cleanup(); - else - kill(); - event.setCancelled(true); - return; + if (_outpostManager.getClansManager().hasTimer(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy an Outpost whilst protected from PvP.")); + return; + } + if (!UtilTime.elapsed(_lastDamage, 5000)) + { + return; + } + if (_health <= 2) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have destroyed " + F.elem(_ownerClan.getName()) + "'s Outpost!")); + + _core.getBlock().setType(Material.AIR); + + _ownerClan.inform("Your Outpost has been destroyed!", null); + UtilTextMiddle.display("Siege", "Your Outpost has been destroyed", 20, 100, 20, _ownerClan.getOnlinePlayersArray()); + + if (getState() == OutpostState.AWAITING) + cleanup(); + else + kill(); + + return; + } + + _lastDamage = System.currentTimeMillis(); + _health -= 2; } if (UtilAlg.inBoundingBox(event.getBlock().getLocation(), _startCorner.clone().subtract(.5, 0, .5), _endCorner)) @@ -425,7 +519,9 @@ public class Outpost implements Listener } if (_lifetimeLeft != null) - _lifetimeLeft.setText("Despawning in " + F.time(UtilTime.MakeStr(MAX_LIFETIME - (System.currentTimeMillis() - _timeSpawned)))); + { + _lifetimeLeft.setText("Health: " + _health, "Despawning in " + F.time(UtilTime.MakeStr(MAX_LIFETIME - (System.currentTimeMillis() - _timeSpawned)))); + } if (_state == OutpostState.CONSTRUCTING) { @@ -482,6 +578,11 @@ public class Outpost implements Listener { kill(); } + if (_health < MAX_HEALTH && UtilTime.elapsed(_lastDamage, 15000) && UtilTime.elapsed(_lastRegen, 1000)) + { + _lastRegen = System.currentTimeMillis(); + _health++; + } } } @@ -519,6 +620,7 @@ public class Outpost implements Listener //Inform nearby Clans for (int chunkX = -3; chunkX < 3; chunkX++) + { for (int chunkZ = -3; chunkZ < 3; chunkZ++) { ClanTerritory territory = _ownerClan.Clans.getClanUtility().getClaim(_origin.getWorld().getChunkAt(_origin.getChunk().getX() + chunkX, _origin.getChunk().getZ() + chunkZ)); @@ -531,6 +633,7 @@ public class Outpost implements Listener UtilTextMiddle.display("Siege", "A Siege has been declared on your Clan!", 20, 100, 20, clan.getOnlinePlayersArray()); } } + } } public void kill() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java index 559fc6b4b..149498943 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java @@ -75,13 +75,20 @@ public class OutpostManager extends MiniPlugin return false; } + if (_clansManager.getWorldEvent().getRaidManager().isInRaid(player.getLocation())) + { + _clansManager.message(player, "You are not allowed to place this in a raid."); + + return false; + } + if (!_clansManager.isInClan(player)) { UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place an Outpost.")); return false; } - if(_clansManager.hasTimer(player)) + if (_clansManager.hasTimer(player)) { UtilPlayer.message(player, F.main("Clans", "You can't place an Outpost whilst protected from PvP.")); return false; @@ -123,6 +130,7 @@ public class OutpostManager extends MiniPlugin } for (int x = -2; x < 2; x++) + { for (int z = -2; z < 2; z++) { Chunk chunk = location.getWorld().getChunkAt(location.getChunk().getX() + x, location.getChunk().getZ() + z); @@ -138,10 +146,12 @@ public class OutpostManager extends MiniPlugin } } } + } boolean gut = false; for (int x = -6; x < 6; x++) + { for (int z = -6; z < 6; z++) { Chunk chunk = location.getWorld().getChunkAt(location.getChunk().getX() + x, location.getChunk().getZ() + z); @@ -159,6 +169,7 @@ public class OutpostManager extends MiniPlugin } } } + } /* das ist schlecht */ if (!gut) @@ -168,7 +179,9 @@ public class OutpostManager extends MiniPlugin } for (int x = -type._size; x < type._size; x++) + { for (int y = -1; y < type._ySize; y++) + { for (int z = -type._size; z < type._size; z++) { Location loc = location.clone().add(x, y, z); @@ -179,6 +192,8 @@ public class OutpostManager extends MiniPlugin return false; } } + } + } _outposts.put(clan.getName(), new Outpost(this, clan, location, type)); _idToOutpost.put(Integer.valueOf(_outposts.get(clan.getName()).getUniqueId()), _outposts.get(clan.getName())); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/tokens/SiegeWeaponToken.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/tokens/SiegeWeaponToken.java index 638aa800c..274039ed8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/tokens/SiegeWeaponToken.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/tokens/SiegeWeaponToken.java @@ -1,8 +1,5 @@ package mineplex.game.clans.clans.siege.repository.tokens; -import java.util.Map; -import java.util.UUID; - import org.bukkit.Location; import mineplex.game.clans.clans.ClanInfo; @@ -15,6 +12,5 @@ public class SiegeWeaponToken public Location Location; public int Health; public int Yaw; - public long LastFired; - -} + public long LastFired; +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java index 4f6602afa..d0fa8832b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java @@ -493,6 +493,10 @@ public abstract class SiegeWeapon implements Listener removeHealth(getHealth()); return; } + if (_ownerClan.getOnlinePlayers().contains(player)) + { + return; + } if (_lastLeft == -1) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java index 0b1630995..c8bbf60ca 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/Crater.java @@ -1,7 +1,7 @@ package mineplex.game.clans.clans.siege.weapon.projectile; -import java.util.HashMap; import java.util.List; +import java.util.Map; import org.bukkit.Location; import org.bukkit.Material; @@ -110,7 +110,7 @@ public class Crater } }, 1L); - HashMap hitMap = UtilEnt.getInRadius(_origin, 3.5); + Map hitMap = UtilEnt.getInRadius(_origin, 3.5); for (LivingEntity hit : hitMap.keySet()) { ClansManager.getInstance().getDamageManager().NewDamageEvent(hit, _cause, null, DamageCause.ENTITY_EXPLOSION, 7 / hitMap.get(hit), true, true, false, _cause.getName(), "Siege Cannon"); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java index 75cd73e49..2cfa6e336 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/projectile/WeaponProjectile.java @@ -3,20 +3,13 @@ package mineplex.game.clans.clans.siege.weapon.projectile; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Entity; -import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.util.Vector; -import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; From 5045bad684733ee5015101cfeeac268aa37c40fb Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 12 Jun 2017 01:03:39 -0400 Subject: [PATCH 169/283] Unify item durabilities in clans --- .../clans/gameplay/DurabilityManager.java | 303 ++++++++++++++++++ 1 file changed, 303 insertions(+) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java new file mode 100644 index 000000000..995598c15 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java @@ -0,0 +1,303 @@ +package mineplex.game.clans.gameplay; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.core.common.util.F; +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.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.items.GearManager; + +public class DurabilityManager implements Listener +{ + private final Map _itemDurabilities = new HashMap<>(); + + public DurabilityManager() + { + _itemDurabilities.put(Material.DIAMOND_HELMET, 900); + _itemDurabilities.put(Material.DIAMOND_CHESTPLATE, 900); + _itemDurabilities.put(Material.DIAMOND_LEGGINGS, 900); + _itemDurabilities.put(Material.DIAMOND_BOOTS, 900); + _itemDurabilities.put(Material.DIAMOND_SWORD, 900); + _itemDurabilities.put(Material.DIAMOND_AXE, 900); + _itemDurabilities.put(Material.IRON_HELMET, 900); + _itemDurabilities.put(Material.IRON_CHESTPLATE, 900); + _itemDurabilities.put(Material.IRON_LEGGINGS, 900); + _itemDurabilities.put(Material.IRON_BOOTS, 900); + _itemDurabilities.put(Material.IRON_SWORD, 900); + _itemDurabilities.put(Material.IRON_AXE, 900); + _itemDurabilities.put(Material.CHAINMAIL_HELMET, 900); + _itemDurabilities.put(Material.CHAINMAIL_CHESTPLATE, 900); + _itemDurabilities.put(Material.CHAINMAIL_LEGGINGS, 900); + _itemDurabilities.put(Material.CHAINMAIL_BOOTS, 900); + _itemDurabilities.put(Material.GOLD_HELMET, 900); + _itemDurabilities.put(Material.GOLD_CHESTPLATE, 900); + _itemDurabilities.put(Material.GOLD_LEGGINGS, 900); + _itemDurabilities.put(Material.GOLD_BOOTS, 900); + _itemDurabilities.put(Material.GOLD_SWORD, 900); + _itemDurabilities.put(Material.GOLD_AXE, 900); + _itemDurabilities.put(Material.LEATHER_HELMET, 900); + _itemDurabilities.put(Material.LEATHER_CHESTPLATE, 900); + _itemDurabilities.put(Material.LEATHER_LEGGINGS, 900); + _itemDurabilities.put(Material.LEATHER_BOOTS, 900); + _itemDurabilities.put(Material.BOW, 900); + } + + private boolean canRepair(ItemStack item) + { + int repairs = ItemStackFactory.Instance.GetLoreVar(item, "Repaired", 0); + boolean canRepair = true; + + if (repairs >= 2) + { + canRepair = false; + } + + return canRepair; + } + + private int getItemDamage(ItemStack item) + { + if (item == null) + { + return 0; + } + if (_itemDurabilities.containsKey(item.getType())) + { + int defaultDurability = _itemDurabilities.get(item.getType()); + return defaultDurability - ItemStackFactory.Instance.GetLoreVar(item, "Durability", 0); + } + else + { + return item.getDurability(); + } + } + + private int itemDuraToLoreDura(ItemStack item) + { + if (item == null || !_itemDurabilities.containsKey(item.getType()) || UtilItem.isUnbreakable(item)) + { + return -1; + } + int currentDura = ItemStackFactory.Instance.GetLoreVar(item, "Durability", -1); + if (item.getDurability() == 0 && currentDura != -1) + { + return -1; + } + if (currentDura == -1) + { + updateItemDamage(item, 0, true); + return -2; + } + int newDura = (currentDura - item.getDurability()); + if (newDura <= 0) + { + return 0; + } + else + { + updateItemDamage(item, newDura, false); + item.setDurability((short)0); + } + return newDura; + } + + private void updateItemDamage(ItemStack item, int itemDamage, boolean subtractFromDefault) + { + if (item == null) + { + return; + } + if (_itemDurabilities.containsKey(item.getType())) + { + int defaultDurability = _itemDurabilities.get(item.getType()); + ItemStackFactory.Instance.SetLoreVar(item, "Durability", Math.min(defaultDurability, subtractFromDefault ? (defaultDurability - itemDamage) : itemDamage) + ""); + } + else + { + item.setDurability((short)itemDamage); + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + Bukkit.getOnlinePlayers().forEach(player -> + { + boolean change = false; + for (int i = 0; i < player.getInventory().getArmorContents().length; i++) + { + int d = itemDuraToLoreDura(player.getInventory().getArmorContents()[i]); + if (d == -2) + { + change = true; + } + else if (d == 0) + { + ItemStack[] armor = new ItemStack[4]; + for (int ar = 0; ar < armor.length; ar++) + { + if (ar != i) + { + armor[ar] = player.getInventory().getArmorContents()[ar]; + } + else + { + armor[ar] = null; + } + } + player.getInventory().setArmorContents(armor); + change = true; + } + else if (d != -1) + { + change = true; + } + } + for (int i = 0; i < player.getInventory().getContents().length; i++) + { + int d = itemDuraToLoreDura(player.getInventory().getContents()[i]); + if (d == -2) + { + change = true; + } + else if (d == 0) + { + player.getInventory().setItem(i, null); + change = true; + } + else if (d != -1) + { + change = true; + } + } + + if (change) + { + UtilInv.Update(player); + } + }); + } + } + + @SuppressWarnings("deprecation") + @EventHandler + public void onRepair(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (event.getClickedBlock() == null || event.getClickedBlock().getType() != Material.ANVIL || !UtilEvent.isAction(event, ActionType.R_BLOCK) || player.isSneaking() || player.getItemInHand().getType() == Material.AIR) + { + return; + } + + if (UtilMath.offset(player.getLocation(), event.getClickedBlock().getLocation()) > 2) + { + UtilPlayer.message(player, F.main("Repair", "You are too far from the " + F.item("Anvil") + ".")); + return; + } + + ItemStack item = player.getItemInHand(); + + if (getItemDamage(item) <= 0) + { + UtilPlayer.message(player, F.main("Repair", "Your " + F.item(item == null ? ChatColor.YELLOW + "Hand" : item.getItemMeta().getDisplayName()) + " does not need repairs.")); + return; + } + + if (!UtilGear.isRepairable(item)) + { + UtilPlayer.message(player, F.main("Repair", "You cannot repair " + F.item(item.getItemMeta().getDisplayName()) + ".")); + 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); + + if (!canRepair) + { + UtilPlayer.message(player, F.main("Repair", "This item cannot be repaired anymore.")); + return; + } + + String creator = ItemStackFactory.Instance.GetLoreVar(item, "Owner"); + + if (creator != null) + { + if (creator.length() > 2) creator = creator.substring(2, creator.length()); + + if (!creator.equals(player.getName())) + { + UtilPlayer.message(player, F.main("Repair", "You cannot repair " + F.item(item.getItemMeta().getDisplayName()) + " by " + F.name(creator) + ".")); + return; + } + } + + if (ClansManager.getInstance().getBlockRestore().contains(event.getClickedBlock())) + { + UtilPlayer.message(player, F.main("Repair", "You cannot repair using that anvil.")); + return; + } + + // Repair! + UtilPlayer.message(player, F.main("Repair", "You repaired " + F.item(item.getItemMeta().getDisplayName()) + ".")); + updateItemDamage(item, 0, true); + UtilInv.Update(player); + + // Break + if (Math.random() > 0.85) + { + byte data = event.getClickedBlock().getData(); + if (data >= 8) // Anvil has already been damaged twice + { + player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, 145); + event.getClickedBlock().setType(Material.AIR); + } + else + { + event.getClickedBlock().setData((byte)(data + 4)); + } + } + + // Record + ItemStackFactory.Instance.SetLoreVar(item, "Repaired", (repairs + 1) + ""); + if (!canRepair(item)) + { + ItemMeta meta = item.getItemMeta(); + meta.getLore().add(ChatColor.BLUE + "Unrepairable"); + item.setItemMeta(meta); + } + + // Effect + player.playSound(player.getLocation(), Sound.ANVIL_USE, 1f, 1f); + } +} \ No newline at end of file From a952ee31cd6e3a8087473e237af2597adb4d4474 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 12 Jun 2017 01:04:05 -0400 Subject: [PATCH 170/283] Remove Repair functionality from Gameplay class --- .../game/clans/gameplay/Gameplay.java | 177 +++--------------- 1 file changed, 27 insertions(+), 150 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index 70b87da02..d54d83ebb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -1,44 +1,8 @@ package mineplex.game.clans.gameplay; import java.util.Arrays; -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; import org.bukkit.Effect; import org.bukkit.Location; @@ -66,19 +30,41 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; -import org.bukkit.event.player.PlayerBucketEmptyEvent; -import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent.State; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.event.world.StructureGrowEvent; -import org.bukkit.inventory.ItemStack; -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.UtilInv; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.weight.Weight; +import mineplex.core.common.weight.WeightSet; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +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 static final int MAX_BUILD_HEIGHT = 120; @@ -102,6 +88,7 @@ public class Gameplay extends MiniPlugin // Register the custom recipes and mobs Bukkit.getPluginManager().registerEvents(new CustomRecipes(), plugin); Bukkit.getPluginManager().registerEvents(new CustomCreatures(), plugin); + Bukkit.getPluginManager().registerEvents(new DurabilityManager(), plugin); } // @EventHandler(priority = EventPriority.LOWEST) @@ -760,116 +747,6 @@ public class Gameplay extends MiniPlugin } } - @EventHandler - public void Repair(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if (event.getClickedBlock() == null || event.getClickedBlock().getType() != Material.ANVIL || !UtilEvent.isAction(event, ActionType.R_BLOCK) || player.isSneaking() || player.getItemInHand().getType() == Material.AIR) - { - return; - } - - if (UtilMath.offset(player.getLocation(), event.getClickedBlock().getLocation()) > 2) - { - UtilPlayer.message(player, F.main("Repair", "You are too far from the " + F.item("Anvil") + ".")); - return; - } - - ItemStack item = player.getItemInHand(); - - if (item.getDurability() <= 0) - { - UtilPlayer.message(player, F.main("Repair", "Your " + F.item(item == null ? ChatColor.YELLOW + "Hand" : item.getItemMeta().getDisplayName()) + " does not need repairs.")); - return; - } - - if (!UtilGear.isRepairable(item)) - { - UtilPlayer.message(player, F.main("Repair", "You cannot repair " + F.item(item.getItemMeta().getDisplayName()) + ".")); - 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); - - if (!canRepair) - { - UtilPlayer.message(player, F.main("Repair", "This item cannot be repaired anymore.")); - return; - } - - String creator = ItemStackFactory.Instance.GetLoreVar(item, "Owner"); - - if (creator != null) - { - if (creator.length() > 2) creator = creator.substring(2, creator.length()); - - if (!creator.equals(player.getName())) - { - UtilPlayer.message(player, F.main("Repair", "You cannot repair " + F.item(item.getItemMeta().getDisplayName()) + " by " + F.name(creator) + ".")); - return; - } - } - - if (_blockRestore.contains(event.getClickedBlock())) - { - UtilPlayer.message(player, F.main("Repair", "You cannot repair using that anvil")); - return; - } - - // Repair! - UtilPlayer.message(player, F.main("Repair", "You repaired " + F.item(item.getItemMeta().getDisplayName()) + ".")); - item.setDurability((short) 0); - UtilInv.Update(player); - - // Break - if (Math.random() > 0.85) - { - byte data = event.getClickedBlock().getData(); - if (data >= 8) // Anvil has already been damaged twice - { - player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, 145); - event.getClickedBlock().setType(Material.AIR); - } - else - { - event.getClickedBlock().setData((byte)(data + 4)); - } - } - - // Record - ItemStackFactory.Instance.SetLoreVar(item, "Repaired", (repairs + 1) + ""); - if (!canRepair(item)) - { - ItemMeta meta = item.getItemMeta(); - meta.getLore().add(ChatColor.BLUE + "Nonfixable"); - item.setItemMeta(meta); - } - - // Effect - player.playSound(player.getLocation(), Sound.ANVIL_USE, 1f, 1f); - } - - private boolean canRepair(ItemStack item) - { - int repairs = ItemStackFactory.Instance.GetLoreVar(item, "Repaired", 0); - boolean gold = UtilGear.isGold(item); - boolean canRepair = true; - - if (repairs >= 3 && gold) - canRepair = false; - else if (repairs >= 2 && !gold) canRepair = false; - - return canRepair; - } - public DamageManager getDamageManager() { return _damageManager; From 97c8dc7cf46def5c96dc02f4d5d26f8398f0c57b Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 12 Jun 2017 01:04:26 -0400 Subject: [PATCH 171/283] Make safelog holograms follow their loggers --- .../src/mineplex/game/clans/gameplay/safelog/SafeLog.java | 2 +- .../mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java index 481abf910..d964df566 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java @@ -23,9 +23,9 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.worldevent.raid.RaidManager; -import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import mineplex.game.clans.restart.RestartManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java index e2095eccf..4dfa74bdd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java @@ -201,6 +201,8 @@ public class CombatLogNPC // Disguise DisguisePlayer disguise = new DisguisePlayer(skel, ((CraftPlayer) player).getHandle().getProfile()); _disguiseManager.disguise(disguise, attempted -> inRange.contains(attempted)); + + _hologram.setFollowEntity(skel); return skel; } From 97efeca225be2c97300e865a3f66ea0dd214a7bf Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 12 Jun 2017 01:05:02 -0400 Subject: [PATCH 172/283] Increase outpost costs and add mounts to pvp shop --- .../game/clans/shop/ClansShopItem.java | 2 +- .../game/clans/shop/pvp/MountBuyButton.java | 74 +++++++++++++++++++ .../mineplex/game/clans/shop/pvp/PvpPage.java | 3 + 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/MountBuyButton.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java index f505ee1f0..d2d472edf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopItem.java @@ -78,7 +78,7 @@ public enum ClansShopItem QUARTZ_BLOCK(75, 15, Material.QUARTZ_BLOCK, 1), CLAY(30, 6, Material.CLAY, 1), GOLD_TOKEN(50000, 50000, Material.GOLD_RECORD, 1, (byte) 0, "Gold Token"), - OUTPOST(30000, 0, Material.BEACON, 1, (byte) 0, C.cBlue + "Outpost"), + OUTPOST(100000, 0, Material.BEACON, 1, (byte) 0, C.cBlue + "Outpost"), CANNON(25000, 0, Material.SPONGE, 1, (byte) 1, C.cBlue + "Cannon"); private int _buyPrice; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/MountBuyButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/MountBuyButton.java new file mode 100644 index 000000000..a0838568f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/MountBuyButton.java @@ -0,0 +1,74 @@ +package mineplex.game.clans.shop.pvp; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.recharge.Recharge; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.mounts.Mount.MountType; +import mineplex.game.clans.clans.mounts.MountClaimToken; +import mineplex.game.clans.economy.GoldManager; + +public class MountBuyButton> implements IButton +{ + private int _buyPrice; + private ItemStack _item; + private T _page; + + public MountBuyButton(T page) + { + _page = page; + _buyPrice = 150000; + _item = new MountClaimToken(1, 1, 1, MountType.HORSE).toItem(); + } + + @Override + public void onClick(final Player player, ClickType clickType) + { + if (!Recharge.Instance.use(player, "Attempt Buy Clans Shop Item", 1500, false, false)) + { + return; + } + if (clickType == ClickType.SHIFT_LEFT || clickType == ClickType.LEFT) + { + int goldCount = GoldManager.getInstance().getGold(player); + + if (goldCount >= _buyPrice) + { + GoldManager.getInstance().deductGold(success -> + { + if (success) + { + giftItem(player, 1); + GoldManager.notify(player, String.format("You have purchased %d item(s) for %dg", 1, _buyPrice)); + + _page.playAcceptSound(player); + } + else + { + GoldManager.notify(player, "You cannot afford that item! Please relog to update your gold count."); + _page.playDenySound(player); + } + + _page.refresh(); + }, player, _buyPrice); + } + else + { + GoldManager.notify(player, "You cannot afford that item."); + _page.playDenySound(player); + } + } + + _page.refresh(); + } + + private void giftItem(Player player, int amount) + { + ItemStack item = _item.clone(); + item.setAmount(amount); + player.getInventory().addItem(item); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpPage.java index b36ea0510..2e94c7554 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpPage.java @@ -1,5 +1,7 @@ package mineplex.game.clans.shop.pvp; +import org.bukkit.Material; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; @@ -57,6 +59,7 @@ public class PvpPage extends ClansShopPage addShopItem(33, ClansShopItem.BOW, "Standard Bow"); addShopItem(34, ClansShopItem.ARROW, (byte) 0, "Arrows", 16); + addButton(51 - 9, new ItemBuilder(Material.IRON_BARDING).setTitle(C.cGreenB + "Standard Mount").setLore(C.cRed, C.cYellow + "Left-Click" + C.cWhite + " to buy " + C.cGreen + "1", C.cWhite + "Costs " + C.cGreen + "150000g").build(), new MountBuyButton<>(this)); addShopItem(52 - 9, ClansShopItem.CANNON, C.cBlue + "Cannon"); addShopItem(53 - 9, ClansShopItem.OUTPOST, C.cBlue + "Outpost"); From 9da5b367fd5ab13280080681020bcb9e8b62e23a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 12 Jun 2017 01:06:33 -0400 Subject: [PATCH 173/283] Further improve raids --- .../clans/worldevent/WorldEventManager.java | 3 + .../clans/worldevent/api/EventCreature.java | 24 ++-- .../clans/worldevent/api/WorldEvent.java | 4 +- .../clans/worldevent/raid/RaidChallenge.java | 6 +- .../clans/worldevent/raid/RaidManager.java | 29 ++++- .../clans/worldevent/raid/RaidWorldEvent.java | 83 +++++++++--- .../clans/worldevent/raid/WorldData.java | 10 +- .../worldevent/raid/wither/WitherRaid.java | 24 +++- .../wither/challenge/five/ChallengeFive.java | 19 ++- .../raid/wither/challenge/five/IronGate.java | 15 +-- .../wither/challenge/four/ChallengeFour.java | 36 ++---- .../raid/wither/challenge/four/FakeBlock.java | 1 + .../wither/challenge/one/ChallengeOne.java | 2 +- .../challenge/seven/ChallengeSeven.java | 2 +- .../challenge/three/ChallengeThree.java | 10 ++ .../challenge/three/ChallengeTorch.java | 2 +- .../creature/archer/ArcherShooting.java | 3 +- .../creature/archer/DecayingArcher.java | 25 +++- .../creature/corpse/ReanimatedCorpse.java | 25 +++- .../raid/wither/creature/giant/Goliath.java | 25 +++- .../wither/creature/mage/KnightPassive.java | 4 +- .../raid/wither/creature/mage/MageBolt.java | 2 +- .../wither/creature/mage/MageBoneExplode.java | 76 +++++++++++ .../raid/wither/creature/mage/MageSummon.java | 2 +- .../wither/creature/mage/UndeadKnight.java | 25 +++- .../raid/wither/creature/mage/UndeadMage.java | 34 ++++- .../wither/creature/magma/BlazeMinion.java | 25 +++- .../raid/wither/creature/magma/Cataclysm.java | 7 +- .../raid/wither/creature/magma/HeatingUp.java | 2 + .../creature/magma/InfernalMinions.java | 3 +- .../raid/wither/creature/magma/Magmus.java | 64 +++++++-- ...agmusPassive.java => MagmusCataclysm.java} | 8 +- .../raid/wither/creature/magma/MagmusEat.java | 89 +++++++++++++ .../wither/creature/magma/MagmusMeteor.java | 122 ++++++++++++++++++ .../wither/creature/magma/MagmusSmash.java | 71 ++++++++++ .../creature/silverfish/PitSwarmer.java | 59 --------- .../creature/silverfish/SwarmerPassive.java | 49 ------- .../wither/creature/wither/BlackHole.java | 11 ++ .../wither/creature/wither/CharlesSkulls.java | 2 + .../creature/wither/CharlesWitherton.java | 96 +++++++++++++- .../wither/creature/wither/MiniCharles.java | 101 ++++++++++++++- .../wither/creature/wither/SummonCorpse.java | 1 + .../wither/creature/wither/SummonMinions.java | 3 +- .../wither/creature/wither/SummonUndead.java | 1 + .../wither/ai/PathfinderGoalCustomFloat.java | 33 +++++ 45 files changed, 1011 insertions(+), 227 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBoneExplode.java rename Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/{MagmusPassive.java => MagmusCataclysm.java} (87%) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/PitSwarmer.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/SwarmerPassive.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/ai/PathfinderGoalCustomFloat.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index a7c44b7a6..b235e1ba3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -14,6 +14,7 @@ import com.google.common.collect.Lists; import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.blood.Blood; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilWorld; @@ -67,6 +68,8 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement _skillFactory = skillFactory; + new Blood(plugin); + _raidManager = new RaidManager(plugin); updateNextEventTime(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreature.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreature.java index dd11c7b79..43326c031 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreature.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/EventCreature.java @@ -2,6 +2,15 @@ package mineplex.game.clans.clans.worldevent.api; import java.util.UUID; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.world.ChunkUnloadEvent; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; @@ -13,15 +22,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import org.bukkit.Location; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.world.ChunkUnloadEvent; - public abstract class EventCreature implements Listener { protected static final boolean DEBUG_MODE = true; @@ -75,7 +75,7 @@ public abstract class EventCreature implements Listener { return getEvent().getDifficulty(); } - + protected void spawnEntity() { Location spawnLocation = _entity == null ? _spawnLocation : _entity.getLocation(); @@ -352,7 +352,7 @@ public abstract class EventCreature implements Listener { return; } - + if (!event.GetDamageeEntity().equals(_entity)) { return; @@ -362,6 +362,8 @@ public abstract class EventCreature implements Listener applyDamage(event.GetDamage()); updateName(); + + _lastDamaged = System.currentTimeMillis(); _event.updateLastActive(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java index a0e662bc4..1790cc269 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java @@ -120,7 +120,7 @@ public abstract class WorldEvent implements Listener, ScoreboardElement public void registerCreature(EventCreature creature) { - UtilServer.getServer().getPluginManager().registerEvents(creature, UtilServer.getPlugin()); + UtilServer.RegisterEvents(creature); _creatures.add(creature); } @@ -223,7 +223,7 @@ public abstract class WorldEvent implements Listener, ScoreboardElement } setState(EventState.LIVE); customStart(); - Bukkit.getPluginManager().registerEvents(this, UtilServer.getPlugin()); + UtilServer.RegisterEvents(this); } public void announceStart() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidChallenge.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidChallenge.java index 896440803..6f30d8744 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidChallenge.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidChallenge.java @@ -47,12 +47,12 @@ public abstract class RaidChallenge implements Listene public void complete() { - complete(false); + complete(true); } - public void complete(boolean onDisable) + public void complete(boolean allowCustom) { - if (!onDisable) + if (allowCustom) { customComplete(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java index a74b712a5..87ccfdfd4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java @@ -22,8 +22,10 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.DisguiseManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilScheduler; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.worldevent.api.EventState; import mineplex.game.clans.clans.worldevent.raid.command.StartRaidCommand; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; @@ -108,8 +110,8 @@ public class RaidManager extends MiniPlugin inside.forEach(in -> UtilPlayer.message(in, F.main(type.getRaidName() + " Raid", "Summoning ancient power..."))); createNewRaid(type, raid -> inside.forEach(in -> { - raid.addPlayer(player); - player.getWorld().strikeLightningEffect(player.getLocation()); + raid.addPlayer(in); + in.getWorld().strikeLightningEffect(in.getLocation()); })); return true; } @@ -126,6 +128,7 @@ public class RaidManager extends MiniPlugin RaidWorldEvent event = type.getClazz().getConstructor(WorldData.class, RaidManager.class).newInstance(data, this); raidConsumer.accept(event); event.start(); + _raids.add(event); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { @@ -139,6 +142,28 @@ public class RaidManager extends MiniPlugin data.LoadChecker = task; } + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + { + UtilServer.getPlayersCollection() + .stream() + .filter(player -> isInRaid(player.getLocation())) + .forEach(player -> + { + ClansManager.getInstance().getItemMapManager().removeMap(player); + }); + return; + } + if (event.getType() != UpdateType.SEC) + { + return; + } + + _raids.removeIf(e -> e.getState() == EventState.STOPPED); + } + @EventHandler public void onInteract(PlayerInteractEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java index 09b0fefae..3705cef86 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java @@ -9,10 +9,12 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.world.ChunkUnloadEvent; import mineplex.core.common.util.F; @@ -38,10 +40,12 @@ public abstract class RaidWorldEvent extends WorldEvent protected final int Id; - protected List Players = new ArrayList<>(); + private List _players = new ArrayList<>(); protected long _forceEnd = -1; + private boolean _cleanup = false; + public RaidWorldEvent(String name, WorldData data, RaidManager manager) { super(name, new Location(data.World, data.MinX + ((data.MaxX - data.MinX) / 2), data.MinY + ((data.MaxY - data.MinY) / 2), data.MinZ + ((data.MaxZ - data.MinZ) / 2)), UtilMath.getMax((data.MaxX - data.MinX) / 2, (data.MaxY - data.MinY) / 2, (data.MaxZ - data.MinZ) / 2), false, manager.getDisguiseManager(), manager.getProjectileManager(), manager.getDamageManager(), manager.getBlockRestore(), manager.getConditionManager()); @@ -81,7 +85,9 @@ public abstract class RaidWorldEvent extends WorldEvent public List getPlayers() { - return Players; + List players = new ArrayList<>(); + players.addAll(_players); + return players; } public int getId() @@ -95,7 +101,7 @@ public abstract class RaidWorldEvent extends WorldEvent _forceEnd = System.currentTimeMillis() + UtilTime.convert(90, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); int spawnIndex = 0; List spawns = WorldData.SpawnLocs.get("Red"); - for (Player player : Players) + for (Player player : _players) { if (spawnIndex >= spawns.size()) { @@ -110,21 +116,28 @@ public abstract class RaidWorldEvent extends WorldEvent @Override public void customCleanup(boolean onDisable) { - Players.forEach(player -> player.teleport(Spawn.getNorthSpawn())); - Players.clear(); + _cleanup = true; + _players.forEach(player -> player.teleport(Spawn.getNorthSpawn())); + _players.clear(); + getCreatures().forEach(creature -> + { + HandlerList.unregisterAll(creature); + creature.getEntity().remove(); + }); + getCreatures().clear(); if (onDisable) { WorldData.uninitialize(); } else { - UtilServer.runSyncLater(WorldData::uninitialize, 120); + UtilServer.runSyncLater(WorldData::uninitialize, 20 * 10); } } public void addPlayer(Player player) { - Players.add(player); + _players.add(player); } public void setForceEnd(long end) @@ -143,7 +156,7 @@ public abstract class RaidWorldEvent extends WorldEvent { return; } - if (Players.isEmpty()) + if (_players.isEmpty()) { stop(); } @@ -178,7 +191,7 @@ public abstract class RaidWorldEvent extends WorldEvent @EventHandler public void onChunkUnload(ChunkUnloadEvent event) { - if (getState() == EventState.STOPPED || this.getState() == EventState.REMOVED) + if (getState() == EventState.STOPPED || getState() == EventState.REMOVED || _cleanup) { return; } @@ -229,10 +242,14 @@ public abstract class RaidWorldEvent extends WorldEvent UtilPlayer.message(player, F.main(getName(), "You cannot build here!")); } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOW) public void onQuit(PlayerQuitEvent event) { - if (Players.remove(event.getPlayer())) + if (_cleanup) + { + return; + } + if (_players.remove(event.getPlayer())) { event.getPlayer().teleport(Spawn.getNorthSpawn()); } @@ -241,22 +258,52 @@ public abstract class RaidWorldEvent extends WorldEvent @EventHandler(priority = EventPriority.LOWEST) public void onDie(PlayerDeathEvent event) { - if (Players.remove(event.getEntity())) + if (_cleanup) { - UtilServer.runSyncLater(() -> event.getEntity().teleport(Spawn.getNorthSpawn()), 5); + return; + } + if (_players.remove(event.getEntity())) + { + event.getEntity().setHealth(event.getEntity().getMaxHealth()); + getCondition().Clean(event.getEntity()); + event.getEntity().getActivePotionEffects().forEach(pe -> event.getEntity().removePotionEffect(pe.getType())); + event.getEntity().setExp(0); + event.getEntity().setLevel(0); + event.getEntity().teleport(Spawn.getNorthSpawn()); + } + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onTeleport(PlayerTeleportEvent event) + { + if (_cleanup) + { + return; + } + if (!event.getTo().getWorld().equals(WorldData.World)) + { + _players.remove(event.getPlayer()); } } @EventHandler public void onTpHome(ClansCommandExecutedEvent event) { + if (!_players.contains(event.getPlayer())) + { + return; + } if (event.getCommand().equalsIgnoreCase("tphome") || event.getCommand().equalsIgnoreCase("stuck")) { - if (Players.contains(event.getPlayer())) - { - event.setCancelled(true); - UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport while in a raid!")); - } + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport while in a raid!")); + return; + } + if (event.getCommand().equalsIgnoreCase("claim") || event.getCommand().equalsIgnoreCase("unclaim") || event.getCommand().equalsIgnoreCase("unclaimall") || event.getCommand().equalsIgnoreCase("homeset")) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot manage your clan's territory while in a raid!")); + return; } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java index 4eee372c0..a647f268c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java @@ -16,6 +16,7 @@ import org.bukkit.Difficulty; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.WorldCreator; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.scheduler.BukkitTask; import mineplex.core.common.timing.TimingManager; @@ -26,8 +27,9 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.WorldUtil; import mineplex.core.common.util.ZipUtil; import mineplex.core.common.util.worldgen.WorldGenCleanRoom; +import mineplex.game.clans.spawn.Spawn; -public class WorldData +public class WorldData { public int Id = -1; @@ -56,10 +58,10 @@ public class WorldData public WorldData(String raidName) { + RaidName = raidName; initialize(); Id = getNewId(); - RaidName = raidName; } private List loadFiles() @@ -136,6 +138,8 @@ public class WorldData World.setDifficulty(Difficulty.HARD); World.setGameRuleValue("showDeathMessages", "false"); + ((CraftWorld)World).getHandle().allowAnimals = false; + ((CraftWorld)World).getHandle().allowMonsters = false; TimingManager.start("WorldData loading WorldConfig."); //Load World Data @@ -380,6 +384,8 @@ public class WorldData return; } + World.getPlayers().forEach(player -> player.teleport(Spawn.getNorthSpawn())); + //Wipe World MapUtil.UnloadWorld(UtilServer.getPlugin(), World); MapUtil.ClearWorldReferences(World.getName()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java index db88e0286..0a19b4fc6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java @@ -5,8 +5,8 @@ import java.util.LinkedList; import java.util.List; import org.bukkit.Location; +import org.bukkit.event.EventHandler; -import mineplex.game.clans.clans.worldevent.api.EventState; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; import mineplex.game.clans.clans.worldevent.raid.RaidManager; import mineplex.game.clans.clans.worldevent.raid.RaidType; @@ -18,10 +18,11 @@ import mineplex.game.clans.clans.worldevent.raid.wither.challenge.seven.Challeng import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; import mineplex.game.clans.clans.worldevent.raid.wither.challenge.three.ChallengeThree; import mineplex.game.clans.clans.worldevent.raid.wither.challenge.two.ChallengeTwo; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; public class WitherRaid extends RaidWorldEvent { - private final List>> _challenges = new LinkedList<>(); + private List>> _challenges; private RaidChallenge _currentChallenge; public WitherRaid(mineplex.game.clans.clans.worldevent.raid.WorldData data, RaidManager manager) @@ -53,7 +54,7 @@ public class WitherRaid extends RaidWorldEvent private void teleportToAltar() { Location altar = WorldData.getCustomLocs("MAIN_ALTAR").get(0); - Players.forEach(player -> player.teleport(altar)); + getPlayers().forEach(player -> player.teleport(altar)); } @Override @@ -61,6 +62,7 @@ public class WitherRaid extends RaidWorldEvent { WorldData.World.setGameRuleValue("doDaylightCycle", "false"); WorldData.World.setTime(14000); + _challenges = new LinkedList<>(); _challenges.add(ChallengeOne.class); _challenges.add(ChallengeTwo.class); _challenges.add(ChallengeThree.class); @@ -83,7 +85,10 @@ public class WitherRaid extends RaidWorldEvent { if (_currentChallenge.isComplete()) { - teleportToAltar(); + if (_challenges.size() < 6) + { + teleportToAltar(); + } nextChallenge(); } } @@ -94,7 +99,16 @@ public class WitherRaid extends RaidWorldEvent { if (_currentChallenge != null) { - _currentChallenge.complete(getState() == EventState.REMOVED); + _currentChallenge.complete(false); + } + } + + @EventHandler + public void onBlockToss(SkillTriggerEvent event) + { + if (event.GetSkillName().equals("Block Toss") && getPlayers().contains(event.GetPlayer())) + { + event.SetCancelled(true); } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java index dab6871b4..b77f231be 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java @@ -11,6 +11,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -19,6 +20,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; import mineplex.game.clans.clans.worldevent.raid.wither.creature.archer.DecayingArcher; @@ -82,6 +84,8 @@ public class ChallengeFive extends RaidChallenge _gates.add(new IronGate(this, getRaid().getWorldData().getCustomLocs("C_FIVE_G" + i), creatures)); i++; } + _goliath = new Goliath(this, getRaid().getWorldData().getCustomLocs("C_FIVE_GIANT").get(0)); + getRaid().registerCreature(_goliath); getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Use the third gate!"))); } @@ -99,6 +103,7 @@ public class ChallengeFive extends RaidChallenge gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); gate.setType(Material.SKULL); gate.setData((byte)1); + _altar.getWorld().dropItem(_altar.clone().add(0, 2, 0), new ItemStack(Material.EMERALD, UtilMath.rRange(15, 17))); } @EventHandler @@ -124,7 +129,7 @@ public class ChallengeFive extends RaidChallenge { Location to = gate.getCenter().clone(); to.setY(_goliath.getEntity().getLocation().getY()); - _goliath.getEntity().setVelocity(UtilAlg.getTrajectory(_goliath.getEntity().getLocation(), to).normalize().multiply(0.5)); + _goliath.getEntity().setVelocity(UtilAlg.getTrajectory(_goliath.getEntity().getLocation(), to).normalize().multiply(0.15)); } if (gate.update()) { @@ -161,4 +166,16 @@ public class ChallengeFive extends RaidChallenge event.SetCancelled(true); } } + + @EventHandler + public void onDeath(EventCreatureDeathEvent event) + { + if (event.getCreature().getEvent() instanceof WitherRaid) + { + if (((WitherRaid)event.getCreature().getEvent()).getId() == getRaid().getId()) + { + _gates.forEach(gate -> gate.handleDeath(event.getCreature())); + } + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java index d9940e37c..b0a0964d5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java @@ -64,19 +64,16 @@ public class IronGate public boolean update() { - int alive = 0; - for (EventCreature guardian : _guardians) - { - if (guardian.getHealth() > 0) - { - alive++; - } - } - if (alive < 0) + if (_guardians.size() < 1) { open(); return true; } return false; } + + public void handleDeath(EventCreature creature) + { + _guardians.remove(creature); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java index 7112c0885..bfb9cb879 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java @@ -9,7 +9,9 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; @@ -18,7 +20,6 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; -import mineplex.game.clans.clans.worldevent.raid.wither.creature.silverfish.PitSwarmer; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; public class ChallengeFour extends RaidChallenge @@ -26,6 +27,7 @@ public class ChallengeFour extends RaidChallenge private Location _altar; private boolean _teleported = false; private List _blocks = new ArrayList<>(); + private double[] _damageYRange = new double[2]; public ChallengeFour(WitherRaid raid) { @@ -41,26 +43,6 @@ public class ChallengeFour extends RaidChallenge UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Complete the parkour!")); player.teleport(getRaid().getWorldData().getCustomLocs("C_FOUR_ENTER").get(0)); }); - Location pos1 = getRaid().getWorldData().getCustomLocs("C_FOUR_SF").get(0); - Location pos2 = getRaid().getWorldData().getCustomLocs("C_FOUR_SF").get(1); - int minX = Math.min(pos1.getBlockX(), pos2.getBlockX()); - int maxX = Math.max(pos1.getBlockX(), pos2.getBlockX()); - int minY = Math.min(pos1.getBlockY(), pos2.getBlockY()); - int maxY = Math.max(pos1.getBlockY(), pos2.getBlockY()); - int minZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ()); - int maxZ = Math.max(pos1.getBlockZ(), pos2.getBlockZ()); - - for (int x = minX; x <= maxX; x++) - { - for (int y = minY; y <= maxY; y++) - { - for (int z = minZ; z <= maxZ; z++) - { - Block block = getRaid().getWorldData().World.getBlockAt(x, y, z); - getRaid().registerCreature(new PitSwarmer(this, block.getLocation())); - } - } - } } @Override @@ -69,8 +51,13 @@ public class ChallengeFour extends RaidChallenge for (Location loc : getRaid().getWorldData().getCustomLocs("C_FOUR_FB")) { loc.getBlock().setType(Material.NETHER_BRICK); + _blocks.add(new FakeBlock(this, loc.getBlock())); } getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Use the second gate!"))); + Location pos1 = getRaid().getWorldData().getCustomLocs("C_FOUR_SF").get(0); + Location pos2 = getRaid().getWorldData().getCustomLocs("C_FOUR_SF").get(1); + _damageYRange[0] = Math.min(pos1.getY(), pos2.getY()); + _damageYRange[1] = Math.max(pos1.getY(), pos2.getY()); } @SuppressWarnings("deprecation") @@ -87,12 +74,13 @@ public class ChallengeFour extends RaidChallenge gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); gate.setType(Material.SKULL); gate.setData((byte)1); + _altar.getWorld().dropItem(_altar.clone().add(0, 2, 0), new ItemStack(Material.EMERALD, UtilMath.rRange(13, 17))); } @EventHandler public void onUpdate(UpdateEvent event) { - if (event.getType() == UpdateType.SEC) + if (event.getType() == UpdateType.SEC && _teleported) { for (Player player : getRaid().getPlayers()) { @@ -101,6 +89,10 @@ public class ChallengeFour extends RaidChallenge complete(); return; } + if (player.getLocation().getY() <= _damageYRange[1] && player.getLocation().getY() >= _damageYRange[0]) + { + getRaid().getDamageManager().NewDamageEvent(player, null, null, DamageCause.LAVA, 1, false, true, true, "Burning Cavern", "Hot Ground"); + } } } if (event.getType() == UpdateType.TICK) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java index 371bec25e..55793d72d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java @@ -26,6 +26,7 @@ public class FakeBlock { _block.setType(Material.AIR); aired = true; + break; } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java index 1edc07d61..57c1fa0af 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java @@ -92,7 +92,7 @@ public class ChallengeOne extends RaidChallenge { for (Player player : getRaid().getPlayers()) { - if (UtilMath.offset(player.getLocation(), _altar) <= 5) + if (UtilMath.offset(player.getLocation(), _altar) <= 10) { _trigger = player; complete(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java index 9fadaa068..f82e86ab0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java @@ -84,7 +84,7 @@ public class ChallengeSeven extends RaidChallenge UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "The evil reign of Charles Witherton is over! You will be returned to spawn in 2 minutes!")); player.teleport(_altar); }); - List anim = UtilShapes.getCircle(_altar.clone().add(0, 2, 0), true, 3); + List anim = UtilShapes.getPointsInCircle(_altar.clone().add(0, 2, 0), 5, 3); int emeralds = UtilMath.rRange((int)Math.ceil(45 / anim.size()), (int)Math.ceil(80 / anim.size())); for (Location drop : anim) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java index 99daf36c0..260e59321 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java @@ -9,8 +9,10 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; @@ -28,6 +30,7 @@ public class ChallengeThree extends RaidChallenge private List _torches = new ArrayList<>(); protected int LitTorches; private long _lastSpawn; + private int _spawnTotal; public ChallengeThree(WitherRaid raid) { @@ -72,6 +75,7 @@ public class ChallengeThree extends RaidChallenge gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); gate.setType(Material.SKULL); gate.setData((byte)1); + _altar.getWorld().dropItem(_altar.clone().add(0, 2, 0), new ItemStack(Material.EMERALD, UtilMath.rRange(10, 15))); } @EventHandler @@ -90,12 +94,18 @@ public class ChallengeThree extends RaidChallenge if (UtilTime.elapsed(_lastSpawn, 7000) && _teleported) { _lastSpawn = System.currentTimeMillis(); + if (_spawnTotal > 100) + { + return; + } getRaid().getWorldData().getCustomLocs("C_THREE_RC").forEach(loc -> { + _spawnTotal++; getRaid().registerCreature(new ReanimatedCorpse(this, loc)); }); getRaid().getWorldData().getCustomLocs("C_THREE_DA").forEach(loc -> { + _spawnTotal++; getRaid().registerCreature(new DecayingArcher(this, loc)); }); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java index 08482b694..90b6e0a4e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java @@ -19,7 +19,7 @@ public class ChallengeTorch public void handleInteract(Block block) { - if (block.equals(_block)) + if (block.equals(_block) && _extinguish == -1) { _challenge.LitTorches++; _extinguish = System.currentTimeMillis() + 3000; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/ArcherShooting.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/ArcherShooting.java index de8ded9ec..9bf61cb22 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/ArcherShooting.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/ArcherShooting.java @@ -2,6 +2,7 @@ package mineplex.game.clans.clans.worldevent.raid.wither.creature.archer; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; @@ -28,7 +29,7 @@ public class ArcherShooting extends BossAbility @Override public void tick() { - if (getEntity().getTarget() != null) + if (getEntity().getTarget() != null && getEntity().getTarget() instanceof Player) { if (UtilTime.elapsed(_lastRope, 10000)) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/DecayingArcher.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/DecayingArcher.java index 13e5bfd46..e7215b1a3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/DecayingArcher.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/DecayingArcher.java @@ -2,18 +2,23 @@ package mineplex.game.clans.clans.worldevent.raid.wither.creature.archer; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.worldevent.api.EventCreature; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.RaidCreature; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; -public class DecayingArcher extends EventCreature +public class DecayingArcher extends RaidCreature { private RaidChallenge _challenge; private ArcherShooting _passive; @@ -62,4 +67,20 @@ public class DecayingArcher extends EventCreature _passive.tick(); } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + public void allyDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + if (damager != null && !(damager instanceof Player)) + { + event.SetCancelled("Allied Damage"); + } + } + } + + @Override + public void handleDeath(Location location) {} } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/ReanimatedCorpse.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/ReanimatedCorpse.java index debf12fa7..e09e61ea2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/ReanimatedCorpse.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/ReanimatedCorpse.java @@ -2,19 +2,24 @@ package mineplex.game.clans.clans.worldevent.raid.wither.creature.corpse; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.UtilMath; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.worldevent.api.EventCreature; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.RaidCreature; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; -public class ReanimatedCorpse extends EventCreature +public class ReanimatedCorpse extends RaidCreature { private static final Material[] SWORDS = {Material.WOOD_SWORD, Material.STONE_SWORD, Material.GOLD_SWORD, Material.IRON_SWORD, Material.DIAMOND_SWORD}; private RaidChallenge _challenge; @@ -64,4 +69,20 @@ public class ReanimatedCorpse extends EventCreature _passive.tick(); } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + public void allyDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + if (damager != null && !(damager instanceof Player)) + { + event.SetCancelled("Allied Damage"); + } + } + } + + @Override + public void handleDeath(Location location) {} } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/Goliath.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/Goliath.java index d5de7b8c2..1920ef4aa 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/Goliath.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/Goliath.java @@ -2,16 +2,21 @@ package mineplex.game.clans.clans.worldevent.raid.wither.creature.giant; import org.bukkit.Location; import org.bukkit.entity.Giant; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.worldevent.api.EventCreature; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.RaidCreature; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; -public class Goliath extends EventCreature +public class Goliath extends RaidCreature { private RaidChallenge _challenge; private GoliathPassive _passive; @@ -56,4 +61,20 @@ public class Goliath extends EventCreature _passive.tick(); } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + public void allyDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + if (damager != null && !(damager instanceof Player)) + { + event.SetCancelled("Allied Damage"); + } + } + } + + @Override + public void handleDeath(Location location) {} } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/KnightPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/KnightPassive.java index 207184797..825254c8b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/KnightPassive.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/KnightPassive.java @@ -46,12 +46,12 @@ public class KnightPassive extends BossPassive if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) { _lastUsed = System.currentTimeMillis(); - event.AddMod("Hilt Smash", 1 - event.GetDamage()); + event.AddMod("Hilt Smash", 4 - event.GetDamage()); getBoss().getEvent().getCondition().Factory().Slow("Hilt Smash", event.GetDamageeEntity(), event.GetDamagerEntity(false), 2, 1, false, true, false, true); } else { - event.AddMod("Knight Attack", 1 - event.GetDamage()); + event.AddMod("Knight Attack", 4 - event.GetDamage()); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBolt.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBolt.java index bff678973..71f6d6944 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBolt.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBolt.java @@ -54,7 +54,7 @@ public class MageBolt extends BossPassive if (canHit) { - getBoss().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.CUSTOM, 2.5, true, true, false, getEntity().getName(), "Mystical Energy"); + getBoss().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.CUSTOM, 5, true, true, false, getEntity().getName(), "Mystical Energy"); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBoneExplode.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBoneExplode.java new file mode 100644 index 000000000..87440c682 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBoneExplode.java @@ -0,0 +1,76 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; + +import java.util.Map; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.Managers; +import mineplex.core.blood.Blood; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class MageBoneExplode extends BossPassive +{ + private long _lastUsed; + + public MageBoneExplode(UndeadMage creature) + { + super(creature); + _lastUsed = System.currentTimeMillis(); + } + + private void explode() + { + Map nearby = UtilPlayer.getInRadius(getLocation(), 4); + for (Player near : nearby.keySet()) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(near, getEntity(), null, DamageCause.CUSTOM, 3, true, true, false, getEntity().getName(), "Bone Explosion"); + } + Managers.get(Blood.class).Effects(null, getLocation().add(0, 0.5, 0), 48, 0.8, Sound.SKELETON_HURT, 2f, 1.2f, Material.BONE, (byte) 0, 40, false); + } + + @Override + public int getCooldown() + { + return 8; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + _lastUsed = System.currentTimeMillis(); + explode(); + } + } + + @EventHandler + public void Knockback(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains("Bone Explosion")) + { + return; + } + + if (event.GetDamagerEntity(false) == null || event.GetDamagerEntity(false).getEntityId() != getEntity().getEntityId()) + { + return; + } + + event.AddKnockback("Bone Explosion", 5); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageSummon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageSummon.java index 09bb949e9..3ee21f400 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageSummon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageSummon.java @@ -25,7 +25,7 @@ public class MageSummon extends BossPassive super(creature); _lastUsed = System.currentTimeMillis(); - MAX_KNIGHTS = spawnLocations.size(); + MAX_KNIGHTS = spawnLocations == null ? 10 : spawnLocations.size(); _spawnLocations = spawnLocations; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadKnight.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadKnight.java index 62456eda6..093d3afa5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadKnight.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadKnight.java @@ -2,9 +2,13 @@ package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -12,11 +16,12 @@ import org.bukkit.potion.PotionEffectType; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.worldevent.api.EventCreature; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.RaidCreature; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; -public class UndeadKnight extends EventCreature +public class UndeadKnight extends RaidCreature { private RaidChallenge _challenge; private KnightPassive _passive; @@ -68,4 +73,20 @@ public class UndeadKnight extends EventCreature _passive.tick(); } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + public void allyDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + if (damager != null && !(damager instanceof Player)) + { + event.SetCancelled("Allied Damage"); + } + } + } + + @Override + public void handleDeath(Location location) {} } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadMage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadMage.java index 428bfa30f..7a767fcdd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadMage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadMage.java @@ -7,15 +7,16 @@ import java.util.Map; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; @@ -34,7 +35,7 @@ public class UndeadMage extends RaidCreature public UndeadMage(RaidChallenge challenge, Location location, boolean invulnerable, List spawnLocations, List blinkLocations) { - super(challenge.getRaid(), location, "Undead Mage", true, 200, 5, true, Skeleton.class); + super(challenge.getRaid(), location, "Undead Mage", true, 500, 1500, true, Skeleton.class); _challenge = challenge; _invuln = invulnerable; @@ -43,12 +44,13 @@ public class UndeadMage extends RaidCreature _abilities.add(new MageSummon(this, spawnLocations)); _abilities.add(new MageBlink(this, blinkLocations)); _abilities.add(new MageBolt(this)); + _abilities.add(new MageBoneExplode(this)); } @Override protected void spawnCustom() { - UtilEnt.vegetate(getEntity()); + //UtilEnt.vegetate(getEntity()); getEntity().setSkeletonType(SkeletonType.WITHER); getEntity().getEquipment().setItemInHand(new ItemStack(Material.RECORD_6)); //Meridian Scepter getEntity().getEquipment().setItemInHandDropChance(0f); @@ -161,6 +163,32 @@ public class UndeadMage extends RaidCreature event.SetCancelled("Boss Invulnerability"); } } + + @EventHandler + public void buffDamage(CustomDamageEvent event) + { + if (event.GetDamagerEntity(false) == null) + { + return; + } + if (event.GetDamagerEntity(false).getEntityId() == getEntity().getEntityId() && event.GetCause() == DamageCause.ENTITY_ATTACK) + { + event.AddMod("Mage Attack", 7 - event.GetDamage()); + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + public void ally(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + if (damager != null && !(damager instanceof Player)) + { + event.SetCancelled("Allied Damage"); + } + } + } @Override public void handleDeath(Location location) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/BlazeMinion.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/BlazeMinion.java index 63783d8de..0d8f9a19a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/BlazeMinion.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/BlazeMinion.java @@ -2,15 +2,20 @@ package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; import org.bukkit.Location; import org.bukkit.entity.Blaze; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.worldevent.api.EventCreature; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.RaidCreature; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; -public class BlazeMinion extends EventCreature +public class BlazeMinion extends RaidCreature { private RaidChallenge _challenge; @@ -42,4 +47,20 @@ public class BlazeMinion extends EventCreature return; } } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + public void allyDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + if (damager != null && !(damager instanceof Player)) + { + event.SetCancelled("Allied Damage"); + } + } + } + + @Override + public void handleDeath(Location location) {} } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Cataclysm.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Cataclysm.java index 0ca7625e4..1a46b6b33 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Cataclysm.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Cataclysm.java @@ -7,6 +7,7 @@ import org.bukkit.event.Listener; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; @@ -21,7 +22,11 @@ public abstract class Cataclysm implements Listener Challenge = challenge; Magmus = magmus; - challenge.getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(challenge.getRaid().getName() + " Raid", getAnnouncement()))); + challenge.getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(challenge.getRaid().getName() + " Raid", getAnnouncement())); + UtilTextMiddle.display("", getAnnouncement(), player); + }); onStart(); UtilServer.RegisterEvents(this); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java index 306b3e17b..78f955916 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java @@ -29,6 +29,7 @@ public class HeatingUp extends Cataclysm @Override protected void onStart() { + ((MagmusMeteor)Magmus.Abilities.get(2)).Disabled = true; _center = Challenge.getRaid().getWorldData().getCustomLocs("C_SIX_C1S").get(0); for (int x = -1; x <= 1; x++) { @@ -49,6 +50,7 @@ public class HeatingUp extends Cataclysm _center.getBlock().getRelative(x, -1, z).setType(Material.STONE); } } + ((MagmusMeteor)Magmus.Abilities.get(2)).Disabled = false; } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/InfernalMinions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/InfernalMinions.java index b892e1332..4255bc09f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/InfernalMinions.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/InfernalMinions.java @@ -22,8 +22,9 @@ public class InfernalMinions extends Cataclysm @Override protected void onStart() { - for (Location loc : Challenge.getRaid().getWorldData().getCustomLocs("C_SIX_C2M")) + for (int i = 0; i < 20; i++) { + Location loc = UtilMath.randomElement(Magmus.getChallenge().getRaid().getPlayers()).getLocation(); if (UtilMath.r(2) == 1) { Challenge.getRaid().registerCreature(new UndeadKnight(Challenge, loc)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java index 746027618..729499e23 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java @@ -1,20 +1,31 @@ package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; +import java.util.ArrayList; +import java.util.List; + import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import mineplex.core.common.util.UtilEnt; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.RaidCreature; import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; -public class Magmus extends EventCreature +public class Magmus extends RaidCreature { private ChallengeSix _challenge; - private MagmusPassive _passive; + protected List> Abilities = new ArrayList<>(); + + protected boolean TeleportBackASAP = true; public Magmus(ChallengeSix challenge, Location location) { @@ -22,7 +33,9 @@ public class Magmus extends EventCreature _challenge = challenge; spawnEntity(); - _passive = new MagmusPassive(this); + Abilities.add(new MagmusCataclysm(this)); + Abilities.add(new MagmusSmash(this)); + Abilities.add(new MagmusMeteor(this)); } protected ChallengeSix getChallenge() @@ -45,8 +58,11 @@ public class Magmus extends EventCreature private void endAbility() { - HandlerList.unregisterAll(_passive); - _passive = null; + Abilities.forEach(ability -> + { + HandlerList.unregisterAll(ability); + }); + Abilities.clear(); } @EventHandler @@ -63,8 +79,40 @@ public class Magmus extends EventCreature return; } - getEntity().teleport(getSpawnLocation()); + if (TeleportBackASAP) + { + getEntity().teleport(getSpawnLocation()); + } - _passive.tick(); + Abilities.forEach(BossPassive::tick); } + + @EventHandler + public void onMagmusDamage(CustomDamageEvent event) + { + if (event.GetDamagerEntity(false) == null) + { + return; + } + if (event.GetDamagerEntity(false).getEntityId() == getEntity().getEntityId() && (event.GetCause() != DamageCause.FIRE && event.GetCause() != DamageCause.CUSTOM && event.GetCause() != DamageCause.PROJECTILE)) + { + event.SetCancelled("Wrong Attack Type Magmus"); + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + public void allyDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + if (damager != null && !(damager instanceof Player)) + { + event.SetCancelled("Allied Damage"); + } + } + } + + @Override + public void handleDeath(Location location) {} } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java similarity index 87% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusPassive.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java index f7fa43922..604ff9844 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusPassive.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java @@ -11,15 +11,15 @@ import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.worldevent.api.BossPassive; import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; -public class MagmusPassive extends BossPassive +public class MagmusCataclysm extends BossPassive { private long _lastUse; private List> _cataclysms = new ArrayList<>(); - public MagmusPassive(Magmus creature) + public MagmusCataclysm(Magmus creature) { super(creature); - _lastUse = System.currentTimeMillis(); + _lastUse = System.currentTimeMillis() - (getCooldown() * 1000); _cataclysms.add(HeatingUp.class); _cataclysms.add(InfernalMinions.class); _cataclysms.add(UndeadAlly.class); @@ -28,7 +28,7 @@ public class MagmusPassive extends BossPassive @Override public int getCooldown() { - return 30; + return 15; } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java new file mode 100644 index 000000000..2fcfef365 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java @@ -0,0 +1,89 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; + +public class MagmusEat extends BossPassive +{ + private long _lastUse; + private Player _eating; + private int _ticks; + + public MagmusEat(Magmus creature) + { + super(creature); + _lastUse = System.currentTimeMillis(); + } + + private void spit() + { + double offset = UtilMath.offset(_eating, getEntity()); + //Velocity + UtilAction.velocity(_eating, + UtilAlg.getTrajectory2d(getLocation().toVector(), _eating.getLocation().toVector()), + 2 + 2 * offset, true, 0, 1.2 + 1.0 * offset, 3, true); + + getBoss().getEvent().getCondition().Factory().Falling("Spit Out", _eating, getEntity(), 10, false, true); + + _lastUse = System.currentTimeMillis(); + _eating = null; + _ticks = -1; + } + + private void eat() + { + if (_ticks < 20 * 10) + { + _eating.setFireTicks(40); + _eating.teleport(getEntity()); + } + else + { + spit(); + } + } + + private void initialEat(Player target) + { + _eating = target; + _ticks = 0; + getBoss().getEvent().getCondition().Factory().Silence("Eat", _eating, getEntity(), 10, true, true); + } + + @Override + public int getCooldown() + { + return 15; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (_eating != null) + { + eat(); + return; + } + if (UtilTime.elapsed(_lastUse, getCooldown() * 1000)) + { + Player target = UtilPlayer.getClosest(getLocation(), 3); + if (target != null) + { + initialEat(target); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java new file mode 100644 index 000000000..5e76ef0de --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java @@ -0,0 +1,122 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLargeFireball; +import org.bukkit.entity.LargeFireball; +import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.ProjectileHitEvent; + +import mineplex.core.common.util.UtilMath; +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.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import net.minecraft.server.v1_8_R3.EntityLargeFireball; + +public class MagmusMeteor extends BossPassive +{ + private long _lastUse; + private List _shot = new ArrayList<>(); + + protected boolean Disabled = false; + + public MagmusMeteor(Magmus creature) + { + super(creature); + _lastUse = System.currentTimeMillis(); + } + + private void newBall() + { + if (Disabled) + { + return; + } + Player target = UtilMath.randomElement(getBoss().getChallenge().getRaid().getPlayers()); + LargeFireball ball = target.getWorld().spawn(target.getLocation().add(Math.random() * 24 - 12, 32 + Math.random() * 16, Math.random() * 24 - 12), LargeFireball.class); + + EntityLargeFireball eFireball = ((CraftLargeFireball) ball).getHandle(); + eFireball.dirX = (Math.random()-0.5)*0.02; + eFireball.dirY = -0.2 - 0.05 * Math.random(); + eFireball.dirZ = (Math.random()-0.5)*0.02; + + ball.setShooter(getEntity()); + ball.setYield(2.2f); + ball.setBounce(false); + _shot.add(ball); + } + + @Override + public int getCooldown() + { + return 30; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (Disabled) + { + return; + } + if (UtilTime.elapsed(_lastUse, getCooldown() * 1000)) + { + _lastUse = System.currentTimeMillis(); + for (int i = 0; i < 20; i++) + { + newBall(); + } + } + } + + @EventHandler + public void onExplode(EntityExplodeEvent event) + { + if (event.getEntity() instanceof LargeFireball) + { + LargeFireball ball = (LargeFireball) event.getEntity(); + if (ball.getShooter() instanceof MagmaCube && ((MagmaCube)ball.getShooter()).getEntityId() == getEntity().getEntityId()) + { + event.blockList().clear(); + return; + } + } + } + + @EventHandler + public void onBallHit(ProjectileHitEvent event) + { + if (event.getEntity() instanceof LargeFireball) + { + LargeFireball ball = (LargeFireball) event.getEntity(); + if (ball.getShooter() instanceof MagmaCube && ((MagmaCube)ball.getShooter()).getEntityId() == getEntity().getEntityId()) + { + _shot.remove(ball); + UtilParticle.PlayParticle(ParticleType.EXPLODE, ball.getLocation(), null, 0, 2, ViewDist.MAX, UtilServer.getPlayers()); + ball.getWorld().playSound(ball.getLocation(), Sound.EXPLODE, 10, 0); + Player hit = UtilPlayer.getClosest(ball.getLocation(), 0.5); + if (hit != null) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(hit, getEntity(), ball, DamageCause.PROJECTILE, 4, true, true, false, getEntity().getName(), "Meteor Shower"); + } + ball.remove(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java new file mode 100644 index 000000000..2de2bb06d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java @@ -0,0 +1,71 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import java.util.Map; + +import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; + +public class MagmusSmash extends BossPassive +{ + private long _lastUse; + + public MagmusSmash(Magmus creature) + { + super(creature); + _lastUse = System.currentTimeMillis(); + } + + private void slam() + { + //Action + Map targets = UtilPlayer.getInRadius(getLocation(), 5.5d + 0.5 * 5); + getBoss().TeleportBackASAP = false; + getEntity().setVelocity(new Vector(0, 5, 0)); + UtilServer.runSyncLater(() -> getBoss().TeleportBackASAP = false, 3 * 20); + for (Player player : targets.keySet()) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, + DamageCause.CUSTOM, 6 * targets.get(player) + 0.5, false, true, false, + getEntity().getName(), "Smash"); + + //Velocity + UtilAction.velocity(player, + UtilAlg.getTrajectory2d(getLocation().toVector(), player.getLocation().toVector()), + 2 + 2 * targets.get(player), true, 0, 1.2 + 1.0 * targets.get(player), 3, true); + + //Condition + getBoss().getEvent().getCondition().Factory().Falling("Smash", player, getEntity(), 10, false, true); + } + } + + @Override + public int getCooldown() + { + return 10; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastUse, getCooldown() * 1000)) + { + _lastUse = System.currentTimeMillis(); + slam(); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/PitSwarmer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/PitSwarmer.java deleted file mode 100644 index 17fc0b66a..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/PitSwarmer.java +++ /dev/null @@ -1,59 +0,0 @@ -package mineplex.game.clans.clans.worldevent.raid.wither.creature.silverfish; - -import org.bukkit.Location; -import org.bukkit.entity.Silverfish; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; - -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.worldevent.api.EventCreature; -import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; -import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; - -public class PitSwarmer extends EventCreature -{ - private RaidChallenge _challenge; - private SwarmerPassive _passive; - - public PitSwarmer(RaidChallenge challenge, Location location) - { - super(challenge.getRaid(), location, "Pit Swarmer", true, 1, 100, true, Silverfish.class); - - _challenge = challenge; - spawnEntity(); - _passive = new SwarmerPassive(this); - } - - @Override - protected void spawnCustom() {} - - @Override - public void dieCustom() - { - endAbility(); - } - - private void endAbility() - { - HandlerList.unregisterAll(_passive); - _passive = null; - } - - @EventHandler - public void onTick(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - { - return; - } - - if (_challenge.isComplete()) - { - remove(); - return; - } - - _passive.tick(); - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/SwarmerPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/SwarmerPassive.java deleted file mode 100644 index 58a8f7e99..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/SwarmerPassive.java +++ /dev/null @@ -1,49 +0,0 @@ -package mineplex.game.clans.clans.worldevent.raid.wither.creature.silverfish; - -import org.bukkit.entity.Silverfish; -import org.bukkit.event.EventHandler; - -import mineplex.game.clans.clans.worldevent.api.BossPassive; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - -public class SwarmerPassive extends BossPassive -{ - public SwarmerPassive(PitSwarmer creature) - { - super(creature); - } - - @Override - public int getCooldown() - { - return 0; - } - - @Override - public boolean isProgressing() - { - return false; - } - - @Override - public void tick() {} - - @EventHandler - public void onDamage(CustomDamageEvent event) - { - if (event.GetDamagerEntity(false) != null) - { - if (event.GetDamagerEntity(false).getEntityId() == getEntity().getEntityId()) - { - event.AddMod("Swarm Attack", 1 - event.GetDamage()); - } - } - if (event.GetDamageeEntity() != null) - { - if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) - { - event.SetCancelled("Swarm Invulnerability"); - } - } - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/BlackHole.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/BlackHole.java index 0431a4b15..2465a56ab 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/BlackHole.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/BlackHole.java @@ -6,6 +6,8 @@ import java.util.Map.Entry; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.entity.Wither; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.util.Vector; import mineplex.core.common.util.F; @@ -115,4 +117,13 @@ public class BlackHole extends BossPassive } } } + + @EventHandler + public void onKick(PlayerKickEvent event) + { + if (_chargeTicks != -1 && getBoss().getChallenge().getRaid().getPlayers().contains(event.getPlayer())) + { + event.setCancelled(true); + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesSkulls.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesSkulls.java index eccb7ab13..88e88a8cd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesSkulls.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesSkulls.java @@ -1,5 +1,6 @@ package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; @@ -36,6 +37,7 @@ public class CharlesSkulls extends BossAbility { super(creature); + _guidedSkulls = new HashMap<>(); _lastUnguided = System.currentTimeMillis(); _lastGuided = System.currentTimeMillis(); _lastBombard = -1; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java index e86a246fc..1043b4187 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java @@ -4,25 +4,46 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWither; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.entity.Wither; +import org.bukkit.entity.WitherSkull; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ProjectileLaunchEvent; + +import com.google.common.base.Predicate; import mineplex.core.common.util.UtilEnt; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.worldevent.api.BossPassive; -import mineplex.game.clans.clans.worldevent.api.EventCreature; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.RaidCreature; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.wither.ai.PathfinderGoalCustomFloat; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import net.minecraft.server.v1_8_R3.Entity; +import net.minecraft.server.v1_8_R3.EntityHuman; +import net.minecraft.server.v1_8_R3.EntityInsentient; +import net.minecraft.server.v1_8_R3.EntityWither; +import net.minecraft.server.v1_8_R3.PathfinderGoalHurtByTarget; +import net.minecraft.server.v1_8_R3.PathfinderGoalLookAtPlayer; +import net.minecraft.server.v1_8_R3.PathfinderGoalNearestAttackableTarget; +import net.minecraft.server.v1_8_R3.PathfinderGoalRandomLookaround; +import net.minecraft.server.v1_8_R3.PathfinderGoalRandomStroll; -public class CharlesWitherton extends EventCreature +public class CharlesWitherton extends RaidCreature { private RaidChallenge _challenge; private CharlesSkulls _passive; private List> _abilities = new ArrayList<>(); - protected boolean Flying = false; + public boolean Flying = false; public CharlesWitherton(RaidChallenge challenge, Location location) { @@ -55,6 +76,26 @@ public class CharlesWitherton extends EventCreature protected void spawnCustom() { UtilEnt.vegetate(getEntity()); + CraftWither cw = (CraftWither)getEntity(); + EntityWither wither = cw.getHandle(); + wither.setVegetated(false); + wither.goalSelector.a(0, new PathfinderGoalCustomFloat(this, wither)); + wither.goalSelector.a(5, new PathfinderGoalRandomStroll(wither, 1.0D)); + wither.goalSelector.a(6, new PathfinderGoalLookAtPlayer(wither, EntityHuman.class, 8.0F)); + wither.goalSelector.a(7, new PathfinderGoalRandomLookaround(wither)); + wither.targetSelector.a(1, new PathfinderGoalHurtByTarget(wither, false, new Class[0])); + wither.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(wither, EntityInsentient.class, 0, false, false, new Predicate() + { + public boolean a(Entity entity) + { + return entity instanceof EntityHuman; + } + + public boolean apply(Entity entity) + { + return this.a(entity); + } + })); } @Override @@ -91,5 +132,54 @@ public class CharlesWitherton extends EventCreature _passive.tick(); _abilities.forEach(BossPassive::tick); + + if (Flying) + { + getEntity().setHealth(500); + } + else + { + getEntity().setHealth(100); + } } + + @EventHandler + public void handleBlockChange(EntityChangeBlockEvent event) + { + if (event.getEntity().getEntityId() == getEntity().getEntityId()) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onLaunch(ProjectileLaunchEvent event) + { + if (event.getEntity() instanceof WitherSkull && event.getEntity().getShooter() instanceof Wither) + { + if (((Wither)event.getEntity().getShooter()).getEntityId() == getEntity().getEntityId()) + { + if (((WitherSkull)event.getEntity()).isCharged()) + { + event.setCancelled(true); + } + } + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + public void allyDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + if (damager != null && !(damager instanceof Player)) + { + event.SetCancelled("Allied Damage"); + } + } + } + + @Override + public void handleDeath(Location location) {} } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java index 5f4d86651..1a3a911e0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java @@ -1,30 +1,53 @@ package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWither; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.entity.Wither; +import org.bukkit.entity.WitherSkull; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ProjectileLaunchEvent; + +import com.google.common.base.Predicate; import mineplex.core.common.util.UtilEnt; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.worldevent.api.EventCreature; import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.RaidCreature; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.wither.ai.PathfinderGoalCustomFloat; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import net.minecraft.server.v1_8_R3.Entity; +import net.minecraft.server.v1_8_R3.EntityHuman; +import net.minecraft.server.v1_8_R3.EntityInsentient; +import net.minecraft.server.v1_8_R3.EntityWither; +import net.minecraft.server.v1_8_R3.PathfinderGoalHurtByTarget; +import net.minecraft.server.v1_8_R3.PathfinderGoalLookAtPlayer; +import net.minecraft.server.v1_8_R3.PathfinderGoalNearestAttackableTarget; +import net.minecraft.server.v1_8_R3.PathfinderGoalRandomLookaround; +import net.minecraft.server.v1_8_R3.PathfinderGoalRandomStroll; -public class MiniCharles extends EventCreature +public class MiniCharles extends RaidCreature { + private CharlesWitherton _charles; private RaidChallenge _challenge; private MiniCharlesSkulls _passive; private int _liveTicks; protected boolean Flying = false; - public MiniCharles(RaidChallenge challenge, Location location) + public MiniCharles(CharlesWitherton charles, Location location) { - super(challenge.getRaid(), location, "Charles' Minion", true, 50, 15000, true, Wither.class); + super(charles.getChallenge().getRaid(), location, "Charles' Minion", true, 50, 15000, true, Wither.class); - _challenge = challenge; + _charles = charles; + _challenge = charles.getChallenge(); spawnEntity(); _passive = new MiniCharlesSkulls(this); } @@ -33,6 +56,25 @@ public class MiniCharles extends EventCreature protected void spawnCustom() { UtilEnt.vegetate(getEntity()); + EntityWither wither = ((CraftWither)getEntity()).getHandle(); + wither.setVegetated(false); + wither.goalSelector.a(0, new PathfinderGoalCustomFloat(_charles, wither)); + wither.goalSelector.a(5, new PathfinderGoalRandomStroll(wither, 1.0D)); + wither.goalSelector.a(6, new PathfinderGoalLookAtPlayer(wither, EntityHuman.class, 8.0F)); + wither.goalSelector.a(7, new PathfinderGoalRandomLookaround(wither)); + wither.targetSelector.a(1, new PathfinderGoalHurtByTarget(wither, false, new Class[0])); + wither.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(wither, EntityInsentient.class, 0, false, false, new Predicate() + { + public boolean a(Entity entity) + { + return entity instanceof EntityHuman; + } + + public boolean apply(Entity entity) + { + return this.a(entity); + } + })); } @Override @@ -69,5 +111,54 @@ public class MiniCharles extends EventCreature { remove(); } + + if (Flying) + { + getEntity().setHealth(500); + } + else + { + getEntity().setHealth(100); + } } + + @EventHandler + public void handleBlockChange(EntityChangeBlockEvent event) + { + if (event.getEntity().getEntityId() == getEntity().getEntityId()) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onLaunch(ProjectileLaunchEvent event) + { + if (event.getEntity() instanceof WitherSkull && event.getEntity().getShooter() instanceof Wither) + { + if (((Wither)event.getEntity().getShooter()).getEntityId() == getEntity().getEntityId()) + { + if (((WitherSkull)event.getEntity()).isCharged()) + { + event.setCancelled(true); + } + } + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + public void allyDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + if (damager != null && !(damager instanceof Player)) + { + event.SetCancelled("Allied Damage"); + } + } + } + + @Override + public void handleDeath(Location location) {} } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonCorpse.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonCorpse.java index 0471b69e2..492b8b714 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonCorpse.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonCorpse.java @@ -41,6 +41,7 @@ public class SummonCorpse extends BossPassive { if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) { + _lastUsed = System.currentTimeMillis(); for (int i = 0; i < 6; i++) { getBoss().getEvent().registerCreature(new ReanimatedCorpse(getBoss().getChallenge(), getLocation())); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonMinions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonMinions.java index b40618cfd..7ea48dcd1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonMinions.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonMinions.java @@ -40,9 +40,10 @@ public class SummonMinions extends BossPassive { if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) { + _lastUsed = System.currentTimeMillis(); for (int i = 0; i < 2; i++) { - getBoss().getEvent().registerCreature(new MiniCharles(getBoss().getChallenge(), getLocation())); + getBoss().getEvent().registerCreature(new MiniCharles(getBoss(), getLocation())); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonUndead.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonUndead.java index dd855ea63..0862c84df 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonUndead.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonUndead.java @@ -41,6 +41,7 @@ public class SummonUndead extends BossPassive { if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) { + _lastUsed = System.currentTimeMillis(); for (int i = 0; i < 6; i++) { getBoss().getEvent().registerCreature(new UndeadKnight(getBoss().getChallenge(), getLocation())); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/ai/PathfinderGoalCustomFloat.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/ai/PathfinderGoalCustomFloat.java new file mode 100644 index 000000000..227413fd3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/ai/PathfinderGoalCustomFloat.java @@ -0,0 +1,33 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither.ai; + +import mineplex.game.clans.clans.worldevent.raid.wither.creature.wither.CharlesWitherton; +import net.minecraft.server.v1_8_R3.EntityInsentient; +import net.minecraft.server.v1_8_R3.Navigation; +import net.minecraft.server.v1_8_R3.PathfinderGoal; + +public class PathfinderGoalCustomFloat extends PathfinderGoal +{ + private CharlesWitherton _boss; + private EntityInsentient a; + + public PathfinderGoalCustomFloat(CharlesWitherton boss, EntityInsentient ent) + { + _boss = boss; + this.a = ent; + this.a(4); + ((Navigation)ent.getNavigation()).d(true); + } + + public boolean a() + { + return _boss.Flying; + } + + public void e() + { + if (this.a.bc().nextFloat() < 0.8F) + { + this.a.getControllerJump().a(); + } + } +} \ No newline at end of file From 3d8998ee13471ba58b16d6f4306ec274166f6185 Mon Sep 17 00:00:00 2001 From: cnr Date: Mon, 12 Jun 2017 15:43:29 -0500 Subject: [PATCH 174/283] Change missed BETA_HUB -> HUB in GH server-sending --- .../src/mineplex/gemhunters/spawn/SpawnModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java index b1802129a..6b1e7fda7 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java @@ -140,7 +140,7 @@ public class SpawnModule extends MiniPlugin new SimpleNPC(_plugin, location, Villager.class, C.cGoldB + "Return To Hub", clicker -> { - Portal.getInstance().sendPlayerToGenericServer(clicker, GenericServer.BETA_HUB, Intent.PLAYER_REQUEST); + Portal.getInstance().sendPlayerToGenericServer(clicker, GenericServer.HUB, Intent.PLAYER_REQUEST); }); } From 3efeb38a0169e41b8d178b0ff7a09e55e40048b7 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 13 Jun 2017 00:29:05 +0100 Subject: [PATCH 175/283] Working through JIRA --- .../game/arcade/game/games/moba/Moba.java | 2 + .../games/moba/boss/wither/WitherBoss.java | 19 ++++++ .../arcade/game/games/moba/buff/Buff.java | 2 +- .../game/games/moba/buff/BuffManager.java | 18 +++++ .../games/moba/buff/buffs/BuffCripple.java | 30 +++++++++ .../arcade/game/games/moba/kit/HeroSkill.java | 8 +++ .../moba/kit/anath/SkillFireProjectile.java | 67 ++----------------- .../game/games/moba/kit/dana/SkillRally.java | 10 +++ .../game/games/moba/kit/hp/HPManager.java | 2 +- .../games/moba/kit/hp/MobaHPRegenEvent.java | 14 +++- .../moba/kit/larissa/SkillWaterDash.java | 39 ++++++----- .../moba/kit/rowena/SkillCombatDash.java | 2 +- .../moba/kit/rowena/SkillLightArrows.java | 35 +++++++--- .../moba/shop/assassin/MobaAssassinShop.java | 63 ++++++++--------- .../shop/effects/MobaAbilityDamageEffect.java | 14 +++- .../moba/shop/effects/MobaKillHealEffect.java | 3 +- .../shop/effects/MobaMeleeDamageEffect.java | 30 +++++++++ .../moba/shop/hunter/MobaHunterShop.java | 12 ++-- .../games/moba/structure/tower/Tower.java | 17 ++++- .../game/games/moba/util/MobaConstants.java | 1 - .../arcade/game/games/moba/util/MobaUtil.java | 4 +- 21 files changed, 253 insertions(+), 139 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 211416885..db0ee8014 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -32,6 +32,7 @@ import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.kit.hp.HPManager; import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa; +import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena; import nautilus.game.arcade.game.games.moba.minion.MinionManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; @@ -99,6 +100,7 @@ public class Moba extends TeamGame new HeroBiff(Manager), new HeroLarissa(Manager), new HeroBardolf(Manager), + new HeroRowena(Manager), new HeroBob(Manager) }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 41b4a242c..c9483bbe1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -1,11 +1,13 @@ package nautilus.game.arcade.game.games.moba.boss.wither; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; 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.UtilTextTop; +import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -22,6 +24,7 @@ import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.EntityEffect; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -29,6 +32,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import java.util.concurrent.TimeUnit; + public class WitherBoss extends MobaBoss { @@ -37,11 +42,13 @@ public class WitherBoss extends MobaBoss private static final float SPEED_HOME = 6F; private static final int INITIAL_HEALTH = 125; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); + private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); private GameTeam _team; private MobaAI _ai; private DisguiseWither _disguise; private boolean _damageable; + private long _lastInform; public WitherBoss(Moba host, Location location, GameTeam team) { @@ -137,6 +144,18 @@ public class WitherBoss extends MobaBoss } } + // Inform the team + if (UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) + { + _lastInform = System.currentTimeMillis(); + + for (Player player : _team.GetPlayers(true)) + { + player.playSound(player.getLocation(), Sound.ANVIL_LAND, 1, 0.5F); + player.sendMessage(F.main("Game", "Your Wither is under attack.")); + } + } + double newHealth = damagee.getHealth() - event.GetDamage(); // Don't allow the wither to move because of damage diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java index 0e9949db2..5c1d996cc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java @@ -11,7 +11,7 @@ public abstract class Buff implements Listener protected final Moba _host; protected final BuffManager _manager; protected final T _entity; - private final long _duration; + protected final long _duration; private long _start; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java index 25ba3d101..66ce3aba8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java @@ -37,6 +37,24 @@ public class BuffManager implements Listener buff.apply(); } + public boolean hasBuff(LivingEntity entity, Class> clazz) + { + if (!_buffs.containsKey(entity)) + { + return false; + } + + for (Buff buff : _buffs.get(entity)) + { + if (buff.getClass().equals(clazz)) + { + return true; + } + } + + return false; + } + @EventHandler public void update(UpdateEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java new file mode 100644 index 000000000..c72f8fe2b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.moba.buff.buffs; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTextMiddle; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.buff.Buff; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class BuffCripple extends Buff +{ + + private static final ItemStack + + public BuffCripple(Moba host, Player entity, long duration) + { + super(host, entity, duration); + } + + @Override + public void onApply() + { + UtilTextMiddle.display("", C.cRed + "Crippled", 10, 20, 10, _entity); + } + + @Override + public void onExpire() + { + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index a813cd146..97a31933a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -14,6 +14,7 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.buff.buffs.BuffCripple; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; @@ -286,6 +287,7 @@ public class HeroSkill extends Perk return; } + Moba moba = (Moba) Manager.GetGame(); long current = System.currentTimeMillis(); for (Player player : Manager.GetGame().GetPlayers(true)) @@ -307,6 +309,12 @@ public class HeroSkill extends Perk boolean done = UtilTime.elapsed(start, cooldown); + // If the player is crippled say they are + if (moba.getBuffManager().hasBuff(player, BuffCripple.class)) + { + itemStack = + } + if (done) { _lastSkill.remove(player.getUniqueId()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 401693e05..53f2313a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -1,27 +1,16 @@ package nautilus.game.arcade.game.games.moba.kit.anath; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Item; import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.SmallFireball; import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - public class SkillFireProjectile extends HeroSkill { @@ -32,8 +21,6 @@ public class SkillFireProjectile extends HeroSkill private static final int DAMAGE = 5; private static final ItemStack SKILL_ITEM = new ItemStack(Material.BLAZE_ROD); - private final List _fireballs = new ArrayList<>(); - public SkillFireProjectile(int slot) { super("Flame Wand", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); @@ -55,54 +42,10 @@ public class SkillFireProjectile extends HeroSkill } Vector direction = player.getLocation().getDirection().multiply(1.25); + Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), _kit.getAmmo()); + item.setVelocity(direction); - SmallFireball fireball = player.getWorld().spawn(player.getEyeLocation().add(direction), SmallFireball.class); - fireball.setShooter(player); - fireball.setVelocity(direction); - _fireballs.add(fireball); - - ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, fireball, DAMAGE); - } - - @EventHandler - public void fireballPrevention(CustomDamageEvent event) - { - if (event.GetProjectile() != null && _fireballs.contains(event.GetProjectile())) - { - event.SetCancelled("Fireball Damage"); - } - } - - @EventHandler - public void projectileHit(ProjectileHitEvent event) - { - Projectile entity = event.getEntity(); - - if (!_fireballs.contains(entity)) - { - return; - } - - Player player = (Player) entity.getShooter(); - Set entities = UtilEnt.getInRadius(entity.getLocation(), 1.5).keySet(); - - if (!entities.isEmpty()) - { - player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 1.2F); - } - - for (LivingEntity nearby : entities) - { - if (isTeamDamage(nearby, player)) - { - continue; - } - - nearby.setFireTicks(40); - Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, DAMAGE, true, true, false, player.getName(), GetName()); - } - - _fireballs.remove(entity); - entity.remove(); + Manager.GetFire().Add(item, player, 3, 0, 1, DAMAGE, GetName(), false); + ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, item, DAMAGE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index d1d302a78..ba64117fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -19,6 +19,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; @@ -200,6 +201,15 @@ public class SkillRally extends HeroSkill } } + @EventHandler + public void itemSpawn(ItemSpawnEvent event) + { + if (event.getEntity().getItemStack().getType() == Material.BANNER) + { + event.setCancelled(true); + } + } + @EventHandler public void playerDeath(PlayerDeathEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java index 7f91b073d..02ad04e8e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java @@ -42,7 +42,7 @@ public class HPManager implements Listener continue; } - MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5); + MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5, true); UtilServer.CallEvent(regenEvent); if (regenEvent.isCancelled()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java index 793c170ba..903ed115c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java @@ -12,14 +12,16 @@ public class MobaHPRegenEvent extends PlayerEvent implements Cancellable private final double _initialHealth; private double _health; + private boolean _natural; private boolean _cancel; - public MobaHPRegenEvent(Player who, double health) + public MobaHPRegenEvent(Player who, double health, boolean natural) { super(who); _initialHealth = health; _health = health; + _natural = natural; } public void setHealth(double health) @@ -37,6 +39,16 @@ public class MobaHPRegenEvent extends PlayerEvent implements Cancellable return _health; } + public void setNatural(boolean natural) + { + _natural = natural; + } + + public boolean isNatural() + { + return _natural; + } + @Override public boolean isCancelled() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java index 85d9f93ee..d66be7c20 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java @@ -1,16 +1,19 @@ package nautilus.game.arcade.game.games.moba.kit.larissa; -import mineplex.core.common.util.UtilBlock; +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.UtilPlayer; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.buff.BuffManager; +import nautilus.game.arcade.game.games.moba.buff.buffs.BuffCripple; import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.BlockFromToEvent; -import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.inventory.ItemStack; +import java.util.concurrent.TimeUnit; + public class SkillWaterDash extends DashSkill { @@ -18,6 +21,7 @@ public class SkillWaterDash extends DashSkill "Dash along the ground, leaving water behind you.", }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + private static final long CRIPPLE_DURATION = TimeUnit.SECONDS.toMillis(3); public SkillWaterDash(int slot) { @@ -34,23 +38,18 @@ public class SkillWaterDash extends DashSkill @Override public void dashTick(Player player) { - Block block = player.getLocation().getBlock(); + UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 5, ViewDist.LONG); + Moba moba = (Moba) Manager.GetGame(); + BuffManager buffManager = moba.getBuffManager(); - while (!UtilBlock.solid(block)) + for (Player nearby : UtilPlayer.getNearby(player.getLocation(), 2)) { - block = block.getRelative(BlockFace.DOWN); - } + if (isTeamDamage(nearby, player) || buffManager.hasBuff(nearby, BuffCripple.class)) + { + continue; + } - Block fBlock = block; - Manager.runSyncLater(() -> Manager.GetBlockRestore().add(fBlock.getRelative(BlockFace.UP), Material.WATER.getId(), (byte) 0, 7000), 10); - } - - @EventHandler - public void onBlockFromTo(BlockFromToEvent event) - { - if (event.getBlock().isLiquid() || event.getToBlock().isLiquid()) - { - event.setCancelled(true); + buffManager.apply(new BuffCripple(moba, nearby, CRIPPLE_DURATION)); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java index 7a1db55a7..27de6635a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java @@ -24,7 +24,7 @@ public class SkillCombatDash extends DashSkill setCooldown(8000); _collide = false; - _velocityTime = 400; + _velocityTime = 250; _velocityStopOnEnd = true; _velocityMagnitude = 1.5; _horizontial = true; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java index fe7221e1a..81f3d536d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java @@ -9,7 +9,9 @@ import mineplex.core.common.util.particles.effects.LineParticle; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Material; import org.bukkit.Sound; @@ -96,8 +98,11 @@ public class SkillLightArrows extends HeroSkill event.getProjectile().remove(); + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.4, 40, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); + lineParticle.setIgnoreAllBlocks(true); + _arrows.putIfAbsent(player, new HashSet<>()); - _arrows.get(player).add(new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.4, 20, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers())); + _arrows.get(player).add(lineParticle); } @EventHandler @@ -108,30 +113,38 @@ public class SkillLightArrows extends HeroSkill return; } + TowerManager towerManager = ((Moba) Manager.GetGame()).getTowerManager(); + for (Entry> entry : _arrows.entrySet()) { Player player = entry.getKey(); Iterator iterator = entry.getValue().iterator(); double damage = MobaUtil.scaleDamageWithBow(player.getInventory().getItem(0), 0); - while (iterator.hasNext()) + lineParticleLoop : while (iterator.hasNext()) { LineParticle lineParticle = iterator.next(); - if (!lineParticle.update()) + for (int i = 0; i < 4; i++) { - for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 1.5).keySet()) + if (!lineParticle.update()) { - if (Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false)) + towerManager.damageTowerAt(lineParticle.getLastLocation(), player, damage); + + for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 1.5).keySet()) { - player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 0.8F); - Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName()); + if (Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false)) + { + player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 0.8F); + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName()); + } } } - } - else - { - iterator.remove(); + else + { + iterator.remove(); + continue lineParticleLoop; + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java index 5ba6f17f5..96c28be81 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java @@ -37,43 +37,43 @@ public class MobaAssassinShop extends MobaShopMenu 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) - ), + .build(), 200), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) - .setTitle(C.cGreen + "Ninja's Rainment") + .setTitle(C.cGreen + "Ninja's Mask") .build(), 500) .addEffects( - new MobaHPRegenEffect(0.1) + new MobaKillHealEffect(2) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Urchin's Cap") + .build(), 600) + .addEffects( + new MobaHPRegenEffect(0.2) ), 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) - ), + .build(), 250), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) - .setTitle(C.cGreen + "Ninja's Rainment") + .setTitle(C.cGreen + "Ninja's Chestcloth") .build(), 750) .addEffects( new MobaCDREffect(0.15) ), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Urchin's Chestcloth") + .build(), 850) + .addEffects( + new MobaMeleeDamageEffect("Urchin's Chestcloth", 1) + ), 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( @@ -81,38 +81,41 @@ public class MobaAssassinShop extends MobaShopMenu .setTitle(C.cGreen + "Leather Leggings") .build(), 250), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) - .setTitle(C.cGreen + "Ninja's Rainment") + .setTitle(C.cGreen + "Ninja's Leggings") .build(), 750) .addEffects( - new MobaTotalHealthEffect(2) + new MobaCDREffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Urchin's Leggings") + .build(), 850) + .addEffects( + new MobaAbilityDamageEffect("Urchin's Leggings", 0.1) ), 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) - ), + .build(), 200), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) - .setTitle(C.cGreen + "Ninja's Rainment") + .setTitle(C.cGreen + "Ninja's Boots") .build(), 500) .addEffects( new MobaSpeedEffect(0.15) ), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Urchin's Boots") + .build(), 600) + .addEffects( + new MobaSpeedEffect(0.17) + ), 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) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java index 6485a4082..b3aedb2ed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.shop.effects; import mineplex.core.common.util.F; import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; @@ -29,9 +30,20 @@ public class MobaAbilityDamageEffect extends MobaItemEffect event.AddMod(_reason, event.GetDamage() * _factor); } + @Override + protected void onHPRegen(MobaHPRegenEvent event) + { + if (event.isNatural()) + { + return; + } + + event.increaseHealth(_factor); + } + @Override public String getDescription() { - return "Increases ability damage by " + F.greenElem(format(_factor * 100)) + "%."; + return "Increases ability damage/healing by " + F.greenElem(format(_factor * 100)) + "%."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java index 7c6bdfba7..d31ff421e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -3,6 +3,7 @@ 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.game.games.moba.shop.MobaItemEffect; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.entity.Player; public class MobaKillHealEffect extends MobaItemEffect @@ -18,7 +19,7 @@ public class MobaKillHealEffect extends MobaItemEffect @Override public void onDeath(Player killed, Player killer) { - killer.setHealth(Math.min(killer.getMaxHealth(), killer.getHealth() + _health)); + MobaUtil.heal(killer, _health); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java new file mode 100644 index 000000000..5dde0b641 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; + +public class MobaMeleeDamageEffect extends MobaItemEffect +{ + + private String _reason; + private double _increase; + + public MobaMeleeDamageEffect(String reason, double increase) + { + _reason = reason; + _increase = increase; + } + + @Override + protected void onDamage(CustomDamageEvent event) + { + event.AddMod(_reason, _increase); + } + + @Override + public String getDescription() + { + return "All your melee attacks deal " + F.greenElem("+" + format(_increase)) + "."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java index 2723bdf3e..2c9b75b86 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java @@ -37,14 +37,14 @@ public class MobaHunterShop extends MobaShopMenu .addEnchantment(Enchantment.ARROW_DAMAGE, 2) .build(), 1200) .addEffects( - new MobaHitConditionEffect("Bow of Pursuit", ConditionType.SPEED, 2, 0, false) + new MobaHitConditionEffect("Bow of Pursuit", ConditionType.SPEED, 3, 1, false) ), new MobaItem(new ItemBuilder(Material.BOW) .setTitle(C.cYellowB + "Vampiric Bow") .addEnchantment(Enchantment.ARROW_DAMAGE, 1) .build(), 1500) .addEffects( - new MobaHitArrowHealEffect(0.25) + new MobaKillHealEffect(0.15) ), new MobaItem(new ItemBuilder(Material.BOW) .setTitle(C.cYellowB + "Bow of Renewal") @@ -88,7 +88,7 @@ public class MobaHunterShop extends MobaShopMenu .setTitle(C.cGreen + "Vampiric Helmet") .build(), 500) .addEffects( - new MobaHitArrowHealEffect(0.05) + new MobaHPRegenEffect(0.2) ), new MobaItem(new ItemBuilder(Material.CHAINMAIL_HELMET) .setTitle(C.cGreen + "Chainmail Helmet") @@ -115,7 +115,7 @@ public class MobaHunterShop extends MobaShopMenu .setTitle(C.cGreen + "Vampiric Chestplate") .build(), 750) .addEffects( - new MobaHitArrowHealEffect(0.15) + new MobaKillHealEffect(3) ), new MobaItem(new ItemBuilder(Material.CHAINMAIL_CHESTPLATE) .setTitle(C.cGreen + "Chainmail Chestplate") @@ -142,7 +142,7 @@ public class MobaHunterShop extends MobaShopMenu .setTitle(C.cGreen + "Vampiric Leggings") .build(), 700) .addEffects( - new MobaHitArrowHealEffect(0.1) + new MobaKillHealEffect(3) ), new MobaItem(new ItemBuilder(Material.CHAINMAIL_LEGGINGS) .setTitle(C.cGreen + "Chainmail Leggings") @@ -169,7 +169,7 @@ public class MobaHunterShop extends MobaShopMenu .setTitle(C.cGreen + "Vampiric Boots") .build(), 500) .addEffects( - new MobaHitArrowHealEffect(0.05) + new MobaKillHealEffect(1) ), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Leather Hiking Boots") diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 48bddbc19..efb13fcb6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -1,8 +1,16 @@ package nautilus.game.arcade.game.games.moba.structure.tower; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +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.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseGuardian; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; @@ -40,6 +48,7 @@ public class Tower private boolean _firstTower; private boolean _dead; private long _lastInform; + private double _damage; private ArmorStand _stand; private DisguiseGuardian _guardian; @@ -55,6 +64,7 @@ public class Tower _maxHealth = health; _firstTower = firstTower; _lastInform = System.currentTimeMillis(); + _damage = DAMAGE; } public void setup() @@ -86,6 +96,9 @@ public class Tower { if (_target == null) { + // Reset damage + _damage = DAMAGE; + // Target just entities LivingEntity target = MobaUtil.getBestEntityTarget(_host, _team, _stand, _crystal.getLocation(), TARGET_RANGE, false); @@ -119,7 +132,7 @@ public class Tower _target.getWorld().playSound(_target.getLocation(), Sound.EXPLODE, 1, 0.2F); UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, _target.getLocation().add(0, 1.5, 0), 0, 0, 0, 0.2F, 1, ViewDist.LONG); - _host.getArcadeManager().GetDamage().NewDamageEvent(_target, null, null, DamageCause.CUSTOM, DAMAGE, false, true, false, "Tower", "Tower"); + _host.getArcadeManager().GetDamage().NewDamageEvent(_target, null, null, DamageCause.CUSTOM, _damage++, false, true, false, "Tower", "Tower"); } private void setLaserTarget(LivingEntity target) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java index f9ca54daa..3dab8cbf2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java @@ -7,7 +7,6 @@ public class MobaConstants public static final String BASIC_ATTACK = "Basic Attack"; public static final String AMMO = "Ammo"; public static final String TEAM_METADATA = "team"; - public static final String SHOOTER_METADATA = "shooter"; // Location Constants public static final String MINION_PATH_START = "WHITE"; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 08c3923e3..72fe45918 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -202,13 +202,15 @@ public class MobaUtil { if (entity instanceof Player) { - MobaHPRegenEvent regenEvent = new MobaHPRegenEvent((Player) entity, health); + MobaHPRegenEvent regenEvent = new MobaHPRegenEvent((Player) entity, health, false); UtilServer.CallEvent(regenEvent); if (regenEvent.isCancelled()) { return; } + + health = regenEvent.getHealth(); } entity.setHealth(Math.min(entity.getHealth() + health, entity.getMaxHealth())); From 4978f924a79fb308d7045be6455abe2e543934a1 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 13 Jun 2017 21:49:34 +0100 Subject: [PATCH 176/283] Lots of bug fixes --- .../src/mineplex/core/game/GameDisplay.java | 2 +- .../src/mineplex/mapparser/GameType.java | 1 + .../game/arcade/game/games/moba/Moba.java | 23 +- .../games/moba/boss/pumpkin/PumpkinBoss.java | 2 +- .../games/moba/buff/buffs/BuffCripple.java | 11 +- .../games/moba/general/MobaDamageManager.java | 15 ++ .../arcade/game/games/moba/kit/HeroSkill.java | 8 +- .../moba/kit/anath/SkillFireProjectile.java | 3 +- .../games/moba/kit/anath/SkillMeteor.java | 6 + .../games/moba/kit/bardolf/SkillFullMoon.java | 1 + .../moba/kit/bardolf/SkillSummonWolf.java | 26 +++ .../games/moba/kit/biff/SkillWarHorse.java | 15 ++ .../games/moba/kit/hp/MobaHPRegenEvent.java | 12 +- .../moba/kit/larissa/SkillAquaCannon.java | 3 +- .../games/moba/kit/rowena/HeroRowena.java | 3 +- .../moba/kit/rowena/SkillBombardment.java | 219 ++++++++++++++++++ .../moba/kit/rowena/SkillLightArrows.java | 14 +- .../game/games/moba/shop/MobaItemEffect.java | 4 + .../arcade/game/games/moba/shop/MobaShop.java | 24 ++ .../shop/effects/MobaAbilityDamageEffect.java | 2 +- .../shop/effects/MobaHitConditionEffect.java | 2 +- .../shop/effects/MobaMeleeDamageEffect.java | 3 +- .../moba/structure/point/CapturePoint.java | 5 + .../structure/point/CapturePointManager.java | 41 ++-- .../moba/structure/tower/TowerManager.java | 2 +- 25 files changed, 414 insertions(+), 33 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 659be4430..8b7ec8606 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -104,7 +104,7 @@ public enum GameDisplay AlienInvasion("Alien Invasion", Material.ENDER_STONE, (byte) 0, GameCategory.EVENT, 69, false), - MOBA("Heroes of the Craft", Material.SKULL_ITEM, (byte)1, GameCategory.CLASSICS, 70, true), + MOBA("Heroes of GWEN", Material.SKULL_ITEM, (byte)1, GameCategory.CLASSICS, 70, true), GemHunters("Gem Hunters", Material.EMERALD, (byte) 0, GameCategory.SURVIVAL, 71, false), diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java index b3b28d303..b8c09946c 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java @@ -44,6 +44,7 @@ public enum GameType MineWare("MineWare"), MinecraftLeague("MCL"), MilkCow("Milk the Cow"), + HOG("Heroes of GWEN"), MonsterLeague("MonsterLeague"), MonsterMaze("Monster Maze"), Paintball("Super Paintball"), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index db0ee8014..f6992f67a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -10,6 +10,7 @@ import mineplex.minecraft.game.core.combat.DeathMessageType; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; @@ -328,13 +329,16 @@ public class Moba extends TeamGame scoreboard.write(red.GetColor() + C.Bold + redTitle); scoreboard.write("Base: " + _tower.getDisplayString(red) + _boss.getWitherDisplayString(red)); - scoreboard.write("Beacons: " + _capturePoint.getDisplayString(red)); scoreboard.writeNewLine(); scoreboard.write(blue.GetColor() + C.Bold + blueTitle); scoreboard.write("Base: " + _tower.getDisplayString(blue) + _boss.getWitherDisplayString(blue)); - scoreboard.write("Beacons: " + _capturePoint.getDisplayString(blue)); + + scoreboard.writeNewLine(); + + scoreboard.write(C.cGreenB + "Beacons"); + scoreboard.write(_capturePoint.getDisplayString()); scoreboard.writeNewLine(); @@ -355,8 +359,6 @@ public class Moba extends TeamGame scoreboard.write(C.cYellowB + "Time"); scoreboard.write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime())); - - scoreboard.writeNewLine(); } private void writeEnd(Player player, GameScoreboard scoreboard) @@ -387,6 +389,19 @@ public class Moba extends TeamGame } } + @EventHandler + public void preventOverfill(PlayerPrepareTeleportEvent event) + { + Player player = event.GetPlayer(); + + if (GetPlayers(true).size() > 8) + { + SetPlayerState(player, GameTeam.PlayerState.OUT); + Manager.addSpectator(player, true); + player.sendMessage(F.main("Game", "Too many players are in this server. You are now spectating, sorry.")); + } + } + @Override public void EndCheck() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index e0ec6c8fb..133a8277e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -125,7 +125,7 @@ public class PumpkinBoss extends MobaBoss Block block = entry.getKey(); double setChance = entry.getValue(); - if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > setChance) + if (!UtilBlock.solid(block)|| block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > setChance) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java index c72f8fe2b..aa06f1003 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java @@ -2,15 +2,24 @@ package nautilus.game.arcade.game.games.moba.buff.buffs; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.buff.Buff; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; public class BuffCripple extends Buff { - private static final ItemStack + private static final ItemStack ITEM = new ItemBuilder(Material.IRON_INGOT) + .setTitle(C.cGray + "Crippled") + .build(); + + public static ItemStack getItemRepresentation() + { + return ITEM; + } public BuffCripple(Moba host, Player entity, long duration) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java index 49a7e4c55..e989d5b09 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.general; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.condition.Condition; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; @@ -10,6 +11,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; public class MobaDamageManager implements Listener @@ -89,4 +91,17 @@ public class MobaDamageManager implements Listener _host.getScoreboardModule().refresh(); } + + @EventHandler(priority = EventPriority.HIGH) + public void unifyKilledWith(CombatDeathEvent event) + { + String word = event.getKilledWord(); + String[] split = word.split("-"); + + if (word.contains("Click") && split.length > 1) + { + word = split[1].trim(); + event.setKilledWord(word); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 97a31933a..df6e2e3e2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -312,7 +312,8 @@ public class HeroSkill extends Perk // If the player is crippled say they are if (moba.getBuffManager().hasBuff(player, BuffCripple.class)) { - itemStack = + player.getInventory().setItem(_slot, BuffCripple.getItemRepresentation()); + continue; } if (done) @@ -385,6 +386,11 @@ public class HeroSkill extends Perk }, 0, 20); } + public void resetCooldown(Player player) + { + _lastSkill.put(player.getUniqueId(), 0L); + } + protected boolean isTeamDamage(LivingEntity damagee, LivingEntity damager) { if (!(damager instanceof Player)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 53f2313a5..59b39a822 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.moba.kit.anath; import mineplex.core.common.util.UtilEvent.ActionType; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Material; import org.bukkit.entity.Item; import org.bukkit.entity.Player; @@ -45,7 +46,7 @@ public class SkillFireProjectile extends HeroSkill Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), _kit.getAmmo()); item.setVelocity(direction); - Manager.GetFire().Add(item, player, 3, 0, 1, DAMAGE, GetName(), false); + Manager.GetFire().Add(item, player, 3, 0, 1, DAMAGE, MobaConstants.BASIC_ATTACK, false); ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, item, DAMAGE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index f2d90f7a7..9d7421a1b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -8,6 +8,7 @@ import mineplex.core.common.util.particles.ColoredParticle; import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.GameTeam; @@ -63,6 +64,11 @@ public class SkillMeteor extends HeroSkill implements IThrown Player player = event.getPlayer(); + if (!Recharge.Instance.use(player, GetName() + "Trigger", 2000, false, false)) + { + return; + } + for (MeteorShowerData data : _data) { if (data.Shooter.equals(player)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java index 7e74745d8..6bfa262bc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java @@ -73,6 +73,7 @@ public class SkillFullMoon extends HeroSkill wolf.getWorld().playSound(wolf.getLocation(), Sound.WOLF_GROWL, 1, 1); } + broadcast(player); useActiveSkill(() -> { _active.remove(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java index 39e7a95ec..4fa75b94f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java @@ -4,6 +4,8 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.SpigotUtil; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; @@ -93,4 +95,28 @@ public class SkillSummonWolf extends HeroSkill useSkill(player); } + + @EventHandler + public void updateWolfItem(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + { + return; + } + + HeroBardolf kit = (HeroBardolf) Kit; + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + WolfData data = kit.getWolfData(player); + ItemStack itemStack = player.getInventory().getItem(getSlot()); + + if (data == null || itemStack == null || itemStack.getType() != SKILL_ITEM.getType()) + { + continue; + } + + itemStack.setAmount(data.getWolves().size()); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index 27784b829..1564ed858 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -11,6 +11,7 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.buff.BuffManager; import nautilus.game.arcade.game.games.moba.buff.buffs.BuffRooting; @@ -138,6 +139,20 @@ public class SkillWarHorse extends HeroSkill } } + @EventHandler + public void horseDamage(CustomDamageEvent event) + { + for (WarHorseData data : _data) + { + if (data.Horse.equals(event.GetDamageeEntity())) + { + event.SetCancelled("Biff Horse"); + return; + } + } + + } + private class WarHorseData { public Player Owner; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java index 903ed115c..2ef3e9875 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.hp; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -10,20 +11,27 @@ public class MobaHPRegenEvent extends PlayerEvent implements Cancellable private static final HandlerList _handlers = new HandlerList(); + private final Player _source; private final double _initialHealth; private double _health; private boolean _natural; private boolean _cancel; - public MobaHPRegenEvent(Player who, double health, boolean natural) + public MobaHPRegenEvent(Player who, Player source, double health, boolean natural) { super(who); + _source = source; _initialHealth = health; _health = health; _natural = natural; } + public Player getSource() + { + return _source; + } + public void setHealth(double health) { _health = health; @@ -31,7 +39,7 @@ public class MobaHPRegenEvent extends PlayerEvent implements Cancellable public void increaseHealth(double factor) { - _health = _initialHealth * factor; + _health = _initialHealth + (_initialHealth * factor); } public double getHealth() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java index 4e1a2bdca..74e61a7f3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java @@ -11,6 +11,7 @@ import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; @@ -65,7 +66,7 @@ public class SkillAquaCannon extends HeroSkill continue; } - Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, DAMAGE, true, false, false, player.getName(), GetName()); + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, DAMAGE, true, false, false, player.getName(), MobaConstants.BASIC_ATTACK); break; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java index 81de69740..d196ad8cb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java @@ -16,7 +16,8 @@ public class HeroRowena extends HeroKit private static final Perk[] PERKS = { new SkillBow(0), new SkillLightArrows(1), - new SkillCombatDash(2) + new SkillCombatDash(2), + new SkillBombardment(3) }; private static final ItemStack AMMO = new ItemBuilder(Material.ARROW) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java new file mode 100644 index 000000000..1a704d5e8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java @@ -0,0 +1,219 @@ +package nautilus.game.arcade.game.games.moba.kit.rowena; + +import mineplex.core.common.events.EntityVelocityChangeEvent; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEvent.ActionType; +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.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class SkillBombardment extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Turns into a Diamond Sword that deals extreme", + "damage to any player hit by it." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + private static final int SHOTS = 3; + private static final int MAX_TIME = 10000; + private static final int DAMAGE_INCREASE = 5; + + private Set _data = new HashSet<>(); + + public SkillBombardment(int slot) + { + super("Bombardment", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(60000); + setDropItemActivate(true); + } + + @Override + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + for (BombardmentData data : _data) + { + if (data.Shooter.equals(player)) + { + return; + } + } + + for (Perk perk : Kit.GetPerks()) + { + if (perk instanceof SkillLightArrows) + { + SkillLightArrows skill = (SkillLightArrows) perk; + + skill.resetCooldown(player); + skill.setPlayerArrows(player, SHOTS); + } + } + + broadcast(player); + UtilAction.velocity(player, new Vector(0, 2, 0)); + _data.add(new BombardmentData(player)); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator iterator = _data.iterator(); + + while (iterator.hasNext()) + { + BombardmentData data = iterator.next(); + Player player = data.Shooter; + + if (data.Block == null && player.getVelocity().getY() <= 0) + { + data.Block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); + data.Block.setType(Material.BARRIER); + + Location playerLocation = player.getLocation(); + Location toTeleport = data.Block.getLocation(); + toTeleport.setYaw(playerLocation.getYaw()); + toTeleport.setPitch(playerLocation.getPitch()); + + player.getInventory().setHeldItemSlot(0); + } + else if (UtilTime.elapsed(data.Start, MAX_TIME) || data.Shots == 0) + { + useSkill(player); + data.Block.setType(Material.AIR); + iterator.remove(); + } + else if (data.Block != null) + { + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, data.Block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.001F, 3, ViewDist.LONG); + } + } + } + + @EventHandler + public void shootArrow(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.getEntity(); + + for (BombardmentData data : _data) + { + if (data.Shooter.equals(player)) + { + data.Shots--; + return; + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void increaseDamage(CustomDamageEvent event) + { + if (event.isCancelled()) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + + if (damager == null || event.GetReason() == null || !event.GetReason().contains("Light Arrows")) + { + return; + } + + damager.playSound(event.GetDamageeEntity().getLocation(), Sound.EXPLODE, 1, 0.6F); + UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, event.GetDamageeEntity().getLocation().add(0, 1, 0), 0, 0, 0, 0.1F, 1, ViewDist.LONG); + event.AddMod(GetName(), DAMAGE_INCREASE); + } + + @EventHandler + public void playerMove(PlayerMoveEvent event) + { + Player player = event.getPlayer(); + + for (BombardmentData data : _data) + { + if (data.Block != null && data.Shooter.equals(player) && (event.getTo().getX() != event.getFrom().getX() || event.getTo().getZ() != event.getFrom().getZ())) + { + event.setTo(event.getFrom()); + } + } + } + + @EventHandler + public void playerVelocity(EntityVelocityChangeEvent event) + { + if (!(event.getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.getEntity(); + + for (BombardmentData data : _data) + { + if (data.Block != null && data.Shooter.equals(player)) + { + event.setCancelled(true); + } + } + } + + private class BombardmentData + { + + Player Shooter; + int Shots; + Block Block; + long Start; + + BombardmentData(Player shooter) + { + Shooter = shooter; + Shots = SHOTS; + Start = System.currentTimeMillis(); + } + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java index 81f3d536d..b71653c29 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.moba.kit.rowena; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.particles.effects.LineParticle; @@ -11,6 +12,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Material; @@ -129,7 +131,12 @@ public class SkillLightArrows extends HeroSkill { if (!lineParticle.update()) { - towerManager.damageTowerAt(lineParticle.getLastLocation(), player, damage); + Tower hitTower = towerManager.damageTowerAt(lineParticle.getLastLocation(), player, damage); + + if (hitTower != null && UtilMath.offsetSquared(hitTower.getCrystal(), player) > Tower.TARGET_RANGE_SQUARED) + { + continue; + } for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 1.5).keySet()) { @@ -163,5 +170,10 @@ public class SkillLightArrows extends HeroSkill _playerArrows.remove(event.getPlayer()); _arrows.remove(event.getPlayer()); } + + void setPlayerArrows(Player player, int amount) + { + _playerArrows.put(player, amount); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java index ce3b3a233..3e37e1cc4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -50,6 +50,10 @@ public abstract class MobaItemEffect { } + protected void onHPRegenOthers(MobaHPRegenEvent event) + { + } + protected void onRespawn(PlayerGameRespawnEvent event) { } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index fb75fd78a..8af803c11 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -444,6 +444,30 @@ public class MobaShop implements Listener } } + @EventHandler + public void hpOther(MobaHPRegenEvent event) + { + if (event.getSource() == null) + { + return; + } + + List items = _upgrades.get(event.getSource()); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onHPRegenOthers(event); + } + } + } + @EventHandler public void repawn(PlayerGameRespawnEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java index b3aedb2ed..63d15b7df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java @@ -31,7 +31,7 @@ public class MobaAbilityDamageEffect extends MobaItemEffect } @Override - protected void onHPRegen(MobaHPRegenEvent event) + protected void onHPRegenOthers(MobaHPRegenEvent event) { if (event.isNatural()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java index 296c5e073..60095e421 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java @@ -51,6 +51,6 @@ public class MobaHitConditionEffect extends MobaItemEffect @Override public String getDescription() { - return "Hitting a player applies " + F.greenElem(format(_conditionType, _multi)) + " for " + F.time(format(_duration)) + " seconds."; + return "Hitting a player gives " + (_applyToDamagee ? "them" : "you") + " " + F.greenElem(format(_conditionType, _multi)) + " for " + F.time(format(_duration)) + " seconds."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java index 5dde0b641..8e2e348bc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.shop.effects; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; @@ -25,6 +26,6 @@ public class MobaMeleeDamageEffect extends MobaItemEffect @Override public String getDescription() { - return "All your melee attacks deal " + F.greenElem("+" + format(_increase)) + "."; + return "All your melee attacks deal " + F.greenElem("+" + format(_increase / 2)) + C.cRed + "❤" + C.cGray + "."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index 25bb5599c..11ab9881d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -284,6 +284,11 @@ public class CapturePoint _center.getBlock().getRelative(BlockFace.DOWN).setData(colour); } + public String getName() + { + return _name; + } + public ChatColor getColour() { return _colour; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java index ae6697317..51b6d7944 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java @@ -5,7 +5,6 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -77,30 +76,42 @@ public class CapturePointManager implements Listener } } - public String getDisplayString(GameTeam team) + public String getDisplayString() { StringBuilder out = new StringBuilder(); - int owned = 0; for (CapturePoint point : _capturePoints) { - if (point.getOwner() == null || !point.getOwner().equals(team)) - { - continue; - } - - out.append(point.getColour()).append("⚑ "); - owned++; - } - - while (owned++ < 3) - { - out.append(C.cGray).append("⚑ "); + out.append(point.getOwner() == null ? C.cWhite : point.getOwner().GetColor()).append(point.getName()).append(" "); } return out.toString().trim(); } +// public String getDisplayString(GameTeam team) +// { +// StringBuilder out = new StringBuilder(); +// int owned = 0; +// +// for (CapturePoint point : _capturePoints) +// { +// if (point.getOwner() == null || !point.getOwner().equals(team)) +// { +// continue; +// } +// +// out.append(point.getColour()).append("⚑ "); +// owned++; +// } +// +// while (owned++ < 3) +// { +// out.append(C.cGray).append("⚑ "); +// } +// +// return out.toString().trim(); +// } + public List getCapturePoints() { return _capturePoints; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index a8a8319db..f31a6c380 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -211,7 +211,7 @@ public class TowerManager implements Listener GameTeam team = _host.GetTeam(player); - if (UtilPlayer.isSpectator(player) || team == null || !canDamage(tower, team) || shouldCancelDamage(tower, player)) + if (UtilPlayer.isSpectator(player) || team == null || !canDamage(tower, team) || shouldCancelDamage(tower, player) || !Recharge.Instance.use(player, "Damage Tower", 200, false, false)) { return; } From d168e03f80f85c2728db38352ee7f09ca5c3045e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 13 Jun 2017 23:13:18 -0400 Subject: [PATCH 177/283] Check for Hardcore mode in Clans Server Selector --- .../mineplex/clanshub/ClansServerPage.java | 114 ++++++++++++------ .../clanshub/ClansTransferManager.java | 11 +- .../src/mineplex/clanshub/ServerInfo.java | 1 + 3 files changed, 86 insertions(+), 40 deletions(-) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java index a561d15fc..983c5ef29 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java @@ -1,20 +1,23 @@ package mineplex.clanshub; import java.util.Collection; -import java.util.Comparator; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.donation.DonationManager; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; +import mineplex.core.stats.StatsManager; import mineplex.game.clans.core.repository.tokens.SimpleClanToken; -import org.bukkit.Material; -import org.bukkit.entity.Player; - /** * GUI page for clans servers */ @@ -31,37 +34,54 @@ public class ClansServerPage extends ShopPageBase= UtilTime.convert(20, TimeUnit.HOURS, TimeUnit.SECONDS); + } + + private String timeTillUnlockHardcore() + { + if (canPlayHardcore()) + { + return "0 Seconds"; } else { - buildJoinHomeServer(clan); + long secondsPlayed = Managers.get(StatsManager.class).Get(_player).getStat("Clans.TimePlaying"); + long needed = UtilTime.convert(20, TimeUnit.HOURS, TimeUnit.SECONDS); + + return UtilTime.MakeStr(UtilTime.convert(needed - secondsPlayed, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)); } } private void buildNoClanPage() { - Collection servers = UtilAlg.sortSet(getPlugin().getServers(), new Comparator() + Collection servers = UtilAlg.sortSet(getPlugin().getServers(true), (o1, o2) -> { - @Override - public int compare(ServerInfo o1, ServerInfo o2) - { - return o1.Name.compareTo(o2.Name); - } + return o1.Name.compareTo(o2.Name); }); int currentSlot = 9; @@ -93,39 +113,57 @@ public class ClansServerPage extends ShopPageBase servers = UtilAlg.sortSet(getPlugin().getServers(), new Comparator() + if (!clan.getClanName().isEmpty()) { - @Override - public int compare(ServerInfo o1, ServerInfo o2) - { - return o1.Name.compareTo(o2.Name); - } + ServerInfo serverInfo = getServerInfo(clan.getHomeServer()); + boolean serverOnline = (serverInfo != null); + String serverStatus = serverOnline ? C.cGreen + "Online" : C.cRed + "Offline"; + + String title = (serverOnline ? C.cGreen : C.cRed) + C.Bold + "Join Home Server!"; + String serverName = C.cYellow + "Server Name: " + C.cWhite + clan.getHomeServer(); + String serverDesc = C.cYellow + "Server Status: " + C.cWhite + serverStatus; + String players = C.cYellow + "Players: " + C.cWhite + (serverOnline ? serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers : "0/0"); + String mode = C.cYellow + "Mode " + C.cWhite + (serverInfo.Hardcore ? "Hardcore" : "Casual"); + ShopItem shopItem = new ShopItem(Material.EMERALD_BLOCK, title, new String[] {" ", serverName, serverDesc, players, mode, " "}, 0, true, true); + addButton(13, shopItem, new JoinServerButton(this, getPlugin(), getServerInfo(clan.getHomeServer()))); + } + + Collection servers = UtilAlg.sortSet(getPlugin().getServers(true), (o1, o2) -> + { + return o1.Name.compareTo(o2.Name); }); int currentSlot = 27; for (ServerInfo server : servers) { - if (server.Name.equalsIgnoreCase(clan.getHomeServer())) + if (!clan.getClanName().isEmpty() && server.Name.equalsIgnoreCase(clan.getHomeServer())) { continue; } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java index 4bbbf3c9d..6229d8b3e 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java @@ -74,10 +74,16 @@ public class ClansTransferManager extends MiniDbClientPlugin * Gets a list of all loaded servers * @return A list of all loaded servers */ - public List getServers() + public List getServers(boolean onlineOnly) { List servers = Lists.newArrayList(); - servers.addAll(_servers.values()); + for (ServerInfo info : _servers.values()) + { + if (!info.MOTD.equalsIgnoreCase("Restarting soon") || !onlineOnly) + { + servers.add(info); + } + } return servers; } @@ -112,6 +118,7 @@ public class ClansTransferManager extends MiniDbClientPlugin info.MOTD = server.getMotd(); info.CurrentPlayers = server.getPlayerCount(); info.MaxPlayers = server.getMaxPlayerCount(); + info.Hardcore = server.getMotd().contains("Hardcore"); _servers.put(server, info); } } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java index e51c34ff6..1dc448609 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java @@ -9,6 +9,7 @@ public class ServerInfo public String MOTD; public int CurrentPlayers = 0; public int MaxPlayers = 0; + public boolean Hardcore = false; /** * Checks how many slots are left on this server From 64c084ecb39d81010c89350cd68dc33148af5eb8 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 13 Jun 2017 23:16:00 -0400 Subject: [PATCH 178/283] Handle Hardcore and Casual modes in clans mechanics --- .../src/mineplex/game/clans/Clans.java | 22 +++++++++++++---- .../game/clans/clans/ClansManager.java | 17 ++++++++++++- .../clans/clans/gui/page/ClanMainPage.java | 2 +- .../scoreboard/ClansPlayerScoreboard.java | 21 +++++++++------- .../game/clans/clans/siege/SiegeManager.java | 5 ++++ .../clans/siege/outpost/OutpostManager.java | 5 ++++ .../game/clans/clans/war/WarManager.java | 5 ++++ .../clans/war/command/WarPointsCommand.java | 6 +++++ .../clans/warpoints/WarPointEvasion.java | 2 +- .../mineplex/game/clans/shop/pvp/PvpPage.java | 24 ++++++++++++------- 10 files changed, 84 insertions(+), 25 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 50d1d76e4..784e5c230 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -1,7 +1,9 @@ package mineplex.game.clans; -import mineplex.core.aprilfools.AprilFoolsManager; -import net.minecraft.server.v1_8_R3.MinecraftServer; +import static mineplex.core.Managers.require; + +import java.io.File; +import java.io.IOException; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -11,7 +13,6 @@ import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.plugin.java.JavaPlugin; import org.spigotmc.SpigotConfig; -import mineplex.core.common.Constants; import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; import mineplex.core.TimingsFix; @@ -20,12 +21,14 @@ import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; import mineplex.core.antihack.guardians.AntiHackGuardian; import mineplex.core.antihack.guardians.GuardianManager; +import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; import mineplex.core.chatsnap.SnapshotManager; import mineplex.core.chatsnap.SnapshotPlugin; import mineplex.core.chatsnap.SnapshotRepository; import mineplex.core.command.CommandCenter; +import mineplex.core.common.Constants; import mineplex.core.common.MinecraftVersion; import mineplex.core.common.Pair; import mineplex.core.common.events.ServerShutdownEvent; @@ -74,12 +77,13 @@ import mineplex.game.clans.shop.mining.MiningShop; import mineplex.game.clans.shop.pvp.PvpShop; import mineplex.game.clans.spawn.travel.TravelShop; import mineplex.game.clans.world.WorldManager; - -import static mineplex.core.Managers.require; +import net.minecraft.server.v1_8_R3.MinecraftServer; public class Clans extends JavaPlugin { public static final String MAP = "Season 3"; + + public static boolean HARDCORE = false; // Modules private CoreClientManager _clientManager; @@ -89,6 +93,14 @@ public class Clans extends JavaPlugin @Override public void onEnable() { + try + { + HARDCORE = new File(new File(".").getCanonicalPath() + File.separator + "Hardcore.dat").exists(); + } + catch (IOException e) + { + e.printStackTrace(); + } Bukkit.setSpawnRadius(0); // Configs diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index cda5d8645..51a916ac4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -31,6 +31,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.vehicle.VehicleEnterEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; @@ -85,6 +86,7 @@ import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.updater.UpdateType; 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; @@ -656,6 +658,19 @@ public class ClansManager extends MiniClientPluginimplements IRelati public long lastPower = System.currentTimeMillis(); + @EventHandler + public void displayHardcoreMode(ServerListPingEvent event) + { + if (Clans.HARDCORE) + { + event.setMotd("Hardcore"); + } + else + { + event.setMotd("Casual"); + } + } + @EventHandler public void savePlayerActiveBuild(PlayerQuitEvent event) { @@ -1449,4 +1464,4 @@ public class ClansManager extends MiniClientPluginimplements IRelati { return _incognitoManager; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanMainPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanMainPage.java index 7db99c36b..ee6361d72 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanMainPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanMainPage.java @@ -361,4 +361,4 @@ public class ClanMainPage extends ClanPageBase addButton(slot, item, new ClanMemeberButton(getShop(), getPlugin(), getPlayer(), guiInfo, guiRole, this, clansPlayer.getPlayerName())); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java index 29950b8db..5b2f870b6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java @@ -13,6 +13,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilText; import mineplex.core.thereallyoldscoreboardapiweshouldremove.PlayerScoreboard; import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; +import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility.ClanRelation; @@ -112,17 +113,19 @@ public class ClansPlayerScoreboard extends PlayerScoreboard team.setPrefix(relation.getColor(false).toString()); } - - Objective domObjective; - if ((domObjective = scoreboard.getObjective(DisplaySlot.BELOW_NAME)) == null) + if (Clans.HARDCORE) { - domObjective = scoreboard.registerNewObjective("war", "dummy"); - domObjective.setDisplayName("War Points"); - domObjective.setDisplaySlot(DisplaySlot.BELOW_NAME); - } + Objective domObjective; + if ((domObjective = scoreboard.getObjective(DisplaySlot.BELOW_NAME)) == null) + { + domObjective = scoreboard.registerNewObjective("war", "dummy"); + domObjective.setDisplayName("War Points"); + domObjective.setDisplaySlot(DisplaySlot.BELOW_NAME); + } - if (clanInfo != null) - domObjective.getScore(otherPlayer.getName()).setScore(ownScore); + if (clanInfo != null) + domObjective.getScore(otherPlayer.getName()).setScore(ownScore); + } team.addPlayer(otherPlayer); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index 38ce9f2fc..223266074 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -13,6 +13,7 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.siege.command.GiveWeaponCommand; import mineplex.game.clans.clans.siege.outpost.OutpostManager; @@ -214,6 +215,10 @@ public class SiegeManager extends MiniPlugin @EventHandler public void onBlockPlace(BlockPlaceEvent event) { + if (!Clans.HARDCORE) + { + return; + } if (event.getItemInHand().isSimilar(Cannon.CANNON_ITEM)) { event.setCancelled(true); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java index 149498943..c962a829d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java @@ -24,6 +24,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; @@ -61,6 +62,10 @@ public class OutpostManager extends MiniPlugin @EventHandler(priority = EventPriority.LOWEST) public void onPlaceBlock(BlockPlaceEvent event) { + if (!Clans.HARDCORE) + { + return; + } if (event.getItemInHand().isSimilar(Outpost.OUTPOST_ITEM)) if (!spawnOutpost(event.getPlayer(), event.getBlock().getLocation(), OutpostType.MK_III)) event.setCancelled(true); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index 592c61a42..05011fe57 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -18,6 +18,7 @@ import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansManager; @@ -107,6 +108,10 @@ public class WarManager extends MiniPlugin implements ScoreboardElement @EventHandler public void handleDeath(final ClansPlayerDeathEvent event) { + if (!Clans.HARDCORE) + { + return; + } ClanInfo deathClan = event.getPlayer().getClan(); if (deathClan == null) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/command/WarPointsCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/command/WarPointsCommand.java index efe673ca6..e44c0f21c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/command/WarPointsCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/command/WarPointsCommand.java @@ -7,6 +7,7 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.core.war.ClanWarData; @@ -22,6 +23,11 @@ public class WarPointsCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { + if (!Clans.HARDCORE) + { + UtilPlayer.message(caller, F.main("Clans", "This is not a hardcore server!")); + return; + } ClansManager clansManager = Plugin.getClansManager(); ClanInfo clan = clansManager.getClan(caller); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/warpoints/WarPointEvasion.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/warpoints/WarPointEvasion.java index 04be2a159..409658256 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/warpoints/WarPointEvasion.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/warpoints/WarPointEvasion.java @@ -72,7 +72,7 @@ public class WarPointEvasion extends MiniPlugin { Chunk chunk = event.getClaimedChunk(); - if(_chunkCooldown.containsKey(chunk)) + if (_chunkCooldown.containsKey(chunk)) { event.setCancelled(true); event.getClaimer().sendMessage(F.main("Clans", "You cannot claim this chunk for another " + UtilTime.convertString(COOLDOWN_TIME - (System.currentTimeMillis() - _chunkCooldown.get(chunk)), 1, UtilTime.TimeUnit.MINUTES))); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpPage.java index 2e94c7554..27d119e6c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpPage.java @@ -6,6 +6,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.shop.ClansShopItem; import mineplex.game.clans.shop.ClansShopPage; @@ -60,14 +61,21 @@ public class PvpPage extends ClansShopPage addShopItem(34, ClansShopItem.ARROW, (byte) 0, "Arrows", 16); addButton(51 - 9, new ItemBuilder(Material.IRON_BARDING).setTitle(C.cGreenB + "Standard Mount").setLore(C.cRed, C.cYellow + "Left-Click" + C.cWhite + " to buy " + C.cGreen + "1", C.cWhite + "Costs " + C.cGreen + "150000g").build(), new MountBuyButton<>(this)); - addShopItem(52 - 9, ClansShopItem.CANNON, C.cBlue + "Cannon"); - addShopItem(53 - 9, ClansShopItem.OUTPOST, C.cBlue + "Outpost"); + + if (Clans.HARDCORE) + { + addShopItem(52 - 9, ClansShopItem.CANNON, C.cBlue + "Cannon"); + addShopItem(53 - 9, ClansShopItem.OUTPOST, C.cBlue + "Outpost"); + } addShopItem(51, ClansShopItem.ENCHANTMENT_TABLE, "Class Shop"); - addShopItem(52, ClansShopItem.TNT, "TNT"); - addButton(53, new ItemBuilder(ClansShopItem.TNT_GENERATOR.getMaterial()).setTitle(C.cAqua + "Manage TNT Generator").build(), (player, click) -> - new TNTGenShop(_plugin, _clientManager, _donationManager).attemptShopOpen(player) - ); + + if (Clans.HARDCORE) + { + addShopItem(52, ClansShopItem.TNT, "TNT"); + addButton(53, new ItemBuilder(ClansShopItem.TNT_GENERATOR.getMaterial()).setTitle(C.cAqua + "Manage TNT Generator").build(), (player, click) -> + new TNTGenShop(_plugin, _clientManager, _donationManager).attemptShopOpen(player) + ); + } } - -} +} \ No newline at end of file From 3b4bad7bba7950dfc51d2587f7e21a6b13d6dfb3 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 13 Jun 2017 23:16:24 -0400 Subject: [PATCH 179/283] Further change builder box UI --- .../game/clans/clans/boxes/BoxManager.java | 8 +- .../boxes/extra/BuilderBoxInventory.java | 163 ++++++++++++++++++ .../clans/boxes/extra/BuilderBoxVerifier.java | 104 ----------- 3 files changed, 167 insertions(+), 108 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxInventory.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxVerifier.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java index 54b62deac..c0019ad74 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java @@ -21,12 +21,12 @@ import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; -import mineplex.game.clans.clans.boxes.extra.BuilderBoxVerifier; +import mineplex.game.clans.clans.boxes.extra.BuilderBoxInventory; import mineplex.game.clans.clans.boxes.extra.DyeBoxSpinner; public class BoxManager extends MiniPlugin { - private BuilderBoxVerifier _builderVerifier; + private BuilderBoxInventory _builderBox; public BoxManager(JavaPlugin plugin) { @@ -34,7 +34,7 @@ public class BoxManager extends MiniPlugin final BoxShop shop = new BoxShop(this); - _builderVerifier = new BuilderBoxVerifier(this, shop); + _builderBox = new BuilderBoxInventory(); addCommand(new CommandBase(this, Rank.ALL, "boxes", "box") { @@ -169,7 +169,7 @@ public class BoxManager extends MiniPlugin public static enum BoxType { - BUILDER_BOX("Clans Builder Box", C.cGold + "Builder's Box", Material.GLOWSTONE, Managers.get(BoxManager.class)._builderVerifier::showVerifier), + BUILDER_BOX("Clans Builder Box", C.cGold + "Builder's Box", Material.GLOWSTONE, Managers.get(BoxManager.class)._builderBox::open), @SuppressWarnings("deprecation") DYE_BOX("Clans Dye Box", C.cGreen + "Dye Box", Material.INK_SACK, DyeColor.RED.getDyeData(), DyeBoxSpinner::createSpinner), ; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxInventory.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxInventory.java new file mode 100644 index 000000000..2308b65a8 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxInventory.java @@ -0,0 +1,163 @@ +package mineplex.game.clans.clans.boxes.extra; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.bukkit.Bukkit; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.boxes.BoxManager.BoxType; + +public class BuilderBoxInventory implements Listener +{ + private Map, ItemStack> _replace = new HashMap<>(); + + public BuilderBoxInventory() + { + _replace.put(Pair.create(Material.STONE, (byte)0), new ItemStack(Material.STAINED_CLAY)); + _replace.put(Pair.create(Material.GLASS, (byte)0), new ItemStack(Material.STAINED_GLASS)); + _replace.put(Pair.create(Material.THIN_GLASS, (byte)0), new ItemStack(Material.STAINED_GLASS_PANE)); + _replace.put(Pair.create(Material.WOOL, (byte)0), new ItemStack(Material.WOOL)); + _replace.put(Pair.create(Material.CARPET, (byte)0), new ItemStack(Material.CARPET)); + _replace.put(Pair.create(Material.RED_ROSE, (byte)0), new ItemStack(Material.RED_ROSE)); + _replace.put(Pair.create(Material.RED_ROSE, (byte)1), new ItemStack(Material.RED_ROSE)); + _replace.put(Pair.create(Material.RED_ROSE, (byte)2), new ItemStack(Material.RED_ROSE)); + _replace.put(Pair.create(Material.RED_ROSE, (byte)3), new ItemStack(Material.RED_ROSE)); + _replace.put(Pair.create(Material.RED_ROSE, (byte)4), new ItemStack(Material.RED_ROSE)); + _replace.put(Pair.create(Material.RED_ROSE, (byte)5), new ItemStack(Material.RED_ROSE)); + _replace.put(Pair.create(Material.RED_ROSE, (byte)6), new ItemStack(Material.RED_ROSE)); + _replace.put(Pair.create(Material.RED_ROSE, (byte)7), new ItemStack(Material.RED_ROSE)); + _replace.put(Pair.create(Material.RED_ROSE, (byte)8), new ItemStack(Material.RED_ROSE)); + _replace.put(Pair.create(Material.COBBLE_WALL, (byte)0), new ItemStack(Material.COBBLE_WALL)); + _replace.put(Pair.create(Material.JACK_O_LANTERN, (byte)0), new ItemStack(Material.GLOWSTONE)); + + UtilServer.RegisterEvents(this); + } + + @SuppressWarnings("deprecation") + private Pair convert(ItemStack old) + { + if (old == null) + { + return Pair.create(old, false); + } + Pair pair = Pair.create(old.getType(), old.getData().getData()); + if (!_replace.containsKey(pair)) + { + return Pair.create(old, false); + } + ItemBuilder after = new ItemBuilder(_replace.get(pair)); + if (after.getType() == Material.RED_ROSE) + { + after.setData((short)UtilMath.r(9)); + } + else if (after.getType() == Material.COBBLE_WALL) + { + after.setData((short)1); + } + else if (after.getType() == Material.GLOWSTONE) + { + after.setData((short)0); + } + else + { + after.setData(UtilMath.randomElement(DyeColor.values()).getWoolData()); + } + after.setAmount(old.getAmount()); + + return Pair.create(after.build(), true); + } + + @SuppressWarnings("deprecation") + public void open(Player player) + { + Inventory newInv = Bukkit.createInventory(player, 27, "Builder's Box"); + ItemStack border = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short)DyeColor.GRAY.getWoolData()).setTitle(C.cRed + " ").build(); + ItemStack button = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short)DyeColor.LIME.getWoolData()).setTitle(C.cGreenB + "Convert").build(); + for (int i = 0; i < 27; i++) + { + if (i == 22) + { + newInv.setItem(i, button); + continue; + } + if (i < 9 || i > 17) + { + newInv.setItem(i, border); + } + } + player.openInventory(newInv); + } + + @EventHandler + public void onClose(InventoryCloseEvent event) + { + InventoryView view = event.getView(); + if (view.getTopInventory() != null) + { + Inventory top = view.getTopInventory(); + if (top.getTitle().equals("Builder's Box")) + { + List items = new ArrayList<>(); + for (int i = 9; i < 18; i++) + { + items.add(top.getItem(i)); + } + if (items != null && !items.isEmpty()); + { + int totalChanged = 0; + for (Pair pair : items.stream().map(this::convert).collect(Collectors.toList())) + { + if (pair.getLeft() == null) + { + continue; + } + if (pair.getRight()) + { + totalChanged++; + } + event.getPlayer().getInventory().addItem(pair.getLeft()); + } + if (totalChanged > 0) + { + ClansManager.getInstance().getInventoryManager().addItemToInventory((Player)event.getPlayer(), BoxType.BUILDER_BOX.getItemName(), -1); + } + } + } + } + } + + @EventHandler + public void onClick(InventoryClickEvent event) + { + if (event.getClickedInventory() != null && event.getClickedInventory().getTitle().equals("Builder's Box")) + { + if (event.getSlot() < 9 || event.getSlot() > 17) + { + event.setCancelled(true); + } + if (event.getSlot() == 22) + { + event.getWhoClicked().closeInventory(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxVerifier.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxVerifier.java deleted file mode 100644 index 9bde6ee83..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxVerifier.java +++ /dev/null @@ -1,104 +0,0 @@ -package mineplex.game.clans.clans.boxes.extra; - -import java.util.HashMap; -import java.util.Map; - -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.Managers; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Pair; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.donation.DonationManager; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.shop.confirmation.ConfirmationCallback; -import mineplex.core.shop.confirmation.ConfirmationPage; -import mineplex.core.shop.confirmation.ConfirmationProcessor; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.boxes.BoxManager; -import mineplex.game.clans.clans.boxes.BoxManager.BoxType; -import mineplex.game.clans.clans.boxes.BoxShop; - -public class BuilderBoxVerifier -{ - private BoxManager _manager; - private BoxShop _shop; - - public BuilderBoxVerifier(BoxManager manager, BoxShop shop) - { - _manager = manager; - _shop = shop; - } - - public void showVerifier(Player player) - { - _shop.openPageForPlayer(player, new ConfirmationPage(player, _manager, _shop, Managers.get(CoreClientManager.class), Managers.get(DonationManager.class), new ConfirmationProcessor() - { - @Override - public void init(Inventory inventory) {} - - @SuppressWarnings("deprecation") - @Override - public void process(ConfirmationCallback callback) - { - ClansManager.getInstance().getInventoryManager().addItemToInventory(player, BoxType.BUILDER_BOX.getItemName(), -1); - - Map, ItemStack> replace = new HashMap<>(); - replace.put(Pair.create(Material.STONE, (byte)0), new ItemStack(Material.STAINED_CLAY)); - replace.put(Pair.create(Material.GLASS, (byte)0), new ItemStack(Material.STAINED_GLASS)); - replace.put(Pair.create(Material.THIN_GLASS, (byte)0), new ItemStack(Material.STAINED_GLASS_PANE)); - replace.put(Pair.create(Material.WOOL, (byte)0), new ItemStack(Material.WOOL)); - replace.put(Pair.create(Material.CARPET, (byte)0), new ItemStack(Material.CARPET)); - replace.put(Pair.create(Material.RED_ROSE, (byte)0), new ItemStack(Material.RED_ROSE)); - replace.put(Pair.create(Material.RED_ROSE, (byte)1), new ItemStack(Material.RED_ROSE)); - replace.put(Pair.create(Material.RED_ROSE, (byte)2), new ItemStack(Material.RED_ROSE)); - replace.put(Pair.create(Material.RED_ROSE, (byte)3), new ItemStack(Material.RED_ROSE)); - replace.put(Pair.create(Material.RED_ROSE, (byte)4), new ItemStack(Material.RED_ROSE)); - replace.put(Pair.create(Material.RED_ROSE, (byte)5), new ItemStack(Material.RED_ROSE)); - replace.put(Pair.create(Material.RED_ROSE, (byte)6), new ItemStack(Material.RED_ROSE)); - replace.put(Pair.create(Material.RED_ROSE, (byte)7), new ItemStack(Material.RED_ROSE)); - replace.put(Pair.create(Material.RED_ROSE, (byte)8), new ItemStack(Material.RED_ROSE)); - replace.put(Pair.create(Material.COBBLE_WALL, (byte)0), new ItemStack(Material.COBBLE_WALL)); - - for (int slot = 0; slot < player.getInventory().getSize(); slot++) - { - ItemStack item = player.getInventory().getItem(slot); - if (item == null) - { - continue; - } - Pair pair = Pair.create(item.getType(), item.getData().getData()); - if (!replace.containsKey(pair)) - { - continue; - } - ItemBuilder after = new ItemBuilder(replace.get(pair)); - if (after.getType() == Material.RED_ROSE) - { - after.setData((short)UtilMath.r(9)); - } - else if (after.getType() == Material.COBBLE_WALL) - { - after.setData((short)1); - } - else - { - after.setData(UtilMath.randomElement(DyeColor.values()).getWoolData()); - } - after.setAmount(item.getAmount()); - player.getInventory().setItem(slot, after.build()); - } - callback.resolve("You have redeemed your box!"); - - UtilPlayer.message(player, F.main("Builder's Box", "You have redeemed your box!")); - } - }, new ItemBuilder(Material.BARRIER).setTitle(C.cDRedB + "WARNING").setLore(C.cRedB + "ALL " + C.cRed + "compatible items", C.cRed + "in your inventory", C.cRed + "will be converted!").build())); - } -} \ No newline at end of file From 6ef6abcd72d9c78be9789612fa1c17bdf9601e18 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 13 Jun 2017 23:16:51 -0400 Subject: [PATCH 180/283] Initial implementation of raid legendary --- .../game/clans/items/GearManager.java | 2 ++ .../items/legendaries/DemonicScythe.java | 30 +++++++++++++++++++ .../items/legendaries/MeridianScepter.java | 27 +++++++++-------- .../game/clans/items/ui/GearPage.java | 3 +- 4 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index b25959a72..dfb7547ea 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -47,6 +47,7 @@ import mineplex.game.clans.items.commands.GearCommand; import mineplex.game.clans.items.commands.RuneCommand; import mineplex.game.clans.items.economy.GoldToken; import mineplex.game.clans.items.legendaries.AlligatorsTooth; +import mineplex.game.clans.items.legendaries.DemonicScythe; import mineplex.game.clans.items.legendaries.GiantsBroadsword; import mineplex.game.clans.items.legendaries.HyperAxe; import mineplex.game.clans.items.legendaries.LegendaryItem; @@ -204,6 +205,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable customItemType.registerSubtype(GoldToken.class); LEGENDARY_WEIGHTS.elements().forEach(customItemType::registerSubtype); RARE_WEIGHTS.elements().forEach(customItemType::registerSubtype); + customItemType.registerSubtype(DemonicScythe.class); // Build GSON instance off factories for future serialization of items. GSON = new GsonBuilder().registerTypeAdapterFactory(attributeFactory).registerTypeAdapterFactory(customItemType).create(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java new file mode 100644 index 000000000..3423234e5 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java @@ -0,0 +1,30 @@ +package mineplex.game.clans.items.legendaries; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class DemonicScythe extends LegendaryItem +{ + public DemonicScythe() + { + super("Demonic Scythe", 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", + }, Material.RECORD_8); + } + + @Override + public void onAttack(CustomDamageEvent event, Player wielder) + { + event.AddMod("Wind Blade", 8); + wielder.setHealth(Math.min(wielder.getMaxHealth(), wielder.getHealth() + 2)); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java index 26003be99..01f539904 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java @@ -1,6 +1,19 @@ package mineplex.game.clans.items.legendaries; import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -20,25 +33,13 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClansManager; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; - public class MeridianScepter extends LegendaryItem { private static final RGBData[] COLORS = { UtilColor.RgbPurple, UtilColor.RgbPurple.Lighten(), UtilColor.RgbPurple.Darken() }; private long _interactWait; - private transient HashMap _animations = new HashMap(); + private transient Map _animations = new HashMap<>(); public MeridianScepter() { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ui/GearPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ui/GearPage.java index a2cc1a83f..e1a9f6193 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ui/GearPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ui/GearPage.java @@ -43,6 +43,7 @@ import mineplex.game.clans.items.attributes.weapon.HasteAttribute; import mineplex.game.clans.items.attributes.weapon.JaggedAttribute; import mineplex.game.clans.items.attributes.weapon.SharpAttribute; import mineplex.game.clans.items.legendaries.AlligatorsTooth; +import mineplex.game.clans.items.legendaries.DemonicScythe; import mineplex.game.clans.items.legendaries.EnergyCrossbow; import mineplex.game.clans.items.legendaries.GiantsBroadsword; import mineplex.game.clans.items.legendaries.HyperAxe; @@ -105,7 +106,7 @@ public class GearPage extends ShopPageBase } }; - _legendaryItems = Arrays.> asList(MeridianScepter.class, AlligatorsTooth.class, WindBlade.class, GiantsBroadsword.class, HyperAxe.class, MagneticMaul.class); + _legendaryItems = Arrays.> asList(MeridianScepter.class, AlligatorsTooth.class, WindBlade.class, GiantsBroadsword.class, HyperAxe.class, MagneticMaul.class, DemonicScythe.class); _rareItems = Arrays.> asList(RunedPickaxe.class); From bc61bdff5e0f6cadc256565e02c531d11a05a5f6 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 13 Jun 2017 23:17:28 -0400 Subject: [PATCH 181/283] Update territory display to show raid world and prevent autoclaiming in nether or raid worlds --- .../src/mineplex/game/clans/clans/ClansDisplay.java | 10 +++++++++- .../scoreboard/elements/ScoreboardElementPlayer.java | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java index 26a95fb7f..0c5629d2d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java @@ -9,6 +9,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -20,6 +21,8 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; +import mineplex.game.clans.clans.nether.NetherManager; +import mineplex.game.clans.clans.worldevent.WorldEventManager; import mineplex.game.clans.core.repository.ClanTerritory; public class ClansDisplay extends MiniPlugin @@ -56,7 +59,7 @@ public class ClansDisplay extends MiniPlugin client.setTerritory(UtilWorld.chunkToStr(player.getLocation().getChunk())); // AutoClaim - if (client.isAutoClaim()) _clansManager.getClanAdmin().claim(player); + if (client.isAutoClaim() && !(Managers.get(NetherManager.class).isInNether(player) || Managers.get(WorldEventManager.class).getRaidManager().isInRaid(player.getLocation()))) _clansManager.getClanAdmin().claim(player); // Map String owner = "Wilderness"; @@ -127,6 +130,11 @@ public class ClansDisplay extends MiniPlugin } } + if (_clansManager.getWorldEvent().getRaidManager().isInRaid(player.getLocation())) + { + ownerString = C.cDRed + "Raid World"; + } + // if (_clansManager.getNetherManager().isInNether(player)) // { // _clansManager.message(player, "You are not allowed to claim territory in " + F.clansNether("The Nether") + "."); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index b5e11e8a1..75b8ef44d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -58,6 +58,11 @@ public class ScoreboardElementPlayer implements ScoreboardElement } } + if (_clansManager.getWorldEvent().getRaidManager().isInRaid(player.getLocation())) + { + regionString = C.cDRed + "Raid World"; + } + output.add(regionString); return output; From c533b170fe4a6e83694181d5d663d05820054aa8 Mon Sep 17 00:00:00 2001 From: cnr Date: Tue, 13 Jun 2017 23:47:30 -0500 Subject: [PATCH 182/283] Add /checkppc to CUST for detailed subscription data --- .../PowerPlayClubRepository.java | 2 - .../powerplayclub/PowerPlayClubRewards.java | 2 +- .../core/powerplayclub/PowerPlayData.java | 37 ++++-- .../customerSupport/CustomerSupport.java | 11 +- .../customerSupport/ListPPCCommand.java | 117 ++++++++++++++++++ 5 files changed, 148 insertions(+), 21 deletions(-) create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/ListPPCCommand.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java index 0e007abdb..ee0e0201a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java @@ -104,8 +104,6 @@ public class PowerPlayClubRepository implements Listener { PowerPlayData cached = getCachedData(player); - List list = PowerPlayClubRewards.rewardsForMonths(cached.getUsableCosmeticMonths()); - PowerPlayClubRewards.rewardsForMonths(cached.getUsableCosmeticMonths()).forEach(item -> item.reward(player)); // Gives Metal Man for anyone subscribed diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 0c68ff1fd..83fc019ad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -113,7 +113,7 @@ public class PowerPlayClubRewards public static List rewardsForMonths(Set months) { - return months.stream().sorted().map(rewards::get).collect(Collectors.toList()); + return months.stream().sorted().map(PowerPlayClubRewards::getReward).collect(Collectors.toList()); } public static Map rewards() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java index f478de57c..3d2524ff7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java @@ -1,12 +1,18 @@ package mineplex.core.powerplayclub; -import com.google.common.base.Objects; - import java.time.LocalDate; import java.time.YearMonth; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; +import com.google.common.base.MoreObjects; + public class PowerPlayData { /* If this is set, the player's subscription is planned to recur. @@ -19,6 +25,9 @@ public class PowerPlayData */ private final Optional _nextClaimDate; + // The source set of subscriptions from which this was built + private final List _subscriptions; + // The months where the player hasn't claimed chests/amplifiers private final Set _unclaimedMonths; @@ -29,11 +38,11 @@ public class PowerPlayData */ private final Set _cosmeticMonths; - static PowerPlayData fromSubsAndClaims(List subscriptions, List claimedMonths) + public static PowerPlayData fromSubsAndClaims(List subscriptions, List claimedMonths) { if (subscriptions.isEmpty()) { - return new PowerPlayData(Optional.empty(), new HashSet<>(), new HashSet<>()); + return new PowerPlayData(subscriptions, Optional.empty(), new HashSet<>(), new HashSet<>()); } final LocalDate today = LocalDate.now(); @@ -96,7 +105,7 @@ public class PowerPlayData .map(YearMonth::from) .collect(Collectors.toSet()); - return new PowerPlayData(nextClaimDate, unclaimedMonths, cosmeticMonths); + return new PowerPlayData(subscriptions, nextClaimDate, unclaimedMonths, cosmeticMonths); } private static List buildMonths(Subscription subscription) @@ -126,10 +135,10 @@ public class PowerPlayData } } - static class Subscription + public static class Subscription { - private final LocalDate _startDate; - private final SubscriptionDuration _duration; + public final LocalDate _startDate; + public final SubscriptionDuration _duration; Subscription(LocalDate startDate, SubscriptionDuration duration) { @@ -143,13 +152,19 @@ public class PowerPlayData MONTH, YEAR } - private PowerPlayData(Optional nextClaimDate, Set unclaimedMonths, Set cosmeticMonths) + private PowerPlayData(List subscriptions, Optional nextClaimDate, Set unclaimedMonths, Set cosmeticMonths) { + _subscriptions = subscriptions; _nextClaimDate = nextClaimDate; _unclaimedMonths = unclaimedMonths; _cosmeticMonths = cosmeticMonths; } + public List getSubscriptions() + { + return _subscriptions; + } + public Optional getNextClaimDate() { return _nextClaimDate; @@ -173,7 +188,7 @@ public class PowerPlayData @Override public String toString() { - return Objects.toStringHelper(this) + return MoreObjects.toStringHelper(this) .add("_nextClaimDate", _nextClaimDate) .add("_unclaimedMonths", _unclaimedMonths) .add("_cosmeticMonths", _cosmeticMonths) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index dceba28ab..6a1edd7a5 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -72,6 +72,10 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable _allowWeatherChange = true; Bukkit.getWorlds().get(0).setStorm(false); _allowWeatherChange = false; + + addCommand(new checkCommand(this)); + addCommand(new checkOwnsPackageCommand(this)); + addCommand(new ListPPCCommand(this, _powerPlayRepo)); } @EventHandler @@ -100,13 +104,6 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable event.setFormat(C.cGold + "%1$s " + C.cWhite + "%2$s"); } - - @Override - public void addCommands() - { - addCommand(new checkCommand(this)); - addCommand(new checkOwnsPackageCommand(this)); - } public void Help(Player caller) { diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/ListPPCCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/ListPPCCommand.java new file mode 100644 index 000000000..6d3c1243a --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/ListPPCCommand.java @@ -0,0 +1,117 @@ +package mineplex.staffServer.customerSupport; + +import java.time.YearMonth; +import java.time.format.TextStyle; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.powerplayclub.PowerPlayClubRepository; +import mineplex.core.powerplayclub.PowerPlayClubRewards; +import mineplex.core.powerplayclub.PowerPlayData; + +public class ListPPCCommand extends CommandBase +{ + private final PowerPlayClubRepository _powerPlayRepo; + + public ListPPCCommand(CustomerSupport customerSupport, PowerPlayClubRepository powerPlayRepo) + { + super(customerSupport, Rank.MODERATOR, "listppc", "checkppc"); + _powerPlayRepo = powerPlayRepo; + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /" + _aliasUsed + " ")); + return; + } + + _commandCenter.GetClientManager().checkPlayerName(caller, args[0], name -> + { + if (name != null) + { + _commandCenter.GetClientManager().loadClientByName(name, client -> + { + if (client == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not load data for " + name)); + return; + } + + PowerPlayData powerPlayData = _powerPlayRepo.loadData(client.getAccountId()).join(); + Inventory inventory = buildPPCDisplay(client.getName(), powerPlayData); + caller.openInventory(inventory); + }); + } + }); + } + + private static Inventory buildPPCDisplay(String playerName, PowerPlayData data) + { + Inventory result = Bukkit.createInventory(null, Math.max(1, (int)Math.ceil(data.getSubscriptions().size() / 9D)) * 9, playerName + "'s Subscriptions"); + data.getSubscriptions().stream().map(sub -> buildSubDisplay(data, sub)).forEach(result::addItem); + return result; + } + + private static ItemStack buildSubDisplay(PowerPlayData data, PowerPlayData.Subscription sub) + { + PowerPlayData dataForSubscription = PowerPlayData.fromSubsAndClaims(Collections.singletonList(sub), Collections.emptyList()); + dataForSubscription.getUnclaimedMonths().removeIf(yearMonth -> !data.getUnclaimedMonths().contains(yearMonth)); + + boolean claimed = dataForSubscription.getUnclaimedMonths().isEmpty(); + + List lore = new ArrayList<>(); + lore.add(C.cYellow + "Start date: " + C.cWhite + sub._startDate.getMonth().getDisplayName(TextStyle.SHORT, Locale.US) + " " + sub._startDate.getDayOfMonth() + " " + sub._startDate.getYear()); + lore.add(C.cYellow + "Duration: " + C.cWhite + sub._duration.name()); + lore.add(" "); + lore.add(C.cGreen + "Subscription Cosmetics"); + PowerPlayClubRewards.rewards().entrySet().stream() + .filter(entry -> dataForSubscription.getUsableCosmeticMonths().contains(entry.getKey())) + .sorted(Comparator.comparing(Map.Entry::getKey)) + .forEach(entry -> + { + YearMonth yearMonth = entry.getKey(); + lore.add(C.cWhite + " " + entry.getValue().getPrizeName() + " " + C.cGold + yearMonth.getMonth().getDisplayName(TextStyle.SHORT, Locale.US) + " " + yearMonth.getYear()); + }); + + lore.add(" "); + + if (claimed) + { + lore.add(C.cYellow + "All current rewards claimed"); + } + else + { + lore.add(C.cRed + "Unclaimed rewards"); + lore.add(" " + C.cWhite + (PowerPlayClubRewards.AMPLIFIERS_PER_MONTH * dataForSubscription.getUnclaimedMonths().size()) + " Game Amplifier"); + lore.add(" " + C.cWhite + (PowerPlayClubRewards.CHESTS_PER_MONTH * dataForSubscription.getUnclaimedMonths().size()) + " Omega Chest"); + } + + ItemStack stack = new ItemStack(claimed ? Material.IRON_BLOCK : Material.GOLD_BLOCK); + ItemMeta meta = stack.getItemMeta(); + + meta.setDisplayName(C.cWhite + "Subscription"); + meta.setLore(lore); + + stack.setItemMeta(meta); + return stack; + } +} From 8d1aa176d382a2babadd11597b71a765eb5eff8d Mon Sep 17 00:00:00 2001 From: cnr Date: Tue, 13 Jun 2017 23:49:14 -0500 Subject: [PATCH 183/283] Remove unused agentCacheMap in CUST --- .../customerSupport/CustomerSupport.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 6a1edd7a5..d9e82ba75 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -6,7 +6,6 @@ import java.time.LocalDate; import java.time.YearMonth; import java.time.format.TextStyle; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.UUID; @@ -54,7 +53,6 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable private CustomerSupportRepository _repository; private PowerPlayClubRepository _powerPlayRepo; - private NautHashMap> _agentCacheMap = new NautHashMap>(); private NautHashMap> _accountBonusLog = new NautHashMap<>(); private boolean _allowWeatherChange = false; @@ -110,14 +108,6 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(F.main(getName(), "Usage : /check defek7")); } - public void addAgentMapping(Player caller, CoreClient client) - { - if (!_agentCacheMap.containsKey(caller)) - _agentCacheMap.put(caller, new HashSet()); - - _agentCacheMap.get(caller).add(client.getName()); - } - public void showPlayerInfo(Player caller, CoreClient client) { String playerName = client.getName(); @@ -470,12 +460,6 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable event.setCancelled(true); } - @EventHandler - public void removeMapping(PlayerQuitEvent event) - { - _agentCacheMap.remove(event.getPlayer()); - } - @EventHandler public void foodLevelChange(FoodLevelChangeEvent event) { From 6c093cc4586c2e86416a8e9d2c3cae4827671451 Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 14 Jun 2017 17:23:20 -0500 Subject: [PATCH 184/283] Reduce beta participation rank constraint to TITAN --- Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java index ca0f67e27..f39636aa5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java @@ -55,7 +55,7 @@ public class BetaWhitelist extends MiniPlugin { Player player = event.getPlayer(); Rank rank = _clientManager.Get(player).GetRank(true); - if ((rank != Rank.MAPDEV && rank != Rank.MAPLEAD && rank.has(Rank.ETERNAL) // If this player is Eternal+ (and not a builder), + if ((rank != Rank.MAPDEV && rank != Rank.MAPPER && rank != Rank.MAPLEAD && rank.has(Rank.TITAN) // If this player is Titan+ (and not a builder), || _powerPlayClubRepository.getCachedData(player).isSubscribed()) // a PPC subscriber, || EXTRA_PLAYERS.contains(player.getUniqueId())) // or explicitly whitelisted, { From 29d5a80a67ee3c9f7eb1131624c7e821f711ffd4 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 15 Jun 2017 01:33:20 +0100 Subject: [PATCH 185/283] Final changes --- .../mineplex/core/common/skin/SkinData.java | 10 ++ .../core/achievement/AchievementCategory.java | 6 +- .../ui/page/AchievementMainPage.java | 2 +- .../game/arcade/game/games/moba/Moba.java | 80 +++++++++++ .../games/moba/boss/wither/WitherBoss.java | 8 ++ .../game/games/moba/general/BetaManager.java | 34 +++++ .../game/games/moba/gold/GoldManager.java | 2 + .../arcade/game/games/moba/kit/HeroKit.java | 32 ++++- .../arcade/game/games/moba/kit/HeroSkill.java | 56 ++------ .../game/games/moba/kit/anath/HeroAnath.java | 3 +- .../games/moba/kit/anath/SkillBurnBeam.java | 5 +- .../games/moba/kit/anath/SkillMeteor.java | 4 +- .../games/moba/kit/bardolf/HeroBardolf.java | 6 +- .../games/moba/kit/bardolf/SkillFullMoon.java | 14 +- .../moba/kit/bardolf/SkillSummonWolf.java | 6 +- .../moba/kit/bardolf/SkillWolfPounce.java | 3 +- .../game/games/moba/kit/biff/HeroBiff.java | 3 +- .../games/moba/kit/biff/SkillBiffDash.java | 6 +- .../game/games/moba/kit/biff/SkillLeash.java | 6 +- .../games/moba/kit/biff/SkillWarHorse.java | 5 +- .../game/games/moba/kit/bob/HeroBob.java | 3 +- .../games/moba/kit/bob/SkillBeatTheDevil.java | 2 +- .../games/moba/kit/bob/SkillHappyTrees.java | 2 +- .../games/moba/kit/common/SkillSword.java | 6 +- .../game/games/moba/kit/dana/HeroDana.java | 3 +- .../games/moba/kit/dana/SkillDanaDash.java | 3 +- .../games/moba/kit/dana/SkillPulseHeal.java | 5 +- .../game/games/moba/kit/dana/SkillRally.java | 5 +- .../game/games/moba/kit/devon/HeroDevon.java | 3 +- .../games/moba/kit/hattori/HeroHattori.java | 3 +- .../games/moba/kit/hattori/SkillSnowball.java | 2 +- .../game/games/moba/kit/hp/HPManager.java | 2 +- .../games/moba/kit/larissa/HeroLarissa.java | 3 +- .../games/moba/kit/larissa/SkillAOEHeal.java | 7 +- .../moba/kit/larissa/SkillAquaCannon.java | 4 +- .../moba/kit/larissa/SkillStormHeal.java | 7 +- .../moba/kit/larissa/SkillWaterDash.java | 3 +- .../games/moba/kit/rowena/HeroRowena.java | 3 +- .../moba/kit/rowena/SkillBombardment.java | 136 ++++++++---------- .../moba/kit/rowena/SkillCombatDash.java | 3 +- .../moba/kit/rowena/SkillLightArrows.java | 9 +- .../game/games/moba/minion/MinionManager.java | 5 + .../game/games/moba/minion/MinionWave.java | 19 ++- .../moba/shop/effects/MobaKillHealEffect.java | 4 +- .../moba/structure/tower/TowerManager.java | 7 +- .../arcade/game/games/moba/util/MobaUtil.java | 4 +- 46 files changed, 356 insertions(+), 188 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index 88dde15c3..f803154ce 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -69,6 +69,16 @@ public class SkinData public final static SkinData SLENDERMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTA0NzUyNzk4NTUsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9hMWNkOTI5OTFmYTRjZGQ2MGVlZDNhZTM3ZmI5NWRmZjFkNWNkOGNiZmYwYWFjMzE4MmQ0ODU2NDU5NTIzYyJ9fX0=", "OVqWFLCekyZcdGli6kPBKNh8/VYPhKZGNqlAvSOKc3RLgh4pIkI6TDPr/Y+VQdhz1wZozARFYSeoDJJJ4nZTi7gi3rVPG2rL1ZnKo7so5hdT8caEzSTRmgwPKzo03ZhEEsW9AEJo9mpiUxGSJdBlgEb9UgodpYFW1IjRC09CcBUqzRWP8QGZTSFSN5x9emQ97DyiFmt0NFWubHCKHdb7CExhchPRtbahL3hOEzPY8/Y+Irl9OZjx7jONE7O/sYItCuZoXc3FaTgCV0riiXHCgH2eA54s5TQVWumtp3FU7VIcKR6pm/o61+GusvqhNgdFNk9XSHWMUyp+HNU0R8sConZQN/eaVx9laJmUUb4zNZ7hX/hLYV+r9LFU1NXOeIZWJPShD+bYfZgEorIpD+EAL4BHht/f5e6a1IZUDBWb001PFibby2t9WWjoDVKz4McbxZ2Xui7EHKFG1K3biPibhWx6fvnOeJ2xW6UDIZcD+TCXwlW/knkFt44Xpyv3oNHk3UNkyrQgghd6qkc3gZHxP8PQCNvKIyK1I+pHR6JMZvSStp7ZQRDpvsvIUyOJvq+7Bs7lFYs8hcJHMzEB+8PYlH2k7P7iLuA6ZYFUmvOW1LLq0+hvxK96ZdNEsJdmMkVVTZBRw7vsZ4GPbkdp2cMOFH2lHcQj80xKqVbd43IqFDA="); public final static SkinData BOB_ROSS = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTU2NjEyOTc2NTcsInByb2ZpbGVJZCI6IjdkYTJhYjNhOTNjYTQ4ZWU4MzA0OGFmYzNiODBlNjhlIiwicHJvZmlsZU5hbWUiOiJHb2xkYXBmZWwiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzVhNzZhN2NlMzZlZGRiYmZhNWMzMmJhZmVhYmUyNmQ3ZWJlNWRlOTBkNzYyYzJmNWY3OTQ1ZTQ1ODUxOTU2ZDYifX19", "b7pUQSZ1UkMZJNSqdaBPGWfm+rfvFkEh58pBvYTG2RBPwVju1kKinb1LfsyYhFKlyPvL1jfqi30udmb0302QvE0SKg7p3txxULa3Hr94+eCJWFxrOxUNorRT9E+TurJxH6jimu6KW1p6goPn77/kgNaWb9xn3+E84+vH0z9ETjgc5G0aYLT+cSzThUorhvOQ7DRLfRgSWiFxfm3Er0g+waLfDEeNNAd6OJ5k3X+kgM/+V6QTIFofnZZ6NdZZInTARAVol2H0pRfQfAuVYfJyVyvA0uF+ZX+wlMuBTG1MeyWjZgI1iUKmGaQADXsAV796kT+Z+tAXpbRYYYZnxil5jx5P4druiHvaQfV2KK3lbKm2uH9M3SZr5d57C3V24BKRRWGS4C9INzgO8ORIIomes7kp0gECS4MnSMI6hcl0JsXVlaAy88BgmT/PKxM+3q4PCQE1N9fTCuhoil7vVYIU3uBXwFUE7NTAOUdBee+3TtMstIu2WP8rtEZBVpGH9CmomaLTCzPZSdXGY31goOFXSRYMNi8j4ykuBgP0qJqimipWH0rBF1bMdHqMu359h62tTLRKipHWXPxj4N8c/n1CVPYjuXH9X3f1HAU4DnET+v93Vb/uzbx8rXFrz6jLPwAjSlJ8Th3VE+4ey/ZBHWPB+SuHetN+e0r/LYxiqwwlnwI="); + public static final SkinData HATTORI = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjEyMTczMDgsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS83MjczMTBiMzlhMTIzOWI3ZTI4Y2JjNTkzMWY1MzlkNGVlNmQxOTc3ODhjNWI1YTY3YWY1NDJlYzk0MmZkMyJ9fX0=", "aHfFqPOZmcQkUqFPjVa27h27k5gyvkZMCOyIaIdIZfqVDg/69/hakkDQazvKg/U8KTlYaDSRyOp9ZD5qOUSCPvRtRDMhuX/Tn68KD9BdW5jYKsXo0puOa7IJDKAE47z7YQ8AvfOtxuOAg6S0ihjYEQqRA56UQ+gPbkd+pxpMxvXoLyAx7IEIKWmlkibG/rmaX8J7OEgq8Wi9s6BhtPVNMaLoznzdzOiiYkcza/zEG5zMXnj/hFHHUpWrYff0Oj7/SUB+krLsiMficASzzs/9HZq81V0ketqUhJYX66HL8F5fQniP8kYu9LbNNcVJmtlER03QaEqP/H8udemlVskFkOYLkTmhxfSetL46N+ZVf0Sxp2xYcFOH3djH/Q26IIXtzEqVyUW5Gun/ZJp8B8zYMOXbXSmaALAYPoX9cs91ZilNX/W7zn7b5Kb9kUBGt58eUpKoXjgK7rSvmH0X2JOZGFVji5QKzp/eOQAqMhkBOU8sEm9AT6mfZjjlyIDOZxSX6hjEJXRVVzFFlzTiRPTcAtaHWRnlRFywsDDSgVBGvQMPNMNa6CFeo0ajnhmfHWa4Ga77kpfQ75PzOoJ/j6Z/2sSIHfQFWE6INAGAyypX/x0Fd/AH6SmYfilnX6lhtd7OsDlxS01QGoRLPBh/ol+wY6rHSM1N6Qta0ulpQZLYIms="); + public static final SkinData ANATH = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0Njg4NjM4MTYsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS81NGI5NGQ4NzE5ZWFhYjc0YjVhMzhjN2Q5NDliM2FkMmIyYzA0ODIxZGY4OWM1ZDA0YjY5ZjNjZmExYmJhNjUifX19", "IKlnXzQ2k57XyTHge5V2ttnV1AqbRKrV0JktZS4+nLXx+ROM77/HRuf3/bYTqg48SB8npXy+c6nLYTCY1fTZOl3t2puS6BpZMBXuTV//A0OMQ1pJKzDb8vW6CwPYw2Nu6o0QX3J/FeUIaBj16GZAPxXOtSekkeOw9qsdh57GyqSmzODlEA/7CnJWqX2Ani5DACzo6j5rzfsz2qRgOzVlnbVlVzpXicRuYYLxKvT4nMS+B3HpQdsyFKAx8nTO/GmCHDzW97jck6w/VDlW9x+J39tPDEaKPLbDz1YV59yJt6hjNAcnwgbf3KvHSAbGZNLqRegq/Rk20ZI2J5GYT5ipiyf+p8rHfkRTxIsVCMyVecnSKaz59YQ7AleiWVGzYHDETU702UyigAZFHGHQ/0Kj9UyyZ4ew228FQuGo7iGY4dS/PKq40d1v3fq+czwBhcXR+Msi1Zqg/4dTh+QwwwWsIS3CKtOInpJgZ3U/tkn4STB3o+oKBbmBWvpJk8SrA6DVKKJMjHQig+67hXKSbdcRUWAoGc/iuRhRXgILkC99Ot4PHohEbwbEW8MsKxm49OFqzP4zptaUaiQpMK4YCxENhLrI7X+w51tt2XTjroIHu4oLYS4pG16ZnhUmd/RFg8Ar7mBVOv/2lUtOO5aMAv88CpyD+XXNcCQB4G5pv4c0F14="); + public static final SkinData DEVON = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0Njk0NDE1MDYsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS85N2FkNjY1MjFmNzNjOWFmYzE4MzliZGExYzE5ZDNkMjg3YjNmMjRmY2EwZTBlMTE1NzhiOTE0ZTNiNWIwZDIifX19", "BNIc7N3SGIXOEUKFe3hrQp4YmniPxkiL5aKAUNkTmYqbygAQlrCCrwJTuK6JrzkWmD5AzMSzMDKkmoMWOikgulhSmDyC88lQz/LQH3co7WldPHaPL6kk27ZirmIIZEm5WKcvWhQ7ChNWQd2KsZuFqxZSdLSQmsbujF9vpuVbhlU4hajsUwbdiOJRZ18fOAFoJYq/g3RlvqC9VtAA/IAAN7jIpXf9Pn5+vjLqN+AdKm27YknCpqMtBfkYaIhMrpTBe2gP+o50TmH0xm0IZPCS+ORYNGwFdCsg6DzEU7a0rtcUdcZgdInc09mS8tMY9eeMAISYYq5MpyliHQ/areGKk0RJEYg7muc9r/N6vBUpxZtZH8BioDj2dNj4JOoH/58cwU3+hv/Woykc9o5NUPyz0nndiOtTUp1SaDXleKyHryoYnIkPyaDPyuA7qTbIKZQHxyAdrRsnknb0PYku6T8RA4kWNK2jlOH+R9D4eiKFcbLRU2Zl6L57lJTZFFI6GUvzDsyD/vBb59gjvXYzRmvguX9CHUc1aLDeUKhV8NFXeaonoYM9VPIUBQRWNdMery9OlBiQvg4VXy1w2yKLvlHRhJZJpDm/IDdsfg27o8+BUOZ0xHF9iXPBDkOiLXXZ02X4IonLcopVNImCMRZJ1dKHwgu9qnFqVTEKH4mwXUz2Zq8="); + public static final SkinData DANA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjkyMzgxMDAsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9hOWRhYTg5OGVkN2E0N2YyOGFkMjVmNjk5Y2Y4MzQyODFmMTVkZTY5OWM1MWVhMTRkOWRlYzVhM2VlNzY1MiJ9fX0=", "KUI3h0MDUNWQ3avjozkw0KnZf1UAMkRHzRKY9yGS/iUh9EMmDbfLcRfBhUvR5Dd6//75Yw2tElBrvPx+VqfJk0LqMACQc71n0lDY1NzqnXbpf6vNGyuhyumjhMSjJTG3BJ8Qtdd1yCsPK2x5ym+cGPS1FevJj4Vcu6rxg9HXZokgfjD11NXEwulFuPIiWHpJlnd8NlBw4a3txlrVwDnaHo7GqYSJeM1uOCrdICdpThSA2N2mOUEmOHvH9rHUhQvkKHipbsQMIxIX4oiXDWeK6P/GtT+Iv0DIeJfQdDkhDiIG5/zUyxmpC2mma1FQIsFsQOaJfgYZLfcOXGdhwlL/OcZ9ULBIKhgSx7Ozwzsc+JKonqlaBOuaietq5z/XvMClgFG9U2a1LXc5BIgaN/ClsO0uTksuoA8H0SDx9k3EmOjaPdrJOsQ/fgWQSkWN2XniLLFiEtSOEOI58vw6ORVXDgjbP+TqD0b6/d10z0jUzS2FD7AO51LHzTw+BjqoyVef4fszNNSqMi5QEgfBl++EAolZBAMHgN7hq6k52ry2LPlO5L8sm6NoZ4DrLyrx1oFNtXZZgYvNVy7rtEpIDdQczwAZkJFV0fuz8tRH3CkW/roA5HbfX3Fv19mQoteoemrSUrOwLlQsyVPxsFsn8uX94Cw88Q5KgBCGmGY2vpXHuiI="); + public static final SkinData BARDOLF = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjkxMTE4NjEsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84MjUxNjZmNzc0ZjcyNmZmMDE3NTQ3OTk0NDc0MGYxNjRmMTZmYmI2M2I3NGI3NmNmNzk0NDMxZGZkNzUyIn19fQ==", "W8TO4M/IQ4rQ91627EaudboKwR8TuKTp5mAYOCyOJLCD0vyyEJmnZFy1Hv9HlXKiXsEm9iC36+cmQ8JfSE0JlIfU2vRH5qbXUL4HUHZi20SHVA5YKM2ztxI9uouc14ctv8pxlhT/huKxYNgB/eJR+ckT1gyc78RBoJj5YLwUTsptO87KE/vFg9hbHVo5lVSdk//jhfDsMRyf0RXp/wKZ1KGxaRA5hWQUc86mLJTiQU1EBVh3Lfb2zUq2w/gpLCoxdwiX8KnNuX1a1iC8pFCZm4VJ20yvNPaIgzFYDFfNQO6Vwv9fcLsdxVH819cEkjxg5do9MpZBj1OVmaWnTmQ4w4r3iKFzL6LMae4eOEyA/vJ8e7mbWUNrxM3+EPUPlxpG/NKr2VsR2ihIIF9GTduBZa2ayj7BJAkL9UK5PEGh/UxG6jf0YS7RjQ9ROaRgmTLMFsOVnQlFlp2UFRTe+heh/woD8/QSpd9MELdWFzeKRAlo7+hvo5AfWyjBI/3e9PIJfCXp+nF3Z92HKoR5V0m9QoYu2WGzbkhU49DJF7n+Bnd3ur0qefHFVl3USdVU2DJLcdcKU+Qn5G6E8NSy/3TVkjDg6u/o38b203b0tUBZNftAYYmCCpx/HVMEoNC03orIBPrwGYD6g//RC1TZ2ZxkLDU4QxeaM6neWq1xryXbvS4="); + public static final SkinData BARDOLF_WEREWOLF = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjkxODMxOTAsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9kNzc0ZGY3OWU1OGFiNDQ5OGQ2YzY3ZTdlMjY2NWFjZmE2OTViOWNjOWNkZTE1MmQ3ZTVlM2NjMTUyNzM5In19fQ==", "nqc7IdRVa2RF2SZXRli/HVhw7q5NfY7rnZFWbDyzjQ90Y/H6NWhb+9gwDDdnh7B1WolyptyUnukzTOQmrAcSecVO5vblhCTYY8PEOfcwUKznjpCmL/BgXdzBoYJHs43HFbtvzt3yhshcQ8Wvh7mtdmNu0MEYKbIX7lTqcfSoUbDk+A1PZDINuOF5RM8disGCrkq6WTdLij+k7pd3e7MJhtf8vJbtSoo5TjfzyzJyFvEvZqa+3lxobbPA9Z4cels0DVWVU8I/FEJhB29aSVXDVAZps3vWUr1sLMM9+PRaZdxHPZfNHx6q9R3oHXgjAlqzJwkljtJGExyOV+vOHEUuxrytdwMcW0XGjalukHVJ1A9DCgNMZqAXEbfYKk+BsN2BzOwT/+dtGfsOU+Rq7Kzp1/iit9saQy1QEG8Bynj6A2Vmg9XZsvbYsXZXsE+qNG6TOADEV0yrS9icEhLhOnO0re/+wE4Zsd5WDF51e87+ugvoH3iM4zrzvaWQb6McgxD/wlYlJyVHD+2f5VYCIw2yacNXp6LaZuXpfQyyDCqpHAosTYNLxWwjinl05C/TprQw+sZoLHFCGbVFQjTPEkDhQzG73PHecnO5Px3USBVleDoTb1kZfq6J2wJ1B1/7MTBW21Din3j2DmmuAVUNJYe6kifaNOhY1ghG2WVRNdIf1b4="); + public static final SkinData LARISSA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjE0MTUxMzQsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jYThjNDRhOWVmZTY3NzExMDYzMjM5ODEwNDRmOTdjYmM1OWJmZmRlOGI1ODdlMGQzMWE4N2ViMDhhMmExZiJ9fX0=", "Lyac51CrnMK/CI2dWgGQLowAm/ZnQMpf0Ict/gqVrUgJVlGWDIVG77Rd1JyMQDEeESvTmoyivH+usiO0ePW95qjisqT3R43YEmLi85CqctGYqLKeSYpGYwYRz8Euw57LwJAALKOMLhVc2s4h2Or9nTecunG8KSmkCuZc4H1qh3frU+ltuV4HLqgdFUULbIHTggyvqiINov2tBqkkXeEjT7sOcTJCJNgNYU2O7//qg5kJmhso2CKHlRLpmy9LsaUK/Z+BzUmoRbwQgSwr3mz7dFAdlVWWKvKNcgX3nt1et0DIig3JKYmrnQX2Fprg+kWcr3nuizzLgjVwAlADC48P3DN0s/VBty2AYoWie16VNPIM+CV4BF2JRQ34GxZ8XceXbCKURrOjoCBgLGHvIhRW35eicoh26xp3/mwLvk5anPi5StJ/qEuzWJALeWcNbLsnt21m2MZp9h/MxaY6ftWOTzjTr5CYVd/teJyscMnGK4+lcV1dlt12lhbDMv6I+iz8iG9NIzuW5OvGkax90dA/Gq+Cd9FXVThPY4ufxWttHcTqgPB64GfMn6rywRm1B0eO1pJpYc/KlJZlW/PuaO8L1assyJs5KkOypBSy3zc6TO6pzgeOZv+VpQfA/UWpogv6ofmTpgdtwpjLFGSzIKTDXvF6FftALKVlYypG0fYbssA="); + public static final SkinData ROWENA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0Njk1MTcxOTgsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jNDY1OGExODY4YzNhNjhhZWVhZmZkOTUxZDQyYmZkN2QxYTRjNGZjNDJjZDI2YTlmYzhkNTNmOTkxMTM1ZCJ9fX0=", "OqXMyH9SMmQ/Pwmb21In29YnCxbsN6yqUxfudN6KNgDwRUK6y072XhW6TIoTh9JQLAUKftpeVB53tk0LxHIxnsuBMrIHvETPDQFysIc/6xq3ABogs+zqFzcp5jk6S73HiD78JxLq5pzfUzhgDPMPuZP5Q/u2q1rYbe6B9lVEJ5sUcxBLUTossgucoR4qXYAlWVQdHRhq85Ol8a+OU7ruw3HackNGto6wt6u2MigCtiHVTt9XhJ/AJE4ScodQ3XwW4L6urpl/lV2OMCsr3mCjjjEz2EMhDbCWxrAorQ9aPpMbDkHBS+4TC1tbMGUlKhj5n+EZBYVaeLr4NGPACPSdT35p/2Zra49+DXn9Xn+681yNEB0ghTdsnsgwXg76+HVPHPqRHQMuTBQGQyGZaaTX/zE0tFjH+osMElLdb8dmz3dC7kQA4A13B2phj3YbMSF1FoU4GvnPKIQn6JIuEd6hd+pRLUW7Y+mgYIHHX1FT0ihrXAyVO6lQQ6rs92gSQr7sxC7tnhPSMFcmh7OcJYcbRpn97GMubthPLanOhVy7CKqjmwIkEVtYgP28idigKwNJ+sJuUONrOu7nMKl1UTD5EEapOacc/np6UhdSw8yW+LnWD/x9ueYz9ksnyRrJgcOa41izo/WCbjPK/j3JVezr9Q3x1yveWuFmdl7CGYdXngw="); + public static final SkinData BIFF = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjEzMDQzNjYsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9mOWMyMTE3ZDY0ZWE0ZmUxMWZiY2NhZmE2YzU5YzhlZjY3NDVkZjVkMTZjM2QwMmI4NmI2OTlmZWJjNTA0OGI1In19fQ==", "mJMpEvQ4A02z0S/chgLm5bKrrrd+zmp7A0012AB7b3KlyIHoLKEDDz+ZJgJtvN6skOqed3P+yNVqkxitugXaZZP8Af9J+/TseHn+vOy6CTK5tykRSY3Zb8Zmw1kn36v/SARAVtDIHD53yuPgJayYSAbVB7aknj1Q8XBQGUmZRMRxWWxeD7rQTOwgRYI4YJeKFf4UL9i6zxvOJuHsOAouJ7scu7VohG8vgR77Js/Z8rSu8/aSG+O9AQdzP6h9ixYNFkkQOHm7DseK/5tsWKHM4FYBgjIDKt3ApQokSbhThzGB55BA1qjXZkfCoOb13y1nOMC8WoIL6Ees1qzxG3VloGx2WAZLh+Q+/irwrFDMxk1zeU5fIRuj1c/UIM2HKdxxWgoRdrZ8ww/Jrll6maiOBx7geMn/0aOUbJ2U7gkTif6RG6YNS5YN9ZQDLh72l/akJMxF3SlmuAPmLs2kBghQ6eD2YQKuxWR/Hf1yS1YXtogFVNsGnzC1nda7F48EGL3zI+kCajbDlAGQ32aRt0btbEQ+Gj575kir3Aa53qiZ0YOIYQlhgZdOsTN2NE2s8uuy/15Rgc6K3ydgEmSZfdqyMyW0Dy7pE5TfVL8DumKRVRXdOceT5WfnW7MyqSmdorP5ab1fw2wLOnAVzhJmW8oXXNSs77WJ1/PURclxOWB4IF8="); + // Comments this out for now, so it doesn't load the player profile // A better way to do this would check for the properties when getting the skull or the skin // Might change on the next version diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index f0273f3e1..123e9db4d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -217,7 +217,11 @@ public enum AchievementCategory GEM_HUNTERS("Gem Hunters", null, new StatDisplay[] {StatDisplay.KILLS, StatDisplay.GEMS_EARNED, StatDisplay.fromGame("Quests Completed", GameDisplay.GemHunters, "QuestsCompleted"), StatDisplay.fromGame("Chests Opened", GameDisplay.GemHunters, "ChestsOpened")}, - Material.EMERALD, 0, GameCategory.SURVIVAL, null, false, GameDisplay.GemHunters.getGameId()); + Material.EMERALD, 0, GameCategory.SURVIVAL, null, false, GameDisplay.GemHunters.getGameId()), + + MOBA("Heroes Of Gwen", null, + new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, StatDisplay.fromGame("Gold Earned", GameDisplay.MOBA, "GoldEarned")}, + Material.PRISMARINE_SHARD, 0, GameCategory.CLASSICS, null, false, GameDisplay.MOBA.getGameId()); private String _name; private String[] _statsToPull; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java index 0ff566c82..bab3f5efd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java @@ -51,7 +51,7 @@ public class AchievementMainPage extends ShopPageBase pageLayout = new ItemLayout( - "XXOXOXOXO", + "OXOXOXOXO", "OXOXOXOXO", "OXOXOXOXO", "OXOXOXOXO", diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index f6992f67a..277fbd021 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,11 +1,17 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.Managers; +import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.leaderboard.Leaderboard; +import mineplex.core.leaderboard.LeaderboardManager; +import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; import mineplex.minecraft.game.core.combat.DeathMessageType; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -19,6 +25,7 @@ import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.buff.BuffManager; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.general.ArrowKBManager; +import nautilus.game.arcade.game.games.moba.general.BetaManager; import nautilus.game.arcade.game.games.moba.general.EnderPearlManager; import nautilus.game.arcade.game.games.moba.general.MobaDamageManager; import nautilus.game.arcade.game.games.moba.gold.GoldManager; @@ -45,7 +52,9 @@ import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; import nautilus.game.arcade.scoreboard.GameScoreboard; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; @@ -151,6 +160,9 @@ public class Moba extends TeamGame // Buffs _buffs = registerManager(new BuffManager()); + // Beta Message + registerManager(new BetaManager(this)); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -268,6 +280,44 @@ public class Moba extends TeamGame } SpectatorSpawn = WorldData.GetCustomLocs("CENTER").get(0); + + // Leaderboards + if (Manager.IsRewardStats()) + { + if (Manager.GetLobby() instanceof NewGameLobbyManager) + { + Map> lobbyCustomLocs = ((NewGameLobbyManager) Manager.GetLobby()).getCustomLocs(); + LeaderboardManager leaderboard = Managers.get(LeaderboardManager.class); + Pair winPair = Pair.create("Win", "Wins"); + Pair killPair = Pair.create("Kill", "Kills"); + Pair goldPair = Pair.create("Gold", "Gold"); + + { + Location location = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_DAILY_WINS", new Leaderboard("Top Daily Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.DAILY, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_DAILY_KILLS", new Leaderboard("Top Daily Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.DAILY, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_DAILY_GOLD").get(0); + leaderboard.registerLeaderboard("TOP_HOG_DAILY_GOLD", new Leaderboard("Top Daily Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.DAILY, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_WINS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_WINS", new Leaderboard("Top Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.ALL, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_KILLS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_KILLS", new Leaderboard("Top Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.ALL, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_GOLD").get(0); + leaderboard.registerLeaderboard("TOP_HOG_GOLD", new Leaderboard("Top Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.ALL, location, 10)); + } + } + } } private void writePrepare(Player player, GameScoreboard scoreboard) @@ -442,11 +492,21 @@ public class Moba extends TeamGame // Get the other team for (GameTeam otherTeam : GetTeamList()) { + for (Player player : otherTeam.GetPlayers(true)) + { + AddGems(player, 10, "Participation", true, true); + } + if (team.equals(otherTeam)) { continue; } + for (Player player : otherTeam.GetPlayers(true)) + { + AddGems(player, 20, "Winning", true, true); + } + AnnounceEnd(otherTeam); SetState(GameState.End); } @@ -505,6 +565,26 @@ public class Moba extends TeamGame } } + // Undisguise everyone upon game end + @EventHandler + public void end(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + { + return; + } + + for (Player player : Bukkit.getOnlinePlayers()) + { + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + + if (disguise != null) + { + Manager.GetDisguise().undisguise(disguise); + } + } + } + public Map getLocationStartsWith(String s) { Map map = new HashMap<>(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index c9483bbe1..edf900681 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -128,6 +128,14 @@ public class WitherBoss extends MobaBoss // If not damageable if (!_damageable) { + Player damager = event.GetDamagerPlayer(true); + + if (damager != null) + { + damager.sendMessage(F.main("Game", "You must destroy both towers before attacking the Wither!")); + damager.playSound(damager.getLocation(), Sound.NOTE_BASS, 1, 0.8F); + } + return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java new file mode 100644 index 000000000..f8f08448a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.game.games.moba.general; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class BetaManager implements Listener +{ + + private static final String MESSAGE = F.main("Game", "You can suggest improvements for the game on our Trello here ") + C.cYellow + "https://trello.com/b/MrxWVhlI/mineplex-heroes-of-gwen-feedback-update"; + private final Moba _host; + + public BetaManager(Moba host) + { + _host = host; + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.MIN_02 || _host.GetState() != GameState.Recruit) + { + return; + } + + Bukkit.broadcastMessage(MESSAGE); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index c55cf84a5..afdd3582d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -157,9 +157,11 @@ public class GoldManager implements Listener public void addGold(Player player, int amount, String reason) { _playerGold.put(player, _playerGold.get(player) + amount); + _host.getArcadeManager().GetStatsManager().incrementStat(player, _host.GetName() + ".GoldEarned", amount); if (amount > 20 && reason != null) { + _host.AddGems(player, (double) amount / 2D, reason, true, true); player.sendMessage(F.main("Game", C.cGold + "+" + amount + " gold (" + reason + ")" + C.cGray + ".")); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index efd7abfe5..1fc1d18d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -1,15 +1,19 @@ package nautilus.game.arcade.game.games.moba.kit; +import com.mojang.authlib.GameProfile; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaRole; @@ -35,6 +39,7 @@ public class HeroKit extends Kit private ItemStack _ammo; private long _giveTime; private int _maxAmmo; + private SkinData _skin; private static final int RECALL_SLOT = 8; private static final ItemStack RECALL_ITEM = new ItemBuilder(Material.BED) @@ -48,12 +53,13 @@ public class HeroKit extends Kit private boolean _visible = true; - public HeroKit(ArcadeManager manager, String name, Perk[] kitPerks, MobaRole role) + public HeroKit(ArcadeManager manager, String name, Perk[] kitPerks, MobaRole role, SkinData skin) { super(manager, name, KitAvailability.Free, new String[0], kitPerks, null, null); _role = role; _maxAmmo = 64; + _skin = skin; } public MobaRole getRole() @@ -231,6 +237,30 @@ public class HeroKit extends Kit } } + @Override + public void GiveItemsCall(Player player) + { + super.GiveItemsCall(player); + + disguise(player); + } + + public void disguise(Player player) + { + disguise(player, _skin); + } + + public void disguise(Player player, SkinData skin) + { + GameProfile profile = UtilGameProfile.getGameProfile(player); + profile.getProperties().clear(); + profile.getProperties().put("textures", skin.getProperty()); + DisguisePlayer disguise = new DisguisePlayer(player, profile); + disguise.showInTabList(true, 0); + + Manager.GetDisguise().disguise(disguise); + } + public boolean isVisible() { return _visible; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index df6e2e3e2..59cdd544a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -31,16 +31,14 @@ import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; public class HeroSkill extends Perk { - protected List _items; + private ItemStack _item; private ItemStack _cooldownItem; private final int _slot; private final ActionType _actionType; @@ -61,8 +59,7 @@ public class HeroSkill extends Perk { super(name, perkDesc); - _items = new ArrayList<>(2); - _items.add(itemStack); + _item = itemStack; _slot = slot; _actionType = actionType; } @@ -109,18 +106,12 @@ public class HeroSkill extends Perk action += "/Drop Item"; } - List items = new ArrayList<>(2); + _item = new ItemBuilder(_item) + .setTitle((action != null ? C.cYellowB + action + C.cGray + " - " : "") + C.cGreenB + GetName()) + .addLore(GetDesc()) + .setUnbreakable(true) + .build(); - for (ItemStack itemStack : _items) - { - items.add(new ItemBuilder(itemStack) - .setTitle((action != null ? C.cYellowB + action + C.cGray + " - " : "") + C.cGreenB + GetName()) - .addLore(GetDesc()) - .setUnbreakable(true) - .build()); - } - - _items = items; _cooldownItem = new ItemBuilder(Material.INK_SACK, (byte) 8) .setTitle(C.cRed + GetName()) .addLore(GetDesc()) @@ -128,12 +119,6 @@ public class HeroSkill extends Perk .build(); } - protected void addSkillItem(ItemStack itemStack) - { - _items.add(itemStack); - prettifyItems(); - } - @Override public void SetHost(Kit kit) { @@ -199,15 +184,8 @@ public class HeroSkill extends Perk return false; } - for (ItemStack correctItem : _items) - { - if (itemStack.isSimilar(correctItem)) - { - return true; - } - } + return itemStack.isSimilar(_item); - return false; } protected boolean isSkillSneak(PlayerToggleSneakEvent event) @@ -225,15 +203,8 @@ public class HeroSkill extends Perk return false; } - for (ItemStack correctItem : _items) - { - if (itemStack.isSimilar(correctItem)) - { - return true; - } - } + return itemStack.isSimilar(_item); - return false; } @EventHandler @@ -282,7 +253,7 @@ public class HeroSkill extends Perk @EventHandler public void updateCooldowns(UpdateEvent event) { - if (event.getType() != UpdateType.FASTEST || _items == null) + if (event.getType() != UpdateType.FASTEST || _item == null) { return; } @@ -341,12 +312,7 @@ public class HeroSkill extends Perk public void giveItem(Player player) { - if (_items.isEmpty()) - { - return; - } - - player.getInventory().setItem(_slot, _items.get(0)); + player.getInventory().setItem(_slot, _item); } public void useActiveSkill(Player player, long time) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java index 59e33556d..6023bd3ed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.anath; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; @@ -25,7 +26,7 @@ public class HeroAnath extends HeroKit public HeroAnath(ArcadeManager manager) { - super(manager, "Anath", PERKS, MobaRole.MAGE); + super(manager, "Anath", PERKS, MobaRole.MAGE, SkinData.ANATH); setAmmo(AMMO, 1000); setMaxAmmo(4); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java index 2349123f2..7938148b3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java @@ -25,8 +25,9 @@ public class SkillBurnBeam extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Fires a single, vertical beam of Flames which move forward in a straight.", + "It passes through enemies and structures dealing damage", + "to anything it passes through." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FIREBALL); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index 9d7421a1b..dc255d790 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -39,7 +39,9 @@ public class SkillMeteor extends HeroSkill implements IThrown { private static final String[] DESCRIPTION = { - "It doesn't blow up the map :)", + "Shoot out a Block of Netherrack which is placed where it lands.", + "Meteors rain from the sky around the block.", + "Enemies within the area are damaged.", }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java index b356195c6..d28975e95 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.bardolf; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -34,6 +35,7 @@ import java.util.Map; public class HeroBardolf extends HeroKit { + private static final int MIN_DIST_SQUARED = 2; private static final int MAX_DIST_SQUARED = 100; private final List _data; @@ -47,7 +49,7 @@ public class HeroBardolf extends HeroKit public HeroBardolf(ArcadeManager manager) { - super(manager, "Bardolf", PERKS, MobaRole.ASSASSIN); + super(manager, "Bardolf", PERKS, MobaRole.ASSASSIN, SkinData.BARDOLF); _data = new ArrayList<>(2); } @@ -101,7 +103,7 @@ public class HeroBardolf extends HeroKit { wolf.teleport(data.getOwner()); } - else if (ownerOffset > 4) + else if (ownerOffset > MIN_DIST_SQUARED) { UtilEnt.CreatureMoveFast(wolf, data.getOwner().getLocation(), data.isUltimate() ? 2F : 1.5F); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java index 6bfa262bc..c68fab17d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.bardolf; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; @@ -21,8 +22,11 @@ public class SkillFullMoon extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Turns the character into a Werewolf.", + "He gains +1 attack Damage and +5% Movement speed for each Wolf alive in his pack.", + "The Wolves gain movement speed to catch up and are healed to their full HP.", + "As wolves die his power decreases.", + "All Wolves in the pack die after the ultimate ends" }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); private static final long DURATION = TimeUnit.SECONDS.toMillis(10); @@ -49,15 +53,18 @@ public class SkillFullMoon extends HeroSkill return; } - WolfData data = ((HeroBardolf) Kit).getWolfData(player); + HeroBardolf kit = (HeroBardolf) Kit; + WolfData data = kit.getWolfData(player); if (data == null) { return; } + _active.add(player); Manager.GetGame().WorldTimeSet = 18000; player.getWorld().strikeLightningEffect(player.getLocation()); + kit.disguise(player, SkinData.BARDOLF_WEREWOLF); data.setUltimate(true); float speedIncrease = (float) data.getWolves().size() * SPEED_FACTOR; @@ -79,6 +86,7 @@ public class SkillFullMoon extends HeroSkill _active.remove(player); Manager.GetGame().WorldTimeSet = 12000; data.setUltimate(false); + kit.disguise(player); player.setWalkSpeed(player.getWalkSpeed() - data.getLastSpeedIncrease()); for (Wolf wolf : data.getWolves()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java index 4fa75b94f..d0e43367b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java @@ -25,8 +25,10 @@ public class SkillSummonWolf extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Click to summon a Wolf to your pack.", + "Wolves are tamed and will attack your target or people who damage you.", + "Wolves are weak and can be killed.", + "Maximum of 5." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.BONE); private static final int MAX_WOLVES = 5; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java index 20e1444dc..e69fdc4c0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java @@ -34,7 +34,8 @@ public class SkillWolfPounce extends HeroSkill { private static final String[] DESCRIPTION = { - "Dash along the ground, leaving fire behind you.", + "Dash into the air", + "Your wolves will follow you." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); private static final int COOLDOWN = 7000; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java index 78314c186..3ea9175bc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.biff; +import mineplex.core.common.skin.SkinData; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; @@ -18,6 +19,6 @@ public class HeroBiff extends HeroKit public HeroBiff(ArcadeManager manager) { - super(manager, "Biff", PERKS, MobaRole.WARRIOR); + super(manager, "Biff", PERKS, MobaRole.WARRIOR, SkinData.BIFF); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java index 6fa9c4ac4..8db6b27f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java @@ -1,7 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.biff; import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; @@ -13,7 +12,6 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Effect; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; @@ -36,7 +34,9 @@ public class SkillBiffDash extends HeroSkill { private static final String[] DESCRIPTION = { - "Dash along the ground, leaving fire behind you.", + "Dash into the air.", + "When you land any enemies near you are damaged", + "and thrown up into the air." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java index 5c9e28f4d..dcbb2ff1d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.moba.kit.biff; -import mineplex.core.common.events.EntityVelocityChangeEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilEvent.ActionType; @@ -29,8 +28,9 @@ public class SkillLeash extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Enemy heroes near to Biff are hooked with a leash to you.", + "Leashed players are slowed and it breaks if the leashed player moves", + "too far away." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.LEASH); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index 1564ed858..9a45a201d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -34,8 +34,9 @@ public class SkillWarHorse extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Mounts you on a horse.", + "Any nearby enemy heroes are rooted and will be", + "unable to move." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java index 8c851c98b..06ad4b260 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.bob; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; @@ -25,7 +26,7 @@ public class HeroBob extends HeroKit public HeroBob(ArcadeManager manager) { - super(manager, "Bob Ross", PERKS, MobaRole.MAGE); + super(manager, "Bob Ross", PERKS, MobaRole.MAGE, SkinData.BOB_ROSS); setAmmo(AMMO, 500); setMaxAmmo(8); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java index 596b43a76..55cc18082 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java @@ -18,7 +18,7 @@ public class SkillBeatTheDevil extends DashSkill { private static final String[] DESCRIPTION = { - "Dash along the ground, leaving fire behind you.", + "Bob Ross" }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java index f5e0fbc4b..9590d39f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java @@ -153,7 +153,7 @@ public class SkillHappyTrees extends HeroSkill continue; } - MobaUtil.heal(entity, 2); + MobaUtil.heal(entity, owner, 2); MobaParticles.healing(entity, 1); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java index 8b892c4eb..c7834d07d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java @@ -16,10 +16,6 @@ import java.util.List; public class SkillSword extends HeroSkill { - private static final String[] DESCRIPTION = { - "Please work" - }; - private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.WOOD_SWORD) .setTitle(C.cGreenB + "Sword") .setUnbreakable(true) @@ -27,7 +23,7 @@ public class SkillSword extends HeroSkill public SkillSword(int slot) { - super("Sword", DESCRIPTION, SKILL_ITEM, slot, null); + super("Sword", new String[0], SKILL_ITEM, slot, null); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java index e6e0f1e8b..f305be717 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.dana; +import mineplex.core.common.skin.SkinData; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; @@ -18,6 +19,6 @@ public class HeroDana extends HeroKit public HeroDana(ArcadeManager manager) { - super(manager, "Dana", PERKS, MobaRole.WARRIOR); + super(manager, "Dana", PERKS, MobaRole.WARRIOR, SkinData.DANA); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java index 0bb7af0f9..8fcb89839 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java @@ -23,7 +23,8 @@ public class SkillDanaDash extends DashSkill { private static final String[] DESCRIPTION = { - "Dash along the ground, leaving fire behind you.", + "Dash along the ground.", + "Nearby enemies are thrown up into the air." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java index 358db05c1..6d26e4cc3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -21,8 +21,7 @@ public class SkillPulseHeal extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Heals nearby allies and minions." }; private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.INK_SACK, (byte) 10).build(); @@ -52,7 +51,7 @@ public class SkillPulseHeal extends HeroSkill continue; } - MobaUtil.heal(entity, 4); + MobaUtil.heal(entity, player, 4); } displayPulse(player.getLocation().add(0, 0.5, 0)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index ba64117fe..ec5ac4cc9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -33,8 +33,9 @@ public class SkillRally extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "You leap up into the air, and upon landing", + "you plant a banner that heals nearby allies", + "and minions." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java index c50db2648..7ff52d150 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.devon; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; @@ -27,7 +28,7 @@ public class HeroDevon extends HeroKit public HeroDevon(ArcadeManager manager) { - super(manager, "Devon", PERKS, MobaRole.HUNTER); + super(manager, "Devon", PERKS, MobaRole.HUNTER, SkinData.DEVON); setAmmo(AMMO, 3000); setMaxAmmo(3); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java index 284a78e01..e9438b9c1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.hattori; +import mineplex.core.common.skin.SkinData; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; @@ -20,6 +21,6 @@ public class HeroHattori extends HeroKit public HeroHattori(ArcadeManager manager) { - super(manager, "Hattori", PERKS, MobaRole.ASSASSIN); + super(manager, "Hattori", PERKS, MobaRole.ASSASSIN, SkinData.HATTORI); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 5b80853d6..f1d06a1dc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -24,7 +24,7 @@ public class SkillSnowball extends HeroSkill implements IThrown private static final String[] DESCRIPTION = { "Fires 3 snowballs, one after another.", - "Each snowball deals 3 damage to any enemy it hits." + "Each snowball deals damage to any enemy it hits." }; private static final int DAMAGE = 3; private static final ItemStack SKILL_ITEM = new ItemStack(Material.SNOW_BALL); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java index 02ad04e8e..956968e06 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java @@ -42,7 +42,7 @@ public class HPManager implements Listener continue; } - MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5, true); + MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, null, HP5, true); UtilServer.CallEvent(regenEvent); if (regenEvent.isCancelled()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java index f208d672b..a1f2cb08b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.larissa; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; @@ -26,7 +27,7 @@ public class HeroLarissa extends HeroKit public HeroLarissa(ArcadeManager manager) { - super(manager, "Larissa", PERKS, MobaRole.MAGE); + super(manager, "Larissa", PERKS, MobaRole.MAGE, SkinData.LARISSA); setAmmo(AMMO, 3000); setMaxAmmo(5); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java index 15a6fe9f8..93e4e5055 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java @@ -44,8 +44,9 @@ public class SkillAOEHeal extends HeroSkill implements IThrown { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Throws a water bucket which upon coming into", + "contact with the ground will heal nearby", + "players and minions." }; private static final long DURATION = TimeUnit.SECONDS.toMillis(6); private static final int RADIUS = 3; @@ -127,7 +128,7 @@ public class SkillAOEHeal extends HeroSkill implements IThrown if (isTeamDamage(entity, owner)) { MobaParticles.healing(entity, HEALTH_PER_SECOND); - MobaUtil.heal(entity, HEALTH_PER_SECOND); + MobaUtil.heal(entity, owner, HEALTH_PER_SECOND); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java index 74e61a7f3..2a64ce53c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java @@ -26,8 +26,8 @@ public class SkillAquaCannon extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Fires a beam of water that deals damage", + "to the first enemy it comes in contact with." }; private static final int DAMAGE = 6; private static final ItemStack SKILL_ITEM = new ItemStack(Material.DIAMOND_HOE); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java index 9c2fbbaca..a26b02cfe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.moba.kit.larissa; -import mineplex.core.Managers; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -30,8 +29,8 @@ public class SkillStormHeal extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "All team members are consistently healed", + "over the next 7 seconds." }; private static final long DURATION = TimeUnit.SECONDS.toMillis(7); private static final int HEALTH_PER_SECOND = 2; @@ -86,7 +85,7 @@ public class SkillStormHeal extends HeroSkill for (Player teamMember : team.GetPlayers(true)) { - MobaUtil.heal(teamMember, HEALTH_PER_SECOND); + MobaUtil.heal(teamMember, player, HEALTH_PER_SECOND); } }); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java index d66be7c20..69cc3a8f4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java @@ -18,7 +18,8 @@ public class SkillWaterDash extends DashSkill { private static final String[] DESCRIPTION = { - "Dash along the ground, leaving water behind you.", + "Dash along the ground, crippling enemies you", + "come into contact with." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); private static final long CRIPPLE_DURATION = TimeUnit.SECONDS.toMillis(3); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java index d196ad8cb..d15ab3174 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.rowena; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; @@ -27,7 +28,7 @@ public class HeroRowena extends HeroKit public HeroRowena(ArcadeManager manager) { - super(manager, "Rowena", PERKS, MobaRole.HUNTER); + super(manager, "Rowena", PERKS, MobaRole.HUNTER, SkinData.ROWENA); setAmmo(AMMO, 2000); setMaxAmmo(2); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java index 1a704d5e8..2499f8d6e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java @@ -1,30 +1,32 @@ package nautilus.game.arcade.game.games.moba.kit.rowena; import mineplex.core.common.events.EntityVelocityChangeEvent; -import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; 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.UtilServer; import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; import java.util.HashSet; import java.util.Iterator; @@ -34,13 +36,16 @@ public class SkillBombardment extends HeroSkill { private static final String[] DESCRIPTION = { - "Turns into a Diamond Sword that deals extreme", - "damage to any player hit by it." + "Take to the sky!", + "Your shots become fast high power explosive shots." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + private static final int DAMAGE_FACTOR = 2; private static final int SHOTS = 3; private static final int MAX_TIME = 10000; - private static final int DAMAGE_INCREASE = 5; + private static final ItemStack ACTIVE_ITEM = new ItemBuilder(Material.DIAMOND_BARDING) + .setTitle(C.cDRedB + "Bombardment") + .build(); private Set _data = new HashSet<>(); @@ -71,20 +76,54 @@ public class SkillBombardment extends HeroSkill } } - for (Perk perk : Kit.GetPerks()) - { - if (perk instanceof SkillLightArrows) - { - SkillLightArrows skill = (SkillLightArrows) perk; + Location toTeleport = player.getLocation().add(0, 15, 0); - skill.resetCooldown(player); - skill.setPlayerArrows(player, SHOTS); - } + player.teleport(toTeleport); + player.getInventory().setItem(0, ACTIVE_ITEM); + player.getInventory().setHeldItemSlot(0); + broadcast(player); + _data.add(new BombardmentData(player)); + } + + @EventHandler + public void interactActive(PlayerInteractEvent event) + { + if (event.getItem() == null || !event.getItem().isSimilar(ACTIVE_ITEM)) + { + return; } - broadcast(player); - UtilAction.velocity(player, new Vector(0, 2, 0)); - _data.add(new BombardmentData(player)); + Player player = event.getPlayer(); + + for (BombardmentData data : _data) + { + if (data.Shooter.equals(player)) + { + Location location = player.getEyeLocation(); + LineParticle lineParticle = new LineParticle(location, location.getDirection(), 0.4, 40, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); + double damage = MobaUtil.scaleDamageWithBow(player.getInventory().getItem(0), 0) * DAMAGE_FACTOR; + + while (!lineParticle.update()) + { + } + + player.playSound(player.getLocation(), Sound.EXPLODE, 1, 0.8F); + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, lineParticle.getDestination(), 0, 0, 0, 0.1F, 1, ViewDist.LONG); + + for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 5).keySet()) + { + if (isTeamDamage(entity, player)) + { + continue; + } + + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName()); + } + + data.Shots--; + return; + } + } } @EventHandler @@ -102,21 +141,10 @@ public class SkillBombardment extends HeroSkill BombardmentData data = iterator.next(); Player player = data.Shooter; - if (data.Block == null && player.getVelocity().getY() <= 0) - { - data.Block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); - data.Block.setType(Material.BARRIER); - - Location playerLocation = player.getLocation(); - Location toTeleport = data.Block.getLocation(); - toTeleport.setYaw(playerLocation.getYaw()); - toTeleport.setPitch(playerLocation.getPitch()); - - player.getInventory().setHeldItemSlot(0); - } - else if (UtilTime.elapsed(data.Start, MAX_TIME) || data.Shots == 0) + if (UtilTime.elapsed(data.Start, MAX_TIME) || data.Shots == 0) { useSkill(player); + Kit.GiveItems(player); data.Block.setType(Material.AIR); iterator.remove(); } @@ -127,46 +155,6 @@ public class SkillBombardment extends HeroSkill } } - @EventHandler - public void shootArrow(EntityShootBowEvent event) - { - if (!(event.getEntity() instanceof Player)) - { - return; - } - - Player player = (Player) event.getEntity(); - - for (BombardmentData data : _data) - { - if (data.Shooter.equals(player)) - { - data.Shots--; - return; - } - } - } - - @EventHandler(priority = EventPriority.HIGH) - public void increaseDamage(CustomDamageEvent event) - { - if (event.isCancelled()) - { - return; - } - - Player damager = event.GetDamagerPlayer(true); - - if (damager == null || event.GetReason() == null || !event.GetReason().contains("Light Arrows")) - { - return; - } - - damager.playSound(event.GetDamageeEntity().getLocation(), Sound.EXPLODE, 1, 0.6F); - UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, event.GetDamageeEntity().getLocation().add(0, 1, 0), 0, 0, 0, 0.1F, 1, ViewDist.LONG); - event.AddMod(GetName(), DAMAGE_INCREASE); - } - @EventHandler public void playerMove(PlayerMoveEvent event) { @@ -212,6 +200,8 @@ public class SkillBombardment extends HeroSkill { Shooter = shooter; Shots = SHOTS; + Block = shooter.getLocation().getBlock().getRelative(BlockFace.DOWN); + Block.setType(Material.BARRIER); Start = System.currentTimeMillis(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java index 27de6635a..a3edb19df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java @@ -13,7 +13,7 @@ public class SkillCombatDash extends DashSkill { private static final String[] DESCRIPTION = { - "Dash along the ground, leaving fire behind you.", + "Dash very fast along the ground.", }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); @@ -25,7 +25,6 @@ public class SkillCombatDash extends DashSkill _collide = false; _velocityTime = 250; - _velocityStopOnEnd = true; _velocityMagnitude = 1.5; _horizontial = true; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java index b71653c29..d4037aa5f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java @@ -38,8 +38,8 @@ public class SkillLightArrows extends HeroSkill { private static final String[] DESCRIPTION = { - "Your next 3 arrows are infused with TNT.", - "They explode on contact dealing damage and knockback." + "Your next 5 arrows become light infused.", + "They pass through blocks and deal high damage." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.GOLD_NUGGET); @@ -170,10 +170,5 @@ public class SkillLightArrows extends HeroSkill _playerArrows.remove(event.getPlayer()); _arrows.remove(event.getPlayer()); } - - void setPlayerArrows(Player player, int amount) - { - _playerArrows.put(player, amount); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 1d90780a7..e3c663632 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -143,6 +143,11 @@ public class MinionManager implements Listener public void unregisterWave(MinionWave wave) { + for (Minion minion : wave.getMinions()) + { + minion.getEntity().remove(); + } + _waves.remove(wave); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index edb5c9917..5d9f3e77f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -33,6 +33,7 @@ import org.jooq.util.derby.sys.Sys; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -163,7 +164,23 @@ public class MinionWave implements Listener return; } - _minions.removeIf(minion -> minion.getEntity() == null || minion.getEntity().isDead() || !minion.getEntity().isValid()); + Iterator iterator = _minions.iterator(); + + while (iterator.hasNext()) + { + Minion minion = iterator.next(); + LivingEntity entity = minion.getEntity(); + + if (entity == null || entity.isDead() || !entity.isValid()) + { + if (entity != null && entity.getKiller() != null) + { + _host.AddGems(entity.getKiller(), 0.1, "Minion Kills", true, true); + } + + iterator.remove(); + } + } // Only should unregister the wave after all entities have spawned if (_minions.isEmpty() && UtilTime.elapsed(_startTime, 10000)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java index d31ff421e..0565ef5e5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -19,12 +19,12 @@ public class MobaKillHealEffect extends MobaItemEffect @Override public void onDeath(Player killed, Player killer) { - MobaUtil.heal(killer, _health); + MobaUtil.heal(killer, killer, _health); } @Override public String getDescription() { - return "Killing a player heals for " + F.greenElem(format(_health / 2)) + C.cRed + "❤" + C.cGray + "."; + return "Killing a player heals for an additional " + F.greenElem(format(_health / 2)) + C.cRed + "❤" + C.cGray + "."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index f31a6c380..a7c9d4d54 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -125,6 +125,11 @@ public class TowerManager implements Listener @EventHandler public void updateTower(UpdateEvent event) { + if (!_host.IsLive()) + { + return; + } + if (event.getType() == UpdateType.FASTEST) { for (Tower tower : _towers) @@ -166,7 +171,7 @@ public class TowerManager implements Listener @EventHandler(priority = EventPriority.LOW) public void crystalDamage(EntityDamageByEntityEvent event) { - if (!(event.getEntity() instanceof EnderCrystal)) + if (!(event.getEntity() instanceof EnderCrystal) || !_host.IsLive()) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 72fe45918..ac09e9aac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -198,11 +198,11 @@ public class MobaUtil return entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(team.GetName()); } - public static void heal(LivingEntity entity, double health) + public static void heal(LivingEntity entity, Player source, double health) { if (entity instanceof Player) { - MobaHPRegenEvent regenEvent = new MobaHPRegenEvent((Player) entity, health, false); + MobaHPRegenEvent regenEvent = new MobaHPRegenEvent((Player) entity, source, health, false); UtilServer.CallEvent(regenEvent); if (regenEvent.isCancelled()) From 2a0796472bada88760a53cb5f078f4114cb9df82 Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 14 Jun 2017 19:54:23 -0500 Subject: [PATCH 186/283] Add beta whitelist to MOBA --- .../src/nautilus/game/arcade/game/games/moba/Moba.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 277fbd021..dd98c6884 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba; import mineplex.core.Managers; +import mineplex.core.beta.BetaWhitelist; import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -97,6 +98,7 @@ public class Moba extends TeamGame private final CapturePointManager _capturePoint; private final ArrowKBManager _arrowKb; private final BuffManager _buffs; + private final BetaWhitelist _betaWhitelist; public Moba(ArcadeManager manager) { @@ -163,6 +165,9 @@ public class Moba extends TeamGame // Beta Message registerManager(new BetaManager(this)); + // Beta Whitelist + _betaWhitelist = new BetaWhitelist(manager.GetClients(), manager.getBonusManager().getPowerPlayClubRepository()); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -527,6 +532,7 @@ public class Moba extends TeamGame super.disable(); _listeners.forEach(UtilServer::Unregister); _listeners.clear(); + _betaWhitelist.deregisterSelf(); } @Override From 8e9c5c43e4a288fd34bf244df4ea4746c28d0afa Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 14 Jun 2017 19:57:58 -0500 Subject: [PATCH 187/283] Remove unused agentCacheMap in CUST --- .../mineplex/staffServer/customerSupport/checkCommand.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java index 62017cba3..d4d2542e6 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java @@ -1,12 +1,11 @@ package mineplex.staffServer.customerSupport; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; public class checkCommand extends CommandBase { @@ -35,7 +34,6 @@ public class checkCommand extends CommandBase if (client != null) { Plugin.showPlayerInfo(caller, client); - Plugin.addAgentMapping(caller, client); } else { From cfe8840d7afaea793c56f49442023ec57d3b19e5 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 15 Jun 2017 01:58:48 +0100 Subject: [PATCH 188/283] Fix some really silly things --- .../game/arcade/game/games/moba/Moba.java | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index dd98c6884..e2aae04a4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -10,6 +10,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.leaderboard.Leaderboard; import mineplex.core.leaderboard.LeaderboardManager; import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; @@ -187,10 +188,6 @@ public class Moba extends TeamGame case Live: writeLive(player, scoreboard); break; - case End: - case WinRoom: - writeEnd(player, scoreboard); - break; } }) .setPrefix((perspective, subject) -> @@ -416,15 +413,6 @@ public class Moba extends TeamGame scoreboard.write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime())); } - private void writeEnd(Player player, GameScoreboard scoreboard) - { - scoreboard.writeNewLine(); - - scoreboard.write("Game Over"); - - scoreboard.writeNewLine(); - } - @EventHandler(priority = EventPriority.LOWEST) public void prepare(GameStateChangeEvent event) { @@ -499,7 +487,7 @@ public class Moba extends TeamGame { for (Player player : otherTeam.GetPlayers(true)) { - AddGems(player, 10, "Participation", true, true); + AddGems(player, 10, "Participation", false, false); } if (team.equals(otherTeam)) @@ -509,7 +497,7 @@ public class Moba extends TeamGame for (Player player : otherTeam.GetPlayers(true)) { - AddGems(player, 20, "Winning", true, true); + AddGems(player, 20, "Winning", false, false); } AnnounceEnd(otherTeam); @@ -575,7 +563,7 @@ public class Moba extends TeamGame @EventHandler public void end(GameStateChangeEvent event) { - if (event.GetState() != GameState.End) + if (event.GetState() != GameState.End && event.GetState() != GameState.Dead) { return; } @@ -584,7 +572,7 @@ public class Moba extends TeamGame { DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); - if (disguise != null) + if (disguise != null && disguise instanceof DisguisePlayer) { Manager.GetDisguise().undisguise(disguise); } From a5fd9bef793d7152778fd48f8bc4d419bf688c49 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 15 Jun 2017 02:01:26 +0100 Subject: [PATCH 189/283] Turns out Achievements are case sensitive --- .../src/mineplex/core/achievement/AchievementCategory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 123e9db4d..885bf7939 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -219,7 +219,7 @@ public enum AchievementCategory new StatDisplay[] {StatDisplay.KILLS, StatDisplay.GEMS_EARNED, StatDisplay.fromGame("Quests Completed", GameDisplay.GemHunters, "QuestsCompleted"), StatDisplay.fromGame("Chests Opened", GameDisplay.GemHunters, "ChestsOpened")}, Material.EMERALD, 0, GameCategory.SURVIVAL, null, false, GameDisplay.GemHunters.getGameId()), - MOBA("Heroes Of Gwen", null, + MOBA("Heroes of GWEN", null, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, StatDisplay.fromGame("Gold Earned", GameDisplay.MOBA, "GoldEarned")}, Material.PRISMARINE_SHARD, 0, GameCategory.CLASSICS, null, false, GameDisplay.MOBA.getGameId()); From ba506f9c7b3ebb11d22d2eb56066cf35b41bc760 Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 14 Jun 2017 22:26:29 -0500 Subject: [PATCH 190/283] Fix beta whitelist duplicate-enable --- .../nautilus/game/arcade/game/games/moba/Moba.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index e2aae04a4..3850dcc77 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -99,7 +99,7 @@ public class Moba extends TeamGame private final CapturePointManager _capturePoint; private final ArrowKBManager _arrowKb; private final BuffManager _buffs; - private final BetaWhitelist _betaWhitelist; + private BetaWhitelist _betaWhitelist; public Moba(ArcadeManager manager) { @@ -167,7 +167,15 @@ public class Moba extends TeamGame registerManager(new BetaManager(this)); // Beta Whitelist - _betaWhitelist = new BetaWhitelist(manager.GetClients(), manager.getBonusManager().getPowerPlayClubRepository()); + _betaWhitelist = Managers.get(BetaWhitelist.class); + if (_betaWhitelist == null) + { + _betaWhitelist = new BetaWhitelist(manager.GetClients(), manager.getBonusManager().getPowerPlayClubRepository()); + } + else + { + _betaWhitelist.registerSelf(); + } new CompassModule() .setGiveCompass(true) From d4f27ef768feae00ce03ff2ada072d91b607188f Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Fri, 9 Jun 2017 16:41:45 -0400 Subject: [PATCH 191/283] Update xenforo forum id for mapper rank --- Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 3041395bf..834c1eff4 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -24,7 +24,7 @@ public enum Rank MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), HELPER("Trainee", "train", ChatColor.GOLD, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 24, DyeColor.ORANGE), MAPLEAD("MapLead", "mapl", ChatColor.BLUE, "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders.", 25, DyeColor.BLUE), - MAPPER("Mapper", "mapp", ChatColor.BLUE, "These senior staff members work closely with \nthe development and design teams to build new \nmaps for new and old content!", 26, DyeColor.BLUE), + MAPPER("Mapper", "mapp", ChatColor.BLUE, "These senior staff members work closely with \nthe development and design teams to build new \nmaps for new and old content!", 100, DyeColor.BLUE), MAPDEV("Builder", "mapd", ChatColor.BLUE, "These creative staff members help \nbuild maps for your favorite games!", 26, DyeColor.BLUE), MEDIA("Media", "media", ChatColor.BLUE, "The Media rank is given to talented artists who are\n endorsed to create content for Mineplex.", -1, DyeColor.BLUE), From c2cbcfc62f262019b82a211bd09dbddb2e4557c7 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 15 Jun 2017 21:22:26 +0100 Subject: [PATCH 192/283] Fix spamming bombardment --- .../arcade/game/games/moba/kit/rowena/SkillBombardment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java index 2499f8d6e..cdb3e4838 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java @@ -141,7 +141,7 @@ public class SkillBombardment extends HeroSkill BombardmentData data = iterator.next(); Player player = data.Shooter; - if (UtilTime.elapsed(data.Start, MAX_TIME) || data.Shots == 0) + if (UtilTime.elapsed(data.Start, MAX_TIME) || data.Shots <= 0) { useSkill(player); Kit.GiveItems(player); From d2c91739434b64780f2c623f8d88e5e4bd7cfb38 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 15 Jun 2017 17:19:19 -0500 Subject: [PATCH 193/283] Add missing instanceof check --- .../src/mineplex/hub/brawl/fountain/FountainManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/brawl/fountain/FountainManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/brawl/fountain/FountainManager.java index 22845867e..5bbeb6618 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/brawl/fountain/FountainManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/brawl/fountain/FountainManager.java @@ -52,7 +52,10 @@ public class FountainManager extends MiniPlugin @EventHandler public void onDamage(EntityDamageByEntityEvent event) { - tryBrawl((Player)event.getDamager(), event.getEntity()); + if (event.getDamager() instanceof Player) + { + tryBrawl((Player) event.getDamager(), event.getEntity()); + } } private void tryBrawl(Player player, Entity entity) From a12564c8a962774c881d70b7dadbeabfcecb974f Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 15 Jun 2017 23:26:29 +0100 Subject: [PATCH 194/283] Fix consumables --- .../arcade/game/games/moba/kit/HeroKit.java | 9 ++- .../arcade/game/games/moba/shop/MobaShop.java | 6 +- .../games/moba/shop/MobaShopCategory.java | 68 ++++++------------- .../games/moba/shop/MobaShopCategoryMenu.java | 14 ++-- .../game/games/moba/shop/MobaShopMenu.java | 2 +- 5 files changed, 39 insertions(+), 60 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 1fc1d18d0..0fbecfe73 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -207,11 +207,18 @@ public class HeroKit extends Kit // Keep moving left from the ammo slot until a free slot is available for (int i = AMMO_SLOT - 1; i >= GetPerks().length - 1; i--) { - if (inventory.getItem(i) == null) + ItemStack consumable = inventory.getItem(i); + + if (consumable == null) { inventory.setItem(i, itemstack); break; } + else if (consumable.isSimilar(itemstack)) + { + consumable.setAmount(consumable.getAmount() + 1); + break; + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 8af803c11..7300d7385 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -206,7 +206,6 @@ public class MobaShop implements Listener player.sendMessage(F.main("Game", "Purchased " + F.greenElem(item.getItem().getItemMeta().getDisplayName()) + ".")); _host.getGoldManager().removeGold(player, item.getCost()); owned.add(item); - category.purchase(player); // 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, // Prevents infinite speed @@ -506,6 +505,11 @@ public class MobaShop implements Listener Player player = (Player) entity; List items = _upgrades.get(player); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java index a978f4545..a01eecac1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java @@ -1,12 +1,8 @@ package nautilus.game.arcade.game.games.moba.shop; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.UUID; public class MobaShopCategory { @@ -14,17 +10,16 @@ public class MobaShopCategory private final String _name; private final List _items; private final ItemStack _menuItem; - private final Map _purchased; - private int _max; private boolean _dropOnDeath; + private boolean _allowMultiple; + private boolean _trackPurchases; public MobaShopCategory(String name, List items, ItemStack menuItem) { _name = name; _items = items; _menuItem = menuItem; - _max = Integer.MAX_VALUE; - _purchased = new HashMap<>(); + _trackPurchases = true; } public String getName() @@ -42,44 +37,6 @@ public class MobaShopCategory return _menuItem; } - public void purchase(Player player) - { - UUID key = player.getUniqueId(); - - if (!_purchased.containsKey(key)) - { - _purchased.put(key, 1); - } - else - { - _purchased.put(key, _purchased.get(key) + 1); - } - } - - public void onDeath(Player player) - { - if (isDroppingOnDeath()) - { - _purchased.remove(player.getUniqueId()); - } - } - - public int getPurchased(Player player) - { - return _purchased.getOrDefault(player.getUniqueId(), 0); - } - - public MobaShopCategory setMax(int max) - { - _max = max; - return this; - } - - public int getMax() - { - return _max; - } - public MobaShopCategory dropOnDeath() { _dropOnDeath = true; @@ -91,8 +48,25 @@ public class MobaShopCategory return _dropOnDeath; } + public MobaShopCategory allowMultiple() + { + _allowMultiple = true; + return this; + } + public boolean isAllowingMultiple() { - return _max < Integer.MAX_VALUE; + return _allowMultiple; + } + + public MobaShopCategory dontTrackPurchases() + { + _trackPurchases = false; + return this; + } + + public boolean isTrackingPurchases() + { + return _trackPurchases; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java index 7c7c3aba5..66c061c14 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -45,9 +45,8 @@ public class MobaShopCategoryMenu extends Menu for (MobaItem item : _category.getItems()) { ItemBuilder builder = new ItemBuilder(item.getItem()); - boolean owns = _shop.ownsItem(player, item); + boolean owns = _shop.ownsItem(player, item) && _category.isTrackingPurchases(); boolean canPurchase = _host.getGoldManager().hasGold(player, item.getCost()); - boolean maxed = _category.getPurchased(player) == _category.getMax(); int gold = _host.getGoldManager().getGold(player); builder.setTitle((canPurchase ? C.cGreen : C.cRed) + item.getItem().getItemMeta().getDisplayName()); @@ -62,11 +61,7 @@ public class MobaShopCategoryMenu extends Menu { builder.addLore(C.cWhite + "Cost: " + C.cGold + item.getCost(), C.cWhite + "Your Gold: " + C.cGold + gold, ""); - if (maxed) - { - builder.addLore(C.cRed + "You have already purchased the maximum amount", C.cRed + "of upgrades from this category."); - } - else if (canPurchase) + if (canPurchase) { builder.addLore(C.cGreen + "Click to purchase."); } @@ -103,11 +98,10 @@ public class MobaShopCategoryMenu extends Menu @Override public void onClick(Player player, ClickType clickType) { - boolean owns = _shop.ownsItem(player, _item); + boolean owns = _shop.ownsItem(player, _item) && _category.isTrackingPurchases(); boolean canPurchase = _host.getGoldManager().hasGold(player, _item.getCost()); - boolean maxed = _category.getPurchased(player) == _category.getMax(); - if (!owns && canPurchase && !maxed) + if (!owns && canPurchase) { player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 1.6F); _shop.purchaseItem(player, _item); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java index db0c94fa3..bc60eba4a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java @@ -42,7 +42,7 @@ public class MobaShopMenu extends Menu new MobaItem(new ItemBuilder(Material.ENDER_PEARL) .setTitle(C.cYellowB + "Ender Pearl") .build(), 750) - ), new ItemStack(Material.POTION)).dropOnDeath().setMax(3); + ), new ItemStack(Material.POTION)).dropOnDeath().allowMultiple().dontTrackPurchases(); private static final int SLOTS = 27; private final Moba _host; From 07779cdf55f6e56680f957932b12a1308a27f726 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 15 Jun 2017 23:26:56 +0100 Subject: [PATCH 195/283] Reduce the damage from TNT Infusion --- .../game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java index 9149558ce..b871b1e7c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java @@ -135,7 +135,7 @@ public class SkillTNTArrows extends HeroSkill continue; } - Manager.GetDamage().NewDamageEvent(entry.getKey(), player, null, DamageCause.BLOCK_EXPLOSION, (entry.getValue() + 0.5) * damage, true, true, false, UtilEnt.getName(player), GetName()); + Manager.GetDamage().NewDamageEvent(entry.getKey(), player, null, DamageCause.CUSTOM, entry.getValue() * damage, true, true, false, UtilEnt.getName(player), GetName()); } } From 336777f89a5ae54eacca085659359e0a41fbb5fe Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 15 Jun 2017 18:15:04 -0500 Subject: [PATCH 196/283] Add builders to the beta whitelist --- .../Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java index f39636aa5..bf384c4c8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java @@ -55,8 +55,8 @@ public class BetaWhitelist extends MiniPlugin { Player player = event.getPlayer(); Rank rank = _clientManager.Get(player).GetRank(true); - if ((rank != Rank.MAPDEV && rank != Rank.MAPPER && rank != Rank.MAPLEAD && rank.has(Rank.TITAN) // If this player is Titan+ (and not a builder), - || _powerPlayClubRepository.getCachedData(player).isSubscribed()) // a PPC subscriber, + if (rank.has(Rank.TITAN) // If this player is Titan+ + || _powerPlayClubRepository.getCachedData(player).isSubscribed() // a PPC subscriber, || EXTRA_PLAYERS.contains(player.getUniqueId())) // or explicitly whitelisted, { return; // allow them in From 724604c76a735d971e42d878ff2734d0999c24c6 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:03:30 -0400 Subject: [PATCH 197/283] Fix bug preventing TNT generators from working if purchaser leaves the clan --- .../game/clans/shop/pvp/tnt/TNTGenPage.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/tnt/TNTGenPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/tnt/TNTGenPage.java index 367cc8464..efae5fd11 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/tnt/TNTGenPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/tnt/TNTGenPage.java @@ -84,7 +84,9 @@ public class TNTGenPage extends ShopPageBase nextTnt = UtilTime.MakeStr((TntGeneratorManager.SECONDS_PER_TNT - generator.getTicks()) * 1000); } - addButton(13, new ItemBuilder(Material.BREWING_STAND_ITEM) + if (clan.getMembers().containsKey(generator.getBuyer())) + { + addButton(13, new ItemBuilder(Material.BREWING_STAND_ITEM) .setTitle(C.cGreen + "TNT Generator") .setLore( " ", @@ -95,7 +97,24 @@ public class TNTGenPage extends ShopPageBase C.cWhite + "Next TNT: " + F.elem(nextTnt)).build(), (player, click) -> { clearPage(); buildPage(); - }); + } + ); + } + else + { + addButton(13, new ItemBuilder(Material.BREWING_STAND_ITEM) + .setTitle(C.cGreen + "TNT Generator") + .setLore( + " ", + C.cWhite + "TNT Available: " + F.elem(Integer.valueOf(generator.getStock())), + " ", + C.cWhite + "Next TNT: " + F.elem(nextTnt)).build(), (player, click) -> + { + clearPage(); + buildPage(); + } + ); + } if (generator.getStock() == 0) { @@ -138,5 +157,4 @@ public class TNTGenPage extends ShopPageBase } } } - -} +} \ No newline at end of file From fc3a4bdbfe1fa48c7ec1887e94a4d215a9a4231c Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:05:16 -0400 Subject: [PATCH 198/283] Fix purchase item goal in tutorial --- .../game/clans/economy/GoldManager.java | 4 ++ .../game/clans/shop/ShopItemButton.java | 50 +++++++++---------- .../tutorials/clans/ClansMainTutorial.java | 11 ++-- 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java index 43da489eb..db67d9a1e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java @@ -366,6 +366,10 @@ public class GoldManager extends MiniDbClientPlugin { rewardGold(resultCallback, player, -amount, true); } + if (amount == 0 && resultCallback != null) + { + resultCallback.run(true); + } } public void rewardGold(final Callback callback, final Player player, final int amount, final boolean updateTotal) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java index 8a292032d..3e3a4e7b0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java @@ -9,7 +9,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.InventoryUtil; import mineplex.core.common.util.UtilItem; @@ -109,38 +108,35 @@ public class ShopItemButton> implements IButton final ItemStack eventItem = _item.clone(); eventItem.setAmount(amount); - GoldManager.getInstance().deductGold(new Callback() + GoldManager.getInstance().deductGold(success -> { - public void run(Boolean success) + if (success) { - if (success) + ClansPlayerBuyItemEvent event = new ClansPlayerBuyItemEvent(player, _page, ShopItemButton.this, eventItem, cost, amount); + UtilServer.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { - ClansPlayerBuyItemEvent event = new ClansPlayerBuyItemEvent(player, _page, ShopItemButton.this, eventItem, cost, amount); - UtilServer.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) - { - GoldManager.getInstance().addGold(player, cost); - return; - } - - _item = event.getItem(); - final int finalCost = event.getCost(); - final int finalAmount = event.getAmount(); - - giftItem(player, finalAmount); - GoldManager.notify(player, String.format("You have purchased %d item(s) for %dg", finalAmount, finalCost)); - - _page.playAcceptSound(player); - } - else - { - GoldManager.notify(player, "You cannot afford that item! Please relog to update your gold count."); - _page.playDenySound(player); + GoldManager.getInstance().addGold(player, cost); + return; } - _page.refresh(); + _item = event.getItem(); + final int finalCost = event.getCost(); + final int finalAmount = event.getAmount(); + + giftItem(player, finalAmount); + GoldManager.notify(player, String.format("You have purchased %d item(s) for %dg", finalAmount, finalCost)); + + _page.playAcceptSound(player); } + else + { + GoldManager.notify(player, "You cannot afford that item! Please relog to update your gold count."); + _page.playDenySound(player); + } + + _page.refresh(); }, player, cost); } else diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java index f9d21b850..9e843924e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java @@ -137,15 +137,10 @@ public class ClansMainTutorial extends Tutorial if (!_taskManager.hasCompletedTask(player, getTaskIdentifier())) { - _taskManager.completedTask(new Callback() + _taskManager.completedTask(data -> { - @Override - public void run(Boolean data) - { - - GoldManager.getInstance().addGold(player, 32000); - UtilPlayer.message(player, F.main("Clans", "You have earned " + F.elem(32000 + " Gold") + " for finishing the tutorial!")); - } + GoldManager.getInstance().addGold(player, 32000); + UtilPlayer.message(player, F.main("Clans", "You have earned " + F.elem(32000 + " Gold") + " for finishing the tutorial!")); }, player, getTaskIdentifier()); } From e8a4e23f05429d5816da6491765fc34b6eac8618 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:05:41 -0400 Subject: [PATCH 199/283] Fix mute bypasses via clans chat commands --- .../clans/clans/commands/ClansAllyChatCommand.java | 14 +++++++++++++- .../clans/clans/commands/ClansChatCommand.java | 11 +++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansAllyChatCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansAllyChatCommand.java index b1723b719..fdbd287a4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansAllyChatCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansAllyChatCommand.java @@ -2,10 +2,13 @@ package mineplex.game.clans.clans.commands; import org.bukkit.entity.Player; +import mineplex.core.Managers; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.punish.Punish; +import mineplex.core.punish.PunishClient; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; @@ -39,7 +42,16 @@ public class ClansAllyChatCommand extends CommandBase { ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); if (clan == null) UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); - else Plugin.chatAlly(clan, caller, F.combine(args, 0, null, false)); + else + { + PunishClient punishClient = Managers.get(Punish.class).GetClient(caller.getName()); + if (punishClient != null && punishClient.IsMuted()) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot do this while muted!")); + return; + } + Plugin.chatAlly(clan, caller, F.combine(args, 0, null, false)); + } } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java index 36619c1ef..3ce97064c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java @@ -2,10 +2,13 @@ package mineplex.game.clans.clans.commands; import org.bukkit.entity.Player; +import mineplex.core.Managers; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.punish.Punish; +import mineplex.core.punish.PunishClient; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; @@ -41,7 +44,15 @@ public class ClansChatCommand extends CommandBase if (clan == null) UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); else + { + PunishClient punishClient = Managers.get(Punish.class).GetClient(caller.getName()); + if (punishClient != null && punishClient.IsMuted()) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot do this while muted!")); + return; + } Plugin.chatClan(clan, caller, F.combine(args, 0, null, false)); + } } } } From 1ea0b4d33a3c4444fc4db78b61257f8b5299618a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:06:38 -0400 Subject: [PATCH 200/283] Final polish on builder box --- .../game/clans/clans/boxes/extra/BuilderBoxInventory.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxInventory.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxInventory.java index 2308b65a8..e45db862a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxInventory.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/extra/BuilderBoxInventory.java @@ -20,7 +20,9 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.Pair; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemBuilder; import mineplex.game.clans.clans.ClansManager; @@ -48,6 +50,7 @@ public class BuilderBoxInventory implements Listener _replace.put(Pair.create(Material.RED_ROSE, (byte)8), new ItemStack(Material.RED_ROSE)); _replace.put(Pair.create(Material.COBBLE_WALL, (byte)0), new ItemStack(Material.COBBLE_WALL)); _replace.put(Pair.create(Material.JACK_O_LANTERN, (byte)0), new ItemStack(Material.GLOWSTONE)); + _replace.put(Pair.create(Material.SMOOTH_BRICK, (byte)0), new ItemStack(Material.SMOOTH_BRICK)); UtilServer.RegisterEvents(this); } @@ -77,6 +80,10 @@ public class BuilderBoxInventory implements Listener { after.setData((short)0); } + else if (after.getType() == Material.SMOOTH_BRICK) + { + after.setData(UtilMath.randomElement(new Short[] {1, 3}).shortValue()); + } else { after.setData(UtilMath.randomElement(DyeColor.values()).getWoolData()); @@ -139,6 +146,7 @@ public class BuilderBoxInventory implements Listener if (totalChanged > 0) { ClansManager.getInstance().getInventoryManager().addItemToInventory((Player)event.getPlayer(), BoxType.BUILDER_BOX.getItemName(), -1); + UtilPlayer.message(event.getPlayer(), F.main("Builder's Box", "You have redeemed your box contents!")); } } } From 802cde9280555e51c335b7689bac1f4fc34c8501 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:07:03 -0400 Subject: [PATCH 201/283] Update clans gui icons to reflect resource pack changes --- .../src/mineplex/game/clans/clans/gui/ClanIcon.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/ClanIcon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/ClanIcon.java index 078b469f7..118549e90 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/ClanIcon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/ClanIcon.java @@ -7,8 +7,8 @@ public enum ClanIcon JOIN(Material.PRISMARINE, (byte) 1), LEAVE(Material.PRISMARINE, (byte) 2), TERRITORY(Material.PRISMARINE, (byte) 0), - MEMBER(Material.SAND, (byte) 1), - COMMANDS(Material.RED_SANDSTONE, (byte) 0), + MEMBER(Material.WATER_BUCKET, (byte) 0), + COMMANDS(Material.LAVA_BUCKET, (byte) 0), ENERGY(Material.SEA_LANTERN, (byte) 0), CASTLE(Material.RECORD_9, (byte) 0), WAR(Material.RECORD_11, (byte) 0), From 01df9b7e443eaa869d447f0bc526721326cff9ee Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:07:21 -0400 Subject: [PATCH 202/283] Prevent claiming via gui in nether or raid worlds --- .../clans/gui/button/ClanTerritoryButton.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanTerritoryButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanTerritoryButton.java index 363c78f01..ebcff0611 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanTerritoryButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/button/ClanTerritoryButton.java @@ -9,6 +9,7 @@ import org.bukkit.event.inventory.ClickType; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanRole; @@ -27,12 +28,18 @@ public class ClanTerritoryButton extends ClanButton { if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Territory)).isCancelled()) return; -// if (_clansManager.getNetherManager().isInNether(player)) -// { -// _clansManager.message(player, "You are not allowed to do anything with Territory while in " + F.clansNether("The Nether") + "."); -// player.closeInventory(); -// return; -// } + if (_clansManager.getNetherManager().isInNether(player)) + { + UtilPlayer.message(player, F.main(_clansManager.getNetherManager().getName(), "You cannot manage your clan's territory while in " + F.clansNether("The Nether") + "!")); + player.closeInventory(); + return; + } + if (_clansManager.getWorldEvent().getRaidManager().isInRaid(player.getLocation())) + { + UtilPlayer.message(player, F.main(_clansManager.getWorldEvent().getRaidManager().getName(), "You cannot manage your clan's territory while in a raid!")); + player.closeInventory(); + return; + } if (clickType == ClickType.LEFT) { From 4485b4bc676d35ff5f99cea2d236bdb3a3432eba Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:07:53 -0400 Subject: [PATCH 203/283] Add mount tokens to the rare loot pool --- .../game/clans/clans/loot/LootManager.java | 4 +- .../game/clans/clans/loot/MountLoot.java | 45 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/MountLoot.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/LootManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/LootManager.java index a322d8041..949723a3a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/LootManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/LootManager.java @@ -4,6 +4,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import mineplex.game.clans.clans.mounts.Mount.MountType; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.items.GearManager; import mineplex.core.common.weight.WeightSet; @@ -87,8 +88,9 @@ public class LootManager private void populateRare() { // Gear - _rareSet.add(90, new GearLoot(_gearManager)); + _rareSet.add(70, new GearLoot(_gearManager)); _rareSet.add(10, new GoldTokenLoot(50000, 100000)); + _rareSet.add(20, new MountLoot(1, 3, MountType.values())); } public void dropCommon(Location location) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/MountLoot.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/MountLoot.java new file mode 100644 index 000000000..65fe0c074 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/MountLoot.java @@ -0,0 +1,45 @@ +package mineplex.game.clans.clans.loot; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.mounts.Mount.MountType; +import mineplex.game.clans.clans.mounts.MountClaimToken; + +public class MountLoot implements ILoot +{ + private int _minStars, _maxStars; + private MountType[] _types; + + public MountLoot(int minStars, int maxStars, MountType... types) + { + _minStars = Math.max(minStars, 1); + _maxStars = Math.min(maxStars, 3); + if (types.length == 0) + { + _types = MountType.values(); + } + else + { + _types = types; + } + } + + @Override + public void dropLoot(Location location) + { + MountClaimToken token = new MountClaimToken(UtilMath.rRange(_minStars, _maxStars), UtilMath.rRange(_minStars, _maxStars), UtilMath.rRange(_minStars, _maxStars), UtilMath.randomElement(_types)); + UtilFirework.playFirework(location.clone().add(0, 3, 0), Type.BALL, Color.SILVER, true, false); + location.getWorld().dropItemNaturally(location.clone().add(0, 3, 0), token.toItem()); + } + + @Override + public ItemStack getItemStack() + { + return new MountClaimToken(UtilMath.rRange(_minStars, _maxStars), UtilMath.rRange(_minStars, _maxStars), UtilMath.rRange(_minStars, _maxStars), UtilMath.randomElement(_types)).toItem(); + } +} From 70212f95960c6fde26003ef4efdf3f3c2cca452c Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:08:15 -0400 Subject: [PATCH 204/283] Tweak jump star values to final levels --- .../src/mineplex/game/clans/clans/mounts/MountManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java index bf5ae510b..2460ffea9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -48,7 +48,7 @@ import mineplex.serverdata.Utility; public class MountManager extends MiniDbClientPlugin { - private static final double[] JUMP_STARS = {1, 1.5, 2}; + private static final double[] JUMP_STARS = {0.8, 1, 1.2}; private static final double[] SPEED_STARS = {0.2, 0.27, 0.33}; private static final int[] STRENGTH_STARS = {1, 2, 3}; From f4397d0b0b69efc5de8934754a5d60960b456de8 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:08:50 -0400 Subject: [PATCH 205/283] Tweak boss nether portals --- .../clans/clans/nether/NetherManager.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 58686ec12..bca2c1acc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -1,5 +1,6 @@ package mineplex.game.clans.clans.nether; +import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; import java.util.List; @@ -19,6 +20,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityPortalEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerDropItemEvent; @@ -72,9 +74,9 @@ public class NetherManager extends MiniPlugin private PortalRepository _repo; private NetherMinibossManager _miniboss; private World _netherWorld; - private List _portals = Lists.newArrayList(); - public List BossPortals = Lists.newArrayList(); - private List _returnPortals = Lists.newArrayList(); + private List _portals = new ArrayList<>(); + public List BossPortals = new ArrayList<>(); + private List _returnPortals = new ArrayList<>(); public Map InNether = new HashMap<>(); public Map OverworldOrigins = new HashMap<>(); public Map Claiming = new HashMap<>(); @@ -305,6 +307,7 @@ public class NetherManager extends MiniPlugin } BossNetherPortal portal = new BossNetherPortal(bossSpawn.clone().add(-2, 5, 0), bossSpawn.clone().add(2, 0, 0), false); portal.open(PORTAL_OPEN_DURATION); + BossPortals.add(portal); for (NetherPortal returnPortal : _returnPortals) { returnPortal.open(-1); @@ -570,6 +573,15 @@ public class NetherManager extends MiniPlugin @EventHandler public void onBossDeath(BossDeathEvent event) { - spawnBossPortal(event.getEvent().getCenterLocation().clone().subtract(0, 1, 0)); + spawnBossPortal(event.getEvent().getCenterLocation().clone()); + } + + @EventHandler + public void onBlockDamage(EntityExplodeEvent event) + { + if (isInNether(event.getLocation())) + { + event.setYield(0f); + } } } \ No newline at end of file From 394ebf9ad0701aa10c28542ee40358f22bde8313 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:09:01 -0400 Subject: [PATCH 206/283] Tweak nether minibosses --- .../miniboss/NetherMinibossManager.java | 15 +++++------- .../nether/miniboss/NetherMinibossType.java | 6 ++--- .../miniboss/bosses/ArcherMiniboss.java | 3 +-- .../nether/miniboss/bosses/GhastMiniboss.java | 23 +++++++++---------- .../miniboss/bosses/WarriorMiniboss.java | 21 ++++++++--------- 5 files changed, 31 insertions(+), 37 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java index 3909e69c5..d93b5ba04 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossManager.java @@ -1,8 +1,8 @@ package mineplex.game.clans.clans.nether.miniboss; -import java.util.Comparator; import java.util.HashMap; import java.util.List; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -29,7 +29,7 @@ public class NetherMinibossManager implements Listener { private static final long MINIBOSS_SPAWN_RATE = 10000; private NetherManager _manager; - private HashMap _spawns = new HashMap<>(); + private Map _spawns = new HashMap<>(); private long _lastSpawned; private boolean _allowSpawn = false; private boolean _allowSpawnEvent = false; @@ -49,16 +49,13 @@ public class NetherMinibossManager implements Listener sort.add(new Location(manager.getNetherWorld(), 43, 134, 22)); sort.add(new Location(manager.getNetherWorld(), 102, 141, -31)); sort.add(new Location(manager.getNetherWorld(), 151, 136, 34)); - sort.sort(new Comparator() + sort.sort((o1, o2) -> { - public int compare(Location o1, Location o2) + if (UtilMath.offset2d(o1, manager.getNetherWorld().getSpawnLocation()) < UtilMath.offset(o2, manager.getNetherWorld().getSpawnLocation())) { - if (UtilMath.offset2d(o1, manager.getNetherWorld().getSpawnLocation()) < UtilMath.offset(o2, manager.getNetherWorld().getSpawnLocation())) - { - return -1; - } - return 1; + return -1; } + return 1; }); for (int i = 0; i < 3; i++) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java index 938810015..3c48b7616 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/NetherMinibossType.java @@ -17,12 +17,12 @@ public enum NetherMinibossType ARCHER("Undead Archer", 25D, EntityType.SKELETON, ArcherMiniboss.class) ; - private Class _code; + private Class> _code; private String _name; private Double _maxHealth; private EntityType _type; - private NetherMinibossType(String name, Double maxHealth, EntityType type, Class code) + private NetherMinibossType(String name, Double maxHealth, EntityType type, Class> code) { _name = name; _maxHealth = maxHealth; @@ -35,7 +35,7 @@ public enum NetherMinibossType * @param spawn The location to spawn the boss in * @return The instance of the miniboss */ - public NetherMiniBoss getNewInstance(Location spawn) + public NetherMiniBoss getNewInstance(Location spawn) { try { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java index 2fc0c29c6..b280f3393 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/ArcherMiniboss.java @@ -1,6 +1,5 @@ package mineplex.game.clans.clans.nether.miniboss.bosses; -import java.util.Arrays; import java.util.Random; import org.bukkit.Location; @@ -38,7 +37,7 @@ public class ArcherMiniboss extends NetherMiniBoss private static final double RUNE_DROP_CHANCE = .02; private static final int MAX_VALUABLE_DROPS = 5; private static final Material[] VALUABLE_DROP_TYPES = new Material[] {Material.DIAMOND, Material.GOLD_INGOT, Material.IRON_INGOT, Material.LEATHER}; - private static final Material[] SET_DROP_TYPES = (Material[])Arrays.asList(Material.values()).stream().filter(t -> t.name().contains("HELMET") || t.name().contains("CHESTPLATE") || t.name().contains("LEGGINGS") || t.name().contains("BOOTS")).toArray(); + private static final Material[] SET_DROP_TYPES = new Material[] {Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS, Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS, Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, Material.CHAINMAIL_HELMET, Material.CHAINMAIL_CHESTPLATE, Material.CHAINMAIL_LEGGINGS, Material.CHAINMAIL_BOOTS, Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS}; private static final double SET_DROP_CHANCE = .02; public ArcherMiniboss(String displayName, Double maxHealth, Location spawn, EntityType type) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java index a6d5a3945..d618923f5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/GhastMiniboss.java @@ -1,18 +1,7 @@ package mineplex.game.clans.clans.nether.miniboss.bosses; -import java.util.Arrays; import java.util.Random; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.amplifiers.AmplifierManager; -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.GameMode; import org.bukkit.Location; import org.bukkit.Material; @@ -24,6 +13,16 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.amplifiers.AmplifierManager; +import mineplex.game.clans.clans.nether.miniboss.MinibossFireball; +import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; +import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; + /** * Class for running an individual Ghast miniboss */ @@ -36,7 +35,7 @@ public class GhastMiniboss extends NetherMiniBoss private static final int MAX_VALUABLE_DROPS = 5; private static final Material[] VALUABLE_DROP_TYPES = new Material[] {Material.DIAMOND, Material.GOLD_INGOT, Material.IRON_INGOT, Material.LEATHER}; private static final double MAX_TARGET_RANGE = 25; - private static final Material[] SET_DROP_TYPES = (Material[])Arrays.asList(Material.values()).stream().filter(t -> t.name().contains("HELMET") || t.name().contains("CHESTPLATE") || t.name().contains("LEGGINGS") || t.name().contains("BOOTS")).toArray(); + private static final Material[] SET_DROP_TYPES = new Material[] {Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS, Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS, Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, Material.CHAINMAIL_HELMET, Material.CHAINMAIL_CHESTPLATE, Material.CHAINMAIL_LEGGINGS, Material.CHAINMAIL_BOOTS, Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS}; private static final double SET_DROP_CHANCE = .02; private long _lastFireballUse; private int _fireballsRemaining; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java index ee0fc199d..d978515d6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/bosses/WarriorMiniboss.java @@ -1,17 +1,7 @@ package mineplex.game.clans.clans.nether.miniboss.bosses; -import java.util.Arrays; import java.util.Random; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilMath; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.amplifiers.AmplifierManager; -import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; -import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -28,6 +18,15 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.amplifiers.AmplifierManager; +import mineplex.game.clans.clans.nether.miniboss.NetherMiniBoss; +import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + /** * Class for running an individual Warrior miniboss */ @@ -36,7 +35,7 @@ public class WarriorMiniboss extends NetherMiniBoss private static final double RUNE_DROP_CHANCE = .02; private static final int MAX_VALUABLE_DROPS = 5; private static final Material[] VALUABLE_DROP_TYPES = new Material[] {Material.DIAMOND, Material.GOLD_INGOT, Material.IRON_INGOT, Material.LEATHER}; - private static final Material[] SET_DROP_TYPES = (Material[])Arrays.asList(Material.values()).stream().filter(t -> t.name().contains("HELMET") || t.name().contains("CHESTPLATE") || t.name().contains("LEGGINGS") || t.name().contains("BOOTS")).toArray(); + private static final Material[] SET_DROP_TYPES = new Material[] {Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS, Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS, Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, Material.CHAINMAIL_HELMET, Material.CHAINMAIL_CHESTPLATE, Material.CHAINMAIL_LEGGINGS, Material.CHAINMAIL_BOOTS, Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS}; private static final double SET_DROP_CHANCE = .02; private static final double LEAP_CHANCE = .9; private static final double LEAP_MIN_DIST = 3; From 21d05b383b63be6df4f8ca5c556aca5e281c132d Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:09:16 -0400 Subject: [PATCH 207/283] Fix skull and string place exploits --- .../src/mineplex/game/clans/clans/ClansBlocks.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBlocks.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBlocks.java index 6a38d402c..fe4755ca0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBlocks.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBlocks.java @@ -78,6 +78,8 @@ public class ClansBlocks denyUsePlace.add(390); //Pot denyUsePlace.add(404); //Comparator denyUsePlace.add(407); //TNT Cart + denyUsePlace.add(287); //String + denyUsePlace.add(397); //Skulls } if (id == 65) From 5829b720a8652cc1e42e4ae61bd22d616efe8228 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:09:34 -0400 Subject: [PATCH 208/283] Update spawn and shop locations for new map --- .../game/clans/clans/ClansManager.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 51a916ac4..b5c293a04 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -437,10 +437,10 @@ public class ClansManager extends MiniClientPluginimplements IRelati new Location(Spawn.getSpawnWorld(), -25, 200, 390), // East Spawn - new Location(Spawn.getSpawnWorld(), 34, 200, -393), - new Location(Spawn.getSpawnWorld(), 8, 200, -365), - new Location(Spawn.getSpawnWorld(), -25, 200, -393), - new Location(Spawn.getSpawnWorld(), 8, 200, -424) + new Location(Spawn.getSpawnWorld(), 34, 206, -393), + new Location(Spawn.getSpawnWorld(), 8, 206, -365), + new Location(Spawn.getSpawnWorld(), -25, 206, -393), + new Location(Spawn.getSpawnWorld(), 8, 206, -424) ); List welcomeHolograms = Arrays.asList( @@ -448,10 +448,10 @@ public class ClansManager extends MiniClientPluginimplements IRelati new Location(Spawn.getSpawnWorld(), 8, 200, 399), new Location(Spawn.getSpawnWorld(), 0, 200, 390), new Location(Spawn.getSpawnWorld(), 8, 200, 381), - new Location(Spawn.getSpawnWorld(), 8, 200, -384), - new Location(Spawn.getSpawnWorld(), 0, 200, -393), - new Location(Spawn.getSpawnWorld(), 8, 200, -402), - new Location(Spawn.getSpawnWorld(), 17, 200, -393) + new Location(Spawn.getSpawnWorld(), 8, 206, -384), + new Location(Spawn.getSpawnWorld(), 0, 206, -393), + new Location(Spawn.getSpawnWorld(), 8, 206, -402), + new Location(Spawn.getSpawnWorld(), 17, 206, -393) ); for (Location location : jumpOffHolograms) @@ -933,7 +933,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati recipients.clear(); } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void disableObsidian(BlockBreakEvent event) { if(event.getBlock().getType().equals(Material.OBSIDIAN)) From 1cdf9d2bba858c51839ae39938433e6f9cc8501f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:10:16 -0400 Subject: [PATCH 209/283] Final season 3 world event tweaks (adds skeleton king) --- .../clans/worldevent/WorldEventManager.java | 36 +- .../clans/worldevent/WorldEventType.java | 66 +-- .../boss/BossArenaLocationFinder.java | 24 +- .../clans/worldevent/boss/BossWorldEvent.java | 23 +- .../worldevent/boss/ironwizard/GolemBoss.java | 5 +- .../boss/ironwizard/GolemCreature.java | 7 +- .../boss/skeletonking/SkeletonBoss.java | 64 +++ .../boss/skeletonking/SkeletonCreature.java | 482 ++++++++++++++++++ .../abilities/SkeletonArcherShield.java | 187 +++++++ .../abilities/SkeletonHellishFlood.java | 119 +++++ .../abilities/SkeletonPassive.java | 120 +++++ .../skeletonking/abilities/SkeletonPulse.java | 108 ++++ .../skeletonking/abilities/SkeletonSmite.java | 104 ++++ .../abilities/SkeletonStrike.java | 167 ++++++ .../abilities/SkeletonWraithSummon.java | 231 +++++++++ .../boss/skeletonking/minion/MinionType.java | 34 ++ .../minion/UndeadArcherCreature.java | 234 +++++++++ .../minion/UndeadWarriorCreature.java | 186 +++++++ .../skeletonking/minion/WraithCreature.java | 190 +++++++ .../worldevent/command/WorldEventCommand.java | 2 +- .../clans/worldevent/raid/RaidAltar.java | 4 +- .../clans/worldevent/raid/RaidManager.java | 12 + .../clans/worldevent/raid/RaidWorldEvent.java | 1 + .../worldevent/raid/wither/WitherRaid.java | 2 +- .../challenge/seven/ChallengeSeven.java | 14 + .../raid/wither/creature/magma/HeatingUp.java | 5 +- .../raid/wither/creature/magma/Magmus.java | 1 + .../creature/magma/MagmusCataclysm.java | 17 +- .../raid/wither/creature/magma/MagmusEat.java | 3 +- .../wither/creature/magma/MagmusMeteor.java | 9 +- .../wither/creature/magma/MagmusSmash.java | 2 +- 31 files changed, 2375 insertions(+), 84 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/SkeletonBoss.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/SkeletonCreature.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonArcherShield.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonHellishFlood.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonPassive.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonPulse.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonSmite.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonStrike.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonWraithSummon.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/MinionType.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/UndeadArcherCreature.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/UndeadWarriorCreature.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/WraithCreature.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index b235e1ba3..032d86c2f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -156,19 +156,25 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement private WorldEventType tryStartEvent() { WorldEventType[] types = WorldEventType.values(); - WorldEventType type = types[_random.nextInt(types.length)]; - Location location = _terrainFinder.findAreaInBorderlands(false); - if (location != null) + if (types.length == 0) { - initializeEvent(type.createInstance(this, location, _skillFactory)); - return type; + return null; } else { - // Try again in 5 minutes - _nextEventStart = System.currentTimeMillis() + (5 * 60 * 1000); + WorldEventType type = types[_random.nextInt(types.length)]; + //Location location = _terrainFinder.findAreaInBorderlands(false); + //if (location != null) + { + initializeEvent(type.createInstance(this)); + return type; + } + //else + //{ + // Try again in 5 minutes + //_nextEventStart = System.currentTimeMillis() + (5 * 60 * 1000); + //} } - return null; } private void initializeEvent(WorldEvent event) @@ -181,13 +187,17 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement event.start(); _runningEvents.add(event); } - - public WorldEvent startEventFromName(Location location, String name) + + public WorldEvent startEventFromName(String name) { WorldEventType eventType = WorldEventType.valueOf(name); if (eventType != null) { - WorldEvent event = eventType.createInstance(this, location, _skillFactory); + WorldEvent event = eventType.createInstance(this); + if (event == null) + { + return null; + } initializeEvent(event); return event; } @@ -199,8 +209,8 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement { if (eventType != null) { - Location location = _terrainFinder.findAreaInBorderlands(true); - WorldEvent event = eventType.createInstance(this, location, _skillFactory); + //Location location = _terrainFinder.findAreaInBorderlands(true); + WorldEvent event = eventType.createInstance(this); if (event != null) { initializeEvent(event); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java index 6ada84c5e..2580c7a9e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventType.java @@ -1,11 +1,8 @@ package mineplex.game.clans.clans.worldevent; -import java.lang.reflect.Constructor; - -import org.bukkit.Location; - import mineplex.game.clans.clans.worldevent.api.WorldEvent; -import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.game.clans.clans.worldevent.boss.ironwizard.GolemBoss; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.SkeletonBoss; public enum WorldEventType { @@ -15,58 +12,34 @@ public enum WorldEventType //IRON_WIZARD("Iron Wizard", GolemBoss.class, 30), //BROOD_MOTHER("Brood Mother", SpiderBoss.class, 30), //SKELETON_KING("Skeleton King", SkeletonBoss.class, 30) + IRON_WIZARD("Iron Wizard", GolemBoss.class, (man) -> + { + return new GolemBoss(man); + }), + SKELETON_KING("Skeleton King", SkeletonBoss.class, (man) -> + { + return new SkeletonBoss(man); + }) ; private String _name; private Class _clazz; - private int _areaNeeded; + private EventCreator _creator; - WorldEventType(String name, Class clazz, int areaNeeded) + WorldEventType(String name, Class clazz, EventCreator creator) { _name = name; _clazz = clazz; - _areaNeeded = areaNeeded; + _creator = creator; } - public int getAreaNeeded() - { - return _areaNeeded; - } - - public WorldEvent createInstance(WorldEventManager eventManager, Location centerLocation, SkillFactory skillFactory) + public WorldEvent createInstance(WorldEventManager eventManager) { WorldEvent worldEvent = null; - try + if (_creator != null) { - for (Constructor con : _clazz.getConstructors()) - { - Class[] classes = con.getParameterTypes(); - - if (classes[0] == WorldEventManager.class) - { - if (classes.length == 3) - { - worldEvent = (WorldEvent) con.newInstance(eventManager, centerLocation, skillFactory); - } - else - { - worldEvent = (WorldEvent) con.newInstance(eventManager, centerLocation); - } - } - else if (classes.length == 4) - { - worldEvent = (WorldEvent) con.newInstance(eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), centerLocation); - } - else - { - worldEvent = (WorldEvent) con.newInstance(eventManager.getDisguiseManager(), eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), eventManager.getClans().getProjectile(), centerLocation); - } - } - } - catch (Exception e) - { - e.printStackTrace(); + worldEvent = _creator.createEvent(eventManager); } return worldEvent; @@ -74,6 +47,11 @@ public enum WorldEventType public String getName() { - return this._name; + return _name; + } + + private static interface EventCreator + { + WorldEvent createEvent(WorldEventManager manager); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossArenaLocationFinder.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossArenaLocationFinder.java index 2ed0146e7..a4c6bbc62 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossArenaLocationFinder.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossArenaLocationFinder.java @@ -20,7 +20,7 @@ public class BossArenaLocationFinder public Location getIronWizardCenter() { - return new Location(_world, 0, 0, 0); + return new Location(_world, 1057, 63, -77); } public Pair, List> getIronWizardPads() @@ -28,12 +28,22 @@ public class BossArenaLocationFinder List in = new ArrayList<>(); List out = new ArrayList<>(); + in.add(new Vector(1006, 62, -77)); + in.add(new Vector(1057, 62, -26)); + in.add(new Vector(1108, 62, -77)); + in.add(new Vector(1057, 62, -128)); + + out.add(new Vector(1035, 63, -77)); + out.add(new Vector(1057, 63, -99)); + out.add(new Vector(1079, 63, -77)); + out.add(new Vector(1057, 63, -55)); + return Pair.create(in, out); } public Location getSkeletonKingCenter() { - return new Location(_world, 0, 0, 0); + return new Location(_world, -1043, 58, 159); } public Pair, List> getSkeletonKingPads() @@ -41,6 +51,16 @@ public class BossArenaLocationFinder List in = new ArrayList<>(); List out = new ArrayList<>(); + in.add(new Vector(-1094, 57, 159)); + in.add(new Vector(-1043, 57, 210)); + in.add(new Vector(-992, 57, 159)); + in.add(new Vector(-1043, 57, 108)); + + out.add(new Vector(-1021, 58, 159)); + out.add(new Vector(-1043, 58, 137)); + out.add(new Vector(-1065, 58, 159)); + out.add(new Vector(-1043, 58, 181)); + return Pair.create(in, out); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java index dd34361c2..2d872d9f0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java @@ -5,14 +5,18 @@ import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.util.Vector; import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.DisguiseManager; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.projectile.ProjectileManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -21,6 +25,8 @@ import mineplex.game.clans.clans.worldevent.api.EventCreature; import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; import mineplex.game.clans.clans.worldevent.api.EventState; import mineplex.game.clans.clans.worldevent.api.WorldEvent; +import mineplex.minecraft.game.classcombat.Skill.ISkill; +import mineplex.minecraft.game.classcombat.Skill.Assassin.Recall; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; @@ -38,7 +44,7 @@ public abstract class BossWorldEvent> extends WorldEv super(name, centerLocation, radius, true, disguiseManager, projectileManager, damageManager, blockRestore, conditionManager); _teleportFrom = teleportFrom.stream().map(vec -> vec.toLocation(centerLocation.getWorld())).collect(Collectors.toList()); - _teleportTo = teleportFrom.stream().map(vec -> vec.toLocation(centerLocation.getWorld())).collect(Collectors.toList()); + _teleportTo = teleportTo.stream().map(vec -> vec.toLocation(centerLocation.getWorld())).collect(Collectors.toList()); } public abstract String getDeathMessage(); @@ -72,7 +78,14 @@ public abstract class BossWorldEvent> extends WorldEv { for (Player player : UtilPlayer.getInRadius(from, TELEPORT_PAD_RANGE).keySet()) { - player.teleport(_teleportTo.get(getRandom().nextInt(_teleportTo.size()))); + player.teleport(UtilMath.randomElement(_teleportTo)); + for (ISkill skill : ClansManager.getInstance().getClassManager().Get(player).GetSkills()) + { + if (skill instanceof Recall) + { + ((Recall)skill).Reset(player); + } + } sendMessage(player, "You have teleported inside the arena!"); } } @@ -89,7 +102,11 @@ public abstract class BossWorldEvent> extends WorldEv { Location drop = event.getCreature().getLastKnownLocation(); UtilServer.CallEvent(new BossDeathEvent(this, drop)); - ClansManager.getInstance().runSyncLater(() -> ClansManager.getInstance().getLootManager().dropRare(drop), DELAY_TILL_DROP_REWARD); + ClansManager.getInstance().runSyncLater(() -> + { + ClansManager.getInstance().getLootManager().dropRare(drop); + drop.getWorld().dropItem(drop, new ItemBuilder(Material.IRON_INGOT).setTitle(C.cDRedB + "Old Silver Token").setLore(C.cRed + "This token pulses with an evil aura.").setGlow(true).build()); + }, DELAY_TILL_DROP_REWARD); Bukkit.broadcastMessage(getDeathMessage()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java index cf729c0ea..2d79eea2d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java @@ -11,7 +11,7 @@ public class GolemBoss extends BossWorldEvent { public GolemBoss(WorldEventManager manager) { - super("Iron Wizard", manager.getBossArenaLocationFinder().getIronWizardCenter(), 30, manager.getBossArenaLocationFinder().getIronWizardPads().getLeft(), manager.getBossArenaLocationFinder().getIronWizardPads().getRight(), manager.getDisguiseManager(), manager.getClans().getProjectile(), manager.getClans().getDamageManager(), manager.getBlockRestore(), manager.getClans().getCondition()); + super("Iron Wizard", manager.getBossArenaLocationFinder().getIronWizardCenter(), 50, manager.getBossArenaLocationFinder().getIronWizardPads().getLeft(), manager.getBossArenaLocationFinder().getIronWizardPads().getRight(), manager.getDisguiseManager(), manager.getClans().getProjectile(), manager.getClans().getDamageManager(), manager.getBlockRestore(), manager.getClans().getCondition()); } @Override @@ -19,7 +19,6 @@ public class GolemBoss extends BossWorldEvent { Bukkit.broadcastMessage(F.main(getName(), "The mighty " + getName() + " challenges you to face him!")); spawnGolem(getCenterLocation()); - announceStart(); } @Override @@ -30,7 +29,7 @@ public class GolemBoss extends BossWorldEvent private GolemCreature spawnGolem(Location location) { - GolemCreature golemCreature = new GolemCreature(this, location, 3000); + GolemCreature golemCreature = new GolemCreature(this, location); registerCreature(golemCreature); setBossCreature(golemCreature); return golemCreature; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemCreature.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemCreature.java index 540c7cea0..216ede265 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemCreature.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemCreature.java @@ -59,7 +59,7 @@ public class GolemCreature extends EventCreature private Vector _afkWalk = new Vector(); private long _lastSlam; - public GolemCreature(GolemBoss boss, Location location, double maxHealth) + public GolemCreature(GolemBoss boss, Location location) { super(boss, location, "Iron Wizard", true, 3000, 30, true, IronGolem.class); @@ -146,7 +146,10 @@ public class GolemCreature extends EventCreature _lastAbility = 20; HandlerList.unregisterAll(ability); - System.out.print("Unregistered golem ability " + ability.getClass().getSimpleName()); + if (DEBUG_MODE) + { + System.out.print("Unregistered golem ability " + ability.getClass().getSimpleName()); + } } else if (!ability.inProgress()) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/SkeletonBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/SkeletonBoss.java new file mode 100644 index 000000000..5c633262b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/SkeletonBoss.java @@ -0,0 +1,64 @@ +package mineplex.game.clans.clans.worldevent.boss.skeletonking; + +import org.bukkit.Bukkit; +import org.bukkit.Location; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilServer; +import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.boss.BossWorldEvent; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.minion.MinionType; + +public class SkeletonBoss extends BossWorldEvent +{ + protected boolean canMove = false; + + public SkeletonBoss(WorldEventManager manager) + { + super("Skeleton King", manager.getBossArenaLocationFinder().getIronWizardCenter(), 50, manager.getBossArenaLocationFinder().getIronWizardPads().getLeft(), manager.getBossArenaLocationFinder().getIronWizardPads().getRight(), manager.getDisguiseManager(), manager.getClans().getProjectile(), manager.getClans().getDamageManager(), manager.getBlockRestore(), manager.getClans().getCondition()); + } + + @Override + protected void customStart() + { + Bukkit.broadcastMessage(F.main(getName(), "The evils of the world have manifested in the form of the " + getName() + "! Become the champion of Light and destroy him!")); + spawnNecromancer(getCenterLocation()); + Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () -> + { + canMove = true; + }, 20 * 3); + } + + public EventCreature spawnMinion(MinionType type, Location location) + { + EventCreature minionCreature = type.getNewInstance(this, location); + if (minionCreature != null) + { + registerCreature(minionCreature); + } + return minionCreature; + } + + private SkeletonCreature spawnNecromancer(Location location) + { + SkeletonCreature necromancerCreature = new SkeletonCreature(this, location); + registerCreature(necromancerCreature); + return necromancerCreature; + } + + @Override + public String getDeathMessage() + { + return F.main(getName(), "The demonic " + getName() + " has been slain!"); + } + + @Override + protected void customTick() {} + + @Override + public void customCleanup(boolean onDisable) {} + + @Override + protected void customStop() {} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/SkeletonCreature.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/SkeletonCreature.java new file mode 100644 index 000000000..be6ae17e4 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/SkeletonCreature.java @@ -0,0 +1,482 @@ +package mineplex.game.clans.clans.worldevent.boss.skeletonking; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Random; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +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.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.abilities.SkeletonArcherShield; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.abilities.SkeletonPassive; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.abilities.SkeletonPulse; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.abilities.SkeletonSmite; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.abilities.SkeletonStrike; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.abilities.SkeletonWraithSummon; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.minion.UndeadArcherCreature; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.minion.UndeadWarriorCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class SkeletonCreature extends EventCreature +{ + private List> _currentAbilities = new ArrayList<>(); + private SkeletonPassive _passive; + private int _lastAbility; + private Map, Long> _cooldowns = new HashMap<>(); + private LinkedList _wraithTriggers = new LinkedList<>(); + private List _movePoints = new ArrayList<>(); + private Location _movingTo; + private boolean _moving; + private long _lastMoved; + private long _lastUsedPassive; + public List Archers = new ArrayList<>(); + public List Warriors = new ArrayList<>(); + + public SkeletonCreature(SkeletonBoss boss, Location location) + { + super(boss, location, "Skeleton King", true, 2500, 30, true, Skeleton.class); + + spawnEntity(); + _passive = new SkeletonPassive(this); + _wraithTriggers.add(1500D); + _wraithTriggers.add(1000D); + _wraithTriggers.add(500D); + _wraithTriggers.add(100D); + getEntity().getWorld().setThunderDuration(10000000); + getEntity().getWorld().setThundering(true); + } + + @Override + protected void spawnCustom() + { + UtilEnt.vegetate(getEntity()); + getEntity().setSkeletonType(SkeletonType.WITHER); + getEntity().getEquipment().setItemInHand(new ItemStack(Material.RECORD_6)); //Meridian Scepter + getEntity().getEquipment().setItemInHandDropChance(0.f); + } + + @Override + public void dieCustom() + { + HandlerList.unregisterAll(_passive); + _passive = null; + endAbility(); + getEntity().getWorld().setThunderDuration(0); + getEntity().getWorld().setThundering(false); + } + + private void endAbility() + { + for (BossAbility ability : _currentAbilities) + { + ability.setFinished(); + HandlerList.unregisterAll(ability); + } + + _currentAbilities.clear(); + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_passive != null && ((SkeletonBoss)getEvent()).canMove) + { + if (UtilTime.elapsed(_lastUsedPassive, _passive.getCooldown() * 20) || _passive.isProgressing()) + { + _lastUsedPassive = System.currentTimeMillis(); + _passive.tick(); + } + } + + Iterator> itel = _currentAbilities.iterator(); + boolean canDoNew = _currentAbilities.size() < 3; + + while (itel.hasNext()) + { + BossAbility ability = itel.next(); + + if (ability.hasFinished()) + { + itel.remove(); + ability.setFinished(); + _lastAbility = 20;// _currentAbility.getCooldown(); + + HandlerList.unregisterAll(ability); + if (DEBUG_MODE) + { + System.out.print("Unregistered necromancer ability " + ability.getClass().getSimpleName()); + } + + _cooldowns.put(ability.getClass(), System.currentTimeMillis() + (ability.getCooldown() * 1000)); + } + else if (ability.inProgress()) + { + canDoNew = false; + _lastAbility = 20;// _currentAbility.getCooldown(); + } + } + + if (_lastAbility-- <= 0 && canDoNew && UtilBlock.solid(getEntity().getLocation().getBlock().getRelative(BlockFace.DOWN))) + { + Map>, Integer> weight = new HashMap<>(); + Map dist = new HashMap<>(); + + for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true)) + { + if (player.hasLineOfSight(getEntity())) + { + dist.put(player, player.getLocation().distance(getEntity().getLocation())); + } + } + + if (!dist.isEmpty()) + { + {// Pulse & Strike + List players = getPlayers(dist, UtilMath.r(10) == 0 ? 25 : 20); + List near = getPlayers(dist, 5); + + if (!players.isEmpty()) + { + if (!near.isEmpty() && near.size() >= 4 && new Random().nextDouble() <= .45) + { + weight.put(SkeletonPulse.class, 999); + } + else + { + weight.put(SkeletonStrike.class, 6); + } + } + } + {// Smite + List players = getPlayers(dist, 15); + + if (!players.isEmpty()) + { + weight.put(SkeletonSmite.class, 6); + } + } + {//Archer Shield + List players = getPlayers(dist, 20); + double score = 0; + for (Player player : players) + { + score += (18 - dist.get(player)) / 2; + } + if (players.size() >= 4) + { + score += 17; + } + if (score > 0) + { + weight.put(SkeletonArcherShield.class, (int) Math.ceil(score)); + } + } + Double wraithUse = null; + for (Double test : _wraithTriggers) + { + if (wraithUse == null) + { + if (getHealth() <= test) + { + wraithUse = test; + break; + } + } + } + if (wraithUse != null) + {// Wraith Summon + _wraithTriggers.remove(wraithUse); + weight.clear(); + weight.put(SkeletonWraithSummon.class, 999); + } + } + + for (BossAbility ability : _currentAbilities) + { + weight.remove(ability.getClass()); + } + + for (Class c : _cooldowns.keySet()) + { + if (_cooldowns.get(c) > System.currentTimeMillis()) + { + weight.remove(c); + } + } + + if (_moving) + { + Iterator>> trying = weight.keySet().iterator(); + while (trying.hasNext()) + { + Class> abilityClass = trying.next(); + + try + { + BossAbility ability = abilityClass.newInstance(); + if (!ability.canMove()) + { + trying.remove(); + } + } + catch (Exception e) {} + } + } + + BossAbility ability = null; + + if (!weight.isEmpty()) + { + int i = 0; + + for (Integer entry : weight.values()) + { + i += entry; + } + + loop: for (int a = 0; a < 10; a++) + { + int luckyNumber = UtilMath.r(i); + + for (Entry>, Integer> entry : weight.entrySet()) + { + luckyNumber -= entry.getValue(); + + if (luckyNumber <= 0) + { + try + { + ability = entry.getKey().getConstructor(SkeletonCreature.class).newInstance(this); + + if (ability.getTarget() == null || ability.hasFinished()) + { + ability = null; + } + else + { + break loop; + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + break; + } + } + } + } + + if (ability != null && ability.getTarget() != null) + { + + Bukkit.getPluginManager().registerEvents(ability, UtilServer.getPlugin()); + + if (DEBUG_MODE) + { + System.out.print("Necromancer is using " + ability.getClass().getSimpleName()); + } + + _currentAbilities.add(ability); + } + + _lastAbility = 10; + } + + for (BossAbility ability : _currentAbilities) + { + try + { + ability.tick(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + boolean canMove = true; + for (BossAbility ability : _currentAbilities) + { + if (!ability.canMove()) + { + canMove = false; + } + } + if (!((SkeletonBoss)getEvent()).canMove) + { + return; + } + + if (_moving) + { + if (_movingTo == null) + { + _movingTo = selectWalkTarget(); + } + if (UtilMath.offset(getEntity().getLocation(), _movingTo) <= 1.3) + { + _lastMoved = System.currentTimeMillis(); + _movingTo = null; + _moving = false; + return; + } + UtilEnt.LookAt(getEntity(), _movingTo); + Vector walk = UtilAlg.getTrajectory(getEntity().getLocation(), _movingTo); + walk.multiply(walk.length()); + walk.multiply(.2); + getEntity().setVelocity(walk); + } + else + { + if (!UtilTime.elapsed(_lastMoved, 7000) || !canMove) + { + return; + } + _movingTo = selectWalkTarget(); + _moving = true; + } + } + + private Location selectWalkTarget() + { + if (_movePoints.isEmpty()) + { + Location base = getSpawnLocation().clone(); + base.setY(getEntity().getLocation().getY()); + generateWalkPoints(base); + } + Location selected = _movePoints.get(new Random().nextInt(_movePoints.size())); + _movePoints.remove(selected); + + return selected; + } + + private void generateWalkPoints(Location base) + { + _movePoints.add(base.clone().add(5 + UtilMath.random(1, 3), 0, 5 + UtilMath.random(1, 3))); + _movePoints.add(base.clone().add(-5 + UtilMath.random(1, 3), 0, 5 + UtilMath.random(1, 3))); + _movePoints.add(base.clone().add(5 + UtilMath.random(1, 3), 0, -5 + UtilMath.random(1, 3))); + _movePoints.add(base.clone().add(-5 + UtilMath.random(1, 3), 0, -5 + UtilMath.random(1, 3))); + } + + private List getPlayers(Map map, double maxDist) + { + return getPlayers(map, 0, maxDist); + } + + private List getPlayers(final Map map, double minDist, double maxDist) + { + List list = new ArrayList<>(); + + for (Player p : map.keySet()) + { + if (map.get(p) >= minDist && map.get(p) <= maxDist) + { + list.add(p); + } + } + + Collections.sort(list, (o1, o2) -> + { + return Double.compare(map.get(o2), map.get(o1)); + }); + + return list; + } + + @EventHandler + public void onSkeletonDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + event.SetKnockback(false); + } + } + + @EventHandler + public void noFallDamage(CustomDamageEvent event) + { + if (getEntity() == null) + { + return; + } + + if (event.GetDamageeEntity().getEntityId() != getEntity().getEntityId()) + { + return; + } + + DamageCause cause = event.GetCause(); + + if (cause == DamageCause.FALL) + { + event.SetCancelled("Boss Invulnerability"); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonArcherShield.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonArcherShield.java new file mode 100644 index 000000000..c4eadb5d4 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonArcherShield.java @@ -0,0 +1,187 @@ +package mineplex.game.clans.clans.worldevent.boss.skeletonking.abilities; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSkeleton; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +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.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.SkeletonCreature; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.minion.UndeadArcherCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class SkeletonArcherShield extends BossAbility +{ + private static long ATTACK_DURATION = 10000; + private static long ARROW_DELAY = 100; + private static long ARROW_WARMUP = 2000; + private static double PULL_RANGE = 12; + private long _start; + private long _lastShoot; + private boolean _teleported; + + public SkeletonArcherShield(SkeletonCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + } + + @Override + public int getCooldown() + { + return 20; + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, ATTACK_DURATION); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - ATTACK_DURATION; + for (UndeadArcherCreature creature : getBoss().Archers) + { + creature.getEntity().remove(); + } + } + + private void run(boolean initial) + { + for (int i = 0; i < getBoss().Archers.size(); i++) + { + Skeleton archer = getBoss().Archers.get(i).getEntity(); + UtilEnt.vegetate(archer); + ((CraftSkeleton)archer).setVegetated(false); + + double lead = i * ((2d * Math.PI)/getBoss().Archers.size()); + + double sizeMod = 2; + + //Orbit + double speed = 10d; + double oX = -Math.sin(getEntity().getTicksLived()/speed + lead) * 2 * sizeMod; + double oY = 0; + double oZ = Math.cos(getEntity().getTicksLived()/speed + lead) * 2 * sizeMod; + + if (initial) + { + archer.teleport(getEntity().getLocation().add(oX, oY, oZ)); + UtilEnt.vegetate(archer); + } + else + { + Location to = getEntity().getLocation().add(oX, oY, oZ); + UtilEnt.LookAt(archer, to); + UtilAction.velocity(archer, UtilAlg.getTrajectory(archer.getLocation(), to), 0.4, false, 0, 0.1, 1, true); + } + } + } + + private void shoot() + { + if (UtilTime.elapsed(_start, ARROW_WARMUP) && UtilTime.elapsed(_lastShoot, ARROW_DELAY)) + { + _lastShoot = System.currentTimeMillis(); + for (UndeadArcherCreature archer : getBoss().Archers) + { + Location spawn = archer.getEntity().getEyeLocation().add(UtilAlg.getTrajectory(getEntity().getEyeLocation(), archer.getEntity().getEyeLocation()).normalize()); + Vector vector = UtilAlg.getTrajectory(getEntity().getEyeLocation(), spawn); + Arrow arrow = archer.getEntity().getWorld().spawnArrow(spawn, vector, 0.6f, 12f); + arrow.setMetadata("SHIELD_SHOT", new FixedMetadataValue(UtilServer.getPlugin(), true)); + arrow.setMetadata("BARBED_ARROW", new FixedMetadataValue(UtilServer.getPlugin(), 10)); + arrow.setShooter(archer.getEntity()); + } + } + } + + @Override + public void tick() + { + if (!_teleported) + { + run(true); + _teleported = true; + for (Player near : UtilPlayer.getInRadius(getEntity().getLocation(), PULL_RANGE).keySet()) + { + Vector velocity = UtilAlg.getTrajectory(near, getEntity()); + UtilAction.velocity(near, velocity, 2, false, 0, 0, 1, true); + near.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 5 * 20, -2)); + for (int i = 0; i < 6; i++) + { + Vector random = new Vector(Math.random() * 4 - 2, Math.random() * 4 - 2, Math.random() * 4 - 2); + + Location origin = getEntity().getLocation().add(0, 1.3, 0); + origin.add(velocity.clone().multiply(10)); + origin.add(random); + + Vector vel = UtilAlg.getTrajectory(origin, getEntity().getLocation().add(0, 1.3, 0)); + vel.multiply(7); + + UtilParticle.PlayParticleToAll(ParticleType.MAGIC_CRIT, origin, (float)vel.getX(), (float)vel.getY(), (float)vel.getZ(), 1, 0, ViewDist.LONG); + } + } + } + else + { + run(false); + shoot(); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(getBoss().getEntity())) + { + if (!hasFinished()) + { + event.SetCancelled("Wraiths Alive"); + } + } + } + + @EventHandler + public void onArrowHit(ProjectileHitEvent event) + { + if (event.getEntity().hasMetadata("SHIELD_SHOT")) + { + Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () -> + { + event.getEntity().remove(); + }, 20L); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonHellishFlood.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonHellishFlood.java new file mode 100644 index 000000000..794e75ada --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonHellishFlood.java @@ -0,0 +1,119 @@ +package mineplex.game.clans.clans.worldevent.boss.skeletonking.abilities; + +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +import org.bukkit.Location; +import org.bukkit.entity.Skeleton; + +import mineplex.core.common.util.UtilMath; +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.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.SkeletonBoss; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.SkeletonCreature; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.minion.MinionType; + +public class SkeletonHellishFlood extends BossAbility +{ + private static final int WAVE_COUNT = 3; + private static final int WAVE_SIZE = 5; + private static final MinionType[] POSSIBLE_MINIONS = new MinionType[] {MinionType.WARRIOR, MinionType.ARCHER}; + private static final long WAVE_DELAY = 1000; + + private Map _waves = new HashMap<>(); + private long _lastSpawned; + private int _current; + private int _ticks; + + public SkeletonHellishFlood(SkeletonCreature creature) + { + super(creature); + + if (WAVE_COUNT > 0) + { + for (int i = 1; i <= WAVE_COUNT; i++) + { + createWave(i); + } + } + _lastSpawned = System.currentTimeMillis(); + _current = 1; + } + + private void createWave(int number) + { + int length = POSSIBLE_MINIONS.length; + if (length <= 0 || WAVE_SIZE <= 0) + { + return; + } + MinionType[] wave = new MinionType[WAVE_SIZE]; + for (int i = 0; i < WAVE_SIZE; i++) + { + wave[i] = POSSIBLE_MINIONS[new Random().nextInt(length)]; + } + _waves.put("Wave " + number, wave); + } + + @Override + public int getCooldown() + { + return 30; + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return _waves.isEmpty() && _ticks > ((WAVE_DELAY / 1000) * 20 * (WAVE_COUNT - 1)); + } + + @Override + public void setFinished() + { + _waves.clear(); + _ticks = 60; + } + + @Override + public void tick() + { + _ticks++; + if (UtilTime.elapsed(_lastSpawned, WAVE_DELAY)) + { + if (_current <= WAVE_COUNT) + { + for (MinionType type : _waves.get("Wave " + _current)) + { + Location toSpawn = getLocation().clone(); + toSpawn.add(UtilMath.random(3, 6), 0, UtilMath.random(3, 6)); + + ((SkeletonBoss)getBoss().getEvent()).spawnMinion(type, toSpawn); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, toSpawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, toSpawn, null, 0, 2, ViewDist.MAX); + } + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + _waves.remove("Wave " + _current); + _current++; + _lastSpawned = System.currentTimeMillis(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonPassive.java new file mode 100644 index 000000000..20c542b2c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonPassive.java @@ -0,0 +1,120 @@ +package mineplex.game.clans.clans.worldevent.boss.skeletonking.abilities; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.UtilMath; +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.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.SkeletonBoss; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.SkeletonCreature; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.minion.MinionType; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.minion.UndeadArcherCreature; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.minion.UndeadWarriorCreature; + +public class SkeletonPassive extends BossPassive +{ + private static final int MAX_ARCHERS = 10; + private static final int MAX_WARRIORS = 8; + private static final long SPAWN_RATE = 5000; + private List _queuedArchers = new ArrayList<>(); + private List _queuedWarriors = new ArrayList<>(); + private long _lastASpawned; + private long _lastWSpawned; + + public SkeletonPassive(SkeletonCreature creature) + { + super(creature); + } + + @Override + public int getCooldown() + { + return 20; + } + + @Override + public boolean isProgressing() + { + return !_queuedArchers.isEmpty() || !_queuedWarriors.isEmpty(); + } + + @Override + public void tick() + { + if (getBoss().Archers.size() < MAX_ARCHERS && _queuedArchers.isEmpty()) + { + for (int i = 0; i < (MAX_ARCHERS - getBoss().Archers.size()); i++) + { + Location spawn = getLocation().clone(); + spawn.add(UtilMath.random(3, 6), 0, UtilMath.random(3, 6)); + _queuedArchers.add(spawn); + } + } + if (getBoss().Warriors.size() < MAX_WARRIORS && _queuedWarriors.isEmpty()) + { + for (int i = 0; i < (MAX_WARRIORS - getBoss().Warriors.size()); i++) + { + Location spawn = getLocation().clone(); + spawn.add(UtilMath.random(3, 6), 0, UtilMath.random(3, 6)); + _queuedWarriors.add(spawn); + } + } + + for (Location animate : _queuedArchers) + { + UtilParticle.PlayParticleToAll(ParticleType.BLOCK_DUST.getParticle(Material.DIRT, 0), + animate.clone().add(0, 0.2, 0), null, 0, 4, ViewDist.NORMAL); + } + for (Location animate : _queuedWarriors) + { + UtilParticle.PlayParticleToAll(ParticleType.BLOCK_DUST.getParticle(Material.DIRT, 0), + animate.clone().add(0, 0.2, 0), null, 0, 4, ViewDist.NORMAL); + } + + if (!_queuedArchers.isEmpty() && UtilTime.elapsed(_lastASpawned, SPAWN_RATE)) + { + _lastASpawned = System.currentTimeMillis(); + Location spawn = _queuedArchers.remove(0); + getBoss().Archers.add((UndeadArcherCreature) ((SkeletonBoss)getBoss().getEvent()).spawnMinion(MinionType.ARCHER, spawn)); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + } + if (!_queuedWarriors.isEmpty() && UtilTime.elapsed(_lastWSpawned, SPAWN_RATE)) + { + _lastWSpawned = System.currentTimeMillis(); + Location spawn = _queuedWarriors.remove(0); + getBoss().Warriors.add((UndeadWarriorCreature) ((SkeletonBoss)getBoss().getEvent()).spawnMinion(MinionType.WARRIOR, spawn)); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + } + } + + @EventHandler + public void onArcherDeath(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof UndeadArcherCreature) + { + getBoss().Archers.remove(event.getCreature()); + } + if (event.getCreature() instanceof UndeadWarriorCreature) + { + getBoss().Warriors.remove(event.getCreature()); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonPulse.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonPulse.java new file mode 100644 index 000000000..db28e1493 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonPulse.java @@ -0,0 +1,108 @@ +package mineplex.game.clans.clans.worldevent.boss.skeletonking.abilities; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +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.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.SkeletonCreature; + +public class SkeletonPulse extends BossAbility +{ + private static final long TOTAL_ATTACK_DURATION = 8000; + private static final long TOTAL_ATTACK_PROGRESS = 3000; + private long _start, _lastIncrement; + private int _radius; + private Location _center; + + public SkeletonPulse(SkeletonCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + _radius = 2; + _lastIncrement = System.currentTimeMillis(); + _center = creature.getEntity().getLocation(); + } + + private int getRadius() + { + return Math.min(8, _radius); + } + + @Override + public int getCooldown() + { + return 7; + } + + @Override + public boolean canMove() + { + return UtilTime.elapsed(_start, TOTAL_ATTACK_PROGRESS); + } + + @Override + public boolean inProgress() + { + return UtilTime.elapsed(_start, TOTAL_ATTACK_PROGRESS); + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, TOTAL_ATTACK_DURATION); + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - TOTAL_ATTACK_DURATION; + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastIncrement, 500)) + { + _lastIncrement = System.currentTimeMillis(); + _radius++; + } + + for (double token = 0; token <= (2 * Math.PI); token += .2) + { + double x = getRadius() * Math.cos(token); + double z = getRadius() * Math.sin(token); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, _center.clone().add(x, 1.5, z), null, 0, 1, ViewDist.MAX); + } + + for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), getRadius()).keySet()) + { + if (player.isDead() || !player.isValid() || !player.isOnline()) + { + continue; + } + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + if (!Recharge.Instance.use(player, "Pulse Knockback", 400, false, false, false)) + { + continue; + } + + player.playSound(player.getLocation(), Sound.AMBIENCE_THUNDER, 1f, 1f); + UtilAction.velocity(player, UtilAlg.getTrajectory2d(getEntity(), player), 2, false, 0.6, 0, 1.4, true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonSmite.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonSmite.java new file mode 100644 index 000000000..fc1a23de3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonSmite.java @@ -0,0 +1,104 @@ +package mineplex.game.clans.clans.worldevent.boss.skeletonking.abilities; + +import java.math.BigDecimal; + +import org.bukkit.GameMode; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +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.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.SkeletonCreature; + +public class SkeletonSmite extends BossAbility +{ + private static final long TOTAL_ATTACK_DURATION = 8000; + private long _start; + private int _ticks; + private boolean _shot; + + public SkeletonSmite(SkeletonCreature creature) + { + super(creature); + _start = System.currentTimeMillis(); + _ticks = 0; + _shot = false; + } + + @Override + public int getCooldown() + { + return 15; + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return UtilTime.elapsed(_start, TOTAL_ATTACK_DURATION) && _shot; + } + + @Override + public void setFinished() + { + _start = System.currentTimeMillis() - TOTAL_ATTACK_DURATION; + _shot = true; + } + + @Override + public void tick() + { + if (_shot) + return; + + if (_ticks < (6 * 20)) + { + _ticks++; + double maxHeight = Math.min(_ticks / 20, 6); + int radius = Math.max(6 - (new BigDecimal(_ticks).divide(new BigDecimal(20)).intValue()), 0); + + for (double y = 0; y < maxHeight; y += 0.5) + { + double cos = radius * Math.cos(y); + double sin = radius * Math.sin(y); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation().add(cos, y, sin), null, 0, 1, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation().add(sin, y, cos), null, 0, 1, ViewDist.MAX); + } + } + else + { + _shot = true; + for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), 15).keySet()) + { + if (player.isDead() || !player.isValid() || !player.isOnline()) + { + continue; + } + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + player.getWorld().strikeLightningEffect(player.getLocation()); + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, DamageCause.LIGHTNING, 15 * getBoss().getDifficulty(), false, true, false, getEntity().getName(), "Lightning Strike"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonStrike.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonStrike.java new file mode 100644 index 000000000..b8588d0b5 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonStrike.java @@ -0,0 +1,167 @@ +package mineplex.game.clans.clans.worldevent.boss.skeletonking.abilities; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +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.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.SkeletonCreature; + +public class SkeletonStrike extends BossAbility +{ + private static final double MAX_RANGE = 25; + private static final Integer MAX_TARGETS = 1; + private boolean _shot; + + public SkeletonStrike(SkeletonCreature creature) + { + super(creature); + _shot = false; + } + + private int getPosition(Player toAdd, LinkedList ordered) + { + int position = ordered.size(); + int index = 0; + for (Player player : ordered) + { + if (player.getHealth() < toAdd.getHealth()) + { + position = index; + return position; + } + index++; + } + + return position; + } + + private List getTargets() + { + Skeleton necromancer = getBoss().getEntity(); + LinkedList selections = new LinkedList<>(); + List targeted = new ArrayList<>(); + + Map near = UtilPlayer.getInRadius(necromancer.getLocation(), MAX_RANGE); + + for (Player nearby : near.keySet()) + { + if (nearby.getGameMode() == GameMode.CREATIVE || nearby.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + if (selections.isEmpty()) + { + selections.addFirst(nearby); + } + else + { + selections.add(getPosition(nearby, selections), nearby); + } + } + + for (int i = 0; i < MAX_TARGETS; i++) + { + if (i < selections.size()) + { + targeted.add(selections.get(i)); + } + } + + return targeted; + } + + private void shootAt(Player target) + { + double curRange = 0; + boolean canHit = false; + + while (curRange <= MAX_RANGE) + { + Location newTarget = getEntity().getEyeLocation().add(UtilAlg.getTrajectory(getEntity(), target).multiply(curRange)); + + if (!UtilBlock.airFoliage(newTarget.getBlock())) + { + canHit = false; + break; + } + if (UtilMath.offset(newTarget, target.getLocation()) <= 0.9) + { + canHit = true; + break; + } + + curRange += 0.2; + + UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, newTarget, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); + + canHit = true; + } + + if (canHit) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.CUSTOM, 12 * getBoss().getDifficulty(), true, true, false, getEntity().getName(), "Mystical Energy"); + } + } + + @Override + public int getCooldown() + { + return 15; + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return _shot; + } + + @Override + public void setFinished() + { + _shot = true; + } + + @Override + public void tick() + { + if (_shot) + return; + + _shot = true; + + for (Player target : getTargets()) + { + shootAt(target); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonWraithSummon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonWraithSummon.java new file mode 100644 index 000000000..a8a8a33b3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/abilities/SkeletonWraithSummon.java @@ -0,0 +1,231 @@ +package mineplex.game.clans.clans.worldevent.boss.skeletonking.abilities; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +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.UtilPlayer; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.SkeletonBoss; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.SkeletonCreature; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.minion.MinionType; +import mineplex.game.clans.clans.worldevent.boss.skeletonking.minion.WraithCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class SkeletonWraithSummon extends BossAbility +{ + private static final int WRAITH_AMOUNT = 4; + private static final double DISTANCE_FROM_KING = 4; + private static final double FINAL_SKELETON_HEALTH = 100; + private static final double FINAL_WRAITH_MULTIPLIER = 2; + private final int WRAITH_AMOUNT_THIS_USE; + + private Map _wraiths = new HashMap<>(); + private Location[] _spawns; + private int _ticks; + + public SkeletonWraithSummon(SkeletonCreature creature) + { + super(creature); + + _spawns = new Location[] + { + getEntity().getLocation().add(DISTANCE_FROM_KING, 0, DISTANCE_FROM_KING), + getEntity().getLocation().add(DISTANCE_FROM_KING * -1, 0, DISTANCE_FROM_KING), + getEntity().getLocation().add(DISTANCE_FROM_KING, 0, DISTANCE_FROM_KING * -1), + getEntity().getLocation().add(DISTANCE_FROM_KING * -1, 0, DISTANCE_FROM_KING * -1), + getEntity().getLocation().add(DISTANCE_FROM_KING / 2, 0, DISTANCE_FROM_KING / 2), + getEntity().getLocation().add((DISTANCE_FROM_KING / 2) * -1, 0, DISTANCE_FROM_KING / 2), + getEntity().getLocation().add(DISTANCE_FROM_KING / 2, 0, (DISTANCE_FROM_KING / 2) * -1), + getEntity().getLocation().add((DISTANCE_FROM_KING / 2) * -1, 0, (DISTANCE_FROM_KING / 2) * -1) + }; + + if (creature.getHealth() <= FINAL_SKELETON_HEALTH) + { + WRAITH_AMOUNT_THIS_USE = (int)(WRAITH_AMOUNT * FINAL_WRAITH_MULTIPLIER); + } + else + { + WRAITH_AMOUNT_THIS_USE = WRAITH_AMOUNT; + } + } + + private String getNumberString(Integer number) + { + String num = number.toString(); + char last = num.toCharArray()[num.length() - 1]; + + String formatted = number.toString(); + String ending = ""; + + if (last == '1' && !num.equals("1" + last)) + { + ending = "st"; + } + if (last == '2' && !num.equals("1" + last)) + { + ending = "nd"; + } + if (last == '3' && !num.equals("1" + last)) + { + ending = "rd"; + } + if (ending.equals("")) + { + ending = "th"; + } + + return formatted + ending; + } + + private void spawnWraith(Location loc, int number) + { + WraithCreature wraith = (WraithCreature)((SkeletonBoss)getBoss().getEvent()).spawnMinion(MinionType.WRAITH, loc); + _wraiths.put(wraith, getNumberString(number)); + } + + @Override + public int getCooldown() + { + return 0; + } + + @Override + public boolean canMove() + { + return false; + } + + @Override + public boolean inProgress() + { + return true; + } + + @Override + public boolean hasFinished() + { + return _wraiths.isEmpty() && _ticks > 40; + } + + @Override + public void setFinished() + { + for (WraithCreature wraith : _wraiths.keySet()) + { + wraith.remove(); + } + _wraiths.clear(); + _ticks = 41; + } + + @Override + public void tick() + { + if (_ticks == 0) + { + if (WRAITH_AMOUNT > 0) + { + for (int i = 0; i < WRAITH_AMOUNT_THIS_USE; i++) + { + int spawnIndex = i; + if (spawnIndex >= _spawns.length) + { + spawnIndex = spawnIndex % _spawns.length; + } + spawnWraith(_spawns[spawnIndex], i + 1); + } + + for (Player player : UtilPlayer.getInRadius(getEntity().getLocation(), 80).keySet()) + { + if (player.isDead() || !player.isValid() || !player.isOnline()) + { + continue; + } + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) + { + continue; + } + + player.sendMessage(F.main(getBoss().getEvent().getName(), "You must slay all " + WRAITH_AMOUNT_THIS_USE + " wraiths before continuing to fight the " + getBoss().getEvent().getName() + "!")); + } + } + } + _ticks++; + if (!hasFinished()) + { + int ticks = 10; + int hticks = 40; + boolean up = getEntity().getTicksLived() % (hticks * 2) < hticks; + int tick = getEntity().getTicksLived() % ticks; + double htick = getEntity().getTicksLived() % hticks; + int splits = 4; + + Location loc = getEntity().getLocation().add(0, 2, 0); + + for (double d = tick * (Math.PI * 2 / splits) / ticks; d < Math.PI * 2; d += Math.PI * 2 / splits) + { + Vector v = new Vector(Math.sin(d), 0, Math.cos(d)); + v.normalize().multiply(Math.max(0.2, Math.sin((htick / hticks) * Math.PI) * 1.0)); + v.setY((htick / hticks) * -2); + if (up) v.setY(-2 + 2 * (htick / hticks)); + + Location lloc = loc.clone().add(v); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, lloc, null, 0f, 2, ViewDist.MAX); + } + } + } + + @EventHandler + public void onWraithDie(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof WraithCreature) + { + String number = _wraiths.remove(event.getCreature()); + if (number != null) + { + double remainPercent = new BigDecimal(_wraiths.size()).divide(new BigDecimal(WRAITH_AMOUNT_THIS_USE)).doubleValue(); + ChatColor remainColor = ChatColor.GREEN; + if (remainPercent < .66) + { + remainColor = ChatColor.YELLOW; + } + if (remainPercent < .33) + { + remainColor = ChatColor.RED; + } + Bukkit.broadcastMessage(F.main(getBoss().getEvent().getName(), "A wraith has been slain!" + " (" + remainColor + _wraiths.size() + "/" + WRAITH_AMOUNT_THIS_USE + C.cGray + ") wraiths remaining!")); + System.out.println(F.main(getBoss().getEvent().getName(), "The " + number + " wraith has been slain!")); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(getBoss().getEntity())) + { + if (!hasFinished()) + { + event.SetCancelled("Wraiths Alive"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/MinionType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/MinionType.java new file mode 100644 index 000000000..8d2f779ca --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/MinionType.java @@ -0,0 +1,34 @@ +package mineplex.game.clans.clans.worldevent.boss.skeletonking.minion; + +import org.bukkit.Location; + +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; + +public enum MinionType +{ + WARRIOR(UndeadWarriorCreature.class), + ARCHER(UndeadArcherCreature.class), + WRAITH(WraithCreature.class); + + private Class> _code; + + private MinionType(Class> code) + { + _code = code; + } + + public EventCreature getNewInstance(WorldEvent event, Location spawn) + { + try + { + return _code.getConstructor(WorldEvent.class, Location.class).newInstance(event, spawn); + } + catch (Exception e) + { + e.printStackTrace(); + } + + return null; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/UndeadArcherCreature.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/UndeadArcherCreature.java new file mode 100644 index 000000000..625b96c0d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/UndeadArcherCreature.java @@ -0,0 +1,234 @@ +package mineplex.game.clans.clans.worldevent.boss.skeletonking.minion; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class UndeadArcherCreature extends EventCreature +{ + private static final int BARBED_LEVEL = 1; + private static final int LIFETIME = -1; + + public UndeadArcherCreature(WorldEvent event, Location spawnLocation) + { + super(event, spawnLocation, "Undead Archer", true, 25, 30, true, Skeleton.class); + + spawnEntity(); + } + + @Override + protected void spawnCustom() + { + Skeleton entity = getEntity(); + EntityEquipment eq = entity.getEquipment(); + eq.setItemInHand(new ItemStack(Material.BOW)); + eq.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET)); + eq.setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); + eq.setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); + eq.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); + eq.setItemInHandDropChance(0.f); + eq.setHelmetDropChance(0.f); + eq.setChestplateDropChance(0.f); + eq.setLeggingsDropChance(0.f); + eq.setBootsDropChance(0.f); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 0)); + } + + @Override + public void dieCustom() + { + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + return; + } + + if (Math.random() > 0.97) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.CHAINMAIL_HELMET)); + } + + if (Math.random() > 0.97) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.CHAINMAIL_CHESTPLATE)); + } + + if (Math.random() > 0.97) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.CHAINMAIL_LEGGINGS)); + } + + if (Math.random() > 0.97) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.CHAINMAIL_BOOTS)); + } + + if (Math.random() > 0.90) + { + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.BOW)); + } + + getEntity().getWorld().dropItem(getEntity().getLocation(), new org.bukkit.inventory.ItemStack(Material.ARROW, UtilMath.r(12) + 1)); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void bowShoot(EntityShootBowEvent event) + { + if (BARBED_LEVEL == 0) + { + return; + } + + if (!(event.getProjectile() instanceof Arrow)) + { + return; + } + + if (event.getEntity().getEntityId() != getEntity().getEntityId()) + { + return; + } + + event.getProjectile().setMetadata("BARBED_ARROW", new FixedMetadataValue(UtilServer.getPlugin(), 2)); + } + + @EventHandler(priority = EventPriority.HIGH) + public void damage(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + if (event.GetCause() != DamageCause.PROJECTILE) + { + return; + } + + Projectile projectile = event.GetProjectile(); + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(true); + + if (projectile == null) + { + return; + } + + if (!projectile.hasMetadata("BARBED_ARROW")) + { + return; + } + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (!getEntity().equals(damager)) + { + return; + } + + // Level + if (BARBED_LEVEL == 0) + { + return; + } + + Player damageePlayer = event.GetDamageePlayer(); + + if (damageePlayer != null) + { + damageePlayer.setSprinting(false); + } + + // Damage + event.AddMod(damager.getName(), "Barbed Arrows", projectile.getMetadata("BARBED_ARROW").get(0).asDouble(), false); + + // Condition + getEvent().getCondition().Factory().Slow("Barbed Arrows", damagee, damager, (projectile.getVelocity().length() / 3) * (2 + BARBED_LEVEL), 0, false, true, true, true); + } + + @EventHandler + public void clean(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + remove(); + return; + } + } + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) + { + if (!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/UndeadWarriorCreature.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/UndeadWarriorCreature.java new file mode 100644 index 000000000..607a2c234 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/UndeadWarriorCreature.java @@ -0,0 +1,186 @@ +package mineplex.game.clans.clans.worldevent.boss.skeletonking.minion; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class UndeadWarriorCreature extends EventCreature +{ + private static final int LIFETIME = -1; + + public UndeadWarriorCreature(WorldEvent event, Location spawnLocation) + { + super(event, spawnLocation, "Undead Warrior", true, 30, 30, true, Zombie.class); + spawnEntity(); + } + + @Override + protected void spawnCustom() + { + Zombie entity = getEntity(); + EntityEquipment eq = entity.getEquipment(); + eq.setHelmet(new ItemStack(Material.IRON_HELMET)); + eq.setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); + eq.setLeggings(new ItemStack(Material.IRON_LEGGINGS)); + eq.setBoots(new ItemStack(Material.IRON_BOOTS)); + eq.setItemInHand(new ItemStack(Material.STONE_SWORD)); + eq.setHelmetDropChance(0.f); + eq.setChestplateDropChance(0.f); + eq.setLeggingsDropChance(0.f); + eq.setBootsDropChance(0.f); + eq.setItemInHandDropChance(0.f); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 0)); + } + + @Override + public void dieCustom() + { + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + return; + } + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.IRON_HELMET)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.IRON_CHESTPLATE)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.IRON_LEGGINGS)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.IRON_BOOTS)); + } + + @EventHandler + public void leap(UpdateEvent event) + { + if (getEntity() == null) + return; + + if (event.getType() != UpdateType.FAST) + return; + + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + remove(); + return; + } + + if (Math.random() < 0.9) + return; + + Zombie zombie = getEntity(); + + if (zombie.getTarget() == null) + return; + + double dist = UtilMath.offset(zombie.getTarget(), zombie); + + if (dist <= 3 || dist > 16) + return; + + + double power = 0.8 + (1.2 * ((dist-3)/13d)); + + //Leap + UtilAction.velocity(zombie, UtilAlg.getTrajectory(zombie, zombie.getTarget()), + power, false, 0, 0.2, 1, true); + + //Effect + zombie.getWorld().playSound(zombie.getLocation(), Sound.ZOMBIE_HURT, 1f, 2f); + } + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) + { + if (!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void attack(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(false); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damager)) + { + if (damagee instanceof Player) + { + ((Player)damagee).setFoodLevel(((Player)damagee).getFoodLevel() - 1); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/WraithCreature.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/WraithCreature.java new file mode 100644 index 000000000..9a9cbcde3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/minion/WraithCreature.java @@ -0,0 +1,190 @@ +package mineplex.game.clans.clans.worldevent.boss.skeletonking.minion; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class WraithCreature extends EventCreature +{ + private static final int LIFETIME = -1; + + public WraithCreature(WorldEvent event, Location spawnLocation) + { + super(event, spawnLocation, "Wraith", true, 200, 30, true, Zombie.class); + spawnEntity(); + } + + @Override + protected void spawnCustom() + { + Zombie entity = getEntity(); + EntityEquipment eq = entity.getEquipment(); + eq.setHelmet(new ItemStack(Material.SKULL_ITEM, 1, (short)1)); + eq.setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.BLACK).build()); + eq.setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.BLACK).build()); + eq.setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.BLACK).build()); + eq.setItemInHand(new ItemStack(Material.IRON_SWORD)); + eq.setHelmetDropChance(0.f); + eq.setChestplateDropChance(0.f); + eq.setLeggingsDropChance(0.f); + eq.setBootsDropChance(0.f); + eq.setItemInHandDropChance(0.f); + entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 0)); + entity.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 999999, 0)); + entity.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 999999, 0)); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 1)); + } + + @Override + public void dieCustom() + { + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + return; + } + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.DIAMOND_HELMET)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.DIAMOND_CHESTPLATE)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.DIAMOND_LEGGINGS)); + + if (Math.random() > 0.97) + getEntity().getWorld().dropItem(getEntity().getLocation(), new ItemStack(Material.DIAMOND_BOOTS)); + } + + @EventHandler(priority = EventPriority.HIGH) + public void damage(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(false); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damager)) + { + event.AddMult(damager.getName(), "Mystical Darkness", 2, false); + } + } + + @EventHandler + public void blink(UpdateEvent event) + { + if (getEntity() == null) + return; + + if (event.getType() != UpdateType.FAST) + return; + + if (LIFETIME >= 0 && getEntity().getTicksLived() >= (20 * LIFETIME)) + { + remove(); + return; + } + + if (Math.random() < 0.6) + return; + + Zombie zombie = getEntity(); + + if (zombie.getTarget() == null) + return; + + double dist = UtilMath.offset(zombie.getTarget(), zombie); + + if (dist <= 10 || dist > 25) + return; + + Location teleport = zombie.getTarget().getLocation().add(Math.random() + 1, 0, Math.random() + 1); + if (UtilMath.offset(getSpawnLocation(), teleport) > 30) + { + return; + } + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, zombie.getLocation(), 0, 0, 0, 0, 5, ViewDist.MAX); + zombie.getWorld().playSound(zombie.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 2f); + zombie.teleport(teleport); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, zombie.getLocation(), 0, 0, 0, 0, 5, ViewDist.MAX); + zombie.getWorld().playSound(zombie.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 2f); + } + + @EventHandler + public void onTarget(EntityTargetLivingEntityEvent event) + { + if (getEntity().equals(event.getEntity())) + { + if (!(event.getTarget() instanceof Player)) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void protect(CustomDamageEvent event) + { + if (event.IsCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + + if (damagee == null) + { + return; + } + + if (damager == null) + { + return; + } + + if (getEntity().equals(damagee)) + { + if (!(damager instanceof Player)) + { + event.SetCancelled("Allied Attacker"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java index 02b3974cf..62e42c6e8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java @@ -22,7 +22,7 @@ public class WorldEventCommand extends MultiCommandBase @Override protected void Help(Player caller, String[] args) { - UtilPlayer.message(caller, F.help("/" + _aliasUsed + " start ", "Start a World Event where you're standing", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " start ", "Start a World Event", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/" + _aliasUsed + " clear", "Clears all World Events", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/" + _aliasUsed + " random", "Starts a random World Event", Rank.ADMIN)); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java index e185d68e0..0bb876d79 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java @@ -78,7 +78,7 @@ public class RaidAltar if (!rejected) { - count++; + count += item.getAmount(); } } @@ -153,10 +153,12 @@ public class RaidAltar { if (item.getAmount() > (amount - removed)) { + removed += (amount - removed); item.setAmount(item.getAmount() - (amount - removed)); } else { + removed += item.getAmount(); player.getInventory().setItem(i, null); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java index 87ccfdfd4..06e29d9de 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java @@ -7,19 +7,24 @@ import java.util.List; import java.util.Set; import java.util.function.Consumer; +import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitTask; import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.DisguiseManager; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.projectile.ProjectileManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -42,6 +47,13 @@ public class RaidManager extends MiniPlugin super("Raid Manager", plugin); addCommand(new StartRaidCommand(this)); + + { + List items = new ArrayList<>(); + items.add(new ItemStack(Material.BONE, 20)); + items.add(new ItemBuilder(Material.IRON_INGOT).setAmount(2).setTitle(C.cDRedB + "Old Silver Token").setLore(C.cRed + "This token pulses with an evil aura.").setGlow(true).build()); + _altars.add(new RaidAltar(new Location(Bukkit.getWorld("world"), 361, 57, -990).getBlock(), RaidType.CHARLES_WITHERTON, items)); + } } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java index 3705cef86..f3331ad5c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java @@ -269,6 +269,7 @@ public abstract class RaidWorldEvent extends WorldEvent event.getEntity().getActivePotionEffects().forEach(pe -> event.getEntity().removePotionEffect(pe.getType())); event.getEntity().setExp(0); event.getEntity().setLevel(0); + event.getEntity().setFireTicks(-1); event.getEntity().teleport(Spawn.getNorthSpawn()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java index 0a19b4fc6..6eb3a4112 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java @@ -85,7 +85,7 @@ public class WitherRaid extends RaidWorldEvent { if (_currentChallenge.isComplete()) { - if (_challenges.size() < 6) + if (_challenges.size() < 5) { teleportToAltar(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java index f82e86ab0..193a2fb37 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java @@ -25,6 +25,12 @@ import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadKnight; import mineplex.game.clans.clans.worldevent.raid.wither.creature.wither.CharlesWitherton; +import mineplex.game.clans.items.ItemType; +import mineplex.game.clans.items.RareItemFactory; +import mineplex.game.clans.items.attributes.weapon.ConqueringAttribute; +import mineplex.game.clans.items.attributes.weapon.FlamingAttribute; +import mineplex.game.clans.items.attributes.weapon.SharpAttribute; +import mineplex.game.clans.items.legendaries.DemonicScythe; public class ChallengeSeven extends RaidChallenge { @@ -91,6 +97,14 @@ public class ChallengeSeven extends RaidChallenge ClansManager.getInstance().getLootManager().dropRare(drop); drop.getWorld().dropItem(drop, new ItemStack(Material.EMERALD, emeralds)); } + RareItemFactory mainFactory = RareItemFactory.begin(ItemType.LEGENDARY).setLegendary(DemonicScythe.class); + if (Math.random() < 0.1) + { + mainFactory.setSuperPrefix(FlamingAttribute.class); + mainFactory.setPrefix(SharpAttribute.class); + mainFactory.setSuffix(ConqueringAttribute.class); + } + _altar.getWorld().dropItem(_altar.clone().add(0, 2, 0), mainFactory.fabricate()); getRaid().getWorldData().getCustomLocs("GATE_FIVE").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); getRaid().setForceEnd(System.currentTimeMillis() + UtilTime.convert(2, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java index 78f955916..c421b4b82 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java @@ -50,7 +50,10 @@ public class HeatingUp extends Cataclysm _center.getBlock().getRelative(x, -1, z).setType(Material.STONE); } } - ((MagmusMeteor)Magmus.Abilities.get(2)).Disabled = false; + if (Magmus.Abilities.size() > 1 && Magmus.Abilities.get(2) instanceof MagmusMeteor) + { + ((MagmusMeteor)Magmus.Abilities.get(2)).Disabled = false; + } } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java index 729499e23..490adbfb0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java @@ -36,6 +36,7 @@ public class Magmus extends RaidCreature Abilities.add(new MagmusCataclysm(this)); Abilities.add(new MagmusSmash(this)); Abilities.add(new MagmusMeteor(this)); + Abilities.add(new MagmusEat(this)); } protected ChallengeSix getChallenge() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java index 604ff9844..1bec42e4c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java @@ -28,7 +28,7 @@ public class MagmusCataclysm extends BossPassive @Override public int getCooldown() { - return 15; + return 23; } @Override @@ -43,13 +43,16 @@ public class MagmusCataclysm extends BossPassive if (UtilTime.elapsed(_lastUse, getCooldown() * 1000)) { _lastUse = System.currentTimeMillis(); - try + if (!_cataclysms.isEmpty()) { - UtilMath.randomElement(_cataclysms).getConstructor(ChallengeSix.class, Magmus.class).newInstance(getBoss().getChallenge(), getBoss()); - } - catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); + try + { + UtilMath.randomElement(_cataclysms).getConstructor(ChallengeSix.class, Magmus.class).newInstance(getBoss().getChallenge(), getBoss()); + } + catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java index 2fcfef365..f174ced35 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java @@ -48,6 +48,7 @@ public class MagmusEat extends BossPassive { spit(); } + _ticks++; } private void initialEat(Player target) @@ -79,7 +80,7 @@ public class MagmusEat extends BossPassive } if (UtilTime.elapsed(_lastUse, getCooldown() * 1000)) { - Player target = UtilPlayer.getClosest(getLocation(), 3); + Player target = UtilPlayer.getClosest(getLocation(), 7); if (target != null) { initialEat(target); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java index 5e76ef0de..c0da5fa5b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java @@ -43,7 +43,7 @@ public class MagmusMeteor extends BossPassive return; } Player target = UtilMath.randomElement(getBoss().getChallenge().getRaid().getPlayers()); - LargeFireball ball = target.getWorld().spawn(target.getLocation().add(Math.random() * 24 - 12, 32 + Math.random() * 16, Math.random() * 24 - 12), LargeFireball.class); + LargeFireball ball = target.getWorld().spawn(target.getLocation().add(2 * Math.random(), 10 + Math.random() * 16, 2 * Math.random()), LargeFireball.class); EntityLargeFireball eFireball = ((CraftLargeFireball) ball).getHandle(); eFireball.dirX = (Math.random()-0.5)*0.02; @@ -51,8 +51,9 @@ public class MagmusMeteor extends BossPassive eFireball.dirZ = (Math.random()-0.5)*0.02; ball.setShooter(getEntity()); - ball.setYield(2.2f); + ball.setYield(0f); ball.setBounce(false); + ball.setIsIncendiary(false); _shot.add(ball); } @@ -105,12 +106,12 @@ public class MagmusMeteor extends BossPassive if (event.getEntity() instanceof LargeFireball) { LargeFireball ball = (LargeFireball) event.getEntity(); - if (ball.getShooter() instanceof MagmaCube && ((MagmaCube)ball.getShooter()).getEntityId() == getEntity().getEntityId()) + if (_shot.contains(ball)) { _shot.remove(ball); UtilParticle.PlayParticle(ParticleType.EXPLODE, ball.getLocation(), null, 0, 2, ViewDist.MAX, UtilServer.getPlayers()); ball.getWorld().playSound(ball.getLocation(), Sound.EXPLODE, 10, 0); - Player hit = UtilPlayer.getClosest(ball.getLocation(), 0.5); + Player hit = UtilPlayer.getClosest(ball.getLocation(), 3); if (hit != null) { getBoss().getEvent().getDamageManager().NewDamageEvent(hit, getEntity(), ball, DamageCause.PROJECTILE, 4, true, true, false, getEntity().getName(), "Meteor Shower"); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java index 2de2bb06d..50eab5b2b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java @@ -30,7 +30,7 @@ public class MagmusSmash extends BossPassive Map targets = UtilPlayer.getInRadius(getLocation(), 5.5d + 0.5 * 5); getBoss().TeleportBackASAP = false; getEntity().setVelocity(new Vector(0, 5, 0)); - UtilServer.runSyncLater(() -> getBoss().TeleportBackASAP = false, 3 * 20); + UtilServer.runSyncLater(() -> getBoss().TeleportBackASAP = true, 3 * 20); for (Player player : targets.keySet()) { getBoss().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, From add639070a30e178e8408c2e34eac86210890b35 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:10:28 -0400 Subject: [PATCH 210/283] Fix cannons not firing --- .../mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java index d0fa8832b..4f6602afa 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/SiegeWeapon.java @@ -493,10 +493,6 @@ public abstract class SiegeWeapon implements Listener removeHealth(getHealth()); return; } - if (_ownerClan.getOnlinePlayers().contains(player)) - { - return; - } if (_lastLeft == -1) { From c64c0866fb92e18cca20e1849aa3b5c92d71a1c0 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:10:55 -0400 Subject: [PATCH 211/283] Update Spawn locations for new map --- .../src/mineplex/game/clans/spawn/Spawn.java | 6 +++--- .../game/clans/spawn/travel/TravelPage.java | 20 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index 979b9743e..07750faf6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -470,17 +470,17 @@ public class Spawn extends MiniPlugin public static Location getEastTown() { - return new Location(getSpawnWorld(), 440.91, 72, -23.08); + return new Location(getSpawnWorld(), 440.91, 63, -23.08); } public static Location getEastTownCenter() { - return new Location(getSpawnWorld(), 425, 72, -8); + return new Location(getSpawnWorld(), 425, 63, -8); } public static Location getNorthSpawn() { - return new Location(getSpawnWorld(), 8.5, 200, -393.5); + return new Location(getSpawnWorld(), 8.5, 206, -393.5); } public static Location getSouthSpawn() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelPage.java index 25b584e64..93deef212 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelPage.java @@ -20,6 +20,7 @@ import mineplex.core.portal.Intent; import mineplex.core.portal.Portal; import mineplex.core.shop.item.IButton; import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanRole; import mineplex.game.clans.clans.ClansManager; @@ -77,15 +78,18 @@ public class TravelPage extends ShopPageBase }, 14 + 10, ClanIcon.CASTLE.getData()); final ClanInfo clan = _plugin.getClan(getPlayer()); - Outpost outpost = _plugin.getSiegeManager().getOutpostManager().Get(clan); - - addTravelLocation(outpost == null ? null : outpost.getCoreLocation().clone().add(0, 1, 0), ClansShopItem.OUTPOST.getMaterial(), (outpost == null ? C.cRedB : C.cDGreenB) + "Outpost", new String[] { - C.cWhite + "Teleport to your Clan's currently", - C.cWhite + "active Outpost.", - " ", - (outpost == null ? C.cRed + "Your Clan does not have an Outpost." : ""), - }, 8, ClanIcon.CASTLE.getData()); + if (Clans.HARDCORE) + { + Outpost outpost = _plugin.getSiegeManager().getOutpostManager().Get(clan); + + addTravelLocation(outpost == null ? null : outpost.getCoreLocation().clone().add(0, 1, 0), ClansShopItem.OUTPOST.getMaterial(), (outpost == null ? C.cRedB : C.cDGreenB) + "Outpost", new String[] { + C.cWhite + "Teleport to your Clan's currently", + C.cWhite + "active Outpost.", + " ", + (outpost == null ? C.cRed + "Your Clan does not have an Outpost." : ""), + }, 8, ClanIcon.CASTLE.getData()); + } From fcce06fea9b0ee873d77eadea4d4ac370637c3b5 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:11:07 -0400 Subject: [PATCH 212/283] Update item system for new legendary --- .../clans/items/legendaries/DemonicScythe.java | 16 ++++++++-------- .../mineplex/game/clans/items/ui/GearPage.java | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java index 3423234e5..b054624ad 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java @@ -10,21 +10,21 @@ public class DemonicScythe extends LegendaryItem { public DemonicScythe() { - super("Demonic Scythe", 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.", + super("Scythe of the Fallen Lord", new String[]{ + C.cWhite + "An old blade fashioned of nothing more", + C.cWhite + "than bones and cloth which served no", + C.cWhite + "purpose. Brave adventurers however have", + C.cWhite + "imbued it with the remnant powers of a", + C.cWhite + "dark and powerful foe.", " ", - C.cYellow + "Right-Click" + C.cWhite + " to use" + C.cGreen + " Fly", + C.cYellow + "Attack" + C.cWhite + " to use" + C.cGreen + " Leach Health", }, Material.RECORD_8); } @Override public void onAttack(CustomDamageEvent event, Player wielder) { - event.AddMod("Wind Blade", 8); + event.AddMod("Scythe of the Fallen Lord", 8); wielder.setHealth(Math.min(wielder.getMaxHealth(), wielder.getHealth() + 2)); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ui/GearPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ui/GearPage.java index e1a9f6193..7bda255f0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ui/GearPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ui/GearPage.java @@ -237,7 +237,7 @@ public class GearPage extends ShopPageBase } }, _factory != null && ItemType.LEGENDARY.equals(_factory.getItemType()), new String[] { _factory != null && ItemType.LEGENDARY.equals(_factory.getItemType()) ? C.cGreen + "Selected" : C.cRed + "Not Selected" }); - addButton(indices[1], Material.RECORD_8, 0, C.cAqua + "Rare", new IButton() + addButton(indices[1], Material.RECORD_7, 0, C.cAqua + "Rare", new IButton() { public void onClick(Player player, ClickType clickType) { From f6c7eaf28b7bbca7c4537ee3d7792c75f5cef491 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 15 Jun 2017 23:47:12 -0400 Subject: [PATCH 213/283] Formatting fix --- .../clans/nether/miniboss/MinibossFireball.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java index d33ad0de6..ea2976684 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/miniboss/MinibossFireball.java @@ -1,11 +1,6 @@ package mineplex.game.clans.clans.nether.miniboss; -import java.util.HashMap; - -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.game.clans.clans.ClansManager; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.Sound; @@ -18,6 +13,11 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.game.clans.clans.ClansManager; + /** * Manager class for managing boss fireballs */ @@ -48,7 +48,7 @@ public class MinibossFireball implements Listener return; } - HashMap hitMap = UtilEnt.getInRadius(proj.getLocation(), FIREBALL_EXPLOSION_RANGE); + Map hitMap = UtilEnt.getInRadius(proj.getLocation(), FIREBALL_EXPLOSION_RANGE); for (LivingEntity cur : hitMap.keySet()) { double range = hitMap.get(cur); From 2b4aecd882ac6904e1c0991cfe96b92b3dbd1156 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 16 Jun 2017 00:01:43 -0400 Subject: [PATCH 214/283] Fix bosses --- .../clans/clans/worldevent/boss/BossWorldEvent.java | 1 + .../worldevent/boss/skeletonking/SkeletonBoss.java | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java index 2d872d9f0..817850ac7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java @@ -108,6 +108,7 @@ public abstract class BossWorldEvent> extends WorldEv drop.getWorld().dropItem(drop, new ItemBuilder(Material.IRON_INGOT).setTitle(C.cDRedB + "Old Silver Token").setLore(C.cRed + "This token pulses with an evil aura.").setGlow(true).build()); }, DELAY_TILL_DROP_REWARD); Bukkit.broadcastMessage(getDeathMessage()); + stop(); } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/SkeletonBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/SkeletonBoss.java index 5c633262b..dd004675e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/SkeletonBoss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/skeletonking/SkeletonBoss.java @@ -16,14 +16,14 @@ public class SkeletonBoss extends BossWorldEvent public SkeletonBoss(WorldEventManager manager) { - super("Skeleton King", manager.getBossArenaLocationFinder().getIronWizardCenter(), 50, manager.getBossArenaLocationFinder().getIronWizardPads().getLeft(), manager.getBossArenaLocationFinder().getIronWizardPads().getRight(), manager.getDisguiseManager(), manager.getClans().getProjectile(), manager.getClans().getDamageManager(), manager.getBlockRestore(), manager.getClans().getCondition()); + super("Skeleton King", manager.getBossArenaLocationFinder().getSkeletonKingCenter(), 50, manager.getBossArenaLocationFinder().getSkeletonKingPads().getLeft(), manager.getBossArenaLocationFinder().getSkeletonKingPads().getRight(), manager.getDisguiseManager(), manager.getClans().getProjectile(), manager.getClans().getDamageManager(), manager.getBlockRestore(), manager.getClans().getCondition()); } @Override protected void customStart() { Bukkit.broadcastMessage(F.main(getName(), "The evils of the world have manifested in the form of the " + getName() + "! Become the champion of Light and destroy him!")); - spawnNecromancer(getCenterLocation()); + spawnSkeletonKing(getCenterLocation()); Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () -> { canMove = true; @@ -40,11 +40,12 @@ public class SkeletonBoss extends BossWorldEvent return minionCreature; } - private SkeletonCreature spawnNecromancer(Location location) + private SkeletonCreature spawnSkeletonKing(Location location) { - SkeletonCreature necromancerCreature = new SkeletonCreature(this, location); - registerCreature(necromancerCreature); - return necromancerCreature; + SkeletonCreature kingCreature = new SkeletonCreature(this, location); + registerCreature(kingCreature); + setBossCreature(kingCreature); + return kingCreature; } @Override From b758254f4cf08624228748fa6f7212a74e2231b5 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 16 Jun 2017 18:54:23 +0100 Subject: [PATCH 215/283] Don't reset the player when an item is purchased --- .../src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 7300d7385..302a1d956 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -222,7 +222,7 @@ public class MobaShop implements Listener } } - _host.GetKit(player).ApplyKit(player); + _host.GetKit(player).GiveItems(player); } public boolean ownsItem(Player player, MobaItem item) From d8bdda2c520709b4b30b66db2cd355ccc8cf8a52 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 16 Jun 2017 16:21:21 -0400 Subject: [PATCH 216/283] Update clans world border size for new map --- .../src/mineplex/game/clans/clans/regions/ClansRegions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java index 55debe953..3ea0964b8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java @@ -24,7 +24,7 @@ public class ClansRegions extends MiniPlugin public final static int SHOP_RADIUS = 6; // Radius of shop claim area (measured in chunks) public final static int FIELDS_RADIUS = 7; // Radius of fields claim area (measured in chunks) public final static int BORDERLANDS_RADIUS = 85; // Radius of borderlands claim area (measured in chunks) - public static final int BORDER_RADIUS = 1250; + public static final int BORDER_RADIUS = 1280; private ClansManager _manager; private World _world; From 93a316e5e3b3a543a54263e6eb178ae6c98b3703 Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Fri, 16 Jun 2017 18:20:21 -0400 Subject: [PATCH 217/283] Add clans box sales package --- .../salespackage/salespackages/ClansBox.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClansBox.java diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClansBox.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClansBox.java new file mode 100644 index 000000000..04f5ab145 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ClansBox.java @@ -0,0 +1,22 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; +import org.bukkit.entity.Player; + +public class ClansBox extends SalesPackageBase +{ + private String _boxType; + + public ClansBox(SalesPackageManager manager, String boxType) + { + super(manager, "1 Clans " + boxType + " Box"); + _boxType = boxType; + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Item Clans " + _boxType + " Box", "Give 1 Clans " + _boxType + " Box."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} From 4e8838d99ebeb64d64357654d3f3889d95e3c189 Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Fri, 16 Jun 2017 18:23:11 -0400 Subject: [PATCH 218/283] Add Clans Dye Box and Clans Builder Box to CUST-1 --- .../staffServer/salespackage/SalesPackageManager.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index 2f8d3f15f..509ea9286 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -38,6 +38,7 @@ import mineplex.staffServer.salespackage.salespackages.OmegaChest; import mineplex.staffServer.salespackage.salespackages.Pet; import mineplex.staffServer.salespackage.salespackages.PowerPlayClub; import mineplex.staffServer.salespackage.salespackages.RuneAmplifier; +import mineplex.staffServer.salespackage.salespackages.ClansBox; import mineplex.staffServer.salespackage.salespackages.SalesPackageBase; import mineplex.staffServer.salespackage.salespackages.SpringChest; import mineplex.staffServer.salespackage.salespackages.StPatricksChest; @@ -80,13 +81,13 @@ public class SalesPackageManager extends MiniPlugin AddSalesPackage(new LifetimeLegend(this)); AddSalesPackage(new LifetimeTitan(this)); AddSalesPackage(new LifetimeEternal(this)); - //AddSalesPackage(new GemHunter(this, 4)); + //AddSalesPackage(new GemHunter(this, 4)); //AddSalesPackage(new GemHunter(this, 8)); AddSalesPackage(new ApplyKits(this)); AddSalesPackage(new OldChest(this)); AddSalesPackage(new AncientChest(this)); AddSalesPackage(new MythicalChest(this)); - AddSalesPackage(new IlluminatedChest(this)); + AddSalesPackage(new IlluminatedChest(this)); AddSalesPackage(new FreedomChest(this)); AddSalesPackage(new GingerbreadChest(this)); //AddSalesPackage(new ValentinesGift(this)); @@ -96,6 +97,8 @@ public class SalesPackageManager extends MiniPlugin AddSalesPackage(new ClanBannerEditor(this)); AddSalesPackage(new RuneAmplifier(this, 20)); AddSalesPackage(new RuneAmplifier(this, 60)); + AddSalesPackage(new ClansBox(this, "Dye")); + AddSalesPackage(new ClansBox(this, "Builder")); AddSalesPackage(new PowerPlayClub(this, false)); AddSalesPackage(new PowerPlayClub(this, true)); AddSalesPackage(new OmegaChest(this)); @@ -180,7 +183,7 @@ public class SalesPackageManager extends MiniPlugin { chestBuilder = chestBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); } - else if (salesPackage instanceof ClanBannerEditor || salesPackage instanceof ClanBannerUsage || salesPackage instanceof RuneAmplifier) + else if (salesPackage instanceof ClanBannerEditor || salesPackage instanceof ClanBannerUsage || salesPackage instanceof RuneAmplifier || salesPackage instanceof ClansBox) { clanBuilder = clanBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); } From 10df654e4211da9b7555f18513915553ef9e38b2 Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Fri, 16 Jun 2017 18:36:38 -0400 Subject: [PATCH 219/283] Track enjin/support-given clans boxes in CUST-1 --- .../customerSupport/CustomerSupport.java | 49 ++++++++++++++----- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index d9e82ba75..b51a9c8e1 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -139,7 +139,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable int ancientChestsReceived = 0; int mythicalChestsReceived = 0; int winterChestsReceived = 0; - int illuminatedChestsReceived = 0; + int illuminatedChestsReceived = 0; int valentinesGiftsReceived = 0; int boostersReceived = 0; int freedomChestsReceived = 0; @@ -155,6 +155,8 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable int loveChestsReceived = 0; int stPatricksChestReceived = 0; int springChestsReceived = 0; + int clansDyeBoxesReceived = 0; + int clansBuilderBoxesReceived = 0; for (CoinTransactionToken transaction : donor.getCoinTransactions()) { @@ -211,17 +213,17 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable } } - if (transaction.SalesPackageName.startsWith("Illuminated Chest")) - { - if (transaction.Coins == 0 && transaction.Gems == 0) - { - if (transaction.SalesPackageName.split(" ").length == 3) - illuminatedChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]); - else if (transaction.SalesPackageName.split(" ").length == 2) - illuminatedChestsReceived += 1; - } + if (transaction.SalesPackageName.startsWith("Illuminated Chest")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 3) + illuminatedChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]); + else if (transaction.SalesPackageName.split(" ").length == 2) + illuminatedChestsReceived += 1; + } - } + } if (transaction.SalesPackageName.startsWith("Freedom Treasure")) { if (transaction.Coins == 0 && transaction.Gems == 0) @@ -369,6 +371,26 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable runeAmplifier60 += 1; } } + if (transaction.SalesPackageName.startsWith("Clans Dye Box")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 4) + clansDyeBoxesReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[3]); + else if (transaction.SalesPackageName.split(" ").length == 3) + clansDyeBoxesReceived += 1; + } + } + if (transaction.SalesPackageName.startsWith("Clans Builder Box")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 4) + clansBuilderBoxesReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[3]); + else if (transaction.SalesPackageName.split(" ").length == 3) + clansBuilderBoxesReceived += 1; + } + } } StatsManager statsManager = Managers.get(StatsManager.class); @@ -392,10 +414,10 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable shards.append(" "); shards.append(C.cBlue + "Shards: " + C.cYellow + donor.getBalance(GlobalCurrency.TREASURE_SHARD)); caller.sendMessage(shards.toString()); - // Strutt20 asked me to remove some stuff from the menu + // Strutt20 asked me to remove some stuff from the menu caller.sendMessage(C.cBlue + "Old Chests Received: " + C.cYellow + oldChestsReceived + " " + C.cBlue + "Ancient Chests Received: " + C.cYellow + ancientChestsReceived); caller.sendMessage(C.cBlue + "Mythical Chests Received: " + C.cYellow + mythicalChestsReceived + " " + C.cBlue + "Illuminated Chests Received: " + C.cYellow + illuminatedChestsReceived); - caller.sendMessage(C.cBlue + "Omega Chests Received: " + C.cYellow + omegaChestsReceived); + caller.sendMessage(C.cBlue + "Omega Chests Received: " + C.cYellow + omegaChestsReceived); caller.sendMessage(C.cBlue + "Haunted Chests Received: " + C.cYellow + hauntedChestsReceived + " " + C.cBlue + "Haunted Chests Opened: " + C.cYellow + hauntedChestsOpened); caller.sendMessage(C.cBlue + "Trick or Treat Chests Received: " + C.cYellow + trickOrTreatChestsReceived + " " + C.cBlue + "Thankful Chests Received: " + C.cYellow + thankfulChestsReceived); caller.sendMessage(C.cBlue + "Gingerbread Chests Received: " + C.cYellow + gingerbreadChestsReceived + " " + C.cBlue + "Minestrike Chests Received: " + C.cYellow + minestrikeChestsReceived); @@ -404,6 +426,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Spring Chests Received: " + C.cYellow + springChestsReceived); caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived); caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min/60 min) Received: " + C.cYellow + runeAmplifier20 + "/" + runeAmplifier60); + caller.sendMessage(C.cBlue + "Clans Dye Boxes Received: " + C.cYellow + clansDyeBoxesReceived + " " + C.cBlue + "Clans Builder Boxes Received: " + C.cYellow + clansBuilderBoxesReceieved); caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Usage") + " " + C.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor")); YearMonth yearMonth = YearMonth.now(); caller.sendMessage(C.cBlue + "Power Play Subscription (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.isSubscribed() ? C.cGreen + "Active" : C.cRed + "Inactive")); From 04d9e7326dae726b73b29c48210454c2ece3562f Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 16 Jun 2017 19:22:53 -0500 Subject: [PATCH 220/283] Fix NPE in OP Skywars startup --- .../arcade/game/games/skywars/modes/OverpoweredSkywars.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/OverpoweredSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/OverpoweredSkywars.java index 7f971dc34..88776e7a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/OverpoweredSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/OverpoweredSkywars.java @@ -48,6 +48,8 @@ public class OverpoweredSkywars extends TeamSkywars super(manager, GameType.Brawl); new AbsorptionFix(this); + + setupOPPlayerLoot(); } @Override @@ -137,8 +139,7 @@ public class OverpoweredSkywars extends TeamSkywars } } - @Override - public void setupPlayerLoot() + public void setupOPPlayerLoot() { //Armor _playerArmor.addLoot(new RandomItem(Material.DIAMOND_HELMET, 20)); From b8d160388f6b9e1b4687c9f7aae3dcfebc42d53c Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 16 Jun 2017 17:05:54 +0100 Subject: [PATCH 221/283] Removed dropped exp from entity kills and fishing --- .../mineplex/gemhunters/world/WorldListeners.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldListeners.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldListeners.java index f40a2605b..0dfab4fb3 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldListeners.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldListeners.java @@ -17,6 +17,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.*; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent; @@ -229,6 +230,18 @@ public class WorldListeners implements Listener } } + @EventHandler + public void removeExp(EntityDeathEvent event) + { + event.setDroppedExp(0); + } + + @EventHandler + public void removeExp(PlayerFishEvent event) + { + event.setExpToDrop(0); + } + public boolean shouldBlock(Player player) { return player.getGameMode() != GameMode.CREATIVE; From 599f391001ee0af414d566c9b96db450247224d8 Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 16 Jun 2017 22:36:33 -0500 Subject: [PATCH 222/283] Fix build (typo) --- .../mineplex/staffServer/customerSupport/CustomerSupport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index b51a9c8e1..0da0df265 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -426,7 +426,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Spring Chests Received: " + C.cYellow + springChestsReceived); caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived); caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min/60 min) Received: " + C.cYellow + runeAmplifier20 + "/" + runeAmplifier60); - caller.sendMessage(C.cBlue + "Clans Dye Boxes Received: " + C.cYellow + clansDyeBoxesReceived + " " + C.cBlue + "Clans Builder Boxes Received: " + C.cYellow + clansBuilderBoxesReceieved); + caller.sendMessage(C.cBlue + "Clans Dye Boxes Received: " + C.cYellow + clansDyeBoxesReceived + " " + C.cBlue + "Clans Builder Boxes Received: " + C.cYellow + clansBuilderBoxesReceived); caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Usage") + " " + C.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor")); YearMonth yearMonth = YearMonth.now(); caller.sendMessage(C.cBlue + "Power Play Subscription (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.isSubscribed() ? C.cGreen + "Active" : C.cRed + "Inactive")); From 04fafea3edc5623d314ac1136315fe04628bf82a Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 17 Jun 2017 12:40:08 +0100 Subject: [PATCH 223/283] Fixed a number of error causes --- .../arcade/game/games/moba/boss/MobaBoss.java | 2 +- .../game/games/moba/kit/common/DashSkill.java | 15 ++++++---- .../games/moba/kit/larissa/SkillAOEHeal.java | 7 +++++ .../arcade/game/games/moba/shop/MobaShop.java | 30 +++++++++++++++++++ .../effects/MobaBasicAttackDamageEffect.java | 2 +- 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index 086858719..0b2f7adc2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -85,7 +85,7 @@ public abstract class MobaBoss implements Listener @EventHandler public void updateMovement(UpdateEvent event) { - if (event.getType() != UpdateType.TICK || _entity == null || !_host.IsLive()) + if (event.getType() != UpdateType.TICK || !_host.IsLive()) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java index 7d8899320..217751e16 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -20,7 +20,9 @@ import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import java.util.*; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; import java.util.Map.Entry; public class DashSkill extends HeroSkill @@ -127,10 +129,12 @@ public class DashSkill extends HeroSkill return; } - for (Entry entry : _startTime.entrySet()) + Iterator iterator = _startTime.keySet().iterator(); + + while (iterator.hasNext()) { - Player player = entry.getKey(); - long start = entry.getValue(); + Player player = iterator.next(); + long start = _startTime.get(player); if (UtilTime.elapsed(start, _velocityTime)) { @@ -138,7 +142,8 @@ public class DashSkill extends HeroSkill { UtilAction.zeroVelocity(player); } - _startTime.remove(player); + + iterator.remove(); postDash(player); } else diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java index 93e4e5055..5f12478e4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java @@ -113,6 +113,13 @@ public class SkillAOEHeal extends HeroSkill implements IThrown AOEHealData data = iterator.next(); Player owner = data.Owner; GameTeam team = Manager.GetGame().GetTeam(owner); + + if (team == null) + { + iterator.remove(); + continue; + } + DustSpellColor colour = new DustSpellColor(team.GetColor() == ChatColor.RED ? java.awt.Color.RED : java.awt.Color.CYAN); if (UtilTime.elapsed(data.Start, DURATION)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 302a1d956..f2707a965 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -342,6 +342,11 @@ public class MobaShop implements Listener Player player = event.getPlayer(); List items = _upgrades.get(player); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) @@ -374,6 +379,11 @@ public class MobaShop implements Listener List items = _upgrades.get(damager); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) @@ -409,6 +419,11 @@ public class MobaShop implements Listener List items = _upgrades.get(killer); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) @@ -429,6 +444,11 @@ public class MobaShop implements Listener Player player = event.getPlayer(); List items = _upgrades.get(player); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) @@ -453,6 +473,11 @@ public class MobaShop implements Listener List items = _upgrades.get(event.getSource()); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) @@ -473,6 +498,11 @@ public class MobaShop implements Listener Player player = event.GetPlayer(); List items = _upgrades.get(player); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java index 3f19d483c..d8e5221ca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java @@ -20,7 +20,7 @@ public class MobaBasicAttackDamageEffect extends MobaItemEffect @Override protected void onDamage(CustomDamageEvent event) { - if (!event.GetReason().contains(MobaConstants.BASIC_ATTACK)) + if (event.GetReason() == null || !event.GetReason().contains(MobaConstants.BASIC_ATTACK)) { return; } From 9c5565ac3bf5d2c26fb305635d0ed03bce795cc1 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 17 Jun 2017 12:45:15 +0100 Subject: [PATCH 224/283] Remove recalling as it is unused --- .../game/arcade/game/games/moba/Moba.java | 2 - .../arcade/game/games/moba/kit/HeroKit.java | 10 +- .../arcade/game/games/moba/recall/Recall.java | 153 ------------------ .../game/games/moba/recall/RecallSession.java | 19 --- 4 files changed, 2 insertions(+), 182 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 3850dcc77..fa549da2e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -46,7 +46,6 @@ import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena; import nautilus.game.arcade.game.games.moba.minion.MinionManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; -import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; @@ -138,7 +137,6 @@ public class Moba extends TeamGame registerManager(new HPManager(this)); registerManager(new MobaDamageManager(this)); registerManager(new MobaFountain(this)); - registerManager(new Recall(this)); // Pregame managers registerManager(new PrepareManager(this)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 0fbecfe73..1e4aaf392 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -3,7 +3,6 @@ package nautilus.game.arcade.game.games.moba.kit; import com.mojang.authlib.GameProfile; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; @@ -41,11 +40,7 @@ public class HeroKit extends Kit private int _maxAmmo; private SkinData _skin; - private static final int RECALL_SLOT = 8; - private static final ItemStack RECALL_ITEM = new ItemBuilder(Material.BED) - .setTitle(C.cGreenB + "Recall to your Base") - .addLore("Clicking this item will teleport you back to your", "base after " + F.time("5") + " seconds.", "Taking damage or moving will cancel", "your teleport.") - .build(); + private static final int SHOP_SLOT = 8; private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT) .setTitle(C.cGold + "Open Gold Upgrades") .addLore("Click to open the Gold Upgrades", "shop while you are respawning.") @@ -173,8 +168,7 @@ public class HeroKit extends Kit // Give standard items inventory.setItem(AMMO_SLOT, _ammo); - //inventory.setItem(RECALL_SLOT, RECALL_ITEM); - inventory.setItem(RECALL_SLOT, SHOP_ITEM); + inventory.setItem(SHOP_SLOT, SHOP_ITEM); Moba game = (Moba) Manager.GetGame(); List items = game.getShop().getOwnedItems(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java deleted file mode 100644 index 2725ecf1f..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java +++ /dev/null @@ -1,153 +0,0 @@ -package nautilus.game.arcade.game.games.moba.recall; - -import mineplex.core.common.util.*; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.game.games.moba.Moba; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.HashSet; -import java.util.Set; - -public class Recall implements Listener -{ - - private static final int RECALL_TIME = 5000; - private static final double PARTICLE_HEIGHT = 2.5; - private static final double PARTICLE_RADIUS = 1.5; - - private final Moba _host; - - private final Set _sessions; - - public Recall(Moba host) - { - _host = host; - - _sessions = new HashSet<>(); - } - - @EventHandler - public void interactBed(PlayerInteractEvent event) - { - if (event.isCancelled()) - { - return; - } - - if (!UtilEvent.isAction(event, ActionType.R)) - { - return; - } - - Player player = event.getPlayer(); - ItemStack itemStack = player.getItemInHand(); - - if (itemStack == null || itemStack.getType() != Material.BED || getSession(player) != null) - { - return; - } - - if (Recharge.Instance.use(player, "Recall", RECALL_TIME, false, true)) - { - _sessions.add(new RecallSession(player)); - } - } - - @EventHandler - public void update(UpdateEvent event) - { - if (event.getType() != UpdateType.FASTER) - { - return; - } - - long now = System.currentTimeMillis(); - - for (Player player : _host.GetPlayers(true)) - { - RecallSession session = getSession(player); - - if (session == null) - { - continue; - } - - if (UtilTime.elapsed(session.Start, RECALL_TIME)) - { - _host.GetTeam(player).SpawnTeleport(player); - removeSession(player, null); - } - else if (UtilMath.offsetSquared(player.getLocation(), session.Location) > 4) - { - removeSession(player, "You moved!"); - } - else - { - Location location = session.Location.clone(); - double height = (double) (now - session.Start) / (double) RECALL_TIME; - - for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 10) - { - double x = PARTICLE_RADIUS * Math.sin(theta); - double z = PARTICLE_RADIUS * Math.cos(theta); - - for (double y = 0.25; y < height * PARTICLE_HEIGHT; y += 0.5) - { - location.add(x, y, z); - - UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); - - location.subtract(x, y, z); - } - } - } - } - } - - @EventHandler - public void damage(CustomDamageEvent event) - { - if (event.GetDamageePlayer() == null) - { - return; - } - - removeSession(event.GetDamageePlayer(), "You took damage!"); - } - - private void removeSession(Player player, String reason) - { - boolean had = _sessions.removeIf(session -> session.Player.equals(player)); - - if (had && reason != null) - { - player.sendMessage(F.main("Game", reason + " You recall has been cancelled")); - } - } - - private RecallSession getSession(Player player) - { - for (RecallSession session : _sessions) - { - if (session.Player.equals(player)) - { - return session; - } - } - - return null; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java deleted file mode 100644 index 0abca7401..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java +++ /dev/null @@ -1,19 +0,0 @@ -package nautilus.game.arcade.game.games.moba.recall; - -import org.bukkit.Location; -import org.bukkit.entity.Player; - -class RecallSession -{ - - public Player Player; - public long Start; - public Location Location; - - public RecallSession(Player player) - { - Player = player; - Start = System.currentTimeMillis(); - Location = player.getLocation(); - } -} From 51460475dea3bc5f6f31345abebef1644cf936ef Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 17 Jun 2017 12:47:28 +0100 Subject: [PATCH 225/283] Change the Shop Item description --- .../src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 1e4aaf392..abde5d9c1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -43,7 +43,7 @@ public class HeroKit extends Kit private static final int SHOP_SLOT = 8; private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT) .setTitle(C.cGold + "Open Gold Upgrades") - .addLore("Click to open the Gold Upgrades", "shop while you are respawning.") + .addLore("Click to open the Gold Upgrades Shop") .build(); private boolean _visible = true; From 1658afefcab2686f017019bc730a0c2f64616b9e Mon Sep 17 00:00:00 2001 From: cnr Date: Sat, 17 Jun 2017 14:36:38 -0500 Subject: [PATCH 226/283] Don't key Maps by strings; use simple data type instead --- .../game/clans/core/ClaimLocation.java | 65 +++++++++++++++++++ .../clans/core/repository/ClanRepository.java | 53 +++++++-------- .../clans/core/repository/ClanTerritory.java | 19 +++--- .../game/clans/clans/ClanEnergyManager.java | 5 +- .../mineplex/game/clans/clans/ClanInfo.java | 15 ++--- .../mineplex/game/clans/clans/ClansAdmin.java | 19 +++--- .../clans/clans/ClansDataAccessLayer.java | 30 ++++----- .../game/clans/clans/ClansDisplay.java | 7 +- .../game/clans/clans/ClansManager.java | 17 +++-- .../game/clans/clans/ClansUtility.java | 49 +++++++------- .../clans/claimview/ClaimVisualizer.java | 40 ++++++------ .../clans/clans/commands/ClansCommand.java | 6 +- .../game/clans/clans/map/ItemMapRenderer.java | 13 ++-- .../clans/clans/regions/ClansRegions.java | 27 ++++---- .../elements/ScoreboardElementPlayer.java | 10 +-- .../clans/items/legendaries/MagneticMaul.java | 20 +++--- 16 files changed, 233 insertions(+), 162 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClaimLocation.java diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClaimLocation.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClaimLocation.java new file mode 100644 index 000000000..adfdfe9d3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClaimLocation.java @@ -0,0 +1,65 @@ +package mineplex.game.clans.core; + +import java.util.Objects; + +import org.bukkit.Bukkit; +import org.bukkit.Chunk; + +public class ClaimLocation +{ + public final String _worldName; + public final int _chunkX; + public final int _chunkZ; + + private ClaimLocation(String worldName, int chunkX, int chunkZ) + { + _worldName = worldName; + _chunkX = chunkX; + _chunkZ = chunkZ; + } + + public static ClaimLocation of(String worldName, int chunkX, int chunkZ) + { + return new ClaimLocation(worldName, chunkX, chunkZ); + } + + public static ClaimLocation of(Chunk chunk) + { + return new ClaimLocation(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()); + } + + public static ClaimLocation fromStoredString(String storedFormat) // TODO: change stored format for next season + { + // Current format: world,x,z + String[] split = storedFormat.split(","); + return new ClaimLocation(split[0], Integer.parseInt(split[1]), Integer.parseInt(split[2])); + } + + public String toStoredString() // TODO: change stored format for next season + { + return _worldName + "," + _chunkX + "," + _chunkZ; + } + + public Chunk toChunk() + { + return Bukkit.getWorld(_worldName).getChunkAt(_chunkX, _chunkZ); + } + + @Override + public int hashCode() + { + return Objects.hash(_worldName, _chunkX, _chunkZ); + } + + @Override + public boolean equals(Object other) + { + if (!(other instanceof ClaimLocation)) + { + return false; + } + + ClaimLocation that = (ClaimLocation) other; + return Objects.equals(_worldName, that._worldName) && Objects.equals(_chunkX, that._chunkX) && Objects.equals(_chunkZ, that._chunkZ); + } +} diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java index f0078e3d7..b57b279c0 100644 --- a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java @@ -9,9 +9,21 @@ import java.sql.Timestamp; import java.util.Collection; import java.util.UUID; -import mineplex.core.common.util.Callback; +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; +import org.jooq.DSLContext; + +import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; -import mineplex.core.database.MinecraftRepository; +import mineplex.database.tables.records.ClansRecord; +import mineplex.game.clans.core.ClaimLocation; +import mineplex.game.clans.core.repository.tokens.ClanAllianceToken; +import mineplex.game.clans.core.repository.tokens.ClanMemberToken; +import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken; +import mineplex.game.clans.core.repository.tokens.ClanToken; +import mineplex.game.clans.core.repository.tokens.ClanWarToken; +import mineplex.game.clans.core.repository.tokens.SimpleClanToken; +import mineplex.game.clans.core.war.ClanWarData; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.ResultSetCallable; @@ -20,22 +32,11 @@ import mineplex.serverdata.database.column.ColumnBoolean; import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnTimestamp; import mineplex.serverdata.database.column.ColumnVarChar; -import mineplex.database.tables.records.ClansRecord; -import mineplex.game.clans.core.repository.tokens.ClanAllianceToken; -import mineplex.game.clans.core.repository.tokens.ClanMemberToken; -import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken; -import mineplex.game.clans.core.repository.tokens.ClanToken; -import mineplex.game.clans.core.repository.tokens.SimpleClanToken; - -import org.bukkit.Bukkit; -import org.bukkit.plugin.java.JavaPlugin; -import mineplex.game.clans.core.repository.tokens.ClanWarToken; -import mineplex.game.clans.core.war.ClanWarData; -import org.jooq.DSLContext; - -import static mineplex.database.Tables.*; -import static org.jooq.impl.DSL.*; +import static mineplex.database.Tables.accountClan; +import static mineplex.database.Tables.accounts; +import static mineplex.database.Tables.clans; +import static org.jooq.impl.DSL.select; public class ClanRepository extends RepositoryBase { @@ -150,7 +151,6 @@ public class ClanRepository extends RepositoryBase * alliances, enemies, teritory claims and homes set on * originating server. * @param clanId - the id of the clan to move - * @param serverId - the id of the destination server being moved to */ public void moveClanServer(final int clanId, String serverName, final Callback callback) { @@ -472,12 +472,12 @@ public class ClanRepository extends RepositoryBase executeUpdate(DELETE_CLAN_ALLIANCE, new ColumnInt("clanid", clanId), new ColumnInt("otherClanId", otherClanId)); } - public boolean addTerritoryClaim(int clanId, String chunk, boolean safe) + public boolean addTerritoryClaim(int clanId, ClaimLocation chunk, boolean safe) { - return executeUpdate(ADD_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("chunk", 100, chunk), new ColumnBoolean("safe", safe)) == 1; + return executeUpdate(ADD_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("chunk", 100, chunk.toStoredString()), new ColumnBoolean("safe", safe)) == 1; } - public boolean addTerritoryClaims(int clanId, boolean safe, String... chunks) + public boolean addTerritoryClaims(int clanId, boolean safe, ClaimLocation... chunks) { int affectedRows = 0; int size = chunks.length; @@ -498,8 +498,9 @@ public class ClanRepository extends RepositoryBase Column safeCol = new ColumnBoolean("safe", safe); int i = 0; - for (String chunk : chunks) + for (ClaimLocation claim : chunks) { + String chunk = claim.toStoredString(); Column chunkCol = new ColumnVarChar("chunk", 100, chunk); clanIdCol.setValue(preparedStatement, i + 1); chunkCol.setValue(preparedStatement, i + 2); @@ -539,9 +540,9 @@ public class ClanRepository extends RepositoryBase // executeUpdate(ADD_CLAN_ENEMY, new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId)); // } - public void removeTerritoryClaim(int clanId, String chunk) + public void removeTerritoryClaim(int clanId, ClaimLocation chunk) { - executeUpdate(DELETE_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("chunk", 100, chunk)); + executeUpdate(DELETE_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("chunk", 100, chunk.toStoredString())); } public void removeTerritoryClaims(int clanId) @@ -574,8 +575,8 @@ public class ClanRepository extends RepositoryBase > 0; } - public void updateTerritoryClaim(String chunk, boolean safe) + public void updateTerritoryClaim(ClaimLocation chunk, boolean safe) { - executeUpdate(UPDATE_CLAN_TERRITORY, new ColumnBoolean("safe", safe), new ColumnVarChar("chunk", 100, chunk)); + executeUpdate(UPDATE_CLAN_TERRITORY, new ColumnBoolean("safe", safe), new ColumnVarChar("chunk", 100, chunk.toStoredString())); } } diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanTerritory.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanTerritory.java index 904388533..658c391ab 100644 --- a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanTerritory.java +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanTerritory.java @@ -2,23 +2,22 @@ package mineplex.game.clans.core.repository; import org.bukkit.Location; -import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken; +import mineplex.game.clans.core.ClaimLocation; public class ClanTerritory { - public ClanTerritory() { } - - public ClanTerritory(ClanTerritoryToken territoryToken) + + public ClanTerritory(ClaimLocation loc, String owner, boolean safe) { - Owner = territoryToken.ClanName; - Safe = territoryToken.Safe; - Chunk = territoryToken.Chunk; + ClaimLocation = loc; + Owner = owner; + Safe = safe; } - + public boolean Safe; public String Owner = ""; - public String Chunk = ""; - + public ClaimLocation ClaimLocation; + public boolean isSafe(Location location) { if (Owner.equals("Spawn")) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java index 9184bd800..2a42c0ae1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java @@ -1,8 +1,6 @@ package mineplex.game.clans.clans; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; @@ -10,6 +8,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.donation.DonationManager; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.shop.energy.EnergyShop; public class ClanEnergyManager extends MiniPlugin implements Runnable @@ -45,7 +44,7 @@ public class ClanEnergyManager extends MiniPlugin implements Runnable if (currentEnergy < energyPerMinute) { - for (String chunk : clanInfo.getClaimSet()) + for (ClaimLocation chunk : clanInfo.getClaimSet()) { _clansManager.getClanDataAccess().unclaimSilent(chunk, true); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java index 2d4d42389..fe1f9b517 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java @@ -9,6 +9,8 @@ import java.util.List; import java.util.Set; import java.util.UUID; +import net.minecraft.server.v1_8_R3.Material; + import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -25,13 +27,13 @@ import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.tntGenerator.TntGenerator; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.tokens.ClanAllianceToken; import mineplex.game.clans.core.repository.tokens.ClanMemberToken; import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken; import mineplex.game.clans.core.repository.tokens.ClanToken; import mineplex.game.clans.core.repository.tokens.ClanWarToken; import mineplex.game.clans.core.war.ClanWarData; -import net.minecraft.server.v1_8_R3.Material; public class ClanInfo { @@ -59,7 +61,7 @@ public class ClanInfo // Loaded from Client private NautHashMap _memberMap = new NautHashMap(); private NautHashMap _allyMap = new NautHashMap(); - private Set _claimSet = new HashSet(); + private Set _claimSet = new HashSet<>(); // Wars Initiated By Others private HashMap _warIn = new HashMap(); @@ -134,7 +136,7 @@ public class ClanInfo for (ClanTerritoryToken territoryToken : token.Territories) { - _claimSet.add(territoryToken.Chunk); + _claimSet.add(ClaimLocation.fromStoredString(territoryToken.Chunk)); } for (ClanAllianceToken allianceToken : token.Alliances) @@ -378,10 +380,7 @@ public class ClanInfo stringList.add(F.main("Clans", getName() + " Territory;")); - for (String cur : getClaimSet()) - { - stringList.add(cur); - } + getClaimSet().stream().map(ClaimLocation::toStoredString).forEach(stringList::add); return stringList; } @@ -439,7 +438,7 @@ public class ClanInfo return _memberMap; } - public Set getClaimSet() + public Set getClaimSet() { return _claimSet; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java index fcc116670..8798c636f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java @@ -2,6 +2,9 @@ package mineplex.game.clans.clans; import java.util.ArrayList; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -9,13 +12,11 @@ import mineplex.core.common.util.UtilInput; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilWorld; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.tokens.ClanToken; import mineplex.game.clans.core.war.ClanWarData; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - public class ClansAdmin { private ClansManager Clans; @@ -761,7 +762,7 @@ public class ClansAdmin if (clientClan == null) return; - String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk()); + ClaimLocation chunk = ClaimLocation.of(caller.getLocation().getChunk()); ClanInfo ownerClan = Clans.getClanUtility().getOwner(caller.getLocation()); //Already Claimed @@ -800,7 +801,7 @@ public class ClansAdmin if (clientClan == null) return; - String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk()); + ClaimLocation chunk = ClaimLocation.of(caller.getLocation().getChunk()); ClanInfo ownerClan = Clans.getClanUtility().getOwner(caller.getLocation()); //Not Claimed @@ -826,12 +827,12 @@ public class ClansAdmin return; //Unclaim - ArrayList toUnclaim = new ArrayList(); + ArrayList toUnclaim = new ArrayList<>(); - for (String chunk : clientClan.getClaimSet()) + for (ClaimLocation chunk : clientClan.getClaimSet()) toUnclaim.add(chunk); - for (String chunk : toUnclaim) + for (ClaimLocation chunk : toUnclaim) Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true); //Inform @@ -861,7 +862,7 @@ public class ClansAdmin return; } - if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(clan.getHome().getChunk()))) + if (!clan.getClaimSet().contains(ClaimLocation.of(clan.getHome().getChunk()))) { UtilPlayer.message(caller, F.main("Clans Admin", "Your Clan has lost its Home Territory.")); return; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java index f92282c73..81e0244f6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java @@ -23,6 +23,7 @@ import mineplex.game.clans.clans.event.ClanLeaveEvent; import mineplex.game.clans.clans.event.ClanSetHomeEvent; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.tntGenerator.TntGenerator; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanRepository; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.tokens.ClanToken; @@ -71,7 +72,7 @@ public class ClansDataAccessLayer public void deleteLocally(ClanInfo clan) { // Territory Unclaim - for (String cur : clan.getClaimSet()) + for (ClaimLocation cur : clan.getClaimSet()) { _manager.getClaimMap().remove(cur); } @@ -454,14 +455,14 @@ public class ClansDataAccessLayer _manager.log("Added Neutral between [" + cA.getName() + "] and [" + cB.getName() + "] by [" + player + "]."); } - public boolean claimAll(final String name, final String player, final boolean safe, final String... chunks) + public boolean claimAll(final String name, final String player, final boolean safe, final ClaimLocation... chunks) { if (!_manager.getClanMap().containsKey(name)) return false; final ClanInfo clan = _manager.getClanMap().get(name); // Unclaim - for (String chunk : chunks) + for (ClaimLocation chunk : chunks) { if (_manager.getClaimMap().containsKey(chunk)) { @@ -469,9 +470,7 @@ public class ClansDataAccessLayer } // Memory - ClanTerritory claim = new ClanTerritory(); - claim.Owner = name; - claim.Safe = safe; + ClanTerritory claim = new ClanTerritory(chunk, name, safe); clan.getClaimSet().add(chunk); _manager.getClaimMap().put(chunk, claim); } @@ -493,7 +492,7 @@ public class ClansDataAccessLayer } @SuppressWarnings("deprecation") - public boolean claim(String name, final String chunk, String player, final boolean safe) + public boolean claim(String name, final ClaimLocation chunk, String player, final boolean safe) { if (!_manager.getClanMap().containsKey(name)) return false; @@ -503,10 +502,7 @@ public class ClansDataAccessLayer if (_manager.getClaimMap().containsKey(chunk)) unclaim(chunk, player, false); // Memory - ClanTerritory claim = new ClanTerritory(); - claim.Owner = name; - claim.Safe = safe; - claim.Chunk = chunk; + ClanTerritory claim = new ClanTerritory(chunk, name, safe); clan.getClaimSet().add(chunk); _manager.getClaimMap().put(chunk, claim); @@ -521,7 +517,7 @@ public class ClansDataAccessLayer }); // Visual - Chunk c = UtilWorld.strToChunk(chunk); + Chunk c = chunk.toChunk(); if (!clan.isAdmin()) { for (int x = 0; x < 16; x++) @@ -544,7 +540,7 @@ public class ClansDataAccessLayer return true; } - public boolean unclaim(final String chunk, String player, boolean sql) + public boolean unclaim(final ClaimLocation chunk, String player, boolean sql) { ClanTerritory claim = _manager.getClaimMap().remove(chunk); @@ -577,7 +573,7 @@ public class ClansDataAccessLayer }); // Restore any glowstone blocks - Chunk c = UtilWorld.strToChunk(chunk); + Chunk c = chunk.toChunk(); if (!clan.isAdmin()) { for (int x = 0; x < 16; x++) @@ -615,7 +611,7 @@ public class ClansDataAccessLayer return true; } - public boolean unclaimSilent(String chunk, boolean sql) + public boolean unclaimSilent(ClaimLocation chunk, boolean sql) { return unclaim(chunk, null, sql); } @@ -790,12 +786,12 @@ public class ClansDataAccessLayer @Override public void run() { - _repository.updateTerritoryClaim(claim.Chunk, claim.Safe); + _repository.updateTerritoryClaim(claim.ClaimLocation, claim.Safe); } }); // Log - _manager.log("Safe Zone at [" + claim.Chunk + "] set to [" + claim.Safe + "] by [" + player + "]."); + _manager.log("Safe Zone at [" + claim.ClaimLocation.toStoredString() + "] set to [" + claim.Safe + "] by [" + player + "]."); } public void retrieveClan(final String clanName, final Callback callback) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java index 0c5629d2d..8123f862a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java @@ -23,6 +23,7 @@ import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; import mineplex.game.clans.clans.nether.NetherManager; import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanTerritory; public class ClansDisplay extends MiniPlugin @@ -112,7 +113,7 @@ public class ClansDisplay extends MiniPlugin if (claim != null) { // Relation - ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.Chunk); + ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.ClaimLocation); // Name ownerString = _clansManager.getClanUtility().mRel(relation, claim.Owner, false); @@ -201,8 +202,8 @@ public class ClansDisplay extends MiniPlugin } // Get Data - ClanInfo curOwner = _clansManager.getClanUtility().getOwner(UtilWorld.chunkToStr(curChunk)); - ClanTerritory curClaim = _clansManager.getClanUtility().getClaim(UtilWorld.chunkToStr(curChunk)); + ClanInfo curOwner = _clansManager.getClanUtility().getOwner(ClaimLocation.of(curChunk)); + ClanTerritory curClaim = _clansManager.getClanUtility().getClaim(ClaimLocation.of(curChunk)); // Add Icon if (i == chunk.getX() && j == chunk.getZ()) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index b5c293a04..1794c63e5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -115,6 +115,7 @@ import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.potato.PotatoManager; import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler; import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.siege.SiegeManager; @@ -245,8 +246,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati // NautHashMap(); private NautHashMap _clanMemberUuidMap = new NautHashMap(); private NautHashMap> _clanMemberLeftMap = new NautHashMap<>(); - private NautHashMap _claimMap = new NautHashMap(); - private NautHashMap _unclaimMap = new NautHashMap(); + private NautHashMap _claimMap = new NautHashMap<>(); + private NautHashMap _unclaimMap = new NautHashMap<>(); public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator; @@ -507,8 +508,12 @@ public class ClansManager extends MiniClientPluginimplements IRelati } for (ClanTerritoryToken territoryToken : clanToken.Territories) - _claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken)); - + { + String[] split = territoryToken.Chunk.split(","); + ClaimLocation location = ClaimLocation.of(split[0], Integer.parseInt(split[1]), Integer.parseInt(split[2])); + _claimMap.put(location, new ClanTerritory(ClaimLocation.fromStoredString(territoryToken.Chunk), territoryToken.ClanName, territoryToken.Safe)); + } + if (loadBanner) _bannerManager.loadBanner(clan); } @@ -651,7 +656,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati return getClan(clanName) != null; } - public NautHashMap getClaimMap() + public NautHashMap getClaimMap() { return _claimMap; } @@ -1130,7 +1135,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati return _clanDisplay; } - public NautHashMap getUnclaimMap() + public NautHashMap getUnclaimMap() { return _unclaimMap; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index a2ecef65e..4f63bf168 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -23,6 +23,7 @@ import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.spawn.Spawn; @@ -300,10 +301,10 @@ public class ClansUtility // PlayerList#updatePlayers -> iterator -> PlayerVelocityEvent -> getChunk -> loadChunk -> loadPersistentEntities -> addTracker -> ITERATE ON SAME SET int chunkX = loc.getBlockX() >> 4; int chunkZ = loc.getBlockZ() >> 4; - String chunkStr = UtilWorld.chunkToStr(loc.getWorld().getName(), chunkX, chunkZ); - if (!_clansManager.getClaimMap().containsKey(chunkStr)) return false; + ClaimLocation claim = ClaimLocation.of(loc.getWorld().getName(), chunkX, chunkZ); + if (!_clansManager.getClaimMap().containsKey(claim)) return false; - return _clansManager.getClaimMap().get(chunkStr).isSafe(loc); + return _clansManager.getClaimMap().get(claim).isSafe(loc); } public boolean isChunkHome(ClanInfo clan, Chunk chunk) @@ -317,7 +318,7 @@ public class ClansUtility public ClanTerritory getClaim(Chunk chunk) { - String chunkTag = UtilWorld.chunkToStr(chunk); + ClaimLocation chunkTag = ClaimLocation.of(chunk); return _clansManager.getClaimMap().get(chunkTag); } @@ -334,12 +335,12 @@ public class ClansUtility return getClaim(loc.getChunk()); } - public ClanTerritory getClaim(String chunk) + public ClanTerritory getClaim(ClaimLocation location) { - return _clansManager.getClaimMap().get(chunk); + return _clansManager.getClaimMap().get(location); } - public ClanInfo getOwner(String chunk) + public ClanInfo getOwner(ClaimLocation chunk) { ClanTerritory claim = getClaim(chunk); @@ -365,7 +366,7 @@ public class ClansUtility { if (xOffset == 0 && zOffset == 0) continue; - String other = UtilWorld.chunkToStr(location.getWorld().getChunkAt(location.getChunk().getX() + xOffset, location.getChunk().getZ() + zOffset)); + ClaimLocation other = ClaimLocation.of(location.getWorld().getChunkAt(location.getChunk().getX() + xOffset, location.getChunk().getZ() + zOffset)); ClanInfo adjClan = getOwner(other); @@ -395,13 +396,13 @@ public class ClansUtility public String getOwnerStringRel(Location loc, Player player) { - ClanRelation rel = relPT(player, UtilWorld.chunkToStr(loc.getChunk())); + ClanRelation rel = relPT(player, ClaimLocation.of(loc.getChunk())); return mRel(rel, getOwnerString(loc), true); } public boolean isClaimed(Location loc) { - String chunk = UtilWorld.chunkToStr(loc.getChunk()); + ClaimLocation chunk = ClaimLocation.of(loc.getChunk()); return _clansManager.getClaimMap().containsKey(chunk); } @@ -478,7 +479,7 @@ public class ClansUtility } // Territory Territory - public ClanRelation relTT(String tA, String tB) + public ClanRelation relTT(ClaimLocation tA, ClaimLocation tB) { return rel(getOwner(tA), getOwner(tB)); } @@ -496,7 +497,7 @@ public class ClansUtility } // Player Territory - public ClanRelation relPT(Player player, String territory) + public ClanRelation relPT(Player player, ClaimLocation territory) { ClanTerritory claim = getClaim(territory); if (claim != null && claim.isSafe(player.getLocation())) @@ -508,7 +509,7 @@ public class ClansUtility } // Clan Territory - public ClanRelation relCT(String cA, String tB) + public ClanRelation relCT(String cA, ClaimLocation tB) { ClanTerritory claim = getClaim(tB); if (claim != null) if (claim.Safe) return ClanRelation.SAFE; @@ -792,7 +793,7 @@ public class ClansUtility return false; } - String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk()); + ClaimLocation chunk = ClaimLocation.of(caller.getLocation().getChunk()); ClanInfo ownerClan = getOwner(caller.getLocation()); // Try to Steal @@ -829,7 +830,7 @@ public class ClansUtility continue; } - String other = UtilWorld.chunkToStr(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z)); + ClaimLocation other = ClaimLocation.of(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z)); ClanInfo adjClan = getOwner(other); @@ -928,10 +929,10 @@ public class ClansUtility int boxed = 0; // This is bad. I know. But the other way doesn't seem to work. - String down = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 0, chunk.getZ() + 1)); - String up = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1)); - String right = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ())); - String left = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ())); + ClaimLocation down = ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX() + 0, chunk.getZ() + 1)); + ClaimLocation up = ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1)); + ClaimLocation right = ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ())); + ClaimLocation left = ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ())); ClanInfo downClan = getOwner(down); ClanInfo upClan = getOwner(up); @@ -960,7 +961,7 @@ public class ClansUtility UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); // Unclaim - _clansManager.getClanDataAccess().unclaim(UtilWorld.chunkToStr(caller.getLocation().getChunk()), caller.getName(), true); + _clansManager.getClanDataAccess().unclaim(ClaimLocation.of(caller.getLocation().getChunk()), caller.getName(), true); return true; } @@ -1132,7 +1133,7 @@ public class ClansUtility return false; } - String chunk = UtilWorld.chunkToStr(c); + ClaimLocation chunk = ClaimLocation.of(c); ClanInfo ownerClan = getOwner(caller.getLocation()); // Try to Steal @@ -1189,14 +1190,14 @@ public class ClansUtility } // Unclaim - ArrayList toUnclaim = new ArrayList(); + ArrayList toUnclaim = new ArrayList<>(); - for (String chunk : clan.getClaimSet()) + for (ClaimLocation chunk : clan.getClaimSet()) { toUnclaim.add(chunk); } - for (String chunk : toUnclaim) + for (ClaimLocation chunk : toUnclaim) { _clansManager.getClanDataAccess().unclaim(chunk, caller.getName(), true); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java index 9408255bd..ef76e4a6b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import net.minecraft.server.v1_8_R3.EnumDirection; + import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; @@ -25,7 +27,6 @@ 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.UtilServer; -import mineplex.core.common.util.UtilWorld; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; @@ -33,9 +34,8 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.claimview.commands.ClaimVisualizeCommand; import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClanLeaveEvent; -import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; -import net.minecraft.server.v1_8_R3.EnumDirection; +import mineplex.game.clans.core.ClaimLocation; public class ClaimVisualizer extends MiniPlugin { @@ -43,7 +43,7 @@ public class ClaimVisualizer extends MiniPlugin private List _visualizing; - private NautHashMap> _calculated; + private NautHashMap> _calculated; public ClaimVisualizer(JavaPlugin plugin, ClansManager clansManager) { @@ -55,7 +55,7 @@ public class ClaimVisualizer extends MiniPlugin for (ClanInfo clan : _clansManager.getClanMap().values()) { - _calculated.put(clan, new NautHashMap()); + _calculated.put(clan, new NautHashMap<>()); } } @@ -76,11 +76,11 @@ public class ClaimVisualizer extends MiniPlugin _calculated.clear(); for (ClanInfo clan : _clansManager.getClanMap().values()) { - _calculated.put(clan, new NautHashMap()); + _calculated.put(clan, new NautHashMap<>()); - for (String serialized : clan.getClaimSet()) + for (ClaimLocation chunk : clan.getClaimSet()) { - calculate(clan, serialized); + calculate(clan, chunk); } } } @@ -106,11 +106,11 @@ public class ClaimVisualizer extends MiniPlugin private void visualize(Player player) { - for (String serialized : _clansManager.getClan(player).getClaimSet()) + for (ClaimLocation claim : _clansManager.getClan(player).getClaimSet()) { - if (!_calculated.get(_clansManager.getClan(player)).containsKey(serialized)) + if (!_calculated.get(_clansManager.getClan(player)).containsKey(claim)) { - calculate(_clansManager.getClan(player), serialized); + calculate(_clansManager.getClan(player), claim); } } @@ -153,35 +153,35 @@ public class ClaimVisualizer extends MiniPlugin } } - private void calculate(ClanInfo clan, String serialized) + private void calculate(ClanInfo clan, ClaimLocation claim) { - Chunk chunk = UtilWorld.strToChunk(serialized); + Chunk chunk = claim.toChunk(); List dirs = new ArrayList<>(); - if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1)))) + if (!clan.getClaimSet().contains(ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1)))) { dirs.add(EnumDirection.NORTH); } - if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ())))) + if (!clan.getClaimSet().contains(ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ())))) { dirs.add(EnumDirection.EAST); } - if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() + 1)))) + if (!clan.getClaimSet().contains(ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() + 1)))) { dirs.add(EnumDirection.SOUTH); } - if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ())))) + if (!clan.getClaimSet().contains(ClaimLocation.of(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ())))) { dirs.add(EnumDirection.WEST); } VisualizedChunkData cached = new VisualizedChunkData(chunk, dirs); - _calculated.get(clan).put(serialized, cached); + _calculated.get(clan).put(claim, cached); } @EventHandler @@ -228,9 +228,9 @@ public class ClaimVisualizer extends MiniPlugin { _calculated.clear(); - for (String serialized : clan.getClaimSet()) + for (ClaimLocation claim : clan.getClaimSet()) { - calculate(clan, serialized); + calculate(clan, claim); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index adef219f9..acec71fc3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -4,6 +4,8 @@ package mineplex.game.clans.clans.commands; import java.util.Collections; import java.util.List; +import net.minecraft.server.v1_8_R3.EnumDirection; + import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; @@ -37,9 +39,9 @@ import mineplex.game.clans.clans.ClientClan; import mineplex.game.clans.clans.event.ClanJoinEvent; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.spawn.Spawn; -import net.minecraft.server.v1_8_R3.EnumDirection; public class ClansCommand extends CommandBase { @@ -967,7 +969,7 @@ public class ClansCommand extends CommandBase UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); // Unclaim - Plugin.getClanDataAccess().unclaim(UtilWorld.chunkToStr(caller.getLocation().getChunk()), caller.getName(), true); + Plugin.getClanDataAccess().unclaim(ClaimLocation.of(caller.getLocation().getChunk()), caller.getName(), true); return true; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java index 07ac8f1cf..37dfc4dc7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java @@ -1,6 +1,6 @@ package mineplex.game.clans.clans.map; -import java.awt.Color; +import java.awt.*; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -18,6 +18,7 @@ import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.clans.worldevent.WorldEventManager; import mineplex.game.clans.clans.worldevent.api.EventState; import mineplex.game.clans.clans.worldevent.api.WorldEvent; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.tutorial.TutorialManager; public class ItemMapRenderer extends MapRenderer @@ -107,7 +108,7 @@ public class ItemMapRenderer extends MapRenderer blockX *= zoom; blockZ *= zoom; - String chunk = "world," + (int) Math.floor(blockX / 16D) + "," + (int) Math.floor(blockZ / 16D); + ClaimLocation chunk = ClaimLocation.of("world", (int) Math.floor(blockX / 16D), (int) Math.floor(blockZ / 16D)); ClanInfo owningClan = _manager.getClansUtility().getOwner(chunk); @@ -196,19 +197,19 @@ public class ItemMapRenderer extends MapRenderer ((chunkBX == 0 || zoom == 13) && - owningClan != _manager.getClansUtility().getOwner("world," + (chunkX1 - 1) + "," + chunkZ1)) + owningClan != _manager.getClansUtility().getOwner(ClaimLocation.of("world", chunkX1 - 1, chunkZ1))) || ((chunkBZ == 0 || zoom == 13) && - owningClan != _manager.getClansUtility().getOwner("world," + chunkX1 + "," + (chunkZ1 - 1))) + owningClan != _manager.getClansUtility().getOwner(ClaimLocation.of("world", chunkX1, chunkZ1 - 1))) || ((chunkBX + zoom > 15 || zoom == 13) && - owningClan != _manager.getClansUtility().getOwner("world," + (chunkX1 + 1) + "," + chunkZ1)) + owningClan != _manager.getClansUtility().getOwner(ClaimLocation.of("world", chunkX1 + 1, chunkZ1))) || ((chunkBZ + zoom > 15 || zoom == 13) && - owningClan != _manager.getClansUtility().getOwner("world," + chunkX1 + "," + (chunkZ1 + 1)))) + owningClan != _manager.getClansUtility().getOwner(ClaimLocation.of("world", chunkX1, chunkZ1 + 1)))) { Color cColor = MapPalette.getColor(color); double clans = colorAll ? 1 : 0.8;// 0.65; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java index 3ea0964b8..012fdc19b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java @@ -3,13 +3,6 @@ package mineplex.game.clans.clans.regions; import java.util.HashSet; import java.util.Set; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.Callback; -import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.spawn.Spawn; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTeleportEvent; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -17,6 +10,14 @@ import org.bukkit.WorldBorder; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.Callback; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.core.ClaimLocation; +import mineplex.game.clans.spawn.Spawn; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTeleportEvent; + public class ClansRegions extends MiniPlugin { public final static String DEFAULT_WORLD_NAME = "world"; @@ -103,7 +104,7 @@ public class ClansRegions extends MiniPlugin System.out.println("Clearing claims for " + name + " with clan id " + clan + "!"); - for (String chunk : clan.getClaimSet()) + for (ClaimLocation chunk : clan.getClaimSet()) { _manager.getClaimMap().remove(chunk); } @@ -168,7 +169,7 @@ public class ClansRegions extends MiniPlugin { int chunkX = location.getChunk().getX(); int chunkZ = location.getChunk().getZ(); - Set chunks = new HashSet(); + Set chunks = new HashSet<>(); int start = addNegative ? -chunkRadius - 1 : -chunkRadius; @@ -178,7 +179,7 @@ public class ClansRegions extends MiniPlugin { int x = chunkX + xOffset; int z = chunkZ + zOffset; - String chunkStr = location.getWorld().getName() + "," + x + "," + z; + ClaimLocation chunk = ClaimLocation.of(location.getWorld().getName(), x, z); if (addNegative) { @@ -192,19 +193,19 @@ public class ClansRegions extends MiniPlugin continue; } - if (_manager.getClaimMap().containsKey(chunkStr)) + if (_manager.getClaimMap().containsKey(chunk)) { // System.out.println("get claim map contains " + chunkStr); // this is really really slowing server startup down. just saying. continue; } - chunks.add(chunkStr); + chunks.add(chunk); } } if (chunks.size() > 0) { - _manager.getClanDataAccess().claimAll(clan.getName(), "ClansRegions", safe, chunks.toArray(new String[0])); + _manager.getClanDataAccess().claimAll(clan.getName(), "ClansRegions", safe, chunks.toArray(new ClaimLocation[chunks.size()])); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java index 75b8ef44d..17ca21092 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java @@ -2,6 +2,10 @@ package mineplex.game.clans.clans.scoreboard.elements; import java.util.List; +import org.bukkit.entity.Player; + +import com.google.common.collect.Lists; + import mineplex.core.common.util.C; import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; @@ -9,10 +13,6 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.core.repository.ClanTerritory; -import org.bukkit.entity.Player; - -import com.google.common.collect.Lists; - public class ScoreboardElementPlayer implements ScoreboardElement { private ClansManager _clansManager; @@ -37,7 +37,7 @@ public class ScoreboardElementPlayer implements ScoreboardElement if (claim != null) { //Relation - ClansUtility.ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.Chunk); + ClansUtility.ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.ClaimLocation); //Name regionString = _clansManager.getClanUtility().mRel(relation, claim.Owner, false); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticMaul.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticMaul.java index 8b05823fb..4f033e705 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticMaul.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticMaul.java @@ -1,5 +1,11 @@ package mineplex.game.clans.items.legendaries; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; @@ -11,17 +17,11 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - public class MagneticMaul extends LegendaryItem { private static final double PULL_RANGE = 10d; @@ -42,7 +42,7 @@ public class MagneticMaul extends LegendaryItem public void update(Player wielder) { Location loc = wielder.getLocation(); - ClanTerritory territory = ClansManager.getInstance().getClaimMap().get(UtilWorld.chunkToStr(loc)); + ClanTerritory territory = ClansManager.getInstance().getClaimMap().get(ClaimLocation.of(loc.getChunk())); if (territory != null && territory.isSafe(loc)) { return; @@ -95,9 +95,9 @@ public class MagneticMaul extends LegendaryItem if (otherTargetDistance < targetDistance && otherDistance <= PULL_RANGE) { // If entity is in safe zone, don't allow pulling of that entity. - if (ClansManager.getInstance().getClaimMap().containsKey(UtilWorld.chunkToStr(entity.getLocation()))) + if (ClansManager.getInstance().getClaimMap().containsKey(ClaimLocation.of(entity.getLocation().getChunk()))) { - if (ClansManager.getInstance().getClaimMap().get(UtilWorld.chunkToStr(entity.getLocation())).isSafe(entity.getLocation())) + if (ClansManager.getInstance().getClaimMap().get(ClaimLocation.of(entity.getLocation().getChunk())).isSafe(entity.getLocation())) { continue; } From 739cb83deb87a3ffd04420850035000bca92ff50 Mon Sep 17 00:00:00 2001 From: cnr Date: Sat, 17 Jun 2017 14:50:58 -0500 Subject: [PATCH 227/283] Revert "Re-implement the main clans tutorial" This reverts commit 1574d93d1b463514db1074f61f34fec9df49a38a. --- .../clans/tutorial/tutorials/clans/ClansMainTutorial.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java index 9e843924e..558ac863d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java @@ -464,7 +464,7 @@ public class ClansMainTutorial extends Tutorial // } // }); - if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier())) + /*if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier())) { ClanInfo clan = ClansManager.getInstance().getClan(event.getPlayer()); if (clan == null) @@ -476,7 +476,7 @@ public class ClansMainTutorial extends Tutorial UtilPlayer.message(event.getPlayer(), F.main("Clans", "It seems you already have a clan here, so we can skip the tutorial")); } } - else if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld())) + else */if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld())) { Spawn.getInstance().teleport(event.getPlayer(), Spawn.getInstance().getSpawnLocation(), 2); } From afdf1a1ad6e8247dc2f5f52efd06a99c9452921c Mon Sep 17 00:00:00 2001 From: cnr Date: Sat, 17 Jun 2017 15:45:39 -0500 Subject: [PATCH 228/283] Fix missed string -> ClaimLocation migration --- .../src/mineplex/game/clans/clans/commands/ClansCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index acec71fc3..e3c90587a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -1027,7 +1027,7 @@ public class ClansCommand extends CommandBase return; } - if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(clan.getHome().getChunk()))) + if (!clan.getClaimSet().contains(ClaimLocation.of(clan.getHome().getChunk()))) { UtilPlayer.message(caller, F.main("Clans", "Your Clan has lost its Home Territory.")); return; From 185ac9fc05b3b1d06d38950cf12786b54c43cc23 Mon Sep 17 00:00:00 2001 From: cnr Date: Sun, 18 Jun 2017 11:23:16 -0500 Subject: [PATCH 229/283] Allow youtubers into full clans servers --- .../src/mineplex/game/clans/clans/ClansManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 1794c63e5..fc98e0c23 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -1273,10 +1273,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati online++; } - if (online >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) + if (online >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && rank != Rank.YOUTUBE && rank != Rank.YOUTUBE_SMALL && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) { event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This Clans server is full! Try again soon"); - event.setKickMessage("This Clans server is full! Try again soon"); } else { From db98aa01c8cc17e8859b63008a91ba90f4be95fd Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 19 Jun 2017 17:10:06 +0100 Subject: [PATCH 230/283] Training game base --- .../src/mineplex/core/game/GameDisplay.java | 3 +- .../src/nautilus/game/arcade/GameType.java | 2 + .../game/arcade/game/games/moba/Moba.java | 52 ++++---- .../games/moba/boss/wither/WitherBoss.java | 7 ++ .../games/moba/kit/larissa/SkillAOEHeal.java | 7 ++ .../games/moba/training/MobaTraining.java | 115 ++++++++++++++++++ .../game/modules/TrainingGameModule.java | 9 +- 7 files changed, 165 insertions(+), 30 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 8b7ec8606..381b5069b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -104,7 +104,8 @@ public enum GameDisplay AlienInvasion("Alien Invasion", Material.ENDER_STONE, (byte) 0, GameCategory.EVENT, 69, false), - MOBA("Heroes of GWEN", Material.SKULL_ITEM, (byte)1, GameCategory.CLASSICS, 70, true), + MOBA("Heroes of GWEN", Material.PRISMARINE, (byte)0, GameCategory.CLASSICS, 70, false), + MOBATraining("Heroes of GWEN Training", Material.PRISMARINE, (byte)0, GameCategory.CLASSICS, 70, false), GemHunters("Gem Hunters", Material.EMERALD, (byte) 0, GameCategory.SURVIVAL, 71, false), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index ac4f37774..fb504456a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -63,6 +63,7 @@ import nautilus.game.arcade.game.games.minestrike.Minestrike; import nautilus.game.arcade.game.games.minestrike.modes.SuperPaintstrike; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.training.MobaTraining; import nautilus.game.arcade.game.games.monsterleague.MonsterLeague; import nautilus.game.arcade.game.games.monstermaze.MonsterMaze; import nautilus.game.arcade.game.games.oldmineware.OldMineWare; @@ -233,6 +234,7 @@ public enum GameType AlienInvasion(AlienInvasion.class, GameDisplay.AlienInvasion), MOBA(Moba.class, GameDisplay.MOBA), + MOBATraining(MobaTraining.class, GameDisplay.MOBA), Event(EventGame.class, GameDisplay.Event, new GameType[]{ GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index fa549da2e..2024cc3d7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -91,18 +91,23 @@ public class Moba extends TeamGame private final Set _listeners = new HashSet<>(); - private final MobaShop _shop; - private final GoldManager _goldManager; - private final BossManager _boss; - private final TowerManager _tower; - private final CapturePointManager _capturePoint; - private final ArrowKBManager _arrowKb; - private final BuffManager _buffs; + protected final MobaShop _shop; + protected final GoldManager _goldManager; + protected final BossManager _boss; + protected final TowerManager _tower; + protected final CapturePointManager _capturePoint; + protected final ArrowKBManager _arrowKb; + protected final BuffManager _buffs; private BetaWhitelist _betaWhitelist; public Moba(ArcadeManager manager) { - super(manager, GameType.MOBA, new Kit[]{new KitPlayer(manager)}, DESCRIPTION); + this(manager, GameType.MOBA); + } + + public Moba(ArcadeManager manager, GameType gameType) + { + super(manager, gameType, new Kit[]{new KitPlayer(manager)}, DESCRIPTION); _kits = new HeroKit[]{ new HeroHattori(Manager), @@ -527,6 +532,17 @@ public class Moba extends TeamGame _listeners.forEach(UtilServer::Unregister); _listeners.clear(); _betaWhitelist.deregisterSelf(); + + // Undisguise all players + for (Player player : Bukkit.getOnlinePlayers()) + { + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + + if (disguise != null && disguise instanceof DisguisePlayer) + { + Manager.GetDisguise().undisguise(disguise); + } + } } @Override @@ -565,26 +581,6 @@ public class Moba extends TeamGame } } - // Undisguise everyone upon game end - @EventHandler - public void end(GameStateChangeEvent event) - { - if (event.GetState() != GameState.End && event.GetState() != GameState.Dead) - { - return; - } - - for (Player player : Bukkit.getOnlinePlayers()) - { - DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); - - if (disguise != null && disguise instanceof DisguisePlayer) - { - Manager.GetDisguise().undisguise(disguise); - } - } - } - public Map getLocationStartsWith(String s) { Map map = new HashMap<>(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index edf900681..bd8177115 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -21,6 +21,7 @@ import nautilus.game.arcade.game.games.moba.boss.MobaBoss; import nautilus.game.arcade.game.games.moba.boss.wither.attack.BossAttackEarthquake; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; +import nautilus.game.arcade.game.games.moba.training.MobaTraining; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.EntityEffect; import org.bukkit.Location; @@ -100,6 +101,12 @@ public class WitherBoss extends MobaBoss @EventHandler(priority = EventPriority.LOWEST) public void preDamage(CustomDamageEvent event) { + if (_host instanceof MobaTraining) + { + event.SetCancelled("Training Mode"); + return; + } + if (!event.GetDamageeEntity().equals(_entity) || MobaUtil.isInBoundary(_team, _entity, _location, getAi().getBoundaries(), event.GetDamagerPlayer(true))) { return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java index 5f12478e4..64441aa11 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java @@ -31,6 +31,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; @@ -81,6 +82,12 @@ public class SkillAOEHeal extends HeroSkill implements IThrown Manager.GetProjectile().AddThrow(item, player, this, 1000, true, true, true, false, 1F); } + @EventHandler + public void emptyBucket(PlayerBucketEmptyEvent event) + { + event.setCancelled(true); + } + @Override public void Collide(LivingEntity target, Block block, ProjectileUser data) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java new file mode 100644 index 000000000..73cb8e7c0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -0,0 +1,115 @@ +package nautilus.game.arcade.game.games.moba.training; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.hologram.Hologram; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.modules.TrainingGameModule; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.function.Function; + +public class MobaTraining extends Moba +{ + + private static final String[][] HELP_HOLOGRAMS = + { + { + + } + }; + private static final int GOLD = 100000; + + private Location _borderA; + private Location _borderB; + private Function _safeFunction = player -> UtilAlg.inBoundingBox(player.getLocation(), _borderA, _borderB); + private Function _teamFunction = player -> GetTeam(ChatColor.GRAY); + + public MobaTraining(ArcadeManager manager) + { + super(manager, GameType.MOBATraining); + + DeathSpectateSecs = 0; + PrepareTime = 500; + GiveClock = false; + HideTeamSheep = true; + + new TrainingGameModule() + .setGiveReturnToSpawn(false) + .setSkillFunction(_safeFunction) + .setDamageFunction(_safeFunction) + .setTeamFunction(_teamFunction) + .register(this); + } + + @Override + public void ParseData() + { + List locations = WorldData.GetDataLocs("BROWN"); + + _borderA = locations.get(0); + _borderB = locations.get(1); + } + + @EventHandler + public void customTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + { + return; + } + + GameTeam players = GetTeam(ChatColor.GRAY); + players.SetName("Players"); + players.setDisplayName(C.cGray + "Players"); + } + + @EventHandler + public void giveGold(PlayerStateChangeEvent event) + { + if (event.GetState() == PlayerState.IN) + { + _goldManager.addGold(event.GetPlayer(), GOLD); + } + } + + @EventHandler + public void spawnTutorial(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + CreatureAllowOverride = true; + + CreatureAllowOverride = false; + } + + private void spawnHelpText() + { + Map locationMap = getLocationStartsWith("HELP"); + + for (Entry entry : locationMap.entrySet()) + { + String[] split = entry.getKey().split(" "); + String index = split[0]; + int indexInt = Integer.parseInt(index); + String[] display = HELP_HOLOGRAMS[indexInt]; + + new Hologram(Manager.getHologramManager(), entry.getValue(), true, display).start(); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java index 3305ba089..45dbf6e46 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java @@ -45,6 +45,7 @@ public class TrainingGameModule extends Module private Function _teamFunction; private Function _skillFunction; private Function _damageFunction; + private boolean _giveReturnToSpawn = true; public TrainingGameModule() { @@ -282,7 +283,7 @@ public class TrainingGameModule extends Module @EventHandler public void giveReturnToSpawn(UpdateEvent event) { - if (event.getType() != UpdateType.FAST) + if (event.getType() != UpdateType.FAST || !_giveReturnToSpawn) { return; } @@ -343,6 +344,12 @@ public class TrainingGameModule extends Module return this; } + public TrainingGameModule setGiveReturnToSpawn(boolean b) + { + _giveReturnToSpawn = b; + return this; + } + private LobbyEnt getFromEntity(Entity entity) { for (LobbyEnt lobbyEnt : _kits) From 7868287ace86498936501ed94d3c3b807d5277f4 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 19 Jun 2017 18:53:34 -0400 Subject: [PATCH 231/283] Temporarily disable clans maps --- .../mineplex/game/clans/clans/ClansGame.java | 2 +- .../game/clans/clans/ClansManager.java | 14 +++++------ .../clans/clans/commands/ClansCommand.java | 24 +++++++++---------- .../game/clans/clans/commands/MapCommand.java | 2 +- .../clans/clans/nether/NetherManager.java | 14 +++++------ .../clans/worldevent/raid/RaidManager.java | 22 ++++++++--------- .../tutorials/clans/ClansMainTutorial.java | 2 +- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index e9116153c..15b9df83f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -377,7 +377,7 @@ public class ClansGame extends MiniPlugin @EventHandler public void respawn(PlayerRespawnEvent event) { - _clans.getItemMapManager().setMap(event.getPlayer()); + //_clans.getItemMapManager().setMap(event.getPlayer()); } @EventHandler(priority = EventPriority.LOW) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index fc98e0c23..8d872a932 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -221,7 +221,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati private ProjectileManager _projectileManager; private WorldEventManager _worldEvent; private Chat _chat; - private ItemMapManager _itemMapManager; +// private ItemMapManager _itemMapManager; private DisguiseManager _disguiseManager; private NpcManager _npcManager; private Explosion _explosion; @@ -305,7 +305,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _clanGame = new ClansGame(plugin, this); _clanUtility = new ClansUtility(this); _tutorial = new TutorialManager(plugin, clientManager, donationManager, chat, hologramManager, this, _npcManager, _taskManager); - _itemMapManager = new ItemMapManager(this, _tutorial, _worldEvent); +// _itemMapManager = new ItemMapManager(this, _tutorial, _worldEvent); new TntGeneratorManager(plugin, this); new SupplyDropManager(plugin, this); @@ -492,7 +492,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati addCommand(new ClansChatCommand(this)); addCommand(new ClansAllyChatCommand(this)); addCommand(new ClanManagementCommand(this)); - addCommand(new MapCommand(this)); +// addCommand(new MapCommand(this)); addCommand(new SpeedCommand(this)); } @@ -563,10 +563,10 @@ public class ClansManager extends MiniClientPluginimplements IRelati return _inventoryManager; } - public ItemMapManager getItemMapManager() - { - return _itemMapManager; - } +// public ItemMapManager getItemMapManager() +// { +// return _itemMapManager; +// } public Explosion getExplosion() { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index e3c90587a..aaa084382 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -987,18 +987,18 @@ public class ClansCommand extends CommandBase Plugin.getClanUtility().unclaimAll(caller); } - public void map(Player caller, String[] args) - { - ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "map"); - UtilServer.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) - { - return; - } - - Plugin.getItemMapManager().setMap(caller); - } +// public void map(Player caller, String[] args) +// { +// ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "map"); +// UtilServer.getServer().getPluginManager().callEvent(event); +// +// if (event.isCancelled()) +// { +// return; +// } +// +// Plugin.getItemMapManager().setMap(caller); +// } public void home(final Player caller, String[] args) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/MapCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/MapCommand.java index ed8b9a0e7..e9d8b13ba 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/MapCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/MapCommand.java @@ -33,6 +33,6 @@ public class MapCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - Plugin.getItemMapManager().setMap(caller); + //Plugin.getItemMapManager().setMap(caller); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index bca2c1acc..fdbe13146 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -469,13 +469,13 @@ public class NetherManager extends MiniPlugin } } - UtilServer.getPlayersCollection() - .stream() - .filter(player -> isInNether(player)) - .forEach(player -> - { - ClansManager.getInstance().getItemMapManager().removeMap(player); - }); +// UtilServer.getPlayersCollection() +// .stream() +// .filter(player -> isInNether(player)) +// .forEach(player -> +// { +// ClansManager.getInstance().getItemMapManager().removeMap(player); +// }); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java index 06e29d9de..f4363b0f5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java @@ -157,17 +157,17 @@ public class RaidManager extends MiniPlugin @EventHandler public void update(UpdateEvent event) { - if (event.getType() == UpdateType.TICK) - { - UtilServer.getPlayersCollection() - .stream() - .filter(player -> isInRaid(player.getLocation())) - .forEach(player -> - { - ClansManager.getInstance().getItemMapManager().removeMap(player); - }); - return; - } +// if (event.getType() == UpdateType.TICK) +// { +// UtilServer.getPlayersCollection() +// .stream() +// .filter(player -> isInRaid(player.getLocation())) +// .forEach(player -> +// { +// ClansManager.getInstance().getItemMapManager().removeMap(player); +// }); +// return; +// } if (event.getType() != UpdateType.SEC) { return; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java index 558ac863d..e75da28b3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java @@ -128,7 +128,7 @@ public class ClansMainTutorial extends Tutorial player.teleport(Spawn.getNorthSpawn()); UtilInv.Clear(player); - ClansManager.getInstance().getItemMapManager().setMap(player); +// ClansManager.getInstance().getItemMapManager().setMap(player); }, 20 * 10L); player.setWalkSpeed(0.2F); From 31605b02b09cc190f73c7825e158e77c7c6f4d9e Mon Sep 17 00:00:00 2001 From: cnr Date: Mon, 19 Jun 2017 18:26:03 -0500 Subject: [PATCH 232/283] Use polygon geometry for MOBA Boss AI boundaries --- .../mineplex/core/common/geom/Point2D.java | 79 +++++++++++++++++ .../mineplex/core/common/geom/Polygon2D.java | 68 ++++++++++++++ .../arcade/game/games/moba/ai/MobaAI.java | 26 ++++-- .../arcade/game/games/moba/util/MobaUtil.java | 88 ++++++++----------- 4 files changed, 201 insertions(+), 60 deletions(-) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/geom/Point2D.java create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/geom/Polygon2D.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/geom/Point2D.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/geom/Point2D.java new file mode 100644 index 000000000..07bdad517 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/geom/Point2D.java @@ -0,0 +1,79 @@ +package mineplex.core.common.geom; + +import javax.annotation.Nonnull; +import java.util.Comparator; + +import org.bukkit.Location; + +public class Point2D implements Comparable +{ + private static final Comparator COMPARE_BY_Y_THEN_X = + Comparator.comparingDouble(Point2D::getY).thenComparingDouble(Point2D::getX); + private final double _x; + private final double _y; + + private Point2D(double x, double y) + { + _x = x; + _y = y; + } + + public static Point2D of(double x, double y) + { + return new Point2D(x, y); + } + + public static Point2D of(Location location) + { + return new Point2D(location.getX(), location.getZ()); + } + + public double getX() + { + return _x; + } + + public double getY() + { + return _y; + } + + public Comparator polarOrder() + { + return (p2, p3) -> + { + double dx1 = p2._x - _x; + double dy1 = p2._y - _y; + double dx2 = p3._x - _x; + double dy2 = p3._y - _y; + + if (dy1 >= 0 && dy2 < 0) return -1; // p2 above; p3 below + else if (dy2 >= 0 && dy1 < 0) return 1; // p2 below; p3 above + else if (dy1 == 0 && dy2 == 0) { // 3-collinear and horizontal + if (dx1 >= 0 && dx2 < 0) return -1; // p2 right; p3 left + else if (dx2 >= 0 && dx1 < 0) return 1; // p2 left ; p3 right + else return 0; // all the same point + } + else return -ccw(Point2D.this, p2, p3); // both above or below + }; + } + + public static int ccw(Point2D a, Point2D b, Point2D c) { + double area2 = (b._x-a._x)*(c._y-a._y) - (b._y-a._y)*(c._x-a._x); + if (area2 < 0) return -1; + else if (area2 > 0) return 1; + else return 0; + } + + @Override + public int compareTo(@Nonnull Point2D that) + { + return COMPARE_BY_Y_THEN_X.compare(this, that); + } + + @Override + public String toString() + { + return "Point2D{_x=" + _x + ",_y=" + _y + "}"; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/geom/Polygon2D.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/geom/Polygon2D.java new file mode 100644 index 000000000..73a834d45 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/geom/Polygon2D.java @@ -0,0 +1,68 @@ +package mineplex.core.common.geom; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Stack; + +public class Polygon2D +{ + private final List _points; + + private Polygon2D(List points) + { + _points = points; + // Ensure points[points.size-1] = points[0] + if (!_points.get(0).equals(points.get(_points.size()-1))) + { + _points.add(points.get(0)); + } + } + + public boolean contains(Point2D point) + { + boolean result = false; + for (int i = 0, j = _points.size() - 1; i < _points.size(); j = i++) + { + if ((_points.get(i).getY() > point.getY()) != (_points.get(j).getY() > point.getY()) && + (point.getX() < (_points.get(j).getX() - _points.get(i).getX()) * (point.getY() - _points.get(i).getY()) / (_points.get(j).getY() - _points.get(i).getY()) + _points.get(i).getX())) + { + result = !result; + } + } + return result; + } + + public static Polygon2D fromUnorderedPoints(List points) + { + Stack hull = new Stack<>(); + + Collections.sort(points); + points.subList(1, points.size()).sort(points.get(0).polarOrder()); + + hull.push(points.get(0)); + hull.push(points.get(1)); + + // find first extreme point (not collinear with first and second elements) + int extreme; + for (extreme = 2; extreme < points.size(); extreme++) + if (Point2D.ccw(points.get(0), points.get(1), points.get(extreme)) != 0) break; + + for (int i = extreme; i < points.size(); i++) + { + Point2D top = hull.pop(); + while (Point2D.ccw(hull.peek(), top, points.get(i)) <= 0) { + top = hull.pop(); + } + hull.push(top); + hull.push(points.get(i)); + } + + return new Polygon2D(new ArrayList<>(hull)); + } + + public static Polygon2D fromPoints(List points) + { + return new Polygon2D(new ArrayList<>(points)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 15f4e9e49..5b89b9884 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -1,14 +1,19 @@ package nautilus.game.arcade.game.games.moba.ai; +import java.util.List; +import java.util.stream.Collectors; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; + +import mineplex.core.common.geom.Point2D; +import mineplex.core.common.geom.Polygon2D; + import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.util.MobaUtil; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.entity.LivingEntity; - -import java.util.List; public class MobaAI { @@ -16,7 +21,7 @@ public class MobaAI private final GameTeam _owner; private final float _speedTarget; private final float _speedHome; - private final List _boundaries; + private final Polygon2D _boundaries; private LivingEntity _entity; private LivingEntity _target; @@ -32,7 +37,12 @@ public class MobaAI _entity = entity; _home = home; _aiMethod = aiMethod; - _boundaries = host.WorldData.GetDataLocs(getBoundaryKey()); + + List boundaryPoints = host.WorldData.GetDataLocs(getBoundaryKey()).stream() + .map(Point2D::of) + .collect(Collectors.toList()); + + _boundaries = Polygon2D.fromUnorderedPoints(boundaryPoints); } public void updateTarget() @@ -80,7 +90,7 @@ public class MobaAI return _target; } - public List getBoundaries() + public Polygon2D getBoundaries() { return _boundaries; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index ac09e9aac..54bf4ee50 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -1,28 +1,32 @@ package nautilus.game.arcade.game.games.moba.util; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilServer; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.util.Vector; - import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map.Entry; import java.util.Set; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; + +import mineplex.core.common.geom.Point2D; +import mineplex.core.common.geom.Polygon2D; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; + +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; + public class MobaUtil { @@ -66,12 +70,12 @@ public class MobaUtil return highest; } - public static boolean isInBoundary(GameTeam owner, LivingEntity source, Location center, List boundaries, LivingEntity target) + public static boolean isInBoundary(GameTeam owner, LivingEntity source, Location center, Polygon2D boundaries, LivingEntity target) { return getEntitiesInBoundary(owner, source, center, boundaries).contains(target); } - public static LivingEntity getBestEntityTarget(GameTeam owner, LivingEntity source, Location center, List boundaries) + public static LivingEntity getBestEntityTarget(GameTeam owner, LivingEntity source, Location center, Polygon2D boundaries) { LivingEntity best = null; double bestDist = Double.MAX_VALUE; @@ -90,9 +94,8 @@ public class MobaUtil return best; } - public static Set getEntitiesInBoundary(GameTeam owner, LivingEntity source, Location center, List boundaries) + public static Set getEntitiesInBoundary(GameTeam owner, LivingEntity source, Location center, Polygon2D boundaries) { - Set entities = new HashSet<>(); List ignored = new ArrayList<>(); if (owner != null) @@ -101,45 +104,26 @@ public class MobaUtil ignored.addAll(owner.GetPlayers(true)); } - // For each boundary - for (Location boundary : boundaries) + Set result = new HashSet<>(); + + for (Entity cur : center.getWorld().getEntities()) // TODO: narrow down to specific chunks contained in the polygon? { - Location checking = center.clone(); - // Get direction from center to boundary - Vector direction = UtilAlg.getTrajectory(center, boundary); - // Store the checked distance - double checkedDist = 0; - // Get the distance squared from the center to the boundary - double maxDist = UtilMath.offsetSquared(center, boundary); + if (!(cur instanceof LivingEntity) || UtilPlayer.isSpectator(cur)) + continue; - // Keep advancing the distance until it hits the boundary - while (checkedDist * checkedDist < maxDist) + LivingEntity ent = (LivingEntity)cur; + + if (boundaries.contains(Point2D.of(ent.getLocation()))) { - // Advance the location - checking.add(direction); - - // Check for nearby entities - for (LivingEntity entity : UtilEnt.getInRadius(checking, 3).keySet()) + if ((owner != null && isTeamEntity(ent, owner)) || source.equals(ent) || ignored.contains(ent)) { - if (source.equals(entity) || ignored.contains(entity)) - { - continue; - } - - // Check for team entities - if (owner != null && isTeamEntity(entity, owner)) - { - continue; - } - - entities.add(entity); + continue; } - - checkedDist++; + result.add(ent); } } - return entities; + return result; } public static String getHealthBar(LivingEntity entity, int bars) From 61c57deaaac67a13f17c83fdb46c80f45ee0cfac Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 19 Jun 2017 19:59:32 -0400 Subject: [PATCH 233/283] Disable these damn guardians lagging my clans servers --- .../antihack/guardians/AntiHackGuardian.java | 148 +++++++++--------- .../antihack/guardians/GuardianManager.java | 12 +- .../src/mineplex/game/clans/Clans.java | 77 --------- 3 files changed, 80 insertions(+), 157 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java index cb9ef2898..b1ddf4d48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java @@ -78,39 +78,39 @@ public class AntiHackGuardian implements Listener { UtilServer.RegisterEvents(this); - this.MAX_DISTANCE_X = maxX; - this.MIN_DISTANCE_X = minX; - this.MAX_DISTANCE_Y = maxY; - this.MIN_DISTANCE_Y = minY; - this.MAX_DISTANCE_Z = maxZ; - this.MIN_DISTANCE_Z = minZ; + MAX_DISTANCE_X = maxX; + MIN_DISTANCE_X = minX; + MAX_DISTANCE_Y = maxY; + MIN_DISTANCE_Y = minY; + MAX_DISTANCE_Z = maxZ; + MIN_DISTANCE_Z = minZ; - this.CENTER_X = MIN_DISTANCE_X + ((MAX_DISTANCE_X - MIN_DISTANCE_X) / 2.0); - this.CENTER_Y = MIN_DISTANCE_Y + ((MAX_DISTANCE_Y - MIN_DISTANCE_Y) / 2.0); - this.CENTER_Z = MIN_DISTANCE_Z + ((MAX_DISTANCE_Z - MIN_DISTANCE_Z) / 2.0); + CENTER_X = MIN_DISTANCE_X + ((MAX_DISTANCE_X - MIN_DISTANCE_X) / 2.0); + CENTER_Y = MIN_DISTANCE_Y + ((MAX_DISTANCE_Y - MIN_DISTANCE_Y) / 2.0); + CENTER_Z = MIN_DISTANCE_Z + ((MAX_DISTANCE_Z - MIN_DISTANCE_Z) / 2.0); //debug("Spawning ArmorStand at " + center + ""); CoreClientManager clientManager = Managers.get(CoreClientManager.class); DisguiseManager disguiseManager = Managers.get(DisguiseManager.class); - this._center = center; - this._center.getChunk().load(); + _center = center; + _center.getChunk().load(); - this._armorStand = (ArmorStand) new EntityArmorStand(((CraftWorld) this._center.getWorld()).getHandle(), this._center.getX(), this._center.getY(), this._center.getZ()).getBukkitEntity(); - this._armorStand.setGravity(false); - this._armorStand.setVisible(false); - this._armorStand.setRemoveWhenFarAway(false); - this._nmsEntity = ((CraftArmorStand) this._armorStand).getHandle(); - this._nmsEntity.maxNoDamageTicks = 86400; - this._nmsEntity.noDamageTicks = 86400; + _armorStand = (ArmorStand) new EntityArmorStand(((CraftWorld) _center.getWorld()).getHandle(), _center.getX(), _center.getY(), _center.getZ()).getBukkitEntity(); + _armorStand.setGravity(false); + _armorStand.setVisible(false); + _armorStand.setRemoveWhenFarAway(false); + _nmsEntity = ((CraftArmorStand) _armorStand).getHandle(); + _nmsEntity.maxNoDamageTicks = 86400; + _nmsEntity.noDamageTicks = 86400; - this._entityUUID = this._armorStand.getUniqueId(); + _entityUUID = _armorStand.getUniqueId(); - this._disguise = new DisguiseGuardian(this._armorStand); - this._disguise.setHideIfNotDisguised(true); + _disguise = new DisguiseGuardian(_armorStand); + _disguise.setHideIfNotDisguised(true); - disguiseManager.disguise(this._disguise, player -> + disguiseManager.disguise(_disguise, player -> { if (!hideForStaff) return true; @@ -141,17 +141,17 @@ public class AntiHackGuardian implements Listener @EventHandler public void onLoad(ChunkAddEntityEvent event) { - if (event.getEntity().getUniqueId().equals(this._entityUUID)) + if (event.getEntity().getUniqueId().equals(_entityUUID)) { - this._armorStand = (ArmorStand) event.getEntity(); - this._nmsEntity = ((CraftArmorStand) this._armorStand).getHandle(); + _armorStand = (ArmorStand) event.getEntity(); + _nmsEntity = ((CraftArmorStand) _armorStand).getHandle(); } } @EventHandler public void onStack(StackerEvent event) { - if (event.getEntity().getUniqueId().equals(this._entityUUID)) + if (event.getEntity().getUniqueId().equals(_entityUUID)) { event.setCancelled(true); } @@ -159,27 +159,27 @@ public class AntiHackGuardian implements Listener public void tick() { - if (this._nmsEntity.dead || !this._nmsEntity.valid) + if (_nmsEntity.dead || !_nmsEntity.valid) { - //debug("Skipping because " + this._armorStand.isDead() + " " + this._armorStand.isValid()); + //debug("Skipping because " + _armorStand.isDead() + " " + _armorStand.isValid()); return; } - if (this._target == null) + if (_target == null) { regularTick(); } else { - this._stalkTime++; + _stalkTime++; targetTick(); } - //debug("Ticking " + this._armorStand + " " + this._armorStand.isDead() + " " + this._armorStand.getLocation() + " " + this._ticksUntilReset); + //debug("Ticking " + _armorStand + " " + _armorStand.isDead() + " " + _armorStand.getLocation() + " " + _ticksUntilReset); } private void regularTick() { - if (this._ticksUntilReset <= 0) + if (_ticksUntilReset <= 0) { reset(); } @@ -187,8 +187,8 @@ public class AntiHackGuardian implements Listener //debug("===== Begin Calculations ====="); - //debug("Target: " + this._targetX + " " + this._targetY + " " + this._targetZ); - //debug("Start: " + this._armorStand.getLocation()); + //debug("Target: " + _targetX + " " + _targetY + " " + _targetZ); + //debug("Start: " + _armorStand.getLocation()); double deltaX = _targetX - _nmsEntity.locX; double deltaY = _targetY - _nmsEntity.locY; double deltaZ = _targetZ - _nmsEntity.locZ; @@ -210,28 +210,28 @@ public class AntiHackGuardian implements Listener _nmsEntity.locY += dy; _nmsEntity.locZ += dz; - //debug("Dest: " + this._nmsEntity.locX + " " + this._nmsEntity.locY + " " + this._nmsEntity.locZ); + //debug("Dest: " + _nmsEntity.locX + " " + _nmsEntity.locY + " " + _nmsEntity.locZ); //debug("===== End Calculations ====="); // Only send look update every second - if (this._nmsEntity.ticksLived % 20 == 0) + if (_nmsEntity.ticksLived % 20 == 0) { UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, _targetX, _targetY, _targetZ); } - this._ticksUntilReset--; + _ticksUntilReset--; } private void targetTick() { - //debug("===== Stalking " + this._target.getName() + " ====="); - EntityPlayer entityPlayer = ((CraftPlayer) this._target).getHandle(); + //debug("===== Stalking " + _target.getName() + " ====="); + EntityPlayer entityPlayer = ((CraftPlayer) _target).getHandle(); - Vector direction = this._target.getLocation().getDirection().normalize().multiply(-6); + Vector direction = _target.getLocation().getDirection().normalize().multiply(-6); - this._nmsEntity.locX = entityPlayer.locX + direction.getX(); - this._nmsEntity.locZ = entityPlayer.locZ + direction.getZ(); - this._nmsEntity.locY = entityPlayer.locY + 10.0 + nextDouble(-1.0, 1.0); + _nmsEntity.locX = entityPlayer.locX + direction.getX(); + _nmsEntity.locZ = entityPlayer.locZ + direction.getZ(); + _nmsEntity.locY = entityPlayer.locY + 10.0 + nextDouble(-1.0, 1.0); UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, entityPlayer.locX, entityPlayer.locY, entityPlayer.locZ); } @@ -261,7 +261,7 @@ public class AntiHackGuardian implements Listener cy = MAGICAL_FUNCTION.apply(cy) * (y > CENTER_Y ? -(MAX_DISTANCE_Y - CENTER_Y) : (CENTER_Y - MIN_DISTANCE_Y)); cz = MAGICAL_FUNCTION.apply(cz) * (z > CENTER_Z ? -(MAX_DISTANCE_Z - CENTER_Z) : (CENTER_Z - MIN_DISTANCE_Z)); - //debug("Start: " + this._armorStand.getLocation()); + //debug("Start: " + _armorStand.getLocation()); //debug("Changes: " + cx + " " + cy + " " + cz); int ex = nextInt(8, 12); @@ -285,18 +285,18 @@ public class AntiHackGuardian implements Listener //debug("Deltas: " + dx + " " + dy + " " + dz); - this._targetX = x + dx; - this._targetY = y + dy; - this._targetZ = z + dz; - //debug("End: " + this._targetX + " " + this._targetY + " " + this._targetZ); + _targetX = x + dx; + _targetY = y + dy; + _targetZ = z + dz; + //debug("End: " + _targetX + " " + _targetY + " " + _targetZ); // If we can't find a good position, just go to the center if (!locCheck()) { - this._targetX = CENTER_X; - this._targetY = CENTER_Y; - this._targetZ = CENTER_Z; + _targetX = CENTER_X; + _targetY = CENTER_Y; + _targetZ = CENTER_Z; dx = (int) (CENTER_X - x); dy = (int) (CENTER_Y - y); @@ -305,46 +305,46 @@ public class AntiHackGuardian implements Listener double maxDelta = Math.max(Math.max(Math.abs(dx), Math.abs(dy)), Math.abs(dz)); - this._ticksUntilReset = (int) (maxDelta / DELTA_MOVE_PER_TICK); + _ticksUntilReset = (int) (maxDelta / DELTA_MOVE_PER_TICK); // Send look update for new target UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, _targetX, _targetY, _targetZ); - //debug("Ticks: " + this._ticksUntilReset); + //debug("Ticks: " + _ticksUntilReset); //debug("======= END RESET ======"); } public void target(Player player) { - this._target = player; + _target = player; } public boolean isTargeting() { - return this._target != null; + return _target != null; } public int getTargetingTime() { - return this._stalkTime; + return _stalkTime; } public void stopTargeting() { - this._target = null; - this._stalkTime = 0; + _target = null; + _stalkTime = 0; reset(); } public void shoot(Player player) { - this._disguise.setTarget(player == null ? 0 : player.getEntityId()); - Managers.get(DisguiseManager.class).updateDisguise(this._disguise); + _disguise.setTarget(player == null ? 0 : player.getEntityId()); + Managers.get(DisguiseManager.class).updateDisguise(_disguise); } public Player getTarget() { - return this._target; + return _target; } private boolean locCheck() @@ -376,31 +376,31 @@ public class AntiHackGuardian implements Listener public void remove() { - this._target = null; + _target = null; UtilServer.Unregister(this); - Managers.get(DisguiseManager.class).undisguise(this._disguise); - this._armorStand.remove(); - this._nmsEntity = null; - this._armorStand = null; - this._center = null; + Managers.get(DisguiseManager.class).undisguise(_disguise); + _armorStand.remove(); + _nmsEntity = null; + _armorStand = null; + _center = null; } public ArmorStand getEntity() { - return this._armorStand; + return _armorStand; } public void moveDelta(double dx, double dy, double dz) { - this._nmsEntity.locX += dx; - this._nmsEntity.locY += dy; - this._nmsEntity.locZ += dz; + _nmsEntity.locX += dx; + _nmsEntity.locY += dy; + _nmsEntity.locZ += dz; } public void move(double x, double y, double z) { - this._nmsEntity.locX = x; - this._nmsEntity.locY = y; - this._nmsEntity.locZ = z; + _nmsEntity.locX = x; + _nmsEntity.locY = y; + _nmsEntity.locZ = z; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java index a5806e753..3d19f0501 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java @@ -41,13 +41,13 @@ public class GuardianManager extends MiniPlugin { super("GuardianManager"); - this._plugin.getServer().getScheduler().runTaskTimer(this._plugin, () -> + _plugin.getServer().getScheduler().runTaskTimer(_plugin, () -> { - for (AntiHackGuardian guardian : this._guardians) + for (AntiHackGuardian guardian : _guardians) { if (guardian.getTarget() != null && !guardian.getTarget().isOnline()) { - this._stalking.remove(guardian.getTarget().getUniqueId()); + _stalking.remove(guardian.getTarget().getUniqueId()); guardian.stopTargeting(); } else if (guardian.getTargetingTime() > MIN_STALK_TIME) @@ -55,7 +55,7 @@ public class GuardianManager extends MiniPlugin double threshold = STALK_END_PROBABILITY_EQUATION.apply(guardian.getTargetingTime() - MIN_STALK_TIME); if (Math.random() <= threshold) { - this._stalking.remove(guardian.getTarget().getUniqueId()); + _stalking.remove(guardian.getTarget().getUniqueId()); _stalkingCooldown.put(guardian.getTarget().getUniqueId(), true); guardian.stopTargeting(); } @@ -64,7 +64,7 @@ public class GuardianManager extends MiniPlugin } }, 0L, 1L); - this._plugin.getServer().getScheduler().runTaskTimer(this._plugin, () -> + _plugin.getServer().getScheduler().runTaskTimer(_plugin, () -> { if (_stalking.size() >= MAX_STALKED_PLAYERS) { @@ -124,6 +124,6 @@ public class GuardianManager extends MiniPlugin public void registerGuardian(AntiHackGuardian guardian) { - this._guardians.add(guardian); + _guardians.add(guardian); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 784e5c230..b3ed131a7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -6,7 +6,6 @@ import java.io.File; import java.io.IOException; import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; @@ -19,7 +18,6 @@ import mineplex.core.TimingsFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; -import mineplex.core.antihack.guardians.AntiHackGuardian; import mineplex.core.antihack.guardians.GuardianManager; import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; @@ -161,81 +159,6 @@ public class Clans extends JavaPlugin new EternalGiveawayManager(this, _clientManager, serverStatusManager); - { - // West Shop - int maxX = -385; - int minX = -462; - int maxY = 100; - int minY = 90; - int maxZ = 46; - int minZ = -30; - Location spawn = new Location(Bukkit.getWorld("world"), -422, 95, 8); - for (int i = 0; i < 10; i++) - { - guardianManager.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); - } - } - - { - // East Shop - int maxX = 385; - int minX = -463; - int maxY = 100; - int minY = 90; - int maxZ = 31; - int minZ = -46; - Location spawn = new Location(Bukkit.getWorld("world"), 424, 95, -8); - for (int i = 0; i < 10; i++) - { - guardianManager.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); - } - } - - { - // North Spawn - int maxX = 25; - int minX = -8; - int maxY = 215; - int minY = 205; - int maxZ = -376; - int minZ = -410; - Location spawn = new Location(Bukkit.getWorld("world"), 9, 210, -393); - for (int i = 0; i < 10; i++) - { - guardianManager.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); - } - } - - { - // South Spawn - int maxX = 25; - int minX = -8; - int maxY = 215; - int minY = 205; - int maxZ = 407; - int minZ = 373; - Location spawn = new Location(Bukkit.getWorld("world"), 8, 210, 390); - for (int i = 0; i < 10; i++) - { - guardianManager.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); - } - } - - { - // Fields - int maxX = 50; - int minX = -60; - int maxY = 110; - int minY = 100; - int maxZ = 70; - int minZ = -70; - Location spawn = new Location(Bukkit.getWorld("world"), 0, 100, 0); - for (int i = 0; i < 40; i++) - { - guardianManager.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ)); - } - } - BlockRestore blockRestore = require(BlockRestore.class); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); From e99be53bb56bda183f34e30d28d8aeb60fcc03a6 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 22 Jun 2017 12:07:11 +0100 Subject: [PATCH 234/283] Add a middle class to deal with multiple modes --- .../src/mineplex/core/game/GameDisplay.java | 2 +- .../src/nautilus/game/arcade/GameType.java | 5 +- .../game/arcade/game/games/moba/Moba.java | 287 ++---------------- .../arcade/game/games/moba/MobaClassic.java | 263 ++++++++++++++++ .../arcade/game/games/moba/MobaPlayer.java | 1 + .../game/games/moba/boss/BossManager.java | 22 +- .../arcade/game/games/moba/boss/MobaBoss.java | 6 - .../games/moba/boss/wither/WitherBoss.java | 12 +- .../games/moba/buff/buffs/BuffCripple.java | 39 --- .../arcade/game/games/moba/kit/HeroSkill.java | 10 +- .../games/moba/kit/common/SkillSword.java | 1 - .../moba/kit/larissa/SkillAquaCannon.java | 1 - .../moba/kit/larissa/SkillWaterDash.java | 1 - .../game/games/moba/minion/MinionManager.java | 13 +- .../game/games/moba/minion/MinionWave.java | 6 - .../moba/structure/point/CapturePoint.java | 1 - .../games/moba/training/MobaTraining.java | 192 +++++++++++- .../arcade/game/games/moba/util/MobaUtil.java | 2 +- .../game/modules/CustomScoreboardModule.java | 3 +- 19 files changed, 512 insertions(+), 355 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 381b5069b..413dbbc8f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -104,7 +104,7 @@ public enum GameDisplay AlienInvasion("Alien Invasion", Material.ENDER_STONE, (byte) 0, GameCategory.EVENT, 69, false), - MOBA("Heroes of GWEN", Material.PRISMARINE, (byte)0, GameCategory.CLASSICS, 70, false), + MOBA("Heroes of GWEN", Material.PRISMARINE, (byte)0, GameCategory.CLASSICS, 70, true), MOBATraining("Heroes of GWEN Training", Material.PRISMARINE, (byte)0, GameCategory.CLASSICS, 70, false), GemHunters("Gem Hunters", Material.EMERALD, (byte) 0, GameCategory.SURVIVAL, 71, false), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index fb504456a..503422b10 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -63,6 +63,7 @@ import nautilus.game.arcade.game.games.minestrike.Minestrike; import nautilus.game.arcade.game.games.minestrike.modes.SuperPaintstrike; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaClassic; import nautilus.game.arcade.game.games.moba.training.MobaTraining; import nautilus.game.arcade.game.games.monsterleague.MonsterLeague; import nautilus.game.arcade.game.games.monstermaze.MonsterMaze; @@ -233,8 +234,8 @@ public enum GameType AlienInvasion(AlienInvasion.class, GameDisplay.AlienInvasion), - MOBA(Moba.class, GameDisplay.MOBA), - MOBATraining(MobaTraining.class, GameDisplay.MOBA), + MOBA(MobaClassic.class, GameDisplay.MOBA), + MOBATraining(MobaTraining.class, GameDisplay.MOBATraining), Event(EventGame.class, GameDisplay.Event, new GameType[]{ GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 2024cc3d7..66274c97e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -4,11 +4,9 @@ import mineplex.core.Managers; import mineplex.core.beta.BetaWhitelist; import mineplex.core.common.Pair; import mineplex.core.common.Rank; -import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.leaderboard.Leaderboard; @@ -23,7 +21,6 @@ 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.boss.BossManager; -import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.buff.BuffManager; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.general.ArrowKBManager; @@ -54,13 +51,10 @@ import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; -import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -75,39 +69,30 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.TimeUnit; public class Moba extends TeamGame { - private static final String[] DESCRIPTION = { - "..." - }; - private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1); - private final HeroKit[] _kits; private final Set _playerData = new HashSet<>(); - private final Set _listeners = new HashSet<>(); protected final MobaShop _shop; protected final GoldManager _goldManager; protected final BossManager _boss; + protected final BuffManager _buffs; + protected final ArrowKBManager _arrowKb; protected final TowerManager _tower; protected final CapturePointManager _capturePoint; - protected final ArrowKBManager _arrowKb; - protected final BuffManager _buffs; + protected final MinionManager _minion; private BetaWhitelist _betaWhitelist; - public Moba(ArcadeManager manager) - { - this(manager, GameType.MOBA); - } + private int _inPlayers; - public Moba(ArcadeManager manager, GameType gameType) + public Moba(ArcadeManager manager, GameType gameType, String[] description) { - super(manager, gameType, new Kit[]{new KitPlayer(manager)}, DESCRIPTION); + super(manager, gameType, new Kit[]{new KitPlayer(manager)}, description); _kits = new HeroKit[]{ new HeroHattori(Manager), @@ -122,16 +107,7 @@ public class Moba extends TeamGame }; AllowParticles = false; - DontAllowOverfill = true; - PrepareAutoAnnounce = false; - PrepareFreeze = false; - PrepareTime = PREPARE_TIME; - DeathOut = false; - DeathSpectateSecs = 12; - HungerSet = 20; - DamageFall = false; - manager.getCosmeticManager().setHideParticles(true); manager.GetCreature().SetDisableCustomDrops(true); // Instantiate managers @@ -139,33 +115,19 @@ public class Moba extends TeamGame // Global managers _shop = registerManager(new MobaShop(this)); _goldManager = registerManager(new GoldManager(this)); + _boss = registerManager(new BossManager(this)); + _buffs = registerManager(new BuffManager()); + _arrowKb = registerManager(new ArrowKBManager(this)); + _minion = registerManager(new MinionManager(this)); registerManager(new HPManager(this)); registerManager(new MobaDamageManager(this)); registerManager(new MobaFountain(this)); - - // Pregame managers - registerManager(new PrepareManager(this)); - registerManager(new PrepareSelection(this)); - - // Bosses - _boss = registerManager(new BossManager(this)); + registerManager(new EnderPearlManager()); // Structures _tower = registerManager(new TowerManager(this)); _capturePoint = registerManager(new CapturePointManager(this)); - // Minions - registerManager(new MinionManager(this)); - - // Arrow Knockback - _arrowKb = registerManager(new ArrowKBManager(this)); - - // Ender Pearls - registerManager(new EnderPearlManager()); - - // Buffs - _buffs = registerManager(new BuffManager()); - // Beta Message registerManager(new BetaManager(this)); @@ -186,66 +148,6 @@ public class Moba extends TeamGame .setGiveCompassToAlive(false) .register(this); - new CustomScoreboardModule() - .setSidebar((player, scoreboard) -> - { - GameState state = GetState(); - - switch (state) - { - case Prepare: - writePrepare(player, scoreboard); - break; - case Live: - writeLive(player, scoreboard); - break; - } - }) - .setPrefix((perspective, subject) -> - { - if (!IsAlive(subject)) - { - return C.cGray; - } - - GameTeam team = GetTeam(subject); - - return team.GetColor().toString(); - }) - .setSuffix((perspective, subject) -> - { - GameState state = GetState(); - GameTeam perspectiveTeam = GetTeam(perspective); - GameTeam subjectTeam = GetTeam(subject); - - if (!IsAlive(subject) || perspectiveTeam == null || subjectTeam == null) - { - return ""; - } - - MobaPlayer mobaPlayer = getMobaData(subject); - String suffix; - - if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam)) - { - suffix = C.cYellow + " Unknown"; - } - else if (mobaPlayer.getKit() == null) - { - suffix = C.cYellow + " Selecting"; - } - else - { - suffix = mobaPlayer.getRole().getChatColor() + " " + mobaPlayer.getKit().GetName(); - } - - return suffix + C.Reset; - }) - .setUnderNameObjective(C.cRed + "❤") - .setUnderName((perspective, subject) -> - (int) (Math.ceil(subject.getHealth() / 2D))) - .register(this); - registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) { @Override @@ -274,7 +176,7 @@ public class Moba extends TeamGame }); } - private T registerManager(T listener) + protected T registerManager(T listener) { _listeners.add(listener); return listener; @@ -333,97 +235,6 @@ public class Moba extends TeamGame } } - private void writePrepare(Player player, GameScoreboard scoreboard) - { - MobaPlayer mobaPlayer = getMobaData(player); - - scoreboard.writeNewLine(); - - scoreboard.write(C.cYellowB + "Hero Selection"); - scoreboard.write(UtilTime.MakeStr(GetStateTime() + PREPARE_TIME - System.currentTimeMillis())); - - scoreboard.writeNewLine(); - - scoreboard.write(C.cYellowB + "Hero"); - scoreboard.write((mobaPlayer == null || mobaPlayer.getKit() == null) ? "Unselected " : mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getName() + ")"); - - scoreboard.writeNewLine(); - - scoreboard.write(C.cYellowB + "Players"); - int kits = 0; - - for (MobaPlayer otherMobaPlayer : _playerData) - { - if (otherMobaPlayer.getKit() != null) - { - kits++; - } - } - - scoreboard.write(kits + "/" + GetPlayers(true).size()); - - scoreboard.writeNewLine(); - } - - private void writeLive(Player player, GameScoreboard scoreboard) - { - GameTeam team = GetTeam(player); - boolean alive = IsAlive(player); - - scoreboard.writeNewLine(); - - // Towers - GameTeam red = GetTeam(ChatColor.RED); - GameTeam blue = GetTeam(ChatColor.AQUA); - String redTitle; - String blueTitle; - - if (alive) - { - boolean playerRed = team.equals(red); - redTitle = playerRed ? "Your Team" : "Enemy Team"; - blueTitle = playerRed ? "Enemy Team" : "Your Team"; - } - else - { - redTitle = "Red Team"; - blueTitle = "Blue Team"; - } - - scoreboard.write(red.GetColor() + C.Bold + redTitle); - scoreboard.write("Base: " + _tower.getDisplayString(red) + _boss.getWitherDisplayString(red)); - - scoreboard.writeNewLine(); - - scoreboard.write(blue.GetColor() + C.Bold + blueTitle); - scoreboard.write("Base: " + _tower.getDisplayString(blue) + _boss.getWitherDisplayString(blue)); - - scoreboard.writeNewLine(); - - scoreboard.write(C.cGreenB + "Beacons"); - scoreboard.write(_capturePoint.getDisplayString()); - - scoreboard.writeNewLine(); - - // Gold - scoreboard.write(C.cGoldB + "Your Gold"); - if (alive) - { - int gold = _goldManager.getGold(player); - - scoreboard.write(String.valueOf(gold)); - } - else - { - scoreboard.write("None"); - } - - scoreboard.writeNewLine(); - - scoreboard.write(C.cYellowB + "Time"); - scoreboard.write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime())); - } - @EventHandler(priority = EventPriority.LOWEST) public void prepare(GameStateChangeEvent event) { @@ -448,7 +259,7 @@ public class Moba extends TeamGame { Player player = event.GetPlayer(); - if (GetPlayers(true).size() > 8) + if (++_inPlayers > 8) { SetPlayerState(player, GameTeam.PlayerState.OUT); Manager.addSpectator(player, true); @@ -456,68 +267,6 @@ public class Moba extends TeamGame } } - @Override - public void EndCheck() - { - if (!IsLive()) - { - return; - } - - // Only one team online check - List teamsWithPlayers = new ArrayList<>(GetTeamList().size()); - - for (GameTeam team : GetTeamList()) - { - if (team.GetPlayers(true).isEmpty()) - { - continue; - } - - teamsWithPlayers.add(team); - } - - if (teamsWithPlayers.size() == 1) - { - AnnounceEnd(teamsWithPlayers.get(0)); - SetState(GameState.End); - return; - } - - // Wither Dead check - for (GameTeam team : GetTeamList()) - { - WitherBoss boss = _boss.getWitherBoss(team); - LivingEntity entity = boss.getEntity(); - - // Dead Wither - if (entity == null || !entity.isValid() || entity.isDead()) - { - // Get the other team - for (GameTeam otherTeam : GetTeamList()) - { - for (Player player : otherTeam.GetPlayers(true)) - { - AddGems(player, 10, "Participation", false, false); - } - - if (team.equals(otherTeam)) - { - continue; - } - - for (Player player : otherTeam.GetPlayers(true)) - { - AddGems(player, 20, "Winning", false, false); - } - - AnnounceEnd(otherTeam); - SetState(GameState.End); - } - } - } - } - @Override public void RespawnPlayer(Player player) { @@ -747,6 +496,11 @@ public class Moba extends TeamGame return _goldManager; } + public BuffManager getBuffManager() + { + return _buffs; + } + public TowerManager getTowerManager() { return _tower; @@ -766,9 +520,4 @@ public class Moba extends TeamGame { return _arrowKb; } - - public BuffManager getBuffManager() - { - return _buffs; - } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java new file mode 100644 index 000000000..8fa8ee3cb --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java @@ -0,0 +1,263 @@ +package nautilus.game.arcade.game.games.moba; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; +import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; +import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; +import nautilus.game.arcade.game.modules.CustomScoreboardModule; +import nautilus.game.arcade.scoreboard.GameScoreboard; +import org.bukkit.ChatColor; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +public class MobaClassic extends Moba +{ + + private static final String[] DESCRIPTION = { + "Select your Role and Hero.", + "Kill the enemy Team!", + "Capture the Beacons to earn gold to spent in the shop!", + "Destroy the enemy's Towers and Wither!" + }; + private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1); + + public MobaClassic(ArcadeManager manager) + { + super(manager, GameType.MOBA, DESCRIPTION); + + DontAllowOverfill = true; + PrepareAutoAnnounce = false; + PrepareFreeze = false; + PrepareTime = PREPARE_TIME; + DeathOut = false; + DeathSpectateSecs = 12; + HungerSet = 20; + DamageFall = false; + + // Pregame managers + registerManager(new PrepareManager(this)); + registerManager(new PrepareSelection(this)); + + new CustomScoreboardModule() + .setSidebar((player, scoreboard) -> + { + GameState state = GetState(); + + switch (state) + { + case Prepare: + writePrepare(player, scoreboard); + break; + case Live: + writeLive(player, scoreboard); + break; + } + }) + .setPrefix((perspective, subject) -> + { + if (!IsAlive(subject)) + { + return C.cGray; + } + + GameTeam team = GetTeam(subject); + + return team.GetColor().toString(); + }) + .setSuffix((perspective, subject) -> + { + GameState state = GetState(); + GameTeam perspectiveTeam = GetTeam(perspective); + GameTeam subjectTeam = GetTeam(subject); + + if (!IsAlive(subject) || perspectiveTeam == null || subjectTeam == null) + { + return ""; + } + + MobaPlayer mobaPlayer = getMobaData(subject); + String suffix; + + if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam)) + { + suffix = C.cYellow + " Unknown"; + } + else if (mobaPlayer.getKit() == null) + { + suffix = C.cYellow + " Selecting"; + } + else + { + suffix = mobaPlayer.getRole().getChatColor() + " [" + mobaPlayer.getKit().GetName() + "]"; + } + + return suffix + C.Reset; + }) + .setUnderNameObjective(C.cRed + "❤") + .setUnderName((perspective, subject) -> + (int) (Math.ceil(subject.getHealth() / 2D))) + .register(this); + } + + private void writePrepare(Player player, GameScoreboard scoreboard) + { + MobaPlayer mobaPlayer = getMobaData(player); + + scoreboard.writeNewLine(); + + scoreboard.write(C.cYellowB + "Hero Selection"); + scoreboard.write(UtilTime.MakeStr(GetStateTime() + PREPARE_TIME - System.currentTimeMillis())); + + scoreboard.writeNewLine(); + + scoreboard.write(C.cYellowB + "Hero"); + scoreboard.write((mobaPlayer == null || mobaPlayer.getKit() == null) ? "Unselected " : mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getName() + ")"); + + scoreboard.writeNewLine(); + + scoreboard.write(C.cYellowB + "Players"); + int kits = 0; + + for (MobaPlayer otherMobaPlayer : getMobaData()) + { + if (otherMobaPlayer.getKit() != null) + { + kits++; + } + } + + scoreboard.write(kits + "/" + GetPlayers(true).size()); + + scoreboard.writeNewLine(); + } + + private void writeLive(Player player, GameScoreboard scoreboard) + { + GameTeam team = GetTeam(player); + boolean alive = IsAlive(player); + + scoreboard.writeNewLine(); + + // Towers + GameTeam red = GetTeam(ChatColor.RED); + GameTeam blue = GetTeam(ChatColor.AQUA); + String redTitle; + String blueTitle; + + if (alive) + { + boolean playerRed = team.equals(red); + redTitle = playerRed ? "Your Team" : "Enemy Team"; + blueTitle = playerRed ? "Enemy Team" : "Your Team"; + } + else + { + redTitle = "Red Team"; + blueTitle = "Blue Team"; + } + + scoreboard.write(red.GetColor() + C.Bold + redTitle); + scoreboard.write("Base: " + _tower.getDisplayString(red) + _boss.getWitherDisplayString(red)); + + scoreboard.writeNewLine(); + + scoreboard.write(blue.GetColor() + C.Bold + blueTitle); + scoreboard.write("Base: " + _tower.getDisplayString(blue) + _boss.getWitherDisplayString(blue)); + + scoreboard.writeNewLine(); + + scoreboard.write(C.cGreenB + "Beacons"); + scoreboard.write(_capturePoint.getDisplayString()); + + scoreboard.writeNewLine(); + + // Gold + scoreboard.write(C.cGoldB + "Your Gold"); + if (alive) + { + int gold = _goldManager.getGold(player); + + scoreboard.write(String.valueOf(gold)); + } + else + { + scoreboard.write("None"); + } + + scoreboard.writeNewLine(); + + scoreboard.write(C.cYellowB + "Time"); + scoreboard.write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime())); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + // Only one team online check + List teamsWithPlayers = new ArrayList<>(GetTeamList().size()); + + for (GameTeam team : GetTeamList()) + { + if (team.GetPlayers(true).isEmpty()) + { + continue; + } + + teamsWithPlayers.add(team); + } + + if (teamsWithPlayers.size() == 1) + { + AnnounceEnd(teamsWithPlayers.get(0)); + SetState(GameState.End); + return; + } + + // Wither Dead check + for (GameTeam team : GetTeamList()) + { + WitherBoss boss = _boss.getWitherBoss(team); + LivingEntity entity = boss.getEntity(); + + // Dead Wither + if (entity == null || !entity.isValid() || entity.isDead()) + { + // Get the other team + for (GameTeam otherTeam : GetTeamList()) + { + for (Player player : otherTeam.GetPlayers(true)) + { + AddGems(player, 10, "Participation", false, false); + } + + if (team.equals(otherTeam)) + { + continue; + } + + for (Player player : otherTeam.GetPlayers(true)) + { + AddGems(player, 20, "Winning", false, false); + } + + AnnounceEnd(otherTeam); + SetState(GameState.End); + } + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java index 29d7083ed..dd2d2a823 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java @@ -32,6 +32,7 @@ public class MobaPlayer public void setKit(HeroKit kit) { + _role = kit.getRole(); _kit = kit; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java index f2a0ef23c..bbf18f390 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -24,6 +24,8 @@ public class BossManager implements Listener private Map _teamBosses; private PumpkinBoss _pumpkinBoss; + private boolean _dummyBosses; + public BossManager(Moba host) { _host = host; @@ -39,15 +41,18 @@ public class BossManager implements Listener // Spawn Team Withers for (GameTeam team : _host.GetTeamList()) { - WitherBoss boss = new WitherBoss(_host, worldData.GetDataLocs(team.GetName().toUpperCase()).get(0), team); + WitherBoss boss = new WitherBoss(_host, worldData.GetDataLocs(team.GetName().toUpperCase()).get(0), team, _dummyBosses); boss.setup(); _teamBosses.put(team, boss); } // Pumpkin King - _pumpkinBoss = new PumpkinBoss(_host, worldData.GetDataLocs("BLACK").get(0)); - _pumpkinBoss.setup(); + if (!_dummyBosses) + { + _pumpkinBoss = new PumpkinBoss(_host, worldData.GetDataLocs("BLACK").get(0)); + _pumpkinBoss.setup(); + } _host.CreatureAllowOverride = false; } @@ -72,7 +77,11 @@ public class BossManager implements Listener } _teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup()); - _pumpkinBoss.cleanup(); + + if (_pumpkinBoss != null) + { + _pumpkinBoss.cleanup(); + } } public String getWitherDisplayString(GameTeam team) @@ -96,4 +105,9 @@ public class BossManager implements Listener return bosses; } + + public void setDummyBosses(boolean dummyBosses) + { + _dummyBosses = dummyBosses; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index 0b2f7adc2..e46cdffd7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -5,22 +5,16 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.MobaAI; -import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; import java.util.ArrayList; import java.util.List; -import java.util.function.Consumer; public abstract class MobaBoss implements Listener { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index bd8177115..9daf921f2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -45,16 +45,18 @@ public class WitherBoss extends MobaBoss private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); - private GameTeam _team; + private final GameTeam _team; + private final boolean _dummy; private MobaAI _ai; private DisguiseWither _disguise; private boolean _damageable; private long _lastInform; - public WitherBoss(Moba host, Location location, GameTeam team) + public WitherBoss(Moba host, Location location, GameTeam team, boolean dummy) { super(host, location); + _dummy = dummy; _location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, host.GetSpectatorLocation()))); _team = team; @@ -101,9 +103,9 @@ public class WitherBoss extends MobaBoss @EventHandler(priority = EventPriority.LOWEST) public void preDamage(CustomDamageEvent event) { - if (_host instanceof MobaTraining) + if (_dummy) { - event.SetCancelled("Training Mode"); + event.SetCancelled("Dummy Boss"); return; } @@ -193,7 +195,7 @@ public class WitherBoss extends MobaBoss { Tower tower = event.getTower(); - if (!_team.equals(tower.getOwner())) + if (!_team.equals(tower.getOwner()) || _dummy) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java deleted file mode 100644 index aa06f1003..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java +++ /dev/null @@ -1,39 +0,0 @@ -package nautilus.game.arcade.game.games.moba.buff.buffs; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.itemstack.ItemBuilder; -import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.buff.Buff; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -public class BuffCripple extends Buff -{ - - private static final ItemStack ITEM = new ItemBuilder(Material.IRON_INGOT) - .setTitle(C.cGray + "Crippled") - .build(); - - public static ItemStack getItemRepresentation() - { - return ITEM; - } - - public BuffCripple(Moba host, Player entity, long duration) - { - super(host, entity, duration); - } - - @Override - public void onApply() - { - UtilTextMiddle.display("", C.cRed + "Crippled", 10, 20, 10, _entity); - } - - @Override - public void onExpire() - { - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 59cdd544a..499440172 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -14,7 +14,6 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.buff.buffs.BuffCripple; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; @@ -280,13 +279,6 @@ public class HeroSkill extends Perk boolean done = UtilTime.elapsed(start, cooldown); - // If the player is crippled say they are - if (moba.getBuffManager().hasBuff(player, BuffCripple.class)) - { - player.getInventory().setItem(_slot, BuffCripple.getItemRepresentation()); - continue; - } - if (done) { _lastSkill.remove(player.getUniqueId()); @@ -366,7 +358,7 @@ public class HeroSkill extends Perk GameTeam team = Manager.GetGame().GetTeam((Player) damager); - return team != null && MobaUtil.isTeamEntity(damagee, team); + return !Manager.GetGame().DamageTeamSelf && team != null && MobaUtil.isTeamEntity(damagee, team); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java index c7834d07d..db20421c5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java @@ -6,7 +6,6 @@ import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.shop.MobaItem; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java index 2a64ce53c..b137f3c32 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java @@ -7,7 +7,6 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.particles.effects.LineParticle; -import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java index 69cc3a8f4..5651ad7fd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java @@ -6,7 +6,6 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.buff.BuffManager; -import nautilus.game.arcade.game.games.moba.buff.buffs.BuffCripple; import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index e3c663632..6e502a6d1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -17,9 +17,6 @@ import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.ChatColor; import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.Sign; import org.bukkit.entity.PigZombie; import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; @@ -70,7 +67,7 @@ public class MinionManager implements Listener @EventHandler public void gameCountdownCommence(GamePrepareCountdownCommence event) { - UtilServer.runSyncLater(() -> setEnabled(true), MINION_SPAWN_DELAY_TICKS); + UtilServer.runSyncLater(() -> setEnabled(!_enabled), MINION_SPAWN_DELAY_TICKS); } @EventHandler @@ -131,7 +128,13 @@ public class MinionManager implements Listener } } - public void setEnabled(boolean enabled) + public void disableMinions() + { + // As when the game starts _enabled is inverted. + _enabled = true; + } + + private void setEnabled(boolean enabled) { _enabled = enabled; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 5d9f3e77f..6339d7ed0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -14,10 +14,8 @@ import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; import nautilus.game.arcade.game.games.moba.boss.MobaBoss; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; -import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; -import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -27,15 +25,11 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.scheduler.BukkitRunnable; -import org.jooq.util.derby.sys.Sys; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Map; public class MinionWave implements Listener { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index 11ab9881d..6a9d42ba5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -7,7 +7,6 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index 73cb8e7c0..6497434a2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -2,7 +2,10 @@ package nautilus.game.arcade.game.games.moba.training; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilTime; import mineplex.core.hologram.Hologram; +import mineplex.core.utils.UtilVariant; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -10,20 +13,32 @@ import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaPlayer; +import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.TrainingGameModule; +import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Villager; import org.bukkit.event.EventHandler; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.function.Function; public class MobaTraining extends Moba { + private static final String[] DESCRIPTION = { + "Heroes of GWEN", + "Training Ground" + }; private static final String[][] HELP_HOLOGRAMS = { { @@ -34,33 +49,156 @@ public class MobaTraining extends Moba private Location _borderA; private Location _borderB; + private Location _teleport; + private Location _selectKit; + private Location _lookAt; private Function _safeFunction = player -> UtilAlg.inBoundingBox(player.getLocation(), _borderA, _borderB); - private Function _teamFunction = player -> GetTeam(ChatColor.GRAY); + private Function _teamFunction = player -> GetTeam(ChatColor.YELLOW); + + private final Set _entities = new HashSet<>(); public MobaTraining(ArcadeManager manager) { - super(manager, GameType.MOBATraining); + super(manager, GameType.MOBATraining, DESCRIPTION); + DamageTeamSelf = true; DeathSpectateSecs = 0; PrepareTime = 500; GiveClock = false; HideTeamSheep = true; + // Prevent the wither from being damaged as well as to not spawn the pumpkin king + _boss.setDummyBosses(true); + + // Disable minions + _minion.disableMinions(); + new TrainingGameModule() .setGiveReturnToSpawn(false) .setSkillFunction(_safeFunction) .setDamageFunction(_safeFunction) .setTeamFunction(_teamFunction) .register(this); + + new CustomScoreboardModule() + .setSidebar(this::write) + .setPrefix((perspective, subject) -> + { + if (!IsAlive(subject)) + { + return C.cGray; + } + + GameTeam team = GetTeam(subject); + + return team.GetColor().toString(); + }) + .setSuffix((perspective, subject) -> + { + GameState state = GetState(); + GameTeam perspectiveTeam = GetTeam(perspective); + GameTeam subjectTeam = GetTeam(subject); + + if (!IsAlive(subject) || perspectiveTeam == null || subjectTeam == null) + { + return ""; + } + + MobaPlayer mobaPlayer = getMobaData(subject); + String suffix; + + if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam)) + { + suffix = C.cYellow + " Unknown"; + } + else if (mobaPlayer.getKit() == null) + { + suffix = C.cYellow + " Selecting"; + } + else + { + suffix = mobaPlayer.getRole().getChatColor() + " [" + mobaPlayer.getKit().GetName() + "]"; + } + + return suffix + C.Reset; + }) + .setUnderNameObjective(C.cRed + "❤") + .setUnderName((perspective, subject) -> + (int) (Math.ceil(subject.getHealth() / 2D))) + .register(this); + } + + private void write(Player player, GameScoreboard scoreboard) + { + boolean alive = IsAlive(player); + MobaPlayer mobaPlayer = getMobaData(player); + + if (mobaPlayer != null && mobaPlayer.getRole() != null && mobaPlayer.getKit() != null) + { + scoreboard.writeNewLine(); + + scoreboard.write(C.cYellowB + "Hero"); + scoreboard.write(mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getChatColor() + mobaPlayer.getRole().getName() + C.cWhite + ")"); + } + + scoreboard.writeNewLine(); + + // Gold + scoreboard.write(C.cGoldB + "Your Gold"); + if (alive) + { + int gold = _goldManager.getGold(player); + + scoreboard.write(String.valueOf(gold)); + } + else + { + scoreboard.write("None"); + } + + scoreboard.writeNewLine(); + + scoreboard.write(C.cYellowB + "Time"); + scoreboard.write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime())); } @Override public void ParseData() { + super.ParseData(); + List locations = WorldData.GetDataLocs("BROWN"); _borderA = locations.get(0); _borderB = locations.get(1); + + _selectKit = WorldData.GetCustomLocs("SELECT_KIT").get(0); + _teleport = WorldData.GetCustomLocs("JOIN_GAME").get(0); + _lookAt = WorldData.GetCustomLocs("LOOK_AT").get(0); + } + + @EventHandler + public void adjuctSpawns(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (Location location : GetTeam(ChatColor.YELLOW).GetSpawns()) + { + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _lookAt))); + } + + for (Location location : GetTeam(ChatColor.GRAY).GetSpawns()) + { + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _lookAt))); + } + + for (Location location : WorldData.GetDataLocs("LIME")) + { + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, SpectatorSpawn))); + } } @EventHandler @@ -72,8 +210,9 @@ public class MobaTraining extends Moba } GameTeam players = GetTeam(ChatColor.GRAY); + players.SetColor(ChatColor.GRAY); players.SetName("Players"); - players.setDisplayName(C.cGray + "Players"); + players.setDisplayName(C.cYellow + "Players"); } @EventHandler @@ -95,6 +234,18 @@ public class MobaTraining extends Moba CreatureAllowOverride = true; + spawnHelpText(); + spawnDummies(); + spawnNPCs(); + + for (LivingEntity entity : _entities) + { + entity.setCustomNameVisible(true); + UtilEnt.vegetate(entity); + UtilEnt.setFakeHead(entity, true); + UtilEnt.silence(entity, true); + } + CreatureAllowOverride = false; } @@ -112,4 +263,39 @@ public class MobaTraining extends Moba new Hologram(Manager.getHologramManager(), entry.getValue(), true, display).start(); } } + + private void spawnDummies() + { + { + Skeleton skeleton = UtilVariant.spawnWitherSkeleton(WorldData.GetCustomLocs("PUMPKIN_KING").get(0)); + skeleton.setCustomName(C.cDRedB + "Pumpkin King"); + UtilEnt.CreatureLook(skeleton, 90); + + _entities.add(skeleton); + } + } + + private void spawnNPCs() + { + { + Villager villager = WorldData.World.spawn(_selectKit, Villager.class); + villager.setCustomName(C.cYellow + "Select A Hero"); + UtilEnt.CreatureLook(villager, _lookAt); + + _entities.add(villager); + } + { + Villager villager = WorldData.World.spawn(_selectKit, Villager.class); + villager.setCustomName(C.cYellow + "Join The Game"); + UtilEnt.CreatureLook(villager, _lookAt); + + _entities.add(villager); + } + } + + private void teleportIntoArena(Player player) + { + player.teleport(UtilAlg.Random(WorldData.GetDataLocs("LIME"))); + SetPlayerTeam(player, GetTeam(ChatColor.YELLOW), true); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 54bf4ee50..b4efa6382 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -46,7 +46,7 @@ public class MobaUtil } // Check for team entities - if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) + if (isTeamEntity(entity, owner)) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java index 928a2e919..efb25437b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java @@ -4,6 +4,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -37,7 +38,7 @@ import java.util.function.BiFunction; * * * @see mineplex.core.scoreboard.MineplexScoreboard - * @see nautilus.game.arcade.game.games.moba.Moba + * @see Moba */ public class CustomScoreboardModule extends Module { From f22a091fa0b82c7336a384dcba836a46b0cd093e Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 22 Jun 2017 20:21:19 +0100 Subject: [PATCH 235/283] More training game stuff --- .../moba/kit/larissa/SkillWaterDash.java | 16 ---- .../games/moba/training/MobaTraining.java | 73 ++++++++++++++----- 2 files changed, 54 insertions(+), 35 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java index 5651ad7fd..21e8686ac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java @@ -3,9 +3,6 @@ package nautilus.game.arcade.game.games.moba.kit.larissa; 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.UtilPlayer; -import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.buff.BuffManager; import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -21,7 +18,6 @@ public class SkillWaterDash extends DashSkill "come into contact with." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); - private static final long CRIPPLE_DURATION = TimeUnit.SECONDS.toMillis(3); public SkillWaterDash(int slot) { @@ -39,18 +35,6 @@ public class SkillWaterDash extends DashSkill public void dashTick(Player player) { UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 5, ViewDist.LONG); - Moba moba = (Moba) Manager.GetGame(); - BuffManager buffManager = moba.getBuffManager(); - - for (Player nearby : UtilPlayer.getNearby(player.getLocation(), 2)) - { - if (isTeamDamage(nearby, player) || buffManager.hasBuff(nearby, BuffCripple.class)) - { - continue; - } - - buffManager.apply(new BuffCripple(moba, nearby, CRIPPLE_DURATION)); - } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index 6497434a2..2791cb139 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -4,8 +4,10 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.hologram.Hologram; import mineplex.core.utils.UtilVariant; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -19,6 +21,7 @@ import nautilus.game.arcade.game.modules.TrainingGameModule; import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.entity.ArmorStand; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; @@ -49,9 +52,8 @@ public class MobaTraining extends Moba private Location _borderA; private Location _borderB; - private Location _teleport; private Location _selectKit; - private Location _lookAt; + private LivingEntity _selectKitEntity; private Function _safeFunction = player -> UtilAlg.inBoundingBox(player.getLocation(), _borderA, _borderB); private Function _teamFunction = player -> GetTeam(ChatColor.YELLOW); @@ -173,12 +175,10 @@ public class MobaTraining extends Moba _borderB = locations.get(1); _selectKit = WorldData.GetCustomLocs("SELECT_KIT").get(0); - _teleport = WorldData.GetCustomLocs("JOIN_GAME").get(0); - _lookAt = WorldData.GetCustomLocs("LOOK_AT").get(0); } @EventHandler - public void adjuctSpawns(GameStateChangeEvent event) + public void adjustSpawns(GameStateChangeEvent event) { if (event.GetState() != GameState.Prepare) { @@ -187,12 +187,12 @@ public class MobaTraining extends Moba for (Location location : GetTeam(ChatColor.YELLOW).GetSpawns()) { - location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _lookAt))); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _selectKit))); } for (Location location : GetTeam(ChatColor.GRAY).GetSpawns()) { - location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _lookAt))); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _selectKit))); } for (Location location : WorldData.GetDataLocs("LIME")) @@ -249,6 +249,22 @@ public class MobaTraining extends Moba CreatureAllowOverride = false; } + @EventHandler + public void entityDamage(CustomDamageEvent event) + { + if (!_entities.contains(event.GetDamageeEntity())) + { + return; + } + + event.SetCancelled("NPC"); + + if (_selectKitEntity != null && _selectKitEntity.equals(event.GetDamageeEntity())) + { + teleportIntoArena(event.GetDamagerPlayer(false)); + } + } + private void spawnHelpText() { Map locationMap = getLocationStartsWith("HELP"); @@ -273,28 +289,47 @@ public class MobaTraining extends Moba _entities.add(skeleton); } + { + Location location = WorldData.GetCustomLocs("DUMMY_WITHER").get(0); + ArmorStand stand = location.getWorld().spawn(location, ArmorStand.class); + + // Reducing the wither's health to 10% gives a shield like effect. + stand.setGravity(false); + + UtilEnt.setBoundingBox(stand, 3, 5); + + DisguiseWither disguise = new DisguiseWither(stand); + disguise.setName(C.cAqua + "Blue's Wither"); + disguise.setCustomNameVisible(true); + Manager.GetDisguise().disguise(disguise); + + _entities.add(stand); + } + { + Location location = WorldData.GetCustomLocs("DUMMY_SHOP").get(0); + Villager villager = location.getWorld().spawn(location, Villager.class); + villager.setCustomName(C.cGoldB + "Gold Upgrades"); + } } private void spawnNPCs() { - { - Villager villager = WorldData.World.spawn(_selectKit, Villager.class); - villager.setCustomName(C.cYellow + "Select A Hero"); - UtilEnt.CreatureLook(villager, _lookAt); + Villager villager = WorldData.World.spawn(_selectKit, Villager.class); + villager.setCustomName(C.cYellow + "Select A Hero"); + UtilEnt.CreatureLook(villager, WorldData.GetDataLocs("LIME").get(0)); - _entities.add(villager); - } - { - Villager villager = WorldData.World.spawn(_selectKit, Villager.class); - villager.setCustomName(C.cYellow + "Join The Game"); - UtilEnt.CreatureLook(villager, _lookAt); + _entities.add(villager); + _selectKitEntity = villager; - _entities.add(villager); - } } private void teleportIntoArena(Player player) { + if (player == null) + { + return; + } + player.teleport(UtilAlg.Random(WorldData.GetDataLocs("LIME"))); SetPlayerTeam(player, GetTeam(ChatColor.YELLOW), true); } From 65ebf41d4fbd4e32237a9b72344df9d8adc08412 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 23 Jun 2017 01:43:11 +0100 Subject: [PATCH 236/283] Finish the training game for now --- .../game/arcade/game/games/moba/MobaRole.java | 2 +- .../game/games/moba/boss/BossManager.java | 14 +- .../games/moba/boss/wither/WitherBoss.java | 13 +- .../games/moba/general/MobaDamageManager.java | 9 +- .../game/games/moba/gold/GoldManager.java | 20 +- .../arcade/game/games/moba/kit/HeroKit.java | 5 + .../arcade/game/games/moba/kit/HeroSkill.java | 13 +- .../game/games/moba/minion/MinionManager.java | 28 +-- .../games/moba/prepare/PrepareSelection.java | 10 +- .../games/moba/training/MobaTraining.java | 198 +++++++++++++++--- .../games/moba/training/SelectKitMenu.java | 70 +++++++ .../game/modules/TrainingGameModule.java | 6 + 12 files changed, 289 insertions(+), 99 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/SelectKitMenu.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index 014d12a4d..dd09209b9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -6,7 +6,7 @@ import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", Color.GRAY, ChatColor.DARK_GRAY), + ASSASSIN("Assassin", Color.GRAY, ChatColor.GRAY), HUNTER("Hunter", Color.LIME, ChatColor.GREEN), MAGE("Mage", Color.PURPLE, ChatColor.DARK_PURPLE), WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java index bbf18f390..7b45daa6b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -34,6 +34,11 @@ public class BossManager implements Listener private void spawnBosses() { + if (_dummyBosses) + { + return; + } + _host.CreatureAllowOverride = true; WorldData worldData = _host.WorldData; @@ -41,18 +46,15 @@ public class BossManager implements Listener // Spawn Team Withers for (GameTeam team : _host.GetTeamList()) { - WitherBoss boss = new WitherBoss(_host, worldData.GetDataLocs(team.GetName().toUpperCase()).get(0), team, _dummyBosses); + WitherBoss boss = new WitherBoss(_host, worldData.GetDataLocs(team.GetName().toUpperCase()).get(0), team); boss.setup(); _teamBosses.put(team, boss); } // Pumpkin King - if (!_dummyBosses) - { - _pumpkinBoss = new PumpkinBoss(_host, worldData.GetDataLocs("BLACK").get(0)); - _pumpkinBoss.setup(); - } + _pumpkinBoss = new PumpkinBoss(_host, worldData.GetDataLocs("BLACK").get(0)); + _pumpkinBoss.setup(); _host.CreatureAllowOverride = false; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 9daf921f2..8d80c7f5e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -21,7 +21,6 @@ import nautilus.game.arcade.game.games.moba.boss.MobaBoss; import nautilus.game.arcade.game.games.moba.boss.wither.attack.BossAttackEarthquake; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; -import nautilus.game.arcade.game.games.moba.training.MobaTraining; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.EntityEffect; import org.bukkit.Location; @@ -46,17 +45,15 @@ public class WitherBoss extends MobaBoss private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); private final GameTeam _team; - private final boolean _dummy; private MobaAI _ai; private DisguiseWither _disguise; private boolean _damageable; private long _lastInform; - public WitherBoss(Moba host, Location location, GameTeam team, boolean dummy) + public WitherBoss(Moba host, Location location, GameTeam team) { super(host, location); - _dummy = dummy; _location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, host.GetSpectatorLocation()))); _team = team; @@ -103,12 +100,6 @@ public class WitherBoss extends MobaBoss @EventHandler(priority = EventPriority.LOWEST) public void preDamage(CustomDamageEvent event) { - if (_dummy) - { - event.SetCancelled("Dummy Boss"); - return; - } - if (!event.GetDamageeEntity().equals(_entity) || MobaUtil.isInBoundary(_team, _entity, _location, getAi().getBoundaries(), event.GetDamagerPlayer(true))) { return; @@ -195,7 +186,7 @@ public class WitherBoss extends MobaBoss { Tower tower = event.getTower(); - if (!_team.equals(tower.getOwner()) || _dummy) + if (!_team.equals(tower.getOwner())) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java index e989d5b09..7fa54255c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java @@ -43,14 +43,7 @@ public class MobaDamageManager implements Listener return; } - if (damageeTeam.equals(damagerTeam)) - { - event.SetCancelled("Team Damage"); - } - else - { - _host.getScoreboardModule().refreshAsSubject(damagee); - } + _host.getScoreboardModule().refreshAsSubject(damagee); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index afdd3582d..312aebec7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -67,20 +67,6 @@ public class GoldManager implements Listener }); } - @EventHandler - public void prepare(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - { - return; - } - - for (Player player : _host.GetPlayers(true)) - { - _playerGold.put(player, 0); - } - } - @EventHandler public void playerQuit(PlayerQuitEvent event) { @@ -146,7 +132,7 @@ public class GoldManager implements Listener public int getGold(Player player) { - return _playerGold.get(player); + return _playerGold.getOrDefault(player, 0); } public void addGold(Player player, int amount) @@ -156,6 +142,7 @@ public class GoldManager implements Listener public void addGold(Player player, int amount, String reason) { + _playerGold.putIfAbsent(player, 0); _playerGold.put(player, _playerGold.get(player) + amount); _host.getArcadeManager().GetStatsManager().incrementStat(player, _host.GetName() + ".GoldEarned", amount); @@ -168,12 +155,13 @@ public class GoldManager implements Listener public void removeGold(Player player, int amount) { + _playerGold.putIfAbsent(player, 0); _playerGold.put(player, _playerGold.get(player) - amount); } public boolean hasGold(Player player, int amount) { - return _playerGold.get(player) >= amount; + return _playerGold.getOrDefault(player, 0) >= amount; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index abde5d9c1..707bc435f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -262,6 +262,11 @@ public class HeroKit extends Kit Manager.GetDisguise().disguise(disguise); } + public SkinData getSkinData() + { + return _skin; + } + public boolean isVisible() { return _visible; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 499440172..4668d565d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -107,13 +107,13 @@ public class HeroSkill extends Perk _item = new ItemBuilder(_item) .setTitle((action != null ? C.cYellowB + action + C.cGray + " - " : "") + C.cGreenB + GetName()) - .addLore(GetDesc()) + .setLore(GetDesc()) .setUnbreakable(true) .build(); _cooldownItem = new ItemBuilder(Material.INK_SACK, (byte) 8) .setTitle(C.cRed + GetName()) - .addLore(GetDesc()) + .setLore(GetDesc()) .setUnbreakable(true) .build(); } @@ -351,14 +351,19 @@ public class HeroSkill extends Perk protected boolean isTeamDamage(LivingEntity damagee, LivingEntity damager) { - if (!(damager instanceof Player)) + if (damagee.equals(damager)) + { + return true; + } + + if (!(damager instanceof Player) || Manager.GetGame().DamageTeamSelf) { return false; } GameTeam team = Manager.GetGame().GetTeam((Player) damager); - return !Manager.GetGame().DamageTeamSelf && team != null && MobaUtil.isTeamEntity(damagee, team); + return team != null && MobaUtil.isTeamEntity(damagee, team); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 6e502a6d1..9e3790713 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -4,11 +4,9 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; @@ -33,7 +31,6 @@ import java.util.concurrent.TimeUnit; public class MinionManager implements Listener { - private static final int MINION_SPAWN_DELAY_TICKS = 40; private static final long MINION_SPAWN_TIME = TimeUnit.SECONDS.toMillis(30); private final Moba _host; @@ -48,6 +45,7 @@ public class MinionManager implements Listener { _host = host; _waves = new HashSet<>(); + _enabled = true; host.registerDebugCommand(new DebugCommand("removeminions", Rank.DEVELOPER) { @@ -64,12 +62,6 @@ public class MinionManager implements Listener }); } - @EventHandler - public void gameCountdownCommence(GamePrepareCountdownCommence event) - { - UtilServer.runSyncLater(() -> setEnabled(!_enabled), MINION_SPAWN_DELAY_TICKS); - } - @EventHandler public void spawnMinions(UpdateEvent event) { @@ -80,6 +72,11 @@ public class MinionManager implements Listener _lastWave = System.currentTimeMillis(); + if (_path == null) + { + preparePath(); + } + for (GameTeam team : _host.GetTeamList()) { List path = new ArrayList<>(_path); @@ -130,18 +127,7 @@ public class MinionManager implements Listener public void disableMinions() { - // As when the game starts _enabled is inverted. - _enabled = true; - } - - private void setEnabled(boolean enabled) - { - _enabled = enabled; - - if (enabled) - { - preparePath(); - } + _enabled = false; } public void unregisterWave(MinionWave wave) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index 23f01e5e9..bad2ee430 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -112,8 +112,6 @@ public class PrepareSelection implements Listener, IPacketHandler List heroKits = _host.getKits(mobaPlayer.getRole()); - ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 2).build(); - UtilServer.runSyncLater(() -> { for (Location location : spawns.values()) @@ -126,10 +124,10 @@ public class PrepareSelection implements Listener, IPacketHandler stand.setCustomNameVisible(true); stand.setCustomName(C.cGreenB + kit.GetName()); stand.setArms(true); - stand.setHelmet(head); -// stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); -// stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); -// stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); + stand.setHelmet(kit.getSkinData().getSkull()); + stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, kit.getRole())); + stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, kit.getRole())); + stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, kit.getRole())); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 0.5F); UtilParticle.PlayParticle(ParticleType.CLOUD, location.clone().add(0, 2, 0), 0.5F, 0.5F, 0.5F, 0.01F, 20, ViewDist.LONG, player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index 2791cb139..35fd2bc74 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -1,38 +1,45 @@ package nautilus.game.arcade.game.games.moba.training; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.hologram.Hologram; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilVariant; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerStateChangeEvent; +import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaPlayer; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.TrainingGameModule; import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.entity.Villager; +import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.concurrent.TimeUnit; import java.util.function.Function; public class MobaTraining extends Moba @@ -45,17 +52,63 @@ public class MobaTraining extends Moba private static final String[][] HELP_HOLOGRAMS = { { - + C.cYellow + "Welcome to " + C.cGreen + "Heroes of GWEN", + C.cYellow + "Here you can use learn about the game", + C.cYellow + "and test out the Heroes.", + C.cYellow + "If you know what you are doing you can type", + C.cGreen + "/skip" + C.cYellow + " to skip to the end of the tutorial." + }, + { + C.cGreen + "Heroes of GWEN" + C.cYellow + " is a MOBA style game.", + C.cYellow + "There are " + C.cGreen + "4" + C.cYellow + " Roles of Heroes to play", + C.cYellow + "with many different Heroes within each role." + }, + { + C.cYellow + "This is a " + C.cGreen + "Tower", + C.cYellow + "You need to destroy these in order to be able", + C.cYellow + "to attack the other team's " + C.cGreen + "Wither" + C.cYellow + " to win the game." + }, + { + C.cYellow + "This is a " + C.cGreen + "Beacon", + C.cYellow + "You can capture these for your team.", + C.cYellow + "Capturing and holding these increases the amount", + C.cYellow + "of " + C.cGold + "Gold" + C.cYellow + " your team earns." + }, + { + C.cYellow + "The is the " + C.cDRedB + "Pumpkin King", + C.cYellow + "He spawns at " + C.cGreen + "10 minutes" + C.cYellow + " into the game.", + C.cYellow + "The team that kills him will be given increased", + C.cYellow + "regeneration and damage." + }, + { + C.cYellow + "Once all of the enemy's towers are destroyed", + C.cYellow + "your team can attack their " + C.cGreen + "Wither", + C.cYellow + "Once the Wither is killed the game is over!" + }, + { + C.cGreen + "Minions" + C.cYellow + " spawn for both teams periodically", + C.cYellow + "and make their way to each other's bases.", + C.cYellow + "They will fight each other and help destroy enemy Towers." + }, + { + C.cYellow + "With the " + C.cGold + "Gold" + C.cYellow + "you earn you can", + C.cYellow + "spend it on upgrades for your weapons and armor.", + C.cYellow + "You can do this via the gold ingot in your inventory", + C.cYellow + "during the game or by clicking on the Villager." + }, + { + C.cYellow + "Now you know the basics", + C.cYellow + "Click on this NPC to select a Hero", + C.cYellow + "to try out!" } }; + private static final long GAME_TIME = TimeUnit.HOURS.toMillis(3); private static final int GOLD = 100000; private Location _borderA; private Location _borderB; private Location _selectKit; private LivingEntity _selectKitEntity; - private Function _safeFunction = player -> UtilAlg.inBoundingBox(player.getLocation(), _borderA, _borderB); - private Function _teamFunction = player -> GetTeam(ChatColor.YELLOW); private final Set _entities = new HashSet<>(); @@ -64,10 +117,13 @@ public class MobaTraining extends Moba super(manager, GameType.MOBATraining, DESCRIPTION); DamageTeamSelf = true; + DamageFall = false; + DeathOut = false; DeathSpectateSecs = 0; PrepareTime = 500; GiveClock = false; HideTeamSheep = true; + HungerSet = 20; // Prevent the wither from being damaged as well as to not spawn the pumpkin king _boss.setDummyBosses(true); @@ -75,11 +131,13 @@ public class MobaTraining extends Moba // Disable minions _minion.disableMinions(); + Function safeFunction = player -> UtilAlg.inBoundingBox(player.getLocation(), _borderA, _borderB); + Function teamFunction = player -> GetTeam(ChatColor.GRAY); new TrainingGameModule() .setGiveReturnToSpawn(false) - .setSkillFunction(_safeFunction) - .setDamageFunction(_safeFunction) - .setTeamFunction(_teamFunction) + .setSkillFunction(safeFunction) + .setDamageFunction(safeFunction) + .setTeamFunction(teamFunction) .register(this); new CustomScoreboardModule() @@ -128,6 +186,18 @@ public class MobaTraining extends Moba .setUnderName((perspective, subject) -> (int) (Math.ceil(subject.getHealth() / 2D))) .register(this); + + registerDebugCommand(new DebugCommand("skip", Rank.ALL) + { + @Override + public void Execute(Player caller, String[] args) + { + if (!safeFunction.apply(caller)) + { + caller.teleport(GetTeam(ChatColor.YELLOW).GetSpawn()); + } + } + }); } private void write(Player player, GameScoreboard scoreboard) @@ -140,7 +210,7 @@ public class MobaTraining extends Moba scoreboard.writeNewLine(); scoreboard.write(C.cYellowB + "Hero"); - scoreboard.write(mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getChatColor() + mobaPlayer.getRole().getName() + C.cWhite + ")"); + scoreboard.write(mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getName() + C.cWhite + ")"); } scoreboard.writeNewLine(); @@ -162,6 +232,8 @@ public class MobaTraining extends Moba scoreboard.write(C.cYellowB + "Time"); scoreboard.write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime())); + + scoreboard.writeNewLine(); } @Override @@ -175,6 +247,7 @@ public class MobaTraining extends Moba _borderB = locations.get(1); _selectKit = WorldData.GetCustomLocs("SELECT_KIT").get(0); + SpectatorSpawn = _selectKit; } @EventHandler @@ -195,9 +268,10 @@ public class MobaTraining extends Moba location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _selectKit))); } + Location center = WorldData.GetCustomLocs("CENTER").get(0); for (Location location : WorldData.GetDataLocs("LIME")) { - location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, SpectatorSpawn))); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, center))); } } @@ -208,19 +282,54 @@ public class MobaTraining extends Moba { return; } + { + GameTeam players = GetTeam(ChatColor.RED); + players.SetColor(ChatColor.GRAY); + players.SetName("Players"); + players.setDisplayName(C.cYellowB + "Players"); + } + { + GameTeam players = GetTeam(ChatColor.GREEN); + players.SetColor(ChatColor.YELLOW); + players.SetName("Players"); + players.setDisplayName(C.cYellowB + "Players"); + } + } - GameTeam players = GetTeam(ChatColor.GRAY); - players.SetColor(ChatColor.GRAY); - players.SetName("Players"); - players.setDisplayName(C.cYellow + "Players"); + @Override + public GameTeam ChooseTeam(Player player) + { + return GetTeam(ChatColor.GRAY); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + if (UtilTime.elapsed(GetStateTime(), GAME_TIME)) + { + SetState(GameState.Dead); + } } @EventHandler - public void giveGold(PlayerStateChangeEvent event) + public void giveGold(UpdateEvent event) { - if (event.GetState() == PlayerState.IN) + if (event.getType() != UpdateType.SEC) { - _goldManager.addGold(event.GetPlayer(), GOLD); + return; + } + + for (Player player : GetPlayers(true)) + { + if (_goldManager.getGold(player) < 100) + { + _goldManager.addGold(player, GOLD); + } } } @@ -261,10 +370,44 @@ public class MobaTraining extends Moba if (_selectKitEntity != null && _selectKitEntity.equals(event.GetDamageeEntity())) { - teleportIntoArena(event.GetDamagerPlayer(false)); + openMenu(event.GetDamagerPlayer(false)); } } + @EventHandler + public void entityInteract(PlayerInteractAtEntityEvent event) + { + if (_selectKitEntity != null && event.getRightClicked().equals(_selectKitEntity)) + { + openMenu(event.getPlayer()); + } + } + + @EventHandler + public void updateEntityLocation(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (LivingEntity entity : _entities) + { + Location location = entity.getLocation(); + ((CraftEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ()); + } + } + + private void openMenu(Player player) + { + if (player == null) + { + return; + } + + new SelectKitMenu(Manager).open(player); + } + private void spawnHelpText() { Map locationMap = getLocationStartsWith("HELP"); @@ -272,9 +415,9 @@ public class MobaTraining extends Moba for (Entry entry : locationMap.entrySet()) { String[] split = entry.getKey().split(" "); - String index = split[0]; + String index = split[1]; int indexInt = Integer.parseInt(index); - String[] display = HELP_HOLOGRAMS[indexInt]; + String[] display = HELP_HOLOGRAMS[indexInt - 1]; new Hologram(Manager.getHologramManager(), entry.getValue(), true, display).start(); } @@ -308,29 +451,32 @@ public class MobaTraining extends Moba { Location location = WorldData.GetCustomLocs("DUMMY_SHOP").get(0); Villager villager = location.getWorld().spawn(location, Villager.class); + villager.setProfession(Profession.LIBRARIAN); villager.setCustomName(C.cGoldB + "Gold Upgrades"); + + _entities.add(villager); } } private void spawnNPCs() { Villager villager = WorldData.World.spawn(_selectKit, Villager.class); - villager.setCustomName(C.cYellow + "Select A Hero"); - UtilEnt.CreatureLook(villager, WorldData.GetDataLocs("LIME").get(0)); + villager.setCustomName(C.cYellowB + "Select A Hero"); + UtilEnt.CreatureLook(villager, GetTeam(ChatColor.YELLOW).GetSpawns().get(0)); _entities.add(villager); _selectKitEntity = villager; - } - private void teleportIntoArena(Player player) + public void teleportIntoArena(Player player, HeroKit kit) { - if (player == null) + if (!kit.equals(GetKit(player))) { - return; + _shop.clearPurchases(player); } player.teleport(UtilAlg.Random(WorldData.GetDataLocs("LIME"))); SetPlayerTeam(player, GetTeam(ChatColor.YELLOW), true); + SetKit(player, kit, true); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/SelectKitMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/SelectKitMenu.java new file mode 100644 index 000000000..6b1287d6e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/SelectKitMenu.java @@ -0,0 +1,70 @@ +package nautilus.game.arcade.game.games.moba.training; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilUI; +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.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +public class SelectKitMenu extends Menu +{ + + public SelectKitMenu(ArcadeManager plugin) + { + super("Select A Hero", plugin); + } + + @Override + protected Button[] setUp(Player player) + { + MobaTraining moba = (MobaTraining) getPlugin().GetGame(); + Button[] buttons = new Button[36]; + int[] slots = UtilUI.getIndicesFor(moba.GetKits().length, 1); + int i = 0; + + for (int slot : slots) + { + HeroKit kit = (HeroKit) moba.GetKits()[i++]; + ItemBuilder builder = new ItemBuilder(kit.getSkinData().getSkull()); + + builder.setTitle(C.cGreen + kit.GetName()); + builder.addLore("", "Skills:"); + + for (Perk perk : kit.GetPerks()) + { + builder.addLore(C.cWhite + " - " + C.cYellow + perk.GetName()); + } + + builder.addLore("", C.cGreen + "Click to join the arena with this kit!"); + + buttons[slot] = new SelectKitButton(builder.build(), getPlugin(), kit); + } + + return buttons; + } + + private class SelectKitButton extends Button + { + + private final HeroKit _kit; + + private SelectKitButton(ItemStack item, ArcadeManager plugin, HeroKit kit) + { + super(item, plugin); + + _kit = kit; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + ((MobaTraining) getPlugin().GetGame()).teleportIntoArena(player, _kit); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java index 45dbf6e46..15f877ec2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java @@ -62,6 +62,12 @@ public class TrainingGameModule extends Module List locations = getGame().WorldData.GetDataLocs("PURPLE"); int i = 0; + + if (locations.isEmpty()) + { + return; + } + getGame().CreatureAllowOverride = true; for (Kit kit : getGame().GetKits()) From 21c7b082b0421280ee83d83b9c633e498a6267ce Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 23 Jun 2017 01:43:38 +0100 Subject: [PATCH 237/283] Add a method to clear purchases --- .../nautilus/game/arcade/game/games/moba/shop/MobaShop.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index f2707a965..a28a1acb2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -251,6 +251,11 @@ public class MobaShop implements Listener return null; } + public void clearPurchases(Player player) + { + _upgrades.remove(player); + } + @EventHandler public void playerDeath(PlayerDeathEvent event) { From 291296829573fdd3ee6b6d2ecc319f3015e4b8fe Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 23 Jun 2017 01:51:16 +0100 Subject: [PATCH 238/283] Fix movable NPCs --- .../arcade/game/games/moba/shop/MobaShop.java | 10 +++++-- .../games/moba/training/MobaTraining.java | 27 ++++++++++--------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index a28a1acb2..0fca426e2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -27,6 +27,7 @@ import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -131,7 +132,7 @@ public class MobaShop implements Listener LivingEntity entity = entry.getKey(); Location location = entry.getValue(); - ((CraftLivingEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ()); + ((CraftEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ()); } } @@ -253,7 +254,7 @@ public class MobaShop implements Listener public void clearPurchases(Player player) { - _upgrades.remove(player); + _upgrades.put(player, new ArrayList<>()); } @EventHandler @@ -327,6 +328,11 @@ public class MobaShop implements Listener Player player = event.getPlayer(); List items = _upgrades.get(player); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index 35fd2bc74..1b68e0af7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -21,6 +21,7 @@ import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.TrainingGameModule; +import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -34,11 +35,10 @@ import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import java.util.HashSet; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.function.Function; @@ -110,7 +110,7 @@ public class MobaTraining extends Moba private Location _selectKit; private LivingEntity _selectKitEntity; - private final Set _entities = new HashSet<>(); + private final Map _entities = new HashMap<>(); public MobaTraining(ArcadeManager manager) { @@ -347,7 +347,7 @@ public class MobaTraining extends Moba spawnDummies(); spawnNPCs(); - for (LivingEntity entity : _entities) + for (LivingEntity entity : _entities.keySet()) { entity.setCustomNameVisible(true); UtilEnt.vegetate(entity); @@ -361,7 +361,7 @@ public class MobaTraining extends Moba @EventHandler public void entityDamage(CustomDamageEvent event) { - if (!_entities.contains(event.GetDamageeEntity())) + if (!_entities.containsKey(event.GetDamageeEntity())) { return; } @@ -391,9 +391,11 @@ public class MobaTraining extends Moba return; } - for (LivingEntity entity : _entities) + for (Entry entry : _entities.entrySet()) { - Location location = entity.getLocation(); + LivingEntity entity = entry.getKey(); + Location location = entry.getValue(); + ((CraftEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ()); } } @@ -430,7 +432,7 @@ public class MobaTraining extends Moba skeleton.setCustomName(C.cDRedB + "Pumpkin King"); UtilEnt.CreatureLook(skeleton, 90); - _entities.add(skeleton); + _entities.put(skeleton, skeleton.getLocation()); } { Location location = WorldData.GetCustomLocs("DUMMY_WITHER").get(0); @@ -446,7 +448,7 @@ public class MobaTraining extends Moba disguise.setCustomNameVisible(true); Manager.GetDisguise().disguise(disguise); - _entities.add(stand); + _entities.put(stand, stand.getLocation()); } { Location location = WorldData.GetCustomLocs("DUMMY_SHOP").get(0); @@ -454,7 +456,7 @@ public class MobaTraining extends Moba villager.setProfession(Profession.LIBRARIAN); villager.setCustomName(C.cGoldB + "Gold Upgrades"); - _entities.add(villager); + _entities.put(villager, villager.getLocation()); } } @@ -464,13 +466,14 @@ public class MobaTraining extends Moba villager.setCustomName(C.cYellowB + "Select A Hero"); UtilEnt.CreatureLook(villager, GetTeam(ChatColor.YELLOW).GetSpawns().get(0)); - _entities.add(villager); + _entities.put(villager, villager.getLocation()); _selectKitEntity = villager; } public void teleportIntoArena(Player player, HeroKit kit) { - if (!kit.equals(GetKit(player))) + Kit currentKit = GetKit(player); + if (currentKit == null || !kit.equals(currentKit)) { _shop.clearPurchases(player); } From b1c3b2c93772d5944869643a40025380c8cd0975 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 23 Jun 2017 02:11:17 +0100 Subject: [PATCH 239/283] Balance changes and QOL changes --- .../game/games/moba/kit/anath/SkillFireProjectile.java | 3 ++- .../arcade/game/games/moba/kit/bardolf/SkillFullMoon.java | 6 ++++++ .../arcade/game/games/moba/kit/hattori/SkillSnowball.java | 2 +- .../arcade/game/games/moba/kit/larissa/SkillAquaCannon.java | 3 ++- .../arcade/game/games/moba/kit/rowena/SkillBombardment.java | 4 ---- .../arcade/game/games/moba/kit/rowena/SkillLightArrows.java | 2 +- .../game/games/moba/shop/assassin/MobaAssassinShop.java | 2 +- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 59b39a822..2fd704386 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.kit.anath; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.util.MobaConstants; @@ -37,7 +38,7 @@ public class SkillFireProjectile extends HeroSkill Player player = event.getPlayer(); - if (!_kit.useAmmo(player, 1)) + if (!Recharge.Instance.use(player, GetName(), 500, false, true) || !_kit.useAmmo(player, 1)) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java index c68fab17d..e2cf73353 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java @@ -89,6 +89,12 @@ public class SkillFullMoon extends HeroSkill kit.disguise(player); player.setWalkSpeed(player.getWalkSpeed() - data.getLastSpeedIncrease()); + ItemStack itemStack = player.getInventory().getItem(1); + if (itemStack != null) + { + itemStack.setAmount(1); + } + for (Wolf wolf : data.getWolves()) { wolf.setHealth(0); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index f1d06a1dc..094700d99 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -33,7 +33,7 @@ public class SkillSnowball extends HeroSkill implements IThrown { super("Shuriken", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); - setCooldown(1000); + setCooldown(1500); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java index b137f3c32..e2f7b1c9f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; @@ -46,7 +47,7 @@ public class SkillAquaCannon extends HeroSkill Player player = event.getPlayer(); - if (!_kit.useAmmo(player, 1)) + if (!Recharge.Instance.use(player, GetName(), 500, false, true) || !_kit.useAmmo(player, 1)) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java index cdb3e4838..3607c0f5c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java @@ -148,10 +148,6 @@ public class SkillBombardment extends HeroSkill data.Block.setType(Material.AIR); iterator.remove(); } - else if (data.Block != null) - { - UtilParticle.PlayParticleToAll(ParticleType.CLOUD, data.Block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.001F, 3, ViewDist.LONG); - } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java index d4037aa5f..4756d65eb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java @@ -127,7 +127,7 @@ public class SkillLightArrows extends HeroSkill { LineParticle lineParticle = iterator.next(); - for (int i = 0; i < 4; i++) + for (int i = 0; i < 6; i++) { if (!lineParticle.update()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java index 96c28be81..052ced61a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java @@ -30,7 +30,7 @@ public class MobaAssassinShop extends MobaShopMenu .build(), 1000), new MobaItem(new ItemBuilder(Material.DIAMOND_SWORD) .setTitle(C.cDRedB + "Pumpkin King's Blade") - .addEnchantment(Enchantment.DAMAGE_ALL, 3) + .addEnchantment(Enchantment.DAMAGE_ALL, 2) .build(), 1750) ), new ItemStack(Material.WOOD_SWORD)); From 037450687908d789f15c0cb8e03733936f19e89a Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 22 Jun 2017 23:20:07 -0500 Subject: [PATCH 240/283] Disable beta whitelist for MOBA --- .../nautilus/game/arcade/game/games/moba/Moba.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 66274c97e..c584057fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,7 +1,6 @@ package nautilus.game.arcade.game.games.moba; import mineplex.core.Managers; -import mineplex.core.beta.BetaWhitelist; import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.util.F; @@ -86,7 +85,6 @@ public class Moba extends TeamGame protected final TowerManager _tower; protected final CapturePointManager _capturePoint; protected final MinionManager _minion; - private BetaWhitelist _betaWhitelist; private int _inPlayers; @@ -131,17 +129,6 @@ public class Moba extends TeamGame // Beta Message registerManager(new BetaManager(this)); - // Beta Whitelist - _betaWhitelist = Managers.get(BetaWhitelist.class); - if (_betaWhitelist == null) - { - _betaWhitelist = new BetaWhitelist(manager.GetClients(), manager.getBonusManager().getPowerPlayClubRepository()); - } - else - { - _betaWhitelist.registerSelf(); - } - new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -280,7 +267,6 @@ public class Moba extends TeamGame super.disable(); _listeners.forEach(UtilServer::Unregister); _listeners.clear(); - _betaWhitelist.deregisterSelf(); // Undisguise all players for (Player player : Bukkit.getOnlinePlayers()) From a6493ed18a31a68c49307e6b1fa079b6ae00a959 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 23 Jun 2017 13:55:48 +1000 Subject: [PATCH 241/283] Update MapParser to 1.12, refactor out some common base utilities. --- Plugins/Mineplex.Core.Common.Base/pom.xml | 20 ++++ .../mineplex/core/common/DefaultHashMap.java | 0 .../mineplex/core/common/GenericRunnable.java | 0 .../mineplex/core/common/GsonLocation.java | 0 .../mineplex/core/common/MaterialData.java | 0 .../core/common/MinecraftVersion.java | 0 .../src/mineplex/core/common/Pair.java | 0 .../mineplex/core/common/ProcessRunner.java | 0 .../core/common/RangeShuffleIterator.java | 0 .../src/mineplex/core/common/Rank.java | 4 +- .../src/mineplex/core/common/TriConsumer.java | 0 .../core/common/currency/Currency.java | 0 .../core/common/currency/GlobalCurrency.java | 0 .../events/EntityVelocityChangeEvent.java | 0 .../common/events/PlayerMessageEvent.java | 0 .../events/PlayerRecieveBroadcastEvent.java | 0 .../common/events/ServerShutdownEvent.java | 0 .../src/mineplex/core/common/util/C.java | 0 .../mineplex/core/common/util/Callback.java | 0 .../src/mineplex/core/common/util/F.java | 0 .../core/common/util/NautArrayList.java | 0 .../core/common/util/NautHashMap.java | 2 +- .../core/common/util/UtilBlockBase.java | 38 ++++++++ .../core/common/util/UtilCollections.java | 0 .../mineplex/core/common/util/UtilEvent.java | 0 .../mineplex/core/common/util/UtilGear.java | 0 .../mineplex/core/common/util/UtilMath.java | 0 .../core/common/util/UtilPlayerBase.java | 97 +++++++++++++++++++ .../mineplex/core/common/util/UtilTime.java | 11 --- .../mineplex/core/common/util/UtilWorld.java | 24 +---- .../mineplex/core/common/util/ZipUtil.java | 0 Plugins/Mineplex.Core.Common/pom.xml | 5 + .../mineplex/core/common/util/UtilBlock.java | 25 +---- .../mineplex/core/common/util/UtilPlayer.java | 67 +------------ .../candycane/ArrowTrailCandyCane.java | 5 +- .../game/clans/world/WorldManager.java | 10 +- Plugins/Mineplex.MapParser/pom.xml | 6 +- .../src/mineplex/mapparser/MapParser.java | 12 +-- .../src/mineplex/mapparser/WorldManager.java | 5 +- .../mapparser/command/AdminCommand.java | 4 +- .../mapparser/command/BaseCommand.java | 4 +- .../mapparser/command/CopyCommand.java | 3 +- .../mapparser/command/DeleteCommand.java | 3 +- .../mapparser/command/GameTypeCommand.java | 3 +- .../mapparser/command/ListCommand.java | 6 +- .../mapparser/command/MapCommand.java | 12 +-- .../mineplex/mapparser/command/PMCommand.java | 5 +- .../mapparser/command/RenameCommand.java | 3 +- .../mapparser/command/SaveCommand.java | 7 +- .../mapparser/command/WorldsCommand.java | 2 - .../module/modules/CommandModule.java | 8 +- .../mapparser/module/modules/EventModule.java | 18 ++-- .../game/games/halloween2016/Crypt.java | 7 +- Plugins/pom.xml | 21 +++- 54 files changed, 254 insertions(+), 183 deletions(-) create mode 100644 Plugins/Mineplex.Core.Common.Base/pom.xml rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/DefaultHashMap.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/GenericRunnable.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/GsonLocation.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/MaterialData.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/MinecraftVersion.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/Pair.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/ProcessRunner.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/RangeShuffleIterator.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/Rank.java (98%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/TriConsumer.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/currency/Currency.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/currency/GlobalCurrency.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/events/EntityVelocityChangeEvent.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/events/PlayerMessageEvent.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/events/PlayerRecieveBroadcastEvent.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/events/ServerShutdownEvent.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/util/C.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/util/Callback.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/util/F.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/util/NautArrayList.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/util/NautHashMap.java (97%) create mode 100644 Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilBlockBase.java rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/util/UtilCollections.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/util/UtilEvent.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/util/UtilGear.java (100%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/util/UtilMath.java (100%) create mode 100644 Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilPlayerBase.java rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/util/UtilTime.java (96%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/util/UtilWorld.java (88%) rename Plugins/{Mineplex.Core.Common => Mineplex.Core.Common.Base}/src/mineplex/core/common/util/ZipUtil.java (100%) diff --git a/Plugins/Mineplex.Core.Common.Base/pom.xml b/Plugins/Mineplex.Core.Common.Base/pom.xml new file mode 100644 index 000000000..e3697fb8a --- /dev/null +++ b/Plugins/Mineplex.Core.Common.Base/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + + com.mineplex + mineplex-parent + dev-SNAPSHOT + + + mineplex-core-common-base + + + + org.spigotmc + spigot-api + + + diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/DefaultHashMap.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/DefaultHashMap.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/DefaultHashMap.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/DefaultHashMap.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/GenericRunnable.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/GenericRunnable.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/GenericRunnable.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/GenericRunnable.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/GsonLocation.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/GsonLocation.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/GsonLocation.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/GsonLocation.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/MaterialData.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/MaterialData.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/MaterialData.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/MaterialData.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/MinecraftVersion.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/MinecraftVersion.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/MinecraftVersion.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/MinecraftVersion.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Pair.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Pair.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/Pair.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Pair.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/ProcessRunner.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/ProcessRunner.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/ProcessRunner.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/ProcessRunner.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/RangeShuffleIterator.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/RangeShuffleIterator.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/RangeShuffleIterator.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/RangeShuffleIterator.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Rank.java similarity index 98% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Rank.java index 834c1eff4..9b2a37f9a 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Rank.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; public enum Rank { @@ -122,7 +122,7 @@ public enum Rank if (inform) { - UtilPlayer.message(player, C.mHead + "Permissions> " + + UtilPlayerBase.message(player, C.mHead + "Permissions> " + C.mBody + "This requires Permission Rank [" + C.mHead + rank.Name.toUpperCase() + C.mBody + "]."); diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/TriConsumer.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/TriConsumer.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/TriConsumer.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/TriConsumer.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/Currency.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/currency/Currency.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/Currency.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/currency/Currency.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/GlobalCurrency.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/currency/GlobalCurrency.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/GlobalCurrency.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/currency/GlobalCurrency.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/EntityVelocityChangeEvent.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/EntityVelocityChangeEvent.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/EntityVelocityChangeEvent.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/EntityVelocityChangeEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/PlayerMessageEvent.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/PlayerMessageEvent.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/PlayerMessageEvent.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/PlayerMessageEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/PlayerRecieveBroadcastEvent.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/PlayerRecieveBroadcastEvent.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/PlayerRecieveBroadcastEvent.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/PlayerRecieveBroadcastEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/ServerShutdownEvent.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/ServerShutdownEvent.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/ServerShutdownEvent.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/ServerShutdownEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/C.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/C.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/C.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/C.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/Callback.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/Callback.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/Callback.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/Callback.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/F.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/F.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautArrayList.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/NautArrayList.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautArrayList.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/NautArrayList.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautHashMap.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/NautHashMap.java similarity index 97% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautHashMap.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/NautHashMap.java index 2f43abed9..41f9d442c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautHashMap.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/NautHashMap.java @@ -4,7 +4,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map.Entry; -import org.apache.commons.lang3.Validate; +import org.apache.commons.lang.Validate; import java.util.Set; diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilBlockBase.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilBlockBase.java new file mode 100644 index 000000000..12c090a72 --- /dev/null +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilBlockBase.java @@ -0,0 +1,38 @@ +package mineplex.core.common.util; + +import java.util.ArrayList; + +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; + +public class UtilBlockBase +{ + + public static ArrayList getSurrounding(Block block, boolean diagonals) + { + ArrayList blocks = new ArrayList(); + + if (diagonals) + { + for (int x = -1; x <= 1; x++) + for (int z = -1; z <= 1; z++) + for (int y = 1; y >= -1; y--) + { + if (x == 0 && y == 0 && z == 0) continue; + + blocks.add(block.getRelative(x, y, z)); + } + } + else + { + blocks.add(block.getRelative(BlockFace.UP)); + blocks.add(block.getRelative(BlockFace.NORTH)); + blocks.add(block.getRelative(BlockFace.SOUTH)); + blocks.add(block.getRelative(BlockFace.EAST)); + blocks.add(block.getRelative(BlockFace.WEST)); + blocks.add(block.getRelative(BlockFace.DOWN)); + } + + return blocks; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilCollections.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilCollections.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilCollections.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilCollections.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilEvent.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilGear.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilGear.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilGear.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilGear.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilPlayerBase.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilPlayerBase.java new file mode 100644 index 000000000..9b2d2b5df --- /dev/null +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilPlayerBase.java @@ -0,0 +1,97 @@ +package mineplex.core.common.util; + +import java.util.LinkedList; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import mineplex.core.common.events.PlayerMessageEvent; +import org.bukkit.Bukkit; + +public class UtilPlayerBase +{ + + public static void message(Entity client, LinkedList messageList) + { + message(client, messageList, false); + } + + public static void message(Entity client, String message) + { + message(client, message, false); + } + + public static void message(Entity client, LinkedList messageList, boolean wiki) + { + for (String curMessage : messageList) + { + message(client, curMessage, wiki); + } + } + + public static void message(Entity client, String message, boolean wiki) + { + if (client == null) + return; + + if (!(client instanceof Player)) + return; + + /* + if (wiki) + message = UtilWiki.link(message); + */ + + PlayerMessageEvent event = new PlayerMessageEvent((Player) client, message); + Bukkit.getPluginManager().callEvent(event); + + if (event.isCancelled()) + return; + + + ((Player) client).sendMessage(message); + } + + public static Player searchOnline(Player caller, String player, boolean inform) + { + LinkedList matchList = new LinkedList(); + + for (Player cur : Bukkit.getOnlinePlayers()) + { + if (cur.getName().equalsIgnoreCase(player)) + return cur; + + if (cur.getName().toLowerCase().contains(player.toLowerCase())) + matchList.add(cur); + } + + // No / Non-Unique + if (matchList.size() != 1) + { + if (!inform) + return null; + + // Inform + message(caller, + F.main("Online Player Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem + + player + C.mBody + "].")); + + if (matchList.size() > 0) + { + String matchString = ""; + for (Player cur : matchList) + matchString += F.elem(cur.getName()) + ", "; + if (matchString.length() > 1) + matchString = matchString.substring(0, matchString.length() - 2); + + message(caller, + F.main("Online Player Search", "" + C.mBody + "Matches [" + C.mElem + matchString + C.mBody + "].")); + } + + return null; + } + + return matchList.get(0); + } + +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilTime.java similarity index 96% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilTime.java index 815c56f5e..712e73b3d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilTime.java @@ -6,8 +6,6 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Calendar; -import net.minecraft.server.v1_8_R3.MinecraftServer; - public class UtilTime { public static final ZoneId CENTRAL_ZONE = ZoneId.of("America/Chicago"); // This means "CST" @@ -54,15 +52,6 @@ public class UtilTime } } - /** - * - * @return Returns the current global server tick. Is reset on server restart. Starts out negative. Counts upwards. - */ - public static int getServerTick() - { - return MinecraftServer.currentTick; - } - /** * Converts a {@link Timestamp} to a {@link LocalDateTime}. * This method will only work for timestamp's stored using {@link #CENTRAL_ZONE}, if stored using diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java similarity index 88% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java index 86c6083f2..b0d4bd9bc 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java @@ -3,6 +3,7 @@ package mineplex.core.common.util; import java.util.Collection; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; @@ -10,19 +11,16 @@ import org.bukkit.World.Environment; import org.bukkit.WorldBorder; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.Entity; import org.bukkit.util.Vector; import com.google.common.collect.Lists; -import net.minecraft.server.v1_8_R3.AxisAlignedBB; - public class UtilWorld { public static World getWorld(String world) { - return UtilServer.getServer().getWorld(world); + return Bukkit.getServer().getWorld(world); } public static boolean areChunksEqual(Location first, Location second) @@ -100,7 +98,7 @@ public class UtilWorld try { - for (World cur : UtilServer.getServer().getWorlds()) + for (World cur : Bukkit.getServer().getWorlds()) { if (cur.getName().equalsIgnoreCase(parts[0])) { @@ -154,7 +152,7 @@ public class UtilWorld try { - for (World cur : UtilServer.getServer().getWorlds()) + for (World cur : Bukkit.getServer().getWorlds()) { if (cur.getName().equalsIgnoreCase(tokens[0])) { @@ -188,7 +186,7 @@ public class UtilWorld public static World getWorldType(Environment env) { - for (World cur : UtilServer.getServer().getWorlds()) + for (World cur : Bukkit.getServer().getWorlds()) if (cur.getEnvironment() == env) return cur; @@ -305,16 +303,4 @@ public class UtilWorld return startX >= minX && startZ <= maxX && endX >= minZ && endZ <= maxZ; } - - public static double distanceSquared(Entity a, Entity b) - { - if (a.getWorld() != b.getWorld()) - throw new IllegalArgumentException("Different worlds: " + a.getWorld().getName() + " and " + b.getWorld().getName()); - net.minecraft.server.v1_8_R3.Entity entityA = ((CraftEntity) a).getHandle(); - net.minecraft.server.v1_8_R3.Entity entityB = ((CraftEntity) b).getHandle(); - double dx = entityA.locX - entityB.locX; - double dy = entityA.locY - entityB.locY; - double dz = entityA.locZ - entityB.locZ; - return (dx * dx) + (dy * dy) + (dz * dz); - } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ZipUtil.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/ZipUtil.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ZipUtil.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/ZipUtil.java diff --git a/Plugins/Mineplex.Core.Common/pom.xml b/Plugins/Mineplex.Core.Common/pom.xml index 65ec63dd8..99340a056 100644 --- a/Plugins/Mineplex.Core.Common/pom.xml +++ b/Plugins/Mineplex.Core.Common/pom.xml @@ -20,6 +20,11 @@ org.apache.httpcomponents httpclient + + ${project.groupId} + mineplex-core-common-base + ${project.version} + com.mineplex mineplex-serverdata diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index acfa65274..4370f1a2a 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -615,30 +615,7 @@ public class UtilBlock public static ArrayList getSurrounding(Block block, boolean diagonals) { - ArrayList blocks = new ArrayList(); - - if (diagonals) - { - for (int x = -1; x <= 1; x++) - for (int z = -1; z <= 1; z++) - for (int y = 1; y >= -1; y--) - { - if (x == 0 && y == 0 && z == 0) continue; - - blocks.add(block.getRelative(x, y, z)); - } - } - else - { - blocks.add(block.getRelative(BlockFace.UP)); - blocks.add(block.getRelative(BlockFace.NORTH)); - blocks.add(block.getRelative(BlockFace.SOUTH)); - blocks.add(block.getRelative(BlockFace.EAST)); - blocks.add(block.getRelative(BlockFace.WEST)); - blocks.add(block.getRelative(BlockFace.DOWN)); - } - - return blocks; + return UtilBlockBase.getSurrounding(block, diagonals); } public static boolean isVisible(Block block) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 0bb9502f6..2ddd54f42 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -348,42 +348,22 @@ public class UtilPlayer public static void message(Entity client, LinkedList messageList) { - message(client, messageList, false); + UtilPlayerBase.message(client, messageList); } public static void message(Entity client, String message) { - message(client, message, false); + UtilPlayerBase.message(client, message); } public static void message(Entity client, LinkedList messageList, boolean wiki) { - for (String curMessage : messageList) - { - message(client, curMessage, wiki); - } + UtilPlayerBase.message(client, messageList, wiki); } public static void message(Entity client, String message, boolean wiki) { - if (client == null) - return; - - if (!(client instanceof Player)) - return; - - /* - if (wiki) - message = UtilWiki.link(message); - */ - - PlayerMessageEvent event = UtilServer.CallEvent(new PlayerMessageEvent((Player) client, message)); - - if (event.isCancelled()) - return; - - - ((Player) client).sendMessage(message); + UtilPlayerBase.message(client, message, wiki); } public static Player searchExact(String name) @@ -454,44 +434,7 @@ public class UtilPlayer public static Player searchOnline(Player caller, String player, boolean inform) { - LinkedList matchList = new LinkedList(); - - for (Player cur : UtilServer.getPlayers()) - { - if (cur.getName().equalsIgnoreCase(player)) - return cur; - - if (cur.getName().toLowerCase().contains(player.toLowerCase())) - matchList.add(cur); - } - - // No / Non-Unique - if (matchList.size() != 1) - { - if (!inform) - return null; - - // Inform - message(caller, - F.main("Online Player Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem - + player + C.mBody + "].")); - - if (matchList.size() > 0) - { - String matchString = ""; - for (Player cur : matchList) - matchString += F.elem(cur.getName()) + ", "; - if (matchString.length() > 1) - matchString = matchString.substring(0, matchString.length() - 2); - - message(caller, - F.main("Online Player Search", "" + C.mBody + "Matches [" + C.mElem + matchString + C.mBody + "].")); - } - - return null; - } - - return matchList.get(0); + return UtilPlayerBase.searchOnline(caller, player, inform); } public static void searchOffline(List matches, final Callback callback, final Player caller, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java index 73010a753..d45b1b023 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java @@ -10,10 +10,11 @@ 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.UtilText; -import mineplex.core.common.util.UtilTime; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ArrowEffectGadget; +import net.minecraft.server.v1_8_R3.MinecraftServer; + public class ArrowTrailCandyCane extends ArrowEffectGadget { @@ -29,7 +30,7 @@ public class ArrowTrailCandyCane extends ArrowEffectGadget public void doTrail(Arrow arrow) { int data = 15; - int tick = Math.abs(UtilTime.getServerTick()%3); + int tick = Math.abs(MinecraftServer.currentTick%3); if(tick == 1) data = 1; if(tick == 2) data = 2; Location loc = arrow.getLocation(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java index e302d1a26..141e52cb0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java @@ -13,6 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; public class WorldManager extends MiniPlugin { @@ -77,6 +78,9 @@ public class WorldManager extends MiniPlugin { List players = world.getPlayers(); Map> entities = new HashMap<>(); + // For optimization reasons reuse location objects + Location entityLocation = new Location(world, 0, 0, 0); + Location playerLocation = new Location(world, 0, 0, 0); for (Entity entity : world.getEntities()) { @@ -104,11 +108,11 @@ public class WorldManager extends MiniPlugin else if (CULL_LIMITS.containsKey(entityType)) { boolean cull = true; + entity.getLocation(entityLocation); for (Player player : players) { - // Using NMS because this is going to be called quite a few times - // and each getLocation() call creates a new Location object - if (UtilWorld.distanceSquared(player, entity) <= MIN_RANGE_SQUARED) + player.getLocation(playerLocation); + if (playerLocation.distanceSquared(entityLocation) <= MIN_RANGE_SQUARED) { cull = false; break; diff --git a/Plugins/Mineplex.MapParser/pom.xml b/Plugins/Mineplex.MapParser/pom.xml index 65a7236aa..1fd1baade 100644 --- a/Plugins/Mineplex.MapParser/pom.xml +++ b/Plugins/Mineplex.MapParser/pom.xml @@ -14,9 +14,13 @@ mineplex-mapparser + + commons-io + commons-io + ${project.groupId} - mineplex-core-common + mineplex-core-common-base ${project.version} diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java index 6fa838da5..5d62fdf65 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -23,9 +24,8 @@ import com.google.common.collect.Sets; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilBlockBase; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.mapparser.command.AddLoreCommand; import mineplex.mapparser.command.AddSplashTextCommand; import mineplex.mapparser.command.AdminCommand; @@ -144,7 +144,7 @@ public class MapParser extends JavaPlugin public void sendValidGameTypes(Player player) { - UtilPlayer.message(player, F.main("Parser", "Valid Game Types;")); + UtilPlayerBase.message(player, F.main("Parser", "Valid Game Types;")); String gameTypes = ""; @@ -256,7 +256,7 @@ public class MapParser extends JavaPlugin public void announce(String msg) { - for (Player player : UtilServer.getPlayers()) + for (Player player : Bukkit.getOnlinePlayers()) { player.sendMessage(C.cGold + msg); } @@ -390,7 +390,7 @@ public class MapParser extends JavaPlugin if (!blocks.add(current)) return blocks; - for (Block other : UtilBlock.getSurrounding(current, true)) + for (Block other : UtilBlockBase.getSurrounding(current, true)) { if (current.getType() != Material.LOG && current.getType() != Material.LEAVES) continue; diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java index 56e3b7218..2ae2e1561 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java @@ -1,6 +1,5 @@ package mineplex.mapparser; -import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.ZipUtil; import org.apache.commons.io.FileUtils; import org.bukkit.Bukkit; @@ -24,7 +23,7 @@ public class WorldManager public World prepMapParse(World world) { //Unload World - MapUtil.UnloadWorld(Host, world, true); + Host.getServer().unloadWorld(world, true); //Delete Non-Map Files String[] folders = new File(world.getName()).list(); @@ -69,7 +68,7 @@ public class WorldManager public void finalizeParsedWorld(World world) { - MapUtil.UnloadWorld(Host, world, true); + Host.getServer().unloadWorld(world, true); ArrayList fileList = new ArrayList(); ArrayList dirList = new ArrayList(); diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AdminCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AdminCommand.java index 962a5813a..b808c2796 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AdminCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AdminCommand.java @@ -4,7 +4,7 @@ import org.bukkit.World; import org.bukkit.entity.Player; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.mapparser.MapData; import mineplex.mapparser.MapParser; @@ -42,7 +42,7 @@ public class AdminCommand extends BaseCommand return true; } - Player other = UtilPlayer.searchOnline(player, args[0], true); + Player other = UtilPlayerBase.searchOnline(player, args[0], true); if (player != null) { diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/BaseCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/BaseCommand.java index 16552b9b0..951c0f6a4 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/BaseCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/BaseCommand.java @@ -6,7 +6,7 @@ import java.util.List; import org.bukkit.entity.Player; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.mapparser.MapParser; /** @@ -59,6 +59,6 @@ public abstract class BaseCommand protected void message(Player player, String message) { - UtilPlayer.message(player, F.main("Parser", message)); + UtilPlayerBase.message(player, F.main("Parser", message)); } } diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CopyCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CopyCommand.java index 4354a90a1..ea1b4e6ea 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CopyCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CopyCommand.java @@ -7,7 +7,6 @@ import org.bukkit.World; import org.bukkit.entity.Player; import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; import mineplex.mapparser.GameType; import mineplex.mapparser.MapParser; import org.apache.commons.io.FileUtils; @@ -73,7 +72,7 @@ public class CopyCommand extends BaseCommand other.teleport(getPlugin().getSpawnLocation()); message(other, "Unloading world for copy..."); } - MapUtil.UnloadWorld(getPlugin(), world, true); + getPlugin().getServer().unloadWorld(world, true); } File source = new File(worldName); diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/DeleteCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/DeleteCommand.java index 59b357c42..c3e1b48fd 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/DeleteCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/DeleteCommand.java @@ -6,7 +6,6 @@ import org.bukkit.World; import org.bukkit.entity.Player; import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; import mineplex.mapparser.GameType; import mineplex.mapparser.MapParser; import org.apache.commons.io.FileUtils; @@ -66,7 +65,7 @@ public class DeleteCommand extends BaseCommand //Unload World //Things break if this isn't set to true for saving the world - MapUtil.UnloadWorld(getPlugin(), world, true); + getPlugin().getServer().unloadWorld(world, true); } //Delete diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/GameTypeCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/GameTypeCommand.java index 4b01a03c9..5d4139b5b 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/GameTypeCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/GameTypeCommand.java @@ -6,7 +6,6 @@ import org.bukkit.World; import org.bukkit.entity.Player; import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; import mineplex.mapparser.GameType; import mineplex.mapparser.MapData; import mineplex.mapparser.MapParser; @@ -69,7 +68,7 @@ public class GameTypeCommand extends BaseCommand other.teleport(getPlugin().getSpawnLocation()); message(player, "Unloading world for rename..."); } - MapUtil.UnloadWorld(getPlugin(), world, true); + getPlugin().getServer().unloadWorld(world, true); File typeFolder = new File("map/" + type.GetName()); if (!typeFolder.exists()) diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ListCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ListCommand.java index 8935eb777..1edb4ad81 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ListCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ListCommand.java @@ -7,7 +7,7 @@ import org.bukkit.entity.Player; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.mapparser.GameType; import mineplex.mapparser.MapParser; @@ -28,7 +28,7 @@ public class ListCommand extends BaseCommand { if (args.length == 0) { - UtilPlayer.message(player, F.main("Parser", "Listing Maps;")); + UtilPlayerBase.message(player, F.main("Parser", "Listing Maps;")); boolean colorSwitch = false; @@ -60,7 +60,7 @@ public class ListCommand extends BaseCommand } } - UtilPlayer.message(player, F.main("Parser", "Listing Maps for gametype " + F.elem(gameType.GetName()))); + UtilPlayerBase.message(player, F.main("Parser", "Listing Maps for gametype " + F.elem(gameType.GetName()))); listMaps(player, gameType, false); } diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java index 6c504b634..56d98de06 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java @@ -1,7 +1,7 @@ package mineplex.mapparser.command; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.mapparser.GameType; import mineplex.mapparser.MapData; import mineplex.mapparser.MapParser; @@ -32,7 +32,7 @@ public class MapCommand extends BaseCommand { if (args.length < 1) { - //UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/map [GameType]"))); + //UtilPlayerBase.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/map [GameType]"))); return false; } @@ -50,7 +50,7 @@ public class MapCommand extends BaseCommand { message(player, "Found more than one possible match:"); for (String s : possibleMaps) - UtilPlayer.message(player, s); + UtilPlayerBase.message(player, s); return true; } @@ -126,9 +126,9 @@ public class MapCommand extends BaseCommand MapData data = getPlugin().getData(worldName); - UtilPlayer.message(player, F.value("Map Name", data.MapName)); - UtilPlayer.message(player, F.value("Author", data.MapCreator)); - UtilPlayer.message(player, F.value("Game Type", data.MapGameType.GetName())); + UtilPlayerBase.message(player, F.value("Map Name", data.MapName)); + UtilPlayerBase.message(player, F.value("Author", data.MapCreator)); + UtilPlayerBase.message(player, F.value("Game Type", data.MapGameType.GetName())); return true; } } diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java index 86c4db4f2..f18483199 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java @@ -2,7 +2,6 @@ package mineplex.mapparser.command; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilServer; import mineplex.mapparser.MapParser; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -38,14 +37,14 @@ public class PMCommand extends BaseCommand { builder.append(s).append(" "); } - for (Player ops : UtilServer.getPlayers()) + for (Player ops : getPlugin().getServer().getOnlinePlayers()) { if (!ops.isOp()) { continue; } ops.sendMessage(F.main("Message", builder.toString().trim())); - ops.playSound(ops.getLocation(), Sound.NOTE_PLING, 1.0f, 1.0f); + ops.playSound(ops.getLocation(), Sound.BLOCK_NOTE_PLING, 1.0f, 1.0f); } return true; diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/RenameCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/RenameCommand.java index 2f66500c2..dfb0cb030 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/RenameCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/RenameCommand.java @@ -6,7 +6,6 @@ import org.bukkit.World; import org.bukkit.entity.Player; import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; import mineplex.mapparser.MapData; import mineplex.mapparser.MapParser; @@ -56,7 +55,7 @@ public class RenameCommand extends BaseCommand other.teleport(getPlugin().getSpawnLocation()); message(other, "Unloading world for rename..."); } - MapUtil.UnloadWorld(getPlugin(), world, true); + getPlugin().getServer().unloadWorld(world, true); message(player, "World unloaded!"); diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/SaveCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/SaveCommand.java index c201f152c..46f52a35f 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/SaveCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/SaveCommand.java @@ -6,8 +6,7 @@ import org.bukkit.World; import org.bukkit.entity.Player; import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; -import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.mapparser.MapParser; /** @@ -37,7 +36,7 @@ public class SaveCommand extends BaseCommand { message(player, "More than one map found:"); for (String s : possibleMaps) - UtilPlayer.message(player, s); + UtilPlayerBase.message(player, s); return true; } @@ -63,7 +62,7 @@ public class SaveCommand extends BaseCommand other.teleport(getPlugin().getSpawnLocation()); //Unload World - MapUtil.UnloadWorld(getPlugin(), world, true); + getPlugin().getServer().unloadWorld(world, true); } else { diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/WorldsCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/WorldsCommand.java index 2b9d6331c..1af45bfaa 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/WorldsCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/WorldsCommand.java @@ -3,8 +3,6 @@ package mineplex.mapparser.command; import org.bukkit.World; import org.bukkit.entity.Player; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; import mineplex.mapparser.MapParser; /** diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/CommandModule.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/CommandModule.java index 368b24df9..3cfe1ac73 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/CommandModule.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/CommandModule.java @@ -2,7 +2,7 @@ package mineplex.mapparser.module.modules; import com.google.common.collect.Maps; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.mapparser.MapParser; import mineplex.mapparser.command.BaseCommand; import mineplex.mapparser.module.Module; @@ -38,7 +38,7 @@ public class CommandModule extends Module if (getPlugin().getCurParse() != null) { - UtilPlayer.message(player, F.main("Parser", "Cannot use commands during Map Parse!")); + UtilPlayerBase.message(player, F.main("Parser", "Cannot use commands during Map Parse!")); return; } if (event.getMessage().toLowerCase().startsWith("/help")) @@ -83,8 +83,8 @@ public class CommandModule extends Module if (!baseCommand.execute(player, commandLabel, args)) { - UtilPlayer.message(player, F.main("Parser", "Invalid Input.")); - UtilPlayer.message(player, F.elem(baseCommand.getUsage())); + UtilPlayerBase.message(player, F.main("Parser", "Invalid Input.")); + UtilPlayerBase.message(player, F.elem(baseCommand.getUsage())); } } diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/EventModule.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/EventModule.java index 1595b9886..2b617a039 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/EventModule.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/EventModule.java @@ -27,9 +27,7 @@ import com.google.common.collect.Lists; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.mapparser.BackupTask; import mineplex.mapparser.MapData; import mineplex.mapparser.MapParser; @@ -135,7 +133,7 @@ public class EventModule extends Module if (world.getPlayers().isEmpty()) { getPlugin().announce("Saving & Closing World: " + F.elem(world.getName())); - MapUtil.UnloadWorld(getPlugin(), world, true); + getPlugin().getServer().unloadWorld(world, true); _updated.remove(world); getPlugin()._mapsBeingZipped.add(world.getName()); System.out.println("Starting backup of " + world); @@ -164,7 +162,7 @@ public class EventModule extends Module String grayName = C.cBlue + event.getPlayer().getName(); String grayWorld = C.cBlue + C.Bold + event.getPlayer().getWorld().getName(); - for (Player player : UtilServer.getPlayers()) + for (Player player : getPlugin().getServer().getOnlinePlayers()) { if (player.getWorld().equals(event.getPlayer().getWorld())) { @@ -212,7 +210,7 @@ public class EventModule extends Module event.setCancelled(true); - Player target = UtilPlayer.searchOnline(player, tokens[1], true); + Player target = UtilPlayerBase.searchOnline(player, tokens[1], true); if (target != null) { if (!target.getWorld().getName().equals("world")) @@ -224,7 +222,7 @@ public class EventModule extends Module return; } } - UtilPlayer.message(player, F.main("Game", "You teleported to " + F.name(target.getName()) + ".")); + UtilPlayerBase.message(player, F.main("Game", "You teleported to " + F.name(target.getName()) + ".")); player.teleport(target); } } @@ -246,7 +244,7 @@ public class EventModule extends Module //Permission if (!getPlugin().getData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer())) { - UtilPlayer.message(event.getPlayer(), F.main("Parser", "You do not have Build-Access for this Map.")); + UtilPlayerBase.message(event.getPlayer(), F.main("Parser", "You do not have Build-Access for this Map.")); event.setCancelled(true); } } @@ -276,10 +274,10 @@ public class EventModule extends Module player.setFlySpeed(speed); - UtilPlayer.message(player, F.main("Game", "Fly Speed set to " + F.elem("" + speed) + ".")); + UtilPlayerBase.message(player, F.main("Game", "Fly Speed set to " + F.elem("" + speed) + ".")); } catch (Exception e) { - UtilPlayer.message(player, F.main("Game", "Invalid Speed Input.")); + UtilPlayerBase.message(player, F.main("Game", "Invalid Speed Input.")); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Crypt.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Crypt.java index 562bd08cc..9057da773 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Crypt.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Crypt.java @@ -14,7 +14,8 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextTop; -import mineplex.core.common.util.UtilTime; + +import net.minecraft.server.v1_8_R3.MinecraftServer; public class Crypt { @@ -42,10 +43,10 @@ public class Crypt { if(isDestroyed()) return false; Integer lastTime = _damageCooldown.get(mob); - if(lastTime != null && lastTime > UtilTime.getServerTick()) return false; + if(lastTime != null && lastTime > MinecraftServer.currentTick) return false; _health -= damage; - _damageCooldown.put(mob, UtilTime.getServerTick() + cooldown); + _damageCooldown.put(mob, MinecraftServer.currentTick + cooldown); updateState(damage); diff --git a/Plugins/pom.xml b/Plugins/pom.xml index bbf652166..95880e508 100644 --- a/Plugins/pom.xml +++ b/Plugins/pom.xml @@ -21,6 +21,7 @@ Mineplex.Cache Mineplex.Core Mineplex.Core.Common + Mineplex.Core.Common.Base Mineplex.Database Mineplex.DDoSProtectionSwitcher Mineplex.EnjinTranslator @@ -36,7 +37,7 @@ Mineplex.ServerData Mineplex.ServerMonitor Mineplex.StaffServer - Mineplex.Votifier + Mineplex.Votifier Nautilus.Game.Arcade Nautilus.Game.Arcade.UHC.WorldGen @@ -51,10 +52,20 @@ mineplex http://dev.mineplex.com:8081/nexus/content/groups/public/ + + spigotmc-public + https://hub.spigotmc.org/nexus/content/groups/public/ + + + commons-io + commons-io + 2.5 + compile + commons-codec commons-codec @@ -68,7 +79,7 @@ compile - com.vexsoftware + com.vexsoftware votifier 1.9 provided @@ -133,6 +144,12 @@ 3.5.2 compile + + org.spigotmc + spigot-api + 1.12-R0.1-SNAPSHOT + compile + com.mineplex spigot From b43203f831a53af70a9476906e3c857fdcf2c561 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 22 Jun 2017 23:32:55 -0500 Subject: [PATCH 242/283] Revert "Disable beta whitelist for MOBA" This reverts commit 037450687908d789f15c0cb8e03733936f19e89a. --- .../nautilus/game/arcade/game/games/moba/Moba.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index c584057fe..66274c97e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba; import mineplex.core.Managers; +import mineplex.core.beta.BetaWhitelist; import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.util.F; @@ -85,6 +86,7 @@ public class Moba extends TeamGame protected final TowerManager _tower; protected final CapturePointManager _capturePoint; protected final MinionManager _minion; + private BetaWhitelist _betaWhitelist; private int _inPlayers; @@ -129,6 +131,17 @@ public class Moba extends TeamGame // Beta Message registerManager(new BetaManager(this)); + // Beta Whitelist + _betaWhitelist = Managers.get(BetaWhitelist.class); + if (_betaWhitelist == null) + { + _betaWhitelist = new BetaWhitelist(manager.GetClients(), manager.getBonusManager().getPowerPlayClubRepository()); + } + else + { + _betaWhitelist.registerSelf(); + } + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -267,6 +280,7 @@ public class Moba extends TeamGame super.disable(); _listeners.forEach(UtilServer::Unregister); _listeners.clear(); + _betaWhitelist.deregisterSelf(); // Undisguise all players for (Player player : Bukkit.getOnlinePlayers()) From dddeb693917934210c2ddca4bc352a9b756af5cc Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 22 Jun 2017 23:35:10 -0500 Subject: [PATCH 243/283] Change beta requirement to ULTRA --- Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java index bf384c4c8..ae121af76 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java @@ -55,7 +55,7 @@ public class BetaWhitelist extends MiniPlugin { Player player = event.getPlayer(); Rank rank = _clientManager.Get(player).GetRank(true); - if (rank.has(Rank.TITAN) // If this player is Titan+ + if (rank.has(Rank.ULTRA) // If this player is Ultra+ || _powerPlayClubRepository.getCachedData(player).isSubscribed() // a PPC subscriber, || EXTRA_PLAYERS.contains(player.getUniqueId())) // or explicitly whitelisted, { From 98f9a58849d3a7618f9a54cbd590419b01e1e60f Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 23 Jun 2017 14:12:36 +0100 Subject: [PATCH 244/283] Fix light arrows being able to damage yourself --- .../arcade/game/games/moba/kit/rowena/SkillLightArrows.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java index 4756d65eb..31111ba47 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java @@ -140,7 +140,7 @@ public class SkillLightArrows extends HeroSkill for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 1.5).keySet()) { - if (Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false)) + if (!isTeamDamage(entity, player) && Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false)) { player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 0.8F); Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName()); From 3c031c70a1986d599ce9f90a8505d142be8b3920 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 24 Jun 2017 10:09:52 +0100 Subject: [PATCH 245/283] Fix training lobby bugs --- .../nautilus/game/arcade/game/games/moba/Moba.java | 2 +- .../game/arcade/game/games/moba/kit/HeroSkill.java | 6 ++++-- .../game/games/moba/training/MobaTraining.java | 14 ++++++++++++-- .../game/games/moba/training/SelectKitMenu.java | 5 +++++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 66274c97e..b5241e7b7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -75,7 +75,7 @@ public class Moba extends TeamGame private final HeroKit[] _kits; - private final Set _playerData = new HashSet<>(); + protected final Set _playerData = new HashSet<>(); private final Set _listeners = new HashSet<>(); protected final MobaShop _shop; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 4668d565d..131714e73 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -107,13 +107,15 @@ public class HeroSkill extends Perk _item = new ItemBuilder(_item) .setTitle((action != null ? C.cYellowB + action + C.cGray + " - " : "") + C.cGreenB + GetName()) - .setLore(GetDesc()) + .setLore() + .addLore(GetDesc()) .setUnbreakable(true) .build(); _cooldownItem = new ItemBuilder(Material.INK_SACK, (byte) 8) .setTitle(C.cRed + GetName()) - .setLore(GetDesc()) + .setLore() + .addLore(GetDesc()) .setUnbreakable(true) .build(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index 1b68e0af7..49f0d3d91 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -34,6 +34,7 @@ import org.bukkit.entity.Villager; import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerJoinEvent; import java.util.HashMap; import java.util.List; @@ -119,7 +120,7 @@ public class MobaTraining extends Moba DamageTeamSelf = true; DamageFall = false; DeathOut = false; - DeathSpectateSecs = 0; + DeathSpectateSecs = 2; PrepareTime = 500; GiveClock = false; HideTeamSheep = true; @@ -171,7 +172,7 @@ public class MobaTraining extends Moba { suffix = C.cYellow + " Unknown"; } - else if (mobaPlayer.getKit() == null) + else if (mobaPlayer == null || mobaPlayer.getKit() == null) { suffix = C.cYellow + " Selecting"; } @@ -333,6 +334,15 @@ public class MobaTraining extends Moba } } + @EventHandler + public void plaeyrJoin(PlayerJoinEvent event) + { + if (InProgress()) + { + _playerData.add(new MobaPlayer(event.getPlayer())); + } + } + @EventHandler public void spawnTutorial(GameStateChangeEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/SelectKitMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/SelectKitMenu.java index 6b1287d6e..2c2efadf3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/SelectKitMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/SelectKitMenu.java @@ -31,6 +31,11 @@ public class SelectKitMenu extends Menu for (int slot : slots) { HeroKit kit = (HeroKit) moba.GetKits()[i++]; + + if (!kit.isVisible()) + { + continue; + } ItemBuilder builder = new ItemBuilder(kit.getSkinData().getSkull()); builder.setTitle(C.cGreen + kit.GetName()); From ed541b7a4fcfc08108bdc060856c1b2d97e5ad8f Mon Sep 17 00:00:00 2001 From: cnr Date: Mon, 26 Jun 2017 20:17:45 -0700 Subject: [PATCH 246/283] Disable automatic timings reports --- .../src/mineplex/core/TimingsFix.java | 104 ------------------ .../src/mineplex/core/monitor/LagMeter.java | 44 ++------ .../src/mineplex/game/clans/Clans.java | 10 +- .../src/mineplex/hub/HubManager.java | 2 - .../src/nautilus/game/arcade/Arcade.java | 10 +- .../src/mineplex/gemhunters/GemHunters.java | 18 ++- 6 files changed, 25 insertions(+), 163 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/TimingsFix.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/TimingsFix.java b/Plugins/Mineplex.Core/src/mineplex/core/TimingsFix.java deleted file mode 100644 index 302ba7674..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/TimingsFix.java +++ /dev/null @@ -1,104 +0,0 @@ -package mineplex.core; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import sun.net.www.protocol.http.HttpURLConnection; - -import javax.net.ssl.HttpsURLConnection; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.net.Proxy; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLDecoder; -import java.nio.charset.StandardCharsets; - -@ReflectivelyCreateMiniPlugin -public class TimingsFix extends MiniPlugin -{ - private static final Gson GSON = new Gson(); - - private TimingsFix() - { - super("Timings Fix"); - - URL.setURLStreamHandlerFactory(protocol -> - { - if (protocol.equals("http")) - { - return new sun.net.www.protocol.http.Handler() - { - @Override - protected URLConnection openConnection(URL u) throws IOException - { - if (u.getHost().contains("paste.ubuntu.com")) - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]); - - return new HttpURLConnection(u, null, this) - { - @Override - public OutputStream getOutputStream() - { - return baos; - } - - @Override - public InputStream getInputStream() - { - return bais; - } - - @Override - public String getHeaderField(String name) - { - if (name.equals("Location")) - { - try - { - String request = new String(baos.toByteArray(), StandardCharsets.UTF_8); - request = request.substring("poster=Spigot&syntax=text&content=".length()); - - request = URLDecoder.decode(request, "UTF-8"); - - URL url = new URL("https://timings.spigotmc.org/paste"); - HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); - connection.setDoOutput(true); - connection.setRequestMethod("POST"); - connection.setInstanceFollowRedirects(false); - connection.getOutputStream().write(request.getBytes(StandardCharsets.UTF_8)); - connection.getOutputStream().close(); - - JsonObject object = GSON.fromJson(new InputStreamReader(connection.getInputStream()), JsonObject.class); - return "http://paste.ubuntu.com/" + object.get("key").getAsString() + "/"; - } - catch (Throwable e) - { - e.printStackTrace(); - return "http://paste.ubuntu.com/0/"; - } - } - return null; - } - }; - } - return super.openConnection(u); - } - - @Override - protected URLConnection openConnection(URL u, Proxy p) throws IOException - { - return super.openConnection(u, p); - } - }; - } - return null; - }); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java index e9f920567..e34150584 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java @@ -2,6 +2,15 @@ package mineplex.core.monitor; import java.util.HashSet; +import net.minecraft.server.v1_8_R3.MinecraftServer; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; @@ -10,17 +19,6 @@ import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; -import net.minecraft.server.v1_8_R3.MinecraftServer; - public class LagMeter extends MiniPlugin { private CoreClientManager _clientManager; @@ -31,12 +29,6 @@ public class LagMeter extends MiniPlugin private long _lastAverage; private long _start; - private long _lastTick = 0; - - private boolean _timingsRunning; - private boolean _timingsPasted; - private long _timingsStarted; - private HashSet _monitoring = new HashSet(); public LagMeter(JavaPlugin plugin, CoreClientManager clientManager) @@ -98,24 +90,6 @@ public class LagMeter extends MiniPlugin _lastRun = now; _count++; - - if (System.currentTimeMillis() - _start > 30000) - { - if (_timingsRunning) - { - if (System.currentTimeMillis() - _timingsStarted > 30000) - { - getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings paste"); - _timingsRunning = false; - } - } - else if (_ticksPerSecond < 10) - { - _timingsRunning = true; - _timingsStarted = System.currentTimeMillis(); - getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings on"); - } - } } public double getTicksPerSecond() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index b3ed131a7..ed924a65f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -1,10 +1,10 @@ package mineplex.game.clans; -import static mineplex.core.Managers.require; - import java.io.File; import java.io.IOException; +import net.minecraft.server.v1_8_R3.MinecraftServer; + import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.World; @@ -14,7 +14,6 @@ import org.spigotmc.SpigotConfig; import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; -import mineplex.core.TimingsFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; @@ -75,7 +74,8 @@ import mineplex.game.clans.shop.mining.MiningShop; import mineplex.game.clans.shop.pvp.PvpShop; import mineplex.game.clans.spawn.travel.TravelShop; import mineplex.game.clans.world.WorldManager; -import net.minecraft.server.v1_8_R3.MinecraftServer; + +import static mineplex.core.Managers.require; public class Clans extends JavaPlugin { @@ -113,8 +113,6 @@ public class Clans extends JavaPlugin _clientManager = new CoreClientManager(this); CommandCenter.Instance.setClientManager(_clientManager); - require(TimingsFix.class); - ItemStackFactory.Initialize(this, false); DelayedTask.Initialize(this); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 070cd582a..bc02c3628 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -43,7 +43,6 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; import mineplex.core.MiniClientPlugin; -import mineplex.core.TimingsFix; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -273,7 +272,6 @@ public class HubManager extends MiniClientPlugin implements IChatMess // new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); require(PlayerDisguiseManager.class); - require(TimingsFix.class); // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _gadgetManager, statsManager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 197d76ff0..ebf57b8d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -1,10 +1,10 @@ package nautilus.game.arcade; -import static mineplex.core.Managers.require; - import java.io.File; import java.util.HashMap; +import net.minecraft.server.v1_8_R3.MinecraftServer; + import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -16,7 +16,6 @@ import org.spigotmc.SpigotConfig; import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; import mineplex.core.PacketsInteractionFix; -import mineplex.core.TimingsFix; import mineplex.core.TwitchIntegrationFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -82,10 +81,11 @@ import mineplex.core.visibility.VisibilityManager; import mineplex.core.website.WebsiteLinkManager; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; + import nautilus.game.arcade.anticheatmetadata.GameInfoMetadata; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameServerConfig; -import net.minecraft.server.v1_8_R3.MinecraftServer; +import static mineplex.core.Managers.require; public class Arcade extends JavaPlugin { @@ -138,8 +138,6 @@ public class Arcade extends JavaPlugin CommandCenter.Instance.setClientManager(_clientManager); require(ProfileCacheManager.class); - require(TimingsFix.class); - ItemStackFactory.Initialize(this, false); Recharge.Initialize(this); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index 9b8256d80..d4e557763 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -1,8 +1,15 @@ package mineplex.gemhunters; +import net.minecraft.server.v1_8_R3.MinecraftServer; + +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.plugin.java.JavaPlugin; +import org.spigotmc.SpigotConfig; + import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; -import mineplex.core.TimingsFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; @@ -93,12 +100,6 @@ import mineplex.gemhunters.worldevent.WorldEventModule; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; -import net.minecraft.server.v1_8_R3.MinecraftServer; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.plugin.java.JavaPlugin; -import org.spigotmc.SpigotConfig; import static mineplex.core.Managers.require; @@ -132,9 +133,6 @@ public class GemHunters extends JavaPlugin // Command Centre CommandCenter.Instance.setClientManager(clientManager); - // Timings - require(TimingsFix.class); - // ItemStacks ItemStackFactory.Initialize(this, false); From a79c79bc998216eec307fc5cd58ed2c01801fffd Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 27 Jun 2017 12:38:43 +0100 Subject: [PATCH 247/283] Add wither overtime --- .../game/arcade/game/games/moba/Moba.java | 15 ++++- .../arcade/game/games/moba/ai/MobaAI.java | 4 +- .../games/moba/boss/wither/WitherBoss.java | 23 +++++++ .../boss/wither/WitherBossOvertimeAI.java | 48 +++++++++++++++ .../game/games/moba/minion/MinionManager.java | 13 ++++ .../games/moba/overtime/OvertimeManager.java | 60 +++++++++++++++++++ 6 files changed, 159 insertions(+), 4 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index b5241e7b7..f1db74bae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -41,8 +41,7 @@ import nautilus.game.arcade.game.games.moba.kit.hp.HPManager; import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa; import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena; import nautilus.game.arcade.game.games.moba.minion.MinionManager; -import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; -import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; +import nautilus.game.arcade.game.games.moba.overtime.OvertimeManager; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; @@ -81,6 +80,7 @@ public class Moba extends TeamGame protected final MobaShop _shop; protected final GoldManager _goldManager; protected final BossManager _boss; + protected final OvertimeManager _overtimeManager; protected final BuffManager _buffs; protected final ArrowKBManager _arrowKb; protected final TowerManager _tower; @@ -116,6 +116,7 @@ public class Moba extends TeamGame _shop = registerManager(new MobaShop(this)); _goldManager = registerManager(new GoldManager(this)); _boss = registerManager(new BossManager(this)); + _overtimeManager = registerManager(new OvertimeManager(this)); _buffs = registerManager(new BuffManager()); _arrowKb = registerManager(new ArrowKBManager(this)); _minion = registerManager(new MinionManager(this)); @@ -496,6 +497,11 @@ public class Moba extends TeamGame return _goldManager; } + public OvertimeManager getOvertimeManager() + { + return _overtimeManager; + } + public BuffManager getBuffManager() { return _buffs; @@ -520,4 +526,9 @@ public class Moba extends TeamGame { return _arrowKb; } + + public MinionManager getMinionManager() + { + return _minion; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 5b89b9884..1ad97af9e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -23,11 +23,11 @@ public class MobaAI private final float _speedHome; private final Polygon2D _boundaries; - private LivingEntity _entity; + protected LivingEntity _entity; private LivingEntity _target; private Location _home; - private MobaAIMethod _aiMethod; + protected MobaAIMethod _aiMethod; public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 8d80c7f5e..d8595853a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -46,6 +46,7 @@ public class WitherBoss extends MobaBoss private final GameTeam _team; private MobaAI _ai; + private MobaAI _aiOvertime; private DisguiseWither _disguise; private boolean _damageable; private long _lastInform; @@ -70,6 +71,7 @@ public class WitherBoss extends MobaBoss stand.setHealth(INITIAL_HEALTH * 0.1); stand.setGravity(false); + MobaUtil.setTeamEntity(stand, _team); UtilEnt.setBoundingBox(stand, 3, 5); _disguise = new DisguiseWither(stand); @@ -87,10 +89,31 @@ public class WitherBoss extends MobaBoss { _ai = new MobaAI(_host, _team, _entity, _location, SPEED_TARGET, SPEED_HOME, AI_METHOD); } + else if (_host.getOvertimeManager().isOvertime()) + { + if (_aiOvertime == null) + { + _aiOvertime = new WitherBossOvertimeAI(_host, _team, _entity, _location, SPEED_TARGET, SPEED_HOME, AI_METHOD); + } + + return _aiOvertime; + } return _ai; } + @Override + @EventHandler + public void updateMovement(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || !_host.IsLive()) + { + return; + } + + getAi().updateTarget(); + } + @Override public String getName() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java new file mode 100644 index 000000000..9a710aaab --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java @@ -0,0 +1,48 @@ +package nautilus.game.arcade.game.games.moba.boss.wither; + +import mineplex.core.common.util.UtilMath; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; + +import java.util.List; + +public class WitherBossOvertimeAI extends MobaAI +{ + + private List _path; + private Location _target; + private int _targetIndex; + + public WitherBossOvertimeAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod) + { + super(host, owner, entity, home, speedTarget, speedHome, aiMethod); + + _path = host.getMinionManager().getPath(owner.GetColor() == ChatColor.RED); + _path = _path.subList(0, (int) (_path.size() / 2D)); + } + + @Override + public void updateTarget() + { + if (_target == null) + { + _target = _path.get(0); + _targetIndex = 0; + } + + double dist = UtilMath.offsetSquared(_target, _entity.getLocation()); + + if (dist < 16 && _targetIndex < _path.size() - 1) + { + _targetIndex++; + _target = _path.get(_targetIndex); + } + + _aiMethod.updateMovement(_entity, _target, 3); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 9e3790713..efdb7356b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -22,6 +22,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -181,4 +182,16 @@ public class MinionManager implements Listener // sign.update(); // } } + + public List getPath(boolean redTeam) + { + List path = new ArrayList<>(_path); + + if (redTeam) + { + Collections.reverse(path); + } + + return path; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java new file mode 100644 index 000000000..9e72823d5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java @@ -0,0 +1,60 @@ +package nautilus.game.arcade.game.games.moba.overtime; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import java.util.concurrent.TimeUnit; + +public class OvertimeManager implements Listener +{ + + private static final long OVERTIME = TimeUnit.MINUTES.toMillis(1); + + private final Moba _host; + private boolean _enabled; + private boolean _overtime; + + public OvertimeManager(Moba host) + { + _host = host; + _enabled = true; + } + + public void disableOvertime() + { + _enabled = false; + } + + @EventHandler + public void updateOvertime(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !_host.IsLive() || !UtilTime.elapsed(_host.GetStateTime(), OVERTIME) || _overtime || !_enabled) + { + return; + } + + _overtime = true; + UtilTextMiddle.display(C.cRedB + "OVERTIME", "Victory or Death, Withers are moving to the center!"); + _host.Announce(F.main("Game", "Victory or Death, Withers are moving to the center!"), false); + + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1.2F); + } + } + + public boolean isOvertime() + { + return _enabled && _overtime; + } +} From b9a72312a80f43694337a964e616e486a6e6f66b Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 28 Jun 2017 00:21:47 +0100 Subject: [PATCH 248/283] Add a go back button on kit selection --- .../core/common/entity/ClientArmorStand.java | 6 +++ .../games/moba/boss/wither/WitherBoss.java | 5 +++ .../boss/wither/WitherBossOvertimeAI.java | 2 +- .../arcade/game/games/moba/kit/HeroSkill.java | 10 +++++ .../games/moba/overtime/OvertimeManager.java | 10 +++++ .../games/moba/prepare/PrepareSelection.java | 43 ++++++++++++++----- .../games/moba/training/MobaTraining.java | 1 + 7 files changed, 65 insertions(+), 12 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java index 239f0af5c..385c9c3ce 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java @@ -79,6 +79,12 @@ public class ClientArmorStand implements ArmorStand _observers = players; } + public void sendSpawnPacket(Player player) + { + Packet packet = new PacketPlayOutSpawnEntityLiving(_armorStand); + UtilPlayer.sendPacket(player, packet); + } + public EntityArmorStand getHandle() { return _armorStand; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index d8595853a..22b4597d1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -253,4 +253,9 @@ public class WitherBoss extends MobaBoss { return _team; } + + public void setDamageable(boolean damageable) + { + _damageable = damageable; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java index 9a710aaab..ea389a6a6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java @@ -43,6 +43,6 @@ public class WitherBossOvertimeAI extends MobaAI _target = _path.get(_targetIndex); } - _aiMethod.updateMovement(_entity, _target, 3); + _aiMethod.updateMovement(_entity, _target, 2); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 131714e73..9a6a9eaf8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -323,6 +323,16 @@ public class HeroSkill extends Perk Recharge.Instance.useForce(player, GetName(), time, true); Recharge.Instance.setDisplayForce(player, GetName(), true); + Manager.runSyncTimer(new BukkitRunnable() + { + + @Override + public void run() + { + double percentage = + } + }, 0, 1); + Manager.runSyncTimer(new BukkitRunnable() { int iterations = 0; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java index 9e72823d5..9c2989fb4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java @@ -7,6 +7,8 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import org.bukkit.Bukkit; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -47,6 +49,14 @@ public class OvertimeManager implements Listener UtilTextMiddle.display(C.cRedB + "OVERTIME", "Victory or Death, Withers are moving to the center!"); _host.Announce(F.main("Game", "Victory or Death, Withers are moving to the center!"), false); + for (MobaBoss boss : _host.getBossManager().getBosses()) + { + if (boss instanceof WitherBoss) + { + ((WitherBoss) boss).setDamageable(true); + } + } + for (Player player : Bukkit.getOnlinePlayers()) { player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1.2F); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index bad2ee430..a7c4b4e99 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -1,9 +1,14 @@ package nautilus.game.arcade.game.games.moba.prepare; import mineplex.core.common.entity.ClientArmorStand; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +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.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler.ListenerPriority; @@ -18,6 +23,7 @@ import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import org.bukkit.ChatColor; +import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -40,6 +46,7 @@ public class PrepareSelection implements Listener, IPacketHandler private final Moba _host; private final Map _roleStands = new HashMap<>(); private final Map _kitStands = new HashMap<>(); + private final Map _goBackStands = new HashMap<>(); public PrepareSelection(Moba host) { @@ -109,9 +116,21 @@ public class PrepareSelection implements Listener, IPacketHandler Location average = UtilAlg.getAverageLocation(team.GetSpawns()); MobaPlayer mobaPlayer = _host.getMobaData(player); - List heroKits = _host.getKits(mobaPlayer.getRole()); + Location goBack = spawns.remove("KIT " + team.GetName().toUpperCase() + " GO_BACK"); + ClientArmorStand goBackStand = ClientArmorStand.spawn(goBack.clone().add(0, 1, 0), player); + + goBackStand.setCustomNameVisible(true); + goBackStand.setCustomName(C.cGreenB + "Go Back"); + goBackStand.setArms(true); + goBackStand.setHelmet(new ItemStack(Material.SKULL_ITEM, (byte) 2)); + goBackStand.setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.MAROON).build()); + goBackStand.setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.MAROON).build()); + goBackStand.setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.MAROON).build()); + + _goBackStands.put(player, goBackStand); + UtilServer.runSyncLater(() -> { for (Location location : spawns.values()) @@ -169,6 +188,16 @@ public class PrepareSelection implements Listener, IPacketHandler Player player = packetInfo.getPlayer(); int entityId = packet.a; + ClientArmorStand goBackStand = _goBackStands.get(player); + + if (goBackStand != null) + { + packetInfo.setCancelled(true); + _host.getMobaData(player).setRole(null); + _goBackStands.remove(player).remove(); + return; + } + for (ClientArmorStand stand : _roleStands.keySet()) { if (stand.getEntityId() != entityId) @@ -199,15 +228,7 @@ public class PrepareSelection implements Listener, IPacketHandler return; } - if (team.GetColor() == ChatColor.RED) - { - spawnKitUI(player); - } - else - { - spawnKitUI(player); - } - + spawnKitUI(player); displayKitInformation(player, role); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index 49f0d3d91..af7f68465 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -128,6 +128,7 @@ public class MobaTraining extends Moba // Prevent the wither from being damaged as well as to not spawn the pumpkin king _boss.setDummyBosses(true); + _overtimeManager.disableOvertime(); // Disable minions _minion.disableMinions(); From 82182c5d50ef1a5dca42461391ca1981f3db1939 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 28 Jun 2017 15:34:56 +0100 Subject: [PATCH 249/283] Balance changes --- .../arcade/game/games/moba/kit/HeroSkill.java | 17 +++++++++++++---- .../games/moba/kit/bardolf/HeroBardolf.java | 2 +- .../games/moba/kit/bardolf/SkillSummonWolf.java | 2 +- .../game/games/moba/kit/biff/SkillWarHorse.java | 2 +- .../game/games/moba/kit/dana/SkillDanaDash.java | 4 ++-- .../games/moba/kit/dana/SkillPulseHeal.java | 4 ++-- .../game/games/moba/kit/dana/SkillRally.java | 2 +- .../games/moba/shop/hunter/MobaHunterShop.java | 13 +++++++++++++ .../moba/structure/tower/TowerManager.java | 4 +++- .../game/games/moba/training/MobaTraining.java | 4 ++-- 10 files changed, 39 insertions(+), 15 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 9a6a9eaf8..48b6529c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -6,9 +6,9 @@ import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; 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.events.PlayerKitGiveEvent; @@ -316,12 +316,11 @@ public class HeroSkill extends Perk public void useActiveSkill(Runnable complete, Player player, long time) { + long now = System.currentTimeMillis(); long ticks = (long) (time / 1000D); ItemStack itemStack = player.getInventory().getItem(getSlot()); itemStack.setAmount((int) (ticks / 20D)); UtilInv.addDullEnchantment(itemStack); - Recharge.Instance.useForce(player, GetName(), time, true); - Recharge.Instance.setDisplayForce(player, GetName(), true); Manager.runSyncTimer(new BukkitRunnable() { @@ -329,7 +328,17 @@ public class HeroSkill extends Perk @Override public void run() { - double percentage = + long timeLeft = System.currentTimeMillis() + time - now; + double percentage = (double) timeLeft / (double) time; + + if (percentage >= 1) + { + UtilTextBottom.display(C.cRedB + GetName(), player); + cancel(); + return; + } + + UtilTextBottom.displayProgress(GetName(), percentage, player); } }, 0, 1); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java index d28975e95..7ac660d7f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java @@ -96,7 +96,7 @@ public class HeroBardolf extends HeroKit if (UtilMath.offsetSquared(wolf.getTarget(), wolf) < 9 && Recharge.Instance.use(data.getOwner(), "Wolf" + wolf.getTarget().getUniqueId(), 500, false, false)) { - Manager.GetDamage().NewDamageEvent(wolf.getTarget(), data.getOwner(), null, DamageCause.CUSTOM, 2, true, true, false, data.getOwner().getName(), "Wolf"); + Manager.GetDamage().NewDamageEvent(wolf.getTarget(), data.getOwner(), null, DamageCause.CUSTOM, 1, true, true, false, data.getOwner().getName(), "Wolf"); } } else if (ownerOffset > MAX_DIST_SQUARED) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java index d0e43367b..29dbd295f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java @@ -32,7 +32,7 @@ public class SkillSummonWolf extends HeroSkill }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.BONE); private static final int MAX_WOLVES = 5; - private static final int HEALTH = 6; + private static final int HEALTH = 8; public SkillSummonWolf(int slot) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index 9a45a201d..d6997e5e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -133,7 +133,7 @@ public class SkillWarHorse extends HeroSkill } owner.sendMessage(F.main("Game", "You hit " + F.name(player.getName()) + ".")); - Manager.GetDamage().NewDamageEvent(player, owner, null, DamageCause.CUSTOM, 10, false, true, false, UtilEnt.getName(owner), GetName()); + Manager.GetDamage().NewDamageEvent(player, owner, null, DamageCause.CUSTOM, 4, false, true, false, UtilEnt.getName(owner), GetName()); buffManager.apply(new BuffRooting(game, player, 1000)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java index 8fcb89839..cd2398103 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java @@ -60,12 +60,12 @@ public class SkillDanaDash extends DashSkill if (entity instanceof Player) { - damage = 10; + damage = 12; UtilAction.velocity(entity, new Vector(Math.random() / 2 - 0.25, 1, Math.random() / 2 - 0.25)); } else { - damage = 6; + damage = 8; UtilAction.velocity(entity, new Vector(Math.random() - 0.5, 0.5, Math.random() - 0.5)); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java index 6d26e4cc3..4908fdf41 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -43,7 +43,7 @@ public class SkillPulseHeal extends HeroSkill Player player = event.getPlayer(); useSkill(player); - for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) + for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 7).keySet()) { // Don't heal enemies if (!isTeamDamage(entity, player)) @@ -68,7 +68,7 @@ public class SkillPulseHeal extends HeroSkill @Override public void run() { - if (radius > 5) + if (radius > 7) { cancel(); return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index ec5ac4cc9..19922f0e1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -151,7 +151,7 @@ public class SkillRally extends HeroSkill for (LivingEntity nearby : UtilEnt.getInRadius(player.getLocation(), 3).keySet()) { - Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, 5, true, true, false, UtilEnt.getName(player), GetName()); + Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, 7, true, true, false, UtilEnt.getName(player), GetName()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java index 2c9b75b86..2429e6819 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java @@ -10,6 +10,7 @@ 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.*; +import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; @@ -74,18 +75,21 @@ public class MobaHunterShop extends MobaShopMenu ), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Leather Cap of Nimble Fingers") + .setColor(Color.GREEN) .build(), 400) .addEffects( new MobaCDRAmmoEffect(0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Focused Cap") + .setColor(Color.PURPLE) .build(), 500) .addEffects( new MobaCDREffect(0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Vampiric Helmet") + .setColor(Color.RED) .build(), 500) .addEffects( new MobaHPRegenEffect(0.2) @@ -101,18 +105,21 @@ public class MobaHunterShop extends MobaShopMenu .build(), 250), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) .setTitle(C.cGreen + "Leather Chestplate of Nimble Fingers") + .setColor(Color.GREEN) .build(), 750) .addEffects( new MobaCDRAmmoEffect(0.15) ), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) .setTitle(C.cGreen + "Focused Chestplate") + .setColor(Color.PURPLE) .build(), 750) .addEffects( new MobaCDREffect(0.1) ), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) .setTitle(C.cGreen + "Vampiric Chestplate") + .setColor(Color.RED) .build(), 750) .addEffects( new MobaKillHealEffect(3) @@ -128,18 +135,21 @@ public class MobaHunterShop extends MobaShopMenu .build(), 250), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) .setTitle(C.cGreen + "Leather Leggings of Nimble Fingers") + .setColor(Color.GREEN) .build(), 750) .addEffects( new MobaCDRAmmoEffect(0.1) ), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) .setTitle(C.cGreen + "Focused Leggings") + .setColor(Color.PURPLE) .build(), 750) .addEffects( new MobaCDREffect(0.1) ), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) .setTitle(C.cGreen + "Vampiric Leggings") + .setColor(Color.RED) .build(), 700) .addEffects( new MobaKillHealEffect(3) @@ -155,18 +165,21 @@ public class MobaHunterShop extends MobaShopMenu .build(), 250), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Leather Boots of Nimble Fingers") + .setColor(Color.GREEN) .build(), 400) .addEffects( new MobaCDRAmmoEffect(0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Focused Boots") + .setColor(Color.PURPLE) .build(), 600) .addEffects( new MobaCDREffect(0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Vampiric Boots") + .setColor(Color.RED) .build(), 500) .addEffects( new MobaKillHealEffect(1) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index a7c9d4d54..eaa2f4626 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -281,7 +281,9 @@ public class TowerManager implements Listener for (Tower tower : _towers) { - if (tower.isDead() || tower.getOwner().equals(team) || UtilMath.offsetSquared(tower.getCrystal().getLocation(), location) > PROJECTILE_RANGE_SQUARED) + Location crystalLocation = tower.getCrystal().getLocation(); + + if (tower.isDead() || tower.getOwner().equals(team) || UtilMath.offsetSquared(crystalLocation, location) > PROJECTILE_RANGE_SQUARED || shouldCancelDamage(tower, shooter)) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index af7f68465..439390385 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -76,7 +76,7 @@ public class MobaTraining extends Moba C.cYellow + "of " + C.cGold + "Gold" + C.cYellow + " your team earns." }, { - C.cYellow + "The is the " + C.cDRedB + "Pumpkin King", + C.cYellow + "This is the " + C.cDRedB + "Pumpkin King", C.cYellow + "He spawns at " + C.cGreen + "10 minutes" + C.cYellow + " into the game.", C.cYellow + "The team that kills him will be given increased", C.cYellow + "regeneration and damage." @@ -92,7 +92,7 @@ public class MobaTraining extends Moba C.cYellow + "They will fight each other and help destroy enemy Towers." }, { - C.cYellow + "With the " + C.cGold + "Gold" + C.cYellow + "you earn you can", + C.cYellow + "With the " + C.cGold + "Gold" + C.cYellow + " you earn you can", C.cYellow + "spend it on upgrades for your weapons and armor.", C.cYellow + "You can do this via the gold ingot in your inventory", C.cYellow + "during the game or by clicking on the Villager." From 85007820d2e35ac7bf989a0b9fce4b725add472f Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 28 Jun 2017 23:38:50 +0100 Subject: [PATCH 250/283] Add a go-back button to kit selection --- .../core/common/entity/ClientArmorStand.java | 22 +++++--- .../games/moba/boss/wither/WitherBoss.java | 44 +++++++-------- .../boss/wither/WitherBossOvertimeAI.java | 7 +++ .../arcade/game/games/moba/kit/HeroSkill.java | 7 ++- .../games/moba/prepare/PrepareSelection.java | 56 ++++++++++++++----- .../arcade/game/games/moba/util/MobaUtil.java | 5 ++ 6 files changed, 95 insertions(+), 46 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java index 385c9c3ce..1c49ca731 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java @@ -79,12 +79,6 @@ public class ClientArmorStand implements ArmorStand _observers = players; } - public void sendSpawnPacket(Player player) - { - Packet packet = new PacketPlayOutSpawnEntityLiving(_armorStand); - UtilPlayer.sendPacket(player, packet); - } - public EntityArmorStand getHandle() { return _armorStand; @@ -182,7 +176,7 @@ public class ClientArmorStand implements ArmorStand @Override public Location getLocation() { - return new Location(getWorld(), _armorStand.locX, _armorStand.locY, _armorStand.locZ); + return new Location(getWorld(), _armorStand.locX, _armorStand.locY, _armorStand.locZ, _armorStand.yaw, _armorStand.pitch); } @Override @@ -246,6 +240,20 @@ public class ClientArmorStand implements ArmorStand return false; } + public boolean teleport(Location location, Player player) + { + double pX = _armorStand.locX; + double pY = _armorStand.locY; + double pZ = _armorStand.locZ; + float pYaw = _armorStand.yaw; + float pPitch = _armorStand.pitch; + + _armorStand.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + UtilPlayer.sendPacket(player, new PacketPlayOutEntityTeleport(_armorStand)); + _armorStand.setPositionRotation(pX, pY, pZ, pYaw, pPitch); + return false; + } + @Override public boolean teleport(Location loc) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 22b4597d1..6e190779b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -40,7 +40,7 @@ public class WitherBoss extends MobaBoss private static final String NAME = "Wither Boss"; private static final float SPEED_TARGET = 4F; private static final float SPEED_HOME = 6F; - private static final int INITIAL_HEALTH = 125; + private static final int INITIAL_HEALTH = 275; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); @@ -66,9 +66,8 @@ public class WitherBoss extends MobaBoss { ArmorStand stand = _location.getWorld().spawn(_location, ArmorStand.class); - // Reducing the wither's health to 10% gives a shield like effect. stand.setMaxHealth(INITIAL_HEALTH); - stand.setHealth(INITIAL_HEALTH * 0.1); + stand.setHealth(INITIAL_HEALTH); stand.setGravity(false); MobaUtil.setTeamEntity(stand, _team); @@ -148,20 +147,6 @@ public class WitherBoss extends MobaBoss return; } - // If not damageable - if (!_damageable) - { - Player damager = event.GetDamagerPlayer(true); - - if (damager != null) - { - damager.sendMessage(F.main("Game", "You must destroy both towers before attacking the Wither!")); - damager.playSound(damager.getLocation(), Sound.NOTE_BASS, 1, 0.8F); - } - - return; - } - LivingEntity damagee = event.GetDamageeEntity(); Player damager = event.GetDamagerPlayer(true); @@ -175,6 +160,18 @@ public class WitherBoss extends MobaBoss } } + // If not damageable + if (!_damageable) + { + if (damager != null) + { + damager.sendMessage(F.main("Game", "You must destroy both towers before attacking the Wither!")); + damager.playSound(damager.getLocation(), Sound.NOTE_BASS, 1, 0.8F); + } + + return; + } + // Inform the team if (UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) { @@ -214,11 +211,14 @@ public class WitherBoss extends MobaBoss return; } - // Here we can remove the shield effect, as the wither is no longer invincible - if (!tower.isFirstTower()) + if (tower.isFirstTower()) { + _entity.setHealth(_entity.getHealth() - 50); + } + else + { + _entity.setHealth(_entity.getHealth() - 100); _damageable = true; - _entity.setHealth(INITIAL_HEALTH); updateDisplay(); } } @@ -235,13 +235,13 @@ public class WitherBoss extends MobaBoss for (Player player : _team.GetPlayers(true)) { - UtilTextTop.displayTextBar(player, percent, _team.GetColor() + "Your Wither"); + UtilTextTop.displayTextBar(player, percent, _team.GetColor() + "Your Wither"); } } public double getHealthPercentage() { - return _damageable ? (_entity.getHealth() / _entity.getMaxHealth()) : 1; + return _entity.getHealth() / _entity.getMaxHealth(); } private void updateDisplay() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java index ea389a6a6..67bd868be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.boss.wither; +import mineplex.core.common.geom.Polygon2D; import mineplex.core.common.util.UtilMath; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; @@ -45,4 +46,10 @@ public class WitherBossOvertimeAI extends MobaAI _aiMethod.updateMovement(_entity, _target, 2); } + + @Override + public Polygon2D getBoundaries() + { + return null; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 48b6529c9..2a19d34cd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -328,17 +328,17 @@ public class HeroSkill extends Perk @Override public void run() { - long timeLeft = System.currentTimeMillis() + time - now; + long timeLeft = now + time - System.currentTimeMillis(); double percentage = (double) timeLeft / (double) time; - if (percentage >= 1) + if (percentage <= 0) { UtilTextBottom.display(C.cRedB + GetName(), player); cancel(); return; } - UtilTextBottom.displayProgress(GetName(), percentage, player); + UtilTextBottom.displayProgress(C.cWhiteB + GetName(), percentage, UtilTime.MakeStr(timeLeft), player); } }, 0, 1); @@ -356,6 +356,7 @@ public class HeroSkill extends Perk complete.run(); } useSkill(player); + Kit.GiveItems(player); cancel(); return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index a7c4b4e99..4480e761f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -22,7 +22,6 @@ import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; -import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; @@ -91,18 +90,24 @@ public class PrepareSelection implements Listener, IPacketHandler location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); - MobaRole role = MobaRole.valueOf(entry.getKey().split(" ")[2]); - ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players); + try + { + MobaRole role = MobaRole.valueOf(entry.getKey().split(" ")[2]); + ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players); - stand.setCustomNameVisible(true); - stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + C.cGreenB + "AVAILABLE"); - stand.setArms(true); - stand.setHelmet(head); - stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); - stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); - stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); + stand.setCustomNameVisible(true); + stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + C.cGreenB + "AVAILABLE"); + stand.setArms(true); + stand.setHelmet(head); + stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); + stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); + stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); - _roleStands.put(stand, role); + _roleStands.put(stand, role); + } + catch (IllegalArgumentException e) + { + } } // Only spawn the NPCs once all players have been loaded into the world. }, _host.GetPlayers(true).size() * _host.TickPerTeleport + 10); @@ -124,7 +129,7 @@ public class PrepareSelection implements Listener, IPacketHandler goBackStand.setCustomNameVisible(true); goBackStand.setCustomName(C.cGreenB + "Go Back"); goBackStand.setArms(true); - goBackStand.setHelmet(new ItemStack(Material.SKULL_ITEM, (byte) 2)); + goBackStand.setHelmet(new ItemStack(Material.SKULL_ITEM)); goBackStand.setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.MAROON).build()); goBackStand.setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.MAROON).build()); goBackStand.setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.MAROON).build()); @@ -190,11 +195,21 @@ public class PrepareSelection implements Listener, IPacketHandler ClientArmorStand goBackStand = _goBackStands.get(player); - if (goBackStand != null) + if (goBackStand != null && goBackStand.getEntityId() == entityId) { packetInfo.setCancelled(true); _host.getMobaData(player).setRole(null); _goBackStands.remove(player).remove(); + + for (ClientArmorStand stand2 : _kitStands.keySet()) + { + stand2.remove(player); + } + + for (ClientArmorStand stand2 : _roleStands.keySet()) + { + stand2.teleport(stand2.getLocation(), player); + } return; } @@ -218,7 +233,7 @@ public class PrepareSelection implements Listener, IPacketHandler for (ClientArmorStand stand2 : _roleStands.keySet()) { - stand2.remove(player); + stand2.teleport(stand2.getLocation().add(0, 100, 0), player); } GameTeam team = _host.GetTeam(player); @@ -243,6 +258,11 @@ public class PrepareSelection implements Listener, IPacketHandler HeroKit kit = _kitStands.get(stand); + if (goBackStand != null) + { + _goBackStands.remove(player).remove(); + } + for (ClientArmorStand stand2 : _kitStands.keySet()) { stand2.remove(player); @@ -287,6 +307,14 @@ public class PrepareSelection implements Listener, IPacketHandler stand.remove(); } + for (ClientArmorStand stand : _goBackStands.values()) + { + stand.remove(); + } + + _roleStands.clear(); + _kitStands.clear(); + _goBackStands.clear(); removePodiums(); _host.getArcadeManager().getPacketHandler().removePacketHandler(this); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index b4efa6382..76721ad08 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -72,6 +72,11 @@ public class MobaUtil public static boolean isInBoundary(GameTeam owner, LivingEntity source, Location center, Polygon2D boundaries, LivingEntity target) { + if (boundaries == null) + { + return true; + } + return getEntitiesInBoundary(owner, source, center, boundaries).contains(target); } From 67d8e0863d22f9708d5d46d1c5d8af25aa10ad5b Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 29 Jun 2017 00:13:06 +0100 Subject: [PATCH 251/283] Fix overtime being at 1 minute --- .../game/arcade/game/games/moba/kit/HeroKit.java | 3 +++ .../game/games/moba/overtime/OvertimeManager.java | 2 +- .../game/arcade/game/games/moba/shop/MobaShop.java | 13 ++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 707bc435f..4758aefcd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -166,6 +166,9 @@ public class HeroKit extends Kit { PlayerInventory inventory = player.getInventory(); + // This is important + inventory.clear(); + // Give standard items inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(SHOP_SLOT, SHOP_ITEM); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java index 9c2989fb4..f22986f4c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java @@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit; public class OvertimeManager implements Listener { - private static final long OVERTIME = TimeUnit.MINUTES.toMillis(1); + private static final long OVERTIME = TimeUnit.MINUTES.toMillis(15); private final Moba _host; private boolean _enabled; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 0fca426e2..efd64d2c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -4,6 +4,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -42,6 +43,7 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.HashMap; @@ -296,11 +298,16 @@ public class MobaShop implements Listener Remove empty potions */ @EventHandler - public void removeEmptyPotions(PlayerItemConsumeEvent event) + public void removeEmptyPotions(UpdateEvent event) { - if (event.getItem().getType() == Material.POTION) + if (event.getType() != UpdateType.FAST) { - _host.getArcadeManager().runSyncLater(() -> event.getPlayer().setItemInHand(null), 1); + return; + } + + for (Player player : _host.GetPlayers(true)) + { + player.getInventory().remove(Material.GLASS_BOTTLE); } } From b8bb25b04dd506fb442a206959c8fbd1272ffa3e Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 29 Jun 2017 00:35:18 +0100 Subject: [PATCH 252/283] Only reset player health upon actual respawn --- .../game/arcade/game/games/moba/minion/MinionWave.java | 2 +- .../game/arcade/game/games/moba/shop/MobaItemEffect.java | 2 +- .../game/arcade/game/games/moba/shop/MobaShop.java | 4 ++-- .../game/games/moba/shop/effects/MobaSpeedEffect.java | 2 +- .../games/moba/shop/effects/MobaTotalHealthEffect.java | 8 ++++++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 6339d7ed0..2ec589c7e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -359,7 +359,7 @@ public class MinionWave implements Listener for (MobaBoss boss : bosses) { // Dead, not close enough - if (boss.isDead() || UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()) > DAMAGE_RANGE_SQUARED) + if (boss.isDead() || MobaUtil.isTeamEntity(boss.getEntity(), _owner) || UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()) > DAMAGE_RANGE_SQUARED) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java index 3e37e1cc4..73b0d1b86 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -54,7 +54,7 @@ public abstract class MobaItemEffect { } - protected void onRespawn(PlayerGameRespawnEvent event) + protected void onRespawn(PlayerGameRespawnEvent event, boolean fake) { } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index efd64d2c9..55c40f2af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -221,7 +221,7 @@ public class MobaShop implements Listener { if (ownedItem.getEffects() != null) { - ownedItem.getEffects().forEach(effect -> effect.onRespawn(fakeEvent)); + ownedItem.getEffects().forEach(effect -> effect.onRespawn(fakeEvent, true)); } } @@ -530,7 +530,7 @@ public class MobaShop implements Listener for (MobaItemEffect effect : item.getEffects()) { - effect.onRespawn(event); + effect.onRespawn(event, false); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java index 15d7d7196..8505a6eb0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java @@ -16,7 +16,7 @@ public class MobaSpeedEffect extends MobaItemEffect } @Override - public void onRespawn(PlayerGameRespawnEvent event) + public void onRespawn(PlayerGameRespawnEvent event, boolean fake) { Player player = event.GetPlayer(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java index 80af5c495..7867ce364 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java @@ -17,12 +17,16 @@ public class MobaTotalHealthEffect extends MobaItemEffect } @Override - public void onRespawn(PlayerGameRespawnEvent event) + public void onRespawn(PlayerGameRespawnEvent event, boolean fake) { Player player = event.GetPlayer(); player.setMaxHealth(player.getMaxHealth() + _health); - player.setHealth(player.getMaxHealth()); + + if (!fake) + { + player.setHealth(player.getMaxHealth()); + } } @Override From 7bd5d65823b92dfd9fefecf7fa8e4b54369f91c6 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 29 Jun 2017 00:37:42 +0100 Subject: [PATCH 253/283] Reduce the amount of gems given for gold earned --- .../nautilus/game/arcade/game/games/moba/gold/GoldManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index 312aebec7..4ce28a71d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -148,7 +148,7 @@ public class GoldManager implements Listener if (amount > 20 && reason != null) { - _host.AddGems(player, (double) amount / 2D, reason, true, true); + _host.AddGems(player, (double) amount / 3D, reason, true, true); player.sendMessage(F.main("Game", C.cGold + "+" + amount + " gold (" + reason + ")" + C.cGray + ".")); } } From 7459a458cd75bf1119800178020e0970ade14e9b Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:28:39 -0400 Subject: [PATCH 254/283] Add gaussian methods to UtilMath --- .../mineplex/core/common/util/UtilMath.java | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java index 5e37e0ac5..1b3b40835 100644 --- a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; import org.bukkit.Location; import org.bukkit.entity.Entity; @@ -13,6 +14,8 @@ import org.bukkit.util.Vector; public class UtilMath { + public static final double TAU = Math.PI * 2D; + public static double trim(int degree, double d) { String format = "#.#"; @@ -332,4 +335,119 @@ public class UtilMath return min; } + + /** + * Creates an array of points, arranged in a circle normal to a vector. + * + * @param center The center of the circle. + * @param normal A vector normal to the circle. + * @param radius The radius of the circle. + * @param points How many points to make up the circle. + * + * @return An array of points of the form double[point #][x=0, y=1, z=3]. + */ + public static double[][] normalCircle(Location center, Vector normal, double radius, int points) + { + return normalCircle(center.toVector(), normal, radius, points); + } + + /** + * Creates an array of points, arranged in a circle normal to a vector. + * + * @param center The center of the circle. + * @param normal A vector normal to the circle. + * @param radius The radius of the circle. + * @param points How many points to make up the circle. + * + * @return An array of points of the form double[point #][x=0, y=1, z=3]. + */ + public static double[][] normalCircle(Vector center, Vector normal, double radius, int points) + { + Vector n = normal.clone().normalize(); + Vector a = n.clone().add(new Vector(1, 1, 1)).crossProduct(n).normalize(); + Vector b = n.getCrossProduct(a).normalize(); + + double[][] data = new double[points][3]; + + double interval = TAU / points; + double theta = 0; + + for (int i = 0; i < points; i++) + { + data[i][0] = center.getX() + (radius * ((Math.cos(theta) * a.getX()) + (Math.sin(theta) * b.getX()))); + data[i][1] = center.getY() + (radius * ((Math.cos(theta) * a.getY()) + (Math.sin(theta) * b.getY()))); + data[i][2] = center.getZ() + (radius * ((Math.cos(theta) * a.getZ()) + (Math.sin(theta) * b.getZ()))); + theta += interval; + } + + return data; + } + + /** + * Slightly randomize a location with a standard deviation of one. + * + * @param location The location to randomize. + * + * @return The original location, now gaussian-randomized. + */ + public static Location gauss(Location location) + { + return gauss(location, 1, 1, 1); + } + + /** + * Slightly randomize a vector with a standard deviation of one. + * + * @param vector The location to randomize. + * + * @return The randomized vector, now gaussian-randomized. + */ + public static Vector gauss(Vector vector) + { + return gauss(vector, 1, 1, 1); + } + + /** + * Slightly randomize a location with a standard deviation of one.
+ * + * This method only accepts positive values for all of its arguments.
+ * + * A good parameter set for small offsets is (loc, 10, 10, 10). + * + * @param location The location to randomize. + * @param x A granularity control for the x-axis, higher numbers = less randomness + * @param y A granularity control for the y-axis, higher numbers = less randomness + * @param z A granularity control for the z-axis, higher numbers = less randomness + * + * @return The original location, now gaussian-randomized + */ + public static Location gauss(Location location, double x, double y, double z) + { + return location.clone().add( + x <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / x), + y <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / y), + z <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / z)); + } + + /** + * Slightly randomize a vector with a standard deviation of one.
+ * + * This method only accepts positive values for all of its arguments.
+ * + * A good parameter set for small offsets is (loc, 10, 10, 10). + * + * @param vector The location to randomize. + * @param x A granularity control for the x-axis, higher numbers = less randomness + * @param y A granularity control for the y-axis, higher numbers = less randomness + * @param z A granularity control for the z-axis, higher numbers = less randomness + * + * @return The randomized vector, now gaussian-randomized + */ + public static Vector gauss(Vector vector, double x, double y, double z) + { + return vector.clone().add(new Vector( + x <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / x), + y <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / y), + z <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / z))); + } } From 93015151dbb068972b3a4ee27ab8e5aac60ff408 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:29:02 -0400 Subject: [PATCH 255/283] Add Hat skin data --- .../src/mineplex/core/common/skin/SkinData.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index f803154ce..6b7b7a675 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -78,6 +78,8 @@ public class SkinData public static final SkinData LARISSA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjE0MTUxMzQsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jYThjNDRhOWVmZTY3NzExMDYzMjM5ODEwNDRmOTdjYmM1OWJmZmRlOGI1ODdlMGQzMWE4N2ViMDhhMmExZiJ9fX0=", "Lyac51CrnMK/CI2dWgGQLowAm/ZnQMpf0Ict/gqVrUgJVlGWDIVG77Rd1JyMQDEeESvTmoyivH+usiO0ePW95qjisqT3R43YEmLi85CqctGYqLKeSYpGYwYRz8Euw57LwJAALKOMLhVc2s4h2Or9nTecunG8KSmkCuZc4H1qh3frU+ltuV4HLqgdFUULbIHTggyvqiINov2tBqkkXeEjT7sOcTJCJNgNYU2O7//qg5kJmhso2CKHlRLpmy9LsaUK/Z+BzUmoRbwQgSwr3mz7dFAdlVWWKvKNcgX3nt1et0DIig3JKYmrnQX2Fprg+kWcr3nuizzLgjVwAlADC48P3DN0s/VBty2AYoWie16VNPIM+CV4BF2JRQ34GxZ8XceXbCKURrOjoCBgLGHvIhRW35eicoh26xp3/mwLvk5anPi5StJ/qEuzWJALeWcNbLsnt21m2MZp9h/MxaY6ftWOTzjTr5CYVd/teJyscMnGK4+lcV1dlt12lhbDMv6I+iz8iG9NIzuW5OvGkax90dA/Gq+Cd9FXVThPY4ufxWttHcTqgPB64GfMn6rywRm1B0eO1pJpYc/KlJZlW/PuaO8L1assyJs5KkOypBSy3zc6TO6pzgeOZv+VpQfA/UWpogv6ofmTpgdtwpjLFGSzIKTDXvF6FftALKVlYypG0fYbssA="); public static final SkinData ROWENA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0Njk1MTcxOTgsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jNDY1OGExODY4YzNhNjhhZWVhZmZkOTUxZDQyYmZkN2QxYTRjNGZjNDJjZDI2YTlmYzhkNTNmOTkxMTM1ZCJ9fX0=", "OqXMyH9SMmQ/Pwmb21In29YnCxbsN6yqUxfudN6KNgDwRUK6y072XhW6TIoTh9JQLAUKftpeVB53tk0LxHIxnsuBMrIHvETPDQFysIc/6xq3ABogs+zqFzcp5jk6S73HiD78JxLq5pzfUzhgDPMPuZP5Q/u2q1rYbe6B9lVEJ5sUcxBLUTossgucoR4qXYAlWVQdHRhq85Ol8a+OU7ruw3HackNGto6wt6u2MigCtiHVTt9XhJ/AJE4ScodQ3XwW4L6urpl/lV2OMCsr3mCjjjEz2EMhDbCWxrAorQ9aPpMbDkHBS+4TC1tbMGUlKhj5n+EZBYVaeLr4NGPACPSdT35p/2Zra49+DXn9Xn+681yNEB0ghTdsnsgwXg76+HVPHPqRHQMuTBQGQyGZaaTX/zE0tFjH+osMElLdb8dmz3dC7kQA4A13B2phj3YbMSF1FoU4GvnPKIQn6JIuEd6hd+pRLUW7Y+mgYIHHX1FT0ihrXAyVO6lQQ6rs92gSQr7sxC7tnhPSMFcmh7OcJYcbRpn97GMubthPLanOhVy7CKqjmwIkEVtYgP28idigKwNJ+sJuUONrOu7nMKl1UTD5EEapOacc/np6UhdSw8yW+LnWD/x9ueYz9ksnyRrJgcOa41izo/WCbjPK/j3JVezr9Q3x1yveWuFmdl7CGYdXngw="); public static final SkinData BIFF = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjEzMDQzNjYsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9mOWMyMTE3ZDY0ZWE0ZmUxMWZiY2NhZmE2YzU5YzhlZjY3NDVkZjVkMTZjM2QwMmI4NmI2OTlmZWJjNTA0OGI1In19fQ==", "mJMpEvQ4A02z0S/chgLm5bKrrrd+zmp7A0012AB7b3KlyIHoLKEDDz+ZJgJtvN6skOqed3P+yNVqkxitugXaZZP8Af9J+/TseHn+vOy6CTK5tykRSY3Zb8Zmw1kn36v/SARAVtDIHD53yuPgJayYSAbVB7aknj1Q8XBQGUmZRMRxWWxeD7rQTOwgRYI4YJeKFf4UL9i6zxvOJuHsOAouJ7scu7VohG8vgR77Js/Z8rSu8/aSG+O9AQdzP6h9ixYNFkkQOHm7DseK/5tsWKHM4FYBgjIDKt3ApQokSbhThzGB55BA1qjXZkfCoOb13y1nOMC8WoIL6Ees1qzxG3VloGx2WAZLh+Q+/irwrFDMxk1zeU5fIRuj1c/UIM2HKdxxWgoRdrZ8ww/Jrll6maiOBx7geMn/0aOUbJ2U7gkTif6RG6YNS5YN9ZQDLh72l/akJMxF3SlmuAPmLs2kBghQ6eD2YQKuxWR/Hf1yS1YXtogFVNsGnzC1nda7F48EGL3zI+kCajbDlAGQ32aRt0btbEQ+Gj575kir3Aa53qiZ0YOIYQlhgZdOsTN2NE2s8uuy/15Rgc6K3ydgEmSZfdqyMyW0Dy7pE5TfVL8DumKRVRXdOceT5WfnW7MyqSmdorP5ab1fw2wLOnAVzhJmW8oXXNSs77WJ1/PURclxOWB4IF8="); + public static final SkinData CANADA_HAT = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg2MDE5MDYwNzYsInByb2ZpbGVJZCI6IjdkYTJhYjNhOTNjYTQ4ZWU4MzA0OGFmYzNiODBlNjhlIiwicHJvZmlsZU5hbWUiOiJHb2xkYXBmZWwiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2M2MTExNTNmODdmMjZjMzRmOTdkODIxM2ZmOTk1ZGJlNjcyZWJkNGM0NjRkNGFkNzM5MWFlNDNjMWU3YTllIn19fQ", "QMw6e1FXl/Xrt+BbfPKsz3OHyOxL9CEPffS9grxRLD6gbLbMD84OT3+bge5V9lBFn9PPnTyID+WTF24qHj4ADTTgK94ykNedCEO6R1wS0FZKPI1UjwOxMhIG5ZeVr7+HxITgGU4Xz94IigBkvW//f2ZGelMvS0GLCrm4iCovEBMUzyYJ2dZ4xgzFSH6v+9efK4/SBAJaj8mHjXpDxU58/vskTGI3T9t5sWlZLXgId9vHcMj0GH3Un6yvUXiMkh38V/rAEM8/R8q08xUVyW0e2R38qWQV2+eKvsG8GmJmgkU/78wA9cKGZdrEz0pnr80eGNCbvXqQvC/czYhEhDapgxfndcHLX8q/Zk3I8msNr340E4ZrQL61Yl7KcVC1qEUQVu3cosq5A6ckXLGvv//HSwXVO8M9ThUbuEC8QjiS/fMFufnVa18lHrVulnfb/2KQ4yPsoCHK/zvGtRkWtD1sLOIfehN+sxCLiaz80ILBiwN0oHITfNHpJzoa4kF/OrxxCualp4Sv5o5TXBv7aWsO18v9ixb9o9CmJKKE8MUl5xmRVz4HQD4dyOfcwtPuxmfcYjJrxqBijdQMrcgLzqqMs+DUqcZZlxM7M5GaNUoEvL9tJNGpZaB2OrBw0DTk5wx15XfANCH4egx8X4+Iy2RUoFthHX3BsVazG7fjSiDnUtI="); + public static final SkinData AMERICA_HAT = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg2MDI3MjMyODgsInByb2ZpbGVJZCI6IjNlMjZiMDk3MWFjZDRjNmQ5MzVjNmFkYjE1YjYyMDNhIiwicHJvZmlsZU5hbWUiOiJOYWhlbGUiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzYzMjI0MDhkYzBiZjMxNjU4N2RiNDJiN2Q5ZmViZTUwYWQ4MGY0OGU4Njc5YzI0NTFkOTk3MTdjZmVjNTdkYWQifX19","oRo6DIuhOTaXDkFsgwJ488LWqx5d1QpwtglwG1SdEvkbX1aCMGdZyDm9YIopQRjfBg0uYKQFetOZ1ZkdMmc/aKC5/dm0+Ema7g8AUzjwf4OaSLH1r4C1UJ4ruaNG5diBxNTkYnMa7yT8zvyEr22CA7lUOIgTh8ymBfSGK35RPhsn8jM0hDjdhjemBAlxKpiioByfmAQbwokNBOrXfh/PnKq+iJYg4WpMSZ1zo5Rr0CzLXwu+/T3dvrb6mg7qry7J3Lj5/qn6iIdBcjJBeyvy1sCo45jQ3Rzc6oL/84Vu5Dpn395EqUK8Sa7mdpVpATTcj56TCjkNNtDapXNqyO/IIQuzU4wnBKNQmZefaxRl6LV0DhZ8n8YQaPj6hH/mr2oDsd23+jejjqu6Y95ReTyukp06mIGqgekmrdZV2etML2oMAOTv9ieVvqtfo5gEomYs+NFAL7rMmzjAlhd17VOgqNRMpmJazAHWOYKl8KdOH99wGDe5XcyKHysh+qyHKMvhPJztIeAEaosynF/aGHghH2PM354KCuUVNmdR5G7UZUoG9ZA5ZU3EzZ854jeqxcqw3jzb6qL7A83QNuFqOsb87ugL/jO3QEDdQ9drdf3WAQauQGkU3nYBrls5wxoMrQ+Ceth+FtZw9a1v7dc+DEWOeJKCtOAIskb29pv6OcRe0Wk="); // Comments this out for now, so it doesn't load the player profile // A better way to do this would check for the properties when getting the skull or the skin From 39f11da63444935d7c6d83fd473fef07935a1b3d Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:30:29 -0400 Subject: [PATCH 256/283] Create flag gadget type --- .../core/common/util/banner/CountryFlag.java | 57 +++++++++-- .../cosmetic/ui/button/open/OpenFlags.java | 25 +++++ .../core/cosmetic/ui/page/FlagPage.java | 62 ++++++++++++ .../core/cosmetic/ui/page/GadgetPage.java | 15 ++- .../mineplex/core/cosmetic/ui/page/Menu.java | 84 +++++++++++----- .../core/gadget/types/FlagGadget.java | 95 +++++++++++++++++++ .../core/gadget/types/GadgetType.java | 3 +- 7 files changed, 302 insertions(+), 39 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java index d4e48144f..54626d736 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java @@ -1,17 +1,30 @@ package mineplex.core.common.util.banner; import org.bukkit.DyeColor; +import org.bukkit.Material; import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.PatternType; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; + +import static org.bukkit.DyeColor.*; +import static org.bukkit.block.banner.PatternType.*; public enum CountryFlag { + // Vetted + MINEPLEX("Mineplex", "Mineplexian", BLACK, new Pattern(ORANGE, TRIANGLE_TOP), new Pattern(BLACK, TRIANGLES_TOP), + new Pattern(ORANGE, STRIPE_LEFT), new Pattern(ORANGE, STRIPE_RIGHT), new Pattern(BLACK, BORDER), + new Pattern(BLACK, STRIPE_BOTTOM)), + USA("The United States of America", "American", RED, new Pattern(WHITE, STRIPE_SMALL), new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(BLUE, SQUARE_TOP_RIGHT), new Pattern(BLUE, SQUARE_TOP_RIGHT)), + + CANADA("Canada", "Canadian", WHITE, new Pattern(RED, CROSS), new Pattern(WHITE, STRIPE_LEFT), new Pattern(RED, STRIPE_MIDDLE), + new Pattern(WHITE, BORDER), new Pattern(RED, STRIPE_TOP), new Pattern(RED, STRIPE_BOTTOM)), + + // Not Vetted BRAZIL(DyeColor.GREEN, new Pattern(DyeColor.YELLOW, PatternType.RHOMBUS_MIDDLE), new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)), - USA(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.BLUE, PatternType.SQUARE_TOP_RIGHT)), - CANADA(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM), - new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)), UK(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNLEFT), new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNRIGHT), new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.CROSS)), IRELAND(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.STRIPE_TOP), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_BOTTOM)), @@ -54,17 +67,47 @@ public enum CountryFlag new Pattern(DyeColor.GREEN, PatternType.STRIPE_CENTER), new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_BOTTOM)), POLAND(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.HALF_VERTICAL_MIRROR)); - private DyeColor _baseColor; - private Pattern[] _patterns; + private final String _country; + private final String _adjective; + private final DyeColor _baseColor; + private final Pattern[] _patterns; - CountryFlag(DyeColor baseColor, Pattern... patterns){ + CountryFlag(String country, String adjective, DyeColor baseColor, Pattern... patterns) + { + _country = country; + _adjective = adjective; _baseColor = baseColor; _patterns = patterns; } + CountryFlag(DyeColor baseColor, Pattern... patterns) + { + this("", "", baseColor, patterns); + } + public ItemStack getBanner() { - return UtilBanner.createBanner(_baseColor, _patterns); + ItemStack banner = new ItemStack(Material.BANNER); + BannerMeta bannerMeta = (BannerMeta) banner.getItemMeta(); + bannerMeta.setBaseColor(_baseColor); + + for (Pattern pattern : _patterns) + { + bannerMeta.addPattern(pattern); + } + + banner.setItemMeta(bannerMeta); + return banner; + } + + public String getCountryName() + { + return _country; + } + + public String getCountryAdjective() + { + return _adjective; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java new file mode 100644 index 000000000..987d549ac --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java @@ -0,0 +1,25 @@ +package mineplex.core.cosmetic.ui.button.open; + +import mineplex.core.cosmetic.ui.page.FlagPage; +import mineplex.core.cosmetic.ui.page.HatPage; +import mineplex.core.cosmetic.ui.page.Menu; +import mineplex.core.gadget.types.Gadget; +import org.bukkit.entity.Player; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class OpenFlags extends OpenPageButton +{ + public OpenFlags(Menu menu, Gadget active) + { + super(menu, active); + } + + @Override + protected void leftClick(Player player) + { + getMenu().getShop().openPageForPlayer(player, new FlagPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(), "Flags", player)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java new file mode 100644 index 000000000..1a2b98635 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java @@ -0,0 +1,62 @@ +package mineplex.core.cosmetic.ui.page; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import java.util.List; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class FlagPage extends GadgetPage +{ + public FlagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, + Player player) + { + super(plugin, shop, clientManager, donationManager, name, player); + } + + @Override + protected void buildPage() + { + int slot = 10; + + List list = getPlugin().getGadgetManager().getGadgets(GadgetType.FLAG); + if(list != null) + for (Gadget gadget : list) + { + addGadget(gadget, slot); + + if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.FLAG) == gadget) + { + addGlow(slot); + } + + slot++; + + if (slot % 9 == 8) + { + slot += 2; + } + } + + addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + { + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index 657d98b30..12523a911 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -8,6 +8,7 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; +import mineplex.core.gadget.types.FlagGadget; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -60,12 +61,16 @@ public class GadgetPage extends ShopPageBase addGadget(gadget, slot); if (getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.getDisplayName()) > 0) + { addGlow(slot); + } slot++; - if (slot == 17 || slot == 26) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() @@ -366,7 +371,7 @@ public class GadgetPage extends ShopPageBase meta.setLore(itemLore); gadgetItemStack.setItemMeta(meta); - if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH + /*if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) { if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) @@ -377,7 +382,7 @@ public class GadgetPage extends ShopPageBase bannerMeta.setLore(meta.getLore()); gadgetItemStack.setItemMeta(bannerMeta); } - } + }*/ addButton(slot, new ShopItem(gadgetItemStack, false, false).hideInfo(), new DeactivateGadgetButton(gadget, this)); } @@ -389,7 +394,7 @@ public class GadgetPage extends ShopPageBase meta.setLore(itemLore); gadgetItemStack.setItemMeta(meta); - if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH + /*if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) { if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) @@ -400,7 +405,7 @@ public class GadgetPage extends ShopPageBase bannerMeta.setLore(meta.getLore()); gadgetItemStack.setItemMeta(bannerMeta); } - } + }*/ /*if (gadget instanceof MorphStray) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 8a27df36e..084025a09 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -1,11 +1,17 @@ package mineplex.core.cosmetic.ui.page; import java.util.ArrayList; +import java.util.Arrays; import java.util.EnumMap; import java.util.List; import java.util.Map; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.cosmetic.ui.button.open.OpenFlags; +import mineplex.core.itemstack.ItemBuilder; +import org.bukkit.DyeColor; import org.bukkit.Material; +import org.bukkit.block.Banner; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -40,6 +46,10 @@ import mineplex.core.mount.Mount; import mineplex.core.pet.PetType; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.inventory.meta.ItemMeta; public class Menu extends ShopPageBase { @@ -64,35 +74,46 @@ public class Menu extends ShopPageBase List shardLore = new ArrayList(); shardLore.add(" "); - shardLore.add(C.cGray + "This seems like it might come in"); - shardLore.add(C.cGray + "handy. Maybe I can collect more!"); + shardLore.add(C.cGray + "These seem like they might come in"); + shardLore.add(C.cGray + "handy. Maybe I should collect more!"); ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false); - // Cosmetic Items - int[] slots = UtilUI.getIndicesFor(15, 0, 5, 1); - /*int particleSlot = 9;//slots[0]; - int arrowSlot = 11;//slots[1]; - int jumpSlot = 13;//slots[2]; - int deathSlot = 15;//slots[3]; - int gadgetSlot = 27;//slots[4]; - int morphSlot = 29;//slots[5]; - int mountSlot = 31;//slots[6]; - int petSlot = 33;//slots[7]; - int hatSlot = 35;//slots[8]; - int costumeSlot = 45;//slots[9]; - int musicSlot = 47;//slots[10]; - int tauntSlot = 49;//slots[11]; - int winEffectSlot = 51; - int gameModifierSlot = 53;*/ - int particleSlot = slots[0], arrowSlot = slots[1], jumpSlot = slots[2], - deathSlot = slots[3], gadgetSlot = slots[4], morphSlot = slots[5], - mountSlot = slots[6], petSlot = slots[7], hatSlot = slots[8], - costumeSlot = slots[9], musicSlot = slots[10], tauntSlot = slots[11], - winEffectSlot = slots[12], gameModifierSlot = slots[13], balloonsSlot = slots[14], - kitSelectorSlot = balloonsSlot + 4; + int deathSlot = 1; + int jumpSlot = 28; + int particleSlot = 10; + int winEffectSlot = 13; + int shardSlot = 22; + int arrowSlot = 19; + int tauntSlot = 31; + int gameModifierSlot = 21; + int kitSelectorSlot = 23; + int musicSlot = 48; + int mountSlot = 50; + int balloonsSlot = 47; + int petSlot = 51; + int gadgetSlot = 49; + int hatSlot = 7; + int flagSlot = 34; + int morphSlot = 25; + int costumeSlot = 16; + + addItem(shardSlot, shards); + + ItemStack pane = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((byte)15).setTitle("").build(); + for (int i = 0; i <= 45; i += 9) addItem(i, pane.clone()); + for (int i = 8; i <= 53; i += 9) addItem(i, pane.clone()); + for (int i = 37; i <= 43; ++i) addItem(i, pane.clone()); + for (int i = 2; i <= 6; ++i) addItem(i, pane.clone()); + for (int i = 11; i <= 29; i += 9) addItem(i, pane.clone()); + for (int i = 15; i <= 33; i += 9) addItem(i, pane.clone()); + addItem(12, pane.clone()); + addItem(14, pane.clone()); + addItem(30, pane.clone()); + addItem(32, pane.clone()); + addItem(46, pane.clone()); + addItem(52, pane.clone()); - addItem(kitSelectorSlot + 2, shards); EnumMap ownedCount = new EnumMap<>(GadgetType.class); EnumMap maxCount = new EnumMap<>(GadgetType.class); @@ -187,7 +208,7 @@ public class Menu extends ShopPageBase if (petActive != null) addGlow(petSlot); type = GadgetType.HAT; - lore = getLore(ownedCount.get(type), maxCount.get(type), "Hats are in this year. Wear them on your head to impress the ladies.", VISIBILITY_HUB, enabled.get(type)); + lore = getLore(ownedCount.get(type), maxCount.get(type), "Hats are in this year. Wear them on your head to impress the others.", VISIBILITY_HUB, enabled.get(type)); addButton(hatSlot, new ShopItem(Material.GOLD_HELMET, "Hats", lore, 1, false), new OpenHats(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(hatSlot); @@ -227,6 +248,17 @@ public class Menu extends ShopPageBase lore = getLore(ownedCount.get(type), maxCount.get(type), "Click here to select different particles to indicate which kit you have selected!", VISIBILITY_GAME_HUB, enabled.get(type)); addButton(kitSelectorSlot, new ShopItem(Material.LEVER, "Kit Selector Particles", lore, 1, false), new OpenKitSelector(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(kitSelectorSlot); + + type = GadgetType.FLAG; + lore = getLore(ownedCount.get(type), maxCount.get(type), "Show off your country's flag!", VISIBILITY_HUB, enabled.get(type)); + addButton(flagSlot, new ShopItem(Material.BANNER, "Flags", lore, 1, false), new OpenFlags(this, enabled.get(type))); + if (enabled.containsKey(type)) addGlow(flagSlot); + BannerMeta banner = (BannerMeta) CountryFlag.MINEPLEX.getBanner().getItemMeta(); + BannerMeta meta = ((BannerMeta) getItem(flagSlot).getItemMeta()); + meta.setBaseColor(banner.getBaseColor()); + meta.setPatterns(banner.getPatterns()); + meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); + getItem(flagSlot).setItemMeta(meta); } private String[] getLore(int ownedCount, int maxCount, String info, String visibility, Gadget enabled) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java new file mode 100644 index 000000000..d28b45a17 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java @@ -0,0 +1,95 @@ +package mineplex.core.gadget.types; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.disguise.disguises.DisguiseSkeleton; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.flag.FlagType; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.itemstack.ItemBuilder; +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.LeatherArmorMeta; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class FlagGadget extends Gadget +{ + private final FlagType _flag; + + public FlagGadget(GadgetManager manager, FlagType flag) + { + super(manager, GadgetType.FLAG, flag.getFlag().getCountryAdjective() + " Flag", + UtilText.splitLineToArray(C.cGray + "The flag of " + C.cWhite + flag.getFlag().getCountryName(), LineFormat.LORE), + flag.getCost(), Material.WOOL, (byte) 0); + + setDisplayItem(flag.getFlag().getBanner()); + _flag = flag; + } + + public void applyArmor(Player player, boolean message) + { + Manager.removeGadgetType(player, GadgetType.MORPH, this); + Manager.removeGadgetType(player, GadgetType.FLAG, this); + Manager.removeOutfit(player, OutfitGadget.ArmorSlot.HELMET); + + _active.add(player); + + if (message) + { + UtilPlayer.message(player, F.main("Gadget", "You unfurled your " + F.elem(getName()) + ".")); + } + } + + public void removeArmor(Player player) + { + if (_active.remove(player)) + { + UtilPlayer.message(player, F.main("Gadget", "You put away your " + F.elem(getName()) + ".")); + } + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + ItemStack flag = _flag.getFlag().getBanner(); + ItemMeta meta = flag.getItemMeta(); + meta.setDisplayName(getDisplayName()); + flag.setItemMeta(meta); + player.getInventory().setHelmet(flag); + player.updateInventory(); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + player.getInventory().setHelmet(new ItemStack(Material.AIR)); + player.updateInventory(); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void playerDeath(PlayerDeathEvent event) + { + disable(event.getEntity()); + } + + public FlagType getFlagType() + { + return _flag; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java index edc823e6d..386f764a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java @@ -18,7 +18,8 @@ public enum GadgetType WIN_EFFECT("Win Effects", "activeWinEffect"), GAME_MODIFIER("Game Modifiers", ""), BALLOON("Balloons", ""), - KIT_SELECTOR("Kit Selectors", "activeKitSelector"); + KIT_SELECTOR("Kit Selectors", "activeKitSelector"), + FLAG("Flags", "activeFlag"); private String _name; private String _databaseKey; From c15e8f8f90d6b335200d675249613c88a437eae8 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:30:56 -0400 Subject: [PATCH 257/283] Allow UtilParticle to accept java awt colors --- .../core/common/util/UtilParticle.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java index a87bb2565..cc58f5d0d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java @@ -418,4 +418,22 @@ public class UtilParticle PlayParticleToAll(particleType, location, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1f, count, dist); } + public static void playColoredParticle(java.awt.Color color, ParticleType particleType, Location location, int count, ViewDist dist, Player... players) + { + if (particleType != ParticleType.RED_DUST + && particleType != ParticleType.MOB_SPELL_AMBIENT) + return; + PlayParticle(particleType, location, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1f, count, dist, players); + } + + public static void playColoredParticleToAll(java.awt.Color color, ParticleType particleType, Location location, int count, ViewDist dist) + { + if (particleType != ParticleType.RED_DUST && particleType != ParticleType.MOB_SPELL_AMBIENT) + { + return; + } + + PlayParticleToAll(particleType, location, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1f, count, dist); + } + } \ No newline at end of file From 53d29fc9c9104be3697d0d4b1e1957c046377274 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:31:54 -0400 Subject: [PATCH 258/283] Reduce lag on Molten Snake --- .../src/mineplex/core/mount/types/MountTitanData.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java index 137ae9bbe..ff998efee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java @@ -39,7 +39,7 @@ public class MountTitanData extends MountData //Nodes _nodes = new ArrayList(); - for (int i=0 ; i<30 ; i++) + for (int i=0 ; i<20 ; i++) { ArmorStand node = loc.getWorld().spawn(loc, ArmorStand.class); @@ -81,7 +81,7 @@ public class MountTitanData extends MountData Location infront = _head.getLocation().add(0, -1.5, 0); //Move - for (int i=0 ; i<30 ; i++) + for (int i=0 ; i<20 ; i++) { ArmorStand node = _nodes.get(i); From 4ef477159c5c855aa42452af6d458c8b9cd82bbc Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:33:03 -0400 Subject: [PATCH 259/283] Fix gadget pages --- .../core/cosmetic/ui/page/ArrowTrailPage.java | 10 +++++++--- .../core/cosmetic/ui/page/BalloonsPage.java | 6 +++++- .../core/cosmetic/ui/page/DeathEffectPage.java | 10 +++++++--- .../core/cosmetic/ui/page/DoubleJumpPage.java | 12 ++++++++---- .../src/mineplex/core/cosmetic/ui/page/HatPage.java | 12 ++++++++---- .../core/cosmetic/ui/page/KitSelectorPage.java | 6 +++++- .../mineplex/core/cosmetic/ui/page/MorphPage.java | 12 +++++++++--- .../mineplex/core/cosmetic/ui/page/MountPage.java | 4 +++- .../mineplex/core/cosmetic/ui/page/MusicPage.java | 4 +++- .../core/cosmetic/ui/page/ParticlePage.java | 12 ++++++++---- .../src/mineplex/core/cosmetic/ui/page/PetPage.java | 13 ++++++++++--- .../mineplex/core/cosmetic/ui/page/TauntPage.java | 12 ++++++++---- .../core/cosmetic/ui/page/WinEffectPage.java | 12 ++++++++---- .../ui/page/custompet/name/CustomPetTagPage.java | 6 ++++++ 14 files changed, 95 insertions(+), 36 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java index 80db4bcd6..e4d1333f9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java @@ -33,12 +33,16 @@ public class ArrowTrailPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.ARROW_TRAIL) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - if (slot == 17) - slot += 2; + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java index fd0b3cf08..3208e5a05 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java @@ -32,12 +32,16 @@ public class BalloonsPage extends GadgetPage addGadget(gadget, slot); if (gadget.isActive(getPlayer())) + { addGlow(slot); + } slot++; - if (slot == 17 || slot == 26) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java index 07dbee136..a54b7f840 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java @@ -33,12 +33,16 @@ public class DeathEffectPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.DEATH) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - if (slot == 17) - slot += 2; + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java index f9748cb06..8ecddc541 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java @@ -33,12 +33,16 @@ public class DoubleJumpPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.DOUBLE_JUMP) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 17) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java index 37f472616..a21f31cea 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java @@ -38,12 +38,16 @@ public class HatPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.HAT) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 17) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java index 26b399783..6ce7f5ebd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java @@ -31,12 +31,16 @@ public class KitSelectorPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.KIT_SELECTOR) == gadget) + { addGlow(slot); + } slot++; - if (slot == 17 || slot == 26 || slot == 35) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java index 682140891..0689b3f07 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java @@ -32,13 +32,19 @@ public class MorphPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.MORPH) == gadget) - if (!(gadget instanceof MorphBlock)) - addGlow(slot); + { + if (!(gadget instanceof MorphBlock)) + { + addGlow(slot); + } + } slot++; - if (slot == 17 || slot == 26 || slot == 35) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java index 6e670effc..0c2b2cd60 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java @@ -46,8 +46,10 @@ public class MountPage extends ShopPageBase addMount(mount, slot); slot++; - if (slot == 17 || slot == 26) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java index 54ff244d7..97f32d027 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java @@ -34,8 +34,10 @@ public class MusicPage extends GadgetPage slot++; - if (slot == 17) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java index a488c922c..168741d0a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java @@ -31,12 +31,16 @@ public class ParticlePage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.PARTICLE) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 17 || slot == 26 || slot == 35) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index e7bf684cb..264f73dbe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java @@ -231,16 +231,23 @@ public class PetPage extends ShopPageBase slot++; - if (slot == 17 || slot == 26) + if (slot % 9 == 8) + { slot += 2; + } } slot = 49; for (PetExtra petExtra : PetExtra.values()) { List itemLore = new ArrayList(); - - if (!getPlugin().getPetManager().hasActivePet(getPlayer().getName())) + + if (getPlugin().getPunishManager().GetClient(_player.getName()).IsMuted()) + { + itemLore.add(C.cRed + "You may not rename pets while muted!"); + getInventory().setItem(slot, new ShopItem(petExtra.getMaterial(), (byte)0, C.cRed + petExtra.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); + } + else if (!getPlugin().getPetManager().hasActivePet(getPlayer().getName())) { itemLore.add(C.cWhite + "You must have an active pet to use this!"); getInventory().setItem(slot, new ShopItem(petExtra.getMaterial(), (byte)0, C.cRed + petExtra.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java index 687516e0f..63ef90b24 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java @@ -38,12 +38,16 @@ public class TauntPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.TAUNT) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 26) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java index cc116cbac..e66674be4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java @@ -49,12 +49,16 @@ public class WinEffectPage extends GadgetPage } if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.WIN_EFFECT) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 17 || slot == 26) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java index 774ecf2d0..2350f8eba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java @@ -1,9 +1,14 @@ package mineplex.core.cosmetic.ui.page.custompet.name; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilItem; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.punish.PunishClient; import net.minecraft.server.v1_8_R3.ItemStack; import net.minecraft.server.v1_8_R3.Items; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; @@ -34,6 +39,7 @@ public class CustomPetTagPage extends ShopPageBase Date: Wed, 28 Jun 2017 01:34:51 -0400 Subject: [PATCH 260/283] Reorganize packages --- .../core/gadget/commands/LockInfusedCommand.java | 12 ++++++------ .../arrowtrail/{vampire => }/ArrowTrailBlood.java | 2 +- .../{candycane => }/ArrowTrailCandyCane.java | 2 +- .../arrowtrail/{party => }/ArrowTrailConfetti.java | 2 +- .../arrowtrail/{cupidslove => }/ArrowTrailCupid.java | 2 +- .../arrowtrail/{emerald => }/ArrowTrailEmerald.java | 2 +- .../arrowtrail/{wisdom => }/ArrowTrailEnchant.java | 2 +- .../arrowtrail/{freedom => }/ArrowTrailFreedom.java | 2 +- .../{frostlord => }/ArrowTrailFrostLord.java | 2 +- .../{halloween => }/ArrowTrailHalloween.java | 2 +- .../arrowtrail/{music => }/ArrowTrailMusic.java | 2 +- .../arrowtrail/{shadow => }/ArrowTrailShadow.java | 2 +- .../arrowtrail/{spring => }/ArrowTrailSpring.java | 2 +- .../{howlingwinds => }/ArrowTrailStorm.java | 2 +- .../arrowtrail/{titan => }/ArrowTrailTitan.java | 2 +- .../gadgets/death/{vampire => }/DeathBlood.java | 2 +- .../death/{candycane => }/DeathCandyCane.java | 2 +- .../{cupidslove => }/DeathCupidsBrokenHeart.java | 2 +- .../gadgets/death/{emerald => }/DeathEmerald.java | 2 +- .../gadgets/death/{wisdom => }/DeathEnchant.java | 2 +- .../gadgets/death/{freedom => }/DeathFreedom.java | 2 +- .../death/{frostlord => }/DeathFrostLord.java | 2 +- .../gadget/gadgets/death/{music => }/DeathMusic.java | 2 +- .../gadgets/death/{party => }/DeathPinataBurst.java | 2 +- .../death/{christmas => }/DeathPresentDanger.java | 2 +- .../gadgets/death/{shadow => }/DeathShadow.java | 2 +- .../gadgets/death/{spring => }/DeathSpring.java | 2 +- .../gadgets/death/{howlingwinds => }/DeathStorm.java | 2 +- .../gadget/gadgets/death/{titan => }/DeathTitan.java | 2 +- .../doublejump/{vampire => }/DoubleJumpBlood.java | 2 +- .../{candycane => }/DoubleJumpCandyCane.java | 2 +- .../{cupidslove => }/DoubleJumpCupidsWings.java | 2 +- .../doublejump/{emerald => }/DoubleJumpEmerald.java | 2 +- .../doublejump/{wisdom => }/DoubleJumpEnchant.java | 2 +- .../{party => }/DoubleJumpFirecracker.java | 2 +- .../doublejump/{freedom => }/DoubleJumpFreedom.java | 4 ++-- .../{frostlord => }/DoubleJumpFrostLord.java | 2 +- .../{halloween => }/DoubleJumpHalloween.java | 2 +- .../doublejump/{music => }/DoubleJumpMusic.java | 2 +- .../doublejump/{shadow => }/DoubleJumpShadow.java | 2 +- .../doublejump/{spring => }/DoubleJumpSpring.java | 2 +- .../{howlingwinds => }/DoubleJumpStorm.java | 2 +- .../doublejump/{titan => }/DoubleJumpTitan.java | 2 +- .../src/mineplex/core/gadget/set/SetCandyCane.java | 6 +++--- .../src/mineplex/core/gadget/set/SetCupidsLove.java | 6 +++--- .../src/mineplex/core/gadget/set/SetEmerald.java | 6 +++--- .../src/mineplex/core/gadget/set/SetFreedom.java | 9 +++++---- .../src/mineplex/core/gadget/set/SetFrostLord.java | 6 +++--- .../mineplex/core/gadget/set/SetHowlingWinds.java | 6 +++--- .../src/mineplex/core/gadget/set/SetMusic.java | 6 +++--- .../src/mineplex/core/gadget/set/SetParty.java | 6 +++--- .../src/mineplex/core/gadget/set/SetShadow.java | 6 +++--- .../src/mineplex/core/gadget/set/SetSpring.java | 6 +++--- .../src/mineplex/core/gadget/set/SetTitan.java | 6 +++--- .../src/mineplex/core/gadget/set/SetVampire.java | 6 +++--- .../src/mineplex/core/gadget/set/SetWisdom.java | 6 +++--- 56 files changed, 90 insertions(+), 89 deletions(-) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{vampire => }/ArrowTrailBlood.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{candycane => }/ArrowTrailCandyCane.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{party => }/ArrowTrailConfetti.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{cupidslove => }/ArrowTrailCupid.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{emerald => }/ArrowTrailEmerald.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{wisdom => }/ArrowTrailEnchant.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{freedom => }/ArrowTrailFreedom.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{frostlord => }/ArrowTrailFrostLord.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{halloween => }/ArrowTrailHalloween.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{music => }/ArrowTrailMusic.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{shadow => }/ArrowTrailShadow.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{spring => }/ArrowTrailSpring.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{howlingwinds => }/ArrowTrailStorm.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{titan => }/ArrowTrailTitan.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{vampire => }/DeathBlood.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{candycane => }/DeathCandyCane.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{cupidslove => }/DeathCupidsBrokenHeart.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{emerald => }/DeathEmerald.java (93%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{wisdom => }/DeathEnchant.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{freedom => }/DeathFreedom.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{frostlord => }/DeathFrostLord.java (93%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{music => }/DeathMusic.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{party => }/DeathPinataBurst.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{christmas => }/DeathPresentDanger.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{shadow => }/DeathShadow.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{spring => }/DeathSpring.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{howlingwinds => }/DeathStorm.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{titan => }/DeathTitan.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{vampire => }/DoubleJumpBlood.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{candycane => }/DoubleJumpCandyCane.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{cupidslove => }/DoubleJumpCupidsWings.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{emerald => }/DoubleJumpEmerald.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{wisdom => }/DoubleJumpEnchant.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{party => }/DoubleJumpFirecracker.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{freedom => }/DoubleJumpFreedom.java (92%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{frostlord => }/DoubleJumpFrostLord.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{halloween => }/DoubleJumpHalloween.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{music => }/DoubleJumpMusic.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{shadow => }/DoubleJumpShadow.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{spring => }/DoubleJumpSpring.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{howlingwinds => }/DoubleJumpStorm.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{titan => }/DoubleJumpTitan.java (96%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java index fef74b9fd..a91dcdb3e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java @@ -9,12 +9,12 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; -import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; -import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.death.DeathCandyCane; +import mineplex.core.gadget.gadgets.death.DeathFrostLord; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; import mineplex.core.gadget.gadgets.hat.HatType; import mineplex.core.gadget.gadgets.item.ItemCoal; import mineplex.core.gadget.gadgets.item.ItemFreezeCannon; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/vampire/ArrowTrailBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBlood.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/vampire/ArrowTrailBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBlood.java index f54c9ae92..180e336de 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/vampire/ArrowTrailBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.vampire; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java index d45b1b023..58cbee4d9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.candycane; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/party/ArrowTrailConfetti.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailConfetti.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/party/ArrowTrailConfetti.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailConfetti.java index d8f06ce45..be2cd9b90 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/party/ArrowTrailConfetti.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailConfetti.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.party; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCupid.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCupid.java index c10562f6d..4249c19c3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCupid.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.cupidslove; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Color; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/emerald/ArrowTrailEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEmerald.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/emerald/ArrowTrailEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEmerald.java index 8592bc16b..b7b8a6df2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/emerald/ArrowTrailEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.emerald; +package mineplex.core.gadget.gadgets.arrowtrail; import mineplex.core.common.util.*; import org.bukkit.Location; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/wisdom/ArrowTrailEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEnchant.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/wisdom/ArrowTrailEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEnchant.java index 00e47e049..b33723020 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/wisdom/ArrowTrailEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.wisdom; +package mineplex.core.gadget.gadgets.arrowtrail; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFreedom.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFreedom.java index 8921b26cc..fa5f7ade2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFreedom.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.freedom; +package mineplex.core.gadget.gadgets.arrowtrail; import java.awt.Color; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/frostlord/ArrowTrailFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/frostlord/ArrowTrailFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java index 6ae8d9b43..3a7c910b5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/frostlord/ArrowTrailFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.frostlord; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java index 112f272ad..bd5b62563 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.halloween; +package mineplex.core.gadget.gadgets.arrowtrail; import java.awt.Color; import java.util.HashMap; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/music/ArrowTrailMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailMusic.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/music/ArrowTrailMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailMusic.java index d535035af..6c6a3006e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/music/ArrowTrailMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.music; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/shadow/ArrowTrailShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailShadow.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/shadow/ArrowTrailShadow.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailShadow.java index aec688901..8db14cbdb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/shadow/ArrowTrailShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailShadow.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.shadow; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailSpring.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailSpring.java index c335ce062..59cb064c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailSpring.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.spring; +package mineplex.core.gadget.gadgets.arrowtrail; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/howlingwinds/ArrowTrailStorm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailStorm.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/howlingwinds/ArrowTrailStorm.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailStorm.java index a3cc14165..084611017 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/howlingwinds/ArrowTrailStorm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailStorm.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.howlingwinds; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java index 956055929..29c39b7d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.titan; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/vampire/DeathBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBlood.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/vampire/DeathBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBlood.java index 5365e3e14..7101aba36 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/vampire/DeathBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.vampire; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/candycane/DeathCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/candycane/DeathCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java index 45a7028d0..2d100b3fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/candycane/DeathCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.candycane; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/cupidslove/DeathCupidsBrokenHeart.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCupidsBrokenHeart.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/cupidslove/DeathCupidsBrokenHeart.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCupidsBrokenHeart.java index 1c92abc02..d0053f9df 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/cupidslove/DeathCupidsBrokenHeart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCupidsBrokenHeart.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.cupidslove; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/emerald/DeathEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEmerald.java similarity index 93% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/emerald/DeathEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEmerald.java index 79ea0b404..85fb2db18 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/emerald/DeathEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.emerald; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/wisdom/DeathEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEnchant.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/wisdom/DeathEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEnchant.java index 7229b155d..35532906d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/wisdom/DeathEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.wisdom; +package mineplex.core.gadget.gadgets.death; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/freedom/DeathFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFreedom.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/freedom/DeathFreedom.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFreedom.java index 24d43eb0b..137b68207 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/freedom/DeathFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFreedom.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.freedom; +package mineplex.core.gadget.gadgets.death; import org.bukkit.ChatColor; import org.bukkit.Location; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/frostlord/DeathFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFrostLord.java similarity index 93% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/frostlord/DeathFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFrostLord.java index 0ce7b546f..72cd2c3cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/frostlord/DeathFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.frostlord; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/music/DeathMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMusic.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/music/DeathMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMusic.java index 2bf566254..d6c4176ad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/music/DeathMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.music; +package mineplex.core.gadget.gadgets.death; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/party/DeathPinataBurst.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPinataBurst.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/party/DeathPinataBurst.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPinataBurst.java index 09ccfe10a..0adc3dfb8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/party/DeathPinataBurst.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPinataBurst.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.party; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/christmas/DeathPresentDanger.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPresentDanger.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/christmas/DeathPresentDanger.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPresentDanger.java index e8db5ed6a..c1b07ce33 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/christmas/DeathPresentDanger.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPresentDanger.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.christmas; +package mineplex.core.gadget.gadgets.death; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/shadow/DeathShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathShadow.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/shadow/DeathShadow.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathShadow.java index 3adb240f2..f80b4ad9b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/shadow/DeathShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathShadow.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.shadow; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathSpring.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathSpring.java index eb15f5986..bae34473b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathSpring.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.spring; +package mineplex.core.gadget.gadgets.death; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/howlingwinds/DeathStorm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathStorm.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/howlingwinds/DeathStorm.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathStorm.java index 00cf6d607..c3cf2f0da 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/howlingwinds/DeathStorm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathStorm.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.howlingwinds; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java index 00b64eace..0e56f8308 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.titan; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/vampire/DoubleJumpBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBlood.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/vampire/DoubleJumpBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBlood.java index 882133687..2f910416c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/vampire/DoubleJumpBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.vampire; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/candycane/DoubleJumpCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/candycane/DoubleJumpCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java index d6a7620c7..62f3ad6c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/candycane/DoubleJumpCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.candycane; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/cupidslove/DoubleJumpCupidsWings.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCupidsWings.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/cupidslove/DoubleJumpCupidsWings.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCupidsWings.java index 71a7b66b5..81884a52b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/cupidslove/DoubleJumpCupidsWings.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCupidsWings.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.cupidslove; +package mineplex.core.gadget.gadgets.doublejump; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/emerald/DoubleJumpEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEmerald.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/emerald/DoubleJumpEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEmerald.java index 0453e0b57..f74859c2c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/emerald/DoubleJumpEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.emerald; +package mineplex.core.gadget.gadgets.doublejump; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/wisdom/DoubleJumpEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEnchant.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/wisdom/DoubleJumpEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEnchant.java index ec1120f3b..d9d4db576 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/wisdom/DoubleJumpEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.wisdom; +package mineplex.core.gadget.gadgets.doublejump; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/party/DoubleJumpFirecracker.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFirecracker.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/party/DoubleJumpFirecracker.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFirecracker.java index 06ee124f7..65ce9bd80 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/party/DoubleJumpFirecracker.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFirecracker.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.party; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/freedom/DoubleJumpFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java similarity index 92% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/freedom/DoubleJumpFreedom.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java index 7f887e345..820ccd155 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/freedom/DoubleJumpFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.freedom; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -18,7 +18,7 @@ public class DoubleJumpFreedom extends DoubleJumpEffectGadget { super(manager, "Leap of Freedom", UtilText.splitLineToArray(UtilText.colorWords("FREEEEEEEEEEEDOM!", ChatColor.RED, ChatColor.WHITE, ChatColor.BLUE), LineFormat.LORE), -8, Material.WOOL, - (byte) 14); + (byte) 0); setDisplayItem(CountryFlag.USA.getBanner()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/frostlord/DoubleJumpFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFrostLord.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/frostlord/DoubleJumpFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFrostLord.java index 62325731c..64cc9f962 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/frostlord/DoubleJumpFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.frostlord; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java index 10155afbd..0f2cc13e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.halloween; +package mineplex.core.gadget.gadgets.doublejump; import java.awt.Color; import java.util.HashMap; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/music/DoubleJumpMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMusic.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/music/DoubleJumpMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMusic.java index 5b7459f0d..2a4d5c1ba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/music/DoubleJumpMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.music; +package mineplex.core.gadget.gadgets.doublejump; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/shadow/DoubleJumpShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpShadow.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/shadow/DoubleJumpShadow.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpShadow.java index 005c3403c..c64052bca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/shadow/DoubleJumpShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpShadow.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.shadow; +package mineplex.core.gadget.gadgets.doublejump; import mineplex.core.common.util.C; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java index 63dabdaf9..c4d06c230 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.spring; +package mineplex.core.gadget.gadgets.doublejump; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/howlingwinds/DoubleJumpStorm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpStorm.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/howlingwinds/DoubleJumpStorm.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpStorm.java index 6b04d1f00..9cd07ef15 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/howlingwinds/DoubleJumpStorm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpStorm.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.howlingwinds; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java index 336aaa5bc..9c81a3309 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.titan; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java index e6f6f5707..9a2d9ce75 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; -import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.death.DeathCandyCane; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java index ccbaf0863..47f1552f7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; -import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart; -import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; +import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java index b34a8f88e..740174dba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; -import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald; -import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.death.DeathEmerald; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java index 6196a145b..e8c300adf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java @@ -1,9 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; -import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; import mineplex.core.gadget.types.GadgetSet; @@ -16,7 +17,7 @@ public class SetFreedom extends GadgetSet manager.getGadget(ArrowTrailFreedom.class), manager.getGadget(DeathFreedom.class), manager.getGadget(DoubleJumpFreedom.class), - manager.getGadget(ParticleFreedom.class)); + manager.getGadget(ParticleStarSpangled.class)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java index 6112655a0..6050a0b00 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; -import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.death.DeathFrostLord; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java index 120a35c95..672f49bdc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; -import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; -import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; +import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java index 9e606f0e2..fdd47eacd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.death.music.DeathMusic; -import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; +import mineplex.core.gadget.gadgets.death.DeathMusic; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java index f9debaef0..0b99f9f2e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; -import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; -import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.death.DeathPinataBurst; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java index befc2e27c..1d5fad5dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; -import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; -import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; +import mineplex.core.gadget.gadgets.death.DeathShadow; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java index 77727b480..fb21b5f9e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; -import mineplex.core.gadget.gadgets.death.spring.DeathSpring; -import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.death.DeathSpring; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java index 7c66a8f6c..0d333818d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.titan.ArrowTrailTitan; -import mineplex.core.gadget.gadgets.death.titan.DeathTitan; -import mineplex.core.gadget.gadgets.doublejump.titan.DoubleJumpTitan; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan; +import mineplex.core.gadget.gadgets.death.DeathTitan; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan; import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java index b070122de..7ec9b7f7a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; -import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; +import mineplex.core.gadget.gadgets.death.DeathBlood; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java index 2d2ff0693..870b70d3f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; -import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; +import mineplex.core.gadget.gadgets.death.DeathEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; import mineplex.core.gadget.types.GadgetSet; From b214d43eec3db6feb23c176bfd452a236dca0f60 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:35:22 -0400 Subject: [PATCH 261/283] Update hat and flag type enums --- .../core/gadget/gadgets/flag/FlagType.java | 34 +++++++++++++++++++ .../core/gadget/gadgets/hat/HatType.java | 6 +++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java new file mode 100644 index 000000000..7e2c48e28 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java @@ -0,0 +1,34 @@ +package mineplex.core.gadget.gadgets.flag; + +import mineplex.core.common.util.banner.CountryFlag; + +/** + * @author J Teissler + * @date 6/27/17 + */ +public enum FlagType +{ + UNITED_STATES(CountryFlag.USA, -8), + CANADA(CountryFlag.CANADA, -8), + + ; + + private final CountryFlag _flag; + private final int _cost; + + FlagType(CountryFlag flag, int cost) + { + _flag = flag; + _cost = cost; + } + + public CountryFlag getFlag() + { + return _flag; + } + + public int getCost() + { + return _cost; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java index c6f623e20..cabad2568 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java @@ -22,7 +22,11 @@ public enum HatType SNOWMAN("Snowman Head", UtilText.splitLineToArray(C.cGray + "Do you want to be a snowman?", LineFormat.LORE), -2, SkinData.SNOWMAN), TEDDY_BEAR("Teddy Bear", UtilText.splitLineToArray(C.cGray + "Aww, it's a cute teddy bear! What shall I name him?", LineFormat.LORE), -6, SkinData.TEDDY_BEAR), UNCLE_SAM("Uncle Sam Hat", UtilText.splitLineToArray(UtilText.colorWords("Uncle Sam has a big hat but now you can too.", ChatColor.RED, ChatColor.WHITE, ChatColor.BLUE), LineFormat.LORE), -8, SkinData.UNCLE_SAM), - PUMPKIN("Pumpkin Hat", UtilText.splitLineToArray(C.cGray + "Pumpkin on the head, don't end up dead!", LineFormat.LORE), -9, Material.PUMPKIN); + PUMPKIN("Pumpkin Hat", UtilText.splitLineToArray(C.cGray + "Pumpkin on the head, don't end up dead!", LineFormat.LORE), -9, Material.PUMPKIN), + CANADA("Warm Canadian Hat", UtilText.splitLineToArray(C.cGray + "Keep your ears nice and warm while up north.", LineFormat.LORE), -8, SkinData.CANADA_HAT), + AMERICA("Patriotic American Hat", UtilText.splitLineToArray(C.cGray + "Careful not to get a big head.", LineFormat.LORE), -8, SkinData.AMERICA_HAT), + + ; private final String _name; private final String[] _lore; From e04d4678304e8437ec42f86cffb5b7d7cb2c8e35 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:35:57 -0400 Subject: [PATCH 262/283] Add new cosmetic items --- .../core/common/shape/ShapeWings.java | 35 +++- .../arrowtrail/ArrowTrailRedWhite.java | 78 ++++++++ .../gadget/gadgets/death/DeathMapleLeaf.java | 44 +++++ .../gadgets/doublejump/DoubleJumpMaple.java | 114 ++++++++++++ .../particle/ParticleAuraNiceness.java | 176 ++++++++++++++++++ .../gadgets/particle/ParticleCanadian.java | 68 +++++++ .../particle/ParticleFreedomFireworks.java | 57 ++++++ .../particle/ParticleStarSpangled.java | 80 ++++++++ .../mineplex/core/gadget/set/SetCanadian.java | 26 +++ 9 files changed, 677 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java index 3c9a78a56..4026dad3f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java @@ -166,7 +166,40 @@ public class ShapeWings extends ShapeGrid implements CosmeticShape "0$#######$0", "$#########$" }; - + + public static final String[] MAPLE_LEAF = new String[] + { + "000000000000000000000000000$000000000000000000000000000", + "00000000000000000000000000$$$00000000000000000000000000", + "0000000000000000000000000$$#$$0000000000000000000000000", + "000000000000000000000000$$###$$000000000000000000000000", + "00000000000000000000000$$#####$$00000000000000000000000", + "0000000000000000$$$000$$#######$$000$$$0000000000000000", + "0000000000000000$#$$$$$#########$$$$$#$0000000000000000", + "0000000000000000$$###################$$0000000000000000", + "00000000000000000$###################$00000000000000000", + "00000000000$$0000$$#################$$0000$$00000000000", + "0$$$000000$$$$$000$#################$000$$$$$000000$$$0", + "00$$$$$$$$$###$$$0$$###############$$0$$$###$$$$$$$$$00", + "00$$############$$$$###############$$$$############$$00", + "000$$#############$$###############$$#############$$000", + "0000$$###########################################$$0000", + "00$$$#############################################$$$00", + "$$$#################################################$$$", + "00$$$$###########################################$$$$00", + "00000$$$#######################################$$$00000", + "00000000$$$$###############################$$$$00000000", + "00000000000$$$###########################$$$00000000000", + "0000000000000$$#########################$$0000000000000", + "0000000000000$$#########################$$0000000000000", + "0000000000000$##$$$$$$$$$$$#$$$$$$$$$$$##$0000000000000", + "000000000000$$$$$000000000$#$000000000$$$$$000000000000", + "00000000000000000000000000$#$00000000000000000000000000", + "00000000000000000000000000$#$00000000000000000000000000", + "00000000000000000000000000$#$00000000000000000000000000", + "00000000000000000000000000$#$00000000000000000000000000", + "00000000000000000000000000$$$00000000000000000000000000" + }; /** * Default rotation to give the wings a little tilt when displayed on players for instance diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java new file mode 100644 index 000000000..e9a3c19e1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java @@ -0,0 +1,78 @@ +package mineplex.core.gadget.gadgets.arrowtrail; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ArrowEffectGadget; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.banner.Pattern; +import org.bukkit.entity.Arrow; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.util.Vector; + +import java.awt.*; + +public class ArrowTrailRedWhite extends ArrowEffectGadget +{ + public ArrowTrailRedWhite(GadgetManager manager) + { + super(manager, "Red & White Arrows", + UtilText.splitLineToArray(C.cRed + "Killing you nicely.", LineFormat.LORE), + -8, Material.WOOL, (byte)0); + + setDisplayItem(CountryFlag.CANADA.getBanner()); + } + + @Override + public void doTrail(Arrow arrow) + { + Vector v = arrow.getVelocity(); + Vector up = UtilAlg.getUp(v); + Vector left = UtilAlg.getLeft(v); + + Location loc = arrow.getLocation(); + + double amount = 2; + double ticks = 15; + + for(int i = 0; i < amount; i++) + { + double rad = Math.PI*2.0; + rad += i/amount * rad; + rad += Math.PI*2*(arrow.getTicksLived()%ticks)/ticks; + double l = -Math.sin(rad); + double u = Math.cos(rad); + + Vector vel = v.clone().add(up.clone().multiply(u)).add(left.clone().multiply(l)); + vel.multiply(0.4); + + if (i == 0) + { + for(int j = 0; j < 3; ++j) + { + UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, loc.clone().add(vel), 0, UtilParticle.ViewDist.NORMAL); + } + } + else + { + for(int j = 0; j < 3; ++j) + { + UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, loc.clone().add(vel), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + } + + @Override + public void doHitEffect(Arrow arrow) + { + //UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, arrow.getLocation(), 0.35f, 0.35f, 0.35f, 1f, 15, UtilParticle.ViewDist.LONGER); + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, arrow.getLocation(), 0, 0, 0, 0, 3, UtilParticle.ViewDist.LONGER); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java new file mode 100644 index 000000000..b1a0e9955 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java @@ -0,0 +1,44 @@ +package mineplex.core.gadget.gadgets.death; + +import mineplex.core.blood.BloodEvent; +import mineplex.core.common.shape.ShapeWings; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.DeathEffectGadget; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class DeathMapleLeaf extends DeathEffectGadget +{ + private final ShapeWings _leafOuter = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1.0, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); + private final ShapeWings _leafInner = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.7, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); + + public DeathMapleLeaf(GadgetManager manager) + { + super(manager, "Fallen Maple Leaf", + UtilText.splitLineToArray(C.cGray + "When you die in " + C.cRed + "Canada" + C.cGray + " you die in real life.", LineFormat.LORE), + -8, Material.WOOL, (byte) 0); + + setDisplayItem(CountryFlag.CANADA.getBanner()); + } + + @Override + public void onBlood(Player player, BloodEvent event) + { + event.setCancelled(true); + Location loc = player.getLocation().add(0, 3, 0); + _leafOuter.display(loc); + _leafInner.display(loc); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java new file mode 100644 index 000000000..1b1396463 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java @@ -0,0 +1,114 @@ +package mineplex.core.gadget.gadgets.doublejump; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.DoubleJumpEffectGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class DoubleJumpMaple extends DoubleJumpEffectGadget +{ + /** + * Amount of particles played per tick as a player flies through the air. + */ + private static final int PARTICLES = 50; + + /** + * Vertical offset of the animation's center from the player's location. + */ + private static final float Y_OFFSET = 0.95f; + + /** + * Divisor of the gaussian distribution of particles as the player flies through the air. + */ + private static final int DISTRIBUTION = 2; + + /** + * Particle ring count when a player launches from the ground. + */ + private static final int LAUNCH_RINGS = 6; + + /** + * The distance between launch rings. + */ + private static final float RING_SPACING = 0.4f; + + /** + * Particles played per 1 unit radius. + */ + private static final int RING_DENSITY = 8; + + private HashMap _playerMap = new HashMap<>(); + + public DoubleJumpMaple(GadgetManager manager) + { + super(manager, "Maple Leap", + UtilText.splitLineToArray(C.cGray + "Jump higher than the maple trees!", LineFormat.LORE), + -8, Material.WOOL, (byte)0); + setDisplayItem(CountryFlag.CANADA.getBanner()); + } + + @Override + public void doEffect(Player player) + { + _playerMap.put(player, System.currentTimeMillis() + 1000); + + float limit = (LAUNCH_RINGS * RING_SPACING) + RING_SPACING; + + for (float r = RING_SPACING; r < limit; r++) + { + double[][] points = UtilMath.normalCircle(player.getLocation(), player.getVelocity(), r, Math.round(RING_DENSITY * r)); + + for (int i = 0; i < points.length; i++) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, new Location(player.getWorld(), points[i][0], points[i][1], points[i][2]), + null, 0, 1, UtilParticle.ViewDist.NORMAL); + } + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if(event.getType() != UpdateType.FASTEST) + { + return; + } + + for(Iterator> it = _playerMap.entrySet().iterator(); it.hasNext();) + { + Map.Entry e = it.next(); + + if(e.getValue() <= System.currentTimeMillis()) + { + it.remove(); + continue; + } + + Location loc = e.getKey().getLocation().add(0, Y_OFFSET, 0); + + for (int i = 0; i < PARTICLES; ++i) + { + UtilParticle.playColoredParticleToAll(java.awt.Color.RED, UtilParticle.ParticleType.RED_DUST, + UtilMath.gauss(loc, DISTRIBUTION, DISTRIBUTION, DISTRIBUTION), 0, UtilParticle.ViewDist.NORMAL); + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java new file mode 100644 index 000000000..39b20d946 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java @@ -0,0 +1,176 @@ +package mineplex.core.gadget.gadgets.particle; + +import mineplex.core.arcadeevents.CoreGameStartEvent; +import mineplex.core.arcadeevents.CoreGameStopEvent; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilSound; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.treasure.event.TreasureFinishEvent; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + +import java.awt.Color; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; +import java.util.stream.Collectors; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class ParticleAuraNiceness extends ParticleGadget +{ + /** Radius within which flowers not allowed near treasure chests */ + private static final int TREASURE_RADIUS = 4; + + private static final double H_FIELD = 0.5; + private static final double V_FIELD = 0.35; + private static final int ROSE_PROBABILITY = 30; + private static final double ROSE_RADIUS = 2.5; + + private final Set _blocks = new HashSet<>(); + + /** Locations at which treasure is currently being opened */ + private final Map _openingTreasure = new HashMap<>(); + + private boolean _enabled = true; + + public ParticleAuraNiceness(GadgetManager manager) + { + super(manager, "Aura of Niceness", + UtilText.splitLineToArray(C.cGray + "Canadians are always nice online.", LineFormat.LORE), -8, Material.WOOL, + (byte) 0); + + setDisplayItem(CountryFlag.CANADA.getBanner()); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + { + return; + } + + for (Location location : _openingTreasure.values()) + { + if (location.toVector().isInSphere(player.getLocation().toVector(), TREASURE_RADIUS)) + { + return; + } + } + + UtilShapes.getCircle(player.getLocation().subtract(0, 0.5, 0), false, ROSE_RADIUS).stream().map(Location::getBlock) + .collect(Collectors.toSet()).forEach(block -> + { + if (ThreadLocalRandom.current().nextInt(ROSE_PROBABILITY) == 0) + { + Block b = block.getRelative(BlockFace.UP); + + if (b.isEmpty() && UtilBlock.fullSolid(block) && !UtilBlock.bottomSlab(block)) + { + Location loc = b.getLocation().add(H_FIELD, V_FIELD, H_FIELD); + + if (_enabled) + { + _blocks.add(b); + Manager.getBlockRestore().add(b, Material.RED_ROSE.getId(), (byte) 3, 5000); + } + + for (int i = 0; i < 20; ++i) + { + UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 4, 4, 4), 0, UtilParticle.ViewDist.NORMAL); + UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 4, 4, 4), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + }); + + for(Iterator it = _blocks.iterator(); it.hasNext();) + { + Block b = it.next(); + + if (b.getType() != Material.RED_ROSE) + { + it.remove(); + Location loc = b.getLocation().add(H_FIELD, V_FIELD, H_FIELD); + for (int i = 0; i < 10; ++i) + { + UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 6, 6, 6), 0, UtilParticle.ViewDist.NORMAL); + UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 6, 6, 6), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + } + + @EventHandler + public void onBlockFade(BlockPhysicsEvent event) + { + if (_blocks.contains(event.getBlock())) + { + event.setCancelled(true); + } + } + + /** + * Disable flowers in the area around treasure being opened. + */ + @EventHandler(priority = EventPriority.LOW) + public void disableOnTreasureStart(TreasureStartEvent event) + { + _openingTreasure.put(event.getPlayer().getUniqueId(), event.getPlayer().getLocation()); + Manager.getBlockRestore().restoreBlockAround(Material.CARPET, event.getPlayer().getLocation(), TREASURE_RADIUS); + } + + /** + * Enable flowers in the area around treasure no longer being opened. + */ + @EventHandler(priority = EventPriority.HIGH) + public void enableOnTreasureFinish(TreasureFinishEvent event) + { + if (_openingTreasure.containsKey(event.getPlayer().getUniqueId())) + { + _openingTreasure.remove(event.getPlayer().getUniqueId()); + } + } + + @EventHandler + public void onGameStart(CoreGameStartEvent event) + { + _enabled = false; + } + + @EventHandler + public void onGameEnd(CoreGameStopEvent event) + { + _enabled = true; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java new file mode 100644 index 000000000..10f87fe29 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java @@ -0,0 +1,68 @@ +package mineplex.core.gadget.gadgets.particle; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; + +import java.awt.Color; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class ParticleCanadian extends ParticleGadget +{ + private static final int STRAND_COUNT = 9; + private static final double STRAND_SPACING = 0.124; + private static final double DISTANCE_FROM_FLOOR = 0.43; + + public ParticleCanadian(GadgetManager manager) + { + super(manager, "Canadian Trail", + UtilText.splitLineToArray(C.cGray + "Lead the way to freedom!", LineFormat.LORE), + -8, Material.WOOL, (byte) 0); + + ItemStack stack = CountryFlag.CANADA.getBanner(); + System.out.println(((BannerMeta)stack.getItemMeta()).getBaseColor().getColor().toString()); + setDisplayItem(stack); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Location center = player.getLocation().add(0, DISTANCE_FROM_FLOOR, 0); + + if (Manager.isMoving(player)) + { + for (int i = 0; i < STRAND_COUNT; i++) + { + if (i < 3 || i > 5) + { + UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, + center.add(0, STRAND_SPACING, 0), 0, UtilParticle.ViewDist.NORMAL); + } + else + { + UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, + center.add(0, STRAND_SPACING, 0), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java new file mode 100644 index 000000000..92721b705 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java @@ -0,0 +1,57 @@ +package mineplex.core.gadget.gadgets.particle; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import java.util.concurrent.ThreadLocalRandom; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class ParticleFreedomFireworks extends ParticleGadget +{ + private static final Material[] BLOCKTYPES = { + Material.REDSTONE_BLOCK, + Material.LAPIS_BLOCK, + Material.QUARTZ_BLOCK + }; + + public ParticleFreedomFireworks(GadgetManager manager) + { + super(manager, "Freedom Fireworks", + UtilText.splitLineToArray(C.cGray + "Keep your patriotism close.", LineFormat.LORE), + -8, Material.WOOL, (byte) 0); + + setDisplayItem(CountryFlag.USA.getBanner()); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + String particle = UtilParticle.ParticleType.BLOCK_CRACK.getParticle(BLOCKTYPES[ThreadLocalRandom.current().nextInt(0, BLOCKTYPES.length)], 0); + Location location = UtilMath.gauss(player.getEyeLocation(), 1, 1, 1); + + for (int i = 0; i < 20; ++i) + { + UtilParticle.PlayParticleToAll(particle, location, null, 3.0f, 1, UtilParticle.ViewDist.NORMAL); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java new file mode 100644 index 000000000..ead0bc411 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java @@ -0,0 +1,80 @@ +package mineplex.core.gadget.gadgets.particle; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import java.awt.*; + + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class ParticleStarSpangled extends ParticleGadget +{ + private static final int STRAND_COUNT = 9; + private static final double STRAND_SPACING = 0.124; + private static final double DISTANCE_FROM_FLOOR = 0.43; + + private static final Color BLUE = new Color(29, 26, 120); + + public ParticleStarSpangled(GadgetManager manager) + { + super(manager, "Star Spangled Stripe", + UtilText.splitLineToArray(C.cGray + "Blaze a trail of freedom!", LineFormat.LORE), + -8, Material.WOOL, (byte) 0); + setDisplayItem(CountryFlag.USA.getBanner()); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Location center = player.getLocation().add(0, DISTANCE_FROM_FLOOR, 0); + + if (Manager.isMoving(player)) + { + for (int i = 0; i < STRAND_COUNT; i++) + { + if (i == 3 || i == 7) + { + if (player.getTicksLived() % 3 == 0) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.FIREWORKS_SPARK, + center.add(0, STRAND_SPACING, 0), 0f, 0f, 0f, 0f, 0, UtilParticle.ViewDist.NORMAL); + continue; + } + } + else if (i == 5) + { + if (player.getTicksLived() + 1 % 3 == 0) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.FIREWORKS_SPARK, + center.add(0, STRAND_SPACING, 0), 0f, 0f, 0f, 0f, 0, UtilParticle.ViewDist.NORMAL); + continue; + } + } + + UtilParticle.playColoredParticleToAll(BLUE, UtilParticle.ParticleType.RED_DUST, + center.add(0, STRAND_SPACING, 0), 0, UtilParticle.ViewDist.NORMAL); + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java new file mode 100644 index 000000000..a295bb9da --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java @@ -0,0 +1,26 @@ +package mineplex.core.gadget.set; + +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; +import mineplex.core.gadget.gadgets.particle.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; +import mineplex.core.gadget.types.GadgetSet; + +public class SetCanadian extends GadgetSet +{ + + public SetCanadian(GadgetManager manager) + { + super(manager, "Canadian", "2x Holiday Points while active (Titles)", + manager.getGadget(ArrowTrailRedWhite.class), + manager.getGadget(DeathMapleLeaf.class), + manager.getGadget(DoubleJumpMaple.class), + manager.getGadget(ParticleCanadian.class)); + } + +} From 4cc10680552cd2134f5ba7ea987ff014e47f4ffa Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:36:21 -0400 Subject: [PATCH 263/283] Allow Flags to interact with costumes and hats correctly --- .../src/mineplex/core/gadget/types/HatGadget.java | 2 +- .../src/mineplex/core/gadget/types/MorphGadget.java | 3 ++- .../src/mineplex/core/gadget/types/OutfitGadget.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java index b6becadc1..38df4c367 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java @@ -47,7 +47,7 @@ public abstract class HatGadget extends OutfitGadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - + Manager.removeGadgetType(player, GadgetType.FLAG, this); Manager.removeOutfit(player, _slot); _active.add(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java index 4fb2b5ed9..7240ed1d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java @@ -26,7 +26,8 @@ public abstract class MorphGadget extends Gadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - Manager.removeGadgetType(player, GadgetType.COSTUME); + Manager.removeGadgetType(player, GadgetType.COSTUME, this); + Manager.removeGadgetType(player, GadgetType.FLAG, this); _active.add(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java index 6ce4d70b7..e5ab85cb3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java @@ -60,7 +60,7 @@ public abstract class OutfitGadget extends Gadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - + Manager.removeGadgetType(player, GadgetType.FLAG, this); Manager.removeOutfit(player, _slot); _active.add(player); From 5387d3b580b4d049494fd4107f2e8bd3dd6604e3 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:36:49 -0400 Subject: [PATCH 264/283] Add cosmetics to chests --- .../core/cosmetic/CosmeticManager.java | 26 ++- .../mineplex/core/gadget/GadgetManager.java | 163 +++++++++++------- .../mineplex/core/reward/RewardManager.java | 112 +++++++----- .../core/treasure/gui/TreasurePage.java | 66 +++++-- 4 files changed, 249 insertions(+), 118 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java index d1ae7b491..9f0552d86 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java @@ -1,5 +1,7 @@ package mineplex.core.cosmetic; +import mineplex.core.chat.Chat; +import mineplex.core.punish.Punish; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -41,19 +43,23 @@ import mineplex.core.twofactor.TwoFactorAuth; public class CosmeticManager extends MiniPlugin { private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class); - private InventoryManager _inventoryManager; - private GadgetManager _gadgetManager; - private MountManager _mountManager; - private PetManager _petManager; - private TreasureManager _treasureManager; - private BoosterManager _boosterManager; + private final InventoryManager _inventoryManager; + private final GadgetManager _gadgetManager; + private final MountManager _mountManager; + private final PetManager _petManager; + private final TreasureManager _treasureManager; + private final BoosterManager _boosterManager; + private final Punish _punish; private CosmeticShop _shop; private boolean _showInterface = true; private int _interfaceSlot = 4; - public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager, TreasureManager treasureManager, BoosterManager boosterManager) + public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, + InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, + PetManager petManager, TreasureManager treasureManager, BoosterManager boosterManager, + Punish punish) { super("Cosmetic Manager", plugin); @@ -63,6 +69,7 @@ public class CosmeticManager extends MiniPlugin _petManager = petManager; _treasureManager = treasureManager; _boosterManager = boosterManager; + _punish = punish; _shop = new CosmeticShop(this, clientManager, donationManager, _moduleName); } @@ -242,6 +249,11 @@ public class CosmeticManager extends MiniPlugin { return _boosterManager; } + + public Punish getPunishManager() + { + return _punish; + } public void displayUI(Player player) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index e0d211e34..18afeb5f7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -10,7 +10,18 @@ import java.util.Set; import java.util.UUID; import java.util.function.Predicate; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; +import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.morph.MorphBobRoss; +import mineplex.core.gadget.gadgets.particle.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; +import mineplex.core.gadget.set.SetCanadian; +import mineplex.core.gadget.types.FlagGadget; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -47,50 +58,50 @@ import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.event.PlayerToggleSwimEvent; import mineplex.core.gadget.event.TauntCommandEvent; -import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; -import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; -import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.arrowtrail.halloween.ArrowTrailHalloween; -import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; -import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; -import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; -import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; -import mineplex.core.gadget.gadgets.arrowtrail.titan.ArrowTrailTitan; -import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.balloons.BalloonItem; import mineplex.core.gadget.gadgets.balloons.BalloonType; -import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; -import mineplex.core.gadget.gadgets.death.christmas.DeathPresentDanger; -import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart; -import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald; -import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; -import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; -import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; -import mineplex.core.gadget.gadgets.death.music.DeathMusic; -import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; -import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; -import mineplex.core.gadget.gadgets.death.spring.DeathSpring; -import mineplex.core.gadget.gadgets.death.titan.DeathTitan; -import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; -import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; -import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; -import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; -import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; -import mineplex.core.gadget.gadgets.doublejump.halloween.DoubleJumpHalloween; -import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; -import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; -import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; -import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; -import mineplex.core.gadget.gadgets.doublejump.titan.DoubleJumpTitan; -import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.death.DeathCandyCane; +import mineplex.core.gadget.gadgets.death.DeathPresentDanger; +import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; +import mineplex.core.gadget.gadgets.death.DeathEmerald; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.death.DeathFrostLord; +import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.death.DeathMusic; +import mineplex.core.gadget.gadgets.death.DeathPinataBurst; +import mineplex.core.gadget.gadgets.death.DeathShadow; +import mineplex.core.gadget.gadgets.death.DeathSpring; +import mineplex.core.gadget.gadgets.death.DeathTitan; +import mineplex.core.gadget.gadgets.death.DeathBlood; +import mineplex.core.gadget.gadgets.death.DeathEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.GameModifierMount; import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.MountType; @@ -366,6 +377,7 @@ public class GadgetManager extends MiniPlugin addSet(new SetMusic(this)); addSet(new SetFreedom(this)); addSet(new SetSpring(this)); + addSet(new SetCanadian(this)); } private void createGadgets() @@ -459,31 +471,40 @@ public class GadgetManager extends MiniPlugin // Particles addGadget(new ParticleFoot(this)); - addGadget(new ParticleFireRings(this)); - addGadget(new ParticleFairy(this)); - addGadget(new ParticleLegend(this)); - addGadget(new ParticleFrostLord(this)); - addGadget(new ParticleTitan(this)); - addGadget(new ParticleCandyCane(this)); - addGadget(new ParticleCoalFumes(this)); - addGadget(new ParticlePartyTime(this)); - addGadget(new ParticleHeart(this)); addGadget(new ParticleEmerald(this)); - addGadget(new ParticleWingsDemons(this)); - addGadget(new ParticleEnchant(this)); addGadget(new ParticleRain(this)); addGadget(new ParticleBlood(this)); + addGadget(new ParticleEnchant(this)); addGadget(new ParticleMusic(this)); - addGadget(new ParticleWingsAngel(this)); - addGadget(new ParticleWingsInfernal(this)); - addGadget(new ParticleWingsPixie(this)); + addGadget(new ParticlePartyTime(this)); + + addGadget(new ParticleHeart(this)); + addGadget(new ParticleCandyCane(this)); + addGadget(new ParticleFrostLord(this)); + addGadget(new ParticleLegend(this)); + addGadget(new ParticleTitan(this)); addGadget(new ParticleYinYang(this)); - addGadget(new ParticleFreedom(this)); - addGadget(new ParticleChristmasTree(this)); + addGadget(new ParticleKing(this, _castleManager)); + + addGadget(new ParticleWingsPixie(this)); + addGadget(new ParticleWingsDemons(this)); + addGadget(new ParticleWingsInfernal(this)); + addGadget(new ParticleWingsAngel(this)); addGadget(new ParticleWingsLove(this)); + addGadget(new ParticleFireRings(this)); + addGadget(new ParticleFairy(this)); + + addGadget(new ParticleChristmasTree(this)); + addGadget(new ParticleCoalFumes(this)); addGadget(new ParticleSpringHalo(this)); addGadget(new ParticleWingsBee(this)); - addGadget(new ParticleKing(this, _castleManager)); + + addGadget(new ParticleFreedom(this)); + addGadget(new ParticleFreedomFireworks(this)); + addGadget(new ParticleStarSpangled(this)); + addGadget(new ParticleAuraNiceness(this)); + addGadget(new ParticleCanadian(this)); + // Arrow Trails addGadget(new ArrowTrailFrostLord(this)); @@ -500,6 +521,7 @@ public class GadgetManager extends MiniPlugin addGadget(new ArrowTrailFreedom(this)); addGadget(new ArrowTrailHalloween(this)); addGadget(new ArrowTrailSpring(this)); + addGadget(new ArrowTrailRedWhite(this)); // Death Effect addGadget(new DeathFrostLord(this)); @@ -516,6 +538,7 @@ public class GadgetManager extends MiniPlugin addGadget(new DeathFreedom(this)); addGadget(new DeathPresentDanger(this)); addGadget(new DeathSpring(this)); + addGadget(new DeathMapleLeaf(this)); // Double Jump addGadget(new DoubleJumpFrostLord(this)); @@ -532,6 +555,7 @@ public class GadgetManager extends MiniPlugin addGadget(new DoubleJumpFreedom(this)); addGadget(new DoubleJumpHalloween(this)); addGadget(new DoubleJumpSpring(this)); + addGadget(new DoubleJumpMaple(this)); // Hat for (HatType hatType : HatType.values()) @@ -625,6 +649,10 @@ public class GadgetManager extends MiniPlugin addGadget(new BlowAKissTaunt(this)); addGadget(new RainbowTaunt(this)); + // Flags + addGadget(new FlagGadget(this, FlagType.UNITED_STATES)); + addGadget(new FlagGadget(this, FlagType.CANADA)); + // Kit Selectors addGadget(new WaterWingsKitSelector(this)); addGadget(new HaloKitSelector(this)); @@ -830,6 +858,23 @@ public class GadgetManager extends MiniPlugin return null; } + public FlagGadget getFlagGadget(FlagType type) + { + for (Gadget gadget : getGadgets(GadgetType.FLAG)) + { + if(gadget instanceof FlagGadget) + { + FlagGadget flagGadget = (FlagGadget) gadget; + + if (type.equals(flagGadget.getFlagType())) + { + return flagGadget; + } + } + } + return null; + } + public BalloonGadget getBalloonGadget(BalloonType balloonType) { for (Gadget gadget : getGadgets(GadgetType.BALLOON)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 5f4e5fb16..eabf8e7e4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -5,6 +5,14 @@ import java.util.EnumMap; import java.util.List; import java.util.Random; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; +import mineplex.core.gadget.gadgets.flag.FlagType; +import mineplex.core.gadget.gadgets.particle.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -15,46 +23,46 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.halloween.ArrowTrailHalloween; -import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; -import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; -import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; -import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; -import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; -import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; -import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.balloons.BalloonType; -import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; -import mineplex.core.gadget.gadgets.death.christmas.DeathPresentDanger; -import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart; -import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald; -import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; -import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; -import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; -import mineplex.core.gadget.gadgets.death.music.DeathMusic; -import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; -import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; -import mineplex.core.gadget.gadgets.death.spring.DeathSpring; -import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; -import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.halloween.DoubleJumpHalloween; -import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; -import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; -import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; -import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; -import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; -import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; -import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; -import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; -import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.death.DeathCandyCane; +import mineplex.core.gadget.gadgets.death.DeathPresentDanger; +import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; +import mineplex.core.gadget.gadgets.death.DeathEmerald; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.death.DeathFrostLord; +import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.death.DeathMusic; +import mineplex.core.gadget.gadgets.death.DeathPinataBurst; +import mineplex.core.gadget.gadgets.death.DeathShadow; +import mineplex.core.gadget.gadgets.death.DeathSpring; +import mineplex.core.gadget.gadgets.death.DeathBlood; +import mineplex.core.gadget.gadgets.death.DeathEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin; import mineplex.core.gadget.gadgets.hat.HatType; import mineplex.core.gadget.gadgets.item.ItemBatGun; @@ -318,6 +326,10 @@ public class RewardManager addHat(Type.WINTER_HOLIDAY, HatType.PRESENT, rarity, 5); addHat(Type.WINTER_HOLIDAY, HatType.SNOWMAN, rarity, 5); + // FREEDOM + addGadget(Type.FREEDOM, getGadget(ArrowTrailRedWhite.class), rarity, 150); + addGadget(Type.FREEDOM, getGadget(ArrowTrailFreedom.class), rarity, 150); + // Omega items addMusicReward(Type.OMEGA, "Blocks Disc", rarity, 25); addMusicReward(Type.OMEGA, "Cat Disc", rarity, 25); @@ -484,9 +496,12 @@ public class RewardManager // FREEDOM addHat(Type.FREEDOM, HatType.UNCLE_SAM, rarity, 100); + addHat(Type.FREEDOM, HatType.AMERICA, rarity, 120); + addHat(Type.FREEDOM, HatType.CANADA, rarity, 120); addGadget(Type.FREEDOM, getGadget(DoubleJumpFreedom.class), rarity, 50); - addGadget(Type.FREEDOM, getGadget(ArrowTrailFreedom.class), rarity, 10); + addGadget(Type.FREEDOM, getGadget(DoubleJumpMaple.class), rarity, 50); addGadget(Type.FREEDOM, getGadget(DeathFreedom.class), rarity, 75); + addGadget(Type.FREEDOM, getGadget(DeathMapleLeaf.class), rarity, 75); // Omega Chest addGadget(Type.OMEGA, getGadget(DoubleJumpFreedom.class), rarity, 5); @@ -758,6 +773,12 @@ public class RewardManager addMount(Type.FREEDOM, getMount(MountFreedomHorse.class), rarity, 1); addGadget(Type.FREEDOM, getGadget(MorphUncleSam.class), rarity, 5); addGadget(Type.FREEDOM, getGadget(ParticleFreedom.class), rarity, 50); + addGadget(Type.FREEDOM, getGadget(ParticleFreedomFireworks.class), rarity, 95); + addGadget(Type.FREEDOM, getGadget(ParticleAuraNiceness.class), rarity, 40); + addGadget(Type.FREEDOM, getGadget(ParticleCanadian.class), rarity, 10); + addGadget(Type.FREEDOM, getGadget(ParticleStarSpangled.class), rarity, 10); + addFlag(Type.FREEDOM, FlagType.CANADA, rarity, 35); + addFlag(Type.FREEDOM, FlagType.UNITED_STATES, rarity, 35); // Omega items addPetReward(Type.OMEGA, PetType.VILLAGER, rarity, 1); @@ -1013,6 +1034,17 @@ public class RewardManager return addGadget(type, gadget, gadget.getDisplayName(), rarity, weight, shards); } + public UnknownPackageReward addFlag(Type type, FlagType flagType, RewardRarity rarity, int weight) + { + return addFlag(type, flagType, rarity, weight, getShards(rarity)); + } + + public UnknownPackageReward addFlag(Type type, FlagType flagType, RewardRarity rarity, int weight, int shards) + { + Gadget gadget = _gadgetManager.getFlagGadget(flagType); + return addGadget(type, gadget, gadget.getDisplayName(), rarity, weight, shards); + } + public UnknownPackageReward addBalloon(Type type, BalloonType balloonType, RewardRarity rarity, int weight) { return addBalloon(type, balloonType, rarity, weight, getShards(rarity)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index 030e3dc1d..de56e4730 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -4,6 +4,15 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; +import mineplex.core.gadget.gadgets.flag.FlagType; +import mineplex.core.gadget.gadgets.hat.HatType; +import mineplex.core.gadget.gadgets.particle.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -20,9 +29,9 @@ import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; -import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; import mineplex.core.gadget.gadgets.morph.MorphUncleSam; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; import mineplex.core.gadget.types.Gadget; @@ -141,7 +150,7 @@ public class TreasurePage extends ShopPageBase int springCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.SPRING.getItemName()); boolean availableChristmas = false; - boolean availableFreedom = false; + boolean availableFreedom = true; boolean availableHaunted = false; boolean availableTrick = false; boolean availableThank = false; @@ -152,8 +161,8 @@ public class TreasurePage extends ShopPageBase List shardLore = new ArrayList<>(); shardLore.add(" "); - shardLore.add(C.cGray + "This seems like it might come in"); - shardLore.add(C.cGray + "handy. Maybe I can collect more!"); + shardLore.add(C.cGray + "These seem like they might come in"); + shardLore.add(C.cGray + "handy. Maybe I should collect more!"); List basicLore = new ArrayList<>(); basicLore.add(" "); @@ -254,14 +263,36 @@ public class TreasurePage extends ShopPageBase freedomLore.add(C.cGray + "carved this chest himself from the wood"); freedomLore.add(C.cGray + "of the apple tree he cut down..."); freedomLore.add(" "); - if (freedomCount > 0 && !hasAllFreedomItems(getPlayer())) - freedomLore.add(C.cGreen + "Click to Open!"); + + if (freedomCount > 0) + { + if (hasAllFreedomItems(getPlayer())) + { + freedomLore.add(C.cWhite + "You own all treasures from this chest."); + } + else + { + freedomLore.add(C.cGreen + "Click to Open!"); + } + } else { - freedomLore.add(C.cRed + "This item is no longer available!"); + if (!availableFreedom) + { + freedomLore.add(C.cRed + "This item is no longer available!"); + } + else if (hasAllFreedomItems(getPlayer())) + { + freedomLore.add(C.cWhite + "You own all treasures from this chest."); + } + else + { + freedomLore.add(ChatColor.RESET + "Purchase at: " + C.cYellow + "www.mineplex.com/shop"); + } } + freedomLore.add(" "); - freedomLore.add(ChatColor.RESET + C.cGreen + getFreedomUnlockedAmount(getPlayer()) + "/7 Unlocked"); + freedomLore.add(ChatColor.RESET + C.cGreen + getFreedomUnlockedAmount(getPlayer()) + "/18 Unlocked"); List omegaLore = new ArrayList<>(); omegaLore.add(" "); @@ -699,7 +730,7 @@ public class TreasurePage extends ShopPageBase public int getFreedomUnlockedAmount(Player player) { if (hasAllFreedomItems(player)) - return 7; + return 18; int amount = 0; Gadget[] gadgets = new Gadget[] { @@ -708,7 +739,18 @@ public class TreasurePage extends ShopPageBase _gadgetManager.getGadget(ArrowTrailFreedom.class), _gadgetManager.getGadget(DoubleJumpFreedom.class), _gadgetManager.getGadget(DeathFreedom.class), - _gadgetManager.getGadget(MorphUncleSam.class) + _gadgetManager.getGadget(MorphUncleSam.class), + _gadgetManager.getGadget(ArrowTrailRedWhite.class), + _gadgetManager.getGadget(DeathMapleLeaf.class), + _gadgetManager.getGadget(DoubleJumpMaple.class), + _gadgetManager.getGadget(ParticleAuraNiceness.class), + _gadgetManager.getGadget(ParticleCanadian.class), + _gadgetManager.getGadget(ParticleFreedomFireworks.class), + _gadgetManager.getGadget(ParticleStarSpangled.class), + _gadgetManager.getHatGadget(HatType.AMERICA), + _gadgetManager.getHatGadget(HatType.CANADA), + _gadgetManager.getFlagGadget(FlagType.CANADA), + _gadgetManager.getFlagGadget(FlagType.UNITED_STATES), }; Mount freedomMount = _gadgetManager.getMountManager().getMount("Freedom Mount"); if (freedomMount != null) From ea8c7be5f08088e54990ea2b2b6cb2d6e8d15d50 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:37:06 -0400 Subject: [PATCH 265/283] Disallow eternal taunt disguising an already disguised player --- .../gadget/gadgets/taunts/EternalTaunt.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java index 103efacd2..1e0c943b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import mineplex.core.disguise.disguises.DisguiseBase; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -41,7 +42,8 @@ public class EternalTaunt extends TauntGadget private static final int COOLDOWN = 30000; private static final int PVP_COOLDOWN = 10000; - private Map> _clocks = new HashMap<>(); + private final Map> _clocks = new HashMap<>(); + private final Map _disguises = new HashMap<>(); public EternalTaunt(GadgetManager manager) { @@ -68,8 +70,12 @@ public class EternalTaunt extends TauntGadget Bukkit.broadcastMessage(F.main("Taunt", F.name(player.getName()) + " waited so long they turned to bones.")); - DisguiseSkeleton disguiseSkeleton = new DisguiseSkeleton(player); - UtilMorph.disguise(player, disguiseSkeleton, Manager); + if (!Manager.getDisguiseManager().isDisguised(player)) + { + DisguiseSkeleton disguiseSkeleton = new DisguiseSkeleton(player); + UtilMorph.disguise(player, disguiseSkeleton, Manager); + _disguises.put(player.getUniqueId(), disguiseSkeleton); + } } @Override @@ -114,7 +120,11 @@ public class EternalTaunt extends TauntGadget @Override public void onFinish(Player player) { - UtilMorph.undisguise(player, Manager.getDisguiseManager()); + if (_disguises.containsKey(player.getUniqueId())) + { + Manager.getDisguiseManager().undisguise(_disguises.remove(player.getUniqueId())); + } + if (_clocks.containsKey(player.getUniqueId())) { _clocks.get(player.getUniqueId()).forEach(c -> c.remove()); From f7ac7994769cc899a9514e41095667c4b219f0f2 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:37:20 -0400 Subject: [PATCH 266/283] Overhaul legend particle --- .../gadgets/particle/ParticleLegend.java | 182 +++++++++++++++++- 1 file changed, 180 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java index f99338a75..51911de42 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java @@ -1,6 +1,9 @@ package mineplex.core.gadget.gadgets.particle; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; import org.bukkit.Effect; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -16,13 +19,46 @@ import mineplex.core.inventory.ClientItem; import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.util.Vector; + +import java.awt.Color; +import java.util.Random; public class ParticleLegend extends ParticleGadget { + private static final double PI = Math.PI; + private static final int BASE_PILLARS = 9; + private static final int PILLAR_VARIANCE = 7; + private static final int COLOR_VARIANCE = 5; + private static final int MOVING_PARTICLES = 8; + private static final double VERTICAL_SPEED = 0.1; + private static final double HEIGHT_VARIANCE = 0.8; + private static final double ROTATIONAL_SPEED = .03; + private static final double RADIAL_VARIANCE = 0.09; + private static final double DARK_PARTICLE_CHANCE = 0.5; + private static final double BASE_RADIUS = 1.30; + private static final double HEIGHT_MODIFIER_BASE = 0.1; + private static final double HEIGHT_MODIFIER_MAX = 1.3; + private static final double HEIGHT_MODIFIER_INTERVAL = 0.2; + private static final Color[] SELECTABLE_COLORS = { + new Color(170, 100, 170), + new Color(50, 10, 60), + new Color(120, 10, 170), + new Color(65, 20, 80) + }; + + private final int _pillars = pillars(); + private final Color[] _colors = colors(); + private final double[] _heights = heights(); + private final double[] _verticals = verticals(); + private final double[] _variance = variances(); + private final double[] _thetas = thetas(); + private final double[] _radii = radii(); + public ParticleLegend(GadgetManager manager) { super(manager, "Legendary Aura", - UtilText.splitLineToArray(C.cGray + "This particle will be updated soon! Yay!", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "Let the energy of the End protect you.", LineFormat.LORE), -1, Material.ENDER_PORTAL_FRAME, (byte)0); } @@ -31,9 +67,151 @@ public class ParticleLegend extends ParticleGadget public void playParticle(Player player, UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } - player.getWorld().playEffect(player.getLocation().add(0, 1, 0), Effect.ENDER_SIGNAL, 0); + if (Manager.isMoving(player)) + { + Location loc = player.getLocation().add(0, 1.5, 0); + + for (int i = 0; i < MOVING_PARTICLES; i++) + { + UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, + UtilMath.gauss(loc, 8, 4, 8), 0, UtilParticle.ViewDist.NORMAL); + } + } + else + { + if (event.getTick() % (ROTATIONAL_SPEED * 100) == 0) + { + for (int i = 0; i < _pillars; i++) + { + _thetas[i] = rollover(_thetas[i], ROTATIONAL_SPEED); + _heights[i] = rollover(_heights[i], _verticals[i]); + + double x = (_radii[i] * Math.cos(_thetas[i])) + player.getLocation().getX(); + double z = (_radii[i] * Math.sin(_thetas[i])) + player.getLocation().getZ(); + double y = (Math.sin(_heights[i]) * _variance[i]) + player.getLocation().getY(); + + for (double h = HEIGHT_MODIFIER_BASE; h <= HEIGHT_MODIFIER_MAX; h+= HEIGHT_MODIFIER_INTERVAL) + { + UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, + new Location(player.getWorld(), x, y + h, z), 0, UtilParticle.ViewDist.NORMAL); + + if (Math.random() < DARK_PARTICLE_CHANCE) + { + UtilParticle.playColoredParticleToAll(Color.BLACK, UtilParticle.ParticleType.RED_DUST, + new Location(player.getWorld(), x, y + h, z), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + } + } + } + + private double[] heights() + { + double[] array = new double[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + array[i] = 6.28 * Math.random(); + } + + return array; + } + + private double[] variances() + { + double[] array = new double[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + array[i] = Math.random() * HEIGHT_VARIANCE; + } + + return array; + } + + private double[] verticals() + { + double[] array = new double[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + array[i] = Math.random() * VERTICAL_SPEED; + } + + return array; + } + + private double[] thetas() + { + double[] array = new double[_pillars]; + double theta = 0; + double interval = (2 * PI) / _pillars; + + for (int i = 0; i < _pillars; i++) + { + array[i] = theta; + theta += interval; + } + + return array; + } + + private double[] radii() + { + double[] array = new double[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + array[i] = BASE_RADIUS + (Math.random() * RADIAL_VARIANCE); + } + + return array; + } + + private Color[] colors() + { + Random random = new Random(); + + Color[] array = new Color[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + Color color = SELECTABLE_COLORS[i % SELECTABLE_COLORS.length]; + + int r = color.getRed() + (int) (random.nextGaussian() * COLOR_VARIANCE); + int g = color.getGreen() + (int) (random.nextGaussian() * COLOR_VARIANCE); + int b = color.getBlue() + (int) (random.nextGaussian() * COLOR_VARIANCE); + + r = Math.min(255, Math.max(0, r)); + g = Math.min(255, Math.max(0, g)); + b = Math.min(255, Math.max(0, b)); + + array[i] = new Color(r, g, b); + } + + return array; + } + + private int pillars() + { + return BASE_PILLARS + (int) ((Math.random() * PILLAR_VARIANCE) - (PILLAR_VARIANCE / 2)); + } + + private double rollover(double value, double additive) + { + value += additive; + + if (value >= 2 * PI) + { + value = value - (2 * PI); + } + + return value; } @EventHandler From 7d17fa0f290bbd680b2ab8d7cc4938acf81202f8 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:37:33 -0400 Subject: [PATCH 267/283] Update hubs with new CosmeticManager constructor --- .../Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java | 2 +- Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java | 2 +- .../Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java | 2 +- .../mavericks-review-hub/src/mineplex/mavericks/review/Hub.java | 2 +- .../src/mineplex/gemhunters/GemHunters.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index 29e6ab472..b02d21718 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -233,7 +233,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter _treasureManager.addTreasureLocation(loc); } - new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); + new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager, punish); new MenuManager(_plugin); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index bc02c3628..eb7242bde 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -235,7 +235,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess _bonusManager = new BonusManager(plugin, null, playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager, "Carl"); _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager()); - CosmeticManager cosmeticManager = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); + CosmeticManager cosmeticManager = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager, punish); _mavericksManager = new MavericksManager(plugin, cosmeticManager, hologramManager, this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index ebf57b8d0..5f75dde80 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -201,7 +201,7 @@ public class Arcade extends JavaPlugin GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager); ThankManager thankManager = new ThankManager(this, _clientManager, _donationManager); BoosterManager boosterManager = new BoosterManager(this, _serverConfiguration.getServerGroup().getBoosterGroup(), _clientManager, _donationManager, inventoryManager, thankManager); - CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager); + CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager, punish); cosmeticManager.setInterfaceSlot(6); gadgetManager.setActiveItemSlot(3); cosmeticManager.disableTeamArmor(); diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java index ebc01ac9c..4fbb830fa 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java @@ -138,7 +138,7 @@ public class Hub extends JavaPlugin RewardManager rewardManager = new RewardManager(_clientManager, _donationManager, inventoryManager, petManager, gadgetManager, statsManager); TreasureManager treasureManager = new TreasureManager(this, _clientManager, serverStatusManager, _donationManager, inventoryManager, petManager, gadgetManager, blockRestore, hologramManager, statsManager, rewardManager); CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, - mountManager, petManager, treasureManager, boosterManager); + mountManager, petManager, treasureManager, boosterManager, punish); cosmeticManager.setInterfaceSlot(7); cosmeticManager.disableTeamArmor(); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index d4e557763..b0df81d54 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -258,7 +258,7 @@ public class GemHunters extends JavaPlugin GadgetManager gadgetManager = new GadgetManager(this, clientManager, donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager); ThankManager thankManager = new ThankManager(this, clientManager, donationManager); BoosterManager boosterManager = new BoosterManager(this, null, clientManager, donationManager, inventoryManager, thankManager); - CosmeticManager cosmeticManager = new CosmeticManager(this, clientManager, donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager); + CosmeticManager cosmeticManager = new CosmeticManager(this, clientManager, donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager, punish); cosmeticManager.setActive(false); cosmeticManager.setHideParticles(true); From aba684ad9516627eac23d79ab2c559d0005d8e1e Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:40:46 -0400 Subject: [PATCH 268/283] Remove unnecessary packages --- .../mineplex/core/gadget/GadgetManager.java | 31 +++++++++---------- .../gadget/commands/LockInfusedCommand.java | 2 +- .../particle/{vampire => }/ParticleBlood.java | 2 +- .../{candycane => }/ParticleCandyCane.java | 2 +- .../{emerald => }/ParticleEmerald.java | 2 +- .../{wisdom => }/ParticleEnchant.java | 2 +- .../particle/{shadow => }/ParticleFoot.java | 2 +- .../{frostlord => }/ParticleFrostLord.java | 2 +- .../{cupidslove => }/ParticleHeart.java | 2 +- .../particle/{music => }/ParticleMusic.java | 2 +- .../{party => }/ParticlePartyTime.java | 2 +- .../{howlingwinds => }/ParticleRain.java | 2 +- .../particle/{titan => }/ParticleTitan.java | 2 +- .../{ => freedom}/ParticleAuraNiceness.java | 2 +- .../{ => freedom}/ParticleCanadian.java | 2 +- .../ParticleFreedomFireworks.java | 2 +- .../{ => freedom}/ParticleStarSpangled.java | 2 +- .../mineplex/core/gadget/set/SetCanadian.java | 6 +--- .../core/gadget/set/SetCandyCane.java | 2 +- .../core/gadget/set/SetCupidsLove.java | 2 +- .../mineplex/core/gadget/set/SetEmerald.java | 2 +- .../mineplex/core/gadget/set/SetFreedom.java | 3 +- .../core/gadget/set/SetFrostLord.java | 2 +- .../core/gadget/set/SetHowlingWinds.java | 2 +- .../mineplex/core/gadget/set/SetMusic.java | 2 +- .../mineplex/core/gadget/set/SetParty.java | 2 +- .../mineplex/core/gadget/set/SetShadow.java | 2 +- .../mineplex/core/gadget/set/SetTitan.java | 2 +- .../mineplex/core/gadget/set/SetVampire.java | 2 +- .../mineplex/core/gadget/set/SetWisdom.java | 2 +- .../mineplex/core/reward/RewardManager.java | 28 ++++++++--------- .../core/treasure/gui/TreasurePage.java | 8 ++--- 32 files changed, 62 insertions(+), 68 deletions(-) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{vampire => }/ParticleBlood.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{candycane => }/ParticleCandyCane.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{emerald => }/ParticleEmerald.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{wisdom => }/ParticleEnchant.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{shadow => }/ParticleFoot.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{frostlord => }/ParticleFrostLord.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{cupidslove => }/ParticleHeart.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{music => }/ParticleMusic.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{party => }/ParticlePartyTime.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{howlingwinds => }/ParticleRain.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{titan => }/ParticleTitan.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => freedom}/ParticleAuraNiceness.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => freedom}/ParticleCanadian.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => freedom}/ParticleFreedomFireworks.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => freedom}/ParticleStarSpangled.java (97%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 18afeb5f7..69e331174 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -10,16 +10,15 @@ import java.util.Set; import java.util.UUID; import java.util.function.Predicate; -import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.morph.MorphBobRoss; -import mineplex.core.gadget.gadgets.particle.ParticleAuraNiceness; -import mineplex.core.gadget.gadgets.particle.ParticleCanadian; -import mineplex.core.gadget.gadgets.particle.ParticleFreedomFireworks; -import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import mineplex.core.gadget.set.SetCanadian; import mineplex.core.gadget.types.FlagGadget; import org.bukkit.Bukkit; @@ -196,19 +195,19 @@ import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsLove; import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; import mineplex.core.gadget.gadgets.particle.ParticleYinYang; -import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; -import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; -import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.ParticleEmerald; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; -import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; -import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; -import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; -import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; -import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleRain; +import mineplex.core.gadget.gadgets.particle.ParticleMusic; +import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; +import mineplex.core.gadget.gadgets.particle.ParticleFoot; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; -import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan; -import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; -import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; +import mineplex.core.gadget.gadgets.particle.ParticleTitan; +import mineplex.core.gadget.gadgets.particle.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; import mineplex.core.gadget.gadgets.taunts.EternalTaunt; import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java index a91dcdb3e..d57b89228 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java @@ -21,7 +21,7 @@ import mineplex.core.gadget.gadgets.item.ItemFreezeCannon; import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.gadgets.morph.MorphSnowman; -import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; import mineplex.core.gadget.types.Gadget; import mineplex.core.mount.Mount; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/vampire/ParticleBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleBlood.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/vampire/ParticleBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleBlood.java index a33078067..0c3c3546a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/vampire/ParticleBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.vampire; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/candycane/ParticleCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/candycane/ParticleCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java index 4d8b223fc..5f31b13fb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/candycane/ParticleCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.candycane; +package mineplex.core.gadget.gadgets.particle; import java.util.HashMap; import java.util.UUID; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/emerald/ParticleEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEmerald.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/emerald/ParticleEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEmerald.java index 417587dbb..f81361c66 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/emerald/ParticleEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.emerald; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/wisdom/ParticleEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/wisdom/ParticleEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java index f8d734e74..706c32fbd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/wisdom/ParticleEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.wisdom; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoot.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoot.java index 9c3b8be54..fd315fc04 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoot.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.shadow; +package mineplex.core.gadget.gadgets.particle; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/frostlord/ParticleFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/frostlord/ParticleFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java index 62c1388b3..32f947e47 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/frostlord/ParticleFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.frostlord; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Material; import org.bukkit.Sound; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java index dea6a85aa..ca008bc75 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.cupidslove; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/music/ParticleMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMusic.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/music/ParticleMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMusic.java index 04874fffc..e0bbb3537 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/music/ParticleMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.music; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/party/ParticlePartyTime.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/party/ParticlePartyTime.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java index 3aab6f928..a3944317c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/party/ParticlePartyTime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.party; +package mineplex.core.gadget.gadgets.particle; import java.util.Arrays; import java.util.Collections; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/howlingwinds/ParticleRain.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/howlingwinds/ParticleRain.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java index f2c45007c..4311666c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/howlingwinds/ParticleRain.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.howlingwinds; +package mineplex.core.gadget.gadgets.particle; import java.util.ArrayList; import java.util.List; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java index b5f02de23..7d062f713 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.titan; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java index 39b20d946..8b72b935c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.freedom; import mineplex.core.arcadeevents.CoreGameStartEvent; import mineplex.core.arcadeevents.CoreGameStopEvent; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java index 10f87fe29..7984af254 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.freedom; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java index 92721b705..4234a257b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.freedom; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java index ead0bc411..cf65cb0dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.freedom; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java index a295bb9da..0b18eca18 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java @@ -1,14 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; -import mineplex.core.gadget.gadgets.death.DeathFreedom; import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; -import mineplex.core.gadget.gadgets.particle.ParticleCanadian; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; import mineplex.core.gadget.types.GadgetSet; public class SetCanadian extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java index 9a2d9ce75..c9b059480 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; import mineplex.core.gadget.gadgets.death.DeathCandyCane; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; +import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; import mineplex.core.gadget.types.GadgetSet; public class SetCandyCane extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java index 47f1552f7..dca2f191c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; -import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; import mineplex.core.gadget.types.GadgetSet; public class SetCupidsLove extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java index 740174dba..26df2fd6f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; import mineplex.core.gadget.gadgets.death.DeathEmerald; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; -import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.ParticleEmerald; import mineplex.core.gadget.types.GadgetSet; public class SetEmerald extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java index e8c300adf..a64e2caf3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java @@ -4,8 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; import mineplex.core.gadget.gadgets.death.DeathFreedom; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; -import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import mineplex.core.gadget.types.GadgetSet; public class SetFreedom extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java index 6050a0b00..311600e5e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; import mineplex.core.gadget.gadgets.death.DeathFrostLord; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; -import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; import mineplex.core.gadget.types.GadgetSet; public class SetFrostLord extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java index 672f49bdc..668503111 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; import mineplex.core.gadget.gadgets.death.DeathStorm; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; -import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; +import mineplex.core.gadget.gadgets.particle.ParticleRain; import mineplex.core.gadget.types.GadgetSet; public class SetHowlingWinds extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java index fdd47eacd..50eef82a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; import mineplex.core.gadget.gadgets.death.DeathMusic; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; +import mineplex.core.gadget.gadgets.particle.ParticleMusic; import mineplex.core.gadget.types.GadgetSet; public class SetMusic extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java index 0b99f9f2e..f22ce959e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; import mineplex.core.gadget.gadgets.death.DeathPinataBurst; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; -import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; +import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; import mineplex.core.gadget.types.GadgetSet; public class SetParty extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java index 1d5fad5dd..80b751d7d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; import mineplex.core.gadget.gadgets.death.DeathShadow; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; -import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFoot; import mineplex.core.gadget.types.GadgetSet; public class SetShadow extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java index 0d333818d..360d86270 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan; import mineplex.core.gadget.gadgets.death.DeathTitan; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan; -import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan; +import mineplex.core.gadget.gadgets.particle.ParticleTitan; import mineplex.core.gadget.types.GadgetSet; public class SetTitan extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java index 7ec9b7f7a..1a5541085 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; import mineplex.core.gadget.gadgets.death.DeathBlood; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.ParticleBlood; import mineplex.core.gadget.types.GadgetSet; public class SetVampire extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java index 870b70d3f..5bbae55da 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.death.DeathEnchant; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; -import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; +import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.types.GadgetSet; public class SetWisdom extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index eabf8e7e4..783e16317 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -9,10 +9,10 @@ import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; import mineplex.core.gadget.gadgets.flag.FlagType; -import mineplex.core.gadget.gadgets.particle.ParticleAuraNiceness; -import mineplex.core.gadget.gadgets.particle.ParticleCanadian; -import mineplex.core.gadget.gadgets.particle.ParticleFreedomFireworks; -import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -124,18 +124,18 @@ import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsLove; import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; import mineplex.core.gadget.gadgets.particle.ParticleYinYang; -import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; -import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; -import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.ParticleEmerald; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; -import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; -import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; -import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; -import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; -import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleRain; +import mineplex.core.gadget.gadgets.particle.ParticleMusic; +import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; +import mineplex.core.gadget.gadgets.particle.ParticleFoot; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; -import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; -import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; +import mineplex.core.gadget.gadgets.particle.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index de56e4730..6c79d08c8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -9,10 +9,10 @@ import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.hat.HatType; -import mineplex.core.gadget.gadgets.particle.ParticleAuraNiceness; -import mineplex.core.gadget.gadgets.particle.ParticleCanadian; -import mineplex.core.gadget.gadgets.particle.ParticleFreedomFireworks; -import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; From 1e289271c6230cda88de148cb47ced76c7dca41a Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 02:02:57 -0400 Subject: [PATCH 269/283] Clean up and add comments --- .../core/cosmetic/CosmeticManager.java | 1 - .../core/cosmetic/ui/page/CostumePage.java | 3 -- .../core/cosmetic/ui/page/FlagPage.java | 4 -- .../core/cosmetic/ui/page/GadgetPage.java | 29 ------------- .../mineplex/core/cosmetic/ui/page/Menu.java | 7 +--- .../core/cosmetic/ui/page/MusicPage.java | 3 -- .../arrowtrail/ArrowTrailRedWhite.java | 11 +++-- .../gadget/gadgets/death/DeathMapleLeaf.java | 9 ++-- .../gadgets/doublejump/DoubleJumpMaple.java | 4 -- .../core/gadget/gadgets/flag/FlagType.java | 3 +- .../freedom/ParticleAuraNiceness.java | 42 +++++++++++++------ .../particle/freedom/ParticleCanadian.java | 12 +++--- .../freedom/ParticleFreedomFireworks.java | 10 +++-- .../core/gadget/types/FlagGadget.java | 13 ++---- .../src/mineplex/core/reward/Reward.java | 3 -- .../src/mineplex/core/reward/RewardData.java | 3 -- .../mineplex/core/reward/RewardRarity.java | 3 -- .../treasure/event/TreasureFinishEvent.java | 2 +- .../treasure/event/TreasurePreStartEvent.java | 2 +- .../treasure/event/TreasureStartEvent.java | 3 ++ 20 files changed, 64 insertions(+), 103 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java index 9f0552d86..7cb686de7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java @@ -1,6 +1,5 @@ package mineplex.core.cosmetic; -import mineplex.core.chat.Chat; import mineplex.core.punish.Punish; import org.bukkit.Bukkit; import org.bukkit.ChatColor; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java index 73af59a89..c1a606358 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java @@ -22,9 +22,6 @@ import mineplex.core.gadget.types.OutfitGadget; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -/** - * Created by shaun on 14-09-15. - */ public class CostumePage extends GadgetPage { public CostumePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java index 1a2b98635..8de6f4cdf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java @@ -15,10 +15,6 @@ import org.bukkit.event.inventory.ClickType; import java.util.List; -/** - * @author J Teissler - * @date 6/26/17 - */ public class FlagPage extends GadgetPage { public FlagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index 12523a911..03efda5ce 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -8,12 +8,10 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; -import mineplex.core.gadget.types.FlagGadget; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.account.CoreClientManager; @@ -22,7 +20,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.GadgetButton; @@ -371,19 +368,6 @@ public class GadgetPage extends ShopPageBase meta.setLore(itemLore); gadgetItemStack.setItemMeta(meta); - /*if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH - || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) - { - if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) - { - gadgetItemStack = CountryFlag.USA.getBanner(); - BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta(); - bannerMeta.setDisplayName(C.cGreen + C.Bold + gadget.getName()); - bannerMeta.setLore(meta.getLore()); - gadgetItemStack.setItemMeta(bannerMeta); - } - }*/ - addButton(slot, new ShopItem(gadgetItemStack, false, false).hideInfo(), new DeactivateGadgetButton(gadget, this)); } else @@ -394,19 +378,6 @@ public class GadgetPage extends ShopPageBase meta.setLore(itemLore); gadgetItemStack.setItemMeta(meta); - /*if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH - || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) - { - if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) - { - gadgetItemStack = CountryFlag.USA.getBanner(); - BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta(); - bannerMeta.setDisplayName(C.cGreen + C.Bold + gadget.getName()); - bannerMeta.setLore(meta.getLore()); - gadgetItemStack.setItemMeta(bannerMeta); - } - }*/ - /*if (gadget instanceof MorphStray) { gadgetItemStack = UtilItem.getVersionSpecificItem(_player, UtilPlayer.PlayerVersion._1_9, gadgetItemStack); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 084025a09..a3275ea39 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -1,7 +1,6 @@ package mineplex.core.cosmetic.ui.page; import java.util.ArrayList; -import java.util.Arrays; import java.util.EnumMap; import java.util.List; import java.util.Map; @@ -9,9 +8,7 @@ import java.util.Map; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.cosmetic.ui.button.open.OpenFlags; import mineplex.core.itemstack.ItemBuilder; -import org.bukkit.DyeColor; import org.bukkit.Material; -import org.bukkit.block.Banner; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -20,7 +17,6 @@ import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilUI; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.open.OpenArrowTrails; @@ -49,7 +45,6 @@ import mineplex.core.shop.page.ShopPageBase; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BannerMeta; -import org.bukkit.inventory.meta.ItemMeta; public class Menu extends ShopPageBase { @@ -253,6 +248,8 @@ public class Menu extends ShopPageBase lore = getLore(ownedCount.get(type), maxCount.get(type), "Show off your country's flag!", VISIBILITY_HUB, enabled.get(type)); addButton(flagSlot, new ShopItem(Material.BANNER, "Flags", lore, 1, false), new OpenFlags(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(flagSlot); + + // Copy over banner design BannerMeta banner = (BannerMeta) CountryFlag.MINEPLEX.getBanner().getItemMeta(); BannerMeta meta = ((BannerMeta) getItem(flagSlot).getItemMeta()); meta.setBaseColor(banner.getBaseColor()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java index 97f32d027..49fa65cf7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java @@ -14,9 +14,6 @@ import mineplex.core.gadget.types.GadgetType; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.item.IButton; -/** - * Created by shaun on 14-09-15. - */ public class MusicPage extends GadgetPage { public MusicPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java index e9a3c19e1..37934c81f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java @@ -10,14 +10,14 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ArrowEffectGadget; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.block.banner.Pattern; import org.bukkit.entity.Arrow; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.util.Vector; -import java.awt.*; +import java.awt.Color; +/** + * Trails a red and white double helix behind the arrow. + */ public class ArrowTrailRedWhite extends ArrowEffectGadget { public ArrowTrailRedWhite(GadgetManager manager) @@ -72,7 +72,6 @@ public class ArrowTrailRedWhite extends ArrowEffectGadget @Override public void doHitEffect(Arrow arrow) { - //UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, arrow.getLocation(), 0.35f, 0.35f, 0.35f, 1f, 15, UtilParticle.ViewDist.LONGER); - UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, arrow.getLocation(), 0, 0, 0, 0, 3, UtilParticle.ViewDist.LONGER); + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, arrow.getLocation(), 0, 0, 0, 0, 3, UtilParticle.ViewDist.NORMAL); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java index b1a0e9955..194a2b6d4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java @@ -5,7 +5,6 @@ import mineplex.core.common.shape.ShapeWings; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.gadget.GadgetManager; @@ -16,11 +15,13 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; /** - * @author J Teissler - * @date 6/26/17 + * Displays a giant maple leaf at the point of death. */ public class DeathMapleLeaf extends DeathEffectGadget { + /** height off the ground of the leaf */ + private static final double HEIGHT = 3; + private final ShapeWings _leafOuter = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1.0, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); private final ShapeWings _leafInner = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.7, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); @@ -37,7 +38,7 @@ public class DeathMapleLeaf extends DeathEffectGadget public void onBlood(Player player, BloodEvent event) { event.setCancelled(true); - Location loc = player.getLocation().add(0, 3, 0); + Location loc = player.getLocation().add(0, HEIGHT, 0); _leafOuter.display(loc); _leafInner.display(loc); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java index 1b1396463..4b9d08338 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java @@ -2,8 +2,6 @@ package mineplex.core.gadget.gadgets.doublejump; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilColor; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilText; @@ -12,12 +10,10 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.DoubleJumpEffectGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.util.Vector; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java index 7e2c48e28..aec958dd9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java @@ -3,8 +3,7 @@ package mineplex.core.gadget.gadgets.flag; import mineplex.core.common.util.banner.CountryFlag; /** - * @author J Teissler - * @date 6/27/17 + * Cosmetic flags representing countries. */ public enum FlagType { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java index 8b72b935c..99a22fff4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java @@ -2,14 +2,12 @@ package mineplex.core.gadget.gadgets.particle.freedom; import mineplex.core.arcadeevents.CoreGameStartEvent; import mineplex.core.arcadeevents.CoreGameStopEvent; -import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilShapes; -import mineplex.core.common.util.UtilSound; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.gadget.GadgetManager; @@ -18,19 +16,14 @@ import mineplex.core.treasure.event.TreasureFinishEvent; import mineplex.core.treasure.event.TreasureStartEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockFadeEvent; import org.bukkit.event.block.BlockPhysicsEvent; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.util.Vector; import java.awt.Color; import java.util.HashMap; @@ -43,24 +36,38 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; /** - * @author J Teissler - * @date 6/26/17 + * Places flowers around the player with poofs of red and white */ public class ParticleAuraNiceness extends ParticleGadget { /** Radius within which flowers not allowed near treasure chests */ private static final int TREASURE_RADIUS = 4; + /** Horizontal offset for particle spawns */ private static final double H_FIELD = 0.5; + + /** Vertical offset for particle spawns */ private static final double V_FIELD = 0.35; - private static final int ROSE_PROBABILITY = 30; + + /** How likely a flower is to be spawned (1/n) */ + private static final int ROSE_PROBABILITY = 40; + + /** Radius in which flowers are spawned */ private static final double ROSE_RADIUS = 2.5; + /** How many particles accompany each flower spawn */ + private static final int PARTICLE_COUNT = 20; + + /** List of blocks that have flowers in them */ private final Set _blocks = new HashSet<>(); + /** Milliseconds for which flowers persist */ + private final long DURATION = 5000; + /** Locations at which treasure is currently being opened */ private final Map _openingTreasure = new HashMap<>(); + /** Whether flowers can be spawned in addition to particles */ private boolean _enabled = true; public ParticleAuraNiceness(GadgetManager manager) @@ -102,10 +109,10 @@ public class ParticleAuraNiceness extends ParticleGadget if (_enabled) { _blocks.add(b); - Manager.getBlockRestore().add(b, Material.RED_ROSE.getId(), (byte) 3, 5000); + Manager.getBlockRestore().add(b, Material.RED_ROSE.getId(), (byte) 3, DURATION); } - for (int i = 0; i < 20; ++i) + for (int i = 0; i < PARTICLE_COUNT; ++i) { UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 4, 4, 4), 0, UtilParticle.ViewDist.NORMAL); UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 4, 4, 4), 0, UtilParticle.ViewDist.NORMAL); @@ -122,7 +129,7 @@ public class ParticleAuraNiceness extends ParticleGadget { it.remove(); Location loc = b.getLocation().add(H_FIELD, V_FIELD, H_FIELD); - for (int i = 0; i < 10; ++i) + for (int i = 0; i < PARTICLE_COUNT / 2; ++i) { UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 6, 6, 6), 0, UtilParticle.ViewDist.NORMAL); UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 6, 6, 6), 0, UtilParticle.ViewDist.NORMAL); @@ -131,6 +138,9 @@ public class ParticleAuraNiceness extends ParticleGadget } } + /** + * Stop flowers from popping off of blocks + */ @EventHandler public void onBlockFade(BlockPhysicsEvent event) { @@ -162,12 +172,18 @@ public class ParticleAuraNiceness extends ParticleGadget } } + /** + * Disable flowers on game start + */ @EventHandler public void onGameStart(CoreGameStartEvent event) { _enabled = false; } + /** + * Enable flowers on game end + */ @EventHandler public void onGameEnd(CoreGameStopEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java index 7984af254..c9efa6b5c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java @@ -18,13 +18,17 @@ import org.bukkit.inventory.meta.BannerMeta; import java.awt.Color; /** - * @author J Teissler - * @date 6/26/17 + * Leaves a trail behind the player with the colors of the Canadian flag. */ public class ParticleCanadian extends ParticleGadget { + /** # of lines of particles */ private static final int STRAND_COUNT = 9; + + /** How far apart each line of particles is */ private static final double STRAND_SPACING = 0.124; + + /** How far off the floor the particles begin */ private static final double DISTANCE_FROM_FLOOR = 0.43; public ParticleCanadian(GadgetManager manager) @@ -33,9 +37,7 @@ public class ParticleCanadian extends ParticleGadget UtilText.splitLineToArray(C.cGray + "Lead the way to freedom!", LineFormat.LORE), -8, Material.WOOL, (byte) 0); - ItemStack stack = CountryFlag.CANADA.getBanner(); - System.out.println(((BannerMeta)stack.getItemMeta()).getBaseColor().getColor().toString()); - setDisplayItem(stack); + setDisplayItem(CountryFlag.CANADA.getBanner()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java index 4234a257b..a7a18702e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java @@ -13,22 +13,24 @@ import mineplex.core.updater.event.UpdateEvent; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.util.Vector; import java.util.concurrent.ThreadLocalRandom; /** - * @author J Teissler - * @date 6/26/17 + * Small fireworks which explode around the player */ public class ParticleFreedomFireworks extends ParticleGadget { + /** Block types to source for particles */ private static final Material[] BLOCKTYPES = { Material.REDSTONE_BLOCK, Material.LAPIS_BLOCK, Material.QUARTZ_BLOCK }; + /** Amount of particles for each firework */ + private static final int PARTICLE_COUNT = 20; + public ParticleFreedomFireworks(GadgetManager manager) { super(manager, "Freedom Fireworks", @@ -49,7 +51,7 @@ public class ParticleFreedomFireworks extends ParticleGadget String particle = UtilParticle.ParticleType.BLOCK_CRACK.getParticle(BLOCKTYPES[ThreadLocalRandom.current().nextInt(0, BLOCKTYPES.length)], 0); Location location = UtilMath.gauss(player.getEyeLocation(), 1, 1, 1); - for (int i = 0; i < 20; ++i) + for (int i = 0; i < PARTICLE_COUNT; ++i) { UtilParticle.PlayParticleToAll(particle, location, null, 3.0f, 1, UtilParticle.ViewDist.NORMAL); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java index d28b45a17..7b7d71883 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java @@ -5,26 +5,18 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.banner.CountryFlag; -import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.flag.FlagType; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; -import mineplex.core.itemstack.ItemBuilder; -import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.LeatherArmorMeta; /** - * @author J Teissler - * @date 6/26/17 + * Flags which sit upon players head. */ public class FlagGadget extends Gadget { @@ -88,6 +80,9 @@ public class FlagGadget extends Gadget disable(event.getEntity()); } + /** + * @return The specific gadget which this represents. + */ public FlagType getFlagType() { return _flag; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java index ef209276e..281374325 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java @@ -6,9 +6,6 @@ import org.bukkit.entity.Player; import mineplex.core.common.util.Callback; -/** - * Created by Shaun on 9/2/2014. - */ public abstract class Reward { protected static final Random RANDOM = new Random(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java index 8179dbb98..6f3acd00b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java @@ -2,9 +2,6 @@ package mineplex.core.reward; import org.bukkit.inventory.ItemStack; -/** - * Created by shaun on 14-09-18. - */ public class RewardData { private final String _header; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java index 759769234..eff019430 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java @@ -7,9 +7,6 @@ import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.common.util.C; import static mineplex.core.common.util.C.*; -/** - * Created by Shaun on 9/2/2014. - */ public enum RewardRarity { /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java index ca001e6a5..15a85c4dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.HandlerList; import mineplex.core.treasure.Treasure; /** - * Created by shaun on 14-09-12. + * Called once a player has finished with the treasure opening process. */ public class TreasureFinishEvent extends Event { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java index d384c61db..29355cfd1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** - * Created by shaun on 14-09-12. + * Called when a player selects a chest to open. */ public class TreasurePreStartEvent extends Event implements Cancellable { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java index 70c891f52..37d59dc74 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java @@ -10,6 +10,9 @@ import org.bukkit.event.HandlerList; import mineplex.core.reward.Reward; import mineplex.core.treasure.Treasure; +/** + * Called when a player is able to begin opening chests. + */ public class TreasureStartEvent extends Event { private static final HandlerList handlers = new HandlerList(); From 36ec3014bf250946a21f7fb276dd9a3cd858a1e1 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:31:39 -0400 Subject: [PATCH 270/283] Swap cosmetic menu positions of items --- .../src/mineplex/core/cosmetic/ui/page/Menu.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index a3275ea39..9814c081b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -74,12 +74,12 @@ public class Menu extends ShopPageBase ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false); - int deathSlot = 1; + int deathSlot = 19; int jumpSlot = 28; - int particleSlot = 10; + int particleSlot = 1; int winEffectSlot = 13; int shardSlot = 22; - int arrowSlot = 19; + int arrowSlot = 10; int tauntSlot = 31; int gameModifierSlot = 21; int kitSelectorSlot = 23; @@ -95,7 +95,7 @@ public class Menu extends ShopPageBase addItem(shardSlot, shards); - ItemStack pane = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((byte)15).setTitle("").build(); + ItemStack pane = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((byte)15).setTitle(C.cBlack).build(); for (int i = 0; i <= 45; i += 9) addItem(i, pane.clone()); for (int i = 8; i <= 53; i += 9) addItem(i, pane.clone()); for (int i = 37; i <= 43; ++i) addItem(i, pane.clone()); From 0495b2d1ec86b9b9a2bec4d6cf0f214e29f40be7 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:31:48 -0400 Subject: [PATCH 271/283] Add cosmetics unlock command for all players --- .../commands/UnlockCosmeticsCommand.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java index 43e1a4756..69e6f863d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java @@ -41,13 +41,30 @@ public class UnlockCosmeticsCommand extends CommandBase { addCosmetics(null, caller); } - else if (args.length == 1) + else if (args.length >= 1) { - Player player = Bukkit.getPlayer(args[0]); - if (player != null) + if (args[0].equalsIgnoreCase("all")) { - addCosmetics(null, player); - UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added all the cosmetics to " + F.name(player.getName()) + "!")); + for (Player player : UtilServer.getPlayers()) + { + if (player != null) + { + addCosmetics(null, player); + UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added all the cosmetics to " + F.name(player.getName()) + "!")); + } + } + } + else + { + for (int i = 0; i < args.length; ++i) + { + Player player = Bukkit.getPlayer(args[i]); + if (player != null) + { + addCosmetics(null, player); + UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added all the cosmetics to " + F.name(player.getName()) + "!")); + } + } } } } From 5a3e79a63f0c1547bc50974a8696e9dc57e4d9bd Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:32:00 -0400 Subject: [PATCH 272/283] Add white to maple leaf death effect --- .../src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java index 194a2b6d4..3cfeeb034 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java @@ -22,7 +22,7 @@ public class DeathMapleLeaf extends DeathEffectGadget /** height off the ground of the leaf */ private static final double HEIGHT = 3; - private final ShapeWings _leafOuter = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1.0, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); + private final ShapeWings _leafOuter = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1.0, 1.0, 1.0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); private final ShapeWings _leafInner = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.7, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); public DeathMapleLeaf(GadgetManager manager) From 816f1467aa082a9bcb5eda844ad43efd02f90f23 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:32:12 -0400 Subject: [PATCH 273/283] Remove green from candy cane cosmetics --- .../core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java | 2 +- .../core/gadget/gadgets/particle/ParticleCandyCane.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java index 62f3ad6c4..209da4b7c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java @@ -30,7 +30,7 @@ public class DoubleJumpCandyCane extends DoubleJumpEffectGadget Location loc = player.getLocation(); UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 1), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); - UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 2), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java index 5f31b13fb..e9e572f19 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java @@ -63,7 +63,7 @@ public class ParticleCandyCane extends ParticleGadget UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 1), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); - UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 2), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); + UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); } @EventHandler From a9311e7457ef553e3745ec3b3d496f7624c71cae Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:32:19 -0400 Subject: [PATCH 274/283] Reduce coal fume particles --- .../core/gadget/gadgets/particle/ParticleCoalFumes.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java index 236bc1e8a..651993fb9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java @@ -1,5 +1,6 @@ package mineplex.core.gadget.gadgets.particle; +import mineplex.core.common.util.UtilMath; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -27,7 +28,7 @@ public class ParticleCoalFumes extends ParticleGadget @Override public void playParticle(Player player, UpdateEvent event) { - if(event.getType() != UpdateType.TICK) return; + if(event.getType() != UpdateType.FASTER) return; float xz = 1; int amount = 5; @@ -39,6 +40,6 @@ public class ParticleCoalFumes extends ParticleGadget amount = 2; } - UtilParticle.playParticleFor(player, type, player.getLocation(), xz, 0, xz, 0, amount, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, type, UtilMath.gauss(player.getLocation(), 2, 6, 2), xz, 0, xz, 0, amount, ViewDist.NORMAL); } } From c2b025e8837cd77ed880cc3d8dffb049d2576fda Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:32:39 -0400 Subject: [PATCH 275/283] Distribute heart particles using a gaussian curve --- .../mineplex/core/gadget/gadgets/particle/ParticleHeart.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java index ca008bc75..c48b0ddb4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java @@ -1,5 +1,6 @@ package mineplex.core.gadget.gadgets.particle; +import mineplex.core.common.util.UtilMath; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -37,11 +38,11 @@ public class ParticleHeart extends ParticleGadget { if(getSet() == null || !getSet().isActive(player)) return; - UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1, 0), null, 0, 1, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1.2, 0), null, 0, 1, ViewDist.NORMAL); } else { - UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, ParticleType.HEART, UtilMath.gauss(player.getLocation(), 1, 3, 1).add(0, 1.2, 0), null, 0, 1, ViewDist.NORMAL); } } From 2021a7e321bf45c5cc6667a5d9d3ae95453c9913 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:32:52 -0400 Subject: [PATCH 276/283] Correctly handle taunt cooldowns --- .../gadget/gadgets/taunts/BlowAKissTaunt.java | 8 ++++++-- .../gadget/gadgets/taunts/EternalTaunt.java | 20 +++++++++++++------ .../gadget/gadgets/taunts/RainbowTaunt.java | 8 ++++++-- .../core/gadget/types/TauntGadget.java | 8 +++++--- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java index fdc5da288..c246b2975 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java @@ -35,10 +35,12 @@ public class BlowAKissTaunt extends TauntGadget } @Override - public void onStart(Player player) + public boolean onStart(Player player) { if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) - return; + { + return false; + } HashSet ignore = new HashSet<>(); ignore.add(Material.AIR); @@ -46,6 +48,8 @@ public class BlowAKissTaunt extends TauntGadget BlowAKissEffect blowAKissEffect = new BlowAKissEffect(player, loc, this); blowAKissEffect.start(); + + return true; } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java index 1e0c943b7..59d3c5484 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java @@ -29,9 +29,7 @@ import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.events.EnableArcadeSpawnEvent; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.TauntGadget; -import mineplex.core.game.GameDisplay; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -52,18 +50,21 @@ public class EternalTaunt extends TauntGadget C.cWhite + "Use /taunt in game to show how long you've been waiting.", C.cRed + "Cannot be used while in PvP!"}, LineFormat.LORE), -15, Material.WATCH, (byte) 0); + setCanPlayWithPvp(false); setPvpCooldown(PVP_COOLDOWN); setShouldPlay(true); setEventType(UpdateType.FAST); - addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination); } @Override - public void onStart(Player player) + public boolean onStart(Player player) { if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) - return; + { + return false; + } + UtilFirework.playFirework(player.getLocation(), FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.fromRGB(255, 175, 175)).withFade(Color.RED).build()); _clocks.put(player.getUniqueId(), new ArrayList<>()); @@ -73,16 +74,23 @@ public class EternalTaunt extends TauntGadget if (!Manager.getDisguiseManager().isDisguised(player)) { DisguiseSkeleton disguiseSkeleton = new DisguiseSkeleton(player); - UtilMorph.disguise(player, disguiseSkeleton, Manager); + disguiseSkeleton.setName(player.getName()); + disguiseSkeleton.setCustomNameVisible(true); + disguiseSkeleton.showArmor(); + Manager.getDisguiseManager().disguise(disguiseSkeleton); _disguises.put(player.getUniqueId(), disguiseSkeleton); } + + return true; } @Override public void onPlay(Player player) { if (!_clocks.containsKey(player.getUniqueId())) + { return; + } int i = getPlayerTicks(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java index de81b6a1b..6a49fe8c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java @@ -36,10 +36,12 @@ public class RainbowTaunt extends TauntGadget } @Override - public void onStart(Player player) + public boolean onStart(Player player) { if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) - return; + { + return false; + } Vector dir = player.getLocation().getDirection(); Vector sideA = dir.clone().setX(-dir.getZ()).setZ(dir.getX()); @@ -51,6 +53,8 @@ public class RainbowTaunt extends TauntGadget RainbowTauntEffect rainbowTauntEffect = new RainbowTauntEffect(start, Manager.getPlugin()); rainbowTauntEffect.setTargetLocation(new EffectLocation(end)); rainbowTauntEffect.start(); + + return true; } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java index 991a7425b..c0b11870d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java @@ -76,11 +76,13 @@ public abstract class TauntGadget extends Gadget public void start(Player player) { - onStart(player); - _ticksPerPlayer.put(player.getUniqueId(), 0); + if (onStart(player)) + { + _ticksPerPlayer.put(player.getUniqueId(), 0); + } } - public abstract void onStart(Player player); + public abstract boolean onStart(Player player); public void play(Player player) { From c33c8998f8c52698151cfe5dfe542750ad798068 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:33:00 -0400 Subject: [PATCH 277/283] Change Legend Aura to green --- .../gadgets/particle/ParticleLegend.java | 59 ++++++++----------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java index 51911de42..8337efae4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java @@ -2,7 +2,6 @@ package mineplex.core.gadget.gadgets.particle; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -19,32 +18,27 @@ import mineplex.core.inventory.ClientItem; import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.util.Vector; import java.awt.Color; -import java.util.Random; public class ParticleLegend extends ParticleGadget { private static final double PI = Math.PI; private static final int BASE_PILLARS = 9; - private static final int PILLAR_VARIANCE = 7; - private static final int COLOR_VARIANCE = 5; + private static final int PILLAR_VARIANCE = 8; private static final int MOVING_PARTICLES = 8; private static final double VERTICAL_SPEED = 0.1; private static final double HEIGHT_VARIANCE = 0.8; private static final double ROTATIONAL_SPEED = .03; private static final double RADIAL_VARIANCE = 0.09; - private static final double DARK_PARTICLE_CHANCE = 0.5; private static final double BASE_RADIUS = 1.30; private static final double HEIGHT_MODIFIER_BASE = 0.1; private static final double HEIGHT_MODIFIER_MAX = 1.3; - private static final double HEIGHT_MODIFIER_INTERVAL = 0.2; + private static final double HEIGHT_MODIFIER_INTERVAL = 0.15; private static final Color[] SELECTABLE_COLORS = { - new Color(170, 100, 170), - new Color(50, 10, 60), - new Color(120, 10, 170), - new Color(65, 20, 80) + new Color(60, 170, 25), + new Color(33, 92, 13), + new Color(0, 0, 0) }; private final int _pillars = pillars(); @@ -58,7 +52,7 @@ public class ParticleLegend extends ParticleGadget public ParticleLegend(GadgetManager manager) { super(manager, "Legendary Aura", - UtilText.splitLineToArray(C.cGray + "Let the energy of the End protect you.", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "Legendary energy protects you.", LineFormat.LORE), -1, Material.ENDER_PORTAL_FRAME, (byte)0); } @@ -73,12 +67,19 @@ public class ParticleLegend extends ParticleGadget if (Manager.isMoving(player)) { - Location loc = player.getLocation().add(0, 1.5, 0); for (int i = 0; i < MOVING_PARTICLES; i++) { - UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, - UtilMath.gauss(loc, 8, 4, 8), 0, UtilParticle.ViewDist.NORMAL); + if (_colors[i].getGreen() == 0) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.SMOKE, + UtilMath.gauss(player.getLocation(), 8, 4, 8), null, 0, 1, UtilParticle.ViewDist.NORMAL); + } + else + { + UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, + UtilMath.gauss(player.getLocation(), 8, 4, 8), 0, UtilParticle.ViewDist.NORMAL); + } } } else @@ -96,12 +97,14 @@ public class ParticleLegend extends ParticleGadget for (double h = HEIGHT_MODIFIER_BASE; h <= HEIGHT_MODIFIER_MAX; h+= HEIGHT_MODIFIER_INTERVAL) { - UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, - new Location(player.getWorld(), x, y + h, z), 0, UtilParticle.ViewDist.NORMAL); - - if (Math.random() < DARK_PARTICLE_CHANCE) + if (_colors[i].getGreen() == 0) { - UtilParticle.playColoredParticleToAll(Color.BLACK, UtilParticle.ParticleType.RED_DUST, + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.SMOKE, + new Location(player.getWorld(), x, y + h, z), null, 0, 1, UtilParticle.ViewDist.NORMAL); + } + else + { + UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, new Location(player.getWorld(), x, y + h, z), 0, UtilParticle.ViewDist.NORMAL); } } @@ -175,23 +178,11 @@ public class ParticleLegend extends ParticleGadget private Color[] colors() { - Random random = new Random(); - Color[] array = new Color[_pillars]; for (int i = 0; i < _pillars; i++) { - Color color = SELECTABLE_COLORS[i % SELECTABLE_COLORS.length]; - - int r = color.getRed() + (int) (random.nextGaussian() * COLOR_VARIANCE); - int g = color.getGreen() + (int) (random.nextGaussian() * COLOR_VARIANCE); - int b = color.getBlue() + (int) (random.nextGaussian() * COLOR_VARIANCE); - - r = Math.min(255, Math.max(0, r)); - g = Math.min(255, Math.max(0, g)); - b = Math.min(255, Math.max(0, b)); - - array[i] = new Color(r, g, b); + array[i] = SELECTABLE_COLORS[i % SELECTABLE_COLORS.length]; } return array; @@ -213,7 +204,7 @@ public class ParticleLegend extends ParticleGadget return value; } - + @EventHandler public void legendOwner(PlayerJoinEvent event) { From 732c996e94c60d2165ab410957ac6670afe46e3a Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:33:18 -0400 Subject: [PATCH 278/283] Spawn trail particles behind player model --- .../core/gadget/gadgets/particle/freedom/ParticleCanadian.java | 3 ++- .../gadget/gadgets/particle/freedom/ParticleStarSpangled.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java index c9efa6b5c..4770908b9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java @@ -48,7 +48,8 @@ public class ParticleCanadian extends ParticleGadget return; } - Location center = player.getLocation().add(0, DISTANCE_FROM_FLOOR, 0); + Location center = player.getLocation().subtract(player.getLocation().getDirection().multiply(0.4)) + .subtract(0, 0.1, 0).add(0, DISTANCE_FROM_FLOOR, 0); if (Manager.isMoving(player)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java index cf65cb0dd..7ad601f9a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java @@ -47,7 +47,8 @@ public class ParticleStarSpangled extends ParticleGadget return; } - Location center = player.getLocation().add(0, DISTANCE_FROM_FLOOR, 0); + Location center = player.getLocation().subtract(player.getLocation().getDirection().multiply(0.4)) + .subtract(0, 0.1, 0).add(0, DISTANCE_FROM_FLOOR, 0); if (Manager.isMoving(player)) { From c97506fe0ef4d209facee733a05e50bc9a93d6ad Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:33:28 -0400 Subject: [PATCH 279/283] Align flowers correctly in spring leap --- .../core/gadget/gadgets/doublejump/DoubleJumpSpring.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java index c4d06c230..527b44b0f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java @@ -38,7 +38,7 @@ public class DoubleJumpSpring extends DoubleJumpEffectGadget { for (int i = 50; i < 60; i++) { - Item sunflower = player.getWorld().dropItem(player.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); + Item sunflower = player.getWorld().dropItem(player.getLocation().add(0.0, 0.2, 0.0), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); _items.add(sunflower); Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d)); From eeb8fabafece4ceff2b9403a9926176541785387 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:33:49 -0400 Subject: [PATCH 280/283] Change niceness aura to use red and white tulips --- .../gadget/gadgets/particle/freedom/ParticleAuraNiceness.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java index 99a22fff4..2e68270e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java @@ -108,8 +108,10 @@ public class ParticleAuraNiceness extends ParticleGadget if (_enabled) { + byte data = ThreadLocalRandom.current().nextInt(2) == 0 ? (byte) 4 : 6; + _blocks.add(b); - Manager.getBlockRestore().add(b, Material.RED_ROSE.getId(), (byte) 3, DURATION); + Manager.getBlockRestore().add(b, Material.RED_ROSE.getId(), data, DURATION); } for (int i = 0; i < PARTICLE_COUNT; ++i) From 6639d6eaed5297d0be0aa19b7c3908961fc8799e Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:36:59 -0400 Subject: [PATCH 281/283] Update disabled games for eternal taunt --- .../src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java index 59d3c5484..6e0a7e133 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java @@ -7,6 +7,7 @@ import java.util.Map; import java.util.UUID; import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.game.GameDisplay; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -55,6 +56,7 @@ public class EternalTaunt extends TauntGadget setPvpCooldown(PVP_COOLDOWN); setShouldPlay(true); setEventType(UpdateType.FAST); + addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination, GameDisplay.SmashTraining); } @Override From 13f4211739636f35d17e7e219ce31d004931accf Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:40:24 -0400 Subject: [PATCH 282/283] Stop outfits from taking off flags --- .../src/mineplex/core/gadget/types/OutfitGadget.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java index e5ab85cb3..78471a943 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java @@ -60,7 +60,12 @@ public abstract class OutfitGadget extends Gadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - Manager.removeGadgetType(player, GadgetType.FLAG, this); + + if (_slot == ArmorSlot.HELMET) + { + Manager.removeGadgetType(player, GadgetType.FLAG, this); + } + Manager.removeOutfit(player, _slot); _active.add(player); From dfe2a61b8f09d84e8ce23c899b6716d3c1358704 Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 28 Jun 2017 23:43:30 -0700 Subject: [PATCH 283/283] Revert freedom chest cosmetics --- .../mineplex/core/common/util/UtilMath.java | 118 ----------- .../core/common/shape/ShapeWings.java | 35 +--- .../mineplex/core/common/skin/SkinData.java | 2 - .../core/common/util/UtilParticle.java | 18 -- .../core/common/util/banner/CountryFlag.java | 57 +---- .../core/cosmetic/CosmeticManager.java | 25 +-- .../cosmetic/ui/button/open/OpenFlags.java | 25 --- .../core/cosmetic/ui/page/ArrowTrailPage.java | 10 +- .../core/cosmetic/ui/page/BalloonsPage.java | 6 +- .../core/cosmetic/ui/page/CostumePage.java | 3 + .../cosmetic/ui/page/DeathEffectPage.java | 10 +- .../core/cosmetic/ui/page/DoubleJumpPage.java | 12 +- .../core/cosmetic/ui/page/FlagPage.java | 58 ------ .../core/cosmetic/ui/page/GadgetPage.java | 34 ++- .../core/cosmetic/ui/page/HatPage.java | 12 +- .../cosmetic/ui/page/KitSelectorPage.java | 6 +- .../mineplex/core/cosmetic/ui/page/Menu.java | 83 +++----- .../core/cosmetic/ui/page/MorphPage.java | 12 +- .../core/cosmetic/ui/page/MountPage.java | 4 +- .../core/cosmetic/ui/page/MusicPage.java | 7 +- .../core/cosmetic/ui/page/ParticlePage.java | 12 +- .../core/cosmetic/ui/page/PetPage.java | 13 +- .../core/cosmetic/ui/page/TauntPage.java | 12 +- .../core/cosmetic/ui/page/WinEffectPage.java | 12 +- .../page/custompet/name/CustomPetTagPage.java | 6 - .../mineplex/core/gadget/GadgetManager.java | 190 +++++++---------- .../gadget/commands/LockInfusedCommand.java | 14 +- .../commands/UnlockCosmeticsCommand.java | 27 +-- .../arrowtrail/ArrowTrailRedWhite.java | 77 ------- .../{ => candycane}/ArrowTrailCandyCane.java | 2 +- .../{ => cupidslove}/ArrowTrailCupid.java | 2 +- .../{ => emerald}/ArrowTrailEmerald.java | 2 +- .../{ => freedom}/ArrowTrailFreedom.java | 2 +- .../{ => frostlord}/ArrowTrailFrostLord.java | 2 +- .../{ => halloween}/ArrowTrailHalloween.java | 2 +- .../{ => howlingwinds}/ArrowTrailStorm.java | 2 +- .../{ => music}/ArrowTrailMusic.java | 2 +- .../{ => party}/ArrowTrailConfetti.java | 2 +- .../{ => shadow}/ArrowTrailShadow.java | 2 +- .../{ => spring}/ArrowTrailSpring.java | 2 +- .../{ => titan}/ArrowTrailTitan.java | 2 +- .../{ => vampire}/ArrowTrailBlood.java | 2 +- .../{ => wisdom}/ArrowTrailEnchant.java | 2 +- .../gadget/gadgets/death/DeathMapleLeaf.java | 45 ---- .../death/{ => candycane}/DeathCandyCane.java | 2 +- .../{ => christmas}/DeathPresentDanger.java | 2 +- .../DeathCupidsBrokenHeart.java | 2 +- .../death/{ => emerald}/DeathEmerald.java | 2 +- .../death/{ => freedom}/DeathFreedom.java | 2 +- .../death/{ => frostlord}/DeathFrostLord.java | 2 +- .../death/{ => howlingwinds}/DeathStorm.java | 2 +- .../gadgets/death/{ => music}/DeathMusic.java | 2 +- .../death/{ => party}/DeathPinataBurst.java | 2 +- .../death/{ => shadow}/DeathShadow.java | 2 +- .../death/{ => spring}/DeathSpring.java | 2 +- .../gadgets/death/{ => titan}/DeathTitan.java | 2 +- .../death/{ => vampire}/DeathBlood.java | 2 +- .../death/{ => wisdom}/DeathEnchant.java | 2 +- .../gadgets/doublejump/DoubleJumpMaple.java | 110 ---------- .../{ => candycane}/DoubleJumpCandyCane.java | 4 +- .../DoubleJumpCupidsWings.java | 2 +- .../{ => emerald}/DoubleJumpEmerald.java | 2 +- .../{ => freedom}/DoubleJumpFreedom.java | 4 +- .../{ => frostlord}/DoubleJumpFrostLord.java | 2 +- .../{ => halloween}/DoubleJumpHalloween.java | 2 +- .../{ => howlingwinds}/DoubleJumpStorm.java | 2 +- .../{ => music}/DoubleJumpMusic.java | 2 +- .../{ => party}/DoubleJumpFirecracker.java | 2 +- .../{ => shadow}/DoubleJumpShadow.java | 2 +- .../{ => spring}/DoubleJumpSpring.java | 4 +- .../{ => titan}/DoubleJumpTitan.java | 2 +- .../{ => vampire}/DoubleJumpBlood.java | 2 +- .../{ => wisdom}/DoubleJumpEnchant.java | 2 +- .../core/gadget/gadgets/flag/FlagType.java | 33 --- .../core/gadget/gadgets/hat/HatType.java | 6 +- .../gadgets/particle/ParticleCoalFumes.java | 5 +- .../gadgets/particle/ParticleLegend.java | 177 +--------------- .../{ => candycane}/ParticleCandyCane.java | 4 +- .../{ => cupidslove}/ParticleHeart.java | 7 +- .../{ => emerald}/ParticleEmerald.java | 2 +- .../freedom/ParticleAuraNiceness.java | 194 ------------------ .../particle/freedom/ParticleCanadian.java | 71 ------- .../freedom/ParticleFreedomFireworks.java | 59 ------ .../freedom/ParticleStarSpangled.java | 81 -------- .../{ => frostlord}/ParticleFrostLord.java | 2 +- .../{ => howlingwinds}/ParticleRain.java | 2 +- .../particle/{ => music}/ParticleMusic.java | 2 +- .../{ => party}/ParticlePartyTime.java | 2 +- .../particle/{ => shadow}/ParticleFoot.java | 2 +- .../particle/{ => titan}/ParticleTitan.java | 2 +- .../particle/{ => vampire}/ParticleBlood.java | 2 +- .../{ => wisdom}/ParticleEnchant.java | 2 +- .../gadget/gadgets/taunts/BlowAKissTaunt.java | 8 +- .../gadget/gadgets/taunts/EternalTaunt.java | 38 +--- .../gadget/gadgets/taunts/RainbowTaunt.java | 8 +- .../mineplex/core/gadget/set/SetCanadian.java | 22 -- .../core/gadget/set/SetCandyCane.java | 8 +- .../core/gadget/set/SetCupidsLove.java | 8 +- .../mineplex/core/gadget/set/SetEmerald.java | 8 +- .../mineplex/core/gadget/set/SetFreedom.java | 10 +- .../core/gadget/set/SetFrostLord.java | 8 +- .../core/gadget/set/SetHowlingWinds.java | 8 +- .../mineplex/core/gadget/set/SetMusic.java | 8 +- .../mineplex/core/gadget/set/SetParty.java | 8 +- .../mineplex/core/gadget/set/SetShadow.java | 8 +- .../mineplex/core/gadget/set/SetSpring.java | 6 +- .../mineplex/core/gadget/set/SetTitan.java | 8 +- .../mineplex/core/gadget/set/SetVampire.java | 8 +- .../mineplex/core/gadget/set/SetWisdom.java | 8 +- .../core/gadget/types/FlagGadget.java | 90 -------- .../core/gadget/types/GadgetType.java | 3 +- .../mineplex/core/gadget/types/HatGadget.java | 2 +- .../core/gadget/types/MorphGadget.java | 3 +- .../core/gadget/types/OutfitGadget.java | 7 +- .../core/gadget/types/TauntGadget.java | 8 +- .../core/mount/types/MountTitanData.java | 4 +- .../src/mineplex/core/reward/Reward.java | 3 + .../src/mineplex/core/reward/RewardData.java | 3 + .../mineplex/core/reward/RewardManager.java | 132 +++++------- .../mineplex/core/reward/RewardRarity.java | 3 + .../treasure/event/TreasureFinishEvent.java | 2 +- .../treasure/event/TreasurePreStartEvent.java | 2 +- .../treasure/event/TreasureStartEvent.java | 3 - .../core/treasure/gui/TreasurePage.java | 66 ++---- .../src/mineplex/clanshub/HubManager.java | 2 +- .../src/mineplex/hub/HubManager.java | 2 +- .../src/nautilus/game/arcade/Arcade.java | 2 +- .../src/mineplex/mavericks/review/Hub.java | 2 +- .../src/mineplex/gemhunters/GemHunters.java | 2 +- 129 files changed, 416 insertions(+), 1905 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => candycane}/ArrowTrailCandyCane.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => cupidslove}/ArrowTrailCupid.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => emerald}/ArrowTrailEmerald.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => freedom}/ArrowTrailFreedom.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => frostlord}/ArrowTrailFrostLord.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => halloween}/ArrowTrailHalloween.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => howlingwinds}/ArrowTrailStorm.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => music}/ArrowTrailMusic.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => party}/ArrowTrailConfetti.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => shadow}/ArrowTrailShadow.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => spring}/ArrowTrailSpring.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => titan}/ArrowTrailTitan.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => vampire}/ArrowTrailBlood.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{ => wisdom}/ArrowTrailEnchant.java (97%) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => candycane}/DeathCandyCane.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => christmas}/DeathPresentDanger.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => cupidslove}/DeathCupidsBrokenHeart.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => emerald}/DeathEmerald.java (93%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => freedom}/DeathFreedom.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => frostlord}/DeathFrostLord.java (93%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => howlingwinds}/DeathStorm.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => music}/DeathMusic.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => party}/DeathPinataBurst.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => shadow}/DeathShadow.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => spring}/DeathSpring.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => titan}/DeathTitan.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => vampire}/DeathBlood.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{ => wisdom}/DeathEnchant.java (97%) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => candycane}/DoubleJumpCandyCane.java (91%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => cupidslove}/DoubleJumpCupidsWings.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => emerald}/DoubleJumpEmerald.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => freedom}/DoubleJumpFreedom.java (92%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => frostlord}/DoubleJumpFrostLord.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => halloween}/DoubleJumpHalloween.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => howlingwinds}/DoubleJumpStorm.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => music}/DoubleJumpMusic.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => party}/DoubleJumpFirecracker.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => shadow}/DoubleJumpShadow.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => spring}/DoubleJumpSpring.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => titan}/DoubleJumpTitan.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => vampire}/DoubleJumpBlood.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{ => wisdom}/DoubleJumpEnchant.java (97%) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => candycane}/ParticleCandyCane.java (93%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => cupidslove}/ParticleHeart.java (84%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => emerald}/ParticleEmerald.java (96%) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => frostlord}/ParticleFrostLord.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => howlingwinds}/ParticleRain.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => music}/ParticleMusic.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => party}/ParticlePartyTime.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => shadow}/ParticleFoot.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => titan}/ParticleTitan.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => vampire}/ParticleBlood.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => wisdom}/ParticleEnchant.java (96%) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java index 1b3b40835..5e37e0ac5 100644 --- a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java @@ -6,7 +6,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Random; -import java.util.concurrent.ThreadLocalRandom; import org.bukkit.Location; import org.bukkit.entity.Entity; @@ -14,8 +13,6 @@ import org.bukkit.util.Vector; public class UtilMath { - public static final double TAU = Math.PI * 2D; - public static double trim(int degree, double d) { String format = "#.#"; @@ -335,119 +332,4 @@ public class UtilMath return min; } - - /** - * Creates an array of points, arranged in a circle normal to a vector. - * - * @param center The center of the circle. - * @param normal A vector normal to the circle. - * @param radius The radius of the circle. - * @param points How many points to make up the circle. - * - * @return An array of points of the form double[point #][x=0, y=1, z=3]. - */ - public static double[][] normalCircle(Location center, Vector normal, double radius, int points) - { - return normalCircle(center.toVector(), normal, radius, points); - } - - /** - * Creates an array of points, arranged in a circle normal to a vector. - * - * @param center The center of the circle. - * @param normal A vector normal to the circle. - * @param radius The radius of the circle. - * @param points How many points to make up the circle. - * - * @return An array of points of the form double[point #][x=0, y=1, z=3]. - */ - public static double[][] normalCircle(Vector center, Vector normal, double radius, int points) - { - Vector n = normal.clone().normalize(); - Vector a = n.clone().add(new Vector(1, 1, 1)).crossProduct(n).normalize(); - Vector b = n.getCrossProduct(a).normalize(); - - double[][] data = new double[points][3]; - - double interval = TAU / points; - double theta = 0; - - for (int i = 0; i < points; i++) - { - data[i][0] = center.getX() + (radius * ((Math.cos(theta) * a.getX()) + (Math.sin(theta) * b.getX()))); - data[i][1] = center.getY() + (radius * ((Math.cos(theta) * a.getY()) + (Math.sin(theta) * b.getY()))); - data[i][2] = center.getZ() + (radius * ((Math.cos(theta) * a.getZ()) + (Math.sin(theta) * b.getZ()))); - theta += interval; - } - - return data; - } - - /** - * Slightly randomize a location with a standard deviation of one. - * - * @param location The location to randomize. - * - * @return The original location, now gaussian-randomized. - */ - public static Location gauss(Location location) - { - return gauss(location, 1, 1, 1); - } - - /** - * Slightly randomize a vector with a standard deviation of one. - * - * @param vector The location to randomize. - * - * @return The randomized vector, now gaussian-randomized. - */ - public static Vector gauss(Vector vector) - { - return gauss(vector, 1, 1, 1); - } - - /** - * Slightly randomize a location with a standard deviation of one.
- * - * This method only accepts positive values for all of its arguments.
- * - * A good parameter set for small offsets is (loc, 10, 10, 10). - * - * @param location The location to randomize. - * @param x A granularity control for the x-axis, higher numbers = less randomness - * @param y A granularity control for the y-axis, higher numbers = less randomness - * @param z A granularity control for the z-axis, higher numbers = less randomness - * - * @return The original location, now gaussian-randomized - */ - public static Location gauss(Location location, double x, double y, double z) - { - return location.clone().add( - x <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / x), - y <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / y), - z <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / z)); - } - - /** - * Slightly randomize a vector with a standard deviation of one.
- * - * This method only accepts positive values for all of its arguments.
- * - * A good parameter set for small offsets is (loc, 10, 10, 10). - * - * @param vector The location to randomize. - * @param x A granularity control for the x-axis, higher numbers = less randomness - * @param y A granularity control for the y-axis, higher numbers = less randomness - * @param z A granularity control for the z-axis, higher numbers = less randomness - * - * @return The randomized vector, now gaussian-randomized - */ - public static Vector gauss(Vector vector, double x, double y, double z) - { - return vector.clone().add(new Vector( - x <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / x), - y <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / y), - z <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / z))); - } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java index 4026dad3f..3c9a78a56 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java @@ -166,40 +166,7 @@ public class ShapeWings extends ShapeGrid implements CosmeticShape "0$#######$0", "$#########$" }; - - public static final String[] MAPLE_LEAF = new String[] - { - "000000000000000000000000000$000000000000000000000000000", - "00000000000000000000000000$$$00000000000000000000000000", - "0000000000000000000000000$$#$$0000000000000000000000000", - "000000000000000000000000$$###$$000000000000000000000000", - "00000000000000000000000$$#####$$00000000000000000000000", - "0000000000000000$$$000$$#######$$000$$$0000000000000000", - "0000000000000000$#$$$$$#########$$$$$#$0000000000000000", - "0000000000000000$$###################$$0000000000000000", - "00000000000000000$###################$00000000000000000", - "00000000000$$0000$$#################$$0000$$00000000000", - "0$$$000000$$$$$000$#################$000$$$$$000000$$$0", - "00$$$$$$$$$###$$$0$$###############$$0$$$###$$$$$$$$$00", - "00$$############$$$$###############$$$$############$$00", - "000$$#############$$###############$$#############$$000", - "0000$$###########################################$$0000", - "00$$$#############################################$$$00", - "$$$#################################################$$$", - "00$$$$###########################################$$$$00", - "00000$$$#######################################$$$00000", - "00000000$$$$###############################$$$$00000000", - "00000000000$$$###########################$$$00000000000", - "0000000000000$$#########################$$0000000000000", - "0000000000000$$#########################$$0000000000000", - "0000000000000$##$$$$$$$$$$$#$$$$$$$$$$$##$0000000000000", - "000000000000$$$$$000000000$#$000000000$$$$$000000000000", - "00000000000000000000000000$#$00000000000000000000000000", - "00000000000000000000000000$#$00000000000000000000000000", - "00000000000000000000000000$#$00000000000000000000000000", - "00000000000000000000000000$#$00000000000000000000000000", - "00000000000000000000000000$$$00000000000000000000000000" - }; + /** * Default rotation to give the wings a little tilt when displayed on players for instance diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index 6b7b7a675..f803154ce 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -78,8 +78,6 @@ public class SkinData public static final SkinData LARISSA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjE0MTUxMzQsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jYThjNDRhOWVmZTY3NzExMDYzMjM5ODEwNDRmOTdjYmM1OWJmZmRlOGI1ODdlMGQzMWE4N2ViMDhhMmExZiJ9fX0=", "Lyac51CrnMK/CI2dWgGQLowAm/ZnQMpf0Ict/gqVrUgJVlGWDIVG77Rd1JyMQDEeESvTmoyivH+usiO0ePW95qjisqT3R43YEmLi85CqctGYqLKeSYpGYwYRz8Euw57LwJAALKOMLhVc2s4h2Or9nTecunG8KSmkCuZc4H1qh3frU+ltuV4HLqgdFUULbIHTggyvqiINov2tBqkkXeEjT7sOcTJCJNgNYU2O7//qg5kJmhso2CKHlRLpmy9LsaUK/Z+BzUmoRbwQgSwr3mz7dFAdlVWWKvKNcgX3nt1et0DIig3JKYmrnQX2Fprg+kWcr3nuizzLgjVwAlADC48P3DN0s/VBty2AYoWie16VNPIM+CV4BF2JRQ34GxZ8XceXbCKURrOjoCBgLGHvIhRW35eicoh26xp3/mwLvk5anPi5StJ/qEuzWJALeWcNbLsnt21m2MZp9h/MxaY6ftWOTzjTr5CYVd/teJyscMnGK4+lcV1dlt12lhbDMv6I+iz8iG9NIzuW5OvGkax90dA/Gq+Cd9FXVThPY4ufxWttHcTqgPB64GfMn6rywRm1B0eO1pJpYc/KlJZlW/PuaO8L1assyJs5KkOypBSy3zc6TO6pzgeOZv+VpQfA/UWpogv6ofmTpgdtwpjLFGSzIKTDXvF6FftALKVlYypG0fYbssA="); public static final SkinData ROWENA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0Njk1MTcxOTgsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jNDY1OGExODY4YzNhNjhhZWVhZmZkOTUxZDQyYmZkN2QxYTRjNGZjNDJjZDI2YTlmYzhkNTNmOTkxMTM1ZCJ9fX0=", "OqXMyH9SMmQ/Pwmb21In29YnCxbsN6yqUxfudN6KNgDwRUK6y072XhW6TIoTh9JQLAUKftpeVB53tk0LxHIxnsuBMrIHvETPDQFysIc/6xq3ABogs+zqFzcp5jk6S73HiD78JxLq5pzfUzhgDPMPuZP5Q/u2q1rYbe6B9lVEJ5sUcxBLUTossgucoR4qXYAlWVQdHRhq85Ol8a+OU7ruw3HackNGto6wt6u2MigCtiHVTt9XhJ/AJE4ScodQ3XwW4L6urpl/lV2OMCsr3mCjjjEz2EMhDbCWxrAorQ9aPpMbDkHBS+4TC1tbMGUlKhj5n+EZBYVaeLr4NGPACPSdT35p/2Zra49+DXn9Xn+681yNEB0ghTdsnsgwXg76+HVPHPqRHQMuTBQGQyGZaaTX/zE0tFjH+osMElLdb8dmz3dC7kQA4A13B2phj3YbMSF1FoU4GvnPKIQn6JIuEd6hd+pRLUW7Y+mgYIHHX1FT0ihrXAyVO6lQQ6rs92gSQr7sxC7tnhPSMFcmh7OcJYcbRpn97GMubthPLanOhVy7CKqjmwIkEVtYgP28idigKwNJ+sJuUONrOu7nMKl1UTD5EEapOacc/np6UhdSw8yW+LnWD/x9ueYz9ksnyRrJgcOa41izo/WCbjPK/j3JVezr9Q3x1yveWuFmdl7CGYdXngw="); public static final SkinData BIFF = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjEzMDQzNjYsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9mOWMyMTE3ZDY0ZWE0ZmUxMWZiY2NhZmE2YzU5YzhlZjY3NDVkZjVkMTZjM2QwMmI4NmI2OTlmZWJjNTA0OGI1In19fQ==", "mJMpEvQ4A02z0S/chgLm5bKrrrd+zmp7A0012AB7b3KlyIHoLKEDDz+ZJgJtvN6skOqed3P+yNVqkxitugXaZZP8Af9J+/TseHn+vOy6CTK5tykRSY3Zb8Zmw1kn36v/SARAVtDIHD53yuPgJayYSAbVB7aknj1Q8XBQGUmZRMRxWWxeD7rQTOwgRYI4YJeKFf4UL9i6zxvOJuHsOAouJ7scu7VohG8vgR77Js/Z8rSu8/aSG+O9AQdzP6h9ixYNFkkQOHm7DseK/5tsWKHM4FYBgjIDKt3ApQokSbhThzGB55BA1qjXZkfCoOb13y1nOMC8WoIL6Ees1qzxG3VloGx2WAZLh+Q+/irwrFDMxk1zeU5fIRuj1c/UIM2HKdxxWgoRdrZ8ww/Jrll6maiOBx7geMn/0aOUbJ2U7gkTif6RG6YNS5YN9ZQDLh72l/akJMxF3SlmuAPmLs2kBghQ6eD2YQKuxWR/Hf1yS1YXtogFVNsGnzC1nda7F48EGL3zI+kCajbDlAGQ32aRt0btbEQ+Gj575kir3Aa53qiZ0YOIYQlhgZdOsTN2NE2s8uuy/15Rgc6K3ydgEmSZfdqyMyW0Dy7pE5TfVL8DumKRVRXdOceT5WfnW7MyqSmdorP5ab1fw2wLOnAVzhJmW8oXXNSs77WJ1/PURclxOWB4IF8="); - public static final SkinData CANADA_HAT = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg2MDE5MDYwNzYsInByb2ZpbGVJZCI6IjdkYTJhYjNhOTNjYTQ4ZWU4MzA0OGFmYzNiODBlNjhlIiwicHJvZmlsZU5hbWUiOiJHb2xkYXBmZWwiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2M2MTExNTNmODdmMjZjMzRmOTdkODIxM2ZmOTk1ZGJlNjcyZWJkNGM0NjRkNGFkNzM5MWFlNDNjMWU3YTllIn19fQ", "QMw6e1FXl/Xrt+BbfPKsz3OHyOxL9CEPffS9grxRLD6gbLbMD84OT3+bge5V9lBFn9PPnTyID+WTF24qHj4ADTTgK94ykNedCEO6R1wS0FZKPI1UjwOxMhIG5ZeVr7+HxITgGU4Xz94IigBkvW//f2ZGelMvS0GLCrm4iCovEBMUzyYJ2dZ4xgzFSH6v+9efK4/SBAJaj8mHjXpDxU58/vskTGI3T9t5sWlZLXgId9vHcMj0GH3Un6yvUXiMkh38V/rAEM8/R8q08xUVyW0e2R38qWQV2+eKvsG8GmJmgkU/78wA9cKGZdrEz0pnr80eGNCbvXqQvC/czYhEhDapgxfndcHLX8q/Zk3I8msNr340E4ZrQL61Yl7KcVC1qEUQVu3cosq5A6ckXLGvv//HSwXVO8M9ThUbuEC8QjiS/fMFufnVa18lHrVulnfb/2KQ4yPsoCHK/zvGtRkWtD1sLOIfehN+sxCLiaz80ILBiwN0oHITfNHpJzoa4kF/OrxxCualp4Sv5o5TXBv7aWsO18v9ixb9o9CmJKKE8MUl5xmRVz4HQD4dyOfcwtPuxmfcYjJrxqBijdQMrcgLzqqMs+DUqcZZlxM7M5GaNUoEvL9tJNGpZaB2OrBw0DTk5wx15XfANCH4egx8X4+Iy2RUoFthHX3BsVazG7fjSiDnUtI="); - public static final SkinData AMERICA_HAT = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg2MDI3MjMyODgsInByb2ZpbGVJZCI6IjNlMjZiMDk3MWFjZDRjNmQ5MzVjNmFkYjE1YjYyMDNhIiwicHJvZmlsZU5hbWUiOiJOYWhlbGUiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzYzMjI0MDhkYzBiZjMxNjU4N2RiNDJiN2Q5ZmViZTUwYWQ4MGY0OGU4Njc5YzI0NTFkOTk3MTdjZmVjNTdkYWQifX19","oRo6DIuhOTaXDkFsgwJ488LWqx5d1QpwtglwG1SdEvkbX1aCMGdZyDm9YIopQRjfBg0uYKQFetOZ1ZkdMmc/aKC5/dm0+Ema7g8AUzjwf4OaSLH1r4C1UJ4ruaNG5diBxNTkYnMa7yT8zvyEr22CA7lUOIgTh8ymBfSGK35RPhsn8jM0hDjdhjemBAlxKpiioByfmAQbwokNBOrXfh/PnKq+iJYg4WpMSZ1zo5Rr0CzLXwu+/T3dvrb6mg7qry7J3Lj5/qn6iIdBcjJBeyvy1sCo45jQ3Rzc6oL/84Vu5Dpn395EqUK8Sa7mdpVpATTcj56TCjkNNtDapXNqyO/IIQuzU4wnBKNQmZefaxRl6LV0DhZ8n8YQaPj6hH/mr2oDsd23+jejjqu6Y95ReTyukp06mIGqgekmrdZV2etML2oMAOTv9ieVvqtfo5gEomYs+NFAL7rMmzjAlhd17VOgqNRMpmJazAHWOYKl8KdOH99wGDe5XcyKHysh+qyHKMvhPJztIeAEaosynF/aGHghH2PM354KCuUVNmdR5G7UZUoG9ZA5ZU3EzZ854jeqxcqw3jzb6qL7A83QNuFqOsb87ugL/jO3QEDdQ9drdf3WAQauQGkU3nYBrls5wxoMrQ+Ceth+FtZw9a1v7dc+DEWOeJKCtOAIskb29pv6OcRe0Wk="); // Comments this out for now, so it doesn't load the player profile // A better way to do this would check for the properties when getting the skull or the skin diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java index cc58f5d0d..a87bb2565 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java @@ -418,22 +418,4 @@ public class UtilParticle PlayParticleToAll(particleType, location, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1f, count, dist); } - public static void playColoredParticle(java.awt.Color color, ParticleType particleType, Location location, int count, ViewDist dist, Player... players) - { - if (particleType != ParticleType.RED_DUST - && particleType != ParticleType.MOB_SPELL_AMBIENT) - return; - PlayParticle(particleType, location, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1f, count, dist, players); - } - - public static void playColoredParticleToAll(java.awt.Color color, ParticleType particleType, Location location, int count, ViewDist dist) - { - if (particleType != ParticleType.RED_DUST && particleType != ParticleType.MOB_SPELL_AMBIENT) - { - return; - } - - PlayParticleToAll(particleType, location, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1f, count, dist); - } - } \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java index 54626d736..d4e48144f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java @@ -1,30 +1,17 @@ package mineplex.core.common.util.banner; import org.bukkit.DyeColor; -import org.bukkit.Material; import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.PatternType; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; - -import static org.bukkit.DyeColor.*; -import static org.bukkit.block.banner.PatternType.*; public enum CountryFlag { - // Vetted - MINEPLEX("Mineplex", "Mineplexian", BLACK, new Pattern(ORANGE, TRIANGLE_TOP), new Pattern(BLACK, TRIANGLES_TOP), - new Pattern(ORANGE, STRIPE_LEFT), new Pattern(ORANGE, STRIPE_RIGHT), new Pattern(BLACK, BORDER), - new Pattern(BLACK, STRIPE_BOTTOM)), - USA("The United States of America", "American", RED, new Pattern(WHITE, STRIPE_SMALL), new Pattern(BLUE, SQUARE_TOP_RIGHT), - new Pattern(BLUE, SQUARE_TOP_RIGHT), new Pattern(BLUE, SQUARE_TOP_RIGHT)), - - CANADA("Canada", "Canadian", WHITE, new Pattern(RED, CROSS), new Pattern(WHITE, STRIPE_LEFT), new Pattern(RED, STRIPE_MIDDLE), - new Pattern(WHITE, BORDER), new Pattern(RED, STRIPE_TOP), new Pattern(RED, STRIPE_BOTTOM)), - - // Not Vetted BRAZIL(DyeColor.GREEN, new Pattern(DyeColor.YELLOW, PatternType.RHOMBUS_MIDDLE), new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)), + USA(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.BLUE, PatternType.SQUARE_TOP_RIGHT)), + CANADA(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM), + new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)), UK(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNLEFT), new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNRIGHT), new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.CROSS)), IRELAND(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.STRIPE_TOP), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_BOTTOM)), @@ -67,47 +54,17 @@ public enum CountryFlag new Pattern(DyeColor.GREEN, PatternType.STRIPE_CENTER), new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_BOTTOM)), POLAND(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.HALF_VERTICAL_MIRROR)); - private final String _country; - private final String _adjective; - private final DyeColor _baseColor; - private final Pattern[] _patterns; + private DyeColor _baseColor; + private Pattern[] _patterns; - CountryFlag(String country, String adjective, DyeColor baseColor, Pattern... patterns) - { - _country = country; - _adjective = adjective; + CountryFlag(DyeColor baseColor, Pattern... patterns){ _baseColor = baseColor; _patterns = patterns; } - CountryFlag(DyeColor baseColor, Pattern... patterns) - { - this("", "", baseColor, patterns); - } - public ItemStack getBanner() { - ItemStack banner = new ItemStack(Material.BANNER); - BannerMeta bannerMeta = (BannerMeta) banner.getItemMeta(); - bannerMeta.setBaseColor(_baseColor); - - for (Pattern pattern : _patterns) - { - bannerMeta.addPattern(pattern); - } - - banner.setItemMeta(bannerMeta); - return banner; - } - - public String getCountryName() - { - return _country; - } - - public String getCountryAdjective() - { - return _adjective; + return UtilBanner.createBanner(_baseColor, _patterns); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java index 7cb686de7..d1ae7b491 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java @@ -1,6 +1,5 @@ package mineplex.core.cosmetic; -import mineplex.core.punish.Punish; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -42,23 +41,19 @@ import mineplex.core.twofactor.TwoFactorAuth; public class CosmeticManager extends MiniPlugin { private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class); - private final InventoryManager _inventoryManager; - private final GadgetManager _gadgetManager; - private final MountManager _mountManager; - private final PetManager _petManager; - private final TreasureManager _treasureManager; - private final BoosterManager _boosterManager; - private final Punish _punish; + private InventoryManager _inventoryManager; + private GadgetManager _gadgetManager; + private MountManager _mountManager; + private PetManager _petManager; + private TreasureManager _treasureManager; + private BoosterManager _boosterManager; private CosmeticShop _shop; private boolean _showInterface = true; private int _interfaceSlot = 4; - public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, - InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, - PetManager petManager, TreasureManager treasureManager, BoosterManager boosterManager, - Punish punish) + public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager, TreasureManager treasureManager, BoosterManager boosterManager) { super("Cosmetic Manager", plugin); @@ -68,7 +63,6 @@ public class CosmeticManager extends MiniPlugin _petManager = petManager; _treasureManager = treasureManager; _boosterManager = boosterManager; - _punish = punish; _shop = new CosmeticShop(this, clientManager, donationManager, _moduleName); } @@ -248,11 +242,6 @@ public class CosmeticManager extends MiniPlugin { return _boosterManager; } - - public Punish getPunishManager() - { - return _punish; - } public void displayUI(Player player) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java deleted file mode 100644 index 987d549ac..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java +++ /dev/null @@ -1,25 +0,0 @@ -package mineplex.core.cosmetic.ui.button.open; - -import mineplex.core.cosmetic.ui.page.FlagPage; -import mineplex.core.cosmetic.ui.page.HatPage; -import mineplex.core.cosmetic.ui.page.Menu; -import mineplex.core.gadget.types.Gadget; -import org.bukkit.entity.Player; - -/** - * @author J Teissler - * @date 6/26/17 - */ -public class OpenFlags extends OpenPageButton -{ - public OpenFlags(Menu menu, Gadget active) - { - super(menu, active); - } - - @Override - protected void leftClick(Player player) - { - getMenu().getShop().openPageForPlayer(player, new FlagPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(), "Flags", player)); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java index e4d1333f9..80db4bcd6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java @@ -33,16 +33,12 @@ public class ArrowTrailPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.ARROW_TRAIL) == gadget) - { - addGlow(slot); - } + addGlow(slot); slot++; - if (slot % 9 == 8) - { - slot += 2; - } + if (slot == 17) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java index 3208e5a05..fd0b3cf08 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java @@ -32,16 +32,12 @@ public class BalloonsPage extends GadgetPage addGadget(gadget, slot); if (gadget.isActive(getPlayer())) - { addGlow(slot); - } slot++; - if (slot % 9 == 8) - { + if (slot == 17 || slot == 26) slot += 2; - } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java index c1a606358..73af59a89 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java @@ -22,6 +22,9 @@ import mineplex.core.gadget.types.OutfitGadget; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; +/** + * Created by shaun on 14-09-15. + */ public class CostumePage extends GadgetPage { public CostumePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java index a54b7f840..07dbee136 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java @@ -33,16 +33,12 @@ public class DeathEffectPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.DEATH) == gadget) - { - addGlow(slot); - } + addGlow(slot); slot++; - if (slot % 9 == 8) - { - slot += 2; - } + if (slot == 17) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java index 8ecddc541..f9748cb06 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java @@ -33,16 +33,12 @@ public class DoubleJumpPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.DOUBLE_JUMP) == gadget) - { - addGlow(slot); - } + addGlow(slot); slot++; - - if (slot % 9 == 8) - { - slot += 2; - } + + if (slot == 17) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java deleted file mode 100644 index 8de6f4cdf..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java +++ /dev/null @@ -1,58 +0,0 @@ -package mineplex.core.cosmetic.ui.page; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.donation.DonationManager; -import mineplex.core.gadget.types.Gadget; -import mineplex.core.gadget.types.GadgetType; -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.item.ShopItem; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import java.util.List; - -public class FlagPage extends GadgetPage -{ - public FlagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, - Player player) - { - super(plugin, shop, clientManager, donationManager, name, player); - } - - @Override - protected void buildPage() - { - int slot = 10; - - List list = getPlugin().getGadgetManager().getGadgets(GadgetType.FLAG); - if(list != null) - for (Gadget gadget : list) - { - addGadget(gadget, slot); - - if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.FLAG) == gadget) - { - addGlow(slot); - } - - slot++; - - if (slot % 9 == 8) - { - slot += 2; - } - } - - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() - { - public void onClick(Player player, ClickType clickType) - { - getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); - } - }); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index 03efda5ce..657d98b30 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -12,6 +12,7 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.account.CoreClientManager; @@ -20,6 +21,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.GadgetButton; @@ -58,16 +60,12 @@ public class GadgetPage extends ShopPageBase addGadget(gadget, slot); if (getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.getDisplayName()) > 0) - { addGlow(slot); - } slot++; - if (slot % 9 == 8) - { + if (slot == 17 || slot == 26) slot += 2; - } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() @@ -368,6 +366,19 @@ public class GadgetPage extends ShopPageBase meta.setLore(itemLore); gadgetItemStack.setItemMeta(meta); + if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH + || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) + { + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) + { + gadgetItemStack = CountryFlag.USA.getBanner(); + BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta(); + bannerMeta.setDisplayName(C.cGreen + C.Bold + gadget.getName()); + bannerMeta.setLore(meta.getLore()); + gadgetItemStack.setItemMeta(bannerMeta); + } + } + addButton(slot, new ShopItem(gadgetItemStack, false, false).hideInfo(), new DeactivateGadgetButton(gadget, this)); } else @@ -378,6 +389,19 @@ public class GadgetPage extends ShopPageBase meta.setLore(itemLore); gadgetItemStack.setItemMeta(meta); + if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH + || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) + { + if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) + { + gadgetItemStack = CountryFlag.USA.getBanner(); + BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta(); + bannerMeta.setDisplayName(C.cGreen + C.Bold + gadget.getName()); + bannerMeta.setLore(meta.getLore()); + gadgetItemStack.setItemMeta(bannerMeta); + } + } + /*if (gadget instanceof MorphStray) { gadgetItemStack = UtilItem.getVersionSpecificItem(_player, UtilPlayer.PlayerVersion._1_9, gadgetItemStack); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java index a21f31cea..37f472616 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java @@ -38,16 +38,12 @@ public class HatPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.HAT) == gadget) - { - addGlow(slot); - } + addGlow(slot); slot++; - - if (slot % 9 == 8) - { - slot += 2; - } + + if (slot == 17) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java index 6ce7f5ebd..26b399783 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java @@ -31,16 +31,12 @@ public class KitSelectorPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.KIT_SELECTOR) == gadget) - { addGlow(slot); - } slot++; - if (slot % 9 == 8) - { + if (slot == 17 || slot == 26 || slot == 35) slot += 2; - } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 9814c081b..8a27df36e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -5,9 +5,6 @@ import java.util.EnumMap; import java.util.List; import java.util.Map; -import mineplex.core.common.util.banner.CountryFlag; -import mineplex.core.cosmetic.ui.button.open.OpenFlags; -import mineplex.core.itemstack.ItemBuilder; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -17,6 +14,7 @@ import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilUI; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.open.OpenArrowTrails; @@ -42,9 +40,6 @@ import mineplex.core.mount.Mount; import mineplex.core.pet.PetType; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; public class Menu extends ShopPageBase { @@ -69,46 +64,35 @@ public class Menu extends ShopPageBase List shardLore = new ArrayList(); shardLore.add(" "); - shardLore.add(C.cGray + "These seem like they might come in"); - shardLore.add(C.cGray + "handy. Maybe I should collect more!"); + shardLore.add(C.cGray + "This seems like it might come in"); + shardLore.add(C.cGray + "handy. Maybe I can collect more!"); ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false); - int deathSlot = 19; - int jumpSlot = 28; - int particleSlot = 1; - int winEffectSlot = 13; - int shardSlot = 22; - int arrowSlot = 10; - int tauntSlot = 31; - int gameModifierSlot = 21; - int kitSelectorSlot = 23; - int musicSlot = 48; - int mountSlot = 50; - int balloonsSlot = 47; - int petSlot = 51; - int gadgetSlot = 49; - int hatSlot = 7; - int flagSlot = 34; - int morphSlot = 25; - int costumeSlot = 16; - - addItem(shardSlot, shards); - - ItemStack pane = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((byte)15).setTitle(C.cBlack).build(); - for (int i = 0; i <= 45; i += 9) addItem(i, pane.clone()); - for (int i = 8; i <= 53; i += 9) addItem(i, pane.clone()); - for (int i = 37; i <= 43; ++i) addItem(i, pane.clone()); - for (int i = 2; i <= 6; ++i) addItem(i, pane.clone()); - for (int i = 11; i <= 29; i += 9) addItem(i, pane.clone()); - for (int i = 15; i <= 33; i += 9) addItem(i, pane.clone()); - addItem(12, pane.clone()); - addItem(14, pane.clone()); - addItem(30, pane.clone()); - addItem(32, pane.clone()); - addItem(46, pane.clone()); - addItem(52, pane.clone()); + // Cosmetic Items + int[] slots = UtilUI.getIndicesFor(15, 0, 5, 1); + /*int particleSlot = 9;//slots[0]; + int arrowSlot = 11;//slots[1]; + int jumpSlot = 13;//slots[2]; + int deathSlot = 15;//slots[3]; + int gadgetSlot = 27;//slots[4]; + int morphSlot = 29;//slots[5]; + int mountSlot = 31;//slots[6]; + int petSlot = 33;//slots[7]; + int hatSlot = 35;//slots[8]; + int costumeSlot = 45;//slots[9]; + int musicSlot = 47;//slots[10]; + int tauntSlot = 49;//slots[11]; + int winEffectSlot = 51; + int gameModifierSlot = 53;*/ + int particleSlot = slots[0], arrowSlot = slots[1], jumpSlot = slots[2], + deathSlot = slots[3], gadgetSlot = slots[4], morphSlot = slots[5], + mountSlot = slots[6], petSlot = slots[7], hatSlot = slots[8], + costumeSlot = slots[9], musicSlot = slots[10], tauntSlot = slots[11], + winEffectSlot = slots[12], gameModifierSlot = slots[13], balloonsSlot = slots[14], + kitSelectorSlot = balloonsSlot + 4; + addItem(kitSelectorSlot + 2, shards); EnumMap ownedCount = new EnumMap<>(GadgetType.class); EnumMap maxCount = new EnumMap<>(GadgetType.class); @@ -203,7 +187,7 @@ public class Menu extends ShopPageBase if (petActive != null) addGlow(petSlot); type = GadgetType.HAT; - lore = getLore(ownedCount.get(type), maxCount.get(type), "Hats are in this year. Wear them on your head to impress the others.", VISIBILITY_HUB, enabled.get(type)); + lore = getLore(ownedCount.get(type), maxCount.get(type), "Hats are in this year. Wear them on your head to impress the ladies.", VISIBILITY_HUB, enabled.get(type)); addButton(hatSlot, new ShopItem(Material.GOLD_HELMET, "Hats", lore, 1, false), new OpenHats(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(hatSlot); @@ -243,19 +227,6 @@ public class Menu extends ShopPageBase lore = getLore(ownedCount.get(type), maxCount.get(type), "Click here to select different particles to indicate which kit you have selected!", VISIBILITY_GAME_HUB, enabled.get(type)); addButton(kitSelectorSlot, new ShopItem(Material.LEVER, "Kit Selector Particles", lore, 1, false), new OpenKitSelector(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(kitSelectorSlot); - - type = GadgetType.FLAG; - lore = getLore(ownedCount.get(type), maxCount.get(type), "Show off your country's flag!", VISIBILITY_HUB, enabled.get(type)); - addButton(flagSlot, new ShopItem(Material.BANNER, "Flags", lore, 1, false), new OpenFlags(this, enabled.get(type))); - if (enabled.containsKey(type)) addGlow(flagSlot); - - // Copy over banner design - BannerMeta banner = (BannerMeta) CountryFlag.MINEPLEX.getBanner().getItemMeta(); - BannerMeta meta = ((BannerMeta) getItem(flagSlot).getItemMeta()); - meta.setBaseColor(banner.getBaseColor()); - meta.setPatterns(banner.getPatterns()); - meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); - getItem(flagSlot).setItemMeta(meta); } private String[] getLore(int ownedCount, int maxCount, String info, String visibility, Gadget enabled) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java index 0689b3f07..682140891 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java @@ -32,19 +32,13 @@ public class MorphPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.MORPH) == gadget) - { - if (!(gadget instanceof MorphBlock)) - { - addGlow(slot); - } - } + if (!(gadget instanceof MorphBlock)) + addGlow(slot); slot++; - if (slot % 9 == 8) - { + if (slot == 17 || slot == 26 || slot == 35) slot += 2; - } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java index 0c2b2cd60..6e670effc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java @@ -46,10 +46,8 @@ public class MountPage extends ShopPageBase addMount(mount, slot); slot++; - if (slot % 9 == 8) - { + if (slot == 17 || slot == 26) slot += 2; - } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java index 49fa65cf7..54ff244d7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java @@ -14,6 +14,9 @@ import mineplex.core.gadget.types.GadgetType; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.item.IButton; +/** + * Created by shaun on 14-09-15. + */ public class MusicPage extends GadgetPage { public MusicPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) @@ -31,10 +34,8 @@ public class MusicPage extends GadgetPage slot++; - if (slot % 9 == 8) - { + if (slot == 17) slot += 2; - } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java index 168741d0a..a488c922c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java @@ -31,16 +31,12 @@ public class ParticlePage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.PARTICLE) == gadget) - { - addGlow(slot); - } + addGlow(slot); slot++; - - if (slot % 9 == 8) - { - slot += 2; - } + + if (slot == 17 || slot == 26 || slot == 35) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index 264f73dbe..e7bf684cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java @@ -231,23 +231,16 @@ public class PetPage extends ShopPageBase slot++; - if (slot % 9 == 8) - { + if (slot == 17 || slot == 26) slot += 2; - } } slot = 49; for (PetExtra petExtra : PetExtra.values()) { List itemLore = new ArrayList(); - - if (getPlugin().getPunishManager().GetClient(_player.getName()).IsMuted()) - { - itemLore.add(C.cRed + "You may not rename pets while muted!"); - getInventory().setItem(slot, new ShopItem(petExtra.getMaterial(), (byte)0, C.cRed + petExtra.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); - } - else if (!getPlugin().getPetManager().hasActivePet(getPlayer().getName())) + + if (!getPlugin().getPetManager().hasActivePet(getPlayer().getName())) { itemLore.add(C.cWhite + "You must have an active pet to use this!"); getInventory().setItem(slot, new ShopItem(petExtra.getMaterial(), (byte)0, C.cRed + petExtra.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java index 63ef90b24..687516e0f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java @@ -38,16 +38,12 @@ public class TauntPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.TAUNT) == gadget) - { - addGlow(slot); - } + addGlow(slot); slot++; - - if (slot % 9 == 8) - { - slot += 2; - } + + if (slot == 26) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java index e66674be4..cc116cbac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java @@ -49,16 +49,12 @@ public class WinEffectPage extends GadgetPage } if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.WIN_EFFECT) == gadget) - { - addGlow(slot); - } + addGlow(slot); slot++; - - if (slot % 9 == 8) - { - slot += 2; - } + + if (slot == 17 || slot == 26) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java index 2350f8eba..774ecf2d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java @@ -1,14 +1,9 @@ package mineplex.core.cosmetic.ui.page.custompet.name; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilItem; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.punish.PunishClient; import net.minecraft.server.v1_8_R3.ItemStack; import net.minecraft.server.v1_8_R3.Items; import org.bukkit.ChatColor; -import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; @@ -39,7 +34,6 @@ public class CustomPetTagPage extends ShopPageBase { addCosmetics(null, caller); } - else if (args.length >= 1) + else if (args.length == 1) { - if (args[0].equalsIgnoreCase("all")) + Player player = Bukkit.getPlayer(args[0]); + if (player != null) { - for (Player player : UtilServer.getPlayers()) - { - if (player != null) - { - addCosmetics(null, player); - UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added all the cosmetics to " + F.name(player.getName()) + "!")); - } - } - } - else - { - for (int i = 0; i < args.length; ++i) - { - Player player = Bukkit.getPlayer(args[i]); - if (player != null) - { - addCosmetics(null, player); - UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added all the cosmetics to " + F.name(player.getName()) + "!")); - } - } + addCosmetics(null, player); + UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added all the cosmetics to " + F.name(player.getName()) + "!")); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java deleted file mode 100644 index 37934c81f..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java +++ /dev/null @@ -1,77 +0,0 @@ -package mineplex.core.gadget.gadgets.arrowtrail; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.banner.CountryFlag; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.ArrowEffectGadget; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Arrow; -import org.bukkit.util.Vector; - -import java.awt.Color; - -/** - * Trails a red and white double helix behind the arrow. - */ -public class ArrowTrailRedWhite extends ArrowEffectGadget -{ - public ArrowTrailRedWhite(GadgetManager manager) - { - super(manager, "Red & White Arrows", - UtilText.splitLineToArray(C.cRed + "Killing you nicely.", LineFormat.LORE), - -8, Material.WOOL, (byte)0); - - setDisplayItem(CountryFlag.CANADA.getBanner()); - } - - @Override - public void doTrail(Arrow arrow) - { - Vector v = arrow.getVelocity(); - Vector up = UtilAlg.getUp(v); - Vector left = UtilAlg.getLeft(v); - - Location loc = arrow.getLocation(); - - double amount = 2; - double ticks = 15; - - for(int i = 0; i < amount; i++) - { - double rad = Math.PI*2.0; - rad += i/amount * rad; - rad += Math.PI*2*(arrow.getTicksLived()%ticks)/ticks; - double l = -Math.sin(rad); - double u = Math.cos(rad); - - Vector vel = v.clone().add(up.clone().multiply(u)).add(left.clone().multiply(l)); - vel.multiply(0.4); - - if (i == 0) - { - for(int j = 0; j < 3; ++j) - { - UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, loc.clone().add(vel), 0, UtilParticle.ViewDist.NORMAL); - } - } - else - { - for(int j = 0; j < 3; ++j) - { - UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, loc.clone().add(vel), 0, UtilParticle.ViewDist.NORMAL); - } - } - } - } - - @Override - public void doHitEffect(Arrow arrow) - { - UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, arrow.getLocation(), 0, 0, 0, 0, 3, UtilParticle.ViewDist.NORMAL); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java index 58cbee4d9..d45b1b023 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.candycane; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCupid.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCupid.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java index 4249c19c3..c10562f6d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCupid.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.cupidslove; import org.bukkit.Color; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/emerald/ArrowTrailEmerald.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/emerald/ArrowTrailEmerald.java index b7b8a6df2..8592bc16b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/emerald/ArrowTrailEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.emerald; import mineplex.core.common.util.*; import org.bukkit.Location; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFreedom.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java index fa5f7ade2..8921b26cc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.freedom; import java.awt.Color; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/frostlord/ArrowTrailFrostLord.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/frostlord/ArrowTrailFrostLord.java index 3a7c910b5..6ae8d9b43 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/frostlord/ArrowTrailFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.frostlord; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java index bd5b62563..112f272ad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.halloween; import java.awt.Color; import java.util.HashMap; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailStorm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/howlingwinds/ArrowTrailStorm.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailStorm.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/howlingwinds/ArrowTrailStorm.java index 084611017..a3cc14165 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailStorm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/howlingwinds/ArrowTrailStorm.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.howlingwinds; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/music/ArrowTrailMusic.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/music/ArrowTrailMusic.java index 6c6a3006e..d535035af 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/music/ArrowTrailMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.music; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailConfetti.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/party/ArrowTrailConfetti.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailConfetti.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/party/ArrowTrailConfetti.java index be2cd9b90..d8f06ce45 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailConfetti.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/party/ArrowTrailConfetti.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.party; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/shadow/ArrowTrailShadow.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailShadow.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/shadow/ArrowTrailShadow.java index 8db14cbdb..aec688901 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/shadow/ArrowTrailShadow.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.shadow; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailSpring.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java index 59cb064c4..c335ce062 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.spring; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java index 29c39b7d0..956055929 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.titan; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/vampire/ArrowTrailBlood.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/vampire/ArrowTrailBlood.java index 180e336de..f54c9ae92 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/vampire/ArrowTrailBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.vampire; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/wisdom/ArrowTrailEnchant.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/wisdom/ArrowTrailEnchant.java index b33723020..00e47e049 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/wisdom/ArrowTrailEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.wisdom; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java deleted file mode 100644 index 3cfeeb034..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java +++ /dev/null @@ -1,45 +0,0 @@ -package mineplex.core.gadget.gadgets.death; - -import mineplex.core.blood.BloodEvent; -import mineplex.core.common.shape.ShapeWings; -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.banner.CountryFlag; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.DeathEffectGadget; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -/** - * Displays a giant maple leaf at the point of death. - */ -public class DeathMapleLeaf extends DeathEffectGadget -{ - /** height off the ground of the leaf */ - private static final double HEIGHT = 3; - - private final ShapeWings _leafOuter = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1.0, 1.0, 1.0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); - private final ShapeWings _leafInner = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.7, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); - - public DeathMapleLeaf(GadgetManager manager) - { - super(manager, "Fallen Maple Leaf", - UtilText.splitLineToArray(C.cGray + "When you die in " + C.cRed + "Canada" + C.cGray + " you die in real life.", LineFormat.LORE), - -8, Material.WOOL, (byte) 0); - - setDisplayItem(CountryFlag.CANADA.getBanner()); - } - - @Override - public void onBlood(Player player, BloodEvent event) - { - event.setCancelled(true); - Location loc = player.getLocation().add(0, HEIGHT, 0); - _leafOuter.display(loc); - _leafInner.display(loc); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/candycane/DeathCandyCane.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/candycane/DeathCandyCane.java index 2d100b3fe..45a7028d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/candycane/DeathCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.candycane; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPresentDanger.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/christmas/DeathPresentDanger.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPresentDanger.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/christmas/DeathPresentDanger.java index c1b07ce33..e8db5ed6a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPresentDanger.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/christmas/DeathPresentDanger.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.christmas; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCupidsBrokenHeart.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/cupidslove/DeathCupidsBrokenHeart.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCupidsBrokenHeart.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/cupidslove/DeathCupidsBrokenHeart.java index d0053f9df..1c92abc02 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCupidsBrokenHeart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/cupidslove/DeathCupidsBrokenHeart.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.cupidslove; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/emerald/DeathEmerald.java similarity index 93% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/emerald/DeathEmerald.java index 85fb2db18..79ea0b404 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/emerald/DeathEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.emerald; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/freedom/DeathFreedom.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFreedom.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/freedom/DeathFreedom.java index 137b68207..24d43eb0b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/freedom/DeathFreedom.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.freedom; import org.bukkit.ChatColor; import org.bukkit.Location; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/frostlord/DeathFrostLord.java similarity index 93% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/frostlord/DeathFrostLord.java index 72cd2c3cb..0ce7b546f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/frostlord/DeathFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.frostlord; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathStorm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/howlingwinds/DeathStorm.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathStorm.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/howlingwinds/DeathStorm.java index c3cf2f0da..00cf6d607 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathStorm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/howlingwinds/DeathStorm.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.howlingwinds; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/music/DeathMusic.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/music/DeathMusic.java index d6c4176ad..2bf566254 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/music/DeathMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.music; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPinataBurst.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/party/DeathPinataBurst.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPinataBurst.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/party/DeathPinataBurst.java index 0adc3dfb8..09ccfe10a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPinataBurst.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/party/DeathPinataBurst.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.party; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/shadow/DeathShadow.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathShadow.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/shadow/DeathShadow.java index f80b4ad9b..3adb240f2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/shadow/DeathShadow.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.shadow; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathSpring.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java index bae34473b..eb15f5986 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.spring; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java index 0e56f8308..00b64eace 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.titan; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/vampire/DeathBlood.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/vampire/DeathBlood.java index 7101aba36..5365e3e14 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/vampire/DeathBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.vampire; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/wisdom/DeathEnchant.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/wisdom/DeathEnchant.java index 35532906d..7229b155d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/wisdom/DeathEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death; +package mineplex.core.gadget.gadgets.death.wisdom; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java deleted file mode 100644 index 4b9d08338..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java +++ /dev/null @@ -1,110 +0,0 @@ -package mineplex.core.gadget.gadgets.doublejump; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.banner.CountryFlag; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.DoubleJumpEffectGadget; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -public class DoubleJumpMaple extends DoubleJumpEffectGadget -{ - /** - * Amount of particles played per tick as a player flies through the air. - */ - private static final int PARTICLES = 50; - - /** - * Vertical offset of the animation's center from the player's location. - */ - private static final float Y_OFFSET = 0.95f; - - /** - * Divisor of the gaussian distribution of particles as the player flies through the air. - */ - private static final int DISTRIBUTION = 2; - - /** - * Particle ring count when a player launches from the ground. - */ - private static final int LAUNCH_RINGS = 6; - - /** - * The distance between launch rings. - */ - private static final float RING_SPACING = 0.4f; - - /** - * Particles played per 1 unit radius. - */ - private static final int RING_DENSITY = 8; - - private HashMap _playerMap = new HashMap<>(); - - public DoubleJumpMaple(GadgetManager manager) - { - super(manager, "Maple Leap", - UtilText.splitLineToArray(C.cGray + "Jump higher than the maple trees!", LineFormat.LORE), - -8, Material.WOOL, (byte)0); - setDisplayItem(CountryFlag.CANADA.getBanner()); - } - - @Override - public void doEffect(Player player) - { - _playerMap.put(player, System.currentTimeMillis() + 1000); - - float limit = (LAUNCH_RINGS * RING_SPACING) + RING_SPACING; - - for (float r = RING_SPACING; r < limit; r++) - { - double[][] points = UtilMath.normalCircle(player.getLocation(), player.getVelocity(), r, Math.round(RING_DENSITY * r)); - - for (int i = 0; i < points.length; i++) - { - UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, new Location(player.getWorld(), points[i][0], points[i][1], points[i][2]), - null, 0, 1, UtilParticle.ViewDist.NORMAL); - } - } - } - - @EventHandler - public void onUpdate(UpdateEvent event) - { - if(event.getType() != UpdateType.FASTEST) - { - return; - } - - for(Iterator> it = _playerMap.entrySet().iterator(); it.hasNext();) - { - Map.Entry e = it.next(); - - if(e.getValue() <= System.currentTimeMillis()) - { - it.remove(); - continue; - } - - Location loc = e.getKey().getLocation().add(0, Y_OFFSET, 0); - - for (int i = 0; i < PARTICLES; ++i) - { - UtilParticle.playColoredParticleToAll(java.awt.Color.RED, UtilParticle.ParticleType.RED_DUST, - UtilMath.gauss(loc, DISTRIBUTION, DISTRIBUTION, DISTRIBUTION), 0, UtilParticle.ViewDist.NORMAL); - } - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/candycane/DoubleJumpCandyCane.java similarity index 91% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/candycane/DoubleJumpCandyCane.java index 209da4b7c..d6a7620c7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/candycane/DoubleJumpCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.candycane; import org.bukkit.Location; import org.bukkit.Material; @@ -30,7 +30,7 @@ public class DoubleJumpCandyCane extends DoubleJumpEffectGadget Location loc = player.getLocation(); UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 1), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); - UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 2), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCupidsWings.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/cupidslove/DoubleJumpCupidsWings.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCupidsWings.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/cupidslove/DoubleJumpCupidsWings.java index 81884a52b..71a7b66b5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCupidsWings.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/cupidslove/DoubleJumpCupidsWings.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.cupidslove; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/emerald/DoubleJumpEmerald.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/emerald/DoubleJumpEmerald.java index f74859c2c..0453e0b57 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/emerald/DoubleJumpEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.emerald; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/freedom/DoubleJumpFreedom.java similarity index 92% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/freedom/DoubleJumpFreedom.java index 820ccd155..7f887e345 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/freedom/DoubleJumpFreedom.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.freedom; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -18,7 +18,7 @@ public class DoubleJumpFreedom extends DoubleJumpEffectGadget { super(manager, "Leap of Freedom", UtilText.splitLineToArray(UtilText.colorWords("FREEEEEEEEEEEDOM!", ChatColor.RED, ChatColor.WHITE, ChatColor.BLUE), LineFormat.LORE), -8, Material.WOOL, - (byte) 0); + (byte) 14); setDisplayItem(CountryFlag.USA.getBanner()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/frostlord/DoubleJumpFrostLord.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/frostlord/DoubleJumpFrostLord.java index 64cc9f962..62325731c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/frostlord/DoubleJumpFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.frostlord; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java index 0f2cc13e8..10155afbd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.halloween; import java.awt.Color; import java.util.HashMap; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpStorm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/howlingwinds/DoubleJumpStorm.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpStorm.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/howlingwinds/DoubleJumpStorm.java index 9cd07ef15..6b04d1f00 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpStorm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/howlingwinds/DoubleJumpStorm.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.howlingwinds; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/music/DoubleJumpMusic.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/music/DoubleJumpMusic.java index 2a4d5c1ba..5b7459f0d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/music/DoubleJumpMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.music; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFirecracker.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/party/DoubleJumpFirecracker.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFirecracker.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/party/DoubleJumpFirecracker.java index 65ce9bd80..06ee124f7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFirecracker.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/party/DoubleJumpFirecracker.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.party; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/shadow/DoubleJumpShadow.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpShadow.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/shadow/DoubleJumpShadow.java index c64052bca..005c3403c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/shadow/DoubleJumpShadow.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.shadow; import mineplex.core.common.util.C; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java index 527b44b0f..63dabdaf9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.spring; import java.util.ArrayList; import java.util.Iterator; @@ -38,7 +38,7 @@ public class DoubleJumpSpring extends DoubleJumpEffectGadget { for (int i = 50; i < 60; i++) { - Item sunflower = player.getWorld().dropItem(player.getLocation().add(0.0, 0.2, 0.0), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); + Item sunflower = player.getWorld().dropItem(player.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); _items.add(sunflower); Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java index 9c81a3309..336aaa5bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.titan; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/vampire/DoubleJumpBlood.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/vampire/DoubleJumpBlood.java index 2f910416c..882133687 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/vampire/DoubleJumpBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.vampire; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/wisdom/DoubleJumpEnchant.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/wisdom/DoubleJumpEnchant.java index d9d4db576..ec1120f3b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/wisdom/DoubleJumpEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.wisdom; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java deleted file mode 100644 index aec958dd9..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java +++ /dev/null @@ -1,33 +0,0 @@ -package mineplex.core.gadget.gadgets.flag; - -import mineplex.core.common.util.banner.CountryFlag; - -/** - * Cosmetic flags representing countries. - */ -public enum FlagType -{ - UNITED_STATES(CountryFlag.USA, -8), - CANADA(CountryFlag.CANADA, -8), - - ; - - private final CountryFlag _flag; - private final int _cost; - - FlagType(CountryFlag flag, int cost) - { - _flag = flag; - _cost = cost; - } - - public CountryFlag getFlag() - { - return _flag; - } - - public int getCost() - { - return _cost; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java index cabad2568..c6f623e20 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java @@ -22,11 +22,7 @@ public enum HatType SNOWMAN("Snowman Head", UtilText.splitLineToArray(C.cGray + "Do you want to be a snowman?", LineFormat.LORE), -2, SkinData.SNOWMAN), TEDDY_BEAR("Teddy Bear", UtilText.splitLineToArray(C.cGray + "Aww, it's a cute teddy bear! What shall I name him?", LineFormat.LORE), -6, SkinData.TEDDY_BEAR), UNCLE_SAM("Uncle Sam Hat", UtilText.splitLineToArray(UtilText.colorWords("Uncle Sam has a big hat but now you can too.", ChatColor.RED, ChatColor.WHITE, ChatColor.BLUE), LineFormat.LORE), -8, SkinData.UNCLE_SAM), - PUMPKIN("Pumpkin Hat", UtilText.splitLineToArray(C.cGray + "Pumpkin on the head, don't end up dead!", LineFormat.LORE), -9, Material.PUMPKIN), - CANADA("Warm Canadian Hat", UtilText.splitLineToArray(C.cGray + "Keep your ears nice and warm while up north.", LineFormat.LORE), -8, SkinData.CANADA_HAT), - AMERICA("Patriotic American Hat", UtilText.splitLineToArray(C.cGray + "Careful not to get a big head.", LineFormat.LORE), -8, SkinData.AMERICA_HAT), - - ; + PUMPKIN("Pumpkin Hat", UtilText.splitLineToArray(C.cGray + "Pumpkin on the head, don't end up dead!", LineFormat.LORE), -9, Material.PUMPKIN); private final String _name; private final String[] _lore; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java index 651993fb9..236bc1e8a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java @@ -1,6 +1,5 @@ package mineplex.core.gadget.gadgets.particle; -import mineplex.core.common.util.UtilMath; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -28,7 +27,7 @@ public class ParticleCoalFumes extends ParticleGadget @Override public void playParticle(Player player, UpdateEvent event) { - if(event.getType() != UpdateType.FASTER) return; + if(event.getType() != UpdateType.TICK) return; float xz = 1; int amount = 5; @@ -40,6 +39,6 @@ public class ParticleCoalFumes extends ParticleGadget amount = 2; } - UtilParticle.playParticleFor(player, type, UtilMath.gauss(player.getLocation(), 2, 6, 2), xz, 0, xz, 0, amount, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, type, player.getLocation(), xz, 0, xz, 0, amount, ViewDist.NORMAL); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java index 8337efae4..f99338a75 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java @@ -1,8 +1,6 @@ package mineplex.core.gadget.gadgets.particle; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import org.bukkit.Location; +import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -19,40 +17,12 @@ import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import java.awt.Color; - public class ParticleLegend extends ParticleGadget { - private static final double PI = Math.PI; - private static final int BASE_PILLARS = 9; - private static final int PILLAR_VARIANCE = 8; - private static final int MOVING_PARTICLES = 8; - private static final double VERTICAL_SPEED = 0.1; - private static final double HEIGHT_VARIANCE = 0.8; - private static final double ROTATIONAL_SPEED = .03; - private static final double RADIAL_VARIANCE = 0.09; - private static final double BASE_RADIUS = 1.30; - private static final double HEIGHT_MODIFIER_BASE = 0.1; - private static final double HEIGHT_MODIFIER_MAX = 1.3; - private static final double HEIGHT_MODIFIER_INTERVAL = 0.15; - private static final Color[] SELECTABLE_COLORS = { - new Color(60, 170, 25), - new Color(33, 92, 13), - new Color(0, 0, 0) - }; - - private final int _pillars = pillars(); - private final Color[] _colors = colors(); - private final double[] _heights = heights(); - private final double[] _verticals = verticals(); - private final double[] _variance = variances(); - private final double[] _thetas = thetas(); - private final double[] _radii = radii(); - public ParticleLegend(GadgetManager manager) { super(manager, "Legendary Aura", - UtilText.splitLineToArray(C.cGray + "Legendary energy protects you.", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "This particle will be updated soon! Yay!", LineFormat.LORE), -1, Material.ENDER_PORTAL_FRAME, (byte)0); } @@ -61,150 +31,11 @@ public class ParticleLegend extends ParticleGadget public void playParticle(Player player, UpdateEvent event) { if (event.getType() != UpdateType.TICK) - { return; - } - if (Manager.isMoving(player)) - { - - for (int i = 0; i < MOVING_PARTICLES; i++) - { - if (_colors[i].getGreen() == 0) - { - UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.SMOKE, - UtilMath.gauss(player.getLocation(), 8, 4, 8), null, 0, 1, UtilParticle.ViewDist.NORMAL); - } - else - { - UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, - UtilMath.gauss(player.getLocation(), 8, 4, 8), 0, UtilParticle.ViewDist.NORMAL); - } - } - } - else - { - if (event.getTick() % (ROTATIONAL_SPEED * 100) == 0) - { - for (int i = 0; i < _pillars; i++) - { - _thetas[i] = rollover(_thetas[i], ROTATIONAL_SPEED); - _heights[i] = rollover(_heights[i], _verticals[i]); - - double x = (_radii[i] * Math.cos(_thetas[i])) + player.getLocation().getX(); - double z = (_radii[i] * Math.sin(_thetas[i])) + player.getLocation().getZ(); - double y = (Math.sin(_heights[i]) * _variance[i]) + player.getLocation().getY(); - - for (double h = HEIGHT_MODIFIER_BASE; h <= HEIGHT_MODIFIER_MAX; h+= HEIGHT_MODIFIER_INTERVAL) - { - if (_colors[i].getGreen() == 0) - { - UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.SMOKE, - new Location(player.getWorld(), x, y + h, z), null, 0, 1, UtilParticle.ViewDist.NORMAL); - } - else - { - UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, - new Location(player.getWorld(), x, y + h, z), 0, UtilParticle.ViewDist.NORMAL); - } - } - } - } - } + player.getWorld().playEffect(player.getLocation().add(0, 1, 0), Effect.ENDER_SIGNAL, 0); } - - private double[] heights() - { - double[] array = new double[_pillars]; - - for (int i = 0; i < _pillars; i++) - { - array[i] = 6.28 * Math.random(); - } - - return array; - } - - private double[] variances() - { - double[] array = new double[_pillars]; - - for (int i = 0; i < _pillars; i++) - { - array[i] = Math.random() * HEIGHT_VARIANCE; - } - - return array; - } - - private double[] verticals() - { - double[] array = new double[_pillars]; - - for (int i = 0; i < _pillars; i++) - { - array[i] = Math.random() * VERTICAL_SPEED; - } - - return array; - } - - private double[] thetas() - { - double[] array = new double[_pillars]; - double theta = 0; - double interval = (2 * PI) / _pillars; - - for (int i = 0; i < _pillars; i++) - { - array[i] = theta; - theta += interval; - } - - return array; - } - - private double[] radii() - { - double[] array = new double[_pillars]; - - for (int i = 0; i < _pillars; i++) - { - array[i] = BASE_RADIUS + (Math.random() * RADIAL_VARIANCE); - } - - return array; - } - - private Color[] colors() - { - Color[] array = new Color[_pillars]; - - for (int i = 0; i < _pillars; i++) - { - array[i] = SELECTABLE_COLORS[i % SELECTABLE_COLORS.length]; - } - - return array; - } - - private int pillars() - { - return BASE_PILLARS + (int) ((Math.random() * PILLAR_VARIANCE) - (PILLAR_VARIANCE / 2)); - } - - private double rollover(double value, double additive) - { - value += additive; - - if (value >= 2 * PI) - { - value = value - (2 * PI); - } - - return value; - } - + @EventHandler public void legendOwner(PlayerJoinEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/candycane/ParticleCandyCane.java similarity index 93% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/candycane/ParticleCandyCane.java index e9e572f19..4d8b223fc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/candycane/ParticleCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.candycane; import java.util.HashMap; import java.util.UUID; @@ -63,7 +63,7 @@ public class ParticleCandyCane extends ParticleGadget UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 1), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); - UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); + UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 2), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java similarity index 84% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java index c48b0ddb4..dea6a85aa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java @@ -1,6 +1,5 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.cupidslove; -import mineplex.core.common.util.UtilMath; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -38,11 +37,11 @@ public class ParticleHeart extends ParticleGadget { if(getSet() == null || !getSet().isActive(player)) return; - UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1.2, 0), null, 0, 1, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1, 0), null, 0, 1, ViewDist.NORMAL); } else { - UtilParticle.playParticleFor(player, ParticleType.HEART, UtilMath.gauss(player.getLocation(), 1, 3, 1).add(0, 1.2, 0), null, 0, 1, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, ViewDist.NORMAL); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/emerald/ParticleEmerald.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/emerald/ParticleEmerald.java index f81361c66..417587dbb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/emerald/ParticleEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.emerald; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java deleted file mode 100644 index 2e68270e5..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java +++ /dev/null @@ -1,194 +0,0 @@ -package mineplex.core.gadget.gadgets.particle.freedom; - -import mineplex.core.arcadeevents.CoreGameStartEvent; -import mineplex.core.arcadeevents.CoreGameStopEvent; -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilShapes; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.banner.CountryFlag; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.ParticleGadget; -import mineplex.core.treasure.event.TreasureFinishEvent; -import mineplex.core.treasure.event.TreasureStartEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockPhysicsEvent; - -import java.awt.Color; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ThreadLocalRandom; -import java.util.stream.Collectors; - -/** - * Places flowers around the player with poofs of red and white - */ -public class ParticleAuraNiceness extends ParticleGadget -{ - /** Radius within which flowers not allowed near treasure chests */ - private static final int TREASURE_RADIUS = 4; - - /** Horizontal offset for particle spawns */ - private static final double H_FIELD = 0.5; - - /** Vertical offset for particle spawns */ - private static final double V_FIELD = 0.35; - - /** How likely a flower is to be spawned (1/n) */ - private static final int ROSE_PROBABILITY = 40; - - /** Radius in which flowers are spawned */ - private static final double ROSE_RADIUS = 2.5; - - /** How many particles accompany each flower spawn */ - private static final int PARTICLE_COUNT = 20; - - /** List of blocks that have flowers in them */ - private final Set _blocks = new HashSet<>(); - - /** Milliseconds for which flowers persist */ - private final long DURATION = 5000; - - /** Locations at which treasure is currently being opened */ - private final Map _openingTreasure = new HashMap<>(); - - /** Whether flowers can be spawned in addition to particles */ - private boolean _enabled = true; - - public ParticleAuraNiceness(GadgetManager manager) - { - super(manager, "Aura of Niceness", - UtilText.splitLineToArray(C.cGray + "Canadians are always nice online.", LineFormat.LORE), -8, Material.WOOL, - (byte) 0); - - setDisplayItem(CountryFlag.CANADA.getBanner()); - } - - @Override - public void playParticle(Player player, UpdateEvent event) - { - if (event.getType() != UpdateType.FASTER) - { - return; - } - - for (Location location : _openingTreasure.values()) - { - if (location.toVector().isInSphere(player.getLocation().toVector(), TREASURE_RADIUS)) - { - return; - } - } - - UtilShapes.getCircle(player.getLocation().subtract(0, 0.5, 0), false, ROSE_RADIUS).stream().map(Location::getBlock) - .collect(Collectors.toSet()).forEach(block -> - { - if (ThreadLocalRandom.current().nextInt(ROSE_PROBABILITY) == 0) - { - Block b = block.getRelative(BlockFace.UP); - - if (b.isEmpty() && UtilBlock.fullSolid(block) && !UtilBlock.bottomSlab(block)) - { - Location loc = b.getLocation().add(H_FIELD, V_FIELD, H_FIELD); - - if (_enabled) - { - byte data = ThreadLocalRandom.current().nextInt(2) == 0 ? (byte) 4 : 6; - - _blocks.add(b); - Manager.getBlockRestore().add(b, Material.RED_ROSE.getId(), data, DURATION); - } - - for (int i = 0; i < PARTICLE_COUNT; ++i) - { - UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 4, 4, 4), 0, UtilParticle.ViewDist.NORMAL); - UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 4, 4, 4), 0, UtilParticle.ViewDist.NORMAL); - } - } - } - }); - - for(Iterator it = _blocks.iterator(); it.hasNext();) - { - Block b = it.next(); - - if (b.getType() != Material.RED_ROSE) - { - it.remove(); - Location loc = b.getLocation().add(H_FIELD, V_FIELD, H_FIELD); - for (int i = 0; i < PARTICLE_COUNT / 2; ++i) - { - UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 6, 6, 6), 0, UtilParticle.ViewDist.NORMAL); - UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 6, 6, 6), 0, UtilParticle.ViewDist.NORMAL); - } - } - } - } - - /** - * Stop flowers from popping off of blocks - */ - @EventHandler - public void onBlockFade(BlockPhysicsEvent event) - { - if (_blocks.contains(event.getBlock())) - { - event.setCancelled(true); - } - } - - /** - * Disable flowers in the area around treasure being opened. - */ - @EventHandler(priority = EventPriority.LOW) - public void disableOnTreasureStart(TreasureStartEvent event) - { - _openingTreasure.put(event.getPlayer().getUniqueId(), event.getPlayer().getLocation()); - Manager.getBlockRestore().restoreBlockAround(Material.CARPET, event.getPlayer().getLocation(), TREASURE_RADIUS); - } - - /** - * Enable flowers in the area around treasure no longer being opened. - */ - @EventHandler(priority = EventPriority.HIGH) - public void enableOnTreasureFinish(TreasureFinishEvent event) - { - if (_openingTreasure.containsKey(event.getPlayer().getUniqueId())) - { - _openingTreasure.remove(event.getPlayer().getUniqueId()); - } - } - - /** - * Disable flowers on game start - */ - @EventHandler - public void onGameStart(CoreGameStartEvent event) - { - _enabled = false; - } - - /** - * Enable flowers on game end - */ - @EventHandler - public void onGameEnd(CoreGameStopEvent event) - { - _enabled = true; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java deleted file mode 100644 index 4770908b9..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java +++ /dev/null @@ -1,71 +0,0 @@ -package mineplex.core.gadget.gadgets.particle.freedom; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.banner.CountryFlag; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.ParticleGadget; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; - -import java.awt.Color; - -/** - * Leaves a trail behind the player with the colors of the Canadian flag. - */ -public class ParticleCanadian extends ParticleGadget -{ - /** # of lines of particles */ - private static final int STRAND_COUNT = 9; - - /** How far apart each line of particles is */ - private static final double STRAND_SPACING = 0.124; - - /** How far off the floor the particles begin */ - private static final double DISTANCE_FROM_FLOOR = 0.43; - - public ParticleCanadian(GadgetManager manager) - { - super(manager, "Canadian Trail", - UtilText.splitLineToArray(C.cGray + "Lead the way to freedom!", LineFormat.LORE), - -8, Material.WOOL, (byte) 0); - - setDisplayItem(CountryFlag.CANADA.getBanner()); - } - - @Override - public void playParticle(Player player, UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - { - return; - } - - Location center = player.getLocation().subtract(player.getLocation().getDirection().multiply(0.4)) - .subtract(0, 0.1, 0).add(0, DISTANCE_FROM_FLOOR, 0); - - if (Manager.isMoving(player)) - { - for (int i = 0; i < STRAND_COUNT; i++) - { - if (i < 3 || i > 5) - { - UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, - center.add(0, STRAND_SPACING, 0), 0, UtilParticle.ViewDist.NORMAL); - } - else - { - UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, - center.add(0, STRAND_SPACING, 0), 0, UtilParticle.ViewDist.NORMAL); - } - } - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java deleted file mode 100644 index a7a18702e..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java +++ /dev/null @@ -1,59 +0,0 @@ -package mineplex.core.gadget.gadgets.particle.freedom; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.banner.CountryFlag; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.ParticleGadget; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import java.util.concurrent.ThreadLocalRandom; - -/** - * Small fireworks which explode around the player - */ -public class ParticleFreedomFireworks extends ParticleGadget -{ - /** Block types to source for particles */ - private static final Material[] BLOCKTYPES = { - Material.REDSTONE_BLOCK, - Material.LAPIS_BLOCK, - Material.QUARTZ_BLOCK - }; - - /** Amount of particles for each firework */ - private static final int PARTICLE_COUNT = 20; - - public ParticleFreedomFireworks(GadgetManager manager) - { - super(manager, "Freedom Fireworks", - UtilText.splitLineToArray(C.cGray + "Keep your patriotism close.", LineFormat.LORE), - -8, Material.WOOL, (byte) 0); - - setDisplayItem(CountryFlag.USA.getBanner()); - } - - @Override - public void playParticle(Player player, UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - { - return; - } - - String particle = UtilParticle.ParticleType.BLOCK_CRACK.getParticle(BLOCKTYPES[ThreadLocalRandom.current().nextInt(0, BLOCKTYPES.length)], 0); - Location location = UtilMath.gauss(player.getEyeLocation(), 1, 1, 1); - - for (int i = 0; i < PARTICLE_COUNT; ++i) - { - UtilParticle.PlayParticleToAll(particle, location, null, 3.0f, 1, UtilParticle.ViewDist.NORMAL); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java deleted file mode 100644 index 7ad601f9a..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java +++ /dev/null @@ -1,81 +0,0 @@ -package mineplex.core.gadget.gadgets.particle.freedom; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.banner.CountryFlag; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.ParticleGadget; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import net.minecraft.server.v1_8_R3.MinecraftServer; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; - -import java.awt.*; - - -/** - * @author J Teissler - * @date 6/26/17 - */ -public class ParticleStarSpangled extends ParticleGadget -{ - private static final int STRAND_COUNT = 9; - private static final double STRAND_SPACING = 0.124; - private static final double DISTANCE_FROM_FLOOR = 0.43; - - private static final Color BLUE = new Color(29, 26, 120); - - public ParticleStarSpangled(GadgetManager manager) - { - super(manager, "Star Spangled Stripe", - UtilText.splitLineToArray(C.cGray + "Blaze a trail of freedom!", LineFormat.LORE), - -8, Material.WOOL, (byte) 0); - setDisplayItem(CountryFlag.USA.getBanner()); - } - - @Override - public void playParticle(Player player, UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - { - return; - } - - Location center = player.getLocation().subtract(player.getLocation().getDirection().multiply(0.4)) - .subtract(0, 0.1, 0).add(0, DISTANCE_FROM_FLOOR, 0); - - if (Manager.isMoving(player)) - { - for (int i = 0; i < STRAND_COUNT; i++) - { - if (i == 3 || i == 7) - { - if (player.getTicksLived() % 3 == 0) - { - UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.FIREWORKS_SPARK, - center.add(0, STRAND_SPACING, 0), 0f, 0f, 0f, 0f, 0, UtilParticle.ViewDist.NORMAL); - continue; - } - } - else if (i == 5) - { - if (player.getTicksLived() + 1 % 3 == 0) - { - UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.FIREWORKS_SPARK, - center.add(0, STRAND_SPACING, 0), 0f, 0f, 0f, 0f, 0, UtilParticle.ViewDist.NORMAL); - continue; - } - } - - UtilParticle.playColoredParticleToAll(BLUE, UtilParticle.ParticleType.RED_DUST, - center.add(0, STRAND_SPACING, 0), 0, UtilParticle.ViewDist.NORMAL); - } - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/frostlord/ParticleFrostLord.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/frostlord/ParticleFrostLord.java index 32f947e47..62c1388b3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/frostlord/ParticleFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.frostlord; import org.bukkit.Material; import org.bukkit.Sound; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/howlingwinds/ParticleRain.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/howlingwinds/ParticleRain.java index 4311666c0..f2c45007c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/howlingwinds/ParticleRain.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.howlingwinds; import java.util.ArrayList; import java.util.List; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/music/ParticleMusic.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/music/ParticleMusic.java index e0bbb3537..04874fffc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/music/ParticleMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.music; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/party/ParticlePartyTime.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/party/ParticlePartyTime.java index a3944317c..3aab6f928 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/party/ParticlePartyTime.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.party; import java.util.Arrays; import java.util.Collections; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoot.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoot.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java index fd315fc04..9c3b8be54 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoot.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.shadow; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java index 7d062f713..b5f02de23 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.titan; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/vampire/ParticleBlood.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/vampire/ParticleBlood.java index 0c3c3546a..a33078067 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/vampire/ParticleBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.vampire; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/wisdom/ParticleEnchant.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/wisdom/ParticleEnchant.java index 706c32fbd..f8d734e74 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/wisdom/ParticleEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.wisdom; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java index c246b2975..fdc5da288 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java @@ -35,12 +35,10 @@ public class BlowAKissTaunt extends TauntGadget } @Override - public boolean onStart(Player player) + public void onStart(Player player) { if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) - { - return false; - } + return; HashSet ignore = new HashSet<>(); ignore.add(Material.AIR); @@ -48,8 +46,6 @@ public class BlowAKissTaunt extends TauntGadget BlowAKissEffect blowAKissEffect = new BlowAKissEffect(player, loc, this); blowAKissEffect.start(); - - return true; } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java index 6e0a7e133..103efacd2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java @@ -6,8 +6,6 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import mineplex.core.disguise.disguises.DisguiseBase; -import mineplex.core.game.GameDisplay; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -30,7 +28,9 @@ import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.events.EnableArcadeSpawnEvent; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.TauntGadget; +import mineplex.core.game.GameDisplay; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -41,8 +41,7 @@ public class EternalTaunt extends TauntGadget private static final int COOLDOWN = 30000; private static final int PVP_COOLDOWN = 10000; - private final Map> _clocks = new HashMap<>(); - private final Map _disguises = new HashMap<>(); + private Map> _clocks = new HashMap<>(); public EternalTaunt(GadgetManager manager) { @@ -51,48 +50,33 @@ public class EternalTaunt extends TauntGadget C.cWhite + "Use /taunt in game to show how long you've been waiting.", C.cRed + "Cannot be used while in PvP!"}, LineFormat.LORE), -15, Material.WATCH, (byte) 0); - setCanPlayWithPvp(false); setPvpCooldown(PVP_COOLDOWN); setShouldPlay(true); setEventType(UpdateType.FAST); - addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination, GameDisplay.SmashTraining); + addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination); } @Override - public boolean onStart(Player player) + public void onStart(Player player) { if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) - { - return false; - } - + return; UtilFirework.playFirework(player.getLocation(), FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.fromRGB(255, 175, 175)).withFade(Color.RED).build()); _clocks.put(player.getUniqueId(), new ArrayList<>()); Bukkit.broadcastMessage(F.main("Taunt", F.name(player.getName()) + " waited so long they turned to bones.")); - if (!Manager.getDisguiseManager().isDisguised(player)) - { - DisguiseSkeleton disguiseSkeleton = new DisguiseSkeleton(player); - disguiseSkeleton.setName(player.getName()); - disguiseSkeleton.setCustomNameVisible(true); - disguiseSkeleton.showArmor(); - Manager.getDisguiseManager().disguise(disguiseSkeleton); - _disguises.put(player.getUniqueId(), disguiseSkeleton); - } - - return true; + DisguiseSkeleton disguiseSkeleton = new DisguiseSkeleton(player); + UtilMorph.disguise(player, disguiseSkeleton, Manager); } @Override public void onPlay(Player player) { if (!_clocks.containsKey(player.getUniqueId())) - { return; - } int i = getPlayerTicks(player); @@ -130,11 +114,7 @@ public class EternalTaunt extends TauntGadget @Override public void onFinish(Player player) { - if (_disguises.containsKey(player.getUniqueId())) - { - Manager.getDisguiseManager().undisguise(_disguises.remove(player.getUniqueId())); - } - + UtilMorph.undisguise(player, Manager.getDisguiseManager()); if (_clocks.containsKey(player.getUniqueId())) { _clocks.get(player.getUniqueId()).forEach(c -> c.remove()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java index 6a49fe8c4..de81b6a1b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java @@ -36,12 +36,10 @@ public class RainbowTaunt extends TauntGadget } @Override - public boolean onStart(Player player) + public void onStart(Player player) { if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) - { - return false; - } + return; Vector dir = player.getLocation().getDirection(); Vector sideA = dir.clone().setX(-dir.getZ()).setZ(dir.getX()); @@ -53,8 +51,6 @@ public class RainbowTaunt extends TauntGadget RainbowTauntEffect rainbowTauntEffect = new RainbowTauntEffect(start, Manager.getPlugin()); rainbowTauntEffect.setTargetLocation(new EffectLocation(end)); rainbowTauntEffect.start(); - - return true; } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java deleted file mode 100644 index 0b18eca18..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java +++ /dev/null @@ -1,22 +0,0 @@ -package mineplex.core.gadget.set; - -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; -import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; -import mineplex.core.gadget.types.GadgetSet; - -public class SetCanadian extends GadgetSet -{ - - public SetCanadian(GadgetManager manager) - { - super(manager, "Canadian", "2x Holiday Points while active (Titles)", - manager.getGadget(ArrowTrailRedWhite.class), - manager.getGadget(DeathMapleLeaf.class), - manager.getGadget(DoubleJumpMaple.class), - manager.getGadget(ParticleCanadian.class)); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java index c9b059480..e6f6f5707 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.death.DeathCandyCane; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; +import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; import mineplex.core.gadget.types.GadgetSet; public class SetCandyCane extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java index dca2f191c..ccbaf0863 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; -import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; -import mineplex.core.gadget.gadgets.particle.ParticleHeart; +import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; +import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart; +import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; +import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; import mineplex.core.gadget.types.GadgetSet; public class SetCupidsLove extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java index 26df2fd6f..b34a8f88e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; -import mineplex.core.gadget.gadgets.death.DeathEmerald; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; -import mineplex.core.gadget.gadgets.particle.ParticleEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald; +import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; import mineplex.core.gadget.types.GadgetSet; public class SetEmerald extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java index a64e2caf3..6196a145b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.death.DeathFreedom; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; +import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; +import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; import mineplex.core.gadget.types.GadgetSet; public class SetFreedom extends GadgetSet @@ -16,7 +16,7 @@ public class SetFreedom extends GadgetSet manager.getGadget(ArrowTrailFreedom.class), manager.getGadget(DeathFreedom.class), manager.getGadget(DoubleJumpFreedom.class), - manager.getGadget(ParticleStarSpangled.class)); + manager.getGadget(ParticleFreedom.class)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java index 311600e5e..6112655a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.death.DeathFrostLord; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; -import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; +import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; import mineplex.core.gadget.types.GadgetSet; public class SetFrostLord extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java index 668503111..120a35c95 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; -import mineplex.core.gadget.gadgets.death.DeathStorm; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; -import mineplex.core.gadget.gadgets.particle.ParticleRain; +import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; +import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; +import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; import mineplex.core.gadget.types.GadgetSet; public class SetHowlingWinds extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java index 50eef82a0..9e606f0e2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.death.DeathMusic; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.particle.ParticleMusic; +import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; +import mineplex.core.gadget.gadgets.death.music.DeathMusic; +import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; +import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; import mineplex.core.gadget.types.GadgetSet; public class SetMusic extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java index f22ce959e..f9debaef0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; -import mineplex.core.gadget.gadgets.death.DeathPinataBurst; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; -import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; +import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; +import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; +import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; import mineplex.core.gadget.types.GadgetSet; public class SetParty extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java index 80b751d7d..befc2e27c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; -import mineplex.core.gadget.gadgets.death.DeathShadow; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; -import mineplex.core.gadget.gadgets.particle.ParticleFoot; +import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; +import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; +import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; +import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; import mineplex.core.gadget.types.GadgetSet; public class SetShadow extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java index fb21b5f9e..77727b480 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; -import mineplex.core.gadget.gadgets.death.DeathSpring; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.death.spring.DeathSpring; +import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java index 360d86270..7c66a8f6c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan; -import mineplex.core.gadget.gadgets.death.DeathTitan; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan; -import mineplex.core.gadget.gadgets.particle.ParticleTitan; +import mineplex.core.gadget.gadgets.arrowtrail.titan.ArrowTrailTitan; +import mineplex.core.gadget.gadgets.death.titan.DeathTitan; +import mineplex.core.gadget.gadgets.doublejump.titan.DoubleJumpTitan; +import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan; import mineplex.core.gadget.types.GadgetSet; public class SetTitan extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java index 1a5541085..b070122de 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.death.DeathBlood; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.particle.ParticleBlood; +import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; +import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; +import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; +import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; import mineplex.core.gadget.types.GadgetSet; public class SetVampire extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java index 5bbae55da..2d2ff0693 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; -import mineplex.core.gadget.gadgets.death.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; -import mineplex.core.gadget.gadgets.particle.ParticleEnchant; +import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; +import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; +import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; import mineplex.core.gadget.types.GadgetSet; public class SetWisdom extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java deleted file mode 100644 index 7b7d71883..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java +++ /dev/null @@ -1,90 +0,0 @@ -package mineplex.core.gadget.types; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilText; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.flag.FlagType; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -/** - * Flags which sit upon players head. - */ -public class FlagGadget extends Gadget -{ - private final FlagType _flag; - - public FlagGadget(GadgetManager manager, FlagType flag) - { - super(manager, GadgetType.FLAG, flag.getFlag().getCountryAdjective() + " Flag", - UtilText.splitLineToArray(C.cGray + "The flag of " + C.cWhite + flag.getFlag().getCountryName(), LineFormat.LORE), - flag.getCost(), Material.WOOL, (byte) 0); - - setDisplayItem(flag.getFlag().getBanner()); - _flag = flag; - } - - public void applyArmor(Player player, boolean message) - { - Manager.removeGadgetType(player, GadgetType.MORPH, this); - Manager.removeGadgetType(player, GadgetType.FLAG, this); - Manager.removeOutfit(player, OutfitGadget.ArmorSlot.HELMET); - - _active.add(player); - - if (message) - { - UtilPlayer.message(player, F.main("Gadget", "You unfurled your " + F.elem(getName()) + ".")); - } - } - - public void removeArmor(Player player) - { - if (_active.remove(player)) - { - UtilPlayer.message(player, F.main("Gadget", "You put away your " + F.elem(getName()) + ".")); - } - } - - @Override - public void enableCustom(Player player, boolean message) - { - applyArmor(player, message); - ItemStack flag = _flag.getFlag().getBanner(); - ItemMeta meta = flag.getItemMeta(); - meta.setDisplayName(getDisplayName()); - flag.setItemMeta(meta); - player.getInventory().setHelmet(flag); - player.updateInventory(); - } - - @Override - public void disableCustom(Player player, boolean message) - { - removeArmor(player); - player.getInventory().setHelmet(new ItemStack(Material.AIR)); - player.updateInventory(); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void playerDeath(PlayerDeathEvent event) - { - disable(event.getEntity()); - } - - /** - * @return The specific gadget which this represents. - */ - public FlagType getFlagType() - { - return _flag; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java index 386f764a4..edc823e6d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java @@ -18,8 +18,7 @@ public enum GadgetType WIN_EFFECT("Win Effects", "activeWinEffect"), GAME_MODIFIER("Game Modifiers", ""), BALLOON("Balloons", ""), - KIT_SELECTOR("Kit Selectors", "activeKitSelector"), - FLAG("Flags", "activeFlag"); + KIT_SELECTOR("Kit Selectors", "activeKitSelector"); private String _name; private String _databaseKey; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java index 38df4c367..b6becadc1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java @@ -47,7 +47,7 @@ public abstract class HatGadget extends OutfitGadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - Manager.removeGadgetType(player, GadgetType.FLAG, this); + Manager.removeOutfit(player, _slot); _active.add(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java index 7240ed1d5..4fb2b5ed9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java @@ -26,8 +26,7 @@ public abstract class MorphGadget extends Gadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - Manager.removeGadgetType(player, GadgetType.COSTUME, this); - Manager.removeGadgetType(player, GadgetType.FLAG, this); + Manager.removeGadgetType(player, GadgetType.COSTUME); _active.add(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java index 78471a943..6ce4d70b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java @@ -60,12 +60,7 @@ public abstract class OutfitGadget extends Gadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - - if (_slot == ArmorSlot.HELMET) - { - Manager.removeGadgetType(player, GadgetType.FLAG, this); - } - + Manager.removeOutfit(player, _slot); _active.add(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java index c0b11870d..991a7425b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java @@ -76,13 +76,11 @@ public abstract class TauntGadget extends Gadget public void start(Player player) { - if (onStart(player)) - { - _ticksPerPlayer.put(player.getUniqueId(), 0); - } + onStart(player); + _ticksPerPlayer.put(player.getUniqueId(), 0); } - public abstract boolean onStart(Player player); + public abstract void onStart(Player player); public void play(Player player) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java index ff998efee..137ae9bbe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java @@ -39,7 +39,7 @@ public class MountTitanData extends MountData //Nodes _nodes = new ArrayList(); - for (int i=0 ; i<20 ; i++) + for (int i=0 ; i<30 ; i++) { ArmorStand node = loc.getWorld().spawn(loc, ArmorStand.class); @@ -81,7 +81,7 @@ public class MountTitanData extends MountData Location infront = _head.getLocation().add(0, -1.5, 0); //Move - for (int i=0 ; i<20 ; i++) + for (int i=0 ; i<30 ; i++) { ArmorStand node = _nodes.get(i); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java index 281374325..ef209276e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java @@ -6,6 +6,9 @@ import org.bukkit.entity.Player; import mineplex.core.common.util.Callback; +/** + * Created by Shaun on 9/2/2014. + */ public abstract class Reward { protected static final Random RANDOM = new Random(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java index 6f3acd00b..8179dbb98 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java @@ -2,6 +2,9 @@ package mineplex.core.reward; import org.bukkit.inventory.ItemStack; +/** + * Created by shaun on 14-09-18. + */ public class RewardData { private final String _header; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 783e16317..5f4e5fb16 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -5,14 +5,6 @@ import java.util.EnumMap; import java.util.List; import java.util.Random; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; -import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; -import mineplex.core.gadget.gadgets.flag.FlagType; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -23,46 +15,46 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; +import mineplex.core.gadget.gadgets.arrowtrail.halloween.ArrowTrailHalloween; +import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; +import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; +import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; +import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; +import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; +import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.balloons.BalloonType; -import mineplex.core.gadget.gadgets.death.DeathCandyCane; -import mineplex.core.gadget.gadgets.death.DeathPresentDanger; -import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; -import mineplex.core.gadget.gadgets.death.DeathEmerald; -import mineplex.core.gadget.gadgets.death.DeathFreedom; -import mineplex.core.gadget.gadgets.death.DeathFrostLord; -import mineplex.core.gadget.gadgets.death.DeathStorm; -import mineplex.core.gadget.gadgets.death.DeathMusic; -import mineplex.core.gadget.gadgets.death.DeathPinataBurst; -import mineplex.core.gadget.gadgets.death.DeathShadow; -import mineplex.core.gadget.gadgets.death.DeathSpring; -import mineplex.core.gadget.gadgets.death.DeathBlood; -import mineplex.core.gadget.gadgets.death.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; +import mineplex.core.gadget.gadgets.death.christmas.DeathPresentDanger; +import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart; +import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald; +import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; +import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; +import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; +import mineplex.core.gadget.gadgets.death.music.DeathMusic; +import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; +import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; +import mineplex.core.gadget.gadgets.death.spring.DeathSpring; +import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; +import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; +import mineplex.core.gadget.gadgets.doublejump.halloween.DoubleJumpHalloween; +import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; +import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; +import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; +import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; +import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; +import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin; import mineplex.core.gadget.gadgets.hat.HatType; import mineplex.core.gadget.gadgets.item.ItemBatGun; @@ -124,18 +116,18 @@ import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsLove; import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; import mineplex.core.gadget.gadgets.particle.ParticleYinYang; -import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; -import mineplex.core.gadget.gadgets.particle.ParticleHeart; -import mineplex.core.gadget.gadgets.particle.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; +import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; -import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; -import mineplex.core.gadget.gadgets.particle.ParticleRain; -import mineplex.core.gadget.gadgets.particle.ParticleMusic; -import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; -import mineplex.core.gadget.gadgets.particle.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; +import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; +import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; +import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; -import mineplex.core.gadget.gadgets.particle.ParticleBlood; -import mineplex.core.gadget.gadgets.particle.ParticleEnchant; +import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken; @@ -326,10 +318,6 @@ public class RewardManager addHat(Type.WINTER_HOLIDAY, HatType.PRESENT, rarity, 5); addHat(Type.WINTER_HOLIDAY, HatType.SNOWMAN, rarity, 5); - // FREEDOM - addGadget(Type.FREEDOM, getGadget(ArrowTrailRedWhite.class), rarity, 150); - addGadget(Type.FREEDOM, getGadget(ArrowTrailFreedom.class), rarity, 150); - // Omega items addMusicReward(Type.OMEGA, "Blocks Disc", rarity, 25); addMusicReward(Type.OMEGA, "Cat Disc", rarity, 25); @@ -496,12 +484,9 @@ public class RewardManager // FREEDOM addHat(Type.FREEDOM, HatType.UNCLE_SAM, rarity, 100); - addHat(Type.FREEDOM, HatType.AMERICA, rarity, 120); - addHat(Type.FREEDOM, HatType.CANADA, rarity, 120); addGadget(Type.FREEDOM, getGadget(DoubleJumpFreedom.class), rarity, 50); - addGadget(Type.FREEDOM, getGadget(DoubleJumpMaple.class), rarity, 50); + addGadget(Type.FREEDOM, getGadget(ArrowTrailFreedom.class), rarity, 10); addGadget(Type.FREEDOM, getGadget(DeathFreedom.class), rarity, 75); - addGadget(Type.FREEDOM, getGadget(DeathMapleLeaf.class), rarity, 75); // Omega Chest addGadget(Type.OMEGA, getGadget(DoubleJumpFreedom.class), rarity, 5); @@ -773,12 +758,6 @@ public class RewardManager addMount(Type.FREEDOM, getMount(MountFreedomHorse.class), rarity, 1); addGadget(Type.FREEDOM, getGadget(MorphUncleSam.class), rarity, 5); addGadget(Type.FREEDOM, getGadget(ParticleFreedom.class), rarity, 50); - addGadget(Type.FREEDOM, getGadget(ParticleFreedomFireworks.class), rarity, 95); - addGadget(Type.FREEDOM, getGadget(ParticleAuraNiceness.class), rarity, 40); - addGadget(Type.FREEDOM, getGadget(ParticleCanadian.class), rarity, 10); - addGadget(Type.FREEDOM, getGadget(ParticleStarSpangled.class), rarity, 10); - addFlag(Type.FREEDOM, FlagType.CANADA, rarity, 35); - addFlag(Type.FREEDOM, FlagType.UNITED_STATES, rarity, 35); // Omega items addPetReward(Type.OMEGA, PetType.VILLAGER, rarity, 1); @@ -1034,17 +1013,6 @@ public class RewardManager return addGadget(type, gadget, gadget.getDisplayName(), rarity, weight, shards); } - public UnknownPackageReward addFlag(Type type, FlagType flagType, RewardRarity rarity, int weight) - { - return addFlag(type, flagType, rarity, weight, getShards(rarity)); - } - - public UnknownPackageReward addFlag(Type type, FlagType flagType, RewardRarity rarity, int weight, int shards) - { - Gadget gadget = _gadgetManager.getFlagGadget(flagType); - return addGadget(type, gadget, gadget.getDisplayName(), rarity, weight, shards); - } - public UnknownPackageReward addBalloon(Type type, BalloonType balloonType, RewardRarity rarity, int weight) { return addBalloon(type, balloonType, rarity, weight, getShards(rarity)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java index eff019430..759769234 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java @@ -7,6 +7,9 @@ import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.common.util.C; import static mineplex.core.common.util.C.*; +/** + * Created by Shaun on 9/2/2014. + */ public enum RewardRarity { /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java index 15a85c4dd..ca001e6a5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.HandlerList; import mineplex.core.treasure.Treasure; /** - * Called once a player has finished with the treasure opening process. + * Created by shaun on 14-09-12. */ public class TreasureFinishEvent extends Event { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java index 29355cfd1..d384c61db 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** - * Called when a player selects a chest to open. + * Created by shaun on 14-09-12. */ public class TreasurePreStartEvent extends Event implements Cancellable { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java index 37d59dc74..70c891f52 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java @@ -10,9 +10,6 @@ import org.bukkit.event.HandlerList; import mineplex.core.reward.Reward; import mineplex.core.treasure.Treasure; -/** - * Called when a player is able to begin opening chests. - */ public class TreasureStartEvent extends Event { private static final HandlerList handlers = new HandlerList(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index 6c79d08c8..030e3dc1d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -4,15 +4,6 @@ import java.io.File; import java.util.ArrayList; import java.util.List; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; -import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; -import mineplex.core.gadget.gadgets.flag.FlagType; -import mineplex.core.gadget.gadgets.hat.HatType; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -29,9 +20,9 @@ import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.death.DeathFreedom; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; +import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; import mineplex.core.gadget.gadgets.morph.MorphUncleSam; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; import mineplex.core.gadget.types.Gadget; @@ -150,7 +141,7 @@ public class TreasurePage extends ShopPageBase int springCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.SPRING.getItemName()); boolean availableChristmas = false; - boolean availableFreedom = true; + boolean availableFreedom = false; boolean availableHaunted = false; boolean availableTrick = false; boolean availableThank = false; @@ -161,8 +152,8 @@ public class TreasurePage extends ShopPageBase List shardLore = new ArrayList<>(); shardLore.add(" "); - shardLore.add(C.cGray + "These seem like they might come in"); - shardLore.add(C.cGray + "handy. Maybe I should collect more!"); + shardLore.add(C.cGray + "This seems like it might come in"); + shardLore.add(C.cGray + "handy. Maybe I can collect more!"); List basicLore = new ArrayList<>(); basicLore.add(" "); @@ -263,36 +254,14 @@ public class TreasurePage extends ShopPageBase freedomLore.add(C.cGray + "carved this chest himself from the wood"); freedomLore.add(C.cGray + "of the apple tree he cut down..."); freedomLore.add(" "); - - if (freedomCount > 0) - { - if (hasAllFreedomItems(getPlayer())) - { - freedomLore.add(C.cWhite + "You own all treasures from this chest."); - } - else - { - freedomLore.add(C.cGreen + "Click to Open!"); - } - } + if (freedomCount > 0 && !hasAllFreedomItems(getPlayer())) + freedomLore.add(C.cGreen + "Click to Open!"); else { - if (!availableFreedom) - { - freedomLore.add(C.cRed + "This item is no longer available!"); - } - else if (hasAllFreedomItems(getPlayer())) - { - freedomLore.add(C.cWhite + "You own all treasures from this chest."); - } - else - { - freedomLore.add(ChatColor.RESET + "Purchase at: " + C.cYellow + "www.mineplex.com/shop"); - } + freedomLore.add(C.cRed + "This item is no longer available!"); } - freedomLore.add(" "); - freedomLore.add(ChatColor.RESET + C.cGreen + getFreedomUnlockedAmount(getPlayer()) + "/18 Unlocked"); + freedomLore.add(ChatColor.RESET + C.cGreen + getFreedomUnlockedAmount(getPlayer()) + "/7 Unlocked"); List omegaLore = new ArrayList<>(); omegaLore.add(" "); @@ -730,7 +699,7 @@ public class TreasurePage extends ShopPageBase public int getFreedomUnlockedAmount(Player player) { if (hasAllFreedomItems(player)) - return 18; + return 7; int amount = 0; Gadget[] gadgets = new Gadget[] { @@ -739,18 +708,7 @@ public class TreasurePage extends ShopPageBase _gadgetManager.getGadget(ArrowTrailFreedom.class), _gadgetManager.getGadget(DoubleJumpFreedom.class), _gadgetManager.getGadget(DeathFreedom.class), - _gadgetManager.getGadget(MorphUncleSam.class), - _gadgetManager.getGadget(ArrowTrailRedWhite.class), - _gadgetManager.getGadget(DeathMapleLeaf.class), - _gadgetManager.getGadget(DoubleJumpMaple.class), - _gadgetManager.getGadget(ParticleAuraNiceness.class), - _gadgetManager.getGadget(ParticleCanadian.class), - _gadgetManager.getGadget(ParticleFreedomFireworks.class), - _gadgetManager.getGadget(ParticleStarSpangled.class), - _gadgetManager.getHatGadget(HatType.AMERICA), - _gadgetManager.getHatGadget(HatType.CANADA), - _gadgetManager.getFlagGadget(FlagType.CANADA), - _gadgetManager.getFlagGadget(FlagType.UNITED_STATES), + _gadgetManager.getGadget(MorphUncleSam.class) }; Mount freedomMount = _gadgetManager.getMountManager().getMount("Freedom Mount"); if (freedomMount != null) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index b02d21718..29e6ab472 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -233,7 +233,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter _treasureManager.addTreasureLocation(loc); } - new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager, punish); + new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); new MenuManager(_plugin); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index eb7242bde..bc02c3628 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -235,7 +235,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess _bonusManager = new BonusManager(plugin, null, playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager, "Carl"); _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager()); - CosmeticManager cosmeticManager = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager, punish); + CosmeticManager cosmeticManager = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); _mavericksManager = new MavericksManager(plugin, cosmeticManager, hologramManager, this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 5f75dde80..ebf57b8d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -201,7 +201,7 @@ public class Arcade extends JavaPlugin GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager); ThankManager thankManager = new ThankManager(this, _clientManager, _donationManager); BoosterManager boosterManager = new BoosterManager(this, _serverConfiguration.getServerGroup().getBoosterGroup(), _clientManager, _donationManager, inventoryManager, thankManager); - CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager, punish); + CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager); cosmeticManager.setInterfaceSlot(6); gadgetManager.setActiveItemSlot(3); cosmeticManager.disableTeamArmor(); diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java index 4fbb830fa..ebc01ac9c 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java @@ -138,7 +138,7 @@ public class Hub extends JavaPlugin RewardManager rewardManager = new RewardManager(_clientManager, _donationManager, inventoryManager, petManager, gadgetManager, statsManager); TreasureManager treasureManager = new TreasureManager(this, _clientManager, serverStatusManager, _donationManager, inventoryManager, petManager, gadgetManager, blockRestore, hologramManager, statsManager, rewardManager); CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, - mountManager, petManager, treasureManager, boosterManager, punish); + mountManager, petManager, treasureManager, boosterManager); cosmeticManager.setInterfaceSlot(7); cosmeticManager.disableTeamArmor(); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index b0df81d54..d4e557763 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -258,7 +258,7 @@ public class GemHunters extends JavaPlugin GadgetManager gadgetManager = new GadgetManager(this, clientManager, donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager); ThankManager thankManager = new ThankManager(this, clientManager, donationManager); BoosterManager boosterManager = new BoosterManager(this, null, clientManager, donationManager, inventoryManager, thankManager); - CosmeticManager cosmeticManager = new CosmeticManager(this, clientManager, donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager, punish); + CosmeticManager cosmeticManager = new CosmeticManager(this, clientManager, donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager); cosmeticManager.setActive(false); cosmeticManager.setHideParticles(true);