From ae03743c63cf88bb86d95231cc18329d882fa167 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 4 May 2015 19:27:16 -0500 Subject: [PATCH 1/9] Build sort of bug fix for teleported into block --- .../src/nautilus/game/arcade/game/games/build/Build.java | 5 +++++ 1 file changed, 5 insertions(+) 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 db8d93e7b..cf215615a 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 @@ -489,6 +489,11 @@ public class Build extends SoloGame Location loc = data.Spawn.clone().add(oX, 0, oZ); loc.setDirection(UtilAlg.getTrajectory(loc, data.Spawn)); + // This is supposed to be a quick fix for players being teleported into blocks + // I am not sure the exact cause of this bug, it seems to happen when there is a specific amount of players + if (loc.getBlock() != null && loc.getBlock().getType() != Material.AIR) + loc.setY(loc.getWorld().getHighestBlockYAt(loc) + 1); + UtilServer.getPlayers()[i].closeInventory(); UtilServer.getPlayers()[i].eject(); UtilServer.getPlayers()[i].leaveVehicle(); From 5ec04263d4cd36d05c04af097d31e4c48f9c642f Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 8 May 2015 07:31:03 +1200 Subject: [PATCH 2/9] Map stuff: First commit (or second?) --- .../src/mineplex/core/map/ChunkMap.java | 42 ++++ .../mineplex/core/map/ChunkMapRenderer.java | 203 ++++++++++++++++++ .../mineplex/core/map/ImageMapRenderer.java | 32 +-- .../src/mineplex/core/map/MapText.java | 182 ++++++++++++++++ .../src/mineplex/core/map/ascii.png | Bin 0 -> 2516 bytes 5 files changed, 443 insertions(+), 16 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMap.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMapRenderer.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/map/ascii.png diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMap.java b/Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMap.java new file mode 100644 index 000000000..f0c6c3e18 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMap.java @@ -0,0 +1,42 @@ +package mineplex.core.map; + +import net.minecraft.server.v1_7_R4.WorldMap; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.map.MapRenderer; +import org.bukkit.map.MapView; + +public class ChunkMap +{ + public ItemStack getItem(Location loc) + { + MapView map = Bukkit.createMap(Bukkit.getWorlds().get(0)); + + for (MapRenderer r : map.getRenderers()) + { + map.removeRenderer(r); + } + + ItemStack item = new ItemStack(Material.MAP); + + item.setDurability(map.getId()); + + WorldMap worldMap = new WorldMap("map_" + map.getId()); + + ChunkMapRenderer renderer = new ChunkMapRenderer(worldMap); + + map.addRenderer(renderer); + + worldMap.scale=(byte)3; + worldMap.centerX = loc.getBlockX(); + worldMap.centerZ = loc.getBlockZ(); + worldMap.c(); + + renderer.setupMap(loc.getWorld()); + + return item; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMapRenderer.java b/Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMapRenderer.java new file mode 100644 index 000000000..ef6431a2b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/ChunkMapRenderer.java @@ -0,0 +1,203 @@ +package mineplex.core.map; + +import java.util.HashMap; +import java.util.Map.Entry; + +import net.minecraft.server.v1_7_R4.Block; +import net.minecraft.server.v1_7_R4.Blocks; +import net.minecraft.server.v1_7_R4.Chunk; +import net.minecraft.server.v1_7_R4.MaterialMapColor; +import net.minecraft.server.v1_7_R4.MathHelper; +import net.minecraft.server.v1_7_R4.WorldMap; +import net.minecraft.util.com.google.common.collect.HashMultiset; +import net.minecraft.util.com.google.common.collect.Iterables; +import net.minecraft.util.com.google.common.collect.Multisets; + +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.entity.Player; +import org.bukkit.map.MapCanvas; +import org.bukkit.map.MapRenderer; +import org.bukkit.map.MapView; + +public class ChunkMapRenderer extends MapRenderer +{ + private final WorldMap worldmap; + private byte[] colors = new byte[128 * 128 * 128]; + + public ChunkMapRenderer(WorldMap worldMap) + { + super(false); + this.worldmap = worldMap; + } + + public void setupMap(World world) + { + int i = 1 << worldmap.scale; + int j = worldmap.centerX; + int k = worldmap.centerZ; + int l = MathHelper.floor(0) / i + 64; + int i1 = MathHelper.floor(0) / i + 64; + int j1 = 128 / i; + + for (int k1 = l - j1 + 1; k1 < l + j1; k1++) + { + int l1 = 255; + int i2 = 0; + double d0 = 0.0D; + + for (int j2 = i1 - j1 - 1; j2 < i1 + j1; j2++) + { + if ((k1 >= 0) && (j2 >= -1) && (k1 < 128) && (j2 < 128)) + { + int k2 = k1 - l; + int l2 = j2 - i1; + boolean flag = k2 * k2 + l2 * l2 > (j1 - 2) * (j1 - 2); + int i3 = (j / i + k1 - 64) * i; + int j3 = (k / i + j2 - 64) * i; + HashMultiset hashmultiset = HashMultiset.create(); + Chunk chunk = ((CraftWorld) world).getHandle().getChunkAtWorldCoords(i3, j3); + + if (!chunk.isEmpty()) + { + int k3 = i3 & 0xF; + int l3 = j3 & 0xF; + int i4 = 0; + double d1 = 0.0D; + + for (int j4 = 0; j4 < i; j4++) + { + for (int k4 = 0; k4 < i; k4++) + { + int l4 = chunk.b(j4 + k3, k4 + l3) + 1; + Block block = Blocks.AIR; + int i5 = 0; + + if (l4 > 1) + { + do + { + l4--; + block = chunk.getType(j4 + k3, l4, k4 + l3); + i5 = chunk.getData(j4 + k3, l4, k4 + l3); + } + while ((block.f(i5) == MaterialMapColor.b) && (l4 > 0)); + + if ((l4 > 0) && (block.getMaterial().isLiquid())) + { + int j5 = l4 - 1; + Block block1; + do + { + block1 = chunk.getType(j4 + k3, j5--, k4 + l3); + i4++; + } + while ((j5 > 0) && (block1.getMaterial().isLiquid())); + } + } + + d1 += l4 / (i * i); + hashmultiset.add(block.f(i5)); + } + } + + i4 /= i * i; + double d2 = (d1 - d0) * 4.0D / (i + 4) + ((k1 + j2 & 0x1) - 0.5D) * 0.4D; + byte b0 = 1; + + if (d2 > 0.6D) + { + b0 = 2; + } + + if (d2 < -0.6D) + { + b0 = 0; + } + + MaterialMapColor materialmapcolor = (MaterialMapColor) Iterables.getFirst( + Multisets.copyHighestCountFirst(hashmultiset), MaterialMapColor.b); + + if (materialmapcolor == MaterialMapColor.n) + { + d2 = i4 * 0.1D + (k1 + j2 & 0x1) * 0.2D; + b0 = 1; + if (d2 < 0.5D) + { + b0 = 2; + } + + if (d2 > 0.9D) + { + b0 = 0; + } + } + + d0 = d1; + if ((j2 >= 0) && (k2 * k2 + l2 * l2 < j1 * j1) && ((!flag) || ((k1 + j2 & 0x1) != 0))) + { + byte b1 = colors[(k1 + j2 * 128)]; + byte b2 = (byte) (materialmapcolor.M * 4 + b0); + + if (b1 != b2) + { + if (l1 > j2) + { + l1 = j2; + } + + if (i2 < j2) + { + i2 = j2; + } + + colors[(k1 + j2 * 128)] = b2; + } + } + } + } + } + + if (l1 <= i2) + worldmap.flagDirty(k1, l1, i2); + } + } + + @Override + public void render(MapView view, MapCanvas canvas, Player player) + { + int scale = 1 << worldmap.scale; + byte i = 30; + + HashMap map = new HashMap(); + + for (int mapX = 0; mapX < 128; mapX++) + { + for (int mapZ = 0; mapZ < 128; mapZ++) + { + byte color = (byte) 0;// worldmap.colors[(z * 128 + x)]; + + int bX = (worldmap.centerX + ((mapX - 64) * scale)) & 0x000F; + int bZ = (worldmap.centerZ + ((mapZ - 64) * scale)) & 0x000F; + + if (bX == 0 || bX == 15 || bZ == 0 || bZ == 15) + { + Entry entry = new HashMap.SimpleEntry((mapX - bX) / 16, (mapZ - bZ) / 16); + + if (!map.containsKey(entry)) + { + map.put(entry, i++); + } + + color = map.get(entry); + } + else + { + color = colors[(mapZ * 128 + mapX)]; + } + + canvas.setPixel(mapX, mapZ, color); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java b/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java index b853aad2f..80b57ae69 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java @@ -1,6 +1,5 @@ package mineplex.core.map; -import java.awt.Image; import java.awt.image.BufferedImage; import org.bukkit.entity.Player; @@ -10,21 +9,22 @@ import org.bukkit.map.MapView; public class ImageMapRenderer extends MapRenderer { - private Image _image; - private boolean _first = true; + private BufferedImage _image; + private boolean _first = true; - public ImageMapRenderer(BufferedImage image) - { - _image = image; - } + public ImageMapRenderer(BufferedImage image) + { + _image = image; + } - @Override - public void render(MapView view, MapCanvas canvas, Player player) - { - if (_image != null && _first) - { - canvas.drawImage(0, 0, _image); - _first = false; - } - } + @Override + public void render(MapView view, MapCanvas canvas, Player player) + { + if (_image != null && _first) + { + canvas.drawImage(0, 0, _image); + + _first = false; + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java b/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java new file mode 100644 index 000000000..289c15570 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java @@ -0,0 +1,182 @@ +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 org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.map.MapRenderer; +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(); + int lineWidth = 0; + String current = ""; + + for (String word : text.split("(?<= )")) + { + int length = 0; + + for (char c : word.toCharArray()) + { + length += _characters.get(c).getWidth(); + } + + if (lineWidth + length >= 127) + { + lineWidth = 0; + returns.add(current); + current = ""; + } + + current += word; + lineWidth += length; + } + + returns.add(current); + + return returns; + } + + public ItemStack getMap(String... text) + { + if (_characters.isEmpty()) + { + loadCharacters(); + } + + BufferedImage image = new BufferedImage(128, 128, BufferedImage.TYPE_INT_RGB); + Graphics g = image.getGraphics(); + int height = 1; + + for (String string : text) + { + for (String line : split(string)) + { + int length = 1; + + for (char c : line.toCharArray()) + { + BufferedImage img = _characters.get(c); + + if (img == null) + { + System.out.print("Error: '" + c + "' has no image associated"); + continue; + } + + g.drawImage(img, length, height, null); + + length += img.getWidth(); + } + + height += 8; + } + } + + MapView map = Bukkit.createMap(Bukkit.getWorlds().get(0)); + + for (MapRenderer r : map.getRenderers()) + { + map.removeRenderer(r); + } + + map.addRenderer(new ImageMapRenderer(image)); + + ItemStack item = new ItemStack(Material.MAP); + + item.setDurability(map.getId()); + + return item; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/ascii.png b/Plugins/Mineplex.Core/src/mineplex/core/map/ascii.png new file mode 100644 index 0000000000000000000000000000000000000000..587966dc34dccb49992236660b344f46c66c965c GIT binary patch literal 2516 zcmV;_2`l!AP)_m$LuoG-{_;|FwLyek9-e9{o+0 zt{v=kxUxLj#$TG<{@vsA(t+;4Y`%iR(R_=0csqm{AF?AYF2&A2N`T$69)+sEz4oK| z-fw1)Pdy(<`QJ;5%uk!KNS=&l^Pip=vC!iJAC%$T4oX$sKV$WQ6*}Vtat%YEgsQg zy+yY2@3I3tW^ug*M1K?AVJl4d*K+`Naj$hma5=j}k#CE`d^-mSp@5979Z`ai-+T2~ zD8RENe6#GA!oUm+L$uhdIaRHRzuC^!}-@-{%kNL6V{FC&2H0HW4HRD66h2e_U4Si2J;4r`Lp1yCuv z>P48LTTpGx5CJR-U_`*(D4?1EHne^L%&tt3SFi^mR9>x!U%l5x#;?E9E4Lb^A!W?| zM_Fu?MMn)e8JM_|S8#TRvyP$J@i(L*%MhY)=tRy3tlj(cgC3N-j>cr&nsUc~-Fb{b zC1dMX_{}pA6R|@maQF-zAT|E$psH-`=mJ(;oM2H#wbG_UTG9Lu%O*X)cCTZ{C9Mo& zkfZ2K|1A-VY>=qa&3`&T#9CIxP8pk6zJfc*t z_>C%+**lNO?oErLyK%htyBYmaTx?;+ukv}wD3~o{?NaLit7zw=zM(k#4u$aCX2u@S z6pP~70jli;s!3$}#$x;Qi>r5Sc}F_iq7Q+iLzzI;E9yC zVBTF0A=TmNXXqB^|3^fv{8jp2Wh|n{rw+?DJE8}>qh{I}stAC27qKZI&1#Dtg={n1ueJt8 z39u=yZZWW_IzRgSdUSjYL|cJCnum+o^ZHDAWqxLS%KXPc!MEf2pPlrRgoHA!v;#0W z8fjmt1ZU=6Wr!--0PJz@6YLDtmO#dQ+VDMk9%_aRM`U{~|a&9BrG-SG;P55Z`_;APHfs(8}yF4mm*Yhdt9F8Y|!WZRTCT zS?~T;?GQ!0|D6h9Up1GAycfWD6=zWzWJzNTB~ib6wtUsAVygFvE5w8{(B*RH>BzMw zl_?sXydJh^okCRc15&?>?4Y|0Jyo`d=#woG%UzVsXXc;f0Bv?yGBsXTD3O-ZcD~rc zDrr>;o^>|@f`JSNKv`^7MnCO~M*s^eu zt)IFcety~N`rVT;fB*K%ZMOBC)UFHN`?iRnrz|OnVAh*{5hYS)h84^cTfSKfk8psi zc6??-3XONxn|>L@5Us!0j{2>J+c`jw8&q1ynEYr2w9JBK-bPlU1dpg`4scaIqHIld zFf?k@(^1&^(eZixi*S%^e%B+&QvOCp28-SA)2wGD8U^&MTuL2ar%5QlV}T>q$v#@7 zEQ{(LmaM$$GQGaB*XO(lBAE@8E&thj;LAC{+pU_a$X^w&k$C;9vJssB{z?LZxz@(VhE|&;mmuxnYWNLy2`BjLj=H5UgUYS73x@-k57(vceN7wgnJfS3EXKDz)lN1 z9GP{Mn%%xC27zLHUYv!<`Nol%Bt*s`%2`hyv(6CKH>x8<^_!Xc1=IK5w>v@Tsxj_-rq9_Dr&vFet*y%i2D0m;m$HpafB!$h{1AOJJ;{^gAJwI zTW||8jpn@9&usrby@?scv#Y|~PcXn7r(_YYwV^79`MH>Wm z5DH=nu9^p>{H`E`VW98IF5hsZmqhEMG64`0000 Date: Fri, 8 May 2015 18:56:00 +1200 Subject: [PATCH 3/9] Achievement: Fix wizards 10 win to 50 wins, change wizards to blaze rod, change stats layout --- .../core/achievement/Achievement.java | 2 +- .../core/achievement/AchievementCategory.java | 2 +- .../ui/page/AchievementMainPage.java | 43 +++++++++---------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 3c6d242b2..b8c9db367 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -95,7 +95,7 @@ public enum Achievement WIZARDS_WINS("Supreme Wizard", 600, new String[]{"Wizards.Wins"}, new String[]{"Win 50 games of Wizards"}, - new int[]{10}, + new int[]{50}, AchievementCategory.WIZARDS), //Smash Mobs diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 7f57f711c..cd9bab208 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -42,7 +42,7 @@ public enum AchievementCategory WIZARDS("Wizards", null, new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" }, new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" }, - Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"), + Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Extra Class Skills"), MINE_STRIKE("MineStrike", null, new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java index 1ad16a15f..ff678620d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java @@ -17,6 +17,7 @@ import mineplex.core.achievement.ui.button.ArcadeButton; import mineplex.core.achievement.ui.button.CategoryButton; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemLayout; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; import mineplex.core.stats.StatsManager; @@ -42,50 +43,46 @@ public class AchievementMainPage extends ShopPageBase pageLayout = new ItemLayout( + "XXXXOXXXX", + "XXXXXXXXX", + "OXOXOXOXO", + "XXXXXXXXX", + "OXOXOXOXO", + "XXXXOXXXX").getItemSlots(); + int listSlot = 0; for (AchievementCategory category : AchievementCategory.values()) { if (category.getGameCategory() == AchievementCategory.GameCategory.ARCADE) continue; - CategoryButton button = new CategoryButton(getShop(), getPlugin(), _statsManager, category, getDonationManager(), getClientManager(), _target); + CategoryButton button = new CategoryButton(getShop(), getPlugin(), _statsManager, category, getDonationManager(), + getClientManager(), _target); ArrayList lore = new ArrayList(); lore.add(" "); - category.addStats(getClientManager(), _statsManager, lore, category == AchievementCategory.GLOBAL ? 5 : 2, getPlayer(), _target); + category.addStats(getClientManager(), _statsManager, lore, category == AchievementCategory.GLOBAL ? 5 : 2, + getPlayer(), _target); lore.add(" "); addAchievements(category, lore, 9); lore.add(" "); lore.add(ChatColor.RESET + "Click for more details!"); - int slot; - switch(category.getGameCategory()) - { - case GLOBAL: - slot = globalSlot; - break; - default: - slot = normalSlot; - normalSlot += 2; - } - - if (normalSlot == 28) - normalSlot = 36; - - ShopItem shopItem = new ShopItem(category.getIcon(), category.getIconData(), C.Bold + category.getFriendlyName(), lore.toArray(new String[0]), 1, false, false); - addButton(slot, shopItem, button); + ShopItem shopItem = new ShopItem(category.getIcon(), category.getIconData(), C.Bold + category.getFriendlyName(), + lore.toArray(new String[0]), 1, false, false); + addButton(pageLayout.get(listSlot++), shopItem, button); } - addArcadeButton(); + + addArcadeButton(pageLayout.get(listSlot++)); } - protected void addArcadeButton() + protected void addArcadeButton(int slot) { ArcadeButton button = new ArcadeButton(getShop(), getPlugin(), _statsManager, getDonationManager(), getClientManager(), _target); ShopItem shopItem = new ShopItem(Material.BOW, (byte) 0, C.Bold + "Arcade Games", new String[] {" ", ChatColor.RESET + "Click for more!"}, 1, false, false); - addButton(44, shopItem, button); + addButton(slot, shopItem, button); } protected void addAchievements(AchievementCategory category, List lore, int max) From 689ca94c5755c441b2eac71cc503bb7f179422ec Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 8 May 2015 18:57:33 +1200 Subject: [PATCH 4/9] Wizards: Nerf rainbow beam damage, rebalance gust spell, raise armor effectiveness --- .../arcade/game/games/wizards/SpellType.java | 8 ++++--- .../arcade/game/games/wizards/Wizards.java | 19 ++++++--------- .../game/games/wizards/spells/SpellGust.java | 24 ++++++++++++++++--- .../wizards/spells/SpellRainbowBeam.java | 2 +- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellType.java index c72976da6..e612fcd9d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellType.java @@ -105,13 +105,15 @@ public enum SpellType // ❤ 0, // Cooldown change per level 5, // Item amount in loot - C.cYellow + C.Bold + "Gust Size: " + C.Bold + C.cWhite + "10 x Spell Level blocks", + C.cYellow + C.Bold + "Gust Size: " + C.Bold + C.cWhite + "(Spell Level x 3) + 10 blocks", C.cYellow + C.Bold + "Gust Strength: " + C.Bold + C.cWhite + "Spell Level x 30%", "", - "Cast the spell and watch your enemies fly!"), + "Cast the spell and watch your enemies fly!", + + "Spell strength decreases with distance"), Heal(SpellElement.SUPPORT, // Spell element WandElement.LIFE, // Wand element @@ -280,7 +282,7 @@ public enum SpellType // ❤ 1, // Cooldown change per level 10, // Item amount in loot - C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "Spell Level + 2", + C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "Spell Level + 1", C.cYellow + C.Bold + "Range: " + C.Bold + C.cWhite + "80", diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java index 1998bcfa6..4351096b2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java @@ -20,7 +20,6 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; @@ -92,7 +91,6 @@ import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemHeldEvent; -import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.AnvilInventory; @@ -355,19 +353,19 @@ public class Wizards extends SoloGame if (name.contains("LEATHER")) { - percent = 8; + percent = 10; } else if (name.contains("GOLDEN") || name.contains("CHAINMAIL")) { - percent = 12; + percent = 15; } else if (name.contains("IRON")) { - percent = 15; + percent = 19; } else if (name.contains("DIAMOND")) { - percent = 20; + percent = 25; } if (name.contains("BOOTS")) @@ -752,12 +750,9 @@ public class Wizards extends SoloGame progressBar += "▌"; } - // Send to Player - for (Player player : players) - { - UtilTextBottom.display((prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar - + (suffix == null ? "" : ChatColor.RESET + " " + suffix), players); - } + UtilTextBottom.display((prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar + + (suffix == null ? "" : ChatColor.RESET + " " + suffix), players); + } public void drawUtilTextBottom(Player player) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java index da0c492d1..730274a97 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java @@ -1,6 +1,8 @@ package nautilus.game.arcade.game.games.wizards.spells; import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.games.wizards.Spell; @@ -20,7 +22,21 @@ public class SpellGust extends Spell implements SpellClick final Vector vector = player.getLocation().getDirection().setY(0).normalize().multiply(1.5).setY(0.3) .multiply(1.2 + (getSpellLevel(player) * 0.4D)); - final HashMap effected = UtilPlayer.getPlayersInPyramid(player, 45, 10 * getSpellLevel(player)); + final double gustSize = (getSpellLevel(player) * 3) + 10; + + final HashMap effected = UtilPlayer.getPlayersInPyramid(player, 45, gustSize); + + Iterator> itel = effected.entrySet().iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + if (!entry.getKey().canSee(player)) + { + itel.remove(); + } + } if (!effected.isEmpty()) { @@ -37,9 +53,11 @@ public class SpellGust extends Spell implements SpellClick continue; } - Wizards.getArcadeManager().GetCondition().Factory().Falling("Gust", target, player, 10, false, true); + Vector vec = vector.clone().multiply(Math.max(0.2, effected.get(target))); - target.setVelocity(vector); + Wizards.getArcadeManager().GetCondition().Factory().Falling("Gust", target, player, 40, false, true); + + target.setVelocity(vec); target.getWorld().playSound(target.getLocation(), Sound.BAT_TAKEOFF, 1, 0.7F); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowBeam.java index 4be60e6c1..ef51b077a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowBeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowBeam.java @@ -35,7 +35,7 @@ public class SpellRainbowBeam extends Spell implements SpellClick p.getEyeLocation().getDirection().normalize() .multiply(0.3 + p.getEyeLocation().distance(((LivingEntity) entityTarget).getEyeLocation()))); - double damage = (getSpellLevel(p) * 2) + 4; + double damage = (getSpellLevel(p) * 2) + 2; double dist = loc.distance(p.getLocation()) - (80 * .2D); // If target is more than 20% away From bca162588fc3c2e22378fa5b2910fc88219df622 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 May 2015 02:27:53 -0500 Subject: [PATCH 5/9] Fix Achievement page bugs (layout needs to be reviewed by chiss) --- .../core/achievement/AchievementCategory.java | 2 +- .../achievement/ui/page/AchievementMainPage.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 7f57f711c..cd9bab208 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -42,7 +42,7 @@ public enum AchievementCategory WIZARDS("Wizards", null, new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" }, new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" }, - Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"), + Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Extra Class Skills"), MINE_STRIKE("MineStrike", null, new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"}, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java index 1ad16a15f..6c0032bbd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java @@ -31,7 +31,7 @@ public class AchievementMainPage extends ShopPageBase lore, int max) From 0751876622e350a9dd04501ef36840947b1c8f26 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 9 May 2015 14:12:46 +1200 Subject: [PATCH 6/9] Wizards: Do a null check and event is cancelled check on damage --- .../nautilus/game/arcade/game/games/wizards/Wizards.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java index 4351096b2..6db30f5e1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java @@ -311,7 +311,7 @@ public class Wizards extends SoloGame public void onWandHit(CustomDamageEvent event) { // Damager is ENTITY - if (event.GetDamagerEntity(true) != null) + if (!event.isCancelled() && event.GetDamagerEntity(true) != null) { if (event.GetReason() == null) { @@ -323,9 +323,12 @@ public class Wizards extends SoloGame { Wizard wizard = getWizard(damager); - String reason = damager.getInventory().getHeldItemSlot() < wizard.getWandsOwned() ? "Wand" : "Fist"; + if (wizard != null) + { + String reason = damager.getInventory().getHeldItemSlot() < wizard.getWandsOwned() ? "Wand" : "Fist"; - event.AddMod(reason, reason, 0, true); + event.AddMod(reason, reason, 0, true); + } } } } From 822718095d9aee745d64e99db99ca0b7778733f8 Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Sat, 9 May 2015 12:23:07 -0500 Subject: [PATCH 7/9] cannot PM from spawn first push of cards game --- .../src/mineplex/core/map/MapText.java | 11 +- .../mineplex/core/message/MessageManager.java | 8 +- .../core/message/PrivateMessageEvent.java | 59 ++++ .../src/mineplex/hub/HubManager.java | 12 + .../src/nautilus/game/arcade/GameFactory.java | 2 + .../src/nautilus/game/arcade/GameType.java | 2 + .../game/arcade/game/games/build/Build.java | 4 +- .../arcade/game/games/cards/CardFactory.java | 66 +++++ .../game/arcade/game/games/cards/Cards.java | 271 ++++++++++++++++++ .../arcade/game/games/cards/RoundState.java | 8 + .../arcade/game/games/cards/VoteRoom.java | 86 ++++++ .../game/games/cards/kits/KitPlayer.java | 37 +++ .../game/arcade/game/games/draw/Draw.java | 2 +- 13 files changed, 564 insertions(+), 4 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/message/PrivateMessageEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/RoundState.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/VoteRoom.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/kits/KitPlayer.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java b/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java index 289c15570..d11f032dc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java @@ -9,8 +9,11 @@ import java.util.HashMap; import javax.imageio.ImageIO; +import mineplex.core.common.util.UtilServer; + import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.map.MapRenderer; import org.bukkit.map.MapView; @@ -128,7 +131,7 @@ public class MapText return returns; } - public ItemStack getMap(String... text) + public ItemStack getMap(boolean sendToServer, String... text) { if (_characters.isEmpty()) { @@ -176,6 +179,12 @@ public class MapText ItemStack item = new ItemStack(Material.MAP); item.setDurability(map.getId()); + + if (sendToServer) + { + for (Player player : UtilServer.getPlayers()) + player.sendMap(map); + } return item; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index b531744a8..b47a092e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -22,6 +22,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.event.StackerEvent; import mineplex.core.friend.FriendManager; import mineplex.core.friend.data.FriendData; import mineplex.core.friend.data.FriendStatus; @@ -96,7 +97,7 @@ public class MessageManager extends MiniClientPlugin } public boolean canMessage(Player from, Player to) - { + { if (!canSenderMessageThem(from, to.getName())) { return false; @@ -179,6 +180,11 @@ public class MessageManager extends MiniClientPlugin public void DoMessage(Player from, Player to, String message) { + PrivateMessageEvent pmEvent = new PrivateMessageEvent(from, to, message); + Bukkit.getServer().getPluginManager().callEvent(pmEvent); + if (pmEvent.isCancelled()) + return; + if (!canMessage(from, to)) { return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/PrivateMessageEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/message/PrivateMessageEvent.java new file mode 100644 index 000000000..07716d21b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/PrivateMessageEvent.java @@ -0,0 +1,59 @@ +package mineplex.core.message; + + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PrivateMessageEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private boolean _cancelled = false; + private Player _sender; + private Player _recipient; + private String _msg; + + public PrivateMessageEvent(Player sender, Player recipient, String msg) + { + _sender = sender; + _recipient = recipient; + _msg = msg; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public void setCancelled(boolean cancel) + { + _cancelled = cancel; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public Player getSender() + { + return _sender; + } + + public Player getRecipient() + { + return _recipient; + } + + public String getMessage() + { + return _msg; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index ebff189d5..529b00d7f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -70,6 +70,7 @@ import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.message.PrivateMessageEvent; import mineplex.core.mount.MountManager; import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.party.Party; @@ -612,6 +613,17 @@ public class HubManager extends MiniClientPlugin _portalTime.remove(event.getPlayer().getName()); } + + @EventHandler + public void playerPrivateMessage(PrivateMessageEvent event) + { + //Dont Let PM Near Spawn! + if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !_clientManager.Get(event.getSender()).GetRank().Has(Rank.HELPER)) + { + UtilPlayer.message(event.getSender(), F.main("Chat", "You must leave spawn before you can Private Message!")); + event.setCancelled(true); + } + } @EventHandler public void PlayerChat(AsyncPlayerChatEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java index 2320c9083..140e9e87e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java @@ -11,6 +11,7 @@ import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.barbarians.Barbarians; import nautilus.game.arcade.game.games.bridge.Bridge; import nautilus.game.arcade.game.games.build.Build; +import nautilus.game.arcade.game.games.cards.Cards; import nautilus.game.arcade.game.games.castlesiege.CastleSiege; import nautilus.game.arcade.game.games.champions.ChampionsDominate; import nautilus.game.arcade.game.games.champions.ChampionsTDM; @@ -70,6 +71,7 @@ public class GameFactory else if (gameType == GameType.BaconBrawl) return new BaconBrawl(_manager); else if (gameType == GameType.Bridge) return new Bridge(_manager); else if (gameType == GameType.Build) return new Build(_manager); + else if (gameType == GameType.Cards) return new Cards(_manager); else if (gameType == GameType.CastleSiege) return new CastleSiege(_manager); else if (gameType == GameType.Christmas) return new Christmas(_manager); else if (gameType == GameType.DeathTag) return new DeathTag(_manager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 3a514a456..2b2c97eec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -54,7 +54,9 @@ public enum GameType WitherAssault("Wither Assault", Material.SKULL_ITEM, (byte)1, GameCategory.ARCADE, 47), Wizards("Wizards", Material.BLAZE_ROD, (byte)0, GameCategory.SURVIVAL, 48, "http://chivebox.com/file/c/ResWizards.zip", true), ZombieSurvival("Zombie Survival", Material.SKULL_ITEM, (byte)2, GameCategory.SURVIVAL, 49), + Build("Master Builders", Material.BRICK, (byte)0, GameCategory.CLASSICS, 50), + Cards("Craft Against Humanity", Material.MAP, (byte)0, GameCategory.CLASSICS, 51), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); 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 db8d93e7b..904c1c042 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 @@ -163,10 +163,12 @@ public class Build extends SoloGame this.CreatureAllow = true; this.WorldFireSpread = true; + + UtilServer.getServer().spigot().getConfig().set("view-distance", 4); _words = new String[] { - "Rollercoaster", "Archery Range", "Pokemon", "Pirates", "Vikings", "Dinosaur", "Dragon", "Toilet", "Farm", "Tree House", "Burger", "Cat", "Truck", "Bicycle", "Soda", "Music Instrument", "Statue", "Cannon", "Catapult", "Sailing Boat", "Grim Reaper", "Star Wars", "Elephant", "Penguin", "Ninja", "Pot of Gold", "Shrek", "Fruit", "Breakfast", "Toaster", "Robot", "Camping", "Rocket", "Aliens", "Shipwreck", "Cannibals", "Flying Creature", "Beach Creature", "Sea Creature", "Spongebob", "Car", "Pot Plant", "Weapons", "Christmas", "King", "Queen", "Angel", "Demon", "Halloween", "Tank", "Aeroplane" + "Rollercoaster", "Archery Range", "Pokemon", "Pirates", "Vikings", "Dinosaur", "Dragon", "Toilet", "Farm", "Tree House", "Burger", "Cat", "Truck", "Bicycle", "Soda", "Music Instrument", "Statue", "Cannon", "Catapult", "Sailing Boat", "Grim Reaper", "Star Wars", "Elephant", "Penguin", "Ninja", "Pot of Gold", "Shrek", "Fruit", "Breakfast", "Toaster", "Robot", "Camping", "Rocket", "Aliens", "Shipwreck", "Flying Creature", "Beach Creature", "Sea Creature", "Spongebob", "Car", "Potted Plant", "Weapons", "Christmas", "King", "Queen", "Angel", "Demon", "Halloween", "Tank", "Aeroplane" }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java new file mode 100644 index 000000000..ac0f3834d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/CardFactory.java @@ -0,0 +1,66 @@ +package nautilus.game.arcade.game.games.cards; + +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilMath; +import mineplex.core.map.MapText; + +public class CardFactory +{ + private MapText _mapText; + + public CardFactory() + { + _mapText = new MapText(); + } + + private String[] _questions = new String[] + { + "When I get home from school, I crave _____.", "I was playing One in the Quiver when I ran into ____.", "Ultra+ now get free _____ every month.", "Everything was fine until _____ joined.", "Help me! My mom is _______.", "_________ crashed the server again…", "_______ ate his pet rabbit when he saw __________.", "My mouse batteries died because I was using it for ______.", "______ is the #1 reason of deaths on the server.", "Ugh, I'm lagging thanks to _____!", "I need to go to the doctor, I'm sick with _________!", "My best friend thinks he is _____.", "The cure for all diseases is partially made out of _____.", "When i was little i wanted to become a ______ and use _____ to save the world.", "I painted a beautiful painting of ____!", "When you grow up you will realize that ______ is all you need.", "_______ knew he had made the wrong choice when he realised he was _______.", "While falling asleep, I dreamt of ______ kissing ______.", "I went to a fancy restaurant, but the chef gave me _____!", "What am I supposed to do when I see _____ ______?", "There is absolutely nothing worse in this world than ___________.", "I get all excited and tingly when I see ________!", "I would rather be _________ than _________.", "I think my brother is a big fan of _______.", "Why can't I sleep at night?", "What's that smell?", "I got 99 problems but ________ ain't one.", "What's the next game coming out on Mineplex?", "What is the next trend on YouTube?", "It's a pity that kids these days are getting involved with ________.", "What's that sound?", "What should I look for in a girlfriend?", "I wish I could forget about _______.", "What don't you want to find in your treasure chest?", "I can't take you seriously when you are always _________.", "I'm sorry, but I couldn't finish my homework because of _________.", "What does Batman do in his spare time?", "What's a girl's best friend?", "___________. That's how I want to die.", "For my next trick, I will pull _______ out of ________.", "________ is a slippery slope that leads to ________.", "Instead of coal, Santa now gives the bad children ________.", "An exciting game of The Bridges would be incomplete without _________.", "War! What is it good for?", "While mining diamonds, I like to think about ________.", "What are my parents hiding from me?", "What will always make girls like you?", "What did I bring back from the Nether?", "What don't you want to find in your Mushroom Soup?", "Step 1: __________, Step 2: __________, Step 3: Profit!" ,"What makes you need to fart?", "What do old people smell like?", "What's your secret power?", "The class field trip was completely ruined by _______.", "I never understood _______, until I found ________.", "What does Justin Beiber enjoy in his spare time?", "Why is the Villager sticky?", "Scientists think that Creepers explode because of _________.", "Why do you hurt all over?", "When you are a billionaire, you will spend all of your money on ________.", "How do you cheer up a sad friend?", "What is the new diet everyone is trying?", "What is the secret ingredient in Mountain Dew?", "________ is one of the few things that makes me happy.", "The most important thing you need to build a house is ________.", "What is the best way to get unbanned from Mineplex?", "_________ is the secret to winning at Super Smash Mobs.", + + }; + + private String[] _answers = new String[] + { + "A Stinky Pig Butt", "Mouldy Raw Fish", "A sawed off 10-foot pole", "billions of diamonds", "A whiny forum post", "Sparkling Diamonds", "Sheep that don’t know when to stop", "Villager Legs", "Curdled cow milk", "That one popcorn piece stuck in your teeth.", "THE DIAMOND DANCE!", "an unstoppable addiction to fly hacks", "the biggest pile of poop you've ever seen!", "Bed time", "A bag of Doritos and a Mountain Dew.", "zombies chewing on my butt", "Jazz hands", "Brain surgery", "A disappointing birthday party.", "Overly friendly Iron Golems", "An Endermans favourite block", "Puppies!", "your friend who deleted you from Skype", "being on fire", "two cows stealing your wallet", "a lifetime of sadness", "a golden notch apple", "dragon eggs", "holding hands", "kissing", "wearing parents on your head", "soup that is too hot", "edible underpants", "people who are terrible at PvP", "obesity", "sheep eating potatoes", "my collection of spider eyes", "oversized fishing rods", "working as a team", "horse meat", "zombies screaming while on fire", "a ghast calling her dad to say happy birthday", "Microsoft releasing a good game", "bad childhood memories", "a bad haircut", "a steamy locker room", "armed robbery", "bankruptcy", "stacks of TNT", "a block of dirt", "cold pizza", "a pack of angry wolves", "eternal sadness", "the Nether", "a blaze having a barbeque", "Endermen robbing your house", "dental surgery", "religious villagers", "poor villagers", "flesh-eating bacteria", "the drive to win", "friends who take all your loot", "Morgan Freeman", "Darth Vader", "Villager #17", "Barrack Obama", "Lady Gaga", "That one hobo that lives down the street", "A Sad Creeper", "Parker Games", "A shaved sheep", "CaptainSparklez", "DanTDM", "SkyDoesMinecraft", "Mineplex", "A Mineplex Administrator", "Miley Cyrus", "Notch", "Mojang", "Pikachu", "BATMAN!!!", "The Hulk", "Justin Beiber", "Herobrine", "Pirates", "Vikings", "Ninjas", "Uncontrollably pooping", "Dancing until a helper warned me", "Making passive aggressive tweets", "complaining about balance on the forums", "Chopping down the mineplex lobby tree", "crashing servers", "falling off a cliff", "Realizing that you arent actually a ninja.", "Eating a hot pepper", "Digging straight down", "using xray hacks", "picking your nose", "Playing against a team in SSM", "Mining diamond with a stone pickaxe", "stepping on Legos", "Shaking it off", "Watching Parker games", "Accidentally hiding an egg as Easter bunny morph", "doing a poop and realizing there is no toilet paper", "Eating rotten flesh", "Understanding how magnets work", "watching videos on YouTube", "finding Legendary loot in a Treasure Chest", "Doing homework", "dividing by 0", "Finding out the meaning of life", "banning players for no reason", "dying", "so angry that he pooped himself.", "spending hours planting carrots", "doing the right thing", "sleeping in a cave", "getting drunk on potions", "trolling on the internet", "punching a tree", "leaving a stinky surprise", "doing math", "being devoured by zombie pigmen", "farting and walking away", "sneakily doing a poop", "blowing everything up with TNT", "peeing a little bit", "Tweeting about cats", "reading the instructions carefully", + "leaving some poop in the corner of the room", "eating a balanced breakfast", "puking", "shooting arrows at bats", "typing /kill", "watching Frozen repeatedly", "building a house out of dirt", "winking at chickens", "yelling at a toaster", "putting in 110% effort", "paying a lot of money", "bribing with candy", "throwing rocks at people", "crying until everything is better" + }; + + public String getQuestionCard() + { + return _questions[UtilMath.r(_questions.length)]; + } + + public String getAnswerCard() + { + return _answers[UtilMath.r(_answers.length)]; + } + + public ItemStack getAnswerStack() + { + String text = getAnswerCard(); + + ItemStack stack = _mapText.getMap(true, text); + + ItemMeta meta = stack.getItemMeta(); + meta.setDisplayName(C.cGreen + text); + stack.setItemMeta(meta); + + return stack; + } + + public ItemStack getQuestionStack() + { + String text = getQuestionCard(); + + ItemStack stack = _mapText.getMap(true, text); + + ItemMeta meta = stack.getItemMeta(); + meta.setDisplayName(C.cYellow + text); + stack.setItemMeta(meta); + + return stack; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java new file mode 100644 index 000000000..07e2ab006 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java @@ -0,0 +1,271 @@ +package nautilus.game.arcade.game.games.cards; + +import java.util.ArrayList; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.GameScore; +import nautilus.game.arcade.game.games.cards.kits.KitPlayer; +import nautilus.game.arcade.kit.Kit; + +public class Cards extends SoloGame +{ + private CardFactory _cardFactory; + + private ArrayList _ranks = new ArrayList(); + + private NautHashMap _voteRooms = new NautHashMap(); + + private Location _questionLoc = null; + private ItemFrame _questionEnt = null; + + private RoundState _roundState = RoundState.View; + private long _roundStateTime = 0; + private Player _roundDealer = null; + + private String _question = null; + + private long _playTime = 16000; + private long _judgeTime = 16000; + private long _viewTime = 6000; + + private ArrayList _dealerOrder = new ArrayList();; + + public Cards(ArcadeManager manager) + { + super(manager, GameType.Cards, + + new Kit[] + { + new KitPlayer(manager), + }, + + new String[] + { + "Be creative and build something", + "based on the build theme!" + }); + + this.StrictAntiHack = true; + this.Damage = false; + this.HungerSet = 20; + this.HealthSet = 20; + + this.WorldTimeSet = 6000; + + this.PrepareFreeze = false; + + _cardFactory = new CardFactory(); + } + + @Override + public void ParseData() + { + for (Location loc : WorldData.GetDataLocs("RED")) loc.getBlock().setType(Material.OBSIDIAN); + for (Location loc : WorldData.GetDataLocs("ORANGE")) loc.getBlock().setType(Material.OBSIDIAN); + for (Location loc : WorldData.GetDataLocs("GREEN")) loc.getBlock().setType(Material.OBSIDIAN); + + + _questionLoc = WorldData.GetDataLocs("PINK").get(0); + _questionLoc.getBlock().setType(Material.OBSIDIAN); + } + + @EventHandler + public void prepare(PlayerPrepareTeleportEvent event) + { + for (int i=0 ; i<9 ; i++) + { + event.GetPlayer().getInventory().addItem(_cardFactory.getAnswerStack()); + } + + _dealerOrder.add(event.GetPlayer()); + + //Prep Vote Room + _voteRooms.put(event.GetPlayer(), new VoteRoom( + WorldData.GetDataLocs("YELLOW").remove(0), + WorldData.GetDataLocs("ORANGE"), + WorldData.GetDataLocs("GREEN"), + WorldData.GetDataLocs("RED"))); + + addScore(event.GetPlayer(), 0); + } + + @EventHandler + public void roundStateUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + if (_roundState == RoundState.PlaceCards && UtilTime.elapsed(_roundStateTime, _playTime)) + { + setRoundState(RoundState.Judge); + } + else if (_roundState == RoundState.Judge && UtilTime.elapsed(_roundStateTime, _judgeTime)) + { + setRoundState(RoundState.View); + } + else if (_roundState == RoundState.View && UtilTime.elapsed(_roundStateTime, _viewTime)) + { + setRoundState(RoundState.PlaceCards); + } + } + + public void setRoundState(RoundState state) + { + _roundStateTime = System.currentTimeMillis(); + _roundState = state; + + if (state == RoundState.PlaceCards) + { + + //Get Dealer + _roundDealer = _dealerOrder.remove(0); + _dealerOrder.add(_roundDealer); + + //New Question + ItemStack questionStack = _cardFactory.getQuestionStack(); + + if (_questionEnt != null) + { + _questionEnt.remove(); + _questionEnt = null; + } + + _questionEnt = _questionLoc.getWorld().spawn(_questionLoc.getBlock().getLocation(), ItemFrame.class); + _questionEnt.setItem(questionStack); + + //Teleport Players to Card Room + for (Player player : _voteRooms.keySet()) + { + VoteRoom room = _voteRooms.get(player); + + room.resetFrames(false); + + if (player.equals(_roundDealer)) + continue; + + player.teleport(room.Spawn); + + room.QuestionEnt.setItem(questionStack); + } + } + else if (state == RoundState.Judge) + { + GetTeamList().get(0).SpawnTeleport(); + + int i=0; + for (VoteRoom room : _voteRooms.values()) + { + room.displayAnswer(); + } + } + } + + public void addScore(Player player, double amount) + { + for (GameScore score : _ranks) + { + if (score.Player.equals(player)) + { + score.Score += amount; + EndCheck(); + return; + } + } + + _ranks.add(new GameScore(player, amount)); + + sortScores(); + } + + private void sortScores() + { + for (int i=0 ; i<_ranks.size() ; i++) + { + for (int j=_ranks.size()-1 ; j>0 ; j--) + { + if (_ranks.get(j).Score > _ranks.get(j-1).Score) + { + GameScore temp = _ranks.get(j); + _ranks.set(j, _ranks.get(j-1)); + _ranks.set(j-1, temp); + } + } + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (!InProgress()) + return; + + if (event.getType() != UpdateType.FAST) + return; + + writeScoreboard(); + } + + public void writeScoreboard() + { + //Wipe Last + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + + if (_roundState == RoundState.PlaceCards) + { + Scoreboard.Write(C.cYellow + C.Bold + "Select Time"); + Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _playTime - (System.currentTimeMillis() - _roundStateTime)), 1)); + + Scoreboard.WriteBlank(); + + Scoreboard.Write(C.cYellow + C.Bold + "Judge"); + Scoreboard.Write(C.cWhite + _roundDealer.getName()); + } + else if (_roundState == RoundState.Judge) + { + Scoreboard.Write(C.cYellow + C.Bold + "Judge Time"); + Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _judgeTime - (System.currentTimeMillis() - _roundStateTime)), 1)); + + Scoreboard.WriteBlank(); + + Scoreboard.Write(C.cYellow + C.Bold + "Judge"); + Scoreboard.Write(C.cWhite + _roundDealer.getName()); + } + else if (_roundState == RoundState.View) + { + Scoreboard.Write(C.cYellow + C.Bold + "View Time"); + Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _viewTime - (System.currentTimeMillis() - _roundStateTime)), 1)); + } + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Round Wins"); + for (GameScore score : _ranks) + { + Scoreboard.Write((int)score.Score + " " + C.Bold + score.Player.getName()); + } + + + Scoreboard.Draw(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/RoundState.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/RoundState.java new file mode 100644 index 000000000..1bce0902c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/RoundState.java @@ -0,0 +1,8 @@ +package nautilus.game.arcade.game.games.cards; + +public enum RoundState +{ + PlaceCards, + Judge, + View, +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/VoteRoom.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/VoteRoom.java new file mode 100644 index 000000000..264d4f45b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/VoteRoom.java @@ -0,0 +1,86 @@ +package nautilus.game.arcade.game.games.cards; + +import java.util.ArrayList; + +import mineplex.core.common.util.UtilAlg; + +import org.bukkit.Location; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.ItemFrame; + +public class VoteRoom +{ + public Location Spawn; + public Location Question; + public Location AnswerA; + public Location AnswerB; + + public ItemFrame QuestionEnt; + public ItemFrame AnswerAEnt; + public ItemFrame AnswerBEnt; + + public Location BoardAnswer; + public ItemFrame BoardAnswerEnt; + + public VoteRoom(Location spawn, ArrayList questions, ArrayList answers, ArrayList board) + { + Spawn = spawn; + + Question = UtilAlg.findClosest(spawn, questions); + questions.remove(Question); + + AnswerA = UtilAlg.findClosest(Question, answers); + answers.remove(AnswerA); + + AnswerB = UtilAlg.findClosest(Question, answers); + answers.remove(AnswerB); + + BoardAnswer = UtilAlg.findClosest(Question, board); + board.remove(BoardAnswer); + } + + public void resetFrames(boolean doubleAnswer) + { + if (QuestionEnt != null) + { + QuestionEnt.remove(); + QuestionEnt = null; + } + + if (AnswerAEnt != null) + { + AnswerAEnt.remove(); + AnswerAEnt = null; + } + + if (AnswerBEnt != null) + { + AnswerBEnt.remove(); + AnswerBEnt = null; + } + + if (BoardAnswerEnt != null) + { + BoardAnswerEnt.remove(); + BoardAnswerEnt = null; + } + + QuestionEnt = Question.getWorld().spawn(Question.getBlock().getLocation(), ItemFrame.class); + AnswerAEnt = AnswerA.getWorld().spawn(AnswerA.getBlock().getLocation(), ItemFrame.class); + BoardAnswerEnt = BoardAnswer.getWorld().spawn(BoardAnswer.getBlock().getLocation(), ItemFrame.class); + +// if (doubleAnswer) +// AnswerBEnt = AnswerB.getWorld().spawn(AnswerB, ItemFrame.class); + +// i.setFacingDirection(BlockFace.SOUTH); +// HangingPlaceEvent hEvent = new HangingPlaceEvent(i, player, bodyBlock, BlockFace.NORTH); +// plugin.getServer().getPluginManager().callEvent(hEvent); + } + + public void displayAnswer() + { + System.out.println(BoardAnswerEnt == null); + System.out.println(AnswerAEnt == null); + BoardAnswerEnt.setItem(AnswerAEnt.getItem()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/kits/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/kits/KitPlayer.java new file mode 100644 index 000000000..2e078e7a6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/kits/KitPlayer.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.cards.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitPlayer extends Kit +{ + public KitPlayer(ArcadeManager manager) + { + super(manager, "Player", KitAvailability.Free, + + new String[] + { + ";dsgoasdyay" + }, + + new Perk[] + { + }, + EntityType.SKELETON, + new ItemStack(Material.MAP)); + + } + + @Override + public void GiveItems(Player player) + { + + } +} \ No newline at end of file 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 b0c8a3e1c..19f322029 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 @@ -116,7 +116,7 @@ public class Draw extends SoloGame _tools.add(new ToolLine(this)); _tools.add(new ToolSquare(this)); _tools.add(new ToolCircle(this)); - + registerStatTrackers( new MrSquiggleStatTracker(this), new KeenEyeStatTracker(this), From 41599de06f45953eba51a615c76aaba37f935f1d Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Sat, 9 May 2015 17:34:07 -0500 Subject: [PATCH 8/9] build vote update --- .../game/arcade/game/games/build/Build.java | 147 ++++++++++++++---- .../arcade/game/games/build/BuildData.java | 40 ++--- .../arcade/game/games/build/BuildQuality.java | 11 +- 3 files changed, 135 insertions(+), 63 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 1d59041be..d1b44f8e5 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 @@ -93,6 +93,8 @@ import nautilus.game.arcade.kit.Kit; public class Build extends SoloGame { private NautHashMap _data = new NautHashMap(); + + private NautHashMap> _votes = new NautHashMap>(); private ArrayList> _scoreboardPlaces = new ArrayList>(); @@ -113,7 +115,7 @@ public class Build extends SoloGame private MobShop _mobShop; private ItemStack _shopItem; - private String[] _hintText = new String[] + private String[] _hintText = new String[] { "Click Creatures to change their settings!", "Set the Time/Weather in the Options Menu!", @@ -330,9 +332,24 @@ public class Build extends SoloGame //Verdict if (!_viewData.Judged) { - BuildQuality quality = BuildQuality.getQuality(_viewData.getScore()); - - if (quality == BuildQuality.Failure) + boolean hasDecentVote = false; + + + for (Player player : _votes.keySet()) + { + NautHashMap votes = _votes.get(player); + + if (votes.containsKey(_viewData.Player)) + { + if (votes.get(_viewData.Player) > 2) + { + hasDecentVote = true; + break; + } + } + } + + if (!hasDecentVote) { Manager.GetExplosion().BlockExplosion(_viewData.Blocks, _viewData.Spawn, false); @@ -343,7 +360,7 @@ public class Build extends SoloGame } //Announce Builder - UtilTextMiddle.display(quality.getText(), "Built by: " + C.Bold + _viewData.Player.getName(), 0, 80, 5); + UtilTextMiddle.display(hasDecentVote ? null : C.cRed + "Failure", "Built by: " + C.Bold + _viewData.Player.getName(), 0, 80, 5); } _viewData.Judged = true; @@ -384,12 +401,12 @@ public class Build extends SoloGame { UtilInv.Clear(player); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)14, 1, C.Bold + "+0 " + C.cRed + C.Bold + "MY EYES ARE BLEEDING!")); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)1, 1, C.Bold + "+1 " + C.cGold + C.Bold + "MEH...")); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)4, 1, C.Bold + "+2 " + C.cYellow + C.Bold + "It's okay...")); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)5, 1, C.Bold + "+3 " + C.cGreen + C.Bold + "Good")); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)3, 1, C.Bold + "+4 " + C.cAqua + C.Bold + "Amazing")); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)10, 1, C.Bold + "+5 " + C.cPurple + C.Bold + "WOW! EVERYTHING IS AWESOME!")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)14, 1, C.cRed + C.Bold + "MY EYES ARE BLEEDING!")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)1, 1, C.cGold + C.Bold + "MEH...")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)4, 1, C.cYellow + C.Bold + "It's okay...")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)5, 1, C.cGreen + C.Bold + "Good")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)3, 1, C.cAqua + C.Bold + "Amazing")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)10, 1, C.cPurple + C.Bold + "WOW! EVERYTHING IS AWESOME!")); UtilTextMiddle.display(null, C.cYellow + "Click to Vote", 0, 60, 5, player); } @@ -410,6 +427,8 @@ public class Build extends SoloGame } else if (_buildGameState == 4) { + tallyScores(); + ArrayList places = new ArrayList(); //Calculate Places @@ -417,21 +436,21 @@ public class Build extends SoloGame while (!_data.isEmpty()) { Player bestPlayer = null; - double bestScore = 0; + double bestPoints = 0; for (Player player : _data.keySet()) { - double score = _data.get(player).getScore(); + double points = _data.get(player).getPoints(); - if (bestPlayer == null || score > bestScore) + if (bestPlayer == null || points > bestPoints) { bestPlayer = player; - bestScore = score; + bestPoints = points; } } - AddGems(bestPlayer, bestScore, "Build Votes", false, false); - + //Average points per player is 1000, so divided by 50 = 20 gems + AddGems(bestPlayer, bestPoints / 50, "Build Votes", false, false); BuildData data = _data.remove(bestPlayer); @@ -442,11 +461,8 @@ public class Build extends SoloGame first = false; } - //Only count if they got above TERRIBLE score - if (BuildQuality.getQuality(bestScore) != BuildQuality.Failure) - places.add(bestPlayer); - - _scoreboardPlaces.add(new AbstractMap.SimpleEntry(bestPlayer, bestScore)); + places.add(bestPlayer); + _scoreboardPlaces.add(new AbstractMap.SimpleEntry(bestPlayer, bestPoints)); } writeScoreboard(); @@ -473,6 +489,66 @@ public class Build extends SoloGame } } + private void tallyScores() + { + //Reset, if being re-called + for (BuildData data : _data.values()) + { + data.clearPoints(); + } + + //Each player has 1000 points to give to the other builders. + //They are assigned based on a ratio of points given. + + //in a 5 player game, a player who gives everyone +0 will be giving everyone equally 250 Points + for (Player voter : _votes.keySet()) + { + //Gather Data + double votesCast = 0; + double voteTotal = 0; + + NautHashMap votes = _votes.get(voter); + + for (int vote : votes.values()) + { + votesCast++; + voteTotal += vote; + } + + AddGems(voter, (int)(voteTotal / 3), "Voting Fairly", false, false); + + double votesNotCast = (GetPlayers(true).size() - 1) - votesCast; + + double averageVote = 1; + if (votesCast > 0) + averageVote = voteTotal/votesCast; + + //This ensures that only 1000 points will be shared among builds + voteTotal += votesNotCast * averageVote; + + //Apply Points to builds + for (Player builder : _data.keySet()) + { + if (builder.equals(voter)) + continue; + + //If the voter didnt vote on this build, it will be given the average of their votes + double vote = averageVote; + if (votes.containsKey(builder)) + vote = votes.get(builder); + + double points = 1000d * (vote/voteTotal); + + _data.get(builder).addPoints(points); + +// System.out.println(voter.getName() + " = " + builder.getName() + " " + +// (votes.containsKey(builder) ? vote : "No Vote (" + averageVote + ")") + " ~ " + points); + } + + //System.out.println( " " ); + } + } + public boolean isBuildTime() { return _buildStateTime == 0; @@ -627,30 +703,33 @@ public class Build extends SoloGame if (!UtilTime.elapsed(_buildStateTime, 1500)) return; + if (!_votes.containsKey(event.getPlayer())) + _votes.put(event.getPlayer(), new NautHashMap()); + switch (event.getPlayer().getItemInHand().getData().getData()) { case 14: - _viewData.addScore(event.getPlayer(), 0); + _votes.get(event.getPlayer()).put(_viewData.Player, 1); UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); break; case 1: - _viewData.addScore(event.getPlayer(), 1); + _votes.get(event.getPlayer()).put(_viewData.Player, 2); UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); break; case 4: - _viewData.addScore(event.getPlayer(), 2); + _votes.get(event.getPlayer()).put(_viewData.Player, 3); UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); break; case 5: - _viewData.addScore(event.getPlayer(), 3); + _votes.get(event.getPlayer()).put(_viewData.Player, 4); UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); break; case 3: - _viewData.addScore(event.getPlayer(), 4); + _votes.get(event.getPlayer()).put(_viewData.Player, 5); UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); break; case 10: - _viewData.addScore(event.getPlayer(), 5); + _votes.get(event.getPlayer()).put(_viewData.Player, 6); UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); break; default: @@ -662,9 +741,11 @@ public class Build extends SoloGame public void playerQuit(PlayerQuitEvent event) { _data.remove(event.getPlayer()); - - for (BuildData data : _data.values()) - data.removeScore(event.getPlayer()); + + for (NautHashMap votedFor : _votes.values()) + votedFor.remove(event.getPlayer()); + + _votes.remove(event.getPlayer()); } @EventHandler @@ -1039,9 +1120,7 @@ public class Build extends SoloGame { for (Entry score : _scoreboardPlaces) { - int percent = (int)(score.getValue() * 20); - - Scoreboard.Write(BuildQuality.getQuality(score.getValue()).getColor() + percent + "% " + ChatColor.RESET + score.getKey().getName()); + Scoreboard.Write(BuildQuality.getFinalQuality(score.getValue()).getColor() + (int)(score.getValue().intValue()/10) + " " + ChatColor.RESET + score.getKey().getName()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java index 177277b8d..d1892ca79 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java @@ -57,7 +57,7 @@ public class BuildData public WeatherType Weather = WeatherType.SUNNY; - public NautHashMap Score = new NautHashMap(); + private double _totalPoints = 0; public BuildData(Player player, Location spawn, ArrayList buildBorders) { @@ -155,29 +155,6 @@ public class BuildData { Blocks.add(block); } - - public void addScore(Player player, int i) - { - Score.put(player, i); - } - - public void removeScore(Player player) - { - Score.remove(player); - } - - public double getScore() - { - if (Score.isEmpty()) - return -1; - - double score = 0; - - for (int i : Score.values()) - score += i; - - return score/(double)Score.size(); - } public boolean inBuildArea(Block block) { @@ -327,4 +304,19 @@ public class BuildData MapUtil.QuickChangeBlockAt(Player.getWorld(), x, y, z, mat, data); } } + + public void addPoints(double d) + { + _totalPoints += d; + } + + public double getPoints() + { + return _totalPoints; + } + + public void clearPoints() + { + _totalPoints = 0; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java index 78e1c1a42..9c2b18918 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java @@ -26,13 +26,14 @@ public enum BuildQuality return _text; } - public static BuildQuality getQuality(double avgScore) + //1000 points is average, if everyone votes for everyone equally + public static BuildQuality getFinalQuality(double avgScore) { if (avgScore < 0) return NoVotes; - if (avgScore <= 1) return Failure; - if (avgScore <= 2) return Satisfactory; - if (avgScore <= 3) return Good; - if (avgScore <= 4) return Awesome; + if (avgScore <= 500) return Failure; + if (avgScore <= 1000) return Satisfactory; + if (avgScore <= 1500) return Good; + if (avgScore <= 2500) return Awesome; return Mindblowing; } From 3e64115f051e501310e17fb66dfab3e173484aff Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Sat, 9 May 2015 17:45:08 -0500 Subject: [PATCH 9/9] vote colors --- .../game/arcade/game/games/build/BuildQuality.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java index 9c2b18918..f308f5227 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java @@ -30,10 +30,10 @@ public enum BuildQuality public static BuildQuality getFinalQuality(double avgScore) { if (avgScore < 0) return NoVotes; - if (avgScore <= 500) return Failure; - if (avgScore <= 1000) return Satisfactory; - if (avgScore <= 1500) return Good; - if (avgScore <= 2500) return Awesome; + if (avgScore <= 400) return Failure; + if (avgScore <= 800) return Satisfactory; + if (avgScore <= 1200) return Good; + if (avgScore <= 1600) return Awesome; return Mindblowing; }