diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mavericks/DisplaySlot.java b/Plugins/Mineplex.Core/src/mineplex/core/mavericks/DisplaySlot.java index b5972171e..8fe12d473 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mavericks/DisplaySlot.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mavericks/DisplaySlot.java @@ -11,6 +11,7 @@ import org.bukkit.util.Vector; import mineplex.core.common.block.schematic.Schematic; import mineplex.core.common.block.schematic.SchematicData; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; @@ -49,9 +50,11 @@ public class DisplaySlot Location a = _loc; Location b = _loc.clone().add(schematic.getWidth(), schematic.getHeight(), schematic.getLength()); + UtilBlock.startQuickRecording(); for(int x = a.getBlockX(); x < b.getX(); x++) { - for(int y = a.getBlockY(); y < b.getY(); y++) + // Ignore the floor to keep the outer ring + for(int y = a.getBlockY() + 1; y < b.getY(); y++) { for(int z = a.getBlockZ(); z < b.getZ(); z++) { @@ -91,7 +94,7 @@ public class DisplaySlot for(Entry e : _particles.entrySet()) { - Location loc = _loc.clone().add(2, 0, 7).add(e.getKey()); + Location loc = _loc.clone().add(e.getKey()); ParticleType type = e.getValue(); @@ -123,5 +126,18 @@ public class DisplaySlot { return _pastedEntities.contains(e); } + + public boolean isInside(Location loc) + { + if(!_loc.getWorld().equals(loc.getWorld())) return false; + if(_data == null) return false; + + Schematic s = _data.getBuild().getSchematic(); + + Location min = _loc.clone(); + Location max = _loc.clone().add(s.getWidth(), s.getHeight(), s.getLength()); + + return UtilAlg.inBoundingBox(loc, min, max); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mavericks/MavericksApprovedRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/mavericks/MavericksApprovedRepository.java index a484a73ee..02f52eb33 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mavericks/MavericksApprovedRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mavericks/MavericksApprovedRepository.java @@ -1,10 +1,10 @@ package mineplex.core.mavericks; import java.sql.Connection; -import java.sql.Date; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -92,8 +92,9 @@ public class MavericksApprovedRepository long approvedDate = set.getLong(2); UUID approvedBy = UUID.fromString(set.getString(3)); boolean display = set.getBoolean(4); - Long firstDisplayed = set.getLong(5); - if(set.wasNull()) firstDisplayed = null; + Timestamp stamp = set.getTimestamp(1); + Long firstDisplayed = null; + if(!set.wasNull() && stamp != null) stamp.getTime(); String theme = set.getString(6); @@ -158,7 +159,8 @@ public class MavericksApprovedRepository try (Connection conn = DBPool.getAccount().getConnection()) { PreparedStatement stmt = conn.prepareStatement("UPDATE " + TABLE_APPROVED + " SET FirstDisplayed=? WHERE BuildId=?"); - stmt.setDate(1, new Date(System.currentTimeMillis())); +// stmt.setDate(1, new Date(System.currentTimeMillis())); + stmt.setTimestamp(1, new Timestamp(System.currentTimeMillis())); stmt.setLong(2, buildid); return stmt.executeUpdate() > 0; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mavericks/MavericksBuildRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/mavericks/MavericksBuildRepository.java index 9fa6ae23b..9d59470fb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mavericks/MavericksBuildRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mavericks/MavericksBuildRepository.java @@ -34,6 +34,11 @@ public class MavericksBuildRepository private static final String TABLE = "mavericksMasterBuildersBuilds"; public CompletableFuture> getToReview(boolean onlyUnreviewed, int limit, int offset) + { + return getToReview(onlyUnreviewed, limit, offset, true); + } + + public CompletableFuture> getToReview(boolean onlyUnreviewed, int limit, int offset, boolean parseData) { return CompletableFuture.supplyAsync(() -> { @@ -60,7 +65,13 @@ public class MavericksBuildRepository byte[] schematic = set.getBytes(8); byte[] particles = set.getBytes(9); boolean reviewed = set.getBoolean(10); - list.add(new MavericksBuildWrapper(buildId, uuid, lastName, theme, votes, place, dateStamp, schematic, particles, reviewed)); + MavericksBuildWrapper data = new MavericksBuildWrapper(buildId, uuid, lastName, theme, votes, place, dateStamp, schematic, particles, reviewed); + if(parseData) + { + data.getParticles(); + data.getSchematic(); + } + list.add(data); } return list; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 44f6e612e..76d61f503 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -217,8 +217,6 @@ public class HubManager extends MiniClientPlugin new WorldManager(this); new JumpManager(this); //new TournamentInviter(this); - - _mavericksManager = new MavericksManager(plugin); _news = new NewsManager(this); @@ -232,7 +230,9 @@ public class HubManager extends MiniClientPlugin _bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, _gadgetManager); _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager()); - new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager); + CosmeticManager cosmetics = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager); + + _mavericksManager = new MavericksManager(plugin, cosmetics); new SoccerManager(this, _gadgetManager); new KothManager(this, _gadgetManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/MavericksManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/MavericksManager.java index 6d0202fe1..66a3200a4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/MavericksManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/MavericksManager.java @@ -5,20 +5,36 @@ import java.util.List; import java.util.concurrent.CompletionStage; import java.util.function.Function; -import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockGrowEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.block.BlockRedstoneEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; +import org.spigotmc.event.entity.EntityMountEvent; import mineplex.core.MiniPlugin; import mineplex.core.common.util.BukkitFuture; +import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.mavericks.DisplaySlot; import mineplex.core.mavericks.MavericksApprovedRepository; import mineplex.core.mavericks.MavericksApprovedWrapper; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.modules.mavericks.MavericksPortalManager; +import mineplex.hub.modules.mavericks.MavericksWorldManager; /** * A manager to handle all mavericks related content in the hub. Holds the mavericks portal manager in addition to handle * the rotation of the "best of" builds from Mavericks Master Builders. @@ -30,18 +46,21 @@ public class MavericksManager extends MiniPlugin private static final long ROTATION_TIME = 1000*30; private MavericksPortalManager _portalManager; + private MavericksWorldManager _worldManager; private MavericksApprovedRepository _repoApproved; private List _displaySlots = new ArrayList<>(); - public MavericksManager(JavaPlugin plugin) + public MavericksManager(JavaPlugin plugin, CosmeticManager cosmeticManager) { super("Mavericks", plugin); - _portalManager = new MavericksPortalManager(_plugin); + + _worldManager = new MavericksWorldManager(plugin); + _portalManager = new MavericksPortalManager(plugin, _worldManager, cosmeticManager); _repoApproved = new MavericksApprovedRepository(); - _displaySlots.add(new DisplaySlot(new Location(Bukkit.getWorld("world"), -19, 63, -118))); - _displaySlots.add(new DisplaySlot(new Location(Bukkit.getWorld("world"), -19, 63, -145))); + _displaySlots.add(new DisplaySlot(new Location(_worldManager.getWorld(), -41, 24, 237))); + _displaySlots.add(new DisplaySlot(new Location(_worldManager.getWorld(), 19, 24, 237))); } /** @@ -137,6 +156,119 @@ public class MavericksManager extends MiniPlugin } + @EventHandler + public void onUnload(ChunkUnloadEvent event) + { + for(Entity e : event.getChunk().getEntities()) + { + if(isStatueEntity(e)) + { + event.setCancelled(true); + return; + } + } + } + + @EventHandler + public void onGrow(BlockGrowEvent event) + { + if(isInsideDisplaySlot(event.getBlock())) + event.setCancelled(true); + } + + @EventHandler + public void onBurn(BlockBurnEvent event) + { + if(isInsideDisplaySlot(event.getBlock())) + event.setCancelled(true); + } + + @EventHandler + public void onFade(BlockFadeEvent event) + { + if(isInsideDisplaySlot(event.getBlock())) + event.setCancelled(true); + } + + @EventHandler + public void onRedstone(BlockRedstoneEvent event) + { + if(isInsideDisplaySlot(event.getBlock())) + event.setNewCurrent(event.getOldCurrent()); + } + + @EventHandler + public void onDecay(LeavesDecayEvent event) + { + if(isInsideDisplaySlot(event.getBlock())) + event.setCancelled(true); + } + + @EventHandler + public void onPhysics(BlockPhysicsEvent event) + { + if(isInsideDisplaySlot(event.getBlock())) + event.setCancelled(true); + } + + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if(isInsideDisplaySlot(event.getClickedBlock())) + event.setCancelled(true); + } + + + @EventHandler + public void ignite(EntityCombustEvent event) + { + if(isStatueEntity(event.getEntity())) + event.setCancelled(true); + } + + @EventHandler + public void onInteractEntity(PlayerInteractEntityEvent event) + { + if(isStatueEntity(event.getRightClicked())) + event.setCancelled(true); + } + + @EventHandler + public void onInteractEntity(PlayerInteractAtEntityEvent event) + { + if(isStatueEntity(event.getRightClicked())) + event.setCancelled(true); + } + + @EventHandler + public void onVehicleCollide(VehicleEntityCollisionEvent event) + { + if(isStatueEntity(event.getVehicle())) + event.setCancelled(true); + } + + @EventHandler + public void onMount(EntityMountEvent event) + { + if(isStatueEntity(event.getMount())) + event.setCancelled(true); + } + + public boolean isInsideDisplaySlot(Block block) + { + return isInsideDisplaySlot(block.getLocation().add(0.5, 0.5, 0.5)); + } + + public boolean isInsideDisplaySlot(Location loc) + { + for(DisplaySlot d : _displaySlots) + { + if(d.isInside(loc)) return true; + } + return false; + } + /** * Check if an entity is spawned in and managed by the mavericks "best of" builds. * @param e The entity you want to check. diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java index 9a05b6047..ca60449f4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java @@ -3,15 +3,14 @@ package mineplex.hub.modules; import java.util.ArrayList; import java.util.HashSet; +import org.bukkit.Color; import org.bukkit.EntityEffect; import org.bukkit.FireworkEffect.Type; -import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Bat; import org.bukkit.entity.Entity; import org.bukkit.entity.Firework; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Slime; import org.bukkit.entity.TNTPrimed; @@ -19,13 +18,11 @@ import org.bukkit.entity.WitherSkull; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.util.Vector; -import mineplex.core.MiniPlugin; +import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -352,6 +349,8 @@ public class SoccerManager extends MiniPlugin public boolean inPlayerArena(Entity entity) { + if(!entity.getWorld().equals(_cornerFieldA.getWorld())) return false; + return UtilAlg.inBoundingBox(entity.getLocation(), _cornerFieldPlayerA, _cornerFieldPlayerB) || UtilAlg.inBoundingBox(entity.getLocation(), _cornerGoalPlayerA, _cornerGoalPlayerB); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java index daa44dd72..c035382b9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java @@ -203,7 +203,7 @@ public class WorldManager extends MiniPlugin if (event.getType() != UpdateType.FASTEST) return; - for (Player player : UtilServer.getPlayers()) + for (Player player : Manager.GetSpawn().getWorld().getPlayers()) { if (UtilMath.offset(player.getLocation(), Manager.GetSpawn()) > 200) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/MavericksPortalManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/MavericksPortalManager.java index 5a0479b12..4f1a8f636 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/MavericksPortalManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/MavericksPortalManager.java @@ -14,6 +14,7 @@ import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; import mineplex.core.common.util.F; +import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; /** @@ -32,23 +33,26 @@ public class MavericksPortalManager extends MiniPlugin private Location _destHub; private Location _destMavericks; + + private CosmeticManager _cosmeticManager; - public MavericksPortalManager(JavaPlugin plugin) + public MavericksPortalManager(JavaPlugin plugin, MavericksWorldManager worldManager, CosmeticManager cosmeticManager) { super("Mavericks Teleporter", plugin); + _cosmeticManager = cosmeticManager; - _portalHubMavericks = new Box("world", new Vector(6, 72, -1), new Vector(5, 75, 1)); - _destMavericks = new Location(Bukkit.getWorld("world"), -32, 63, -119, -90, 0); + _portalHubMavericks = new Box("world", new Vector(6, 72, -1), new Vector(7, 75, 1)); + _destMavericks = worldManager.getSpawn(); - _portalMavericksHub = new Box("world", new Vector(-36, 63, -120), new Vector(-35, 66, -117)); + _portalMavericksHub = new Box(worldManager.getWorld().getName(), new Vector(-5, 20, 306), new Vector(-9, 23, 307)); _destHub = new Location(Bukkit.getWorld("world"), 0.5, 80, 0.5); } @EventHandler public void onUpdate(UpdateEvent event) { - if(event.getType() != UpdateType.FASTER) return; + if(event.getType() != UpdateType.TICK) return; for(Iterator it = _cooldown.iterator(); it.hasNext();) { @@ -63,15 +67,18 @@ public class MavericksPortalManager extends MiniPlugin if(box == null) continue; + _cosmeticManager.getPetManager().DisableAll(p); + _cosmeticManager.getMountManager().DisableAll(p); + if(box == _portalHubMavericks) { p.teleport(_destMavericks); - p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("mavericks") + " area.")); + p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Mavericks") + " area.")); } else if (box == _portalMavericksHub) { p.teleport(_destHub); - p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("hub") + " area.")); + p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Hub") + " area.")); } p.playSound(p.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1); @@ -86,7 +93,6 @@ public class MavericksPortalManager extends MiniPlugin return null; } - /** * A small AABB box util class. */ diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/MobPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/MobPage.java index 2165634ba..56eb7cb62 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/MobPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/MobPage.java @@ -65,7 +65,7 @@ public class MobPage extends ShopPageBase else ageable.setAdult(); - UtilPlayer.message(player, F.main("Game", entityName + " is now an " + (ageable.isAdult() ? "Adult" : "Baby"))); + UtilPlayer.message(player, F.main("Game", entityName + " is now " + (ageable.isAdult() ? "an Adult" : "a Baby"))); buildPage(); } }); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/buildmavericks/BuildMavericks.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/buildmavericks/BuildMavericks.java index c50ce817e..fbf9590b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/buildmavericks/BuildMavericks.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/buildmavericks/BuildMavericks.java @@ -53,22 +53,10 @@ public class BuildMavericks extends Build _words = new String[] { - "Rollercoaster", "Pokemon", "Pirates", "Vikings", "Dinosaur", "Dragon", "Toilet", "Farm", "Tree House", - "Cat", "Truck", "Bicycle", "Soda", "Music Instrument", "Statue", "Pot of Gold", "Shrek", "Fruit", "Breakfast", - "Toaster", "Robot", "Camping", "Rocket", "Aliens", "Shipwreck", "Spongebob", "Car", "Potted Plant", "Weapons", - "Christmas", "King", "Queen", "Angel", "Demon", "Halloween", "Tank", "Helicopter", "Knight", "Rabbit", - "Sandwich", "Snowman", "Ice Cream", "Sea Shell", "Rainbow", - "Volcano", "Hot Tub", "Octopus", "Ghost", "Ant", "Cheese", "Kite Flying", "Reptile", - "Space Ship", "Pixel Art", "Chicken", "Shoe", "Owl", "Bear", "Flowers", "Lighthouse", - "Lion", "Television", "Batman", "Tiger", "Castle", "House", - "Bed", "Party", "Volleyball", "Toys", "Library", "Love", "Skull", - "Hat", "Snake", "Vacation", "Umbrella", "Magic", "Tornado", "Candy", "Dentist", "Pizza", "Bird", - "Superhero", "Turtle", "Chicken", "Build Anything!", "Food", "Picnic", - "Trophy", "Pool Party", "Hot Air Balloon", "Train", "Chocolate Bar", - "Clown", "Windmill", "Alligator", - "Police", "Igloo", "Gift", "Bumblebee", "Jellyfish", "Speedboat", - "Fall", "Summer", "Autumn", "Winter", "Disco", "Moose", - "Water Gun", "Astronaut", "Wither", "Meteor" + "Maverick", "Champ", "Basketball", "Net", "Court", "Referee", "Basket", "Scoreboard", "Jump ball", "Player", + "Coach", "Shot clock", "Backboard", "Rim", "Bench", "Dribble", "Dunk", "Defense", "Swish", "Cheerleaders", + "Fans", "Trophy", "All-star", "Jersey", "Uniform", "Basketball shoes", "MVP", "Basketball shorts", "Jumbotron", + "Block", "Team bus", "Team plane", "Victory" }; _reposetory = new MavericksBuildRepository(); @@ -101,7 +89,8 @@ public class BuildMavericks extends Build BuildData data = e.getValue(); //TODO: Insert some real value here -// if(data.getPoints() <= 0) continue; + if(data.getPoints() < 2) continue; + if(data.IsAbusive) continue; UUID uuid = e.getKey().getUniqueId(); 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 2a3c5b75d..0ab765a42 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 @@ -42,6 +42,7 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerRespawnEvent; @@ -159,7 +160,7 @@ public class GamePlayerManager implements Listener @EventHandler public void DisallowCreativeClick(InventoryClickEvent event) { - if (Manager.GetGame() == null || !Manager.GetGame().InProgress() || Manager.GetGameHostManager().isEventServer() || Manager.GetGame().GetType() == GameType.Build) + if (Manager.GetGame() == null || !Manager.GetGame().InProgress() || Manager.GetGameHostManager().isEventServer() || Manager.GetGame().GetType() == GameType.Build || Manager.GetGame().GetType() == GameType.BuildMavericks) return; if ((event.getInventory().getType() == InventoryType.CREATIVE || event.getInventory().getType() == InventoryType.PLAYER) && !event.getWhoClicked().isOp()) diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/MavericksReviewManager.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/MavericksReviewManager.java index 7dca2d62e..c1234f33b 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/MavericksReviewManager.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/MavericksReviewManager.java @@ -22,8 +22,14 @@ import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockGrowEvent; import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.block.BlockRedstoneEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.FoodLevelChangeEvent; @@ -35,6 +41,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; @@ -49,6 +56,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; @@ -77,8 +85,12 @@ public class MavericksReviewManager extends MiniPlugin private Location _spawn; private World _world; + private List _processing = new ArrayList<>(); + private List _reviewQueue = new ArrayList<>(); + private final boolean DEBUG = false; + private ItemStack _itemEnterReviewMode; private ItemStack _itemExitReviewMode; private ItemStack _itemNext; @@ -139,6 +151,36 @@ public class MavericksReviewManager extends MiniPlugin }.runTask(UtilServer.getPlugin()); } + @EventHandler + public void onGrow(BlockGrowEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onBurn(BlockBurnEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void ignite(EntityCombustEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onRedstone(BlockRedstoneEvent event) + { + event.setNewCurrent(event.getOldCurrent()); + } + + @EventHandler + public void onDecay(LeavesDecayEvent event) + { + event.setCancelled(true); + } + @EventHandler public void onIgnite(BlockIgniteEvent event) { @@ -157,6 +199,12 @@ public class MavericksReviewManager extends MiniPlugin event.setCancelled(true); } + @EventHandler + public void onVehicleCollide(VehicleEntityCollisionEvent event) + { + event.setCancelled(true); + } + @EventHandler public void onDamage(EntityDamageEvent event) { @@ -170,7 +218,6 @@ public class MavericksReviewManager extends MiniPlugin @EventHandler public void onJoin(PlayerJoinEvent event) { - OFFSET_VECTOR.setX(8); event.getPlayer().getInventory().removeItem(_itemApprove, _itemDeny, _itemExitReviewMode, _itemFilter, _itemNext, _itemPrevious); event.getPlayer().getInventory().setItem(0, _itemEnterReviewMode); @@ -214,7 +261,7 @@ public class MavericksReviewManager extends MiniPlugin @EventHandler public void onInteract(PlayerInteractEvent event) - { + { Player player = event.getPlayer(); if(isActionItem(event.getItem())) @@ -232,6 +279,15 @@ public class MavericksReviewManager extends MiniPlugin if(!Recharge.Instance.use(player, "MavericksReviewManager Action - " + name, 500, false, false)) return; + if(_processing.contains(player)) + { + player.sendMessage(F.main(getName(), "Your action is still processing. Please wait...")); + player.playSound(player.getLocation(), Sound.NOTE_PIANO, 0.5f, 1); + return; + } + + _processing.add(player); + if(event.getItem().equals(_itemEnterReviewMode)) { if(isInReviewMode(player)) @@ -248,11 +304,13 @@ public class MavericksReviewManager extends MiniPlugin player.getInventory().setItem(i, null); } - player.getInventory().setItem(0, _itemPrevious); + ItemStack back = _itemPrevious.clone(); + UtilInv.addDullEnchantment(back); + player.getInventory().setItem(0, back); player.getInventory().setItem(1, _itemNext); player.getInventory().setItem(3, _itemApprove); player.getInventory().setItem(4, _itemDeny); - player.getInventory().setItem(6, _itemFilter); + //player.getInventory().setItem(6, _itemFilter); player.getInventory().setItem(8, _itemExitReviewMode); _reviewers.put(player, data); @@ -275,6 +333,8 @@ public class MavericksReviewManager extends MiniPlugin _reviewers.remove(player); player.teleport(_spawn); + + _processing.remove(player); } else if(!isInReviewMode(player)) @@ -282,6 +342,7 @@ public class MavericksReviewManager extends MiniPlugin player.sendMessage(F.main(getName(), "Invalid action!")); player.sendMessage(F.main(getName(), "You are not currently in " + F.item("review mode"))); player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0); + _processing.remove(player); return; } else if(event.getItem().equals(_itemApprove)) @@ -293,6 +354,7 @@ public class MavericksReviewManager extends MiniPlugin player.sendMessage(F.main(getName(), "Invalid action!")); player.sendMessage(F.main(getName(), "You are currently not reviewing a build.")); player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0); + _processing.remove(player); return; } @@ -302,6 +364,7 @@ public class MavericksReviewManager extends MiniPlugin player.sendMessage(F.main(getName(), "Contact the tech wizards if you want to change the")); player.sendMessage(F.main(getName(), "state of the already reviewed build.")); player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0); + _processing.remove(player); return; } @@ -321,20 +384,23 @@ public class MavericksReviewManager extends MiniPlugin player.sendMessage(F.main(getName(), "Marked build as " + F.item("processed") + ".")); player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 0); player.sendMessage(F.main(getName(), "Loading next build...")); + clear(reviewData); pasteBuild(player, true); } else { - player.sendMessage(F.main(getName(), "Unable to mark the build as " + F.color("denied", C.cRed) + "!")); + player.sendMessage(F.main(getName(), "Unable to mark the build as " + F.item("processed") + "!")); player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0); } + _processing.remove(player); })); } else { - player.sendMessage(F.main(getName(), "Unable to mark the build as " + F.color("denied", C.cRed) + "!")); + player.sendMessage(F.main(getName(), "Unable to mark the build as " + F.color("approved", C.cGreen) + "!")); player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0); + _processing.remove(player); } })); } @@ -346,15 +412,18 @@ public class MavericksReviewManager extends MiniPlugin player.sendMessage(F.main(getName(), "Invalid action!")); player.sendMessage(F.main(getName(), "You are currently not reviewing a build.")); player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0); + _processing.remove(player); return; } if(data.isReviewed()) { - player.sendMessage(F.main(getName(), "This build has already been reviewed!")); - player.sendMessage(F.main(getName(), "Contact the tech wizards if you want to change the")); - player.sendMessage(F.main(getName(), "state of the already reviewed build.")); + player.sendMessage(F.main(getName(), "This build has already been")); + player.sendMessage(F.main(getName(), "reviewed! Contact the tech wizards")); + player.sendMessage(F.main(getName(), "if you want to change the state of")); + player.sendMessage(F.main(getName(), "the already reviewed build.")); player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0); + _processing.remove(player); return; } @@ -362,9 +431,11 @@ public class MavericksReviewManager extends MiniPlugin { if(success) { + data.setReviewed(true); player.sendMessage(F.main(getName(), "Marked build as " + F.color("denied", C.cRed) + ".")); player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 0); player.sendMessage(F.main(getName(), "Loading next build...")); + clear(_reviewers.get(player)); pasteBuild(player, true); } else @@ -372,12 +443,14 @@ public class MavericksReviewManager extends MiniPlugin player.sendMessage(F.main(getName(), "Unable to mark the build as " + F.color("denied", C.cRed) + "!")); player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0); } + _processing.remove(player); })); } else if(event.getItem().equals(_itemFilter)) { player.sendMessage(F.main(getName(), "Not yet implemented.")); player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0); + _processing.remove(player); } else if(event.getItem().equals(_itemNext)) { @@ -396,6 +469,7 @@ public class MavericksReviewManager extends MiniPlugin { player.sendMessage(F.main(getName(), "Invalid action!")); player.sendMessage(F.main(getName(), "You are not currently in " + F.item("review mode"))); + _processing.remove(player); return; } @@ -411,7 +485,11 @@ public class MavericksReviewManager extends MiniPlugin if(!next && data == null) { player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0.5f); - player.sendMessage(F.main(getName(), "No more previous build")); + player.sendMessage(F.main(getName(), "No previous builds available")); + ItemStack back = player.getInventory().getItem(0).clone(); + UtilInv.addDullEnchantment(back); + player.getInventory().setItem(0, back); + _processing.remove(player); return; } if(next && data == null) @@ -423,35 +501,33 @@ public class MavericksReviewManager extends MiniPlugin { player.sendMessage(F.main(getName(), "No new data was found.")); player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0); + _processing.remove(player); } else { - Bukkit.broadcastMessage("Displaying from DB -2"); + if(DEBUG) Bukkit.broadcastMessage("Displaying from DB -2"); try { + player.getInventory().setItem(0, _itemPrevious); display(player, review, pulledData); } catch(Exception e) { e.printStackTrace(); + _processing.remove(player); } } }); } if(data != null) { - Bukkit.broadcastMessage("Displaying fast"); + if(DEBUG) Bukkit.broadcastMessage("Displaying fast"); display(player, review, data); + player.getInventory().setItem(0, _itemPrevious); } } - private void display(Player player, ReviewData review, MavericksBuildWrapper data) + private void clear(ReviewData review) { - Location loc = review.getLoc(); - Location paste = review.getAreaMin().add(1, 1, 1); - loc.setDirection(OFFSET_VECTOR.clone().add(new Vector(0, 4, 0))); - - Bukkit.broadcastMessage("Trying to parse from " + data.getDateStamp()); - Bukkit.broadcastMessage("SBytes: " + data.getSchematicBytes().length + ", Schematic: " + data.getSchematic()); - Schematic schematic = data.getSchematic(); + if(review == null) return; UtilBlock.startQuickRecording(); //Clear old blocks for stuff like lava and so on. @@ -462,7 +538,6 @@ public class MavericksReviewManager extends MiniPlugin Location a = review.getAreaMin(); Location b = review.getAreaMax(); b.setY(a.getY()); - // Floor for(Block block : UtilBlock.getInBoundingBox(a, b, false)) { @@ -475,16 +550,27 @@ public class MavericksReviewManager extends MiniPlugin } UtilBlock.stopQuickRecording(); - List list = review.getEntitiesInArea(); for(Entity e : list) { e.remove(); } - Bukkit.broadcastMessage("Cleared " + list.size() + " entities in area"); + if(DEBUG) Bukkit.broadcastMessage("Cleared " + list.size() + " entities in area"); + } + + private void display(Player player, ReviewData review, MavericksBuildWrapper data) + { + Location loc = review.getLoc(); + Location paste = review.getAreaMin().add(1, 1, 1); + loc.setDirection(OFFSET_VECTOR.clone().add(new Vector(0, 4, 0))); + + clear(review); + + if(DEBUG) Bukkit.broadcastMessage("Trying to parse from " + data.getDateStamp()); + if(DEBUG) Bukkit.broadcastMessage("SBytes: " + data.getSchematicBytes().length + ", Schematic: " + data.getSchematic()); + Schematic schematic = data.getSchematic(); SchematicData pasteData = schematic.paste(paste, false, false); - for(Entity e : pasteData.getEntities()) { if(e instanceof Item) @@ -498,18 +584,17 @@ public class MavericksReviewManager extends MiniPlugin UtilEnt.ghost(e, true, false); } } - player.sendMessage(ArcadeFormat.Line); String key = C.cGreen + C.Bold; String value = C.cYellow + C.Bold; - SimpleDateFormat dformat = new SimpleDateFormat("LL-MM-DD kk:mm:ss z"); + SimpleDateFormat dformat = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss z"); player.sendMessage(key + "BuildId: " + value + data.getBuildId()); player.sendMessage(key + "Creator: " + value + data.getUUID()); player.sendMessage(key + "Last C Name: " + value + (data.hasNameSet() ? data.getName() : C.Italics + "Not Avalible")); player.sendMessage(key + "Word: " + value + data.getTheme()); - player.sendMessage(key + "Place: " + value + data.getPlace()); + player.sendMessage(key + "Place: " + value + (data.getPlace() + 1)); player.sendMessage(key + "Points: " + value + data.getPoints()); player.sendMessage(key + "Date: " + value + dformat.format(new Date(data.getDateStamp()))); player.sendMessage(key + "Reviewed: " + value + data.isReviewed()); @@ -523,6 +608,7 @@ public class MavericksReviewManager extends MiniPlugin review.setData(data); + _processing.remove(player); } @@ -635,10 +721,10 @@ public class MavericksReviewManager extends MiniPlugin if(isTaken(wrapper)) continue; if(wrapper.isReviewed()) continue; if(wrapper.getSchematic() == null) continue; - Bukkit.broadcastMessage("Found avalible index: " + i); + if(DEBUG) Bukkit.broadcastMessage("Found avalible index: " + i); return i; } - Bukkit.broadcastMessage("Found no avalible indexes, returning next one: " + _reviewQueue.size()); + if(DEBUG) Bukkit.broadcastMessage("Found no avalible indexes, returning next one: " + _reviewQueue.size()); return _reviewQueue.size(); } @@ -647,7 +733,7 @@ public class MavericksReviewManager extends MiniPlugin if(_reviewQueue.size() > index) { consumer.accept(_reviewQueue.get(index)); - Bukkit.broadcastMessage("Local queue is bigger then index"); + if(DEBUG) Bukkit.broadcastMessage("Local queue is bigger then index"); return; } @@ -656,19 +742,26 @@ public class MavericksReviewManager extends MiniPlugin { if(!build.isReviewed()) offset++; } - Bukkit.broadcastMessage("Pulling from DB, limit: " + (index-_reviewQueue.size()+1) + ", offset " + offset); + + if(DEBUG) Bukkit.broadcastMessage("Pulling from DB, limit: " + (index-_reviewQueue.size()+1) + ", offset " + offset); + _repoBuilds.getToReview(true, index-_reviewQueue.size()+1, offset).thenCompose(BukkitFuture.accept((list) -> { - Bukkit.broadcastMessage("Retrived " + list.size() + " entries from DB"); + if(DEBUG) Bukkit.broadcastMessage("Retrived " + list.size() + " entries from DB"); + + + _reviewQueue.addAll(list); if(_reviewQueue.size() > index) { - Bukkit.broadcastMessage("Found new entry to process!"); + if(DEBUG) Bukkit.broadcastMessage("Found new entry to process!"); + consumer.accept(_reviewQueue.get(index)); } else { - Bukkit.broadcastMessage("Still not enough though"); + if(DEBUG) Bukkit.broadcastMessage("Still not enough though"); + consumer.accept(null); } })); diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/ReviewData.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/ReviewData.java index 5126579fb..f8c8bcab2 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/ReviewData.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/ReviewData.java @@ -7,7 +7,6 @@ import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import mineplex.core.common.block.schematic.Schematic; import mineplex.core.mavericks.MavericksBuildWrapper; /** * A simple wrapper class used to hold build data related to a location and player. @@ -59,7 +58,13 @@ public class ReviewData if(index <= 0) return null; - return _logg.get(index-1); + MavericksBuildWrapper data = _logg.get(index-1); + if(data != null && data.isReviewed()) + { + _data = data; + return getPrevious(); + } + return data; } public MavericksBuildWrapper getNext() @@ -69,7 +74,13 @@ public class ReviewData if(index == -1) return null; if(index+1 >= _logg.size()) return null; - return _logg.get(index+1); + MavericksBuildWrapper data = _logg.get(index+1); + if(data != null && data.isReviewed()) + { + _data = data; + return getNext(); + } + return data; } public boolean containsData(MavericksBuildWrapper data)