From 4ba2e8c96c56f1819407c4e3a4156a9004dc89b6 Mon Sep 17 00:00:00 2001 From: Cheese Date: Tue, 8 Dec 2015 10:31:11 +1100 Subject: [PATCH 1/6] fixed old staff being stuck invis. partially changed scoreboard to show playercount --- .../src/mineplex/hub/HubClient.java | 14 +------------- .../src/mineplex/hub/HubManager.java | 17 ++++++++--------- .../hub/modules/HubVisibilityManager.java | 2 +- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubClient.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubClient.java index 4008f1b63..4b56eff02 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubClient.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubClient.java @@ -22,9 +22,7 @@ public class HubClient public int DisplayLength = 16; private int _lastGemCount = 0; - - private int _lastCoinCount = 0; - + public HubClient(String name) { ScoreboardString = " Welcome " + name + ", to the Mineplex Network!"; @@ -133,14 +131,4 @@ public class HubClient return display; } - - public void SetLastCoinCount(int coins) - { - _lastCoinCount = coins; - } - - public int GetLastCoinCount() - { - return _lastCoinCount; - } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index ea96b4c65..8e78486e7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -165,7 +165,7 @@ public class HubManager extends MiniClientPlugin private HashMap _scoreboards = new HashMap(); private String _serverName = ""; - + private int _lastPlayerCount = 0; private boolean _shuttingDown; private HashMap _portalTime = new HashMap(); @@ -719,15 +719,14 @@ public class HubManager extends MiniClientPlugin //Space obj.getScore(" ").setScore(line--); - //Coins - obj.getScore(C.cYellow + C.Bold + "Coins").setScore(line--); + //Players + obj.getScore(C.cYellow + C.Bold + "Players").setScore(line--); - // Remove Old - player.getScoreboard().resetScores(Get(player.getName()).GetLastCoinCount() + ""); - // Add New - obj.getScore(GetDonation().Get(player.getName()).getCoins() + "").setScore(line--); - - Get(player.getName()).SetLastCoinCount(GetDonation().Get(player.getName()).getCoins()); + player.getScoreboard().resetScores(_lastPlayerCount + ""); + + _lastPlayerCount++; + + obj.getScore(_lastPlayerCount + "").setScore(line--); //Space diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index db7624cd9..1733a2fcc 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -65,7 +65,7 @@ public class HubVisibilityManager extends MiniPlugin { boolean hideMe = Manager.GetTutorial().InTutorial(player) || UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || - Manager.getPreferences().Get(player).Invisibility || + (Manager.getPreferences().Get(player).Invisibility && Manager.GetClients().Get(player).GetRank().has(Rank.MODERATOR)) || _hiddenPlayers.contains(player); for (Player other : UtilServer.getPlayers()) From fe1f763374bcaf0b98839715b97ed7c81131b87e Mon Sep 17 00:00:00 2001 From: Cheese Date: Tue, 8 Dec 2015 15:26:32 +1100 Subject: [PATCH 2/6] changed order blocks will be added to the list --- .../src/mineplex/core/common/util/UtilBlock.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index da7bc464c..8f3b37176 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -552,8 +552,8 @@ public class UtilBlock if (diagonals) { for (int x = -1; x <= 1; x++) - for (int y = -1; y <= 1; y++) - for (int z = -1; z <= 1; z++) + for (int z = -1; z <= 1; z++) + for (int y = 1; y >= -1; y--) { if (x == 0 && y == 0 && z == 0) continue; @@ -563,11 +563,11 @@ public class UtilBlock else { blocks.add(block.getRelative(BlockFace.UP)); - blocks.add(block.getRelative(BlockFace.DOWN)); blocks.add(block.getRelative(BlockFace.NORTH)); blocks.add(block.getRelative(BlockFace.SOUTH)); blocks.add(block.getRelative(BlockFace.EAST)); blocks.add(block.getRelative(BlockFace.WEST)); + blocks.add(block.getRelative(BlockFace.DOWN)); } return blocks; From a84f580719d1b221bbcaa49cd19d4251defa3b11 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 8 Dec 2015 05:45:26 -0500 Subject: [PATCH 3/6] Update IntelliJ to Java 8 --- Plugins/.idea/compiler.xml | 3 ++- Plugins/.idea/misc.xml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/.idea/compiler.xml b/Plugins/.idea/compiler.xml index 30263f09d..b232f8467 100644 --- a/Plugins/.idea/compiler.xml +++ b/Plugins/.idea/compiler.xml @@ -5,6 +5,7 @@ + @@ -28,7 +29,7 @@ - + - + \ No newline at end of file From b22c64ca6a5419e6b23abea1681cc750d15b6d37 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 8 Dec 2015 05:51:21 -0500 Subject: [PATCH 4/6] Fix excludes --- Plugins/.idea/compiler.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/Plugins/.idea/compiler.xml b/Plugins/.idea/compiler.xml index b232f8467..df8666836 100644 --- a/Plugins/.idea/compiler.xml +++ b/Plugins/.idea/compiler.xml @@ -5,7 +5,6 @@ - From addb2c8c0e91c5ac1162d5d09ed1cca5b4611910 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 8 Dec 2015 08:02:40 -0500 Subject: [PATCH 5/6] Fix java 8 compiler issue --- .../game/arcade/game/games/smash/perks/PerkCowAngryHerd.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowAngryHerd.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowAngryHerd.java index 79f51f53b..d398bba74 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowAngryHerd.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowAngryHerd.java @@ -87,7 +87,8 @@ public class PerkCowAngryHerd extends SmashPerk loc.add(UtilAlg.getLeft(dir).multiply(i*1.5)); Manager.GetGame().CreatureAllowOverride = true; - Cow cow = player.getWorld().spawn(loc, isSuperActive(player) ? MushroomCow.class : Cow.class); + Class clazz = isSuperActive(player) ? MushroomCow.class : Cow.class; + Cow cow = player.getWorld().spawn(loc, clazz); Manager.GetGame().CreatureAllowOverride = false; _active.add(new DataCowCharge(player, cow)); From a1915e324c4a7af83142cd83a518c101b925966b Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 8 Dec 2015 08:42:45 -0500 Subject: [PATCH 6/6] Some java 8 code --- .../mineplex/core/common/util/UtilServer.java | 7 ++ .../mineplex/core/noteblock/NotePlayer.java | 94 ++++++++----------- 2 files changed, 45 insertions(+), 56 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java index c56faa15a..79f248c3d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java @@ -1,10 +1,12 @@ package mineplex.core.common.util; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.LinkedList; import java.util.List; +import java.util.stream.Stream; import org.bukkit.Bukkit; import org.bukkit.Server; @@ -18,6 +20,11 @@ public class UtilServer return getServer().getOnlinePlayers().toArray(new Player[0]); } + public static Collection getPlayersCollection() + { + return getServer().getOnlinePlayers(); + } + public static List getSortedPlayers() { return getSortedPlayers(new Comparator() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/noteblock/NotePlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/noteblock/NotePlayer.java index 941bc1dd9..70e5a8c1f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/noteblock/NotePlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/noteblock/NotePlayer.java @@ -1,7 +1,10 @@ package mineplex.core.noteblock; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -40,78 +43,57 @@ public class NotePlayer private void startThread() { - Thread thread = new Thread(new Runnable() - { - @Override - public void run() + Thread thread = new Thread(() -> { + while (!_finished) { - long startTime = System.currentTimeMillis(); - while (!_finished) + _tick++; + if (_tick > _song.getLength()) { - _tick++; - if (_tick > _song.getLength()) + if (_loop) { - if (_loop) - { - _tick = 1; - } - else - { - _finished = true; - - _plugin.getServer().getScheduler().runTask(_plugin, new Runnable() - { - @Override - public void run() - { - SongFinishEvent event = new SongFinishEvent(_song); - _plugin.getServer().getPluginManager().callEvent(event); - } - }); - - return; - } + _tick = 1; } - - playTick(_tick); - - try + else { - Thread.sleep(_sleepMs); - } - catch (InterruptedException e) - { - e.printStackTrace(); + _finished = true; + + _plugin.getServer().getScheduler().runTask(_plugin, () -> { + SongFinishEvent event = new SongFinishEvent(_song); + _plugin.getServer().getPluginManager().callEvent(event); + }); + + return; } } + + playTick(_tick); + + try + { + Thread.sleep(_sleepMs); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } } }); thread.start(); } + private void playNote(Note note, float volume, Collection players) + { + players.stream().filter(_verifier::shouldPlay).forEach((player) -> + player.playSound(player.getEyeLocation(), UtilNote.getInstrumentSound(note.getInstrument()), volume, (float) UtilNote.getPitch(note.getNote() - 33))); + } + private void playTick(int tick) { - Player[] playerArray = UtilServer.getPlayers(); - List players = new ArrayList<>(playerArray.length); - for (Player player : playerArray) - { - if (_verifier.shouldPlay(player)) - players.add(player); - } + Collection players = UtilServer.getPlayersCollection(); - for (NoteLayer layer : _song.getLayers()) - { - Note note = layer.getNote(tick); - if (note != null) - { - float volume = _volumeMult * (layer.getVolume() / 100F); - for (Player player : players) - { - player.playSound(player.getEyeLocation(), UtilNote.getInstrumentSound(note.getInstrument()), volume, (float) UtilNote.getPitch(note.getNote() - 33)); - } - } - } + float volume = _volumeMult * 1F; + _song.getLayers().stream().map(layer -> layer.getNote(tick)).filter(Objects::nonNull).forEach((note) -> playNote(note, volume, players)); } public void cancel()