From 5f755add782fc6032f76844862e095f0c55b1746 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Fri, 21 Oct 2016 17:24:27 +0100 Subject: [PATCH 01/56] Rename /reportstats command to /reporthistory --- .../src/mineplex/core/report/ReportPlugin.java | 4 ++-- ...{ReportStatsCommand.java => ReportHistoryCommand.java} | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) rename Plugins/Mineplex.Core/src/mineplex/core/report/command/{ReportStatsCommand.java => ReportHistoryCommand.java} (92%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java index 7f960f1a7..15a364d82 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java @@ -10,7 +10,7 @@ import mineplex.core.report.command.ReportCloseCommand; import mineplex.core.report.command.ReportCommand; import mineplex.core.report.command.ReportHandleCommand; import mineplex.core.report.command.ReportInfoCommand; -import mineplex.core.report.command.ReportStatsCommand; +import mineplex.core.report.command.ReportHistoryCommand; /** * Main class for this module, handles initialization and disabling of the module. @@ -36,7 +36,7 @@ public class ReportPlugin extends MiniPlugin addCommand(new ReportCommand(this)); addCommand(new ReportHandleCommand(this)); addCommand(new ReportCloseCommand(this)); - addCommand(new ReportStatsCommand(this)); + addCommand(new ReportHistoryCommand(this)); addCommand(new ReportInfoCommand(this)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java similarity index 92% rename from Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java index e02de3ae1..f581a902d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportStatsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java @@ -18,11 +18,11 @@ import mineplex.core.report.ReportRole; /** * A staff command for viewing report related statistics of a player. */ -public class ReportStatsCommand extends CommandBase +public class ReportHistoryCommand extends CommandBase { - public ReportStatsCommand(ReportPlugin reportPlugin) + public ReportHistoryCommand(ReportPlugin reportPlugin) { - super(reportPlugin, Rank.MODERATOR, "reportstats", "rs"); + super(reportPlugin, Rank.MODERATOR, "reporthistory", "rhis"); } @Override @@ -40,7 +40,7 @@ public class ReportStatsCommand extends CommandBase Plugin.getReportManager().getReportRepository().getAccountStatistics(accountId).thenCompose(BukkitFuture.accept(stats -> { - UtilPlayer.message(player, F.main(Plugin.getName(), "Report Statistics for " + F.elem(playerName))); + UtilPlayer.message(player, F.main(Plugin.getName(), "Report History for " + F.elem(playerName))); for (ReportRole role : ReportRole.values()) { From e0d05d3c87cf6f114990d7034d37cc51f4d9fe57 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sat, 22 Oct 2016 15:06:18 +0100 Subject: [PATCH 02/56] PC-1140 Keep reports region-separated --- .../mineplex/core/report/ReportManager.java | 14 +++++++-- .../src/mineplex/core/report/data/Report.java | 14 +++++++-- .../core/report/data/ReportRepository.java | 31 ++++++++++++++----- .../core/report/ui/ReportHandlePage.java | 5 ++- .../src/mineplex/game/clans/Clans.java | 2 +- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 2 +- .../sql/{upgrade.sql => 1-upgrade.sql} | 0 ...{after-upgrade.sql => 2-after-upgrade.sql} | 0 .../sql/{hotfix.sql => 3-hotfix.sql} | 0 ...pshot-tokens.sql => 4-snapshot-tokens.sql} | 0 .../Mineplex.ReportSite/sql/5-region-lock.sql | 3 ++ .../src/nautilus/game/arcade/Arcade.java | 2 +- 12 files changed, 55 insertions(+), 18 deletions(-) rename Plugins/Mineplex.ReportSite/sql/{upgrade.sql => 1-upgrade.sql} (100%) rename Plugins/Mineplex.ReportSite/sql/{after-upgrade.sql => 2-after-upgrade.sql} (100%) rename Plugins/Mineplex.ReportSite/sql/{hotfix.sql => 3-hotfix.sql} (100%) rename Plugins/Mineplex.ReportSite/sql/{snapshot-tokens.sql => 4-snapshot-tokens.sql} (100%) create mode 100644 Plugins/Mineplex.ReportSite/sql/5-region-lock.sql diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index 69002af2b..a8290f74b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -41,6 +41,7 @@ import mineplex.core.report.data.ReportUser; import mineplex.core.report.data.ReportUserRepository; import mineplex.core.report.data.ReportRepository; import mineplex.core.report.redis.ReportersNotification; +import mineplex.serverdata.Region; import mineplex.serverdata.commands.ServerCommandManager; import static com.google.common.base.Preconditions.checkNotNull; @@ -58,6 +59,7 @@ public class ReportManager private final CoreClientManager _clientManager; private final IncognitoManager _incognitoManager; private final Punish _punish; + private final Region _region; private final String _serverName; private final int _serverWeight; @@ -65,13 +67,14 @@ public class ReportManager private final ReportUserRepository _reportUserRepository; public ReportManager(JavaPlugin plugin, SnapshotManager snapshotManager, CoreClientManager clientManager, - IncognitoManager incognitoManager, Punish punish, String serverName, int serverWeight) + IncognitoManager incognitoManager, Punish punish, Region region, String serverName, int serverWeight) { _plugin = plugin; _snapshotManager = snapshotManager; _clientManager = clientManager; _incognitoManager = incognitoManager; _punish = punish; + _region = region; _serverName = serverName; _serverWeight = serverWeight; @@ -92,6 +95,11 @@ public class ReportManager return _snapshotManager; } + public Region getRegion() + { + return _region; + } + /** * Gets the {@link ReportRepository} we are using. * @@ -168,12 +176,12 @@ public class ReportManager reportOptional.orElseGet(() -> { _plugin.getLogger().log(Level.WARNING, "Report #%d couldn't be fetched, opening new report."); - return new Report(suspectId, category); + return new Report(suspectId, category, _region); })); } else { - return CompletableFuture.completedFuture(new Report(suspectId, category)); + return CompletableFuture.completedFuture(new Report(suspectId, category, _region)); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java index 6fd4af9f6..8bb8ed8a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/Report.java @@ -10,6 +10,7 @@ import mineplex.core.report.ReportCategory; import mineplex.core.report.ReportHandlerTask; import mineplex.core.report.ReportResult; import mineplex.core.report.ReportTeam; +import mineplex.serverdata.Region; /** * Holds data for a Report. @@ -19,6 +20,7 @@ public class Report protected Long _reportId; private final int _suspectId; private final ReportCategory _category; + private final Region _region; // set of player account ids and the reason they reported this player private final Map _reportMessages = new HashMap<>(); private Integer _handlerId = null; @@ -28,16 +30,17 @@ public class Report private ReportHandlerTask _handlerTask = null; - public Report(int suspectId, ReportCategory category) + public Report(int suspectId, ReportCategory category, Region region) { - this(null, suspectId, category); + this(null, suspectId, category, region); } - protected Report(Long reportId, int suspectId, ReportCategory category) + protected Report(Long reportId, int suspectId, ReportCategory category, Region region) { _reportId = reportId; _suspectId = suspectId; _category = category; + _region = region; } public Optional getId() @@ -55,6 +58,11 @@ public class Report return _category; } + public Optional getRegion() + { + return Optional.ofNullable(_region); + } + public Map getMessages() { return _reportMessages; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index 57f553921..e0c2554d3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -38,6 +38,7 @@ import mineplex.core.report.ReportResult; import mineplex.core.report.ReportResultType; import mineplex.core.report.ReportRole; import mineplex.core.report.ReportTeam; +import mineplex.serverdata.Region; import mineplex.serverdata.database.DBPool; import org.apache.commons.lang3.StringUtils; @@ -46,8 +47,8 @@ import org.apache.commons.lang3.StringUtils; */ public class ReportRepository { - private static final String INSERT_REPORT = "INSERT INTO reports (suspectId, categoryId, snapshotId, assignedTeam)\n" + - "VALUES (?, ?, ?, ?);"; + private static final String INSERT_REPORT = "INSERT INTO reports (suspectId, categoryId, snapshotId, assignedTeam, region)\n" + + "VALUES (?, ?, ?, ?, ?);"; private static final String UPDATE_REPORT = "UPDATE reports SET snapshotId = ?, assignedTeam = ? WHERE id = ?;"; @@ -79,6 +80,7 @@ public class ReportRepository " LEFT JOIN reportHandlers ON reports.id = reportHandlers.reportId\n" + " LEFT JOIN reportReasons ON reports.id = reportReasons.reportId\n" + "WHERE reports.categoryId = ?\n" + + " AND (reports.region IS NULL OR reports.region = ?)\n" + " AND reportResults.reportId IS NULL\n" + " /* Bypass for testing purposes or check player isn't suspect */\n" + " AND (? IS TRUE OR reports.suspectId != ?)\n" + @@ -162,7 +164,7 @@ public class ReportRepository * @param devMode if true, allows various restrictions to be bypassed * @return the ids of unhandled reports the supplied account is allowed to handle */ - public CompletableFuture> getUnhandledReports(int accountId, ReportCategory category, boolean devMode) + public CompletableFuture> getUnhandledReports(int accountId, ReportCategory category, Region region, boolean devMode) { CompletableFuture> future = CompletableFuture.supplyAsync(() -> { @@ -172,12 +174,13 @@ public class ReportRepository { PreparedStatement preparedStatement = connection.prepareStatement(GET_UNHANDLED_REPORTS); preparedStatement.setShort(1, category.getId()); - preparedStatement.setBoolean(2, devMode); - preparedStatement.setInt(3, accountId); + preparedStatement.setString(2, region.name()); + preparedStatement.setBoolean(3, devMode); preparedStatement.setInt(4, accountId); preparedStatement.setInt(5, accountId); - preparedStatement.setBoolean(6, devMode); - preparedStatement.setInt(7, accountId); + preparedStatement.setInt(6, accountId); + preparedStatement.setBoolean(7, devMode); + preparedStatement.setInt(8, accountId); ResultSet resultSet = preparedStatement.executeQuery(); while (resultSet.next()) @@ -333,8 +336,10 @@ public class ReportRepository long reportId = resultSet.getLong("id"); int suspectId = resultSet.getInt("suspectId"); ReportCategory reportCategory = ReportCategory.getById(resultSet.getInt("categoryId")); + String regionName = resultSet.getString("region"); + Region region = !resultSet.wasNull() ? Region.valueOf(regionName) : null; - Report report = new Report(reportId, suspectId, reportCategory); + Report report = new Report(reportId, suspectId, reportCategory, region); int snapshotId = resultSet.getInt("snapshotId"); if (!resultSet.wasNull()) @@ -546,6 +551,7 @@ public class ReportRepository try (Connection connection = DBPool.getAccount().getConnection()) { Optional reportIdOptional = report.getId(); + Optional regionOptional = report.getRegion(); Optional snapshotIdOptional = report.getSnapshotMetadata().map(SnapshotMetadata::getId); Optional teamOptional = report.getAssignedTeam(); long reportId; @@ -603,6 +609,15 @@ public class ReportRepository insertReportStatement.setNull(4, Types.TINYINT); } + if (regionOptional.isPresent()) + { + insertReportStatement.setString(5, regionOptional.get().name()); + } + else + { + insertReportStatement.setNull(5, Types.VARCHAR); + } + insertReportStatement.executeUpdate(); ResultSet resultSet = insertReportStatement.getGeneratedKeys(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java index 830085fa5..a10835ae2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java @@ -19,6 +19,7 @@ import mineplex.core.report.ReportManager; import mineplex.core.report.ReportPlugin; import mineplex.core.report.data.Report; import mineplex.core.report.data.ReportRepository; +import mineplex.serverdata.Region; /** * An interface which allows the user to select the type of report they'd like to handle. @@ -28,6 +29,7 @@ public class ReportHandlePage extends SimpleGui implements ReportCategoryCallbac private final ReportPlugin _plugin; private final Player _handler; private final int _handlerId; + private final Region _region; public ReportHandlePage(ReportPlugin plugin, Player handler, int handlerId) { @@ -36,6 +38,7 @@ public class ReportHandlePage extends SimpleGui implements ReportCategoryCallbac _plugin = plugin; _handler = handler; _handlerId = handlerId; + _region = plugin.getReportManager().getRegion(); buildPage(); } @@ -70,7 +73,7 @@ public class ReportHandlePage extends SimpleGui implements ReportCategoryCallbac // the below fetches the ids of all unhandled reports and gets a Report object for each of these ids // the priority of the report is then calculated and the results placed in a map - reportRepository.getUnhandledReports(_handlerId, category, devMode).thenCompose(reportRepository::getReports).thenAccept(reports -> + reportRepository.getUnhandledReports(_handlerId, category, _region, devMode).thenCompose(reportRepository::getReports).thenAccept(reports -> CompletableFuture.allOf(reports.stream().map(report -> reportManager.calculatePriority(report).thenAccept(priority -> { 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 5ff84a246..00ba471e7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -239,7 +239,7 @@ public class Clans extends JavaPlugin SnapshotManager snapshotManager = new SnapshotManager(this, new SnapshotRepository(serverStatusManager.getCurrentServerName(), getLogger())); new SnapshotPlugin(this, snapshotManager, _clientManager); - new ReportPlugin(this, new ReportManager(this, snapshotManager, _clientManager, incognito, punish, serverStatusManager.getCurrentServerName(), 1)); + new ReportPlugin(this, new ReportManager(this, snapshotManager, _clientManager, incognito, punish, serverStatusManager.getRegion(), serverStatusManager.getCurrentServerName(), 1)); // Enable custom-gear related managers new CustomTagFix(this, packetHandler); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 56a6af3ae..c6756c64b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -187,7 +187,7 @@ public class Hub extends JavaPlugin implements IRelation //new Replay(this, packetHandler); SnapshotManager snapshotManager = new SnapshotManager(this, new SnapshotRepository(serverStatusManager.getCurrentServerName(), getLogger())); - ReportManager reportManager = new ReportManager(this, snapshotManager, clientManager, incognito, punish, serverStatusManager.getCurrentServerName(), 3); + ReportManager reportManager = new ReportManager(this, snapshotManager, clientManager, incognito, punish, serverStatusManager.getRegion(), serverStatusManager.getCurrentServerName(), 3); new SnapshotPlugin(this, snapshotManager, clientManager); new ReportPlugin(this, reportManager); diff --git a/Plugins/Mineplex.ReportSite/sql/upgrade.sql b/Plugins/Mineplex.ReportSite/sql/1-upgrade.sql similarity index 100% rename from Plugins/Mineplex.ReportSite/sql/upgrade.sql rename to Plugins/Mineplex.ReportSite/sql/1-upgrade.sql diff --git a/Plugins/Mineplex.ReportSite/sql/after-upgrade.sql b/Plugins/Mineplex.ReportSite/sql/2-after-upgrade.sql similarity index 100% rename from Plugins/Mineplex.ReportSite/sql/after-upgrade.sql rename to Plugins/Mineplex.ReportSite/sql/2-after-upgrade.sql diff --git a/Plugins/Mineplex.ReportSite/sql/hotfix.sql b/Plugins/Mineplex.ReportSite/sql/3-hotfix.sql similarity index 100% rename from Plugins/Mineplex.ReportSite/sql/hotfix.sql rename to Plugins/Mineplex.ReportSite/sql/3-hotfix.sql diff --git a/Plugins/Mineplex.ReportSite/sql/snapshot-tokens.sql b/Plugins/Mineplex.ReportSite/sql/4-snapshot-tokens.sql similarity index 100% rename from Plugins/Mineplex.ReportSite/sql/snapshot-tokens.sql rename to Plugins/Mineplex.ReportSite/sql/4-snapshot-tokens.sql diff --git a/Plugins/Mineplex.ReportSite/sql/5-region-lock.sql b/Plugins/Mineplex.ReportSite/sql/5-region-lock.sql new file mode 100644 index 000000000..33260ef6b --- /dev/null +++ b/Plugins/Mineplex.ReportSite/sql/5-region-lock.sql @@ -0,0 +1,3 @@ +ALTER TABLE Account.reports ADD region VARCHAR(5) NULL; +ALTER TABLE Account.reports + MODIFY COLUMN region VARCHAR(5) AFTER categoryId; \ No newline at end of file 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 2a9f9b518..422862f46 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -161,7 +161,7 @@ public class Arcade extends JavaPlugin new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); SnapshotManager snapshotManager = new SnapshotManager(this, new SnapshotRepository(serverStatusManager.getCurrentServerName(), getLogger())); - ReportManager reportManager = new ReportManager(this, snapshotManager, _clientManager, incognito, punish, serverStatusManager.getCurrentServerName(), 1); + ReportManager reportManager = new ReportManager(this, snapshotManager, _clientManager, incognito, punish, serverStatusManager.getRegion(), serverStatusManager.getCurrentServerName(), 1); new SnapshotPlugin(this, snapshotManager, _clientManager); new ReportPlugin(this, reportManager); From 35048b46a70b558ca02d69d2c2231769578158b4 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sat, 22 Oct 2016 19:17:20 +0100 Subject: [PATCH 03/56] Report/snapshot code clean-up --- .../core/chatsnap/SnapshotManager.java | 27 +++--- .../core/chatsnap/SnapshotRepository.java | 89 +++++-------------- .../PushSnapshotsCommand.java | 2 +- .../PushSnapshotsHandler.java | 2 +- .../mineplex/core/report/ReportManager.java | 4 +- 5 files changed, 41 insertions(+), 83 deletions(-) rename Plugins/Mineplex.Core/src/mineplex/core/chatsnap/{command => redis}/PushSnapshotsCommand.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/chatsnap/{command => redis}/PushSnapshotsHandler.java (97%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java index 7f063cf6a..389d772bb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java @@ -134,18 +134,19 @@ public class SnapshotManager public CompletableFuture saveReportSnapshot(Report report, Collection messages) { - return _snapshotRepository - .saveReportSnapshot(report, messages) - .whenComplete((snapshotMetadata, throwable) -> - { - if (throwable == null) - { - report.setSnapshotMetadata(snapshotMetadata); - } - else - { - _javaPlugin.getLogger().log(Level.SEVERE, "Error whilst saving snapshot.", throwable); - } - }); + SnapshotMetadata snapshotMetadata = report.getSnapshotMetadata().orElseThrow(() -> + new IllegalStateException("Report does not have associated snapshot.")); + + return _snapshotRepository.insertMessages(snapshotMetadata.getId(), messages).whenComplete(((aVoid, throwable) -> + { + if (throwable == null) + { + report.setSnapshotMetadata(snapshotMetadata); + } + else + { + _javaPlugin.getLogger().log(Level.SEVERE, "Error whilst saving snapshot.", throwable); + } + })).thenApply(aVoid -> snapshotMetadata); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java index e832cd8b6..8ab7297a9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java @@ -82,42 +82,6 @@ public class SnapshotRepository _logger = logger; } - public CompletableFuture saveReportSnapshot(Report report, Collection messages) - { - return CompletableFuture.supplyAsync(() -> - { - try (Connection connection = DBPool.getAccount().getConnection()) - { - SnapshotMetadata snapshotMetadata = report.getSnapshotMetadata().orElseThrow(() -> - new IllegalStateException("Report does not have associated snapshot.")); - - insertMessages(snapshotMetadata.getId(), messages, connection); - return snapshotMetadata; - } - catch (SQLException e) - { - throw new RuntimeException(e); - } - }); - } - - public CompletableFuture saveSnapshot(Collection messages) - { - return CompletableFuture.supplyAsync(() -> - { - try (Connection connection = DBPool.getAccount().getConnection()) - { - SnapshotMetadata snapshotMetadata = createSnapshot(connection, null); - insertMessages(snapshotMetadata.getId(), messages, connection); - return snapshotMetadata; - } - catch (SQLException e) - { - throw new RuntimeException(e); - } - }); - } - public CompletableFuture createSnapshot(Integer creatorAccountId) { return CompletableFuture.supplyAsync(() -> @@ -254,36 +218,9 @@ public class SnapshotRepository } } - private void insertMessages(int snapshotId, Collection messages, Connection connection) throws SQLException + public CompletableFuture insertMessages(int snapshotId, Collection messages) { - try (PreparedStatement insertSnapshotStatement = connection.prepareStatement(INSERT_MESSAGE, new String[]{"id"})) - { - try (PreparedStatement insertRecipientStatement = connection.prepareStatement(INSERT_MESSAGE_RECIPIENT)) - { - try (PreparedStatement insertMappingStatement = connection.prepareStatement(INSERT_MESSAGE_MAPPING)) - { - for (SnapshotMessage message : messages) - { - try - { - insertMessage(insertSnapshotStatement, insertRecipientStatement, insertMappingStatement, snapshotId, message); - } - catch (Exception e) - { - _logger.log(Level.SEVERE, "Error inserting snapshot message.", e); - } - } - - insertRecipientStatement.executeBatch(); - insertMappingStatement.executeBatch(); - } - } - } - } - - public CompletableFuture insertMessage(int snapshotId, SnapshotMessage message) - { - return CompletableFuture.supplyAsync(() -> + CompletableFuture future = CompletableFuture.supplyAsync(() -> { try (Connection connection = DBPool.getAccount().getConnection()) { @@ -293,7 +230,21 @@ public class SnapshotRepository { try (PreparedStatement insertMappingStatement = connection.prepareStatement(INSERT_MESSAGE_MAPPING)) { - insertMessage(insertSnapshotStatement, insertRecipientStatement, insertMappingStatement, snapshotId, message); + for (SnapshotMessage message : messages) + { + try + { + insertMessage(insertSnapshotStatement, insertRecipientStatement, insertMappingStatement, snapshotId, message); + } + catch (Exception e) + { + _logger.log(Level.SEVERE, "Error inserting snapshot message.", e); + } + } + + insertRecipientStatement.executeBatch(); + insertMappingStatement.executeBatch(); + return null; } } } @@ -302,9 +253,15 @@ public class SnapshotRepository { throw new RuntimeException(e); } + }); + future.exceptionally(throwable -> + { + _logger.log(Level.SEVERE, "Error whilst inserting messages into snapshot.", throwable); return null; }); + + return future; } private void insertMessage(PreparedStatement insertSnapshotStatement, PreparedStatement insertRecipientStatement, PreparedStatement insertMappingStatement, int snapshotId, SnapshotMessage message) throws SQLException diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/PushSnapshotsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsCommand.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/PushSnapshotsCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsCommand.java index d34a6ebb1..0c11fc2d3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/PushSnapshotsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsCommand.java @@ -1,4 +1,4 @@ -package mineplex.core.chatsnap.command; +package mineplex.core.chatsnap.redis; import java.util.Set; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/PushSnapshotsHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsHandler.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/PushSnapshotsHandler.java rename to Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsHandler.java index a499a7332..5ee86ecb4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/PushSnapshotsHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsHandler.java @@ -1,4 +1,4 @@ -package mineplex.core.chatsnap.command; +package mineplex.core.chatsnap.redis; import java.util.Set; import mineplex.core.chatsnap.SnapshotMessage; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index a8290f74b..d899bae48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -20,8 +20,8 @@ import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.chatsnap.SnapshotManager; import mineplex.core.chatsnap.SnapshotMetadata; -import mineplex.core.chatsnap.command.PushSnapshotsCommand; -import mineplex.core.chatsnap.command.PushSnapshotsHandler; +import mineplex.core.chatsnap.redis.PushSnapshotsCommand; +import mineplex.core.chatsnap.redis.PushSnapshotsHandler; import mineplex.core.command.CommandCenter; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.JsonMessage; From 81bf9bc406839959e4d38bff1d6c3e8de1dbf57a Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sat, 22 Oct 2016 19:21:38 +0100 Subject: [PATCH 04/56] Small method rename --- .../src/mineplex/core/chatsnap/SnapshotManager.java | 2 +- .../core/chatsnap/redis/PushSnapshotsHandler.java | 2 +- .../src/mineplex/core/report/ReportHandlerTask.java | 8 ++++---- .../src/mineplex/core/report/ReportManager.java | 6 +++--- .../src/mineplex/core/report/ReportRedisManager.java | 4 ++-- .../mineplex/core/report/command/ReportCloseCommand.java | 2 +- .../core/report/command/ReportHistoryCommand.java | 4 ++-- .../mineplex/core/report/command/ReportInfoCommand.java | 2 +- .../src/mineplex/core/report/data/ReportRepository.java | 2 +- .../src/mineplex/core/report/ui/ReportHandlePage.java | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java index 389d772bb..bed67e9c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java @@ -38,7 +38,7 @@ public class SnapshotManager _snapshotRepository = snapshotRepository; } - public SnapshotRepository getSnapshotRepository() + public SnapshotRepository getRepository() { return _snapshotRepository; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsHandler.java index 5ee86ecb4..b6668041c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/redis/PushSnapshotsHandler.java @@ -35,7 +35,7 @@ public class PushSnapshotsHandler implements CommandCallback if (messages.size() > 0) { - _reportManager.getReportRepository().getReport(reportId).thenAccept(reportOptional -> + _reportManager.getRepository().getReport(reportId).thenAccept(reportOptional -> { if (reportOptional.isPresent()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportHandlerTask.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportHandlerTask.java index f8d4974ba..bee2d6181 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportHandlerTask.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportHandlerTask.java @@ -38,7 +38,7 @@ public class ReportHandlerTask extends BukkitRunnable private CompletableFuture> getReport() { - return _reportManager.getReportRepository().getReport(_reportId); + return _reportManager.getRepository().getReport(_reportId); } public void start(JavaPlugin plugin) @@ -70,7 +70,7 @@ public class ReportHandlerTask extends BukkitRunnable { if (isActive) { - _reportManager.getReportRepository().getAccountName(report.getSuspectId()) + _reportManager.getRepository().getAccountName(report.getSuspectId()) .thenAccept(suspectName -> { String prefix = F.main(ReportManager.getReportPrefix(reportId), ""); @@ -121,7 +121,7 @@ public class ReportHandlerTask extends BukkitRunnable int handlerId = handlerIdOptional.get(); JsonMessage finalJsonMessage = jsonMessage; - _reportManager.getReportRepository().getAccountUUID(handlerId).thenAccept(handlerUUID -> + _reportManager.getRepository().getAccountUUID(handlerId).thenAccept(handlerUUID -> { if (handlerUUID != null) { @@ -165,7 +165,7 @@ public class ReportHandlerTask extends BukkitRunnable for (ReportMessage reportMessage : reportMessages) { // this is blocking, but that's okay as it will only be called asynchronously - String reporterName = _reportManager.getReportRepository().getAccountName(reportMessage.getReporterId()).join(); + String reporterName = _reportManager.getRepository().getAccountName(reportMessage.getReporterId()).join(); // triple backslashes so this translates to valid JSON output[count++] = String.format("%4$s(%d%4$s) %s%s%s - \\\"%s%s%4$s\\\"", count, C.cGold, reporterName, C.cGray, C.cPurple, reportMessage.getMessage()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index d899bae48..076b362b6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -105,7 +105,7 @@ public class ReportManager * * @return the repository */ - public ReportRepository getReportRepository() + public ReportRepository getRepository() { return _reportRepository; } @@ -157,7 +157,7 @@ public class ReportManager // create snapshot id ahead of time if (category == ReportCategory.CHAT_ABUSE) { - SnapshotMetadata snapshotMetadata = _snapshotManager.getSnapshotRepository().createSnapshot(null).join(); + SnapshotMetadata snapshotMetadata = _snapshotManager.getRepository().createSnapshot(null).join(); report.setSnapshotMetadata(snapshotMetadata); } @@ -454,7 +454,7 @@ public class ReportManager */ public CompletableFuture isActiveReport(long reportId) { - return getReportRepository().getReport(reportId).thenCompose(reportOptional -> + return getRepository().getReport(reportId).thenCompose(reportOptional -> { if (reportOptional.isPresent()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRedisManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRedisManager.java index 4b4e1afa3..757f82501 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRedisManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRedisManager.java @@ -33,13 +33,13 @@ public class ReportRedisManager implements CommandCallback { HandlerNotification reportNotification = (HandlerNotification) command; - _reportManager.getReportRepository().getReport(reportNotification.getReportId()).thenAccept(report -> + _reportManager.getRepository().getReport(reportNotification.getReportId()).thenAccept(report -> { if (report != null) { int handlerId = reportNotification.getHandlerId(); - _reportManager.getReportRepository().getAccountUUID(handlerId).thenAccept(handlerUUID -> + _reportManager.getRepository().getAccountUUID(handlerId).thenAccept(handlerUUID -> { if (handlerUUID != null) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java index cea670742..432fe5856 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java @@ -45,7 +45,7 @@ public class ReportCloseCommand extends CommandBase { Report report = reportOptional.get(); - reportManager.getReportRepository().getAccountName(report.getSuspectId()).thenCompose(BukkitFuture.accept(suspectName -> + reportManager.getRepository().getAccountName(report.getSuspectId()).thenCompose(BukkitFuture.accept(suspectName -> { ReportResultPage reportResultPage = new ReportResultPage(Plugin, report, player, suspectName, reason); reportResultPage.openInventory(); // report is closed when player selects the result diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java index f581a902d..fccd6787b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java @@ -32,13 +32,13 @@ public class ReportHistoryCommand extends CommandBase { String playerName = args[0]; - Plugin.getReportManager().getReportRepository().getAccountId(playerName).thenAccept(accountIdOptional -> + Plugin.getReportManager().getRepository().getAccountId(playerName).thenAccept(accountIdOptional -> { if (accountIdOptional.isPresent()) { int accountId = accountIdOptional.get(); - Plugin.getReportManager().getReportRepository().getAccountStatistics(accountId).thenCompose(BukkitFuture.accept(stats -> + Plugin.getReportManager().getRepository().getAccountStatistics(accountId).thenCompose(BukkitFuture.accept(stats -> { UtilPlayer.message(player, F.main(Plugin.getName(), "Report History for " + F.elem(playerName))); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java index 4f5b92b46..c97979861 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java @@ -43,7 +43,7 @@ public class ReportInfoCommand extends CommandBase long reportId = Long.parseLong(args[0]); ReportManager reportManager = Plugin.getReportManager(); - ReportRepository repository = reportManager.getReportRepository(); + ReportRepository repository = reportManager.getRepository(); repository.getReport(reportId).thenAccept(reportOptional -> { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index e0c2554d3..1336ed555 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -344,7 +344,7 @@ public class ReportRepository int snapshotId = resultSet.getInt("snapshotId"); if (!resultSet.wasNull()) { - SnapshotMetadata snapshotMetadata = _reportManager.getSnapshotManager().getSnapshotRepository() + SnapshotMetadata snapshotMetadata = _reportManager.getSnapshotManager().getRepository() .getSnapshotMetadata(snapshotId).join(); report.setSnapshotMetadata(snapshotMetadata); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java index a10835ae2..9cacb7adf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java @@ -60,7 +60,7 @@ public class ReportHandlePage extends SimpleGui implements ReportCategoryCallbac public void handleReport(ReportCategory category) { ReportManager reportManager = _plugin.getReportManager(); - ReportRepository reportRepository = reportManager.getReportRepository(); + ReportRepository reportRepository = reportManager.getRepository(); reportManager.isHandlingReport(_handler).whenComplete((handlingReport, throwable) -> { From c6ca976653e0104a614f50888ce476cb595b4544 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sat, 22 Oct 2016 20:23:31 +0100 Subject: [PATCH 05/56] PC-1139 Add /chatsnap command --- .../core/chatsnap/SnapshotPlugin.java | 3 +- .../chatsnap/command/ChatSnapCommand.java | 60 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java index 774e9d962..7aaba16a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java @@ -11,6 +11,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.chatsnap.command.ChatSnapCommand; import mineplex.core.message.PrivateMessageEvent; /** @@ -36,7 +37,7 @@ public class SnapshotPlugin extends MiniPlugin @Override public void addCommands() { - + addCommand(new ChatSnapCommand(this)); } @EventHandler(priority = EventPriority.MONITOR) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java new file mode 100644 index 000000000..2ab7ffc70 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java @@ -0,0 +1,60 @@ +package mineplex.core.chatsnap.command; + +import java.util.Set; + +import org.bukkit.entity.Player; + +import mineplex.core.chatsnap.SnapshotManager; +import mineplex.core.chatsnap.SnapshotMessage; +import mineplex.core.chatsnap.SnapshotPlugin; +import mineplex.core.chatsnap.SnapshotRepository; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +/** + * A command which when executed will create a chat log which will be viewable online. + */ +public class ChatSnapCommand extends CommandBase +{ + public ChatSnapCommand(SnapshotPlugin plugin) + { + super(plugin, Rank.TITAN, "chatsnap"); + } + + @Override + public void Execute(Player player, String[] args) + { + if (args == null || args.length == 0) + { + SnapshotManager manager = Plugin.getSnapshotManager(); + SnapshotRepository repository = manager.getRepository(); + + int accountId = _commandCenter.GetClientManager().getAccountId(player); + Set messages = manager.getMessagesInvolving(accountId); + + repository.createSnapshot(accountId).thenAccept(snapshotMetadata -> + { + String token = snapshotMetadata.getToken().orElseThrow(() -> + new IllegalStateException("Snapshot doesn't have a token.")); + + repository.insertMessages(snapshotMetadata.getId(), messages).join(); + + UtilPlayer.message(player, F.main(Plugin.getName(), "Snapshot successfully created.")); + + new JsonMessage(F.main(Plugin.getName(), "Your snapshot token is: ")) + .extra(F.elem(token)) + .click(ClickEvent.OPEN_URL, SnapshotRepository.getURL(token)) + .sendToPlayer(player); + }); + } + else + { + UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + F.elem("/" + _aliasUsed))); + } + } +} From ecd9dfef1a9b5c25a5eef2cfc1d3274725fa3ac9 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sat, 22 Oct 2016 20:49:14 +0100 Subject: [PATCH 06/56] PC-1139 Update chatsnap site to support displaying of snapshots with no associated report --- Plugins/Mineplex.ReportSite/view.php | 106 ++++++++++++++------------- 1 file changed, 57 insertions(+), 49 deletions(-) diff --git a/Plugins/Mineplex.ReportSite/view.php b/Plugins/Mineplex.ReportSite/view.php index c039365a8..2172577d5 100644 --- a/Plugins/Mineplex.ReportSite/view.php +++ b/Plugins/Mineplex.ReportSite/view.php @@ -1,5 +1,4 @@ getPlayers(); $involvedUsers[$report->getSuspect()->getId()] = $report->getSuspect(); foreach ($report->getReporters() as $reporterReason) { @@ -384,6 +381,7 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id $validToken = isset($_GET['token']); $errorMsg = ""; + $title = 'Report & Snapshot System'; $token = null; $expanded = null; $report = null; @@ -401,15 +399,16 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id $snapshot = getSnapshot($snapshotId); $messages = $snapshot->getMessages(); $reportId = getSnapshotReportId($snapshotId); + $report = null; if ($reportId) { $report = getReport($reportId); + $title = "Report #$reportId"; } else { - $validToken = false; - $errorMsg = 'Associated report not found.'; // TODO: Allow snapshots without reports in future + $title = "Snapshot #$snapshotId"; } } else @@ -428,13 +427,7 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id - <?php if ($validToken): ?> - Report #<?= $report->getId() ?> - <?php else: ?> - Report System - <?php endif; ?> - - · Mineplex + <?= $title ?> · Mineplex @@ -471,7 +464,7 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id

- Report #getId() ?> +


@@ -481,21 +474,23 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
getReporters() as $reporterReason) + if ($report != null) { - $reporterUsernames[count($reporterUsernames)] = $reporterReason->getUser()->getUsername(); + $involvedUsers = getInvolvedUsers($report); + } + else + { + $involvedUsers = array(); } - $involvedUsers = getInvolvedUsers($snapshot, $report); - - $reportCreationTime = $report->getTimeCreated(); - $age = approximateHumanInterval($reportCreationTime->diff(new DateTime('now', $reportCreationTime->getTimezone()))); + foreach ($snapshot->getPlayers() as $player) + { + $involvedUsers[$player->getId()] = $player; + } if($displayAmount == 0): ?> No chat log available for this report. @@ -517,7 +512,7 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id - getSender()->getUsername() ?> + getSender()->getUsername() ?>  -> getRecipients()[0]->getUsername() ?> @@ -542,36 +537,49 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id

   Information


-
-
- - -
+ + getReporters() as $reporterReason) + { + $reporterUsernames[count($reporterUsernames)] = $reporterReason->getUser()->getUsername(); + } - - getCategory()] ?> -
+ $reportCreationTime = $report->getTimeCreated(); + $age = approximateHumanInterval($reportCreationTime->diff(new DateTime('now', $reportCreationTime->getTimezone()))); + ?> +
+
+ + +
- - Reported by -
+ + getCategory()] ?> +
- - Suspect is getSuspect()->getUsername() ?> -
+ + Reported by +
- - - getHandler() != null): ?> - Staff Member assigned is getHandler()->getUsername() ?> - - No Staff Member assigned - - -
+ + Suspect is getSuspect()->getUsername() ?> +
+ + + + getHandler() != null): ?> + Staff Member assigned is getHandler()->getUsername() ?> + + No Staff Member assigned + + +
+
-
-
+
+

   Users


From ff8f77f8d163d729a464ff76ff3f1d04fc7482ec Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sat, 22 Oct 2016 23:08:59 +0100 Subject: [PATCH 07/56] Rename these variables to make better sense --- .../src/mineplex/core/chatsnap/SnapshotManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java index bed67e9c0..fdd39dfb4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java @@ -74,21 +74,21 @@ public class SnapshotManager * Does not include PMs unless sender or receiver is in the exclusions collection. * * @param accountId the account to search for messages involved in - * @param pmIdWhitelist a list of account ids of which to include PMs of + * @param pmWhitelistIds a list of account ids of which to include PMs of * @return the messages that the account is involved in */ - public Set getMessagesInvolving(int accountId, Collection pmIdWhitelist) + public Set getMessagesInvolving(int accountId, Collection pmWhitelistIds) { return getMessagesInvolving(accountId).stream() - .filter(message -> includeMessage(message, pmIdWhitelist)) + .filter(message -> includeMessage(message, pmWhitelistIds)) .collect(Collectors.toCollection(TreeSet::new)); } - private boolean includeMessage(SnapshotMessage message, Collection pmExclusions) + private boolean includeMessage(SnapshotMessage message, Collection pmWhitelistIds) { return message.getType() != MessageType.PM || - pmExclusions.contains(message.getSenderId()) || - !Collections.disjoint(message.getRecipientIds(), pmExclusions); + pmWhitelistIds.contains(message.getSenderId()) || + !Collections.disjoint(message.getRecipientIds(), pmWhitelistIds); } /** From 52d001c26eff536811bbd87e9daab9767e1e87d1 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Wed, 26 Oct 2016 10:28:01 +0100 Subject: [PATCH 08/56] PC-1153 Add /reportmetrics command --- .../mineplex/core/report/ReportManager.java | 32 +++- .../mineplex/core/report/ReportPlugin.java | 2 + .../core/report/ReportResultType.java | 14 +- .../report/command/ReportMetricsCommand.java | 108 ++++++++++++ .../data/metrics/ReportGlobalMetrics.java | 37 +++++ .../report/data/metrics/ReportMetrics.java | 48 ++++++ .../data/metrics/ReportMetricsRepository.java | 156 ++++++++++++++++++ 7 files changed, 385 insertions(+), 12 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportGlobalMetrics.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetrics.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetricsRepository.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index 076b362b6..428645d21 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -34,6 +34,7 @@ import mineplex.core.portal.Portal; import mineplex.core.punish.Category; import mineplex.core.punish.Punish; import mineplex.core.punish.PunishClient; +import mineplex.core.report.data.metrics.ReportMetricsRepository; import mineplex.core.report.redis.HandlerNotification; import mineplex.core.report.data.Report; import mineplex.core.report.data.ReportMessage; @@ -64,7 +65,8 @@ public class ReportManager private final int _serverWeight; private final ReportRepository _reportRepository; - private final ReportUserRepository _reportUserRepository; + private final ReportUserRepository _userRepository; + private final ReportMetricsRepository _metricsRepository; public ReportManager(JavaPlugin plugin, SnapshotManager snapshotManager, CoreClientManager clientManager, IncognitoManager incognitoManager, Punish punish, Region region, String serverName, int serverWeight) @@ -79,8 +81,8 @@ public class ReportManager _serverWeight = serverWeight; _reportRepository = new ReportRepository(this, _plugin.getLogger()); - - _reportUserRepository = new ReportUserRepository(plugin); + _userRepository = new ReportUserRepository(plugin); + _metricsRepository = new ReportMetricsRepository(_plugin.getLogger()); ServerCommandManager commandManager = ServerCommandManager.getInstance(); ReportRedisManager notificationCallback = new ReportRedisManager(this, _serverName); @@ -101,7 +103,7 @@ public class ReportManager } /** - * Gets the {@link ReportRepository} we are using. + * Gets the {@link ReportRepository} this instance is using. * * @return the repository */ @@ -110,6 +112,26 @@ public class ReportManager return _reportRepository; } + /** + * Gets the {@link ReportUserRepository} this instance is using. + * + * @return the repository + */ + public ReportUserRepository getUserRepository() + { + return _userRepository; + } + + /** + * Gets the {@link ReportMetricsRepository} this instance is using. + * + * @return the repository + */ + public ReportMetricsRepository getMetricsRepository() + { + return _metricsRepository; + } + /** * Creates a new report or adds to an existing one. * @@ -595,7 +617,7 @@ public class ReportManager for (Map.Entry entry : report.getMessages().entrySet()) { int accountId = entry.getKey(); - ReportUser user = _reportUserRepository.getUser(accountId).join(); + ReportUser user = _userRepository.getUser(accountId).join(); int categoryReputation = user.getReputation(report.getCategory()); ReportMessage message = entry.getValue(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java index 15a364d82..47c8a3c81 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java @@ -11,6 +11,7 @@ import mineplex.core.report.command.ReportCommand; import mineplex.core.report.command.ReportHandleCommand; import mineplex.core.report.command.ReportInfoCommand; import mineplex.core.report.command.ReportHistoryCommand; +import mineplex.core.report.command.ReportMetricsCommand; /** * Main class for this module, handles initialization and disabling of the module. @@ -38,6 +39,7 @@ public class ReportPlugin extends MiniPlugin addCommand(new ReportCloseCommand(this)); addCommand(new ReportHistoryCommand(this)); addCommand(new ReportInfoCommand(this)); + addCommand(new ReportMetricsCommand(this)); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportResultType.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportResultType.java index af2cb3e8b..e54b5e780 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportResultType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportResultType.java @@ -7,23 +7,23 @@ import org.apache.commons.lang3.text.WordUtils; */ public enum ReportResultType { - ACCEPTED(0, false), - DENIED(1, false), - ABUSIVE(2, true), - EXPIRED(3, true); + ACCEPTED((short) 0, false), + DENIED((short) 1, false), + ABUSIVE((short) 2, true), + EXPIRED((short) 3, true); - private final int _id; + private final short _id; private final boolean _globalStat; private final String _name; - ReportResultType(int id, boolean globalStat) + ReportResultType(short id, boolean globalStat) { _id = id; _globalStat = globalStat; _name = WordUtils.capitalizeFully(name().replace('_', ' ')); } - public int getId() + public short getId() { return _id; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java new file mode 100644 index 000000000..239df4fce --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java @@ -0,0 +1,108 @@ +package mineplex.core.report.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.BukkitFuture; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.report.ReportPlugin; +import mineplex.core.report.data.metrics.ReportMetrics; + +/** + * Displays various report-related metrics on a player. + */ +public class ReportMetricsCommand extends CommandBase +{ + public ReportMetricsCommand(ReportPlugin plugin) + { + super(plugin, Rank.MODERATOR, "reportmetrics"); + } + + @Override + public void Execute(Player player, String[] args) + { + if (args.length <= 2) + { + int days = 30; + + if (args.length >= 1) // has target argument + { + String targetName = args[0]; + + if (args.length > 1) + { + String daysString = args[1]; + + try + { + days = Integer.parseInt(daysString); + } + catch (NumberFormatException e) + { + UtilPlayer.message(player, F.main(Plugin.getName(), F.elem(daysString) + C.cRed + " is not a valid number.")); + } + } + + int finalDays = days; + Plugin.getReportManager().getRepository().getAccountId(targetName).thenAccept(targetIdOptional -> + { + if (targetIdOptional.isPresent()) + { + int targetId = targetIdOptional.get(); + displayUserMetrics(player, targetName, targetId, finalDays); + } + else + { + UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Player not found.")); + } + }); + } + else // display global metrics + { + // TODO: do we parse days for global metrics? + UtilPlayer.message(player, F.main("Report Metrics", F.elem("Global Metrics") + " (" + F.elem(days + " days") + ")")); + displayGlobalMetrics(player, days); + } + } + else + { + UtilPlayer.message(player, + F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + + F.elem("/" + _aliasUsed + " [days]"))); + } + } + + public void displayGlobalMetrics(Player player, int days) + { + Plugin.getReportManager().getMetricsRepository().getGlobalMetrics(days).thenCompose( + BukkitFuture.accept(globalMetrics -> + { + UtilPlayer.message(player, F.main("Report Metrics", "Submitted: " + F.elem(globalMetrics.getSubmitted()))); + UtilPlayer.message(player, F.main("Report Metrics", "Expired: " + F.elem(globalMetrics.getExpired()))); + displayMetrics(player, globalMetrics); + })); + } + + public void displayUserMetrics(Player player, String targetName, int targetId, int days) + { + Plugin.getReportManager().getMetricsRepository().getUserMetrics(targetId, days).thenCompose( + BukkitFuture.accept(userMetrics -> + { + UtilPlayer.message(player, + F.main("Report Metrics", + F.elem(targetName) + " (" + F.elem(days + " days") + ")")); + + displayMetrics(player, userMetrics); + })); + } + + public void displayMetrics(Player player, ReportMetrics reportMetrics) + { + UtilPlayer.message(player, F.main("Report Metrics", "Accepted: " + F.elem(reportMetrics.getAccepted()))); + UtilPlayer.message(player, F.main("Report Metrics", "Denied: " + F.elem(reportMetrics.getDenied()))); + UtilPlayer.message(player, F.main("Report Metrics", "Flagged Abusive: " + F.elem(reportMetrics.getFlagged()))); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportGlobalMetrics.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportGlobalMetrics.java new file mode 100644 index 000000000..c81056a83 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportGlobalMetrics.java @@ -0,0 +1,37 @@ +package mineplex.core.report.data.metrics; + +/** + * Extends the standard report metrics class to hold global-scope metrics. + */ +public class ReportGlobalMetrics extends ReportMetrics +{ + private final long _submitted; + private final long _expired; + + public ReportGlobalMetrics(long submitted, long expired, long accepted, long denied, long flagged) + { + super(accepted, denied, flagged); + _submitted = submitted; + _expired = expired; + } + + /** + * Gets the amount of reports submitted. + * + * @return the amount + */ + public long getSubmitted() + { + return _submitted; + } + + /** + * Gets the amount of reports expired. + * + * @return the amount + */ + public long getExpired() + { + return _expired; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetrics.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetrics.java new file mode 100644 index 000000000..16314b2a1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetrics.java @@ -0,0 +1,48 @@ +package mineplex.core.report.data.metrics; + +/** + * Holds report-related metrics which can be applied to a user or global scope. + */ +public class ReportMetrics +{ + private final long _accepted; + private final long _denied; + private final long _flagged; + + public ReportMetrics(long accepted, long denied, long flagged) + { + _accepted = accepted; + _denied = denied; + _flagged = flagged; + } + + /** + * Gets the amount of reports accepted. + * + * @return the amount + */ + public long getAccepted() + { + return _accepted; + } + + /** + * Gets the amount of reports denied. + * + * @return the amount + */ + public long getDenied() + { + return _denied; + } + + /** + * Gets the amount of reports flagged (marked as spam). + * + * @return the amount + */ + public long getFlagged() + { + return _flagged; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetricsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetricsRepository.java new file mode 100644 index 000000000..884f1a378 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/metrics/ReportMetricsRepository.java @@ -0,0 +1,156 @@ +package mineplex.core.report.data.metrics; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.concurrent.CompletableFuture; +import java.util.logging.Level; +import java.util.logging.Logger; + +import mineplex.core.report.ReportResultType; +import mineplex.serverdata.database.DBPool; + +/** + * Handles all fetching of report-related metrics. + */ +public class ReportMetricsRepository +{ + private static final String GET_GLOBAL_SUBMITTED = "SELECT COUNT(DISTINCT reportReasons.reportId) AS submitted FROM reportReasons\n" + + " WHERE reportReasons.time BETWEEN NOW() - INTERVAL ? DAY AND NOW();"; + + private static final String GET_GLOBAL_RESULT = "SELECT COUNT(reportResults.reportId) AS amount FROM reportResults\n" + + " WHERE reportResults.resultId = ?\n" + + " AND reportResults.closedTime BETWEEN NOW() - INTERVAL ? DAY AND NOW();"; + + private static final String GET_USER_RESULT = "SELECT COUNT(reportResults.reportId) AS amount FROM reportResults\n" + + " LEFT JOIN reportHandlers ON reportResults.reportId = reportHandlers.reportId AND reportHandlers.aborted IS FALSE\n" + + " WHERE reportHandlers.handlerId = ?\n" + + " AND reportResults.resultId = ?\n" + + " AND reportResults.closedTime BETWEEN NOW() - INTERVAL ? DAY AND NOW();"; + + private final Logger _logger; + + public ReportMetricsRepository(Logger logger) + { + _logger = logger; + } + + public CompletableFuture getGlobalMetrics(int days) + { + CompletableFuture future = CompletableFuture.supplyAsync(() -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + long submitted = getGlobalSubmitted(connection, days); + + try (PreparedStatement preparedStatement = connection.prepareStatement(GET_GLOBAL_RESULT)) + { + long expired = getGlobalResult(preparedStatement, ReportResultType.EXPIRED, days); + long accepted = getGlobalResult(preparedStatement, ReportResultType.ACCEPTED, days); + long denied = getGlobalResult(preparedStatement, ReportResultType.DENIED, days); + long flagged = getGlobalResult(preparedStatement, ReportResultType.ABUSIVE, days); + + return new ReportGlobalMetrics(submitted, expired, accepted, denied, flagged); + } + } + catch (SQLException e) + { + throw new RuntimeException(e); + } + }); + + future.exceptionally(throwable -> + { + _logger.log(Level.SEVERE, "Error fetching global metrics.", throwable); + return null; + }); + + return future; + } + + private long getGlobalSubmitted(Connection connection, int days) throws SQLException + { + PreparedStatement preparedStatement = connection.prepareStatement(GET_GLOBAL_SUBMITTED); + preparedStatement.setInt(1, days); + + try (ResultSet resultSet = preparedStatement.executeQuery()) + { + if (resultSet.next()) + { + return resultSet.getLong("submitted"); + } + else + { + return 0; + } + } + } + + private long getGlobalResult(PreparedStatement preparedStatement, ReportResultType resultType, int days) throws SQLException + { + preparedStatement.setShort(1, resultType.getId()); + preparedStatement.setInt(2, days); + + try (ResultSet resultSet = preparedStatement.executeQuery()) + { + if (resultSet.next()) + { + return resultSet.getLong("amount"); + } + else + { + return 0; + } + } + } + + public CompletableFuture getUserMetrics(int accountId, int days) + { + CompletableFuture future = CompletableFuture.supplyAsync(() -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + try (PreparedStatement preparedStatement = connection.prepareStatement(GET_USER_RESULT)) + { + long accepted = getUserResult(preparedStatement, accountId, ReportResultType.ACCEPTED, days); + long denied = getUserResult(preparedStatement, accountId, ReportResultType.DENIED, days); + long flagged = getUserResult(preparedStatement, accountId, ReportResultType.ABUSIVE, days); + + return new ReportMetrics(accepted, denied, flagged); + } + } + catch (SQLException e) + { + throw new RuntimeException(e); + } + }); + + future.exceptionally(throwable -> + { + _logger.log(Level.SEVERE, "Error fetching user metrics.", throwable); + return null; + }); + + return future; + } + + private long getUserResult(PreparedStatement preparedStatement, int accountId, ReportResultType resultType, int days) throws SQLException + { + preparedStatement.setInt(1, accountId); + preparedStatement.setShort(2, resultType.getId()); + preparedStatement.setInt(3, days); + + try (ResultSet resultSet = preparedStatement.executeQuery()) + { + if (resultSet.next()) + { + return resultSet.getLong("amount"); + } + else + { + return 0; + } + } + } +} From a97ad8dd769fd345bc6c797a1cbdd9cc7bf957f3 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Wed, 26 Oct 2016 10:42:10 +0100 Subject: [PATCH 09/56] PC-1153 Don't allow days argument to exceed 30 days --- .../report/command/ReportMetricsCommand.java | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java index 239df4fce..1323ecb1b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java @@ -16,6 +16,9 @@ import mineplex.core.report.data.metrics.ReportMetrics; */ public class ReportMetricsCommand extends CommandBase { + private static final String PREFIX = "Report Metrics"; + private static final int MAX_DAYS = 30; + public ReportMetricsCommand(ReportPlugin plugin) { super(plugin, Rank.MODERATOR, "reportmetrics"); @@ -34,15 +37,15 @@ public class ReportMetricsCommand extends CommandBase if (args.length > 1) { - String daysString = args[1]; + Integer nullableDays = parseDaysArgument(player, args[1]); - try + if (nullableDays != null) { - days = Integer.parseInt(daysString); + days = nullableDays; } - catch (NumberFormatException e) + else { - UtilPlayer.message(player, F.main(Plugin.getName(), F.elem(daysString) + C.cRed + " is not a valid number.")); + return; } } @@ -75,6 +78,31 @@ public class ReportMetricsCommand extends CommandBase } } + public Integer parseDaysArgument(Player sender, String daysString) + { + Integer days; + + try + { + days = Integer.parseInt(daysString); + } + catch (NumberFormatException e) + { + UtilPlayer.message(sender, F.main(PREFIX, F.elem(daysString) + C.cRed + " is not a valid integer.")); + return null; + } + + if (days > MAX_DAYS) + { + UtilPlayer.message(sender, F.main(PREFIX, + C.cRed + "Cannot view metrics for longer than " + F.elem(MAX_DAYS + " days") + C.cRed + ".")); + + return null; + } + + return days; + } + public void displayGlobalMetrics(Player player, int days) { Plugin.getReportManager().getMetricsRepository().getGlobalMetrics(days).thenCompose( From 79b5439aa46f45a5b91ec310852e0327f0781228 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Wed, 26 Oct 2016 10:50:49 +0100 Subject: [PATCH 10/56] Small refactoring --- .../src/mineplex/core/report/ReportPlugin.java | 14 +++++++------- .../core/report/command/ReportCloseCommand.java | 2 +- .../core/report/command/ReportCommand.java | 2 +- .../core/report/command/ReportHistoryCommand.java | 4 ++-- .../core/report/command/ReportInfoCommand.java | 2 +- .../core/report/command/ReportMetricsCommand.java | 6 +++--- .../mineplex/core/report/ui/ReportCreatePage.java | 4 ++-- .../mineplex/core/report/ui/ReportHandlePage.java | 4 ++-- .../mineplex/core/report/ui/ReportResultPage.java | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java index 47c8a3c81..a37718c7e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java @@ -18,17 +18,17 @@ import mineplex.core.report.command.ReportMetricsCommand; */ public class ReportPlugin extends MiniPlugin { - private final ReportManager _reportManager; + private final ReportManager _manager; - public ReportPlugin(JavaPlugin plugin, ReportManager reportManager) + public ReportPlugin(JavaPlugin plugin, ReportManager manager) { super("Report", plugin); - _reportManager = reportManager; + _manager = manager; } - public ReportManager getReportManager() + public ReportManager getManager() { - return _reportManager; + return _manager; } @Override @@ -45,12 +45,12 @@ public class ReportPlugin extends MiniPlugin @EventHandler public void onPlayerJoin(PlayerJoinEvent e) { - _reportManager.onPlayerJoin(e.getPlayer()); + _manager.onPlayerJoin(e.getPlayer()); } @EventHandler public void onPlayerQuit(PlayerQuitEvent e) { - _reportManager.onPlayerQuit(e.getPlayer()); + _manager.onPlayerQuit(e.getPlayer()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java index 432fe5856..35c6fef1e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java @@ -35,7 +35,7 @@ public class ReportCloseCommand extends CommandBase else { String reason = F.combine(args, 0, null, false); - ReportManager reportManager = Plugin.getReportManager(); + ReportManager reportManager = Plugin.getManager(); reportManager.getReportHandling(player).whenComplete((reportOptional, throwable) -> { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java index ac1e5ec34..7abfd2499 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java @@ -35,7 +35,7 @@ public class ReportCommand extends CommandBase } else { - ReportManager reportManager = Plugin.getReportManager(); + ReportManager reportManager = Plugin.getManager(); boolean canReport = reportManager.canReport(reporter); if (canReport) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java index fccd6787b..98a7b6abe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java @@ -32,13 +32,13 @@ public class ReportHistoryCommand extends CommandBase { String playerName = args[0]; - Plugin.getReportManager().getRepository().getAccountId(playerName).thenAccept(accountIdOptional -> + Plugin.getManager().getRepository().getAccountId(playerName).thenAccept(accountIdOptional -> { if (accountIdOptional.isPresent()) { int accountId = accountIdOptional.get(); - Plugin.getReportManager().getRepository().getAccountStatistics(accountId).thenCompose(BukkitFuture.accept(stats -> + Plugin.getManager().getRepository().getAccountStatistics(accountId).thenCompose(BukkitFuture.accept(stats -> { UtilPlayer.message(player, F.main(Plugin.getName(), "Report History for " + F.elem(playerName))); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java index c97979861..894d03847 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java @@ -42,7 +42,7 @@ public class ReportInfoCommand extends CommandBase { long reportId = Long.parseLong(args[0]); - ReportManager reportManager = Plugin.getReportManager(); + ReportManager reportManager = Plugin.getManager(); ReportRepository repository = reportManager.getRepository(); repository.getReport(reportId).thenAccept(reportOptional -> diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java index 1323ecb1b..6c247d826 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java @@ -50,7 +50,7 @@ public class ReportMetricsCommand extends CommandBase } int finalDays = days; - Plugin.getReportManager().getRepository().getAccountId(targetName).thenAccept(targetIdOptional -> + Plugin.getManager().getRepository().getAccountId(targetName).thenAccept(targetIdOptional -> { if (targetIdOptional.isPresent()) { @@ -105,7 +105,7 @@ public class ReportMetricsCommand extends CommandBase public void displayGlobalMetrics(Player player, int days) { - Plugin.getReportManager().getMetricsRepository().getGlobalMetrics(days).thenCompose( + Plugin.getManager().getMetricsRepository().getGlobalMetrics(days).thenCompose( BukkitFuture.accept(globalMetrics -> { UtilPlayer.message(player, F.main("Report Metrics", "Submitted: " + F.elem(globalMetrics.getSubmitted()))); @@ -116,7 +116,7 @@ public class ReportMetricsCommand extends CommandBase public void displayUserMetrics(Player player, String targetName, int targetId, int days) { - Plugin.getReportManager().getMetricsRepository().getUserMetrics(targetId, days).thenCompose( + Plugin.getManager().getMetricsRepository().getUserMetrics(targetId, days).thenCompose( BukkitFuture.accept(userMetrics -> { UtilPlayer.message(player, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java index 4ee980e93..4dd452f64 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java @@ -69,7 +69,7 @@ public class ReportCreatePage extends SimpleGui implements ReportCategoryCallba private boolean hasSentMessage(int accountId) { - SnapshotManager snapshotManager = _plugin.getReportManager().getSnapshotManager(); + SnapshotManager snapshotManager = _plugin.getManager().getSnapshotManager(); int suspectId = _suspect.getAccountId(); List suspectMessages = snapshotManager.getMessagesFrom(accountId).stream() .filter(message -> message.getSenderId() == suspectId || message.getRecipientIds().contains(suspectId)) @@ -80,7 +80,7 @@ public class ReportCreatePage extends SimpleGui implements ReportCategoryCallba private void createReport(ReportCategory category) { - _plugin.getReportManager().createReport(_reporterId, _suspect.getAccountId(), category, _reason) + _plugin.getManager().createReport(_reporterId, _suspect.getAccountId(), category, _reason) .thenAccept(report -> { boolean error = true; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java index 9cacb7adf..7be19ad04 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java @@ -38,7 +38,7 @@ public class ReportHandlePage extends SimpleGui implements ReportCategoryCallbac _plugin = plugin; _handler = handler; _handlerId = handlerId; - _region = plugin.getReportManager().getRegion(); + _region = plugin.getManager().getRegion(); buildPage(); } @@ -59,7 +59,7 @@ public class ReportHandlePage extends SimpleGui implements ReportCategoryCallbac public void handleReport(ReportCategory category) { - ReportManager reportManager = _plugin.getReportManager(); + ReportManager reportManager = _plugin.getManager(); ReportRepository reportRepository = reportManager.getRepository(); reportManager.isHandlingReport(_handler).whenComplete((handlingReport, throwable) -> diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java index 113e4b728..92b1f6abe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportResultPage.java @@ -31,7 +31,7 @@ public class ReportResultPage extends SimpleGui { super(plugin.getPlugin(), reportCloser, "Close Report", 9 * 4); _plugin = plugin; - _reportManager = plugin.getReportManager(); + _reportManager = plugin.getManager(); _report = report; _suspectName = suspectName; _reason = reason; From 3bd575b7182901bacc5520e44b87936234f6fd06 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Wed, 26 Oct 2016 13:29:11 +0100 Subject: [PATCH 11/56] PC-1153 Improve /reportmetrics usage --- .../report/command/ReportMetricsCommand.java | 56 ++++++++----------- .../core/treasure/gui/BuyChestButton.java | 2 +- 2 files changed, 23 insertions(+), 35 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java index 6c247d826..6594f019a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java @@ -27,54 +27,42 @@ public class ReportMetricsCommand extends CommandBase @Override public void Execute(Player player, String[] args) { - if (args.length <= 2) + if (args.length > 0 && args.length <= 2) { - int days = 30; + Integer days = parseDaysArgument(player, args[0]); - if (args.length >= 1) // has target argument + if (days != null) { - String targetName = args[0]; - - if (args.length > 1) + if (args.length >= 2) // has target argument { - Integer nullableDays = parseDaysArgument(player, args[1]); + String targetName = args[1]; - if (nullableDays != null) + Plugin.getManager().getRepository().getAccountId(targetName).thenAccept(targetIdOptional -> { - days = nullableDays; - } - else - { - return; - } + if (targetIdOptional.isPresent()) + { + int targetId = targetIdOptional.get(); + displayUserMetrics(player, targetName, targetId, days); + } + else + { + UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Player not found.")); + } + }); } - - int finalDays = days; - Plugin.getManager().getRepository().getAccountId(targetName).thenAccept(targetIdOptional -> + else // display global metrics { - if (targetIdOptional.isPresent()) - { - int targetId = targetIdOptional.get(); - displayUserMetrics(player, targetName, targetId, finalDays); - } - else - { - UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Player not found.")); - } - }); - } - else // display global metrics - { - // TODO: do we parse days for global metrics? - UtilPlayer.message(player, F.main("Report Metrics", F.elem("Global Metrics") + " (" + F.elem(days + " days") + ")")); - displayGlobalMetrics(player, days); + // TODO: do we parse days for global metrics? + UtilPlayer.message(player, F.main("Report Metrics", F.elem("Global Metrics") + " (" + F.elem(days + " days") + ")")); + displayGlobalMetrics(player, days); + } } } else { UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Invalid Usage: " - + F.elem("/" + _aliasUsed + " [days]"))); + + F.elem("/" + _aliasUsed + " [player]"))); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java index 35e92ca7e..f661dec3f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -49,7 +49,7 @@ public class BuyChestButton implements IButton if (_chestType == TreasureType.TRICK_OR_TREAT) { - if (Calendar.MONTH != Calendar.OCTOBER || Calendar.DAY_OF_WEEK < CALENDAR.FRIDAY) + if (Calendar.MONTH != Calendar.OCTOBER || Calendar.DAY_OF_WEEK < Calendar.FRIDAY) { player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); return; From 3bcfa6adc5d8678c0fb77644800543984325d601 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Thu, 27 Oct 2016 15:34:07 +0100 Subject: [PATCH 12/56] PC-1150 Only show information section of site when report is being displayed --- Plugins/Mineplex.ReportSite/view.php | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Plugins/Mineplex.ReportSite/view.php b/Plugins/Mineplex.ReportSite/view.php index 2172577d5..9283ef46b 100644 --- a/Plugins/Mineplex.ReportSite/view.php +++ b/Plugins/Mineplex.ReportSite/view.php @@ -535,22 +535,22 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
-

   Information

-
- getReporters() as $reporterReason) - { - $reporterUsernames[count($reporterUsernames)] = $reporterReason->getUser()->getUsername(); - } - - $reportCreationTime = $report->getTimeCreated(); - $age = approximateHumanInterval($reportCreationTime->diff(new DateTime('now', $reportCreationTime->getTimezone()))); - ?> +

   Information

+
+ getReporters() as $reporterReason) + { + $reporterUsernames[count($reporterUsernames)] = $reporterReason->getUser()->getUsername(); + } + + $reportCreationTime = $report->getTimeCreated(); + $age = approximateHumanInterval($reportCreationTime->diff(new DateTime('now', $reportCreationTime->getTimezone()))); + ?>
@@ -576,10 +576,10 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
-
+
-
- +
+

   Users


From 100dc53ead47a62080031dfdc1a52c1185fcb0c3 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Thu, 27 Oct 2016 16:09:11 +0100 Subject: [PATCH 13/56] PC-1150 Close div's correctly --- Plugins/Mineplex.ReportSite/view.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.ReportSite/view.php b/Plugins/Mineplex.ReportSite/view.php index 9283ef46b..289895028 100644 --- a/Plugins/Mineplex.ReportSite/view.php +++ b/Plugins/Mineplex.ReportSite/view.php @@ -576,11 +576,10 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
- +
- -
- +
+

   Users


From 30f56e3b125be2b3583f245ca4c9ac1e455758a3 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Thu, 27 Oct 2016 23:40:09 +0100 Subject: [PATCH 14/56] PC-1016 Add cleanup task sql script --- .../sql/6-cleanup-task.sql | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql diff --git a/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql new file mode 100644 index 000000000..faa980399 --- /dev/null +++ b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql @@ -0,0 +1,52 @@ +-- CASCADE HANDLERS TABLE +ALTER TABLE Account.reportHandlers DROP FOREIGN KEY reportHandlers_reports_id_fk; +ALTER TABLE Account.reportHandlers + ADD CONSTRAINT reportHandlers_reports_id_fk +FOREIGN KEY (reportId) REFERENCES reports (id) ON DELETE CASCADE; + +-- CASCADE REASONS/REPORTERS TABLE +ALTER TABLE Account.reportReasons DROP FOREIGN KEY reportReasons_reports_id_fk; +ALTER TABLE Account.reportReasons + ADD CONSTRAINT reportReasons_reports_id_fk +FOREIGN KEY (reportId) REFERENCES reports (id) ON DELETE CASCADE; + +-- CASCADE RESULTS TABLE +ALTER TABLE Account.reportResults DROP FOREIGN KEY reportResults_reports_id_fk; +ALTER TABLE Account.reportResults + ADD CONSTRAINT reportResults_reports_id_fk +FOREIGN KEY (reportId) REFERENCES reports (id) ON DELETE CASCADE; + +-- CASCADE SNAPSHOT MESSAGE MAP +ALTER TABLE Account.snapshotMessageMap DROP FOREIGN KEY snapshotMessageMap_snapshots_id_fk; +ALTER TABLE Account.snapshotMessageMap + ADD CONSTRAINT snapshotMessageMap_snapshots_id_fk +FOREIGN KEY (snapshotId) REFERENCES snapshots (id) ON DELETE CASCADE; +ALTER TABLE Account.snapshotMessageMap DROP FOREIGN KEY snapshotMessageMap_snapshotMessages_id_fk; +ALTER TABLE Account.snapshotMessageMap + ADD CONSTRAINT snapshotMessageMap_snapshotMessages_id_fk +FOREIGN KEY (messageId) REFERENCES snapshotMessages (id) ON DELETE CASCADE; + +-- CASCADE SNAPSHOT RECIPIENTS TABLE +ALTER TABLE Account.snapshotRecipients DROP FOREIGN KEY snapshotRecipients_snapshotMessages_id_fk; +ALTER TABLE Account.snapshotRecipients + ADD CONSTRAINT snapshotRecipients_snapshotMessages_id_fk +FOREIGN KEY (messageId) REFERENCES snapshotMessages (id) ON DELETE CASCADE; + +-- CREATE CLEANUP TASK +DELIMITER // + +CREATE EVENT `report_cleanup` + ON SCHEDULE EVERY 1 MONTH + ON COMPLETION PRESERVE +DO BEGIN + -- DELETE REPORTS (AND ASSOCIATED SNAPSHOT IF ANY) CLOSED > 30 DAYS AGO + DELETE reports, snapshots FROM reports, snapshots + LEFT JOIN reportResults ON reports.id = reportResults.reportId + LEFT JOIN snapshots ON reports.snapshotId = snapshots.id + WHERE reportResults.closedTime NOT BETWEEN NOW() - INTERVAL 30 DAY AND NOW(); + + -- DELETE ORPHANED SNAPSHOT MESSAGES + DELETE snapshotMessages FROM snapshotMessages + LEFT JOIN snapshotMessageMap ON snapshotMessages.id = snapshotMessageMap.messageId + WHERE snapshotMessageMap.snapshotId IS NULL; +END// \ No newline at end of file From e7ff175efff4fc3e79d6ec1e777abe9f6feb0c31 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Thu, 27 Oct 2016 23:48:54 +0100 Subject: [PATCH 15/56] Remove report site token todo message (is now resolved) --- Plugins/Mineplex.ReportSite/view.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.ReportSite/view.php b/Plugins/Mineplex.ReportSite/view.php index 289895028..09fe80a32 100644 --- a/Plugins/Mineplex.ReportSite/view.php +++ b/Plugins/Mineplex.ReportSite/view.php @@ -125,7 +125,7 @@ { $connection = getConnection('ACCOUNT'); $statement = $connection->prepare('SELECT id FROM snapshots WHERE token = ?;'); - $statement->bind_param('s', $token); // TODO: correct data type + $statement->bind_param('s', $token); $statement->execute(); $statement->bind_result($snapshotId); $statement->store_result(); From 8283af25af2af34a47263aaf6464cc4067a4a546 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Thu, 27 Oct 2016 23:49:40 +0100 Subject: [PATCH 16/56] Remove resolved todo for metrics command --- .../src/mineplex/core/report/command/ReportMetricsCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java index 6594f019a..5a061ea61 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java @@ -52,7 +52,6 @@ public class ReportMetricsCommand extends CommandBase } else // display global metrics { - // TODO: do we parse days for global metrics? UtilPlayer.message(player, F.main("Report Metrics", F.elem("Global Metrics") + " (" + F.elem(days + " days") + ")")); displayGlobalMetrics(player, days); } From f0f01b74e8211129b28834b1b1877f4b4a3cbdd2 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Fri, 28 Oct 2016 18:13:20 +0100 Subject: [PATCH 17/56] PC-1016 Schedule cleanup task for everyday at 00:00 CDT --- Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql index faa980399..264c37d8c 100644 --- a/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql +++ b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql @@ -35,12 +35,17 @@ FOREIGN KEY (messageId) REFERENCES snapshotMessages (id) ON DELETE CASCADE; -- CREATE CLEANUP TASK DELIMITER // +-- CREATE EVENT TO RUN EVERY DAY AT 00:00 CREATE EVENT `report_cleanup` - ON SCHEDULE EVERY 1 MONTH + ON SCHEDULE + EVERY 1 DAY + -- FORCE TASK TO RUN AT 00:00 DAILY + STARTS (TIMESTAMP(CURRENT_DATE) + INTERVAL 1 DAY) ON COMPLETION PRESERVE + COMMENT 'Cleans up old report and snapshot data.' DO BEGIN -- DELETE REPORTS (AND ASSOCIATED SNAPSHOT IF ANY) CLOSED > 30 DAYS AGO - DELETE reports, snapshots FROM reports, snapshots + DELETE reports, snapshots FROM reports LEFT JOIN reportResults ON reports.id = reportResults.reportId LEFT JOIN snapshots ON reports.snapshotId = snapshots.id WHERE reportResults.closedTime NOT BETWEEN NOW() - INTERVAL 30 DAY AND NOW(); From eb37c5da2ecdc9dfb4e9e4d5fa6cc3baebb4c91c Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sat, 29 Oct 2016 14:26:16 +0100 Subject: [PATCH 18/56] PC-1016 Create column `created` to store date time for snapshots --- Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql index 264c37d8c..451877729 100644 --- a/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql +++ b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql @@ -1,3 +1,8 @@ +-- STORE DATETIME SNAPSHOT CREATED (CLEANUP PURPOSES) +ALTER TABLE Account.snapshots ADD created DATETIME DEFAULT NOW() NOT NULL; +ALTER TABLE Account.snapshots + MODIFY COLUMN creator INT(11) AFTER created; + -- CASCADE HANDLERS TABLE ALTER TABLE Account.reportHandlers DROP FOREIGN KEY reportHandlers_reports_id_fk; ALTER TABLE Account.reportHandlers From 09e5d13b96d5f1350251f35ddf3671482aefdb6c Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sat, 29 Oct 2016 14:27:19 +0100 Subject: [PATCH 19/56] PC-1016 Rename column `creator` to `creatorId` --- .../src/mineplex/core/chatsnap/SnapshotRepository.java | 2 +- Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java index 8ab7297a9..f239ff55c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java @@ -65,7 +65,7 @@ public class SnapshotRepository return token; } - private static final String INSERT_SNAPSHOT = "INSERT INTO snapshots (token, creator) VALUES (?, ?);"; + private static final String INSERT_SNAPSHOT = "INSERT INTO snapshots (token, creatorId) VALUES (?, ?);"; private static final String INSERT_MESSAGE = "INSERT INTO snapshotMessages (senderId, `server`, `time`, message, snapshotType) VALUES (?, ?, ?, ?, ?);"; private static final String INSERT_MESSAGE_RECIPIENT = "INSERT INTO snapshotRecipients (messageId, recipientId) VALUES (?, ?);"; private static final String INSERT_MESSAGE_MAPPING = "INSERT INTO snapshotMessageMap (snapshotId, messageId) VALUES (?, ?);"; diff --git a/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql index 451877729..b83563c92 100644 --- a/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql +++ b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql @@ -1,7 +1,10 @@ +-- RENAME COLUMN `creator` to `creatorId` +ALTER TABLE Account.snapshots CHANGE creator creatorId INT(11); + -- STORE DATETIME SNAPSHOT CREATED (CLEANUP PURPOSES) ALTER TABLE Account.snapshots ADD created DATETIME DEFAULT NOW() NOT NULL; ALTER TABLE Account.snapshots - MODIFY COLUMN creator INT(11) AFTER created; + MODIFY COLUMN creatorId INT(11) AFTER created; -- CASCADE HANDLERS TABLE ALTER TABLE Account.reportHandlers DROP FOREIGN KEY reportHandlers_reports_id_fk; From 3dc441d61d7045f218652b357e0f4884d23d9995 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sat, 29 Oct 2016 14:38:16 +0100 Subject: [PATCH 20/56] PC-1016 Delete snapshots > 30 days and not linked to report in cleanup task --- Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql index b83563c92..b0a634722 100644 --- a/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql +++ b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql @@ -58,6 +58,12 @@ DO BEGIN LEFT JOIN snapshots ON reports.snapshotId = snapshots.id WHERE reportResults.closedTime NOT BETWEEN NOW() - INTERVAL 30 DAY AND NOW(); + -- DELETE SNAPSHOTS NOT LINKED TO REPORT AND OLDER THAN 30 DAYS + DELETE snapshots FROM snapshots + LEFT JOIN reports ON snapshots.id = reports.snapshotId + WHERE reports.id IS NULL + AND snapshots.created NOT BETWEEN NOW() - INTERVAL 30 DAY AND NOW(); + -- DELETE ORPHANED SNAPSHOT MESSAGES DELETE snapshotMessages FROM snapshotMessages LEFT JOIN snapshotMessageMap ON snapshotMessages.id = snapshotMessageMap.messageId From 696a99b872896cb549b594359d176932706827ce Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sat, 29 Oct 2016 15:26:02 +0100 Subject: [PATCH 21/56] Refactor some parameter names to make method function more obvious --- .../core/report/data/ReportRepository.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index 1336ed555..b2a32161e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -160,11 +160,11 @@ public class ReportRepository /** * Gets the ids of unhandled reports that the supplied user is allowed to handle. * - * @param accountId the id of the account carrying out the search + * @param handlerId the id of the account carrying out the search * @param devMode if true, allows various restrictions to be bypassed * @return the ids of unhandled reports the supplied account is allowed to handle */ - public CompletableFuture> getUnhandledReports(int accountId, ReportCategory category, Region region, boolean devMode) + public CompletableFuture> getUnhandledReports(int handlerId, ReportCategory category, Region region, boolean devMode) { CompletableFuture> future = CompletableFuture.supplyAsync(() -> { @@ -176,11 +176,11 @@ public class ReportRepository preparedStatement.setShort(1, category.getId()); preparedStatement.setString(2, region.name()); preparedStatement.setBoolean(3, devMode); - preparedStatement.setInt(4, accountId); - preparedStatement.setInt(5, accountId); - preparedStatement.setInt(6, accountId); + preparedStatement.setInt(4, handlerId); + preparedStatement.setInt(5, handlerId); + preparedStatement.setInt(6, handlerId); preparedStatement.setBoolean(7, devMode); - preparedStatement.setInt(8, accountId); + preparedStatement.setInt(8, handlerId); ResultSet resultSet = preparedStatement.executeQuery(); while (resultSet.next()) @@ -207,10 +207,10 @@ public class ReportRepository /** * Gets a list containing the ids of reports the account is handling - * @param accountId the id of the account + * @param handlerId the id of the account * @return a list containing the ids of reports being handled */ - public CompletableFuture> getReportsHandling(int accountId) + public CompletableFuture> getReportsHandling(int handlerId) { CompletableFuture> future = CompletableFuture.supplyAsync(() -> { @@ -219,7 +219,7 @@ public class ReportRepository try (Connection connection = DBPool.getAccount().getConnection()) { PreparedStatement preparedStatement = connection.prepareStatement(GET_REPORTS_HANDLING); - preparedStatement.setInt(1, accountId); + preparedStatement.setInt(1, handlerId); ResultSet resultSet = preparedStatement.executeQuery(); @@ -397,7 +397,7 @@ public class ReportRepository return null; } - public CompletableFuture> getOngoingReports(int accountId) + public CompletableFuture> getOngoingReports(int suspectId) { CompletableFuture> future = CompletableFuture.supplyAsync(() -> { @@ -405,7 +405,7 @@ public class ReportRepository { List reports = new ArrayList<>(); PreparedStatement preparedStatement = connection.prepareStatement(GET_ONGOING_REPORT); - preparedStatement.setInt(1, accountId); + preparedStatement.setInt(1, suspectId); ResultSet resultSet = preparedStatement.executeQuery(); while (resultSet.next()) @@ -441,21 +441,21 @@ public class ReportRepository future.exceptionally(throwable -> { - _logger.log(Level.SEVERE, "Error getting ongoing report for account: " + accountId + ".", throwable); + _logger.log(Level.SEVERE, "Error getting ongoing report for account: " + suspectId + ".", throwable); return null; }); return future; } - public CompletableFuture> getOngoingReports(int accountId, ReportCategory category) + public CompletableFuture> getOngoingReports(int suspectId, ReportCategory category) { CompletableFuture> future = CompletableFuture.supplyAsync(() -> { try (Connection connection = DBPool.getAccount().getConnection()) { PreparedStatement preparedStatement = connection.prepareStatement(GET_ONGOING_REPORT_CATEGORY); - preparedStatement.setInt(1, accountId); + preparedStatement.setInt(1, suspectId); preparedStatement.setInt(2, category.getId()); ResultSet resultSet = preparedStatement.executeQuery(); @@ -475,7 +475,7 @@ public class ReportRepository future.exceptionally(throwable -> { - _logger.log(Level.SEVERE, "Error fetching ongoing report for account: " + accountId + ", category: " + category + ".", throwable); + _logger.log(Level.SEVERE, "Error fetching ongoing report for account: " + suspectId + ", category: " + category + ".", throwable); return new ArrayList<>(); }); @@ -512,13 +512,13 @@ public class ReportRepository return reportMessages; } - public CompletableFuture getResultCount(int accountId, ReportResultType resultType) + public CompletableFuture getResultCount(int reporterId, ReportResultType resultType) { CompletableFuture future = CompletableFuture.supplyAsync(() -> { try (Connection connection = DBPool.getAccount().getConnection()) { PreparedStatement preparedStatement = connection.prepareStatement(GET_USER_RESULT_COUNT); - preparedStatement.setInt(1, accountId); + preparedStatement.setInt(1, reporterId); preparedStatement.setInt(2, resultType.getId()); ResultSet resultSet = preparedStatement.executeQuery(); @@ -537,7 +537,7 @@ public class ReportRepository future.exceptionally(throwable -> { - _logger.log(Level.SEVERE, "Error fetching result count for account: " + accountId + ", type: " + resultType + ".", throwable); + _logger.log(Level.SEVERE, "Error fetching result count for account: " + reporterId + ", type: " + resultType + ".", throwable); return 0; }); From 7aa3daca9dc0073180cd10dfd8930205fcc9e9c1 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sat, 29 Oct 2016 15:54:01 +0100 Subject: [PATCH 22/56] PC-1140 Fix various issues with region-locked reports --- .../mineplex/core/report/ReportManager.java | 7 +-- .../core/report/data/ReportRepository.java | 44 +++++++++++-------- .../core/report/ui/ReportHandlePage.java | 5 +-- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index 428645d21..225535f89 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -80,7 +80,7 @@ public class ReportManager _serverName = serverName; _serverWeight = serverWeight; - _reportRepository = new ReportRepository(this, _plugin.getLogger()); + _reportRepository = new ReportRepository(this, region, _plugin.getLogger()); _userRepository = new ReportUserRepository(plugin); _metricsRepository = new ReportMetricsRepository(_plugin.getLogger()); @@ -97,11 +97,6 @@ public class ReportManager return _snapshotManager; } - public Region getRegion() - { - return _region; - } - /** * Gets the {@link ReportRepository} this instance is using. * diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index b2a32161e..cd555fb14 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -94,23 +94,26 @@ public class ReportRepository " /* Bypass for testing purposes or check player isn't a reporter */\n" + " AND (? IS TRUE OR SUM(IF(reportReasons.reporterId != ?, 1, 0)) = COUNT(reportReasons.reporterId));"; - private static final String GET_ONGOING_REPORT = "SELECT reports.id FROM reports" + - " LEFT JOIN reportResults ON reports.id = reportResults.reportId" + - " WHERE reportResults.reportId IS NULL" + - " AND reports.suspectId = ?;"; + private static final String GET_ONGOING_REPORT = "SELECT reports.id FROM reports\n" + + " LEFT JOIN reportResults ON reports.id = reportResults.reportId\n" + + "WHERE reportResults.reportId IS NULL\n" + + " AND reports.suspectId = ?\n" + + " AND reports.region = ?;"; - private static final String GET_ONGOING_REPORT_CATEGORY = "SELECT reports.id FROM reports" + - " LEFT JOIN reportResults ON reports.id = reportResults.reportId" + - " WHERE reportResults.reportId IS NULL" + - " AND reports.suspectId = ?" + - " AND reports.categoryId = ?;"; + private static final String GET_ONGOING_REPORT_CATEGORY = "SELECT reports.id FROM reports\n" + + " LEFT JOIN reportResults ON reports.id = reportResults.reportId\n" + + "WHERE reportResults.reportId IS NULL\n" + + " AND reports.suspectId = ?\n" + + " AND reports.categoryId = ?\n" + + " AND reports.region = ?;"; - private static final String GET_REPORTS_HANDLING = "SELECT reports.id FROM reports" + - " LEFT JOIN reportResults ON reports.id = reportResults.reportId" + - " INNER JOIN reportHandlers ON reports.id = reportHandlers.reportId" + - " AND reportHandlers.aborted IS FALSE" + - " WHERE reportResults.reportId IS NULL" + - " AND reportHandlers.handlerId = ?;"; + private static final String GET_REPORTS_HANDLING = "SELECT reports.id FROM reports\n" + + " LEFT JOIN reportResults ON reports.id = reportResults.reportId\n" + + " INNER JOIN reportHandlers ON reports.id = reportHandlers.reportId\n" + + " AND reportHandlers.aborted IS FALSE\n" + + "WHERE reportResults.reportId IS NULL\n" + + " AND reportHandlers.handlerId = ?\n" + + " AND reports.region = ?;"; private static final String GET_USER_RESULT_COUNT = "SELECT COUNT(reports.id) AS resultCount" + " FROM reports, reportReasons, reportResults" + @@ -144,6 +147,7 @@ public class ReportRepository "WHERE reports.suspectId = ?;"; private final ReportManager _reportManager; + private final Region _region; private final Logger _logger; private final Cache _cachedReports = CacheBuilder.newBuilder() @@ -151,9 +155,10 @@ public class ReportRepository .expireAfterAccess(5, TimeUnit.MINUTES) .build(); - public ReportRepository(ReportManager reportManager, Logger logger) + public ReportRepository(ReportManager reportManager, Region region, Logger logger) { _reportManager = reportManager; + _region = region; _logger = logger; } @@ -164,7 +169,7 @@ public class ReportRepository * @param devMode if true, allows various restrictions to be bypassed * @return the ids of unhandled reports the supplied account is allowed to handle */ - public CompletableFuture> getUnhandledReports(int handlerId, ReportCategory category, Region region, boolean devMode) + public CompletableFuture> getUnhandledReports(int handlerId, ReportCategory category, boolean devMode) { CompletableFuture> future = CompletableFuture.supplyAsync(() -> { @@ -174,7 +179,7 @@ public class ReportRepository { PreparedStatement preparedStatement = connection.prepareStatement(GET_UNHANDLED_REPORTS); preparedStatement.setShort(1, category.getId()); - preparedStatement.setString(2, region.name()); + preparedStatement.setString(2, _region.name()); preparedStatement.setBoolean(3, devMode); preparedStatement.setInt(4, handlerId); preparedStatement.setInt(5, handlerId); @@ -220,6 +225,7 @@ public class ReportRepository { PreparedStatement preparedStatement = connection.prepareStatement(GET_REPORTS_HANDLING); preparedStatement.setInt(1, handlerId); + preparedStatement.setString(2, _region.name()); ResultSet resultSet = preparedStatement.executeQuery(); @@ -406,6 +412,7 @@ public class ReportRepository List reports = new ArrayList<>(); PreparedStatement preparedStatement = connection.prepareStatement(GET_ONGOING_REPORT); preparedStatement.setInt(1, suspectId); + preparedStatement.setString(2, _region.name()); ResultSet resultSet = preparedStatement.executeQuery(); while (resultSet.next()) @@ -457,6 +464,7 @@ public class ReportRepository PreparedStatement preparedStatement = connection.prepareStatement(GET_ONGOING_REPORT_CATEGORY); preparedStatement.setInt(1, suspectId); preparedStatement.setInt(2, category.getId()); + preparedStatement.setString(3, _region.name()); ResultSet resultSet = preparedStatement.executeQuery(); List reports = new ArrayList<>(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java index 7be19ad04..c8f2238e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportHandlePage.java @@ -19,7 +19,6 @@ import mineplex.core.report.ReportManager; import mineplex.core.report.ReportPlugin; import mineplex.core.report.data.Report; import mineplex.core.report.data.ReportRepository; -import mineplex.serverdata.Region; /** * An interface which allows the user to select the type of report they'd like to handle. @@ -29,7 +28,6 @@ public class ReportHandlePage extends SimpleGui implements ReportCategoryCallbac private final ReportPlugin _plugin; private final Player _handler; private final int _handlerId; - private final Region _region; public ReportHandlePage(ReportPlugin plugin, Player handler, int handlerId) { @@ -38,7 +36,6 @@ public class ReportHandlePage extends SimpleGui implements ReportCategoryCallbac _plugin = plugin; _handler = handler; _handlerId = handlerId; - _region = plugin.getManager().getRegion(); buildPage(); } @@ -73,7 +70,7 @@ public class ReportHandlePage extends SimpleGui implements ReportCategoryCallbac // the below fetches the ids of all unhandled reports and gets a Report object for each of these ids // the priority of the report is then calculated and the results placed in a map - reportRepository.getUnhandledReports(_handlerId, category, _region, devMode).thenCompose(reportRepository::getReports).thenAccept(reports -> + reportRepository.getUnhandledReports(_handlerId, category, devMode).thenCompose(reportRepository::getReports).thenAccept(reports -> CompletableFuture.allOf(reports.stream().map(report -> reportManager.calculatePriority(report).thenAccept(priority -> { From 08f113bb9910096c9c5e71a9e7aab42461e5b1f2 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sun, 30 Oct 2016 01:58:56 +0100 Subject: [PATCH 23/56] Various improvements and fixes to report related database queries --- .../mineplex/core/report/data/ReportRepository.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index cd555fb14..b6335d014 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -98,22 +98,22 @@ public class ReportRepository " LEFT JOIN reportResults ON reports.id = reportResults.reportId\n" + "WHERE reportResults.reportId IS NULL\n" + " AND reports.suspectId = ?\n" + - " AND reports.region = ?;"; + " AND (reports.region IS NULL OR reports.region = ?);"; private static final String GET_ONGOING_REPORT_CATEGORY = "SELECT reports.id FROM reports\n" + " LEFT JOIN reportResults ON reports.id = reportResults.reportId\n" + "WHERE reportResults.reportId IS NULL\n" + " AND reports.suspectId = ?\n" + " AND reports.categoryId = ?\n" + - " AND reports.region = ?;"; + " AND (reports.region IS NULL OR reports.region = ?);"; private static final String GET_REPORTS_HANDLING = "SELECT reports.id FROM reports\n" + " LEFT JOIN reportResults ON reports.id = reportResults.reportId\n" + - " INNER JOIN reportHandlers ON reports.id = reportHandlers.reportId\n" + - " AND reportHandlers.aborted IS FALSE\n" + + " LEFT JOIN reportHandlers ON reports.id = reportHandlers.reportId\n" + "WHERE reportResults.reportId IS NULL\n" + " AND reportHandlers.handlerId = ?\n" + - " AND reports.region = ?;"; + " AND reportHandlers.aborted IS FALSE\n" + + " AND (reports.region IS NULL OR reports.region = ?);"; private static final String GET_USER_RESULT_COUNT = "SELECT COUNT(reports.id) AS resultCount" + " FROM reports, reportReasons, reportResults" + From 1405aef0c32bf44dbce9e9eeda7caf66afeb68a6 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sun, 30 Oct 2016 01:16:40 +0000 Subject: [PATCH 24/56] Update code to use column `creatorId` instead of `creator` --- .../src/mineplex/core/chatsnap/SnapshotRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java index f239ff55c..1ee5e0daa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java @@ -70,7 +70,7 @@ public class SnapshotRepository private static final String INSERT_MESSAGE_RECIPIENT = "INSERT INTO snapshotRecipients (messageId, recipientId) VALUES (?, ?);"; private static final String INSERT_MESSAGE_MAPPING = "INSERT INTO snapshotMessageMap (snapshotId, messageId) VALUES (?, ?);"; private static final String GET_ID_FROM_TOKEN = "SELECT snapshots.id FROM snapshots WHERE snapshots.token = ?;"; - private static final String GET_METADATA = "SELECT token, creator FROM snapshots WHERE id = ?;"; + private static final String GET_METADATA = "SELECT token, creatorId FROM snapshots WHERE id = ?;"; private static final String SET_TOKEN = "UPDATE snapshots SET token = ? WHERE id = ?;"; private final String _serverName; @@ -182,7 +182,7 @@ public class SnapshotRepository setToken(connection, snapshotId, token); } - Integer creatorId = resultSet.getInt("creator"); + Integer creatorId = resultSet.getInt("creatorId"); if (resultSet.wasNull()) creatorId = null; return new SnapshotMetadata(snapshotId, token, creatorId); From 8f07d377f15d8d8293ed66edc01922780b6bf534 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sun, 30 Oct 2016 01:25:06 +0000 Subject: [PATCH 25/56] Clear report cache after closing message has been sent, prevents report cache being cleared and instantly reloaded --- .../Mineplex.Core/src/mineplex/core/report/ReportManager.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index 225535f89..b4f1f6d7b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -339,12 +339,10 @@ public class ReportManager } jsonMessage = jsonMessage.add(F.main(prefix, "Reason: " + F.elem(reason))); - new ReportersNotification(ids, jsonMessage).publish(); + _reportRepository.clearCache(reportId); }); }); - - _reportRepository.clearCache(reportId); } catch (Throwable throwable) { From e72573d6fdb3f7a71248e52f23777b98476903b3 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sun, 30 Oct 2016 01:41:28 +0000 Subject: [PATCH 26/56] Fix getReports method not checking report cache first --- .../core/report/data/ReportRepository.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index b6335d014..6b1dc4bf9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -264,14 +264,22 @@ public class ReportRepository for (long reportId : reportIds) { - preparedStatement.setLong(1, reportId); - ResultSet resultSet = preparedStatement.executeQuery(); - Report report = loadReport(connection, resultSet); + Report report = _cachedReports.getIfPresent(reportId); - if (report != null) + if (report == null) { - reports.add(report); + preparedStatement.setLong(1, reportId); + ResultSet resultSet = preparedStatement.executeQuery(); + + report = loadReport(connection, resultSet); + + if (report == null) + { + continue; + } } + + reports.add(report); } return reports; @@ -641,6 +649,8 @@ public class ReportRepository } } + _cachedReports.put(reportId, report); // cache the report + PreparedStatement setReportMessageStatement = connection.prepareStatement(SET_REPORT_MESSAGE); for (Map.Entry entry : report.getMessages().entrySet()) From 4971adcfb3c685141babbff9b11e9b657eac22ae Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sun, 30 Oct 2016 01:53:52 +0000 Subject: [PATCH 27/56] This should be an inner join --- .../src/mineplex/core/report/data/ReportRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index 6b1dc4bf9..99b302211 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -109,7 +109,7 @@ public class ReportRepository private static final String GET_REPORTS_HANDLING = "SELECT reports.id FROM reports\n" + " LEFT JOIN reportResults ON reports.id = reportResults.reportId\n" + - " LEFT JOIN reportHandlers ON reports.id = reportHandlers.reportId\n" + + " INNER JOIN reportHandlers ON reports.id = reportHandlers.reportId\n" + "WHERE reportResults.reportId IS NULL\n" + " AND reportHandlers.handlerId = ?\n" + " AND reportHandlers.aborted IS FALSE\n" + From b5ef642f39a9c3d538aee5b972dbb9e423a8b84c Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sun, 30 Oct 2016 22:13:52 +0000 Subject: [PATCH 28/56] Improve getReportHandling code --- .../mineplex/core/report/ReportManager.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index b4f1f6d7b..6ed64ae66 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -569,22 +569,27 @@ public class ReportManager .thenApply(UtilCollections::unboxPresent) .thenApply(reports -> { - Report report = null; int size = reports.size(); - if (size == 1) + if (size == 0) { - report = reports.get(0); + return Optional.empty(); } - else if (size > 1) + else if (size == 1) + { + return Optional.of(reports.get(0)); + } + else { throw new IllegalStateException("Account is handling multiple reports."); } - - return Optional.ofNullable(report); }); - future.exceptionally(throwable -> Optional.empty()); + future.exceptionally(throwable -> + { + _plugin.getLogger().log(Level.SEVERE, "Error whilst fetching report being handled by: " + accountId + "."); + return Optional.empty(); + }); return future; } From 828f39536b6fd21dd03d286080b3df7ebe26b454 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Mon, 31 Oct 2016 15:49:15 +0000 Subject: [PATCH 29/56] Don't allow players to have more than 5 open reports at a time --- .../mineplex/core/report/ReportManager.java | 11 ++++ .../core/report/command/ReportCommand.java | 65 +++++++++++++------ .../core/report/data/ReportRepository.java | 34 ++++++++++ 3 files changed, 89 insertions(+), 21 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index 6ed64ae66..ba70b4291 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -54,6 +54,7 @@ public class ReportManager private static final String NAME = "Report"; private static final int INITIAL_PRIORITY = 15; private static final int ABUSE_BAN_THRESHOLD = 3; + public static final int MAXIMUM_REPORTS = 5; private final JavaPlugin _plugin; private final SnapshotManager _snapshotManager; @@ -594,6 +595,16 @@ public class ReportManager return future; } + public CompletableFuture> getOpenReports(int reporterId) + { + return _reportRepository.getOpenReports(reporterId) + .thenApply(reportIds -> + reportIds.stream().map(_reportRepository::getReport).collect(Collectors.toList())) + .thenCompose(UtilFuture::sequence) + .thenApply(UtilCollections::unboxPresent) + .thenCompose(reports -> UtilFuture.filter(reports, this::isActiveReport)); + } + /** * Calculates the priority of a report. * This takes many parameters into account including: diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java index 7abfd2499..e9f3e2280 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java @@ -1,5 +1,7 @@ package mineplex.core.report.command; +import java.util.logging.Level; + import org.bukkit.entity.Player; import mineplex.core.account.CoreClient; @@ -51,34 +53,55 @@ public class ReportCommand extends CommandBase Player suspect = UtilPlayer.searchOnline(reporter, playerName, false); String reason = F.combine(args, 1, null, false); - if (suspect != null) + reportManager.getOpenReports(reporterId).whenComplete((reports, throwable) -> { - // allow developer (iKeirNez) to report himself (for easy testing reasons) - if (suspect == reporter && !reportManager.isDevMode(reporter.getUniqueId())) + if (throwable == null) { - UtilPlayer.message(reporter, F.main(Plugin.getName(), C.cRed + "You cannot report yourself.")); - } - else - { - CoreClient suspectClient = clientManager.Get(suspect); - new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); - } - } - else - { - clientManager.loadClientByName(playerName, suspectClient -> - { - if (suspectClient != null) + if (reports.size() < ReportManager.MAXIMUM_REPORTS) { - new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); + if (suspect != null) + { + // allow developer (iKeirNez) to report himself (for easy testing reasons) + if (suspect == reporter && !reportManager.isDevMode(reporter.getUniqueId())) + { + UtilPlayer.message(reporter, F.main(Plugin.getName(), + C.cRed + "You cannot report yourself.")); + } + else + { + CoreClient suspectClient = clientManager.Get(suspect); + new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); + } + } + else + { + clientManager.loadClientByName(playerName, suspectClient -> + { + if (suspectClient != null) + { + new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); + } + else + { + UtilPlayer.message(reporter, F.main(Plugin.getName(), + C.cRed + "Unable to find player '" + playerName + "'!")); + } + }); + } } else { - UtilPlayer.message(reporter, F.main(Plugin.getName(), C.cRed + "Unable to find player '" - + playerName + "'!")); + UtilPlayer.message(reporter, F.main(Plugin.getName(), + C.cRed + "Cannot create report, you currently have too many open reports.")); } - }); - } + } + else + { + UtilPlayer.message(reporter, F.main(Plugin.getName(), + C.cRed + "An error occurred, please try again.")); + Plugin.getPlugin().getLogger().log(Level.SEVERE, "Error whilst fetching open reports.", throwable); + } + }); } } else diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index 99b302211..cacb668d7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -115,6 +115,12 @@ public class ReportRepository " AND reportHandlers.aborted IS FALSE\n" + " AND (reports.region IS NULL OR reports.region = ?);"; + private static final String GET_USER_OPEN_REPORTS = "SELECT reports.id FROM reports\n" + + " INNER JOIN reportReasons ON reports.id = reportReasons.reportId\n" + + " LEFT JOIN reportResults ON reports.id = reportResults.reportId\n" + + "WHERE reportResults.reportId IS NULL\n" + + " AND reportReasons.reporterId = ?;"; + private static final String GET_USER_RESULT_COUNT = "SELECT COUNT(reports.id) AS resultCount" + " FROM reports, reportReasons, reportResults" + " WHERE reports.id = reportReasons.reportId" + @@ -498,6 +504,34 @@ public class ReportRepository return future; } + public CompletableFuture> getOpenReports(int reporterId) + { + CompletableFuture> future = CompletableFuture.supplyAsync(() -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + PreparedStatement preparedStatement = connection.prepareStatement(GET_USER_OPEN_REPORTS); + preparedStatement.setInt(1, reporterId); + + ResultSet resultSet = preparedStatement.executeQuery(); + List reports = new ArrayList<>(); + + while (resultSet.next()) + { + reports.add(resultSet.getLong("id")); + } + + return reports; + } + catch (SQLException e) + { + throw new RuntimeException(e); + } + }); + + return future; + } + private Set getReportReasons(Connection connection, long reportId) { Set reportMessages = new HashSet<>(); From aaa248833ebcc613a9b0ea65db93da435a65e6d0 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Tue, 1 Nov 2016 17:21:56 +0000 Subject: [PATCH 30/56] Don't allow players to have more than 5 open snapshots at a time --- .../core/chatsnap/SnapshotManager.java | 2 + .../core/chatsnap/SnapshotRepository.java | 38 ++++++++++++++++++- .../chatsnap/command/ChatSnapCommand.java | 33 ++++++++++------ .../core/report/command/ReportCommand.java | 2 +- .../core/report/data/ReportRepository.java | 4 +- 5 files changed, 63 insertions(+), 16 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java index fdd39dfb4..aea72eb29 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotManager.java @@ -20,6 +20,8 @@ import mineplex.core.report.data.Report; */ public class SnapshotManager { + public static final int MAX_SNAPSHOTS = 5; + // There aren't any List or Set caching implementations // For an easy work around, we store values as the Key // For the value we just use some dummy object diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java index 1ee5e0daa..261f081f8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotRepository.java @@ -6,15 +6,16 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; +import java.util.ArrayList; import java.util.Base64; import java.util.Collection; +import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.logging.Level; import java.util.logging.Logger; import mineplex.core.common.util.UtilTime; -import mineplex.core.report.data.Report; import mineplex.serverdata.database.DBPool; /** @@ -72,6 +73,7 @@ public class SnapshotRepository private static final String GET_ID_FROM_TOKEN = "SELECT snapshots.id FROM snapshots WHERE snapshots.token = ?;"; private static final String GET_METADATA = "SELECT token, creatorId FROM snapshots WHERE id = ?;"; private static final String SET_TOKEN = "UPDATE snapshots SET token = ? WHERE id = ?;"; + private static final String GET_USER_SNAPSHOTS = "SELECT snapshots.id FROM snapshots WHERE snapshots.creatorId = ?;"; private final String _serverName; private final Logger _logger; @@ -208,6 +210,40 @@ public class SnapshotRepository return future; } + public CompletableFuture> getUserSnapshots(int creatorId) + { + CompletableFuture> future = CompletableFuture.supplyAsync(() -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + PreparedStatement preparedStatement = connection.prepareStatement(GET_USER_SNAPSHOTS); + preparedStatement.setInt(1, creatorId); + + ResultSet resultSet = preparedStatement.executeQuery(); + List snapshotIds = new ArrayList<>(); + + while (resultSet.next()) + { + snapshotIds.add(resultSet.getInt("id")); + } + + return snapshotIds; + } + catch (SQLException e) + { + throw new RuntimeException(e); + } + }); + + future.exceptionally(throwable -> + { + _logger.log(Level.SEVERE, "Error getting snapshots for user " + creatorId + "."); + return new ArrayList<>(); + }); + + return future; + } + private void setToken(Connection connection, int snapshotId, String token) throws SQLException { try (PreparedStatement setTokenStatement = connection.prepareStatement(SET_TOKEN)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java index 2ab7ffc70..1c085c647 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java @@ -33,23 +33,34 @@ public class ChatSnapCommand extends CommandBase { SnapshotManager manager = Plugin.getSnapshotManager(); SnapshotRepository repository = manager.getRepository(); - int accountId = _commandCenter.GetClientManager().getAccountId(player); - Set messages = manager.getMessagesInvolving(accountId); - repository.createSnapshot(accountId).thenAccept(snapshotMetadata -> + Plugin.getSnapshotManager().getRepository().getUserSnapshots(accountId).thenAccept(snapshotIds -> { - String token = snapshotMetadata.getToken().orElseThrow(() -> - new IllegalStateException("Snapshot doesn't have a token.")); + if (snapshotIds.size() < SnapshotManager.MAX_SNAPSHOTS) + { + Set messages = manager.getMessagesInvolving(accountId); - repository.insertMessages(snapshotMetadata.getId(), messages).join(); + repository.createSnapshot(accountId).thenAccept(snapshotMetadata -> + { + String token = snapshotMetadata.getToken().orElseThrow(() -> + new IllegalStateException("Snapshot doesn't have a token.")); - UtilPlayer.message(player, F.main(Plugin.getName(), "Snapshot successfully created.")); + repository.insertMessages(snapshotMetadata.getId(), messages).join(); - new JsonMessage(F.main(Plugin.getName(), "Your snapshot token is: ")) - .extra(F.elem(token)) - .click(ClickEvent.OPEN_URL, SnapshotRepository.getURL(token)) - .sendToPlayer(player); + UtilPlayer.message(player, F.main(Plugin.getName(), "Snapshot successfully created.")); + + new JsonMessage(F.main(Plugin.getName(), "Your snapshot token is: ")) + .extra(F.elem(token)) + .click(ClickEvent.OPEN_URL, SnapshotRepository.getURL(token)) + .sendToPlayer(player); + }); + } + else + { + UtilPlayer.message(player, F.main(Plugin.getName(), + C.cRed + "Cannot create snapshot, you have reached the limit.")); + } }); } else diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java index e9f3e2280..89be81d30 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java @@ -92,7 +92,7 @@ public class ReportCommand extends CommandBase else { UtilPlayer.message(reporter, F.main(Plugin.getName(), - C.cRed + "Cannot create report, you currently have too many open reports.")); + C.cRed + "Cannot create report, you have reached the limit.")); } } else diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index cacb668d7..94fda9c24 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -506,7 +506,7 @@ public class ReportRepository public CompletableFuture> getOpenReports(int reporterId) { - CompletableFuture> future = CompletableFuture.supplyAsync(() -> + return CompletableFuture.supplyAsync(() -> { try (Connection connection = DBPool.getAccount().getConnection()) { @@ -528,8 +528,6 @@ public class ReportRepository throw new RuntimeException(e); } }); - - return future; } private Set getReportReasons(Connection connection, long reportId) From 6273996ebe8d6b13076af9846814b089d5c39999 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Mon, 7 Nov 2016 15:38:55 +0000 Subject: [PATCH 31/56] Only set incognito and teleport player when report is hacking or gameplay offense --- .../src/mineplex/core/report/ReportManager.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index ba70b4291..ed08e2d49 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -245,15 +245,18 @@ public class ReportManager new ReportHandlerTask(this, reportId).start(_plugin); }); - if (!_incognitoManager.Get(reportHandler).Status) + if (report.getCategory() != ReportCategory.CHAT_ABUSE) { - _incognitoManager.toggle(reportHandler); - } + if (!_incognitoManager.Get(reportHandler).Status) + { + _incognitoManager.toggle(reportHandler); + } - String lastServer = report.getLatestMessage().getServer(); - if (!_serverName.equals(lastServer)) - { - Portal.transferPlayer(reportHandler.getName(), lastServer); + String lastServer = report.getLatestMessage().getServer(); + if (!_serverName.equals(lastServer)) + { + Portal.transferPlayer(reportHandler.getName(), lastServer); + } } reportHandler.sendMessage( From af7557c9b186750633da6b91c771cb2897123b54 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Wed, 9 Nov 2016 01:25:33 +0000 Subject: [PATCH 32/56] When multiple accounts with the same name occur, pick the one that logged in most recently --- .../core/report/data/ReportRepository.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index 94fda9c24..fb1e6ffb6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -128,16 +128,23 @@ public class ReportRepository " AND reportReasons.reporterId = ?" + " AND reportResults.resultId = ?;"; - private static final String GET_ACCOUNT_NAME = "SELECT id, `name` FROM accounts" + - " WHERE id = ?" + - " LIMIT 1;"; + // We order by lastLogin in the below queries to resolve cases whereby two account + // entries exist with the same name (online and offline mode versions), to get + // around this, we simply picked the one that logged in most recently + + private static final String GET_ACCOUNT_ID = "SELECT id, `name` FROM accounts\n" + + "WHERE `name` = ?\n" + + "ORDER BY lastLogin DESC\n" + + "LIMIT 1;"; + + private static final String GET_ACCOUNT_NAME = "SELECT id, `name` FROM accounts\n" + + "WHERE id = ?\n" + + "ORDER BY lastLogin DESC\n" + + "LIMIT 1;"; private static final String GET_ACCOUNT_UUID = "SELECT id, uuid FROM accounts" + " WHERE id IN (%s);"; - private static final String GET_ACCOUNT_ID = "SELECT id, `name` FROM accounts\n" + - "WHERE `name` = ?;"; - /** STATISTICS **/ private static final String STATISTICS_GET_REPORTS_MADE = "SELECT reports.id FROM reports, reportReasons\n" + From 70ca2c7964e5f5c6aaeb22109847bec3936d07a2 Mon Sep 17 00:00:00 2001 From: cnr Date: Tue, 15 Nov 2016 13:58:07 -0600 Subject: [PATCH 33/56] Add 1.11 support --- .../src/mineplex/core/CustomTagFix.java | 27 +++-- .../mineplex/core/bonuses/BonusManager.java | 70 ++++++------ .../core/creature/command/MobCommand.java | 11 ++ .../disguise/disguises/DisguiseAgeable.java | 6 +- .../disguise/disguises/DisguiseAmbient.java | 4 +- .../disguise/disguises/DisguiseAnimal.java | 6 +- .../disguises/DisguiseAnimalBase.java | 4 +- .../disguises/DisguiseArmorStand.java | 2 +- .../core/disguise/disguises/DisguiseBase.java | 32 ++++-- .../core/disguise/disguises/DisguiseBat.java | 2 +- .../disguise/disguises/DisguiseBlaze.java | 2 +- .../disguise/disguises/DisguiseBlock.java | 3 +- .../core/disguise/disguises/DisguiseCat.java | 2 +- .../disguises/DisguiseCaveSpider.java | 3 +- .../disguise/disguises/DisguiseChicken.java | 6 +- .../core/disguise/disguises/DisguiseCow.java | 6 +- .../disguise/disguises/DisguiseCreature.java | 7 +- .../disguise/disguises/DisguiseCreeper.java | 2 +- .../disguise/disguises/DisguiseEnderman.java | 2 +- .../disguise/disguises/DisguiseGolem.java | 6 +- .../disguise/disguises/DisguiseGuardian.java | 6 +- .../disguise/disguises/DisguiseHorse.java | 2 +- .../disguise/disguises/DisguiseHuman.java | 4 +- .../disguises/DisguiseInsentient.java | 9 +- .../disguise/disguises/DisguiseIronGolem.java | 2 +- .../disguise/disguises/DisguiseLiving.java | 12 +-- .../disguise/disguises/DisguiseMagmaCube.java | 3 +- .../disguise/disguises/DisguiseMonster.java | 4 +- .../disguise/disguises/DisguiseMooshroom.java | 4 +- .../core/disguise/disguises/DisguisePig.java | 6 +- .../disguise/disguises/DisguisePigZombie.java | 4 +- .../disguise/disguises/DisguiseRabbit.java | 6 +- .../disguise/disguises/DisguiseSheep.java | 2 +- .../disguise/disguises/DisguiseSkeleton.java | 2 +- .../disguise/disguises/DisguiseSlime.java | 2 +- .../disguise/disguises/DisguiseSnowman.java | 6 +- .../disguise/disguises/DisguiseSpider.java | 2 +- .../disguise/disguises/DisguiseSquid.java | 6 +- .../disguises/DisguiseTameableAnimal.java | 4 +- .../disguise/disguises/DisguiseVillager.java | 7 +- .../disguise/disguises/DisguiseWitch.java | 2 +- .../disguise/disguises/DisguiseWither.java | 5 +- .../core/disguise/disguises/DisguiseWolf.java | 2 +- .../disguise/disguises/DisguiseZombie.java | 6 +- .../gadgets/wineffect/WinEffectHalloween.java | 33 +++--- .../src/mineplex/core/hologram/Hologram.java | 34 +++--- .../src/mineplex/core/mount/HorseMount.java | 6 +- .../core/mount/types/MountChicken.java | 4 +- .../core/mount/types/MountSpider.java | 3 +- .../src/mineplex/core/utils/UtilVariant.java | 65 +++++++++++ .../hub/modules/AdminMountManager.java | 18 ++-- .../mineplex/hub/modules/WorldManager.java | 11 +- .../game/core/boss/snake/SnakeSegment.java | 20 ++-- .../game/games/castlesiege/CastleSiege.java | 78 +++++++------- .../games/christmas/content/PumpkinKing.java | 31 +++--- .../game/games/christmas/parts/Part4.java | 6 +- .../wither/data/WitherMinionManager.java | 49 ++++++--- .../games/smash/kits/KitSkeletalHorse.java | 8 +- .../perks/witherskeleton/PerkWitherImage.java | 6 +- .../game/arcade/kit/perks/PerkHorsePet.java | 58 +++++----- .../game/arcade/kit/perks/PerkSkeletons.java | 101 +++++++++++------- .../game/arcade/kit/perks/PerkWolfPet.java | 65 ++++++----- 62 files changed, 543 insertions(+), 364 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/utils/UtilVariant.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index 67e0e00fb..8372203e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -9,16 +9,6 @@ import java.util.Map.Entry; import java.util.Set; import java.util.UUID; -import mineplex.core.common.DummyEntity; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.event.CustomTagEvent; -import mineplex.core.packethandler.IPacketHandler; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.packethandler.PacketVerifier; -import mineplex.core.packethandler.PacketInfo; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; import net.minecraft.server.v1_8_R3.Entity; @@ -42,10 +32,19 @@ 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.event.player.PlayerToggleFlightEvent; -import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.common.DummyEntity; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.event.CustomTagEvent; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.packethandler.PacketInfo; +import mineplex.core.packethandler.PacketVerifier; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class CustomTagFix extends MiniPlugin implements IPacketHandler { private Map> _entityMap = new HashMap<>(); @@ -524,9 +523,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler } else { - PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(); - entityMetadata.a = entityIds[0]; - entityMetadata.b = watcher.c(); + PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityIds[0], watcher, true); packetList.bypassProcess(entityMetadata); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index d609f656b..82829872e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -1,5 +1,37 @@ package mineplex.core.bonuses; +import java.sql.Date; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Queue; +import java.util.TimeZone; +import java.util.UUID; + +import net.minecraft.server.v1_8_R3.DataWatcher; +import net.minecraft.server.v1_8_R3.EntityCreeper; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +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 org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.jooq.SQLDialect; +import org.jooq.impl.DSL; + import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; @@ -47,36 +79,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.core.youtube.YoutubeManager; import mineplex.database.Tables; import mineplex.serverdata.database.DBPool; -import net.minecraft.server.v1_8_R3.DataWatcher; -import net.minecraft.server.v1_8_R3.EntityCreeper; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -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 org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; -import org.jooq.SQLDialect; -import org.jooq.impl.DSL; - -import java.sql.Date; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Queue; -import java.util.TimeZone; -import java.util.UUID; public class BonusManager extends MiniClientPlugin implements ILoginProcessor { @@ -719,9 +721,7 @@ public class BonusManager extends MiniClientPlugin implements I watcher.a(0, (byte) 0, EntityCreeper.META_ENTITYDATA, (byte) 0); watcher.a(1, (short) 300, EntityCreeper.META_AIR, 0); watcher.a(17, (byte) 1, EntityCreeper.META_POWERED, true); - PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(); - packet.a = _carlNpc.getEntity().getEntityId(); - packet.b = watcher.c(); + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(_carlNpc.getEntity().getEntityId(), watcher, true); UtilPlayer.sendPacket(player, packet); } @@ -736,9 +736,7 @@ public class BonusManager extends MiniClientPlugin implements I // Charged DataWatcher watcher = new DataWatcher(null); watcher.a(17, (byte) 0, EntityCreeper.META_POWERED, false); - PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(); - packet.a = _carlNpc.getEntity().getEntityId(); - packet.b = watcher.c(); + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(_carlNpc.getEntity().getEntityId(), watcher, true); UtilPlayer.sendPacket(player, packet); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java index faf8929e2..33e0ed950 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java @@ -10,6 +10,7 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Ageable; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Guardian; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; @@ -163,6 +164,16 @@ public class MobCommand extends MultiCommandBase UtilPlayer.message(caller, F.desc("Angry", "True")); argHandle.add(arg); } + + else if (arg.equalsIgnoreCase("elder")) + { + for (Entity ent : entSet) + if (ent instanceof Guardian) + ((Guardian)ent).setElder(true); + + UtilPlayer.message(caller, F.desc("Elder", "True")); + argHandle.add(arg); + } //Profession else if (arg.toLowerCase().charAt(0) == 'p') diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAgeable.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAgeable.java index f51230ef4..c70db1088 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAgeable.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAgeable.java @@ -2,13 +2,13 @@ package mineplex.core.disguise.disguises; import net.minecraft.server.v1_8_R3.EntityAgeable; -import org.bukkit.entity.*; +import org.bukkit.entity.EntityType; public abstract class DisguiseAgeable extends DisguiseCreature { - public DisguiseAgeable(EntityType disguiseType, org.bukkit.entity.Entity entity) + public DisguiseAgeable(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) { - super(disguiseType, entity); + super(disguiseType, entity, clazz); DataWatcher.a(12, new Byte((byte)0), EntityAgeable.META_BABY, false); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java index d72e9aafb..668ee91e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java @@ -4,8 +4,8 @@ import org.bukkit.entity.EntityType; public abstract class DisguiseAmbient extends DisguiseInsentient { - public DisguiseAmbient(EntityType entityType, org.bukkit.entity.Entity entity) + public DisguiseAmbient(EntityType entityType, org.bukkit.entity.Entity entity, Class clazz) { - super(entityType, entity); + super(entityType, entity, clazz); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimal.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimal.java index e65ff3d5f..af73365c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimal.java @@ -1,11 +1,11 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.*; +import org.bukkit.entity.EntityType; public abstract class DisguiseAnimal extends DisguiseAgeable { - public DisguiseAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity) + public DisguiseAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) { - super(disguiseType, entity); + super(disguiseType, entity, clazz); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimalBase.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimalBase.java index f47327a24..f3ce535e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimalBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimalBase.java @@ -5,9 +5,9 @@ import org.bukkit.entity.EntityType; public class DisguiseAnimalBase extends DisguiseAnimal { - public DisguiseAnimalBase(EntityType entityType, org.bukkit.entity.Entity entity) + public DisguiseAnimalBase(EntityType entityType, org.bukkit.entity.Entity entity, Class clazz) { - super(entityType, entity); + super(entityType, entity, clazz); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java index 79695ec61..5c8d79dd2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java @@ -13,7 +13,7 @@ public class DisguiseArmorStand extends DisguiseInsentient { public DisguiseArmorStand(org.bukkit.entity.Entity entity) { - super(EntityType.ARMOR_STAND, entity); + super(EntityType.ARMOR_STAND, entity, EntityArmorStand.class); DataWatcher.a(10, (byte) 0, EntityArmorStand.META_ARMOR_OPTION, (byte) 0); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java index 2d0334abc..91c763e5c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java @@ -1,7 +1,13 @@ package mineplex.core.disguise.disguises; -import mineplex.core.common.DummyEntity; -import mineplex.core.common.util.UtilPlayer; +import java.lang.ref.WeakReference; +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.Entity; import net.minecraft.server.v1_8_R3.EntityPlayer; @@ -12,18 +18,17 @@ import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; import net.minecraft.server.v1_8_R3.WorldServer; + import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.entity.CreatureSpawnEvent; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import mineplex.core.common.util.UtilPlayer; public abstract class DisguiseBase { + private final Map,net.minecraft.server.v1_8_R3.Entity> dummyEntities = new HashMap<>(); private WeakReference _entity = new WeakReference<>(null); protected DataWatcher DataWatcher; @@ -37,7 +42,7 @@ public abstract class DisguiseBase */ private boolean _hideIfNotDisguised = false; - public DisguiseBase(EntityType entityType, org.bukkit.entity.Entity entity) + public DisguiseBase(EntityType entityType, org.bukkit.entity.Entity entity, Class entityClazz) { if (entity == null) { @@ -48,7 +53,18 @@ public abstract class DisguiseBase setEntity(entity); - DataWatcher = new DataWatcher(new DummyEntity(null)); + DataWatcher = new DataWatcher(dummyEntities.computeIfAbsent(entityClazz, clazz -> + { + try + { + Constructor constructor = clazz.getDeclaredConstructor(net.minecraft.server.v1_8_R3.World.class); + return constructor.newInstance((net.minecraft.server.v1_8_R3.World)null); + } catch (Exception e) + { + e.printStackTrace(); + return null; + } + })); DataWatcher.a(0, (byte) 0, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0); DataWatcher.a(1, (short) 300, net.minecraft.server.v1_8_R3.Entity.META_AIR, 300); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBat.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBat.java index b5100c880..eed6f6e85 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBat.java @@ -8,7 +8,7 @@ public class DisguiseBat extends DisguiseCreature { public DisguiseBat(org.bukkit.entity.Entity entity) { - super(EntityType.BAT, entity); + super(EntityType.BAT, entity, EntityBat.class); DataWatcher.a(16, new Byte((byte) 0), EntityBat.META_UPSIDEDOWN, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlaze.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlaze.java index c0d782982..9c7e1bedb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlaze.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlaze.java @@ -8,7 +8,7 @@ public class DisguiseBlaze extends DisguiseMonster { public DisguiseBlaze(org.bukkit.entity.Entity entity) { - super(EntityType.BLAZE, entity); + super(EntityType.BLAZE, entity, EntityBlaze.class); DataWatcher.a(16, new Byte((byte) 0), EntityBlaze.META_FIRE, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java index 387208c51..8b23dfceb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java @@ -2,6 +2,7 @@ package mineplex.core.disguise.disguises; import java.util.Random; +import net.minecraft.server.v1_8_R3.EntityFallingBlock; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; @@ -16,7 +17,7 @@ public class DisguiseBlock extends DisguiseBase public DisguiseBlock(org.bukkit.entity.Entity entity, int blockId, int blockData) { - super(EntityType.FALLING_BLOCK, entity); + super(EntityType.FALLING_BLOCK, entity, EntityFallingBlock.class); _blockId = blockId; _blockData = blockData; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCat.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCat.java index 621d77259..6cebfee7a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCat.java @@ -8,7 +8,7 @@ public class DisguiseCat extends DisguiseTameableAnimal { public DisguiseCat(org.bukkit.entity.Entity entity) { - super(EntityType.OCELOT, entity); + super(EntityType.OCELOT, entity, EntityOcelot.class); DataWatcher.a(18, Byte.valueOf((byte) 0), EntityOcelot.META_TYPE, 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java index 09b3d076a..ff4bf7a7a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java @@ -2,6 +2,7 @@ package mineplex.core.disguise.disguises; import org.bukkit.entity.EntityType; +import net.minecraft.server.v1_8_R3.EntityCaveSpider; import net.minecraft.server.v1_8_R3.EntitySpider; public class DisguiseCaveSpider extends DisguiseMonster @@ -9,7 +10,7 @@ public class DisguiseCaveSpider extends DisguiseMonster public DisguiseCaveSpider(org.bukkit.entity.Entity entity) { - super(EntityType.CAVE_SPIDER, entity); + super(EntityType.CAVE_SPIDER, entity, EntityCaveSpider.class); DataWatcher.a(16, new Byte((byte) 0), EntitySpider.META_CLIMBING, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseChicken.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseChicken.java index f55c6d707..8c4155c46 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseChicken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseChicken.java @@ -1,12 +1,14 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.*; +import net.minecraft.server.v1_8_R3.EntityChicken; + +import org.bukkit.entity.EntityType; public class DisguiseChicken extends DisguiseAnimal { public DisguiseChicken(org.bukkit.entity.Entity entity) { - super(EntityType.CHICKEN, entity); + super(EntityType.CHICKEN, entity, EntityChicken.class); } public String getHurtSound() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCow.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCow.java index 86b1dc192..e26a08a1b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCow.java @@ -1,12 +1,14 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.*; +import net.minecraft.server.v1_8_R3.EntityCow; + +import org.bukkit.entity.EntityType; public class DisguiseCow extends DisguiseAnimal { public DisguiseCow(org.bukkit.entity.Entity entity) { - super(EntityType.COW, entity); + super(EntityType.COW, entity, EntityCow.class); } public String getHurtSound() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java index d477ab3bc..c888e73a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java @@ -3,13 +3,14 @@ package mineplex.core.disguise.disguises; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; -import org.bukkit.entity.*; + +import org.bukkit.entity.EntityType; public abstract class DisguiseCreature extends DisguiseInsentient { - public DisguiseCreature(EntityType disguiseType, org.bukkit.entity.Entity entity) + public DisguiseCreature(EntityType disguiseType, org.bukkit.entity.Entity entity, Class entityClazz) { - super(disguiseType, entity); + super(disguiseType, entity, entityClazz); } @SuppressWarnings("deprecation") diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreeper.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreeper.java index 6d1eeb73b..189ac20f0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreeper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreeper.java @@ -8,7 +8,7 @@ public class DisguiseCreeper extends DisguiseMonster { public DisguiseCreeper(org.bukkit.entity.Entity entity) { - super(EntityType.CREEPER, entity); + super(EntityType.CREEPER, entity, EntityCreeper.class); DataWatcher.a(16, Byte.valueOf((byte) -1), EntityCreeper.META_FUSE_STATE, -1); DataWatcher.a(17, Byte.valueOf((byte) 0), EntityCreeper.META_POWERED, false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java index d8d9703c4..8aee3501f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java @@ -19,7 +19,7 @@ public class DisguiseEnderman extends DisguiseMonster { public DisguiseEnderman(org.bukkit.entity.Entity entity) { - super(EntityType.ENDERMAN, entity); + super(EntityType.ENDERMAN, entity, EntityEnderman.class); DataWatcher.a(16, new Short((short) 0), EntityEnderman.META_BLOCK, Optional. absent()); DataWatcher.a(17, new Byte((byte) 0), EntityEnderman.META_BLOCK, Optional. absent()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGolem.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGolem.java index de5a8b1fd..2457d6a4a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGolem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGolem.java @@ -1,11 +1,11 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.*; +import org.bukkit.entity.EntityType; public abstract class DisguiseGolem extends DisguiseCreature { - public DisguiseGolem(EntityType disguiseType, org.bukkit.entity.Entity entity) + public DisguiseGolem(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) { - super(disguiseType, entity); + super(disguiseType, entity, clazz); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java index af05e67bb..d65455002 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java @@ -1,14 +1,14 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.*; - import net.minecraft.server.v1_8_R3.EntityGuardian; +import org.bukkit.entity.EntityType; + public class DisguiseGuardian extends DisguiseCreature { public DisguiseGuardian(org.bukkit.entity.Entity entity) { - super(EntityType.GUARDIAN, entity); + super(EntityType.GUARDIAN, entity, EntityGuardian.class); DataWatcher.a(16, 0, EntityGuardian.META_ELDER, (byte) 0); DataWatcher.a(17, 0, EntityGuardian.META_TARGET, 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java index cbd7ee097..b2c06f503 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java @@ -12,7 +12,7 @@ public class DisguiseHorse extends DisguiseAnimal { public DisguiseHorse(org.bukkit.entity.Entity entity) { - super(EntityType.HORSE, entity); + super(EntityType.HORSE, entity, EntityHorse.class); DataWatcher.a(16, Integer.valueOf(0), EntityHorse.META_HORSE_STATE, (byte) 0); DataWatcher.a(19, Byte.valueOf((byte) 0), EntityHorse.META_TYPE, 0); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java index 344af0254..1931af450 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java @@ -3,11 +3,13 @@ package mineplex.core.disguise.disguises; import net.minecraft.server.v1_8_R3.EntityHuman; import org.bukkit.entity.EntityType; +import mineplex.core.common.DummyEntity; + public abstract class DisguiseHuman extends DisguiseLiving { public DisguiseHuman(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(disguiseType, entity); + super(disguiseType, entity, DummyEntity.class); byte skin = 0; skin |= (1 << 0); //Enable Cape diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java index 843af0c09..6d0f650d4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java @@ -1,18 +1,19 @@ package mineplex.core.disguise.disguises; -import mineplex.core.common.*; import net.minecraft.server.v1_8_R3.EntityInsentient; -import org.bukkit.*; +import org.bukkit.ChatColor; import org.bukkit.entity.EntityType; +import mineplex.core.common.Rank; + public abstract class DisguiseInsentient extends DisguiseLiving { private boolean _showArmor; - public DisguiseInsentient(EntityType disguiseType, org.bukkit.entity.Entity entity) + public DisguiseInsentient(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) { - super(disguiseType, entity); + super(disguiseType, entity, clazz); DataWatcher.a(3, Byte.valueOf((byte) 0), EntityInsentient.META_CUSTOMNAME_VISIBLE, false); DataWatcher.a(2, "", EntityInsentient.META_CUSTOMNAME, ""); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseIronGolem.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseIronGolem.java index 0e487c7e7..07165e023 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseIronGolem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseIronGolem.java @@ -8,7 +8,7 @@ public class DisguiseIronGolem extends DisguiseGolem { public DisguiseIronGolem(org.bukkit.entity.Entity entity) { - super(EntityType.IRON_GOLEM, entity); + super(EntityType.IRON_GOLEM, entity, EntityIronGolem.class); DataWatcher.a(16, Byte.valueOf((byte) 0), EntityIronGolem.META_PLAYER_CREATED, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java index dc3608873..47624d0e9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java @@ -3,24 +3,24 @@ package mineplex.core.disguise.disguises; import java.util.ArrayList; import java.util.Random; +import net.minecraft.server.v1_8_R3.EntityLiving; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; + import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; -import net.minecraft.server.v1_8_R3.EntityLiving; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; - public abstract class DisguiseLiving extends DisguiseBase { private static Random _random = new Random(); private boolean _invisible; private ItemStack[] _equipment = new ItemStack[5]; - public DisguiseLiving(EntityType disguiseType, org.bukkit.entity.Entity entity) + public DisguiseLiving(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) { - super(disguiseType, entity); + super(disguiseType, entity, clazz); DataWatcher.a(6, Float.valueOf(1.0F), EntityLiving.META_HEALTH, 1F); DataWatcher.a(7, Integer.valueOf(0), EntityLiving.META_POTION_COLOR, 0); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java index 904835bba..2de9ca123 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java @@ -1,5 +1,6 @@ package mineplex.core.disguise.disguises; +import net.minecraft.server.v1_8_R3.EntityMagmaCube; import net.minecraft.server.v1_8_R3.EntitySlime; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; @@ -10,7 +11,7 @@ public class DisguiseMagmaCube extends DisguiseInsentient { public DisguiseMagmaCube(org.bukkit.entity.Entity entity) { - super(EntityType.MAGMA_CUBE, entity); + super(EntityType.MAGMA_CUBE, entity, EntityMagmaCube.class); DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMonster.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMonster.java index d64c04a7d..e1d5b3ec8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMonster.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMonster.java @@ -4,8 +4,8 @@ import org.bukkit.entity.*; public abstract class DisguiseMonster extends DisguiseCreature { - public DisguiseMonster(EntityType disguiseType, org.bukkit.entity.Entity entity) + public DisguiseMonster(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) { - super(disguiseType, entity); + super(disguiseType, entity, clazz); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMooshroom.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMooshroom.java index 8b6d64485..91c5c6eba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMooshroom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMooshroom.java @@ -1,12 +1,14 @@ package mineplex.core.disguise.disguises; +import net.minecraft.server.v1_8_R3.EntityMushroomCow; + import org.bukkit.entity.*; public class DisguiseMooshroom extends DisguiseAnimal { public DisguiseMooshroom(org.bukkit.entity.Entity entity) { - super(EntityType.MUSHROOM_COW, entity); + super(EntityType.MUSHROOM_COW, entity, EntityMushroomCow.class); } public String getHurtSound() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePig.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePig.java index b2ce16dc1..750e0bd4f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePig.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePig.java @@ -1,12 +1,14 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.*; +import net.minecraft.server.v1_8_R3.EntityPig; + +import org.bukkit.entity.EntityType; public class DisguisePig extends DisguiseAnimal { public DisguisePig(org.bukkit.entity.Entity entity) { - super(EntityType.PIG, entity); + super(EntityType.PIG, entity, EntityPig.class); } public String getHurtSound() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePigZombie.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePigZombie.java index 259dfb163..8e0c8de9c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePigZombie.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePigZombie.java @@ -1,12 +1,14 @@ package mineplex.core.disguise.disguises; +import net.minecraft.server.v1_8_R3.EntityPigZombie; + import org.bukkit.entity.*; public class DisguisePigZombie extends DisguiseZombie { public DisguisePigZombie(org.bukkit.entity.Entity entity) { - super(EntityType.PIG_ZOMBIE, entity); + super(EntityType.PIG_ZOMBIE, entity, EntityPigZombie.class); } protected String getHurtSound() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java index 3facd4fe2..0461a8fe2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java @@ -1,18 +1,18 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.EntityType; - import net.minecraft.server.v1_8_R3.EntityRabbit; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import org.bukkit.entity.EntityType; + public class DisguiseRabbit extends DisguiseAnimal { public DisguiseRabbit(org.bukkit.entity.Entity entity) { - super(EntityType.RABBIT, entity); + super(EntityType.RABBIT, entity, EntityRabbit.class); DataWatcher.a(18, Byte.valueOf((byte) 0), EntityRabbit.META_TYPE, 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSheep.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSheep.java index 83e32ad0a..7ed6edc16 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSheep.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSheep.java @@ -9,7 +9,7 @@ public class DisguiseSheep extends DisguiseAnimal { public DisguiseSheep(org.bukkit.entity.Entity entity) { - super(EntityType.SHEEP, entity); + super(EntityType.SHEEP, entity, EntitySheep.class); DataWatcher.a(16, new Byte((byte) 0), EntitySheep.META_WOOL_STATE, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java index 122490073..9c099a369 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java @@ -9,7 +9,7 @@ public class DisguiseSkeleton extends DisguiseMonster { public DisguiseSkeleton(org.bukkit.entity.Entity entity) { - super(EntityType.SKELETON, entity); + super(EntityType.SKELETON, entity, EntitySkeleton.class); DataWatcher.a(13, Byte.valueOf((byte) 0), EntitySkeleton.META_TYPE, 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java index 96bb78cd9..dcbb66702 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java @@ -10,7 +10,7 @@ public class DisguiseSlime extends DisguiseInsentient { public DisguiseSlime(org.bukkit.entity.Entity entity) { - super(EntityType.SLIME, entity); + super(EntityType.SLIME, entity, EntitySlime.class); DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSnowman.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSnowman.java index 0c643e94d..569a6316f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSnowman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSnowman.java @@ -1,11 +1,13 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.*; +import net.minecraft.server.v1_8_R3.EntitySnowman; + +import org.bukkit.entity.EntityType; public class DisguiseSnowman extends DisguiseGolem { public DisguiseSnowman(org.bukkit.entity.Entity entity) { - super(EntityType.SNOWMAN, entity); + super(EntityType.SNOWMAN, entity, EntitySnowman.class); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSpider.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSpider.java index 8851de909..f90bb860f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSpider.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSpider.java @@ -8,7 +8,7 @@ public class DisguiseSpider extends DisguiseMonster { public DisguiseSpider(org.bukkit.entity.Entity entity) { - super(EntityType.SPIDER, entity); + super(EntityType.SPIDER, entity, EntitySpider.class); DataWatcher.a(16, new Byte((byte) 0), EntitySpider.META_CLIMBING, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSquid.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSquid.java index 040d5de5c..c03e50b35 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSquid.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSquid.java @@ -1,12 +1,14 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.*; +import net.minecraft.server.v1_8_R3.EntitySquid; + +import org.bukkit.entity.EntityType; public class DisguiseSquid extends DisguiseMonster { public DisguiseSquid(org.bukkit.entity.Entity entity) { - super(EntityType.SQUID, entity); + super(EntityType.SQUID, entity, EntitySquid.class); } protected String getHurtSound() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseTameableAnimal.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseTameableAnimal.java index 8309387c9..c281b020b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseTameableAnimal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseTameableAnimal.java @@ -10,9 +10,9 @@ import com.google.common.base.Optional; public abstract class DisguiseTameableAnimal extends DisguiseAnimal { - public DisguiseTameableAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity) + public DisguiseTameableAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) { - super(disguiseType, entity); + super(disguiseType, entity, clazz); DataWatcher.a(16, Byte.valueOf((byte) 0), EntityTameableAnimal.META_SITTING_TAMED, (byte) 0); DataWatcher.a(17, "", EntityTameableAnimal.META_OWNER, Optional. absent()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseVillager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseVillager.java index d9f367bdf..9f36f02f7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseVillager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseVillager.java @@ -1,12 +1,15 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.*; +import net.minecraft.server.v1_8_R3.EntityVillager; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; public class DisguiseVillager extends DisguiseAgeable { public DisguiseVillager(Entity entity) { - super(EntityType.VILLAGER, entity); + super(EntityType.VILLAGER, entity, EntityVillager.class); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWitch.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWitch.java index 83db8142c..8bb8c12e4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWitch.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWitch.java @@ -8,7 +8,7 @@ public class DisguiseWitch extends DisguiseMonster { public DisguiseWitch(org.bukkit.entity.Entity entity) { - super(EntityType.WITCH, entity); + super(EntityType.WITCH, entity, EntityWitch.class); DataWatcher.a(21, Byte.valueOf((byte) 0), EntityWitch.META_AGGRESSIVE, false); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWither.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWither.java index 333d283bd..6c715ce0a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWither.java @@ -3,15 +3,12 @@ package mineplex.core.disguise.disguises; import net.minecraft.server.v1_8_R3.EntityWither; import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; - -import mineplex.core.common.util.UtilMath; public class DisguiseWither extends DisguiseMonster { public DisguiseWither(org.bukkit.entity.Entity entity) { - super(EntityType.WITHER, entity); + super(EntityType.WITHER, entity, EntityWither.class); DataWatcher.a(17, new Integer(0), EntityWither.META_INVUL_TIME, 0); DataWatcher.a(18, new Integer(0), EntityWither.META_TARGET_1, 0); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWolf.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWolf.java index 3b663f075..952f4a284 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWolf.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWolf.java @@ -8,7 +8,7 @@ public class DisguiseWolf extends DisguiseTameableAnimal { public DisguiseWolf(org.bukkit.entity.Entity entity) { - super(EntityType.WOLF, entity); + super(EntityType.WOLF, entity, EntityWolf.class); DataWatcher.a(18, new Float(20F), EntityWolf.META_WOLF_HEALTH, 20F); DataWatcher.a(19, new Byte((byte) 0), EntityWolf.META_BEGGING, false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseZombie.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseZombie.java index df1d4118e..1aacdc46e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseZombie.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseZombie.java @@ -8,12 +8,12 @@ public class DisguiseZombie extends DisguiseMonster { public DisguiseZombie(Entity entity) { - this(EntityType.ZOMBIE, entity); + this(EntityType.ZOMBIE, entity, EntityZombie.class); } - public DisguiseZombie(EntityType disguiseType, Entity entity) + public DisguiseZombie(EntityType disguiseType, Entity entity, Class clazz) { - super(disguiseType, entity); + super(disguiseType, entity, clazz); DataWatcher.a(12, Byte.valueOf((byte) 0), EntityZombie.META_CHILD, false); DataWatcher.a(13, Byte.valueOf((byte) 0), EntityZombie.META_VILLAGER, false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java index ffd1e29be..17d8c4075 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java @@ -3,16 +3,6 @@ package mineplex.core.gadget.gadgets.wineffect; import java.util.ArrayList; import java.util.List; -import mineplex.core.common.skin.SkinData; -import mineplex.core.common.util.*; -import mineplex.core.common.util.particles.ColoredParticle; -import mineplex.core.common.util.particles.DustSpellColor; -import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.particle.unrelated.BabyFireworkEffect; -import mineplex.core.gadget.types.WinEffectGadget; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; @@ -22,6 +12,26 @@ import org.bukkit.entity.Skeleton; import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilSkull; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.particle.unrelated.BabyFireworkEffect; +import mineplex.core.gadget.types.WinEffectGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; + public class WinEffectHalloween extends WinEffectGadget { @@ -119,10 +129,9 @@ public class WinEffectHalloween extends WinEffectGadget private void spawnSkeleton() { - Skeleton skeleton = getBaseLocation().getWorld().spawn(getBaseLocation(), Skeleton.class); + Skeleton skeleton = UtilVariant.spawnWitherSkeleton(getBaseLocation()); skeleton.setCustomName(getRank(_player) + _player.getName()); skeleton.setCustomNameVisible(true); - skeleton.setSkeletonType(Skeleton.SkeletonType.WITHER); skeleton.getEquipment().setHelmet(new ItemStack(Material.JACK_O_LANTERN)); UtilEnt.ghost(skeleton, true, false); UtilEnt.Vegetate(skeleton); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java index b06707ed2..f873ea35c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java @@ -1,14 +1,12 @@ package mineplex.core.hologram; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.EntityArmorStand; import net.minecraft.server.v1_8_R3.Packet; @@ -18,6 +16,14 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; + public class Hologram { public enum HologramTarget { @@ -481,12 +487,6 @@ public class Hologram { // Send update metadata packets Integer entityId = _entityIds.get(i); - PacketPlayOutEntityMetadata metadata1_8 = new PacketPlayOutEntityMetadata(); - PacketPlayOutEntityMetadata metadata1_9 = new PacketPlayOutEntityMetadata(); - - metadata1_8.a = entityId; - metadata1_9.a = entityId; - DataWatcher watcher1_8 = new DataWatcher(null); DataWatcher watcher1_9 = new DataWatcher(null); @@ -504,11 +504,9 @@ public class Hologram { watcher1_9.a(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16); } } - metadata1_8.b = watcher1_8.c(); - metadata1_9.b = watcher1_9.c(); - packets1_8.add(metadata1_8); - packets1_9.add(metadata1_9); + packets1_8.add(new PacketPlayOutEntityMetadata(entityId, watcher1_8, true)); + packets1_9.add(new PacketPlayOutEntityMetadata(entityId, watcher1_9, true)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java index 05a85e24d..f383958b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java @@ -23,6 +23,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.core.utils.UtilVariant; public class HorseMount extends Mount> { @@ -103,13 +104,12 @@ public class HorseMount extends Mount> //Remove other mounts Manager.DeregisterAll(player); - - Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); + + Horse horse = UtilVariant.spawnHorse(player.getLocation(), _variant); horse.setAdult(); horse.setAgeLock(true); horse.setColor(_color); horse.setStyle(_style); - horse.setVariant(_variant); horse.setOwner(player); horse.setMaxDomestication(1); horse.setJumpStrength(_jump); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountChicken.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountChicken.java index 68b439005..6c8382210 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountChicken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountChicken.java @@ -28,6 +28,7 @@ import mineplex.core.mount.SingleEntityMountData; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; public class MountChicken extends HorseMount { @@ -61,12 +62,11 @@ public class MountChicken extends HorseMount //Remove other mounts Manager.DeregisterAll(player); - Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); + Horse horse = UtilVariant.spawnHorse(player.getLocation(), _variant); horse.setAdult(); horse.setAgeLock(true); horse.setColor(_color); horse.setStyle(_style); - horse.setVariant(_variant); horse.setOwner(player); horse.setMaxDomestication(1); horse.setJumpStrength(_jump); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java index 90b7ab87c..3962bf332 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java @@ -35,6 +35,7 @@ import mineplex.core.mount.SingleEntityMountData; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; public class MountSpider extends HorseMount { @@ -76,7 +77,7 @@ public class MountSpider extends HorseMount //Remove other mounts Manager.DeregisterAll(player); - Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); + Horse horse = UtilVariant.spawnHorse(player.getLocation(), _variant); horse.setAdult(); horse.setAgeLock(true); horse.setColor(_color); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/utils/UtilVariant.java b/Plugins/Mineplex.Core/src/mineplex/core/utils/UtilVariant.java new file mode 100644 index 000000000..8134ca1f5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/utils/UtilVariant.java @@ -0,0 +1,65 @@ +package mineplex.core.utils; + +import net.minecraft.server.v1_8_R3.EntityGuardian; +import net.minecraft.server.v1_8_R3.EntityHorse; +import net.minecraft.server.v1_8_R3.EntitySkeleton; +import net.minecraft.server.v1_8_R3.EntityZombie; +import net.minecraft.server.v1_8_R3.World; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.Guardian; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Zombie; +import org.bukkit.event.entity.CreatureSpawnEvent; + +public class UtilVariant +{ + + public static Horse spawnHorse(Location location, Horse.Variant variant) + { + World world = ((CraftWorld) location.getWorld()).getHandle(); + + EntityHorse horse = new EntityHorse(world); + horse.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + horse.setType(variant.ordinal()); + world.addEntity(horse, CreatureSpawnEvent.SpawnReason.CUSTOM); + + return (Horse) horse.getBukkitEntity(); + } + + public static Zombie spawnZombieVillager(Location location) + { + World world = ((CraftWorld) location.getWorld()).getHandle(); + + EntityZombie zombie = new EntityZombie(world); + zombie.setVillager(true); + world.addEntity(zombie, CreatureSpawnEvent.SpawnReason.CUSTOM); + + return (Zombie) zombie.getBukkitEntity(); + } + + public static Skeleton spawnWitherSkeleton(Location location) + { + World world = ((CraftWorld) location.getWorld()).getHandle(); + + EntitySkeleton skeleton = new EntitySkeleton(world); + skeleton.setSkeletonType(1); + world.addEntity(skeleton, CreatureSpawnEvent.SpawnReason.CUSTOM); + + return (Skeleton) skeleton.getBukkitEntity(); + } + + public static Guardian spawnElderGuardian(Location location) + { + World world = ((CraftWorld) location.getWorld()).getHandle(); + + EntityGuardian guardian = new EntityGuardian(world); + guardian.setElder(true); + world.addEntity(guardian, CreatureSpawnEvent.SpawnReason.CUSTOM); + + return (Guardian) guardian.getBukkitEntity(); + + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java index 90806d135..d1ba19b1f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java @@ -3,24 +3,25 @@ package mineplex.hub.modules; import java.util.ArrayList; import java.util.HashMap; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.hub.HubManager; -import mineplex.hub.commands.HorseSpawn; - import org.bukkit.Material; import org.bukkit.entity.Horse; -import org.bukkit.entity.Player; 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.event.EventHandler; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.utils.UtilVariant; +import mineplex.hub.HubManager; +import mineplex.hub.commands.HorseSpawn; + public class AdminMountManager extends MiniPlugin { private HubManager Manager; @@ -291,12 +292,11 @@ public class AdminMountManager extends MiniPlugin Horse horse = _mounts.remove(caller); if (horse != null) horse.remove(); - horse = caller.getWorld().spawn(caller.getLocation(), Horse.class); + horse = UtilVariant.spawnHorse(caller.getLocation(), var); horse.setAdult(); horse.setAgeLock(true); horse.setColor(Color.DARK_BROWN); horse.setStyle(Style.WHITE_DOTS); - horse.setVariant(var); horse.setOwner(caller); horse.setMaxDomestication(1); horse.setJumpStrength(1); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java index 1d8a19f78..0d83153c4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java @@ -20,7 +20,6 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Pig; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.entity.Snowman; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -50,6 +49,7 @@ import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; import mineplex.hub.HubManager; import mineplex.hub.HubType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -130,11 +130,14 @@ public class WorldManager extends MiniPlugin //Spawn if (Manager.Type == HubType.Halloween) { - Skeleton ent = loc.getWorld().spawn(loc, Skeleton.class); - + final Skeleton ent; if (Math.random() > 0.5) { - ent.setSkeletonType(SkeletonType.WITHER); + ent = UtilVariant.spawnWitherSkeleton(loc); + + } else + { + ent = loc.getWorld().spawn(loc, Skeleton.class); } ent.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.PUMPKIN)); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeSegment.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeSegment.java index 3f58ac483..4366c95b1 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeSegment.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeSegment.java @@ -2,13 +2,6 @@ package mineplex.minecraft.game.core.boss.snake; import java.util.UUID; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; -import org.bukkit.entity.EntityType; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.EntityArmorStand; import net.minecraft.server.v1_8_R3.Packet; @@ -19,6 +12,14 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_8_R3.Vector3f; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; + public class SnakeSegment { private int _entityId = UtilEnt.getNewEntityId(); @@ -107,10 +108,7 @@ public class SnakeSegment watcher.a(15, new Vector3f(0, 0, 0), EntityArmorStand.META_LEFT_LEG_POSE, new Vector3f(0, 0, 0)); watcher.a(16, new Vector3f(0, 0, 0), EntityArmorStand.META_RIGHT_LEG_POSE, new Vector3f(0, 0, 0)); - PacketPlayOutEntityMetadata meta = new PacketPlayOutEntityMetadata(); - - meta.a = getId(); - meta.b = watcher.c(); + PacketPlayOutEntityMetadata meta = new PacketPlayOutEntityMetadata(getId(), watcher, true); return new Packet[] { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index e9dba2596..7a8bffcce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -1,5 +1,43 @@ package nautilus.game.arcade.game.games.castlesiege; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.EntityEffect; +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.Creature; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Horse.Style; +import org.bukkit.entity.LivingEntity; +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.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; @@ -18,6 +56,7 @@ 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.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -38,44 +77,6 @@ import nautilus.game.arcade.stats.KingSlayerStatTracker; import nautilus.game.arcade.stats.TeamDeathsStatTracker; import nautilus.game.arcade.stats.TeamKillsStatTracker; import nautilus.game.arcade.stats.WinAsTeamStatTracker; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Effect; -import org.bukkit.EntityEffect; -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.Creature; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Horse.Style; -import org.bukkit.entity.Horse.Variant; -import org.bukkit.entity.LivingEntity; -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.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.player.PlayerEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; public class CastleSiege extends TeamGame { @@ -329,7 +330,6 @@ public class CastleSiege extends TeamGame horse.setAgeLock(true); horse.setColor(org.bukkit.entity.Horse.Color.BLACK); horse.setStyle(Style.BLACK_DOTS); - horse.setVariant(Variant.HORSE); horse.setMaxDomestication(1); horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); horse.getInventory().setArmor(new ItemStack(Material.IRON_BARDING)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/PumpkinKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/PumpkinKing.java index 1397465e1..75aca805b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/PumpkinKing.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/PumpkinKing.java @@ -2,30 +2,30 @@ package nautilus.game.arcade.game.games.christmas.content; import java.util.ArrayList; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilTime; -import nautilus.game.arcade.game.games.christmas.ChristmasAudio; -import nautilus.game.arcade.game.games.christmas.parts.Part5; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; 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.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.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.utils.UtilVariant; + +import nautilus.game.arcade.game.games.christmas.ChristmasAudio; +import nautilus.game.arcade.game.games.christmas.parts.Part5; + public class PumpkinKing { private Part5 Host; @@ -45,12 +45,11 @@ public class PumpkinKing _grid = grid; Host.Host.CreatureAllowOverride = true; - _ent = loc.getWorld().spawn(loc, Skeleton.class); + _ent = UtilVariant.spawnWitherSkeleton(loc); Host.Host.CreatureAllowOverride = false; UtilEnt.Vegetate(_ent); UtilEnt.ghost(_ent, true, false); - _ent.setSkeletonType(SkeletonType.WITHER); _ent.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); _ent.getEquipment().setItemInHand(new ItemStack(Material.TNT)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part4.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part4.java index 26b282b57..146402ed2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part4.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part4.java @@ -23,6 +23,7 @@ import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; 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.game.games.christmas.Christmas; import nautilus.game.arcade.game.games.christmas.ChristmasAudio; @@ -180,15 +181,14 @@ public class Part4 extends Part Location loc = UtilAlg.Random(_mobSpawns); Host.CreatureAllowOverride = true; - Zombie ent = loc.getWorld().spawn(loc, Zombie.class); + Zombie ent = UtilVariant.spawnZombieVillager(loc); Host.CreatureAllowOverride = false; ent.getEquipment().setItemInHand(new ItemStack(Material.WOOD_PICKAXE)); ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); - ent.setVillager(true); - + ent.setCustomName("Evil Elf " + UtilMath.randomElement(_evilElfNames)); ent.setHealth(9); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index ebaff1a07..acbdded52 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -1,17 +1,8 @@ package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data; -import mineplex.core.common.util.*; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilTime.TimeUnit; -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.GameStateChangeEvent; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.games.minecraftleague.tracker.GrabSkullEvent; -import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; +import java.util.List; +import java.util.Random; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.FireworkEffect.Type; @@ -19,8 +10,10 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSkeleton; -import org.bukkit.entity.*; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.entity.Wither; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -37,8 +30,31 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; -import java.util.List; -import java.util.Random; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; +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.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +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.UtilVariant; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.minecraftleague.tracker.GrabSkullEvent; +import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; public class WitherMinionManager implements Listener { @@ -105,9 +121,8 @@ public class WitherMinionManager implements Listener else chosen = _spawns.get(_lastUsed); _host.Host.CreatureAllowOverride = true; - Entity e = _host.Manager.GetCreature().SpawnEntity(chosen, EntityType.SKELETON); _host.Host.CreatureAllowOverride = false; - ((Skeleton)e).setSkeletonType(SkeletonType.WITHER); + Skeleton e = UtilVariant.spawnWitherSkeleton(chosen); _entity = (Skeleton)e; UtilEnt.ghost(e, true, false); UtilEnt.Vegetate(e); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeletalHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeletalHorse.java index 6bcd59057..0872b37ce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeletalHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkeletalHorse.java @@ -14,6 +14,8 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.disguise.disguises.DisguiseHorse; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.utils.UtilVariant; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.smash.perks.PerkSmashStats; @@ -110,10 +112,8 @@ public class KitSkeletalHorse extends SmashKit @Override public Entity SpawnEntity(Location loc) { - Horse horse = (Horse) super.SpawnEntity(loc); - - horse.setVariant(Variant.SKELETON_HORSE); - + Horse horse = UtilVariant.spawnHorse(loc, Variant.SKELETON_HORSE); + return horse; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherImage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherImage.java index bdc668038..348241aab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherImage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/witherskeleton/PerkWitherImage.java @@ -11,7 +11,6 @@ import org.bukkit.Sound; 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.entity.EntityTargetEvent; @@ -29,7 +28,9 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; 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.game.games.smash.perks.SmashPerk; public class PerkWitherImage extends SmashPerk @@ -91,10 +92,9 @@ public class PerkWitherImage extends SmashPerk // Spawn Manager.GetGame().CreatureAllowOverride = true; - Skeleton skel = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Skeleton.class); Manager.GetGame().CreatureAllowOverride = false; - skel.setSkeletonType(SkeletonType.WITHER); + Skeleton skel = UtilVariant.spawnWitherSkeleton(player.getEyeLocation().add(player.getLocation().getDirection())); skel.getEquipment().setItemInHand(player.getItemInHand()); skel.setMaxHealth(20); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java index 22eb53950..051a3e8d1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java @@ -1,16 +1,8 @@ package nautilus.game.arcade.kit.perks; -import mineplex.core.common.Rank; -import mineplex.core.common.util.*; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier; -import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; -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; -import nautilus.game.arcade.kit.Perk; +import java.util.HashMap; +import java.util.Iterator; + import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Entity; @@ -25,8 +17,25 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.inventory.ItemStack; -import java.util.HashMap; -import java.util.Iterator; +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.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier; +import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; +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.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.kit.Perk; public class PerkHorsePet extends Perk { @@ -53,39 +62,40 @@ public class PerkHorsePet extends Perk return; Manager.GetGame().CreatureAllowOverride = true; - Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); Manager.GetGame().CreatureAllowOverride = false; - horse.setAdult(); - horse.setAgeLock(true); - horse.setColor(Color.BROWN); - horse.setStyle(Style.NONE); KitModifier kitModifier = getHorseType(player); + final Horse.Variant variant; if (kitModifier != null) { switch (getHorseType(player)) { case Survival_Games_Horseman_Mule: - horse.setVariant(Variant.MULE); + variant = Variant.MULE; break; case Survival_Games_Horseman_Skeleton_Horse: - horse.setVariant(Variant.SKELETON_HORSE); + variant = Variant.SKELETON_HORSE; break; case Survival_Games_Horseman_Zombie_Horse: - horse.setVariant(Variant.UNDEAD_HORSE); + variant = Variant.UNDEAD_HORSE; break; case Survival_Games_Horseman_Donkey: - horse.setVariant(Variant.DONKEY); + variant = Variant.DONKEY; break; default: - horse.setVariant(Variant.HORSE); + variant = Variant.HORSE; break; } } else { - horse.setVariant(Variant.HORSE); + variant = Variant.HORSE; } + Horse horse = UtilVariant.spawnHorse(player.getLocation(), variant); + horse.setAdult(); + horse.setAgeLock(true); + horse.setColor(Color.BROWN); + horse.setStyle(Style.NONE); horse.setOwner(player); horse.setMaxDomestication(1); horse.setJumpStrength(1); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java index 4e7075481..af6651b66 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java @@ -1,18 +1,13 @@ package nautilus.game.arcade.kit.perks; -import mineplex.core.common.Rank; -import mineplex.core.common.util.*; -import mineplex.core.disguise.disguises.DisguiseZombie; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier; -import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; -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.kit.Perk; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + import net.minecraft.server.v1_8_R3.EntityCreature; import net.minecraft.server.v1_8_R3.NavigationAbstract; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -30,10 +25,23 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerEvent; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; +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.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.disguise.disguises.DisguiseZombie; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier; +import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.kit.Perk; public class PerkSkeletons extends Perk { @@ -100,9 +108,47 @@ public class PerkSkeletons extends Perk Player killed = (Player) event.GetEvent().getEntity(); Manager.GetGame().CreatureAllowOverride = true; - Skeleton skel = killer.getWorld().spawn(killed.getLocation(), Skeleton.class); Manager.GetGame().CreatureAllowOverride = false; + + KitModifier kitModifier = getSkeletonType(killer); + final Skeleton.SkeletonType type; + if (kitModifier != null) + { + switch (kitModifier) + { + case Survival_Games_Necromancer_Wither_Skeleton: + type = Skeleton.SkeletonType.WITHER; + break; + case Survival_Games_Necromancer_Zombie: + type = Skeleton.SkeletonType.NORMAL; + break; + default: + type = Skeleton.SkeletonType.NORMAL; + break; + } + } + else + { + type = Skeleton.SkeletonType.NORMAL; + } + + final Skeleton skel; + if (type == Skeleton.SkeletonType.NORMAL) + { + skel = killer.getWorld().spawn(killed.getLocation(), Skeleton.class); + + } else + { + skel = UtilVariant.spawnWitherSkeleton(killed.getLocation()); + } + + if (kitModifier != null && kitModifier == KitModifier.Survival_Games_Necromancer_Zombie) + { + DisguiseZombie disguiseZombie = new DisguiseZombie(skel); + Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseZombie); + } + UtilEnt.removeGoalSelectors(skel); skel.setMaxHealth(30); @@ -126,29 +172,6 @@ public class PerkSkeletons extends Perk skel.getEquipment().setLeggingsDropChance(1f); skel.getEquipment().setBootsDropChance(1f); - KitModifier kitModifier = getSkeletonType(killer); - if (kitModifier != null) - { - switch (kitModifier) - { - case Survival_Games_Necromancer_Wither_Skeleton: - skel.setSkeletonType(Skeleton.SkeletonType.WITHER); - break; - case Survival_Games_Necromancer_Zombie: - skel.setSkeletonType(Skeleton.SkeletonType.NORMAL); - DisguiseZombie disguiseZombie = new DisguiseZombie(skel); - Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseZombie); - break; - default: - skel.setSkeletonType(Skeleton.SkeletonType.NORMAL); - break; - } - } - else - { - skel.setSkeletonType(Skeleton.SkeletonType.NORMAL); - } - if (_name) { skel.setCustomName("Skeletal " + UtilEnt.getName(event.GetEvent().getEntity())); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java index 4914d7264..065bfb462 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java @@ -1,8 +1,43 @@ package nautilus.game.arcade.kit.perks; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +import net.minecraft.server.v1_8_R3.EntityCreature; +import net.minecraft.server.v1_8_R3.NavigationAbstract; + +import org.bukkit.DyeColor; +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWolf; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; + import mineplex.core.common.Rank; -import mineplex.core.common.util.*; -import mineplex.core.disguise.disguises.DisguiseAnimalBase; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.SpigotUtil; +import mineplex.core.common.util.UtilAction; +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.disguise.disguises.DisguiseGuardian; import mineplex.core.disguise.disguises.DisguiseSquid; import mineplex.core.gadget.GadgetManager; @@ -12,28 +47,8 @@ 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.kit.Perk; -import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.NavigationAbstract; -import org.bukkit.DyeColor; -import org.bukkit.EntityEffect; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWolf; -import org.bukkit.entity.*; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; +import nautilus.game.arcade.kit.Perk; public class PerkWolfPet extends Perk { @@ -382,8 +397,8 @@ public class PerkWolfPet extends Perk Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseSquid); return; } - DisguiseAnimalBase disguiseAnimal = new DisguiseAnimalBase(entityType, wolf); - Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseAnimal); + /*DisguiseAnimalBase disguiseAnimal = new DisguiseAnimalBase(entityType, wolf); // TODO: what does this even do? + Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseAnimal);*/ } } From 684432d7dcd023a4ba1b652ff834d48b91acfb96 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 17 Nov 2016 00:59:24 +0000 Subject: [PATCH 34/56] Add Rules Command (#272) * Added a /rules command * Remove unused space * More Spaces! --- .../core/punish/Command/RulesCommand.java | 26 +++++++++++++++++++ .../src/mineplex/core/punish/Punish.java | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/punish/Command/RulesCommand.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/RulesCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/RulesCommand.java new file mode 100644 index 000000000..7e043c09b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/RulesCommand.java @@ -0,0 +1,26 @@ +package mineplex.core.punish.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.punish.Punish; + +public class RulesCommand extends CommandBase +{ + + private static final String RULES_MESSAGE = "The rules can be found here:" + C.cGreen + " www.mineplex.com/rules"; + + public RulesCommand(Punish plugin) + { + super(plugin, Rank.ALL, "rules"); + } + + @Override + public void Execute(Player caller, String[] args) + { + caller.sendMessage(F.main("Rules", RULES_MESSAGE)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index 69fcedb27..4575de030 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -30,6 +30,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.punish.Command.PunishCommand; +import mineplex.core.punish.Command.RulesCommand; import mineplex.core.punish.Tokens.PunishClientToken; import mineplex.core.punish.Tokens.PunishmentToken; import mineplex.core.updater.UpdateType; @@ -62,6 +63,7 @@ public class Punish extends MiniPlugin public void addCommands() { addCommand(new PunishCommand(this)); + addCommand(new RulesCommand(this)); } @EventHandler From 8d6eb135047b127fa623e9d2c183313fcc9fbdf7 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 17 Nov 2016 01:10:16 +0000 Subject: [PATCH 35/56] Add "%player% is your teammate" in 2 player team games (#273) * Add "%player% is your teammate" in 2 player team games * Add to Team Skyfall --- .../src/nautilus/game/arcade/game/Game.java | 3 + .../game/games/skyfall/TeamSkyfall.java | 1 + .../game/games/skywars/TeamSkywars.java | 1 + .../game/games/smash/TeamSuperSmash.java | 58 +------------------ .../survivalgames/TeamSurvivalGames.java | 1 + .../arcade/managers/GamePlayerManager.java | 57 +++++++++++++++++- 6 files changed, 65 insertions(+), 56 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 153a260f0..430870814 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 @@ -362,6 +362,9 @@ public abstract class Game implements Listener public boolean TeamMode = false; public boolean TeamPerSpawn = false; + + // Used for "%player% is your teammate" + public boolean ShowTeammateMessage = false; public boolean ForceTeamSize = true; public int PlayersPerTeam = 2; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java index ef02c6deb..05fe70127 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java @@ -40,6 +40,7 @@ public class TeamSkyfall extends Skyfall DontAllowOverfill = true; TeamMode = true; + ShowTeammateMessage = true; HideTeamSheep = true; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java index 74ed0a76a..ead56b27c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java @@ -67,6 +67,7 @@ public class TeamSkywars extends Skywars TeamMode = true; TeamPerSpawn = true; + ShowTeammateMessage = true; registerModule(new TeamModule()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java index c6414d5fd..d142b1471 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java @@ -6,18 +6,15 @@ import java.util.List; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.scheduler.BukkitRunnable; import mineplex.core.common.Pair; import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilTextMiddle; 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.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.modules.TeamModule; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -40,12 +37,12 @@ public class TeamSuperSmash extends SuperSmash SpawnNearAllies = true; DamageTeamSelf = false; - TeamArmorHotbar = true; - DontAllowOverfill = true; TeamMode = true; - + TeamArmorHotbar = true; + ShowTeammateMessage = true; + registerModule(new TeamModule()); registerStatTrackers(new WinWithoutDyingStatTracker(this, "MLGPro"), new FreeKitWinStatTracker(this), new OneVThreeStatTracker(this), new KillFastStatTracker(this, 3, 10, "TripleKill"), @@ -99,55 +96,6 @@ public class TeamSuperSmash extends SuperSmash Scoreboard.draw(); } - - @Override - @EventHandler - public void gameStart(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - { - return; - } - - super.gameStart(event); - - new BukkitRunnable() - { - - @Override - public void run() - { - for (Player player : GetPlayers(true)) - { - GameTeam team = GetTeam(player); - Player bestTeamMember = null; - - if (team == null) - { - continue; - } - - for (Player teamMember : team.GetPlayers(true)) - { - if (player.equals(teamMember)) - { - continue; - } - - bestTeamMember = teamMember; - } - - if (bestTeamMember == null) - { - UtilTextMiddle.display(C.cRedB + "No one", "You don\'t have a teammate :(", 10, 50, 10, player); - return; - } - - UtilTextMiddle.display(null, team.GetColor() + bestTeamMember.getName() + " is your teammate", 10, 50, 10, player); - } - } - }.runTaskLater(Manager.getPlugin(), 40); - } @EventHandler public void onCustomDamage(CustomDamageEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java index f6c6b1820..229a38aef 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java @@ -48,6 +48,7 @@ public class TeamSurvivalGames extends SurvivalGames DontAllowOverfill = true; TeamMode = true; + ShowTeammateMessage = true; registerModule(new TeamModule()); 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 efa539be2..d75c0f38f 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 @@ -6,6 +6,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTabTitle; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.party.PartyManager; import mineplex.core.recharge.Recharge; @@ -16,6 +17,7 @@ import mineplex.minecraft.game.core.condition.Condition.ConditionType; 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.Game; import nautilus.game.arcade.game.Game.GameState; @@ -44,10 +46,13 @@ import java.util.ArrayList; public class GamePlayerManager implements Listener { ArcadeManager Manager; + + private static final int TEAMMATE_MESSAGE_DELAY = 40; + private static final long PLAYER_VISIBILITY_REFRESH_RATE = 30000; private static final int VIEW_DISTANCE_BLOCK_VALUE = 8; private long _lastVisibilityRefresh = 0; - + public GamePlayerManager(ArcadeManager manager) { Manager = manager; @@ -418,4 +423,54 @@ public class GamePlayerManager implements Listener player.teleport(target); } } + + @EventHandler + public void sendTeammateDetails(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + Game game = Manager.GetGame(); + + if (!game.ShowTeammateMessage || game.GetTeamList().size() == 1) + { + return; + } + + Manager.runSyncLater(() -> { + + for (Player player : game.GetPlayers(true)) + { + GameTeam team = game.GetTeam(player); + Player bestTeamMember = null; + + if (team == null) + { + continue; + } + + for (Player teamMember : team.GetPlayers(true)) + { + if (player.equals(teamMember)) + { + continue; + } + + bestTeamMember = teamMember; + } + + if (bestTeamMember == null) + { + UtilTextMiddle.display(C.cRedB + "No one", "You don\'t have a teammate :(", 10, 50, 10, player); + return; + } + + UtilTextMiddle.display(null, team.GetColor() + bestTeamMember.getName() + " is your teammate", 10, 50, 10, player); + } + + }, TEAMMATE_MESSAGE_DELAY); + } + } \ No newline at end of file From 0039b7928189f98cb7cbc742eeb0599bbbe431fd Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Wed, 16 Nov 2016 20:23:14 -0500 Subject: [PATCH 36/56] Change Youtube Button Link (#275) * Fix possible NPE in Preferences * Change youtube button link --- .../src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java | 4 ++-- .../src/mineplex/core/preferences/PreferencesManager.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java index 477fa382d..cab491f83 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/YoutubeButton.java @@ -85,8 +85,8 @@ public class YoutubeButton implements GuiItem UtilPlayer.message(_player, C.cGold + C.Bold + C.Strike + "============================================="); UtilPlayer.message(_player, ""); - new JsonMessage(" " + C.Bold + "Click to Open in Web Browser and " + message).click(ClickEvent.OPEN_URL, "https://www.youtube.com/embed/RW3sOmkiEG-A?list=UU1MtBclG_aHPd0nLmUupCKg&controls=0&showinfo=0&autoplay=1").sendToPlayer(_player); - new JsonMessage( " " + C.cGreen + C.Line + "http://youtube.com/mineplexgamesofficial").click(ClickEvent.OPEN_URL, "https://www.youtube.com/embed/RW3sOmkiEG-A?list=UU1MtBclG_aHPd0nLmUupCKg&controls=0&showinfo=0&autoplay=1").sendToPlayer(_player); + new JsonMessage(" " + C.Bold + "Click to Open in Web Browser and " + message).click(ClickEvent.OPEN_URL, "http://file.mineplex.com/ads.php").sendToPlayer(_player); + new JsonMessage( " " + C.cGreen + C.Line + "http://youtube.com/mineplexgamesofficial").click(ClickEvent.OPEN_URL, "http://file.mineplex.com/ads.php").sendToPlayer(_player); UtilPlayer.message(_player, ""); UtilPlayer.message(_player, C.cGold + C.Bold + C.Strike + "============================================="); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java index ca98268ad..15a9d01ff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java @@ -65,7 +65,8 @@ public class PreferencesManager extends MiniPlugin implements ILoginProcessor { Player player = event.getPlayer(); int accountId = _clientManager.getAccountId(player); - _repository.saveUserPreferences(_preferences.remove(accountId)); + UserPreferences p = _preferences.remove(accountId); + if (p != null) _repository.saveUserPreferences(p); } @EventHandler From 735550c157bc1caaea200f30e3d0a89e563b1a5d Mon Sep 17 00:00:00 2001 From: md-5 Date: Thu, 17 Nov 2016 12:29:33 +1100 Subject: [PATCH 37/56] Use Mineplex Pair Util Class in Halloween 2016 (#274) JavaFX is not included in OpenJDK. --- .../arcade/game/games/halloween2016/Halloween2016.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java index 4fef083cc..d868e9164 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java @@ -23,6 +23,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import mineplex.core.common.Pair; import mineplex.core.common.animation.AnimationPoint; import mineplex.core.common.animation.Animator; import mineplex.core.common.animation.AnimatorFactory; @@ -38,7 +39,6 @@ import mineplex.core.reward.rewards.PetReward; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import javafx.util.Pair; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -139,8 +139,8 @@ public class Halloween2016 extends Halloween _lockAllPlayers = null; for(Entry> e : _playerPreLockData.entrySet()) { - e.getKey().teleport(e.getValue().getKey()); - e.getKey().setGameMode(e.getValue().getValue()); + e.getKey().teleport(e.getValue().getLeft()); + e.getKey().setGameMode(e.getValue().getRight()); if(IsAlive(e.getKey())) { UtilPlayer.showForAll(e.getKey()); @@ -171,7 +171,7 @@ public class Halloween2016 extends Halloween { if(!_playerPreLockData.containsKey(p)) { - _playerPreLockData.put(p, new Pair(p.getLocation(), p.getGameMode())); + _playerPreLockData.put(p, Pair.create(p.getLocation(), p.getGameMode())); p.setGameMode(GameMode.SPECTATOR); } p.teleport(_lockAllPlayers); From 4709161180c92dd4ed21e9405ce248c60665d551 Mon Sep 17 00:00:00 2001 From: Sam Sun Date: Wed, 16 Nov 2016 21:40:42 -0500 Subject: [PATCH 38/56] Attempt to fix CTF Proxies (#280) --- .../nautilus/game/arcade/ArcadeManager.java | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) 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 76f7a3669..798662f66 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -190,6 +190,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation //Champions Modules private boolean _enabled = true; + private Boolean _registered = null; private ClassManager _classManager; private SkillFactory _skillFactory; private ItemFactory _itemFactory; @@ -1723,40 +1724,43 @@ public class ArcadeManager extends MiniPlugin implements IRelation public void enableChampionsModules() { - _classManager.setEnabled(true); - _classShopManager.registerSelf(); - _skillFactory.registerSelf(); - _itemFactory.registerSelf(); - _energy.registerSelf(); - _eloManager.registerSelf(); + if (_registered == null || !_registered) + { + _classManager.setEnabled(true); + _classShopManager.registerSelf(); + _skillFactory.registerSelf(); + _itemFactory.registerSelf(); + _energy.registerSelf(); + _eloManager.registerSelf(); - //Class Shop - _plugin.getServer().getPluginManager().registerEvents(_classShop, _plugin); + //Class Shop + _plugin.getServer().getPluginManager().registerEvents(_classShop, _plugin); + + _registered = true; + } } public void disableChampionsModules() { - _classManager.setEnabled(false); - _classShopManager.deregisterSelf(); - _skillFactory.deregisterSelf(); - _itemFactory.deregisterSelf(); - _energy.deregisterSelf(); - _eloManager.deregisterSelf(); + if (_registered != null && _registered) + { + _classManager.setEnabled(false); + _classShopManager.deregisterSelf(); + _skillFactory.deregisterSelf(); + _itemFactory.deregisterSelf(); + _energy.deregisterSelf(); + _eloManager.deregisterSelf(); - //Class Shop - HandlerList.unregisterAll(_classShop); + //Class Shop + HandlerList.unregisterAll(_classShop); + _registered = false; + } } public void toggleChampionsModules(GameType gameType) { boolean isChamps = gameType == GameType.ChampionsDominate || gameType == GameType.ChampionsTDM || gameType == GameType.ChampionsCTF || gameType == GameType.BossBattles; - if (_enabled == isChamps) - { - System.out.println("----------Champions Modules are still " + isChamps); - return; - } - System.out.println("----------Champions Modules set to " + isChamps); _enabled = isChamps; From 4cb257e84a2459560d88b6e79dccb06d0a12d9a5 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 27 Oct 2016 05:28:46 -0400 Subject: [PATCH 39/56] Tweak blocked commands system --- .../src/mineplex/core/command/CommandCenter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java index db7597b9d..db1f8d113 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java @@ -2,6 +2,7 @@ package mineplex.core.command; import com.google.common.collect.Lists; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -22,7 +23,7 @@ public class CommandCenter implements Listener protected CoreClientManager ClientManager; protected static NautHashMap Commands; private final List BLOCKED_COMMANDS = Lists.newArrayList("pl", "plugins", "ver", "version", "icanhasbukkit"); - private final String MESSAGE = C.cRed + "I''m sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error."; + private final String MESSAGE = C.cRed + "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error."; public static void Initialize(JavaPlugin plugin) { @@ -59,7 +60,7 @@ public class CommandCenter implements Listener args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" "); } - if(BLOCKED_COMMANDS.contains(commandName.toLowerCase())) + if (BLOCKED_COMMANDS.contains(commandName.toLowerCase()) && !(event.getPlayer().isOp() || ClientManager.Get(event.getPlayer()).GetRank().has(Rank.DEVELOPER))) { event.setCancelled(true); event.getPlayer().sendMessage(MESSAGE); From d5f89bb37099462375227e8f3bf4b106b35e22ed Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 27 Oct 2016 05:36:17 -0400 Subject: [PATCH 40/56] Add more blocked commands and move the blocked command handler below the Mineplex command executor --- .../src/mineplex/core/command/CommandCenter.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java index db1f8d113..0a42176bf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java @@ -22,7 +22,7 @@ public class CommandCenter implements Listener protected JavaPlugin Plugin; protected CoreClientManager ClientManager; protected static NautHashMap Commands; - private final List BLOCKED_COMMANDS = Lists.newArrayList("pl", "plugins", "ver", "version", "icanhasbukkit"); + private final List BLOCKED_COMMANDS = Lists.newArrayList("pl", "plugins", "ver", "version", "icanhasbukkit", "about", "?", "help"); private final String MESSAGE = C.cRed + "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error."; public static void Initialize(JavaPlugin plugin) @@ -60,13 +60,6 @@ public class CommandCenter implements Listener args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" "); } - if (BLOCKED_COMMANDS.contains(commandName.toLowerCase()) && !(event.getPlayer().isOp() || ClientManager.Get(event.getPlayer()).GetRank().has(Rank.DEVELOPER))) - { - event.setCancelled(true); - event.getPlayer().sendMessage(MESSAGE); - return; - } - ICommand command = Commands.get(commandName.toLowerCase()); if (command != null) @@ -86,6 +79,13 @@ public class CommandCenter implements Listener command.Execute(event.getPlayer(), args); } } + + if (BLOCKED_COMMANDS.contains(commandName.toLowerCase()) && !(event.getPlayer().isOp() || ClientManager.Get(event.getPlayer()).GetRank().has(Rank.DEVELOPER))) + { + event.setCancelled(true); + event.getPlayer().sendMessage(MESSAGE); + return; + } } From 824ef685c0539b1144f223b48fe145e6a9eef9e3 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 27 Oct 2016 05:37:19 -0400 Subject: [PATCH 41/56] Add missing return --- .../Mineplex.Core/src/mineplex/core/command/CommandCenter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java index 0a42176bf..92301a0e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java @@ -78,6 +78,7 @@ public class CommandCenter implements Listener command.SetAliasUsed(commandName.toLowerCase()); command.Execute(event.getPlayer(), args); } + return; } if (BLOCKED_COMMANDS.contains(commandName.toLowerCase()) && !(event.getPlayer().isOp() || ClientManager.Get(event.getPlayer()).GetRank().has(Rank.DEVELOPER))) From 0070fed6c79d2df2db594b3c3c7dbcb48e7e4215 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 29 Oct 2016 11:05:36 -0400 Subject: [PATCH 42/56] Fix playwire multithreading and convert to new 5-ticket per 24-hour system --- .../mineplex/core/bonuses/BonusManager.java | 6 +- .../bonuses/gui/buttons/PlayWireButton.java | 6 +- .../core/playwire/PlayWireClientData.java | 63 ++++------- .../core/playwire/PlayWireManager.java | 107 ++++++++++++------ .../core/playwire/PlayWireRepository.java | 59 ++++++---- .../mineplex/core/playwire/ResponseType.java | 20 ++-- .../src/mineplex/clanshub/HubManager.java | 2 +- .../src/mineplex/hub/HubManager.java | 2 +- .../nautilus/game/arcade/ArcadeManager.java | 2 +- 9 files changed, 153 insertions(+), 114 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 82829872e..3ab6b1292 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -677,8 +677,8 @@ public class BonusManager extends MiniClientPlugin implements I BonusClientData client = Get(player); int availableRewards = 0; - - if (_playWireManager.canRedeem(player)) availableRewards++; + + if (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() == -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) availableRewards++; if (_youtubeManager.canYoutube(player)) availableRewards++; if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++; if (canDaily(player)) availableRewards++; @@ -839,7 +839,7 @@ public class BonusManager extends MiniClientPlugin implements I { if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false)) { - if(_pollManager.hasPoll(player) || _playWireManager.canRedeem(player) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) + if(_pollManager.hasPoll(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() == -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) { if(_showCarl.containsKey(player.getName())) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java index a427b793b..95b989e9b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java @@ -61,7 +61,11 @@ public class PlayWireButton implements GuiItem @Override public ItemStack getObject() { - return _manager.canRedeem(_player) ? ENABLED_ICON : DISABLED_ICON; + if (_manager.Get(_player) == null || _manager.Get(_player).getAccountId() == -1) + { + return DISABLED_ICON; + } + return _manager.canRedeemTickets(_manager.Get(_player)) ? ENABLED_ICON : DISABLED_ICON; } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireClientData.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireClientData.java index 109131f5e..c5513684e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireClientData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireClientData.java @@ -1,53 +1,40 @@ package mineplex.core.playwire; -import mineplex.core.common.util.UtilTime.TimeUnit; - -/** - * - */ public class PlayWireClientData { + private int _accountId; + private int _ticketsRemaining; + private long _ticketRefresh; - private long _redeemTime; - private int _streak; - - public PlayWireClientData(long date) + public PlayWireClientData(int accountId, int ticketsRemaining, long ticketRefresh) { - _redeemTime = date; - long curr = System.currentTimeMillis(); - - if (_redeemTime <= 0) - { - _streak = 0; - } + _accountId = accountId; + _ticketsRemaining = ticketsRemaining; + _ticketRefresh = ticketRefresh; } - - public long getRedeemTime() + + public int getAccountId() { - return _redeemTime; + return _accountId; } - - public void setRedeemTime(long date) + + public int getTicketsRemaining() { - long old = _redeemTime; - _redeemTime = date; - - if (_redeemTime - old > TimeUnit.DAYS.getMilliseconds() * 2) - { - _streak = 0; - } else - { - setStreak(getStreak() + 1); - } + return _ticketsRemaining; } - - public int getStreak() + + public long getTicketRefresh() { - return _streak; + return _ticketRefresh; } - - public void setStreak(int streak) + + public void setTicketsRemaining(int ticketsRemaining) { - _streak = streak; + _ticketsRemaining = ticketsRemaining; } -} + + public void setTicketRefresh(long ticketRefresh) + { + _ticketRefresh = ticketRefresh; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java index 631ffc7ec..f86f8aaee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java @@ -4,10 +4,13 @@ import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; @@ -16,72 +19,100 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.bonuses.BonusManager; 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.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.donation.DonationManager; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.treasure.TreasureType; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.database.DBPool; -/** - * - */ public class PlayWireManager extends MiniDbClientPlugin { - - private final long COOL_DOWN = TimeUnit.HOURS.getMilliseconds(); + private static final int MAX_TICKETS_PER_PERIOD = 5; + private final long COOL_DOWN = TimeUnit.HOURS.getMilliseconds() * 24; private static final int REWARD_MESSAGE_DELAY_SECONDS = 10; private final CoreClientManager _clientManager; - private final DonationManager _donationManager; private final PlayWireRepository _repository; - public PlayWireManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) + public PlayWireManager(JavaPlugin plugin, CoreClientManager clientManager) { super("PlayWire", plugin, clientManager); _clientManager = clientManager; - _donationManager = donationManager; _repository = new PlayWireRepository(this); getPlugin().getCommand("playwire").setExecutor(new PlayWireCommand(this)); } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + final Map update = new HashMap<>(); + Bukkit.getOnlinePlayers().stream().filter(player -> Get(player) != null && Get(player).getAccountId() != -1 && Get(player).getTicketRefresh() != -1 && Get(player).getTicketRefresh() < System.currentTimeMillis()).forEach(player -> + { + PlayWireClientData data = Get(player); + data.setTicketRefresh(-1); + data.setTicketsRemaining(MAX_TICKETS_PER_PERIOD); + update.put(data, player); + }); + + if (!update.isEmpty()) + { + runAsync(() -> + { + update.entrySet().forEach(entry -> + { + PlayWireClientData data = entry.getKey(); + _repository.attemptPlayWire(data, () -> + { + UtilPlayer.message(entry.getValue(), F.main("Carl", "Your Ad Ticketssssss have refresssshed! Come ssssee me for ssssome " + F.elem("Spin Tickets") + "!")); + }, false); + }); + + update.clear(); + }); + } + } @Override public String getQuery(int accountId, String uuid, String name) { - return "SELECT `redeemed`, `streak` FROM `play_wire` WHERE `accountId`=" + accountId + ";"; + return "SELECT ticketsRemaining, ticketRefresh FROM play_wire WHERE accountId=" + accountId + ";"; } - public boolean canRedeem(Player player) + public boolean canRedeemTickets(PlayWireClientData data) { - PlayWireClientData data = Get(player); long now = System.currentTimeMillis(); - return data == null || data.getRedeemTime() == -1 || (now - data.getRedeemTime()) > COOL_DOWN; + return data == null || data.getTicketRefresh() >= now || data.getTicketsRemaining() <= 0; } public void attemptRedeem(Player player) { - if (!canRedeem(player)) + final PlayWireClientData client = Get(player); + if (client == null || client.getAccountId() == -1) { - player.sendMessage(ResponseType.UNCOUNTED.getMessage()); + player.sendMessage(ResponseType.UNFILLED.getMessage()); return; } - - PlayWireClientData client = Get(player); - client.setRedeemTime(System.currentTimeMillis()); - if(client.getStreak() == 7) + if (!canRedeemTickets(client)) { - // - Managers.get(InventoryManager.class).addItemToInventory(player, TreasureType.ANCIENT.getItemName(), 1); - } else if(client.getStreak() == 14) - { - Managers.get(InventoryManager.class).addItemToInventory(player, TreasureType.ANCIENT.getItemName(), 1); - client.setStreak(0); + player.sendMessage(ResponseType.UNCOUNTED.getMessage(UtilTime.MakeStr(client.getTicketRefresh() - System.currentTimeMillis()))); + return; } - - _repository.attemptPlayWire(player, client, () -> + + if (client.getTicketsRemaining() >= MAX_TICKETS_PER_PERIOD) + { + client.setTicketRefresh(System.currentTimeMillis() + COOL_DOWN); + } + client.setTicketsRemaining(Math.max(client.getTicketsRemaining() - 1, 0)); + + _repository.attemptPlayWireAsync(client, () -> { - _donationManager.RewardCoinsLater("Watching Ad", player, 100); final int accountId = _clientManager.Get(player).getAccountId(); final Callback ticketCallback = new Callback() { @@ -118,7 +149,7 @@ public class PlayWireManager extends MiniDbClientPlugin } }); Managers.get(BonusManager.class).addPendingExplosion(player, player.getName()); - Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, ResponseType.COUNTED.getMessage()), REWARD_MESSAGE_DELAY_SECONDS * 20L); + Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, ResponseType.COUNTED.getMessage(client.getTicketsRemaining() + "")), REWARD_MESSAGE_DELAY_SECONDS * 20L); }); } @@ -151,18 +182,20 @@ public class PlayWireManager extends MiniDbClientPlugin boolean hasRow = resultSet.next(); if (hasRow) { - PlayWireClientData client = new PlayWireClientData(resultSet.getLong(1)); - client.setStreak(resultSet.getInt(2)); + PlayWireClientData client = new PlayWireClientData(accountId, resultSet.getInt("ticketsRemaining"), resultSet.getLong("ticketRefresh")); Set(uuid, client); - } else + } + else { - Set(uuid, new PlayWireClientData(-1)); + PlayWireClientData client = new PlayWireClientData(accountId, MAX_TICKETS_PER_PERIOD, -1L); + Set(uuid, client); + _repository.attemptPlayWire(client, null, false); } } @Override protected PlayWireClientData addPlayer(UUID uuid) { - return new PlayWireClientData(-1); + return new PlayWireClientData(-1, -1, -1); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireRepository.java index 0b138e4d9..cb97496bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireRepository.java @@ -1,20 +1,14 @@ package mineplex.core.playwire; -import mineplex.serverdata.database.DBPool; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -/** - * Totally original code I wrote, did not copy it from YouTubeRepo, no sir. - */ +import mineplex.serverdata.database.DBPool; + public class PlayWireRepository { - - private static final String INSERT_LAST_REDEEMED = "INSERT INTO `play_wire` VALUES(?,?,?) ON DUPLICATE KEY UPDATE `redeemed` = ?, `streak` = ?"; + private static final String INSERT_LAST_REDEEMED = "INSERT INTO play_wire (accountId, ticketsRemaining, ticketRefresh) VALUES (?,?,?) ON DUPLICATE KEY UPDATE ticketsRemaining=VALUES(ticketsRemaining), ticketRefresh=VALUES(ticketRefresh)"; private final PlayWireManager _manager; @@ -22,31 +16,46 @@ public class PlayWireRepository { _manager = manager; } - - public void attemptPlayWire(Player player, PlayWireClientData client, Runnable runnable) + + public void attemptPlayWire(final PlayWireClientData client, final Runnable runnable, boolean forceAsync) { - int accountId = _manager.getClientManager().Get(player).getAccountId(); - - Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), () -> + if (client.getAccountId() == -1) + { + return; + } + Runnable doSQL = () -> { try (Connection connection = DBPool.getAccount().getConnection()) { PreparedStatement statement = connection.prepareStatement(INSERT_LAST_REDEEMED); - statement.setInt(1, accountId); - statement.setLong(2, client.getRedeemTime()); - statement.setInt(3, client.getStreak()); - statement.setLong(4, client.getRedeemTime()); - statement.setInt(5, client.getStreak()); + statement.setInt(1, client.getAccountId()); + statement.setInt(2, client.getTicketsRemaining()); + statement.setLong(3, client.getTicketRefresh()); statement.executeUpdate(); - - runnable.run(); - } catch (SQLException e) + + if (runnable != null) + { + _manager.runSync(runnable); + } + } + catch (SQLException e) { e.printStackTrace(); } - }); + }; + if (forceAsync) + { + _manager.runAsync(doSQL); + } + else + { + doSQL.run(); + } } - -} + public void attemptPlayWireAsync(final PlayWireClientData client, final Runnable runnable) + { + attemptPlayWire(client, runnable, false); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java index e35d18c62..06ebbb413 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java @@ -7,9 +7,8 @@ import mineplex.core.common.util.F; */ public enum ResponseType { - - COUNTED(F.main("Carl", "Rewarded " + F.elem("100 Treasure Shards") + " and " + F.elem("1 Carl Spin Ticket") + " for watching the Ad")), - UNCOUNTED(F.main("Carl", "You already watched the Ad within the past hour!")), + COUNTED(F.main("Carl", "Rewarded " + F.elem("1 Carl Spin Ticket") + " for watching the Ad! %elem% tickets remaining for the current 24 hour period!")), + UNCOUNTED(F.main("Carl", "You already received your 5 " + F.elem("Carl Spin Tickets") + " for the current 24 hours! Your available tickets will refresh in %elem%!")), BLOCKED(F.main("Carl", "You have an AdBlocker on, but tried to watch the Ad! Ssssssslight problem there!")), UNFILLED(F.main("Carl", "Ssssomething went wrong with the Ad, we'll get it sorted ASAP.")),; @@ -20,9 +19,16 @@ public enum ResponseType _message = message; } - public String getMessage() + public String getMessage(String... elements) { - return _message; + String message = _message; + if (elements.length > 0) + { + for (int i = 0; i < elements.length; i++) + { + message = message.replaceFirst("%elem%", elements[i]); + } + } + return message; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index 138afe4b1..44ce0a05f 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -190,7 +190,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); - PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager, donationManager); + PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager); _bonusManager = new BonusManager(plugin, null, playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager); World world = _spawn.getWorld(); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index fdba4cb6c..50eb8abc6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -218,7 +218,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); - PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager, donationManager); + PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager); _bonusManager = new BonusManager(plugin, null, playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager); 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 798662f66..811cc6730 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -336,7 +336,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation new GameStatManager(this); FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); - PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager, donationManager); + PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager); _bonusManager = new BonusManager(plugin, _gameLobbyManager.getCarl(), playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _cosmeticManager.getGadgetManager(), thankManager); new GameLootManager(this, petManager, _bonusManager.getRewardManager()); From b374d728f54e5208c7fa17bcfbf4dce5b6edcebc Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 11 Nov 2016 21:59:59 -0500 Subject: [PATCH 43/56] Change playwire button, modify player messages, and fix availability bugs --- .../bonuses/gui/buttons/PlayWireButton.java | 20 +++++++++---------- .../core/playwire/PlayWireManager.java | 9 +++++++-- .../mineplex/core/playwire/ResponseType.java | 6 +++--- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java index 95b989e9b..ae4c59806 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PlayWireButton.java @@ -1,14 +1,15 @@ package mineplex.core.bonuses.gui.buttons; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.gui.GuiItem; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.playwire.PlayWireManager; import mineplex.core.recharge.Recharge; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; /** * @@ -20,11 +21,11 @@ public class PlayWireButton implements GuiItem .setTitle(C.cGreen + C.Bold + "Watch an Ad!") .addLore( C.cWhite + "You have already redeemed your", - C.cWhite + "rewards for watching the Ad!", + C.cWhite + "rewards for watching the Ads!", " ", - C.cWhite + "You can watch it again, but you won't earn any shards!", + C.cWhite + "You can watch some more, but you won't earn any rewards!", " ", - C.cWhite + "You can watch the Ad once every hour.", + C.cWhite + "You can watch 5 Ads every 24 hours.", " ", C.cWhite + "Ads help us keep Mineplex awesome", C.cRedB + "Be sure to have your AdBlocker disabled!", @@ -36,11 +37,10 @@ public class PlayWireButton implements GuiItem private static final ItemStack ENABLED_ICON = new ItemBuilder(Material.TRIPWIRE_HOOK) .setTitle(C.cGreen + C.Bold + "Watch an Ad!") .addLore( - C.cYellow + "Earn a 100 Shard Reward", - C.cYellow + "and 1 Carl Spin Ticket", + C.cYellow + "Earn 1 Carl Spin Ticket", C.cWhite + "by checking out our partner's Advertisement", " ", - C.cWhite + "You can watch the Ad once every hour.", + C.cWhite + "You can watch 5 Ads every 24 hours.", " ", C.cWhite + "Ads help us keep Mineplex awesome", C.cRedB + "Be sure to have your AdBlocker disabled!", diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java index f86f8aaee..017b3a0d1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/PlayWireManager.java @@ -87,8 +87,8 @@ public class PlayWireManager extends MiniDbClientPlugin public boolean canRedeemTickets(PlayWireClientData data) { long now = System.currentTimeMillis(); - - return data == null || data.getTicketRefresh() >= now || data.getTicketsRemaining() <= 0; + + return data == null || (data.getTicketRefresh() < now || data.getTicketRefresh() == -1) || data.getTicketsRemaining() > 0; } public void attemptRedeem(Player player) @@ -166,6 +166,11 @@ public class PlayWireManager extends MiniDbClientPlugin getPlugin().getLogger().severe("PLAY WIRE PLAYER NOT FOUND ERROR: PlayerName: " + target); return; } + + if (response == ResponseType.UNCOUNTED) + { + response = ResponseType.UNFILLED; + } if (response == ResponseType.COUNTED) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java index 06ebbb413..a823fde30 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java @@ -7,10 +7,10 @@ import mineplex.core.common.util.F; */ public enum ResponseType { - COUNTED(F.main("Carl", "Rewarded " + F.elem("1 Carl Spin Ticket") + " for watching the Ad! %elem% tickets remaining for the current 24 hour period!")), - UNCOUNTED(F.main("Carl", "You already received your 5 " + F.elem("Carl Spin Tickets") + " for the current 24 hours! Your available tickets will refresh in %elem%!")), + COUNTED(F.main("Carl", "Rewarded " + F.elem("1 Carl Spin Ticket") + " for watching the Ad! " + F.elem("%elem%") + " tickets remaining for the current 24 hour period!")), + UNCOUNTED(F.main("Carl", "You already received your " + F.elem("5 Carl Spin Tickets") + " for the current 24 hour period! Your available tickets will refresh in " + F.elem("%elem%") + "!")), BLOCKED(F.main("Carl", "You have an AdBlocker on, but tried to watch the Ad! Ssssssslight problem there!")), - UNFILLED(F.main("Carl", "Ssssomething went wrong with the Ad, we'll get it sorted ASAP.")),; + UNFILLED(F.main("Carl", "Ssssomething went wrong with the Ad, we'll get it ssssorted ASAP. Try again in a few minutessss!")),; private String _message; From c21e71606d70f9c2d52f9cd1caca0cf8ce89a2e5 Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Fri, 11 Nov 2016 22:10:22 -0500 Subject: [PATCH 44/56] Fix message line spacing for Prince Artix --- .../src/mineplex/core/playwire/ResponseType.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java b/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java index a823fde30..25f51ff47 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playwire/ResponseType.java @@ -7,7 +7,7 @@ import mineplex.core.common.util.F; */ public enum ResponseType { - COUNTED(F.main("Carl", "Rewarded " + F.elem("1 Carl Spin Ticket") + " for watching the Ad! " + F.elem("%elem%") + " tickets remaining for the current 24 hour period!")), + COUNTED(F.main("Carl", "Rewarded " + F.elem("1 Carl Spin Ticket") + " for watching the Ad! You have " + F.elem("%elem%") + " tickets remaining for the current 24 hour period!")), UNCOUNTED(F.main("Carl", "You already received your " + F.elem("5 Carl Spin Tickets") + " for the current 24 hour period! Your available tickets will refresh in " + F.elem("%elem%") + "!")), BLOCKED(F.main("Carl", "You have an AdBlocker on, but tried to watch the Ad! Ssssssslight problem there!")), UNFILLED(F.main("Carl", "Ssssomething went wrong with the Ad, we'll get it ssssorted ASAP. Try again in a few minutessss!")),; @@ -31,4 +31,4 @@ public enum ResponseType } return message; } -} \ No newline at end of file +} From 63ef68976c8b51bcd88b81e19a7b90cbcaeeed6e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 14 Oct 2016 17:14:47 -0400 Subject: [PATCH 45/56] Patch illusion in nether, stop cobble generation, lower rune drop rate, make tnt time based and better function in water, make scorching not damage teammates or those in safezones, make runed pickaxe more effective --- .../mineplex/game/clans/clans/ClansGame.java | 54 +++++++++++++++++++ .../clans/clans/nether/NetherManager.java | 27 ++++++++++ .../miniboss/NetherMinibossManager.java | 25 ++++++--- .../miniboss/bosses/ArcherMiniboss.java | 2 +- .../nether/miniboss/bosses/GhastMiniboss.java | 2 +- .../miniboss/bosses/WarriorMiniboss.java | 2 +- .../clans/siege/weapon/projectile/Crater.java | 3 +- .../weapon/projectile/WeaponProjectile.java | 2 +- .../attributes/bow/ScorchingAttribute.java | 4 ++ .../game/clans/items/rares/RunedPickaxe.java | 37 +++++++++++++ .../classcombat/Skill/Assassin/Illusion.java | 4 +- .../ClassCombatCreatureAllowSpawnEvent.java | 8 ++- 12 files changed, 154 insertions(+), 16 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 e1bf068c2..fafbc49fe 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 @@ -20,6 +20,8 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockPistonExtendEvent; @@ -61,6 +63,7 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansUtility.ClanRelation; +import mineplex.game.clans.clans.event.ClansWaterPlaceEvent; import mineplex.game.clans.clans.siege.weapon.projectile.event.CraterExplodeEvent; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -968,4 +971,55 @@ public class ClansGame extends MiniPlugin event.getInventory().addItem(new ItemBuilder(Material.TRAPPED_CHEST).setAmount(stack.getAmount()).setTitle(C.cDGray + "Safe").build()); } } + + @EventHandler(ignoreCancelled=true) + public void onBlockDispense(BlockDispenseEvent event) + { + if (event.getItem().getType() == Material.WATER_BUCKET || event.getItem().getType() == Material.LAVA_BUCKET || event.getItem().getType() == Material.BUCKET) + { + event.setCancelled(true); + } + } + + @EventHandler + public void noMonsterLava(BlockFromToEvent event) + { + Block block = event.getBlock(); + if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA || block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) + { + Block next = event.getToBlock(); + for (BlockFace bf : BlockFace.values()) + { + if (!next.getRelative(bf).equals(block)) + { + if (block.getType().toString().contains("LAVA")) + { + if (next.getRelative(bf).getType().toString().contains("WATER")) + { + event.setCancelled(true); + } + } + if (block.getType().toString().contains("WATER")) + { + if (next.getRelative(bf).getType().toString().contains("LAVA")) + { + event.setCancelled(true); + } + } + } + } + } + } + + @EventHandler + public void onUseWater(ClansWaterPlaceEvent event) + { + for (BlockFace bf : BlockFace.values()) + { + if (event.getBlock().getRelative(bf).getType().toString().contains("LAVA")) + { + event.setCancelled(true); + } + } + } } \ No newline at end of file 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 a14a74b58..dbf3a3a91 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 @@ -3,6 +3,7 @@ package mineplex.game.clans.clans.nether; import java.util.Comparator; import java.util.HashMap; import java.util.List; +import java.util.Random; import org.bukkit.Bukkit; import org.bukkit.GameMode; @@ -20,6 +21,7 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityPortalEvent; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPortalEvent; @@ -529,4 +531,29 @@ public class NetherManager extends MiniPlugin spawnBossPortal(event.getCreature().getEvent().getCenterLocation().clone().subtract(0, 1, 0)); } } + + @EventHandler + public void onCommand(PlayerCommandPreprocessEvent event) + { + if (event.getMessage().toUpperCase().startsWith("/TRYDOUBLES") && event.getPlayer().isOp()) + { + int mult = 1; + if (event.getMessage().toUpperCase().equalsIgnoreCase("/TRYDOUBLES 2")) + { + mult = 2; + } + if (event.getMessage().toUpperCase().equalsIgnoreCase("/TRYDOUBLES 3")) + { + mult = 3; + } + for (int i = 0; i < 100 * mult; i++) + { + double d = new Random().nextDouble(); + if (d <= 0.075) + { + Bukkit.broadcastMessage("FOUND ONE - " + d); + } + } + } + } } \ No newline at end of file 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 5f28115a4..3909e69c5 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 @@ -4,12 +4,6 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.nether.NetherManager; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -21,6 +15,13 @@ import org.bukkit.event.world.ChunkUnloadEvent; import com.google.common.collect.Lists; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.nether.NetherManager; +import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent; + /** * Manager to handle miniboss spawning in the nether */ @@ -31,6 +32,7 @@ public class NetherMinibossManager implements Listener private HashMap _spawns = new HashMap<>(); private long _lastSpawned; private boolean _allowSpawn = false; + private boolean _allowSpawnEvent = false; public NetherMinibossManager(NetherManager manager) { @@ -83,12 +85,21 @@ public class NetherMinibossManager implements Listener _allowSpawn = false; } + @EventHandler + public void onAllowSpawn(ClassCombatCreatureAllowSpawnEvent event) + { + if (event.getWorldName().equalsIgnoreCase(_manager.getNetherWorld().getName())) + { + _allowSpawnEvent = event.getAllowed(); + } + } + @EventHandler public void onSpawnNormal(EntitySpawnEvent event) { if (event.getEntity() instanceof LivingEntity && _manager.getNetherWorld().equals(event.getLocation().getWorld())) { - if (!_allowSpawn) + if (!_allowSpawn && !_allowSpawnEvent) { event.setCancelled(true); } 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 72ce7c439..380a95964 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 @@ -34,7 +34,7 @@ import org.bukkit.potion.PotionEffectType; public class ArcherMiniboss extends NetherMiniBoss { private static final int BARBED_LEVEL = 1; - private static final double RUNE_DROP_CHANCE = .1; + private static final double RUNE_DROP_CHANCE = .075; private static final int MAX_DIAMOND_DROPS = 5; 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 45133db1c..6edd6a985 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 @@ -31,7 +31,7 @@ public class GhastMiniboss extends NetherMiniBoss private static final long MAIN_FIREBALL_COOLDOWN = 5000; private static final long FIREBALL_LAUNCH_RATE = 500; private static final int FIREBALLS_PER_USE = 5; - private static final double RUNE_DROP_CHANCE = .1; + private static final double RUNE_DROP_CHANCE = .075; private static final int MAX_DIAMOND_DROPS = 5; private static final double MAX_TARGET_RANGE = 25; private long _lastFireballUse; 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 df682506a..6140e43e0 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 @@ -32,7 +32,7 @@ import org.bukkit.potion.PotionEffectType; */ public class WarriorMiniboss extends NetherMiniBoss { - private static final double RUNE_DROP_CHANCE = .1; + private static final double RUNE_DROP_CHANCE = .075; private static final int MAX_DIAMOND_DROPS = 5; private static final double LEAP_CHANCE = .9; private static final double LEAP_MIN_DIST = 3; 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 d3c8049af..0b78bfa26 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 @@ -3,7 +3,6 @@ package mineplex.game.clans.clans.siege.weapon.projectile; import java.util.HashMap; import java.util.List; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -44,7 +43,7 @@ public class Crater { List blocks = Lists.newArrayList(); List noRepeats = Lists.newArrayList(); - for (Block block : UtilBlock.getExplosionBlocks(_origin, 2.6f, false)) + for (Block block : UtilBlock.getInRadius(_origin, 3).keySet()) { String locID = block.getLocation().getX() + " " + block.getLocation().getY() + " " + block.getLocation().getZ(); if (noRepeats.contains(locID)) 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 a305dfd20..75cd73e49 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 @@ -74,7 +74,7 @@ public abstract class WeaponProjectile implements Listener boolean moving = Math.abs(_projectileEntity.getVelocity().getX()) > 0.01 || Math.abs(_projectileEntity.getVelocity().getZ()) > 0.01; // Some rough collision detection. Not perfect, but the best I could conjure up myself. - if (!moving && !UtilBlock.boundless(_projectileEntity.getLocation(), 2)) + if ((!moving && !UtilBlock.boundless(_projectileEntity.getLocation(), 2)) || (_projectileEntity instanceof TNTPrimed && _projectileEntity.getTicksLived() >= 80)) { SiegeWeaponExplodeEvent newEvent = UtilServer.CallEvent(new SiegeWeaponExplodeEvent(_weapon, this)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/ScorchingAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/ScorchingAttribute.java index daa299754..c8bcfb635 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/ScorchingAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/ScorchingAttribute.java @@ -33,6 +33,10 @@ public class ScorchingAttribute extends AttackAttribute @Override public void triggerAttack(Entity attacker, Entity defender) { + if (isTeammate(attacker, defender)) + { + return; + } defender.setFireTicks((int) (_fireDuration * 20)); } 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 9072d0dfe..70837d017 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,13 +1,19 @@ 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; +import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -35,6 +41,7 @@ public class RunedPickaxe extends RareItem { UtilServer.RegisterEvents(new Listener() { + @SuppressWarnings("deprecation") @EventHandler public void update(UpdateEvent event) { @@ -65,6 +72,11 @@ public class RunedPickaxe extends RareItem pick._enabled = false; } + + if (!pick._enabled) + { + player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 20 * 2, 100)); + } }); } @@ -105,6 +117,31 @@ public class RunedPickaxe extends RareItem event.getPlayer().playSound(event.getBlock().getLocation(), Sound.LAVA_POP, 1.f, 1.f); } } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void blockDamage(BlockBreakEvent event) + { + PlayerGear gear = ClansManager.getInstance().getGearManager().getPlayerGear(event.getPlayer()); + + if (!(gear.getWeapon() instanceof RunedPickaxe)) + { + return; + } + + RunedPickaxe pick = (RunedPickaxe) gear.getWeapon(); + + if (ClansManager.getInstance().getNetherManager().getNetherWorld().equals(event.getBlock().getWorld())) + return; + + if (ClansManager.getInstance().getBlockRestore().contains(event.getBlock())) + return; + + if (!pick._enabled) + { + event.setCancelled(true); + event.getBlock().breakNaturally(); + } + } }); } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java index 8c7fe10d2..43b9624ec 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java @@ -90,7 +90,7 @@ public class Illusion extends SkillActive public void Skill(Player player, int level) { //Spawn - ClassCombatCreatureAllowSpawnEvent enableEvent = new ClassCombatCreatureAllowSpawnEvent(true); + ClassCombatCreatureAllowSpawnEvent enableEvent = new ClassCombatCreatureAllowSpawnEvent(player.getWorld().getName(), true); UtilServer.getServer().getPluginManager().callEvent(enableEvent); Skeleton skel = player.getWorld().spawn(player.getLocation(), Skeleton.class); @@ -101,7 +101,7 @@ public class Illusion extends SkillActive skel.setMaxHealth(14); skel.setHealth(14); - ClassCombatCreatureAllowSpawnEvent disableEvent = new ClassCombatCreatureAllowSpawnEvent(false); + ClassCombatCreatureAllowSpawnEvent disableEvent = new ClassCombatCreatureAllowSpawnEvent(player.getWorld().getName(), false); UtilServer.getServer().getPluginManager().callEvent(disableEvent); skel.getEquipment().setHelmet(player.getInventory().getHelmet()); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/ClassCombatCreatureAllowSpawnEvent.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/ClassCombatCreatureAllowSpawnEvent.java index 97ccfe772..b21eee5c0 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/ClassCombatCreatureAllowSpawnEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/ClassCombatCreatureAllowSpawnEvent.java @@ -7,12 +7,18 @@ public class ClassCombatCreatureAllowSpawnEvent extends Event { private static final HandlerList handlers = new HandlerList(); + private String _worldName; private boolean _allow; - public ClassCombatCreatureAllowSpawnEvent(boolean allow) + public ClassCombatCreatureAllowSpawnEvent(String worldName, boolean allow) { _allow = allow; } + + public String getWorldName() + { + return _worldName; + } public HandlerList getHandlers() { From 1535fcc38b0d340e828ca3998eebdc33f81325a0 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 22 Oct 2016 16:19:02 -0400 Subject: [PATCH 46/56] Fix temp blocks in unloaded claims not restoring, fix ClassCombatCreatureSpawnEvent having a null world name, fix block toss fallingblocks solidifying in unloaded chunks, make safelog in clans disable when server shuts down, and make UtilBlock recognize 1.8 fence gates as usable blocks --- .../mineplex/core/common/util/UtilBlock.java | 10 +++---- .../core/blockrestore/BlockRestore.java | 29 +++++++++++++++---- .../mineplex/game/clans/clans/ClansGame.java | 2 +- .../game/clans/clans/ClansManager.java | 5 +++- .../game/clans/gameplay/CustomRecipes.java | 2 +- .../game/clans/gameplay/safelog/SafeLog.java | 6 ++++ .../classcombat/Skill/Brute/BlockToss.java | 21 ++++++++++++++ .../ClassCombatCreatureAllowSpawnEvent.java | 1 + 8 files changed, 62 insertions(+), 14 deletions(-) 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 00a28781d..201f36c2f 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 @@ -304,11 +304,11 @@ public class UtilBlock blockUseSet.add((byte) Material.JUNGLE_FENCE_GATE.getId()); blockUseSet.add((byte) Material.DARK_OAK_FENCE_GATE.getId()); blockUseSet.add((byte) Material.ACACIA_FENCE_GATE.getId()); - blockUseSet.add((byte) Material.SPRUCE_FENCE.getId()); - blockUseSet.add((byte) Material.BIRCH_FENCE.getId()); - blockUseSet.add((byte) Material.JUNGLE_FENCE.getId()); - blockUseSet.add((byte) Material.DARK_OAK_FENCE.getId()); - blockUseSet.add((byte) Material.ACACIA_FENCE.getId()); + blockUseSet.add((byte) Material.SPRUCE_FENCE_GATE.getId()); + blockUseSet.add((byte) Material.BIRCH_FENCE_GATE.getId()); + blockUseSet.add((byte) Material.JUNGLE_FENCE_GATE.getId()); + blockUseSet.add((byte) Material.DARK_OAK_FENCE_GATE.getId()); + blockUseSet.add((byte) Material.ACACIA_FENCE_GATE.getId()); blockUseSet.add((byte) Material.SPRUCE_DOOR.getId()); blockUseSet.add((byte) Material.BIRCH_DOOR.getId()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java index bea07b8e5..664a742de 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java @@ -5,12 +5,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; - -import mineplex.core.MiniPlugin; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; +import java.util.Map.Entry; import org.bukkit.Effect; import org.bukkit.Location; @@ -22,8 +17,15 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class BlockRestore extends MiniPlugin { private HashMap _blocks = new HashMap(); @@ -98,6 +100,21 @@ public class BlockRestore extends MiniPlugin for (Block cur : toRemove) _blocks.remove(cur); } + + @EventHandler + public void expireUnload(ChunkUnloadEvent event) + { + Iterator> iterator = _blocks.entrySet().iterator(); + while (iterator.hasNext()) + { + Entry entry = iterator.next(); + if (entry.getKey().getChunk().equals(event.getChunk())) + { + entry.getValue().restore(); + iterator.remove(); + } + } + } public boolean restore(Block block) { 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 fafbc49fe..e9116153c 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 @@ -495,7 +495,7 @@ public class ClansGame extends MiniPlugin if (blockClan != null && blockClan.equals(mimicClan)) access = ClanRelation.SELF; // Doors, chests, & furnaces - if (blockClan != null && (!blockClan.equals(clan) && !blockClan.equals(mimicClan)) && (event.getAction() == Action.RIGHT_CLICK_BLOCK && (loc.getBlock().getType().name().contains("DOOR") || UtilItem.doesHaveGUI(loc.getBlock().getType())))) + if (blockClan != null && (!blockClan.equals(clan) && !blockClan.equals(mimicClan)) && (event.getAction() == Action.RIGHT_CLICK_BLOCK && (loc.getBlock().getType().name().contains("DOOR") || loc.getBlock().getType().name().contains("GATE") || UtilItem.doesHaveGUI(loc.getBlock().getType())))) { UtilPlayer.message(player, F.main("Clans", "You are not allowed to use that here.")); event.setCancelled(true); 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 f6a5c2e18..0b1a36e50 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 @@ -201,6 +201,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati private BannerManager _bannerManager; private AmplifierManager _amplifierManager; + private SafeLog _safeLog; + public ClassManager getClassManager() { return _classManager; @@ -317,7 +319,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati // Required managers to be initialized new Spawn(plugin, this); new NPCManager(this, _hologramManager); - new SafeLog(plugin, this); + _safeLog = new SafeLog(plugin, this); _observerManager = new ObserverManager(plugin, _condition, this); new ClanEnergyTracker(plugin, this); @@ -1208,6 +1210,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _bannerManager.onDisable(); _amplifierManager.onDisable(); _netherManager.onDisable(); + _safeLog.onDisable(); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java index abeabf652..d9238ea97 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java @@ -12,7 +12,7 @@ import mineplex.core.common.util.UtilPlayer; public class CustomRecipes implements Listener { - private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX, Material.FISHING_ROD, Material.BED }; + private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX, Material.FISHING_ROD, Material.BED, Material.BOAT}; @EventHandler public void onPlayerCraftItem(CraftItemEvent event) 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 db6fa935f..5699b4d5b 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 @@ -41,6 +41,12 @@ public class SafeLog extends MiniPlugin new File(clansManager.UserDataDir).mkdir(); } + @Override + public void disable() + { + NPCManager.getInstance().disable(); + } + public void onPlayerQuit(Player player) { boolean isSafeLog = false; diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java index 3422b690b..931426de1 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java @@ -3,6 +3,7 @@ package mineplex.minecraft.game.classcombat.Skill.Brute; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -20,6 +21,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -63,7 +65,9 @@ public class BlockToss extends SkillCharge implements IThrown Material.BURNING_FURNACE, Material.WORKBENCH, Material.WATER, + Material.STATIONARY_WATER, Material.LAVA, + Material.STATIONARY_LAVA, Material.STONE_PLATE, Material.WOOD_PLATE, Material.GOLD_PLATE, @@ -428,6 +432,23 @@ public class BlockToss extends SkillCharge implements IThrown if (UtilMath.offset(event.getEntity().getLocation(), block.getLocation()) < 1) event.setCancelled(true); } + + @EventHandler + public void expireUnload(ChunkUnloadEvent event) + { + Iterator> iterator = _falling.entrySet().iterator(); + while (iterator.hasNext()) + { + Entry entry = iterator.next(); + FallingBlock key = entry.getKey(); + + if (key.getLocation().getChunk().equals(event.getChunk())) + { + key.remove(); + iterator.remove(); + } + } + } @Override public void Reset(Player player) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/ClassCombatCreatureAllowSpawnEvent.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/ClassCombatCreatureAllowSpawnEvent.java index b21eee5c0..227857266 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/ClassCombatCreatureAllowSpawnEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/ClassCombatCreatureAllowSpawnEvent.java @@ -12,6 +12,7 @@ public class ClassCombatCreatureAllowSpawnEvent extends Event public ClassCombatCreatureAllowSpawnEvent(String worldName, boolean allow) { + _worldName = worldName; _allow = allow; } From a219a2d0722be4531fcc045dbfac603c780a5163 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 30 Oct 2016 14:22:02 -0400 Subject: [PATCH 47/56] Fix TNT breaking bedrock, increase build height and add a minimum chest place height --- .../clans/siege/weapon/projectile/Crater.java | 4 ++-- .../mineplex/game/clans/gameplay/Gameplay.java | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) 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 0b78bfa26..0b1630995 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 @@ -54,7 +54,7 @@ public class Crater { noRepeats.add(locID); } - if (block.getType() == Material.AIR || block.isLiquid()) + if (block.getType() == Material.AIR || block.isLiquid() || block.getType() == Material.BEDROCK) { continue; } @@ -81,7 +81,7 @@ public class Crater UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _origin, null, 0, 1, ViewDist.NORMAL); for (Block block : event.getBlocks()) { - if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE) + if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE || block.getType() == Material.BED_BLOCK) { block.breakNaturally(); } 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 2c7a971f1..cafa0fe65 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 @@ -80,6 +80,8 @@ import org.bukkit.plugin.java.JavaPlugin; public class Gameplay extends MiniPlugin { + private static final int MAX_BUILD_HEIGHT = 120; + private static final int MIN_CHEST_HEIGHT = 30; private ClansManager _clansManager; private BlockRestore _blockRestore; private DamageManager _damageManager; @@ -230,19 +232,27 @@ public class Gameplay extends MiniPlugin @EventHandler(priority = EventPriority.LOWEST) public void MaxHeight(BlockPlaceEvent event) { - if (event.getBlock().getLocation().getBlockY() > 100) + if (event.getBlock().getLocation().getBlockY() > MAX_BUILD_HEIGHT) { UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place blocks this high.")); event.setCancelled(true); - } else if(event.getBlock().getLocation().getBlockY() == 99 && event.getBlock().getType().name().contains("DOOR") && !event.getBlock().getType().equals(Material.TRAP_DOOR)) { + } + else if(event.getBlock().getLocation().getBlockY() == (MAX_BUILD_HEIGHT - 1) && event.getBlock().getType().name().contains("DOOR") && event.getBlock().getType() != Material.TRAP_DOOR && event.getBlock().getType() != Material.IRON_TRAPDOOR) + { UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place blocks this high.")); event.setCancelled(true); } + + if (event.getBlock().getLocation().getBlockY() < MIN_CHEST_HEIGHT && (event.getBlock().getType() == Material.CHEST || event.getBlock().getType() == Material.TRAPPED_CHEST)) + { + event.setCancelled(true); + } } @EventHandler(priority = EventPriority.LOWEST) - public void GrowTree(StructureGrowEvent event) { - event.getBlocks().stream().filter(blockState -> blockState.getLocation().getBlockY() > 100).forEach(blockState -> blockState.setType(Material.AIR) ); + public void GrowTree(StructureGrowEvent event) + { + event.getBlocks().stream().filter(blockState -> blockState.getLocation().getBlockY() > MAX_BUILD_HEIGHT).forEach(blockState -> blockState.setType(Material.AIR) ); } /** From 4fc2b875d4ef06e36358ed747947885cb9f266df Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 30 Oct 2016 14:22:56 -0400 Subject: [PATCH 48/56] Add a clans map generator to codebase --- Plugins/Mineplex.ClansGenerator/plugin.yml | 4 + Plugins/Mineplex.ClansGenerator/pom.xml | 23 +++ .../clansgenerator/ClansGenerator.java | 176 ++++++++++++++++++ Plugins/pom.xml | 1 + 4 files changed, 204 insertions(+) create mode 100644 Plugins/Mineplex.ClansGenerator/plugin.yml create mode 100644 Plugins/Mineplex.ClansGenerator/pom.xml create mode 100644 Plugins/Mineplex.ClansGenerator/src/mineplex/clansgenerator/ClansGenerator.java diff --git a/Plugins/Mineplex.ClansGenerator/plugin.yml b/Plugins/Mineplex.ClansGenerator/plugin.yml new file mode 100644 index 000000000..c04a38071 --- /dev/null +++ b/Plugins/Mineplex.ClansGenerator/plugin.yml @@ -0,0 +1,4 @@ +name: ClansGenerator +main: mineplex.clansgenerator.ClansGenerator +version: 1.0 +author: Alex \ No newline at end of file diff --git a/Plugins/Mineplex.ClansGenerator/pom.xml b/Plugins/Mineplex.ClansGenerator/pom.xml new file mode 100644 index 000000000..655d4d4c6 --- /dev/null +++ b/Plugins/Mineplex.ClansGenerator/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + com.mineplex + mineplex-plugin + dev-SNAPSHOT + ../plugin.xml + + + ClansGenerator + mineplex-clansgenerator + + + + ${project.groupId} + mineplex-core-common + ${project.version} + + + diff --git a/Plugins/Mineplex.ClansGenerator/src/mineplex/clansgenerator/ClansGenerator.java b/Plugins/Mineplex.ClansGenerator/src/mineplex/clansgenerator/ClansGenerator.java new file mode 100644 index 000000000..fbab3adc7 --- /dev/null +++ b/Plugins/Mineplex.ClansGenerator/src/mineplex/clansgenerator/ClansGenerator.java @@ -0,0 +1,176 @@ +package mineplex.clansgenerator; + +import java.io.File; +import java.io.IOException; +import java.util.concurrent.ThreadLocalRandom; + +import org.apache.commons.io.FileUtils; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.World.Environment; +import org.bukkit.WorldCreator; +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerPreLoginEvent; +import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result; +import org.bukkit.event.world.ChunkPopulateEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.spigotmc.WatchdogThread; + +import net.minecraft.server.v1_8_R3.BiomeBase; + +public class ClansGenerator extends JavaPlugin implements Runnable, Listener +{ + private static final int MIN_X = -100; + private static final int MIN_Z = -100; + private static final int MAX_X = 100; + private static final int MAX_Z = 100; + + private File _root; + private File _outputDir; + private boolean _debug = false; + + public void onEnable() + { + _root = new File("."); + if (!_root.exists()) + { + getLogger().severe("Root folder does not exist. Aborting"); + getServer().shutdown(); + return; + } + _outputDir = new File(_root, "output"); + if (new File(_root, "DEBUG.dat").exists()) + { + _debug = true; + } + if (!_outputDir.exists()) + { + if (_debug) + { + getLogger().info("Creating map output directory!"); + } + _outputDir.mkdir(); + } + BiomeBase.getBiomes()[BiomeBase.OCEAN.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.PLAINS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.DESERT.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.EXTREME_HILLS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.FOREST.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.TAIGA.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.SWAMPLAND.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.RIVER.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.HELL.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.SKY.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.FROZEN_OCEAN.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.FROZEN_RIVER.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.ICE_PLAINS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.ICE_MOUNTAINS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.MUSHROOM_ISLAND.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.MUSHROOM_SHORE.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.BEACH.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.DESERT_HILLS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.FOREST_HILLS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.TAIGA_HILLS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.SMALL_MOUNTAINS.id] = BiomeBase.PLAINS; + BiomeBase.getBiomes()[BiomeBase.JUNGLE.id] = BiomeBase.EXTREME_HILLS; + BiomeBase.getBiomes()[BiomeBase.JUNGLE_HILLS.id] = BiomeBase.EXTREME_HILLS; + BiomeBase.getBiomes()[BiomeBase.JUNGLE_EDGE.id] = BiomeBase.EXTREME_HILLS; + BiomeBase.getBiomes()[BiomeBase.DEEP_OCEAN.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.STONE_BEACH.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.COLD_BEACH.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.BIRCH_FOREST.id] = BiomeBase.BIRCH_FOREST; + BiomeBase.getBiomes()[BiomeBase.BIRCH_FOREST_HILLS.id] = BiomeBase.BIRCH_FOREST_HILLS; + BiomeBase.getBiomes()[BiomeBase.ROOFED_FOREST.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.COLD_TAIGA.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.COLD_TAIGA_HILLS.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.MEGA_TAIGA.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.MEGA_TAIGA_HILLS.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.EXTREME_HILLS_PLUS.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.SAVANNA.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.SAVANNA_PLATEAU.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.MESA.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.MESA_PLATEAU_F.id] = BiomeBase.FOREST; + BiomeBase.getBiomes()[BiomeBase.MESA_PLATEAU.id] = BiomeBase.FOREST; + WatchdogThread.doStop(); + getServer().getScheduler().runTaskTimer(this, this, 20L, 100L); + getServer().getPluginManager().registerEvents(this, this); + } + + @EventHandler + public void onPopulate(ChunkPopulateEvent event) + { + Block block; + for (int x = 0; x < 16; x++) + { + for (int y = 1; y < 128; y++) + { + for (int z = 0; z < 16; z++) + { + block = event.getChunk().getBlock(x, y, z); + if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.MOB_SPAWNER) + { + block.setType(Material.AIR); + if (_debug) + { + getLogger().info("Removing dungeon pieces"); + } + } + } + } + } + } + + @EventHandler + public void onJoin(AsyncPlayerPreLoginEvent event) + { + event.setLoginResult(Result.KICK_OTHER); + event.setKickMessage("Shoo, go away"); + } + + public void run() + { + int nextFileId = 0; + for (int existingFiles = 0; new File(_outputDir, "Clans_Map_" + existingFiles).exists(); existingFiles++) + { + nextFileId++; + } + + getLogger().info("Generating world id " + nextFileId); + World world = (new WorldCreator("Clans_Map_" + nextFileId)).environment(Environment.NORMAL).generateStructures(false).seed(ThreadLocalRandom.current().nextLong()).createWorld(); + world.setKeepSpawnInMemory(false); + for (int x = MIN_X; x <= MAX_X; x++) + { + getLogger().info("Generating chunks for x coord " + x); + for (int z = MIN_Z; z <= MAX_Z; z++) + { + world.getChunkAt(x, z).load(true); + } + } + + for (int x = MIN_X; x <= MAX_X; x++) + { + getLogger().info("Unloading chunks for x coord " + x); + for (int z = MIN_Z; z <= MAX_Z; z++) + { + world.getChunkAt(x, z).unload(true, false); + } + } + + getLogger().info("Unloading and saving world"); + Bukkit.unloadWorld(world, true); + getLogger().info("Finished unloading and saving world"); + try + { + FileUtils.moveDirectoryToDirectory(new File(_root, "Clans_Map_" + nextFileId), _outputDir, false); + } + catch (IOException e) + { + e.printStackTrace(); + } + getLogger().info("Finished generating world id " + nextFileId); + getServer().shutdown(); + } +} \ No newline at end of file diff --git a/Plugins/pom.xml b/Plugins/pom.xml index 905d6e24b..9ea10d382 100644 --- a/Plugins/pom.xml +++ b/Plugins/pom.xml @@ -29,6 +29,7 @@ Mineplex.Hub Mineplex.Hub.Clans Mineplex.MapParser + Mineplex.ClansGenerator Mineplex.Minecraft.Game.ClassCombat Mineplex.Minecraft.Game.Core Mineplex.ServerData From 4a186a8dece5fc0be12e19c14646819ae5f5a3ce Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 30 Oct 2016 14:24:26 -0400 Subject: [PATCH 49/56] Disable crafting of hoppers --- .../src/mineplex/game/clans/gameplay/CustomRecipes.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java index d9238ea97..21a47a454 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java @@ -12,7 +12,7 @@ import mineplex.core.common.util.UtilPlayer; public class CustomRecipes implements Listener { - private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX, Material.FISHING_ROD, Material.BED, Material.BOAT}; + private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX, Material.FISHING_ROD, Material.BED, Material.BOAT, Material.HOPPER, Material.HOPPER_MINECART }; @EventHandler public void onPlayerCraftItem(CraftItemEvent event) From a8e3a530c1f4d155d15d5c8109fc8a22f04215ab Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 30 Oct 2016 15:20:22 -0400 Subject: [PATCH 50/56] Prevent safely logging out in shop zones while tagged --- .../src/mineplex/game/clans/gameplay/CustomRecipes.java | 2 +- .../src/mineplex/game/clans/gameplay/safelog/SafeLog.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java index 21a47a454..fe96c7d1e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java @@ -43,4 +43,4 @@ public class CustomRecipes implements Listener { UtilPlayer.message(player, F.main("Recipes", message)); } -} +} \ 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 5699b4d5b..154ac45b3 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 @@ -51,7 +51,7 @@ public class SafeLog extends MiniPlugin { boolean isSafeLog = false; - if (_clansManager.getClanUtility().isSafe(player.getLocation())) + if (_clansManager.getClanUtility().isSafe(player)) { isSafeLog = true; } From 5e1fcabe36200493aa048993575e31968b2f31ae Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 11 Nov 2016 20:52:18 -0500 Subject: [PATCH 51/56] Final changes for S2 --- .../src/mineplex/game/clans/Clans.java | 2 +- .../game/clans/clans/ClansUtility.java | 12 +++++- .../clans/clans/ban/ClansBanRepository.java | 11 ++--- .../clans/ban/commands/ClansBanCommand.java | 3 +- .../clans/clans/nether/BossNetherPortal.java | 7 ++-- .../clans/clans/nether/NetherManager.java | 41 +++++-------------- .../game/clans/clans/nether/NetherPortal.java | 7 ++-- .../miniboss/bosses/ArcherMiniboss.java | 2 +- .../nether/miniboss/bosses/GhastMiniboss.java | 2 +- .../miniboss/bosses/WarriorMiniboss.java | 2 +- .../items/attributes/AttackAttribute.java | 2 +- .../armor/ConqueringArmorAttribute.java | 31 +++++++++++--- .../attributes/armor/ReductionAttribute.java | 2 +- .../weapon/ConqueringAttribute.java | 2 +- .../src/mineplex/game/clans/spawn/Spawn.java | 4 ++ 15 files changed, 68 insertions(+), 62 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 5ff84a246..2685d1156 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -71,7 +71,7 @@ import static mineplex.core.Managers.require; public class Clans extends JavaPlugin { - public static final String MAP = "Map 1"; + public static final String MAP = "Season 2"; private String WEB_CONFIG = "webServer"; // Modules 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 5b225e410..b4dd54100 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 @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; import org.bukkit.ChatColor; import org.bukkit.Chunk; @@ -24,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.clans.nether.NetherPortal; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.spawn.Spawn; @@ -289,6 +289,16 @@ public class ClansUtility public boolean isSafe(Location loc) { + if (_clansManager.getNetherManager().getNetherWorld().equals(loc.getWorld())) + { + for (NetherPortal portal : _clansManager.getNetherManager().getReturnPortals()) + { + if (UtilMath.offset2d(loc, portal.getLocation()) <= 5) + { + return true; + } + } + } // Fix for PC-279 // Do not change to getChunk // PlayerList#updatePlayers -> iterator -> PlayerVelocityEvent -> getChunk -> loadChunk -> loadPersistentEntities -> addTracker -> ITERATE ON SAME SET diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java index c33511639..9248f8605 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java @@ -1,6 +1,7 @@ package mineplex.game.clans.clans.ban; -import mineplex.core.common.util.UUIDFetcher; +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; import mineplex.core.database.MinecraftRepository; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.column.ColumnInt; @@ -92,17 +93,11 @@ public class ClansBanRepository extends MinecraftRepository }); } - /** - * @deprecated This invokes a mojang UUID query and should be replaced. - * It's called infrequently enough (i.e., only when a moderator - * invokes /cban), so not entirely pressing. - */ - @Deprecated public CompletableFuture> loadClient(String name) { // Yes, this is garbage. // Yes, it would be better implemented in a functional language. - return CompletableFuture.supplyAsync(() -> UUIDFetcher.getUUIDOf(name)) + return CompletableFuture.supplyAsync(() -> Managers.get(CoreClientManager.class).loadUUIDFromDB(name)) .thenCompose(uuid -> { if (uuid == null) 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 e43c9f130..6cca5d188 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 @@ -16,7 +16,6 @@ public class ClansBanCommand extends CommandBase super(plugin, Rank.CMOD, "cbans", "cb", "cban", "cp", "cpunish", "clanspunish", "clanpunish"); } - @SuppressWarnings("deprecation") @Override public void Execute(final Player caller, String[] args) { @@ -43,7 +42,7 @@ public class ClansBanCommand extends CommandBase { if (!maybeClient.isPresent()) { - UtilPlayer.message(caller, C.cRed + "Could not find player with name " + C.cYellow + " " + playerName); + UtilPlayer.message(caller, C.cRed + "Could not find player with name " + C.cYellow + playerName); } else { new ClansBanShop(Plugin, playerName, maybeClient.get(), finalReason).attemptShopOpen(caller); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java index 815897c4e..fd8c2554d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/BossNetherPortal.java @@ -12,6 +12,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.spawn.Spawn; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -245,15 +246,13 @@ public class BossNetherPortal implements Listener ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity()); ((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); - ClansManager.getInstance().runSyncLater(() -> - { - ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis()); - }, 20); + ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); } else { ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); + ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); } } 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 dbf3a3a91..179afb7b7 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 @@ -3,7 +3,7 @@ package mineplex.game.clans.clans.nether; import java.util.Comparator; import java.util.HashMap; import java.util.List; -import java.util.Random; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.GameMode; @@ -21,7 +21,6 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityPortalEvent; import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPortalEvent; @@ -74,9 +73,9 @@ public class NetherManager extends MiniPlugin private List _portals = Lists.newArrayList(); public List BossPortals = Lists.newArrayList(); private List _returnPortals = Lists.newArrayList(); - public HashMap InNether = new HashMap<>(); - public HashMap OverworldOrigins = new HashMap<>(); - public HashMap Claiming = new HashMap<>(); + public Map InNether = new HashMap<>(); + public Map OverworldOrigins = new HashMap<>(); + public Map Claiming = new HashMap<>(); public NetherManager(ClansManager manager) { @@ -183,6 +182,11 @@ public class NetherManager extends MiniPlugin return null; } + public List getReturnPortals() + { + return _returnPortals; + } + /** * Loads a nether portal into the manager * @param portal The portal to load @@ -389,6 +393,7 @@ public class NetherManager extends MiniPlugin OverworldOrigins.remove(event.getPlayer()); event.getPlayer().removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have escaped " + F.clansNether("The Nether") + "!")); + ClansManager.getInstance().getCombatManager().Get(event.getPlayer()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); }, 1); } @@ -415,6 +420,7 @@ public class NetherManager extends MiniPlugin player.teleport(getReturnLocation(player)); OverworldOrigins.remove(player); player.removePotionEffect(PotionEffectType.NIGHT_VISION); + ClansManager.getInstance().getCombatManager().Get(player).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); UtilPlayer.message(player, F.main(getName(), "You have been forced to escape " + F.clansNether("The Nether") + " to survive its demonic poisons!")); } } @@ -531,29 +537,4 @@ public class NetherManager extends MiniPlugin spawnBossPortal(event.getCreature().getEvent().getCenterLocation().clone().subtract(0, 1, 0)); } } - - @EventHandler - public void onCommand(PlayerCommandPreprocessEvent event) - { - if (event.getMessage().toUpperCase().startsWith("/TRYDOUBLES") && event.getPlayer().isOp()) - { - int mult = 1; - if (event.getMessage().toUpperCase().equalsIgnoreCase("/TRYDOUBLES 2")) - { - mult = 2; - } - if (event.getMessage().toUpperCase().equalsIgnoreCase("/TRYDOUBLES 3")) - { - mult = 3; - } - for (int i = 0; i < 100 * mult; i++) - { - double d = new Random().nextDouble(); - if (d <= 0.075) - { - Bukkit.broadcastMessage("FOUND ONE - " + d); - } - } - } - } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java index 2e3ea55d4..daf5ca438 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherPortal.java @@ -11,6 +11,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.clans.ClansManager; import org.bukkit.Bukkit; @@ -256,15 +257,13 @@ public class NetherPortal implements Listener ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity()); ((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION); UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!")); - ClansManager.getInstance().runSyncLater(() -> - { - ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis()); - }, 20); + ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); } else { ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire); event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation()); + ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity()); } } 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 380a95964..d2a4e938c 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 @@ -34,7 +34,7 @@ import org.bukkit.potion.PotionEffectType; public class ArcherMiniboss extends NetherMiniBoss { private static final int BARBED_LEVEL = 1; - private static final double RUNE_DROP_CHANCE = .075; + private static final double RUNE_DROP_CHANCE = .02; private static final int MAX_DIAMOND_DROPS = 5; 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 6edd6a985..6ff341b58 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 @@ -31,7 +31,7 @@ public class GhastMiniboss extends NetherMiniBoss private static final long MAIN_FIREBALL_COOLDOWN = 5000; private static final long FIREBALL_LAUNCH_RATE = 500; private static final int FIREBALLS_PER_USE = 5; - private static final double RUNE_DROP_CHANCE = .075; + private static final double RUNE_DROP_CHANCE = .02; private static final int MAX_DIAMOND_DROPS = 5; private static final double MAX_TARGET_RANGE = 25; private long _lastFireballUse; 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 6140e43e0..248c9bf64 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 @@ -32,7 +32,7 @@ import org.bukkit.potion.PotionEffectType; */ public class WarriorMiniboss extends NetherMiniBoss { - private static final double RUNE_DROP_CHANCE = .075; + private static final double RUNE_DROP_CHANCE = .02; private static final int MAX_DIAMOND_DROPS = 5; private static final double LEAP_CHANCE = .9; private static final double LEAP_MIN_DIST = 3; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttackAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttackAttribute.java index aa702ebfd..0c72d609f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttackAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/AttackAttribute.java @@ -32,7 +32,7 @@ public abstract class AttackAttribute extends ItemAttribute { if(event.IsCancelled() || event.isCancelled()) return; _attackCount++; - System.out.println("Attack count " + _attackCount + " - " + _attackLimit); +// System.out.println("Attack count " + _attackCount + " - " + _attackLimit); if (_attackCount >= _attackLimit) { _attackCount = 0; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ConqueringArmorAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ConqueringArmorAttribute.java index 9e9596b05..d339abe72 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ConqueringArmorAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ConqueringArmorAttribute.java @@ -5,17 +5,20 @@ import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import mineplex.game.clans.items.attributes.AttributeType; +import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; // A.K.A Conquering for Armor -public class ConqueringArmorAttribute extends FlatReductionAttribute +public class ConqueringArmorAttribute extends ItemAttribute { - private static ValueDistribution reductionGen = generateDistribution(1.0d, 4.0d); - private static ReductionConfig config = new ReductionConfig(); + private static ValueDistribution reductionGen = generateDistribution(2.5d, 6.25d); + private double _reduction; public ConqueringArmorAttribute() { - super(AttributeType.SUFFIX, reductionGen, config); + super(AttributeType.SUFFIX); + _reduction = reductionGen.generateValue() / 100; } @Override @@ -23,14 +26,30 @@ public class ConqueringArmorAttribute extends FlatReductionAttribute { return "Conquering"; } + + @Override + public void onAttacked(CustomDamageEvent event) + { + DamageCause cause = event.GetCause(); + Entity attacker = event.GetDamagerEntity(true); + + if (reducesDamage(cause, attacker)) + { + event.AddMult("Conquering Armor", new String(), 1 - _reduction, false); +// System.out.println("Reduced damage by " + reduction); + } + else + { +// System.out.println("Armor doesn't reduce " + cause); + } + } @Override public String getDescription() { - return String.format("-%.1f damage taken from mobs & bosses", getFlatReduction()); + return String.format("%.1f%% damage taken from mobs & bosses", (1 - _reduction) * 100); } - @Override public boolean reducesDamage(DamageCause cause, Entity attacker) { return !(attacker instanceof Player); // Reduces damage from all entities diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionAttribute.java index c7362f417..764c44d11 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionAttribute.java @@ -36,7 +36,7 @@ public abstract class ReductionAttribute extends ItemAttribute double damage = event.GetDamage(); double reduction = getDamageReduction(damage); event.AddMod("Reduction Armor", -reduction); - System.out.println("Reduced damage by " + reduction); +// System.out.println("Reduced damage by " + reduction); } else { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/ConqueringAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/ConqueringAttribute.java index bc0a56ec8..02c7744b7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/ConqueringAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/ConqueringAttribute.java @@ -9,7 +9,7 @@ import org.bukkit.entity.Player; public class ConqueringAttribute extends DamageAttribute { - private static ValueDistribution damageGen = generateDistribution(1.0d, 6.0d); + private static ValueDistribution damageGen = generateDistribution(1.0d, 4.0d); public ConqueringAttribute() { 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 5c57ef602..10df32a92 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 @@ -314,6 +314,10 @@ public class Spawn extends MiniPlugin for (LivingEntity entity : getSpawnWorld().getLivingEntities()) { + if (entity.hasMetadata("CombatLogNPC")) + { + continue; + } if (entity instanceof Monster) { Monster monster = (Monster) entity; From 7d14b6073dd66952faf574eb1d818d1724c232fe Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 13 Nov 2016 02:13:52 -0500 Subject: [PATCH 52/56] Give SlackAPI a valid payload link, fix some display issues with clans nether, fix claiming in clans nether, update coordinates to match new map --- .../src/mineplex/core/slack/SlackTeam.java | 2 +- .../game/clans/clans/ClansDisplay.java | 11 ++++- .../game/clans/clans/ClansUtility.java | 13 +++--- .../clans/clans/nether/NetherManager.java | 25 ++++++++++++ .../elements/ScoreboardElementPlayer.java | 4 ++ .../clans/worldevent/EventTerrainFinder.java | 22 +++++----- .../game/clans/restart/RestartManager.java | 40 +++++++++++++++++-- .../src/mineplex/game/clans/spawn/Spawn.java | 4 +- 8 files changed, 95 insertions(+), 26 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java b/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java index b1d913d5a..4dd60c9fa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java @@ -6,7 +6,7 @@ package mineplex.core.slack; public enum SlackTeam { // Dev team - mineplex.slack.com - DEVELOPER("Mineplex Dev", "T045RUM7F", "B2ED9B9Q9", "STwdq9LFar2Qt4H3JWyDK3Ow"), + DEVELOPER("Mineplex Dev", "T045RUM7F", "B3165UYN4", "lV5GESG9FDIHG3mQ0LlOGeNV"), // QA team - mineplexqa.slack.com QA("Mineplex QA", "todo", "todo", "todo"), // TODO: new details 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 17d27fc9c..804690b92 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") ? false : _clansManager.getClanUtility().getClaim(player.getLocation()).isSafe(player.getLocation()), true); + 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); UtilServer.getServer().getPluginManager().callEvent(event); @@ -118,6 +118,15 @@ public class ClansDisplay extends MiniPlugin if (relation == ClanRelation.ALLY_TRUST) ownerString += " " + C.mBody + "(" + C.mElem + "Trusted" + C.mBody + ")"; } + if (_clansManager.getNetherManager().isInNether(player)) + { + ownerString = C.cClansNether + "The Nether"; + if (_clansManager.getClanUtility().isSafe(player.getLocation())) + { + ownerString = C.cClansNether + "Nether Spawn"; + } + } + // 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/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index b4dd54100..b1c63970f 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,7 +23,6 @@ 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.clans.nether.NetherPortal; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.spawn.Spawn; @@ -291,12 +290,9 @@ public class ClansUtility { if (_clansManager.getNetherManager().getNetherWorld().equals(loc.getWorld())) { - for (NetherPortal portal : _clansManager.getNetherManager().getReturnPortals()) + if (_clansManager.getNetherManager().isInSpawn(loc)) { - if (UtilMath.offset2d(loc, portal.getLocation()) <= 5) - { - return true; - } + return true; } } // Fix for PC-279 @@ -779,6 +775,11 @@ public class ClansUtility return false; } + if (_clansManager.getNetherManager().isInNether(caller)) + { + UtilPlayer.message(caller, F.main("Clans", "You cannot claim territory while in " + F.clansNether("The Nether") + "!")); + } + if (!ClansManager.isClaimable(caller.getLocation())) { UtilPlayer.message(caller, F.main("Clans", "You cannot claim territory at this location!")); 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 179afb7b7..13ea3c37d 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 @@ -67,6 +67,11 @@ public class NetherManager extends MiniPlugin private static final String CLAIM_WAND_NAME = C.cRedB + "Portal Claim Wand"; private static final String[] CLAIM_WAND_LORE = new String[] {C.cYellow + "Left Click to select the Portal's first corner", C.cYellow + "Right Click to select the Portal's second corner"}; private static final ItemStack CLAIM_WAND = new ItemBuilder(Material.WOOD_AXE).setTitle(CLAIM_WAND_NAME).setLore(CLAIM_WAND_LORE).build(); + private static final int SPAWN_MIN_X = 30; + private static final int SPAWN_MIN_Z = 99; + private static final int SPAWN_MAX_X = 56; + private static final int SPAWN_MAX_Z = 115; + private PortalRepository _repo; private NetherMinibossManager _miniboss; private World _netherWorld; @@ -149,6 +154,26 @@ public class NetherManager extends MiniPlugin return player.getWorld().equals(_netherWorld); } + /** + * Checks if a location is inside Nether Spawn + * @param loc The location to check + * @return true if the location is inside the Nether Spawn + */ + public boolean isInSpawn(Location loc) + { + if (loc.getWorld().equals(getNetherWorld())) + { + if (loc.getBlockX() >= SPAWN_MIN_X && loc.getBlockX() <= SPAWN_MAX_X) + { + if (loc.getBlockZ() >= SPAWN_MIN_Z && loc.getBlockZ() <= SPAWN_MAX_Z) + { + return true; + } + } + } + return false; + } + /** * Gets the place a player will exit the nether * @param player The player to check 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 3fb06b2f0..b5e11e8a1 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 @@ -52,6 +52,10 @@ public class ScoreboardElementPlayer implements ScoreboardElement if (_clansManager.getNetherManager().isInNether(player)) { regionString = C.cClansNether + "The Nether"; + if (_clansManager.getClanUtility().isSafe(player.getLocation())) + { + regionString = C.cClansNether + "Nether Spawn"; + } } output.add(regionString); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java index 378b50478..d8b89874e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/EventTerrainFinder.java @@ -21,7 +21,7 @@ import com.google.common.collect.Lists; public class EventTerrainFinder { - private static final long EVENT_AREA_COOLDOWN = UtilTime.convert(3, TimeUnit.HOURS, TimeUnit.MILLISECONDS); + private static final long EVENT_AREA_COOLDOWN = UtilTime.convert(2, TimeUnit.HOURS, TimeUnit.MILLISECONDS); private ClansManager _clansManager; public EventTerrainFinder(ClansManager clansManager) @@ -135,18 +135,14 @@ public class EventTerrainFinder */ private static enum EventLocation { - NORTH_1("world", -495, 73, -1028), - NORTH_2("world", 197, 66, -1018), - NORTH_3("world", 948, 72, -959), - EAST_1("world", 1109, 66, -753), - EAST_2("world", 1141, 68, 31), - EAST_3("world", 1044, 71, 603), - SOUTH_1("world", 690, 71, 895), - SOUTH_2("world", 144, 66, 1012), - SOUTH_3("world", -1093, 72, 895), - WEST_1("world", -937, 71, 559), - WEST_2("world", -1092, 67, -9), - WEST_3("world", -969, 72, -441); + ONE("world", -662, 64, -1108), + TWO("world", 738, 64, -986), + THREE("world", 1180, 64, -435), + FOUR("world", 995, 64, 550), + FIVE("world", 375, 64, 1142), + SIX("world", -479, 64, 975), + SEVEN("world", -1140, 64, 449), + EIGHT("world", -1014, 64, -342); private String _world; private double _x, _y, _z; 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 2800434cb..23d5fd391 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 @@ -14,9 +14,13 @@ import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.portal.Portal; +import mineplex.core.slack.SlackAPI; +import mineplex.core.slack.SlackMessage; +import mineplex.core.slack.SlackTeam; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import net.minecraft.server.v1_8_R3.MinecraftServer; public class RestartManager extends MiniPlugin { @@ -26,10 +30,16 @@ public class RestartManager extends MiniPlugin private Long _restartTime = -1L; private boolean _restarting; + private final String _serverName; + private final boolean _testServer; + public RestartManager(JavaPlugin plugin) { super("Restart Manager", plugin); + _serverName = plugin.getConfig().getString("serverstatus.name"); + _testServer = plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"); + if (inRestartZone(Calendar.HOUR_OF_DAY)) { _restartUnlock = System.currentTimeMillis() + 1000 + UtilTime.convert(MAX_RESTART_TIME - Calendar.HOUR_OF_DAY, TimeUnit.HOURS, TimeUnit.MILLISECONDS); @@ -44,6 +54,11 @@ public class RestartManager extends MiniPlugin _warnings.add(10000L); _warnings.add(5000L); addCommand(new RestartCommand(this)); + + if (!_testServer) + { + SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-server-status", new SlackMessage("Clans Uptime", "crossed_swords", _serverName + " has started up!"), true); + } } private boolean inRestartZone(int hour) @@ -51,7 +66,7 @@ public class RestartManager extends MiniPlugin return hour >= 0 && hour < MAX_RESTART_TIME; //12 am = 0 } - private boolean tryRestart() + private boolean tryRestartTime() { if (!inRestartZone(Calendar.HOUR_OF_DAY) || System.currentTimeMillis() < _restartUnlock) { @@ -73,6 +88,18 @@ public class RestartManager extends MiniPlugin return true; } + private boolean tryRestartTps() + { + boolean restart = MinecraftServer.getServer().recentTps[0] <= 12; + + if (restart && !_testServer) + { + SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-server-status", new SlackMessage("Clans Uptime", "crossed_swords", _serverName + " has scheduled an immediate restart due to low TPS!"), true); + } + + return restart; + } + public void restart() { Bukkit.broadcastMessage(F.main("Clans", "This Clans server will be restarting in " + F.elem(UtilTime.MakeStr(120000)) + "!")); @@ -107,12 +134,19 @@ public class RestartManager extends MiniPlugin { _restarting = true; Portal.getInstance().sendAllPlayers("ClansHub"); - runSyncLater(() -> {Bukkit.shutdown();}, 120L); + runSyncLater(() -> + { + if (!_testServer) + { + SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-server-status", new SlackMessage("Clans Uptime", "crossed_swords", _serverName + " is now restarting!"), true); + } + Bukkit.shutdown(); + }, 120L); } } else { - if (tryRestart()) + if (tryRestartTime() || tryRestartTps()) { restart(); } 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 10df32a92..979b9743e 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 @@ -460,7 +460,7 @@ public class Spawn extends MiniPlugin public static Location getWestTown() { - return new Location(getSpawnWorld(), -440.91, 65, 23.08); + return new Location(getSpawnWorld(), -440.91, 67, 23.08); } public static Location getWestTownCenter() @@ -470,7 +470,7 @@ public class Spawn extends MiniPlugin public static Location getEastTown() { - return new Location(getSpawnWorld(), 440.91, 65, -23.08); + return new Location(getSpawnWorld(), 440.91, 72, -23.08); } public static Location getEastTownCenter() From c250796bdf6c3477a291dc34d20bb22222b1b8b1 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Wed, 16 Nov 2016 22:36:19 -0500 Subject: [PATCH 53/56] Fix pom.xml formatting --- Plugins/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/pom.xml b/Plugins/pom.xml index 9ea10d382..81118c0bf 100644 --- a/Plugins/pom.xml +++ b/Plugins/pom.xml @@ -29,7 +29,7 @@ Mineplex.Hub Mineplex.Hub.Clans Mineplex.MapParser - Mineplex.ClansGenerator + Mineplex.ClansGenerator Mineplex.Minecraft.Game.ClassCombat Mineplex.Minecraft.Game.Core Mineplex.ServerData From db1598f89675074f457825f2d058323e7c9e1932 Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 16 Nov 2016 04:19:33 -0600 Subject: [PATCH 54/56] Revert 1.11 disguise changes Entity type tracking for disguises is now done in our spigot build. --- .../disguise/disguises/DisguiseAgeable.java | 6 ++-- .../disguise/disguises/DisguiseAmbient.java | 4 +-- .../disguise/disguises/DisguiseAnimal.java | 6 ++-- .../disguises/DisguiseAnimalBase.java | 4 +-- .../disguises/DisguiseArmorStand.java | 2 +- .../core/disguise/disguises/DisguiseBase.java | 32 +++++-------------- .../core/disguise/disguises/DisguiseBat.java | 2 +- .../disguise/disguises/DisguiseBlaze.java | 2 +- .../disguise/disguises/DisguiseBlock.java | 3 +- .../core/disguise/disguises/DisguiseCat.java | 2 +- .../disguises/DisguiseCaveSpider.java | 3 +- .../disguise/disguises/DisguiseChicken.java | 6 ++-- .../core/disguise/disguises/DisguiseCow.java | 6 ++-- .../disguise/disguises/DisguiseCreature.java | 7 ++-- .../disguise/disguises/DisguiseCreeper.java | 2 +- .../disguise/disguises/DisguiseEnderman.java | 2 +- .../disguise/disguises/DisguiseGolem.java | 6 ++-- .../disguise/disguises/DisguiseGuardian.java | 6 ++-- .../disguise/disguises/DisguiseHorse.java | 2 +- .../disguise/disguises/DisguiseHuman.java | 4 +-- .../disguises/DisguiseInsentient.java | 9 +++--- .../disguise/disguises/DisguiseIronGolem.java | 2 +- .../disguise/disguises/DisguiseLiving.java | 12 +++---- .../disguise/disguises/DisguiseMagmaCube.java | 3 +- .../disguise/disguises/DisguiseMonster.java | 4 +-- .../disguise/disguises/DisguiseMooshroom.java | 4 +-- .../core/disguise/disguises/DisguisePig.java | 6 ++-- .../disguise/disguises/DisguisePigZombie.java | 4 +-- .../disguise/disguises/DisguiseRabbit.java | 6 ++-- .../disguise/disguises/DisguiseSheep.java | 2 +- .../disguise/disguises/DisguiseSkeleton.java | 2 +- .../disguise/disguises/DisguiseSlime.java | 2 +- .../disguise/disguises/DisguiseSnowman.java | 6 ++-- .../disguise/disguises/DisguiseSpider.java | 2 +- .../disguise/disguises/DisguiseSquid.java | 6 ++-- .../disguises/DisguiseTameableAnimal.java | 4 +-- .../disguise/disguises/DisguiseVillager.java | 7 ++-- .../disguise/disguises/DisguiseWitch.java | 2 +- .../disguise/disguises/DisguiseWither.java | 5 ++- .../core/disguise/disguises/DisguiseWolf.java | 2 +- .../disguise/disguises/DisguiseZombie.java | 6 ++-- 41 files changed, 83 insertions(+), 120 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAgeable.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAgeable.java index c70db1088..f51230ef4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAgeable.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAgeable.java @@ -2,13 +2,13 @@ package mineplex.core.disguise.disguises; import net.minecraft.server.v1_8_R3.EntityAgeable; -import org.bukkit.entity.EntityType; +import org.bukkit.entity.*; public abstract class DisguiseAgeable extends DisguiseCreature { - public DisguiseAgeable(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) + public DisguiseAgeable(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(disguiseType, entity, clazz); + super(disguiseType, entity); DataWatcher.a(12, new Byte((byte)0), EntityAgeable.META_BABY, false); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java index 668ee91e8..d72e9aafb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAmbient.java @@ -4,8 +4,8 @@ import org.bukkit.entity.EntityType; public abstract class DisguiseAmbient extends DisguiseInsentient { - public DisguiseAmbient(EntityType entityType, org.bukkit.entity.Entity entity, Class clazz) + public DisguiseAmbient(EntityType entityType, org.bukkit.entity.Entity entity) { - super(entityType, entity, clazz); + super(entityType, entity); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimal.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimal.java index af73365c1..e65ff3d5f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimal.java @@ -1,11 +1,11 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.EntityType; +import org.bukkit.entity.*; public abstract class DisguiseAnimal extends DisguiseAgeable { - public DisguiseAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) + public DisguiseAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(disguiseType, entity, clazz); + super(disguiseType, entity); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimalBase.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimalBase.java index f3ce535e6..f47327a24 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimalBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAnimalBase.java @@ -5,9 +5,9 @@ import org.bukkit.entity.EntityType; public class DisguiseAnimalBase extends DisguiseAnimal { - public DisguiseAnimalBase(EntityType entityType, org.bukkit.entity.Entity entity, Class clazz) + public DisguiseAnimalBase(EntityType entityType, org.bukkit.entity.Entity entity) { - super(entityType, entity, clazz); + super(entityType, entity); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java index 5c8d79dd2..79695ec61 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseArmorStand.java @@ -13,7 +13,7 @@ public class DisguiseArmorStand extends DisguiseInsentient { public DisguiseArmorStand(org.bukkit.entity.Entity entity) { - super(EntityType.ARMOR_STAND, entity, EntityArmorStand.class); + super(EntityType.ARMOR_STAND, entity); DataWatcher.a(10, (byte) 0, EntityArmorStand.META_ARMOR_OPTION, (byte) 0); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java index 91c763e5c..2d0334abc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java @@ -1,13 +1,7 @@ package mineplex.core.disguise.disguises; -import java.lang.ref.WeakReference; -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import mineplex.core.common.DummyEntity; +import mineplex.core.common.util.UtilPlayer; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.Entity; import net.minecraft.server.v1_8_R3.EntityPlayer; @@ -18,17 +12,18 @@ import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; import net.minecraft.server.v1_8_R3.WorldServer; - import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.entity.CreatureSpawnEvent; -import mineplex.core.common.util.UtilPlayer; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public abstract class DisguiseBase { - private final Map,net.minecraft.server.v1_8_R3.Entity> dummyEntities = new HashMap<>(); private WeakReference _entity = new WeakReference<>(null); protected DataWatcher DataWatcher; @@ -42,7 +37,7 @@ public abstract class DisguiseBase */ private boolean _hideIfNotDisguised = false; - public DisguiseBase(EntityType entityType, org.bukkit.entity.Entity entity, Class entityClazz) + public DisguiseBase(EntityType entityType, org.bukkit.entity.Entity entity) { if (entity == null) { @@ -53,18 +48,7 @@ public abstract class DisguiseBase setEntity(entity); - DataWatcher = new DataWatcher(dummyEntities.computeIfAbsent(entityClazz, clazz -> - { - try - { - Constructor constructor = clazz.getDeclaredConstructor(net.minecraft.server.v1_8_R3.World.class); - return constructor.newInstance((net.minecraft.server.v1_8_R3.World)null); - } catch (Exception e) - { - e.printStackTrace(); - return null; - } - })); + DataWatcher = new DataWatcher(new DummyEntity(null)); DataWatcher.a(0, (byte) 0, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0); DataWatcher.a(1, (short) 300, net.minecraft.server.v1_8_R3.Entity.META_AIR, 300); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBat.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBat.java index eed6f6e85..b5100c880 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBat.java @@ -8,7 +8,7 @@ public class DisguiseBat extends DisguiseCreature { public DisguiseBat(org.bukkit.entity.Entity entity) { - super(EntityType.BAT, entity, EntityBat.class); + super(EntityType.BAT, entity); DataWatcher.a(16, new Byte((byte) 0), EntityBat.META_UPSIDEDOWN, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlaze.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlaze.java index 9c7e1bedb..c0d782982 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlaze.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlaze.java @@ -8,7 +8,7 @@ public class DisguiseBlaze extends DisguiseMonster { public DisguiseBlaze(org.bukkit.entity.Entity entity) { - super(EntityType.BLAZE, entity, EntityBlaze.class); + super(EntityType.BLAZE, entity); DataWatcher.a(16, new Byte((byte) 0), EntityBlaze.META_FIRE, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java index 8b23dfceb..387208c51 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBlock.java @@ -2,7 +2,6 @@ package mineplex.core.disguise.disguises; import java.util.Random; -import net.minecraft.server.v1_8_R3.EntityFallingBlock; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; @@ -17,7 +16,7 @@ public class DisguiseBlock extends DisguiseBase public DisguiseBlock(org.bukkit.entity.Entity entity, int blockId, int blockData) { - super(EntityType.FALLING_BLOCK, entity, EntityFallingBlock.class); + super(EntityType.FALLING_BLOCK, entity); _blockId = blockId; _blockData = blockData; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCat.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCat.java index 6cebfee7a..621d77259 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCat.java @@ -8,7 +8,7 @@ public class DisguiseCat extends DisguiseTameableAnimal { public DisguiseCat(org.bukkit.entity.Entity entity) { - super(EntityType.OCELOT, entity, EntityOcelot.class); + super(EntityType.OCELOT, entity); DataWatcher.a(18, Byte.valueOf((byte) 0), EntityOcelot.META_TYPE, 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java index ff4bf7a7a..09b3d076a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java @@ -2,7 +2,6 @@ package mineplex.core.disguise.disguises; import org.bukkit.entity.EntityType; -import net.minecraft.server.v1_8_R3.EntityCaveSpider; import net.minecraft.server.v1_8_R3.EntitySpider; public class DisguiseCaveSpider extends DisguiseMonster @@ -10,7 +9,7 @@ public class DisguiseCaveSpider extends DisguiseMonster public DisguiseCaveSpider(org.bukkit.entity.Entity entity) { - super(EntityType.CAVE_SPIDER, entity, EntityCaveSpider.class); + super(EntityType.CAVE_SPIDER, entity); DataWatcher.a(16, new Byte((byte) 0), EntitySpider.META_CLIMBING, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseChicken.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseChicken.java index 8c4155c46..f55c6d707 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseChicken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseChicken.java @@ -1,14 +1,12 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.EntityChicken; - -import org.bukkit.entity.EntityType; +import org.bukkit.entity.*; public class DisguiseChicken extends DisguiseAnimal { public DisguiseChicken(org.bukkit.entity.Entity entity) { - super(EntityType.CHICKEN, entity, EntityChicken.class); + super(EntityType.CHICKEN, entity); } public String getHurtSound() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCow.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCow.java index e26a08a1b..86b1dc192 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCow.java @@ -1,14 +1,12 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.EntityCow; - -import org.bukkit.entity.EntityType; +import org.bukkit.entity.*; public class DisguiseCow extends DisguiseAnimal { public DisguiseCow(org.bukkit.entity.Entity entity) { - super(EntityType.COW, entity, EntityCow.class); + super(EntityType.COW, entity); } public String getHurtSound() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java index c888e73a4..d477ab3bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java @@ -3,14 +3,13 @@ package mineplex.core.disguise.disguises; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; - -import org.bukkit.entity.EntityType; +import org.bukkit.entity.*; public abstract class DisguiseCreature extends DisguiseInsentient { - public DisguiseCreature(EntityType disguiseType, org.bukkit.entity.Entity entity, Class entityClazz) + public DisguiseCreature(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(disguiseType, entity, entityClazz); + super(disguiseType, entity); } @SuppressWarnings("deprecation") diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreeper.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreeper.java index 189ac20f0..6d1eeb73b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreeper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreeper.java @@ -8,7 +8,7 @@ public class DisguiseCreeper extends DisguiseMonster { public DisguiseCreeper(org.bukkit.entity.Entity entity) { - super(EntityType.CREEPER, entity, EntityCreeper.class); + super(EntityType.CREEPER, entity); DataWatcher.a(16, Byte.valueOf((byte) -1), EntityCreeper.META_FUSE_STATE, -1); DataWatcher.a(17, Byte.valueOf((byte) 0), EntityCreeper.META_POWERED, false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java index 8aee3501f..d8d9703c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java @@ -19,7 +19,7 @@ public class DisguiseEnderman extends DisguiseMonster { public DisguiseEnderman(org.bukkit.entity.Entity entity) { - super(EntityType.ENDERMAN, entity, EntityEnderman.class); + super(EntityType.ENDERMAN, entity); DataWatcher.a(16, new Short((short) 0), EntityEnderman.META_BLOCK, Optional. absent()); DataWatcher.a(17, new Byte((byte) 0), EntityEnderman.META_BLOCK, Optional. absent()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGolem.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGolem.java index 2457d6a4a..de5a8b1fd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGolem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGolem.java @@ -1,11 +1,11 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.EntityType; +import org.bukkit.entity.*; public abstract class DisguiseGolem extends DisguiseCreature { - public DisguiseGolem(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) + public DisguiseGolem(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(disguiseType, entity, clazz); + super(disguiseType, entity); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java index d65455002..af05e67bb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java @@ -1,14 +1,14 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.EntityGuardian; +import org.bukkit.entity.*; -import org.bukkit.entity.EntityType; +import net.minecraft.server.v1_8_R3.EntityGuardian; public class DisguiseGuardian extends DisguiseCreature { public DisguiseGuardian(org.bukkit.entity.Entity entity) { - super(EntityType.GUARDIAN, entity, EntityGuardian.class); + super(EntityType.GUARDIAN, entity); DataWatcher.a(16, 0, EntityGuardian.META_ELDER, (byte) 0); DataWatcher.a(17, 0, EntityGuardian.META_TARGET, 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java index b2c06f503..cbd7ee097 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java @@ -12,7 +12,7 @@ public class DisguiseHorse extends DisguiseAnimal { public DisguiseHorse(org.bukkit.entity.Entity entity) { - super(EntityType.HORSE, entity, EntityHorse.class); + super(EntityType.HORSE, entity); DataWatcher.a(16, Integer.valueOf(0), EntityHorse.META_HORSE_STATE, (byte) 0); DataWatcher.a(19, Byte.valueOf((byte) 0), EntityHorse.META_TYPE, 0); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java index 1931af450..344af0254 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHuman.java @@ -3,13 +3,11 @@ package mineplex.core.disguise.disguises; import net.minecraft.server.v1_8_R3.EntityHuman; import org.bukkit.entity.EntityType; -import mineplex.core.common.DummyEntity; - public abstract class DisguiseHuman extends DisguiseLiving { public DisguiseHuman(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(disguiseType, entity, DummyEntity.class); + super(disguiseType, entity); byte skin = 0; skin |= (1 << 0); //Enable Cape diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java index 6d0f650d4..843af0c09 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java @@ -1,19 +1,18 @@ package mineplex.core.disguise.disguises; +import mineplex.core.common.*; import net.minecraft.server.v1_8_R3.EntityInsentient; -import org.bukkit.ChatColor; +import org.bukkit.*; import org.bukkit.entity.EntityType; -import mineplex.core.common.Rank; - public abstract class DisguiseInsentient extends DisguiseLiving { private boolean _showArmor; - public DisguiseInsentient(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) + public DisguiseInsentient(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(disguiseType, entity, clazz); + super(disguiseType, entity); DataWatcher.a(3, Byte.valueOf((byte) 0), EntityInsentient.META_CUSTOMNAME_VISIBLE, false); DataWatcher.a(2, "", EntityInsentient.META_CUSTOMNAME, ""); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseIronGolem.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseIronGolem.java index 07165e023..0e487c7e7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseIronGolem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseIronGolem.java @@ -8,7 +8,7 @@ public class DisguiseIronGolem extends DisguiseGolem { public DisguiseIronGolem(org.bukkit.entity.Entity entity) { - super(EntityType.IRON_GOLEM, entity, EntityIronGolem.class); + super(EntityType.IRON_GOLEM, entity); DataWatcher.a(16, Byte.valueOf((byte) 0), EntityIronGolem.META_PLAYER_CREATED, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java index 47624d0e9..dc3608873 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseLiving.java @@ -3,24 +3,24 @@ package mineplex.core.disguise.disguises; import java.util.ArrayList; import java.util.Random; -import net.minecraft.server.v1_8_R3.EntityLiving; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; - import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; +import net.minecraft.server.v1_8_R3.EntityLiving; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; + public abstract class DisguiseLiving extends DisguiseBase { private static Random _random = new Random(); private boolean _invisible; private ItemStack[] _equipment = new ItemStack[5]; - public DisguiseLiving(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) + public DisguiseLiving(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(disguiseType, entity, clazz); + super(disguiseType, entity); DataWatcher.a(6, Float.valueOf(1.0F), EntityLiving.META_HEALTH, 1F); DataWatcher.a(7, Integer.valueOf(0), EntityLiving.META_POTION_COLOR, 0); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java index 2de9ca123..904835bba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java @@ -1,6 +1,5 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.EntityMagmaCube; import net.minecraft.server.v1_8_R3.EntitySlime; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; @@ -11,7 +10,7 @@ public class DisguiseMagmaCube extends DisguiseInsentient { public DisguiseMagmaCube(org.bukkit.entity.Entity entity) { - super(EntityType.MAGMA_CUBE, entity, EntityMagmaCube.class); + super(EntityType.MAGMA_CUBE, entity); DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMonster.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMonster.java index e1d5b3ec8..d64c04a7d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMonster.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMonster.java @@ -4,8 +4,8 @@ import org.bukkit.entity.*; public abstract class DisguiseMonster extends DisguiseCreature { - public DisguiseMonster(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) + public DisguiseMonster(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(disguiseType, entity, clazz); + super(disguiseType, entity); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMooshroom.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMooshroom.java index 91c5c6eba..8b6d64485 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMooshroom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMooshroom.java @@ -1,14 +1,12 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.EntityMushroomCow; - import org.bukkit.entity.*; public class DisguiseMooshroom extends DisguiseAnimal { public DisguiseMooshroom(org.bukkit.entity.Entity entity) { - super(EntityType.MUSHROOM_COW, entity, EntityMushroomCow.class); + super(EntityType.MUSHROOM_COW, entity); } public String getHurtSound() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePig.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePig.java index 750e0bd4f..b2ce16dc1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePig.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePig.java @@ -1,14 +1,12 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.EntityPig; - -import org.bukkit.entity.EntityType; +import org.bukkit.entity.*; public class DisguisePig extends DisguiseAnimal { public DisguisePig(org.bukkit.entity.Entity entity) { - super(EntityType.PIG, entity, EntityPig.class); + super(EntityType.PIG, entity); } public String getHurtSound() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePigZombie.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePigZombie.java index 8e0c8de9c..259dfb163 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePigZombie.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePigZombie.java @@ -1,14 +1,12 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.EntityPigZombie; - import org.bukkit.entity.*; public class DisguisePigZombie extends DisguiseZombie { public DisguisePigZombie(org.bukkit.entity.Entity entity) { - super(EntityType.PIG_ZOMBIE, entity, EntityPigZombie.class); + super(EntityType.PIG_ZOMBIE, entity); } protected String getHurtSound() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java index 0461a8fe2..3facd4fe2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseRabbit.java @@ -1,18 +1,18 @@ package mineplex.core.disguise.disguises; +import org.bukkit.entity.EntityType; + import net.minecraft.server.v1_8_R3.EntityRabbit; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; -import org.bukkit.entity.EntityType; - public class DisguiseRabbit extends DisguiseAnimal { public DisguiseRabbit(org.bukkit.entity.Entity entity) { - super(EntityType.RABBIT, entity, EntityRabbit.class); + super(EntityType.RABBIT, entity); DataWatcher.a(18, Byte.valueOf((byte) 0), EntityRabbit.META_TYPE, 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSheep.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSheep.java index 7ed6edc16..83e32ad0a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSheep.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSheep.java @@ -9,7 +9,7 @@ public class DisguiseSheep extends DisguiseAnimal { public DisguiseSheep(org.bukkit.entity.Entity entity) { - super(EntityType.SHEEP, entity, EntitySheep.class); + super(EntityType.SHEEP, entity); DataWatcher.a(16, new Byte((byte) 0), EntitySheep.META_WOOL_STATE, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java index 9c099a369..122490073 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java @@ -9,7 +9,7 @@ public class DisguiseSkeleton extends DisguiseMonster { public DisguiseSkeleton(org.bukkit.entity.Entity entity) { - super(EntityType.SKELETON, entity, EntitySkeleton.class); + super(EntityType.SKELETON, entity); DataWatcher.a(13, Byte.valueOf((byte) 0), EntitySkeleton.META_TYPE, 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java index dcbb66702..96bb78cd9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java @@ -10,7 +10,7 @@ public class DisguiseSlime extends DisguiseInsentient { public DisguiseSlime(org.bukkit.entity.Entity entity) { - super(EntityType.SLIME, entity, EntitySlime.class); + super(EntityType.SLIME, entity); DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSnowman.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSnowman.java index 569a6316f..0c643e94d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSnowman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSnowman.java @@ -1,13 +1,11 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.EntitySnowman; - -import org.bukkit.entity.EntityType; +import org.bukkit.entity.*; public class DisguiseSnowman extends DisguiseGolem { public DisguiseSnowman(org.bukkit.entity.Entity entity) { - super(EntityType.SNOWMAN, entity, EntitySnowman.class); + super(EntityType.SNOWMAN, entity); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSpider.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSpider.java index f90bb860f..8851de909 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSpider.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSpider.java @@ -8,7 +8,7 @@ public class DisguiseSpider extends DisguiseMonster { public DisguiseSpider(org.bukkit.entity.Entity entity) { - super(EntityType.SPIDER, entity, EntitySpider.class); + super(EntityType.SPIDER, entity); DataWatcher.a(16, new Byte((byte) 0), EntitySpider.META_CLIMBING, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSquid.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSquid.java index c03e50b35..040d5de5c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSquid.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSquid.java @@ -1,14 +1,12 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.EntitySquid; - -import org.bukkit.entity.EntityType; +import org.bukkit.entity.*; public class DisguiseSquid extends DisguiseMonster { public DisguiseSquid(org.bukkit.entity.Entity entity) { - super(EntityType.SQUID, entity, EntitySquid.class); + super(EntityType.SQUID, entity); } protected String getHurtSound() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseTameableAnimal.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseTameableAnimal.java index c281b020b..8309387c9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseTameableAnimal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseTameableAnimal.java @@ -10,9 +10,9 @@ import com.google.common.base.Optional; public abstract class DisguiseTameableAnimal extends DisguiseAnimal { - public DisguiseTameableAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity, Class clazz) + public DisguiseTameableAnimal(EntityType disguiseType, org.bukkit.entity.Entity entity) { - super(disguiseType, entity, clazz); + super(disguiseType, entity); DataWatcher.a(16, Byte.valueOf((byte) 0), EntityTameableAnimal.META_SITTING_TAMED, (byte) 0); DataWatcher.a(17, "", EntityTameableAnimal.META_OWNER, Optional. absent()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseVillager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseVillager.java index 9f36f02f7..d9f367bdf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseVillager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseVillager.java @@ -1,15 +1,12 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.EntityVillager; - -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; +import org.bukkit.entity.*; public class DisguiseVillager extends DisguiseAgeable { public DisguiseVillager(Entity entity) { - super(EntityType.VILLAGER, entity, EntityVillager.class); + super(EntityType.VILLAGER, entity); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWitch.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWitch.java index 8bb8c12e4..83db8142c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWitch.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWitch.java @@ -8,7 +8,7 @@ public class DisguiseWitch extends DisguiseMonster { public DisguiseWitch(org.bukkit.entity.Entity entity) { - super(EntityType.WITCH, entity, EntityWitch.class); + super(EntityType.WITCH, entity); DataWatcher.a(21, Byte.valueOf((byte) 0), EntityWitch.META_AGGRESSIVE, false); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWither.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWither.java index 6c715ce0a..333d283bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWither.java @@ -3,12 +3,15 @@ package mineplex.core.disguise.disguises; import net.minecraft.server.v1_8_R3.EntityWither; import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; + +import mineplex.core.common.util.UtilMath; public class DisguiseWither extends DisguiseMonster { public DisguiseWither(org.bukkit.entity.Entity entity) { - super(EntityType.WITHER, entity, EntityWither.class); + super(EntityType.WITHER, entity); DataWatcher.a(17, new Integer(0), EntityWither.META_INVUL_TIME, 0); DataWatcher.a(18, new Integer(0), EntityWither.META_TARGET_1, 0); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWolf.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWolf.java index 952f4a284..3b663f075 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWolf.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseWolf.java @@ -8,7 +8,7 @@ public class DisguiseWolf extends DisguiseTameableAnimal { public DisguiseWolf(org.bukkit.entity.Entity entity) { - super(EntityType.WOLF, entity, EntityWolf.class); + super(EntityType.WOLF, entity); DataWatcher.a(18, new Float(20F), EntityWolf.META_WOLF_HEALTH, 20F); DataWatcher.a(19, new Byte((byte) 0), EntityWolf.META_BEGGING, false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseZombie.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseZombie.java index 1aacdc46e..df1d4118e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseZombie.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseZombie.java @@ -8,12 +8,12 @@ public class DisguiseZombie extends DisguiseMonster { public DisguiseZombie(Entity entity) { - this(EntityType.ZOMBIE, entity, EntityZombie.class); + this(EntityType.ZOMBIE, entity); } - public DisguiseZombie(EntityType disguiseType, Entity entity, Class clazz) + public DisguiseZombie(EntityType disguiseType, Entity entity) { - super(disguiseType, entity, clazz); + super(disguiseType, entity); DataWatcher.a(12, Byte.valueOf((byte) 0), EntityZombie.META_CHILD, false); DataWatcher.a(13, Byte.valueOf((byte) 0), EntityZombie.META_VILLAGER, false); From b862a30c768b157ee144e9d1a8048826edd814c9 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Thu, 17 Nov 2016 05:06:00 -0200 Subject: [PATCH 55/56] Thanksgiving Cosmetics (#278) * Added chickens to Holiday Manager (Thanksgiving) Added TextEffect Moved all the effects to a different package to make it easier to find Added method in Effect to get the Effect Location * Removed(?) wildcard import * Testing New year thing Added some symbols to UtilBlockText * Allow multiple pets with the same EntityType * Added Stray Morph Added Shulker Pet Added code for a possible new year effect Added Metal Man Morph to the menus Added Metal Man Morph as an yearly bonus for PPC subscriptions * Added chickens to Holiday Manager (Thanksgiving) Added TextEffect Moved all the effects to a different package to make it easier to find Added method in Effect to get the Effect Location * Removed(?) wildcard import * Testing New year thing Added some symbols to UtilBlockText * Allow multiple pets with the same EntityType * Added Stray Morph Added Shulker Pet Added code for a possible new year effect Added Metal Man Morph to the menus Added Metal Man Morph as an yearly bonus for PPC subscriptions * I seriously don't remember what is in this commit, I'm just doing it to fix the thing with develop... * Fixed Pet menu Fixed morph menu Changed from List to Set * Changed from PurchasUnknownSalesPackage to AddUnknownSalesPackageOwned * Added Santa Morph Removed Sleigh Morph Changed all the cosmetics GUIs to start on the second row, instead of the first * Changed some stuff from Holiday Manager so now chickens will walk around when spawned * Added sound effects to Metal Man Added slowness to Metal Man * Added new lore for the Metal Man Morph description Added Stray Morph Ability Fixed some problems with the Thanksgiving Chickens * Added Fated giveaway manager and animation Moved titan and fated giveaway managers to a new package * Fixed lores for Stray morph and Shulker pet Changed ability of Stray morph * Removed Stray and Shulker pet from the menu Deleted Pet class since it was not being used Changed position of achievement on the menu Changed color of chicken's name Changed colors of Power Play message Stray morph, Santa morph and Shulker pet are hidden from the menus for now Removed feathers dropping from chickens, changed them to snow particles * Added hover ability to Metal Man Morph * Fixed some stuff on Metal Man --- .../core/common/util/UtilBlockText.java | 28 ++ .../core/common/util/UtilFirework.java | 18 + .../mineplex/core/common/util/UtilItem.java | 26 +- .../mineplex/core/common/util/UtilPlayer.java | 71 +++- .../mineplex/core/common/util/UtilText.java | 37 ++ .../core/achievement/Achievement.java | 7 + .../gui/buttons/PowerPlayClubButton.java | 13 +- .../mineplex/core/cosmetic/ui/PetSorter.java | 16 - .../core/cosmetic/ui/button/PetButton.java | 10 +- .../cosmetic/ui/button/RenamePetButton.java | 7 +- .../ui/button/activate/ActivatePetButton.java | 8 +- .../core/cosmetic/ui/page/ArrowTrailPage.java | 6 +- .../core/cosmetic/ui/page/BalloonsPage.java | 15 +- .../cosmetic/ui/page/DeathEffectPage.java | 6 +- .../core/cosmetic/ui/page/DoubleJumpPage.java | 6 +- .../core/cosmetic/ui/page/GadgetPage.java | 26 +- .../core/cosmetic/ui/page/HatPage.java | 6 +- .../mineplex/core/cosmetic/ui/page/Menu.java | 9 +- .../core/cosmetic/ui/page/MorphPage.java | 17 +- .../core/cosmetic/ui/page/MountPage.java | 6 +- .../core/cosmetic/ui/page/MusicPage.java | 6 +- .../core/cosmetic/ui/page/ParticlePage.java | 8 +- .../core/cosmetic/ui/page/PetPage.java | 121 ++++--- .../core/cosmetic/ui/page/PetTagPage.java | 44 ++- .../core/cosmetic/ui/page/TauntPage.java | 4 +- .../core/cosmetic/ui/page/WinEffectPage.java | 6 +- .../page/gamemodifiers/GameModifierPage.java | 6 +- .../gamemodifiers/GameModifierSubPage.java | 14 +- .../gamemodifiers/KitGameModifierPage.java | 11 +- .../mineplex/core/gadget/GadgetManager.java | 8 +- .../core/gadget/commands/AmmoCommand.java | 4 +- .../gadget/commands/LockCosmeticsCommand.java | 13 +- .../gadget/commands/ReindeerTestCommand.java | 85 ----- .../commands/UnlockCosmeticsCommand.java | 14 +- .../arrowtrail/freedom/ArrowTrailFreedom.java | 2 +- .../core/gadget/gadgets/item/ItemCoal.java | 7 +- .../gadget/gadgets/morph/MorphGrimReaper.java | 4 +- .../gadget/gadgets/morph/MorphMetalMan.java | 94 ++++- .../core/gadget/gadgets/morph/MorphSanta.java | 281 ++++++++++++++ .../gadget/gadgets/morph/MorphSleigh.java | 238 ------------ .../core/gadget/gadgets/morph/MorphStray.java | 128 +++++++ .../gadgets/morph/WitchEffectManager.java | 2 +- .../gadgets/morph/managers/SantaPresent.java | 38 ++ .../gadgets/morph/managers/sleigh/Sleigh.java | 187 ---------- .../morph/managers/sleigh/SleighPosition.java | 76 ---- .../particle/freedom/ParticleFreedom.java | 2 +- .../gadgets/wineffect/WinEffectHalloween.java | 2 +- .../core/itemstack/ItemStackFactory.java | 15 +- .../core/mount/types/MountFreedomHorse.java | 3 +- .../BabyFireworkEffect.java | 9 +- .../unrelated => particleeffects}/Effect.java | 21 +- .../EffectLocation.java | 2 +- .../FreedomFireworkEffect.java | 2 +- .../FreedomTrailEffect.java | 12 +- .../HalloweenSmashedEffect.java | 5 +- .../MetalManEffect.java | 60 ++- .../core/particleeffects/NewYearEffect.java | 155 ++++++++ .../NewYearFireworkEffect.java | 46 +++ .../core/particleeffects/TextEffect.java | 87 +++++ .../WitchParticleEffect.java | 7 +- .../src/mineplex/core/pet/Pet.java | 57 --- .../src/mineplex/core/pet/PetClient.java | 19 +- .../src/mineplex/core/pet/PetExtra.java | 42 ++- .../src/mineplex/core/pet/PetFactory.java | 72 ---- .../src/mineplex/core/pet/PetManager.java | 127 ++++--- .../src/mineplex/core/pet/PetType.java | 104 ++++++ .../core/pet/repository/PetRepository.java | 53 +-- .../core/pet/sales/PetExtraSalesPackage.java | 19 + .../core/pet/sales/PetSalesPackage.java | 22 ++ .../src/mineplex/core/pet/types/Elf.java | 14 - .../core/pet/types/PetCoalApparition.java | 14 - .../src/mineplex/core/pet/types/Pumpkin.java | 13 - .../PowerPlayClubRepository.java | 42 ++- .../LightFlicker.java | 2 +- .../fatedgiveaway/FatedGiveawayAnimation.java | 61 ++++ .../fatedgiveaway/FatedGiveawayManager.java | 111 ++++++ .../FatedGiveawayRepository.java | 71 ++++ .../redis/FatedGiveawayMessage.java | 32 ++ .../redis/GiveawayMessageHandler.java | 21 +- .../redis/TitanChestGiveawayHandler.java | 2 +- .../redis/TitanChestGiveawayMessage.java | 2 +- .../redis/TitanGiveawayMessage.java | 2 +- .../titangiveaway/TitanGiveawayAnimation.java | 15 +- .../titangiveaway/TitanGiveawayManager.java | 12 +- .../TitanGiveawayRepository.java | 3 +- .../mineplex/core/reward/RewardManager.java | 54 ++- .../core/reward/rewards/PetReward.java | 18 +- .../mineplex/core/shop/page/ShopPageBase.java | 28 +- .../src/mineplex/core/treasure/Treasure.java | 2 +- .../animation/ChestSpawnAnimation.java | 2 +- .../core/treasure/gui/BuyChestButton.java | 6 +- .../src/mineplex/clanshub/ClansHub.java | 2 +- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 11 +- .../salespackage/SalesPackageManager.java | 17 +- .../salespackage/command/PetCommand.java | 10 +- .../salespackage/salespackages/Pet.java | 6 +- .../nautilus/game/arcade/ArcadeManager.java | 26 +- .../games/halloween2016/Halloween2016.java | 4 +- .../game/arcade/managers/HolidayManager.java | 342 +++++++++++++++--- .../events/SpecialEntityDeathEvent.java | 42 +++ 100 files changed, 2335 insertions(+), 1334 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/PetSorter.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/ReindeerTestCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSanta.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSleigh.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphStray.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/SantaPresent.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/Sleigh.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/SleighPosition.java rename Plugins/Mineplex.Core/src/mineplex/core/{gadget/gadgets/particle/unrelated => particleeffects}/BabyFireworkEffect.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/{gadget/gadgets/particle/unrelated => particleeffects}/Effect.java (80%) rename Plugins/Mineplex.Core/src/mineplex/core/{gadget/gadgets/particle/unrelated => particleeffects}/EffectLocation.java (92%) rename Plugins/Mineplex.Core/src/mineplex/core/{gadget/gadgets/particle/unrelated => particleeffects}/FreedomFireworkEffect.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/{gadget/gadgets/particle/unrelated => particleeffects}/FreedomTrailEffect.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/{gadget/gadgets/particle/unrelated => particleeffects}/HalloweenSmashedEffect.java (91%) rename Plugins/Mineplex.Core/src/mineplex/core/{gadget/gadgets/particle/unrelated => particleeffects}/MetalManEffect.java (66%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearEffect.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearFireworkEffect.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/particleeffects/TextEffect.java rename Plugins/Mineplex.Core/src/mineplex/core/{gadget/gadgets/particle/unrelated => particleeffects}/WitchParticleEffect.java (91%) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetExtraSalesPackage.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetSalesPackage.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/pet/types/Elf.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/pet/types/PetCoalApparition.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/pet/types/Pumpkin.java rename Plugins/Mineplex.Core/src/mineplex/core/{titangiveaway => rankGiveaway}/LightFlicker.java (96%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayAnimation.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayRepository.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/FatedGiveawayMessage.java rename Plugins/Mineplex.Core/src/mineplex/core/{titangiveaway => rankGiveaway}/redis/GiveawayMessageHandler.java (61%) rename Plugins/Mineplex.Core/src/mineplex/core/{titangiveaway => rankGiveaway}/redis/TitanChestGiveawayHandler.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/{titangiveaway => rankGiveaway}/redis/TitanChestGiveawayMessage.java (91%) rename Plugins/Mineplex.Core/src/mineplex/core/{titangiveaway => rankGiveaway}/redis/TitanGiveawayMessage.java (91%) rename Plugins/Mineplex.Core/src/mineplex/core/{ => rankGiveaway}/titangiveaway/TitanGiveawayAnimation.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/{ => rankGiveaway}/titangiveaway/TitanGiveawayManager.java (90%) rename Plugins/Mineplex.Core/src/mineplex/core/{ => rankGiveaway}/titangiveaway/TitanGiveawayRepository.java (95%) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/events/SpecialEntityDeathEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlockText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlockText.java index b2c99338c..0242d205c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlockText.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlockText.java @@ -524,5 +524,33 @@ public class UtilBlockText {0,1,0,0}, {1,1,1,1} }); + + alphabet.put(':', new int[][] + { + {0}, + {1}, + {0}, + {1}, + {0} + }); + + alphabet.put('=', new int[][] + { + {0,0,0}, + {1,1,1}, + {0,0,0}, + {1,1,1}, + {0,0,0} + }); + + // THIS IS A SINGLE SPACE + alphabet.put('|', new int[][] + { + {0}, + {0}, + {0}, + {0}, + {0} + }); } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java index ec8b4ae5e..f10851755 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFirework.java @@ -114,4 +114,22 @@ public class UtilFirework playFirework(location, FireworkEffect.builder().withColor(Color.RED).withColor(Color.BLUE) .withColor(Color.WHITE).withFade(Color.RED).withFade(Color.BLUE).withFade(Color.WHITE).build()); } + + public static FireworkEffect getRandomFireworkEffect(boolean fade, int maxColors, int maxFade) + { + FireworkEffect.Builder builder = FireworkEffect.builder().with(Type.values()[UtilMath.r(Type.values().length)]) + .withColor(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256))).flicker(UtilMath.random.nextBoolean()).trail(UtilMath.random.nextBoolean()); + if (fade) + { + for (int i = 0; i < maxFade; i++) + { + builder.withFade(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256))); + } + } + for (int i = 0; i < maxColors; i++) + { + builder.withColor(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256))); + } + return builder.build(); + } } 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 68a0a4493..6869beb84 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 @@ -9,6 +9,9 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import net.minecraft.server.v1_8_R3.NBTTagCompound; +import net.minecraft.server.v1_8_R3.NBTTagLong; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -22,8 +25,6 @@ import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; import mineplex.core.common.structs.ItemContainer; -import net.minecraft.server.v1_8_R3.NBTTagCompound; -import net.minecraft.server.v1_8_R3.NBTTagLong; public class UtilItem { @@ -1216,6 +1217,27 @@ public class UtilItem return ent; } + public static ItemStack getVersionSpecificItem(Player player, UtilPlayer.PlayerVersion requiredVersion, ItemStack base) + { + if (UtilPlayer.getPlayerVersion(player).compare(requiredVersion)) + { + return base; + } + else + { + ItemStack barrier = new ItemStack(Material.BARRIER); + ItemMeta meta = barrier.getItemMeta(); + meta.setDisplayName(base.getItemMeta().getDisplayName()); + List lore = new ArrayList<>(); + lore.addAll(base.getItemMeta().getLore()); + lore.add(" "); + lore.add(C.cRedB + "REQUIRES VERSION " + requiredVersion.getFriendlyName() + "+!"); + meta.setLore(lore); + barrier.setItemMeta(meta); + return barrier; + } + } + public static double getAttackDamage(Material type) { return ItemDamage.get(type); 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 5f7e00ddc..930bf299a 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 @@ -3,6 +3,7 @@ package mineplex.core.common.util; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -10,8 +11,21 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.Set; import java.util.UUID; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ClickEvent.Action; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.EntityTracker; +import net.minecraft.server.v1_8_R3.EntityTrackerEntry; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder; +import net.minecraft.server.v1_8_R3.PlayerConnection; +import net.minecraft.server.v1_8_R3.WorldBorder; + import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; @@ -33,18 +47,6 @@ import org.bukkit.util.Vector; import mineplex.core.common.MinecraftVersion; import mineplex.core.common.events.PlayerMessageEvent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ClickEvent.Action; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.EntityTracker; -import net.minecraft.server.v1_8_R3.EntityTrackerEntry; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder; -import net.minecraft.server.v1_8_R3.PlayerConnection; -import net.minecraft.server.v1_8_R3.WorldBorder; -import java.util.*; public class UtilPlayer { @@ -1124,4 +1126,49 @@ public class UtilPlayer { return (playerUUID.hashCode() & 1) == 1; } + + public static PlayerVersion getPlayerVersion(Player player) + { + int playerVersion = ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion(); + if (playerVersion >= 210) + { + return PlayerVersion._1_10; + } + else if (playerVersion >= 107) + { + return PlayerVersion._1_9; + } + return PlayerVersion._1_8; + } + + public enum PlayerVersion + { + _1_8(47, "1.8"), + _1_9(107, "1.9"), + _1_10(210, "1.10"); + + private int _version; + private String _friendlyName; + + PlayerVersion(int version, String friendlyName) + { + _version = version; + _friendlyName = friendlyName; + } + + public int getVersion() + { + return _version; + } + + public String getFriendlyName() + { + return _friendlyName; + } + + public boolean compare(PlayerVersion versionToCompare) + { + return versionToCompare.getVersion() >= getVersion(); + } + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java index 8a2d3d371..c151fcf84 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java @@ -1,6 +1,12 @@ package mineplex.core.common.util; import javax.imageio.ImageIO; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Color; +import java.awt.FontMetrics; +import java.awt.font.FontRenderContext; +import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; @@ -764,4 +770,35 @@ public class UtilText } return stringBuilder.toString(); } + + /** + * Creates an image based on a string + * Removed from EffectLib + * @param font The font that is used + * @param s The string + * @return A buffered image containing the text + */ + public static BufferedImage stringToBufferedImage(Font font, String s) { + BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR); + Graphics g = img.getGraphics(); + g.setFont(font); + + FontRenderContext frc = g.getFontMetrics().getFontRenderContext(); + Rectangle2D rect = font.getStringBounds(s, frc); + g.dispose(); + + img = new BufferedImage((int) Math.ceil(rect.getWidth()), (int) Math.ceil(rect.getHeight()), BufferedImage.TYPE_4BYTE_ABGR); + g = img.getGraphics(); + g.setColor(Color.black); + g.setFont(font); + + FontMetrics fm = g.getFontMetrics(); + int x = 0; + int y = fm.getAscent(); + + g.drawString(s, x, y); + g.dispose(); + + return img; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 32e54d2bb..7dbe9d5fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -44,6 +44,13 @@ public enum Achievement new int[]{10}, AchievementCategory.HOLIDAY), + GLOBAL_CHICKEN_CHASER_2016("2016 Chicken Chaser", 4000, + new String[]{"Global.Thanksgiving Chickens 2016"}, + new String[]{"Catch 200 Thanksgiving Chickens,", + "during Thanksgiving 2016!"}, + new int[]{200}, + AchievementCategory.HOLIDAY), + //Bridges BRIDGES_WINS("Bridge Champion", 600, new String[]{"The Bridges.Wins"}, 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 c9eb2cd78..2d231cdd3 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 @@ -11,6 +11,12 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + import mineplex.core.bonuses.BonusManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -22,11 +28,6 @@ import mineplex.core.powerplayclub.PowerPlayClubRepository; import mineplex.core.powerplayclub.PowerPlayClubRewards; import mineplex.core.powerplayclub.PowerPlayData; import mineplex.core.shop.item.ShopItem; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; public class PowerPlayClubButton implements GuiItem { @@ -77,7 +78,7 @@ public class PowerPlayClubButton implements GuiItem } else { - UtilPlayer.message(_player, F.main("Power Play Club", "You have no months left! Buy more months at " + C.cAqua + "www.mineplex.com/shop" + C.Reset + "!")); + UtilPlayer.message(_player, F.main("Power Play Club", "You have no months left! Buy more months at " + F.greenElem("www.mineplex.com/shop") + "!")); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/PetSorter.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/PetSorter.java deleted file mode 100644 index 64de96efc..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/PetSorter.java +++ /dev/null @@ -1,16 +0,0 @@ -package mineplex.core.cosmetic.ui; - -import java.util.Comparator; - -import mineplex.core.pet.Pet; - -public class PetSorter implements Comparator -{ - public int compare(Pet a, Pet b) - { - if (a.getPetType().getTypeId() < b.getPetType().getTypeId()) - return -1; - - return 1; - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/PetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/PetButton.java index 6578303c7..331fa43b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/PetButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/PetButton.java @@ -3,23 +3,23 @@ package mineplex.core.cosmetic.ui.button; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; -import mineplex.core.pet.Pet; import mineplex.core.cosmetic.ui.page.PetPage; +import mineplex.core.pet.PetType; import mineplex.core.shop.item.IButton; public class PetButton implements IButton { - private Pet _pet; + private PetType _petType; private PetPage _page; - public PetButton(Pet pet, PetPage page) + public PetButton(PetType pet, PetPage page) { - _pet = pet; + _petType = pet; _page = page; } public void onClick(Player player, ClickType clickType) { - _page.purchasePet(player, _pet); + _page.purchasePet(player, _petType); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/RenamePetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/RenamePetButton.java index 82cad1f70..631d92c20 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/RenamePetButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/RenamePetButton.java @@ -1,11 +1,10 @@ package mineplex.core.cosmetic.ui.button; -import org.bukkit.entity.Creature; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import mineplex.core.cosmetic.ui.page.PetPage; -import mineplex.core.pet.Pet; +import mineplex.core.pet.PetType; import mineplex.core.shop.item.IButton; public class RenamePetButton implements IButton @@ -21,7 +20,7 @@ public class RenamePetButton implements IButton public void onClick(Player player, ClickType clickType) { _page.playAcceptSound(player); - Creature currentPet = _page.getPlugin().getPetManager().getActivePet(player.getName()); - _page.renamePet(player, new Pet(currentPet.getCustomName(), currentPet.getType(), 1), false); + PetType currentType = _page.getPlugin().getPetManager().getActivePetType(player.getName()); + _page.renamePet(player, currentType, false); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/activate/ActivatePetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/activate/ActivatePetButton.java index 61539e368..310b5843c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/activate/ActivatePetButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/activate/ActivatePetButton.java @@ -5,15 +5,15 @@ import org.bukkit.event.inventory.ClickType; import mineplex.core.cosmetic.ui.page.Menu; import mineplex.core.cosmetic.ui.page.PetPage; -import mineplex.core.pet.Pet; +import mineplex.core.pet.PetType; import mineplex.core.shop.item.IButton; public class ActivatePetButton implements IButton { - private Pet _pet; + private PetType _pet; private PetPage _page; - public ActivatePetButton(Pet pet, PetPage page) + public ActivatePetButton(PetType pet, PetPage page) { _pet = pet; _page = page; @@ -23,7 +23,7 @@ public class ActivatePetButton implements IButton public void onClick(Player player, ClickType clickType) { _page.playAcceptSound(player); - _page.getPlugin().getPetManager().addPetOwner(player, _pet.getPetType(), player.getLocation()); + _page.getPlugin().getPetManager().addPetOwner(player, _pet, player.getLocation()); _page.getShop().openPageForPlayer(player, new Menu(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), 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 52c877e7d..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 @@ -26,7 +26,7 @@ public class ArrowTrailPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.ARROW_TRAIL)) { @@ -37,8 +37,8 @@ public class ArrowTrailPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; + 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 6eebd5515..4d7b0276c 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 @@ -1,5 +1,9 @@ package mineplex.core.cosmetic.ui.page; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; @@ -9,9 +13,6 @@ 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; public class BalloonsPage extends GadgetPage { @@ -24,7 +25,7 @@ public class BalloonsPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.BALLOON)) { @@ -35,10 +36,8 @@ public class BalloonsPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; - if(slot == 35) - slot = 37; + 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/DeathEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java index 22a203051..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 @@ -26,7 +26,7 @@ public class DeathEffectPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.DEATH)) { @@ -37,8 +37,8 @@ public class DeathEffectPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; + 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 9e7ab7349..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 @@ -26,7 +26,7 @@ public class DoubleJumpPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.DOUBLE_JUMP)) { @@ -37,8 +37,8 @@ public class DoubleJumpPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; + 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/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index bd55b33f0..b699559ff 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 @@ -53,7 +53,7 @@ public class GadgetPage extends ShopPageBase protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.ITEM)) { @@ -67,7 +67,7 @@ public class GadgetPage extends ShopPageBase slot++; - if (slot == 26 || slot == 35) + if (slot == 17 || slot == 26) slot += 2; } @@ -165,7 +165,7 @@ public class GadgetPage extends ShopPageBase } else { - itemLore.add(C.cBlue + "Found in Power Play Club"); + itemLore.add(C.cBlue + "Bonus Item Unlocked with Power Play Club"); } } @@ -355,7 +355,25 @@ public class GadgetPage extends ShopPageBase } } - addButton(slot, new ShopItem(gadgetItemStack, false, false).hideInfo(), new ActivateGadgetButton(gadget, this)); + /*if (gadget instanceof MorphStray) + { + gadgetItemStack = UtilItem.getVersionSpecificItem(_player, UtilPlayer.PlayerVersion._1_9, gadgetItemStack); + }*/ + + IButton iButton = new ActivateGadgetButton(gadget, this); + + /*if (gadgetItemStack.getData().getItemType().equals(Material.BARRIER)) + { + iButton = null; + } + else + { + // Does not set the item stack yet + //gadgetItemStack.setType(Material.getMaterial(440)); + }*/ + + + addButton(slot, new ShopItem(gadgetItemStack, false, false).hideInfo(), iButton); } } else 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 c37e4dc9c..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 @@ -29,7 +29,7 @@ public class HatPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; List list = getPlugin().getGadgetManager().getGadgets(GadgetType.HAT); if(list != null) @@ -42,8 +42,8 @@ public class HatPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; + 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/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 4ab38eae7..90e02e269 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 @@ -25,13 +25,12 @@ import mineplex.core.donation.DonationManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.mount.Mount; -import mineplex.core.pet.Pet; +import mineplex.core.pet.PetType; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; import org.bukkit.Material; import org.bukkit.entity.Creature; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -122,10 +121,10 @@ public class Menu extends ShopPageBase int petOwned = 0; int petMax = 0; - for (Pet pet : getPlugin().getPetManager().getFactory().GetPets()) + for (PetType type : PetType.values()) { - Map pets = getPlugin().getPetManager().Get(getPlayer()).getPets(); - if (pets != null && pets.containsKey(pet.getPetType())) + Map pets = getPlugin().getPetManager().Get(getPlayer()).getPets(); + if (pets != null && pets.containsKey(type)) { petOwned++; } 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 291921cd4..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 @@ -1,5 +1,9 @@ package mineplex.core.cosmetic.ui.page; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; @@ -10,9 +14,6 @@ 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; public class MorphPage extends GadgetPage { @@ -24,7 +25,7 @@ public class MorphPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.MORPH)) { @@ -35,11 +36,9 @@ public class MorphPage extends GadgetPage addGlow(slot); slot++; - - if (slot == 26) - slot = 28; - if (slot == 35) - slot = 37; + + 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 86638709d..24d260e4a 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 @@ -39,15 +39,15 @@ public class MountPage extends ShopPageBase protected void buildPage() { - int slot = 19; + int slot = 10; for (Mount mount : getPlugin().getMountManager().getMounts()) { addMount(mount, slot); slot++; - if (slot == 26) - slot = 28; + 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/MusicPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java index 7acb6a46c..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 @@ -26,7 +26,7 @@ public class MusicPage extends GadgetPage protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.MUSIC_DISC)) { @@ -34,8 +34,8 @@ public class MusicPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; + 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 479841a09..0bd0885c2 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 @@ -24,7 +24,7 @@ public class ParticlePage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.PARTICLE)) { @@ -35,10 +35,8 @@ public class ParticlePage extends GadgetPage slot++; - if (slot == 26) - slot = 28; - if(slot == 35) - slot = 37; + 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/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index 30bd7bf8c..cf903bc21 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 @@ -1,7 +1,9 @@ package mineplex.core.cosmetic.ui.page; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.List; import net.minecraft.server.v1_8_R3.Blocks; @@ -25,14 +27,13 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.PetSorter; import mineplex.core.cosmetic.ui.button.PetButton; import mineplex.core.cosmetic.ui.button.RenamePetButton; import mineplex.core.cosmetic.ui.button.activate.ActivatePetButton; import mineplex.core.cosmetic.ui.button.deactivate.DeactivatePetButton; import mineplex.core.donation.DonationManager; -import mineplex.core.pet.Pet; import mineplex.core.pet.PetExtra; +import mineplex.core.pet.PetType; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.AnvilContainer; @@ -49,87 +50,91 @@ public class PetPage extends ShopPageBase protected void buildPage() { - int slot = 19; - - List pets = new ArrayList(getPlugin().getPetManager().getFactory().GetPets()); - - Collections.sort(pets, new PetSorter()); - - for (Pet pet : pets) + int slot = 10; + + PetType[] pets = PetType.values(); + Arrays.sort(pets, Comparator.comparing(type -> type.getEntityType().getTypeId())); + + for (PetType pet : pets) { List itemLore = new ArrayList(); itemLore.add(C.cBlack); - if (pet.getLore() != null) + if (pet.getLore().isPresent()) { - Collections.addAll(itemLore, UtilText.splitLineToArray(C.cGray + pet.getLore(), LineFormat.LORE)); + Collections.addAll(itemLore, UtilText.splitLineToArray(C.cGray + pet.getLore().get(), LineFormat.LORE)); } else { itemLore.add(C.cGray + "Your very own " + pet.getName() + "!"); } //Chest Unlocks - if (!getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType())) + if (!getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet)) { - if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -1) + if (pet.getPrice() == -1) { //Nothing } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -2 || pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0) + else if (pet.getPrice() == -2 || pet.getPrice() > 0) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Treasure Chests"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -3) + else if (pet.getPrice() == -3) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Winter Holiday Treasure"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -4) + else if (pet.getPrice() == -4) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Earned by defeating the Pumpkin King"); itemLore.add(C.cBlue + "in the 2014 Christmas Chaos Event."); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -5) + else if (pet.getPrice() == -5) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Easter Holiday Treasure"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -8) + else if (pet.getPrice() == -8) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Pumpkin's Revenge"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -9) + else if (pet.getPrice() == -9) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Haunted Chests"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -14) + else if (pet.getPrice() == -14) + { + itemLore.add(C.cBlack); + itemLore.add(C.cBlue + "Found in Power Play Club"); + } + else if (pet.getPrice() == -14) { itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Power Play Club"); } //Rank Unlocks - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -10) + else if (pet.getPrice() == -10) { itemLore.add(C.cBlack); itemLore.add(C.cAqua + "Unlocked with Ultra Rank"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -11) + else if (pet.getPrice() == -11) { itemLore.add(C.cBlack); itemLore.add(C.cPurple + "Unlocked with Hero Rank"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -12) + else if (pet.getPrice() == -12) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Unlocked with Legend Rank"); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -13) + else if (pet.getPrice() == -13) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Unlocked with Titan Rank"); @@ -137,21 +142,21 @@ public class PetPage extends ShopPageBase } //Owned - if (getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType())) + if (getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet)) { - String petName = getPlugin().getPetManager().Get(getPlayer()).getPets().get(pet.getPetType()); + String petName = getPlugin().getPetManager().Get(getPlayer()).getPets().get(pet); if (petName == null) { petName = pet.getName(); } - if (getPlugin().getPetManager().hasActivePet(getPlayer().getName()) && getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() == pet.getPetType()) + if (getPlugin().getPetManager().hasActivePet(getPlayer().getName()) && getPlugin().getPetManager().getActivePetType(getPlayer().getName()) == pet) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Disable"); - addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getPetType().getTypeId(), - pet.getPetName() + " (" + C.cWhite + petName + C.cGreen + ")", + addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getEntityType().getTypeId(), + pet.getName() + " (" + C.cWhite + petName + C.cGreen + ")", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivatePetButton(this, getPlugin().getPetManager())); addGlow(slot); @@ -160,56 +165,76 @@ public class PetPage extends ShopPageBase { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Enable"); + /* + ItemStack petItem = ItemStackFactory.Instance.CreateStack(pet.getMaterial(), pet.getData(), 1, + pet.getName() + " (" + C.cWhite + petName + C.cGreen + ")", itemLore); + + IButton iButton = new ActivatePetButton(pet, this); + + if (pet.equals(PetType.SHULKER)) + { + petItem = UtilItem.getVersionSpecificItem(_player, UtilPlayer.PlayerVersion._1_9, petItem); + if (petItem.getType().equals(Material.BARRIER)) + { + iButton = null; + } + else + { + // Does not set the item stack yet + //petItem.setType(Material.getMaterial(201)); + } + }*/ - addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getPetType().getTypeId(), - pet.getPetName() + " (" + C.cWhite + petName + C.cGreen + ")", + addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getEntityType().getTypeId(), + pet.getName() + " (" + C.cWhite + petName + C.cGreen + ")", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivatePetButton(pet, this)); + //addButton(slot, new ShopItem(petItem, false, false), iButton); } } //Not Owned else { - if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0) + if (pet.getPrice() > 0) { itemLore.add(C.cBlack); - itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + pet.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards"); + itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + pet.getPrice() + " Treasure Shards"); } - if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= pet.getCost(GlobalCurrency.TREASURE_SHARD)) + if (pet.getPrice() > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= pet.getPrice()) { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); - addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new PetButton(pet, this)); + addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, pet.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new PetButton(pet, this)); } - else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0) + else if (pet.getPrice() > 0) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Not enough Treasure Shards."); - setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); } else { - setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); } } slot++; - - if (slot == 26) - slot = 28; + + if (slot == 17 || slot == 26) + slot += 2; } slot = 49; - for (PetExtra petExtra : getPlugin().getPetManager().getFactory().GetPetExtras()) + for (PetExtra petExtra : PetExtra.values()) { List itemLore = new ArrayList(); 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()); + getInventory().setItem(slot, new ShopItem(petExtra.getMaterial(), (byte)0, C.cRed + petExtra.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); } // Silverfish = Wither disguised // Villager = Elf @@ -218,7 +243,7 @@ public class PetPage extends ShopPageBase || getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.VILLAGER || getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.ZOMBIE) { - addButton(slot, new ShopItem(petExtra.GetMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.getCost(GlobalCurrency.TREASURE_SHARD) + C.cGreen + " Shards", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); + addButton(slot, new ShopItem(petExtra.getMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.getPrice(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); } slot++; @@ -233,12 +258,12 @@ public class PetPage extends ShopPageBase }); } - public void purchasePet(final Player player, final Pet pet) + public void purchasePet(final Player player, final PetType petType) { - renamePet(player, pet, true); + renamePet(player, petType, true); } - public void renamePet(Player player, Pet pet, boolean petPurchase) + public void renamePet(Player player, PetType pet, boolean petPurchase) { playAcceptSound(player); @@ -260,4 +285,4 @@ public class PetPage extends ShopPageBase getPlugin().getPetManager().removePet(player, true); refresh(); } -} \ No newline at end of file +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java index 0a5c568fa..49756c42f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java @@ -1,9 +1,14 @@ package mineplex.core.cosmetic.ui.page; +import net.minecraft.server.v1_8_R3.ItemStack; +import net.minecraft.server.v1_8_R3.Items; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + import mineplex.cache.player.PlayerCache; import mineplex.core.account.CoreClientManager; import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.cosmetic.CosmeticManager; @@ -11,31 +16,26 @@ import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.CloseButton; import mineplex.core.cosmetic.ui.button.SelectTagButton; import mineplex.core.donation.DonationManager; -import mineplex.core.pet.Pet; import mineplex.core.pet.PetExtra; +import mineplex.core.pet.PetType; import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.core.pet.repository.token.PetToken; import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.SalesPackageProcessor; import mineplex.core.shop.page.ShopPageBase; -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; public class PetTagPage extends ShopPageBase { private String _tagName = "Pet Tag"; - private Pet _pet; + private PetType _petType; private boolean _petPurchase; - public PetTagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Pet pet, boolean petPurchase) + public PetTagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, PetType petType, boolean petPurchase) { super(plugin, shop, clientManager, donationManager, name, player, 3); - _pet = pet; + _petType = petType; _petPurchase = petPurchase; buildPage(); @@ -84,7 +84,7 @@ public class PetTagPage extends ShopPageBase return; } - if (_tagName.equalsIgnoreCase("ULTRA")) + if (_tagName.toLowerCase().contains("ultra")) { UtilPlayer.message(getPlayer(), F.main(getPlugin().getName(), ChatColor.RED + _tagName + " is a restricted name.")); playDenySound(getPlayer()); @@ -92,11 +92,16 @@ public class PetTagPage extends ShopPageBase getShop().openPageForPlayer(getPlayer(), new PetPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Pets", getPlayer())); return; } - - PetExtra tag = new PetExtra("Rename " + _pet.getName() + " to " + _tagName, Material.NAME_TAG, 100); - final SalesPackageBase salesPackage = _petPurchase ? _pet : tag; - - _pet.setDisplayName(C.cGreen + "Purchase " + _tagName); + + final SalesPackageBase salesPackage; + if (_petPurchase) + { + salesPackage = _petType.toSalesPackage(_tagName); + + } else + { + salesPackage = PetExtra.NAME_TAG.toSalesPackage("Rename " + _petType.getName() + " to " + _tagName); + } getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<>(_player, this, new SalesPackageProcessor(_player, GlobalCurrency.TREASURE_SHARD, salesPackage, _donationManager, () -> { @@ -108,8 +113,7 @@ public class PetTagPage extends ShopPageBase token.AccountId = PlayerCache.getInstance().getPlayer(getPlayer().getUniqueId()).getAccountId(); token.Name = getPlayer().getName(); - token.PetType = _pet.getPetType().toString(); - token.PetId = _pet.getPetType().ordinal(); + token.PetType = _petType.toString(); token.PetName = _tagName; PetToken petToken = new PetToken(); @@ -118,7 +122,7 @@ public class PetTagPage extends ShopPageBase if (_petPurchase) { getPlugin().getPetManager().getRepository().AddPet(token); - getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.getPetType()); + getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _petType); } else { @@ -126,7 +130,7 @@ public class PetTagPage extends ShopPageBase getPlugin().getPetManager().addRenamePetToQueue(getPlayer().getName(), token.PetName); } - getPlugin().getPetManager().Get(getPlayer()).getPets().put(_pet.getPetType(), token.PetName); + getPlugin().getPetManager().Get(getPlayer()).getPets().put(_petType, token.PetName); getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer())); }), salesPackage.buildIcon())); 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 1ff5531fc..3db625e5d 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 @@ -29,7 +29,7 @@ public class TauntPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; List list = getPlugin().getGadgetManager().getGadgets(GadgetType.TAUNT); if(list != null) @@ -43,7 +43,7 @@ public class TauntPage extends GadgetPage slot++; if (slot == 26) - slot = 28; + 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 74b50f0ea..3236de2fb 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 @@ -26,7 +26,7 @@ public class WinEffectPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.WIN_EFFECT)) { @@ -37,8 +37,8 @@ public class WinEffectPage extends GadgetPage slot++; - if (slot == 26) - slot = 28; + 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/gamemodifiers/GameModifierPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierPage.java index beeeba200..3b513420a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierPage.java @@ -2,8 +2,6 @@ package mineplex.core.cosmetic.ui.page.gamemodifiers; import java.util.List; -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.cosmetic.ui.page.Menu; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -14,6 +12,8 @@ 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.cosmetic.ui.page.GadgetPage; +import mineplex.core.cosmetic.ui.page.Menu; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.types.GameModifierGadget; @@ -32,7 +32,7 @@ public class GameModifierPage extends GadgetPage @Override protected void buildPage() { - int slot = 19; + int slot = 10; for (GameModifierType type : GameModifierType.values()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierSubPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierSubPage.java index 8049beb5d..7e7dc50c6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierSubPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameModifierSubPage.java @@ -1,24 +1,24 @@ package mineplex.core.cosmetic.ui.page.gamemodifiers; -import mineplex.core.cosmetic.ui.page.GadgetPage; +import java.util.List; + 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.common.util.C; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.cosmetic.ui.page.GadgetPage; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; import mineplex.core.gadget.types.GameModifierGadget; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.List; public class GameModifierSubPage extends GadgetPage { @@ -38,7 +38,7 @@ public class GameModifierSubPage extends GadgetPage { if(_type == null) return; - int slot = 19; + int slot = 10; if (_type.hasKits()) { @@ -78,7 +78,7 @@ public class GameModifierSubPage extends GadgetPage slot++; - if(slot%9 == 8) slot += 2; + if(slot % 9 == 8) slot += 2; } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/KitGameModifierPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/KitGameModifierPage.java index 77590aa93..ec71a2f5c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/KitGameModifierPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/KitGameModifierPage.java @@ -1,5 +1,9 @@ package mineplex.core.cosmetic.ui.page.gamemodifiers; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; @@ -12,9 +16,6 @@ import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; import mineplex.core.gadget.types.GameModifierGadget; 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; public class KitGameModifierPage extends GadgetPage { @@ -36,7 +37,7 @@ public class KitGameModifierPage extends GadgetPage { if(_type == null) return; - int slot = 19; + int slot = 10; for (GameModifierGadget gadget : getPlugin().getGadgetManager().getGameModifiers(_kitType)) { @@ -52,7 +53,7 @@ public class KitGameModifierPage extends GadgetPage slot++; - if(slot%9 == 8) slot += 2; + if(slot % 9 == 8) slot += 2; } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 419576874..78086823e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -114,6 +114,7 @@ import mineplex.core.gadget.gadgets.morph.MorphCow; import mineplex.core.gadget.gadgets.morph.MorphCreeper; import mineplex.core.gadget.gadgets.morph.MorphEnderman; import mineplex.core.gadget.gadgets.morph.MorphGrimReaper; +import mineplex.core.gadget.gadgets.morph.MorphMetalMan; import mineplex.core.gadget.gadgets.morph.MorphPig; import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing; import mineplex.core.gadget.gadgets.morph.MorphSlime; @@ -366,10 +367,11 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphSquid(this)); addGadget(new MorphWitch(this)); addGadget(new MorphGrimReaper(this)); + addGadget(new MorphMetalMan(this)); addGadget(new MorphTurkey(this)); - // Hidden in this update - //addGadget(new MorphSleigh(this)); - //addGadget(new MorphMetalMan(this)); + // Not in this update + //addGadget(new MorphStray(this)); + //addGadget(new MorphSanta(this)); // Particles addGadget(new ParticleFoot(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java index 4f7a4df5c..c2d289d9c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java @@ -1,6 +1,7 @@ package mineplex.core.gadget.commands; -import mineplex.core.account.CoreClient; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; @@ -8,7 +9,6 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; -import org.bukkit.entity.Player; public class AmmoCommand extends CommandBase { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java index e726517a2..e81367341 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java @@ -1,5 +1,8 @@ package mineplex.core.gadget.commands; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; @@ -10,10 +13,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.mount.Mount; -import mineplex.core.pet.Pet; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; +import mineplex.core.pet.PetType; public class LockCosmeticsCommand extends CommandBase { @@ -106,11 +106,10 @@ public class LockCosmeticsCommand extends CommandBase private void removePets(Player caller) { int removed = 0; - for (Pet pet : _plugin.getPetManager().getFactory().GetPets()) + for (PetType pet : PetType.values()) { - if (_plugin.getPetManager().Get(caller).getPets().containsKey(pet.getPetType())) + if (_plugin.getPetManager().Get(caller).getPets().remove(pet) != null) { - _plugin.getPetManager().Get(caller).getPets().remove(pet.getPetType()); removed++; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/ReindeerTestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/ReindeerTestCommand.java deleted file mode 100644 index b8af63074..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/ReindeerTestCommand.java +++ /dev/null @@ -1,85 +0,0 @@ -package mineplex.core.gadget.commands; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.EulerAngle; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilServer; -import mineplex.core.gadget.GadgetManager; - -public class ReindeerTestCommand extends CommandBase -{ - - private GadgetManager _plugin; - private Horse _horse; - private ArmorStand _armorStand; - - public ReindeerTestCommand(GadgetManager plugin) - { - super(plugin, Rank.JNR_DEV, "reindeer"); - _plugin = plugin; - } - - @Override - public void Execute(Player caller, String[] args) - { - if (_horse == null) - { - Location testHorse = new Location(caller.getWorld(), 8.5, 71, 0.5, 0, 0); - testHorse.setYaw(180); - Horse horse = testHorse.getWorld().spawn(testHorse, Horse.class); - horse.setVariant(Horse.Variant.HORSE); - horse.setColor(Horse.Color.BROWN); - horse.setStyle(Horse.Style.NONE); - - UtilEnt.Vegetate(horse, true); - UtilEnt.ghost(horse, true, false); - - /** - * South - * .4 1 .6 - * .2 1 .7 - * 0 4 0 - * 0 2 0 - * - * North - */ - - Location hornALoc = horse.getLocation().clone().add(-.3, 1, -.5); - Location hornBLoc = horse.getLocation().clone().add(-.25, 1, -.6); - - ArmorStand hornA = hornALoc.getWorld().spawn(hornALoc, ArmorStand.class); - hornA.setVisible(false); - hornA.setGravity(false); - hornA.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH)); - hornA.setRightArmPose(new EulerAngle(0, 4, 0)); - - ArmorStand hornB = hornBLoc.getWorld().spawn(hornBLoc, ArmorStand.class); - hornB.setVisible(false); - hornB.setGravity(false); - hornB.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH)); - hornB.setRightArmPose(new EulerAngle(0, 2, 0)); - - _horse = horse; - - Bukkit.getScheduler().scheduleSyncRepeatingTask(UtilServer.getPlugin(), new Runnable() - { - @Override - public void run() - { - Location location = _horse.getLocation(); - location.setYaw(180); - _horse.teleport(location); - } - }, 1l, 1l); - } - } -} 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 f1867e009..3f4c0ea3d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java @@ -1,5 +1,8 @@ package mineplex.core.gadget.commands; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; @@ -10,10 +13,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.mount.Mount; -import mineplex.core.pet.Pet; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; +import mineplex.core.pet.PetType; public class UnlockCosmeticsCommand extends CommandBase { @@ -111,11 +111,11 @@ public class UnlockCosmeticsCommand extends CommandBase private void addPets(Player caller) { int added = 0; - for (Pet pet : _plugin.getPetManager().getFactory().GetPets()) + for (PetType pet : PetType.values()) { - if (!_plugin.getPetManager().Get(caller).getPets().containsKey(pet.getPetType())) + if (!_plugin.getPetManager().Get(caller).getPets().containsKey(pet)) { - _plugin.getPetManager().Get(caller).getPets().put(pet.getPetType(), pet.getName()); + _plugin.getPetManager().Get(caller).getPets().put(pet, pet.getName()); added++; } } 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/freedom/ArrowTrailFreedom.java index 8e6d2bd51..cdc26c768 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java @@ -6,7 +6,7 @@ import mineplex.core.common.util.UtilText; import mineplex.core.common.util.particles.ColoredParticle; import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.particle.unrelated.BabyFireworkEffect; +import mineplex.core.particleeffects.BabyFireworkEffect; import mineplex.core.gadget.types.ArrowEffectGadget; import org.bukkit.ChatColor; import org.bukkit.Color; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoal.java index ebe2d8083..8534e02e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoal.java @@ -1,6 +1,5 @@ package mineplex.core.gadget.gadgets.item; -import mineplex.core.gadget.gadgets.hat.HatType; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Sound; @@ -19,16 +18,18 @@ import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; 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.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent; import mineplex.core.gadget.gadgets.Ammo; +import mineplex.core.gadget.gadgets.hat.HatType; import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes; import mineplex.core.gadget.types.ItemGadget; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.pet.PetType; import mineplex.core.recharge.Recharge; import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardRarity; @@ -130,7 +131,7 @@ public class ItemCoal extends ItemGadget Manager.getPetManager(), Manager.getInventoryManager(), Manager.getDonationManager(), - "Coal Apparition", "Coal Apparition", EntityType.PIG_ZOMBIE, RewardRarity.OTHER, 0, 0); + "Coal Apparition", "Coal Apparition", PetType.PIG_ZOMBIE, RewardRarity.OTHER, 0, 0); if (reward.canGiveReward(player)) reward.giveReward(null, player, new Callback() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGrimReaper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGrimReaper.java index 6586967cd..44c761772 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGrimReaper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGrimReaper.java @@ -105,6 +105,8 @@ public class MorphGrimReaper extends MorphGadget public void disableCustom(Player player, boolean message) { this.removeArmor(player); + player.setFlying(false); + player.setAllowFlight(false); _flying.remove(player); _flyReady.remove(player); _soulManager.resetSouls(player); @@ -189,7 +191,7 @@ public class MorphGrimReaper extends MorphGadget private void setFlying(Player player, boolean flying, boolean isFast) { - if (flying) + if (flying && isActive(player)) { if (UtilPlayer.isSpectator(player)) return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java index fbed219e4..06838168e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java @@ -2,15 +2,21 @@ package mineplex.core.gadget.gadgets.morph; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.Map; import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; import com.mojang.authlib.GameProfile; @@ -18,29 +24,39 @@ import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.GadgetSelectLocationEvent; import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; -import mineplex.core.gadget.gadgets.particle.unrelated.MetalManEffect; import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.particleeffects.MetalManEffect; import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilGameProfile; public class MorphMetalMan extends MorphGadget { private Map _playerColors = new HashMap<>(); + private Map _flying = new HashMap<>(); + + private static final int FLY_TIME = 15; public MorphMetalMan(GadgetManager manager) { super(manager, "Metal Man Morph", UtilText.splitLinesToArray(new String[]{ C.cGray + "This powerful suit forged of metal makes the wearer strong enough to even battle the gods", "", - C.cWhite + "Left-click to shoot laser beam" + C.cWhite + "Left-click to shoot laser beam", + C.cWhite + "Sneak to hover" }, LineFormat.LORE), -14, Material.IRON_INGOT, (byte) 0); } @@ -57,6 +73,8 @@ public class MorphMetalMan extends MorphGadget DisguisePlayer disguisePlayer = new DisguisePlayer(player, gameProfile); disguisePlayer.showInTabList(true, 0); UtilMorph.disguise(player, disguisePlayer, Manager); + + player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 1, true, false)); } @Override @@ -65,6 +83,21 @@ public class MorphMetalMan extends MorphGadget removeArmor(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); + + if (_playerColors.containsKey(player.getUniqueId())) + { + _playerColors.remove(player.getUniqueId()); + } + + if (_flying.containsKey(player)) + { + _flying.remove(player); + } + + player.setFlying(false); + player.setAllowFlight(false); + + player.removePotionEffect(PotionEffectType.SLOW); } @EventHandler @@ -81,7 +114,7 @@ public class MorphMetalMan extends MorphGadget if (player.getItemInHand().getType() != Material.AIR) return; - if (!Recharge.Instance.use(player, getName(), 5000, true, false, "Cosmetics")) + if (!Recharge.Instance.use(player, "Metal Man Missile", 5000, true, false, "Cosmetics")) return; // Creates colored laser @@ -114,6 +147,61 @@ public class MorphMetalMan extends MorphGadget metalManEffect.start(); } + @EventHandler + public void onSneak(PlayerToggleSneakEvent event) + { + if (!isActive(event.getPlayer())) + return; + + if (!event.isSneaking()) + return; + + if (_flying.containsKey(event.getPlayer())) + return; + + Player player = event.getPlayer(); + + if (!Recharge.Instance.use(player, "Metal Man Fly", 45000, true, false, "Cosmetics")) + return; + + UtilAction.velocity(player, new Vector(0, 1, 0)); + player.teleport(player.getLocation().add(0, 1, 0)); + player.playSound(player.getLocation(), Sound.WITHER_SHOOT, 1, 1); + _flying.put(player, System.currentTimeMillis()); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Iterator> iterator = _flying.entrySet().iterator(); + while (iterator.hasNext()) + { + Map.Entry entry = iterator.next(); + Player player = entry.getKey(); + if (!isActive(player)) + { + iterator.remove(); + continue; + } + long started = entry.getValue(); + if (UtilTime.elapsed(started, 15000)) + { + player.setFlying(false); + player.setAllowFlight(false); + iterator.remove(); + continue; + } + player.setAllowFlight(true); + player.setFlying(true); + int filledBars = (int) ((started + 15000 - System.currentTimeMillis()) / 1000); + UtilTextBottom.displayProgress("Flying", "", 15, filledBars, player); + UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, player.getLocation(), 0, 0, 0, 0, 5, UtilParticle.ViewDist.NORMAL); + } + } + public void increaseColor(UUID uuid) { if (_playerColors.containsKey(uuid)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSanta.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSanta.java new file mode 100644 index 000000000..42d46a0a1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSanta.java @@ -0,0 +1,281 @@ +package mineplex.core.gadget.gadgets.morph; + +import java.time.Month; +import java.time.YearMonth; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ItemDespawnEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; + +import com.mojang.authlib.GameProfile; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.SantaPresent; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; + +public class MorphSanta extends MorphGadget +{ + + private HashMap _items = new HashMap<>(); + + private static final int SHARD_CHARGE = 50; + + public MorphSanta(GadgetManager manager) + { + super(manager, "Santa Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), -14, Material.STAINED_CLAY, (byte) 14, YearMonth.of(2016, Month.DECEMBER)); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + GameProfile profile = UtilGameProfile.getGameProfile(player); + profile.getProperties().clear(); + profile.getProperties().put("textures", SkinData.SANTA.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile); + disguisePlayer.showInTabList(true, 0); + UtilMorph.disguise(player, disguisePlayer, Manager); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + } + + // PRESENT + + @EventHandler + public void throwPresent(PlayerInteractEvent event) + { + if (!isActive(event.getPlayer())) + return; + + if (!UtilEvent.isAction(event, UtilEvent.ActionType.L)) + return; + + Player player = event.getPlayer(); + + int type = 0; + + if (UtilMath.random(0.1, 1.1) > 0.76) + { + type = 1; + } + + if (player.getItemInHand().getType() != Material.AIR) + return; + + //if (!Recharge.Instance.use(player, getName(), 150000, true, false, "Cosmetics")) + //return; + + if (type == 0) + { + int shards = UtilMath.rRange(250, 500); + + if (Manager.getDonationManager().Get(player).getBalance(GlobalCurrency.TREASURE_SHARD) < shards + SHARD_CHARGE) + { + UtilPlayer.message(player, F.main("Gadget", "You do not have enough Shards.")); + return; + } + + Item present = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), + SkinData.PRESENT.getSkull("Present " + System.currentTimeMillis(), new ArrayList<>())); + UtilAction.velocity(present, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false); + + Manager.getDonationManager().RewardCoinsLater(this.getName() + " Present Hide", player, -(shards + SHARD_CHARGE)); + + present.setPickupDelay(40); + + _items.put(present, new SantaPresent(player.getName(), SantaPresent.PresentType.PRESENT, shards)); + + //Announce + Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() + + ChatColor.RESET + C.Bold + " hid a " + + C.cRed + C.Bold + "Christmas Present" + + ChatColor.RESET + C.Bold + " worth " + + C.cRed + C.Bold + shards + " Shards"); + + for (Player other : UtilServer.getPlayers()) + other.playSound(other.getLocation(), Sound.BLAZE_HIT, 1.5f, 1.5f); + } + else + { + ItemStack coalStack = ItemStackFactory.Instance.CreateStack(Material.COAL, (byte)0, 1, "Hidden Coal" + System.currentTimeMillis()); + Item coal = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), coalStack); + UtilAction.velocity(coal, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false); + + int coals = UtilMath.rRange(1, 3); + + coal.setPickupDelay(40); + + _items.put(coal, new SantaPresent(player.getName(), SantaPresent.PresentType.COAL, coals)); + + //Announce + Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() + + ChatColor.RESET + C.Bold + " hid a " + + C.cRed + C.Bold + "Christmas Coal" + + ChatColor.RESET + C.Bold + " worth " + + C.cRed + C.Bold + coals + " Coal Ammo"); + + for (Player other : UtilServer.getPlayers()) + other.playSound(other.getLocation(), Sound.DIG_SNOW, 1.5f, 1.5f); + } + } + + @EventHandler + public void presentPickup(PlayerPickupItemEvent event) + { + if (_items.containsKey(event.getItem()) && !_items.get(event.getItem()).getThrower().equals(event.getPlayer().getName())) + { + SantaPresent santaPresent = _items.get(event.getItem()); + + _items.remove(event.getItem()); + + event.setCancelled(true); + event.getItem().remove(); + + int presentsLeft = 0, coalsLeft = 0; + for (SantaPresent present : _items.values()) + { + if (present.getPresentType().equals(SantaPresent.PresentType.PRESENT)) + { + presentsLeft++; + } + else if (present.getPresentType().equals(SantaPresent.PresentType.COAL)) + { + coalsLeft++; + } + } + + if (santaPresent.getPresentType().equals(SantaPresent.PresentType.PRESENT)) + { + Manager.getDonationManager().RewardCoinsLater(getName() + " Present Pickup", event.getPlayer(), santaPresent.getAmmo()); + + //Announce + Bukkit.broadcastMessage(C.cGold + C.Bold + event.getPlayer().getName() + + ChatColor.RESET + C.Bold + " found a " + + C.cGold + C.Bold + "Christmas Present" + + ChatColor.RESET + C.Bold + "! " + presentsLeft + " Presents left!"); + } + else if (santaPresent.getPresentType().equals(SantaPresent.PresentType.COAL)) + { + // Gives coals + Manager.getInventoryManager().addItemToInventory(event.getPlayer(), "Coal", santaPresent.getAmmo()); + + //Announce + Bukkit.broadcastMessage(C.cGold + C.Bold + event.getPlayer().getName() + + ChatColor.RESET + C.Bold + " found a " + + C.cGold + C.Bold + "Christmas Coal" + + ChatColor.RESET + C.Bold + "! " + coalsLeft + " Coals left!"); + } + + event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1.5f, 0.75f); + event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1.5f, 1.25f); + + UtilFirework.playFirework(event.getItem().getLocation(), FireworkEffect.Type.BURST, Color.RED, true, true); + } + } + + @EventHandler + public void presentClean(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + Iterator presentIter = _items.keySet().iterator(); + + while (presentIter.hasNext()) + { + Item presentItem = presentIter.next(); + + if (!presentItem.isValid() || presentItem.getTicksLived() > 24000) + { + SantaPresent santaPresent = _items.get(presentItem); + + presentItem.remove(); + presentIter.remove(); + + //Announce + if (santaPresent.getPresentType().equals(SantaPresent.PresentType.PRESENT)) + { + int presentsLeft = 0; + for (SantaPresent present : _items.values()) + { + if (present.getPresentType().equals(SantaPresent.PresentType.PRESENT)) + { + presentsLeft++; + } + } + Bukkit.broadcastMessage( + ChatColor.RESET + C.Bold + "No one found a " + + C.cGold + C.Bold + "Christmas Present" + + ChatColor.RESET + C.Bold + "! " + presentsLeft + " Presents left!"); + } + else if (santaPresent.getPresentType().equals(SantaPresent.PresentType.COAL)) + { + int coalsLeft = 0; + for (SantaPresent present : _items.values()) + { + if (present.getPresentType().equals(SantaPresent.PresentType.COAL)) + { + coalsLeft++; + } + } + Bukkit.broadcastMessage( + ChatColor.RESET + C.Bold + "No one found a " + + C.cGold + C.Bold + "Christmas Coal" + + ChatColor.RESET + C.Bold + "! " + coalsLeft + " Coals left!"); + } + } + else + { + UtilParticle.PlayParticle(UtilParticle.ParticleType.SNOW_SHOVEL, presentItem.getLocation().add(0, 0.1, 0), 0.1f, 0.1f, 0.1f, 0, 1, + UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + + @EventHandler + public void presentDespawnCancel(ItemDespawnEvent event) + { + if (_items.containsKey(event.getEntity())) + event.setCancelled(true); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSleigh.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSleigh.java deleted file mode 100644 index 9f6bb794c..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSleigh.java +++ /dev/null @@ -1,238 +0,0 @@ -package mineplex.core.gadget.gadgets.morph; - -import java.io.File; -import java.io.IOException; -import java.time.Month; -import java.time.YearMonth; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -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.event.vehicle.VehicleExitEvent; - -import mineplex.core.common.block.schematic.Schematic; -import mineplex.core.common.block.schematic.UtilSchematic; -import mineplex.core.common.util.F; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilText; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.morph.managers.sleigh.Sleigh; -import mineplex.core.gadget.gadgets.morph.managers.sleigh.SleighPosition; -import mineplex.core.gadget.types.MorphGadget; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - -public class MorphSleigh extends MorphGadget -{ - - /** - * Directions of the Sleigh, with the correct coord for the player to be teleported and the schematic name - */ - public enum SleighDirection - { - NORTH("SleighMorphNorth.schematic", 0.5, 4.5), - SOUTH("SleighMorphSouth.schematic", 0.5, 1.5), - EAST("SleighMorphEast.schematic", 1.5, 1.5), - WEST("SleighMorphWest.schematic", 4.5, 1.5); - - private String _schematic; - private double _fixedX; - private double _fixedZ; - - SleighDirection(String schematic, double fixedX, double fixedZ) - { - _schematic = schematic; - _fixedX = fixedX; - _fixedZ = fixedZ; - } - - public String getSchematic() - { - return _schematic; - } - - public double getFixedX() - { - return _fixedX; - } - - public double getFixedZ() - { - return _fixedZ; - } - - } - - private Map _sleighs = new HashMap<>(); - private Map _schematics = new HashMap<>(); - - private List _positions = new ArrayList<>(); - - private Long _rightClickStart = null; - - public MorphSleigh(GadgetManager manager) - { - super(manager, "Sleigh Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), -14, Material.STAINED_CLAY, (byte) 14, YearMonth.of(2016, Month.DECEMBER)); - // Loads sleigh schematics - for (SleighDirection sleighDirection : SleighDirection.values()) - { - try - { - Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/" + sleighDirection.getSchematic())); - _schematics.put(sleighDirection, schematic); - } catch (IOException e) - { - e.printStackTrace(); - } - } - buildPositions(); - } - - @Override - public void enableCustom(Player player, boolean message) - { - applyArmor(player, message); - - // TODO DISGUISE - } - - @Override - public void disableCustom(Player player, boolean message) - { - removeArmor(player); - - // TODO UNDISGUISE - if (_sleighs.containsKey(player)) - { - _sleighs.get(player).stopEffect(); - _sleighs.remove(player); - } - } - - /** - * Activates the sleigh effect when left-clicking - * This will be changed in the next releases - * @param event - */ - @EventHandler - public void activateSleigh(PlayerInteractEvent event) - { - if (!isActive(event.getPlayer())) - return; - - if (!UtilEvent.isAction(event, UtilEvent.ActionType.L)) - return; - - Player player = event.getPlayer(); - - if (player.getItemInHand().getType() != Material.AIR) - return; - - //if (!Recharge.Instance.use(player, getName(), 150000, true, false, "Cosmetics")) - //return; - - List freePositions = _positions.stream().filter(position -> !position.isUsed()).collect(Collectors.toList()); - - if (freePositions.size() == 0) - { - UtilPlayer.message(player, F.main("Sleigh Ride", "There are too many sleighs in the sky right now! Please wait a minute and try again!")); - return; - } - - int randomPosition = UtilMath.random.nextInt(freePositions.size()); - SleighPosition position = freePositions.get(randomPosition); - position.setUsed(true); - SleighDirection direction = position.getDirection(); - Schematic schematic = _schematics.get(direction); - if (schematic == null) - { - try - { - schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/SleighMorph.schematic")); - Location fixYaw = player.getLocation().clone(); - fixYaw.setYaw(90); - player.teleport(fixYaw); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - Sleigh sleigh = new Sleigh(player, schematic, position); - sleigh.startEffect(); - _sleighs.put(player, sleigh); - } - - /** - * Stops player from leaving the sleigh if it's activte - * @param event - */ - @EventHandler - public void onLeaveVehicle(VehicleExitEvent event) - { - if (event.getExited() instanceof Player) - { - Player player = (Player) event.getExited(); - if (isActive(player)) - { - event.setCancelled(true); - } - } - } - - /** - * Creates positions in the hub map - * TODO add arcade positions - */ - private void buildPositions() - { - _positions.add(new SleighPosition(-11, 143, -30, SleighDirection.SOUTH, -9.5, 145.5, -28.5)); - _positions.add(new SleighPosition(57, 109, -150, SleighDirection.SOUTH, 58.5, 111.5, -148.5)); - _positions.add(new SleighPosition(141, 101, 80, SleighDirection.NORTH, 142.5, 103.5, 84.5)); - _positions.add(new SleighPosition(-12, 88, 85, SleighDirection.NORTH, -10.5, 90.5, 89.5)); - _positions.add(new SleighPosition(-95, 90, 70, SleighDirection.NORTH, -93.5, 92.5, 74.5)); - _positions.add(new SleighPosition(-105, 115, -80, SleighDirection.EAST, -103.5, 117.5, -78.5)); - _positions.add(new SleighPosition(-135, 97, -8, SleighDirection.EAST, -133.5, 99.5, -6.5)); - _positions.add(new SleighPosition(-45, 97, 15, SleighDirection.EAST, -43.5, 99.5, 16.5)); - _positions.add(new SleighPosition(136, 116, 85, SleighDirection.WEST, 140.5, 118.5, 86.5)); - } - - /** - * Removes sleighs if they run out of time, or moves them if they still have time - * @param event - */ - @EventHandler - public void onUpdate(UpdateEvent event) - { - if (event.getType() == UpdateType.FASTER) - { - _sleighs.values().forEach(Sleigh::playSound); - } - - if (event.getType() != UpdateType.TICK) - return; - - Iterator> iterator = _sleighs.entrySet().iterator(); - while (iterator.hasNext()) - { - Map.Entry entry = iterator.next(); - Sleigh sleigh = entry.getValue(); - if (!sleigh.update()) - { - iterator.remove(); - } - } - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphStray.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphStray.java new file mode 100644 index 000000000..a2fecafb5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphStray.java @@ -0,0 +1,128 @@ +package mineplex.core.gadget.gadgets.morph; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.inventory.ItemStack; + +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.disguise.disguises.DisguiseSquid; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.itemstack.ItemStackFactory; + +/** + * THIS MORPH IS 1.9+ ONLY + */ +public class MorphStray extends MorphGadget +{ + + private List _strayArrows = new ArrayList<>(); + private ItemStack _arrow; + + public MorphStray(GadgetManager manager) + { + super(manager, "Stray Morph", UtilText.splitLinesToArray(new String[]{ + C.cGray + "Even though it's a stray your mom probably won't let you keep this puppy.", + "", + C.cWhite + "Gains an arrow every 5 seconds with EXTREME knockback." + }, LineFormat.LORE), + 0, Material.BARRIER, (byte) 0); + _arrow = ItemStackFactory.Instance.CreateStack(Material.ARROW, (byte) 0, 1, C.cGreen + "Stray Arrow", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE)); + } + + @Override + public void enableCustom(Player player, boolean message) + { + // TODO CHECK IF LOBBY IS 1.9+ + applyArmor(player, message); + DisguiseSquid disguiseSquid = new DisguiseSquid(player); + UtilMorph.disguise(player, disguiseSquid, Manager); + + // Gives bow and arrow + ItemStack bow = ItemStackFactory.Instance.CreateStack(Material.BOW, (byte) 0, 1, C.cGreen + "Stray Bow", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE)); + player.getInventory().setItem(2, bow); + player.getInventory().setItem(17, _arrow); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + + // Removes bow and arrow + player.getInventory().setItem(2, new ItemStack(Material.AIR)); + player.getInventory().setItem(17, new ItemStack(Material.AIR)); + } + + @EventHandler + public void onShoot(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + return; + + if (!(event.getProjectile() instanceof Arrow)) + return; + + Player player = (Player) event.getEntity(); + + if (!isActive(player)) + return; + + _strayArrows.add((Arrow) event.getProjectile()); + + Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + player.getInventory().setItem(17, _arrow); + } + }, 3 * 20L); + } + + @EventHandler + public void onArrowHitPlayer(EntityDamageByEntityEvent event) + { + if (!(event.getDamager() instanceof Arrow)) + return; + + if (!(event.getEntity() instanceof Player)) + return; + + if (!(((Arrow) event.getDamager()).getShooter() instanceof Player)) + return; + + Arrow arrow = (Arrow) event.getDamager(); + Player player = (Player) event.getEntity(); + + if (!_strayArrows.contains(arrow)) + return; + + _strayArrows.remove(arrow); + + Player shooter = (Player) arrow.getShooter(); + arrow.remove(); + + if (shooter.getUniqueId().equals(player.getUniqueId())) + return; + + player.setVelocity(player.getVelocity().multiply(-15).setY(15)); + UtilPlayer.message(player, F.main("Stray Arrow", "You were hit with a " + F.greenElem("Stray Arrow") + " from " + F.name(shooter.getName()) + " and got knocked back!")); + UtilPlayer.message(shooter, F.main("Stray Arrow", "You hit " + F.name(player.getName()) + " with the " + F.greenElem("Stray Arrow") + " and they got knocked back!")); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java index ce6598a5d..a30b400fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java @@ -5,7 +5,7 @@ import java.util.Map; import java.util.Set; import mineplex.core.common.util.UtilServer; -import mineplex.core.gadget.gadgets.particle.unrelated.WitchParticleEffect; +import mineplex.core.particleeffects.WitchParticleEffect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Bat; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/SantaPresent.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/SantaPresent.java new file mode 100644 index 000000000..5a05ad30c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/SantaPresent.java @@ -0,0 +1,38 @@ +package mineplex.core.gadget.gadgets.morph.managers; + +public class SantaPresent +{ + + public enum PresentType + { + PRESENT, + COAL + } + + private final String _thrower; + private final PresentType _presentType; + private final int _ammo; + + public SantaPresent(String thrower, PresentType presentType, int ammo) + { + _thrower = thrower; + _presentType = presentType; + _ammo = ammo; + } + + public String getThrower() + { + return _thrower; + } + + public PresentType getPresentType() + { + return _presentType; + } + + public int getAmmo() + { + return _ammo; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/Sleigh.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/Sleigh.java deleted file mode 100644 index 07a32faaf..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/Sleigh.java +++ /dev/null @@ -1,187 +0,0 @@ -package mineplex.core.gadget.gadgets.morph.managers.sleigh; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Player; - -import mineplex.core.common.block.schematic.Schematic; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.gadget.gadgets.morph.MorphSleigh; - -/** - * Creates the sleigh effect for the Sleigh Morph - */ -public class Sleigh -{ - - private Map _oldBlockMaterials = new HashMap<>(); - private Map _oldBlockDatas = new HashMap<>(); - - private Player _player; - private Location _originalLocation; - private Schematic _schematic; - private SleighPosition _sleighPosition; - private Arrow _arrow; - private float _yaw; - - private int _moves = 0; - - public Sleigh(Player player, Schematic schematic, SleighPosition sleighPosition) - { - _player = player; - _schematic = schematic; - _sleighPosition = sleighPosition; - _yaw = (sleighPosition.getDirection() == MorphSleigh.SleighDirection.SOUTH) ? 0f : - (sleighPosition.getDirection() == MorphSleigh.SleighDirection.NORTH) ? 180f : - (sleighPosition.getDirection() == MorphSleigh.SleighDirection.WEST) ? 90f : -90f; - } - - /** - * Starts the sleigh effect - */ - public void startEffect() - { - _originalLocation = _player.getLocation().clone(); - Location origin = new Location(_originalLocation.getWorld(), _sleighPosition.getX(), - _sleighPosition.getY(), _sleighPosition.getZ()); - try - { - pasteSchematic(origin, 0, 0); - } catch (IOException e) - { - e.printStackTrace(); - } - } - - /** - * Stops the sleigh effect - */ - public void stopEffect() - { - restoreBlocks(); - _arrow.remove(); - _player.teleport(_originalLocation.clone().add(0, 5, 0)); - _sleighPosition.setUsed(false); - } - - /** - * Pastes the schematic for the sleigh - * @param origin The location where the sleigh schematic will be placed - * @param playerX The X coord where player will be teleported - * @param playerZ The Z coord where player will be teleported - * @throws IOException - */ - private void pasteSchematic(Location origin, int playerX, int playerZ) throws IOException - { - restoreBlocks(); - short width = _schematic.getWidth(); - short height = _schematic.getHeight(); - short length = _schematic.getLength(); - for (short x = 0; x < width; x++) - { - for (short y = 0; y < height; y++) - { - for (short z = 0; z < length; z++) - { - Location location = origin.clone().add(x, y, z); - _oldBlockMaterials.put(location, location.getBlock().getType()); - _oldBlockDatas.put(location, location.getBlock().getData()); - } - } - } - _schematic.paste(origin); - Location playerLoc = new Location(_originalLocation.getWorld(), _sleighPosition.getPlayerX() + playerX, - _sleighPosition.getPlayerY(), _sleighPosition.getPlayerZ() + playerZ); - // Spawns arrow so it looks like player is sitting on the sleigh - if (_arrow != null) - { - _arrow.remove(); - } - _arrow = playerLoc.getWorld().spawn(playerLoc, Arrow.class); - UtilEnt.ghost(_arrow, true, true); - playerLoc.setYaw(_yaw); - playerLoc.setPitch(0.0f); - _player.teleport(playerLoc); - _arrow.setPassenger(_player); - } - - /** - * Updates sleigh to look like its moving - * @return true if the sleigh was moved, false if the time is over (3 seconds) - */ - public boolean update() - { - _moves++; - int x = 0, z = 0; - switch (_sleighPosition.getDirection()) - { - case NORTH: - z = -1 * _moves; - break; - case SOUTH: - z = _moves; - break; - case WEST: - x = -1 * _moves; - break; - case EAST: - x = _moves; - } - Location newOrigin = new Location(_originalLocation.getWorld(), _sleighPosition.getX() + x, - _sleighPosition.getY(), _sleighPosition.getZ() + z); - restoreBlocks(); - UtilParticle.PlayParticle(UtilParticle.ParticleType.SNOW_SHOVEL, _player.getLocation(), 0f, 0f, 0f, 0.6f, 100, - UtilParticle.ViewDist.LONGER, UtilServer.getPlayers()); - try - { - pasteSchematic(newOrigin, x, z); - } catch (IOException e) - { - e.printStackTrace(); - } - if (_moves >= 20 * 3) - { - stopEffect(); - return false; - } - return true; - } - - /** - * Plays sleigh sound to the player - */ - public void playSound() - { - _player.playSound(_player.getLocation(), Sound.ORB_PICKUP, 1f, 1f); - } - - /** - * Restores the blocks that were changed from pasting the schematic - */ - private void restoreBlocks() - { - for (Map.Entry entry : _oldBlockMaterials.entrySet()) - { - Location location = entry.getKey(); - Material material = entry.getValue(); - byte data = 0; - if (_oldBlockDatas.containsKey(location)) - { - data = _oldBlockDatas.get(location); - } - location.getBlock().setType(material); - location.getBlock().setData(data); - } - _oldBlockMaterials.clear(); - _oldBlockDatas.clear(); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/SleighPosition.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/SleighPosition.java deleted file mode 100644 index f8d76bd3d..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/sleigh/SleighPosition.java +++ /dev/null @@ -1,76 +0,0 @@ -package mineplex.core.gadget.gadgets.morph.managers.sleigh; - -import mineplex.core.gadget.gadgets.morph.MorphSleigh; - -/** - * Handles positions from Sleigh and player, and the direction of the sleigh and player - */ -public class SleighPosition -{ - - private int _x; - private int _y; - private int _z; - private MorphSleigh.SleighDirection _direction; - private double _playerX; - private double _playerY; - private double _playerZ; - private boolean _used; - - public SleighPosition(int x, int y, int z, MorphSleigh.SleighDirection direction, double playerX, double playerY, double playerZ) - { - _x = x; - _y = y; - _z = z; - _direction = direction; - _playerX = playerX; - _playerY = playerY; - _playerZ = playerZ; - _used = false; - } - - public int getX() - { - return _x; - } - - public int getY() - { - return _y; - } - - public int getZ() - { - return _z; - } - - public MorphSleigh.SleighDirection getDirection() - { - return _direction; - } - - public double getPlayerX() - { - return _playerX; - } - - public double getPlayerY() - { - return _playerY; - } - - public double getPlayerZ() - { - return _playerZ; - } - - public void setUsed(boolean used) - { - _used = used; - } - - public boolean isUsed() - { - return _used; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedom.java index 65b2525cf..4b639156c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedom.java @@ -7,7 +7,7 @@ import java.util.UUID; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.particle.unrelated.FreedomFireworkEffect; +import mineplex.core.particleeffects.FreedomFireworkEffect; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.updater.event.UpdateEvent; import org.bukkit.ChatColor; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java index 17d8c4075..49aaa7bbe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectHalloween.java @@ -26,7 +26,7 @@ import mineplex.core.common.util.particles.ColoredParticle; import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.particle.unrelated.BabyFireworkEffect; +import mineplex.core.particleeffects.BabyFireworkEffect; import mineplex.core.gadget.types.WinEffectGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java index dec383adb..5f6453616 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java @@ -5,15 +5,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Map.Entry; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilTime; - import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; @@ -30,14 +23,20 @@ import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent; import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.inventory.InventoryType.SlotType; +import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; + public class ItemStackFactory extends MiniPlugin { public static ItemStackFactory Instance; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFreedomHorse.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFreedomHorse.java index 5f8c2d498..e270d9f36 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFreedomHorse.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFreedomHorse.java @@ -3,10 +3,9 @@ package mineplex.core.mount.types; import java.util.*; import java.util.List; -import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; -import mineplex.core.gadget.gadgets.particle.unrelated.FreedomTrailEffect; +import mineplex.core.particleeffects.FreedomTrailEffect; import mineplex.core.mount.HorseMount; import mineplex.core.mount.MountManager; import mineplex.core.mount.SingleEntityMountData; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/BabyFireworkEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BabyFireworkEffect.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/BabyFireworkEffect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BabyFireworkEffect.java index 69714b83d..d0fdbc78e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/BabyFireworkEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BabyFireworkEffect.java @@ -1,14 +1,15 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; import java.util.Random; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.particles.ColoredParticle; import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.common.util.particles.NormalParticle; -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.plugin.java.JavaPlugin; public class BabyFireworkEffect extends Effect { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/Effect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/Effect.java similarity index 80% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/Effect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/Effect.java index b819c0e56..818d75c63 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/Effect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/Effect.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; @@ -11,6 +11,7 @@ public abstract class Effect public EffectLocation _effectLocation; public EffectLocation _targetLocation; protected JavaPlugin _javaPlugin; + private boolean _running = false; public Effect(int ticks, EffectLocation effectLocation, JavaPlugin javaPlugin) { @@ -29,6 +30,8 @@ public abstract class Effect public void start() { + onStart(); + _running = true; _task = Bukkit.getScheduler().scheduleSyncRepeatingTask(_javaPlugin, new Runnable() { @Override @@ -42,9 +45,15 @@ public abstract class Effect public void stop() { + _running = false; Bukkit.getScheduler().cancelTask(_task); + onStop(); } + public void onStart(){}; + + public void onStop(){}; + private void update() { _ticks++; @@ -52,6 +61,11 @@ public abstract class Effect Bukkit.getScheduler().cancelTask(_task); } + public boolean isRunning() + { + return _running; + } + public abstract void runEffect(); public void setTargetLocation(EffectLocation effectLocation) @@ -64,4 +78,9 @@ public abstract class Effect return _targetLocation; } + public EffectLocation getEffectLocation() + { + return _effectLocation; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/EffectLocation.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/EffectLocation.java similarity index 92% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/EffectLocation.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/EffectLocation.java index 81ab19200..7cb36a401 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/EffectLocation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/EffectLocation.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; import org.bukkit.Location; import org.bukkit.entity.Entity; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/FreedomFireworkEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomFireworkEffect.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/FreedomFireworkEffect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomFireworkEffect.java index cc63e8fae..8ea666184 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/FreedomFireworkEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomFireworkEffect.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; import org.bukkit.Color; import org.bukkit.Location; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/FreedomTrailEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomTrailEffect.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/FreedomTrailEffect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomTrailEffect.java index 2a0be19fa..86f55dfa1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/FreedomTrailEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/FreedomTrailEffect.java @@ -1,13 +1,15 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.entity.Entity; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.particles.ColoredParticle; import mineplex.core.common.util.particles.DustSpellColor; -import org.bukkit.*; -import org.bukkit.entity.Entity; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.util.Vector; public class FreedomTrailEffect extends Effect { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/HalloweenSmashedEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/HalloweenSmashedEffect.java similarity index 91% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/HalloweenSmashedEffect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/HalloweenSmashedEffect.java index c8ab96a6f..f99fe1ad8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/HalloweenSmashedEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/HalloweenSmashedEffect.java @@ -1,10 +1,11 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; -import mineplex.core.common.util.UtilFirework; import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.common.util.UtilFirework; + public class HalloweenSmashedEffect extends Effect { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java similarity index 66% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java index b60de7ee9..bb5615b72 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java @@ -1,18 +1,24 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; -import java.awt.*; import java.util.HashMap; +import java.util.HashSet; -import mineplex.core.common.util.*; -import mineplex.core.common.util.particles.ColoredParticle; -import mineplex.core.common.util.particles.DustSpellColor; import org.bukkit.Color; -import mineplex.core.gadget.types.Gadget; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.gadget.types.Gadget; + public class MetalManEffect extends Effect { @@ -23,20 +29,28 @@ public class MetalManEffect extends Effect private Location _fixedLoc; private Gadget _gadget; private Player _player; + private int _totalCount = 0; + private boolean _forceStop = false; public MetalManEffect(Location location, Location target, int color, Gadget gadget, Player player) { - super(-1, new EffectLocation(location), gadget.Manager.getPlugin()); + super(-1, new EffectLocation(player), gadget.Manager.getPlugin()); _color = color; _gadget = gadget; _player = player; setTargetLocation(new EffectLocation(target)); } + @Override + public void onStart() + { + _player.getWorld().playSound(_player.getLocation(), Sound.PISTON_RETRACT, 1f, 1f); + } + @Override public void runEffect() { - Location location = _effectLocation.getFixedLocation().clone(); + Location location = _effectLocation.getFixedLocation().clone().add(0, 1, 0); if (_vector == null) { Location targetLoc = getTargetLocation().getFixedLocation().clone(); @@ -54,21 +68,41 @@ public class MetalManEffect extends Effect coloredParticle.setLocation(_fixedLoc); coloredParticle.display(UtilParticle.ViewDist.LONG); } - if (_fixedLoc.getBlock().getType() != Material.AIR || _count == 1000) + if (_fixedLoc.getBlock().getType() != Material.AIR ) { - explode(); + stop(); + } + else if (_count >= 1000) + { + _forceStop = true; + stop(); } _count += 5; } - private void explode() + @Override + public void onStop() { - this.stop(); + if (!_forceStop) + { + _count = 0; + _vector = null; + HashSet ignore = new HashSet(); + ignore.add(Material.AIR); + Location loc = _player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5); + _effectLocation = new EffectLocation(_player); + setTargetLocation(new EffectLocation(loc)); + _totalCount++; + if (_totalCount != 3) + { + start(); + } + } // Creates the explosion and knockback players Location loc = _fixedLoc; loc.getWorld().createExplosion(loc, 0f); UtilParticle.PlayParticle(UtilParticle.ParticleType.EXPLODE, loc, 3f, 3f, 3f, 0, 32, UtilParticle.ViewDist.MAX, UtilServer.getPlayers()); - HashMap players = UtilPlayer.getInRadius(loc, 5d); + HashMap players = UtilPlayer.getInRadius(loc, 9d); for (Player ent : players.keySet()) { if (_gadget.Manager.collideEvent(_player, _gadget, ent)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearEffect.java new file mode 100644 index 000000000..f9ea7e172 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearEffect.java @@ -0,0 +1,155 @@ +package mineplex.core.particleeffects; + +public class NewYearEffect //extends Effect +{ + + /*private static final int SECONDS_IN_A_MINUTE = 60; + + private final Location _ballLocation, _clockLocation, _timerLocation, _timerLocationTen; + + private int _seconds = 90; + private Collection _blocks = new ArrayList<>(); + private List _schematics = new ArrayList<>(); + private boolean _placed = false; + private int _currentRun = 0; + + public NewYearEffect(JavaPlugin plugin, Location location) + { + super(-1, new EffectLocation(location), plugin, 10); + _ballLocation = new Location(location.clone().getWorld(), 0, 71, 38); + _clockLocation = _ballLocation.clone().add(-12, 0, -15); + _timerLocation = _clockLocation.clone().add(19, 7, 0); + _timerLocationTen = _timerLocation.clone().add(1, 0, 0); + try + { + for (int i = 0; i <= 10; i++) + { + Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/NewYearBall" + i + ".schematic")); + _schematics.add(i, schematic); + } + Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/NewYearClock.schematic")); + _schematics.add(11, schematic); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + @Override + public void runEffect() + { + if (!_placed) + { + pasteSchematic(10, true); + _placed = true; + } + + if (_seconds == -60) + { + stop(); + return; + } + + if (_seconds == 0) + { + List fireworkLocations = new ArrayList<>(); + List fixedFireworkLocations = new ArrayList<>(); + int[][] fireworkCoords = new int[][] + { + {0, 77, -37}, + {-6, 71, 17}, + {6, 71, 17}, + {12, 71, 7}, + {-12, 71, 7}, + {5, 71, 92}, + {-7, 71, 92}, + {-9, 103, 37}, + {13, 107, 40} + }; + fireworkLocations.addAll(Arrays.asList(fireworkCoords)); + int[][] fixedFireworkCoords = new int[][] + { + {0, 80, 0}, + {0, 80, -32}, + {6, 80, -26}, + {-6, 80, -26} + }; + fixedFireworkLocations.addAll(Arrays.asList(fixedFireworkCoords)); + NewYearFireworkEffect newYearFireworkEffect = new NewYearFireworkEffect(_javaPlugin, fireworkLocations, fixedFireworkLocations, getEffectLocation().getFixedLocation().getWorld()); + newYearFireworkEffect.start(); + } + + if (_currentRun % 2 != 0 && _seconds >= 0) + { + //Format seconds + int totalMinutes = 0, totalSeconds = 0, placeholder; + placeholder = _seconds; + if (_seconds > SECONDS_IN_A_MINUTE) + { + while (placeholder > SECONDS_IN_A_MINUTE) + { + totalMinutes++; + placeholder -= SECONDS_IN_A_MINUTE; + } + } + totalSeconds = placeholder; + String formatted = String.format("%02d:%02d", totalMinutes, totalSeconds); + if (_seconds <= 10) + { + formatted = "| " + _seconds + " |"; + pasteSchematic(_seconds, false); + } + updateTimer(formatted, (byte) 0); + _seconds--; + } + else if (_seconds >= 0 && _seconds <= 10) + { + updateTimer("| " + _seconds + " |", (byte) 14); + } + else if (_currentRun % 2 != 0 && _seconds < 0) + { + updateTimer("2017!", (byte) 0); + _seconds--; + } + else if (_seconds < 0) + { + updateTimer("2017!", (byte) 14); + } + + _currentRun++; + } + + @Override + public void onStop() + { + _blocks.forEach(b -> b.setType(Material.AIR)); + _blocks.clear(); + updateTimer("2017!", (byte) 14); + } + + private void pasteSchematic(int second, boolean pasteClock) + { + Schematic schematic = _schematics.get(second); + if (schematic != null) + { + schematic.paste(_ballLocation, false, true); + + if (pasteClock) + { + Schematic clockSchematic = _schematics.get(11); + clockSchematic.paste(_clockLocation); + } + } + } + + private void updateTimer(String time, byte color) + { + // Clears previous blocks + _blocks.forEach(b -> b.setType(Material.AIR)); + + Collection blocks = UtilBlockText.MakeText(time, (_seconds <= 10 && _seconds >= 0) ? _timerLocationTen : _timerLocation, BlockFace.WEST, Material.STAINED_CLAY.getId(), color, UtilBlockText.TextAlign.LEFT, false); + _blocks = blocks; + }*/ + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearFireworkEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearFireworkEffect.java new file mode 100644 index 000000000..86da70fd4 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/NewYearFireworkEffect.java @@ -0,0 +1,46 @@ +package mineplex.core.particleeffects; + +public class NewYearFireworkEffect //extends Effect +{ + + /*private static final int MAX_TICKS = 1200; + + private List _locations = new ArrayList<>(); + private List _fixedLocations = new ArrayList<>(); + private int _ticks = 0; + + public NewYearFireworkEffect(JavaPlugin plugin, List locations, List fixedLocations, World world) + { + super(-1, null, plugin, 5); + for (int[] locCoords : locations) + { + _locations.add(new Location(world, locCoords[0], locCoords[1], locCoords[2])); + } + for (int[] locCoords : fixedLocations) + { + _locations.add(new Location(world, locCoords[0], locCoords[1], locCoords[2])); + } + } + + @Override + public void runEffect() + { + for (int i = 0; i < 5; i++) + { + int r = UtilMath.random.nextInt(_locations.size() - 1); + Location location = _locations.get(r); + UtilFirework.launchFirework(location, UtilFirework.getRandomFireworkEffect(true, 2, 2), + new Vector((Math.random() - 0.5) * 0.05, 0.1, (Math.random() - 0.5) * 0.05), 1); + } + for (Location location : _fixedLocations) + { + UtilFirework.launchFirework(location, UtilFirework.getRandomFireworkEffect(true, 2, 2), + new Vector((Math.random() - 0.5) * 0.05, 0.1, (Math.random() - 0.5) * 0.05), 1); + } + _ticks += 5; + if (_ticks >= MAX_TICKS) + { + stop(); + } + }*/ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/TextEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/TextEffect.java new file mode 100644 index 000000000..aca62fb56 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/TextEffect.java @@ -0,0 +1,87 @@ +package mineplex.core.particleeffects; + +import java.awt.*; +import java.awt.image.BufferedImage; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; + +public class TextEffect extends Effect +{ + + private static final double IMAGE_SIZE = 0.2; + + private String _text; + private Font _font; + private boolean _realtime; + private boolean _invert; + private BufferedImage _bufferedImage; + + private ColoredParticle _coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(Color.GREEN), null); + + public TextEffect(JavaPlugin plugin, int ticks, String text, Location location, boolean realtime, boolean invert) throws Exception + { + super(ticks, new EffectLocation(location), plugin); + _text = text; + _font = new Font("Tahoma", Font.PLAIN, 16); + _realtime = realtime; + _invert = invert; + } + + public void setText(String text) + { + if (!_realtime) + return; + + _text = text; + } + + @Override + public void runEffect() + { + if (_text == null || _font == null) + { + stop(); + return; + } + if (_bufferedImage == null || _realtime) + { + _bufferedImage = UtilText.stringToBufferedImage(_font, _text); + } + int color = 0; + for (int y = 0; y < _bufferedImage.getHeight(); y++) + { + for (int x = 0; x < _bufferedImage.getWidth(); x++) + { + color = _bufferedImage.getRGB(x, y); + if (!_invert && java.awt.Color.black.getRGB() != color) + continue; + else if (_invert && java.awt.Color.black.getRGB() == color) + continue; + + Vector vector = new Vector((float) _bufferedImage.getWidth() / 2 - x, (float) _bufferedImage.getHeight() / 2 - y, 0).multiply(IMAGE_SIZE); + vector = rotateAroundAxisY(vector, -_effectLocation.getFixedLocation().getYaw() * (Math.PI / 180)); + _coloredParticle.setLocation(_effectLocation.getFixedLocation().clone().add(vector)); + _coloredParticle.display(); + } + } + } + + private Vector rotateAroundAxisY(Vector v, double angle) + { + double x, z, cos, sin; + cos = Math.cos(angle); + sin = Math.sin(angle); + x = v.getX() * cos + v.getZ() * sin; + z = v.getX() * -sin + v.getZ() * cos; + return v.setX(x).setZ(z); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/WitchParticleEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/WitchParticleEffect.java similarity index 91% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/WitchParticleEffect.java rename to Plugins/Mineplex.Core/src/mineplex/core/particleeffects/WitchParticleEffect.java index 4b36d4de1..f53da0be7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/WitchParticleEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/WitchParticleEffect.java @@ -1,9 +1,10 @@ -package mineplex.core.gadget.gadgets.particle.unrelated; +package mineplex.core.particleeffects; + +import org.bukkit.Location; +import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; -import org.bukkit.Location; -import org.bukkit.plugin.java.JavaPlugin; public class WitchParticleEffect extends Effect { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java deleted file mode 100644 index 7ea9aebe7..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java +++ /dev/null @@ -1,57 +0,0 @@ -package mineplex.core.pet; - -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.pet.repository.token.PetSalesToken; -import mineplex.core.shop.item.SalesPackageBase; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; - -public class Pet extends SalesPackageBase -{ - private String _name; - private EntityType _petType; - private String _lore = null; - - public Pet(String name, EntityType petType, int cost) - { - super(name, Material.MONSTER_EGG, (byte)petType.getTypeId(), new String[] {}); - - _name = name; - _petType = petType; - CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost); - - KnownPackage = false; - } - - public Pet(String name, EntityType petType, int cost, String lore) - { - super(name, Material.MONSTER_EGG, (byte)petType.getTypeId(), new String[] {}); - - _name = name; - _petType = petType; - CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost); - _lore = lore; - - KnownPackage = false; - } - - public EntityType getPetType() - { - return _petType; - } - - public void update(PetSalesToken petToken) - { - _name = petToken.Name; - } - - public String getPetName() - { - return _name; - } - - public String getLore() - { - return _lore; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java index f33ed7e5c..45da43cdc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java @@ -1,33 +1,28 @@ package mineplex.core.pet; -import org.bukkit.entity.EntityType; - -import mineplex.core.common.util.NautHashMap; -import mineplex.core.pet.repository.token.ClientPetToken; -import mineplex.core.pet.repository.token.PetToken; - import java.util.HashMap; import java.util.Map; +import mineplex.core.pet.repository.token.ClientPetToken; +import mineplex.core.pet.repository.token.PetToken; + public class PetClient { - private Map _pets = new HashMap<>(); + private Map _pets = new HashMap<>(); private int _petNameTagCount; public void load(ClientPetToken token) { for (PetToken petToken : token.Pets) { - if (petToken.PetName == null) - petToken.PetName = Enum.valueOf(EntityType.class, petToken.PetType).getName(); - - _pets.put(Enum.valueOf(EntityType.class, petToken.PetType), petToken.PetName); + PetType type = PetType.valueOf(petToken.PetType); + _pets.put(type, petToken.PetName != null ? petToken.PetName : type.getName()); } _petNameTagCount = Math.max(0, token.PetNameTagCount); } - public Map getPets() + public Map getPets() { return _pets; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java index ca38ba1a9..90d0c08b6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java @@ -1,30 +1,22 @@ package mineplex.core.pet; -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.pet.repository.token.PetExtraToken; -import mineplex.core.shop.item.SalesPackageBase; import org.bukkit.Material; -public class PetExtra extends SalesPackageBase +import mineplex.core.pet.sales.PetExtraSalesPackage; + +public enum PetExtra { - private String _name; - private Material _material; - - public PetExtra(String name, Material material, int cost) + NAME_TAG("Name Tag", Material.NAME_TAG, 100) + ; + private final String _name; + private final Material _material; + private final int _price; + + PetExtra(String name, Material material, int price) { - super(name, material, (byte)0, new String[] { }); - _name = name; _material = material; - CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost); - - KnownPackage = false; - OneTimePurchaseOnly = false; - } - - public void Update(PetExtraToken token) - { - + _price = price; } public String getName() @@ -32,8 +24,18 @@ public class PetExtra extends SalesPackageBase return _name; } - public Material GetMaterial() + public Material getMaterial() { return _material; } + + public int getPrice() + { + return _price; + } + + public PetExtraSalesPackage toSalesPackage(String text) + { + return new PetExtraSalesPackage(text, _material, _price); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java deleted file mode 100644 index 66565261e..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -package mineplex.core.pet; - -import java.util.Collection; - -import org.bukkit.Material; -import org.bukkit.entity.EntityType; - -import mineplex.core.common.util.NautHashMap; -import mineplex.core.pet.repository.PetRepository; -import mineplex.core.pet.types.Elf; -import mineplex.core.pet.types.PetCoalApparition; -import mineplex.core.pet.types.Pumpkin; - -public class PetFactory -{ - private PetRepository _repository; - private NautHashMap _pets; - private NautHashMap _petExtras; - - public PetFactory(PetRepository repository) - { - _repository = repository; - _pets = new NautHashMap<>(); - _petExtras = new NautHashMap<>(); - - CreatePets(); - CreatePetExtras(); - } - - private void CreatePets() - { - _pets.put(EntityType.ZOMBIE, new Pumpkin()); - _pets.put(EntityType.PIG_ZOMBIE, new PetCoalApparition()); - _pets.put(EntityType.VILLAGER, new Elf()); - _pets.put(EntityType.PIG, new Pet("Pig", EntityType.PIG, 5000)); - _pets.put(EntityType.SHEEP, new Pet("Sheep", EntityType.SHEEP, 3000)); - _pets.put(EntityType.COW, new Pet("Cow", EntityType.COW, 2000)); - _pets.put(EntityType.CHICKEN, new Pet("Chicken", EntityType.CHICKEN, 7000)); - _pets.put(EntityType.WOLF, new Pet("Dog", EntityType.WOLF, 8000)); - _pets.put(EntityType.OCELOT, new Pet("Cat", EntityType.OCELOT, 6000)); - _pets.put(EntityType.MUSHROOM_COW, new Pet("Mooshroom", EntityType.MUSHROOM_COW, 5000)); - _pets.put(EntityType.WITHER, new Pet("Widder", EntityType.WITHER, -12)); - _pets.put(EntityType.SKELETON, new Pet("Guardian", EntityType.SKELETON, -13)); - _pets.put(EntityType.RABBIT, new Pet("Baby Zombie", EntityType.RABBIT, -9, "They're so cute - until a pack of them chases down your family and eats them.")); - _pets.put(EntityType.BLAZE, new Pet("Grim Reaper", EntityType.BLAZE, -8, "Aww isn't he so cute with his little wings and little scythe?")); - } - - private void CreatePetExtras() - { - _petExtras.put(Material.SIGN, new PetExtra("Name Tag", Material.NAME_TAG, 100)); - } - - public Collection GetPets() - { - return _pets.values(); - } - - public Collection GetPetExtras() - { - return _petExtras.values(); - } - - public Collection GetPetExtraBySalesId(int salesId) - { - return _petExtras.values(); - } - - public Pet getPet(EntityType type) - { - return _pets.get(type); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index 028fee9fd..58c17bea5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -1,37 +1,33 @@ package mineplex.core.pet; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; import java.util.Map.Entry; +import java.util.UUID; -import com.google.gson.Gson; -import mineplex.core.MiniClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.account.event.ClientWebResponseEvent; -import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.common.Rank; -import mineplex.core.common.shape.ShapeWings; -import mineplex.core.common.util.*; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.disguise.DisguiseManager; -import mineplex.core.disguise.disguises.DisguiseChicken; -import mineplex.core.disguise.disguises.DisguiseGuardian; -import mineplex.core.disguise.disguises.DisguiseWither; -import mineplex.core.disguise.disguises.DisguiseZombie; -import mineplex.core.donation.DonationManager; -import mineplex.core.events.AddConditionEvent; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.pet.repository.PetRepository; -import mineplex.core.pet.repository.token.ClientPetTokenWrapper; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import net.minecraft.server.v1_8_R3.EntityCreature; import net.minecraft.server.v1_8_R3.NavigationAbstract; -import org.bukkit.*; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.SkullType; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPigZombie; -import org.bukkit.entity.*; +import org.bukkit.entity.Ageable; +import org.bukkit.entity.Blaze; +import org.bukkit.entity.Creature; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.PigZombie; +import org.bukkit.entity.Player; +import org.bukkit.entity.Rabbit; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent; @@ -45,6 +41,35 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import com.google.gson.Gson; + +import mineplex.core.MiniClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.event.ClientWebResponseEvent; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.Rank; +import mineplex.core.common.shape.ShapeWings; +import mineplex.core.common.util.NautHashMap; +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.UtilServer; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseChicken; +import mineplex.core.disguise.disguises.DisguiseGuardian; +import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.disguise.disguises.DisguiseZombie; +import mineplex.core.donation.DonationManager; +import mineplex.core.events.AddConditionEvent; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.pet.repository.PetRepository; +import mineplex.core.pet.repository.token.ClientPetTokenWrapper; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class PetManager extends MiniClientPlugin { private static Object _petOwnerSynch = new Object(); @@ -53,13 +78,13 @@ public class PetManager extends MiniClientPlugin private DisguiseManager _disguiseManager; private mineplex.core.creature.Creature _creatureModule; private PetRepository _repository; - private PetFactory _petFactory; private BlockRestore _blockRestore; - + + private Map _activePetOwnerTypes = new HashMap<>(); private NautHashMap _activePetOwners; private NautHashMap _failedAttempts; - private NautHashMap _petOwnerQueue = new NautHashMap(); + private Map _petOwnerQueue = new HashMap<>(); private NautHashMap _petRenameQueue = new NautHashMap(); private DonationManager _donationManager; private CoreClientManager _clientManager; @@ -78,7 +103,6 @@ public class PetManager extends MiniClientPlugin _creatureModule = creatureModule; _disguiseManager = disguiseManager; _repository = new PetRepository(plugin, webAddress); - _petFactory = new PetFactory(_repository); _blockRestore = restore; _donationManager = donationManager; _clientManager = clientManager; @@ -88,11 +112,11 @@ public class PetManager extends MiniClientPlugin _failedAttempts = new NautHashMap(); } - public void addPetOwnerToQueue(String playerName, EntityType entityType) + public void addPetOwnerToQueue(String playerName, PetType petType) { synchronized (_petOwnerSynch) { - _petOwnerQueue.put(playerName, entityType); + _petOwnerQueue.put(playerName, petType); } } @@ -150,31 +174,32 @@ public class PetManager extends MiniClientPlugin if (rank.has(Rank.LEGEND)) { - if (!Get(p).getPets().containsKey(EntityType.WITHER)) - Get(p).getPets().put(EntityType.WITHER, "Widder"); + if (!Get(p).getPets().containsKey(PetType.WITHER)) + Get(p).getPets().put(PetType.WITHER, "Widder"); } if (rank.has(Rank.TITAN)) { - if (!Get(p).getPets().containsKey(EntityType.SKELETON)) - Get(p).getPets().put(EntityType.SKELETON, "Guardian"); + if (!Get(p).getPets().containsKey(PetType.SKELETON)) + Get(p).getPets().put(PetType.SKELETON, "Guardian"); } } - public void addPetOwner(Player player, EntityType entityType, Location location) + public void addPetOwner(Player player, PetType petType, Location location) { - if (_activePetOwners.containsKey(player.getName())) + if (_activePetOwnerTypes.containsKey(player.getName())) { - if (_activePetOwners.get(player.getName()).getType() != entityType) + if (_activePetOwnerTypes.get(player.getName()) != petType) { removePet(player, true); } else return; } - + Creature pet; - + EntityType entityType = petType.getEntityType(); + //Wither Spawn if (entityType == EntityType.WITHER) { @@ -200,14 +225,14 @@ public class PetManager extends MiniClientPlugin //Default Spawn else { - pet = (Creature)_creatureModule.SpawnEntity(location, entityType); + pet = (Creature)_creatureModule.SpawnEntity(location, petType.getEntityType()); } //Named Pet - if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0) + if (Get(player).getPets().get(petType) != null && Get(player).getPets().get(petType).length() > 0) { //pet.setCustomNameVisible(true); - pet.setCustomName(Get(player).getPets().get(entityType)); + pet.setCustomName(Get(player).getPets().get(petType)); } if (pet instanceof Zombie) @@ -281,7 +306,8 @@ public class PetManager extends MiniClientPlugin GrimReaperPetManager grimReaperPetManager = new GrimReaperPetManager(player, (Blaze) pet); _grimReaperMorphs.put((Blaze) pet, grimReaperPetManager); } - + + _activePetOwnerTypes.put(player.getName(), petType); _activePetOwners.put(player.getName(), pet); _failedAttempts.put(player.getName(), 0); @@ -318,6 +344,7 @@ public class PetManager extends MiniClientPlugin if (removeOwner) { + _activePetOwnerTypes.remove(player.getName()); _activePetOwners.remove(player.getName()); } } @@ -504,11 +531,6 @@ public class PetManager extends MiniClientPlugin return new PetClient(); } - public PetFactory getFactory() - { - return _petFactory; - } - public PetRepository getRepository() { return _repository; @@ -516,7 +538,12 @@ public class PetManager extends MiniClientPlugin public boolean hasActivePet(String name) { - return _activePetOwners.containsKey(name); + return _activePetOwnerTypes.containsKey(name); + } + + public PetType getActivePetType(String name) + { + return _activePetOwnerTypes.get(name); } public Creature getActivePet(String name) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java new file mode 100644 index 000000000..4072f41c1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java @@ -0,0 +1,104 @@ +package mineplex.core.pet; + +import java.util.Optional; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; + +import mineplex.core.pet.sales.PetSalesPackage; + +public enum PetType +{ + // These pets are named by EntityType for historic reasons -- the enum + // name() is stored by MSSQL to determine pet ownership. Future pet names + // can be made more accurate. + ZOMBIE("Pumpling", EntityType.ZOMBIE, -5), // Pumpling + PIG_ZOMBIE("Coal Apparition", EntityType.PIG_ZOMBIE, -1), + VILLAGER("Christmas Elf", EntityType.VILLAGER, -4), + PIG("Pig", EntityType.PIG, 5000), + SHEEP("Sheep", EntityType.SHEEP, 3000), + COW("Cow", EntityType.COW, 2000), + CHICKEN("Chicken", EntityType.CHICKEN, 7000), + WOLF("Dog", EntityType.WOLF, 8000), + OCELOT("Cat", EntityType.OCELOT, 6000), + MUSHROOM_COW("Mooshroom", EntityType.MUSHROOM_COW, 5000), + WITHER("Widder", EntityType.WITHER, -12), + SKELETON("Guardian", EntityType.SKELETON, -13), + RABBIT("Baby Zombie", EntityType.RABBIT, -9, "They're so cute - until a pack of them chases down your family and eats them."), + BLAZE("Grim Reaper", EntityType.BLAZE, -8, "Aww isn't he so cute with his little wings and little scythe?"), + // TODO CHECK IF LOBBY IS 1.9+ + // Not in this update + //SHULKER("Shulker Pet", EntityType.BAT, 0, "Is it a turtle or an alien? Either way its shot can be really UPLIFTING.") + ; + private final String _name; + private final EntityType _entityType; + private final int _price; + private final Optional _lore; + private final Material _material; + private final byte _data; + + PetType(String name, EntityType entityType, int price) + { + _name = name; + _entityType = entityType; + _price = price; + _lore = Optional.empty(); + _material = Material.MONSTER_EGG; + _data = (byte) entityType.getTypeId(); + } + + PetType(String name, EntityType entityType, int price, String lore) + { + _name = name; + _entityType = entityType; + _price = price; + _lore = Optional.of(lore); + _material = Material.MONSTER_EGG; + _data = (byte) entityType.getTypeId(); + } + + PetType(String name, EntityType entityType, int price, String lore, Material material, byte data) + { + _name = name; + _entityType = entityType; + _price = price; + _lore = Optional.of(lore); + _material = material; + _data = data; + } + + public String getName() + { + return _name; + } + + public EntityType getEntityType() + { + return _entityType; + } + + public int getPrice() + { + return _price; + } + + public Optional getLore() + { + return _lore; + } + + public Material getMaterial() + { + return _material; + } + + public byte getData() + { + return _data; + } + + public PetSalesPackage toSalesPackage(String tagName) + { + return new PetSalesPackage(this, tagName); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java index e607bd0c3..9dc141afb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java @@ -2,19 +2,16 @@ package mineplex.core.pet.repository; import java.util.List; -import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; import com.google.gson.reflect.TypeToken; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnInt; -import mineplex.serverdata.database.column.ColumnVarChar; +import mineplex.core.database.MinecraftRepository; import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.core.pet.repository.token.PetExtraToken; import mineplex.core.server.remotecall.AsyncJsonWebCall; import mineplex.core.server.remotecall.JsonWebCall; +import mineplex.serverdata.database.DBPool; public class PetRepository extends MinecraftRepository { @@ -30,37 +27,11 @@ public class PetRepository extends MinecraftRepository public void AddPet(final PetChangeToken token) { new AsyncJsonWebCall(_webAddress + "Pets/AddPet").Execute(token); - - getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - if (token.PetId == 0 || token.AccountId == 0) - return; - - executeInsert("INSERT INTO accountPets(petName, petId, accountId) VALUES (?, ?, ?);", null, new ColumnVarChar("petName", 32, token.PetName) - , new ColumnInt("petId", token.PetId) - , new ColumnInt("accountId", token.AccountId)); - } - }); } public void RemovePet(final PetChangeToken token) { new AsyncJsonWebCall(_webAddress + "Pets/RemovePet").Execute(token); - - getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - if (token.PetId == 0 || token.AccountId == 0) - return; - - executeUpdate("DELETE FROM accountPets WHERE petId = ? AND accountId = ?;" - , new ColumnInt("petId", token.PetId) - , new ColumnInt("accountId", token.AccountId)); - } - }); } public List GetPetExtras(List petExtraTokens) @@ -71,26 +42,6 @@ public class PetRepository extends MinecraftRepository public void UpdatePet(final PetChangeToken token) { new AsyncJsonWebCall(_webAddress + "Pets/UpdatePet").Execute(token); - - getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - if (token.PetId == 0 || token.AccountId == 0) - return; - - int rowsChanged = executeUpdate("UPDATE accountPets SET petName = ? WHERE petId = ? AND accountId = ?;", new ColumnVarChar("petName", 32, token.PetName) - , new ColumnInt("petId", token.PetId) - , new ColumnInt("accountId", token.AccountId)); - - if (rowsChanged < 1) - { - executeInsert("INSERT INTO accountPets(petName, petId, accountId) VALUES (?, ?, ?);", null, new ColumnVarChar("petName", 32, token.PetName) - , new ColumnInt("petId", token.PetId) - , new ColumnInt("accountId", token.AccountId)); - } - } - }); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetExtraSalesPackage.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetExtraSalesPackage.java new file mode 100644 index 000000000..206e64a8f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetExtraSalesPackage.java @@ -0,0 +1,19 @@ +package mineplex.core.pet.sales; + +import org.bukkit.Material; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.shop.item.SalesPackageBase; + +public class PetExtraSalesPackage extends SalesPackageBase +{ + + public PetExtraSalesPackage(String name, Material material, int price) + { + super(name, material, (byte)0, new String[0]); + CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, price); + + KnownPackage = false; + OneTimePurchaseOnly = false; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetSalesPackage.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetSalesPackage.java new file mode 100644 index 000000000..2189e1469 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/sales/PetSalesPackage.java @@ -0,0 +1,22 @@ +package mineplex.core.pet.sales; + +import org.bukkit.Material; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.pet.PetType; +import mineplex.core.shop.item.SalesPackageBase; + +public class PetSalesPackage extends SalesPackageBase +{ + + @SuppressWarnings("deprecation") + public PetSalesPackage(PetType type, String tagName) + { + super(type.getName(), Material.MONSTER_EGG, (byte)type.getEntityType().getTypeId(), new String[0]); + CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, type.getPrice()); + KnownPackage = false; + + setDisplayName(C.cGreen + "Purchase " + tagName); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Elf.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Elf.java deleted file mode 100644 index 9f3e3c3ee..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Elf.java +++ /dev/null @@ -1,14 +0,0 @@ -package mineplex.core.pet.types; - -import org.bukkit.entity.EntityType; - -import mineplex.core.pet.Pet; - -public class Elf extends Pet -{ - public Elf() - { - super("Christmas Elf", EntityType.VILLAGER, -4); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/PetCoalApparition.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/types/PetCoalApparition.java deleted file mode 100644 index 7d787f744..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/PetCoalApparition.java +++ /dev/null @@ -1,14 +0,0 @@ -package mineplex.core.pet.types; - -import org.bukkit.entity.EntityType; - -import mineplex.core.pet.Pet; - -public class PetCoalApparition extends Pet -{ - public PetCoalApparition() - { - super("Coal Apparition", EntityType.PIG_ZOMBIE, -1); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Pumpkin.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Pumpkin.java deleted file mode 100644 index a2f3acc17..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Pumpkin.java +++ /dev/null @@ -1,13 +0,0 @@ -package mineplex.core.pet.types; - -import org.bukkit.entity.EntityType; - -import mineplex.core.pet.Pet; - -public class Pumpkin extends Pet -{ - public Pumpkin() - { - super("Pumpling", EntityType.ZOMBIE, -5); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java index 195856061..37fbeb41d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java @@ -1,9 +1,22 @@ package mineplex.core.powerplayclub; -import mineplex.core.account.CoreClientManager; -import mineplex.core.account.ILoginProcessor; -import mineplex.core.donation.DonationManager; -import mineplex.serverdata.database.DBPool; +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.LocalDate; +import java.time.YearMonth; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; + import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -12,13 +25,10 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; -import java.sql.*; -import java.sql.Date; -import java.time.LocalDate; -import java.time.YearMonth; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.ILoginProcessor; +import mineplex.core.donation.DonationManager; +import mineplex.serverdata.database.DBPool; public class PowerPlayClubRepository implements Listener { // Data loaded by the first ILoginProcessor, waiting for the second @@ -29,6 +39,8 @@ public class PowerPlayClubRepository implements Listener { // giving a player his/her rewards. private final Map _cachedPlayerData = new HashMap<>(); + private final Set _yearlySubscriptions = new HashSet<>(); + private final CoreClientManager _clientManager; private final DonationManager _donationManager; @@ -74,6 +86,10 @@ public class PowerPlayClubRepository implements Listener { LocalDate date = resultSet.getDate("startDate").toLocalDate(); PowerPlayData.SubscriptionDuration duration = PowerPlayData.SubscriptionDuration.valueOf(resultSet.getString("duration").toUpperCase()); subscriptions.add(new PowerPlayData.Subscription(date, duration)); + if (duration.equals(PowerPlayData.SubscriptionDuration.YEAR)) + { + _yearlySubscriptions.add(uuid); + } } // Now that we have the claims from the first processor and subscriptions from this one, combine them @@ -97,6 +113,9 @@ public class PowerPlayClubRepository implements Listener { PowerPlayClubRewards.rewardsForMonths(cached.getUsableCosmeticMonths()).stream() .map(PowerPlayClubRewards.PowerPlayClubItem::getPrize) .forEach(_donationManager.Get(player)::AddUnknownSalesPackagesOwned); + + // Gives Metal Man for anyone subscribed + _donationManager.Get(player).AddUnknownSalesPackagesOwned("Metal Man Morph"); } @EventHandler @@ -104,6 +123,7 @@ public class PowerPlayClubRepository implements Listener { { _stageOneDataClaims.remove(event.getPlayer().getUniqueId()); // Just in case. _cachedPlayerData.remove(event.getPlayer().getUniqueId()); + _yearlySubscriptions.remove(event.getPlayer().getUniqueId()); } public CompletableFuture addSubscription(int accountId, LocalDate date, String duration) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/LightFlicker.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/LightFlicker.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/LightFlicker.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/LightFlicker.java index dbebdb828..fad5a7d74 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/LightFlicker.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/LightFlicker.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway; +package mineplex.core.rankGiveaway; import java.util.Random; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayAnimation.java new file mode 100644 index 000000000..3b4a0b021 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayAnimation.java @@ -0,0 +1,61 @@ +package mineplex.core.rankGiveaway.fatedgiveaway; + +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; + +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class FatedGiveawayAnimation implements Listener +{ + private Location _location; + private Long _duration, _startTime, _worldTime; + + public FatedGiveawayAnimation(FatedGiveawayManager manager, Location start, Long duration) + { + _location = start.clone(); + _duration = duration; + _startTime = System.currentTimeMillis(); + Bukkit.getPluginManager().registerEvents(this, manager.getPlugin()); + } + + public FatedGiveawayAnimation(FatedGiveawayManager manager, Location start) + { + this(manager, start, 11111L); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void tick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (UtilTime.elapsed(_startTime, _duration)) + { + remove(); + return; + } + + for (Player player : UtilServer.getPlayers()) + { + player.playSound(_location, Sound.ORB_PICKUP, 5, 5); + UtilFirework.packetPlayFirework(player, _location, Type.BURST, Color.fromRGB(255, 105, 180), true, false); + } + } + + private void remove() + { + HandlerList.unregisterAll(this); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayManager.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayManager.java new file mode 100644 index 000000000..d3ec0e8d0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayManager.java @@ -0,0 +1,111 @@ +package mineplex.core.rankGiveaway.fatedgiveaway; + +import java.util.Random; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.common.util.Callback; +import mineplex.core.rankGiveaway.redis.FatedGiveawayMessage; +import mineplex.core.rankGiveaway.redis.GiveawayMessageHandler; +import mineplex.core.status.ServerStatusManager; +import mineplex.serverdata.Region; +import mineplex.serverdata.commands.ServerCommandManager; + +public class FatedGiveawayManager extends MiniPlugin +{ + + private static final double RANK_FIND_CHANCE = 0.001; + + private FatedGiveawayRepository _repository; + private CoreClientManager _clientManager; + private ServerStatusManager _statusManager; + private Random _random; + + public FatedGiveawayManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager) + { + super("Fated Giveaway", plugin); + + _repository = new FatedGiveawayRepository(plugin); + _clientManager = clientManager; + _statusManager = statusManager; + _random = new Random(); + + ServerCommandManager.getInstance().registerCommandType("FatedGiveawayMessage", FatedGiveawayMessage.class, new GiveawayMessageHandler(plugin)); + } + + public void openPumpkin(final Player player, final Runnable onSuccess) + { + double rand = _random.nextDouble(); + if (!hasFated(player) && rand < RANK_FIND_CHANCE) + { + final int accountId = _clientManager.getAccountId(player); + final Region region = getRegion(); + final String serverName = getServerName(); + + // Need to check database that we can give away a rank + runAsync(new Runnable() + { + @Override + public void run() + { + final boolean pass = _repository.canGiveaway(region); + + if (pass && _repository.addFated(accountId, region, serverName)) + { + runSync(new Runnable() + { + @Override + public void run() + { + giveRank(new Callback() + { + @Override + public void run(Rank rank) + { + // TODO CHANGE RANK + if (rank == Rank.TITAN) + { + FatedGiveawayMessage message = new FatedGiveawayMessage(player.getName(), _repository.getFatedCount() + 1); + message.publish(); + if (onSuccess != null) onSuccess.run(); + } + } + // TODO CHANGE RANK + }, Rank.TITAN, player); + } + }); + } + } + }); + } + } + + /** + * Confirm that the player doesn't already have FATED rank + */ + private boolean hasFated(Player player) + { + // TODO CHANGE RANK + return _clientManager.hasRank(player, Rank.TITAN); + } + + public Region getRegion() + { + return _statusManager.getRegion(); + } + + public String getServerName() + { + return _statusManager.getCurrentServerName(); + } + + private void giveRank(Callback callback, Rank rank, Player player) + { + _clientManager.Get(player).SetRank(rank, false); + _clientManager.getRepository().saveRank(callback, player.getName(), player.getUniqueId(), rank, true); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayRepository.java new file mode 100644 index 000000000..cd5d09c9d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayRepository.java @@ -0,0 +1,71 @@ +package mineplex.core.rankGiveaway.fatedgiveaway; + +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.Types; + +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.database.MinecraftRepository; +import mineplex.serverdata.Region; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; + +public class FatedGiveawayRepository extends MinecraftRepository +{ + private static final String ADD_FATED = "INSERT INTO fatedGiveaway (accountId, region, serverName) VALUES (?, ?, ?)"; + + private int _fatedCount; + + public FatedGiveawayRepository(JavaPlugin plugin) + { + super(plugin, DBPool.getAccount()); + _fatedCount = 0; + } + + @Override + protected void initialize() + { + + } + + @Override + protected void update() + { + + } + + public boolean addFated(int accountId, Region region, String serverName) + { + return 1 == executeUpdate(ADD_FATED, new ColumnInt("accountId", accountId), new ColumnVarChar("region", 10, region.name()), new ColumnVarChar("serverName", 64, serverName)); + } + + public boolean canGiveaway(Region region) + { + try (Connection connection = getConnection(); + CallableStatement callableStatement = connection.prepareCall("{call check_fatedGiveaway(?, ?, ?)}")) + { + callableStatement.setString(1, region.name()); + callableStatement.registerOutParameter(2, Types.BOOLEAN); + callableStatement.registerOutParameter(3, Types.INTEGER); + callableStatement.executeUpdate(); + + boolean pass = callableStatement.getBoolean(2); + int fatedCount = callableStatement.getInt(3); + + _fatedCount = fatedCount; + return pass; + } + catch (Exception e) + { + e.printStackTrace(); + } + return false; + } + + public int getFatedCount() + { + return _fatedCount; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/FatedGiveawayMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/FatedGiveawayMessage.java new file mode 100644 index 000000000..e3f77e888 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/FatedGiveawayMessage.java @@ -0,0 +1,32 @@ +package mineplex.core.rankGiveaway.redis; + +import mineplex.serverdata.commands.ServerCommand; + +public class FatedGiveawayMessage extends ServerCommand +{ + private String _playerName; + private int _fatedCount; + + public FatedGiveawayMessage(String playerName, int fatedCount) + { + _playerName = playerName; + _fatedCount = fatedCount; + } + + public String getPlayerName() + { + return _playerName; + } + + public int getFatedCount() + { + return _fatedCount; + } + + @Override + public void run() + { + // Handled in Command Callback + } +} + diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/GiveawayMessageHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java similarity index 61% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/GiveawayMessageHandler.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java index 3afc7c3c1..ac994929f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/GiveawayMessageHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway.redis; +package mineplex.core.rankGiveaway.redis; import org.bukkit.Bukkit; import org.bukkit.Sound; @@ -10,7 +10,7 @@ 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.titangiveaway.LightFlicker; +import mineplex.core.rankGiveaway.LightFlicker; import mineplex.serverdata.commands.CommandCallback; import mineplex.serverdata.commands.ServerCommand; @@ -44,5 +44,22 @@ public class GiveawayMessageHandler implements CommandCallback player.playSound(player.getEyeLocation(), Sound.AMBIENCE_CAVE, 1, 1); } } + else if (command instanceof FatedGiveawayMessage) + { + FatedGiveawayMessage message = ((FatedGiveawayMessage) command); + String playerName = message.getPlayerName(); + int count = message.getFatedCount(); + String countString = count + UtilTime.getDayOfMonthSuffix(count); + String chatMessage = C.cPurple + playerName + C.cWhite + " found Fated in a " + C.cPurple + "Thanksgiving Chicken"; + UtilTextMiddle.display(C.cDPurple + C.Bold + "FATED", chatMessage, 20, 80, 20, UtilServer.getPlayers()); + World world = UtilServer.getPlayers().length > 0 ? UtilServer.getPlayers()[0].getWorld() : Bukkit.getWorlds().get(0); + LightFlicker lightFlicker = new LightFlicker(world); + lightFlicker.runTaskTimer(_plugin, 1, 1); + + for (Player player : UtilServer.getPlayers()) + { + player.playSound(player.getEyeLocation(), Sound.AMBIENCE_CAVE, 1, 1); + } + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanChestGiveawayHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanChestGiveawayHandler.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanChestGiveawayHandler.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanChestGiveawayHandler.java index 0c99ada73..93901991a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanChestGiveawayHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanChestGiveawayHandler.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway.redis; +package mineplex.core.rankGiveaway.redis; import org.bukkit.Sound; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanChestGiveawayMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanChestGiveawayMessage.java similarity index 91% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanChestGiveawayMessage.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanChestGiveawayMessage.java index beb3e7276..c0bf3901a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanChestGiveawayMessage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanChestGiveawayMessage.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway.redis; +package mineplex.core.rankGiveaway.redis; import mineplex.serverdata.commands.ServerCommand; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanGiveawayMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanGiveawayMessage.java similarity index 91% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanGiveawayMessage.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanGiveawayMessage.java index c2f39792c..44b12872f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/redis/TitanGiveawayMessage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/TitanGiveawayMessage.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway.redis; +package mineplex.core.rankGiveaway.redis; import mineplex.serverdata.commands.ServerCommand; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayAnimation.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayAnimation.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayAnimation.java index 2a5e70db6..1ce6c4b8d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayAnimation.java @@ -1,11 +1,4 @@ -package mineplex.core.titangiveaway; - -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +package mineplex.core.rankGiveaway.titangiveaway; import org.bukkit.Bukkit; import org.bukkit.Color; @@ -18,6 +11,12 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class TitanGiveawayAnimation implements Listener { private Location _location; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayManager.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java similarity index 90% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayManager.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java index 46a13f688..93fe89cab 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway; +package mineplex.core.rankGiveaway.titangiveaway; import java.util.Random; @@ -10,17 +10,17 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.status.ServerStatusManager; -import mineplex.core.titangiveaway.redis.GiveawayMessageHandler; -import mineplex.core.titangiveaway.redis.TitanChestGiveawayHandler; -import mineplex.core.titangiveaway.redis.TitanChestGiveawayMessage; -import mineplex.core.titangiveaway.redis.TitanGiveawayMessage; +import mineplex.core.rankGiveaway.redis.GiveawayMessageHandler; +import mineplex.core.rankGiveaway.redis.TitanChestGiveawayHandler; +import mineplex.core.rankGiveaway.redis.TitanChestGiveawayMessage; +import mineplex.core.rankGiveaway.redis.TitanGiveawayMessage; import mineplex.serverdata.Region; import mineplex.serverdata.commands.ServerCommandManager; public class TitanGiveawayManager extends MiniPlugin { + private static final double RANK_FIND_CHANCE = 0.001; -// private static final double RANK_FIND_CHANCE = 1; private TitanGiveawayRepository _repository; private CoreClientManager _clientManager; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayRepository.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java rename to Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayRepository.java index 29c0d6a88..a9157e562 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayRepository.java @@ -1,4 +1,4 @@ -package mineplex.core.titangiveaway; +package mineplex.core.rankGiveaway.titangiveaway; import java.sql.CallableStatement; import java.sql.Connection; @@ -8,7 +8,6 @@ import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.serverdata.Region; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index ee76e8f53..b5a0f5b35 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -6,7 +6,6 @@ import java.util.List; import java.util.Random; import org.bukkit.Material; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -129,8 +128,8 @@ import mineplex.core.mount.types.MountSpider; import mineplex.core.mount.types.MountUndead; import mineplex.core.mount.types.MountValentinesSheep; import mineplex.core.mount.types.MountZombie; -import mineplex.core.pet.Pet; import mineplex.core.pet.PetManager; +import mineplex.core.pet.PetType; import mineplex.core.reward.RewardPool.Type; import mineplex.core.reward.rewards.ChestReward; import mineplex.core.reward.rewards.GameAmplifierReward; @@ -242,13 +241,13 @@ public class RewardManager addInventoryReward(Type.NORMAL, getGadget(ItemTNT.class), rarity, 250, 0, 20, 40); //Pets - addPetReward(Type.NORMAL, EntityType.CHICKEN, rarity, 143); - addPetReward(Type.NORMAL, EntityType.COW, rarity, 500); - addPetReward(Type.NORMAL, EntityType.MUSHROOM_COW, rarity, 200); - addPetReward(Type.NORMAL, EntityType.OCELOT, rarity, 167); - addPetReward(Type.NORMAL, EntityType.PIG, rarity, 200); - addPetReward(Type.NORMAL, EntityType.SHEEP, rarity, 333); - addPetReward(Type.NORMAL, EntityType.WOLF, rarity, 125); + addPetReward(Type.NORMAL, PetType.CHICKEN, rarity, 143); + addPetReward(Type.NORMAL, PetType.COW, rarity, 500); + addPetReward(Type.NORMAL, PetType.MUSHROOM_COW, rarity, 200); + addPetReward(Type.NORMAL, PetType.OCELOT, rarity, 167); + addPetReward(Type.NORMAL, PetType.PIG, rarity, 200); + addPetReward(Type.NORMAL, PetType.SHEEP, rarity, 333); + addPetReward(Type.NORMAL, PetType.WOLF, rarity, 125); //Music Discs @@ -543,12 +542,12 @@ public class RewardManager addGadget(Type.FREEDOM, getGadget(MorphUncleSam.class), rarity, 5); addGadget(Type.FREEDOM, getGadget(ParticleFreedom.class), rarity, 50); - // OMEGA - addPetReward(Type.OMEGA, EntityType.VILLAGER, rarity, 1); - addPetReward(Type.OMEGA, EntityType.ZOMBIE, rarity, 10); - addPetReward(Type.OMEGA, EntityType.PIG_ZOMBIE, rarity, 1); - addPetReward(Type.OMEGA, EntityType.RABBIT, rarity, 10); - addPetReward(Type.OMEGA, EntityType.BLAZE, rarity, 2); + // Omega items + addPetReward(Type.OMEGA, PetType.VILLAGER, rarity, 1); + addPetReward(Type.OMEGA, PetType.ZOMBIE, rarity, 10); + addPetReward(Type.OMEGA, PetType.PIG_ZOMBIE, rarity, 1); + addPetReward(Type.OMEGA, PetType.BLAZE, rarity, 2); + addPetReward(Type.OMEGA, PetType.RABBIT, rarity, 10); addGadget(Type.OMEGA, getGadget(MorphBunny.class), rarity, 1); addGadget(Type.OMEGA, getGadget(MorphUncleSam.class), rarity, 5); @@ -608,17 +607,17 @@ public class RewardManager addHat(Type.OMEGA, HatType.GRINCH, rarity, 25); // HAUNTED - addPetReward(Type.HAUNTED, EntityType.RABBIT, rarity, 100); - addGadget(Type.HAUNTED, getGadget(MorphGrimReaper.class), rarity, 25); + addPetReward(Type.HAUNTED, PetType.RABBIT, rarity, 100); + addGadget(Type.HAUNTED, getGadget(MorphGrimReaper.class), rarity, 25); addGadget(Type.HAUNTED, getGadget(WinEffectHalloween.class), rarity, 50); - addMount(Type.HAUNTED, getMount(MountNightmareSteed.class), rarity, 60); + addMount(Type.HAUNTED, getMount(MountNightmareSteed.class), rarity, 60); //TRICK OR TREAT - addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.MYTHICAL, 1, 3, rarity, 50, 0)); + addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.MYTHICAL, 1, 3, rarity, 50, 0)); addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.ILLUMINATED, 1, 1, rarity, 30, 0)); - addMount(Type.TRICK_OR_TREAT, getMount(MountZombie.class), rarity, 25); - addPetReward(Type.TRICK_OR_TREAT, EntityType.ZOMBIE, rarity, 10); - addGadget(Type.TRICK_OR_TREAT, getGadget(MorphPumpkinKing.class), rarity, 5); + addMount(Type.TRICK_OR_TREAT, getMount(MountZombie.class), rarity, 25); + addPetReward(Type.TRICK_OR_TREAT, PetType.ZOMBIE, rarity, 10); + addGadget(Type.TRICK_OR_TREAT, getGadget(MorphPumpkinKing.class), rarity, 5); } public UnknownPackageReward addMount(Type type, Mount mount, RewardRarity rarity, int weight) @@ -731,16 +730,15 @@ public class RewardManager return reward; } - public PetReward addPetReward(Type type, EntityType entityType, RewardRarity rarity, int weight) + public PetReward addPetReward(Type type, PetType petType, RewardRarity rarity, int weight) { - return addPetReward(type, entityType, rarity, weight, getShards(rarity)); + return addPetReward(type, petType, rarity, weight, getShards(rarity)); } - public PetReward addPetReward(Type type, EntityType entityType, RewardRarity rarity, int weight, int shards) + public PetReward addPetReward(Type type, PetType petType, RewardRarity rarity, int weight, int shards) { - Pet pet = _petManager.getFactory().getPet(entityType); - PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager, - pet.getName() + " Pet", pet.getName(), entityType, rarity, weight, shards); + PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager, + petType.getName() + " Pet", petType.getName(), petType, rarity, weight, shards); addReward(type, reward); return reward; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java index f869a2d5f..19f500c87 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java @@ -1,7 +1,6 @@ package mineplex.core.reward.rewards; import org.bukkit.Material; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -9,6 +8,7 @@ import mineplex.cache.player.PlayerCache; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.pet.PetManager; +import mineplex.core.pet.PetType; import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.core.pet.repository.token.PetToken; import mineplex.core.reward.RewardData; @@ -22,15 +22,15 @@ public class PetReward extends UnknownPackageReward { private InventoryManager _inventoryManager; private PetManager _petManager; - private EntityType _petEntity; + private PetType _petType; - public PetReward(PetManager petManager, InventoryManager inventoryManager, DonationManager donationManager, String name, String packageName, EntityType petEntity, RewardRarity rarity, int weight, int shardValue) + public PetReward(PetManager petManager, InventoryManager inventoryManager, DonationManager donationManager, String name, String packageName, PetType petType, RewardRarity rarity, int weight, int shardValue) { - super(donationManager, "Pet", name, packageName, new ItemStack(Material.MONSTER_EGG, 1, petEntity.getTypeId()), rarity, weight, shardValue); + super(donationManager, "Pet", name, packageName, new ItemStack(Material.MONSTER_EGG, 1, petType.getEntityType().getTypeId()), rarity, weight, shardValue); _petManager = petManager; _inventoryManager = inventoryManager; - _petEntity = petEntity; + _petType = petType; } @Override @@ -44,16 +44,16 @@ public class PetReward extends UnknownPackageReward token.AccountId = PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(); token.Name = player.getName(); - token.PetType = _petEntity.toString(); + token.PetType = _petType.toString(); token.PetName = getPackageName(); PetToken petToken = new PetToken(); petToken.PetType = token.PetType; _petManager.getRepository().AddPet(token); - _petManager.Get(player).getPets().put(_petEntity, token.PetName); + _petManager.Get(player).getPets().put(_petType, token.PetName); - _inventoryManager.addItemToInventory(player, _petEntity.toString(), 1); + _inventoryManager.addItemToInventory(player, _petType.toString(), 1); return getFakeRewardData(player); } @@ -67,6 +67,6 @@ public class PetReward extends UnknownPackageReward return false; } - return !_petManager.Get(player).getPets().containsKey(_petEntity); + return !_petManager.Get(player).getPets().containsKey(_petType); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java index ec53f2357..7f1a8c525 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java @@ -1,13 +1,5 @@ package mineplex.core.shop.page; -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClient; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilInv; -import mineplex.core.donation.DonationManager; -import mineplex.core.shop.ShopBase; -import mineplex.core.shop.item.IButton; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCustom; @@ -19,6 +11,15 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilInv; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.item.IButton; + public abstract class ShopPageBase> extends CraftInventoryCustom implements Listener { protected PluginType _plugin; @@ -87,11 +88,22 @@ public abstract class ShopPageBase _salesPackages = new NautHashMap(); public SalesPackageManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, StatsManager statsManager, PowerPlayClubRepository powerPlayRepo) @@ -60,8 +59,7 @@ public class SalesPackageManager extends MiniPlugin _powerPlayRepo = powerPlayRepo; _petRepo = new PetRepository(plugin, plugin.getConfig().getString("webServer")); - _petFactory = new PetFactory(_petRepo); - + //Strutt20 asked me to remove some of the stuff from the menu AddSalesPackage(new Coins(this, 5000)); @@ -95,9 +93,9 @@ public class SalesPackageManager extends MiniPlugin AddSalesPackage(new HauntedChest(this)); AddSalesPackage(new TrickOrTreatChest(this)); - for (mineplex.core.pet.Pet pet : _petFactory.GetPets()) + for (PetType petType : PetType.values()) { - AddSalesPackage(new Pet(this, pet.getName(), pet.getPetType())); + AddSalesPackage(new Pet(this, petType.getName(), petType)); } } @@ -137,11 +135,6 @@ public class SalesPackageManager extends MiniPlugin { return _petRepo; } - - public PetFactory getPetFactory() - { - return _petFactory; - } public void help(Player player) { diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java index 69c5d6aac..4fcca75da 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java @@ -2,7 +2,6 @@ package mineplex.staffServer.salespackage.command; import java.util.UUID; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import com.google.gson.Gson; @@ -11,8 +10,8 @@ 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.pet.Pet; import mineplex.core.pet.PetClient; +import mineplex.core.pet.PetType; import mineplex.core.pet.repository.token.ClientPetTokenWrapper; import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.staffServer.salespackage.SalesPackageManager; @@ -33,13 +32,13 @@ public class PetCommand extends CommandBase final String playerName = args[0]; int petId = Integer.parseInt(args[1]); - if ((petId < 0 || petId >= EntityType.values().length) || Plugin.getPetFactory().getPet(EntityType.values()[petId]) == null) + if (petId < 0 || petId >= PetType.values().length) { caller.sendMessage(F.main(Plugin.getName(), "You have entered an invalid Pet Type.")); return; } - final EntityType petType = EntityType.values()[petId]; + final PetType petType = PetType.values()[petId]; Plugin.getClientManager().loadClientByName(playerName, client -> { @@ -57,12 +56,11 @@ public class PetCommand extends CommandBase } else { - Pet pet = Plugin.getPetFactory().getPet(petType); PetChangeToken token = new PetChangeToken(); token.AccountId = client.getAccountId(); token.Name = playerName; token.PetType = petType.toString(); - token.PetName = pet.getName(); + token.PetName = petType.getName(); Plugin.getPetRepo().AddPet(token); Plugin.getInventoryManager().addItemToInventoryForOffline(success -> diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/Pet.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/Pet.java index add8d52ae..86a15bca4 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/Pet.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/Pet.java @@ -1,16 +1,16 @@ package mineplex.staffServer.salespackage.salespackages; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import mineplex.core.pet.PetType; import mineplex.staffServer.salespackage.SalesPackageManager; public class Pet extends SalesPackageBase { private String _petName; - private EntityType _petType; + private PetType _petType; - public Pet(SalesPackageManager manager, String petName, EntityType petType) + public Pet(SalesPackageManager manager, String petName, PetType petType) { super(manager, "1 " + petName + " Pet"); _petName = petName; 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 811cc6730..e0bd8ed06 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -14,7 +14,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -90,9 +89,8 @@ import mineplex.core.preferences.PreferencesManager; import mineplex.core.progression.KitProgressionManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; +import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayManager; import mineplex.core.resourcepack.ResourcePackManager; -import mineplex.core.reward.RewardRarity; -import mineplex.core.reward.rewards.PetReward; import mineplex.core.scoreboard.MineplexScoreboard; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.sponsorbranding.BrandingManager; @@ -102,7 +100,7 @@ import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.thank.ThankManager; import mineplex.core.timing.TimingManager; -import mineplex.core.titangiveaway.TitanGiveawayManager; +import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager; import mineplex.core.valentines.ValentinesGiftManager; import mineplex.core.youtube.YoutubeManager; import mineplex.minecraft.game.classcombat.Class.ClassManager; @@ -154,6 +152,7 @@ import nautilus.game.arcade.managers.GameStatManager; import nautilus.game.arcade.managers.GameTestingManager; import nautilus.game.arcade.managers.GameTournamentManager; import nautilus.game.arcade.managers.GameWorldManager; +import nautilus.game.arcade.managers.HolidayManager; import nautilus.game.arcade.managers.IdleManager; import nautilus.game.arcade.managers.MiscManager; import nautilus.game.arcade.managers.NextBestGameManager; @@ -346,9 +345,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation _hologramManager = hologramManager; _idleManager = new IdleManager(this); TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager); + FatedGiveawayManager fatedGiveaway = new FatedGiveawayManager(getPlugin(), clientManager, serverStatusManager); - //new HolidayManager(this, titanGiveaway); - IsHolidayEnabled = false; + new HolidayManager(this, titanGiveaway, fatedGiveaway); + IsHolidayEnabled = true; new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _cosmeticManager.getGadgetManager(), statsManager); new GameTestingManager(this); @@ -1708,20 +1708,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _idleManager; } - public void rewardPet(Player player, String pet, EntityType type) - { - if (!player.isOnline()) - return; - - PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager, pet, pet, type, RewardRarity.OTHER, 0, 0); - - if (reward.canGiveReward(player)) - reward.giveReward(null, player, data -> - { - - }); - } - public void enableChampionsModules() { if (_registered == null || !_registered) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java index d868e9164..2240ee244 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Halloween2016.java @@ -12,7 +12,6 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -34,6 +33,7 @@ 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.pet.PetType; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.rewards.PetReward; import mineplex.core.updater.UpdateType; @@ -682,7 +682,7 @@ public class Halloween2016 extends Halloween if (!player.isOnline()) continue; - PetReward pr = new PetReward(Manager.getCosmeticManager().getPetManager(), Manager.getInventoryManager(), Manager.GetDonation(), "Grim Reaper", "Grim Reaper", EntityType.BLAZE, RewardRarity.OTHER, 0, 0); + PetReward pr = new PetReward(Manager.getCosmeticManager().getPetManager(), Manager.getInventoryManager(), Manager.GetDonation(), "Grim Reaper", "Grim Reaper", PetType.BLAZE, RewardRarity.OTHER, 0, 0); if (pr.canGiveReward(player)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java index c7b572244..aa48f5d45 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java @@ -4,45 +4,71 @@ import java.util.EnumMap; import java.util.HashSet; import java.util.Iterator; -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.gadget.gadgets.particle.unrelated.HalloweenSmashedEffect; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.reward.RewardPool; -import mineplex.core.reward.RewardRarity; -import mineplex.core.titangiveaway.TitanGiveawayManager; -import mineplex.core.treasure.TreasureType; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.Game.GameState; import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction; -import org.bukkit.*; + +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.FireworkEffect; +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.util.CraftMagicNumbers; +import org.bukkit.entity.Chicken; import org.bukkit.entity.Item; import org.bukkit.entity.Player; 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.entity.ItemSpawnEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.util.Vector; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +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.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.particleeffects.HalloweenSmashedEffect; +import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayAnimation; +import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayManager; +import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager; +import mineplex.core.reward.RewardPool; +import mineplex.core.reward.RewardRarity; +import mineplex.core.treasure.TreasureType; +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.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.managers.events.SpecialEntityDeathEvent; + public class HolidayManager implements Listener { public enum HolidayType { - Christmas(Material.CHEST, "Present", Sound.CAT_MEOW), - Halloween(Material.PUMPKIN, "Pumpkin", Sound.ZOMBIE_REMEDY), - Easter(Material.CHEST, "Egg Basket", Sound.CAT_MEOW); + CHRISTMAS(Material.CHEST, "Present", Sound.CAT_MEOW), + HALLOWEEN(Material.PUMPKIN, "Pumpkin", Sound.ZOMBIE_REMEDY), + EASTER(Material.CHEST, "Egg Basket", Sound.CAT_MEOW), + THANKSGIVING(null, C.cGoldB + "Thanksgiving Chicken", null); private Material _blockType; private String _blockName; @@ -71,29 +97,34 @@ public class HolidayManager implements Listener } } - private HolidayType type = HolidayType.Halloween; - private String _statName = "Halloween 2016"; + private HolidayType _type = HolidayType.THANKSGIVING; + private String _statName = "Thanksgiving Chickens 2016"; - ArcadeManager Manager; + private ArcadeManager _arcadeManager; private TitanGiveawayManager _titanManager; + private FatedGiveawayManager _fatedManager; - public HashSet _active = new HashSet(); + public HashSet _active = new HashSet<>(); + public HashSet _activeEntities = new HashSet<>(); - private HashSet _eggs = new HashSet(); + private HashSet _items = new HashSet<>(); - private HashSet _coins = new HashSet(); - private HashSet _gems = new HashSet(); + private HashSet _coins = new HashSet<>(); + private HashSet _gems = new HashSet<>(); private static final double CHEST_CHANCE = 0.001; + private static final double SPAWN_CHANCE = 0.01; + private static final double CHICKEN_DAMAGE = 0.5; public long _lastSpawn = System.currentTimeMillis(); private EnumMap _rewardPools; - public HolidayManager(ArcadeManager manager, TitanGiveawayManager titanManager) + public HolidayManager(ArcadeManager arcadeManager, TitanGiveawayManager titanManager, FatedGiveawayManager fatedManager) { - Manager = manager; + _arcadeManager = arcadeManager; _titanManager = titanManager; + _fatedManager = fatedManager; _rewardPools = new EnumMap<>(RewardPool.Type.class); for (RewardPool.Type type : RewardPool.Type.values()) @@ -101,7 +132,7 @@ public class HolidayManager implements Listener _rewardPools.put(type, new RewardPool()); } - Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); + _arcadeManager.getPluginManager().registerEvents(this, _arcadeManager.getPlugin()); } @EventHandler @@ -134,7 +165,7 @@ public class HolidayManager implements Listener continue; } - if (type == HolidayType.Halloween) + if (_type.equals(HolidayType.HALLOWEEN)) { UtilParticle.PlayParticle(ParticleType.FLAME, block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0.06f, 4, ViewDist.LONG, UtilServer.getPlayers()); @@ -150,18 +181,18 @@ public class HolidayManager implements Listener } } } - else if (type == HolidayType.Easter) + else if (_type.equals(HolidayType.EASTER)) { UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, block.getLocation().add(0.5, 0.2, 0.5), 0.3f, 0.2f, 0.3f, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); if (Math.random() > 0.90) { - Item egg = block.getWorld().dropItem(block.getLocation().add(0.5, 0.8, 0.5), + Item egg = block.getWorld().dropItem(block.getLocation().add(0.5, 0.8, 0.5), ItemStackFactory.Instance.CreateStack(Material.EGG, (byte)0, 1, System.currentTimeMillis() + "Egg")); egg.setVelocity(new Vector((Math.random()-0.5)*0.3, Math.random()-0.4, (Math.random()-0.5)*0.3)); - _eggs.add(egg); + _items.add(egg); block.getWorld().playSound(block.getLocation(), Sound.CHICKEN_EGG_POP, 0.25f + (float)Math.random() * 0.75f, 0.75f + (float)Math.random() * 0.5f); } @@ -171,12 +202,35 @@ public class HolidayManager implements Listener sendChestPackets(block); } } - else if (type == HolidayType.Christmas) + else if (_type.equals(HolidayType.CHRISTMAS)) { UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, block.getLocation().add(0.5, 1, 0.5), 0.5f, 0.5f, 0.5f, 0, 3, ViewDist.LONG, UtilServer.getPlayers()); } } + + Iterator entityIterator = _activeEntities.iterator(); + + while (entityIterator.hasNext()) + { + org.bukkit.entity.Entity entity = entityIterator.next(); + + if (!(entity instanceof Chicken)) + { + specialEntityKill(null, entity); + entityIterator.remove(); + } + + if (_type.equals(HolidayType.THANKSGIVING)) + { + if (Math.random() > 0.90) + { + UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, entity.getLocation().add(0.5, 1, 0.5), 0.5f, 0.5f, 0.5f, 0, 3, + ViewDist.LONG, UtilServer.getPlayers()); + } + } + + } } @EventHandler @@ -185,25 +239,28 @@ public class HolidayManager implements Listener if (event.getType() != UpdateType.SEC) return; - if (Manager.GetGame() == null) + if (_arcadeManager.GetGame() == null) return; - if (Manager.GetGameHostManager().isPrivateServer()) + if (_arcadeManager.GetGameHostManager().isPrivateServer()) return; - Game game = Manager.GetGame(); + Game game = _arcadeManager.GetGame(); - int requirement = (int)((double)Manager.GetPlayerFull() * 0.5d); + int requirement = (int)((double) _arcadeManager.GetPlayerFull() * 0.5d); if (UtilServer.getPlayers().length < requirement) return; if (game.GetState() != GameState.Live) - return; + return; + + if (game.GetType().equals(GameType.UHC)) + return; if (!UtilTime.elapsed(_lastSpawn, 90000)) return; - if (Math.random() > 0.01) + if (Math.random() > SPAWN_CHANCE) return; int toDrop = Math.max(1, game.GetPlayers(false).size()/6); @@ -228,10 +285,26 @@ public class HolidayManager implements Listener return; } - block.setType(type.getBlockType()); - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, type.getBlockType()); + if (_type.getBlockType() == null && _type.equals(HolidayType.THANKSGIVING)) + { + // Spawns thanksgiving chicken + boolean oldValue = _arcadeManager.GetGame().CreatureAllowOverride; + _arcadeManager.GetGame().CreatureAllowOverride = true; + Chicken chicken = block.getWorld().spawn(block.getLocation().clone().add(.5, .5, .5), Chicken.class); + _arcadeManager.GetGame().CreatureAllowOverride = oldValue; + chicken.setAdult(); + chicken.setCustomName(_type.getBlockName()); + chicken.setCustomNameVisible(true); + chicken.setVelocity(chicken.getVelocity().multiply(15)); + block.getWorld().playSound(block.getLocation(), Sound.CHICKEN_IDLE, 1f, 1f); + _activeEntities.add(chicken); + return; + } - if (type.getBlockType() == Material.CHEST) + block.setType(_type.getBlockType()); + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _type.getBlockType()); + + if (_type.getBlockType() == Material.CHEST) { sendChestPackets(block); } @@ -299,12 +372,108 @@ public class HolidayManager implements Listener if (UtilPlayer.isSpectator(event.getPlayer())) return; - if (Manager.GetGame() != null && !Manager.GetGame().IsAlive(event.getPlayer())) + if (_arcadeManager.GetGame() != null && !_arcadeManager.GetGame().IsAlive(event.getPlayer())) return; specialBlockBreak(event.getPlayer(), event.getClickedBlock()); } + @EventHandler + public void specialEntityDeath(SpecialEntityDeathEvent event) + { + if (!_type.equals(HolidayType.THANKSGIVING)) + return; + + if (!(event.getEntity() instanceof Chicken)) + return; + + if (event.getKiller() == null) + return; + + Chicken chicken = (Chicken) event.getEntity(); + Player killer = event.getKiller(); + + if (_arcadeManager.GetGame() != null && !_arcadeManager.GetGame().IsAlive(killer)) + return; + + if (!_activeEntities.contains(chicken)) + return; + + _activeEntities.remove(chicken); + specialEntityKill(killer, chicken); + killer.getWorld().playSound(killer.getLocation(), Sound.CHICKEN_HURT, 1f, 1f); + } + + @EventHandler + public void specialEntityDamage(EntityDamageEvent event) + { + if (!(event.getEntity() instanceof Chicken)) + return; + + if (_arcadeManager.GetGame() == null) + return; + + Chicken chicken = (Chicken) event.getEntity(); + + if (!_activeEntities.contains(chicken)) + return; + + if (event.getCause().equals(EntityDamageEvent.DamageCause.VOID) || event.getCause().equals(EntityDamageEvent.DamageCause.LAVA) || + event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) + { + specialEntityKill(null, chicken); + _activeEntities.remove(chicken); + chicken.remove(); + } + + event.setCancelled(true); + } + + @EventHandler + public void specialEntityDamageByEntity(EntityDamageByEntityEvent event) + { + if (!(event.getEntity() instanceof Chicken)) + return; + + if (!(event.getDamager() instanceof Player)) + return; + + if (_arcadeManager.GetGame() == null) + return; + + if (UtilPlayer.isSpectator(event.getDamager())) + return; + + Chicken chicken = (Chicken) event.getEntity(); + + if (!_activeEntities.contains(chicken)) + return; + + if (chicken.getHealth() <= CHICKEN_DAMAGE) + { + SpecialEntityDeathEvent specialEntityDeathEvent = new SpecialEntityDeathEvent(chicken, (Player) event.getDamager()); + Bukkit.getPluginManager().callEvent(specialEntityDeathEvent); + chicken.remove(); + return; + } + + chicken.damage(CHICKEN_DAMAGE); + } + + @EventHandler + public void cancelSpecialEntityItemDrops(ItemSpawnEvent event) + { + Material material = event.getEntity().getItemStack().getType(); + if (material.equals(Material.FEATHER) || material.equals(Material.RAW_CHICKEN) || material.equals(Material.BONE)) + { + if (_items.contains(event.getEntity())) + return; + + event.getEntity().remove(); + event.setCancelled(true); + } + } + private void specialBlockBreak(Player player, final Block block) { if (!_active.contains(block)) @@ -312,12 +481,12 @@ public class HolidayManager implements Listener _active.remove(block); - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, type.getBlockType()); + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _type.getBlockType()); block.setType(Material.AIR); - if (player != null && Manager.GetGame() != null) + if (player != null && _arcadeManager.GetGame() != null) { - Manager.GetGame().AddStat(player, _statName, 1, false, true); + _arcadeManager.GetGame().AddStat(player, _statName, 1, false, true); System.out.println("Recording Pumpkin Break for " + player.getName()); } @@ -373,7 +542,7 @@ public class HolidayManager implements Listener if (player != null) { - InventoryManager manager = Manager.getInventoryManager(); + InventoryManager manager = _arcadeManager.getInventoryManager(); double rand = UtilMath.random.nextDouble(); if (rand < CHEST_CHANCE) { @@ -384,7 +553,7 @@ public class HolidayManager implements Listener .withFade(Color.BLACK).flicker(true).build(); manager.addItemToInventory(player, "Haunted Chest", 1); HalloweenSmashedEffect halloweenSmashedEffect = new HalloweenSmashedEffect(block.getLocation() - .add(.5, .5, .5), fireworkEffect, Manager.getPlugin()); + .add(.5, .5, .5), fireworkEffect, _arcadeManager.getPlugin()); halloweenSmashedEffect.start(); } else @@ -394,14 +563,73 @@ public class HolidayManager implements Listener .withFade(Color.BLACK).flicker(true).build(); manager.addItemToInventory(player, "Omega Chest", 1); HalloweenSmashedEffect halloweenSmashedEffect = new HalloweenSmashedEffect(block.getLocation() - .add(.5, .5, .5), fireworkEffect, Manager.getPlugin()); + .add(.5, .5, .5), fireworkEffect, _arcadeManager.getPlugin()); halloweenSmashedEffect.start(); } } } //Effect - block.getWorld().playSound(block.getLocation(), type.getBlockSound(), 1f, 1f); + block.getWorld().playSound(block.getLocation(), _type.getBlockSound(), 1f, 1f); + } + + private void specialEntityKill(Player player, org.bukkit.entity.Entity entity) + { + if (player != null && _arcadeManager.GetGame() != null) + { + _arcadeManager.GetGame().AddStat(player, _statName, 1, false, true); + System.out.println("Recording Entity Killong for " + player.getName()); + } + + //Coins + for (int i=0 ; i < 4 + Math.random()*8 ; i++) + { + Item coin = entity.getWorld().dropItem(entity.getLocation().add(0.5, 1, 0.5), + ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte)0, 1, UtilMath.r(999999) + "Coin")); + + Vector vel = new Vector( + (Math.random() - 0.5) * 0.5, + 0.1 + Math.random() * 0.3, + (Math.random() - 0.5) * 0.5); + + coin.setVelocity(vel); + + coin.setPickupDelay(20); + + _coins.add(coin); + } + + //Gems + for (int i=0 ; i < 4 + Math.random()*8 ; i++) + { + Item gem = entity.getWorld().dropItem(entity.getLocation().add(0.5, 1, 0.5), + ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte)0, 1, UtilMath.r(999999) + "Gem")); + + Vector vel = new Vector( + (Math.random() - 0.5) * 0.5, + 0.1 + Math.random() * 0.3, + (Math.random() - 0.5) * 0.5); + + gem.setVelocity(vel); + + gem.setPickupDelay(20); + + _gems.add(gem); + } + + // Fated Giveaway + if (player != null) + { + _fatedManager.openPumpkin(player, new Runnable() + { + @Override + public void run() + { + Location location = entity.getLocation().add(0.5, 0.5, 0.5); + new FatedGiveawayAnimation(_fatedManager, location, 3000L); + } + }); + } } @EventHandler @@ -415,7 +643,7 @@ public class HolidayManager implements Listener event.setCancelled(true); event.getItem().remove(); - Manager.GetDonation().RewardCoinsLater(type + " Coins", event.getPlayer(), 4 * event.getItem().getItemStack().getAmount()); + _arcadeManager.GetDonation().RewardCoinsLater(_type + " Coins", event.getPlayer(), 4 * event.getItem().getItemStack().getAmount()); event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f); } @@ -424,12 +652,12 @@ public class HolidayManager implements Listener event.setCancelled(true); event.getItem().remove(); - Manager.GetDonation().RewardGemsLater(type + " Gems", event.getPlayer(), 4 * event.getItem().getItemStack().getAmount()); + _arcadeManager.GetDonation().RewardGemsLater(_type + " Gems", event.getPlayer(), 4 * event.getItem().getItemStack().getAmount()); event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f); } - else if (_eggs.contains(event.getItem())) + else if (_items.contains(event.getItem())) { event.setCancelled(true); } @@ -467,7 +695,7 @@ public class HolidayManager implements Listener } } - Iterator eggIterator = _eggs.iterator(); + Iterator eggIterator = _items.iterator(); while (eggIterator.hasNext()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/events/SpecialEntityDeathEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/events/SpecialEntityDeathEvent.java new file mode 100644 index 000000000..8f9a142c4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/events/SpecialEntityDeathEvent.java @@ -0,0 +1,42 @@ +package nautilus.game.arcade.managers.events; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class SpecialEntityDeathEvent extends Event +{ + + private static final HandlerList handlers = new HandlerList(); + + private Entity _entity; + private Player _killer; + + public SpecialEntityDeathEvent(Entity entity, Player killer) + { + _entity = entity; + _killer = killer; + } + + public Entity getEntity() + { + return _entity; + } + + public Player getKiller() + { + return _killer; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} From e845f7fca91388ac4e2c20bb47bef1a9ed8e2288 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 17 Nov 2016 02:13:48 -0500 Subject: [PATCH 56/56] Disable Fated giveaway tools for now --- .../fatedgiveaway/FatedGiveawayAnimation.java | 61 ---------- .../fatedgiveaway/FatedGiveawayManager.java | 111 ------------------ .../FatedGiveawayRepository.java | 71 ----------- .../redis/FatedGiveawayMessage.java | 32 ----- .../redis/GiveawayMessageHandler.java | 17 --- .../nautilus/game/arcade/ArcadeManager.java | 6 +- .../game/arcade/managers/HolidayManager.java | 19 +-- 7 files changed, 3 insertions(+), 314 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayAnimation.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayManager.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayRepository.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/FatedGiveawayMessage.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayAnimation.java deleted file mode 100644 index 3b4a0b021..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayAnimation.java +++ /dev/null @@ -1,61 +0,0 @@ -package mineplex.core.rankGiveaway.fatedgiveaway; - -import org.bukkit.Bukkit; -import org.bukkit.Color; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; - -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - -public class FatedGiveawayAnimation implements Listener -{ - private Location _location; - private Long _duration, _startTime, _worldTime; - - public FatedGiveawayAnimation(FatedGiveawayManager manager, Location start, Long duration) - { - _location = start.clone(); - _duration = duration; - _startTime = System.currentTimeMillis(); - Bukkit.getPluginManager().registerEvents(this, manager.getPlugin()); - } - - public FatedGiveawayAnimation(FatedGiveawayManager manager, Location start) - { - this(manager, start, 11111L); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void tick(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - if (UtilTime.elapsed(_startTime, _duration)) - { - remove(); - return; - } - - for (Player player : UtilServer.getPlayers()) - { - player.playSound(_location, Sound.ORB_PICKUP, 5, 5); - UtilFirework.packetPlayFirework(player, _location, Type.BURST, Color.fromRGB(255, 105, 180), true, false); - } - } - - private void remove() - { - HandlerList.unregisterAll(this); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayManager.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayManager.java deleted file mode 100644 index d3ec0e8d0..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayManager.java +++ /dev/null @@ -1,111 +0,0 @@ -package mineplex.core.rankGiveaway.fatedgiveaway; - -import java.util.Random; - -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; -import mineplex.core.rankGiveaway.redis.FatedGiveawayMessage; -import mineplex.core.rankGiveaway.redis.GiveawayMessageHandler; -import mineplex.core.status.ServerStatusManager; -import mineplex.serverdata.Region; -import mineplex.serverdata.commands.ServerCommandManager; - -public class FatedGiveawayManager extends MiniPlugin -{ - - private static final double RANK_FIND_CHANCE = 0.001; - - private FatedGiveawayRepository _repository; - private CoreClientManager _clientManager; - private ServerStatusManager _statusManager; - private Random _random; - - public FatedGiveawayManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager) - { - super("Fated Giveaway", plugin); - - _repository = new FatedGiveawayRepository(plugin); - _clientManager = clientManager; - _statusManager = statusManager; - _random = new Random(); - - ServerCommandManager.getInstance().registerCommandType("FatedGiveawayMessage", FatedGiveawayMessage.class, new GiveawayMessageHandler(plugin)); - } - - public void openPumpkin(final Player player, final Runnable onSuccess) - { - double rand = _random.nextDouble(); - if (!hasFated(player) && rand < RANK_FIND_CHANCE) - { - final int accountId = _clientManager.getAccountId(player); - final Region region = getRegion(); - final String serverName = getServerName(); - - // Need to check database that we can give away a rank - runAsync(new Runnable() - { - @Override - public void run() - { - final boolean pass = _repository.canGiveaway(region); - - if (pass && _repository.addFated(accountId, region, serverName)) - { - runSync(new Runnable() - { - @Override - public void run() - { - giveRank(new Callback() - { - @Override - public void run(Rank rank) - { - // TODO CHANGE RANK - if (rank == Rank.TITAN) - { - FatedGiveawayMessage message = new FatedGiveawayMessage(player.getName(), _repository.getFatedCount() + 1); - message.publish(); - if (onSuccess != null) onSuccess.run(); - } - } - // TODO CHANGE RANK - }, Rank.TITAN, player); - } - }); - } - } - }); - } - } - - /** - * Confirm that the player doesn't already have FATED rank - */ - private boolean hasFated(Player player) - { - // TODO CHANGE RANK - return _clientManager.hasRank(player, Rank.TITAN); - } - - public Region getRegion() - { - return _statusManager.getRegion(); - } - - public String getServerName() - { - return _statusManager.getCurrentServerName(); - } - - private void giveRank(Callback callback, Rank rank, Player player) - { - _clientManager.Get(player).SetRank(rank, false); - _clientManager.getRepository().saveRank(callback, player.getName(), player.getUniqueId(), rank, true); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayRepository.java deleted file mode 100644 index cd5d09c9d..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayRepository.java +++ /dev/null @@ -1,71 +0,0 @@ -package mineplex.core.rankGiveaway.fatedgiveaway; - -import java.sql.CallableStatement; -import java.sql.Connection; -import java.sql.Types; - -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.database.MinecraftRepository; -import mineplex.serverdata.Region; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.column.ColumnInt; -import mineplex.serverdata.database.column.ColumnVarChar; - -public class FatedGiveawayRepository extends MinecraftRepository -{ - private static final String ADD_FATED = "INSERT INTO fatedGiveaway (accountId, region, serverName) VALUES (?, ?, ?)"; - - private int _fatedCount; - - public FatedGiveawayRepository(JavaPlugin plugin) - { - super(plugin, DBPool.getAccount()); - _fatedCount = 0; - } - - @Override - protected void initialize() - { - - } - - @Override - protected void update() - { - - } - - public boolean addFated(int accountId, Region region, String serverName) - { - return 1 == executeUpdate(ADD_FATED, new ColumnInt("accountId", accountId), new ColumnVarChar("region", 10, region.name()), new ColumnVarChar("serverName", 64, serverName)); - } - - public boolean canGiveaway(Region region) - { - try (Connection connection = getConnection(); - CallableStatement callableStatement = connection.prepareCall("{call check_fatedGiveaway(?, ?, ?)}")) - { - callableStatement.setString(1, region.name()); - callableStatement.registerOutParameter(2, Types.BOOLEAN); - callableStatement.registerOutParameter(3, Types.INTEGER); - callableStatement.executeUpdate(); - - boolean pass = callableStatement.getBoolean(2); - int fatedCount = callableStatement.getInt(3); - - _fatedCount = fatedCount; - return pass; - } - catch (Exception e) - { - e.printStackTrace(); - } - return false; - } - - public int getFatedCount() - { - return _fatedCount; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/FatedGiveawayMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/FatedGiveawayMessage.java deleted file mode 100644 index e3f77e888..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/FatedGiveawayMessage.java +++ /dev/null @@ -1,32 +0,0 @@ -package mineplex.core.rankGiveaway.redis; - -import mineplex.serverdata.commands.ServerCommand; - -public class FatedGiveawayMessage extends ServerCommand -{ - private String _playerName; - private int _fatedCount; - - public FatedGiveawayMessage(String playerName, int fatedCount) - { - _playerName = playerName; - _fatedCount = fatedCount; - } - - public String getPlayerName() - { - return _playerName; - } - - public int getFatedCount() - { - return _fatedCount; - } - - @Override - public void run() - { - // Handled in Command Callback - } -} - diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java index ac994929f..557b227e1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java @@ -44,22 +44,5 @@ public class GiveawayMessageHandler implements CommandCallback player.playSound(player.getEyeLocation(), Sound.AMBIENCE_CAVE, 1, 1); } } - else if (command instanceof FatedGiveawayMessage) - { - FatedGiveawayMessage message = ((FatedGiveawayMessage) command); - String playerName = message.getPlayerName(); - int count = message.getFatedCount(); - String countString = count + UtilTime.getDayOfMonthSuffix(count); - String chatMessage = C.cPurple + playerName + C.cWhite + " found Fated in a " + C.cPurple + "Thanksgiving Chicken"; - UtilTextMiddle.display(C.cDPurple + C.Bold + "FATED", chatMessage, 20, 80, 20, UtilServer.getPlayers()); - World world = UtilServer.getPlayers().length > 0 ? UtilServer.getPlayers()[0].getWorld() : Bukkit.getWorlds().get(0); - LightFlicker lightFlicker = new LightFlicker(world); - lightFlicker.runTaskTimer(_plugin, 1, 1); - - for (Player player : UtilServer.getPlayers()) - { - player.playSound(player.getEyeLocation(), Sound.AMBIENCE_CAVE, 1, 1); - } - } } } 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 e0bd8ed06..4c4272685 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -89,7 +89,6 @@ import mineplex.core.preferences.PreferencesManager; import mineplex.core.progression.KitProgressionManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; -import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayManager; import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.scoreboard.MineplexScoreboard; import mineplex.core.scoreboard.ScoreboardManager; @@ -345,9 +344,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation _hologramManager = hologramManager; _idleManager = new IdleManager(this); TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager); - FatedGiveawayManager fatedGiveaway = new FatedGiveawayManager(getPlugin(), clientManager, serverStatusManager); - - new HolidayManager(this, titanGiveaway, fatedGiveaway); + + new HolidayManager(this, titanGiveaway); IsHolidayEnabled = true; new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _cosmeticManager.getGadgetManager(), statsManager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java index aa48f5d45..3aa7d7131 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java @@ -45,8 +45,6 @@ import mineplex.core.common.util.UtilWorld; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.particleeffects.HalloweenSmashedEffect; -import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayAnimation; -import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayManager; import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager; import mineplex.core.reward.RewardPool; import mineplex.core.reward.RewardRarity; @@ -102,7 +100,6 @@ public class HolidayManager implements Listener private ArcadeManager _arcadeManager; private TitanGiveawayManager _titanManager; - private FatedGiveawayManager _fatedManager; public HashSet _active = new HashSet<>(); public HashSet _activeEntities = new HashSet<>(); @@ -120,11 +117,10 @@ public class HolidayManager implements Listener private EnumMap _rewardPools; - public HolidayManager(ArcadeManager arcadeManager, TitanGiveawayManager titanManager, FatedGiveawayManager fatedManager) + public HolidayManager(ArcadeManager arcadeManager, TitanGiveawayManager titanManager) { _arcadeManager = arcadeManager; _titanManager = titanManager; - _fatedManager = fatedManager; _rewardPools = new EnumMap<>(RewardPool.Type.class); for (RewardPool.Type type : RewardPool.Type.values()) @@ -617,19 +613,6 @@ public class HolidayManager implements Listener _gems.add(gem); } - // Fated Giveaway - if (player != null) - { - _fatedManager.openPumpkin(player, new Runnable() - { - @Override - public void run() - { - Location location = entity.getLocation().add(0.5, 0.5, 0.5); - new FatedGiveawayAnimation(_fatedManager, location, 3000L); - } - }); - } } @EventHandler