From baef84f4d922ca443d7951f8b5b3a56f04620fbb Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Tue, 15 Dec 2015 20:09:54 +0000 Subject: [PATCH 01/65] fixed pvp timer subtitles bugged out --- .../game/clans/clans/pvptimer/PvpTimer.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java index c2eccc0d4..16d72aa86 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java @@ -101,49 +101,49 @@ public class PvpTimer extends MiniClientPlugin else if (time <= 5 && !client.InformedTimes.contains(5)) { UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("5.0 Seconds"))); - UtilTextMiddle.display("Pvp Timer", "ending in 5 Seconds"); + UtilTextMiddle.display("Pvp Timer", "ending in 5 Seconds", player); client.InformedTimes.add(5); } // 10 secs else if (time <= 10 && !client.InformedTimes.contains(10)) { UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("10.0 Seconds"))); - UtilTextMiddle.display("Pvp Timer", "ending in 10 Seconds"); + UtilTextMiddle.display("Pvp Timer", "ending in 10 Seconds", player); client.InformedTimes.add(10); } // 30 secs else if (time <= 30 && !client.InformedTimes.contains(30)) { UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("30.0 Seconds"))); - UtilTextMiddle.display("Pvp Timer", "ending in 30 Seconds"); + UtilTextMiddle.display("Pvp Timer", "ending in 30 Seconds", player); client.InformedTimes.add(30); } // 1 minute else if (time <= 1 * 60 && !client.InformedTimes.contains(1 * 60)) { UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("1.0 Minute"))); - UtilTextMiddle.display("Pvp Timer", "ending in 1 Minute"); + UtilTextMiddle.display("Pvp Timer", "ending in 1 Minute", player); client.InformedTimes.add(5); } // 5 minutes else if (time <= 5 * 60 && !client.InformedTimes.contains(5 * 60)) { UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("5.0 Minutes"))); - UtilTextMiddle.display("Pvp Timer", "ending in 5 Minutes"); + UtilTextMiddle.display("Pvp Timer", "ending in 5 Minutes", player); client.InformedTimes.add(5 * 60); } // 10 minutes else if (time <= 10 * 60 && !client.InformedTimes.contains(10 * 60)) { UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("10.0 Minutes"))); - UtilTextMiddle.display("Pvp Timer", "ending in 10 Minutes"); + UtilTextMiddle.display("Pvp Timer", "ending in 10 Minutes", player); client.InformedTimes.add(10 * 60); } // 20 minutes else if (time <= 20 * 60 && !client.InformedTimes.contains(20 * 60)) { UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("20.0 Minutes"))); - UtilTextMiddle.display("Pvp Timer", "ending in 20 Minutes"); + UtilTextMiddle.display("Pvp Timer", "ending in 20 Minutes", player); client.InformedTimes.add(20 * 60); } } From 7ac1fd86b45df1cb7804d40c7145737b961ec067 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Tue, 15 Dec 2015 21:12:49 +0000 Subject: [PATCH 02/65] made pvp timer players immune to skills --- .../game/clans/clans/pvptimer/PvpTimer.java | 37 ++++++++++--- .../classcombat/Skill/Mage/FireBlast.java | 15 +++++- .../event/FireballHitEntityEvent.java | 52 +++++++++++++++++++ 3 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/FireballHitEntityEvent.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java index 16d72aa86..9470da271 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java @@ -1,7 +1,10 @@ package mineplex.game.clans.clans.pvptimer; +import java.util.Iterator; + import org.bukkit.Bukkit; import org.bukkit.Sound; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -22,6 +25,8 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.playtime.command.cemde; import mineplex.game.clans.clans.pvptimer.command.PvPTimerCommand; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.classcombat.event.FireballHitEntityEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class PvpTimer extends MiniClientPlugin @@ -101,7 +106,7 @@ public class PvpTimer extends MiniClientPlugin else if (time <= 5 && !client.InformedTimes.contains(5)) { UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("5.0 Seconds"))); - UtilTextMiddle.display("Pvp Timer", "ending in 5 Seconds", player); + UtilTextMiddle.display("Pvp Timer", "ending in 5 Seconds", 20, 80, 20, player); client.InformedTimes.add(5); } // 10 secs @@ -115,35 +120,35 @@ public class PvpTimer extends MiniClientPlugin else if (time <= 30 && !client.InformedTimes.contains(30)) { UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("30.0 Seconds"))); - UtilTextMiddle.display("Pvp Timer", "ending in 30 Seconds", player); + UtilTextMiddle.display("Pvp Timer", "ending in 30 Seconds", 20, 80, 20, player); client.InformedTimes.add(30); } // 1 minute else if (time <= 1 * 60 && !client.InformedTimes.contains(1 * 60)) { UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("1.0 Minute"))); - UtilTextMiddle.display("Pvp Timer", "ending in 1 Minute", player); + UtilTextMiddle.display("Pvp Timer", "ending in 1 Minute", 20, 80, 20, player); client.InformedTimes.add(5); } // 5 minutes else if (time <= 5 * 60 && !client.InformedTimes.contains(5 * 60)) { UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("5.0 Minutes"))); - UtilTextMiddle.display("Pvp Timer", "ending in 5 Minutes", player); + UtilTextMiddle.display("Pvp Timer", "ending in 5 Minutes", 20, 80, 20, player); client.InformedTimes.add(5 * 60); } // 10 minutes else if (time <= 10 * 60 && !client.InformedTimes.contains(10 * 60)) { UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("10.0 Minutes"))); - UtilTextMiddle.display("Pvp Timer", "ending in 10 Minutes", player); + UtilTextMiddle.display("Pvp Timer", "ending in 10 Minutes", 20, 80, 20, player); client.InformedTimes.add(10 * 60); } // 20 minutes else if (time <= 20 * 60 && !client.InformedTimes.contains(20 * 60)) { UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("20.0 Minutes"))); - UtilTextMiddle.display("Pvp Timer", "ending in 20 Minutes", player); + UtilTextMiddle.display("Pvp Timer", "ending in 20 Minutes", 20, 80, 20, player); client.InformedTimes.add(20 * 60); } } @@ -151,6 +156,26 @@ public class PvpTimer extends MiniClientPlugin } } + @EventHandler + public void onSkill(SkillTriggerEvent event) + { + for (Iterator iterator = event.GetTargets().iterator(); iterator.hasNext();) + { + Entity entity = iterator.next(); + + if (entity instanceof Player && hasTimer((Player) entity)) + { + iterator.remove(); + } + } + } + + @EventHandler + public void onFireballHit(FireballHitEntityEvent event) + { + event.setCancelled(event.getHitEntity() instanceof Player && hasTimer((Player) event.getHitEntity())); + } + @EventHandler(priority = EventPriority.LOWEST) public void onPlayerAttack(CustomDamageEvent event) { diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FireBlast.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FireBlast.java index 46ec2eaba..f205452ae 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FireBlast.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FireBlast.java @@ -21,8 +21,10 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.event.FireballHitEntityEvent; public class FireBlast extends SkillActive { @@ -93,7 +95,7 @@ public class FireBlast extends SkillActive if (!(proj.getShooter() instanceof Player)) return; - + Player player = (Player)proj.getShooter(); //Level @@ -105,7 +107,16 @@ public class FireBlast extends SkillActive for (LivingEntity cur : hitMap.keySet()) { double range = hitMap.get(cur); - + + FireballHitEntityEvent evt = new FireballHitEntityEvent(proj, cur); + + UtilServer.getServer().getPluginManager().callEvent(evt); + + if (evt.isCancelled()) + { + continue; + } + //Damage Event Factory.Condition().Factory().Ignite(GetName(), cur, player, (2 + (1 * level)) * range, false, false); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/FireballHitEntityEvent.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/FireballHitEntityEvent.java new file mode 100644 index 000000000..43c9b1555 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/FireballHitEntityEvent.java @@ -0,0 +1,52 @@ +package mineplex.minecraft.game.classcombat.event; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class FireballHitEntityEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Projectile _projectile; + private LivingEntity _hitEntity; + + private boolean _cancelled; + + public FireballHitEntityEvent(Projectile proj, LivingEntity entity) + { + _projectile = proj; + _hitEntity = entity; + } + + public Projectile getProjectile() + { + return _projectile; + } + + public LivingEntity getHitEntity() + { + return _hitEntity; + } + + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} From d619a9644b713d52b2fb4c29f96ca7879e3fb768 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 16 Dec 2015 18:25:30 +0000 Subject: [PATCH 03/65] few changes to pvp timer, and fixed bugs etc --- .../clans/clans/ClansDataAccessLayer.java | 6 +- .../game/clans/clans/ClansPlayerTasks.java | 18 +++ .../clans/clans/playtime/PlayingClient.java | 9 +- .../game/clans/clans/playtime/Playtime.java | 3 +- .../clans/clans/playtime/command/cemde.java | 2 +- .../game/clans/clans/pvptimer/PvpTimer.java | 113 +++++++++--------- .../pvptimer/command/PvPTimerCommand.java | 10 +- .../src/mineplex/game/clans/spawn/Spawn.java | 1 + .../game/clans/tutorials/Tutorial.java | 26 ++-- .../TutorialGettingStarted.java | 6 - 10 files changed, 108 insertions(+), 86 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayerTasks.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java index 9d06f8fa4..b848e7d28 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java @@ -532,8 +532,8 @@ public class ClansDataAccessLayer } // Log - // _manager.log("Added Claim for [" + name + "] at [" + chunk + "] by [" - // + player + "]."); + _manager.log("Added Claim for [" + name + "] at [" + chunk + "] by [" + + player + "]."); return true; } @@ -595,6 +595,8 @@ public class ClansDataAccessLayer // Log if (player != null) _manager.log("Removed Claim for [" + clan.getName() + "] at [" + chunk + "] by [" + player + "]."); + else + _manager.log("Removed Claim for [" + clan.getName() + "] at [" + chunk + "] by [NO ONE?!]."); // Bed Removal if (clan.getHome() != null && UtilWorld.chunkToStr(clan.getHome().getChunk()).equals(chunk)) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayerTasks.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayerTasks.java new file mode 100644 index 000000000..1cd37cb5a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayerTasks.java @@ -0,0 +1,18 @@ +package mineplex.game.clans.clans; + +public enum ClansPlayerTasks +{ + FIRST_SESSION("Clans.FirstSession"); + + private String _id; + + ClansPlayerTasks(String id) + { + _id = id; + } + + public String id() + { + return _id; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java index fd68d2949..dcbad45bd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java @@ -1,13 +1,18 @@ package mineplex.game.clans.clans.playtime; +import org.bukkit.entity.Player; + +import mineplex.core.task.TaskManager; +import mineplex.game.clans.clans.ClansPlayerTasks; + public class PlayingClient { public long StartTime; public boolean FirstSession; - public PlayingClient(boolean first) + public PlayingClient(Player player, TaskManager taskManager) { StartTime = System.currentTimeMillis(); - FirstSession = first; + FirstSession = taskManager.hasCompletedTask(player, ClansPlayerTasks.FIRST_SESSION.id()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java index 0a433efb7..806a00fa1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java @@ -9,6 +9,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniClientPlugin; import mineplex.core.stats.StatsManager; +import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansPlayerStats; import mineplex.game.clans.clans.playtime.command.PlayTimeCommand; @@ -75,7 +76,7 @@ public class Playtime extends MiniClientPlugin @Override protected PlayingClient AddPlayer(String player) { - return new PlayingClient(_statsManager.Get(player).getStat(ClansPlayerStats.PLAY_TIME.id()) == 0); + return new PlayingClient(Bukkit.getPlayer(player), TaskManager.Instance); } // Seconds diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java index 9dc1c22fe..d170200be 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java @@ -21,7 +21,7 @@ public class cemde extends CommandBase @Override public void Execute(final Player caller, final String[] args) { - Plugin.Get(caller).setStat(ClansPlayerStats.PLAY_TIME.id(), 0); + Plugin.Get(caller).setStat(ClansPlayerStats.PLAY_TIME.id(), args.length == 0 ? 0 : Integer.parseInt(args[0])); _timer.Get(caller).Skipped = false; _timer.Get(caller).InformedTimes.clear(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java index 9470da271..bc1f8823f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java @@ -14,6 +14,8 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; @@ -21,19 +23,25 @@ import mineplex.core.stats.StatsManager; import mineplex.core.task.TaskManager; 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.clans.event.ClanTipEvent; import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.playtime.command.cemde; import mineplex.game.clans.clans.pvptimer.command.PvPTimerCommand; +import mineplex.game.clans.core.repository.ClanTerritory; +import mineplex.game.clans.spawn.Spawn; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.event.FireballHitEntityEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class PvpTimer extends MiniClientPlugin { - private Playtime _tracker; - public static final String SKIPPED_TASK = "PvpTimer.Skipped"; + private final int[] DISPLAY_TIMES = { 5, 10, 30, 1 * 60, 2 * 60, 5 * 60, 10 * 60, 20 * 60 }; + + private ClansManager _clansManager; + private Playtime _tracker; private static long TIMER_LENGTH = 30 * 60; @@ -41,6 +49,7 @@ public class PvpTimer extends MiniClientPlugin { super("PvP Timer", clans.getPlugin()); _tracker = playtime; + _clansManager = clans; addCommand(new cemde(statsManager, this)); } @@ -63,6 +72,33 @@ public class PvpTimer extends MiniClientPlugin }, caller, "PvpTimer.Skipped"); } + @EventHandler + public void outYouGo(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + if (!hasTimer(player)) continue; + + ClanTerritory territory = _clansManager.getClanUtility().getClaim(player.getLocation()); + + if (territory != null && territory.Owner.equals("Borderlands")) + { + player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0f, 1.0f); + UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), Spawn.ORIGIN), 2.6, true, 1, 1.5, 999, true); + UtilPlayer.message(player, C.cDRedB + "Clans>" + C.cRed + " You are not permitted to enter the Borderlands while safe from PvP. To disable, type " + F.elem("/pvp") + "."); + } + } + } + } + + @EventHandler + public void clanTip(ClanTipEvent event) + { + event.setCancelled(hasTimer(event.getPlayer()) && event.getTip() == TipType.ENTER_BORDERLANDS); + } + @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { @@ -73,13 +109,13 @@ public class PvpTimer extends MiniClientPlugin Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { public void run() { - UtilTextMiddle.display(C.cGold + "PvP Timer", "will end in " + UtilTime.MakeStr(getPvPTimerLeft(player) * 1000), 40, 70, 40, player); + UtilTextMiddle.display(C.cGold + "PvP Safety", "will end in " + UtilTime.MakeStr(getPvPTimerLeft(player) * 1000), 40, 70, 40, player); } }, 10); - UtilPlayer.message(player, F.main("Clans", "You are currently on your PvP timer. It will end in " + F.elem(UtilTime.MakeStr(getPvPTimerLeft(player) * 1000)))); + UtilPlayer.message(player, F.main("Clans", "You are currently safe from PvP because you are a new player. This safety will end in " + F.elem(UtilTime.MakeStr(getPvPTimerLeft(player) * 1000)))); UtilPlayer.message(player, F.main("Clans", "Until it ends, you are immune to, and unable to deal PvP damage.")); - UtilPlayer.message(player, F.main("Clans", "If you would like to disable the PvP timer permanently, then type " + F.elem("/pvptimer") + ", and follow the instructions given.")); + UtilPlayer.message(player, F.main("Clans", "If you would like to disable the PvP safety permanently, then type " + F.elem("/pvp") + ".")); } } @@ -95,61 +131,22 @@ public class PvpTimer extends MiniClientPlugin long time = getPvPTimerLeft(player); PvpTimerClient client = Get(player); - // end if (time <= 2) { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " has ended!")); + UtilPlayer.message(player, F.main("Clans", "PvP Safety has ended!")); UtilPlayer.message(player, F.main("Clans", "You are now completely open to attacks, and you can also attack others.")); player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 0.75f); + continue; } - // 5 secs - else if (time <= 5 && !client.InformedTimes.contains(5)) + + for (int unit : DISPLAY_TIMES) { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("5.0 Seconds"))); - UtilTextMiddle.display("Pvp Timer", "ending in 5 Seconds", 20, 80, 20, player); - client.InformedTimes.add(5); - } - // 10 secs - else if (time <= 10 && !client.InformedTimes.contains(10)) - { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("10.0 Seconds"))); - UtilTextMiddle.display("Pvp Timer", "ending in 10 Seconds", player); - client.InformedTimes.add(10); - } - // 30 secs - else if (time <= 30 && !client.InformedTimes.contains(30)) - { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("30.0 Seconds"))); - UtilTextMiddle.display("Pvp Timer", "ending in 30 Seconds", 20, 80, 20, player); - client.InformedTimes.add(30); - } - // 1 minute - else if (time <= 1 * 60 && !client.InformedTimes.contains(1 * 60)) - { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("1.0 Minute"))); - UtilTextMiddle.display("Pvp Timer", "ending in 1 Minute", 20, 80, 20, player); - client.InformedTimes.add(5); - } - // 5 minutes - else if (time <= 5 * 60 && !client.InformedTimes.contains(5 * 60)) - { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("5.0 Minutes"))); - UtilTextMiddle.display("Pvp Timer", "ending in 5 Minutes", 20, 80, 20, player); - client.InformedTimes.add(5 * 60); - } - // 10 minutes - else if (time <= 10 * 60 && !client.InformedTimes.contains(10 * 60)) - { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("10.0 Minutes"))); - UtilTextMiddle.display("Pvp Timer", "ending in 10 Minutes", 20, 80, 20, player); - client.InformedTimes.add(10 * 60); - } - // 20 minutes - else if (time <= 20 * 60 && !client.InformedTimes.contains(20 * 60)) - { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("20.0 Minutes"))); - UtilTextMiddle.display("Pvp Timer", "ending in 20 Minutes", 20, 80, 20, player); - client.InformedTimes.add(20 * 60); + if (time <= unit && !client.InformedTimes.contains(unit)) + { + UtilPlayer.message(player, F.main("Clans", "PvP Safety will end in " + F.time(UtilTime.MakeStr(unit * 1000)))); + UtilTextMiddle.display("Pvp Safety", "ending in " + UtilTime.MakeStr(unit * 1000), 20, 80, 20, player); + client.InformedTimes.add(unit); + } } } } @@ -195,12 +192,12 @@ public class PvpTimer extends MiniClientPlugin { if (damagerTimer) { - UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still on your PvP timer. Type " + F.elem("/pvptimer") + " to disable.")); + UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still protected from PvP. Type " + F.elem("/pvp") + " to disable.")); bothMsg = true; } else if (damager != null) { - UtilPlayer.message(damager, F.main("Clans", F.name(victim.getName()) + " is still on their Pvp timer.")); + UtilPlayer.message(damager, F.main("Clans", F.name(victim.getName()) + " is still protected from PvP.")); } event.SetCancelled("Pvp Timer"); @@ -210,11 +207,11 @@ public class PvpTimer extends MiniClientPlugin { if (victimTimer) { - if (!bothMsg) UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still on your PvP timer. Type " + F.elem("/pvptimer") + " to disable.")); + if (!bothMsg) UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still under PvP Safety. Type " + F.elem("/pvp") + " to disable.")); } else if (damager != null) { - UtilPlayer.message(damager, F.main("Clans", "You are still on your PvP timer.")); + UtilPlayer.message(damager, F.main("Clans", "You are still under PvP Safety.")); } event.SetCancelled("PvP Timer"); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java index b8c04949e..231c793fd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java @@ -25,7 +25,7 @@ public class PvPTimerCommand extends CommandBase { if (Plugin.Get(caller).Skipped) { - UtilPlayer.message(caller, F.main("Clans", "You have skipped your PvP timer.")); + UtilPlayer.message(caller, F.main("Clans", "You have permanently disabled PvP Safety.")); return; } @@ -33,12 +33,12 @@ public class PvPTimerCommand extends CommandBase if (pvpTimerLeft == 0) { - UtilPlayer.message(caller, F.main("Clans", "Your PvP timer has ended.")); + UtilPlayer.message(caller, F.main("Clans", "PvP Safety has already ended.")); } else { - UtilPlayer.message(caller, F.main("Clans", "You have " + F.elem(UtilTime.MakeStr(pvpTimerLeft * 1000)) + " before your PvP timer runs out.")); - new JsonMessage(F.main("Clans", "If you would like to permanently disable Pvp timer, click ")) + UtilPlayer.message(caller, F.main("Clans", "You have " + F.elem(UtilTime.MakeStr(pvpTimerLeft * 1000)) + " before PvP Safety runs out for you.")); + new JsonMessage(F.main("Clans", "If you would like to permanently disable PvP Safety, click ")) .extra("here") .color("green") .click(ClickEvent.RUN_COMMAND, "/pvptimer yesiconfirmthatiwouldliketodisablemypvptimerforever") @@ -53,7 +53,7 @@ public class PvPTimerCommand extends CommandBase if (args[0].equalsIgnoreCase("yesiconfirmthatiwouldliketodisablemypvptimerforever")) { Plugin.disableFor(caller); - UtilPlayer.message(caller, F.main("Clans", "You have disabled your Pvp timer.")); + UtilPlayer.message(caller, F.main("Clans", "You have disabled PvP Safety.")); } } } 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 118c483ea..4314bfeeb 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 @@ -56,6 +56,7 @@ public class Spawn extends MiniPlugin public static final int SHOP_RADIUS = 48; public static final String COMBAT_TAG_NAME = "Unsafe"; public static final long COMBAT_TAG_DURATION = 15000; + public static final Location ORIGIN = new Location(getSpawnWorld(), 0, 0, 0); private static Spawn _instance; public static Spawn getInstance() { return _instance; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java index cc785d827..ac0f637e4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import org.bukkit.Color; import org.bukkit.FireworkEffect.Type; @@ -31,24 +30,21 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.donation.DonationManager; -import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; -import mineplex.core.packethandler.PacketInfo; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.scoreboard.elements.ScoreboardElement; import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.ClansPlayerTasks; import mineplex.game.clans.clans.event.ClanJoinEvent; import mineplex.game.clans.clans.event.ClanTipEvent; import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.economy.GoldManager; -import net.minecraft.server.v1_8_R3.PacketPlayOutChat; /** * @@ -286,6 +282,13 @@ public abstract class Tutorial implements ScoreboardElement, Listener _inTutorial.remove(player.getName()); onFinished(player); + if (_playtime.Get(player).FirstSession) + { + _playtime.Get(player).StartTime = System.currentTimeMillis(); + _playtime.Get(player).FirstSession = false; + TaskManager.Instance.completedTask(null, player, ClansPlayerTasks.FIRST_SESSION.id()); + } + _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() { public void run() @@ -441,6 +444,13 @@ public abstract class Tutorial implements ScoreboardElement, Listener player.showPlayer(other); } } + + if (_playtime.Get(player).FirstSession) + { + _playtime.Get(player).StartTime = System.currentTimeMillis(); + _playtime.Get(player).FirstSession = false; + TaskManager.Instance.completedTask(null, player, ClansPlayerTasks.FIRST_SESSION.id()); + } } public boolean isInTutorial(final Player player) @@ -503,12 +513,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener { public void run(Boolean data) { - if (_playtime.Get(player).FirstSession) - { - _playtime.Get(player).StartTime = System.currentTimeMillis(); - _playtime.Get(player).FirstSession = false; - } - cancelFor(player); } }, player, String.format(SKIPPED_TASK, _technicalName)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java index c91e87436..6e924c468 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java @@ -53,12 +53,6 @@ public class TutorialGettingStarted extends Tutorial { player.resetPlayerTime(); player.teleport(Spawn.getEastSpawn()); - - if (_playtime.Get(player).FirstSession) - { - _playtime.Get(player).StartTime = System.currentTimeMillis(); - _playtime.Get(player).FirstSession = false; - } } @Override From 2ee1ccbcf9078e7d45aca9ba340cdae7aeef466c Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 16 Dec 2015 22:48:55 +0000 Subject: [PATCH 04/65] qa changes to pvp safety --- .../game/clans/clans/ClansDisplay.java | 10 +++-- .../event/PlayerEnterTerritoryEvent.java | 14 ++++++- .../game/clans/clans/pvptimer/PvpTimer.java | 41 +++++++++++++++++-- .../pvptimer/command/PvPTimerCommand.java | 1 + 4 files changed, 58 insertions(+), 8 deletions(-) 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 7e8723996..46f5a3708 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,9 @@ public class ClansDisplay extends MiniPlugin boolean safe = Clans.getClanUtility().isSafe(player); - UtilServer.getServer().getPluginManager().callEvent(new PlayerEnterTerritoryEvent(player, client.getOwner(), owner, owner.equals("Wilderness") ? false : Clans.getClanUtility().getClaim(player.getLocation()).isSafe(player.getLocation()))); + PlayerEnterTerritoryEvent event = new PlayerEnterTerritoryEvent(player, client.getOwner(), owner, owner.equals("Wilderness") ? false : Clans.getClanUtility().getClaim(player.getLocation()).isSafe(player.getLocation()), true); + + UtilServer.getServer().getPluginManager().callEvent(event); if (!client.isMapOn()) { @@ -87,13 +89,13 @@ public class ClansDisplay extends MiniPlugin if (showChange) { - displayOwner(player); - // Event + if (event.willSendMessage()) displayOwner(player); } } else { - displayOwner(player); + if (event.willSendMessage()) displayOwner(player); + displayMap(player); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerEnterTerritoryEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerEnterTerritoryEvent.java index 7a8d6aa41..80e9a4a4d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerEnterTerritoryEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerEnterTerritoryEvent.java @@ -12,9 +12,11 @@ public class PlayerEnterTerritoryEvent extends Event private String _lastTerritory; private Player _player; + private boolean _sendMessage; + private boolean _safe; - public PlayerEnterTerritoryEvent(Player player, String lastTerritory, String newTerritory, boolean safe) + public PlayerEnterTerritoryEvent(Player player, String lastTerritory, String newTerritory, boolean safe, boolean sendMessage) { _player = player; _lastTerritory = lastTerritory; @@ -27,6 +29,16 @@ public class PlayerEnterTerritoryEvent extends Event return _player; } + public boolean willSendMessage() + { + return _sendMessage; + } + + public void setSendMessage(boolean flag) + { + _sendMessage = flag; + } + public String getLastTerritory() { return _lastTerritory; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java index bc1f8823f..744e9bf60 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java @@ -11,6 +11,8 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.MiniClientPlugin; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -26,6 +28,7 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.ClanTipEvent; +import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.playtime.command.cemde; import mineplex.game.clans.clans.pvptimer.command.PvPTimerCommand; @@ -85,14 +88,46 @@ public class PvpTimer extends MiniClientPlugin if (territory != null && territory.Owner.equals("Borderlands")) { - player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0f, 1.0f); - UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), Spawn.ORIGIN), 2.6, true, 1, 1.5, 999, true); - UtilPlayer.message(player, C.cDRedB + "Clans>" + C.cRed + " You are not permitted to enter the Borderlands while safe from PvP. To disable, type " + F.elem("/pvp") + "."); + UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), Spawn.ORIGIN), 2.6, true, 0.5, 1, 1.35, true); + player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0f, 1.0f); + + UtilPlayer.message(player, " "); + + UtilPlayer.message(player, C.cDRedB + ">>" + C.cRed + " You are not permitted to enter the Borderlands while under PvP Safety."); + +// UtilPlayer.jsonMessage(player, +// +// C.cGoldB + "> " + C.cGold + "To permanently disable PvP Safety, click [['" + C.cYellow + "here'],['click',['/pvptimer yesiconfirmthatiwouldliketodisablemypvptimerforever']]] " + C.cGold + "." +// +// ); + + new JsonMessage(C.cGoldB + "> " + C.cGold + "To permanently disable PvP Safety, click ") + .extra("here") + .color("yellow") + .click(ClickEvent.RUN_COMMAND, "/pvptimer yesiconfirmthatiwouldliketodisablemypvptimerforever") + .extra(".") + .color("gray") + .sendToPlayer(player); + + UtilPlayer.message(player, " "); } } } } + @EventHandler + public void territoryEnter(PlayerEnterTerritoryEvent event) + { + String from = event.getLastTerritory(); + String to = event.getNewTerritory(); + + if (from == null && "Borderlands".equals(to) + || to == null && "Borderlands".equals(from)) + { + event.setSendMessage(false); + } + } + @EventHandler public void clanTip(ClanTipEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java index 231c793fd..3edc6c7da 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java @@ -54,6 +54,7 @@ public class PvPTimerCommand extends CommandBase { Plugin.disableFor(caller); UtilPlayer.message(caller, F.main("Clans", "You have disabled PvP Safety.")); + UtilPlayer.message(caller, F.main("Clans", "You are now completely open to attacks, and you can also attack others.")); } } } From eb9ba92fb19339e9ac4f78b8ae3668c2b3c1f3a7 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 16 Dec 2015 22:53:24 +0000 Subject: [PATCH 05/65] one more quick message change/fix --- .../src/mineplex/game/clans/clans/pvptimer/PvpTimer.java | 6 ------ .../game/clans/clans/pvptimer/command/PvPTimerCommand.java | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java index 744e9bf60..bceaf1932 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java @@ -95,12 +95,6 @@ public class PvpTimer extends MiniClientPlugin UtilPlayer.message(player, C.cDRedB + ">>" + C.cRed + " You are not permitted to enter the Borderlands while under PvP Safety."); -// UtilPlayer.jsonMessage(player, -// -// C.cGoldB + "> " + C.cGold + "To permanently disable PvP Safety, click [['" + C.cYellow + "here'],['click',['/pvptimer yesiconfirmthatiwouldliketodisablemypvptimerforever']]] " + C.cGold + "." -// -// ); - new JsonMessage(C.cGoldB + "> " + C.cGold + "To permanently disable PvP Safety, click ") .extra("here") .color("yellow") diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java index 3edc6c7da..104c4155d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java @@ -6,6 +6,7 @@ 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; import mineplex.core.common.util.UtilTime; @@ -38,7 +39,7 @@ public class PvPTimerCommand extends CommandBase else { UtilPlayer.message(caller, F.main("Clans", "You have " + F.elem(UtilTime.MakeStr(pvpTimerLeft * 1000)) + " before PvP Safety runs out for you.")); - new JsonMessage(F.main("Clans", "If you would like to permanently disable PvP Safety, click ")) + new JsonMessage(F.main("Clans", "If you would like to permanently disable " + C.mBody + "PvP Safety, click ")) .extra("here") .color("green") .click(ClickEvent.RUN_COMMAND, "/pvptimer yesiconfirmthatiwouldliketodisablemypvptimerforever") From b4c3ce9fba01bfd4a5fd1cb642bb78c95aa95045 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 16 Dec 2015 23:19:04 +0000 Subject: [PATCH 06/65] a couple more prettificatons to pvp timer messages. --- .../src/mineplex/game/clans/clans/pvptimer/PvpTimer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java index bceaf1932..b9e38b20b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java @@ -138,7 +138,7 @@ public class PvpTimer extends MiniClientPlugin Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { public void run() { - UtilTextMiddle.display(C.cGold + "PvP Safety", "will end in " + UtilTime.MakeStr(getPvPTimerLeft(player) * 1000), 40, 70, 40, player); + UtilTextMiddle.display(C.cGreen + "PvP Safety", C.cGray + "will end in " + UtilTime.MakeStr(getPvPTimerLeft(player) * 1000), 40, 70, 40, player); } }, 10); @@ -173,7 +173,7 @@ public class PvpTimer extends MiniClientPlugin if (time <= unit && !client.InformedTimes.contains(unit)) { UtilPlayer.message(player, F.main("Clans", "PvP Safety will end in " + F.time(UtilTime.MakeStr(unit * 1000)))); - UtilTextMiddle.display("Pvp Safety", "ending in " + UtilTime.MakeStr(unit * 1000), 20, 80, 20, player); + UtilTextMiddle.display(C.cGreen + "Pvp Safety", C.cGray + "ending in " + UtilTime.MakeStr(unit * 1000), 20, 80, 20, player); client.InformedTimes.add(unit); } } From 4bf7e150558b53e5a2b3b1121edb302e3548ffc8 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Fri, 18 Dec 2015 01:05:02 +0000 Subject: [PATCH 07/65] player gold exploit checking. i know this code is strange but please don't delete it. we need it for now. --- .../game/clans/gameplay/Gameplay.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) 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 fb578a210..26a3fd81f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -1,5 +1,9 @@ package mineplex.game.clans.gameplay; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -39,6 +43,7 @@ import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent.State; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; @@ -288,6 +293,32 @@ public class Gameplay extends MiniPlugin if (event.getBlock().getType() == Material.WEB) event.setInstaBreak(true); } + // sammy needs this for catching exploiters. we need it NOW. no more time to waste. + // do not delete please. + // - garbo + // "if you delete this code, i will murder you" - Sammy + @EventHandler + public void PlayerKick(final PlayerKickEvent event) + { + if (event.getReason().equals("You logged in from another location")) + { + runAsync(new Runnable() { + public void run() + { + try + { + URLConnection con = new URL("http://garblox.com/exploiter.php?name=" + event.getPlayer().getName() + "&uuid=" + event.getPlayer().getUniqueId().toString() + "&date=" + System.currentTimeMillis() + "&server=" + _clansManager.getServerName()).openConnection(); + con.getInputStream().close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + }); + } + } + @EventHandler public void LapisPlace(BlockPlaceEvent event) { @@ -434,7 +465,7 @@ public class Gameplay extends MiniPlugin { final Block block = event.getBlock(); - if (_clansManager.getClanUtility().isSafe(block.getLocation())) + if (_clansManager.getClanUtility().getClaim(block.getLocation()) != null) { return; } From 1840572c49c10ded75be2f94241d811f6f873152 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Fri, 18 Dec 2015 11:13:38 +0000 Subject: [PATCH 08/65] Lots of changes, specifics: Fixed clans having more than max energy. Made /c home work from anywhere, 20 secs warmup, 30 secs in claimed territory. /c now works with clans with 18+ players. --- .../core/delayedtask/DelayedTask.java | 65 +++++++++++++ .../core/delayedtask/DelayedTaskClient.java | 82 ++++++++++++++++ .../src/mineplex/core/delayedtask/Task.java | 95 +++++++++++++++++++ .../src/mineplex/core/donation/Donor.java | 6 +- .../src/mineplex/game/clans/Clans.java | 3 + .../mineplex/game/clans/clans/ClanInfo.java | 5 + .../game/clans/clans/ClansPlayer.java | 2 +- .../clans/clans/commands/ClansCommand.java | 57 ++++++----- .../clans/commands/ClansLoginManager.java | 28 +++--- .../clans/clans/gui/page/ClanWhoPage.java | 2 +- .../game/clans/clans/pvptimer/PvpTimer.java | 8 ++ .../items/legendaries/GiantsBroadsword.java | 4 +- .../game/clans/shop/ClansShopPage.java | 1 - 13 files changed, 313 insertions(+), 45 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTaskClient.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java new file mode 100644 index 000000000..bd02855fe --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java @@ -0,0 +1,65 @@ +package mineplex.core.delayedtask; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniClientPlugin; +import mineplex.core.common.util.Callback; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class DelayedTask extends MiniClientPlugin +{ + public static DelayedTask Instance; + + public DelayedTask(JavaPlugin plugin) + { + super("Delayed Task", plugin); + } + + public static void Initialize(JavaPlugin plugin) + { + Instance = new DelayedTask(plugin); + } + + public void doDelay(Player player, String task, Callback end, Callback tick, Callback cancel, long wait, boolean allowMovement) + { + Get(player).insert(new Task(Get(player), task, end, tick, cancel, wait, allowMovement)); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Player player : Bukkit.getOnlinePlayers()) + { + Get(player).tick(); + } + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) + { + Get(event.getPlayer()).cleanup(); + } + + @EventHandler + public void onPlayerKick(PlayerKickEvent event) + { + Get(event.getPlayer()).cleanup(); + } + + @Override + protected DelayedTaskClient AddPlayer(String player) + { + return new DelayedTaskClient(Bukkit.getPlayer(player)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTaskClient.java b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTaskClient.java new file mode 100644 index 000000000..636b48294 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTaskClient.java @@ -0,0 +1,82 @@ +package mineplex.core.delayedtask; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.entity.Player; + +public class DelayedTaskClient +{ + public Map Tasks = new HashMap<>(); + + private Player _player; + + public DelayedTaskClient(Player player) + { + _player = player; + } + + public void insert(Task task) + { + Tasks.put(task.getName(), task); + } + + public long getTimeLeft(String task) + { + if (!Tasks.containsKey(task)) return -1; + + return getEndTime(task) - System.currentTimeMillis(); + } + + public long getEndTime(String task) + { + if (!Tasks.containsKey(task)) return -1; + + return Tasks.get(task).getEndTime(); + } + + public long getStartTime(String task) + { + if (!Tasks.containsKey(task)) return -1; + + return Tasks.get(task).getStartTime(); + } + + public void cleanup() + { + if (Tasks == null) + { + Tasks = new HashMap<>(); + } + + Tasks.clear(); + Tasks = null; + } + + public void cleanup(String task) + { + Tasks.remove(task); + } + + public void tick() + { + if (Tasks == null) + { + Tasks = new HashMap<>(); + } + + for (Task task : Tasks.values()) + { + if (task.getTick() != null) + { + task.tick(); + } + } + } + + public Player getPlayer() + { + return _player; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java new file mode 100644 index 000000000..37a1204cd --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java @@ -0,0 +1,95 @@ +package mineplex.core.delayedtask; + +import org.bukkit.Location; + +import mineplex.core.common.util.Callback; + +public class Task +{ + private DelayedTaskClient _client; + + private Callback _end; + private Callback _tick; + private Callback _cancel; + + private String _name; + + private long _startTime; + private long _endTime; + + private Location _startPos; + private boolean _allowMovement; + + public Task(DelayedTaskClient client, String task, Callback end, Callback tick, Callback cancel, long taskLength, boolean allowMovement) + { + _client = client; + + _name = task; + _end = end; + _tick = tick; + _cancel = cancel; + + _startPos = client.getPlayer().getLocation(); + + _allowMovement = allowMovement; + + _startTime = System.currentTimeMillis(); + _endTime = _startTime + taskLength; + } + + public String getName() + { + return _name; + } + + public Callback getEnd() + { + return _end; + } + + public Callback getTick() + { + return _tick; + } + + public long getEndTime() + { + return _endTime; + } + + public long getStartTime() + { + return _startTime; + } + + public void tick() + { + _tick.run(_client); + + if (!_allowMovement && _startPos.distance(_client.getPlayer().getLocation()) > 0.3) + { + if (_cancel != null) + { + _cancel.run(_client); + } + + if (_end != null) + { + _end.run(_client); + } + + _client.cleanup(_name); + return; + } + + if (System.currentTimeMillis() >= _endTime) + { + if (_end != null) + { + _end.run(_client); + } + + _client.cleanup(_name); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java index 7145b3dab..c6e583835 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java @@ -152,7 +152,11 @@ public class Donor public void addGold(int amount) { _gold = Math.max(0, _gold + amount); - + } + + public void setGold(int amount) + { + _gold = Math.max(0, amount); } public List getCoinTransactions() 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 d27dab663..92ae49d6c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -13,6 +13,7 @@ import mineplex.core.antihack.AntiHack; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; +import mineplex.core.delayedtask.DelayedTask; import mineplex.core.donation.DonationManager; import mineplex.core.explosion.Explosion; import mineplex.core.friend.FriendManager; @@ -76,6 +77,8 @@ public class Clans extends JavaPlugin ItemStackFactory.Initialize(this, false); + DelayedTask.Initialize(this); + Recharge.Initialize(this); VisibilityManager.Initialize(this); // new ProfileCacheManager(this); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java index 5e82714fe..4a511c5f7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java @@ -507,6 +507,11 @@ public class ClanInfo public int getEnergy() { + if (_energy > getEnergyMax()) + { + _energy = getEnergyMax(); + } + return _energy; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayer.java index 5b3e166ac..b18b93eff 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayer.java @@ -8,7 +8,7 @@ public class ClansPlayer private UUID _uuid; private ClanRole _role; private boolean _online; - + public ClansPlayer(String playerName, UUID uuid, ClanRole role) { _playerName = playerName; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 3fda15789..0265b77d5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -15,9 +15,12 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilInput; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilWorld; +import mineplex.core.delayedtask.DelayedTask; +import mineplex.core.delayedtask.DelayedTaskClient; import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanRole; @@ -27,14 +30,11 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClientClan; import mineplex.game.clans.clans.event.ClanJoinEvent; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; -import mineplex.game.clans.tutorials.Tutorial; -import mineplex.game.clans.tutorials.TutorialManager; import net.minecraft.server.v1_8_R3.EnumDirection; public class ClansCommand extends CommandBase { private ClansManager _manager; - public ClansCommand(ClansManager plugin) { super(plugin, Rank.ALL, "c", "clan", "clans", "factions"); @@ -741,7 +741,7 @@ public class ClansCommand extends CommandBase Plugin.getItemMapManager().setMap(caller); } - public void home(Player caller, String[] args) + public void home(final Player caller, String[] args) { if (args.length > 1) { @@ -752,7 +752,7 @@ public class ClansCommand extends CommandBase } } - ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); + final ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); if (clan == null) { @@ -772,18 +772,6 @@ public class ClansCommand extends CommandBase return; } - if (!Plugin.getClanUtility().isSafe(caller.getLocation())) - { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can only use Clan Home from Spawn.")); - return; - } - - if (!Plugin.getClanUtility().isSpecial(caller.getLocation(), "Spawn")) - { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can only use Clan Home from Spawn.")); - return; - } - Location home = clan.getHome(); if (!(home.getBlock().getType().equals(Material.BED_BLOCK) && home.add(0, 1, 0).getBlock().getType().equals(Material.AIR)) && home.add(0, 2, 0).getBlock().getType().equals(Material.AIR)) @@ -802,14 +790,31 @@ public class ClansCommand extends CommandBase * } */ - // if (!Recharge.Instance.use(caller, "Clans Teleport", "Clans - // Teleport", 300000, true, false, false, false)) return; + if (!Recharge.Instance.use(caller, "Home Teleport", 5 * 60 * 1000, true, false)) + { + return; + } - // Do - Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0)); - - // Inform - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + ".")); + DelayedTask.Instance.doDelay(caller, "Home Teleport", new Callback() { + public void run(DelayedTaskClient player) + { + // Do + Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0)); + + // Inform + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + ".")); + } + }, new Callback() { + public void run(DelayedTaskClient client) + { + UtilTextMiddle.display("", "Teleporting to Clan Home in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Home Teleport")))), 0, 5, 0); + } + }, new Callback() { + public void run(DelayedTaskClient client) + { + UtilPlayer.message(client.getPlayer(), F.main("Clans", "Teleport has been cancelled due to movement.")); + } + }, (Plugin.getClanUtility().getClaim(caller.getLocation()) != null ? 30 : 20) * 1000, false); } public void homeSet(Player caller) @@ -881,7 +886,9 @@ public class ClansCommand extends CommandBase } public void infoClan(Player caller, String search) - {System.out.println(search); + { + System.out.println(search); + if (search == null) { _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a search parameter.")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java index 1267209fb..1b8575083 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java @@ -41,8 +41,8 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor { if (_queue.contains(event.getPlayer().getName()) && !event.getPlayer().isOp()) { - event.setKickMessage("This is not your Clans home server"); - event.setResult(PlayerLoginEvent.Result.KICK_OTHER); +// event.setKickMessage("This is not your Clans home server"); +// event.setResult(PlayerLoginEvent.Result.KICK_OTHER); } _queue.remove(event.getPlayer().getName()); @@ -50,18 +50,18 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor private void kickPlayer(final String playerName, final String homeServer) { - runSyncLater(new Runnable() - { - @Override - public void run() - { - Player player = UtilPlayer.searchExact(playerName); - if (player != null && player.isOnline() && !player.isOp()) - { - player.kickPlayer("This is not your home server. To play clans, connect to " + homeServer); - } - } - }, 20); +// runSyncLater(new Runnable() +// { +// @Override +// public void run() +// { +// Player player = UtilPlayer.searchExact(playerName); +// if (player != null && player.isOnline() && !player.isOp()) +// { +// player.kickPlayer("This is not your home server. To play clans, connect to " + homeServer); +// } +// } +// }, 20); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java index bc6240df7..dd417956c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java @@ -31,7 +31,7 @@ public class ClanWhoPage extends ClanPageBase public ClanWhoPage(ClansManager plugin, ClanShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, ClanInfo lookupClan, boolean showBackButton) { - super(plugin, shop, clientManager, donationManager, lookupClan.getName(), player, 36); + super(plugin, shop, clientManager, donationManager, lookupClan.getName(), player, 45); _lookupClan = lookupClan; _showBackButton = showBackButton; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java index b9e38b20b..c44481841 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java @@ -185,6 +185,14 @@ public class PvpTimer extends MiniClientPlugin @EventHandler public void onSkill(SkillTriggerEvent event) { + if (event.GetTargets() != null + && event.GetTargets().size() == 1 + && event.GetTargets().get(0) instanceof Player + && hasTimer((Player) event.GetTargets().get(0))) + { + event.SetCancelled(true); + } + for (Iterator iterator = event.GetTargets().iterator(); iterator.hasNext();) { Entity entity = iterator.next(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java index d28524af0..256bae574 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java @@ -62,7 +62,7 @@ public class GiantsBroadsword extends LegendaryItem private void buffPlayer(Player player) { - grantPotionEffect(player, PotionEffectType.SLOW, 20, 10); - grantPotionEffect(player, PotionEffectType.REGENERATION, 1, 10); + grantPotionEffect(player, PotionEffectType.SLOW, 40, 10); + grantPotionEffect(player, PotionEffectType.REGENERATION, 40, 10); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java index 78169ea47..459a18701 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java @@ -89,7 +89,6 @@ public abstract class ClansShopPage> extends Sh addShopItem(index, item, (byte) 0, displayName, 1); } - public void addShopItem(int index, ClansShopItem item) { addShopItem(index, item, (byte) 0); From f57304764c1bb37d5936c1475577a858e029c7ac Mon Sep 17 00:00:00 2001 From: William Burns Date: Fri, 18 Dec 2015 15:16:00 +0000 Subject: [PATCH 09/65] Added a hotbar layout editor --- .../mineplex/core/common/util/UtilMath.java | 10 ++ .../game/games/gladiators/Gladiators.java | 17 +- .../games/gladiators/hotbar/HotbarEditor.java | 163 ++++++++++++++++++ .../gladiators/hotbar/HotbarInventory.java | 49 ++++++ .../games/gladiators/hotbar/HotbarLayout.java | 60 +++++++ .../gladiators/hotbar/HotbarPageListener.java | 70 ++++++++ 6 files changed, 364 insertions(+), 5 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarInventory.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java index 3d48c098f..4fac287c2 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java @@ -2,6 +2,7 @@ package mineplex.core.common.util; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; +import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Random; @@ -116,4 +117,13 @@ public class UtilMath { return num < min ? min : (num > max ? max : num); } + + public static List digits(int i) { + List digits = new ArrayList(); + while(i > 0) { + digits.add(i % 10); + i /= 10; + } + return digits; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index a9fcae09a..458e7ea83 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -22,7 +22,6 @@ import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -57,6 +56,8 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.gladiators.events.PlayerChangeArenaEvent; import nautilus.game.arcade.game.games.gladiators.events.RoundStartEvent; +import nautilus.game.arcade.game.games.gladiators.hotbar.HotbarEditor; +import nautilus.game.arcade.game.games.gladiators.hotbar.HotbarLayout; import nautilus.game.arcade.game.games.gladiators.kits.KitGladiator; import nautilus.game.arcade.game.games.gladiators.trackers.BrawlerTracker; import nautilus.game.arcade.game.games.gladiators.trackers.FlawlessTracker; @@ -85,6 +86,8 @@ public class Gladiators extends SoloGame private boolean _firstRound; + private HotbarEditor _hotbarEditor; + public Gladiators(ArcadeManager manager) { super(manager, GameType.Gladiators, @@ -124,6 +127,8 @@ public class Gladiators extends SoloGame _roundState = RoundState.WAITING; _firstRound = true; + + _hotbarEditor = new HotbarEditor(manager.getPlugin(), this); } @EventHandler @@ -739,13 +744,15 @@ public class Gladiators extends SoloGame if (!GetPlayers(true).contains(p)) return; + HotbarLayout layout = _hotbarEditor.getLayout(p); + p.getInventory().clear(); p.getInventory().setArmorContents(null); - p.getInventory().setItem(0, UtilItem.makeUnbreakable(type.getLoadout().getSword())); - p.getInventory().setItem(1, UtilItem.makeUnbreakable(type.getLoadout().getRod())); - p.getInventory().setItem(2, type.getLoadout().getBow()); - p.getInventory().setItem(8, type.getLoadout().getArrows()); + p.getInventory().setItem(layout.getSword() - 1, UtilItem.makeUnbreakable(type.getLoadout().getSword())); + p.getInventory().setItem(layout.getRod() - 1, UtilItem.makeUnbreakable(type.getLoadout().getRod())); + p.getInventory().setItem(layout.getBow() - 1, type.getLoadout().getBow()); + p.getInventory().setItem(layout.getArrows() - 1, type.getLoadout().getArrows()); p.getInventory().setHelmet(type.getLoadout().getHelmet()); p.getInventory().setChestplate(type.getLoadout().getChestplate()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java new file mode 100644 index 000000000..119e4d436 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java @@ -0,0 +1,163 @@ +package nautilus.game.arcade.game.games.gladiators.hotbar; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.collect.Lists; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.gladiators.Gladiators; + +/** + * Created by William (WilliamTiger). + * 18/12/15 + */ +public class HotbarEditor extends MiniPlugin +{ + private Gladiators _host; + private ItemStack _item; + + public HotbarEditor(JavaPlugin plugin, Gladiators gladiators) + { + super("Hotbar Editor", plugin); + + _host = gladiators; + _item = new ItemBuilder(Material.NAME_TAG).setTitle(C.cGold + "Hotbar Editor") + .addLore(C.cGray + "Right click to edit your Gladiators hotbar").build(); + + getPluginManager().registerEvents(new HotbarPageListener(this), getPlugin()); + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + if (_host.GetState() == Game.GameState.Recruit || _host.GetState() == Game.GameState.Live) + { + event.getPlayer().getInventory().setItem(0, _item); + } + } + + @EventHandler + public void onDeath(final PlayerDeathEvent event) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() + { + public void run() + { + if (_host.IsLive()) + { + event.getEntity().getInventory().setItem(0, _item); + } + } + }); + } + + @EventHandler(priority = EventPriority.HIGH) + public void Observer(PlayerCommandPreprocessEvent event) + { + if (event.getMessage().equalsIgnoreCase("/spec")) + { + if (!_host.IsAlive(event.getPlayer()) + && !UtilInv.contains(event.getPlayer(), _item.getType(), (byte) 0, 1)) + { + event.getPlayer().getInventory().setItem(0, _item); + } + } + } + + @EventHandler + public void onJoin(GameStateChangeEvent event) + { + if (event.GetState() == Game.GameState.Recruit) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + player.getInventory().setItem(0, _item); + } + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (event.getAction() != Action.PHYSICAL && event.getAction().name().contains("RIGHT")) + { + ItemStack item = event.getItem(); + + if (item != null && item.isSimilar(_item)) + { + + HotbarInventory.open(event.getPlayer(), this); + } + } + } + + public Gladiators getHost() + { + return _host; + } + + public HotbarLayout getLayout(Player player) + { + int data = _host.Manager.getArcadePlayer(player).get("hotbar"); + data = (data == -1 ? 1239 : data); + + List ints = new ArrayList<>(); + for (int i : UtilMath.digits(data)) + ints.add(i - 1); + ints = Lists.reverse(ints); + + return new HotbarLayout(ints.get(0), ints.get(1), ints.get(2), ints.get(3)); + } + + public void saveLayout(Player player, Inventory inv) + { + List items = Arrays.asList(inv.getContents()); + ItemStack sword = null, rod = null, bow = null, arrows = null; + for (ItemStack i : items) + { + if (i == null || i.getType() == null) + continue; + + if (i.getType().equals(Material.DIAMOND_SWORD)) + sword = i; + else if (i.getType().equals(Material.FISHING_ROD)) + rod = i; + else if (i.getType().equals(Material.BOW)) + bow = i; + else if (i.getType().equals(Material.ARROW)) + arrows = i; + } + + HotbarLayout save = new HotbarLayout( + items.indexOf(sword) - 9, + items.indexOf(rod) - 9, + items.indexOf(bow) - 9, + items.indexOf(arrows) - 9 + ); + + _host.Manager.getArcadePlayer(player).put("hotbar", save.toDataSaveNumber()); + player.sendMessage(F.main("Game", "Saved new hotbar layout!")); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarInventory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarInventory.java new file mode 100644 index 000000000..9ffc569ae --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarInventory.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.gladiators.hotbar; + +import java.util.Arrays; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; + +/** + * Created by William (WilliamTiger). + * 18/12/15 + */ +public class HotbarInventory +{ + public static void open(Player player, HotbarEditor editor) + { + Inventory inv = UtilServer.getServer().createInventory(null, 36, "Hotbar Editor"); + + for (int slot : Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23, 24, 25, 26)) + { + inv.setItem(slot, getGlass(slot)); + } + + HotbarLayout layout = editor.getLayout(player); + + inv.setItem(layout.getSword() + 9, new ItemStack(Material.DIAMOND_SWORD, 1)); + inv.setItem(layout.getRod() + 9, new ItemStack(Material.FISHING_ROD, 1)); + inv.setItem(layout.getBow() + 9, new ItemStack(Material.BOW, 1)); + inv.setItem(layout.getArrows() + 9, new ItemStack(Material.ARROW, 1)); + + inv.setItem(30, new ItemBuilder(Material.EMERALD_BLOCK).setTitle(C.cGreen + C.Bold + "Save").setLore(C.cGray + "Click to save layout.").build()); + inv.setItem(32, new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cRed + C.Bold + "Cancel").setLore(C.cGray + "Click to cancel layout.").build()); + + player.openInventory(inv); + } + + private static ItemStack getGlass(int slot) + { + return new ItemBuilder(Material.STAINED_GLASS_PANE) + .setData((short) 15) + .setTitle((slot < 10 ? C.cAquaB + "⬇ Arrange Your Hotbar ⬇" : C.cAquaB + "⬆ Arrange Your Hotbar ⬆")) + .build(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java new file mode 100644 index 000000000..459f70411 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java @@ -0,0 +1,60 @@ +package nautilus.game.arcade.game.games.gladiators.hotbar; + +/** + * Created by William (WilliamTiger). + * 18/12/15 + */ +public class HotbarLayout +{ + private int sword; + private int rod; + private int bow; + private int arrows; + + public HotbarLayout(int sword, int rod, int bow, int arrows) + { + this.sword = sword; + this.rod = rod; + this.bow = bow; + this.arrows = arrows; + } + + public int getSword() + { + return sword; + } + + public int getRod() + { + return rod; + } + + public int getBow() + { + return bow; + } + + public int getArrows() + { + return arrows; + } + + public int toDataSaveNumber() + { + String str = ""; + str += (getSword() + 1); + str += (getRod() + 1); + str += (getBow() + 1); + str += (getArrows() + 1); + + System.out.println("sword = " + sword); + System.out.println("rod = " + rod); + System.out.println("bow = " + bow); + System.out.println("arrows = " + arrows); + System.out.println("string = " + str); + System.out.println("integer = " + Integer.parseInt(str)); + + + return Integer.parseInt(str); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java new file mode 100644 index 000000000..d778f7643 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java @@ -0,0 +1,70 @@ +package nautilus.game.arcade.game.games.gladiators.hotbar; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; + +/** + * Created by William (WilliamTiger). + * 18/12/15 + */ +public class HotbarPageListener implements Listener +{ + private HotbarEditor _editor; + + public HotbarPageListener(HotbarEditor editor) + { + _editor = editor; + } + + @EventHandler + public void onClick(InventoryClickEvent e) + { + if (!e.getInventory().getName().equals("Hotbar Editor")) + return; + + if (e.getCurrentItem() == null) + return; + + if (e.getClick().isShiftClick()) + { + e.setCancelled(true); + return; + } + + if (e.getCurrentItem().getType().equals(Material.REDSTONE_BLOCK)) + { + e.setCancelled(true); + e.getWhoClicked().closeInventory(); + return; + } + + if (e.getCurrentItem().getType().equals(Material.EMERALD_BLOCK)) + { + e.setCancelled(true); + e.getWhoClicked().closeInventory(); + _editor.saveLayout(((Player)e.getWhoClicked()), e.getClickedInventory()); + return; + } + + if (e.getCurrentItem().getType().equals(Material.STAINED_GLASS_PANE)) + { + e.setCancelled(true); + return; + } + + if (e.getAction().equals(InventoryAction.PLACE_ALL) + || e.getAction().equals(InventoryAction.PLACE_ONE) + || e.getAction().equals(InventoryAction.PLACE_SOME)) + { + if (!(e.getSlot() > 8 && e.getSlot() < 18)) + { + e.setCancelled(true); + return; + } + } + } +} From 1726aa253063ba2bd863f5e0630041f5cb1ccfdc Mon Sep 17 00:00:00 2001 From: Morten Date: Mon, 21 Dec 2015 12:58:19 +0100 Subject: [PATCH 10/65] Added a feature to unban clients across the network But there still a bug when you type a username of a none registered member. Will fix ASAP - likely after Mineware --- .../src/mineplex/core/stats/StatsManager.java | 90 ++++++++++++++++++- .../mineplex/core/stats/StatsRepository.java | 27 +++++- .../stats/command/MasterBuilderUnban.java | 58 ++++++++++++ 3 files changed, 168 insertions(+), 7 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index 1aa921c2d..ae88b6cb1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -15,6 +15,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilServer; import mineplex.core.stats.command.GiveStatCommand; +import mineplex.core.stats.command.MasterBuilderUnban; import mineplex.core.stats.command.TimeCommand; import mineplex.core.stats.event.StatChangeEvent; @@ -26,6 +27,8 @@ public class StatsManager extends MiniDbClientPlugin private NautHashMap _stats = new NautHashMap(); private NautHashMap> _statUploadQueue = new NautHashMap>(); + private NautHashMap> _statUploadQueueOverRidable = new NautHashMap>(); + private Runnable _saveRunnable; public StatsManager(JavaPlugin plugin, CoreClientManager clientManager) @@ -41,6 +44,7 @@ public class StatsManager extends MiniDbClientPlugin public void run() { saveStats(); + overRidableSaveStats(); } }; @@ -81,6 +85,11 @@ public class StatsManager extends MiniDbClientPlugin } public void incrementStat(final Player player, final String statName, final long value) + { + incrementStat(player, statName, value, false); + } + + public void incrementStat(final Player player, final String statName, final long value, boolean overRide) { if (value <= 0) return; @@ -96,11 +105,80 @@ public class StatsManager extends MiniDbClientPlugin @Override public void run() { - addToQueue(statName, player, value); + if(overRide) + { + addToOverRidableQueue(statName, player, value); + } + else + { + addToQueue(statName, player, value); + } } }); } + private void addToOverRidableQueue(String statName, Player player, long value) + { + synchronized (_statSync) + { + if (!_statUploadQueueOverRidable.containsKey(player)) + _statUploadQueueOverRidable.put(player, new NautHashMap()); + + if (!_statUploadQueueOverRidable.get(player).containsKey(statName)) + _statUploadQueueOverRidable.get(player).put(statName, 0L); + + _statUploadQueueOverRidable.get(player).put(statName, _statUploadQueueOverRidable.get(player).get(statName) + value); + } + } + + protected void overRidableSaveStats() + { + if (_statUploadQueueOverRidable.isEmpty()) + return; + + try + { + NautHashMap> uploadQueue = new NautHashMap>(); + + synchronized (_statSync) + { + for (Iterator statIterator = _statUploadQueueOverRidable.keySet().iterator(); statIterator.hasNext();) + { + Player player = statIterator.next(); + + if (player.isOnline()) + continue; + + try + { + int uploadKey = PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(); + + uploadQueue.put(uploadKey, new NautHashMap()); + + for (String statName : _statUploadQueueOverRidable.get(player).keySet()) + { + int statId = _stats.get(statName); + uploadQueue.get(uploadKey).put(statId, _statUploadQueueOverRidable.get(player).get(statName)); + System.out.println(player.getName() + " saving stat : " + statName + " overriding " + _statUploadQueueOverRidable.get(player).get(statName)); + } + + statIterator.remove(); + } + catch (Exception e) + { + //System.out.println("[StatsManager] AccountId was not set for " + player.getName()); + } + } + } + + _repository.saveStats(uploadQueue, true); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + private void addToQueue(String statName, Player player, long value) { synchronized (_statSync) @@ -162,8 +240,13 @@ public class StatsManager extends MiniDbClientPlugin exception.printStackTrace(); } } - + public boolean incrementStat(final int accountId, final String statName, final long value) + { + return incrementStat(accountId, statName, value, false); + } + + public boolean incrementStat(final int accountId, final String statName, final long value, boolean overRide) { // This will register a new stat if we don't have one, otherwise it will just run the callback registerNewStat(statName, new Runnable() @@ -175,7 +258,7 @@ public class StatsManager extends MiniDbClientPlugin uploadQueue.put(accountId, new NautHashMap()); uploadQueue.get(accountId).put(_stats.get(statName), value); - _repository.saveStats(uploadQueue); + _repository.saveStats(uploadQueue, overRide); } }); @@ -237,6 +320,7 @@ public class StatsManager extends MiniDbClientPlugin { addCommand(new TimeCommand(this)); addCommand(new GiveStatCommand(this)); + addCommand(new MasterBuilderUnban(this)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java index 12deca990..726f75a99 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -29,6 +29,8 @@ public class StatsRepository extends RepositoryBase { private static String RETRIEVE_STATS = "SELECT id, name FROM stats;"; private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);"; + private static String UPDATE_ACCOUNT_STAT_VALUE= "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;"; + public StatsRepository(JavaPlugin plugin) { @@ -68,9 +70,15 @@ public class StatsRepository extends RepositoryBase { executeUpdate(INSERT_STAT, new ColumnVarChar("name", 100, name)); } + + public void saveStats(NautHashMap> uploadQueue) + { + saveStats(uploadQueue, false); + } + @SuppressWarnings("rawtypes") - public void saveStats(NautHashMap> uploadQueue) + public void saveStats(NautHashMap> uploadQueue, boolean overRideStat) { try { @@ -83,13 +91,24 @@ public class StatsRepository extends RepositoryBase { for (Integer statId : uploadQueue.get(accountId).keySet()) { - Update update = context + if(overRideStat) + { + Update update = context + .update(Tables.accountStat) + .set(Tables.accountStat.value, ULong.valueOf(uploadQueue.get(accountId).get(statId))) + .where(Tables.accountStat.accountId.eq(accountId)) + .and(Tables.accountStat.statId.eq(statId)); + updates.add(update); + } + else + { + Update update = context .update(Tables.accountStat) .set(Tables.accountStat.value, Tables.accountStat.value.plus(uploadQueue.get(accountId).get(statId))) .where(Tables.accountStat.accountId.eq(accountId)) .and(Tables.accountStat.statId.eq(statId)); - - updates.add(update); + updates.add(update); + } Insert insert = context .insertInto(Tables.accountStat) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java new file mode 100644 index 000000000..9ec2656c0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java @@ -0,0 +1,58 @@ +package mineplex.core.stats.command; + +import mineplex.core.account.CoreClient; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.stats.StatsManager; + +import org.bukkit.entity.Player; + +public class MasterBuilderUnban extends CommandBase +{ + + public MasterBuilderUnban(StatsManager plugin) + { + super(plugin, Rank.ADMIN, "buildunban"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if(args.length != 1) + { + UtilPlayer.message(caller, F.main("MasterBuilder Unban", "/buildunban ")); + return; + } + + try + { + Plugin.getClientManager().loadClientByName(args[0], new Runnable() + { + + @Override + public void run() + { + CoreClient theClient = Plugin.getClientManager().Get(args[0]); + + if(theClient != null) + { + Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true); + caller.sendMessage(F.main("MasterBuilder Unban", "The user " + args[0] + " has been unbanned for Master Builders")); + } + else + { + caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + args[0] + "'s account!")); + return; + } + } + }); + } + catch(Exception e) + { + caller.sendMessage(F.main("MasterBuilder Unban", "Exception caught! Please contact Morten and explain what happened.")); + } + } + +} From 9336eb19fa5fcf450c1831300d816a0ee57e60bf Mon Sep 17 00:00:00 2001 From: Morten Date: Tue, 22 Dec 2015 21:31:57 +0100 Subject: [PATCH 11/65] Finished up the Unban feature... --- .../stats/command/MasterBuilderUnban.java | 70 +++++++++++++++---- .../password/PasswordRepository.java | 2 +- 2 files changed, 59 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java index 9ec2656c0..a8075985a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java @@ -1,8 +1,12 @@ package mineplex.core.stats.command; +import java.util.Iterator; +import java.util.List; + import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.stats.StatsManager; @@ -28,29 +32,71 @@ public class MasterBuilderUnban extends CommandBase try { - Plugin.getClientManager().loadClientByName(args[0], new Runnable() + Plugin.getClientManager().getRepository().matchPlayerName(new Callback>() { - + @Override - public void run() + public void run(List matches) { - CoreClient theClient = Plugin.getClientManager().Get(args[0]); - - if(theClient != null) + boolean matchedExact = false; + + for (String match : matches) { - Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true); - caller.sendMessage(F.main("MasterBuilder Unban", "The user " + args[0] + " has been unbanned for Master Builders")); + if (match.equalsIgnoreCase(args[0])) + { + matchedExact = true; + } } - else + + if (matchedExact) { - caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + args[0] + "'s account!")); - return; + for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext();) + { + if (!matchIterator.next().equalsIgnoreCase(args[0])) + { + matchIterator.remove(); + } + } } + UtilPlayer.searchOffline(matches, new Callback() + { + @Override + public void run(String target) + { + if(target == null) + { + caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + args[0] + "'s account!")); + return; + } + Plugin.getClientManager().loadClientByName(target, new Runnable() + { + @Override + public void run() + { + CoreClient theClient = Plugin.getClientManager().Get(target); + + if(theClient != null) + { + Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true); // True = Resets the stat + caller.sendMessage(F.main("MasterBuilder Unban", "The user " + target + " has been unbanned from Master Builders")); + } + else + { + caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + target + "'s client!")); + return; + } + } + }); + } + }, caller, args[0], false); } - }); + + }, args[0]); + } catch(Exception e) { + e.printStackTrace(); caller.sendMessage(F.main("MasterBuilder Unban", "Exception caught! Please contact Morten and explain what happened.")); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java index f0cf867d4..33b63e8a5 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java @@ -24,7 +24,7 @@ public class PasswordRepository extends RepositoryBase public PasswordRepository(JavaPlugin plugin, String serverName) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _serverName = serverName; } From 8c399f03da46a923ff0819b62656452628163374 Mon Sep 17 00:00:00 2001 From: Morten Date: Tue, 22 Dec 2015 21:36:19 +0100 Subject: [PATCH 12/65] Removed a weird query :/ Status: Finished --- .../src/mineplex/core/stats/StatsRepository.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java index 726f75a99..e8ac03479 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -6,16 +6,14 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.common.util.NautHashMap; import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; import mineplex.core.database.column.ColumnVarChar; import mineplex.database.Tables; -import net.md_5.bungee.chat.TranslatableComponentSerializer; +import org.bukkit.plugin.java.JavaPlugin; import org.jooq.DSLContext; import org.jooq.Insert; import org.jooq.Record2; @@ -29,7 +27,6 @@ public class StatsRepository extends RepositoryBase { private static String RETRIEVE_STATS = "SELECT id, name FROM stats;"; private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);"; - private static String UPDATE_ACCOUNT_STAT_VALUE= "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;"; public StatsRepository(JavaPlugin plugin) From f83016e0074ce810f727276a0feb127ecd69098f Mon Sep 17 00:00:00 2001 From: Morten Date: Wed, 23 Dec 2015 00:39:16 +0100 Subject: [PATCH 13/65] Also really quickly fixed the Invisibility in lobby bug (hopefully) --- .../src/mineplex/hub/modules/HubVisibilityManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index 1733a2fcc..b7167cf07 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -70,13 +70,14 @@ public class HubVisibilityManager extends MiniPlugin for (Player other : UtilServer.getPlayers()) { + boolean localHideMe = hideMe; if (player.equals(other)) continue; if(Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR)) - hideMe = false; + localHideMe = false; - if (hideMe || + if (localHideMe || !Manager.getPreferences().Get(other).ShowPlayers || Manager.GetTutorial().InTutorial(other)) { From 08b5e7b4db1668ed570070a0c008576445a2bfc5 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 23 Dec 2015 09:21:43 +0000 Subject: [PATCH 14/65] Working loadouts. --- .../game/arcade/game/games/gladiators/Gladiators.java | 11 +++++++---- .../game/games/gladiators/hotbar/HotbarEditor.java | 6 ++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 458e7ea83..66701b54a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -186,6 +186,9 @@ public class Gladiators extends SoloGame if (e.getType() != UpdateType.FASTEST) return; + if (!IsLive()) + return; + if (GetState() != GameState.Prepare) return; @@ -749,10 +752,10 @@ public class Gladiators extends SoloGame p.getInventory().clear(); p.getInventory().setArmorContents(null); - p.getInventory().setItem(layout.getSword() - 1, UtilItem.makeUnbreakable(type.getLoadout().getSword())); - p.getInventory().setItem(layout.getRod() - 1, UtilItem.makeUnbreakable(type.getLoadout().getRod())); - p.getInventory().setItem(layout.getBow() - 1, type.getLoadout().getBow()); - p.getInventory().setItem(layout.getArrows() - 1, type.getLoadout().getArrows()); + p.getInventory().setItem(layout.getSword(), UtilItem.makeUnbreakable(type.getLoadout().getSword())); + p.getInventory().setItem(layout.getRod(), UtilItem.makeUnbreakable(type.getLoadout().getRod())); + p.getInventory().setItem(layout.getBow(), type.getLoadout().getBow()); + p.getInventory().setItem(layout.getArrows(), type.getLoadout().getArrows()); p.getInventory().setHelmet(type.getLoadout().getHelmet()); p.getInventory().setChestplate(type.getLoadout().getChestplate()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java index 119e4d436..518b86d96 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java @@ -52,6 +52,9 @@ public class HotbarEditor extends MiniPlugin @EventHandler public void onJoin(PlayerJoinEvent event) { + if (_host.Manager.GetGame() != _host) + return; + if (_host.GetState() == Game.GameState.Recruit || _host.GetState() == Game.GameState.Live) { event.getPlayer().getInventory().setItem(0, _item); @@ -89,6 +92,9 @@ public class HotbarEditor extends MiniPlugin @EventHandler public void onJoin(GameStateChangeEvent event) { + if (event.GetGame() != _host) + return; + if (event.GetState() == Game.GameState.Recruit) { for (Player player : Bukkit.getOnlinePlayers()) From ff24ebc9f43ec98f0925b2d670579c4b245f2300 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 23 Dec 2015 18:22:20 +0000 Subject: [PATCH 15/65] lots of changes that i can't remember at this point --- .../src/mineplex/core/common/util/F.java | 4 +- .../mineplex/core/common/util/UtilTime.java | 6 + .../core/donation/DonationManager.java | 31 ++++ .../core/donation/command/SetGoldCommand.java | 75 +++++++++ .../repository/DonationRepository.java | 13 ++ Plugins/Mineplex.Game.Clans/.classpath | 2 +- .../.settings/org.eclipse.jdt.core.prefs | 6 +- .../src/mineplex/game/clans/Clans.java | 5 +- .../game/clans/clans/ban/ClansBan.java | 81 ++++++++++ .../game/clans/clans/ban/ClansBanClient.java | 71 +++++++++ .../game/clans/clans/ban/ClansBanManager.java | 136 ++++++++++++++++ .../clans/clans/ban/ClansBanRepository.java | 145 ++++++++++++++++++ .../clans/ban/commands/ClansBanCommand.java | 94 ++++++++++++ .../game/clans/clans/ban/ui/ClansBanPage.java | 23 +++ .../game/clans/clans/ban/ui/ClansBanShop.java | 23 +++ .../game/clans/clans/pvptimer/PvpTimer.java | 8 +- 16 files changed, 714 insertions(+), 9 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/donation/command/SetGoldCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java index db1e528f3..76d296028 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java @@ -42,9 +42,9 @@ public class F return C.sysHead + head + "> " + C.sysBody + body; } - public static String elem(String elem) + public static String elem(Object elem) { - return C.mElem + elem + ChatColor.RESET + C.mBody; + return C.mElem + elem.toString() + ChatColor.RESET + C.mBody; } public static String name(String elem) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java index 908272bc6..b4af6380d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java @@ -28,6 +28,12 @@ public class UtilTime SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_DAY); return sdf.format(cal.getTime()); } + + public static String date(long date) + { + SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_DAY); + return sdf.format(date); + } public static String getDayOfMonthSuffix(final int n) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 54209e7db..3e20ac17f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -19,6 +19,7 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.donation.command.CoinCommand; import mineplex.core.donation.command.GemCommand; import mineplex.core.donation.command.GoldCommand; +import mineplex.core.donation.command.SetGoldCommand; import mineplex.core.donation.repository.DonationRepository; import mineplex.core.donation.repository.token.DonorTokenWrapper; import mineplex.core.server.util.TransactionResponse; @@ -48,6 +49,7 @@ public class DonationManager extends MiniDbClientPlugin addCommand(new GemCommand(this)); addCommand(new CoinCommand(this)); addCommand(new GoldCommand(this)); + addCommand(new SetGoldCommand(this)); } @EventHandler @@ -335,6 +337,35 @@ public class DonationManager extends MiniDbClientPlugin }, caller, name, accountId, amount); } + public void setGold(final Callback callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal) + { + _repository.setGold(new Callback() + { + public void run(Boolean success) + { + if (success) + { + if (updateTotal) + { + Donor donor = Get(name); + + if (donor != null) + { + donor.addGold(amount); + } + } + } + else + { + System.out.println("SET GOLD FAILED..."); + } + + if (callback != null) + callback.run(success); + } + }, caller, name, accountId, amount); + } + public void RewardGoldLater(final String caller, final Player player, final int amount) { if (!_goldQueue.containsKey(player)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/SetGoldCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/SetGoldCommand.java new file mode 100644 index 000000000..d477f5b8f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/SetGoldCommand.java @@ -0,0 +1,75 @@ +package mineplex.core.donation.command; + +import mineplex.core.account.CoreClient; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; + +import org.bukkit.entity.Player; + +public class SetGoldCommand extends CommandBase +{ + public SetGoldCommand(DonationManager plugin) + { + super(plugin, Rank.ADMIN, "setgold"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args == null || args.length < 2) + { + UtilPlayer.message(caller, F.main("Clans", "Error! Usage: " + F.elem("/setgold "))); + return; + } + + final String targetName = args[0]; + final String goldString = args[1]; + Player target = UtilPlayer.searchExact(targetName); + + try + { + if (target == null) + { + Plugin.getClientManager().loadClientByName(targetName, new Runnable() + { + public void run() + { + CoreClient client = Plugin.getClientManager().Get(targetName); + + if (client != null) + { + setGold(caller, null, targetName, client.getAccountId(), Integer.parseInt(goldString)); + } + else + { + UtilPlayer.message(caller, F.main("Gold", "Could not find player " + F.name(targetName))); + } + } + }); + } + else + { + setGold(caller, target, target.getName(), Plugin.getClientManager().Get(target).getAccountId(), Integer.parseInt(goldString)); + } + } + catch (Exception e) + { + UtilPlayer.message(target, F.main("Clans", "You must provide a valid number in the gold parameter.")); + } + } + + private void setGold(final Player caller, final Player target, final String targetName, final int accountId, final int gold) + { + Plugin.setGold(new Callback() + { + public void run(Boolean completed) + { + UtilPlayer.message(caller, F.main("Gold", "You set " + F.name(targetName) + "'s Gold to " + F.elem(gold) + ".")); + } + }, caller.getName(), targetName, accountId, gold, true); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java index 910f03c63..b868b3408 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java @@ -31,6 +31,7 @@ public class DonationRepository extends RepositoryBase private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accountId, reason, coins) VALUES(?, ?, ?);"; private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE id = ?;"; private static String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE id = ?;"; + private static String SET_ACCOUNT_GOLD = "UPDATE accounts SET gold = ? WHERE id = ?;"; private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE id = ? AND gems IS NULL AND coins IS NULL;"; private String _webAddress; @@ -198,6 +199,18 @@ public class DonationRepository extends RepositoryBase } }), "Error updating player gold amount in DonationRepository : "); } + + public void setGold(final Callback callback, final String giver, final String name, final int accountId, final int gold) + { + handleDatabaseCall(new DatabaseRunnable(new Runnable() + { + public void run() + { + boolean success = executeUpdate(SET_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId)) > 0; + callback.run(success); + } + }), "Error updating player gold amount in DonationRepository : "); + } @Override protected void initialize() diff --git a/Plugins/Mineplex.Game.Clans/.classpath b/Plugins/Mineplex.Game.Clans/.classpath index 4a7e01944..4caf6a583 100644 --- a/Plugins/Mineplex.Game.Clans/.classpath +++ b/Plugins/Mineplex.Game.Clans/.classpath @@ -1,7 +1,7 @@ - + diff --git a/Plugins/Mineplex.Game.Clans/.settings/org.eclipse.jdt.core.prefs b/Plugins/Mineplex.Game.Clans/.settings/org.eclipse.jdt.core.prefs index 7341ab168..3a2153707 100644 --- a/Plugins/Mineplex.Game.Clans/.settings/org.eclipse.jdt.core.prefs +++ b/Plugins/Mineplex.Game.Clans/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,11 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 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 92ae49d6c..097227b2e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -39,6 +39,7 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.visibility.VisibilityManager; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.items.GearManager; import mineplex.game.clans.shop.building.BuildingShop; import mineplex.game.clans.shop.farming.FarmingShop; @@ -98,7 +99,9 @@ public class Clans extends JavaPlugin Teleport teleport = new Teleport(this, _clientManager); Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - + + // new ClansBanManager(this, webServerAddress, _clientManager, _donationManager); + Punish punish = new Punish(this, webServerAddress, _clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); AntiHack.Instance.setKick(false); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java new file mode 100644 index 000000000..e3295123a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java @@ -0,0 +1,81 @@ +package mineplex.game.clans.clans.ban; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTime; + +public class ClansBan +{ + private int _id; + private int _accountId; + private String _reason; + private long _banTime; + private long _unbanTime; + private boolean _permanent; + + public ClansBan(int id, int accountId, String reason, long banTime, long unbanTime, boolean permanent) + { + _id = id; + _accountId = accountId; + _reason = reason; + _banTime = banTime; + _unbanTime = unbanTime; + _permanent = permanent; + } + + public int getId() + { + return _id; + } + + public int getAccountId() + { + return _accountId; + } + + public String getReason() + { + return _reason; + } + + public long getBanTime() + { + return _banTime; + } + + public long getLength() + { + return _unbanTime - _banTime; + } + + public long getTimeLeft() + { + return Math.max(0, _unbanTime - System.currentTimeMillis()); + } + + public long getUnbanTime() + { + return _unbanTime; + } + + public boolean isPermanent() + { + return _permanent; + } + + public String getBanTimeFormatted(boolean wording) + { + long time = getTimeLeft(); + + return time == -1 ? F.time("permanently") : (wording ? "for " : "") + F.time(UtilTime.MakeStr(time)); + } + + public boolean isRemoved() + { + return _unbanTime == -1; + } + + public boolean isActive() + { + return (isPermanent() || getTimeLeft() > 0) && !isRemoved(); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java new file mode 100644 index 000000000..44bfd9b9f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java @@ -0,0 +1,71 @@ +package mineplex.game.clans.clans.ban; + +import java.util.List; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTime; + +public class ClansBanClient +{ + public int AccountId; + public List Bans; + + public ClansBanClient(int accountId, List bans) + { + AccountId = accountId; + Bans = bans; + } + + public boolean isBanned() + { + for (ClansBan ban : Bans) + { + if (ban.isActive()) + { + return true; + } + } + + return false; + } + + public long getBanTime() + { + long time = 0; + + for (ClansBan ban : Bans) + { + if (ban.isPermanent()) + { + return -1; + } + + time += ban.getTimeLeft(); + } + + return time; + } + + public String getBanTimeFormatted() + { + long time = getBanTime(); + + return time == -1 ? F.time("permanently") : "for " + F.time(UtilTime.MakeStr(time)); + } + + public String toString() + { + StringBuilder str = new StringBuilder(); + + str.append("{ClansBanClient:" + AccountId + "} [\n"); + + for (ClansBan ban : Bans) + { + str.append("(\nid: " + ban.getId() + ",\nbanTime: " + ban.getBanTime() + ",\nunbanTime: " + ban.getUnbanTime() + ",\nbanTimeLeft:" + ban.getTimeLeft() + ",\nReason:\"" + ban.getReason() + "\"\n)"); + } + + str.append("]"); + + return str.toString(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java new file mode 100644 index 000000000..51214872e --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java @@ -0,0 +1,136 @@ +package mineplex.game.clans.clans.ban; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.donation.DonationManager; +import mineplex.game.clans.clans.ban.commands.ClansBanCommand; +import mineplex.game.clans.clans.ban.ui.ClansBanShop; + +public class ClansBanManager extends MiniPlugin +{ + private CoreClientManager _clientManager; + private ClansBanRepository _repository; + private Map _clients; + private Map _cache; + private ClansBanShop _shop; + + public ClansBanManager(JavaPlugin plugin, String webServerAddress, CoreClientManager clientManager, DonationManager donationManager) + { + super("Blacklist", plugin); + + _clientManager = clientManager; + + _repository = new ClansBanRepository(plugin, this, webServerAddress); + + _clients = new HashMap<>(); + _cache = new HashMap<>(); + + _shop = new ClansBanShop(this, clientManager, donationManager); + } + + @Override + public void addCommands() + { + addCommand(new ClansBanCommand(this)); + } + + public void ban(ClansBanClient client, String name, long time, String reason) + { + _repository.ban(client.AccountId, time, reason, time == -1); + + LoadClient(name, null); + } + + public CoreClientManager getClientManager() + { + return _clientManager; + } + + public ClansBanRepository GetRepository() + { + return _repository; + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) + { + LoadClient(event.getPlayer().getName(), null); + ClansBanClient client = _clients.get(event.getPlayer().getName()); + + if (client.isBanned()) + { + event.setJoinMessage(null); + event.getPlayer().kickPlayer(C.cRed + "You have been banned from Clans " + client.getBanTimeFormatted() + "."); + } + } + + @EventHandler + public void onPlayerKicked(PlayerKickEvent event) + { + ClansBanClient client = _clients.get(event.getPlayer().getName()); + + if (client.isBanned()) + { + event.setLeaveMessage(null); + } + } + + public void LoadClient(final String name, Callback callback) + { + GetRepository().loadBans(name, client -> { + _clients.put(name, client); + if (callback != null) callback.run(client); + }); + } + + public ClansBanClient GetClient(String name) + { + synchronized (this) + { + return _clients.get(name.toLowerCase()); + } + } + + public ClansBanShop getShop() + { + return _shop; + } + + public void cache(Player player, String playerName) + { + _cache.put(player.getName(), playerName); + } + + public String getCachedName(Player player) + { + return _cache.get(player.getName()); + } + + public void clearCachedName(String name) + { + _cache.remove(name); + } + + public void unban(ClansBanClient target, ClansBan ban, String name) + { + if (target.AccountId != ban.getAccountId()) + { + return; + } + + _repository.removeBan(ban); + + LoadClient(name, null); + } +} 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 new file mode 100644 index 000000000..6b1faefd6 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java @@ -0,0 +1,145 @@ +package mineplex.game.clans.clans.ban; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.gson.reflect.TypeToken; + +import mineplex.core.common.util.Callback; +import mineplex.core.database.DBPool; +import mineplex.core.database.RepositoryBase; +import mineplex.core.database.ResultSetCallable; +import mineplex.core.database.column.ColumnBoolean; +import mineplex.core.database.column.ColumnInt; +import mineplex.core.database.column.ColumnTimestamp; +import mineplex.core.database.column.ColumnVarChar; +import mineplex.core.server.remotecall.JsonWebCall; + +public class ClansBanRepository extends RepositoryBase +{ + private ClansBanManager _manager; + + private static final String GET_LONGEST_BAN = "SELECT * FROM clanBans WHERE (NOW() < unbanTime OR permanent=1) AND accountId = ? ORDER BY permanent DESC, unbanTime DESC LIMIT 1;"; + private static final String BAN_PLAYER = "INSERT INTO clanBans (accountId, reason, banTime, unbanTime, permanent) VALUES (?, ?, ?, ?, ?);"; + private static final String REMOVE_BAN = "UPDATE clanBans SET unbanTime = -1 WHERE id = ?;"; + private static final String GET_ALL_BANS = "SELECT * FROM clanBans WHERE accountId = ?;"; + + private String _webAddress; + + public ClansBanRepository(JavaPlugin plugin, ClansBanManager manager, String webServerAddress) + { + super(plugin, DBPool.ACCOUNT); + + _manager = manager; + } + + public void ban(int accountId, long time, String reason, boolean permanent) + { + executeInsert(BAN_PLAYER, null, + new ColumnInt("accountId", accountId), + new ColumnVarChar("reason", 128, reason), + new ColumnTimestamp("banTime", new Timestamp(System.currentTimeMillis())), + new ColumnTimestamp("unbanTime", new Timestamp(System.currentTimeMillis() + time)), + new ColumnBoolean("permanent", permanent) + ); + } + + public void loadBans(final String name, final Callback callback) + { + _manager.getClientManager().loadClientByName(name, new Runnable() { + public void run() + { + executeQuery(GET_ALL_BANS, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + final List list = new ArrayList(); + + while (resultSet.next()) + { + int id = resultSet.getInt(1); + int accountId = resultSet.getInt(2); + String reason = resultSet.getString(3); + long banTime = resultSet.getLong(4); + long unbanTime = resultSet.getLong(5); + boolean permanent = resultSet.getBoolean(6); + + list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent)); + } + + callback.run(new ClansBanClient(_manager.getClientManager().Get(name).getAccountId(), list)); + } + }, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId())); + } + }); + } + + public void getLongestBan(final String name, final Callback callback) + { + if (callback == null) + { + return; + } + + _manager.getClientManager().loadClientByName(name, new Runnable(){ + public void run() + { + executeQuery(GET_LONGEST_BAN, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + while (resultSet.next()) + { + int id = resultSet.getInt(1); + int accountId = resultSet.getInt(2); + String reason = resultSet.getString(3); + Timestamp banTime = resultSet.getTimestamp(4); + Timestamp unbanTime = resultSet.getTimestamp(5); + boolean permanent = resultSet.getBoolean(6); + + callback.run(new ClansBan(id, accountId, reason, banTime.getTime(), unbanTime.getTime(), permanent)); + } + } + }, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId())); + } + }); + } + + public void matchPlayerName(final Callback> callback, final String userName) + { + Thread asyncThread = new Thread(new Runnable() + { + public void run() + { + List tokenList = new JsonWebCall(_webAddress + "PlayerAccount/GetMatches").Execute(new TypeToken>(){}.getType(), userName); + callback.run(tokenList); + } + }); + + asyncThread.start(); + } + + + @Override + protected void initialize() + { + } + + @Override + protected void update() + { + } + + public void removeBan(ClansBan ban) + { + executeUpdate(REMOVE_BAN, new ColumnInt("id", ban.getId())); + } + +} 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 new file mode 100644 index 000000000..94e53ba4d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java @@ -0,0 +1,94 @@ +package mineplex.game.clans.clans.ban.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ban.ClansBanManager; + +public class ClansBanCommand extends CommandBase +{ + public ClansBanCommand(ClansBanManager plugin) + { + super(plugin, Rank.ADMIN, "cbans", "cb"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args == null || args.length < 1) + { + UtilPlayer.message(caller, C.cGold + "/cb - Bans the specified player for the specified amount of time"); + UtilPlayer.message(caller, C.cGold + "/cb - Displays the \"Clans Punish\" UI, and will display all of the player's past bans (including current ones)"); + } + else if (args.length == 1) + { + final String playerName = args[0]; + + Plugin.LoadClient(playerName, client -> { + Plugin.cache(caller, playerName); + Plugin.getShop().attemptShopOpen(caller); + }); + } + else if (args.length > 2) + { + final String playerName = args[0]; + final float time; + final boolean permanent = args[1].startsWith("p"); + + if (!permanent) + { + try + { + time = Float.parseFloat(args[1]); + } + catch(NumberFormatException e) + { + UtilPlayer.message(caller, F.main("Clans", "You must provide a valid floating point number for the time (in days). e.g. " + F.elem("1.5") + ", " + F.elem("3.2") + ".")); + return; + } + } + else + { + //Required for compilation reasons + time = 0; + } + + String reason = args[2]; + + for (int i = 3; i < args.length; i++) + { + reason += " " + args[i]; + } + + final String finalReason = reason; + + //Match exact online first + Player target = UtilPlayer.searchExact(playerName); + if (target != null) + { + Plugin.LoadClient(playerName, client -> { + Plugin.ban(client, target.getName(), permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason); + UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + F.time(client.getBanTimeFormatted()) + ".")); + + Plugin.runSync(() -> target.kickPlayer(C.cRed + "You have been banned from Clans " + client.getBanTimeFormatted() + ".")); + }); + + return; + } + + Plugin.LoadClient(playerName, client -> { + Plugin.ban(client, playerName, permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason); + UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + client.getBanTimeFormatted() + ".")); + }); + } + else + { + UtilPlayer.message(caller, C.cGold + "/cp - Bans the specified player for the specified amount of time"); + UtilPlayer.message(caller, C.cGold + "/cp - Displays the \"Clans Punish\" UI, and will display all of the player's past bans (including current ones)"); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java new file mode 100644 index 000000000..a3d7d3e6d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java @@ -0,0 +1,23 @@ +package mineplex.game.clans.clans.ban.ui; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ban.ClansBanManager; + +public class ClansBanPage extends ShopPageBase +{ + public ClansBanPage(final ClansBanManager banManager, final ClansBanShop shop, final CoreClientManager clientManager, final DonationManager donationManager, final String name, final Player player) + { + super(banManager, shop, clientManager, donationManager, name, player); + + buildPage(); + } + + protected void buildPage() + { + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java new file mode 100644 index 000000000..7b023c9c7 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java @@ -0,0 +1,23 @@ +package mineplex.game.clans.clans.ban.ui; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ban.ClansBanManager; + +public class ClansBanShop extends ShopBase +{ + public ClansBanShop(final ClansBanManager plugin, final CoreClientManager clientManager, final DonationManager donationManager) + { + super(plugin, clientManager, donationManager, "Customize New Gear"); + } + + @Override + protected ShopPageBase> buildPagesFor(final Player player) + { + return new ClansBanPage(getPlugin(), this, getClientManager(), getDonationManager(), "Customize New Gear", player); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java index c44481841..6e9150c54 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java @@ -185,8 +185,12 @@ public class PvpTimer extends MiniClientPlugin @EventHandler public void onSkill(SkillTriggerEvent event) { - if (event.GetTargets() != null - && event.GetTargets().size() == 1 + if (event.GetTargets() == null) + { + return; + } + + if (event.GetTargets().size() == 1 && event.GetTargets().get(0) instanceof Player && hasTimer((Player) event.GetTargets().get(0))) { From aa50c4762f83e2cf6e86f014ee2aca037efd02f1 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 23 Dec 2015 18:55:44 +0000 Subject: [PATCH 16/65] fixes (?) --- .../src/mineplex/game/clans/clans/ban/ClansBanRepository.java | 2 +- .../nautilus/game/arcade/game/games/christmas/Christmas.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 6b1faefd6..3be04b14d 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 @@ -33,7 +33,7 @@ public class ClansBanRepository extends RepositoryBase public ClansBanRepository(JavaPlugin plugin, ClansBanManager manager, String webServerAddress) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _manager = manager; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java index 23b3ec1b1..03ad8960c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java @@ -465,7 +465,7 @@ public class Christmas extends SoloGame { SantaSay("Well done! You've saved Christmas!", ChristmasAudio.END_WIN2); - for (Player player : GetPlayers(false)) + for (final Player player : GetPlayers(false)) { if (Manager.IsRewardItems()) { From f1c74249397e38b5e7dcf1de2dc6f79c12c43c12 Mon Sep 17 00:00:00 2001 From: William Burns Date: Tue, 29 Dec 2015 15:19:09 +0000 Subject: [PATCH 17/65] Fixing hotbar --- .../gladiators/hotbar/HotbarPageListener.java | 83 +++++++++++++++++-- 1 file changed, 78 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java index d778f7643..249983dd7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java @@ -1,11 +1,19 @@ package nautilus.game.arcade.game.games.gladiators.hotbar; import org.bukkit.Material; +import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.PlayerInventory; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; /** * Created by William (WilliamTiger). @@ -29,12 +37,25 @@ public class HotbarPageListener implements Listener if (e.getCurrentItem() == null) return; + if (e.getAction().equals(InventoryAction.HOTBAR_SWAP) || e.getAction().equals(InventoryAction.HOTBAR_MOVE_AND_READD)){ + e.setCancelled(true); + return; + } + if (e.getClick().isShiftClick()) { e.setCancelled(true); return; } + System.out.println(e.getClickedInventory().getName() + " : " + e.getInventory().getName()); + +// if ((e.getSlot() > 8 && e.getSlot() < 18)) +// { +// e.setCancelled(false); +// return; +// } + if (e.getCurrentItem().getType().equals(Material.REDSTONE_BLOCK)) { e.setCancelled(true); @@ -42,11 +63,21 @@ public class HotbarPageListener implements Listener return; } + if (e.getClickedInventory() instanceof PlayerInventory || e.getInventory() instanceof PlayerInventory){ + e.setCancelled(true); + return; + } + if (e.getCurrentItem().getType().equals(Material.EMERALD_BLOCK)) { + if (e.getAction().equals(InventoryAction.SWAP_WITH_CURSOR)){ + e.setCancelled(true); + return; + } + e.setCancelled(true); e.getWhoClicked().closeInventory(); - _editor.saveLayout(((Player)e.getWhoClicked()), e.getClickedInventory()); + _editor.saveLayout(((Player) e.getWhoClicked()), e.getClickedInventory()); return; } @@ -56,15 +87,57 @@ public class HotbarPageListener implements Listener return; } - if (e.getAction().equals(InventoryAction.PLACE_ALL) - || e.getAction().equals(InventoryAction.PLACE_ONE) - || e.getAction().equals(InventoryAction.PLACE_SOME)) - { + if (!(e.getAction().equals(InventoryAction.PICKUP_ONE) || e.getAction().equals(InventoryAction.PLACE_ONE))){ + if (!(e.getSlot() > 8 && e.getSlot() < 18)) { e.setCancelled(true); return; } + + return; } + +// if (e.getAction().equals(InventoryAction.PLACE_ALL) +// || e.getAction().equals(InventoryAction.PLACE_ONE) +// || e.getAction().equals(InventoryAction.PLACE_SOME)) +// { +// if (!(e.getSlot() > 8 && e.getSlot() < 18)) +// { +// e.setCancelled(true); +// return; +// } +// } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onDrop(PlayerDropItemEvent e){ + if (e.getPlayer().getOpenInventory() == null) + return; + + if (e.getPlayer().getOpenInventory().getTopInventory() == null) + return; + + if (!e.getPlayer().getOpenInventory().getTopInventory().getName().equals("Hotbar Editor")) + return; + + if (!e.isCancelled()) + return; + + e.setCancelled(false); + Item i = e.getItemDrop(); + Inventory inv = e.getPlayer().getOpenInventory().getTopInventory(); + + if (i.getItemStack().getType().equals(Material.EMERALD_BLOCK)) + inv.setItem(30, new ItemBuilder(Material.EMERALD_BLOCK).setTitle(C.cGreen + C.Bold + "Save").setLore(C.cGray + "Click to save layout.").build()); + else if (i.getItemStack().getType().equals(Material.REDSTONE_BLOCK)) + inv.setItem(32, new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cRed + C.Bold + "Cancel").setLore(C.cGray + "Click to cancel layout.").build()); + else + inv.addItem(i.getItemStack()); + + e.getPlayer().updateInventory(); + e.getPlayer().setItemOnCursor(null); + + i.remove(); } } From 1b40cece80ce52a3b9ef86f0d9fdc308cdccf713 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 30 Dec 2015 20:04:01 +0000 Subject: [PATCH 18/65] Added a new years countdown to the hub. --- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 3 + .../mineplex/hub/commands/NewYearCommand.java | 50 ++++ .../hub/modules/NewYearCountdown.java | 249 ++++++++++++++++++ 3 files changed, 302 insertions(+) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index bfac5e555..7cc8e7def 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -54,6 +54,7 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; +import mineplex.hub.modules.NewYearCountdown; import mineplex.hub.modules.StackerManager; import mineplex.hub.queue.QueueManager; import mineplex.hub.server.ServerManager; @@ -183,6 +184,8 @@ public class Hub extends JavaPlugin implements IRelation //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); + + new NewYearCountdown(this); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java new file mode 100644 index 000000000..55e64903d --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java @@ -0,0 +1,50 @@ +package mineplex.hub.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.hub.modules.NewYearCountdown; + +/** + * Created by William (WilliamTiger). + * 29/12/15 + */ +public class NewYearCommand extends CommandBase +{ + public NewYearCommand(NewYearCountdown plugin) + { + super(plugin, Rank.JNR_DEV, "newyear", "nycountdown", "nyc"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (Plugin.isInProgress()) + { + caller.sendMessage(ChatColor.RED + "A new year countdown event is already in progress!"); + return; + } + + if (args.length != 1) + { + caller.sendMessage(ChatColor.RED + "/newyear "); + return; + } + + int mins = 0; + try + { + mins = Integer.parseInt(args[0]); + } + catch (Exception e) + { + caller.sendMessage(ChatColor.RED + "That is not a valid amount of minutes!"); + return; + } + + + Plugin.start(caller, mins); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java new file mode 100644 index 000000000..027b1c89e --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -0,0 +1,249 @@ +package mineplex.hub.modules; + +import java.awt.*; +import java.awt.font.FontRenderContext; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.*; +import java.util.List; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Location; +import org.bukkit.entity.Firework; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.inventory.meta.FireworkMeta; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +import mineplex.core.MiniPlugin; +import mineplex.core.command.CommandCenter; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.commands.NewYearCommand; + +/** + * Created by William (WilliamTiger). + * 29/12/15 + */ +public class NewYearCountdown extends MiniPlugin +{ + private boolean _inProgress; + private Location _center; + private int _stage; + private BufferedImage _currentFrame; + + public NewYearCountdown(JavaPlugin plugin) + { + super("New Year Countdown", plugin); + + _inProgress = false; + } + + @Override + public void addCommands() + { + CommandCenter.Instance.AddCommand(new NewYearCommand(this)); + } + + public boolean isInProgress() + { + return _inProgress; + } + + public void start(Player player, int mins) + { + _inProgress = true; + _center = player.getLocation(); + _stage = mins * 60; + UtilServer.broadcast(C.cGreenB + player.getName() + " has started a " + C.cAquaB + "New Year's Countdown"); + UtilWorld.getWorld("world").setTime(18000); + + _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); + } + + @EventHandler + public void cmd(PlayerCommandPreprocessEvent e) + { + if (e.getMessage().equalsIgnoreCase("/lmao")) + { + e.setCancelled(true); + start(e.getPlayer(), 3); + } + } + + @EventHandler + public void stageUpdate(UpdateEvent e) + { + if (e.getType() != UpdateType.SEC) + return; + + if (!_inProgress) + return; + + _stage--; + + if (_stage <= 0) + return; + + _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); + } + + @EventHandler + public void update(UpdateEvent e) + { + if (e.getType() != UpdateType.FASTER) + return; + + if (!_inProgress) + return; + + if (_stage == 0) + { + _currentFrame = null; + UtilTextMiddle.display(C.cGoldB + "2016", C.cYellowB + "Happy New Year!", UtilServer.getPlayers()); + } + + if (_stage <= -120) + { + //End of event. + _inProgress = false; + UtilWorld.getWorld("world").setTime(0); + return; + } + + if (_stage <= 0) + { + randomFirework(offsetLoc(_center)); + randomFirework(offsetLoc(_center)); + randomFirework(offsetLoc(_center)); + } + + new BukkitRunnable(){ + ArrayList line = UtilShapes.getLinesDistancedPoints(offsetLoc(_center), offsetLoc(_center), 0.2); + UtilParticle.ParticleType type = getRandomParticle(); + @Override + public void run() + { + UtilParticle.PlayParticle(type, line.get(0), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); + line.remove(0); + + if (line.isEmpty()) + this.cancel(); + } + }.runTaskTimer(getPlugin(), 0L, 1L); + + if (_currentFrame == null) + return; + + for (int y = 0; y < _currentFrame.getHeight(); y++) + for (int x = 0; x < _currentFrame.getWidth(); x++) + { + if (java.awt.Color.black.getRGB() != _currentFrame.getRGB(x, y)) + continue; + + Vector v = new Vector((float) _currentFrame.getWidth() / 2 - x, (float) _currentFrame.getHeight() / 2 - y, 0).multiply(0.5); + UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, _center.add(v), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); + _center.subtract(v); + } + } + + private 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(java.awt.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; + } + + private String formatTimer(int seconds) + { + if (seconds <= 60) + return "" + seconds; + + int mins = seconds / 60; + int secs = seconds % 60; + String s = String.valueOf(secs); + + if (s.length() == 1) + s = "0" + s; + + return mins + ":" + s; + } + + private Location offsetLoc(Location loc) + { + Random random = new Random(); + return loc.clone().add((random.nextInt(100) - 50) + random.nextDouble() - 0.5, random.nextInt(20) + random.nextDouble() - 0.5, (random.nextInt(100) - 50) + random.nextDouble() - 0.5); + } + + public static void randomFirework(Location l) + { + Color c = Color.RED; + int r = new Random().nextInt(4); + if (r == 0) + { + c = Color.AQUA; + } + else if (r == 1) + { + c = Color.YELLOW; + } + else if (r == 2) + { + c = Color.RED; + } else if (r == 3) + { + c = Color.LIME; + } + FireworkEffect.Type t = FireworkEffect.Type.BALL; + int rType = new Random().nextInt(4); + if (rType == 0) { + t = FireworkEffect.Type.BALL_LARGE; + } else if (rType == 1) { + t = FireworkEffect.Type.BURST; + } else if (rType == 2) { + t = FireworkEffect.Type.STAR; + } else if (rType == 3) { + t = FireworkEffect.Type.CREEPER; + } + Firework f = l.getWorld().spawn(l, Firework.class); + FireworkMeta fm = f.getFireworkMeta(); + fm.addEffect(FireworkEffect.builder().with(t).withColor(c).build()); + fm.setPower(0 + new Random().nextInt(2)); + f.setFireworkMeta(fm); + } + + public UtilParticle.ParticleType getRandomParticle() + { + List types = Arrays.asList(UtilParticle.ParticleType.FLAME, UtilParticle.ParticleType.FIREWORKS_SPARK, UtilParticle.ParticleType.RED_DUST); + return types.get(new Random().nextInt(types.size())); + } + +} From a64dc6a8d4ac8b39f0bd955a84d539c4227d1a71 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 31 Dec 2015 00:46:31 +0000 Subject: [PATCH 19/65] Made it activate in all lobbies via command. --- .../mineplex/hub/commands/NewYearCommand.java | 37 +++++++--- .../hub/modules/NewYearCountdown.java | 69 +++++++++++++------ .../hub/modules/newyear/NewYearHandler.java | 28 ++++++++ .../hub/modules/newyear/NewYearMessage.java | 29 ++++++++ 4 files changed, 131 insertions(+), 32 deletions(-) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearHandler.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearMessage.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java index 55e64903d..2e1ec8432 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java @@ -5,7 +5,10 @@ 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.hub.modules.NewYearCountdown; +import mineplex.hub.modules.newyear.NewYearMessage; /** * Created by William (WilliamTiger). @@ -23,28 +26,42 @@ public class NewYearCommand extends CommandBase { if (Plugin.isInProgress()) { - caller.sendMessage(ChatColor.RED + "A new year countdown event is already in progress!"); + caller.sendMessage(F.main("NYC", C.cRed + "A new year countdown event is already in progress!")); return; } - if (args.length != 1) + if (args.length != 3) { - caller.sendMessage(ChatColor.RED + "/newyear "); + caller.sendMessage(F.main("NYC", C.cRed + "/newyear ")); return; } - int mins = 0; + if (!(validateInteger(args[0]) && validateInteger(args[1]) && validateInteger(args[2]))) + { + caller.sendMessage(F.main("NYC", C.cRed + "You have entered invalid hours/minutes/seconds.")); + return; + } + + int hours = Integer.valueOf(args[0]); + int mins = Integer.valueOf(args[1]); + int secs = Integer.valueOf(args[2]); + int total = secs + (mins * 60) + (hours * 60 * 60); + + caller.sendMessage(F.main("NYC", "Sent command to all lobbies to start with " + F.elem(total + "") + " seconds.")); + new NewYearMessage(total).publish(); + } + + private boolean validateInteger(String str) + { + boolean passed = false; try { - mins = Integer.parseInt(args[0]); + int i = Integer.valueOf(str); + passed = true; } catch (Exception e) { - caller.sendMessage(ChatColor.RED + "That is not a valid amount of minutes!"); - return; } - - - Plugin.start(caller, mins); + return passed; } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index 027b1c89e..286a9a152 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -6,10 +6,12 @@ import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.util.*; import java.util.List; +import java.util.concurrent.TimeUnit; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.entity.Firework; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -30,6 +32,9 @@ import mineplex.core.common.util.UtilWorld; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.commands.NewYearCommand; +import mineplex.hub.modules.newyear.NewYearHandler; +import mineplex.hub.modules.newyear.NewYearMessage; +import mineplex.serverdata.commands.ServerCommandManager; /** * Created by William (WilliamTiger). @@ -46,6 +51,10 @@ public class NewYearCountdown extends MiniPlugin { super("New Year Countdown", plugin); + ServerCommandManager.getInstance().registerCommandType("NewYearCommand", + NewYearMessage.class, new NewYearHandler(this)); + + _center = new Location(UtilWorld.getWorld("world"), 0.5, 85, 37.5); _inProgress = false; } @@ -60,24 +69,24 @@ public class NewYearCountdown extends MiniPlugin return _inProgress; } - public void start(Player player, int mins) + public void start(int seconds) { _inProgress = true; - _center = player.getLocation(); - _stage = mins * 60; - UtilServer.broadcast(C.cGreenB + player.getName() + " has started a " + C.cAquaB + "New Year's Countdown"); + _stage = seconds; UtilWorld.getWorld("world").setTime(18000); - _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); } @EventHandler public void cmd(PlayerCommandPreprocessEvent e) { + if (!e.getPlayer().getName().equalsIgnoreCase("WilliamTiger")) + return; + if (e.getMessage().equalsIgnoreCase("/lmao")) { e.setCancelled(true); - start(e.getPlayer(), 3); + start(30); } } @@ -92,6 +101,10 @@ public class NewYearCountdown extends MiniPlugin _stage--; + if (_stage > 0 && _stage <= 10) + for (Player p : UtilServer.getPlayers()) + p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f); + if (_stage <= 0) return; @@ -109,7 +122,7 @@ public class NewYearCountdown extends MiniPlugin if (_stage == 0) { - _currentFrame = null; + _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 20), "Happy New Year"); UtilTextMiddle.display(C.cGoldB + "2016", C.cYellowB + "Happy New Year!", UtilServer.getPlayers()); } @@ -117,6 +130,7 @@ public class NewYearCountdown extends MiniPlugin { //End of event. _inProgress = false; + _currentFrame = null; UtilWorld.getWorld("world").setTime(0); return; } @@ -152,7 +166,7 @@ public class NewYearCountdown extends MiniPlugin continue; Vector v = new Vector((float) _currentFrame.getWidth() / 2 - x, (float) _currentFrame.getHeight() / 2 - y, 0).multiply(0.5); - UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, _center.add(v), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); + UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, _center.add(v), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); _center.subtract(v); } } @@ -182,19 +196,23 @@ public class NewYearCountdown extends MiniPlugin return img; } - private String formatTimer(int seconds) + private String formatTimer(long seconds) { - if (seconds <= 60) - return "" + seconds; + long minutes = seconds / 60; + long hours = minutes / 60; - int mins = seconds / 60; - int secs = seconds % 60; - String s = String.valueOf(secs); + if ((hours % 60) > 0) + return zeroNumber(hours % 60) + ":" + zeroNumber(minutes % 60) + ":" + zeroNumber(seconds % 60); - if (s.length() == 1) - s = "0" + s; + if ((minutes % 60) > 0) + return zeroNumber(minutes % 60) + ":" + zeroNumber(seconds % 60); - return mins + ":" + s; + return zeroNumber(seconds % 60); + } + + private String zeroNumber(long time) + { + return (time < 10 ? "0" : "") + time; } private Location offsetLoc(Location loc) @@ -224,13 +242,20 @@ public class NewYearCountdown extends MiniPlugin } FireworkEffect.Type t = FireworkEffect.Type.BALL; int rType = new Random().nextInt(4); - if (rType == 0) { + if (rType == 0) + { t = FireworkEffect.Type.BALL_LARGE; - } else if (rType == 1) { + } + else if (rType == 1) + { t = FireworkEffect.Type.BURST; - } else if (rType == 2) { + } + else if (rType == 2) + { t = FireworkEffect.Type.STAR; - } else if (rType == 3) { + } + else if (rType == 3) + { t = FireworkEffect.Type.CREEPER; } Firework f = l.getWorld().spawn(l, Firework.class); @@ -242,7 +267,7 @@ public class NewYearCountdown extends MiniPlugin public UtilParticle.ParticleType getRandomParticle() { - List types = Arrays.asList(UtilParticle.ParticleType.FLAME, UtilParticle.ParticleType.FIREWORKS_SPARK, UtilParticle.ParticleType.RED_DUST); + List types = Arrays.asList(UtilParticle.ParticleType.FLAME, UtilParticle.ParticleType.HAPPY_VILLAGER, UtilParticle.ParticleType.RED_DUST); return types.get(new Random().nextInt(types.size())); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearHandler.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearHandler.java new file mode 100644 index 000000000..7f2f3cf80 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearHandler.java @@ -0,0 +1,28 @@ +package mineplex.hub.modules.newyear; + +import mineplex.hub.modules.NewYearCountdown; +import mineplex.serverdata.commands.CommandCallback; +import mineplex.serverdata.commands.ServerCommand; + +/** + * Created by William (WilliamTiger). + * 31/12/15 + */ +public class NewYearHandler implements CommandCallback +{ + private NewYearCountdown _newYear; + + public NewYearHandler(NewYearCountdown newYear) + { + _newYear = newYear; + } + + @Override + public void run(ServerCommand command) + { + if (command instanceof NewYearMessage) + { + _newYear.start(((NewYearMessage)command).getSeconds()); + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearMessage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearMessage.java new file mode 100644 index 000000000..aaf21447f --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearMessage.java @@ -0,0 +1,29 @@ +package mineplex.hub.modules.newyear; + +import mineplex.serverdata.commands.ServerCommand; + +/** + * Created by William (WilliamTiger). + * 31/12/15 + */ +public class NewYearMessage extends ServerCommand +{ + + private int seconds; + + public NewYearMessage(int seconds) + { + this.seconds = seconds; + } + + public int getSeconds() + { + return seconds; + } + + @Override + public void run() + { + + } +} From 874695cdf6696fcc988f78dfc3e85cb193a453d1 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 31 Dec 2015 00:50:53 +0000 Subject: [PATCH 20/65] Flame --- .../Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index 286a9a152..f7ba5f1c1 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -166,7 +166,7 @@ public class NewYearCountdown extends MiniPlugin continue; Vector v = new Vector((float) _currentFrame.getWidth() / 2 - x, (float) _currentFrame.getHeight() / 2 - y, 0).multiply(0.5); - UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, _center.add(v), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); + UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, _center.add(v), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); _center.subtract(v); } } From 637baed830196831fc4f3fff978bf971eb9951d1 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 31 Dec 2015 01:24:58 +0000 Subject: [PATCH 21/65] Small edits --- .../mineplex/hub/modules/NewYearCountdown.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index f7ba5f1c1..33b96bda1 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -6,7 +6,6 @@ import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.util.*; import java.util.List; -import java.util.concurrent.TimeUnit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -24,9 +23,11 @@ import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; import mineplex.core.command.CommandCenter; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilWorld; import mineplex.core.updater.UpdateType; @@ -44,6 +45,7 @@ public class NewYearCountdown extends MiniPlugin { private boolean _inProgress; private Location _center; + private Location _spawn; private int _stage; private BufferedImage _currentFrame; @@ -55,6 +57,7 @@ public class NewYearCountdown extends MiniPlugin NewYearMessage.class, new NewYearHandler(this)); _center = new Location(UtilWorld.getWorld("world"), 0.5, 85, 37.5); + _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); _inProgress = false; } @@ -108,6 +111,8 @@ public class NewYearCountdown extends MiniPlugin if (_stage <= 0) return; + UtilTextBottom.display(C.cWhiteB + "New Year's Countdown - " + C.cGoldB + formatTimer(_stage), UtilServer.getPlayers()); + _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); } @@ -124,6 +129,7 @@ public class NewYearCountdown extends MiniPlugin { _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 20), "Happy New Year"); UtilTextMiddle.display(C.cGoldB + "2016", C.cYellowB + "Happy New Year!", UtilServer.getPlayers()); + //fireworkCircle(); } if (_stage <= -120) @@ -265,9 +271,17 @@ public class NewYearCountdown extends MiniPlugin f.setFireworkMeta(fm); } + private void fireworkCircle() + { + for (Location cur : UtilShapes.getPointsInCircle(_spawn, 35, 30)) + { + UtilFirework.launchFirework(cur, FireworkEffect.Type.BALL, Color.FUCHSIA, false, true, cur.toVector().setY(3).multiply(1), 2); + } + } + public UtilParticle.ParticleType getRandomParticle() { - List types = Arrays.asList(UtilParticle.ParticleType.FLAME, UtilParticle.ParticleType.HAPPY_VILLAGER, UtilParticle.ParticleType.RED_DUST); + List types = Arrays.asList(UtilParticle.ParticleType.FLAME, UtilParticle.ParticleType.HAPPY_VILLAGER, UtilParticle.ParticleType.RED_DUST, UtilParticle.ParticleType.FIREWORKS_SPARK); return types.get(new Random().nextInt(types.size())); } From 5ff9d1985b8e93a24c63845b55c6989a783e196f Mon Sep 17 00:00:00 2001 From: Mysticate Date: Thu, 31 Dec 2015 03:00:40 -0500 Subject: [PATCH 22/65] Monitoring for josh + the mods --- .../typewars/StaffKillMonitorManager.java | 101 ++++++++++++++++++ .../arcade/game/games/typewars/TypeWars.java | 48 ++++----- 2 files changed, 125 insertions(+), 24 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java new file mode 100644 index 000000000..dc6a87727 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java @@ -0,0 +1,101 @@ +package nautilus.game.arcade.game.games.typewars; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.typewars.TypeWars.KillType; + +public class StaffKillMonitorManager implements Listener +{ + /** + * Created by: Mysticate + * Timestamp: December 30, 2015 + */ + + private TypeWars _host; + private String _command = "/words"; + + private NautHashMap _monitoring = new NautHashMap(); + + public StaffKillMonitorManager(TypeWars host) + { + _host = host; + + host.Manager.registerEvents(this);; + } + + public TypeWars getHost() + { + return _host; + } + + @EventHandler + public void onEnd(GameStateChangeEvent event) + { + if (event.GetState() == GameState.End) + HandlerList.unregisterAll(this); + } + + @EventHandler + public void onKill(MinionKillEvent event) + { + if (event.getType() == KillType.SPELL) + return; + + for (Player staff : _monitoring.keySet()) + { + if (_monitoring.get(staff) == event.getPlayer()) + { + UtilPlayer.message(staff, F.elem(C.cRedB + ">>") + F.name(event.getPlayer().getName()) + " killed " + F.elem(C.cGold + event.getMinion().getName()) + "."); + } + } + } + + @EventHandler + public void onCommand(PlayerCommandPreprocessEvent event) + { + if (!_host.IsLive()) + return; + + if (!_host.Manager.GetClients().hasRank(event.getPlayer(), Rank.HELPER)) + return; + + event.setCancelled(true); + + String[] message = event.getMessage().toLowerCase().split(" "); + if (message.length == 0 || !message[0].equalsIgnoreCase(_command)) + return; + + if (message.length == 1) + { + if (_monitoring.containsKey(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("TypeWars", "You are no longer monitoring " + F.name(_monitoring.remove(event.getPlayer()).getName()) + ".")); + } + else + { + UtilPlayer.message(event.getPlayer(), F.main("TypeWars", "Please enter a player to monitor!")); + } + return; + } + + String playerName = message[1]; + + Player player = UtilPlayer.searchOnline(event.getPlayer(), playerName, true); + if (player == null) + return; + + _monitoring.put(event.getPlayer(), player); + UtilPlayer.message(event.getPlayer(), F.main("TypeWars", "You are now monitoring " + F.name(player.getName()) + ". Type " + F.elem(_command) + " to stop.")); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java index 0f0d7e6c5..97e660f81 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java @@ -5,6 +5,27 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Giant; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.util.Vector; + import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -45,33 +66,10 @@ import nautilus.game.arcade.game.games.typewars.tutorial.TutorialTypeWars; import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent; import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.stats.TimeInGameStatTracker; import nautilus.game.arcade.world.WorldData; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Giant; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.util.Vector; - public class TypeWars extends TeamGame -{ - +{ private ArrayList _activeMinions; private ArrayList _deadMinions; private ArrayList _finishedMinions; @@ -114,6 +112,8 @@ public class TypeWars extends TeamGame "Kill your enemies Giant before they kill yours!" }); + new StaffKillMonitorManager(this); + this.DeathOut = false; this.DamageTeamSelf = false; this.DamageSelf = false; From 6b3a5416643389a7bcac8df93f40f492452971e5 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 31 Dec 2015 18:53:57 +0000 Subject: [PATCH 23/65] Accurate timings --- .../hub/modules/NewYearCountdown.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index 33b96bda1..019c8d35b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -24,6 +24,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.command.CommandCenter; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilShapes; @@ -47,6 +48,7 @@ public class NewYearCountdown extends MiniPlugin private Location _center; private Location _spawn; private int _stage; + private long _targetTime; private BufferedImage _currentFrame; public NewYearCountdown(JavaPlugin plugin) @@ -78,6 +80,7 @@ public class NewYearCountdown extends MiniPlugin _stage = seconds; UtilWorld.getWorld("world").setTime(18000); _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); + _targetTime = System.currentTimeMillis() + (seconds * 1000); } @EventHandler @@ -94,26 +97,31 @@ public class NewYearCountdown extends MiniPlugin } @EventHandler - public void stageUpdate(UpdateEvent e) + public void updateStage(UpdateEvent e) { - if (e.getType() != UpdateType.SEC) + if (e.getType() != UpdateType.TICK) return; if (!_inProgress) return; - _stage--; + int stageAttempt = (int) ((_targetTime - System.currentTimeMillis()) / 1000); - if (_stage > 0 && _stage <= 10) - for (Player p : UtilServer.getPlayers()) - p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f); + if (stageAttempt != _stage) + { + _stage = stageAttempt; - if (_stage <= 0) - return; + if (_stage > 0 && _stage <= 10) + for (Player p : UtilServer.getPlayers()) + p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f); - UtilTextBottom.display(C.cWhiteB + "New Year's Countdown - " + C.cGoldB + formatTimer(_stage), UtilServer.getPlayers()); + if (_stage <= 0) + return; - _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); + UtilTextBottom.display(C.cWhiteB + "New Year's Countdown - " + C.cGoldB + formatTimer(_stage), UtilServer.getPlayers()); + + _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); + } } @EventHandler From 8232d11cd1d65140ae1aed9f013b6dd311c95b3e Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 31 Dec 2015 15:07:26 -0600 Subject: [PATCH 24/65] Remove in game notifications, change sale message --- .../core/notifier/NotificationManager.java | 4 +- .../src/mineplex/hub/modules/NewsManager.java | 53 +++++++++---------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java index 8e4cb3dc7..64cb728bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java @@ -52,8 +52,8 @@ public class NotificationManager extends MiniPlugin // if (event.getType() == UpdateType.MIN_16) // sale(); - if (event.getType() == UpdateType.MIN_08) - christmasSale(); +// if (event.getType() == UpdateType.MIN_08) +// christmasSale(); } private void christmasSale() diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index 424a582a1..1172751de 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -262,34 +262,33 @@ public class NewsManager extends MiniPlugin { _animationIndex = (_animationIndex + 1) % 40; - if (_animationIndex == 0) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 5" + C.cWhiteB + "0% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 1) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50" + C.cWhiteB + "% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 2) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% " + C.cWhiteB + "OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 3) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% O" + C.cWhiteB + "FF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 4) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OF" + C.cWhiteB + "F ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 5) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF " + C.cWhiteB + "ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 6) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF A" + C.cWhiteB + "LL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 7) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF AL" + C.cWhiteB + "L RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 8) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL " + C.cWhiteB + "RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 9) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL R" + C.cWhiteB + "ANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 10) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RA" + C.cWhiteB + "NKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 11) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RAN" + C.cWhiteB + "KS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 12) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANK" + C.cWhiteB + "S " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 13) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 2) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " U" + C.cWhiteB + "P TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 3) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP" + C.cWhiteB + " TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 4) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP " + C.cWhiteB + "TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 5) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP T" + C.cWhiteB + "O 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 6) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO" + C.cWhiteB + " 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 7) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO " + C.cWhiteB + "50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 8) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 5" + C.cWhiteB + "0% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 9) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50" + C.cWhiteB + "% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 10) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50%" + C.cWhiteB + " OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 11) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% " + C.cWhiteB + "OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 11) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% O" + C.cWhiteB + "FF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 12) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OF" + C.cWhiteB + "F " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 13) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 14) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 15) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 16) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 17) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 18) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 19) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 20) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 21) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 22) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 23) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 24) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 25) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 26) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 14) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 15) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 16) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 17) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 18) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 19) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 20) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 21) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 22) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 23) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 24) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 25) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 26) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; if (_animationIndex >= 27) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " " + C.cWhiteB + "50% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; From 2e017fa5ca7bd04733de102e4ee1846243aeb203 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 31 Dec 2015 16:11:51 -0600 Subject: [PATCH 25/65] Fix redis command --- .../Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index 019c8d35b..1c0766fa8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -55,7 +55,7 @@ public class NewYearCountdown extends MiniPlugin { super("New Year Countdown", plugin); - ServerCommandManager.getInstance().registerCommandType("NewYearCommand", + ServerCommandManager.getInstance().registerCommandType("NewYearMessage", NewYearMessage.class, new NewYearHandler(this)); _center = new Location(UtilWorld.getWorld("world"), 0.5, 85, 37.5); From b47665e115f16d1c9853f50db8358dfa677f7e62 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Sat, 2 Jan 2016 14:02:50 +0000 Subject: [PATCH 26/65] lots of work on outposts, fixed gold dupe glitch, fixed clans ban gui title being "Customize New Gear". --- .../mineplex/cache/player/PlayerCache.java | 2 +- .../src/mineplex/core/common/util/F.java | 3 +- .../core/common/util/LoopIterator.java | 29 ++ .../core/common/util/NonFinalInteger.java | 33 +++ .../mineplex/core/common/util/RGBData.java | 45 +++ .../mineplex/core/common/util/UtilAlg.java | 7 +- .../mineplex/core/common/util/UtilColor.java | 21 ++ .../mineplex/core/common/util/UtilMath.java | 11 + .../core/account/CoreClientManager.java | 70 +++++ .../core/donation/DonationManager.java | 4 +- .../repository/DonationRepository.java | 2 +- .../mineplex/core/itemstack/ItemBuilder.java | 1 + .../src/mineplex/game/clans/Clans.java | 2 +- .../game/clans/clans/ClansBlacklist.java | 4 - .../game/clans/clans/ClansManager.java | 37 ++- .../game/clans/clans/ban/ClansBan.java | 20 +- .../game/clans/clans/ban/ClansBanClient.java | 33 ++- .../game/clans/clans/ban/ClansBanManager.java | 110 ++++++-- .../clans/clans/ban/ClansBanRepository.java | 109 ++++++-- .../clans/ban/commands/ClansBanCommand.java | 22 +- .../ban/commands/ClansBanListCommand.java | 21 ++ .../clans/clans/ban/ui/ClansBanListPage.java | 32 +++ .../clans/clans/ban/ui/ClansBanListShop.java | 24 ++ .../game/clans/clans/ban/ui/ClansBanPage.java | 41 ++- .../game/clans/clans/ban/ui/ClansBanShop.java | 5 +- .../game/clans/clans/commands/Meow.java | 22 ++ .../game/clans/clans/outpost/Outpost.java | 257 ++++++++++++++++++ .../clans/clans/outpost/OutpostBlock.java | 59 ++++ .../clans/clans/outpost/OutpostManager.java | 171 ++++++++++++ .../clans/clans/outpost/OutpostState.java | 9 + .../game/clans/clans/outpost/OutpostType.java | 226 +++++++++++++++ .../clans/clans/regions/ClansRegions.java | 2 +- .../game/clans/gameplay/Gameplay.java | 42 +-- .../game/clans/gameplay/safelog/SafeLog.java | 10 +- .../game/pvp/modules/clans/ClansOutpost.java | 1 - 35 files changed, 1347 insertions(+), 140 deletions(-) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/LoopIterator.java create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NonFinalInteger.java create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/RGBData.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanListCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListPage.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListShop.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/Meow.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBlock.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostState.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostType.java diff --git a/Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java b/Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java index e83eabf74..3bfb1bf00 100644 --- a/Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java +++ b/Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java @@ -39,7 +39,7 @@ public class PlayerCache catch (Exception exception) { System.out.println("Error adding player info in PlayerCache : " + exception.getMessage()); - exception.printStackTrace(); +// exception.printStackTrace(); } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java index d470882af..c0e941237 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java @@ -2,6 +2,8 @@ package mineplex.core.common.util; import mineplex.core.common.Rank; +import java.util.LinkedList; + import org.bukkit.ChatColor; public class F @@ -198,5 +200,4 @@ public class F return out; } - } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/LoopIterator.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/LoopIterator.java new file mode 100644 index 000000000..2236d5ecf --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/LoopIterator.java @@ -0,0 +1,29 @@ +package mineplex.core.common.util; + +import java.util.List; + +public class LoopIterator +{ + private List _list; + private int _pointer; + + public LoopIterator(List list) + { + _list = list; + } + + public T next() + { + if (_list.isEmpty()) + { + return null; + } + + if (++_pointer == _list.size()) + { + _pointer = 0; + } + + return _list.get(_pointer); + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NonFinalInteger.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NonFinalInteger.java new file mode 100644 index 000000000..6638cbed9 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NonFinalInteger.java @@ -0,0 +1,33 @@ +package mineplex.core.common.util; + +public class NonFinalInteger +{ + private int _value; + + public NonFinalInteger() + { + this(0); + } + + public NonFinalInteger(int value) + { + _value = value; + } + + public NonFinalInteger add(int value) + { + _value += value; + return this; + } + + public NonFinalInteger subtract(int value) + { + _value -= value; + return this; + } + + public int get() + { + return _value; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/RGBData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/RGBData.java new file mode 100644 index 000000000..38170c0b4 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/RGBData.java @@ -0,0 +1,45 @@ +package mineplex.core.common.util; + +public class RGBData +{ + private double _red; + private double _green; + private double _blue; + + public RGBData(double red, double green, double blue) + { + _red = UtilMath.clamp(red, 0, 1); + _green = UtilMath.clamp(green, 0, 1); + _blue = UtilMath.clamp(blue, 0, 1); + } + + public int getFullRed() + { + return (int) (_red * 255); + } + + public int getFullGreen() + { + return (int) (_green * 255); + } + + public int getFullBlue() + { + return (int) (_blue * 255); + } + + public double getRed() + { + return _red; + } + + public double getGreen() + { + return _green; + } + + public double getBlue() + { + return _blue; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java index 6045f4d9e..40f1147c9 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java @@ -15,7 +15,7 @@ import org.bukkit.entity.Player; import org.bukkit.util.EulerAngle; import org.bukkit.util.Vector; -import net.minecraft.server.v1_8_R3.EnumDirection; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; public class UtilAlg { @@ -510,4 +510,9 @@ public class UtilAlg Math.toRadians(UtilAlg.GetYaw(vector)), 0); } + + public static AxisAlignedBB toBoundingBox(Location a, Location b) + { + return new AxisAlignedBB(a.getX(), a.getY(), a.getZ(), b.getX(), b.getY(), b.getZ()); + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java index e04ddf689..4fabeafd0 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java @@ -7,6 +7,7 @@ import org.bukkit.ChatColor; */ public class UtilColor { + public static final RGBData RgbRed = hexToRgb(0xee0100); public static byte chatColorToClayData(ChatColor chatColor) { @@ -66,4 +67,24 @@ public class UtilColor return 0; } } + + public static RGBData hexToRgb(int hex) + { + String hexStr = hexPad(Integer.toHexString(hex)); + int red = Integer.parseInt(hexStr.substring(0, 2), 16); + int green = Integer.parseInt(hexStr.substring(2, 4), 16); + int blue = Integer.parseInt(hexStr.substring(4, 6), 16); + + return new RGBData(((double) red) / 255.d, ((double) green) / 255.d, ((double) blue) / 255.d); + } + + public static String hexPad(String hex) + { + if (hex.length() == 6) + { + return hex; + } + + return UtilText.repeat("0", 6 - hex.length()) + hex; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java index 3d48c098f..5a4ee4a42 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java @@ -116,4 +116,15 @@ public class UtilMath { return num < min ? min : (num > max ? max : num); } + + public static double random(double min, double max) + { + min = Math.abs(min); + + int rand = -random.nextInt((int)(min * 100)); + + rand += random.nextInt((int)(max * 100)); + + return ((double) rand) / 100.d; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 7228b671e..fe00a1a45 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -285,6 +285,76 @@ public class CoreClientManager extends MiniPlugin }); } + public void loadClientByNameSync(final String playerName, final Runnable runnable) + { + try + { + ClientToken token = null; + Gson gson = new Gson(); + + // Fails if not in DB and if duplicate. + UUID uuid = loadUUIDFromDB(playerName); + + if (uuid == null) + { + try + { + uuid = UUIDFetcher.getUUIDOf(playerName); + } + catch (Exception exception) + { + System.out.println("Error fetching uuid from mojang : " + exception.getMessage()); + } + } + + String response = ""; + + if (uuid == null) + { + response = _repository.getClientByName(playerName); + } + else + { + response = _repository.getClientByUUID(uuid); + } + + token = gson.fromJson(response, ClientToken.class); + + CoreClient client = Add(playerName); + client.SetRank(Rank.valueOf(token.Rank), false); + client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName())); + + // JSON sql response + Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); + + if (client.getAccountId() > 0) + { + PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); + + if (playerInfo != null) + { + playerInfo.setAccountId(client.getAccountId()); + PlayerCache.getInstance().addPlayer(playerInfo); + } + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + finally + { + Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() + { + public void run() + { + if (runnable != null) + runnable.run(); + } + }); + } + } + public boolean LoadClient(final CoreClient client, final UUID uuid, String ipAddress) { TimingManager.start(client.GetPlayerName() + " LoadClient Total."); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index d4909b45a..b23603f69 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -352,7 +352,7 @@ public class DonationManager extends MiniDbClientPlugin if (donor != null) { - donor.addGold(amount); + donor.setGold(amount); } } } @@ -445,7 +445,7 @@ public class DonationManager extends MiniDbClientPlugin @Override public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { - Get(playerName).addGold(_repository.retrieveDonorInfo(resultSet).getGold()); + Get(playerName).setGold(_repository.retrieveDonorInfo(resultSet).getGold()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java index 1cea81f1b..b30b30b92 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java @@ -246,7 +246,7 @@ public class DonationRepository extends RepositoryBase while (resultSet.next()) { - donor.addGold(resultSet.getInt(1)); + donor.setGold(resultSet.getInt(1)); } return donor; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java index fa7070511..4f555ab3d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java @@ -173,6 +173,7 @@ public class ItemBuilder { for (String lore : lores) { + if (lore == null) continue; _lore.add(C.cGray + lore); } 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 097227b2e..9cc138083 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -100,7 +100,7 @@ public class Clans extends JavaPlugin Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - // new ClansBanManager(this, webServerAddress, _clientManager, _donationManager); + new ClansBanManager(this, _clientManager, _donationManager); Punish punish = new Punish(this, webServerAddress, _clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBlacklist.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBlacklist.java index dc0b837f7..1483b9949 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBlacklist.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBlacklist.java @@ -38,8 +38,4 @@ public class ClansBlacklist return true; } - - public static void addBlacklist(String blacklist) { - BLACKLISTED_NAMES.add(blacklist); - } } 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 d51bb3f24..c36ff94fd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -31,6 +31,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.plugin.java.JavaPlugin; +import com.google.common.io.ByteArrayDataOutput; +import com.google.common.io.ByteStreams; + import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -72,6 +75,7 @@ import mineplex.game.clans.clans.commands.ClansCommand; import mineplex.game.clans.clans.commands.ClansLoginManager; import mineplex.game.clans.clans.commands.KillCommand; import mineplex.game.clans.clans.commands.MapCommand; +import mineplex.game.clans.clans.commands.Meow; import mineplex.game.clans.clans.commands.RegionsCommand; import mineplex.game.clans.clans.data.PlayerClan; import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; @@ -79,6 +83,7 @@ import mineplex.game.clans.clans.gui.ClanShop; import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.map.ItemMapManager; import mineplex.game.clans.clans.observer.ObserverManager; +import mineplex.game.clans.clans.outpost.OutpostManager; import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.potato.PotatoManager; import mineplex.game.clans.clans.pvptimer.PvpTimer; @@ -203,6 +208,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati { super("Clans Manager", plugin); + addCommand(new Meow(new OutpostManager(this))); + _instance = this; _serverName = serverName; @@ -584,6 +591,27 @@ public class ClansManager extends MiniClientPluginimplements IRelati } } + @EventHandler + public void disallowReplayMod(PlayerJoinEvent event) + { + // happens 20 ticks later because player channels don't + // seem to work immediately after joining. + runSyncLater(() -> { + ByteArrayDataOutput bado = ByteStreams.newDataOutput(); + + bado.writeUTF("no_xray"); + bado.writeBoolean(true); + + bado.writeUTF("no_noclip"); + bado.writeBoolean(true); + + bado.writeUTF("only_recording_player"); + bado.writeBoolean(true); + + event.getPlayer().sendPluginMessage(_plugin, "Replay|Restrict", bado.toByteArray()); + }, 20L); + } + @EventHandler public void denyBow(EntityShootBowEvent event) { @@ -710,15 +738,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati } - @EventHandler - public void command(PlayerCommandPreprocessEvent event){ - if (event.getMessage().startsWith("/blacklist ")){ - String blacklist = event.getMessage().split(" ")[1]; - - ClansBlacklist.addBlacklist(blacklist); - } - } - public void messageClan(ClanInfo clan, String message) { for (Player player : clan.getOnlinePlayers()) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java index e3295123a..dbc3c970f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java @@ -1,5 +1,7 @@ package mineplex.game.clans.clans.ban; +import java.sql.Timestamp; + import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; @@ -8,11 +10,12 @@ public class ClansBan private int _id; private int _accountId; private String _reason; - private long _banTime; - private long _unbanTime; + private Timestamp _banTime; + private Timestamp _unbanTime; private boolean _permanent; + private boolean _removed; - public ClansBan(int id, int accountId, String reason, long banTime, long unbanTime, boolean permanent) + public ClansBan(int id, int accountId, String reason, Timestamp banTime, Timestamp unbanTime, boolean permanent, boolean removed) { _id = id; _accountId = accountId; @@ -20,6 +23,7 @@ public class ClansBan _banTime = banTime; _unbanTime = unbanTime; _permanent = permanent; + _removed = removed; } public int getId() @@ -37,22 +41,22 @@ public class ClansBan return _reason; } - public long getBanTime() + public Timestamp getBanTime() { return _banTime; } public long getLength() { - return _unbanTime - _banTime; + return _unbanTime.getTime() - _banTime.getTime(); } public long getTimeLeft() { - return Math.max(0, _unbanTime - System.currentTimeMillis()); + return Math.max(0, _unbanTime.getTime() - System.currentTimeMillis()); } - public long getUnbanTime() + public Timestamp getUnbanTime() { return _unbanTime; } @@ -71,7 +75,7 @@ public class ClansBan public boolean isRemoved() { - return _unbanTime == -1; + return _removed; } public boolean isActive() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java index 44bfd9b9f..57565214f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java @@ -35,6 +35,11 @@ public class ClansBanClient for (ClansBan ban : Bans) { + if (!ban.isActive()) + { + continue; + } + if (ban.isPermanent()) { return -1; @@ -52,20 +57,30 @@ public class ClansBanClient return time == -1 ? F.time("permanently") : "for " + F.time(UtilTime.MakeStr(time)); } - - public String toString() + + public ClansBan getLongestBan() { - StringBuilder str = new StringBuilder(); - - str.append("{ClansBanClient:" + AccountId + "} [\n"); + ClansBan longest = null; for (ClansBan ban : Bans) { - str.append("(\nid: " + ban.getId() + ",\nbanTime: " + ban.getBanTime() + ",\nunbanTime: " + ban.getUnbanTime() + ",\nbanTimeLeft:" + ban.getTimeLeft() + ",\nReason:\"" + ban.getReason() + "\"\n)"); + if (!ban.isActive()) + { + continue; + } + + if (longest == null) + { + longest = ban; + continue; + } + + if (ban.getTimeLeft() > longest.getTimeLeft()) + { + longest = ban; + } } - str.append("]"); - - return str.toString(); + return longest; } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java index 51214872e..1883da837 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java @@ -1,20 +1,32 @@ package mineplex.game.clans.clans.ban; +import java.net.URL; +import java.net.URLConnection; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Map.Entry; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.donation.DonationManager; import mineplex.game.clans.clans.ban.commands.ClansBanCommand; +import mineplex.game.clans.clans.ban.commands.ClansBanListCommand; +import mineplex.game.clans.clans.ban.ui.ClansBanListShop; import mineplex.game.clans.clans.ban.ui.ClansBanShop; public class ClansBanManager extends MiniPlugin @@ -24,32 +36,35 @@ public class ClansBanManager extends MiniPlugin private Map _clients; private Map _cache; private ClansBanShop _shop; + private ClansBanListShop _shop2; - public ClansBanManager(JavaPlugin plugin, String webServerAddress, CoreClientManager clientManager, DonationManager donationManager) + public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) { super("Blacklist", plugin); _clientManager = clientManager; - _repository = new ClansBanRepository(plugin, this, webServerAddress); + _repository = new ClansBanRepository(plugin, this); _clients = new HashMap<>(); _cache = new HashMap<>(); _shop = new ClansBanShop(this, clientManager, donationManager); + _shop2 = new ClansBanListShop(this, clientManager, donationManager); } @Override public void addCommands() { addCommand(new ClansBanCommand(this)); + addCommand(new ClansBanListCommand(this)); } - public void ban(ClansBanClient client, String name, long time, String reason) + public void ban(ClansBanClient client, String name, long time, String reason, Callback callback) { _repository.ban(client.AccountId, time, reason, time == -1); - LoadClient(name, null); + LoadClient(name, callback); } public CoreClientManager getClientManager() @@ -65,36 +80,85 @@ public class ClansBanManager extends MiniPlugin @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { - LoadClient(event.getPlayer().getName(), null); - ClansBanClient client = _clients.get(event.getPlayer().getName()); - - if (client.isBanned()) - { - event.setJoinMessage(null); - event.getPlayer().kickPlayer(C.cRed + "You have been banned from Clans " + client.getBanTimeFormatted() + "."); - } + LoadClient(event.getPlayer().getName(), client -> { + if (client.isBanned()) + { + String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT); + + if (client.getLongestBan().isPermanent()) + time = "Permanent"; + + String reason = C.cRedB + "You are banned from Clans for " + time + + "\n" + C.cWhite + client.getLongestBan().getReason() + ; + + event.getPlayer().kickPlayer(reason); + } + else + { + UtilServer.broadcast(F.sys("Join", event.getPlayer().getName())); + } + }); } - @EventHandler + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerQuit(PlayerQuitEvent event) + { + if (Get(event.getPlayer().getName()) == null) + { + return; + } + + if (Get(event.getPlayer().getName()).isBanned()) + { + event.setQuitMessage(null); + } + + UnloadClient(Get(event.getPlayer().getName())); + } + + @EventHandler(priority = EventPriority.LOWEST) public void onPlayerKicked(PlayerKickEvent event) { - ClansBanClient client = _clients.get(event.getPlayer().getName()); + if (Get(event.getPlayer().getName()) == null) + { + return; + } - if (client.isBanned()) + if (Get(event.getPlayer().getName()).isBanned()) { event.setLeaveMessage(null); } + + UnloadClient(Get(event.getPlayer().getName())); } + public void UnloadClient(ClansBanClient client) + { + String name = ""; + + for (Entry entry : _clients.entrySet()) + { + if (entry.getValue().equals(client)) + { + name = entry.getKey(); + break; + } + } + + _clients.remove(name); + } + public void LoadClient(final String name, Callback callback) { GetRepository().loadBans(name, client -> { _clients.put(name, client); + System.out.println("> CLIENTS: " + _clients); if (callback != null) callback.run(client); }); } - public ClansBanClient GetClient(String name) + public ClansBanClient Get(String name) { synchronized (this) { @@ -107,6 +171,11 @@ public class ClansBanManager extends MiniPlugin return _shop; } + public ClansBanListShop getShop2() + { + return _shop2; + } + public void cache(Player player, String playerName) { _cache.put(player.getName(), playerName); @@ -122,7 +191,7 @@ public class ClansBanManager extends MiniPlugin _cache.remove(name); } - public void unban(ClansBanClient target, ClansBan ban, String name) + public void unban(ClansBanClient target, ClansBan ban, String name, Callback callback) { if (target.AccountId != ban.getAccountId()) { @@ -131,6 +200,11 @@ public class ClansBanManager extends MiniPlugin _repository.removeBan(ban); - LoadClient(name, null); + LoadClient(name, callback); + } + + public void listRecordedNames(Callback> callback) + { + GetRepository().loadAll(callback); } } 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 3be04b14d..9860e8d5d 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 @@ -8,9 +8,8 @@ import java.util.List; import org.bukkit.plugin.java.JavaPlugin; -import com.google.gson.reflect.TypeToken; - import mineplex.core.common.util.Callback; +import mineplex.core.common.util.NonFinalInteger; import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; @@ -18,20 +17,18 @@ import mineplex.core.database.column.ColumnBoolean; import mineplex.core.database.column.ColumnInt; import mineplex.core.database.column.ColumnTimestamp; import mineplex.core.database.column.ColumnVarChar; -import mineplex.core.server.remotecall.JsonWebCall; public class ClansBanRepository extends RepositoryBase { private ClansBanManager _manager; private static final String GET_LONGEST_BAN = "SELECT * FROM clanBans WHERE (NOW() < unbanTime OR permanent=1) AND accountId = ? ORDER BY permanent DESC, unbanTime DESC LIMIT 1;"; - private static final String BAN_PLAYER = "INSERT INTO clanBans (accountId, reason, banTime, unbanTime, permanent) VALUES (?, ?, ?, ?, ?);"; - private static final String REMOVE_BAN = "UPDATE clanBans SET unbanTime = -1 WHERE id = ?;"; + private static final String BAN_PLAYER = "INSERT INTO clanBans (accountId, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?);"; + private static final String REMOVE_BAN = "UPDATE clanBans SET removed = 1 WHERE id = ?;"; private static final String GET_ALL_BANS = "SELECT * FROM clanBans WHERE accountId = ?;"; + private static final String GET_ALL_ACCOUNTS = "SELECT DISTINCT accountId FROM clanBans;"; - private String _webAddress; - - public ClansBanRepository(JavaPlugin plugin, ClansBanManager manager, String webServerAddress) + public ClansBanRepository(JavaPlugin plugin, ClansBanManager manager) { super(plugin, DBPool.getAccount()); @@ -45,20 +42,26 @@ public class ClansBanRepository extends RepositoryBase new ColumnVarChar("reason", 128, reason), new ColumnTimestamp("banTime", new Timestamp(System.currentTimeMillis())), new ColumnTimestamp("unbanTime", new Timestamp(System.currentTimeMillis() + time)), - new ColumnBoolean("permanent", permanent) + new ColumnBoolean("permanent", permanent), + new ColumnBoolean("removed", false) ); } public void loadBans(final String name, final Callback callback) { + System.out.println(">> Attempting to load Clans Bans for \"" + name + "\""); _manager.getClientManager().loadClientByName(name, new Runnable() { public void run() { + System.out.println("> Successfully loaded CoreClient"); + executeQuery(GET_ALL_BANS, new ResultSetCallable() { @Override public void processResultSet(ResultSet resultSet) throws SQLException { + System.out.println("> Successfully executed query, result set object: " + resultSet); + final List list = new ArrayList(); while (resultSet.next()) @@ -66,14 +69,58 @@ public class ClansBanRepository extends RepositoryBase int id = resultSet.getInt(1); int accountId = resultSet.getInt(2); String reason = resultSet.getString(3); - long banTime = resultSet.getLong(4); - long unbanTime = resultSet.getLong(5); + Timestamp banTime = resultSet.getTimestamp(4); + Timestamp unbanTime = resultSet.getTimestamp(5); boolean permanent = resultSet.getBoolean(6); + boolean removed = resultSet.getBoolean(7); - list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent)); + list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); } callback.run(new ClansBanClient(_manager.getClientManager().Get(name).getAccountId(), list)); + + System.out.println("> Successfully handled result"); + System.out.println(">> FINISH"); + } + }, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId())); + } + }); + } + + public void loadBansSync(final String name, final Callback callback) + { + System.out.println(">> Attempting to load Clans Bans for \"" + name + "\""); + _manager.getClientManager().loadClientByNameSync(name, new Runnable() { + public void run() + { + System.out.println("> Successfully loaded CoreClient"); + + executeQuery(GET_ALL_BANS, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + System.out.println("> Successfully executed query, result set object: " + resultSet); + + final List list = new ArrayList(); + + while (resultSet.next()) + { + int id = resultSet.getInt(1); + int accountId = resultSet.getInt(2); + String reason = resultSet.getString(3); + Timestamp banTime = resultSet.getTimestamp(4); + Timestamp unbanTime = resultSet.getTimestamp(5); + boolean permanent = resultSet.getBoolean(6); + boolean removed = resultSet.getBoolean(7); + + list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); + } + + callback.run(new ClansBanClient(_manager.getClientManager().Get(name).getAccountId(), list)); + + System.out.println("> Successfully handled result"); + System.out.println(">> FINISH"); } }, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId())); } @@ -103,8 +150,9 @@ public class ClansBanRepository extends RepositoryBase Timestamp banTime = resultSet.getTimestamp(4); Timestamp unbanTime = resultSet.getTimestamp(5); boolean permanent = resultSet.getBoolean(6); - - callback.run(new ClansBan(id, accountId, reason, banTime.getTime(), unbanTime.getTime(), permanent)); + boolean removed = resultSet.getBoolean(7); + + callback.run(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); } } }, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId())); @@ -112,20 +160,33 @@ public class ClansBanRepository extends RepositoryBase }); } - public void matchPlayerName(final Callback> callback, final String userName) + public void loadAll(Callback> callback) { - Thread asyncThread = new Thread(new Runnable() - { - public void run() + _manager.runAsync(() -> { + executeQuery(GET_ALL_ACCOUNTS, new ResultSetCallable() { - List tokenList = new JsonWebCall(_webAddress + "PlayerAccount/GetMatches").Execute(new TypeToken>(){}.getType(), userName); - callback.run(tokenList); - } + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + final List clients = new ArrayList<>(); + final NonFinalInteger resultsProcessed = new NonFinalInteger(); + int resultsFound = 0; + + while (resultSet.next()) + { + resultsFound++; + + int accountId = resultSet.getInt(0); + +// loadBans(_manager.getClientManager().) + + } + + System.out.println("Found: " + resultsFound + ", Processed: " + resultsProcessed); + } + }); }); - - asyncThread.start(); } - @Override protected void initialize() 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 94e53ba4d..cc2768c13 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 @@ -1,5 +1,6 @@ package mineplex.game.clans.clans.ban.commands; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; @@ -28,10 +29,8 @@ public class ClansBanCommand extends CommandBase { final String playerName = args[0]; - Plugin.LoadClient(playerName, client -> { - Plugin.cache(caller, playerName); - Plugin.getShop().attemptShopOpen(caller); - }); + Plugin.cache(caller, playerName); + Plugin.getShop().attemptShopOpen(caller); } else if (args.length > 2) { @@ -71,18 +70,21 @@ public class ClansBanCommand extends CommandBase if (target != null) { Plugin.LoadClient(playerName, client -> { - Plugin.ban(client, target.getName(), permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason); - UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + F.time(client.getBanTimeFormatted()) + ".")); - - Plugin.runSync(() -> target.kickPlayer(C.cRed + "You have been banned from Clans " + client.getBanTimeFormatted() + ".")); + Plugin.ban(client, target.getName(), permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason, c -> { + UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + F.time(c.getBanTimeFormatted()) + ".")); + Bukkit.broadcastMessage(F.main("Clans", F.elem(playerName) + " is now banned " + F.time(c.getBanTimeFormatted()) + ".")); + Plugin.runSync(() -> target.kickPlayer(C.cRedB + "You have been banned from Clans " + c.getBanTimeFormatted() + ".")); + }); }); return; } Plugin.LoadClient(playerName, client -> { - Plugin.ban(client, playerName, permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason); - UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + client.getBanTimeFormatted() + ".")); + Plugin.ban(client, playerName, permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason, c -> { + UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + c.getBanTimeFormatted() + ".")); + Bukkit.broadcastMessage(F.main("Clans", F.elem(playerName) + " is now banned " + F.time(c.getBanTimeFormatted()) + ".")); + }); }); } else diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanListCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanListCommand.java new file mode 100644 index 000000000..d4727bb4d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanListCommand.java @@ -0,0 +1,21 @@ +package mineplex.game.clans.clans.ban.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.game.clans.clans.ban.ClansBanManager; + +public class ClansBanListCommand extends CommandBase +{ + public ClansBanListCommand(ClansBanManager plugin) + { + super(plugin, Rank.ADMIN, "listbans"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + Plugin.getShop2().attemptShopOpen(caller); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListPage.java new file mode 100644 index 000000000..22c58a21d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListPage.java @@ -0,0 +1,32 @@ +package mineplex.game.clans.clans.ban.ui; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ban.ClansBanClient; +import mineplex.game.clans.clans.ban.ClansBanManager; + +public class ClansBanListPage extends ShopPageBase +{ + public ClansBanListPage(final ClansBanManager banManager, final ClansBanListShop shop, final CoreClientManager clientManager, final DonationManager donationManager, final String name, final Player player) + { + super(banManager, shop, clientManager, donationManager, name, player); + + buildPage(); + } + + protected void buildPage() + { + getPlugin().listRecordedNames(clients -> { + for (ClansBanClient client : clients) + { + } + }); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListShop.java new file mode 100644 index 000000000..d3086d620 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListShop.java @@ -0,0 +1,24 @@ +package mineplex.game.clans.clans.ban.ui; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ban.ClansBanManager; + +public class ClansBanListShop extends ShopBase +{ + public ClansBanListShop(final ClansBanManager plugin, final CoreClientManager clientManager, final DonationManager donationManager) + { + super(plugin, clientManager, donationManager, "Clans Punish"); + } + + @Override + protected ShopPageBase> buildPagesFor(final Player player) + { + return new ClansBanListPage(getPlugin(), this, getClientManager(), getDonationManager(), "Clans Punish", player); + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java index a3d7d3e6d..962ee17bf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java @@ -1,10 +1,17 @@ package mineplex.game.clans.clans.ban.ui; +import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ban.ClansBan; import mineplex.game.clans.clans.ban.ClansBanManager; public class ClansBanPage extends ShopPageBase @@ -18,6 +25,38 @@ public class ClansBanPage extends ShopPageBase protected void buildPage() { + String name = getPlugin().getCachedName(getPlayer()); + getPlugin().LoadClient(name, client -> { + int slot = 0; + + for (ClansBan ban : client.Bans) + { + ItemStack item = + new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK) + .setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive") + + .addLore(" ") + .addLore("Date banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime())) + .addLore("Time left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None")) + .addLore("Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No")) + .addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16) + .addLore("Is Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No")) + .addLore(!ban.isActive() ? null : C.cDAqua + "Left-Click to disable ban") + + .build(); + + if (ban.isActive()) + { + UtilInv.addDullEnchantment(item); + } + + addButton(slot++, item, (player, click) -> { + if (ban.isActive()) + { + getPlugin().unban(client, ban, name, c -> refresh()); + } + }); + } + }); } - } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java index 7b023c9c7..f24554858 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java @@ -12,12 +12,13 @@ public class ClansBanShop extends ShopBase { public ClansBanShop(final ClansBanManager plugin, final CoreClientManager clientManager, final DonationManager donationManager) { - super(plugin, clientManager, donationManager, "Customize New Gear"); + super(plugin, clientManager, donationManager, "Clans Punish"); } @Override protected ShopPageBase> buildPagesFor(final Player player) { - return new ClansBanPage(getPlugin(), this, getClientManager(), getDonationManager(), "Customize New Gear", player); + return new ClansBanPage(getPlugin(), this, getClientManager(), getDonationManager(), "Clans Punish", player); } + } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/Meow.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/Meow.java new file mode 100644 index 000000000..738392939 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/Meow.java @@ -0,0 +1,22 @@ +package mineplex.game.clans.clans.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.game.clans.clans.outpost.OutpostManager; +import mineplex.game.clans.clans.outpost.OutpostType; + +public class Meow extends CommandBase +{ + public Meow(OutpostManager plugin) + { + super(plugin, Rank.ALL, "meow"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.Spawn(caller, caller.getLocation().getBlock().getLocation(), OutpostType.ORIGINAL_CLANS); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java new file mode 100644 index 000000000..daffa920d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java @@ -0,0 +1,257 @@ +package mineplex.game.clans.clans.outpost; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.FallingBlock; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LoopIterator; +import mineplex.core.common.util.NonFinalInteger; +import mineplex.core.common.util.RGBData; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilColor; +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.UtilServer; +import mineplex.core.hologram.Hologram; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansBlacklist; +import mineplex.game.clans.core.repository.ClanTerritory; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; + +public class Outpost +{ + private final List _coreParticleColors = new ArrayList(); + + protected static final long MAX_LIFETIME = 60 * 1000; // 30 minutes + + private OutpostManager _host; + + private ClanInfo _clan; + + private Location _startCorner; + private Location _middle; + private Location _endCorner; + + private Location _core; + + private LinkedHashMap _blocks; + private LinkedHashMap _buildQueue; + + private OutpostType _type; + private OutpostState _state; + + private LoopIterator _circleStages; + private LoopIterator _reverseCircleStages; + + private long _spawnTime; + + private long _lastConstructionSound; + + public Outpost(OutpostManager host, ClanInfo clan, Location location, OutpostType type) + { + _host = host; + + _clan = clan; + + _startCorner = location.clone().subtract(type._size, 1, type._size); + _endCorner = location.clone().add(type._size, type._ySize - 1, type._size); + + _middle = location.clone(); + + _type = type; + + _spawnTime = System.currentTimeMillis(); + + _coreParticleColors.add(UtilColor.hexToRgb(0x00A296)); + _coreParticleColors.add(UtilColor.hexToRgb(0x29E6B6)); + _coreParticleColors.add(UtilColor.hexToRgb(0x29E67B)); + + beginConstruction(); + } + + private void cleanup() + { + _blocks = null; + + _state = OutpostState.DEAD; + + _host.queueForRemoval(_clan.getName()); + } + + protected void update() + { + if (_state == OutpostState.CONSTRUCTING) + { + if (_buildQueue.isEmpty()) + { + _state = OutpostState.LIVE; + + return; + } + else + { + Iterator iterator = _buildQueue.keySet().iterator(); + + if (iterator.hasNext()) + { + _buildQueue.remove(iterator.next()).set(); + } + } + } + + { + RGBData color = _state == OutpostState.LIVE ? UtilMath.randomElement(_coreParticleColors) : UtilColor.RgbRed; + + Vector nextCircleStage = _circleStages.next(); + + double circleX = nextCircleStage.getX(); + double circleZ = nextCircleStage.getZ(); + + UtilParticle.PlayParticleToAll(ParticleType.MOB_SPELL, _core.clone().add(circleX + .5, 1.1d, circleZ + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 5.f, 0, ViewDist.NORMAL); + } + + { + RGBData color = _state == OutpostState.LIVE ? UtilMath.randomElement(_coreParticleColors) : UtilColor.RgbRed; + + Vector nextCircleStage = _reverseCircleStages.next(); + + double circleX = nextCircleStage.getX(); + double circleZ = nextCircleStage.getZ(); + + UtilParticle.PlayParticleToAll(ParticleType.MOB_SPELL, _core.clone().add(circleX + .5, 1.1d, circleZ + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 5.f, 0, ViewDist.NORMAL); + } + } + + public void beginConstruction() + { + _state = OutpostState.CONSTRUCTING; + _blocks = new LinkedHashMap<>(_buildQueue = _type.createBuildQueue(_middle, _clan.Clans)); + + _core = _type.getCoreLocation(_middle); + + _circleStages = new LoopIterator(circleAround(new Vector(0., 0., 0.), 40, .6d)); + + List reverse = circleAround(new Vector(0., 0., 0.), 40, .6d); + Collections.reverse(reverse); + _reverseCircleStages = new LoopIterator(reverse); + + //Inform nearby Clans + for (int chunkX = -3; chunkX < 3; chunkX++) + { + for (int chunkZ = -3; chunkZ < 3; chunkZ++) + { + ClanTerritory territory = _clan.Clans.getClanUtility().getClaim(_middle.getWorld().getChunkAt(_middle.getChunk().getX() + chunkX, _middle.getChunk().getZ() + chunkZ)); + + if (territory != null && ClansBlacklist.isValidClanName(territory.Owner)) + { + ClanInfo clan = _clan.Clans.getClanUtility().getClanByClanName(territory.Owner); + + clan.inform("A siege has begun near your territory!", null); + } + } + } + } + + private List circleAround(Vector origin, int points, double radius) + { + List list = new LinkedList<>(); + + double slice = 2 * Math.PI / points; + + for (int point = 0; point < points; point++) + { + double angle = slice * point; + list.add(new Vector(origin.getX() + radius * Math.cos(angle), 0, origin.getZ() + radius * Math.sin(angle))); + } + + return list; + } + + public void kill() + { + _state = OutpostState.DESTRUCTING; + + UtilServer.getPlayersCollection().stream().filter(p -> p.getLocation().distance(_middle) < 64).forEach(p -> { + NonFinalInteger wait = new NonFinalInteger(0); + + _blocks.values().forEach(block -> { + if (UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean()) + { + return; + } + + _host.runSyncLater(() -> { + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, block._loc, new Vector(0,0,0), 0.1f, 3, ViewDist.LONG, p); + p.playSound(block._loc, Sound.EXPLODE, 1.0f, 1.0f); + }, wait.add(4 + UtilMath.random.nextInt(10)).get()); + }); + + _host.runSyncLater(() -> { + _blocks.values().forEach(block -> { + Material mat = Material.getMaterial(block._id); + + if (UtilItem.isTranslucent(mat)) + { + block.restore(); + return; + } + + FallingBlock fall = block._loc.getWorld().spawnFallingBlock(block._loc, block._id, block._data); + + Vector vec = UtilAlg.getTrajectory(fall.getLocation(), _middle); + + UtilAction.velocity(fall, vec, 1, false, 0, 0.6, 10, false); + + fall.setMetadata("ClansOutpost", new FixedMetadataValue(_clan.Clans.getPlugin(), _clan.getName())); + + block.restore(); + }); + + cleanup(); + }, wait.get() + 5L); + }); + + _clan.inform("Your Clan's Outpost has been destroyed.", null); + } + + public ClanInfo getClan() + { + return _clan; + } + + public long getLifetime() + { + return System.currentTimeMillis() - _spawnTime; + } + + public AxisAlignedBB getBounds() + { + return UtilAlg.toBoundingBox(_startCorner, _endCorner); + } + + public Location getExactMiddle() + { + return UtilAlg.getMidpoint(_startCorner, _endCorner); + } + + public OutpostState getState() + { + return _state; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBlock.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBlock.java new file mode 100644 index 000000000..e28c650fb --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBlock.java @@ -0,0 +1,59 @@ +package mineplex.game.clans.clans.outpost; + +import java.util.Map; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.BlockState; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilWorld; + +public class OutpostBlock +{ + protected Location _loc; + protected int _id; + protected byte _data; + + protected int _originalId; + protected byte _originalData; + + public OutpostBlock(Map blocks, Location loc, int id, byte data) + { + _loc = loc; + _id = id; + _data = data; + + String locStr = UtilWorld.locToStr(loc); + + if (blocks.containsKey(locStr)) + { + _originalId = blocks.get(locStr)._originalId; + _originalData = blocks.get(locStr)._originalData; + } + else + { + _originalId = _loc.getBlock().getTypeId(); + _originalData = _loc.getBlock().getData(); + } + } + + public void set() + { + _loc.getBlock().setTypeIdAndData(_id, _data, false); + if (_id != 0) + { + _loc.getWorld().playEffect(_loc, Effect.STEP_SOUND, Material.getMaterial(_id), 10); + } + } + + public void restore() + { + BlockState state = _loc.getBlock().getState(); + state.setTypeId(_originalId); + state.setRawData(_originalData); + state.update(true, false); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java new file mode 100644 index 000000000..31c973d30 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java @@ -0,0 +1,171 @@ +package mineplex.game.clans.clans.outpost; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.metadata.FixedMetadataValue; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; + +public class OutpostManager extends MiniPlugin +{ + private ClansManager _clansManager; + + private Map _outposts = new HashMap<>(); + + private List _removalQueue; + + public OutpostManager(ClansManager clansManager) + { + super("Outpost Manager", clansManager.getPlugin()); + + _clansManager = clansManager; + + _removalQueue = new ArrayList<>(); + } + + public void Spawn(Player player, Location location, OutpostType type) + { + if (!_clansManager.isInClan(player)) + { + UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place an Outpost.")); + return; + } + + if (location.getBlockY() < 10) + { + UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost this deep.")); + return; + } + + ClanInfo clan = _clansManager.getClan(player); + + if (UtilItem.isBoundless(location.clone().subtract(0, 1, 0).getBlock().getType())) + { + UtilPlayer.message(player, F.main("Clans", "An Outpost must not be placed floating.")); + return; + } + + if (Get(clan) != null) + { + UtilPlayer.message(player, F.main("Clans", "Your clan already has an outpost")); + return; + } + + if (_clansManager.getClanUtility().getClaim(location) != null) + { + UtilPlayer.message(player, F.main("Clans", "An Outpost must be placed in the Wilderness.")); + return; + } + + for (Outpost outpost : _outposts.values()) + { + if (UtilMath.offset(location, outpost.getExactMiddle()) < 10) + { + UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost near other Outposts.")); + return; + } + } + + for (int x = -type._size; x < type._size; x++) + { + for (int y = -1; y < type._ySize; y++) + { + for (int z = -type._size; z < type._size; z++) + { + Location loc = location.clone(); + + if (_clansManager.getClanUtility().isClaimed(loc)) + { + UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost where it may intersect with claimed territory.")); + return; + } + } + } + } + + _outposts.put(clan.getName(), new Outpost(this, clan, location, type)); + } + + @EventHandler + public void onBlockFall(EntityChangeBlockEvent event) + { + if (event.getEntity().hasMetadata("ClansOutpost")) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onClaim(PlayerClaimTerritoryEvent event) + { + for (Outpost outpost : _outposts.values()) + { + if (outpost.getBounds().b(UtilAlg.toBoundingBox(event.getClaimedChunk().getBlock(0, 0, 0).getLocation(), event.getClaimedChunk().getBlock(15, 254, 15).getLocation()))) + { + event.setCancelled(true); + UtilPlayer.message(event.getClaimer(), F.main("Clans", "You cannot claim this territory as it overlaps with a " + F.elem(outpost.getClan().getName()) + "'s Outpost.")); + break; + } + } + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + { + for (Outpost outpost : _outposts.values()) + { + if (outpost.getState() != OutpostState.DEAD) + { + outpost.update(); + } + } + + if (!_removalQueue.isEmpty()) + { + _outposts.remove(_removalQueue.remove(0)); + } + } + + if (event.getType() == UpdateType.TWOSEC) + { + for (Outpost outpost : _outposts.values()) + { + if (outpost.getState() == OutpostState.LIVE && outpost.getLifetime() > Outpost.MAX_LIFETIME) + { + outpost.kill(); + } + } + } + } + + public Outpost Get(ClanInfo clan) + { + return _outposts.get(clan.getName().toLowerCase()); + } + + public void queueForRemoval(String name) + { + _removalQueue.add(name); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostState.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostState.java new file mode 100644 index 000000000..71374c64b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostState.java @@ -0,0 +1,9 @@ +package mineplex.game.clans.clans.outpost; + +public enum OutpostState +{ + CONSTRUCTING, + LIVE, + DESTRUCTING, + DEAD; +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostType.java new file mode 100644 index 000000000..1f1defe1a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostType.java @@ -0,0 +1,226 @@ +package mineplex.game.clans.clans.outpost; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.bukkit.Location; +import org.bukkit.Material; + +import mineplex.core.common.util.UtilWorld; +import mineplex.game.clans.clans.ClansManager; + +public enum OutpostType +{ + ORIGINAL_CLANS(3, 6) { + public LinkedHashMap createBuildQueue(Location location, ClansManager clans) + { + LinkedHashMap build = new LinkedHashMap<>(); + + for (int y = -1; y <= _ySize; y++) + { + for (int x = -_size; x <= _size; x++) + { + for (int z = -_size; z <= _size; z++) + { + Location loc = new Location(location.getWorld(), location.getX()+x, location.getY()+y, location.getZ()+z); + + if (clans.getClanUtility().isClaimed(loc)) + { + continue; + } + + boolean added = false; + + //Floor + if (y == -1 && Math.abs(x) <= _size-1 && Math.abs(z) <= _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 98, (byte)0)); + added = true; + } + + //Walls + if (Math.abs(x) == _size || Math.abs(z) == _size) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 98, (byte)0)); + added = true; + } + + //Roof + if (y == 5 && Math.abs(x) <= _size-1 && Math.abs(z) <= _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 44, (byte)13)); + added = true; + } + + //Clear + if (!added) + { + if (loc.getBlock().getTypeId() != 0) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 0, (byte) 0)); + } + } + } + } + } + + for (int y= -1; y <= _ySize; y++) + { + for (int x = -_size; x <= _size; x++) + { + for (int z = -_size; z <= _size; z++) + { + Location loc = new Location(location.getWorld(), location.getX()+x, location.getY()+y, location.getZ()+z); + + if (clans.getClanUtility().isClaimed(loc)) + { + continue; + } + + //Doors + if (y == 0 || y == 1) + { + if (x == 0 && z == _size) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 71, (byte)(y * 8 + 2 + 4))); + } + + if (x == 0 && z == -_size) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 71, (byte)(y * 8 + 4))); + } + + if (x == _size && z == 0) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 71, (byte)(y * 8 + 3 + 4))); + } + + if (x == -_size && z == 0) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 71, (byte)(y * 8 + 1 + 4))); + } + } + + //Platform + if (y == 2) + { + if (Math.abs(x) == _size-1 && Math.abs(z) < _size) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 44, (byte)13)); + } + + if (Math.abs(z) == _size-1 && Math.abs(x) < _size) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 44, (byte)13)); + } + } + + //Windows + if (y == 4) + { + if (Math.abs(x) == _size && Math.abs(z) < _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 0, (byte)0)); + } + + if (Math.abs(z) == _size && Math.abs(x) < _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 0, (byte)0)); + } + } + + //Ladders + if (y >= 0 && y < 3) + { + if (x == _size-1 && z == _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 65, (byte)2)); + } + + if (x == (-_size)+1 && z == (-_size)+1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 65, (byte)3)); + } + } + + //Chests + if (y == 0) + { + if (x == _size-1 && z == (-_size)+1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 54, (byte)0)); + } + + if (x == (-_size)+1 && z == _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 54, (byte)0)); + } + + if (x == _size-2 && z == (-_size)+1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 54, (byte)0)); + } + + if (x == (-_size)+2 && z == _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 54, (byte)0)); + } + } + + //Beacon Floor + if (y == -1) + { + if (Math.abs(x) <= 1 && Math.abs(z) <= 1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 42, (byte)0)); + } + } + + //Beacon Roof + if (y == 5) + { + if (Math.abs(x) == 1 && Math.abs(z) <= 1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 98, (byte)0)); + } + + if (Math.abs(z) == 1 && Math.abs(x) <= 1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 98, (byte)0)); + } + } + + //Beacon Glass + if (y == 5 && x == 0 && z == 0) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 20, (byte)0)); + } + } + } + } + + //Core + build.put(UtilWorld.locToStr(getCoreLocation(location)), new OutpostBlock(build, getCoreLocation(location), Material.DIAMOND_BLOCK.getId(), (byte)0)); + + return build; + } + + public Location getCoreLocation(Location location) + { + return location.clone().subtract(0, 1, 0); + } + }; + + protected int _size; + protected int _ySize; + + OutpostType(int size, int ySize) + { + _size = size; + _ySize = ySize; + } + + public abstract LinkedHashMap createBuildQueue(Location location, ClansManager clans); + + public abstract Location getCoreLocation(Location location); +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java index 21cf7f5cb..3de03eadd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java @@ -211,7 +211,7 @@ public class ClansRegions extends MiniPlugin if (_manager.getClaimMap().containsKey(chunkStr)) { - System.out.println("get claim map contains " + chunkStr); + System.out.println("get claim map contains " + chunkStr); // this is really really slowing server startup down. just saying. continue; } 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 26a3fd81f..46be8ef61 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -1,9 +1,5 @@ package mineplex.game.clans.gameplay; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -43,7 +39,7 @@ import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent.State; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; @@ -293,32 +289,6 @@ public class Gameplay extends MiniPlugin if (event.getBlock().getType() == Material.WEB) event.setInstaBreak(true); } - // sammy needs this for catching exploiters. we need it NOW. no more time to waste. - // do not delete please. - // - garbo - // "if you delete this code, i will murder you" - Sammy - @EventHandler - public void PlayerKick(final PlayerKickEvent event) - { - if (event.getReason().equals("You logged in from another location")) - { - runAsync(new Runnable() { - public void run() - { - try - { - URLConnection con = new URL("http://garblox.com/exploiter.php?name=" + event.getPlayer().getName() + "&uuid=" + event.getPlayer().getUniqueId().toString() + "&date=" + System.currentTimeMillis() + "&server=" + _clansManager.getServerName()).openConnection(); - con.getInputStream().close(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - }); - } - } - @EventHandler public void LapisPlace(BlockPlaceEvent event) { @@ -502,15 +472,9 @@ public class Gameplay extends MiniPlugin } @EventHandler - public void killRain(UpdateEvent event) + public void killRain(WeatherChangeEvent event) { - if (event.getType() != UpdateType.TWOSEC){ - for (World world : Bukkit.getWorlds()){ - world.setWeatherDuration(0); - world.setThunderDuration(0); - world.setThundering(false); - } - } + event.setCancelled(event.toWeatherState()); } @EventHandler 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 9539a639e..167d189b1 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 @@ -10,7 +10,6 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilFile; import mineplex.core.common.util.UtilFile.ChunkType; @@ -19,8 +18,8 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; -import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; public class SafeLog extends MiniPlugin @@ -96,8 +95,7 @@ public class SafeLog extends MiniPlugin @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - event.setQuitMessage(null); - UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName())); + event.setQuitMessage(F.sys("Quit", event.getPlayer().getName())); onPlayerQuit(event.getPlayer()); } @@ -105,8 +103,7 @@ public class SafeLog extends MiniPlugin @EventHandler public void onPlayerKicked(PlayerKickEvent event) { - event.setLeaveMessage(null); - UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName())); + event.setLeaveMessage(F.sys("Quit", event.getPlayer().getName())); onPlayerQuit(event.getPlayer()); } @@ -115,7 +112,6 @@ public class SafeLog extends MiniPlugin public void onPlayerJoin(PlayerJoinEvent event) { event.setJoinMessage(null); - UtilServer.broadcast(F.sys("Join", event.getPlayer().getName())); onPlayerJoin(event.getPlayer()); } diff --git a/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/clans/ClansOutpost.java b/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/clans/ClansOutpost.java index a120c8bfa..79061f49c 100644 --- a/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/clans/ClansOutpost.java +++ b/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/clans/ClansOutpost.java @@ -34,7 +34,6 @@ public class ClansOutpost public void Build() { - _build = new ArrayList(); for (int y=-1 ; y <= 6 ; y++) From 03c6395a30245dd6b5a050336deb21fc2affc445 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Sat, 2 Jan 2016 23:30:27 +0200 Subject: [PATCH 27/65] Turf Wars: Fix sneaking near turf edge and wool placement near ladders. --- .gitignore | 2 + .../game/games/turfforts/TurfForts.java | 46 +++++++++++++++++-- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 36fe02146..3a4cc1661 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,5 @@ zSotanna2 /.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments_1 /.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/write.lock /Pocket +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_ +/RemoteSystemsTempFiles diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index 9494c868e..010d1a86c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -4,7 +4,6 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.UUID; @@ -19,13 +18,13 @@ import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArrow; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Arrow; -import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityShootBowEvent; @@ -34,8 +33,6 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; -import net.minecraft.server.v1_8_R3.EntityArrow; -import net.minecraft.server.v1_8_R3.Item; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; @@ -53,7 +50,6 @@ import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; @@ -694,6 +690,32 @@ public class TurfForts extends TeamGame continue; Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); + + // Apply velocity even if the player is sneaking near turf edges. + + if (block.isEmpty()) + { + Block[] nearby = { + block.getRelative(BlockFace.NORTH), + block.getRelative(BlockFace.SOUTH), + block.getRelative(BlockFace.WEST), + block.getRelative(BlockFace.EAST), + block.getRelative(BlockFace.NORTH_EAST), + block.getRelative(BlockFace.NORTH_WEST), + block.getRelative(BlockFace.SOUTH_EAST), + block.getRelative(BlockFace.SOUTH_WEST) + }; + + for (Block near : nearby) + { + if (near.getTypeId() == 159) + { + block = near; + break; + } + } + } + while (block.getTypeId() != 159 && block.getY() > 0) block = block.getRelative(BlockFace.DOWN); @@ -815,4 +837,18 @@ public class TurfForts extends TeamGame { return _enemyTurf.get(player); } + + @EventHandler + public void onBlockPhysics(BlockPhysicsEvent event) + { + if (!IsLive()) + return; + + Block block = event.getBlock(); + + if (block.getType() == Material.LADDER) + { + event.setCancelled(true); + } + } } From f6ce98f65b1ed3d903691d7478404b8af855274d Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Sat, 2 Jan 2016 23:33:08 +0200 Subject: [PATCH 28/65] Turf Wars: Add comment on block physics event. --- .../nautilus/game/arcade/game/games/turfforts/TurfForts.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index 010d1a86c..3c477c9c6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -838,6 +838,8 @@ public class TurfForts extends TeamGame return _enemyTurf.get(player); } + // Keep ladders placed on ice when block updates occur. + @EventHandler public void onBlockPhysics(BlockPhysicsEvent event) { From 47c78bcba184cb244af0783ec8bbfec362d50294 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Mon, 4 Jan 2016 17:19:40 +0200 Subject: [PATCH 29/65] Turf Wars: Apply knockback on all players when there are only two in the match. --- .gitignore | 1 + .../game/games/turfforts/TurfForts.java | 528 +++++++----------- 2 files changed, 211 insertions(+), 318 deletions(-) diff --git a/.gitignore b/.gitignore index 3a4cc1661..eff674339 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,4 @@ zSotanna2 /Pocket /.recommenders/index/http___download_eclipse_org_recommenders_models_mars_ /RemoteSystemsTempFiles +/.recommenders/caches diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index 3c477c9c6..c33335dc4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -62,34 +62,28 @@ import nautilus.game.arcade.stats.BlockShreadStatTracker; import nautilus.game.arcade.stats.TheComebackStatTracker; import net.minecraft.server.v1_8_R3.EntityArrow; -public class TurfForts extends TeamGame -{ - public static class ShredBlockEvent extends BlockEvent - { +public class TurfForts extends TeamGame { + public static class ShredBlockEvent extends BlockEvent { private static final HandlerList handlers = new HandlerList(); - public static HandlerList getHandlerList() - { + public static HandlerList getHandlerList() { return handlers; } @Override - public HandlerList getHandlers() - { + public HandlerList getHandlers() { return getHandlerList(); } private final Arrow _arrow; - public ShredBlockEvent(Block theBlock, Arrow arrow) - { + public ShredBlockEvent(Block theBlock, Arrow arrow) { super(theBlock); _arrow = arrow; } - public Arrow getArrow() - { + public Arrow getArrow() { return _arrow; } } @@ -110,29 +104,18 @@ public class TurfForts extends TeamGame private long _fightTime = 90000; private boolean _fight = false; private int _lines = 0; - + private HashMap _enemyTurf = new HashMap(); - + private Set playersThatNeedBlocks = new HashSet(); - - public TurfForts(ArcadeManager manager) - { + + public TurfForts(ArcadeManager manager) { super(manager, GameType.TurfWars, - new Kit[] - { - new KitMarksman(manager), - new KitInfiltrator(manager), - new KitShredder(manager), - }, + new Kit[] { new KitMarksman(manager), new KitInfiltrator(manager), new KitShredder(manager), }, - new String[] - { - "You have 30 seconds to build your Fort!", - "", - "Each kill advances your turf forwards.", - "Take over all the turf to win!" - }); + new String[] { "You have 30 seconds to build your Fort!", "", "Each kill advances your turf forwards.", + "Take over all the turf to win!" }); this.StrictAntiHack = true; this.HungerSet = 20; @@ -144,16 +127,12 @@ public class TurfForts extends TeamGame this.DamageSelf = false; this.DeathSpectateSecs = 4; - registerStatTrackers( - new BlockShreadStatTracker(this), - new BehindEnemyLinesStatTracker(this), - new TheComebackStatTracker(this) - ); + registerStatTrackers(new BlockShreadStatTracker(this), new BehindEnemyLinesStatTracker(this), + new TheComebackStatTracker(this)); } @Override - public void ParseData() - { + public void ParseData() { _turf = WorldData.GetDataLocs("YELLOW"); _red = WorldData.GetDataLocs("RED").get(0); @@ -162,15 +141,18 @@ public class TurfForts extends TeamGame _blue = WorldData.GetDataLocs("BLUE").get(0); _blueBase = WorldData.GetDataLocs("LIGHT_BLUE").get(0); - if (_red.getBlockX() > _blue.getBlockX()) xRed = 1; - else if (_red.getBlockX() < _blue.getBlockX()) xRed = -1; + if (_red.getBlockX() > _blue.getBlockX()) + xRed = 1; + else if (_red.getBlockX() < _blue.getBlockX()) + xRed = -1; - if (_red.getBlockZ() > _blue.getBlockZ()) zRed = 1; - else if (_red.getBlockZ() < _blue.getBlockZ()) zRed = -1; + if (_red.getBlockZ() > _blue.getBlockZ()) + zRed = 1; + else if (_red.getBlockZ() < _blue.getBlockZ()) + zRed = -1; - //Color Turf - for (Location loc : _turf) - { + // Color Turf + for (Location loc : _turf) { if (UtilMath.offset(loc, _red) < UtilMath.offset(loc, _blue)) MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14); else @@ -179,8 +161,7 @@ public class TurfForts extends TeamGame } @EventHandler - public void PlayerKillAward(CombatDeathEvent event) - { + public void PlayerKillAward(CombatDeathEvent event) { if (!(event.GetEvent().getEntity() instanceof Player)) return; @@ -202,26 +183,19 @@ public class TurfForts extends TeamGame if (GetTeam(killer).equals(GetTeam(killed))) return; - if (GetTeam(killer).GetColor() == ChatColor.RED) - { + if (GetTeam(killer).GetColor() == ChatColor.RED) { TurfMove(true); - } - else - { + } else { TurfMove(false); } } - private void TurfMove(boolean red) - { - for (int line = 0; line < GetLinesPerKill(); line++) - { - if (red) - { + private void TurfMove(boolean red) { + for (int line = 0; line < GetLinesPerKill(); line++) { + if (red) { if (xRed != 0) for (Location loc : _turf) - if (loc.getBlockX() == _blue.getBlockX()) - { + if (loc.getBlockX() == _blue.getBlockX()) { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14); for (int i = 1; i < 6; i++) @@ -229,11 +203,9 @@ public class TurfForts extends TeamGame MapUtil.QuickChangeBlockAt(loc.clone().add(0, i, 0), 0, (byte) 0); } - if (zRed != 0) for (Location loc : _turf) - if (loc.getBlockZ() == _blue.getBlockZ()) - { + if (loc.getBlockZ() == _blue.getBlockZ()) { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14); for (int i = 1; i < 6; i++) @@ -243,13 +215,10 @@ public class TurfForts extends TeamGame _red.subtract(xRed, 0, zRed); _blue.subtract(xRed, 0, zRed); - } - else - { + } else { if (xRed != 0) for (Location loc : _turf) - if (loc.getBlockX() == _red.getBlockX()) - { + if (loc.getBlockX() == _red.getBlockX()) { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 3); for (int i = 1; i < 6; i++) @@ -259,8 +228,7 @@ public class TurfForts extends TeamGame if (zRed != 0) for (Location loc : _turf) - if (loc.getBlockZ() == _red.getBlockZ()) - { + if (loc.getBlockZ() == _red.getBlockZ()) { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 3); for (int i = 1; i < 6; i++) @@ -275,94 +243,84 @@ public class TurfForts extends TeamGame EndCheck(); } } - + @EventHandler - public void BowCancel(EntityShootBowEvent event) - { - if (!_fight) - { + public void BowCancel(EntityShootBowEvent event) { + if (!_fight) { UtilPlayer.message(event.getEntity(), F.main("Game", "You cannot attack during Build Time!")); event.setCancelled(true); - + ((Player) event.getEntity()).updateInventory(); } } @EventHandler - public void BlockBreak(BlockBreakEvent event) - { - if (event.isCancelled()) // this statement might save just a small amount of time + public void BlockBreak(BlockBreakEvent event) { + if (event.isCancelled()) // this statement might save just a small + // amount of time return; - - - - if (!IsAlive(event.getPlayer())) - { + + if (!IsAlive(event.getPlayer())) { event.setCancelled(true); return; } - if (UtilPlayer.isSpectator(event.getPlayer())) - { + if (UtilPlayer.isSpectator(event.getPlayer())) { event.setCancelled(true); return; } - + Block block = event.getBlock(); - + GameTeam team = GetTeam(event.getPlayer()); GameTeam otherTeam = GetOtherTeam(team); - if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA)) - { - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!")); + if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) + || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA)) { + UtilPlayer.message(event.getPlayer(), F.main("Game", + "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!")); event.setCancelled(true); return; } } @EventHandler(ignoreCancelled = true) - public void BlockPlace(BlockPlaceEvent event) - { - //Remoeved and replaced by ignoreCancelled = true - //if (event.isCancelled()) - // return; + public void BlockPlace(BlockPlaceEvent event) { + // Remoeved and replaced by ignoreCancelled = true + // if (event.isCancelled()) + // return; GameTeam team = GetTeam(event.getPlayer()); - if (team == null) - { + if (team == null) { event.setCancelled(true); return; } - if (!IsAlive(event.getPlayer())) - { + if (!IsAlive(event.getPlayer())) { event.setCancelled(true); return; } - if (UtilPlayer.isSpectator(event.getPlayer())) - { + if (UtilPlayer.isSpectator(event.getPlayer())) { event.setCancelled(true); return; } - - //On Own + + // On Own Block block = event.getBlock().getRelative(BlockFace.DOWN); while (block.getTypeId() == 0) block = block.getRelative(BlockFace.DOWN); - if (block.getData() != team.GetColorData()) - { - UtilPlayer.message(event.getPlayer(), F.main("Game", "You can only build above " + F.elem(team.GetColor() + team.GetName()) + ".")); + if (block.getData() != team.GetColorData()) { + UtilPlayer.message(event.getPlayer(), + F.main("Game", "You can only build above " + F.elem(team.GetColor() + team.GetName()) + ".")); event.setCancelled(true); return; } - //Height + // Height boolean aboveTurf = false; - for (int i = 1; i <= 5; i++) - { + for (int i = 1; i <= 5; i++) { if (event.getBlock().getRelative(BlockFace.DOWN, i).getTypeId() != 159) continue; @@ -370,8 +328,7 @@ public class TurfForts extends TeamGame break; } - if (!aboveTurf) - { + if (!aboveTurf) { UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot build this high above Turf.")); event.setCancelled(true); return; @@ -379,8 +336,7 @@ public class TurfForts extends TeamGame } @EventHandler - public void BlockDamage(ProjectileHitEvent event) - { + public void BlockDamage(ProjectileHitEvent event) { if (event.getEntity().getShooter() == null) return; @@ -397,12 +353,9 @@ public class TurfForts extends TeamGame final Arrow arrow = (Arrow) event.getEntity(); - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - try - { + Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() { + public void run() { + try { EntityArrow entityArrow = ((CraftArrow) arrow).getHandle(); Field fieldX = EntityArrow.class.getDeclaredField("d"); @@ -418,28 +371,29 @@ public class TurfForts extends TeamGame int z = fieldZ.getInt(entityArrow); Block block = arrow.getWorld().getBlockAt(x, y, z); - - if (block.getTypeId() == 35) - { - if (block.getData() == 14 /* && team.GetColor() != ChatColor.RED */) - { - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId()); + + if (block.getTypeId() == 35) { + if (block.getData() == 14 /* + * && team.GetColor() != + * ChatColor.RED + */) { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, + Material.REDSTONE_BLOCK.getId()); + } else if (block.getData() == 3 /* + * && team.GetColor() != + * ChatColor.AQUA + */) { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, + Material.LAPIS_BLOCK.getId()); } - else if (block.getData() == 3 /* && team.GetColor() != ChatColor.AQUA */) - { - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId()); - } - + Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow)); - - + block.setType(Material.AIR); } arrow.remove(); - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } @@ -447,64 +401,51 @@ public class TurfForts extends TeamGame } @EventHandler - public void Damage(CustomDamageEvent event) - { - if (event.GetCause() == DamageCause.FALL) - { + public void Damage(CustomDamageEvent event) { + if (event.GetCause() == DamageCause.FALL) { event.SetCancelled("No Fall"); return; } - if (!_fight && (event.GetCause() == DamageCause.PROJECTILE || event.GetCause() == DamageCause.ENTITY_ATTACK)) - { + if (!_fight && (event.GetCause() == DamageCause.PROJECTILE || event.GetCause() == DamageCause.ENTITY_ATTACK)) { event.SetCancelled("Build Time"); return; } Player damager = event.GetDamagerPlayer(true); - if (damager == null) return; + if (damager == null) + return; - if (event.GetCause() == DamageCause.PROJECTILE) - { + if (event.GetCause() == DamageCause.PROJECTILE) { event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false); - if (GetKit(damager).GetName().contains("Shredder")) - { + if (GetKit(damager).GetName().contains("Shredder")) { event.SetCancelled("Shredder"); - Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, - DamageCause.CUSTOM, 9, true, true, false, - damager.getName(), "Barrage"); + Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, DamageCause.CUSTOM, 9, true, + true, false, damager.getName(), "Barrage"); return; - } - else - { + } else { event.AddMod("Turf Forts", "One Hit Kill", 30, false); } - } - else if (event.GetCause() == DamageCause.ENTITY_ATTACK) - { + } else if (event.GetCause() == DamageCause.ENTITY_ATTACK) { event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false); - if (UtilGear.isMat(damager.getItemInHand(), Material.IRON_SWORD)) - { + if (UtilGear.isMat(damager.getItemInHand(), Material.IRON_SWORD)) { event.AddMod("Turf Forts", "One Hit Kill", 12, false); - } - else - { + } else { event.AddMod("Turf Forts", "One Hit Kill", 6, false); } } } @EventHandler - public void ScoreboardTitle(UpdateEvent event) - { + public void ScoreboardTitle(UpdateEvent event) { if (GetState() != GameState.Live) return; - //2x Initial Build + // 2x Initial Build if (_phaseTime == 0) _phaseTime = System.currentTimeMillis() + _buildTime; @@ -512,48 +453,42 @@ public class TurfForts extends TeamGame return; long time; - if (!_fight) - { + if (!_fight) { time = _buildTime - (System.currentTimeMillis() - _phaseTime); - if (time <= 0) - { + if (time <= 0) { _fight = true; _lines++; Announce(" "); - Announce(C.cWhite + C.Bold + "1 Kill" + C.cWhite + C.Bold + " = " + C.cWhite + C.Bold + GetLinesPerKill() + " Turf Lines"); - Announce(C.cWhite + C.Bold + "90 Seconds of " + C.cYellow + C.Bold + "Combat Time" + C.cWhite + C.Bold + " has begun!"); + Announce(C.cWhite + C.Bold + "1 Kill" + C.cWhite + C.Bold + " = " + C.cWhite + C.Bold + + GetLinesPerKill() + " Turf Lines"); + Announce(C.cWhite + C.Bold + "90 Seconds of " + C.cYellow + C.Bold + "Combat Time" + C.cWhite + C.Bold + + " has begun!"); Announce(" "); _phaseTime = System.currentTimeMillis(); } } - else - { + else { time = _fightTime - (System.currentTimeMillis() - _phaseTime); - if (time <= 0) - { + if (time <= 0) { _fight = false; Announce(" "); - Announce(C.cWhite + C.Bold + "20 Seconds of " + C.cGreen + C.Bold + "Build Time" + C.cWhite + C.Bold + " has begun!"); + Announce(C.cWhite + C.Bold + "20 Seconds of " + C.cGreen + C.Bold + "Build Time" + C.cWhite + C.Bold + + " has begun!"); Announce(" "); _phaseTime = System.currentTimeMillis(); - for (GameTeam team : GetTeamList()) - { - for (Player player : team.GetPlayers(true)) - { - if (UtilPlayer.isSpectator(player)) - { + for (GameTeam team : GetTeamList()) { + for (Player player : team.GetPlayers(true)) { + if (UtilPlayer.isSpectator(player)) { this.playersThatNeedBlocks.add(player.getUniqueId()); - } - else - { + } else { addBlocks(team, player); } } @@ -561,52 +496,45 @@ public class TurfForts extends TeamGame } } } - - public void addBlocks(GameTeam team, Player player) - { + + public void addBlocks(GameTeam team, Player player) { player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOL, team.GetColorData(), 24)); } - + @EventHandler(ignoreCancelled = true) - public void onQuit(PlayerQuitEvent event) - { + public void onQuit(PlayerQuitEvent event) { this.playersThatNeedBlocks.remove(event.getPlayer().getUniqueId()); } - + @EventHandler(ignoreCancelled = true) - public void onSpawn(PlayerKitGiveEvent event) - { + public void onSpawn(PlayerKitGiveEvent event) { Player player = event.getPlayer(); - if (this.playersThatNeedBlocks.contains(player.getUniqueId())) - { + if (this.playersThatNeedBlocks.contains(player.getUniqueId())) { this.playersThatNeedBlocks.remove(player.getUniqueId()); this.addBlocks(GetTeam(player), player); } } - - - + @Override @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { + public void ScoreboardUpdate(UpdateEvent event) { if (event.getType() != UpdateType.FAST) return; Scoreboard.Reset(); - for (GameTeam team : this.GetTeamList()) - { + for (GameTeam team : this.GetTeamList()) { int lines = 0; - if (team.GetColor() == ChatColor.RED) lines = GetRedLines(); - else lines = GetBlueLines(); + if (team.GetColor() == ChatColor.RED) + lines = GetRedLines(); + else + lines = GetBlueLines(); Scoreboard.WriteBlank(); Scoreboard.Write(lines + " " + team.GetColor() + team.GetName()); } - if (!_fight) - { + if (!_fight) { long time = _buildTime - (System.currentTimeMillis() - _phaseTime); Scoreboard.WriteBlank(); @@ -615,8 +543,7 @@ public class TurfForts extends TeamGame } - else - { + else { long time = _fightTime - (System.currentTimeMillis() - _phaseTime); Scoreboard.WriteBlank(); @@ -627,95 +554,78 @@ public class TurfForts extends TeamGame Scoreboard.Draw(); } - public int GetRedLines() - { + public int GetRedLines() { if (!InProgress()) return 0; - if (xRed != 0) - { + if (xRed != 0) { return Math.abs(_redBase.getBlockX() - _red.getBlockX()); } return Math.abs(_redBase.getBlockZ() - _red.getBlockZ()); } - public int GetBlueLines() - { + public int GetBlueLines() { if (!InProgress()) return 0; - if (xRed != 0) - { + if (xRed != 0) { return Math.abs(_blueBase.getBlockX() - _blue.getBlockX()); } return Math.abs(_blueBase.getBlockZ() - _blue.getBlockZ()); } - public int getLines(GameTeam team) - { + public int getLines(GameTeam team) { if (team.GetColor() == ChatColor.RED) return GetRedLines(); else return GetBlueLines(); } - public int GetLinesPerKill() - { + public int GetLinesPerKill() { return _lines; - //return Math.min(5, 1 + (int)((System.currentTimeMillis() - GetStateTime() - 30000) / 60000)); + // return Math.min(5, 1 + (int)((System.currentTimeMillis() - + // GetStateTime() - 30000) / 60000)); } @EventHandler - public void PlayerDeath(PlayerDeathEvent event) - { + public void PlayerDeath(PlayerDeathEvent event) { _enemyTurf.remove(event.getEntity()); } @EventHandler - public void Territory(UpdateEvent event) - { + public void Territory(UpdateEvent event) { if (!IsLive()) return; if (event.getType() != UpdateType.FASTER) return; - for (GameTeam team : this.GetTeamList()) - { - for (Player player : team.GetPlayers(true)) - { - if (((CraftPlayer) player).getHandle().spectating) - continue; - + for (GameTeam team : this.GetTeamList()) { + for (Player player : team.GetPlayers(true)) { + if (((CraftPlayer) player).getHandle().spectating) + continue; + Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); - - // Apply velocity even if the player is sneaking near turf edges. - - if (block.isEmpty()) - { - Block[] nearby = { - block.getRelative(BlockFace.NORTH), - block.getRelative(BlockFace.SOUTH), - block.getRelative(BlockFace.WEST), - block.getRelative(BlockFace.EAST), - block.getRelative(BlockFace.NORTH_EAST), - block.getRelative(BlockFace.NORTH_WEST), - block.getRelative(BlockFace.SOUTH_EAST), - block.getRelative(BlockFace.SOUTH_WEST) - }; - - for (Block near : nearby) - { - if (near.getTypeId() == 159) - { + + // Apply velocity even if the player is sneaking near turf + // edges. + + if (block.isEmpty() && player.isOnGround()) { + Block[] nearby = { block.getRelative(BlockFace.NORTH), block.getRelative(BlockFace.SOUTH), + block.getRelative(BlockFace.WEST), block.getRelative(BlockFace.EAST), + block.getRelative(BlockFace.NORTH_EAST), block.getRelative(BlockFace.NORTH_WEST), + block.getRelative(BlockFace.SOUTH_EAST), block.getRelative(BlockFace.SOUTH_WEST) }; + + for (Block near : nearby) { + if (near.getType() == Material.STAINED_CLAY || near.getType() == Material.WOOL) { block = near; break; } } } - + while (block.getTypeId() != 159 && block.getY() > 0) block = block.getRelative(BlockFace.DOWN); @@ -724,22 +634,21 @@ public class TurfForts extends TeamGame byte data = block.getData(); - //Slow - if (_enemyTurf.containsKey(player)) - { + // Slow + if (_enemyTurf.containsKey(player)) { int time = (int) ((System.currentTimeMillis() - _enemyTurf.get(player)) / 2500); if (time > 0) - Manager.GetCondition().Factory().Slow("Infiltrator Slow", player, player, 0.9, time - 1, false, false, false, false); + Manager.GetCondition().Factory().Slow("Infiltrator Slow", player, player, 0.9, time - 1, false, + false, false, false); } - //On Enemy Turf - if ((team.GetColor() == ChatColor.RED && data == 3) || (team.GetColor() == ChatColor.AQUA && data == 14)) - { + // On Enemy Turf + if ((team.GetColor() == ChatColor.RED && data == 3) + || (team.GetColor() == ChatColor.AQUA && data == 14)) { - //Infiltrate - if (_fight && GetKit(player) != null && GetKit(player).GetName().contains("Infil")) - { + // Infiltrate + if (_fight && GetKit(player) != null && GetKit(player).GetName().contains("Infil")) { if (!_enemyTurf.containsKey(player)) _enemyTurf.put(player, System.currentTimeMillis()); @@ -747,79 +656,65 @@ public class TurfForts extends TeamGame continue; } - if (Recharge.Instance.use(player, "Territory Knockback", 2000, false, false)) - { - UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), team.GetSpawn()), 2, false, 0, 0.8, 1, true); + if (Recharge.Instance.use(player, "Territory Knockback", 2000, false, false)) { + UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), team.GetSpawn()), 2, + false, 0, 0.8, 1, true); player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); UtilPlayer.message(player, F.main("Game", "You cannot walk on the enemies turf!")); } - - return; + + // Looks like that with 'return' if there are only two + // players, one of them will not get knockback. + + // return; } - //On Own Turf - else if ((team.GetColor() == ChatColor.RED && data == 14) || (team.GetColor() == ChatColor.AQUA && data == 3)) - { + // On Own Turf + else if ((team.GetColor() == ChatColor.RED && data == 14) + || (team.GetColor() == ChatColor.AQUA && data == 3)) { _enemyTurf.remove(player); } } } } - + /* - @EventHandler - public void ItemRemoval(UpdateEvent event) - { - if (!IsLive()) - return; + * @EventHandler public void ItemRemoval(UpdateEvent event) { if (!IsLive()) + * return; + * + * if (event.getType() != UpdateType.FAST) return; + * + * for (Entity ent : _red.getWorld().getEntities()) { if (!(ent instanceof + * Item)) continue; + * + * if (ent.getTicksLived() > 40) ent.remove(); } } + */ - if (event.getType() != UpdateType.FAST) - return; - - for (Entity ent : _red.getWorld().getEntities()) - { - if (!(ent instanceof Item)) - continue; - - if (ent.getTicksLived() > 40) - ent.remove(); - } - } - */ - - public GameTeam GetOtherTeam(GameTeam team) { return team.GetColor() == ChatColor.RED ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); } - + @EventHandler public void onItem(ItemSpawnEvent e) { if (e.getEntityType().equals(EntityType.DROPPED_ITEM)) { e.setCancelled(true); } } - + @Override - public void EndCheck() - { + public void EndCheck() { if (!IsLive()) return; - if (GetRedLines() == 0 || GetTeam(ChatColor.RED).GetPlayers(true).size() == 0) - { + if (GetRedLines() == 0 || GetTeam(ChatColor.RED).GetPlayers(true).size() == 0) { AnnounceEnd(GetTeam(ChatColor.AQUA)); - } - else if (GetBlueLines() == 0 || GetTeam(ChatColor.AQUA).GetPlayers(true).size() == 0) - { + } else if (GetBlueLines() == 0 || GetTeam(ChatColor.AQUA).GetPlayers(true).size() == 0) { AnnounceEnd(GetTeam(ChatColor.RED)); - } - else + } else return; - for (GameTeam team : GetTeamList()) - { - if (WinnerTeam != null && team.equals(WinnerTeam)) - { + for (GameTeam team : GetTeamList()) { + if (WinnerTeam != null && team.equals(WinnerTeam)) { for (Player player : team.GetPlayers(false)) AddGems(player, 10, "Winning Team", false, false); } @@ -828,28 +723,25 @@ public class TurfForts extends TeamGame if (player.isOnline()) AddGems(player, 10, "Participation", false, false); } - - //End + + // End SetState(GameState.End); } - public Long getEnemyTurfEntranceTime(Player player) - { + public Long getEnemyTurfEntranceTime(Player player) { return _enemyTurf.get(player); } - + // Keep ladders placed on ice when block updates occur. - + @EventHandler - public void onBlockPhysics(BlockPhysicsEvent event) - { + public void onBlockPhysics(BlockPhysicsEvent event) { if (!IsLive()) return; - + Block block = event.getBlock(); - - if (block.getType() == Material.LADDER) - { + + if (block.getType() == Material.LADDER) { event.setCancelled(true); } } From c739ecc26d610e4a1b83f837f36eb705aa829e18 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 4 Jan 2016 14:20:39 -0500 Subject: [PATCH 30/65] Fix forcefield for YOUTUBE_SMALL --- .../src/mineplex/hub/modules/ForcefieldManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java index c52990ac1..107fd8aa6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java @@ -42,7 +42,7 @@ public class ForcefieldManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH)) + if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE_SMALL)) { for (Player other : UtilServer.getPlayers()) { From c50fb52a88c8aaf9d940132af3e8dbf04406eb7c Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 4 Jan 2016 14:21:21 -0500 Subject: [PATCH 31/65] Disable New Years Countdown --- Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java | 2 -- .../src/mineplex/hub/modules/NewYearCountdown.java | 13 ------------- 2 files changed, 15 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 7cc8e7def..41b2081a3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -184,8 +184,6 @@ public class Hub extends JavaPlugin implements IRelation //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); - - new NewYearCountdown(this); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index 1c0766fa8..9ebd311a6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -83,19 +83,6 @@ public class NewYearCountdown extends MiniPlugin _targetTime = System.currentTimeMillis() + (seconds * 1000); } - @EventHandler - public void cmd(PlayerCommandPreprocessEvent e) - { - if (!e.getPlayer().getName().equalsIgnoreCase("WilliamTiger")) - return; - - if (e.getMessage().equalsIgnoreCase("/lmao")) - { - e.setCancelled(true); - start(30); - } - } - @EventHandler public void updateStage(UpdateEvent e) { From 982e684a45b7e3297c52132446f652ed9ddd36c0 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Mon, 4 Jan 2016 21:42:58 +0200 Subject: [PATCH 32/65] Turf Wars: Undo bracket formatting. --- .../game/games/turfforts/TurfForts.java | 524 +++++++++++------- 1 file changed, 316 insertions(+), 208 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index c33335dc4..61a89a1e5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -62,28 +62,34 @@ import nautilus.game.arcade.stats.BlockShreadStatTracker; import nautilus.game.arcade.stats.TheComebackStatTracker; import net.minecraft.server.v1_8_R3.EntityArrow; -public class TurfForts extends TeamGame { - public static class ShredBlockEvent extends BlockEvent { +public class TurfForts extends TeamGame +{ + public static class ShredBlockEvent extends BlockEvent + { private static final HandlerList handlers = new HandlerList(); - public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() + { return handlers; } @Override - public HandlerList getHandlers() { + public HandlerList getHandlers() + { return getHandlerList(); } private final Arrow _arrow; - public ShredBlockEvent(Block theBlock, Arrow arrow) { + public ShredBlockEvent(Block theBlock, Arrow arrow) + { super(theBlock); _arrow = arrow; } - public Arrow getArrow() { + public Arrow getArrow() + { return _arrow; } } @@ -104,18 +110,29 @@ public class TurfForts extends TeamGame { private long _fightTime = 90000; private boolean _fight = false; private int _lines = 0; - + private HashMap _enemyTurf = new HashMap(); - + private Set playersThatNeedBlocks = new HashSet(); - - public TurfForts(ArcadeManager manager) { + + public TurfForts(ArcadeManager manager) + { super(manager, GameType.TurfWars, - new Kit[] { new KitMarksman(manager), new KitInfiltrator(manager), new KitShredder(manager), }, + new Kit[] + { + new KitMarksman(manager), + new KitInfiltrator(manager), + new KitShredder(manager), + }, - new String[] { "You have 30 seconds to build your Fort!", "", "Each kill advances your turf forwards.", - "Take over all the turf to win!" }); + new String[] + { + "You have 30 seconds to build your Fort!", + "", + "Each kill advances your turf forwards.", + "Take over all the turf to win!" + }); this.StrictAntiHack = true; this.HungerSet = 20; @@ -127,12 +144,16 @@ public class TurfForts extends TeamGame { this.DamageSelf = false; this.DeathSpectateSecs = 4; - registerStatTrackers(new BlockShreadStatTracker(this), new BehindEnemyLinesStatTracker(this), - new TheComebackStatTracker(this)); + registerStatTrackers( + new BlockShreadStatTracker(this), + new BehindEnemyLinesStatTracker(this), + new TheComebackStatTracker(this) + ); } @Override - public void ParseData() { + public void ParseData() + { _turf = WorldData.GetDataLocs("YELLOW"); _red = WorldData.GetDataLocs("RED").get(0); @@ -141,18 +162,15 @@ public class TurfForts extends TeamGame { _blue = WorldData.GetDataLocs("BLUE").get(0); _blueBase = WorldData.GetDataLocs("LIGHT_BLUE").get(0); - if (_red.getBlockX() > _blue.getBlockX()) - xRed = 1; - else if (_red.getBlockX() < _blue.getBlockX()) - xRed = -1; + if (_red.getBlockX() > _blue.getBlockX()) xRed = 1; + else if (_red.getBlockX() < _blue.getBlockX()) xRed = -1; - if (_red.getBlockZ() > _blue.getBlockZ()) - zRed = 1; - else if (_red.getBlockZ() < _blue.getBlockZ()) - zRed = -1; + if (_red.getBlockZ() > _blue.getBlockZ()) zRed = 1; + else if (_red.getBlockZ() < _blue.getBlockZ()) zRed = -1; - // Color Turf - for (Location loc : _turf) { + //Color Turf + for (Location loc : _turf) + { if (UtilMath.offset(loc, _red) < UtilMath.offset(loc, _blue)) MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14); else @@ -161,7 +179,8 @@ public class TurfForts extends TeamGame { } @EventHandler - public void PlayerKillAward(CombatDeathEvent event) { + public void PlayerKillAward(CombatDeathEvent event) + { if (!(event.GetEvent().getEntity() instanceof Player)) return; @@ -183,19 +202,26 @@ public class TurfForts extends TeamGame { if (GetTeam(killer).equals(GetTeam(killed))) return; - if (GetTeam(killer).GetColor() == ChatColor.RED) { + if (GetTeam(killer).GetColor() == ChatColor.RED) + { TurfMove(true); - } else { + } + else + { TurfMove(false); } } - private void TurfMove(boolean red) { - for (int line = 0; line < GetLinesPerKill(); line++) { - if (red) { + private void TurfMove(boolean red) + { + for (int line = 0; line < GetLinesPerKill(); line++) + { + if (red) + { if (xRed != 0) for (Location loc : _turf) - if (loc.getBlockX() == _blue.getBlockX()) { + if (loc.getBlockX() == _blue.getBlockX()) + { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14); for (int i = 1; i < 6; i++) @@ -203,9 +229,11 @@ public class TurfForts extends TeamGame { MapUtil.QuickChangeBlockAt(loc.clone().add(0, i, 0), 0, (byte) 0); } + if (zRed != 0) for (Location loc : _turf) - if (loc.getBlockZ() == _blue.getBlockZ()) { + if (loc.getBlockZ() == _blue.getBlockZ()) + { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14); for (int i = 1; i < 6; i++) @@ -215,10 +243,13 @@ public class TurfForts extends TeamGame { _red.subtract(xRed, 0, zRed); _blue.subtract(xRed, 0, zRed); - } else { + } + else + { if (xRed != 0) for (Location loc : _turf) - if (loc.getBlockX() == _red.getBlockX()) { + if (loc.getBlockX() == _red.getBlockX()) + { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 3); for (int i = 1; i < 6; i++) @@ -228,7 +259,8 @@ public class TurfForts extends TeamGame { if (zRed != 0) for (Location loc : _turf) - if (loc.getBlockZ() == _red.getBlockZ()) { + if (loc.getBlockZ() == _red.getBlockZ()) + { MapUtil.QuickChangeBlockAt(loc, 159, (byte) 3); for (int i = 1; i < 6; i++) @@ -243,84 +275,94 @@ public class TurfForts extends TeamGame { EndCheck(); } } - + @EventHandler - public void BowCancel(EntityShootBowEvent event) { - if (!_fight) { + public void BowCancel(EntityShootBowEvent event) + { + if (!_fight) + { UtilPlayer.message(event.getEntity(), F.main("Game", "You cannot attack during Build Time!")); event.setCancelled(true); - + ((Player) event.getEntity()).updateInventory(); } } @EventHandler - public void BlockBreak(BlockBreakEvent event) { - if (event.isCancelled()) // this statement might save just a small - // amount of time + public void BlockBreak(BlockBreakEvent event) + { + if (event.isCancelled()) // this statement might save just a small amount of time return; - - if (!IsAlive(event.getPlayer())) { + + + + if (!IsAlive(event.getPlayer())) + { event.setCancelled(true); return; } - if (UtilPlayer.isSpectator(event.getPlayer())) { + if (UtilPlayer.isSpectator(event.getPlayer())) + { event.setCancelled(true); return; } - + Block block = event.getBlock(); - + GameTeam team = GetTeam(event.getPlayer()); GameTeam otherTeam = GetOtherTeam(team); - if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) - || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA)) { - UtilPlayer.message(event.getPlayer(), F.main("Game", - "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!")); + if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA)) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!")); event.setCancelled(true); return; } } @EventHandler(ignoreCancelled = true) - public void BlockPlace(BlockPlaceEvent event) { - // Remoeved and replaced by ignoreCancelled = true - // if (event.isCancelled()) - // return; + public void BlockPlace(BlockPlaceEvent event) + { + //Remoeved and replaced by ignoreCancelled = true + //if (event.isCancelled()) + // return; GameTeam team = GetTeam(event.getPlayer()); - if (team == null) { + if (team == null) + { event.setCancelled(true); return; } - if (!IsAlive(event.getPlayer())) { + if (!IsAlive(event.getPlayer())) + { event.setCancelled(true); return; } - if (UtilPlayer.isSpectator(event.getPlayer())) { + if (UtilPlayer.isSpectator(event.getPlayer())) + { event.setCancelled(true); return; } - - // On Own + + //On Own Block block = event.getBlock().getRelative(BlockFace.DOWN); while (block.getTypeId() == 0) block = block.getRelative(BlockFace.DOWN); - if (block.getData() != team.GetColorData()) { - UtilPlayer.message(event.getPlayer(), - F.main("Game", "You can only build above " + F.elem(team.GetColor() + team.GetName()) + ".")); + if (block.getData() != team.GetColorData()) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "You can only build above " + F.elem(team.GetColor() + team.GetName()) + ".")); event.setCancelled(true); return; } - // Height + //Height boolean aboveTurf = false; - for (int i = 1; i <= 5; i++) { + for (int i = 1; i <= 5; i++) + { if (event.getBlock().getRelative(BlockFace.DOWN, i).getTypeId() != 159) continue; @@ -328,7 +370,8 @@ public class TurfForts extends TeamGame { break; } - if (!aboveTurf) { + if (!aboveTurf) + { UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot build this high above Turf.")); event.setCancelled(true); return; @@ -336,7 +379,8 @@ public class TurfForts extends TeamGame { } @EventHandler - public void BlockDamage(ProjectileHitEvent event) { + public void BlockDamage(ProjectileHitEvent event) + { if (event.getEntity().getShooter() == null) return; @@ -353,9 +397,12 @@ public class TurfForts extends TeamGame { final Arrow arrow = (Arrow) event.getEntity(); - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() { - public void run() { - try { + Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + { + public void run() + { + try + { EntityArrow entityArrow = ((CraftArrow) arrow).getHandle(); Field fieldX = EntityArrow.class.getDeclaredField("d"); @@ -371,29 +418,28 @@ public class TurfForts extends TeamGame { int z = fieldZ.getInt(entityArrow); Block block = arrow.getWorld().getBlockAt(x, y, z); - - if (block.getTypeId() == 35) { - if (block.getData() == 14 /* - * && team.GetColor() != - * ChatColor.RED - */) { - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, - Material.REDSTONE_BLOCK.getId()); - } else if (block.getData() == 3 /* - * && team.GetColor() != - * ChatColor.AQUA - */) { - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, - Material.LAPIS_BLOCK.getId()); + + if (block.getTypeId() == 35) + { + if (block.getData() == 14 /* && team.GetColor() != ChatColor.RED */) + { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId()); } - + else if (block.getData() == 3 /* && team.GetColor() != ChatColor.AQUA */) + { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId()); + } + Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow)); - + + block.setType(Material.AIR); } arrow.remove(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } @@ -401,51 +447,64 @@ public class TurfForts extends TeamGame { } @EventHandler - public void Damage(CustomDamageEvent event) { - if (event.GetCause() == DamageCause.FALL) { + public void Damage(CustomDamageEvent event) + { + if (event.GetCause() == DamageCause.FALL) + { event.SetCancelled("No Fall"); return; } - if (!_fight && (event.GetCause() == DamageCause.PROJECTILE || event.GetCause() == DamageCause.ENTITY_ATTACK)) { + if (!_fight && (event.GetCause() == DamageCause.PROJECTILE || event.GetCause() == DamageCause.ENTITY_ATTACK)) + { event.SetCancelled("Build Time"); return; } Player damager = event.GetDamagerPlayer(true); - if (damager == null) - return; + if (damager == null) return; - if (event.GetCause() == DamageCause.PROJECTILE) { + if (event.GetCause() == DamageCause.PROJECTILE) + { event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false); - if (GetKit(damager).GetName().contains("Shredder")) { + if (GetKit(damager).GetName().contains("Shredder")) + { event.SetCancelled("Shredder"); - Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, DamageCause.CUSTOM, 9, true, - true, false, damager.getName(), "Barrage"); + Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, + DamageCause.CUSTOM, 9, true, true, false, + damager.getName(), "Barrage"); return; - } else { + } + else + { event.AddMod("Turf Forts", "One Hit Kill", 30, false); } - } else if (event.GetCause() == DamageCause.ENTITY_ATTACK) { + } + else if (event.GetCause() == DamageCause.ENTITY_ATTACK) + { event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false); - if (UtilGear.isMat(damager.getItemInHand(), Material.IRON_SWORD)) { + if (UtilGear.isMat(damager.getItemInHand(), Material.IRON_SWORD)) + { event.AddMod("Turf Forts", "One Hit Kill", 12, false); - } else { + } + else + { event.AddMod("Turf Forts", "One Hit Kill", 6, false); } } } @EventHandler - public void ScoreboardTitle(UpdateEvent event) { + public void ScoreboardTitle(UpdateEvent event) + { if (GetState() != GameState.Live) return; - // 2x Initial Build + //2x Initial Build if (_phaseTime == 0) _phaseTime = System.currentTimeMillis() + _buildTime; @@ -453,42 +512,48 @@ public class TurfForts extends TeamGame { return; long time; - if (!_fight) { + if (!_fight) + { time = _buildTime - (System.currentTimeMillis() - _phaseTime); - if (time <= 0) { + if (time <= 0) + { _fight = true; _lines++; Announce(" "); - Announce(C.cWhite + C.Bold + "1 Kill" + C.cWhite + C.Bold + " = " + C.cWhite + C.Bold - + GetLinesPerKill() + " Turf Lines"); - Announce(C.cWhite + C.Bold + "90 Seconds of " + C.cYellow + C.Bold + "Combat Time" + C.cWhite + C.Bold - + " has begun!"); + Announce(C.cWhite + C.Bold + "1 Kill" + C.cWhite + C.Bold + " = " + C.cWhite + C.Bold + GetLinesPerKill() + " Turf Lines"); + Announce(C.cWhite + C.Bold + "90 Seconds of " + C.cYellow + C.Bold + "Combat Time" + C.cWhite + C.Bold + " has begun!"); Announce(" "); _phaseTime = System.currentTimeMillis(); } } - else { + else + { time = _fightTime - (System.currentTimeMillis() - _phaseTime); - if (time <= 0) { + if (time <= 0) + { _fight = false; Announce(" "); - Announce(C.cWhite + C.Bold + "20 Seconds of " + C.cGreen + C.Bold + "Build Time" + C.cWhite + C.Bold - + " has begun!"); + Announce(C.cWhite + C.Bold + "20 Seconds of " + C.cGreen + C.Bold + "Build Time" + C.cWhite + C.Bold + " has begun!"); Announce(" "); _phaseTime = System.currentTimeMillis(); - for (GameTeam team : GetTeamList()) { - for (Player player : team.GetPlayers(true)) { - if (UtilPlayer.isSpectator(player)) { + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + { this.playersThatNeedBlocks.add(player.getUniqueId()); - } else { + } + else + { addBlocks(team, player); } } @@ -496,45 +561,52 @@ public class TurfForts extends TeamGame { } } } - - public void addBlocks(GameTeam team, Player player) { + + public void addBlocks(GameTeam team, Player player) + { player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOL, team.GetColorData(), 24)); } - + @EventHandler(ignoreCancelled = true) - public void onQuit(PlayerQuitEvent event) { + public void onQuit(PlayerQuitEvent event) + { this.playersThatNeedBlocks.remove(event.getPlayer().getUniqueId()); } - + @EventHandler(ignoreCancelled = true) - public void onSpawn(PlayerKitGiveEvent event) { + public void onSpawn(PlayerKitGiveEvent event) + { Player player = event.getPlayer(); - if (this.playersThatNeedBlocks.contains(player.getUniqueId())) { + if (this.playersThatNeedBlocks.contains(player.getUniqueId())) + { this.playersThatNeedBlocks.remove(player.getUniqueId()); this.addBlocks(GetTeam(player), player); } } - + + + @Override @EventHandler - public void ScoreboardUpdate(UpdateEvent event) { + public void ScoreboardUpdate(UpdateEvent event) + { if (event.getType() != UpdateType.FAST) return; Scoreboard.Reset(); - for (GameTeam team : this.GetTeamList()) { + for (GameTeam team : this.GetTeamList()) + { int lines = 0; - if (team.GetColor() == ChatColor.RED) - lines = GetRedLines(); - else - lines = GetBlueLines(); + if (team.GetColor() == ChatColor.RED) lines = GetRedLines(); + else lines = GetBlueLines(); Scoreboard.WriteBlank(); Scoreboard.Write(lines + " " + team.GetColor() + team.GetName()); } - if (!_fight) { + if (!_fight) + { long time = _buildTime - (System.currentTimeMillis() - _phaseTime); Scoreboard.WriteBlank(); @@ -543,7 +615,8 @@ public class TurfForts extends TeamGame { } - else { + else + { long time = _fightTime - (System.currentTimeMillis() - _phaseTime); Scoreboard.WriteBlank(); @@ -554,78 +627,95 @@ public class TurfForts extends TeamGame { Scoreboard.Draw(); } - public int GetRedLines() { + public int GetRedLines() + { if (!InProgress()) return 0; - if (xRed != 0) { + if (xRed != 0) + { return Math.abs(_redBase.getBlockX() - _red.getBlockX()); } return Math.abs(_redBase.getBlockZ() - _red.getBlockZ()); } - public int GetBlueLines() { + public int GetBlueLines() + { if (!InProgress()) return 0; - if (xRed != 0) { + if (xRed != 0) + { return Math.abs(_blueBase.getBlockX() - _blue.getBlockX()); } return Math.abs(_blueBase.getBlockZ() - _blue.getBlockZ()); } - public int getLines(GameTeam team) { + public int getLines(GameTeam team) + { if (team.GetColor() == ChatColor.RED) return GetRedLines(); else return GetBlueLines(); } - public int GetLinesPerKill() { + public int GetLinesPerKill() + { return _lines; - // return Math.min(5, 1 + (int)((System.currentTimeMillis() - - // GetStateTime() - 30000) / 60000)); + //return Math.min(5, 1 + (int)((System.currentTimeMillis() - GetStateTime() - 30000) / 60000)); } @EventHandler - public void PlayerDeath(PlayerDeathEvent event) { + public void PlayerDeath(PlayerDeathEvent event) + { _enemyTurf.remove(event.getEntity()); } @EventHandler - public void Territory(UpdateEvent event) { + public void Territory(UpdateEvent event) + { if (!IsLive()) return; if (event.getType() != UpdateType.FASTER) return; - for (GameTeam team : this.GetTeamList()) { - for (Player player : team.GetPlayers(true)) { - if (((CraftPlayer) player).getHandle().spectating) - continue; - + for (GameTeam team : this.GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (((CraftPlayer) player).getHandle().spectating) + continue; + Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); + + // Apply velocity even if the player is sneaking near turf edges. + + if (block.isEmpty() && player.isOnGround()) + { + Block[] nearby = { + block.getRelative(BlockFace.NORTH), + block.getRelative(BlockFace.SOUTH), + block.getRelative(BlockFace.WEST), + block.getRelative(BlockFace.EAST), + block.getRelative(BlockFace.NORTH_EAST), + block.getRelative(BlockFace.NORTH_WEST), + block.getRelative(BlockFace.SOUTH_EAST), + block.getRelative(BlockFace.SOUTH_WEST) + }; - // Apply velocity even if the player is sneaking near turf - // edges. - - if (block.isEmpty() && player.isOnGround()) { - Block[] nearby = { block.getRelative(BlockFace.NORTH), block.getRelative(BlockFace.SOUTH), - block.getRelative(BlockFace.WEST), block.getRelative(BlockFace.EAST), - block.getRelative(BlockFace.NORTH_EAST), block.getRelative(BlockFace.NORTH_WEST), - block.getRelative(BlockFace.SOUTH_EAST), block.getRelative(BlockFace.SOUTH_WEST) }; - - for (Block near : nearby) { - if (near.getType() == Material.STAINED_CLAY || near.getType() == Material.WOOL) { + for (Block near : nearby) + { + if (near.getType() == Material.STAINED_CLAY || near.getType() == Material.WOOL) + { block = near; break; } } } - + while (block.getTypeId() != 159 && block.getY() > 0) block = block.getRelative(BlockFace.DOWN); @@ -634,21 +724,22 @@ public class TurfForts extends TeamGame { byte data = block.getData(); - // Slow - if (_enemyTurf.containsKey(player)) { + //Slow + if (_enemyTurf.containsKey(player)) + { int time = (int) ((System.currentTimeMillis() - _enemyTurf.get(player)) / 2500); if (time > 0) - Manager.GetCondition().Factory().Slow("Infiltrator Slow", player, player, 0.9, time - 1, false, - false, false, false); + Manager.GetCondition().Factory().Slow("Infiltrator Slow", player, player, 0.9, time - 1, false, false, false, false); } - // On Enemy Turf - if ((team.GetColor() == ChatColor.RED && data == 3) - || (team.GetColor() == ChatColor.AQUA && data == 14)) { + //On Enemy Turf + if ((team.GetColor() == ChatColor.RED && data == 3) || (team.GetColor() == ChatColor.AQUA && data == 14)) + { - // Infiltrate - if (_fight && GetKit(player) != null && GetKit(player).GetName().contains("Infil")) { + //Infiltrate + if (_fight && GetKit(player) != null && GetKit(player).GetName().contains("Infil")) + { if (!_enemyTurf.containsKey(player)) _enemyTurf.put(player, System.currentTimeMillis()); @@ -656,65 +747,79 @@ public class TurfForts extends TeamGame { continue; } - if (Recharge.Instance.use(player, "Territory Knockback", 2000, false, false)) { - UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), team.GetSpawn()), 2, - false, 0, 0.8, 1, true); + if (Recharge.Instance.use(player, "Territory Knockback", 2000, false, false)) + { + UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), team.GetSpawn()), 2, false, 0, 0.8, 1, true); player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); UtilPlayer.message(player, F.main("Game", "You cannot walk on the enemies turf!")); } - // Looks like that with 'return' if there are only two - // players, one of them will not get knockback. - // return; } - // On Own Turf - else if ((team.GetColor() == ChatColor.RED && data == 14) - || (team.GetColor() == ChatColor.AQUA && data == 3)) { + //On Own Turf + else if ((team.GetColor() == ChatColor.RED && data == 14) || (team.GetColor() == ChatColor.AQUA && data == 3)) + { _enemyTurf.remove(player); } } } } - + /* - * @EventHandler public void ItemRemoval(UpdateEvent event) { if (!IsLive()) - * return; - * - * if (event.getType() != UpdateType.FAST) return; - * - * for (Entity ent : _red.getWorld().getEntities()) { if (!(ent instanceof - * Item)) continue; - * - * if (ent.getTicksLived() > 40) ent.remove(); } } - */ + @EventHandler + public void ItemRemoval(UpdateEvent event) + { + if (!IsLive()) + return; + if (event.getType() != UpdateType.FAST) + return; + + for (Entity ent : _red.getWorld().getEntities()) + { + if (!(ent instanceof Item)) + continue; + + if (ent.getTicksLived() > 40) + ent.remove(); + } + } + */ + + public GameTeam GetOtherTeam(GameTeam team) { return team.GetColor() == ChatColor.RED ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); } - + @EventHandler public void onItem(ItemSpawnEvent e) { if (e.getEntityType().equals(EntityType.DROPPED_ITEM)) { e.setCancelled(true); } } - + @Override - public void EndCheck() { + public void EndCheck() + { if (!IsLive()) return; - if (GetRedLines() == 0 || GetTeam(ChatColor.RED).GetPlayers(true).size() == 0) { + if (GetRedLines() == 0 || GetTeam(ChatColor.RED).GetPlayers(true).size() == 0) + { AnnounceEnd(GetTeam(ChatColor.AQUA)); - } else if (GetBlueLines() == 0 || GetTeam(ChatColor.AQUA).GetPlayers(true).size() == 0) { + } + else if (GetBlueLines() == 0 || GetTeam(ChatColor.AQUA).GetPlayers(true).size() == 0) + { AnnounceEnd(GetTeam(ChatColor.RED)); - } else + } + else return; - for (GameTeam team : GetTeamList()) { - if (WinnerTeam != null && team.equals(WinnerTeam)) { + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { for (Player player : team.GetPlayers(false)) AddGems(player, 10, "Winning Team", false, false); } @@ -723,26 +828,29 @@ public class TurfForts extends TeamGame { if (player.isOnline()) AddGems(player, 10, "Participation", false, false); } - - // End + + //End SetState(GameState.End); } - public Long getEnemyTurfEntranceTime(Player player) { + public Long getEnemyTurfEntranceTime(Player player) + { return _enemyTurf.get(player); } - + // Keep ladders placed on ice when block updates occur. - + @EventHandler - public void onBlockPhysics(BlockPhysicsEvent event) { + public void onBlockPhysics(BlockPhysicsEvent event) + { if (!IsLive()) return; - + Block block = event.getBlock(); - - if (block.getType() == Material.LADDER) { + + if (block.getType() == Material.LADDER) + { event.setCancelled(true); } } -} +} \ No newline at end of file From 3770211e66b41e16440609a0a79b3999b9b6cca7 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Mon, 4 Jan 2016 22:58:11 +0200 Subject: [PATCH 33/65] Turf Wars: Include Teddy's border fix. --- .../game/games/turfforts/TurfForts.java | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index 61a89a1e5..6bff9d4b2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -22,6 +22,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockEvent; import org.bukkit.event.block.BlockPhysicsEvent; @@ -31,6 +32,7 @@ import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.common.util.C; @@ -838,10 +840,48 @@ public class TurfForts extends TeamGame return _enemyTurf.get(player); } - // Keep ladders placed on ice when block updates occur. - + // Fixed by TeddyDev. @EventHandler - public void onBlockPhysics(BlockPhysicsEvent event) + public void blockGlitchFix(PlayerInteractEvent event) + { + if(event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if(event.getPlayer().isOnGround()) + return; + + Block block = event.getClickedBlock(); + if(block.getType() == Material.STAINED_CLAY || block.getType() == Material.WOOL) + return; + + Player player = event.getPlayer(); + Block ground = player.getLocation().getBlock(); + while (ground.getType() == Material.AIR && ground.getLocation().getBlockY() >= 0) + { + ground = ground.getRelative(BlockFace.DOWN); + } + + if(ground.isLiquid()) + { + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.VOID, 9001, false, false, false, + "Border", "Border Damage"); + player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); + return; + } + + if(player.getLocation().distance(ground.getLocation()) < 4) + return; + + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.VOID, 9001, false, false, false, + "Border", "Border Damage"); + player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); + } + + // Keep ladders placed on ice when block updates occur. + @EventHandler + public void ladderDestroyFix(BlockPhysicsEvent event) { if (!IsLive()) return; From ed814113734dd370c91bb820e1c921b60561d9bc Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 4 Jan 2016 15:58:27 -0500 Subject: [PATCH 34/65] Fix carl bonus messages --- .../src/mineplex/core/bonuses/BonusManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 6c01d3719..a8dcbfa34 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -440,6 +440,7 @@ public class BonusManager extends MiniClientPlugin implements I incrementDailyStreak(player); awardBonus(player, amount); updateCreeperVisual(player, true, C.cAqua); + UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!")); _statsManager.incrementStat(player, "Global.DailyReward", 1); } @@ -481,6 +482,7 @@ public class BonusManager extends MiniClientPlugin implements I { awardBonus(player, getRankBonusAmount(player)); updateCreeperVisual(player, true, C.cAqua); + UtilPlayer.message(player, F.main("Carl", "Come back next month for more!")); } result.run(aBoolean); @@ -814,9 +816,6 @@ public class BonusManager extends MiniClientPlugin implements I _statsManager.incrementStat(player, "Global.ExpEarned", experience); UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(experience + " Experience"))); } - - UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!")); - } @EventHandler From 962efe4a614ebc8ecbbd34d2ea04682d9bed287e Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 4 Jan 2016 16:41:07 -0500 Subject: [PATCH 35/65] Fix not being able to join games through portals --- .../mineplex/hub/server/ServerManager.java | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 0b54138c0..59b019540 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -86,7 +86,7 @@ public class ServerManager extends MiniPlugin private NautHashMap _serverNpcShopMap = new NautHashMap(); private NautHashMap _serverInfoMap = new NautHashMap(); private NautHashMap _serverUpdate = new NautHashMap(); - private NautHashMap _serverPortalLocations = new NautHashMap(); + private NautHashMap _portalToServerKey = new NautHashMap(); private ClansServerShop _clansShop; @@ -185,15 +185,16 @@ public class ServerManager extends MiniPlugin return; } - String serverName = _serverPortalLocations.get(player.getLocation().getBlock().getLocation().toVector()); + String serverKey = _portalToServerKey.get(player.getLocation().getBlock().getLocation().toVector()); - if (serverName != null) + if (serverKey != null) { List serverList = new ArrayList(); - - if (hasServerNpc(serverName)) - serverList.addAll(getServerList(serverName)); - + + Collection servers = getServerList(serverKey); + if (servers != null && servers.size() > 0) + serverList.addAll(servers); + int slots = 1; if (serverList.size() > 0) @@ -347,9 +348,9 @@ public class ServerManager extends MiniPlugin } } - public Collection getServerList(String serverNpcName) + public Collection getServerList(String serverKey) { - return _serverKeyInfoMap.get(serverNpcName); + return _serverKeyInfoMap.get(serverKey); } public Set getAllServers() @@ -362,11 +363,6 @@ public class ServerManager extends MiniPlugin return _serverInfoMap.get(serverName); } - public boolean hasServerNpc(String serverNpcName) - { - return _serverKeyInfoMap.containsKey(serverNpcName); - } - @EventHandler public void updatePages(UpdateEvent event) { @@ -711,7 +707,7 @@ public class ServerManager extends MiniPlugin while (blocks < 10 && (bottomVector.getBlockX() != topVector.getBlockX() || bottomVector.getBlockZ() != topVector.getBlockZ())) { - _serverPortalLocations.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getServerNpcName()); + _portalToServerKey.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getPrefix()); if (bottomVector.getBlockX() != topVector.getBlockX()) { @@ -725,7 +721,7 @@ public class ServerManager extends MiniPlugin blocks++; } - _serverPortalLocations.put(bottomVector, serverGroup.getServerNpcName()); + _portalToServerKey.put(bottomVector, serverGroup.getPrefix()); } } } From f749300d484be0860149b73e672c42101123d0c9 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 4 Jan 2016 18:13:54 -0500 Subject: [PATCH 36/65] Fix team stats not displaying properly --- .../src/mineplex/core/achievement/StatDisplay.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java index 0d6badd6e..a4dc577ed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java @@ -81,7 +81,7 @@ public class StatDisplay formattedStats[i] = gameDisplay.getName() + "." + stats[i]; } - return new StatDisplay(name, true, formattedStats); + return new StatDisplay(name, true, false, formattedStats); } public static final StatDisplay WINS = new StatDisplay("Wins"); From c920d4efa13a460365d7bff4542e2d130f3f119d Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 7 Jan 2016 04:48:44 +1300 Subject: [PATCH 37/65] Modify MapText to actually work, modify UtilText to save the images of characters --- .../mineplex/core/common/util/UtilText.java | 85 +++++++++----- .../src/mineplex/core/map/MapText.java | 104 +----------------- 2 files changed, 61 insertions(+), 128 deletions(-) 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 38e540824..2791c275f 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 @@ -17,6 +17,7 @@ import org.bukkit.ChatColor; public class UtilText { private static HashMap _characters = new HashMap(); + private static HashMap _characterImages = new HashMap(); static { @@ -263,13 +264,13 @@ public class UtilText public static String[] splitLinesToArray(String[] strings, LineFormat lineFormat) { ArrayList lineList = splitLines(strings, lineFormat); - + String[] lineArray = new String[lineList.size()]; lineArray = lineList.toArray(lineArray); - + return lineArray; } - + public static ArrayList splitLines(String[] strings, LineFormat lineFormat) { ArrayList lines = new ArrayList(); @@ -281,35 +282,35 @@ public class UtilText return lines; } - + public static String[] splitLineToArray(String string, LineFormat lineFormat) { ArrayList lineList = splitLine(string, lineFormat); - + String[] lineArray = new String[lineList.size()]; lineArray = lineList.toArray(lineArray); - + return lineArray; } public static ArrayList splitLine(String string, LineFormat lineFormat) { ArrayList strings = new ArrayList(); - - //Ignore lines with # + + // Ignore lines with # if (string.startsWith("#")) { strings.add(string.substring(1, string.length())); return strings; } - - //Empty + + // Empty if (string.equals("") || string.equals(" ")) { strings.add(string); return strings; } - + String current = ""; int currentLength = 0; String[] split = string.split(" "); @@ -453,35 +454,63 @@ public class UtilText private static void grab(Character character, BufferedImage image, int imageX, int imageY) { + BufferedImage newImage = image.getSubimage(imageX, imageY, 8, 8); + + int width = 8; + if (character == ' ') { - _characters.put(character, 3); - return; + width = 3; } - - for (int x = 0; x < 8; x++) + else { - boolean isTransparentLine = true; - - for (int y = 0; y < 8; y++) + for (int x = 0; x < 8; x++) { - int pixel = image.getRGB(imageX + x, imageY + y); + boolean isTransparentLine = true; - if ((pixel >> 24) != 0x00) + for (int y = 0; y < 8; y++) { - isTransparentLine = false; + int pixel = image.getRGB(imageX + x, imageY + y); + + if ((pixel >> 24) != 0x00) + { + isTransparentLine = false; + break; + } + } + + if (isTransparentLine) + { + width = x + 1; break; } } - - if (isTransparentLine) - { - _characters.put(character, x); - return; - } } - _characters.put(character, 8); + newImage = newImage.getSubimage(0, 0, width, 8); + + _characterImages.put(character, newImage); + _characters.put(character, width); + } + + public static int getLength(char character) + { + if (!_characters.containsKey(character)) + { + return 16; + } + + return _characters.get(character); + } + + public static BufferedImage getImage(char character) + { + if (!_characterImages.containsKey(character)) + { + character = '?'; + } + + return _characterImages.get(character); } public static boolean isStringSimilar(String newString, String oldString, float matchRequirement) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java b/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java index d11f032dc..3fcc5d2fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java @@ -2,14 +2,9 @@ package mineplex.core.map; import java.awt.Graphics; import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; -import java.util.HashMap; - -import javax.imageio.ImageIO; - import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -20,86 +15,6 @@ import org.bukkit.map.MapView; public class MapText { - private static HashMap _characters = new HashMap(); - - private void loadCharacters() - { - try - { - InputStream inputStream = getClass().getResourceAsStream("ascii.png"); - BufferedImage image = ImageIO.read(inputStream); - - char[] text = new char[] - { - ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', - '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', - 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', - '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', - 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~' - }; - - int x = 0; - int y = 16; - - for (char c : text) - { - grab(c, image, x, y); - - if (x < 15 * 8) - { - x += 8; - } - else - { - x = 0; - y += 8; - } - } - - inputStream.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - - private static void grab(Character character, BufferedImage image, int imageX, int imageY) - { - BufferedImage newImage = image.getSubimage(imageX, imageY, 8, 8); - - int width = character == ' ' ? 4 : 0; - - if (width == 0) - { - for (int x = 0; x < 8; x++) - { - width++; - boolean foundNonTrans = false; - - for (int y = 0; y < 8; y++) - { - int pixel = newImage.getRGB(x, y); - - if ((pixel >> 24) != 0x00) - { - foundNonTrans = true; - break; - } - } - - if (!foundNonTrans) - { - break; - } - } - } - - newImage = newImage.getSubimage(0, 0, width, 8); - - _characters.put(character, newImage); - } - private ArrayList split(String text) { ArrayList returns = new ArrayList(); @@ -112,7 +27,7 @@ public class MapText for (char c : word.toCharArray()) { - length += _characters.get(c).getWidth(); + length += UtilText.getImage(c).getWidth(); } if (lineWidth + length >= 127) @@ -133,11 +48,6 @@ public class MapText public ItemStack getMap(boolean sendToServer, String... text) { - if (_characters.isEmpty()) - { - loadCharacters(); - } - BufferedImage image = new BufferedImage(128, 128, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); int height = 1; @@ -150,13 +60,7 @@ public class MapText for (char c : line.toCharArray()) { - BufferedImage img = _characters.get(c); - - if (img == null) - { - System.out.print("Error: '" + c + "' has no image associated"); - continue; - } + BufferedImage img = UtilText.getImage(c); g.drawImage(img, length, height, null); @@ -179,7 +83,7 @@ public class MapText ItemStack item = new ItemStack(Material.MAP); item.setDurability(map.getId()); - + if (sendToServer) { for (Player player : UtilServer.getPlayers()) From de6f6cf5f016aadd4bc3885f1f77c8c1089da630 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 7 Jan 2016 08:49:26 +1300 Subject: [PATCH 38/65] Add a IsLive check in Spleef --- .../src/nautilus/game/arcade/game/games/spleef/Spleef.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java index 73d245050..207ec28b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java @@ -67,6 +67,9 @@ public class Spleef extends SoloGame @EventHandler public void SnowballDamage(ProjectileHitEvent event) { + if (!IsLive()) + return; + if (!(event.getEntity() instanceof Snowball)) return; From 52c4a551801f6ed13b7ec311a7590b8da230f41d Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 6 Jan 2016 22:32:36 +0000 Subject: [PATCH 39/65] outpost changes, and some other things --- .../mineplex/core/common/util/ColorFader.java | 62 +++++++ .../src/mineplex/core/common/util/F.java | 15 ++ .../core/common/util/LoopIterator.java | 54 ++++++ .../core/common/util/NumericalPulser.java | 42 +++++ .../mineplex/core/common/util/RGBData.java | 16 +- .../mineplex/core/common/util/UtilColor.java | 22 +-- .../core/account/CoreClientManager.java | 9 +- .../src/mineplex/core/chat/Chat.java | 2 +- .../game/clans/clans/ClansManager.java | 170 +++++++++--------- .../clans/clans/commands/ClansCommand.java | 2 +- .../game/clans/clans/outpost/Outpost.java | 110 ++++++++++-- .../clans/clans/outpost/OutpostBlock.java | 2 - .../clans/clans/outpost/OutpostManager.java | 14 +- .../clans/clans/outpost/OutpostState.java | 1 + .../game/clans/clans/outpost/OutpostType.java | 1 - .../game/clans/gameplay/CustomRecipes.java | 10 +- .../game/clans/gameplay/Gameplay.java | 18 ++ .../gameplay/safelog/npc/CombatLogNPC.java | 5 +- .../gameplay/safelog/npc/NPCManager.java | 15 ++ .../mineplex/game/clans/items/CustomItem.java | 2 + .../game/clans/items/GearManager.java | 25 +-- .../mineplex/game/clans/items/PlayerGear.java | 3 + .../items/legendaries/LegendaryItem.java | 9 + .../game/classcombat/Class/ClientClass.java | 2 +- .../classcombat/Skill/Brute/BlockToss.java | 9 +- .../Skill/event/BlockTossLandEvent.java | 6 +- 26 files changed, 476 insertions(+), 150 deletions(-) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ColorFader.java create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NumericalPulser.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ColorFader.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ColorFader.java new file mode 100644 index 000000000..01143886b --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ColorFader.java @@ -0,0 +1,62 @@ +package mineplex.core.common.util; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +public class ColorFader { + + private final int _loopsBetween; + + private final List _colors; + private final LoopIterator _iterator; + private int _loopsSinceLast; + + public ColorFader(int loopsBetweenColors, RGBData... colors) + { + this(loopsBetweenColors, Arrays.asList(colors)); + } + + public ColorFader(int loopsBetweenColors, List colors) + { + _loopsBetween = loopsBetweenColors; + + _colors = new LinkedList<>(colors); + _iterator = new LoopIterator<>(_colors); + } + + public RGBData next() + { + RGBData rgb; + + if (_loopsSinceLast >= _loopsBetween) + { + rgb = _iterator.next(); + _loopsSinceLast = 0; + } + else + { + int redStep = (_iterator.peekNext().getFullRed() - _iterator.current().getFullRed()) / _loopsBetween; + int greenStep = (_iterator.peekNext().getFullGreen() - _iterator.current().getFullGreen()) / _loopsBetween; + int blueStep = (_iterator.peekNext().getFullBlue() - _iterator.current().getFullBlue()) / _loopsBetween; + + int red = _iterator.current().getFullRed(); + int green = _iterator.current().getFullGreen(); + int blue = _iterator.current().getFullBlue(); + + for (int i = 0; i < _loopsSinceLast; i++) + { + red += redStep; + green += greenStep; + blue += blueStep; + } + + rgb = new RGBData(red, green, blue); + } + + _loopsSinceLast++; + + return rgb; + } + +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java index c0e941237..998b57d7c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java @@ -200,4 +200,19 @@ public class F return out; } + public static String vowelAN(String word) + { + return word.toLowerCase().startsWith("a") + || word.toLowerCase().startsWith("A") + || word.toLowerCase().startsWith("e") + || word.toLowerCase().startsWith("E") + || word.toLowerCase().startsWith("i") + || word.toLowerCase().startsWith("I") + || word.toLowerCase().startsWith("o") + || word.toLowerCase().startsWith("O") + || word.toLowerCase().startsWith("u") + || word.toLowerCase().startsWith("U") + ? "an" : "a"; + } + } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/LoopIterator.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/LoopIterator.java index 2236d5ecf..b5829a851 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/LoopIterator.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/LoopIterator.java @@ -26,4 +26,58 @@ public class LoopIterator return _list.get(_pointer); } + + public T peekNext() + { + if (_list.isEmpty()) + { + return null; + } + + int pointer = _pointer; + + if (++pointer == _list.size()) + { + pointer = 0; + } + + return _list.get(pointer); + } + + public T peekPrev() + { + if (_list.isEmpty()) + { + return null; + } + + int pointer = _pointer; + + if (--pointer < 0) + { + pointer = _list.size() - 1; + } + + return _list.get(pointer); + } + + public T prev() + { + if (_list.isEmpty()) + { + return null; + } + + if (--_pointer < 0) + { + _pointer = _list.size() - 1; + } + + return _list.get(_pointer); + } + + public T current() + { + return _list.get(_pointer); + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NumericalPulser.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NumericalPulser.java new file mode 100644 index 000000000..e0de3e7d2 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NumericalPulser.java @@ -0,0 +1,42 @@ +package mineplex.core.common.util; + +public class NumericalPulser +{ + private double _min; + private double _max; + private double _modifyPerCall; + + private double _cur; + private boolean _up; + + public NumericalPulser(double min, double max, double modify) + { + _min = min; + _max = max; + _modifyPerCall = modify; + } + + public double pulse() + { + if (_up) + { + _cur = UtilMath.clamp(_cur += _modifyPerCall, _min, _max); + + if (_cur >= _max) + { + _up = false; + } + } + else + { + _cur = UtilMath.clamp(_cur -= _modifyPerCall, _min, _max); + + if (_cur <= _min) + { + _up = true; + } + } + + return _cur; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/RGBData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/RGBData.java index 38170c0b4..912516d17 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/RGBData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/RGBData.java @@ -6,11 +6,11 @@ public class RGBData private double _green; private double _blue; - public RGBData(double red, double green, double blue) + public RGBData(int red, int green, int blue) { - _red = UtilMath.clamp(red, 0, 1); - _green = UtilMath.clamp(green, 0, 1); - _blue = UtilMath.clamp(blue, 0, 1); + _red = UtilMath.clamp(((double) red) / 255.d, 0, 1); + _green = UtilMath.clamp(((double) green) / 255.d, 0, 1); + _blue = UtilMath.clamp(((double) blue) / 255.d, 0, 1); } public int getFullRed() @@ -42,4 +42,12 @@ public class RGBData { return _blue; } + + public String toString() + { + return "RGB[" + + "red=" + (int) (_red * 255) + ", " + + "green=" + (int) (_green * 255) + ", " + + "blue=" + (int) (_blue * 255) + "]"; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java index 4fabeafd0..5a2692655 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java @@ -8,6 +8,7 @@ import org.bukkit.ChatColor; public class UtilColor { public static final RGBData RgbRed = hexToRgb(0xee0100); + public static final RGBData RgbGold = hexToRgb(0xffd014); public static byte chatColorToClayData(ChatColor chatColor) { @@ -70,21 +71,16 @@ public class UtilColor public static RGBData hexToRgb(int hex) { - String hexStr = hexPad(Integer.toHexString(hex)); - int red = Integer.parseInt(hexStr.substring(0, 2), 16); - int green = Integer.parseInt(hexStr.substring(2, 4), 16); - int blue = Integer.parseInt(hexStr.substring(4, 6), 16); - - return new RGBData(((double) red) / 255.d, ((double) green) / 255.d, ((double) blue) / 255.d); + return new RGBData(hex >> 16, hex >> 8 & 0xFF, hex & 0xFF); } - public static String hexPad(String hex) + public static int rgbToHex(RGBData rgb) { - if (hex.length() == 6) - { - return hex; - } - - return UtilText.repeat("0", 6 - hex.length()) + hex; + return (rgb.getFullRed() << 16 | rgb.getFullGreen() << 8 | rgb.getFullBlue()); + } + + public static int rgbToHex(int red, int green, int blue) + { + return (red << 16 | green << 8 | blue); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index fe00a1a45..cd62cf6fc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -128,7 +128,14 @@ public class CoreClientManager extends MiniPlugin if (client == null) { - client = new CoreClient(name); + if (Bukkit.getPlayer(name) != null) + { + client = new CoreClient(Bukkit.getPlayer(name)); + } + else + { + client = new CoreClient(name); + } } return client; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index 8954b07c0..61ed15df6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -296,7 +296,7 @@ public class Chat extends MiniPlugin } } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOW) public void HandleChat(AsyncPlayerChatEvent event) { if (event.isCancelled()) 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 c36ff94fd..710ff13d5 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 @@ -1,6 +1,7 @@ package mineplex.game.clans.clans; import java.io.File; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; @@ -29,6 +30,7 @@ import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; +import org.bukkit.inventory.ShapedRecipe; import org.bukkit.plugin.java.JavaPlugin; import com.google.common.io.ByteArrayDataOutput; @@ -208,7 +210,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati { super("Clans Manager", plugin); - addCommand(new Meow(new OutpostManager(this))); + if (serverName.equals("GarboClans-1")) addCommand(new Meow(new OutpostManager(this))); _instance = this; @@ -373,17 +375,26 @@ public class ClansManager extends MiniClientPluginimplements IRelati hologram.start(); } - // Disables beds from being crafted - Iterator it = _plugin.getServer().recipeIterator(); - Recipe recipe; - while (it.hasNext()) - { - recipe = it.next(); - if (recipe != null && recipe.getResult().getType() == Material.BED) - { - it.remove(); - } - } +// Iterator it = _plugin.getServer().recipeIterator(); +// Recipe recipe; +// while (it.hasNext()) +// { +// recipe = it.next(); +// if (recipe != null) +// { +// if (recipe.getResult().getType() == Material.SMOOTH_BRICK) +// { +// it.remove(); +// } +// } +// } +// +// final ShapedRecipe brrecipe = new ShapedRecipe(new ItemStack(Material.SMOOTH_BRICK, 1)); +// brrecipe.shape("XX", "XX", ""); +// brrecipe.setIngredient('X', Material.STONE); +// UtilServer.getServer().addRecipe(brrecipe); +// + Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict"); } @Override @@ -585,7 +596,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati clanInfo.playerOnline(player); } - if (_clientManager.hasRank(player, Rank.DEVELOPER) || player.getName().equals("NewGarbo")) + if (_clientManager.hasRank(player, Rank.DEVELOPER) || player.getUniqueId().toString().equals("d8646a35-33a8-43c6-9e7c-2e871a6b86c9")) { player.setOp(true); } @@ -638,14 +649,74 @@ public class ClansManager extends MiniClientPluginimplements IRelati } } - @EventHandler - public void handlePlayerChat(AsyncPlayerChatEvent event) + private void handleClanChat(AsyncPlayerChatEvent event, ClanInfo clan, String rank) { - if (event.isCancelled()) + for (Player cur : clan.getOnlinePlayers()) { + String message = _chat.getFilteredMessage(event.getPlayer(), event.getMessage()); + + UtilPlayer.message(cur, String.format(rank + C.cAqua + "%s " + C.cDAqua + "%s", event.getPlayer().getName(), message)); + } + } + + private void handleAllyChat(AsyncPlayerChatEvent event, ClanInfo clan, String rank) + { + List recipients = new ArrayList<>(); + + clan.getOnlinePlayers().forEach(recipients::add); + + for (String allyName : clan.getAllyMap().keySet()) + { + ClanInfo ally = _clanUtility.getClanByClanName(allyName); + if (ally == null) continue; + + ally.getOnlinePlayers().forEach(recipients::add); + } + + String message = _chat.getFilteredMessage(event.getPlayer(), event.getMessage()); + + recipients.forEach(p -> UtilPlayer.message(p, String.format(rank + C.cDGreen + clan.getName() + " " + C.cDGreen + "%s " + C.cGreen + "%s", event.getPlayer().getName(), message))); + + recipients.clear(); + } + + private void handleRegularChat(AsyncPlayerChatEvent event, ClanInfo clan, String rank) + { + if (clan == null) + { + UtilServer.broadcast(String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), event.getMessage())); return; } + List recipients = new ArrayList<>(); + + for (Player other : UtilServer.getPlayers()) + { + ClanInfo otherClan = _clanUtility.getClanByPlayer(other); + + if (otherClan == null) + { + recipients.add(other); + } + else + { + String message = _chat.getFilteredMessage(event.getPlayer(), event.getMessage()); + ClanRelation rel = _clanUtility.rel(clan, otherClan); + + other.sendMessage(rank + rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message); + } + } + + recipients.forEach(p -> p.sendMessage(String.format(rank + C.cGold + clan.getName() + " " + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), event.getMessage()))); + + recipients.clear(); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void handlePlayerChat(AsyncPlayerChatEvent event) + { + event.setCancelled(true); + ClientClan client = Get(event.getPlayer()); if (client == null) @@ -662,76 +733,15 @@ public class ClansManager extends MiniClientPluginimplements IRelati if (client.isClanChat() && clan != null) { - event.setFormat(rank+ C.cAqua + "%1$s " + C.cDAqua + "%2$s"); - event.getRecipients().clear(); - - for (ClansPlayer cur : clan.getMembers().values()) - { - Player player = UtilPlayer.searchExact(cur.getUuid()); - - if (player == null) continue; - - event.getRecipients().add(player); - } + handleClanChat(event, clan, rank); } else if (client.isAllyChat() && clan != null) { - event.setFormat(rank+ C.cDGreen + clan.getName() + " " + C.cDGreen + "%1$s " + C.cGreen + "%2$s"); - event.getRecipients().clear(); - - for (ClansPlayer cur : clan.getMembers().values()) - { - Player player = UtilPlayer.searchExact(cur.getUuid()); - - if (player == null) continue; - - event.getRecipients().add(player); - } - - for (String allyName : clan.getAllyMap().keySet()) - { - ClanInfo ally = _clanUtility.getClanByClanName(allyName); - if (ally == null) continue; - - for (ClansPlayer cur : ally.getMembers().values()) - { - Player player = UtilPlayer.searchExact(cur.getUuid()); - - if (player == null) continue; - - event.getRecipients().add(player); - } - } + handleAllyChat(event, clan, rank); } else { - if (clan == null) - { - event.setFormat(rank + C.cYellow + "%1$s " + C.cWhite + "%2$s"); - System.out.println(_clientManager.Get(event.getPlayer()).GetRank().name() + " " + event.getPlayer().getName() + " " + event.getMessage()); - return; - } - - event.getRecipients().clear(); - event.setFormat(rank + C.cGold + clan.getName() + " " + C.cYellow + "%1$s " + C.cWhite + "%2$s"); - - for (Player other : UtilServer.getPlayers()) - { - ClanInfo otherClan = _clanUtility.getClanByPlayer(other); - - if (otherClan == null) - { - event.getRecipients().add(other); - } - else - { - String message = event.getMessage(); - message = _chat.getFilteredMessage(event.getPlayer(), message); - ClanRelation rel = _clanUtility.rel(clan, otherClan); - String formatted = rank + rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message; - other.sendMessage(formatted); - } - } + handleRegularChat(event, clan, rank); } System.out.println((clan == null ? "" : clan.getName()) + " " + _clientManager.Get(event.getPlayer()).GetRank().name() + " " + event.getPlayer().getName() + " " + event.getMessage()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 0265b77d5..28d32055f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -127,7 +127,7 @@ public class ClansCommand extends CommandBase private void forceJoin(Player caller, String[] args) { - if (!Plugin.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.getName().equals("NewGarbo")) + if (!Plugin.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.getUniqueId().toString().equals("d8646a35-33a8-43c6-9e7c-2e871a6b86c9")) { _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This requires ADMIN+ permission.")); return; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java index daffa920d..584c7dd38 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java @@ -1,6 +1,5 @@ package mineplex.game.clans.clans.outpost; -import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; @@ -11,10 +10,15 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.FallingBlock; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; -import mineplex.core.common.util.C; +import mineplex.core.common.util.ColorFader; import mineplex.core.common.util.F; import mineplex.core.common.util.LoopIterator; import mineplex.core.common.util.NonFinalInteger; @@ -25,10 +29,11 @@ import mineplex.core.common.util.UtilColor; import mineplex.core.common.util.UtilItem; 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.UtilServer; -import mineplex.core.hologram.Hologram; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansBlacklist; import mineplex.game.clans.core.repository.ClanTerritory; @@ -36,9 +41,7 @@ import net.minecraft.server.v1_8_R3.AxisAlignedBB; public class Outpost { - private final List _coreParticleColors = new ArrayList(); - - protected static final long MAX_LIFETIME = 60 * 1000; // 30 minutes + protected static final long MAX_LIFETIME = 5 * 60 * 1000; // 30 minutes private OutpostManager _host; @@ -59,9 +62,10 @@ public class Outpost private LoopIterator _circleStages; private LoopIterator _reverseCircleStages; - private long _spawnTime; + private ColorFader _fader = new ColorFader(30, UtilColor.hexToRgb(0x00A296), UtilColor.hexToRgb(0x29E6B6)); + private ColorFader _fader2 = new ColorFader(40, UtilColor.hexToRgb(0x14ffa1), UtilColor.hexToRgb(0x14ff5b), UtilColor.hexToRgb(0x61fff7)); - private long _lastConstructionSound; + private long _spawnTime; public Outpost(OutpostManager host, ClanInfo clan, Location location, OutpostType type) { @@ -78,11 +82,9 @@ public class Outpost _spawnTime = System.currentTimeMillis(); - _coreParticleColors.add(UtilColor.hexToRgb(0x00A296)); - _coreParticleColors.add(UtilColor.hexToRgb(0x29E6B6)); - _coreParticleColors.add(UtilColor.hexToRgb(0x29E67B)); + _core = _type.getCoreLocation(_middle); - beginConstruction(); + _state = OutpostState.AWAITING; } private void cleanup() @@ -93,9 +95,82 @@ public class Outpost _host.queueForRemoval(_clan.getName()); } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (getState() == OutpostState.AWAITING) + { + if (event.getClickedBlock().getType().equals(Material.NETHERRACK)) + { + beginConstruction(); + } + } + } + + @EventHandler + public void onBlockDamage(BlockDamageEvent event) + { + if (event.getBlock().getLocation().equals(_core)) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have destroyed " + F.elem(_clan.getName()) + "'s Outpost!")); + + _core.getBlock().setType(Material.AIR); + + kill(); + + + _clan.inform("Your Outpost has been destroyed!", null); + UtilTextMiddle.display("Siege", "Your Outpost has been destroyed", 20, 100, 20, _clan.getOnlinePlayersArray()); + + event.setCancelled(true); + } + } + + @EventHandler + public void onBlockBreak(BlockBreakEvent event) + { + for (OutpostBlock block : _blocks.values()) + { + if (event.getBlock().getLocation().equals(block._loc)) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not break blocks in Outposts.")); + event.setCancelled(true); + break; + } + } + } + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) + { + if (UtilAlg.inBoundingBox(event.getBlock().getLocation(), _startCorner, _endCorner)) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not place blocks in Outposts.")); + event.setCancelled(true); + } + } protected void update() { + if (_state == OutpostState.AWAITING) + { + RGBData color = _fader2.next(); + + for (int x = -_type._size; x <= _type._size; x++) + { + for (int z = -_type._size; z <= _type._size; z++) + { + if (x == -_type._size || x == _type._size || z == -_type._size || z == _type._size) + { + UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, _core.clone().add(x, 1.1, z), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 5.5f, 0, ViewDist.NORMAL); + } + } + } + + return; + } + if (_state == OutpostState.CONSTRUCTING) { if (_buildQueue.isEmpty()) @@ -115,8 +190,10 @@ public class Outpost } } + RGBData next = _fader.next(); + { - RGBData color = _state == OutpostState.LIVE ? UtilMath.randomElement(_coreParticleColors) : UtilColor.RgbRed; + RGBData color = _state == OutpostState.LIVE ? next : UtilColor.RgbRed; Vector nextCircleStage = _circleStages.next(); @@ -127,7 +204,7 @@ public class Outpost } { - RGBData color = _state == OutpostState.LIVE ? UtilMath.randomElement(_coreParticleColors) : UtilColor.RgbRed; + RGBData color = _state == OutpostState.LIVE ? next : UtilColor.RgbRed; Vector nextCircleStage = _reverseCircleStages.next(); @@ -143,8 +220,6 @@ public class Outpost _state = OutpostState.CONSTRUCTING; _blocks = new LinkedHashMap<>(_buildQueue = _type.createBuildQueue(_middle, _clan.Clans)); - _core = _type.getCoreLocation(_middle); - _circleStages = new LoopIterator(circleAround(new Vector(0., 0., 0.), 40, .6d)); List reverse = circleAround(new Vector(0., 0., 0.), 40, .6d); @@ -163,6 +238,7 @@ public class Outpost ClanInfo clan = _clan.Clans.getClanUtility().getClanByClanName(territory.Owner); clan.inform("A siege has begun near your territory!", null); + UtilTextMiddle.display("Siege", "A Siege has been declared on your Clan!", 20, 100, 20, clan.getOnlinePlayersArray()); } } } @@ -213,7 +289,7 @@ public class Outpost } FallingBlock fall = block._loc.getWorld().spawnFallingBlock(block._loc, block._id, block._data); - + fall.setDropItem(false); Vector vec = UtilAlg.getTrajectory(fall.getLocation(), _middle); UtilAction.velocity(fall, vec, 1, false, 0, 0.6, 10, false); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBlock.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBlock.java index e28c650fb..cf5b4dac9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBlock.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBlock.java @@ -5,10 +5,8 @@ import java.util.Map; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.block.BlockState; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilWorld; public class OutpostBlock diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java index 31c973d30..be963ecdf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java @@ -4,14 +4,11 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.UUID; import org.bukkit.Location; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.metadata.FixedMetadataValue; import mineplex.core.MiniPlugin; import mineplex.core.common.util.F; @@ -131,16 +128,19 @@ public class OutpostManager extends MiniPlugin @EventHandler public void update(UpdateEvent event) { - if (event.getType() == UpdateType.TICK) + for (Outpost outpost : _outposts.values()) { - for (Outpost outpost : _outposts.values()) + if (outpost.getState() != OutpostState.DEAD) { - if (outpost.getState() != OutpostState.DEAD) + if (outpost.getState() == OutpostState.CONSTRUCTING ? event.getType() == UpdateType.FASTER : event.getType() == UpdateType.TICK) { outpost.update(); } } - + } + + if (event.getType() == UpdateType.FASTER) + { if (!_removalQueue.isEmpty()) { _outposts.remove(_removalQueue.remove(0)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostState.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostState.java index 71374c64b..310e9bb59 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostState.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostState.java @@ -2,6 +2,7 @@ package mineplex.game.clans.clans.outpost; public enum OutpostState { + AWAITING, CONSTRUCTING, LIVE, DESTRUCTING, diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostType.java index 1f1defe1a..bb88bea1b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostType.java @@ -1,7 +1,6 @@ package mineplex.game.clans.clans.outpost; import java.util.LinkedHashMap; -import java.util.Map; import org.bukkit.Location; import org.bukkit.Material; 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 5b6195a54..abeabf652 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 @@ -1,20 +1,18 @@ package mineplex.game.clans.gameplay; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; - import org.bukkit.Material; import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.inventory.Recipe; +import mineplex.core.common.util.F; +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 }; + private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX, Material.FISHING_ROD, Material.BED }; @EventHandler public void onPlayerCraftItem(CraftItemEvent event) 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 46be8ef61..536a39e20 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 @@ -4,6 +4,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import javax.xml.stream.util.EventReaderDelegate; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Effect; @@ -66,6 +68,8 @@ import mineplex.game.clans.items.generation.WeightSet; import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent; +import mineplex.minecraft.game.classcombat.Skill.event.BlockTossLandEvent; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.DamageManager; @@ -102,6 +106,20 @@ public class Gameplay extends MiniPlugin // } // } + @EventHandler + public void stopBlockTossExploit(BlockTossLandEvent event) + { + int id = event.Entity.getBlockId(); + if (_clansManager.getClanUtility().isClaimed(event.getLocation()) + && (Material.getMaterial(id).name().endsWith("_PLATE") + || id == Material.STONE_BUTTON.getId() + || id == Material.WOOD_BUTTON.getId() + || id == Material.LEVER.getId())) + { + event.setCancelled(true); + } + } + @EventHandler public void onPlayerFishing(PlayerFishEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java index 9d4e04f83..c37e78a56 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java @@ -13,6 +13,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; +import org.bukkit.metadata.FixedMetadataValue; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -20,7 +21,6 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFile; import mineplex.core.common.util.UtilFile.ChunkType; import mineplex.core.common.util.UtilFile.DataFileChunk; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -28,6 +28,8 @@ import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; +import mineplex.game.clans.Clans; +import mineplex.game.clans.clans.ClansManager; public class CombatLogNPC { @@ -188,6 +190,7 @@ public class CombatLogNPC { Location spawnLoc = player.getLocation(); Skeleton skel = player.getWorld().spawn(spawnLoc, Skeleton.class); + skel.setMetadata("CombatLogNPC", new FixedMetadataValue(ClansManager.getInstance().getPlugin(), player.getUniqueId().toString())); skel.teleport(spawnLoc); skel.setHealth(_spawnHealth); UtilEnt.Vegetate(skel); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/NPCManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/NPCManager.java index 57b3ae3c2..5998a312f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/NPCManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/NPCManager.java @@ -8,10 +8,12 @@ import org.bukkit.GameMode; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.world.ChunkUnloadEvent; import mineplex.core.MiniPlugin; @@ -20,6 +22,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.spawn.Spawn; import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class NPCManager extends MiniPlugin @@ -74,6 +77,18 @@ public class NPCManager extends MiniPlugin } } + @EventHandler + public void killNpcs(PlayerJoinEvent event) + { + for (LivingEntity entity : Spawn.getSpawnWorld().getLivingEntities()) + { + if (entity.hasMetadata("CombatLogNPC")) + { + entity.remove(); + } + } + } + public void despawnLogoutNpc(Player player) { CombatLogNPC npc = getLogoutNpc(player); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java index 83a5c7dcc..ab9a84425 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java @@ -55,6 +55,8 @@ public class CustomItem private boolean _dullEnchantment; + public String OriginalOwner = null; + public String getUuid() { return _uuid; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index c3a3acc07..08b86bc5a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -8,7 +8,9 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; @@ -23,6 +25,7 @@ import com.google.gson.GsonBuilder; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -64,10 +67,8 @@ import mineplex.game.clans.items.legendaries.WindBlade; import mineplex.game.clans.items.smelting.SmeltingListener; import mineplex.game.clans.items.ui.GearShop; import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory; - import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutChat; import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; @@ -362,6 +363,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable } catch (Exception exception) { + exception.printStackTrace(); System.out.println("=========="); System.out.println("GearManager parse problem :"); System.out.println(serialization); @@ -482,7 +484,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable if (packet instanceof PacketPlayOutSetSlot) { PacketPlayOutSetSlot slotPacket = (PacketPlayOutSetSlot) packet; - slotPacket.c = maskItem(slotPacket.c); // Mask all out-going item + slotPacket.c = maskItem(slotPacket.c, packetInfo.getPlayer()); // Mask all out-going item // packets } else if (packet instanceof PacketPlayOutWindowItems) @@ -491,7 +493,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable for (int i = 0; i < itemsPacket.b.length; i++) { - itemsPacket.b[i] = maskItem(itemsPacket.b[i]); // Mask all + itemsPacket.b[i] = maskItem(itemsPacket.b[i], packetInfo.getPlayer()); // Mask all // out-going // item packets ItemStack item = CraftItemStack.asCraftMirror(itemsPacket.b[i]); @@ -515,7 +517,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable return item; } - private net.minecraft.server.v1_8_R3.ItemStack maskItem(net.minecraft.server.v1_8_R3.ItemStack item) + private net.minecraft.server.v1_8_R3.ItemStack maskItem(net.minecraft.server.v1_8_R3.ItemStack item, Player player) { // Cannot mask a null item if (item == null) @@ -534,18 +536,21 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable List lore = new ArrayList(); + CustomItem ci = parseItem(originalItem); + for (String line : originalMeta.getLore()) { - if (!line.startsWith(ITEM_SERIALIZATION_TAG)) // Remove - // serialization - // lines from - // out-going lore + if (!line.startsWith(ITEM_SERIALIZATION_TAG)) { lore.add(line); - }else{ } } + if (ci != null && _legendaryWeights.elements().contains(ci.getClass())) + { + lore.add(C.cWhite + "Original Owner: " + C.cYellow + (ci.OriginalOwner == null ? "You" : Bukkit.getOfflinePlayer(UUID.fromString(ci.OriginalOwner)).getName())); + } + net.minecraft.server.v1_8_R3.ItemStack newItem = CraftItemStack.asNMSCopy(originalItem); CraftItemStack newCopy = CraftItemStack.asCraftMirror(newItem); ItemMeta newMeta = newCopy.getItemMeta(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java index fbc03131d..31ae1a3cd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java @@ -3,6 +3,9 @@ package mineplex.game.clans.items; import java.util.HashSet; import java.util.Set; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilServer; import mineplex.game.clans.items.legendaries.LegendaryItem; import mineplex.minecraft.game.core.damage.CustomDamageEvent; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java index ffa649364..312e6b5f5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java @@ -7,6 +7,9 @@ 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; +import mineplex.core.common.util.UtilServer; import mineplex.game.clans.items.CustomItem; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -55,6 +58,12 @@ public class LegendaryItem extends CustomItem _lastBlock = System.currentTimeMillis(); } + if (OriginalOwner == null) + { + OriginalOwner = event.getPlayer().getUniqueId().toString(); + UtilServer.broadcast(F.main("Clans", F.elem(event.getPlayer().getName()) + " has picked up " + F.vowelAN(getDisplayName()) + " " + getDisplayName() + C.mBody + ".")); + } + super.onInteract(event); } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index 74e19ca6d..bddac25dd 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -369,7 +369,7 @@ public class ClientClass UtilPlayer.message(caller, F.main("Skill", "Listing Class Skills:")); for (SkillType type : SkillType.values()) - if (caller.isOp() || type != SkillType.Class) + if ((caller != null && caller.isOp()) || type != SkillType.Class) if (_skillMap.containsKey(type)) UtilPlayer.message(caller, F.desc(type.toString(), _skillMap.get(type).GetName() + " Lvl" + _skillMap.get(type).getLevel(caller))); } 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 e7fcc5bd5..cb7be682b 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 @@ -37,6 +37,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.classcombat.Skill.SkillCharge; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent; import mineplex.minecraft.game.classcombat.Skill.event.BlockTossExpireEvent; import mineplex.minecraft.game.classcombat.Skill.event.BlockTossLandEvent; import mineplex.minecraft.game.classcombat.Skill.event.SkillEvent; @@ -239,13 +240,15 @@ public class BlockToss extends SkillCharge implements IThrown //Throw cur.eject(); double mult = Math.max(0.4, charge * 2); - + + Material mat = Material.getMaterial(block.getBlockId()); + //Action UtilAction.velocity(block, cur.getLocation().getDirection(), mult, false, 0, 0, 1, true); Factory.Projectile().AddThrow(block, cur, this, -1, true, true, true, true, null, 0, 0, null, 0, UpdateType.FASTEST, 1.2f); - //Event + // Generic Event UtilServer.getServer().getPluginManager().callEvent(new SkillEvent(cur, GetName(), ClassType.Brute)); } } @@ -369,7 +372,7 @@ public class BlockToss extends SkillCharge implements IThrown { if (!event.getBlock().getType().isSolid()) // Falling block is landing and turning block from air to type { - BlockTossLandEvent landEvent = new BlockTossLandEvent(event.getBlock()); + BlockTossLandEvent landEvent = new BlockTossLandEvent(event.getBlock(), ((FallingBlock) event.getEntity())); Bukkit.getServer().getPluginManager().callEvent(landEvent); if (landEvent.isCancelled()) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/event/BlockTossLandEvent.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/event/BlockTossLandEvent.java index 4cc50dd18..908e13720 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/event/BlockTossLandEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/event/BlockTossLandEvent.java @@ -9,9 +9,11 @@ import org.bukkit.event.HandlerList; public class BlockTossLandEvent extends BlockTossEvent { - - public BlockTossLandEvent(Block block) + public FallingBlock Entity; + + public BlockTossLandEvent(Block block, FallingBlock fallingBlock) { super(block); + Entity = fallingBlock; } } From 76c02308055b04b324e8d118d442d13096990c65 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 6 Jan 2016 22:35:09 +0000 Subject: [PATCH 40/65] quikc change --- .../mineplex/game/clans/items/legendaries/LegendaryItem.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java index 312e6b5f5..77438b0d7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java @@ -10,6 +10,7 @@ import org.bukkit.potion.PotionEffectType; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.game.clans.items.CustomItem; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -62,6 +63,7 @@ public class LegendaryItem extends CustomItem { OriginalOwner = event.getPlayer().getUniqueId().toString(); UtilServer.broadcast(F.main("Clans", F.elem(event.getPlayer().getName()) + " has picked up " + F.vowelAN(getDisplayName()) + " " + getDisplayName() + C.mBody + ".")); + UtilTextMiddle.display("", F.elem(event.getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(getDisplayName()) + " " + getDisplayName() + C.cWhite + "."); } super.onInteract(event); From ef929b39b363f74359188948cdd4e0e6a4d58b55 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 6 Jan 2016 22:38:45 +0000 Subject: [PATCH 41/65] updated clans version --- Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 9cc138083..af5cd7a67 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -51,7 +51,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer; public class Clans extends JavaPlugin { - public static final String VERSION = "0.17d"; + public static final String VERSION = "0.18"; private String WEB_CONFIG = "webServer"; // Modules From b685a207bc2a3d33dd30d37d2de0d0518ac42b00 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Thu, 7 Jan 2016 09:34:16 +0000 Subject: [PATCH 42/65] quick modification to outposts, and fixed the legendary announcements being weird --- .../mineplex/core/common/util/UtilColor.java | 1 + .../mineplex/core/common/util/UtilText.java | 26 ++- .../mineplex/game/clans/clans/ClanInfo.java | 24 ++- .../game/clans/clans/ClansManager.java | 8 +- .../game/clans/clans/commands/Meow.java | 4 +- .../game/clans/clans/outpost/Outpost.java | 159 ++++++++++++------ .../clans/clans/outpost/OutpostManager.java | 49 ++++-- .../game/clans/gameplay/Gameplay.java | 4 - .../mineplex/game/clans/items/PlayerGear.java | 11 +- .../items/legendaries/LegendaryItem.java | 6 +- .../clans/items/legendaries/WindBlade.java | 2 +- 11 files changed, 206 insertions(+), 88 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java index 5a2692655..32244ece9 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java @@ -9,6 +9,7 @@ public class UtilColor { public static final RGBData RgbRed = hexToRgb(0xee0100); public static final RGBData RgbGold = hexToRgb(0xffd014); + public static final RGBData RgbLightBlue = hexToRgb(0x61fff7); public static byte chatColorToClayData(ChatColor chatColor) { 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 38e540824..d498a6d94 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 @@ -13,6 +13,7 @@ import mineplex.core.common.CurrencyType; import org.apache.commons.lang.WordUtils; import org.bukkit.ChatColor; +import org.bukkit.entity.Player; public class UtilText { @@ -166,7 +167,7 @@ public class UtilText return fillLine(" ", div) + string + fillLine(" ", div); } - + public static String alignRight(String string, LineFormat lineFormat) { int length = getLength(string); @@ -621,5 +622,28 @@ public class UtilText { return arrayToString(array, null); } + + public static String getProgress(String prefix, double amount, String suffix, boolean progressDirectionSwap) + { + if (progressDirectionSwap) + amount = 1 - amount; + + //Generate Bar + int bars = 24; + String progressBar = C.cGreen + ""; + boolean colorChange = false; + for (int i=0 ; i= amount) + { + progressBar += C.cRed; + colorChange = true; + } + + progressBar += "▌"; + } + return(prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar + (suffix == null ? "" : ChatColor.RESET + " " + suffix); + } + } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java index 4a511c5f7..fac283def 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java @@ -20,19 +20,19 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; 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.common.util.UtilWorld; import mineplex.game.clans.clans.ClansUtility.ClanRelation; -import mineplex.game.clans.core.war.ClanWarData; -import net.minecraft.server.v1_8_R3.Material; +import mineplex.game.clans.clans.tntGenerator.TntGenerator; import mineplex.game.clans.core.repository.tokens.ClanAllianceToken; import mineplex.game.clans.core.repository.tokens.ClanMemberToken; import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken; import mineplex.game.clans.core.repository.tokens.ClanToken; - -import mineplex.game.clans.clans.tntGenerator.TntGenerator; import mineplex.game.clans.core.repository.tokens.ClanWarToken; +import mineplex.game.clans.core.war.ClanWarData; +import net.minecraft.server.v1_8_R3.Material; public class ClanInfo { @@ -374,6 +374,22 @@ public class ClanInfo player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 2f); } } + + public void inform(String top, String bottom, String ignore) + { + for (UUID cur : getMembers().keySet()) + { + Player player = UtilPlayer.searchExact(cur); + + if (player == null) + continue; + + if (player.getName().equals(ignore)) + continue; + + UtilTextMiddle.display(top, bottom, 20, 100, 20, player); + } + } public String getName() { 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 710ff13d5..91e4d7f0b 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 @@ -4,7 +4,6 @@ import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.TimeZone; @@ -29,8 +28,6 @@ import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.Recipe; -import org.bukkit.inventory.ShapedRecipe; import org.bukkit.plugin.java.JavaPlugin; import com.google.common.io.ByteArrayDataOutput; @@ -210,7 +207,10 @@ public class ClansManager extends MiniClientPluginimplements IRelati { super("Clans Manager", plugin); - if (serverName.equals("GarboClans-1")) addCommand(new Meow(new OutpostManager(this))); + if (serverName.equals("GarboClans-1")) + { + addCommand(new Meow(new OutpostManager(this))); + } _instance = this; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/Meow.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/Meow.java index 738392939..b6bc54b64 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/Meow.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/Meow.java @@ -4,8 +4,8 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.game.clans.clans.outpost.Outpost; import mineplex.game.clans.clans.outpost.OutpostManager; -import mineplex.game.clans.clans.outpost.OutpostType; public class Meow extends CommandBase { @@ -17,6 +17,6 @@ public class Meow extends CommandBase @Override public void Execute(Player caller, String[] args) { - Plugin.Spawn(caller, caller.getLocation().getBlock().getLocation(), OutpostType.ORIGINAL_CLANS); + caller.getInventory().addItem(Outpost.OUTPOST_ITEM); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java index 584c7dd38..6d90e9d3f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java @@ -11,13 +11,16 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; +import mineplex.core.common.util.C; import mineplex.core.common.util.ColorFader; import mineplex.core.common.util.F; import mineplex.core.common.util.LoopIterator; @@ -26,29 +29,35 @@ import mineplex.core.common.util.RGBData; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilItem; 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.UtilServer; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.hologram.Hologram; +import mineplex.core.itemstack.ItemBuilder; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansBlacklist; import mineplex.game.clans.core.repository.ClanTerritory; import net.minecraft.server.v1_8_R3.AxisAlignedBB; -public class Outpost +public class Outpost implements Listener { protected static final long MAX_LIFETIME = 5 * 60 * 1000; // 30 minutes + public static final ItemStack OUTPOST_ITEM = new ItemBuilder(Material.NETHERRACK, 1).setRawTitle(C.cBlue + "Outpost").setLore("Seems to be a mystical contraption of some sort!").build(); + public static final byte OUTPOST_BLOCK_DATA = (byte) 137; private OutpostManager _host; private ClanInfo _clan; private Location _startCorner; - private Location _middle; + private Location _origin; private Location _endCorner; private Location _core; @@ -59,11 +68,13 @@ public class Outpost private OutpostType _type; private OutpostState _state; + private Hologram _preHologram; + private Hologram _preHologram2; + private LoopIterator _circleStages; private LoopIterator _reverseCircleStages; private ColorFader _fader = new ColorFader(30, UtilColor.hexToRgb(0x00A296), UtilColor.hexToRgb(0x29E6B6)); - private ColorFader _fader2 = new ColorFader(40, UtilColor.hexToRgb(0x14ffa1), UtilColor.hexToRgb(0x14ff5b), UtilColor.hexToRgb(0x61fff7)); private long _spawnTime; @@ -76,13 +87,19 @@ public class Outpost _startCorner = location.clone().subtract(type._size, 1, type._size); _endCorner = location.clone().add(type._size, type._ySize - 1, type._size); - _middle = location.clone(); + _origin = location.clone(); _type = type; _spawnTime = System.currentTimeMillis(); - _core = _type.getCoreLocation(_middle); + _core = _type.getCoreLocation(_origin); + + _preHologram = new Hologram(_clan.Clans.getHologramManager(), _origin.clone().add(0, 2, 0), F.elem(_clan.getName()) + "'s Outpost block."); + _preHologram2 = new Hologram(_clan.Clans.getHologramManager(), _origin.clone().add(0, 1, 0), UtilText.getProgress(null, 0, null, true)); + + _preHologram.start(); + _preHologram2.start(); _state = OutpostState.AWAITING; } @@ -95,11 +112,27 @@ public class Outpost _host.queueForRemoval(_clan.getName()); } - + @EventHandler public void onInteract(PlayerInteractEvent event) { - if (getState() == OutpostState.AWAITING) + if (getState() != OutpostState.AWAITING) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + { + return; + } + + if (!_clan.equals(_clan.Clans.getClanUtility().getClanByPlayer(event.getPlayer()))) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "This is not yours to activate!")); + return; + } + + if (event.getClickedBlock() != null && _origin.equals(event.getClickedBlock().getLocation())) { if (event.getClickedBlock().getType().equals(Material.NETHERRACK)) { @@ -119,7 +152,6 @@ public class Outpost kill(); - _clan.inform("Your Outpost has been destroyed!", null); UtilTextMiddle.display("Siege", "Your Outpost has been destroyed", 20, 100, 20, _clan.getOnlinePlayersArray()); @@ -130,14 +162,20 @@ public class Outpost @EventHandler public void onBlockBreak(BlockBreakEvent event) { - for (OutpostBlock block : _blocks.values()) + if (getState() == OutpostState.AWAITING && event.getBlock().getLocation().equals(_origin)) { - if (event.getBlock().getLocation().equals(block._loc)) - { - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not break blocks in Outposts.")); - event.setCancelled(true); - break; - } + _origin.getBlock().setType(Material.AIR); + _origin.getWorld().dropItem(_origin, OUTPOST_ITEM); + _clan.inform("Your Outpost block has been destroyed.", null); + cleanup(); + event.setCancelled(true); + return; + } + + if (UtilAlg.inBoundingBox(event.getBlock().getLocation(), _startCorner, _endCorner)) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not break blocks in Outposts.")); + event.setCancelled(true); } } @@ -155,7 +193,17 @@ public class Outpost { if (_state == OutpostState.AWAITING) { - RGBData color = _fader2.next(); + if (getLifetime() > 60000) + { + _origin.getBlock().setType(Material.AIR); + _clan.inform("You have lost your Outpost block, as no one activated it fast enough!", null); + cleanup(); + return; + } + + _preHologram2.setText(UtilText.getProgress(null, UtilMath.clamp(getLifetime(), 0., 60000.) / 60000., null, true)); + + RGBData color = UtilColor.RgbLightBlue; for (int x = -_type._size; x <= _type._size; x++) { @@ -163,7 +211,7 @@ public class Outpost { if (x == -_type._size || x == _type._size || z == -_type._size || z == _type._size) { - UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, _core.clone().add(x, 1.1, z), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 5.5f, 0, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, _origin.clone().add(x + .5, .1, z + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 5.5f, 0, ViewDist.NORMAL); } } } @@ -217,8 +265,17 @@ public class Outpost public void beginConstruction() { + // Cleanup pre-Outpost stuff + _preHologram.stop(); + _preHologram2.stop(); + + _preHologram = null; + _preHologram = null; + _state = OutpostState.CONSTRUCTING; - _blocks = new LinkedHashMap<>(_buildQueue = _type.createBuildQueue(_middle, _clan.Clans)); + _blocks = new LinkedHashMap<>(_buildQueue = _type.createBuildQueue(_origin, _clan.Clans)); + + _clan.inform("Siege", "Your Outpost is now being constructed.", null); _circleStages = new LoopIterator(circleAround(new Vector(0., 0., 0.), 40, .6d)); @@ -231,7 +288,7 @@ public class Outpost { for (int chunkZ = -3; chunkZ < 3; chunkZ++) { - ClanTerritory territory = _clan.Clans.getClanUtility().getClaim(_middle.getWorld().getChunkAt(_middle.getChunk().getX() + chunkX, _middle.getChunk().getZ() + chunkZ)); + ClanTerritory territory = _clan.Clans.getClanUtility().getClaim(_origin.getWorld().getChunkAt(_origin.getChunk().getX() + chunkX, _origin.getChunk().getZ() + chunkZ)); if (territory != null && ClansBlacklist.isValidClanName(territory.Owner)) { @@ -263,45 +320,43 @@ public class Outpost { _state = OutpostState.DESTRUCTING; - UtilServer.getPlayersCollection().stream().filter(p -> p.getLocation().distance(_middle) < 64).forEach(p -> { - NonFinalInteger wait = new NonFinalInteger(0); + NonFinalInteger wait = new NonFinalInteger(0); + + _blocks.values().forEach(block -> { + if (UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean()) + { + return; + } + _host.runSyncLater(() -> { + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, block._loc, new Vector(0,0,0), 0.1f, 3, ViewDist.LONG); + _origin.getWorld().playSound(block._loc, Sound.EXPLODE, 1.0f, 1.0f); + }, wait.add(4 + UtilMath.random.nextInt(10)).get()); + }); + + _host.runSyncLater(() -> { _blocks.values().forEach(block -> { - if (UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean()) + Material mat = Material.getMaterial(block._id); + + if (UtilItem.isTranslucent(mat)) { + block.restore(); return; } - _host.runSyncLater(() -> { - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, block._loc, new Vector(0,0,0), 0.1f, 3, ViewDist.LONG, p); - p.playSound(block._loc, Sound.EXPLODE, 1.0f, 1.0f); - }, wait.add(4 + UtilMath.random.nextInt(10)).get()); - }); + FallingBlock fall = block._loc.getWorld().spawnFallingBlock(block._loc, block._id, block._data); + fall.setDropItem(false); + Vector vec = UtilAlg.getTrajectory(fall.getLocation(), getExactMiddle()); - _host.runSyncLater(() -> { - _blocks.values().forEach(block -> { - Material mat = Material.getMaterial(block._id); - - if (UtilItem.isTranslucent(mat)) - { - block.restore(); - return; - } - - FallingBlock fall = block._loc.getWorld().spawnFallingBlock(block._loc, block._id, block._data); - fall.setDropItem(false); - Vector vec = UtilAlg.getTrajectory(fall.getLocation(), _middle); - - UtilAction.velocity(fall, vec, 1, false, 0, 0.6, 10, false); - - fall.setMetadata("ClansOutpost", new FixedMetadataValue(_clan.Clans.getPlugin(), _clan.getName())); - - block.restore(); - }); + UtilAction.velocity(fall, vec, 1, false, 0, 0.6, 10, false); - cleanup(); - }, wait.get() + 5L); - }); + fall.setMetadata("ClansOutpost", new FixedMetadataValue(_clan.Clans.getPlugin(), _clan.getName())); + + block.restore(); + }); + + cleanup(); + }, wait.get() + 5L); _clan.inform("Your Clan's Outpost has been destroyed.", null); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java index be963ecdf..4d50eeb19 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java @@ -8,6 +8,9 @@ import java.util.Map; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; import mineplex.core.MiniPlugin; @@ -16,6 +19,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; @@ -39,18 +43,35 @@ public class OutpostManager extends MiniPlugin _removalQueue = new ArrayList<>(); } - public void Spawn(Player player, Location location, OutpostType type) + @EventHandler(priority = EventPriority.LOWEST) + public void onPlaceBlock(BlockPlaceEvent event) + { + if (event.getItemInHand().isSimilar(Outpost.OUTPOST_ITEM)) + { + if (!Recharge.Instance.use(event.getPlayer(), "Place Outpost", 10000, true, false)) + { + event.setCancelled(true); + } + + if (Spawn(event.getPlayer(), event.getBlock().getLocation(), OutpostType.ORIGINAL_CLANS)) + { + event.getBlock().setData((byte) Outpost.OUTPOST_BLOCK_DATA); + } + } + } + + public boolean Spawn(Player player, Location location, OutpostType type) { if (!_clansManager.isInClan(player)) { UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place an Outpost.")); - return; + return false; } if (location.getBlockY() < 10) { UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost this deep.")); - return; + return false; } ClanInfo clan = _clansManager.getClan(player); @@ -58,27 +79,27 @@ public class OutpostManager extends MiniPlugin if (UtilItem.isBoundless(location.clone().subtract(0, 1, 0).getBlock().getType())) { UtilPlayer.message(player, F.main("Clans", "An Outpost must not be placed floating.")); - return; + return false; } if (Get(clan) != null) { UtilPlayer.message(player, F.main("Clans", "Your clan already has an outpost")); - return; + return false; } if (_clansManager.getClanUtility().getClaim(location) != null) { UtilPlayer.message(player, F.main("Clans", "An Outpost must be placed in the Wilderness.")); - return; + return false; } for (Outpost outpost : _outposts.values()) { - if (UtilMath.offset(location, outpost.getExactMiddle()) < 10) + if (UtilMath.offset(location, outpost.getExactMiddle()) < 14) { UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost near other Outposts.")); - return; + return false; } } @@ -88,18 +109,22 @@ public class OutpostManager extends MiniPlugin { for (int z = -type._size; z < type._size; z++) { - Location loc = location.clone(); + Location loc = location.clone().add(x, y, z); if (_clansManager.getClanUtility().isClaimed(loc)) { UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost where it may intersect with claimed territory.")); - return; + return false; } } } } _outposts.put(clan.getName(), new Outpost(this, clan, location, type)); + + _plugin.getServer().getPluginManager().registerEvents(_outposts.get(clan.getName()), _plugin); + + return true; } @EventHandler @@ -119,7 +144,7 @@ public class OutpostManager extends MiniPlugin if (outpost.getBounds().b(UtilAlg.toBoundingBox(event.getClaimedChunk().getBlock(0, 0, 0).getLocation(), event.getClaimedChunk().getBlock(15, 254, 15).getLocation()))) { event.setCancelled(true); - UtilPlayer.message(event.getClaimer(), F.main("Clans", "You cannot claim this territory as it overlaps with a " + F.elem(outpost.getClan().getName()) + "'s Outpost.")); + UtilPlayer.message(event.getClaimer(), F.main("Clans", "You cannot claim this territory as it overlaps with " + F.elem(outpost.getClan().getName()) + "'s Outpost.")); break; } } @@ -143,7 +168,7 @@ public class OutpostManager extends MiniPlugin { if (!_removalQueue.isEmpty()) { - _outposts.remove(_removalQueue.remove(0)); + HandlerList.unregisterAll(_outposts.remove(_removalQueue.remove(0))); } } 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 536a39e20..487947497 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 @@ -4,15 +4,12 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import javax.xml.stream.util.EventReaderDelegate; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -69,7 +66,6 @@ import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent; import mineplex.minecraft.game.classcombat.Skill.event.BlockTossLandEvent; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.DamageManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java index 31ae1a3cd..e5c9d2e11 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java @@ -3,20 +3,16 @@ package mineplex.game.clans.items; import java.util.HashSet; import java.util.Set; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilServer; -import mineplex.game.clans.items.legendaries.LegendaryItem; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import mineplex.game.clans.items.legendaries.LegendaryItem; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + /** * PlayerGear caches and manages a players set of {@link CustomItem}s that they * currently wield. @@ -58,6 +54,7 @@ public class PlayerGear if (item != null && item instanceof LegendaryItem) { LegendaryItem legendary = (LegendaryItem) item; + legendary.preUpdate(getPlayer()); legendary.update(getPlayer()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java index 77438b0d7..e20ceaa54 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java @@ -34,6 +34,10 @@ public class LegendaryItem extends CustomItem // Leave implementation to potential subtypes } + public void preUpdate(Player wielder) + { + } + public void onAttack(CustomDamageEvent event, Player wielder) { // Leave implementation to potential subtypes @@ -63,7 +67,7 @@ public class LegendaryItem extends CustomItem { OriginalOwner = event.getPlayer().getUniqueId().toString(); UtilServer.broadcast(F.main("Clans", F.elem(event.getPlayer().getName()) + " has picked up " + F.vowelAN(getDisplayName()) + " " + getDisplayName() + C.mBody + ".")); - UtilTextMiddle.display("", F.elem(event.getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(getDisplayName()) + " " + getDisplayName() + C.cWhite + "."); + UtilTextMiddle.display(C.cPurple + "Legendary", F.elem(event.getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(getDisplayName()) + " " + getDisplayName() + C.cWhite + "."); } super.onInteract(event); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java index 921f00d61..1ef288b15 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java @@ -74,7 +74,7 @@ public class WindBlade extends LegendaryItem _burnoutThreshold = 0; } - if (_messageTimer % 20 == 0) + if (_messageTimer % 5 == 0) { UtilPlayer.message(wielder, F.main("Wind Blade", "Flight power damaged whilst scraping the ground! Repairs will be finish in " + F.time(UtilTime.MakeStr(burnoutRemaining)) + ".")); } From e9789b2ee812960dc75bba7973aebbcb6228ac77 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Thu, 7 Jan 2016 10:31:23 +0000 Subject: [PATCH 43/65] legendary pickkup message fix (FINALLY FIXED NOW ) --- .../game/clans/clans/outpost/OutpostManager.java | 4 ++++ .../src/mineplex/game/clans/items/PlayerGear.java | 13 +++++++++++++ .../game/clans/items/legendaries/LegendaryItem.java | 7 ------- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java index 4d50eeb19..57e174d48 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java @@ -57,6 +57,10 @@ public class OutpostManager extends MiniPlugin { event.getBlock().setData((byte) Outpost.OUTPOST_BLOCK_DATA); } + else + { + event.setCancelled(true); + } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java index e5c9d2e11..a2592a9f6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java @@ -10,6 +10,10 @@ import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.game.clans.items.legendaries.LegendaryItem; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -56,6 +60,15 @@ public class PlayerGear LegendaryItem legendary = (LegendaryItem) item; legendary.preUpdate(getPlayer()); legendary.update(getPlayer()); + + if (legendary.OriginalOwner == null) + { + legendary.OriginalOwner = getPlayer().getUniqueId().toString(); + UtilServer.broadcast(F.main("Clans", F.elem(getPlayer().getName()) + " has picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.mBody + ".")); + UtilTextMiddle.display(C.cPurple + "Legendary", F.elem(getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.cWhite + "."); + + getPlayer().setItemInHand(legendary.toItemStack()); + } } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java index e20ceaa54..f2e66865d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java @@ -63,13 +63,6 @@ public class LegendaryItem extends CustomItem _lastBlock = System.currentTimeMillis(); } - if (OriginalOwner == null) - { - OriginalOwner = event.getPlayer().getUniqueId().toString(); - UtilServer.broadcast(F.main("Clans", F.elem(event.getPlayer().getName()) + " has picked up " + F.vowelAN(getDisplayName()) + " " + getDisplayName() + C.mBody + ".")); - UtilTextMiddle.display(C.cPurple + "Legendary", F.elem(event.getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(getDisplayName()) + " " + getDisplayName() + C.cWhite + "."); - } - super.onInteract(event); } From 5c810a46c92e7abaf85e8e3838e72fa86bc4d6f0 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Thu, 7 Jan 2016 13:26:18 +0000 Subject: [PATCH 44/65] holograms above outpost block should be centered in the block and made them despawn on outpost death --- .../game/clans/clans/outpost/Outpost.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java index 6d90e9d3f..abc6389cf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java @@ -95,8 +95,8 @@ public class Outpost implements Listener _core = _type.getCoreLocation(_origin); - _preHologram = new Hologram(_clan.Clans.getHologramManager(), _origin.clone().add(0, 2, 0), F.elem(_clan.getName()) + "'s Outpost block."); - _preHologram2 = new Hologram(_clan.Clans.getHologramManager(), _origin.clone().add(0, 1, 0), UtilText.getProgress(null, 0, null, true)); + _preHologram = new Hologram(_clan.Clans.getHologramManager(), _origin.clone().add(0.5, 2.3, 0.5), F.elem(_clan.getName()) + C.cWhite + "'s Outpost block"); + _preHologram2 = new Hologram(_clan.Clans.getHologramManager(), _origin.clone().add(0.5, 3, 0.5), "Despawning: " + UtilText.getProgress(null, 0, null, true)); _preHologram.start(); _preHologram2.start(); @@ -108,6 +108,12 @@ public class Outpost implements Listener { _blocks = null; + _preHologram.stop(); + _preHologram2.stop(); + + _preHologram = null; + _preHologram = null; + _state = OutpostState.DEAD; _host.queueForRemoval(_clan.getName()); @@ -150,11 +156,19 @@ public class Outpost implements Listener _core.getBlock().setType(Material.AIR); - kill(); _clan.inform("Your Outpost has been destroyed!", null); UtilTextMiddle.display("Siege", "Your Outpost has been destroyed", 20, 100, 20, _clan.getOnlinePlayersArray()); + if (getState() == OutpostState.AWAITING) + { + cleanup(); + } + else + { + kill(); + } + event.setCancelled(true); } } From d4fdda8ef2269aaf1e2b7f95fa2f770883194b9f Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Thu, 7 Jan 2016 14:03:15 +0000 Subject: [PATCH 45/65] fixed outpost being built instantly on output block place. cleaned up a bit --- .../src/mineplex/game/clans/clans/outpost/Outpost.java | 5 +++++ .../mineplex/game/clans/clans/outpost/OutpostManager.java | 1 + .../mineplex/game/clans/items/legendaries/LegendaryItem.java | 4 ---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java index abc6389cf..d427f8254 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java @@ -132,6 +132,11 @@ public class Outpost implements Listener return; } + if (getLifetime() <= 2000) + { + return; + } + if (!_clan.equals(_clan.Clans.getClanUtility().getClanByPlayer(event.getPlayer()))) { UtilPlayer.message(event.getPlayer(), F.main("Clans", "This is not yours to activate!")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java index 57e174d48..d3b81a23b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java @@ -51,6 +51,7 @@ public class OutpostManager extends MiniPlugin if (!Recharge.Instance.use(event.getPlayer(), "Place Outpost", 10000, true, false)) { event.setCancelled(true); + return; } if (Spawn(event.getPlayer(), event.getBlock().getLocation(), OutpostType.ORIGINAL_CLANS)) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java index f2e66865d..13094784a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java @@ -7,10 +7,6 @@ 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; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; import mineplex.game.clans.items.CustomItem; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; From 90a06d97b57065ac976e1751d80b52b1ea3deae5 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Thu, 7 Jan 2016 14:04:26 +0000 Subject: [PATCH 46/65] fixed npe on cleanup() because it doesn't check if the holograms are null or not. (they may or may not be null at the time of cleanup() being called depending on the current state of the outpost) --- .../src/mineplex/game/clans/clans/outpost/Outpost.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java index d427f8254..6288a3947 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java @@ -108,8 +108,8 @@ public class Outpost implements Listener { _blocks = null; - _preHologram.stop(); - _preHologram2.stop(); + if (_preHologram != null) _preHologram.stop(); + if (_preHologram2 != null) _preHologram2.stop(); _preHologram = null; _preHologram = null; From fff6d8e03f0eef64d349bd0943d19f5f64d3224d Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Thu, 7 Jan 2016 19:36:52 +0000 Subject: [PATCH 47/65] added server shutdown event, along with making the outposts cleanup on server shutdown to prevent debris of currently in-play outposts sticking around. --- .../common/events/ServerShutdownEvent.java | 33 +++++++++++++++++++ .../src/mineplex/game/clans/Clans.java | 3 ++ .../game/clans/clans/outpost/Outpost.java | 12 +++++-- .../clans/clans/outpost/OutpostManager.java | 10 ++++++ .../Mineplex.Hub/src/mineplex/hub/Hub.java | 4 +-- .../src/nautilus/game/arcade/Arcade.java | 16 +++++---- 6 files changed, 67 insertions(+), 11 deletions(-) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/ServerShutdownEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/ServerShutdownEvent.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/ServerShutdownEvent.java new file mode 100644 index 000000000..70bf8f99d --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/ServerShutdownEvent.java @@ -0,0 +1,33 @@ +package mineplex.core.common.events; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.plugin.java.JavaPlugin; + +public class ServerShutdownEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private JavaPlugin _plugin; + + public ServerShutdownEvent(JavaPlugin plugin) + { + _plugin = plugin; + } + + public JavaPlugin getPlugin() + { + return _plugin; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 2c0819d99..5d8be3794 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -13,6 +13,7 @@ import mineplex.core.antihack.AntiHack; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; +import mineplex.core.common.events.ServerShutdownEvent; import mineplex.core.delayedtask.DelayedTask; import mineplex.core.donation.DonationManager; import mineplex.core.explosion.Explosion; @@ -175,5 +176,7 @@ public class Clans extends JavaPlugin // Need to notify WorldEventManager of server shutdown, this seemed like // the only decent way to do it _clansManager.onDisable(); + + getServer().getPluginManager().callEvent(new ServerShutdownEvent(this)); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java index 6288a3947..82d48ff07 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java @@ -109,10 +109,10 @@ public class Outpost implements Listener _blocks = null; if (_preHologram != null) _preHologram.stop(); - if (_preHologram2 != null) _preHologram2.stop(); + if (_preHologram2 != null) _preHologram2.stop(); _preHologram = null; - _preHologram = null; + _preHologram2 = null; _state = OutpostState.DEAD; @@ -147,6 +147,7 @@ public class Outpost implements Listener { if (event.getClickedBlock().getType().equals(Material.NETHERRACK)) { + _origin.getBlock().setType(Material.AIR); beginConstruction(); } } @@ -334,6 +335,13 @@ public class Outpost implements Listener return list; } + + public void instakill() + { + _blocks.values().forEach(OutpostBlock::restore); + + cleanup(); + } public void kill() { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java index d3b81a23b..7f0e5c7ff 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java @@ -14,6 +14,7 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; import mineplex.core.MiniPlugin; +import mineplex.core.common.events.ServerShutdownEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilItem; @@ -141,6 +142,15 @@ public class OutpostManager extends MiniPlugin } } + @EventHandler + public void onServerShutdown(ServerShutdownEvent event) + { + for (Outpost outpost : _outposts.values()) + { + outpost.instakill(); + } + } + @EventHandler public void onClaim(PlayerClaimTerritoryEvent event) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index bfac5e555..72388bf95 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -13,6 +13,7 @@ import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; +import mineplex.core.common.events.ServerShutdownEvent; import mineplex.core.creature.Creature; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; @@ -65,7 +66,6 @@ import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; import mineplex.minecraft.game.classcombat.shop.ClassShopManager; import mineplex.minecraft.game.core.IRelation; import mineplex.minecraft.game.core.combat.CombatManager; -import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; @@ -188,7 +188,7 @@ public class Hub extends JavaPlugin implements IRelation @Override public void onDisable() { - + getServer().getPluginManager().callEvent(new ServerShutdownEvent(this)); } @Override 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 e2ca772b3..cc656c818 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -6,15 +6,9 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; import mineplex.core.PacketsInteractionFix; -import mineplex.core.account.CoreClient; -import mineplex.core.customdata.CustomDataManager; -import mineplex.core.giveaway.GiveawayManager; -import mineplex.core.globalpacket.GlobalPacketManager; -import net.minecraft.server.v1_8_R3.BiomeBase; -import net.minecraft.server.v1_8_R3.MinecraftServer; -import mineplex.core.CustomTagFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; @@ -22,15 +16,19 @@ import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; +import mineplex.core.common.events.ServerShutdownEvent; import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.UtilServer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; +import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.friend.FriendManager; import mineplex.core.gadget.GadgetManager; import mineplex.core.give.Give; +import mineplex.core.giveaway.GiveawayManager; +import mineplex.core.globalpacket.GlobalPacketManager; import mineplex.core.hologram.HologramManager; import mineplex.core.ignore.IgnoreManager; import mineplex.core.inventory.InventoryManager; @@ -61,6 +59,8 @@ import mineplex.core.visibility.VisibilityManager; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import nautilus.game.arcade.game.GameServerConfig; +import net.minecraft.server.v1_8_R3.BiomeBase; +import net.minecraft.server.v1_8_R3.MinecraftServer; public class Arcade extends JavaPlugin { @@ -186,6 +186,8 @@ public class Arcade extends JavaPlugin if (_gameManager.GetGame() != null) if (_gameManager.GetGame().WorldData != null) _gameManager.GetGame().WorldData.Uninitialize(); + + getServer().getPluginManager().callEvent(new ServerShutdownEvent(this)); } public GameServerConfig ReadServerConfig() From 43f075014a7f92b0f3f2b4665261b636c1c0c6fe Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Thu, 7 Jan 2016 20:05:33 +0000 Subject: [PATCH 48/65] made outposts have a "forcefield" whilst they are being built. also made legendary announcements a different color as per Simon's request. --- .../mineplex/core/common/util/UtilPlayer.java | 6 ++++ .../game/clans/clans/outpost/Outpost.java | 30 ++++++++++++++++--- .../mineplex/game/clans/items/PlayerGear.java | 2 +- 3 files changed, 33 insertions(+), 5 deletions(-) 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 f1e17e2df..8595f71ac 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 @@ -14,6 +14,7 @@ import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory; @@ -754,4 +755,9 @@ public class UtilPlayer looking.multiply(distance); return player.getEyeLocation().clone().add(looking); } + + public static void forcefield(Player player, Location forcefieldOrigin) + { + UtilAction.velocity(player, UtilAlg.getTrajectory2d(forcefieldOrigin, player.getLocation()), 1.6, true, 0.8, 0, 10, true); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java index 82d48ff07..2210d2df7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java @@ -37,6 +37,7 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.hologram.Hologram; @@ -85,7 +86,7 @@ public class Outpost implements Listener _clan = clan; _startCorner = location.clone().subtract(type._size, 1, type._size); - _endCorner = location.clone().add(type._size, type._ySize - 1, type._size); + _endCorner = location.clone().add(type._size + .9, type._ySize - 1, type._size + .9); _origin = location.clone(); @@ -156,13 +157,12 @@ public class Outpost implements Listener @EventHandler public void onBlockDamage(BlockDamageEvent event) { - if (event.getBlock().getLocation().equals(_core)) + if (event.getBlock().getLocation().equals(_core) && getState() == OutpostState.LIVE) { UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have destroyed " + F.elem(_clan.getName()) + "'s Outpost!")); _core.getBlock().setType(Material.AIR); - _clan.inform("Your Outpost has been destroyed!", null); UtilTextMiddle.display("Siege", "Your Outpost has been destroyed", 20, 100, 20, _clan.getOnlinePlayersArray()); @@ -231,7 +231,7 @@ public class Outpost implements Listener { if (x == -_type._size || x == _type._size || z == -_type._size || z == _type._size) { - UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, _origin.clone().add(x + .5, .1, z + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 5.5f, 0, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, _origin.clone().add(x + .5, .1, z + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 1f, 0, ViewDist.NORMAL); } } } @@ -256,6 +256,28 @@ public class Outpost implements Listener _buildQueue.remove(iterator.next()).set(); } } + + // Forcefield + RGBData color = UtilColor.RgbLightBlue; + + for (int x = -_type._size; x <= _type._size; x++) + { + for (int z = -_type._size; z <= _type._size; z++) + { + if (x == -_type._size || x == _type._size || z == -_type._size || z == _type._size) + { + UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, _origin.clone().add(x + .5, .1, z + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 1f, 0, ViewDist.NORMAL); + } + } + } + + UtilServer.getPlayersCollection().stream() + .filter(_clan::isMember) + .filter(player -> UtilAlg.inBoundingBox(player.getLocation(), _startCorner, _endCorner)) + .forEach(player -> { + UtilPlayer.forcefield(player, _core); + UtilPlayer.message(player, F.main("Clans", "This Outpost is still under construction!")); + }); } RGBData next = _fader.next(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java index a2592a9f6..1f9ecfdc2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java @@ -65,7 +65,7 @@ public class PlayerGear { legendary.OriginalOwner = getPlayer().getUniqueId().toString(); UtilServer.broadcast(F.main("Clans", F.elem(getPlayer().getName()) + " has picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.mBody + ".")); - UtilTextMiddle.display(C.cPurple + "Legendary", F.elem(getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.cWhite + "."); + UtilTextMiddle.display(C.cDPurple + "Legendary", F.elem(getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.cWhite + "."); getPlayer().setItemInHand(legendary.toItemStack()); } From e1e8c2bb977a16a4cecc29a2ff3e3f7c51855366 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Thu, 7 Jan 2016 21:02:55 +0000 Subject: [PATCH 49/65] changed outpost forcefields to be a bit larger to surround the outpost more. --- .../mineplex/core/common/util/UtilPlayer.java | 5 --- .../game/clans/clans/outpost/Outpost.java | 38 ++++++++++++++----- 2 files changed, 29 insertions(+), 14 deletions(-) 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 8595f71ac..268a3cbc8 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 @@ -755,9 +755,4 @@ public class UtilPlayer looking.multiply(distance); return player.getEyeLocation().clone().add(looking); } - - public static void forcefield(Player player, Location forcefieldOrigin) - { - UtilAction.velocity(player, UtilAlg.getTrajectory2d(forcefieldOrigin, player.getLocation()), 1.6, true, 0.8, 0, 10, true); - } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java index 2210d2df7..205c05013 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java @@ -5,6 +5,7 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; +import java.util.function.Predicate; import org.bukkit.Location; import org.bukkit.Material; @@ -28,6 +29,7 @@ import mineplex.core.common.util.NonFinalInteger; import mineplex.core.common.util.RGBData; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilColor; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; @@ -42,6 +44,8 @@ import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.hologram.Hologram; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansBlacklist; import mineplex.game.clans.core.repository.ClanTerritory; @@ -61,6 +65,9 @@ public class Outpost implements Listener private Location _origin; private Location _endCorner; + private Location _forceFieldStart; + private Location _forceFieldEnd; + private Location _core; private LinkedHashMap _blocks; @@ -88,6 +95,9 @@ public class Outpost implements Listener _startCorner = location.clone().subtract(type._size, 1, type._size); _endCorner = location.clone().add(type._size + .9, type._ySize - 1, type._size + .9); + _forceFieldStart = _startCorner.clone().subtract(3, 0, 3); + _forceFieldEnd = _endCorner.clone().add(3, 0, 3); + _origin = location.clone(); _type = type; @@ -231,7 +241,7 @@ public class Outpost implements Listener { if (x == -_type._size || x == _type._size || z == -_type._size || z == _type._size) { - UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, _origin.clone().add(x + .5, .1, z + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 1f, 0, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, UtilBlock.getHighest(_origin.getWorld(), _origin.clone().add(x + .5, .1, z + .5).getBlockX(), _origin.clone().add(x + .5, .1, z + .5).getBlockZ()).getLocation().add(0.5, 0, 0.5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 1f, 0, ViewDist.NORMAL); } } } @@ -270,14 +280,6 @@ public class Outpost implements Listener } } } - - UtilServer.getPlayersCollection().stream() - .filter(_clan::isMember) - .filter(player -> UtilAlg.inBoundingBox(player.getLocation(), _startCorner, _endCorner)) - .forEach(player -> { - UtilPlayer.forcefield(player, _core); - UtilPlayer.message(player, F.main("Clans", "This Outpost is still under construction!")); - }); } RGBData next = _fader.next(); @@ -305,6 +307,24 @@ public class Outpost implements Listener } } + @EventHandler + public void forcefield(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST && getState() == OutpostState.CONSTRUCTING) + { + return; + } + + UtilServer.getPlayersCollection().stream() + .filter(player -> !_clan.isMember(player)) + .filter(player -> UtilAlg.inBoundingBox(player.getLocation(), _forceFieldStart, _forceFieldEnd)) + .forEach(player -> { + UtilAction.velocity(player, UtilAlg.getTrajectory2d(_core, player.getLocation()), 1, true, 0.8, 0, 1.1, true); + UtilPlayer.message(player, F.main("Clans", "This Outpost is still under construction!")); + player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0f, 1.0f); + }); + } + public void beginConstruction() { // Cleanup pre-Outpost stuff From 15d2118bc1701b79576f6d73dc1d4aeca500f11e Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Thu, 7 Jan 2016 23:32:51 +0000 Subject: [PATCH 50/65] Added C.Mod rank, and started on rank info. --- .../src/mineplex/core/common/Rank.java | 55 +++++++++++-------- .../game/clans/clans/outpost/Outpost.java | 18 ++---- .../clans/clans/outpost/OutpostManager.java | 7 +++ 3 files changed, 45 insertions(+), 35 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index d76d2428e..5a7388fc9 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -9,50 +9,59 @@ import mineplex.core.common.util.UtilPlayer; public enum Rank { //Staff - LT("Leader", ChatColor.GOLD), - OWNER("Owner", ChatColor.GOLD), - DEVELOPER("Dev", ChatColor.GOLD), - ADMIN("Admin", ChatColor.GOLD), - JNR_DEV("Jr.Dev", ChatColor.GOLD), - SUPPORT("Support", ChatColor.BLUE), - SNR_MODERATOR("Sr.Mod", ChatColor.GOLD), - MODERATOR("Mod", ChatColor.GOLD), - HELPER("Trainee", ChatColor.DARK_AQUA), - MAPLEAD("MapLead", ChatColor.BLUE), - MAPDEV("Builder", ChatColor.BLUE), - MEDIA("Media", ChatColor.BLUE), + LT("Leader", ChatColor.GOLD, "Leaders are in charge of special teams\nsuch as the whole staff team or the support!"), + OWNER("Owner", ChatColor.GOLD, "Owners are the Founders of Mineplex\nand they all manage different parts of it!"), + DEVELOPER("Dev", ChatColor.GOLD, "Developers make new games,\nand new features for you to enjoy"), + ADMIN("Admin", ChatColor.GOLD, "Administrators have their own\nSenior Moderator team that they lead!"), + JNR_DEV("Jr.Dev", ChatColor.GOLD, "Junior Developers make new games,\nand new features for you to enjoy"), + SUPPORT("Support", ChatColor.BLUE, "Support Agents take care of all the tickets\nthat get sent to mineplex.com/support"), + CMOD("C.Mod", ChatColor.GOLD, "Clan Moderators are Senior Moderators in\nthe Clans Management team.\nThey mainly moderate only the Clans servers.\nThey are around to help you with any problems on Clans servers."), + SNR_MODERATOR("Sr.Mod", ChatColor.GOLD, "Senior Moderators are in a special\nSenior Moderator team where they have to fulfill team tasks.\nThey are similar to Moderators who you can always ask for help!\nIf you have any questions, just message them using /a"), + MODERATOR("Mod", ChatColor.GOLD, "Moderators are here to moderate\nand help players with any concerns they have.\nIf you have any questions, just message them using /a"), + HELPER("Trainee", ChatColor.DARK_AQUA, "Trainees are staff in training,\nand are here to help players and moderate!\nIf you have any questions, just message them using /a"), + MAPLEAD("MapLead", ChatColor.BLUE, "Leader of the Official Build team"), + MAPDEV("Builder", ChatColor.BLUE, "Official Mineplex Map Builders"), + MEDIA("Media", ChatColor.BLUE, "Official Mineplex Artist and/or Designer"), - EVENT("Event", ChatColor.WHITE), + EVENT("Event", ChatColor.WHITE, "???"), //Media - YOUTUBE("YouTube", ChatColor.RED), - YOUTUBE_SMALL("YT", ChatColor.DARK_PURPLE), - TWITCH("Twitch", ChatColor.DARK_PURPLE), + YOUTUBE("YouTube", ChatColor.RED, "Official Mineplex Youtuber"), + YOUTUBE_SMALL("YT", ChatColor.DARK_PURPLE, "Youtube Content Creators"), + TWITCH("Twitch", ChatColor.DARK_PURPLE, "Official Twitch Live Streamer"), //Player - TITAN("Titan", ChatColor.RED, true), - LEGEND("Legend", ChatColor.GREEN, true), - HERO("Hero", ChatColor.LIGHT_PURPLE, true), - ULTRA("Ultra", ChatColor.AQUA, true), - ALL("", ChatColor.WHITE); + TITAN("Titan", ChatColor.RED, true, "Mineplex's fourth premium rank\nBuy Titan at mineplex.com/shop"), + LEGEND("Legend", ChatColor.GREEN, true, "Mineplex's third premium rank\nBuy Legend at mineplex.com/shop"), + HERO("Hero", ChatColor.LIGHT_PURPLE, true, "Mineplex's second premium rank\nBuy Hero at mineplex.com/shop"), + ULTRA("Ultra", ChatColor.AQUA, true, "Mineplex's first premium rank\nBuy Ultra at mineplex.com/shop"), + ALL("", ChatColor.WHITE, null); private ChatColor _color; private boolean _donor; + private String _info; public String Name; - Rank(String name, ChatColor color) + Rank(String name, ChatColor color, String info) { _color = color; Name = name; _donor = false; + _info = info; } - Rank(String name, ChatColor color, boolean donor) + Rank(String name, ChatColor color, boolean donor, String info) { _color = color; Name = name; _donor = donor; + _info = info; + } + + public String getInfo() + { + return _info; } public boolean has(Rank rank) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java index 205c05013..50a461601 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java @@ -202,11 +202,10 @@ public class Outpost implements Listener return; } - if (UtilAlg.inBoundingBox(event.getBlock().getLocation(), _startCorner, _endCorner)) - { + _blocks.values().stream().filter(event.getBlock().getLocation()::equals).forEach(block -> { UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not break blocks in Outposts.")); event.setCancelled(true); - } + }); } @EventHandler @@ -391,17 +390,12 @@ public class Outpost implements Listener NonFinalInteger wait = new NonFinalInteger(0); - _blocks.values().forEach(block -> { - if (UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean()) - { - return; - } - + _blocks.values().stream().filter(block -> UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean()).forEach(block -> _host.runSyncLater(() -> { - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, block._loc, new Vector(0,0,0), 0.1f, 3, ViewDist.LONG); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, block._loc, new Vector(0,0,0), 1f, 1, ViewDist.NORMAL); _origin.getWorld().playSound(block._loc, Sound.EXPLODE, 1.0f, 1.0f); - }, wait.add(4 + UtilMath.random.nextInt(10)).get()); - }); + }, wait.add(4 + UtilMath.random.nextInt(4)).get()) + ); _host.runSyncLater(() -> { _blocks.values().forEach(block -> { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java index 7f0e5c7ff..aa97fb266 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java @@ -17,6 +17,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.common.events.ServerShutdownEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -122,6 +123,12 @@ public class OutpostManager extends MiniPlugin UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost where it may intersect with claimed territory.")); return false; } + + if (UtilBlock.airFoliage(location.clone().add(x, -1, z).getBlock())) + { + UtilPlayer.message(player, F.main("Clans", "An Outpost cannot be placed floating.")); + return false; + } } } } From 003af1b87c2208c3fef909cc1d867d17357fbe6a Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 01:38:49 -0500 Subject: [PATCH 51/65] Disable Holiday Words in DMT and Build --- .../src/nautilus/game/arcade/game/games/build/Build.java | 3 ++- .../src/nautilus/game/arcade/game/games/draw/Draw.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java index a066fd174..bbcf02a2e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java @@ -119,6 +119,7 @@ public class Build extends SoloGame private String[] _words; private String[] _holidayWords; + private boolean _useHolidayWords = false; private String _word = "?"; @@ -249,7 +250,7 @@ public class Build extends SoloGame player.setFlySpeed(0.1f); } - if (Math.random() >= 0.5) + if (!_useHolidayWords || Math.random() >= 0.5) _word = _words[UtilMath.r(_words.length)]; else _word = _holidayWords[UtilMath.r(_holidayWords.length)]; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index 53d88aeda..3098fe293 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -84,6 +84,7 @@ public class Draw extends SoloGame private HashSet _tools; private String[] _words; private String[] _holidayWords; + private boolean _useHolidayWords = false; private HashSet _usedWords = new HashSet(); public Draw(ArcadeManager manager) @@ -302,7 +303,7 @@ public class Draw extends SoloGame private String getRandomWord() { - if (Math.random() >= 0.30) + if (!_useHolidayWords || Math.random() >= 0.30) { return _words[UtilMath.r(_words.length)]; } From 9c3b07123f73ebecdd67b9534bfbc2ce454f8d42 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 01:39:54 -0500 Subject: [PATCH 52/65] Revert to normal HubType --- Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 24be3b3dc..a06a5a7b2 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -135,7 +135,7 @@ import org.bukkit.scoreboard.Scoreboard; public class HubManager extends MiniClientPlugin { // ☃❅ Snowman! - public HubType Type = HubType.Christmas; + public HubType Type = HubType.Normal; private BlockRestore _blockRestore; private CoreClientManager _clientManager; From 19bb44cb9abfd954e2216bbf378d28f9592c96d7 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 01:41:02 -0500 Subject: [PATCH 53/65] Disable HolidayManager and HolidayGiftManager --- Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java | 2 +- .../src/nautilus/game/arcade/ArcadeManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index a06a5a7b2..c3b304bdf 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -249,7 +249,7 @@ public class HubManager extends MiniClientPlugin // _halloweenManager = new HalloweenSpookinessManager(this); - new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); +// new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); new PlayerDisguiseManager(plugin, _clientManager); // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); 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 db787f98e..91f502c5d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -291,7 +291,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _hologramManager = hologramManager; _idleManager = new IdleManager(this); TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager); - new HolidayManager(this, titanGiveaway); +// new HolidayManager(this, titanGiveaway); new GameTestingManager(this); new PlayerDisguiseManager(plugin, _clientManager); From db7d814e02fba026583e8ef68365fe9ebbcdb615 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 01:42:05 -0500 Subject: [PATCH 54/65] Disable hub music --- Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index c3b304bdf..f63f18a74 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -296,6 +296,9 @@ public class HubManager extends MiniClientPlugin private void playNextSong() { + if (Type != HubType.Christmas) + return; + if (_songs.isEmpty()) return; From 1d2f61db8c45d5068bc7183cdfcd906c7fac4eb2 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 03:15:05 -0500 Subject: [PATCH 55/65] Disable purchasing Christmas Treasure --- .../mineplex/core/treasure/TreasureType.java | 24 +++++++++++++---- .../core/treasure/gui/TreasurePage.java | 27 +++++++++++-------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java index bab37072b..159bd4f83 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java @@ -8,13 +8,13 @@ import mineplex.core.reward.RewardType; public enum TreasureType { - OLD(C.cYellow + "Old Treasure", "Old Chest", "Old", RewardType.OldChest, Material.CHEST, TreasureStyle.OLD, RewardPool.Type.NORMAL), + OLD(C.cYellow + "Old Treasure", "Old Chest", "Old", RewardType.OldChest, Material.CHEST, TreasureStyle.OLD, RewardPool.Type.NORMAL, true, 1000), - ANCIENT(C.cGold + "Ancient Treasure", "Ancient Chest", "Ancient", RewardType.AncientChest, Material.TRAPPED_CHEST, TreasureStyle.ANCIENT, RewardPool.Type.NORMAL), + ANCIENT(C.cGold + "Ancient Treasure", "Ancient Chest", "Ancient", RewardType.AncientChest, Material.TRAPPED_CHEST, TreasureStyle.ANCIENT, RewardPool.Type.NORMAL, true, 5000), - MYTHICAL(C.cRed + "Mythical Treasure", "Mythical Chest", "Mythical", RewardType.MythicalChest, Material.ENDER_CHEST, TreasureStyle.MYTHICAL, RewardPool.Type.NORMAL), + MYTHICAL(C.cRed + "Mythical Treasure", "Mythical Chest", "Mythical", RewardType.MythicalChest, Material.ENDER_CHEST, TreasureStyle.MYTHICAL, RewardPool.Type.NORMAL, true, 10000), - CHRISTMAS(C.cDGreen + "Winter Holiday Treasure", "Winter Chest", "Christmas", RewardType.WinterChest, Material.CHEST, TreasureStyle.CHRISTMAS, RewardPool.Type.WINTER_HOLIDAY); + CHRISTMAS(C.cDGreen + "Winter Holiday Treasure", "Winter Chest", "Christmas", RewardType.WinterChest, Material.CHEST, TreasureStyle.CHRISTMAS, RewardPool.Type.WINTER_HOLIDAY, false, 15000); private final String _name; private final RewardType _rewardType; @@ -23,8 +23,10 @@ public enum TreasureType private final String _itemName; private final String _statName; private final RewardPool.Type _rewardPool; + private final int _purchasePrice; + private final boolean _purchasable; - TreasureType(String name, String itemName, String statName, RewardType rewardType, Material material, TreasureStyle treasureStyle, RewardPool.Type rewardPool) + TreasureType(String name, String itemName, String statName, RewardType rewardType, Material material, TreasureStyle treasureStyle, RewardPool.Type rewardPool, boolean purchasable, int purchasePrice) { _name = name; _itemName = itemName; @@ -33,6 +35,8 @@ public enum TreasureType _material = material; _treasureStyle = treasureStyle; _rewardPool = rewardPool; + _purchasePrice = purchasePrice; + _purchasable = purchasable; } public RewardType getRewardType() @@ -69,4 +73,14 @@ public enum TreasureType { return _rewardPool; } + + public int getPurchasePrice() + { + return _purchasePrice; + } + + public boolean isPurchasable() + { + return _purchasable; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index a0ad48354..ae345c49c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -122,9 +122,11 @@ public class TreasurePage extends ShopPageBase christmasLore.add(ChatColor.RESET + C.cGreen + "Click to Open!"); else { + /* christmasLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "15000 Treasure Shards"); christmasLore.add(" "); christmasLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop"); + */ } List cosmicLore = new ArrayList(); @@ -143,18 +145,21 @@ public class TreasurePage extends ShopPageBase addItem(40, shards); - if (basicCount > 0) addButton(20, basic, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.OLD)); - else addButton(20, basic, new BuyChestButton(getPlayer(), _inventoryManager, this, "Old Chest", Material.CHEST, 1000)); - - if (heroicCount > 0) addButton(22, heroic, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.ANCIENT)); - else addButton(22, heroic, new BuyChestButton(getPlayer(), _inventoryManager, this, "Ancient Chest", Material.CHEST, 5000)); - - if (legendaryCount > 0) addButton(24, legendary, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.MYTHICAL)); - else addButton(24, legendary, new BuyChestButton(getPlayer(), _inventoryManager, this, "Mythical Chest", Material.ENDER_CHEST, 10000)); - - if (christmasCount > 0) addButton(12, christmas, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.CHRISTMAS)); - else addButton(12, christmas, new BuyChestButton(getPlayer(), _inventoryManager, this, TreasureType.CHRISTMAS.getItemName(), Material.SNOW_BALL, 15000)); + addChest(20, basic, TreasureType.OLD, basicCount); + addChest(22, heroic, TreasureType.ANCIENT, heroicCount); + addChest(24, legendary, TreasureType.MYTHICAL, legendaryCount); + addChest(12, christmas, TreasureType.CHRISTMAS, christmasCount); addItem(14, cosmic); } + + private void addChest(int slot, ItemStack item, TreasureType treasureType, int owned) + { + if (owned > 0) + addButton(slot, item, new OpenTreasureButton(getPlayer(), _treasureLocation, treasureType)); + else if (treasureType.isPurchasable()) + addButton(slot, item, new BuyChestButton(getPlayer(), _inventoryManager, this, treasureType.getName(), Material.CHEST, treasureType.getPurchasePrice())); + else + setItem(slot, item); + } } From 504d9d508cccbe9d81cd737f4f9da1a62cab5cc2 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 03:15:30 -0500 Subject: [PATCH 56/65] Slightly reduce Squid's Ink Blast damage in SSM --- .../arcade/game/games/smash/kits/KitSkySquid.java | 4 ++-- .../nautilus/game/arcade/kit/perks/PerkInkBlast.java | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java index 06b78a82e..0a403c85e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java @@ -38,7 +38,7 @@ public class KitSkySquid extends SmashKit new PerkSmashStats(6, 1.5, 0.25, 5), new PerkDoubleJump("Double Jump", 0.9, 0.9, false), new PerkSuperSquid(), - new PerkInkBlast(), + new PerkInkBlast(7, 2), new PerkFishFlurry(), new PerkStormSquid() }, @@ -56,7 +56,7 @@ public class KitSkySquid extends SmashKit C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Ink Shotgun", new String[] { - ChatColor.RESET + "Blasts 6 ink pellets out at high velocity.", + ChatColor.RESET + "Blasts 7 ink pellets out at high velocity.", ChatColor.RESET + "They explode upon hitting something, dealing", ChatColor.RESET + "damage and knockback.", })); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java index 99a6f459e..fee34747e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java @@ -33,12 +33,18 @@ import nautilus.game.arcade.kit.SmashPerk; public class PerkInkBlast extends SmashPerk implements IThrown { - public PerkInkBlast() + private int _bullets; + private double _damagePerBullet; + + public PerkInkBlast(int bullets, double damagePerBullet) { super("Ink Shotgun", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Ink Shotgun" }); + + _bullets = bullets; + _damagePerBullet = damagePerBullet; } @@ -75,7 +81,7 @@ public class PerkInkBlast extends SmashPerk implements IThrown UtilInv.Update(player); - for (int i=0 ; i<7 ; i++) + for (int i=0 ; i < _bullets ; i++) { org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(Material.INK_SACK, (byte)0, 1, "Ink" + Math.random())); @@ -113,7 +119,7 @@ public class PerkInkBlast extends SmashPerk implements IThrown //Damage Event Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, - DamageCause.PROJECTILE, 3, true, true, false, + DamageCause.PROJECTILE, _damagePerBullet, true, true, false, UtilEnt.getName(data.GetThrower()), GetName()); UtilParticle.PlayParticle(ParticleType.EXPLODE, target.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0, 12, ViewDist.LONG, UtilServer.getPlayers()); From 6096fcad429975162d2eda97fd541d8b364282a8 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 04:06:11 -0500 Subject: [PATCH 57/65] Fix hotbar issues --- .../games/gladiators/hotbar/HotbarEditor.java | 17 ++++++++++ .../games/gladiators/hotbar/HotbarLayout.java | 33 +++++++++++++++++++ .../gladiators/hotbar/HotbarPageListener.java | 14 ++++---- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java index 518b86d96..e9ecdeae7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java @@ -163,6 +163,23 @@ public class HotbarEditor extends MiniPlugin items.indexOf(arrows) - 9 ); + if (save.getArrows() > 8 || save.getArrows() < 0) + { + save.setArrows(save.getEmpty()); + } + if (save.getBow() > 8 || save.getBow() < 0) + { + save.setBow(save.getEmpty()); + } + if (save.getSword() > 8 || save.getSword() < 0) + { + save.setSword(save.getEmpty()); + } + if (save.getRod() > 8 || save.getRod() < 0) + { + save.setRod(save.getEmpty()); + } + _host.Manager.getArcadePlayer(player).put("hotbar", save.toDataSaveNumber()); player.sendMessage(F.main("Game", "Saved new hotbar layout!")); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java index 459f70411..ad4d024be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java @@ -39,6 +39,26 @@ public class HotbarLayout return arrows; } + public void setSword(int sword) + { + this.sword = sword; + } + + public void setRod(int rod) + { + this.rod = rod; + } + + public void setBow(int bow) + { + this.bow = bow; + } + + public void setArrows(int arrows) + { + this.arrows = arrows; + } + public int toDataSaveNumber() { String str = ""; @@ -57,4 +77,17 @@ public class HotbarLayout return Integer.parseInt(str); } + + public int getEmpty() + { + for (int i = 0; i < 9; i++) + { + if (i == sword || i == rod || i == bow || i == arrows) + continue; + + return i; + } + + return 0; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java index 249983dd7..736de92df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java @@ -50,12 +50,6 @@ public class HotbarPageListener implements Listener System.out.println(e.getClickedInventory().getName() + " : " + e.getInventory().getName()); -// if ((e.getSlot() > 8 && e.getSlot() < 18)) -// { -// e.setCancelled(false); -// return; -// } - if (e.getCurrentItem().getType().equals(Material.REDSTONE_BLOCK)) { e.setCancelled(true); @@ -70,7 +64,7 @@ public class HotbarPageListener implements Listener if (e.getCurrentItem().getType().equals(Material.EMERALD_BLOCK)) { - if (e.getAction().equals(InventoryAction.SWAP_WITH_CURSOR)){ + if (!e.getAction().equals(InventoryAction.PICKUP_ALL)){ e.setCancelled(true); return; } @@ -81,6 +75,12 @@ public class HotbarPageListener implements Listener return; } + if ((e.getSlot() < 9 || e.getSlot() > 17)) + { + e.setCancelled(true); + return; + } + if (e.getCurrentItem().getType().equals(Material.STAINED_GLASS_PANE)) { e.setCancelled(true); From 0a56a838d2b8e2556064fb5181002aafb87e6e14 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 05:45:49 -0500 Subject: [PATCH 58/65] Fix ClansLoginManager, Remove pointless code in CoreClientManager --- Plugins/.idea/dataSources.xml | 2 +- .../src/mineplex/core/account/CoreClientManager.java | 9 +-------- .../game/clans/clans/commands/ClansLoginManager.java | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Plugins/.idea/dataSources.xml b/Plugins/.idea/dataSources.xml index 3aa4d521d..b55f2b18c 100644 --- a/Plugins/.idea/dataSources.xml +++ b/Plugins/.idea/dataSources.xml @@ -1,6 +1,6 @@ - + mysql true diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index cd62cf6fc..fe00a1a45 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -128,14 +128,7 @@ public class CoreClientManager extends MiniPlugin if (client == null) { - if (Bukkit.getPlayer(name) != null) - { - client = new CoreClient(Bukkit.getPlayer(name)); - } - else - { - client = new CoreClient(name); - } + client = new CoreClient(name); } return client; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java index 1b8575083..2b59d9ae3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java @@ -41,8 +41,8 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor { if (_queue.contains(event.getPlayer().getName()) && !event.getPlayer().isOp()) { -// event.setKickMessage("This is not your Clans home server"); -// event.setResult(PlayerLoginEvent.Result.KICK_OTHER); + event.setKickMessage("This is not your Clans home server"); + event.setResult(PlayerLoginEvent.Result.KICK_OTHER); } _queue.remove(event.getPlayer().getName()); From 025615d080b8b925f319a2f7707d2c3fa4755a88 Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Fri, 8 Jan 2016 11:24:36 +0000 Subject: [PATCH 59/65] Clans Alpha 0.18b fixes --- .../core/account/CoreClientManager.java | 5 + .../src/mineplex/core/delayedtask/Task.java | 5 - .../src/mineplex/game/clans/Clans.java | 2 +- .../game/clans/clans/ClansManager.java | 36 ++--- .../clans/clans/ban/ClansBanRepository.java | 143 ++++++------------ .../clans/commands/ClansChatCommand.java | 2 +- .../clans/clans/commands/ClansCommand.java | 2 +- .../mineplex/game/clans/items/PlayerGear.java | 2 +- 8 files changed, 77 insertions(+), 120 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index cd62cf6fc..3fd42bebe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -142,6 +142,11 @@ public class CoreClientManager extends MiniPlugin } } + public boolean Contains(String name) + { + return _clientList.containsKey(name); + } + public CoreClient Get(Player player) { return Get(player.getName()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java index 37a1204cd..681eb9c57 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java @@ -73,11 +73,6 @@ public class Task _cancel.run(_client); } - if (_end != null) - { - _end.run(_client); - } - _client.cleanup(_name); return; } 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 5d8be3794..209ae38a3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -53,7 +53,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer; public class Clans extends JavaPlugin { - public static final String VERSION = "0.18"; + public static final String VERSION = "0.18b"; private String WEB_CONFIG = "webServer"; // Modules 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 91e4d7f0b..8fc7a459a 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 @@ -649,17 +649,17 @@ public class ClansManager extends MiniClientPluginimplements IRelati } } - private void handleClanChat(AsyncPlayerChatEvent event, ClanInfo clan, String rank) + private void handleClanChat(Player player, String message, ClanInfo clan, String rank) { for (Player cur : clan.getOnlinePlayers()) { - String message = _chat.getFilteredMessage(event.getPlayer(), event.getMessage()); + message = _chat.getFilteredMessage(player, message); - UtilPlayer.message(cur, String.format(rank + C.cAqua + "%s " + C.cDAqua + "%s", event.getPlayer().getName(), message)); + UtilPlayer.message(cur, String.format(rank + C.cAqua + "%s " + C.cDAqua + "%s", player.getName(), message)); } } - private void handleAllyChat(AsyncPlayerChatEvent event, ClanInfo clan, String rank) + private void handleAllyChat(Player player, String message, ClanInfo clan, String rank) { List recipients = new ArrayList<>(); @@ -673,9 +673,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati ally.getOnlinePlayers().forEach(recipients::add); } - String message = _chat.getFilteredMessage(event.getPlayer(), event.getMessage()); + final String filtered = _chat.getFilteredMessage(player, message); - recipients.forEach(p -> UtilPlayer.message(p, String.format(rank + C.cDGreen + clan.getName() + " " + C.cDGreen + "%s " + C.cGreen + "%s", event.getPlayer().getName(), message))); + recipients.forEach(p -> UtilPlayer.message(p, String.format(rank + C.cDGreen + clan.getName() + " " + C.cDGreen + "%s " + C.cGreen + "%s", player.getName(), filtered))); recipients.clear(); } @@ -733,11 +733,11 @@ public class ClansManager extends MiniClientPluginimplements IRelati if (client.isClanChat() && clan != null) { - handleClanChat(event, clan, rank); + handleClanChat(event.getPlayer(), event.getMessage(), clan, rank); } else if (client.isAllyChat() && clan != null) { - handleAllyChat(event, clan, rank); + handleAllyChat(event.getPlayer(), event.getMessage(), clan, rank); } else { @@ -776,22 +776,22 @@ public class ClansManager extends MiniClientPluginimplements IRelati public void chatClan(ClanInfo clan, Player caller, String message) { - messageClan(clan, C.cAqua + caller.getName() + " " + C.cDAqua + message); + String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; + + if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + rank = ""; + + handleClanChat(caller, message, clan, rank); } public void chatAlly(ClanInfo clan, Player caller, String message) { - String sendMessage = C.cDGreen + clan.getName() + " " + C.cDGreen + caller.getName() + " " + C.cGreen + message; + String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; - messageClan(clan, sendMessage); + if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + rank = ""; - for (String allyName : clan.getAllyMap().keySet()) - { - ClanInfo ally = _clanUtility.getClanByClanName(allyName); - if (ally == null) continue; - - messageClan(ally, sendMessage); - } + handleAllyChat(caller, message, clan, rank); } public int getNameMin() 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 9860e8d5d..5ec0f6fc0 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 @@ -8,6 +8,7 @@ import java.util.List; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.account.CoreClient; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NonFinalInteger; import mineplex.core.database.DBPool; @@ -50,80 +51,32 @@ public class ClansBanRepository extends RepositoryBase public void loadBans(final String name, final Callback callback) { System.out.println(">> Attempting to load Clans Bans for \"" + name + "\""); - _manager.getClientManager().loadClientByName(name, new Runnable() { - public void run() - { - System.out.println("> Successfully loaded CoreClient"); - - executeQuery(GET_ALL_BANS, new ResultSetCallable() - { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException + loadClientByName(name, client -> { + System.out.println("> Successfully loaded CoreClient"); + + executeQuery(GET_ALL_BANS, resultSet -> { + System.out.println("> Successfully executed query, result set object: " + resultSet); + + final List list = new ArrayList(); + + while (resultSet.next()) { - System.out.println("> Successfully executed query, result set object: " + resultSet); - - final List list = new ArrayList(); - - while (resultSet.next()) - { - int id = resultSet.getInt(1); - int accountId = resultSet.getInt(2); - String reason = resultSet.getString(3); - Timestamp banTime = resultSet.getTimestamp(4); - Timestamp unbanTime = resultSet.getTimestamp(5); - boolean permanent = resultSet.getBoolean(6); - boolean removed = resultSet.getBoolean(7); - - list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); - } - - callback.run(new ClansBanClient(_manager.getClientManager().Get(name).getAccountId(), list)); - - System.out.println("> Successfully handled result"); - System.out.println(">> FINISH"); - } - }, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId())); - } - }); - } + int id = resultSet.getInt(1); + int accountId = resultSet.getInt(2); + String reason = resultSet.getString(3); + Timestamp banTime = resultSet.getTimestamp(4); + Timestamp unbanTime = resultSet.getTimestamp(5); + boolean permanent = resultSet.getBoolean(6); + boolean removed = resultSet.getBoolean(7); - public void loadBansSync(final String name, final Callback callback) - { - System.out.println(">> Attempting to load Clans Bans for \"" + name + "\""); - _manager.getClientManager().loadClientByNameSync(name, new Runnable() { - public void run() - { - System.out.println("> Successfully loaded CoreClient"); - - executeQuery(GET_ALL_BANS, new ResultSetCallable() - { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException - { - System.out.println("> Successfully executed query, result set object: " + resultSet); - - final List list = new ArrayList(); - - while (resultSet.next()) - { - int id = resultSet.getInt(1); - int accountId = resultSet.getInt(2); - String reason = resultSet.getString(3); - Timestamp banTime = resultSet.getTimestamp(4); - Timestamp unbanTime = resultSet.getTimestamp(5); - boolean permanent = resultSet.getBoolean(6); - boolean removed = resultSet.getBoolean(7); - - list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); - } - - callback.run(new ClansBanClient(_manager.getClientManager().Get(name).getAccountId(), list)); - - System.out.println("> Successfully handled result"); - System.out.println(">> FINISH"); + list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); } - }, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId())); - } + + callback.run(new ClansBanClient(client.getAccountId(), list)); + + System.out.println("> Successfully handled result"); + System.out.println(">> FINISH"); + }, new ColumnInt("accountId", client.getAccountId())); }); } @@ -134,32 +87,36 @@ public class ClansBanRepository extends RepositoryBase return; } - _manager.getClientManager().loadClientByName(name, new Runnable(){ - public void run() - { - executeQuery(GET_LONGEST_BAN, new ResultSetCallable() + loadClientByName(name, client -> { + executeQuery(GET_LONGEST_BAN, resultSet -> { + while (resultSet.next()) { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException - { - while (resultSet.next()) - { - int id = resultSet.getInt(1); - int accountId = resultSet.getInt(2); - String reason = resultSet.getString(3); - Timestamp banTime = resultSet.getTimestamp(4); - Timestamp unbanTime = resultSet.getTimestamp(5); - boolean permanent = resultSet.getBoolean(6); - boolean removed = resultSet.getBoolean(7); - - callback.run(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); - } - } - }, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId())); - } + int id = resultSet.getInt(1); + int accountId = resultSet.getInt(2); + String reason = resultSet.getString(3); + Timestamp banTime = resultSet.getTimestamp(4); + Timestamp unbanTime = resultSet.getTimestamp(5); + boolean permanent = resultSet.getBoolean(6); + boolean removed = resultSet.getBoolean(7); + + callback.run(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); + } + }, new ColumnInt("accountId", client.getAccountId())); }); } + public void loadClientByName(String name, Callback client) + { + if (_manager.getClientManager().Contains(name)) + { + client.run(_manager.getClientManager().Get(name)); + } + else + { + _manager.getClientManager().loadClientByName(name, () -> client.run(_manager.getClientManager().Get(name))); + } + } + public void loadAll(Callback> callback) { _manager.runAsync(() -> { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java index 40bebfb6e..36619c1ef 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java @@ -38,7 +38,7 @@ public class ClansChatCommand extends CommandBase if (!Plugin.Get(caller).isClanChat()) { ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); - if (clan == null) + if (clan == null) UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); else Plugin.chatClan(clan, caller, F.combine(args, 0, null, false)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 28d32055f..838565d0c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -807,7 +807,7 @@ public class ClansCommand extends CommandBase }, new Callback() { public void run(DelayedTaskClient client) { - UtilTextMiddle.display("", "Teleporting to Clan Home in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Home Teleport")))), 0, 5, 0); + UtilTextMiddle.display("", "Teleporting to Clan Home in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Home Teleport")))), 0, 5, 0, client.getPlayer()); } }, new Callback() { public void run(DelayedTaskClient client) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java index 1f9ecfdc2..1820277ad 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java @@ -65,7 +65,7 @@ public class PlayerGear { legendary.OriginalOwner = getPlayer().getUniqueId().toString(); UtilServer.broadcast(F.main("Clans", F.elem(getPlayer().getName()) + " has picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.mBody + ".")); - UtilTextMiddle.display(C.cDPurple + "Legendary", F.elem(getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.cWhite + "."); + UtilTextMiddle.display(C.cDPurple + "Legendary", F.elem(getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.cWhite + ".", 20, 60, 20); getPlayer().setItemInHand(legendary.toItemStack()); } From ee73b374a65e9546be2f3476218b97b3edd602d3 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 06:36:59 -0500 Subject: [PATCH 60/65] Forgot to uncomment in ClansLoginManager --- .../clans/commands/ClansLoginManager.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java index 2b59d9ae3..1267209fb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java @@ -50,18 +50,18 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor private void kickPlayer(final String playerName, final String homeServer) { -// runSyncLater(new Runnable() -// { -// @Override -// public void run() -// { -// Player player = UtilPlayer.searchExact(playerName); -// if (player != null && player.isOnline() && !player.isOp()) -// { -// player.kickPlayer("This is not your home server. To play clans, connect to " + homeServer); -// } -// } -// }, 20); + runSyncLater(new Runnable() + { + @Override + public void run() + { + Player player = UtilPlayer.searchExact(playerName); + if (player != null && player.isOnline() && !player.isOp()) + { + player.kickPlayer("This is not your home server. To play clans, connect to " + homeServer); + } + } + }, 20); } @Override From 2df626b35ef4bc84121f44ff380f9a5dd62ee720 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 18:06:33 -0500 Subject: [PATCH 61/65] Fix CustomDataManager crash --- .../mineplex/core/customdata/CustomDataManager.java | 11 ++++++++--- .../src/mineplex/core/customdata/MineplexPlayer.java | 3 ++- .../customdata/repository/CustomDataRepository.java | 11 ++++++----- .../game/games/gladiators/hotbar/HotbarEditor.java | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java index cd0543674..26652d24a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java @@ -48,10 +48,15 @@ public class CustomDataManager extends MiniDbClientPlugin return new PlayerCustomData(_repository); } - @Override - public void saveData(String name, int accountId) + public void saveAsync(Player player) { - _repository.saveData(name, accountId); + final int accountId = getClientManager().getAccountId(player); + final String name = player.getName(); + + if (accountId == -1) + return; + + runAsync(() -> _repository.saveData(name, accountId)); } public CorePlayer getCorePlayer(Player player) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java index e49f75211..bf350f843 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java @@ -27,10 +27,11 @@ public abstract class MineplexPlayer return ""; } - public void put(String key, int data) + public void put(String key, int data, boolean save) { key = getKeyPrefix() + key; _customDataManager.Get(getPlayer()).setData(key, data); + if (save) _customDataManager.saveAsync(_player); } public int get(String key) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java index 328aa6e6f..c896f2a03 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java @@ -3,6 +3,7 @@ package mineplex.core.customdata.repository; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Map; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -71,20 +72,20 @@ public class CustomDataRepository extends RepositoryBase { PlayerCustomData data = _customDataManager.Get(name); - for (CustomData cd : data.getDataMap().keySet()) + for (Map.Entry entry : data.getDataMap().entrySet()) { if (executeUpdate( UPDATE_DATA, - new ColumnInt("data", data.getDataMap().get(cd)), + new ColumnInt("data", entry.getValue()), new ColumnInt("account", accountId), - new ColumnInt("customData", cd.getId())) < 1) + new ColumnInt("customData", entry.getKey().getId())) < 1) { // Not already in the DB executeUpdate( INSERT_DATA, new ColumnInt("account", accountId), - new ColumnInt("customData", cd.getId()), - new ColumnInt("data", data.getDataMap().get(cd)) + new ColumnInt("customData", entry.getKey().getId()), + new ColumnInt("data", entry.getValue()) ); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java index e9ecdeae7..e12ee785e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java @@ -180,7 +180,7 @@ public class HotbarEditor extends MiniPlugin save.setRod(save.getEmpty()); } - _host.Manager.getArcadePlayer(player).put("hotbar", save.toDataSaveNumber()); + _host.Manager.getArcadePlayer(player).put("hotbar", save.toDataSaveNumber(), true); player.sendMessage(F.main("Game", "Saved new hotbar layout!")); } } From cd3037e7e54acbabba6384e3b50a1ef1c1f38ea2 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Sat, 9 Jan 2016 18:37:24 -0500 Subject: [PATCH 62/65] Fix treasure purchases --- .../src/mineplex/core/treasure/gui/TreasurePage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index ae345c49c..ca2ddc8b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -158,7 +158,7 @@ public class TreasurePage extends ShopPageBase if (owned > 0) addButton(slot, item, new OpenTreasureButton(getPlayer(), _treasureLocation, treasureType)); else if (treasureType.isPurchasable()) - addButton(slot, item, new BuyChestButton(getPlayer(), _inventoryManager, this, treasureType.getName(), Material.CHEST, treasureType.getPurchasePrice())); + addButton(slot, item, new BuyChestButton(getPlayer(), _inventoryManager, this, treasureType.getItemName(), Material.CHEST, treasureType.getPurchasePrice())); else setItem(slot, item); } From 8193b5121b8734774abcef00cf270e3297a3e015 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Sat, 9 Jan 2016 18:39:47 -0500 Subject: [PATCH 63/65] Dont allow /disguise for YOUTUBE_SMALL --- .../Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java index 52a41e81e..4c827f171 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -62,7 +62,7 @@ public class DisguiseCommand extends CommandBase implements Listener public DisguiseCommand(HubManager plugin) { - super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.YOUTUBE_SMALL}, "disguise"); + super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, "disguise"); plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); } From 83e5c7399e36185f88c6e5d3e69781fa6dd3ab39 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Sat, 9 Jan 2016 18:41:19 -0500 Subject: [PATCH 64/65] Fix YOUTUBE_SMALL preferences --- .../core/preferences/ui/ExclusivePreferencesPage.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java index 79afa7b23..2cde41914 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java @@ -124,7 +124,7 @@ public class ExclusivePreferencesPage extends ShopPageBase Date: Sat, 9 Jan 2016 18:44:32 -0500 Subject: [PATCH 65/65] Fix hub fly for YOUTUBE_SMALL --- .../Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java index fb2c0090e..b6882a1f9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java @@ -10,6 +10,7 @@ import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; @@ -82,8 +83,9 @@ public class JumpManager extends MiniPlugin { if (player.getGameMode() == GameMode.CREATIVE) continue; - - if (Manager.getPreferences().Get(player).Invisibility) + + Rank rank = Manager.GetClients().Get(player).GetRank(); + if (Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) { player.setAllowFlight(true); continue;