diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java index 5e37e0ac5..1b3b40835 100644 --- a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; import org.bukkit.Location; import org.bukkit.entity.Entity; @@ -13,6 +14,8 @@ import org.bukkit.util.Vector; public class UtilMath { + public static final double TAU = Math.PI * 2D; + public static double trim(int degree, double d) { String format = "#.#"; @@ -332,4 +335,119 @@ public class UtilMath return min; } + + /** + * Creates an array of points, arranged in a circle normal to a vector. + * + * @param center The center of the circle. + * @param normal A vector normal to the circle. + * @param radius The radius of the circle. + * @param points How many points to make up the circle. + * + * @return An array of points of the form double[point #][x=0, y=1, z=3]. + */ + public static double[][] normalCircle(Location center, Vector normal, double radius, int points) + { + return normalCircle(center.toVector(), normal, radius, points); + } + + /** + * Creates an array of points, arranged in a circle normal to a vector. + * + * @param center The center of the circle. + * @param normal A vector normal to the circle. + * @param radius The radius of the circle. + * @param points How many points to make up the circle. + * + * @return An array of points of the form double[point #][x=0, y=1, z=3]. + */ + public static double[][] normalCircle(Vector center, Vector normal, double radius, int points) + { + Vector n = normal.clone().normalize(); + Vector a = n.clone().add(new Vector(1, 1, 1)).crossProduct(n).normalize(); + Vector b = n.getCrossProduct(a).normalize(); + + double[][] data = new double[points][3]; + + double interval = TAU / points; + double theta = 0; + + for (int i = 0; i < points; i++) + { + data[i][0] = center.getX() + (radius * ((Math.cos(theta) * a.getX()) + (Math.sin(theta) * b.getX()))); + data[i][1] = center.getY() + (radius * ((Math.cos(theta) * a.getY()) + (Math.sin(theta) * b.getY()))); + data[i][2] = center.getZ() + (radius * ((Math.cos(theta) * a.getZ()) + (Math.sin(theta) * b.getZ()))); + theta += interval; + } + + return data; + } + + /** + * Slightly randomize a location with a standard deviation of one. + * + * @param location The location to randomize. + * + * @return The original location, now gaussian-randomized. + */ + public static Location gauss(Location location) + { + return gauss(location, 1, 1, 1); + } + + /** + * Slightly randomize a vector with a standard deviation of one. + * + * @param vector The location to randomize. + * + * @return The randomized vector, now gaussian-randomized. + */ + public static Vector gauss(Vector vector) + { + return gauss(vector, 1, 1, 1); + } + + /** + * Slightly randomize a location with a standard deviation of one.
+ * + * This method only accepts positive values for all of its arguments.
+ * + * A good parameter set for small offsets is (loc, 10, 10, 10). + * + * @param location The location to randomize. + * @param x A granularity control for the x-axis, higher numbers = less randomness + * @param y A granularity control for the y-axis, higher numbers = less randomness + * @param z A granularity control for the z-axis, higher numbers = less randomness + * + * @return The original location, now gaussian-randomized + */ + public static Location gauss(Location location, double x, double y, double z) + { + return location.clone().add( + x <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / x), + y <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / y), + z <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / z)); + } + + /** + * Slightly randomize a vector with a standard deviation of one.
+ * + * This method only accepts positive values for all of its arguments.
+ * + * A good parameter set for small offsets is (loc, 10, 10, 10). + * + * @param vector The location to randomize. + * @param x A granularity control for the x-axis, higher numbers = less randomness + * @param y A granularity control for the y-axis, higher numbers = less randomness + * @param z A granularity control for the z-axis, higher numbers = less randomness + * + * @return The randomized vector, now gaussian-randomized + */ + public static Vector gauss(Vector vector, double x, double y, double z) + { + return vector.clone().add(new Vector( + x <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / x), + y <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / y), + z <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / z))); + } } diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java index b0d4bd9bc..696cf72d3 100644 --- a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java @@ -11,7 +11,6 @@ import org.bukkit.World.Environment; import org.bukkit.WorldBorder; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.entity.Entity; import org.bukkit.util.Vector; import com.google.common.collect.Lists; @@ -22,6 +21,11 @@ public class UtilWorld { return Bukkit.getServer().getWorld(world); } + + public static boolean isInChunk(Location location, Chunk chunk) + { + return location.getChunk().getX() == chunk.getX() && location.getChunk().getZ() == chunk.getZ() && chunk.getWorld().equals(location.getChunk().getWorld()); + } public static boolean areChunksEqual(Location first, Location second) { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java index 3c9a78a56..4026dad3f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java @@ -166,7 +166,40 @@ public class ShapeWings extends ShapeGrid implements CosmeticShape "0$#######$0", "$#########$" }; - + + public static final String[] MAPLE_LEAF = new String[] + { + "000000000000000000000000000$000000000000000000000000000", + "00000000000000000000000000$$$00000000000000000000000000", + "0000000000000000000000000$$#$$0000000000000000000000000", + "000000000000000000000000$$###$$000000000000000000000000", + "00000000000000000000000$$#####$$00000000000000000000000", + "0000000000000000$$$000$$#######$$000$$$0000000000000000", + "0000000000000000$#$$$$$#########$$$$$#$0000000000000000", + "0000000000000000$$###################$$0000000000000000", + "00000000000000000$###################$00000000000000000", + "00000000000$$0000$$#################$$0000$$00000000000", + "0$$$000000$$$$$000$#################$000$$$$$000000$$$0", + "00$$$$$$$$$###$$$0$$###############$$0$$$###$$$$$$$$$00", + "00$$############$$$$###############$$$$############$$00", + "000$$#############$$###############$$#############$$000", + "0000$$###########################################$$0000", + "00$$$#############################################$$$00", + "$$$#################################################$$$", + "00$$$$###########################################$$$$00", + "00000$$$#######################################$$$00000", + "00000000$$$$###############################$$$$00000000", + "00000000000$$$###########################$$$00000000000", + "0000000000000$$#########################$$0000000000000", + "0000000000000$$#########################$$0000000000000", + "0000000000000$##$$$$$$$$$$$#$$$$$$$$$$$##$0000000000000", + "000000000000$$$$$000000000$#$000000000$$$$$000000000000", + "00000000000000000000000000$#$00000000000000000000000000", + "00000000000000000000000000$#$00000000000000000000000000", + "00000000000000000000000000$#$00000000000000000000000000", + "00000000000000000000000000$#$00000000000000000000000000", + "00000000000000000000000000$$$00000000000000000000000000" + }; /** * Default rotation to give the wings a little tilt when displayed on players for instance diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index f803154ce..9b84839e4 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -78,6 +78,19 @@ public class SkinData public static final SkinData LARISSA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjE0MTUxMzQsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jYThjNDRhOWVmZTY3NzExMDYzMjM5ODEwNDRmOTdjYmM1OWJmZmRlOGI1ODdlMGQzMWE4N2ViMDhhMmExZiJ9fX0=", "Lyac51CrnMK/CI2dWgGQLowAm/ZnQMpf0Ict/gqVrUgJVlGWDIVG77Rd1JyMQDEeESvTmoyivH+usiO0ePW95qjisqT3R43YEmLi85CqctGYqLKeSYpGYwYRz8Euw57LwJAALKOMLhVc2s4h2Or9nTecunG8KSmkCuZc4H1qh3frU+ltuV4HLqgdFUULbIHTggyvqiINov2tBqkkXeEjT7sOcTJCJNgNYU2O7//qg5kJmhso2CKHlRLpmy9LsaUK/Z+BzUmoRbwQgSwr3mz7dFAdlVWWKvKNcgX3nt1et0DIig3JKYmrnQX2Fprg+kWcr3nuizzLgjVwAlADC48P3DN0s/VBty2AYoWie16VNPIM+CV4BF2JRQ34GxZ8XceXbCKURrOjoCBgLGHvIhRW35eicoh26xp3/mwLvk5anPi5StJ/qEuzWJALeWcNbLsnt21m2MZp9h/MxaY6ftWOTzjTr5CYVd/teJyscMnGK4+lcV1dlt12lhbDMv6I+iz8iG9NIzuW5OvGkax90dA/Gq+Cd9FXVThPY4ufxWttHcTqgPB64GfMn6rywRm1B0eO1pJpYc/KlJZlW/PuaO8L1assyJs5KkOypBSy3zc6TO6pzgeOZv+VpQfA/UWpogv6ofmTpgdtwpjLFGSzIKTDXvF6FftALKVlYypG0fYbssA="); public static final SkinData ROWENA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0Njk1MTcxOTgsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jNDY1OGExODY4YzNhNjhhZWVhZmZkOTUxZDQyYmZkN2QxYTRjNGZjNDJjZDI2YTlmYzhkNTNmOTkxMTM1ZCJ9fX0=", "OqXMyH9SMmQ/Pwmb21In29YnCxbsN6yqUxfudN6KNgDwRUK6y072XhW6TIoTh9JQLAUKftpeVB53tk0LxHIxnsuBMrIHvETPDQFysIc/6xq3ABogs+zqFzcp5jk6S73HiD78JxLq5pzfUzhgDPMPuZP5Q/u2q1rYbe6B9lVEJ5sUcxBLUTossgucoR4qXYAlWVQdHRhq85Ol8a+OU7ruw3HackNGto6wt6u2MigCtiHVTt9XhJ/AJE4ScodQ3XwW4L6urpl/lV2OMCsr3mCjjjEz2EMhDbCWxrAorQ9aPpMbDkHBS+4TC1tbMGUlKhj5n+EZBYVaeLr4NGPACPSdT35p/2Zra49+DXn9Xn+681yNEB0ghTdsnsgwXg76+HVPHPqRHQMuTBQGQyGZaaTX/zE0tFjH+osMElLdb8dmz3dC7kQA4A13B2phj3YbMSF1FoU4GvnPKIQn6JIuEd6hd+pRLUW7Y+mgYIHHX1FT0ihrXAyVO6lQQ6rs92gSQr7sxC7tnhPSMFcmh7OcJYcbRpn97GMubthPLanOhVy7CKqjmwIkEVtYgP28idigKwNJ+sJuUONrOu7nMKl1UTD5EEapOacc/np6UhdSw8yW+LnWD/x9ueYz9ksnyRrJgcOa41izo/WCbjPK/j3JVezr9Q3x1yveWuFmdl7CGYdXngw="); public static final SkinData BIFF = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjEzMDQzNjYsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9mOWMyMTE3ZDY0ZWE0ZmUxMWZiY2NhZmE2YzU5YzhlZjY3NDVkZjVkMTZjM2QwMmI4NmI2OTlmZWJjNTA0OGI1In19fQ==", "mJMpEvQ4A02z0S/chgLm5bKrrrd+zmp7A0012AB7b3KlyIHoLKEDDz+ZJgJtvN6skOqed3P+yNVqkxitugXaZZP8Af9J+/TseHn+vOy6CTK5tykRSY3Zb8Zmw1kn36v/SARAVtDIHD53yuPgJayYSAbVB7aknj1Q8XBQGUmZRMRxWWxeD7rQTOwgRYI4YJeKFf4UL9i6zxvOJuHsOAouJ7scu7VohG8vgR77Js/Z8rSu8/aSG+O9AQdzP6h9ixYNFkkQOHm7DseK/5tsWKHM4FYBgjIDKt3ApQokSbhThzGB55BA1qjXZkfCoOb13y1nOMC8WoIL6Ees1qzxG3VloGx2WAZLh+Q+/irwrFDMxk1zeU5fIRuj1c/UIM2HKdxxWgoRdrZ8ww/Jrll6maiOBx7geMn/0aOUbJ2U7gkTif6RG6YNS5YN9ZQDLh72l/akJMxF3SlmuAPmLs2kBghQ6eD2YQKuxWR/Hf1yS1YXtogFVNsGnzC1nda7F48EGL3zI+kCajbDlAGQ32aRt0btbEQ+Gj575kir3Aa53qiZ0YOIYQlhgZdOsTN2NE2s8uuy/15Rgc6K3ydgEmSZfdqyMyW0Dy7pE5TfVL8DumKRVRXdOceT5WfnW7MyqSmdorP5ab1fw2wLOnAVzhJmW8oXXNSs77WJ1/PURclxOWB4IF8="); + public static final SkinData CANADA_HAT = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg2MDE5MDYwNzYsInByb2ZpbGVJZCI6IjdkYTJhYjNhOTNjYTQ4ZWU4MzA0OGFmYzNiODBlNjhlIiwicHJvZmlsZU5hbWUiOiJHb2xkYXBmZWwiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2M2MTExNTNmODdmMjZjMzRmOTdkODIxM2ZmOTk1ZGJlNjcyZWJkNGM0NjRkNGFkNzM5MWFlNDNjMWU3YTllIn19fQ", "QMw6e1FXl/Xrt+BbfPKsz3OHyOxL9CEPffS9grxRLD6gbLbMD84OT3+bge5V9lBFn9PPnTyID+WTF24qHj4ADTTgK94ykNedCEO6R1wS0FZKPI1UjwOxMhIG5ZeVr7+HxITgGU4Xz94IigBkvW//f2ZGelMvS0GLCrm4iCovEBMUzyYJ2dZ4xgzFSH6v+9efK4/SBAJaj8mHjXpDxU58/vskTGI3T9t5sWlZLXgId9vHcMj0GH3Un6yvUXiMkh38V/rAEM8/R8q08xUVyW0e2R38qWQV2+eKvsG8GmJmgkU/78wA9cKGZdrEz0pnr80eGNCbvXqQvC/czYhEhDapgxfndcHLX8q/Zk3I8msNr340E4ZrQL61Yl7KcVC1qEUQVu3cosq5A6ckXLGvv//HSwXVO8M9ThUbuEC8QjiS/fMFufnVa18lHrVulnfb/2KQ4yPsoCHK/zvGtRkWtD1sLOIfehN+sxCLiaz80ILBiwN0oHITfNHpJzoa4kF/OrxxCualp4Sv5o5TXBv7aWsO18v9ixb9o9CmJKKE8MUl5xmRVz4HQD4dyOfcwtPuxmfcYjJrxqBijdQMrcgLzqqMs+DUqcZZlxM7M5GaNUoEvL9tJNGpZaB2OrBw0DTk5wx15XfANCH4egx8X4+Iy2RUoFthHX3BsVazG7fjSiDnUtI="); + public static final SkinData AMERICA_HAT = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg2MDI3MjMyODgsInByb2ZpbGVJZCI6IjNlMjZiMDk3MWFjZDRjNmQ5MzVjNmFkYjE1YjYyMDNhIiwicHJvZmlsZU5hbWUiOiJOYWhlbGUiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzYzMjI0MDhkYzBiZjMxNjU4N2RiNDJiN2Q5ZmViZTUwYWQ4MGY0OGU4Njc5YzI0NTFkOTk3MTdjZmVjNTdkYWQifX19","oRo6DIuhOTaXDkFsgwJ488LWqx5d1QpwtglwG1SdEvkbX1aCMGdZyDm9YIopQRjfBg0uYKQFetOZ1ZkdMmc/aKC5/dm0+Ema7g8AUzjwf4OaSLH1r4C1UJ4ruaNG5diBxNTkYnMa7yT8zvyEr22CA7lUOIgTh8ymBfSGK35RPhsn8jM0hDjdhjemBAlxKpiioByfmAQbwokNBOrXfh/PnKq+iJYg4WpMSZ1zo5Rr0CzLXwu+/T3dvrb6mg7qry7J3Lj5/qn6iIdBcjJBeyvy1sCo45jQ3Rzc6oL/84Vu5Dpn395EqUK8Sa7mdpVpATTcj56TCjkNNtDapXNqyO/IIQuzU4wnBKNQmZefaxRl6LV0DhZ8n8YQaPj6hH/mr2oDsd23+jejjqu6Y95ReTyukp06mIGqgekmrdZV2etML2oMAOTv9ieVvqtfo5gEomYs+NFAL7rMmzjAlhd17VOgqNRMpmJazAHWOYKl8KdOH99wGDe5XcyKHysh+qyHKMvhPJztIeAEaosynF/aGHghH2PM354KCuUVNmdR5G7UZUoG9ZA5ZU3EzZ854jeqxcqw3jzb6qL7A83QNuFqOsb87ugL/jO3QEDdQ9drdf3WAQauQGkU3nYBrls5wxoMrQ+Ceth+FtZw9a1v7dc+DEWOeJKCtOAIskb29pv6OcRe0Wk="); + public static final SkinData REVOLUTIONARY = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg3ODQ5Mzk3NjAsInByb2ZpbGVJZCI6ImIwZDRiMjhiYzFkNzQ4ODlhZjBlODY2MWNlZTk2YWFiIiwicHJvZmlsZU5hbWUiOiJZZWxlaGEiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2I4NTBkZDNkYWQ0MjkxYzFhYmU4NGU2OTM2ZmQ3MDM0ZWVlZTk1OTk2MWI3YjE5NDZhODIxYWRlMTFiODI2YjIifX19","U2xBG+ryUacvZq3WreWF2J4QnQERuvp1okqdlkAYECqvVHz0cars78usPuZYD4s3HyOM0eGASzS4zkQERF6Hk8crnG+ZtqvML5kL+TkxK8gEbn2j5qB+YDG0qTx635mYGC77sGaqE/CsZAlhRYU6lyXILW2616Af8B8orOlpyCMRytijp/OfJREK0bC4I1QnB7AJ2QmBYuZJ9l8473858fJOlCVHjbsC/WRcUvepPSYYxvl8Z5NwayyIVnnz3tGVN6hnM7tzil/gQmsmDwGhlSyify/MEGssvd0sHLTlccA7XX98tyUFHXU84L5MJuNKg/uXTYz+9cRPIgJaptJNfqCoEa/ape+YHlOlK2lm5qRvubvp931X+VwFbcrEuaIFgbqr9cof5JW6DYfpVKvcngi9+K9IzgtPG59Jro5kxb70IfQhZcDkcHGo1pz5Tj7cdJdD7crBeIBaE/EoKU6iaSOrUFoILEdpcWQfaToRnk4L/JMet7zPXBNE/D/vEgQLGLNX7byofdCXSD9njtjLWmHg4rCzwuUqaiWnTCYIkkdg/mFuRQ3oTRRTzdlLXsK90Pz0XU9N6gBhWA9pxhzDJR7YK+mdXODALuMXE6zcCsbVuWhqbnN+EByGdjT9X1QPSN+/5iV9d5JyweiJrF7arf2PmxgEIb9OSjePNKRmHoo="); + public static final SkinData MELON_PERSON = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjA2OTU5MDgsInByb2ZpbGVJZCI6ImNiZDIwN2M3ZDNkZDQwYTg5NTBiZGQ4ZTU4M2IyYjY1IiwicHJvZmlsZU5hbWUiOiJBbGVzc2FuZHJvQ2Vydm8iLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzNiNDQwYjc5NWY3ZGNjZGNiODY3MzBjYzMyYzE0MGQ4NzM2NmRjNDU2YWZhZjA4Y2VkNjE1OTEyOWViMCJ9fX0=","U5yXWm6A0R4gzZRFWeeI0IUwOlpjOUogDIJyPX1b9ItcT1CMkKF/oc2IKmbMJGhwktzV8U3YKh8J3IHHomJYMiZN6WH8QNyzAiw4uaaWd2JFtG5LYRLFI7DPiaXrRW0Wdz4IffFBZ5yyDOIOLcGCExLrxyeKAO7yNah6IMgEbtY8wX6uZYFWkxRx7Orbici2zsDakghXUFcnvNE+plmK3Gxjb45RtYfWeurGzcsCEEjkRK/aQ4aohvCkx5sc4Bl3ObWiDVJ9FvHzPSd09zjnIpL9jyxKQTscbeRFKasjtbJLEbq/yq5cAjI9uGYbPkBG9C1JgmWDZBz9a0bCwRokihKtYJbDAs1417qcyzoH0ylLt85fz+XM7G+MIHba8hZ3aJFZughyslsCg/+5jAm+Ci9yQJgYFf3yHFUrmVktHz+dsWdgrfDqIMXKJWXVKccvHMD0u+yKCMxW6C4RxZmOgnAqYfvPUJqTrAW4FpbFuPBTpFsGYF7QfgIekib8aXsUr0hCh1HqEYqICVXT8Jr38A4ySMZ1NKnbRzEsDwL/4gE5YDtza+qcanY2Ewl906Z+m3uMXXXKM7uYq47RyOYWYyOcyJhr9n7C1pEbyoaTt1m4+u9j9TEMX/8oN7qCSvDhkBH5M+XIt6OJhu7bJObW0HjqUo6yADUx3srK9cX9Rpw="); + + public static final SkinData APPLE = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjMzODU3NzAsInByb2ZpbGVJZCI6IjQzYTgzNzNkNjQyOTQ1MTBhOWFhYjMwZjViM2NlYmIzIiwicHJvZmlsZU5hbWUiOiJTa3VsbENsaWVudFNraW42Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zNWUyZTA5NTk3MTJkY2QzMzU3Y2MzY2VhODVmOTliM2ZkODA5Nzg1NWM3NTRiOWIxNzFmOTYzNTE0MjI1ZCJ9fX0=", "tK+zKZp42fBhSLoXyFMwJ7AYubID12WUhhp9At4YA7A6SuYHj022IrkxWjsl8e7stsd+gmMsPbr25HMHH8JXRQhzH+5qRa3PBVqhYFUHWI7jrrmTk7krhwZOg+Ozw0+TU4nqyRZGeZxwKiy0DcpO7tsgcFQtbJTG27jh4ZGlkqANDHYsqi8BiOXVz51yquuf8x8Bgml+0wyuCrkgUo2a0iXB5la9zs/HnxFJbHi/IHn+a2+RqGa49JhgMCykKkohsgPEqcuCBuUbqs8pxdnUHTqCxmZ/XKjgXq3NpFkfp2RYynDTW5RfZdEbo+D+cbivZgrehBtJatJd8vZu+kmuxwxYR0mdre4MrlRcgn1CpSvPk5/EJrkst8TVv1iEtUeR2l82umw+QfemNOgrOP3K/DT+JX6faRskrLP7J6JAIWP04dEuDI83t1Y7UPX/tSsGOrA2PO/VR8670dwCMS5Wc60RLhT98PKs0ctFaPK4RQRp4XbOw7jtWiNUZ+iy7JOUFLKcoTZNOFqoXs1IVs2JZ/nHJHkzLXkvaHzeM5KlYiq8igCy3XF5CQvVrTsFYX+PELkq+2wpyVgSHITqhUZl96mDAWMFm8IepE0JEkTfp8VrTTXeym3LL5Ecu7Azeoh7SiKf5lSKyLro3hp2N+JvN8l0BPB8qpZAjs4VJd79dns="); + public static final SkinData MELON = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjMzNTc0MjcsInByb2ZpbGVJZCI6ImJiMDgwOTFhOTJlZDQzYWQ5NGYxZWRmZDc0NmIwYTJjIiwicHJvZmlsZU5hbWUiOiJJcDRuZHgiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzFjNDA4MWM4ZjRmY2RjODE5Y2VjZDZmOTRmM2ViZmFiZTBkMDMxMTVkZjJjNjYyODIwYTdhZWJhODljMmUifX19", "qHvPSsGfSDapqJlLxk1BQb2cVFbjggbDbQWCaHkzpfCx7yTojSR29ywqg0F5rLabZ7Q13wG7l2CUkdCsK4urO1qx2MpSK3iVL/mG2x2O3m3Hg7FUU6fcaupP9T8V36n8HNag5uM3lbtnzoNmhwuCS6EbzRbgk5cL38jRwPod4Bxea/UKOBFmrl506Y2pjg0gi3nZVHPmnweNC3kV8FwmHHfFUt2T6QrvULKANLfxTYmIJj9jrG5CZ3oGQj6vnHo0iA5NpMpUYAqLSKrAV2GTVZ8U7SEcTkUgLkXfd7UnNKGWVoH93LUtRyti71fwtx5q591xfqdbRiMQZBz5r5U0kUg9HrCuz8nUaCX4ox9vPJp3TktlRT8cqRyadm+bqVHPccnS0Wt/7HTMC85X1VhB+5EawHdx8umkky404mEJbPcWZZlXfbsDchASMq2tgfeZZufgJX/DY/qyVz8L1Pmp9IXuqnzvV2CaUwjKtyc8gd6ZrOGOmYovhth/IgvRUaChB248Wwh2qe3sQz0PYxAuFMP0D3mf8ctLFmVyR3bPKtxJYW6vrLiZ8a6lg1houf/pQMF4q5HQSzW7Nbic7gR766TXgy5dRxavyToPRuFkCnI3EQwmleeYg88pazcGRWGOEueAM1/4dbNjNsAoif8fCSI3/1UT7lgvcCAinDJe6AE="); + public static final SkinData ORANGE = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjU4OTA3MDMsInByb2ZpbGVJZCI6ImNhYjI4ODVkMTUxNjQ1OTNhZmI2MDkwODJlOTE2NmU3IiwicHJvZmlsZU5hbWUiOiJGYW5jeV9MdWR3aWciLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzU5ZTNlMGUxOTZjY2I3MjRhMjI1NzRmYzdjNjdhNmM2OGVlNDIwZjE3ZWM5MzI3YTUyNjYxZDcyNGQ5OGU1YzcifX19", "Bjj4N79wGgpPDV4oBDtB6B2dva3gN6pP+siJ9r309oJ1LXqPB9kbBIe7bquTKXAJgrNWuK2phASVoFdvJUbc7pazpk5h2ZDdPqWCnP8H7Oq2BtRpCJuvOnINZFGURzkdhbrfnvgoN7WEm3MsdZ6I702ZHrC15rVwTvimKV0bD3kq5W18nYZL446SxdBqKilK1Uly4582ZuEajZ3xsJfdVohPFNDKKu5z3HWPkcPu6jIi4/ACMsxSk7SYic3ZnwN+ULgHAoWymfcta3zmHeNDqYn+68iJRE1+WYHvkXlrO3gdgDqWD2MIyDCvFkLPuPZ/W93zr6V+WAXpH1Pgh6+Sw24EiIKnHR1paCo7eJI+1c4BlYgAwctj36pyRHh7N8Po5GSi7vQKrzoMLoBBJqRVKK5gbIVOWxBBKnhK+q2va5ZVoYPhBb808i4HA538dLk3qeAhVKX/x0uyAGtKgIKa4OlxcBk40LKQ1a/NnC7vOSB6lWLE1PiVoZ8yhe2pJQKy+7nztWehrO1g0IcwLYZSjraAiZ17Zx1fFHYp+4qnjncYewvGDXrcIofG7EEpSCNzY/HsagykPZMyPPSDcwuDZHI08JIPTRkwXTzae2BDggkF4d6PxyLryZE3BnG7lSb6yMKYvsDqpkhuqsUPI4put1DKJEFx+hIlT0I5kVI3rQc="); + public static final SkinData STRAWBERRY = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjU4NjE1MTEsInByb2ZpbGVJZCI6ImFkMWM2Yjk1YTA5ODRmNTE4MWJhOTgyMzY0OTllM2JkIiwicHJvZmlsZU5hbWUiOiJGdXJrYW5iejAwIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS82NmE4ZDlmM2YxOWNmZDZlZGNmNzFjOWM0ZjNhZDA5OGYzZTk1OWE5OTBkNjEyZjQ5YzI1MTgxNzM1M2JjYmUxIn19fQ==", "wxroo0ThDSb1B69kNyZsdtpg5qPxjWSt+LX3hg3KvgxziiNhMVmsLVks6+yz2vaeHPDyqckFO+eaVyb1wCuczFCOxLCKBHVhhBFKEbaF5NZTS0HOK6fvY6jxxETX93TmANgWm9MzrcVMGKvBck/gOI40+kxcVJKUg0Jb3yGQcuY820thGB95qznHDLIbnnTaB3mJr4yog2intDOqSF7I0fnd5U0Qceaor2u0WWiXaVr+SKvA8D9xvOfrc+IGYV55EHuQu1o3fl5qfK1mBASG9xWACCyTdoOkt06MsJCTxxo60ZE1nnL5m3a27XJ5HeiVNKjjrMOqlTfieBN8H0sWxfzMJ5gjFmGjxq6qhnAjn8Gr/SyhDbnTHILOTbh/V8XdZCwqYD7XI/3///LyPCEfoLmPsFnMd9M8V3DIiDJ3GvD8qTQd54vYHnUw6yR/mA6ONx1OxHBHprIaP5urq9MNIljg2PtVtOzSWypObpf3kR+ZhUC0t8hqiapsLAvpzkb7FO12db0Hwr+4NIbZQ8ZYTe0ds2Zb8Iq1BMWOZ16ffwnDnaqulhQN+nIAA+61Q4k5y2sa60lmvr23yX3AV3Ywop13k1Gvc/amrA+ni66i5ezXMa4+V22fUEAqb+VrEF6IMg4Vac50HIbvIpM1QaWP4fqoHE5lHjCRwmqGjEL9WXQ="); + public static final SkinData PINEAPPLE = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjU5Mjc3OTMsInByb2ZpbGVJZCI6ImJiMDgwOTFhOTJlZDQzYWQ5NGYxZWRmZDc0NmIwYTJjIiwicHJvZmlsZU5hbWUiOiJJcDRuZHgiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzczMjVlYmI5NmE3YWYzZTg3ZThiNmNhOWE4YzE5ZTllOWVlZDgxYjU4Y2RhZWUzNTIyMTg2NTc0YzgyN2Y0In19fQ==", "wrrEvFHwXhSivSnSN1VbXwjfZ7JrdizB4kAGCpOgYu090M087cJUoWan5KfjMN4N9DjmxmWt6M/yE25+47iu3grzaxnsIAUY+b7HzYzk1nrII3R9LLRbOF6cr6ug2c9scQ1wTsWHpul8y5U/vNekTN8+rRBBurmzUR+50M/wXh+mVFhVFtI2QFwDOZZWz4Tz/mPqGiRAtfT1UcPmGS9d5qETqWQlOAbtdlhuYQADNKSf3pIizRvbJKrEtDI6+deqzzGj35L7LdnsOO+k0qFz5m75AdbOty0l11ID1XGXf604iOocvNk/mO4oO+C7Na2jdwazgd7TJ0H+7qAz2suXflco+ALGcRJob3ysBleHBY2l1IpCWH6SPQG+mQvyOfi356dS4HM/QnPBswLJZ+q7rpkAyW8nArLP49/s+ou0PRs75EiFM61xzFoQRt1fLhx7X+IP2QYy7KIMWw5oRJvLKedu2bDTilMq5lyj6o7I7mfKIou8+O4P30eOwBFTPpjPe3BLMws7/Muwqh4TeSdTIuEkTca8qxb8RUv136DJkmkMJTYiZg7kNHLRL0oP8Hz1o8sCX9w6MElyHeRv/h+sE6PHP3zApjr3+wAun6CFBnLvtVcOA5/zvYQcNbzN2sdwWf7V+djN5Eqq78FduhK1MqiYXpJq9pM/cM3beM1rXE4="); + public static final SkinData GREEN_APPLE = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjU4MTM1MzIsInByb2ZpbGVJZCI6ImE5MGI4MmIwNzE4NTQ0ZjU5YmE1MTZkMGY2Nzk2NDkwIiwicHJvZmlsZU5hbWUiOiJJbUZhdFRCSCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjY3OGNmNjAzOTg2ZTM4NDcwNjkyZjgwYWJlNDE4ZjM5YTJjYWQ3N2Q4Nzc4YWY4NTc0NmU5MTkzMzdjZmQ2In19fQ==", "xAm3i+xi9OynV2uaqdF0VTws0qCsH3SP3zeEa5gUZejbhzXA7/i4JZC2+Ag9ULj4AaTbZhc1mFMB9+XAozmrWr+BEQjaD8/sbyQIirzUAk/X6ZTCKkp7Xk46mFlKjd4IVvoUSopCa/HCTRZTugjqJrPbdy232/UVC9JBShAcMq7pD7rmH5+O/vVtMcrtT8MjY95vnlhyXyNpDwYhCW9YlmZcG5fS5nPaq8k8mCaNe/fILVf2T/hQqqMTuZiqQk53L+5C8aiU4nySrGATB3UK1OwVTB7t3gen4MQtUT0ursOKoLLbxWboQWjsFYOxycfDeccOcB50iHfqCW8UmARt8mUT17RfWQvwIqlv1uThdnKsFZjx3LAodPAzcqyIoyR8EbCEeV82pDtYG5X7gT/pV/inYDgrLT7ZmONRk2x1TzTC3PicKNXu40OcOU63yaB/nvQY3FURNVCpvWXwPD1QyZBYfKtO4no1/TfPoZPcdGz9E1Xor74AlDAUJTlGQ5+OlQldJiwHvmPxTPJKdgOJLXRVUHcFLV32VtWnmrBRq9pm3qO3MTEVytB4XVaGmsf3zqcwrVur910CpPxDjyXqe1NvxN2I/43FAQInL3iX/NqOpwsx7alSIUe3ZhdqP6l8SSTDK0Sp+1GtvGrvRiX/8dStDfAsNCN0HxvxQQUVM2w="); + public static final SkinData PLUM = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjQyMzY0NjMsInByb2ZpbGVJZCI6IjBiZTU2MmUxNzIyODQ3YmQ5MDY3MWYxNzNjNjA5NmNhIiwicHJvZmlsZU5hbWUiOiJ4Y29vbHgzIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9lZWIzZjU5NzlhNWVhMGI4MmM4NTUyNmZkYjg0ZjI2YTY4YmY1YTI1NDQ5YzRiNTk2NWU5Y2IxYzQ5NDM5YWY0In19fQ==", "jC6e7Cy7wGmvqSUjIYXwPXQZjAVxnOMoST+IKy/m/g4uklandxhBT9HJskBI+rtVjz67psyLmY941gAtqIbLkRxEhAeT/Qc3iRMV9MN7Ac7b3UaQsnO5gnY3IBZZxSTJhX8oxyTXD+c9k4lsjladzxXA3DcmEn0Cqp0t0oFQA5mEYpa1qGB6NCoXvi5deXNID3PQJjj+PLkohoLKhsDEqbYb3djwGTDKWYGFAwuF7KnA3cuPXa5KN6sPbM7qdjnF3Gke9bkinTn8F7cXVxEpcqAxiUyv8Wv/umHRaEBuDf9yxrDaberkRQu+YIqK6fw805QwcxQePiG/qMU9yZAOuPoolp/SUROHF69pjN9lI8O5Vs08f/K3rSIpgyU16K+lUmE1XIPukUBjNsK2mRTLfJgv8csilzS5jWmVzjr859l0Inr51tGtfQ3VEyUJtIowcOh9GfZWTvaYeDnyGhRUaEpPOmCo1QLIbedAbq51+gYykeQMTmRc+joxxN9SBlF252d7ncOcVAChHxmcFWbPbhV2lMfSTxGmKAx1T9dmw22Z0WTM0NkMG7EsG7wFz1U8f0OY4lyrtVUM7Oy8pc8RuRPhOgQGAvuhA58k6DLgmOpMOVBuEkoOFpZaJKWgVMQI+u9g6COC7WRTF/Z3EW//BFQ09L+uSAPaeyD8rzFqbCo="); + // Comments this out for now, so it doesn't load the player profile // A better way to do this would check for the properties when getting the skull or the skin diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 7af6ab2dd..07a2058c5 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -1025,14 +1025,15 @@ public class UtilEnt } // Nicer than doing entity.getMetadata(key).get(0); - public static Object GetMetadata(Entity entity, String key) + @SuppressWarnings("unchecked") + public static T GetMetadata(Entity entity, String key) { if (!entity.hasMetadata(key)) { return null; } - return entity.getMetadata(key).get(0).value(); + return (T) entity.getMetadata(key).get(0).value(); } public static void removeMetadata(Entity entity, String key) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java index a87bb2565..cc58f5d0d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java @@ -418,4 +418,22 @@ public class UtilParticle PlayParticleToAll(particleType, location, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1f, count, dist); } + public static void playColoredParticle(java.awt.Color color, ParticleType particleType, Location location, int count, ViewDist dist, Player... players) + { + if (particleType != ParticleType.RED_DUST + && particleType != ParticleType.MOB_SPELL_AMBIENT) + return; + PlayParticle(particleType, location, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1f, count, dist, players); + } + + public static void playColoredParticleToAll(java.awt.Color color, ParticleType particleType, Location location, int count, ViewDist dist) + { + if (particleType != ParticleType.RED_DUST && particleType != ParticleType.MOB_SPELL_AMBIENT) + { + return; + } + + PlayParticleToAll(particleType, location, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1f, count, dist); + } + } \ No newline at end of file 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 63b55feab..5fa174eea 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 @@ -9,6 +9,7 @@ import mineplex.serverdata.Region; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.Sound; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -43,14 +44,7 @@ public class UtilServer public static List getSortedPlayers() { - return getSortedPlayers(new Comparator() - { - @Override - public int compare(Player o1, Player o2) - { - return o1.getName().compareTo(o2.getName()); - } - }); + return getSortedPlayers(Comparator.comparing(HumanEntity::getName)); } public static List getSortedPlayers(Comparator comparator) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java index d4e48144f..e5ea8f1af 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java @@ -1,70 +1,1124 @@ package mineplex.core.common.util.banner; import org.bukkit.DyeColor; +import org.bukkit.Material; import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.PatternType; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; +import java.util.Arrays; +import java.util.List; + +import static org.bukkit.DyeColor.*; +import static org.bukkit.block.banner.PatternType.*; + +/** + * Banner patterns for country (and related) flags. + */ public enum CountryFlag { - BRAZIL(DyeColor.GREEN, new Pattern(DyeColor.YELLOW, PatternType.RHOMBUS_MIDDLE), new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)), - USA(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.BLUE, PatternType.SQUARE_TOP_RIGHT)), - CANADA(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM), - new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)), - UK(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNLEFT), new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNRIGHT), - new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.CROSS)), - IRELAND(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.STRIPE_TOP), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_BOTTOM)), - SPAIN(DyeColor.YELLOW, new Pattern(DyeColor.RED, PatternType.STRIPE_LEFT), new Pattern(DyeColor.RED, PatternType.STRIPE_RIGHT)), - JAPAN(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)), - SOUTH_SUDAN(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_LEFT), new Pattern(DyeColor.BLACK, PatternType.STRIPE_RIGHT), - new Pattern(DyeColor.GREEN, PatternType.TRIANGLE_BOTTOM)), - JAMAICA(DyeColor.GREEN, new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_TOP), new Pattern(DyeColor.BLACK, PatternType.TRIANGLES_BOTTOM), - new Pattern(DyeColor.YELLOW, PatternType.CROSS)), - ITALY(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM)), - SENEGAL(DyeColor.YELLOW, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM), - new Pattern(DyeColor.GREEN, PatternType.CIRCLE_MIDDLE)), - FRANCE(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM)), - INDIA(DyeColor.WHITE, new Pattern(DyeColor.ORANGE, PatternType.STRIPE_LEFT), new Pattern(DyeColor.GREEN, PatternType.STRIPE_RIGHT), - new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)), - BELGIUM(DyeColor.YELLOW, new Pattern(DyeColor.BLACK, PatternType.STRIPE_BOTTOM), new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)), - ENGLAND(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS)), - AUSTRIA(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER)), - ARMENIA(DyeColor.RED, new Pattern(DyeColor.BLUE, PatternType.STRIPE_CENTER), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_RIGHT)), - ARGENTINA(DyeColor.LIGHT_BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER), new Pattern(DyeColor.YELLOW, PatternType.CIRCLE_MIDDLE)), - GREECE(DyeColor.LIGHT_BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.LIGHT_BLUE, PatternType.SQUARE_BOTTOM_LEFT)), - CZECH_REPUBLIC(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.HALF_VERTICAL_MIRROR), new Pattern(DyeColor.BLUE, PatternType.TRIANGLE_BOTTOM)), - ROMANIA(DyeColor.YELLOW, new Pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM), new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)), - HONDURAS(DyeColor.WHITE, new Pattern(DyeColor.BLUE, PatternType.STRIPE_LEFT), new Pattern(DyeColor.BLUE, PatternType.STRIPE_RIGHT)), - ALGERIA(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.HALF_HORIZONTAL_MIRROR), new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)), - PORTUGAL(DyeColor.RED, new Pattern(DyeColor.GREEN, PatternType.STRIPE_TOP), new Pattern(DyeColor.YELLOW, PatternType.CIRCLE_MIDDLE)), - BAHRAIN(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.TRIANGLES_BOTTOM)), - GERMANY(DyeColor.RED, new Pattern(DyeColor.BLACK, PatternType.STRIPE_LEFT), new Pattern(DyeColor.YELLOW, PatternType.STRIPE_RIGHT)), - GABON(DyeColor.YELLOW, new Pattern(DyeColor.BLUE, PatternType.STRIPE_RIGHT), new Pattern(DyeColor.LIME, PatternType.STRIPE_LEFT)), - SCOTLAND(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.CROSS)), - PERU(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM)), - TANZANIA(DyeColor.LIME, new Pattern(DyeColor.LIGHT_BLUE, PatternType.DIAGONAL_RIGHT), new Pattern(DyeColor.BLACK, PatternType.STRIPE_DOWNLEFT)), - MOROCCO(DyeColor.RED, new Pattern(DyeColor.GREEN, PatternType.CIRCLE_MIDDLE)), - SOLOMON_ISLANDS(DyeColor.GREEN, new Pattern(DyeColor.BLUE, PatternType.DIAGONAL_LEFT_MIRROR), new Pattern(DyeColor.YELLOW, PatternType.STRIPE_DOWNRIGHT)), - SWITZERLAND(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM), - new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)), - FINLAND(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.SQUARE_BOTTOM_LEFT), new Pattern(DyeColor.WHITE, PatternType.SQUARE_BOTTOM_RIGHT), - new Pattern(DyeColor.WHITE, PatternType.HALF_HORIZONTAL), new Pattern(DyeColor.BLUE, PatternType.STRIPE_CENTER)), - SOUTH_AFRICA(DyeColor.WHITE, new Pattern(DyeColor.BLUE, PatternType.HALF_VERTICAL_MIRROR), new Pattern(DyeColor.RED, PatternType.HALF_VERTICAL), - new Pattern(DyeColor.GREEN, PatternType.STRIPE_CENTER), new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_BOTTOM)), - POLAND(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.HALF_VERTICAL_MIRROR)); + MINEPLEX("Mineplex", "Mineplex", BLACK, + new Pattern(ORANGE, TRIANGLE_TOP), + new Pattern(BLACK, TRIANGLES_TOP), + new Pattern(ORANGE, STRIPE_LEFT), + new Pattern(ORANGE, STRIPE_RIGHT), + new Pattern(BLACK, BORDER), + new Pattern(BLACK, STRIPE_BOTTOM)), - private DyeColor _baseColor; - private Pattern[] _patterns; + AFGHANISTAN("Afghanistan", "Afghanistani", RED, + new Pattern(BLACK, STRIPE_TOP), + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), - CountryFlag(DyeColor baseColor, Pattern... patterns){ + ALBANIA("Albania", "Albanian", RED, + new Pattern(BLACK, FLOWER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, BORDER), + new Pattern(RED, STRIPE_SMALL), + new Pattern(BLACK, CIRCLE_MIDDLE)), + + ALGERIA("Algeria", "Algerian", GREEN, + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(WHITE, TRIANGLE_BOTTOM)), + + ANGOLA("Angola", "Angolan", RED, + new Pattern(BLACK, HALF_VERTICAL), + new Pattern(YELLOW, FLOWER), + new Pattern(BLACK, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT)), + + ARGENTINA("Argentina", "Argentinian", WHITE, + new Pattern(LIGHT_BLUE, STRIPE_LEFT), + new Pattern(LIGHT_BLUE, STRIPE_RIGHT), + new Pattern(YELLOW, CIRCLE_MIDDLE)), + + ARMENIA("Armenia", "Armenian", RED, + new Pattern(ORANGE, HALF_VERTICAL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), + + AUSTRALIA("Australia", "Australian", WHITE, + new Pattern(BLUE, CROSS), + new Pattern(BLUE, STRAIGHT_CROSS), + new Pattern(BLUE, CURLY_BORDER), + new Pattern(RED, SQUARE_TOP_RIGHT)), + + AUSTRIA("Austria", "Austrian", RED, + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER)), + + AZERBAIJAN("Azerbaijan", "Azerbaijani", RED, + new Pattern(WHITE, FLOWER), + new Pattern(WHITE, FLOWER), + new Pattern(WHITE, FLOWER), + new Pattern(RED, DIAGONAL_LEFT_MIRROR), + new Pattern(RED, DIAGONAL_RIGHT_MIRROR), + new Pattern(LIGHT_BLUE, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_LEFT)), + + BAHRAIN("Bahrain", "Bahraini", RED, + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP)), + + BANGLADESH("Bangladesh", "Bangladeshi", GREEN, + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + BELARUS("Belarus", "Belarusian", RED, + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(WHITE, TRIANGLES_TOP)), + + BELGIUM("Belgium", "Belgian", YELLOW, + new Pattern(BLACK, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + BERMUDA("Bermuda", "Bermudian", BLUE, + new Pattern(WHITE, BRICKS), + new Pattern(RED, HALF_VERTICAL), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, STRIPE_MIDDLE)), + + BHUTAN("Bhutan", "Bhutanese", YELLOW, + new Pattern(ORANGE, DIAGONAL_LEFT_MIRROR), + new Pattern(WHITE, RHOMBUS_MIDDLE)), + + BOLIVIA("Bolivia", "Bolivian", RED, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE), + new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE), + new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + BOSNIA_AND_HERZEGOVINA("Bosnia and Herzegovina", "Bosnia and Herzegovinian", BLUE, + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(BLUE, BRICKS), + new Pattern(YELLOW, DIAGONAL_RIGHT), + new Pattern(BLUE, STRIPE_BOTTOM)), + + BRAZIL("Brazil", "Brazilian", LIME, + new Pattern(YELLOW, RHOMBUS_MIDDLE), + new Pattern(YELLOW, RHOMBUS_MIDDLE), + new Pattern(YELLOW, RHOMBUS_MIDDLE), + new Pattern(BLUE, CIRCLE_MIDDLE), + new Pattern(BLUE, CIRCLE_MIDDLE)), + + BRUNEI("Brunei", "Bruneian", YELLOW, + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(BLACK, CROSS), + new Pattern(YELLOW, DIAGONAL_LEFT), + new Pattern(YELLOW, SQUARE_BOTTOM_RIGHT), + new Pattern(RED, CIRCLE_MIDDLE)), + + BULGARIA("Bulgaria", "Bulgarian", WHITE, + new Pattern(RED, HALF_VERTICAL), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_CENTER)), + + CAMBODIA("Cambodia", "Cambodian", RED, + new Pattern(WHITE, FLOWER), + new Pattern(BLUE, STRIPE_LEFT), + new Pattern(BLUE, STRIPE_RIGHT)), + + CAMEROON("Cameroon", "Cameroonian", RED, + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(YELLOW, STRIPE_BOTTOM)), + + CANADA("Canada", "Canadian", WHITE, + new Pattern(RED, CROSS), + new Pattern(WHITE, STRIPE_LEFT), + new Pattern(RED, STRIPE_MIDDLE), + new Pattern(WHITE, BORDER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + CHILE("Chile", "Chilean", BLUE, + new Pattern(WHITE, CROSS), + new Pattern(BLUE, TRIANGLES_TOP), + new Pattern(BLUE, RHOMBUS_MIDDLE), + new Pattern(BLUE, BORDER), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(RED, HALF_VERTICAL)), + + CHINA("China", "Chinese", RED, + new Pattern(YELLOW, SQUARE_TOP_RIGHT), + new Pattern(RED, PatternType.STRIPE_SMALL), + new Pattern(RED, BORDER), + new Pattern(RED, BRICKS)), + + COLOMBIA("Colombia", "Colombian", RED, + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(YELLOW, HALF_VERTICAL_MIRROR)), + + COSTA_RICA("Costa Rica", "Costa Rican", WHITE, + new Pattern(BLUE, STRIPE_SMALL), + new Pattern(BLUE, STRIPE_SMALL), + new Pattern(BLUE, STRIPE_SMALL), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER)), + + CROATIA("Croatia", "Croatian", RED, + new Pattern(WHITE, FLOWER), + new Pattern(BLUE, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, CIRCLE_MIDDLE)), + + CUBA("Cuba", "Cuban", BLUE, + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(RED, TRIANGLE_TOP)), + + CYPRUS("Cyprus", "Cyprus", WHITE, + new Pattern(ORANGE, FLOWER), + new Pattern(ORANGE, FLOWER), + new Pattern(ORANGE, FLOWER), + new Pattern(ORANGE, CIRCLE_MIDDLE), + new Pattern(WHITE, DIAGONAL_LEFT_MIRROR), + new Pattern(WHITE, CURLY_BORDER), + new Pattern(WHITE, CURLY_BORDER), + new Pattern(WHITE, CURLY_BORDER)), + + CZECH_REPUBLIC("Czech Republic", "Czech Republic", true, WHITE, + new Pattern(RED, HALF_VERTICAL), + new Pattern(BLUE, TRIANGLE_TOP)), + + DENMARK("Denmark", "Danish", WHITE, + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_CENTER)), + + DOMINICAN_REPUBLIC("Dominican Republic", "Dominican", true, WHITE, + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(BLUE, SQUARE_BOTTOM_LEFT), + new Pattern(RED, SQUARE_TOP_LEFT), + new Pattern(RED, SQUARE_BOTTOM_RIGHT), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + ECUADOR("Ecuador", "Ecuadorian", RED, + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(YELLOW, HALF_VERTICAL_MIRROR), + new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE)), + + EGYPT("Egypt", "Egyptian", WHITE, + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(BLACK, STRIPE_LEFT)), + + EL_SALVADOR("El Salvador", "El Salvadorian", BLUE, + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + ENGLAND("England", "English", WHITE, + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS)), + + ESTONIA("Estonia", "Estonian", BLUE, + new Pattern(WHITE, HALF_VERTICAL), + new Pattern(BLACK, STRIPE_CENTER), + new Pattern(BLACK, STRIPE_CENTER), + new Pattern(BLACK, STRIPE_CENTER)), + + ETHIOPIA("Ethiopia", "Ethiopian", GREEN, + new Pattern(RED, HALF_VERTICAL), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(BLUE, CIRCLE_MIDDLE), + new Pattern(BLUE, CIRCLE_MIDDLE), + new Pattern(BLUE, CIRCLE_MIDDLE)), + + EU("European Union", "European Union", true, BLUE, + new Pattern(YELLOW, CROSS), + new Pattern(YELLOW, STRIPE_MIDDLE), + new Pattern(BLUE, BORDER), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, STRIPE_BOTTOM), + new Pattern(BLUE, CIRCLE_MIDDLE)), + + FAROE_ISLANDS("Faroe Islands", "Faroese", true, RED, + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER)), + + FINLAND("Finland", "Finnish", BLUE, + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, STRIPE_CENTER)), + + FRANCE("France", "French", WHITE, + new Pattern(BLUE, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + GABON("Gabon", "Gabonese", GREEN, + new Pattern(BLUE, HALF_VERTICAL), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER)), + + GEORGIA("Georgia", "Georgian", WHITE, + new Pattern(RED, TRIANGLES_TOP), + new Pattern(RED, TRIANGLES_TOP), + new Pattern(RED, TRIANGLES_TOP), + new Pattern(RED, TRIANGLES_BOTTOM), + new Pattern(RED, TRIANGLES_BOTTOM), + new Pattern(RED, TRIANGLES_BOTTOM), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS)), + + GERMANY("Germany", "German", BLACK, + new Pattern(YELLOW, HALF_VERTICAL), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER)), + + GHANA("Ghana", "Ghanaian", YELLOW, + new Pattern(BLACK, CROSS), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_LEFT)), + + GREECE("Greece", "Greek", BLUE, + new Pattern(BLUE, HALF_VERTICAL), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(BLUE, SQUARE_TOP_RIGHT)), + + GUATEMALA("Guatemala", "Guatemalan", WHITE, + new Pattern(LIGHT_BLUE, STRIPE_TOP), + new Pattern(LIGHT_BLUE, STRIPE_BOTTOM), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + HONDURAS("Honduras", "Honduran", WHITE, + new Pattern(BLUE, FLOWER), + new Pattern(WHITE, STRIPE_LEFT), + new Pattern(WHITE, STRIPE_LEFT), + new Pattern(WHITE, STRIPE_LEFT), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(BLUE, STRIPE_LEFT), + new Pattern(BLUE, STRIPE_RIGHT)), + + HONG_KONG("Hong Kong", "Hong Kongese", RED, + new Pattern(WHITE, FLOWER)), + + HUNGARY("Hungary", "Hungarian", RED, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER)), + + ICELAND("Iceland", "Icelandic", RED, + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER)), + + INDIA("India", "Indian", WHITE, + new Pattern(ORANGE, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_RIGHT), + new Pattern(BLUE, CIRCLE_MIDDLE)), + + INDONESIA("Indonesia", "Indonesian", WHITE, + new Pattern(RED, HALF_VERTICAL_MIRROR)), + + IRAN("Iran", "Iranian", WHITE, + new Pattern(GREEN, STRIPE_RIGHT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + IRAQ("Iraq", "Iraqi", WHITE, + new Pattern(GREEN, FLOWER), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(BLACK, STRIPE_LEFT)), + + IRELAND("Ireland", "Irish", WHITE, + new Pattern(GREEN, STRIPE_TOP), + new Pattern(ORANGE, STRIPE_BOTTOM)), + + ISLE_OF_MAN("Isle of Man", "Isle of Man", true, RED, + new Pattern(WHITE, SKULL), + new Pattern(WHITE, FLOWER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT)), + + ISRAEL("Israel", "Israeli", WHITE, + new Pattern(BLUE, STRIPE_LEFT), + new Pattern(BLUE, STRIPE_RIGHT), + new Pattern(BLUE, FLOWER)), + + ITALY("Italy", "Italian", WHITE, + new Pattern(GREEN, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + IVORY_COAST("Ivory Coast", "Ivory Coast", true, WHITE, + new Pattern(ORANGE, STRIPE_TOP), + new Pattern(ORANGE, STRIPE_TOP), + new Pattern(ORANGE, STRIPE_TOP), + new Pattern(LIME, STRIPE_BOTTOM), + new Pattern(LIME, STRIPE_BOTTOM), + new Pattern(LIME, STRIPE_BOTTOM)), + + JAMAICA("Jamaica", "Jamaican", GREEN, + new Pattern(YELLOW, STRIPE_DOWNLEFT), + new Pattern(YELLOW, STRIPE_DOWNLEFT), + new Pattern(YELLOW, STRIPE_DOWNLEFT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(BLACK, TRIANGLE_TOP), + new Pattern(BLACK, TRIANGLE_BOTTOM)), + + JAPAN("Japan", "Japanese", WHITE, + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + JORDAN("Jordan", "Jordanian", BLACK, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, TRIANGLE_TOP), + new Pattern(RED, TRIANGLE_TOP), + new Pattern(RED, TRIANGLE_TOP)), + + KAZAKHSTAN("Kazakhstan", "Kazakhstani", LIGHT_BLUE, + new Pattern(YELLOW, CREEPER), + new Pattern(LIGHT_BLUE, HALF_VERTICAL), + new Pattern(YELLOW, TRIANGLES_TOP)), + + KENYA("Kenya", "Kenyan", WHITE, + new Pattern(BLACK, STRIPE_RIGHT), + new Pattern(RED, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(WHITE, FLOWER), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + KUWAIT("Kuwait", "Kuwaiti", GREEN, + new Pattern(RED, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(BLACK, TRIANGLE_TOP), + new Pattern(WHITE, CIRCLE_MIDDLE)), + + KYRGYZSTAN("Kyrgyzstan", "Kyrgyzstani", RED, + new Pattern(YELLOW, CIRCLE_MIDDLE)), + + LATVIA("Latvia", "Latvian", RED, + new Pattern(WHITE, STRIPE_CENTER)), + + LEBANON("Lebanon", "Lebanese", WHITE, + new Pattern(GREEN, FLOWER), + new Pattern(GREEN, FLOWER), + new Pattern(GREEN, FLOWER), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + LIBYA("Libya", "Libyan", BLACK, + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(BLACK, FLOWER), + new Pattern(BLACK, TRIANGLE_TOP), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_LEFT)), + + LITHUANIA("Lithuania", "Lithuanian", YELLOW, + new Pattern(RED, HALF_VERTICAL), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_CENTER)), + + LUXEMBOURG("Luxembourg", "Luxembourg", RED, + new Pattern(LIGHT_BLUE, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER)), + + MACAU("Macau", "Macau", GREEN, + new Pattern(YELLOW, BRICKS), + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(WHITE, FLOWER), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_BOTTOM)), + + MACEDONIA("Macedonia", "Macedonian", RED, + new Pattern(YELLOW, CROSS), + new Pattern(YELLOW, STRAIGHT_CROSS), + new Pattern(RED, RHOMBUS_MIDDLE), + new Pattern(YELLOW, CIRCLE_MIDDLE)), + + MALAYSIA("Malaysia", "Malaysian", RED, + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(YELLOW, TRIANGLES_TOP)), + + MALTA("Malta", "Maltese", WHITE, + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(GRAY, SQUARE_TOP_RIGHT), + new Pattern(WHITE, SQUARE_TOP_RIGHT)), + + MEXICO("Mexico", "Mexican", WHITE, + new Pattern(GREEN, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(BROWN, CIRCLE_MIDDLE), + new Pattern(BROWN, CIRCLE_MIDDLE), + new Pattern(YELLOW, CIRCLE_MIDDLE)), + + MOLDOVA("Moldova", "Moldovan", YELLOW, + new Pattern(BROWN, CIRCLE_MIDDLE), + new Pattern(YELLOW, STRIPE_LEFT), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + MONGOLIA("Mongolia", "Mongolian", BLUE, + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(YELLOW, TRIANGLES_TOP)), + + MONTENEGRO("Montenegro", "Montenegrin", RED, + new Pattern(YELLOW, FLOWER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(YELLOW, BORDER)), + + MOROCCO("Morocco", "Moroccan", RED, + new Pattern(GREEN, CROSS), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + MOZAMBIQUE("Mozambique", "Mozambique", WHITE, + new Pattern(CYAN, STRIPE_RIGHT), + new Pattern(YELLOW, STRIPE_LEFT), + new Pattern(BLACK, STRIPE_CENTER), + new Pattern(RED, TRIANGLE_TOP)), + + NEPAL("Nepal", "Nepali", RED, + new Pattern(BLUE, BORDER), + new Pattern(BLUE, BORDER), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, FLOWER)), + + NETHERLANDS("Netherlands", "Dutch", true, WHITE, + new Pattern(RED, PatternType.STRIPE_RIGHT), + new Pattern(RED, PatternType.STRIPE_RIGHT), + new Pattern(BLUE, PatternType.STRIPE_LEFT), + new Pattern(BLUE, PatternType.STRIPE_LEFT)), + + NEW_ZEALAND("New Zealand", "New Zealand", RED, + new Pattern(BLUE, CROSS), + new Pattern(BLUE, STRAIGHT_CROSS), + new Pattern(BLUE, CURLY_BORDER), + new Pattern(WHITE, SQUARE_TOP_RIGHT)), + + NIGERIA("Nigeria", "Nigerian", WHITE, + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_BOTTOM)), + + NORWAY("Norway", "Norwegian", BLUE, + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), + + OMAN("Oman", "Omani", WHITE, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(RED, TRIANGLES_TOP), + new Pattern(RED, SQUARE_TOP_LEFT)), + + PAKISTAN("Pakistan", "Pakistani", GREEN, + new Pattern(WHITE, FLOWER), + new Pattern(GREEN, TRIANGLE_BOTTOM), + new Pattern(GREEN, TRIANGLE_BOTTOM), + new Pattern(GREEN, TRIANGLE_BOTTOM), + new Pattern(GREEN, BORDER), + new Pattern(GREEN, BORDER), + new Pattern(GREEN, BORDER), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(WHITE, STRIPE_TOP)), + + PANAMA("Panama", "Panamanian", WHITE, + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(RED, SQUARE_BOTTOM_LEFT), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, CURLY_BORDER), + new Pattern(RED, SQUARE_BOTTOM_RIGHT), + new Pattern(BLUE, SQUARE_TOP_LEFT)), + + PARAGUAY("Paraguay", "Paraguayan", RED, + new Pattern(BLUE, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + PERU("Peru", "Peruvian", WHITE, + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + PHILIPPINES("Philippines", "Philippine", true, BLUE, + new Pattern(RED, HALF_VERTICAL), + new Pattern(WHITE, TRIANGLE_TOP)), + + POLAND("Poland", "Polish", WHITE, + new Pattern(RED, HALF_VERTICAL)), + + PORTUGAL("Portugal", "Portuguese", RED, + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(YELLOW, CREEPER), + new Pattern(YELLOW, SKULL), + new Pattern(RED, HALF_HORIZONTAL)), + + PUERTO_RICO("Puerto Rico", "Puerto Rican", RED, + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(BLUE, TRIANGLE_TOP)), + + QATAR("Qatar", "Qatari", RED, + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP)), + + ROMANIA("Romania", "Romanian", YELLOW, + new Pattern(BLUE, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + RUSSIA("Germany", "German", WHITE, + new Pattern(RED, HALF_VERTICAL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), + + RWANDA("Rwanda", "Rwandan", LIGHT_BLUE, + new Pattern(YELLOW, TRIANGLES_TOP), + new Pattern(LIGHT_BLUE, BORDER), + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER)), + + SAUDI_ARABIA("Saudi Arabia", "Saudi Arabian", GREEN, + new Pattern(WHITE, SKULL), + new Pattern(WHITE, MOJANG), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, BORDER)), + + SCOTLAND("Scotland", "Scottish", BLUE, + new Pattern(WHITE, CROSS), + new Pattern(WHITE, CROSS)), + + SENEGAL("Senegal", "Senegalese", YELLOW, + new Pattern(GREEN, CROSS), + new Pattern(YELLOW, STRIPE_BOTTOM), + new Pattern(YELLOW, STRIPE_BOTTOM), + new Pattern(YELLOW, STRIPE_TOP), + new Pattern(YELLOW, STRIPE_TOP), + new Pattern(YELLOW, STRIPE_TOP), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + SERBIA("Serbia", "Serbian", RED, + new Pattern(WHITE, HALF_VERTICAL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE)), + + SINGAPORE("Singapore", "Singaporean", RED, + new Pattern(WHITE, FLOWER), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, STRIPE_CENTER), + new Pattern(WHITE, HALF_VERTICAL)), + + SLOVAKIA("Slovakia", "Slovakian", BLUE, + new Pattern(RED, SKULL), + new Pattern(WHITE, BRICKS), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_LEFT)), + + SLOVENIA("Slovenia", "Slovenian", WHITE, + new Pattern(BLUE, CROSS), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, HALF_VERTICAL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), + + SOLOMON_ISLANDS("Solomon Islands", "Solomon Islands", true, BLUE, + new Pattern(WHITE, BRICKS), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, BORDER), + new Pattern(BLUE, CURLY_BORDER), + new Pattern(BLUE, RHOMBUS_MIDDLE), + new Pattern(BLUE, HALF_VERTICAL), + new Pattern(GREEN, DIAGONAL_LEFT_MIRROR), + new Pattern(BLACK, STRIPE_DOWNRIGHT), + new Pattern(BLACK, STRIPE_DOWNRIGHT)), + + SOMALIA("Somalia", "Somalian", LIGHT_BLUE, + new Pattern(WHITE, CROSS), + new Pattern(LIGHT_BLUE, STRIPE_TOP), + new Pattern(LIGHT_BLUE, STRIPE_BOTTOM)), + + SOUTH_AFRICA("South Africa", "South African", WHITE, + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(YELLOW, TRIANGLE_TOP), + new Pattern(YELLOW, TRIANGLE_TOP), + new Pattern(YELLOW, TRIANGLE_TOP), + new Pattern(BLACK, TRIANGLE_TOP)), + + SOUTH_KOREA("South Korea", "South Korean", RED, + new Pattern(BLUE, DIAGONAL_LEFT_MIRROR), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, CURLY_BORDER), + new Pattern(WHITE, STRIPE_BOTTOM), + new Pattern(BLACK, TRIANGLES_TOP), + new Pattern(BLACK, TRIANGLES_TOP), + new Pattern(BLACK, TRIANGLES_TOP), + new Pattern(BLACK, TRIANGLES_BOTTOM), + new Pattern(BLACK, TRIANGLES_BOTTOM), + new Pattern(BLACK, TRIANGLES_BOTTOM), + new Pattern(WHITE, TRIANGLES_BOTTOM), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, BORDER)), + + SOUTH_SUDAN("South Sudan", "South Sudanese", WHITE, + new Pattern(BLACK, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(RED, STRIPE_CENTER), + new Pattern(BLUE, TRIANGLE_TOP)), + + SPAIN("Spain", "Spanish", YELLOW, + new Pattern(BROWN, FLOWER), + new Pattern(YELLOW, HALF_HORIZONTAL_MIRROR)), + + SRI_LANKA("Sri Lanka", "Sri Lankan", RED, + new Pattern(YELLOW, STRIPE_MIDDLE), + new Pattern(YELLOW, CREEPER), + new Pattern(ORANGE, HALF_HORIZONTAL), + new Pattern(LIME, STRIPE_TOP), + new Pattern(YELLOW, BORDER)), + + SUDAN("Sudan", "Sudanese", RED, + new Pattern(BLACK, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(GREEN, TRIANGLE_TOP)), + + SURINAME("Suriname", "Surinamese", WHITE, + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(YELLOW, FLOWER), + new Pattern(YELLOW, SKULL), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_RIGHT)), + + SWEDEN("Sweden", "Swedish", YELLOW, + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(YELLOW, STRIPE_CENTER)), + + SWITZERLAND("Switzerland", "Swiss", RED, + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, BORDER), + new Pattern(RED, BORDER), + new Pattern(RED, BORDER)), + + SYRIA("Syria", "Syrian", WHITE, + new Pattern(GREEN, FLOWER), + new Pattern(GREEN, FLOWER), + new Pattern(GREEN, FLOWER), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(BLACK, STRIPE_LEFT), + new Pattern(BLACK, STRIPE_LEFT), + new Pattern(BLACK, STRIPE_LEFT)), + + TAIWAN("Taiwan", "Taiwanese", BLUE, + new Pattern(WHITE, CROSS), + new Pattern(BLUE, CURLY_BORDER), + new Pattern(BLUE, FLOWER), + new Pattern(BLUE, CIRCLE_MIDDLE), + new Pattern(BLUE, RHOMBUS_MIDDLE), + new Pattern(RED, HALF_VERTICAL), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, HALF_HORIZONTAL_MIRROR)), + + TAJIKISTAN("Tajikistan", "Tajikistani", WHITE, + new Pattern(YELLOW, CROSS), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_BOTTOM), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT)), + + TANZANIA("Tanzania", "Tanzanian", LIGHT_BLUE, + new Pattern(LIME, DIAGONAL_RIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT)), + + THAILAND("Thailand", "Thai", WHITE, + new Pattern(RED, STRIPE_SMALL), + new Pattern(RED, STRIPE_SMALL), + new Pattern(RED, STRIPE_SMALL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), + + TUNISIA("Tunisia", "Tunisian", RED, + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, FLOWER), + new Pattern(RED, TRIANGLE_BOTTOM)), + + TURKEY("Turkey", "Turkish", RED, + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, FLOWER), + new Pattern(RED, TRIANGLE_BOTTOM)), + + UAE("United Arab Emirates", "United Arab Emirates", true, GREEN, + new Pattern(BLACK, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP)), + + UGANDA("Uganda", "Ugandan", RED, + new Pattern(BLACK, STRIPE_LEFT), + new Pattern(BLACK, STRIPE_RIGHT), + new Pattern(YELLOW, STRIPE_SMALL), + new Pattern(RED, BORDER)), + + UK("United Kingdom", "British", true, BLUE, + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(WHITE, STRIPE_DOWNRIGHT), + new Pattern(WHITE, STRIPE_DOWNRIGHT), + new Pattern(RED, CROSS), + new Pattern(RED, CROSS), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS)), + + UKRAINE("Ukraine", "Ukrainian", BLUE, + new Pattern(YELLOW, HALF_VERTICAL)), + + URUGUAY("Uruguay", "Uruguayan", WHITE, + new Pattern(BLUE, STRIPE_SMALL), + new Pattern(YELLOW, SQUARE_TOP_RIGHT)), + + USA("United States of America", "American", true, RED, + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(BLUE, SQUARE_TOP_RIGHT)), + + UZBEKISTAN("Uzbekistan", "Uzbekistani", RED, + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(LIGHT_BLUE, STRIPE_RIGHT)), + + VENEZUELA("Venezuela", "Venezuelan", BLUE, + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(BLUE, STRAIGHT_CROSS), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_LEFT)), + + VIETNAM("Vietnam", "Vietnamese", RED, + new Pattern(YELLOW, CROSS), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + WALES("Wales", "Welsh", WHITE, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(RED, MOJANG), + new Pattern(RED, MOJANG), + new Pattern(RED, SKULL)), + + YEMEN("Yemen", "Yemeni", RED, + new Pattern(BLACK, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER)), + + ZAMBIA("Zambia", "Zambian", LIME, + new Pattern(YELLOW, FLOWER), + new Pattern(RED, STRIPE_MIDDLE), + new Pattern(BLACK, HALF_HORIZONTAL_MIRROR), + new Pattern(ORANGE, STRIPE_BOTTOM)), + + ZIMBABWE("Zimbabwe", "Zimbabwean", RED, + new Pattern(BLACK, STRAIGHT_CROSS), + new Pattern(YELLOW, STRIPE_LEFT), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(GREEN, BORDER), + new Pattern(WHITE, TRIANGLE_TOP)), + + ; + + private final boolean _article; + private final String _country; + private final String _adjective; + private final DyeColor _baseColor; + private final Pattern[] _patterns; + + /** + * Create a country flag banner. + * + * @param country Country name. + * @param adjective Country name as an adjective. + * @param baseColor base color of the banner. + * @param patterns List of patterns to apply to the banner. + */ + CountryFlag(String country, String adjective, DyeColor baseColor, Pattern... patterns) + { + this(country, adjective, false, baseColor, patterns); + } + + /** + * Create a country flag banner for a country with a name often preceded with "The". + * + * @param country Country name. + * @param adjective Country name as an adjective. + * @param article Whether the country name should be preceded with "The". + * @param baseColor base color of the banner. + * @param patterns List of patterns to apply to the banner. + */ + CountryFlag(String country, String adjective, boolean article, DyeColor baseColor, Pattern... patterns) + { + _country = country; + _adjective = adjective; + _article = article; _baseColor = baseColor; _patterns = patterns; } + /** + * @return a flag banner item. + */ public ItemStack getBanner() { - return UtilBanner.createBanner(_baseColor, _patterns); + ItemStack banner = new ItemStack(Material.BANNER); + BannerMeta bannerMeta = (BannerMeta) banner.getItemMeta(); + bannerMeta.setBaseColor(_baseColor); + + for (Pattern pattern : _patterns) + { + bannerMeta.addPattern(pattern); + } + + banner.setItemMeta(bannerMeta); + return banner; + } + + /** + * @return the name of the country. + */ + public String getCountryName() + { + return (_article ? "The " : "") + _country; + } + + /** + * @return the name of the country without a possible article before the country name. + */ + public String getCountryNameRaw() + { + return _country; + } + + /** + * @return the name of the country written in an adjectival manner. + */ + public String getCountryAdjective() + { + return _adjective; + } + + /** + * @return the banner color. + */ + public DyeColor getBaseColor() + { + return _baseColor; + } + + /** + * @return the patterns applied to the banner. + */ + public List getPatterns() + { + return Arrays.asList(_patterns); } } diff --git a/Plugins/Mineplex.Core/pom.xml b/Plugins/Mineplex.Core/pom.xml index 50bfe79f3..b89d67002 100644 --- a/Plugins/Mineplex.Core/pom.xml +++ b/Plugins/Mineplex.Core/pom.xml @@ -48,7 +48,7 @@ com.mineplex anticheat - 1.5 + 1.6 org.tukaani diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java index 379dc217d..71c935918 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java @@ -45,7 +45,7 @@ public class CoreClient public UUID getUniqueId() { - return this._uuid; + return _uuid; } public String getName() @@ -134,20 +134,20 @@ public class CoreClient public void undisguise() { - this._disguisedName = null; - this._disguisedSkin = null; - this._disguisedRank = null; - this._disguisedUUID = null; + _disguisedName = null; + _disguisedSkin = null; + _disguisedRank = null; + _disguisedUUID = null; } public String getDisguisedAs() { - return this._disguisedName; + return _disguisedName; } public String getDisguisedSkin() { - return this._disguisedSkin; + return _disguisedSkin; } public Rank getDisguisedRank() @@ -157,32 +157,32 @@ public class CoreClient public UUID getDisguisedAsUUID() { - return this._disguisedUUID; + return _disguisedUUID; } public boolean isDisguised() { - if (this._disguisedName == null) + if (_disguisedName == null) { return false; } - return !this._name.equalsIgnoreCase(this._disguisedName); + return !_name.equalsIgnoreCase(_disguisedName); } public void disguise(String name, UUID uuid, Rank rank) { - this._disguisedName = name; - this._disguisedUUID = uuid; - this._disguisedRank = rank; + _disguisedName = name; + _disguisedUUID = uuid; + _disguisedRank = rank; } public Rank getRealOrDisguisedRank() { - if (this._disguisedRank != null) + if (_disguisedRank != null) { - return this._disguisedRank; + return _disguisedRank; } - return this.GetRank(); + return GetRank(); } public void setNetworkSessionLoginTime(long loginTime) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java index ba8c69ffa..da9f6343f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java @@ -92,7 +92,7 @@ public class UpdateRank extends CommandBase if (Plugin.Get(p).GetRank() != Plugin.Get(p).GetRank(true)) Plugin.Get(p).resetTemp(); - OnlineRankUpdateEvent event = new OnlineRankUpdateEvent(caller, Plugin.Get(caller).GetRank(), rank, true); + OnlineRankUpdateEvent event = new OnlineRankUpdateEvent(caller, Plugin.Get(caller).GetRank(), rank, false); Plugin.Get(p).SetRank(rank, false); Bukkit.getPluginManager().callEvent(event); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 0b392ed76..670007c27 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -462,6 +462,15 @@ public enum Achievement new String[]{"Novice I", "Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, AchievementCategory.CASTLE_ASSAULT), + CASTLE_ASSAULT_ALCHEMIST_KIT("Alchemist", 0, + new String[]{"Castle Assault.AlchemistKitKills", "Castle Assault TDM.AlchemistKitKills"}, + new String[]{"Kill opponents while wearing the Alchemist Kit"}, + new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, + new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, + "Initiate", + new String[]{"Novice I", "Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, + AchievementCategory.CASTLE_ASSAULT), + CASTLE_ASSAULT_WINNER("Assault", 0, new String[]{"Castle Assault.Wins", "Castle Assault TDM.Wins"}, new String[]{"Win games of Castle Assault"}, @@ -1226,7 +1235,62 @@ public enum Achievement new String[]{"Gem Hunters.ChestsOpened"}, new String[]{"+1 for each chest opened"}, new int[]{50,100,200,400,1000}, - AchievementCategory.GEM_HUNTERS); + AchievementCategory.GEM_HUNTERS), + + MOBA_GOLD_EARNED("Gold Farmer", 0, + new String[]{"Heroes of GWEN.GoldEarned"}, + new String[]{"Earn Gold"}, + new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}}, + new int[]{100000,500000,1000000,2500000,5000000}, + "I", + new String[] {"II","III","IV","V","X"}, + AchievementCategory.MOBA), + + MOBA_KILLS("Champion Slayer", 0, + new String[]{"Heroes of GWEN.Kills"}, + new String[]{"Kill players"}, + new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}}, + new int[]{100,250,500,1000,5000}, + "I", + new String[] {"II","III","IV","V","X"}, + AchievementCategory.MOBA), + + MOBA_WINS_ASSASSIN("Assassin Victor", 0, + new String[]{"Heroes of GWEN.Assassin.Wins"}, + new String[]{"Win Games as an Assassin"}, + new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}}, + new int[]{10,50,100,250,500}, + "I", + new String[] {"II","III","IV","V","X"}, + AchievementCategory.MOBA), + + MOBA_WINS_HUNTER("Hunter Victor", 0, + new String[]{"Heroes of GWEN.Hunter.Wins"}, + new String[]{"Win Games as a Hunter"}, + new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}}, + new int[]{10,50,100,250,500}, + "I", + new String[] {"II","III","IV","V","X"}, + AchievementCategory.MOBA), + + MOBA_WINS_MAGE("Mage Victor", 0, + new String[]{"Heroes of GWEN.Mage.Wins"}, + new String[]{"Win Games as a Mage"}, + new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}}, + new int[]{10,50,100,250,500}, + "I", + new String[] {"II","III","IV","V","X"}, + AchievementCategory.MOBA), + + MOBA_WINS_WARRIOR("Warrior Victor", 0, + new String[]{"Heroes of GWEN.Warrior.Wins"}, + new String[]{"Win Games as a Warrior"}, + new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}}, + new int[]{10,50,100,250,500}, + "I", + new String[] {"II","III","IV","V","X"}, + AchievementCategory.MOBA), + ; private String _name; private String[] _desc; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 885bf7939..fd7adbe9b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -43,7 +43,7 @@ public enum AchievementCategory StatDisplay.fromGame("Wins", GameDisplay.SkywarsTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SkywarsTeams, "Wins", "Losses"), StatDisplay.fromGame("Kills", GameDisplay.SkywarsTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SkywarsTeams, "Deaths"), StatDisplay.fromGame("Gems Earned", GameDisplay.SkywarsTeams, "GemsEarned") }, - Material.FEATHER, 0, GameCategory.SURVIVAL, "Destructor Kit", false, GameDisplay.Skywars.getGameId(), GameDisplay.SkywarsTeams.getGameId()), + Material.FEATHER, 0, GameCategory.SURVIVAL, "Earth Kit", false, GameDisplay.Skywars.getGameId(), GameDisplay.SkywarsTeams.getGameId()), UHC("Ultra Hardcore", null, new StatDisplay[] { @@ -220,7 +220,7 @@ public enum AchievementCategory Material.EMERALD, 0, GameCategory.SURVIVAL, null, false, GameDisplay.GemHunters.getGameId()), MOBA("Heroes of GWEN", null, - new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, StatDisplay.fromGame("Gold Earned", GameDisplay.MOBA, "GoldEarned")}, + new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, null, StatDisplay.fromGame("Gold Earned", GameDisplay.MOBA, "GoldEarned")}, Material.PRISMARINE_SHARD, 0, GameCategory.CLASSICS, null, false, GameDisplay.MOBA.getGameId()); private String _name; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java index 3915059e8..d68117cf7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java @@ -31,7 +31,7 @@ import mineplex.core.stats.StatsManager; public class AchievementPage extends ShopPageBase { - private static int ACHIEVEMENT_MIDDLE_INDEX = 31; + private static final int ACHIEVEMENT_MIDDLE_INDEX = 31; private AchievementCategory _category; private StatsManager _statsManager; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 97cdfe07c..e3a6df469 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -1,6 +1,5 @@ package mineplex.core.antihack; -import javax.xml.bind.DatatypeConverter; import java.util.Collections; import java.util.HashSet; import java.util.Map; @@ -10,11 +9,7 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; +import javax.xml.bind.DatatypeConverter; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -48,6 +43,7 @@ import com.mineplex.anticheat.checks.combat.KillauraTypeF; import com.mineplex.anticheat.checks.move.Glide; import com.mineplex.anticheat.checks.move.HeadRoll; import com.mineplex.anticheat.checks.move.Speed; +import com.mineplex.anticheat.checks.move.Timer; import com.mineplex.anticheat.checks.move.Toggle; import com.mineplex.anticheat.checks.player.BadPackets; @@ -76,6 +72,7 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.punish.Category; @@ -84,11 +81,16 @@ import mineplex.core.punish.PunishClient; import mineplex.core.punish.Punishment; import mineplex.core.punish.PunishmentResponse; import mineplex.serverdata.commands.ServerCommandManager; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; @ReflectivelyCreateMiniPlugin public class AntiHack extends MiniPlugin { - private static final Map, CheckThresholds> CHECKS = ImmutableMap., CheckThresholds>builder() + public static final Map, CheckThresholds> CHECKS = ImmutableMap., CheckThresholds>builder() .put(KillauraTypeA.class, new CheckThresholds("Kill Aura", 25, 45, 60)) .put(KillauraTypeB.class, new CheckThresholds("High CPS", 0, 0, Integer.MAX_VALUE)) .put(KillauraTypeC.class, new CheckThresholds("Reach", 25, Integer.MAX_VALUE, Integer.MAX_VALUE)) @@ -100,11 +102,12 @@ public class AntiHack extends MiniPlugin .put(Speed.class, new CheckThresholds("Speed", 1000, 2000, 3500)) .put(HeadRoll.class, new CheckThresholds("Illegal Movement", 0, 0, 1000)) .put(Toggle.class, new CheckThresholds("AutoSneak", 100, 200, 300)) + .put(Timer.class, new CheckThresholds("Timer", 1000, 2000, 3000)) .build(); private static final CheckThresholds NOOP_THRESHOLD = new CheckThresholds("Unknown", Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); - private static final Map, AntiHackAction> ACTIONS = ImmutableMap., AntiHackAction>builder() + public static final Map, AntiHackAction> ACTIONS = ImmutableMap., AntiHackAction>builder() .put(KillauraTypeA.class, new ImmediateBanAction(200)) .put(KillauraTypeD.class, new BanwaveAction(1500)) .put(KillauraTypeF.class, new BanwaveAction(600)) @@ -112,6 +115,7 @@ public class AntiHack extends MiniPlugin .put(Speed.class, new ImmediateBanAction(10000)) .put(HeadRoll.class, new ImmediateBanAction(2000)) .put(Toggle.class, new ImmediateBanAction(500)) + .put(Timer.class, new ImmediateBanAction(15000)) .put(BadPackets.class, new GEPBanAction(300)) .put(KillauraTypeB.class, new GEPBanAction(100)) .build(); @@ -158,7 +162,7 @@ public class AntiHack extends MiniPlugin require(GuardianManager.class); _banWaveManager = require(BanWaveManager.class); - Bukkit.getServicesManager().register(MineplexLink.class, new MineplexLinkImpl(), this._plugin, ServicePriority.Normal); + Bukkit.getServicesManager().register(MineplexLink.class, new MineplexLinkImpl(), _plugin, ServicePriority.Normal); ServerCommandManager.getInstance().registerCommandType(MajorViolationCommand.class, violation -> { @@ -167,9 +171,13 @@ public class AntiHack extends MiniPlugin for (Player player : Bukkit.getOnlinePlayers()) { if (_detailedMessages.contains(player.getName())) + { player.spigot().sendMessage(detailed); + } else if (_clientManager.Get(player).GetRank().has(Rank.HELPER) && (violation.getOriginatingServer().equals(_thisServer) || _preferences.get(player).isActive(Preference.GLOBAL_GWEN_REPORTS))) + { player.spigot().sendMessage(minimal); + } } }); @@ -222,12 +230,19 @@ public class AntiHack extends MiniPlugin { Consumer> doPunish = after -> { - runAsync(() -> - { - new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish(); - }); + runAsync(() -> + { + new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish(); + }); - _punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after); + _punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after); + if (UtilServer.getGroup().equals("Clans")) + { + _punish.getClansPunish().loadClient(coreClient.getUniqueId(), client -> + { + _punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, UtilTime.TimeUnit.DAYS, UtilTime.TimeUnit.MILLISECONDS), ChatColor.stripColor(finalMessage).replace("\n", ""), null, ban -> {}); + }); + } }; if (coreClient.GetRank().has(Rank.TWITCH)) @@ -241,17 +256,18 @@ public class AntiHack extends MiniPlugin else { runBanAnimation(player, () -> - doPunish.accept(result -> + { + doPunish.accept(result -> + { + if (result == PunishmentResponse.Punished) { - if (result == PunishmentResponse.Punished) - { - announceBan(player); - _banned.add(player.getUniqueId()); - _banWaveManager.flagDone(coreClient); - } - _pendingBan.remove(player); - }) - ); + announceBan(player); + _banned.add(player.getUniqueId()); + _banWaveManager.flagDone(coreClient); + } + _pendingBan.remove(player); + }); + }); } }, custom); } @@ -266,14 +282,21 @@ public class AntiHack extends MiniPlugin Consumer> doPunish = after -> { - _punish.AddPunishment(coreClient.getName(), Category.Hacking, info.getMessage(), AntiHack.NAME, 3, true, getHoursBanned(player), true, after); + final int hoursBanned = getHoursBanned(player); + _punish.AddPunishment(coreClient.getName(), Category.Hacking, info.getMessage(), AntiHack.NAME, 3, true, hoursBanned, true, after); + String[] serverSplit = info.getServer().split("-"); + if (serverSplit.length > 0 && serverSplit[0].equals("Clans")) + { + _punish.getClansPunish().loadClient(coreClient.getUniqueId(), client -> + { + _punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, UtilTime.TimeUnit.DAYS, UtilTime.TimeUnit.MILLISECONDS), ChatColor.stripColor(info.getMessage()).replace("\n", ""), null, ban -> {}); + }); + } }; if (coreClient.GetRank().has(Rank.TWITCH)) { - doPunish.accept(response -> - { - }); + doPunish.accept(response -> {}); } else { @@ -332,14 +355,18 @@ public class AntiHack extends MiniPlugin public void on(EntityDamageEvent event) { if (_pendingBan.contains(event.getEntity())) + { event.setCancelled(true); + } } @EventHandler(priority = EventPriority.LOWEST) public void on(EntityDamageByEntityEvent event) { if (_pendingBan.contains(event.getDamager())) + { event.setCancelled(true); + } } public int getPunishments(Player player) @@ -414,7 +441,9 @@ public class AntiHack extends MiniPlugin } if (_ignoredChecks.contains(event.getCheckClass())) + { return; + } ACTIONS.getOrDefault(event.getCheckClass(), NOOP_ACTION).handle(event); @@ -434,7 +463,7 @@ public class AntiHack extends MiniPlugin MajorViolationCommand command = new MajorViolationCommand(_thisServer, event.getPlayer().getName(), CheckManager.getCheckSimpleName(event.getCheckClass()), event.getViolations(), event.getMessage()); ServerCommandManager.getInstance().publishCommand(command); - this._cooldown.put(key, event.getViolations()); + _cooldown.put(key, event.getViolations()); } } @@ -525,6 +554,6 @@ public class AntiHack extends MiniPlugin public void setStrict(boolean strict) { - this._strict = strict; + _strict = strict; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java index 2c471cd07..d9ff6e428 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java @@ -116,4 +116,4 @@ public class BanWaveInfo { return Objects.hash(_accountId, _timeToBan, _hackType, _message, _vl, _server); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java index 7123a383c..9c56787e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java @@ -62,7 +62,7 @@ public class BanWaveManager extends MiniPlugin CoreClient client = _clientManager.Get(player); - if (this._repository.insertBanWaveInfo(client.getAccountId(), timeToBan, CheckManager.getCheckSimpleName(checkClass), newMessage, vl, server)) + if (_repository.insertBanWaveInfo(client.getAccountId(), timeToBan, CheckManager.getCheckSimpleName(checkClass), newMessage, vl, server)) { runAsync(() -> { @@ -81,4 +81,4 @@ public class BanWaveManager extends MiniPlugin { _repository.flagDone(client.getAccountId()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatDatabase.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatDatabase.java index 087b68d3c..721abb330 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatDatabase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatDatabase.java @@ -5,7 +5,6 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import mineplex.core.common.util.UtilTasks; -import mineplex.core.database.MinecraftRepository; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; @@ -45,4 +44,4 @@ public class AnticheatDatabase extends RepositoryBase } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatMetadata.java index dc015a66a..9ae46926e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatMetadata.java @@ -20,4 +20,4 @@ public abstract class AnticheatMetadata implements Listener public abstract JsonElement build(UUID player); public abstract void remove(UUID player); -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PartyInfoMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PartyInfoMetadata.java index 5b56687d8..6d0be3f48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PartyInfoMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PartyInfoMetadata.java @@ -28,7 +28,12 @@ public class PartyInfoMetadata extends AnticheatMetadata @Override public JsonElement build(UUID player) { - Party party = require(PartyManager.class).getPartyByPlayer(player); + PartyManager pm = require(PartyManager.class); + if (pm == null) + { + return JsonNull.INSTANCE; + } + Party party = pm.getPartyByPlayer(player); if (party != null) { JsonObject partyData = new JsonObject(); @@ -52,4 +57,4 @@ public class PartyInfoMetadata extends AnticheatMetadata { } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java index 479db70d2..509561a76 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java @@ -48,4 +48,4 @@ public class PlayerInfoMetadata extends AnticheatMetadata { } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java index 7376a6d3e..2b838a9cc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java @@ -35,4 +35,4 @@ public class ServerInfoMetadata extends AnticheatMetadata { } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ViolationInfoMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ViolationInfoMetadata.java index da2ee4278..69685a46c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ViolationInfoMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ViolationInfoMetadata.java @@ -9,6 +9,7 @@ import java.util.UUID; import net.minecraft.server.v1_8_R3.MinecraftServer; import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; @@ -49,6 +50,8 @@ public class ViolationInfoMetadata extends AnticheatMetadata private static final String KEY_Z = "z"; private static final String KEY_YAW = "yaw"; private static final String KEY_PITCH = "pitch"; + private static final String KEY_PING = "ping"; + private static final String KEY_SERVER_TPS = "server-tps"; private static final JsonObject VAL_CHECK_DISABLED; @@ -143,12 +146,14 @@ public class ViolationInfoMetadata extends AnticheatMetadata location.addProperty(KEY_PITCH, MUTABLE_LOCATION.getPitch()); playerInfo.add(KEY_LOCATION, location); + playerInfo.addProperty(KEY_PING, Math.min(((CraftPlayer) event.getPlayer()).getHandle().ping, 1000)); JsonObject data = new JsonObject(); data.add(KEY_CURRENT_TIME, currentTime); data.add(KEY_VIOLATION_INFO, violationInfo); data.add(KEY_PLAYER_INFO, playerInfo); + data.addProperty(KEY_SERVER_TPS, MinecraftServer.getServer().recentTps[0]); violations.add(data); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 2bdd967f5..ef84b512f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -149,7 +149,6 @@ public class BonusManager extends MiniClientPlugin implements I private int _visualTick; private ArrayList _voteList; - private List> _youtubers; private String _creeperName; @@ -182,18 +181,8 @@ public class BonusManager extends MiniClientPlugin implements I { _voteList.add("http://vote1.mineplex.com"); _voteList.add("http://vote2.mineplex.com"); - _voteList.add("http://vote3.mineplex.com"); } - _youtubers = new ArrayList<>(); - if (!ClansBonus) - { - _youtubers.add(Pair.create("Sigils", "https://www.youtube.com/user/SigilsPlaysGames?sub_confirmation=1")); - _youtubers.add(Pair.create("SallyGreenGamer", "https://www.youtube.com/channel/UCt8eypdLUND5CBvgXzEZrxw?sub_confirmation=1")); - _youtubers.add(Pair.create("RustyDawgT", "https://www.youtube.com/user/RustyDawgT?sub_confirmation=1")); - } - _youtubers.add(Pair.create("SamitoD", "https://www.youtube.com/user/SamitoD?sub_confirmation=1")); - _creeperName = "Carl"; updateOffSet(); @@ -240,18 +229,8 @@ public class BonusManager extends MiniClientPlugin implements I { _voteList.add("http://vote1.mineplex.com"); _voteList.add("http://vote2.mineplex.com"); - _voteList.add("http://vote3.mineplex.com"); } _canVote = true; - - _youtubers = new ArrayList<>(); - if (!ClansBonus) - { - _youtubers.add(Pair.create("Sigils", "https://www.youtube.com/user/SigilsPlaysGames?sub_confirmation=1")); - _youtubers.add(Pair.create("SallyGreenGamer", "https://www.youtube.com/channel/UCt8eypdLUND5CBvgXzEZrxw?sub_confirmation=1")); - _youtubers.add(Pair.create("RustyDawgT", "https://www.youtube.com/user/RustyDawgT?sub_confirmation=1")); - } - _youtubers.add(Pair.create("SamitoD", "https://www.youtube.com/user/SamitoD?sub_confirmation=1")); if (npcManager != null) { @@ -1005,7 +984,6 @@ public class BonusManager extends MiniClientPlugin implements I if (canVote(player)) availableRewards++; if (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) availableRewards++; if (_youtubeManager.canYoutube(player)) availableRewards++; - if (_youtubeManager.canSpecificYoutube(player)) availableRewards++; if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++; if (canDaily(player)) availableRewards++; if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++; @@ -1165,7 +1143,7 @@ public class BonusManager extends MiniClientPlugin implements I { if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false)) { - if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.canSpecificYoutube(player) || _youtubeManager.canYoutube(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) + if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.canYoutube(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) { if (_showCarl.containsKey(player.getName())) { @@ -1186,23 +1164,6 @@ public class BonusManager extends MiniClientPlugin implements I int index = date % _voteList.size(); return _voteList.get(index); } - - public Pair getSpecificCreator() - { - long sqlTime = getSqlTime(); - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(sqlTime); - int date = calendar.get(Calendar.DAY_OF_YEAR); - if (_youtubers.size() >= 1) - { - int index = date % _youtubers.size(); - return _youtubers.get(index); - } - else - { - return Pair.create("MineplexGames", "http://youtube.com/mineplexgamesofficial?sub_confirmation=1"); - } - } /** * Used for disabling rank rewards during first month of release diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java index ea4c1a099..413816698 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java @@ -12,7 +12,6 @@ import mineplex.core.bonuses.gui.buttons.PlayWireButton; import mineplex.core.bonuses.gui.buttons.PollButton; import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton; import mineplex.core.bonuses.gui.buttons.RankBonusButton; -import mineplex.core.bonuses.gui.buttons.SpecificChannelButton; import mineplex.core.bonuses.gui.buttons.TwitterButton; import mineplex.core.bonuses.gui.buttons.VoteButton; import mineplex.core.bonuses.gui.buttons.YoutubeButton; @@ -33,10 +32,9 @@ public class BonusGui extends SimpleGui private final int CLAIM_TIPS_SLOT = 30; private final int POWER_PLAY_SLOT = 16; private final int CARL_SPINNER_SLOT = 14; - private final int YOUTUBE_SLOT = 22; + private final int YOUTUBE_SLOT = 24; private final int TWITTER_SLOT = 34; private final int PLAY_WIRE_SLOT = 32; - private final int SPECIFIC_YOUTUBE_SLOT = 24; private static final int INV_SIZE = 54; @@ -65,8 +63,6 @@ public class BonusGui extends SimpleGui setItem(CARL_SPINNER_SLOT, new CarlSpinButton(getPlugin(), player, manager, rewardManager)); setItem(PLAY_WIRE_SLOT, new PlayWireButton(playWireManager, player)); - - setItem(SPECIFIC_YOUTUBE_SLOT, new SpecificChannelButton(player, youtubeManager)); } @Override @@ -74,4 +70,4 @@ public class BonusGui extends SimpleGui { super.finalize(); } -} \ No newline at end of file +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/SpecificChannelButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/SpecificChannelButton.java index 1edafc35d..f04a6f2b3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/SpecificChannelButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/SpecificChannelButton.java @@ -34,7 +34,7 @@ public class SpecificChannelButton implements GuiItem @Override public void setup() { - _channel = Managers.get(BonusManager.class).getSpecificCreator(); + _channel = Pair.create("", ""); if (_youtubeManager.canSpecificYoutube(_player)) { _item = new ItemBuilder(Material.APPLE) @@ -111,4 +111,4 @@ public class SpecificChannelButton implements GuiItem { return _item; } -} \ No newline at end of file +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index 63087f2f9..3949ff3fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -377,7 +377,25 @@ public class Chat extends MiniPlugin } if (!event.isCancelled()) + { + String oldMessage = event.getMessage(); + if (!_clientManager.Get(sender).GetRank().has(Rank.ADMIN)) + { + int capsCount = 0; + for (char c : oldMessage.toCharArray()) + { + if (Character.isUpperCase(c)) + { + capsCount++; + } + } + if (capsCount > 30) + { + event.setMessage(oldMessage.toLowerCase()); + } + } _playerLastMessage.put(sender.getUniqueId(), new MessageData(event.getMessage())); + } for (Function filter : _lowPriorityFilters) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java index 02709a26f..264fe539f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java @@ -63,7 +63,7 @@ public abstract class CommandBase implements ICom public void setRequiredRank(Rank rank) { - this._requiredRank = rank; + _requiredRank = rank; } public Rank[] GetSpecificRanks() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java index d1ae7b491..7cb686de7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java @@ -1,5 +1,6 @@ package mineplex.core.cosmetic; +import mineplex.core.punish.Punish; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -41,19 +42,23 @@ import mineplex.core.twofactor.TwoFactorAuth; public class CosmeticManager extends MiniPlugin { private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class); - private InventoryManager _inventoryManager; - private GadgetManager _gadgetManager; - private MountManager _mountManager; - private PetManager _petManager; - private TreasureManager _treasureManager; - private BoosterManager _boosterManager; + private final InventoryManager _inventoryManager; + private final GadgetManager _gadgetManager; + private final MountManager _mountManager; + private final PetManager _petManager; + private final TreasureManager _treasureManager; + private final BoosterManager _boosterManager; + private final Punish _punish; private CosmeticShop _shop; private boolean _showInterface = true; private int _interfaceSlot = 4; - public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager, TreasureManager treasureManager, BoosterManager boosterManager) + public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, + InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, + PetManager petManager, TreasureManager treasureManager, BoosterManager boosterManager, + Punish punish) { super("Cosmetic Manager", plugin); @@ -63,6 +68,7 @@ public class CosmeticManager extends MiniPlugin _petManager = petManager; _treasureManager = treasureManager; _boosterManager = boosterManager; + _punish = punish; _shop = new CosmeticShop(this, clientManager, donationManager, _moduleName); } @@ -242,6 +248,11 @@ public class CosmeticManager extends MiniPlugin { return _boosterManager; } + + public Punish getPunishManager() + { + return _punish; + } public void displayUI(Player player) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java new file mode 100644 index 000000000..d54ad3b10 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java @@ -0,0 +1,25 @@ +package mineplex.core.cosmetic.ui.button.open; + +import mineplex.core.cosmetic.ui.page.FlagPage; +import mineplex.core.cosmetic.ui.page.HatPage; +import mineplex.core.cosmetic.ui.page.Menu; +import mineplex.core.gadget.types.Gadget; +import org.bukkit.entity.Player; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class OpenFlags extends OpenPageButton +{ + public OpenFlags(Menu menu, Gadget active) + { + super(menu, active); + } + + @Override + protected void leftClick(Player player) + { + getMenu().getShop().openPageForPlayer(player, new FlagPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(), "Flags - 1", player)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java index 80db4bcd6..e4d1333f9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java @@ -33,12 +33,16 @@ public class ArrowTrailPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.ARROW_TRAIL) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - if (slot == 17) - slot += 2; + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java index fd0b3cf08..3208e5a05 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java @@ -32,12 +32,16 @@ public class BalloonsPage extends GadgetPage addGadget(gadget, slot); if (gadget.isActive(getPlayer())) + { addGlow(slot); + } slot++; - if (slot == 17 || slot == 26) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java index 73af59a89..c1a606358 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java @@ -22,9 +22,6 @@ import mineplex.core.gadget.types.OutfitGadget; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -/** - * Created by shaun on 14-09-15. - */ public class CostumePage extends GadgetPage { public CostumePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java index 07dbee136..a54b7f840 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java @@ -33,12 +33,16 @@ public class DeathEffectPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.DEATH) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - if (slot == 17) - slot += 2; + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java index f9748cb06..8ecddc541 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java @@ -33,12 +33,16 @@ public class DoubleJumpPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.DOUBLE_JUMP) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 17) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java new file mode 100644 index 000000000..34009c2b7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java @@ -0,0 +1,106 @@ +package mineplex.core.cosmetic.ui.page; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import java.util.List; + +public class FlagPage extends GadgetPage +{ + private int _page; + + public FlagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, + Player player) + { + this(plugin, shop, clientManager, donationManager, name, player, 0); + } + + public FlagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, + Player player, int page) + { + super(plugin, shop, clientManager, donationManager, name, player, false); + _page = page; + buildPage(); + } + + @Override + protected void buildPage() + { + // chose a beginning slot + int slot = 10; + + // grab all flags + List list = getPlugin().getGadgetManager().getGadgets(GadgetType.FLAG); + + if(list != null) + { + int size = list.size(); + int limit = (_page + 1) * 28; + + // loop through the flags for a specific page + for (int i = _page * 28; i < limit && i < size; ++i) + { + Gadget gadget = list.get(i); + + addGadget(gadget, slot); + + if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.FLAG) == gadget) + { + addGlow(slot); + } + + slot++; + + if (slot % 9 == 8) + { + slot += 2; + } + } + + // back arrow + if (size > 28) + { + if (_page > 0) + { + addButton(45, new ShopItem(Material.ARROW, C.cGreen + "◀ Previous Page (" + C.cWhite + _page + C.cGreen + ")", new String[]{}, 1, false), + (player, clickType) -> + { + FlagPage page = new FlagPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Flags - " + (_page), player, _page - 1); + getShop().openPageForPlayer(player, page); + }); + } + + // next arrow + if (_page < (size - 1) / 28) + { + addButton(53, new ShopItem(Material.ARROW, C.cGreen + "(" + C.cWhite + (_page + 2) + C.cGreen + ") Next Page ►", new String[]{}, 1, false), + (player, clickType) -> + { + FlagPage page = new FlagPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Flags - " + (_page + 2), player, _page + 1); + getShop().openPageForPlayer(player, page); + + + }); + } + } + } + + addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + { + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index 657d98b30..913844276 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -12,7 +12,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.account.CoreClientManager; @@ -21,7 +20,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.GadgetButton; @@ -42,10 +40,18 @@ import mineplex.core.shop.page.ShopPageBase; public class GadgetPage extends ShopPageBase { public GadgetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) + { + this(plugin, shop, clientManager, donationManager, name, player, true); + } + + public GadgetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, boolean build) { super(plugin, shop, clientManager, donationManager, name, player, 54); - buildPage(); + if (build) + { + buildPage(); + } } protected void buildPage() @@ -60,12 +66,16 @@ public class GadgetPage extends ShopPageBase addGadget(gadget, slot); if (getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.getDisplayName()) > 0) + { addGlow(slot); + } slot++; - if (slot == 17 || slot == 26) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() @@ -366,19 +376,6 @@ public class GadgetPage extends ShopPageBase meta.setLore(itemLore); gadgetItemStack.setItemMeta(meta); - if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH - || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) - { - if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) - { - gadgetItemStack = CountryFlag.USA.getBanner(); - BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta(); - bannerMeta.setDisplayName(C.cGreen + C.Bold + gadget.getName()); - bannerMeta.setLore(meta.getLore()); - gadgetItemStack.setItemMeta(bannerMeta); - } - } - addButton(slot, new ShopItem(gadgetItemStack, false, false).hideInfo(), new DeactivateGadgetButton(gadget, this)); } else @@ -389,19 +386,6 @@ public class GadgetPage extends ShopPageBase meta.setLore(itemLore); gadgetItemStack.setItemMeta(meta); - if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH - || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) - { - if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) - { - gadgetItemStack = CountryFlag.USA.getBanner(); - BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta(); - bannerMeta.setDisplayName(C.cGreen + C.Bold + gadget.getName()); - bannerMeta.setLore(meta.getLore()); - gadgetItemStack.setItemMeta(bannerMeta); - } - } - /*if (gadget instanceof MorphStray) { gadgetItemStack = UtilItem.getVersionSpecificItem(_player, UtilPlayer.PlayerVersion._1_9, gadgetItemStack); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java index 37f472616..a21f31cea 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java @@ -38,12 +38,16 @@ public class HatPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.HAT) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 17) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java index 26b399783..6ce7f5ebd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java @@ -31,12 +31,16 @@ public class KitSelectorPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.KIT_SELECTOR) == gadget) + { addGlow(slot); + } slot++; - if (slot == 17 || slot == 26 || slot == 35) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 8a27df36e..ab57f6835 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -5,6 +5,9 @@ import java.util.EnumMap; import java.util.List; import java.util.Map; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.cosmetic.ui.button.open.OpenFlags; +import mineplex.core.itemstack.ItemBuilder; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -14,7 +17,6 @@ import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilUI; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.open.OpenArrowTrails; @@ -40,6 +42,9 @@ import mineplex.core.mount.Mount; import mineplex.core.pet.PetType; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; public class Menu extends ShopPageBase { @@ -64,35 +69,46 @@ public class Menu extends ShopPageBase List shardLore = new ArrayList(); shardLore.add(" "); - shardLore.add(C.cGray + "This seems like it might come in"); - shardLore.add(C.cGray + "handy. Maybe I can collect more!"); + shardLore.add(C.cGray + "These seem like they might come in"); + shardLore.add(C.cGray + "handy. Maybe I should collect more!"); ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false); - // Cosmetic Items - int[] slots = UtilUI.getIndicesFor(15, 0, 5, 1); - /*int particleSlot = 9;//slots[0]; - int arrowSlot = 11;//slots[1]; - int jumpSlot = 13;//slots[2]; - int deathSlot = 15;//slots[3]; - int gadgetSlot = 27;//slots[4]; - int morphSlot = 29;//slots[5]; - int mountSlot = 31;//slots[6]; - int petSlot = 33;//slots[7]; - int hatSlot = 35;//slots[8]; - int costumeSlot = 45;//slots[9]; - int musicSlot = 47;//slots[10]; - int tauntSlot = 49;//slots[11]; - int winEffectSlot = 51; - int gameModifierSlot = 53;*/ - int particleSlot = slots[0], arrowSlot = slots[1], jumpSlot = slots[2], - deathSlot = slots[3], gadgetSlot = slots[4], morphSlot = slots[5], - mountSlot = slots[6], petSlot = slots[7], hatSlot = slots[8], - costumeSlot = slots[9], musicSlot = slots[10], tauntSlot = slots[11], - winEffectSlot = slots[12], gameModifierSlot = slots[13], balloonsSlot = slots[14], - kitSelectorSlot = balloonsSlot + 4; + int deathSlot = 19; + int jumpSlot = 28; + int particleSlot = 1; + int winEffectSlot = 13; + int shardSlot = 22; + int arrowSlot = 10; + int tauntSlot = 31; + int gameModifierSlot = 21; + int kitSelectorSlot = 23; + int musicSlot = 48; + int mountSlot = 50; + int balloonsSlot = 47; + int petSlot = 51; + int gadgetSlot = 49; + int hatSlot = 7; + int flagSlot = 34; + int morphSlot = 25; + int costumeSlot = 16; + + addItem(shardSlot, shards); + + ItemStack pane = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((byte)15).setTitle(C.cBlack).build(); + for (int i = 0; i <= 45; i += 9) addItem(i, pane.clone()); + for (int i = 8; i <= 53; i += 9) addItem(i, pane.clone()); + for (int i = 37; i <= 43; ++i) addItem(i, pane.clone()); + for (int i = 2; i <= 6; ++i) addItem(i, pane.clone()); + for (int i = 11; i <= 29; i += 9) addItem(i, pane.clone()); + for (int i = 15; i <= 33; i += 9) addItem(i, pane.clone()); + addItem(12, pane.clone()); + addItem(14, pane.clone()); + addItem(30, pane.clone()); + addItem(32, pane.clone()); + addItem(46, pane.clone()); + addItem(52, pane.clone()); - addItem(kitSelectorSlot + 2, shards); EnumMap ownedCount = new EnumMap<>(GadgetType.class); EnumMap maxCount = new EnumMap<>(GadgetType.class); @@ -187,13 +203,13 @@ public class Menu extends ShopPageBase if (petActive != null) addGlow(petSlot); type = GadgetType.HAT; - lore = getLore(ownedCount.get(type), maxCount.get(type), "Hats are in this year. Wear them on your head to impress the ladies.", VISIBILITY_HUB, enabled.get(type)); + lore = getLore(ownedCount.get(type), maxCount.get(type), "Hats are in this year. Wear them on your head to impress the others.", VISIBILITY_HUB, enabled.get(type)); addButton(hatSlot, new ShopItem(Material.GOLD_HELMET, "Hats", lore, 1, false), new OpenHats(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(hatSlot); type = GadgetType.COSTUME; // -4 Fixes more than the real costumes being counted (Happens because of the hub games costumes - lore = getLore(ownedCount.get(type) - 4, maxCount.get(type) - 4, "Sometimes going out calls for special clothes! Gain bonus effects for matching outfit.", VISIBILITY_HUB, enabled.get(type)); + lore = getLore(ownedCount.get(type), maxCount.get(type) - 4, "Sometimes going out calls for special clothes! Gain bonus effects for matching outfit.", VISIBILITY_HUB, enabled.get(type)); addButton(costumeSlot, new ShopItem(Material.DIAMOND_CHESTPLATE, "Costumes", lore, 1, false), new OpenCostumes(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(costumeSlot); @@ -227,6 +243,19 @@ public class Menu extends ShopPageBase lore = getLore(ownedCount.get(type), maxCount.get(type), "Click here to select different particles to indicate which kit you have selected!", VISIBILITY_GAME_HUB, enabled.get(type)); addButton(kitSelectorSlot, new ShopItem(Material.LEVER, "Kit Selector Particles", lore, 1, false), new OpenKitSelector(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(kitSelectorSlot); + + type = GadgetType.FLAG; + lore = getLore(ownedCount.get(type), maxCount.get(type), "Show off your country's flag!", VISIBILITY_HUB, enabled.get(type)); + addButton(flagSlot, new ShopItem(Material.BANNER, "Flags", lore, 1, false), new OpenFlags(this, enabled.get(type))); + if (enabled.containsKey(type)) addGlow(flagSlot); + + // Copy over banner design + BannerMeta banner = (BannerMeta) CountryFlag.MINEPLEX.getBanner().getItemMeta(); + BannerMeta meta = ((BannerMeta) getItem(flagSlot).getItemMeta()); + meta.setBaseColor(banner.getBaseColor()); + meta.setPatterns(banner.getPatterns()); + meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); + getItem(flagSlot).setItemMeta(meta); } private String[] getLore(int ownedCount, int maxCount, String info, String visibility, Gadget enabled) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java index 682140891..0689b3f07 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java @@ -32,13 +32,19 @@ public class MorphPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.MORPH) == gadget) - if (!(gadget instanceof MorphBlock)) - addGlow(slot); + { + if (!(gadget instanceof MorphBlock)) + { + addGlow(slot); + } + } slot++; - if (slot == 17 || slot == 26 || slot == 35) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java index 6e670effc..0c2b2cd60 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java @@ -46,8 +46,10 @@ public class MountPage extends ShopPageBase addMount(mount, slot); slot++; - if (slot == 17 || slot == 26) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java index 54ff244d7..49fa65cf7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java @@ -14,9 +14,6 @@ import mineplex.core.gadget.types.GadgetType; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.item.IButton; -/** - * Created by shaun on 14-09-15. - */ public class MusicPage extends GadgetPage { public MusicPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) @@ -34,8 +31,10 @@ public class MusicPage extends GadgetPage slot++; - if (slot == 17) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java index a488c922c..168741d0a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java @@ -31,12 +31,16 @@ public class ParticlePage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.PARTICLE) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 17 || slot == 26 || slot == 35) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index e7bf684cb..264f73dbe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java @@ -231,16 +231,23 @@ public class PetPage extends ShopPageBase slot++; - if (slot == 17 || slot == 26) + if (slot % 9 == 8) + { slot += 2; + } } slot = 49; for (PetExtra petExtra : PetExtra.values()) { List itemLore = new ArrayList(); - - if (!getPlugin().getPetManager().hasActivePet(getPlayer().getName())) + + if (getPlugin().getPunishManager().GetClient(_player.getName()).IsMuted()) + { + itemLore.add(C.cRed + "You may not rename pets while muted!"); + getInventory().setItem(slot, new ShopItem(petExtra.getMaterial(), (byte)0, C.cRed + petExtra.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); + } + else if (!getPlugin().getPetManager().hasActivePet(getPlayer().getName())) { itemLore.add(C.cWhite + "You must have an active pet to use this!"); getInventory().setItem(slot, new ShopItem(petExtra.getMaterial(), (byte)0, C.cRed + petExtra.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java index 687516e0f..63ef90b24 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java @@ -38,12 +38,16 @@ public class TauntPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.TAUNT) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 26) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java index cc116cbac..e66674be4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java @@ -49,12 +49,16 @@ public class WinEffectPage extends GadgetPage } if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.WIN_EFFECT) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 17 || slot == 26) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java index 774ecf2d0..2350f8eba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java @@ -1,9 +1,14 @@ package mineplex.core.cosmetic.ui.page.custompet.name; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilItem; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.punish.PunishClient; import net.minecraft.server.v1_8_R3.ItemStack; import net.minecraft.server.v1_8_R3.Items; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; @@ -34,6 +39,7 @@ public class CustomPetTagPage extends ShopPageBase } argHandle.add(arg); } + + else if (arg.equalsIgnoreCase("wither")) + { + for (Entity ent : entSet) + { + if (ent instanceof Skeleton) + { + ((Skeleton) ent).setSkeletonType(SkeletonType.WITHER); + } + } + + argHandle.add(arg); + } } for (String arg : argHandle) argSet.remove(arg); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 89c28093f..59783273d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -228,6 +228,9 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler if (!spawnedIn) { refreshTrackers(disguise.getEntity().getBukkitEntity()); + } else + { + disguise.markSpawnedIn(); } disguise.onDisguise(true); @@ -360,6 +363,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler final Packet packet = packetInfo.getPacket(); final Player owner = packetInfo.getPlayer(); final PacketVerifier packetVerifier = packetInfo.getVerifier(); + final int protocol = ((CraftPlayer) owner).getHandle().getProtocol(); if (packet instanceof PacketPlayOutPlayerInfo) { @@ -406,7 +410,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler { packetInfo.setCancelled(true); - handleSpawnPackets(packetInfo.getVerifier(), latestDisguise); + handleSpawnPackets(packetInfo.getVerifier(), latestDisguise, protocol); } else if (latestDisguise.isHideIfNotDisguised()) { @@ -436,7 +440,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler if (latestDisguise != null && containsSpawnDisguise(owner, latestDisguise) && owner.getEntityId() != entityId) { packetInfo.setCancelled(true); - handlePacket(latestDisguise.getMetadataPacket(), packetVerifier); + handlePacket(latestDisguise.modifyMetaPacket(protocol, latestDisguise.getMetadataPacket()), packetVerifier); } } else if (packet instanceof PacketPlayOutEntityEquipment) @@ -475,7 +479,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler _handlingPacket = false; } - private void handleSpawnPackets(PacketVerifier packetVerifier, DisguiseBase disguise) + private void handleSpawnPackets(PacketVerifier packetVerifier, DisguiseBase disguise, int protocol) { if (disguise instanceof DisguisePlayer) { @@ -493,14 +497,14 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler handlePacket(infoPacket, packetVerifier); } - handlePacket(pDisguise.getSpawnPacket(), packetVerifier); + handlePacket(pDisguise.modifySpawnPacket(protocol, pDisguise.getSpawnPacket()), packetVerifier); for (Packet packet : pDisguise.getEquipmentPackets()) { handlePacket(packet, packetVerifier); } - handlePacket(pDisguise.getMetadataPacket(), packetVerifier); + handlePacket(pDisguise.modifyMetaPacket(protocol, pDisguise.getMetadataPacket()), packetVerifier); if (pDisguise.getSleepingDirection() != null) { @@ -556,7 +560,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler } else { - handlePacket(disguise.getSpawnPacket(), packetVerifier); + handlePacket(disguise.modifySpawnPacket(protocol, disguise.getSpawnPacket()), packetVerifier); if (disguise instanceof DisguiseLiving) { @@ -644,10 +648,12 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler { if (tester.test(player)) { - if (disguise.getEntity() == ((CraftPlayer) player).getHandle()) + EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle(); + if (disguise.getEntity() == nmsPlayer) continue; - UtilPlayer.sendPacket(player, disguise.getMetadataPacket()); + int protocol = nmsPlayer.getProtocol(); + UtilPlayer.sendPacket(player, disguise.modifyMetaPacket(protocol, disguise.getMetadataPacket())); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java index 2d0334abc..e6e02767b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java @@ -1,26 +1,21 @@ package mineplex.core.disguise.disguises; -import mineplex.core.common.DummyEntity; -import mineplex.core.common.util.UtilPlayer; -import net.minecraft.server.v1_8_R3.DataWatcher; -import net.minecraft.server.v1_8_R3.Entity; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.EntityTrackerEntry; -import net.minecraft.server.v1_8_R3.IntHashMap; -import net.minecraft.server.v1_8_R3.MinecraftServer; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import net.minecraft.server.v1_8_R3.WorldServer; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.CreatureSpawnEvent; - import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.function.Predicate; +import java.util.function.Supplier; + +import net.minecraft.server.v1_8_R3.*; + +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.CreatureSpawnEvent; + +import mineplex.core.common.DummyEntity; +import mineplex.core.common.util.UtilPlayer; public abstract class DisguiseBase { @@ -37,6 +32,8 @@ public abstract class DisguiseBase */ private boolean _hideIfNotDisguised = false; + protected boolean _spawnedIn = false; + public DisguiseBase(EntityType entityType, org.bukkit.entity.Entity entity) { if (entity == null) @@ -72,15 +69,7 @@ public abstract class DisguiseBase DataWatcher.watch(1, getEntity().getDataWatcher().getShort(1), net.minecraft.server.v1_8_R3.Entity.META_AIR, (int) getEntity().getDataWatcher().getShort(1)); } - public abstract Packet getSpawnPacket(); - - public Packet getMetadataPacket() - { - UpdateDataWatcher(); - return new PacketPlayOutEntityMetadata(getEntity().getId(), DataWatcher, true); - } - - public void resendMetadata() + protected void sendToWatchers(Predicate protocolPredicate, Supplier supplier) { if (getEntity() == null || !getEntity().getBukkitEntity().isValid() || !(getEntity().world instanceof WorldServer)) return; @@ -90,14 +79,57 @@ public abstract class DisguiseBase if (tracker.get(getEntity().getId()) == null) return; - Packet packet = getMetadataPacket(); + Packet packet = supplier.get(); + if (packet == null) + return; for (EntityPlayer player : tracker.get(getEntity().getId()).trackedPlayers) { - UtilPlayer.sendPacket(player.getBukkitEntity(), packet); + int protocol = player.getProtocol(); + if (!protocolPredicate.test(protocol)) + continue; + + if (packet instanceof PacketPlayOutEntityMetadata) + { + player.playerConnection.sendPacket(modifyMetaPacket(protocol, packet)); + } else if (packet instanceof PacketPlayOutSpawnEntityLiving) + { + player.playerConnection.sendPacket(modifySpawnPacket(protocol, packet)); + } else + { + player.playerConnection.sendPacket(packet); + } } } + protected void sendToWatchers(Supplier supplier) + { + sendToWatchers(x -> true, supplier); + } + + public abstract Packet getSpawnPacket(); + + public Packet modifySpawnPacket(int protocol, Packet packet) + { + return packet; + } + + public Packet getMetadataPacket() + { + UpdateDataWatcher(); + return new PacketPlayOutEntityMetadata(getEntity().getId(), DataWatcher, true); + } + + public void resendMetadata() + { + sendToWatchers(this::getMetadataPacket); + } + + public Packet modifyMetaPacket(int protocol, Packet packet) + { + return packet; + } + public void setSoundDisguise(DisguiseBase soundDisguise) { _soundDisguise = soundDisguise; @@ -182,6 +214,11 @@ public abstract class DisguiseBase } + public void markSpawnedIn() + { + _spawnedIn = true; + } + public void setHideIfNotDisguised(boolean hideIfNotDisguised) { this._hideIfNotDisguised = hideIfNotDisguised; @@ -197,7 +234,7 @@ public abstract class DisguiseBase return this._disguiseType; } - public void setEntity(net.minecraft.server.v1_8_R3.Entity entity) + public void setEntity(Entity entity) { _entity.clear(); _entity = new WeakReference<>(entity); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java index d477ab3bc..290d321f1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java @@ -1,9 +1,16 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.MathHelper; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; -import org.bukkit.entity.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import com.mineplex.MetadataRewriter; +import com.mineplex.ProtocolVersion; + +import net.minecraft.server.v1_8_R3.*; +import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; + +import org.bukkit.entity.EntityType; public abstract class DisguiseCreature extends DisguiseInsentient { @@ -18,9 +25,9 @@ public abstract class DisguiseCreature extends DisguiseInsentient PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); packet.a = getEntity().getId(); packet.b = (byte) getDisguiseType().getTypeId(); - packet.c = (int) MathHelper.floor(getEntity().locX*32D); - packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D); - packet.e = (int) MathHelper.floor(getEntity().locZ*32D); + packet.c = MathHelper.floor(getEntity().locX * 32.0D); + packet.d = MathHelper.floor(getEntity().locY * 32.0D); + packet.e = MathHelper.floor(getEntity().locZ * 32.0D); packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F)); packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); @@ -70,4 +77,97 @@ public abstract class DisguiseCreature extends DisguiseInsentient return packet; } + + // ---- Metadata processing + + // This WON'T be post-processed by the Spigot metadata processor + + @Override + public Packet modifySpawnPacket(int protocol, Packet packet) + { + if (protocol >= ProtocolVersion.v1_10_PRE) + { + PacketPlayOutSpawnEntityLiving newSpawn = (PacketPlayOutSpawnEntityLiving) getSpawnPacket(); + + // Allow the entity type to be changed (needed on 1.11+) + newSpawn.b = getTypeId(protocol >= ProtocolVersion.v1_11); + + boolean hasArms = false; + List meta = DataWatcher.b(); + + if (meta != null) + { + // Run the meta through our Spigot rewriter + meta = MetadataRewriter.rewrite(getTypeId(false), protocol, meta).objects; + + // Remove indexes >= 12 on 1.11+ + if (protocol >= ProtocolVersion.v1_11) + { + Iterator iter = meta.iterator(); + while (iter.hasNext()) + { + WatchableObject next = iter.next(); + if (next.getIndex().a() == 6) + { + hasArms = true; + } else if (next.getIndex().a() >= 12) + { + iter.remove(); + } + } + } + } else + { + meta = new ArrayList<>(); + } + + if (!hasArms) + { + WatchableObject arms = new WatchableObject<>(0, 0, null, + new DataIndex<>(6, DataType.BYTE), (byte) 0); + meta.add(arms); + } + + newSpawn.m = meta; + return newSpawn; + } + + return packet; + } + + protected int getTypeId(boolean separate) + { + return getDisguiseType().getTypeId(); + } + + // This WILL be post-processed by Spigot's metadata processor + + @Override + public Packet modifyMetaPacket(int protocol, Packet packet) + { + if (protocol >= ProtocolVersion.v1_10_PRE) + { + PacketPlayOutEntityMetadata newMeta = new PacketPlayOutEntityMetadata(); + newMeta.a = getEntityId(); + + List meta = MetadataRewriter.rewrite(getTypeId(false), protocol, DataWatcher.c()).objects; + + for (int i = 0; i < meta.size(); i++) + { + WatchableObject object = meta.get(i); + int index = object.getIndex().a(); + if (index >= 6) + { + index--; + meta.set(i, new WatchableObject(0, 0, null, + new DataIndex(index, object.getIndex().b()), object.getValue())); + } + } + + newMeta.b = meta; + return newMeta; + } + + return packet; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java index af05e67bb..1f40da543 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java @@ -1,11 +1,17 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.*; - import net.minecraft.server.v1_8_R3.EntityGuardian; -public class DisguiseGuardian extends DisguiseCreature +import org.bukkit.entity.EntityType; + +public class DisguiseGuardian extends DisguiseMutable { + private static final int GUARDIAN_ID = 68; + private static final int ELDER_GUARDIAN_ID = 4; + + private int target = 0; + private boolean elder = false; + public DisguiseGuardian(org.bukkit.entity.Entity entity) { super(EntityType.GUARDIAN, entity); @@ -15,17 +21,31 @@ public class DisguiseGuardian extends DisguiseCreature public void setTarget(int target) { + this.target = target; + DataWatcher.watch(17, target, EntityGuardian.META_TARGET, target); } public void setElder(boolean elder) { - DataWatcher.watch(16, Integer.valueOf(DataWatcher.getInt(16) | 4), EntityGuardian.META_ELDER, (byte) (DataWatcher.getInt(16) | 4)); + this.elder = elder; + + int oldValue = DataWatcher.getInt(16); + int newValue = elder ? oldValue | 4 : oldValue & ~4; + + DataWatcher.watch(16, Integer.valueOf(newValue), EntityGuardian.META_ELDER, (byte) newValue); + + mutate(); } public boolean isElder() { - return (this.DataWatcher.getInt(16) & 4) != 0; + return elder; + } + + public int getTarget() + { + return target; } protected String getHurtSound() @@ -37,4 +57,10 @@ public class DisguiseGuardian extends DisguiseCreature return "mob.guardian.hit"; } + + @Override + protected int getTypeId(boolean separate) + { + return separate && isElder() ? ELDER_GUARDIAN_ID : GUARDIAN_ID; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java index cbd7ee097..b306a76b6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java @@ -2,14 +2,24 @@ package mineplex.core.disguise.disguises; import java.util.UUID; -import net.minecraft.server.v1_8_R3.EntityHorse; - -import org.bukkit.entity.*; - import com.google.common.base.Optional; -public class DisguiseHorse extends DisguiseAnimal +import net.minecraft.server.v1_8_R3.EntityAgeable; +import net.minecraft.server.v1_8_R3.EntityHorse; + +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Horse; + +public class DisguiseHorse extends DisguiseMutable { + private static final int HORSE_ID = 100; + private static final int DONKEY_ID = 31; + private static final int MULE_ID = 32; + private static final int ZOMBIE_HORSE_ID = 29; + private static final int SKELETON_HORSE_ID = 28; + + private Horse.Variant variant = Horse.Variant.HORSE; + public DisguiseHorse(org.bukkit.entity.Entity entity) { super(EntityType.HORSE, entity); @@ -19,11 +29,25 @@ public class DisguiseHorse extends DisguiseAnimal DataWatcher.a(20, Integer.valueOf(0), EntityHorse.META_VARIANT, 0); DataWatcher.a(21, String.valueOf(""), EntityHorse.META_OWNER, Optional. absent()); DataWatcher.a(22, Integer.valueOf(0), EntityHorse.META_ARMOR, 0); + + DataWatcher.a(12, new Byte((byte)0), EntityAgeable.META_BABY, false); + } + + public boolean isBaby() + { + return DataWatcher.getByte(12) < 0; + } + + public void setBaby() + { + DataWatcher.watch(12, new Byte((byte) ( -1 )), EntityAgeable.META_BABY, true); } public void setType(Horse.Variant horseType) { DataWatcher.watch(19, Byte.valueOf((byte) horseType.ordinal()), EntityHorse.META_TYPE, horseType.ordinal()); + this.variant = horseType; + mutate(); } public Horse.Variant getType() @@ -72,4 +96,23 @@ public class DisguiseHorse extends DisguiseAnimal { DataWatcher.watch(22, Integer.valueOf(i), EntityHorse.META_ARMOR, i); } + + // 1.11 and up require separate entity ids + @Override + protected int getTypeId(boolean separate) + { + if (separate && variant != Horse.Variant.HORSE) + { + switch (variant) + { + case DONKEY: return DONKEY_ID; + case MULE: return MULE_ID; + case UNDEAD_HORSE: return ZOMBIE_HORSE_ID; + case SKELETON_HORSE: return SKELETON_HORSE_ID; + default: return HORSE_ID; + } + } + + return HORSE_ID; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java index 904835bba..e06a56b17 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java @@ -1,95 +1,15 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.EntitySlime; -import net.minecraft.server.v1_8_R3.MathHelper; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; -public class DisguiseMagmaCube extends DisguiseInsentient +/** + * Magma cubes are essentially identical to slimes for disguise purposes + */ +public class DisguiseMagmaCube extends DisguiseSlime { - public DisguiseMagmaCube(org.bukkit.entity.Entity entity) + public DisguiseMagmaCube(Entity entity) { super(EntityType.MAGMA_CUBE, entity); - - DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1); } - - public void SetSize(int i) - { - DataWatcher.watch(16, new Byte((byte) i), EntitySlime.META_SIZE, i); - } - - public int GetSize() - { - return DataWatcher.getByte(16); - } - - public Packet getSpawnPacket() - { - PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); - packet.a = getEntity().getId(); - packet.b = (byte) 62; - packet.c = (int) MathHelper.floor(getEntity().locX * 32D); - packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D); - packet.e = (int) MathHelper.floor(getEntity().locZ * 32D); - packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); - packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F)); - packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); - packet.uuid = getEntity().getUniqueID(); - - double var2 = 3.9D; - double var4 = 0; - double var6 = 0; - double var8 = 0; - - if (var4 < -var2) - { - var4 = -var2; - } - - if (var6 < -var2) - { - var6 = -var2; - } - - if (var8 < -var2) - { - var8 = -var2; - } - - if (var4 > var2) - { - var4 = var2; - } - - if (var6 > var2) - { - var6 = var2; - } - - if (var8 > var2) - { - var8 = var2; - } - - packet.f = (int) (var4 * 8000.0D); - packet.g = (int) (var6 * 8000.0D); - packet.h = (int) (var8 * 8000.0D); - - packet.l = DataWatcher; - packet.m = DataWatcher.b(); - - return packet; - } - - protected String getHurtSound() - { - return "mob.slime." + (GetSize() > 1 ? "big" : "small"); - } - - protected float getVolume() - { - return 0.4F * (float) GetSize(); - } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMutable.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMutable.java new file mode 100644 index 000000000..d3ff2216c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMutable.java @@ -0,0 +1,40 @@ +package mineplex.core.disguise.disguises; + +import java.util.function.Predicate; + +import com.mineplex.ProtocolVersion; + +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; + +/** + * Represents a disguise that can "mutate" from one entity type to another. + */ +public abstract class DisguiseMutable extends DisguiseCreature +{ + public DisguiseMutable(EntityType disguiseType, Entity entity) + { + super(disguiseType, entity); + } + + protected void mutate() + { +// if (!_spawnedIn) +// return; + + Predicate pred = v -> v >= ProtocolVersion.v1_11; + sendToWatchers(pred, this::getDestroyPacket); + sendToWatchers(pred, this::getSpawnPacket); + sendToWatchers(pred, this::getMetadataPacket); + } + + private Packet getDestroyPacket() + { + return new PacketPlayOutEntityDestroy(new int[] { getEntityId() }); + } + + protected abstract int getTypeId(boolean separate); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java index 122490073..34dd47cc0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java @@ -2,11 +2,16 @@ package mineplex.core.disguise.disguises; import net.minecraft.server.v1_8_R3.EntitySkeleton; -import org.bukkit.entity.*; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Skeleton.SkeletonType; -public class DisguiseSkeleton extends DisguiseMonster +public class DisguiseSkeleton extends DisguiseMutable { + private static final int SKELETON_ID = 51; + private static final int WITHER_SKELETON_ID = 5; + + private SkeletonType type = SkeletonType.NORMAL; + public DisguiseSkeleton(org.bukkit.entity.Entity entity) { super(EntityType.SKELETON, entity); @@ -17,15 +22,24 @@ public class DisguiseSkeleton extends DisguiseMonster public void SetSkeletonType(SkeletonType skeletonType) { DataWatcher.watch(13, Byte.valueOf((byte) skeletonType.getId()), EntitySkeleton.META_TYPE, skeletonType.getId()); + this.type = skeletonType; + mutate(); } - public int GetSkeletonType() + public SkeletonType getSkeletonType() { - return DataWatcher.getByte(13); + return type; } protected String getHurtSound() { return "mob.skeleton.hurt"; } + + // 1.11 and up require separate entity ids + @Override + protected int getTypeId(boolean separate) + { + return separate && type == SkeletonType.WITHER ? WITHER_SKELETON_ID : SKELETON_ID; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java index 96bb78cd9..6a0cb2a34 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java @@ -4,14 +4,26 @@ import net.minecraft.server.v1_8_R3.EntitySlime; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; + +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; -public class DisguiseSlime extends DisguiseInsentient +/** + * Slimes have an odd type hierarchy, but they're essentially creatures as far as disguises are concerned. + */ +public class DisguiseSlime extends DisguiseCreature { - public DisguiseSlime(org.bukkit.entity.Entity entity) + public DisguiseSlime(Entity entity) { - super(EntityType.SLIME, entity); + this(EntityType.SLIME, entity); + } + /** + * For magma cubes + */ + protected DisguiseSlime(EntityType type, Entity entity) + { + super(type, entity); DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1); } @@ -25,63 +37,6 @@ public class DisguiseSlime extends DisguiseInsentient return DataWatcher.getByte(16); } - public Packet getSpawnPacket() - { - PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); - packet.a = getEntity().getId(); - packet.b = (byte) 55; - packet.c = (int) MathHelper.floor(getEntity().locX * 32D); - packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D); - packet.e = (int) MathHelper.floor(getEntity().locZ * 32D); - packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); - packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F)); - packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); - packet.uuid = getEntity().getUniqueID(); - - double var2 = 3.9D; - double var4 = 0; - double var6 = 0; - double var8 = 0; - - if (var4 < -var2) - { - var4 = -var2; - } - - if (var6 < -var2) - { - var6 = -var2; - } - - if (var8 < -var2) - { - var8 = -var2; - } - - if (var4 > var2) - { - var4 = var2; - } - - if (var6 > var2) - { - var6 = var2; - } - - if (var8 > var2) - { - var8 = var2; - } - - packet.f = (int) (var4 * 8000.0D); - packet.g = (int) (var6 * 8000.0D); - packet.h = (int) (var8 * 8000.0D); - packet.l = DataWatcher; - packet.m = DataWatcher.b(); - - return packet; - } - protected String getHurtSound() { return "mob.slime." + (GetSize() > 1 ? "big" : "small"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java index e0c544659..4b53402cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java @@ -37,11 +37,9 @@ public class DisguiseCommand extends CommandBase implemen return; } - Plugin.runAsync(() -> - { - new PlayerDisguiseNotification(realName, currentUUID, args[0], args.length > 1 ? args[1] : args[0]).publish(); - }); - - Plugin.disguise(caller, args[0], args.length > 1 ? args[1] : args[0]); + String skin = args.length > 1 ? args[1] : args[0]; + Plugin.tryDisguise(caller, args[0], skin, () -> // onComplete + Plugin.runAsync(() -> // task + new PlayerDisguiseNotification(realName, currentUUID, args[0], skin).publish())); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/ExpiringSet.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/ExpiringSet.java new file mode 100644 index 000000000..12aa1d0ca --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/ExpiringSet.java @@ -0,0 +1,96 @@ +package mineplex.core.disguise.playerdisguise; + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; +import java.util.function.Predicate; +import java.util.stream.Stream; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; + +/** + * Set with contents that expire after X amount of time units. Essentially HashSet reimplemented with a Cache instead of HashMap. + * @author Dan + */ +public class ExpiringSet extends AbstractSet implements Set +{ + private transient Cache cache; + + private static final Object DUMMY = new Object(); + + public ExpiringSet(long duration, TimeUnit unit) + { + this.cache = CacheBuilder.newBuilder().expireAfterWrite(duration, unit).build(); + } + + @Override + public Iterator iterator() + { + return cache.asMap().keySet().iterator(); + } + + @Override + public void forEach(Consumer action) + { + cache.asMap().keySet().forEach(action); + } + + @Override + public boolean removeIf(Predicate filter) + { + return cache.asMap().keySet().removeIf(filter); + } + + @Override + public Spliterator spliterator() + { + return cache.asMap().keySet().spliterator(); + } + + @Override + public Stream stream() + { + return cache.asMap().keySet().stream(); + } + + @Override + public Stream parallelStream() + { + return cache.asMap().keySet().parallelStream(); + } + + @Override + public int size() + { + return (int) cache.size(); + } + + @Override + public boolean contains(Object o) + { + return cache.getIfPresent(o) != null; + } + + @Override + public boolean add(E e) + { + boolean contained = contains(e); + cache.put(e, DUMMY); + return contained; + } + + @Override + public boolean remove(Object o) + { + boolean contained = contains(o); + cache.invalidate(o); + return contained; + } + + @Override + public void clear() + { + cache.invalidateAll(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java index a650df7ec..30de25c49 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java @@ -1,14 +1,8 @@ package mineplex.core.disguise.playerdisguise; import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import net.minecraft.server.v1_8_R3.MinecraftServer; @@ -86,7 +80,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler ILLEGAL_USERNAMES = ImmutableSet.copyOf(Arrays.asList("hypixel", "chiss", "dctr", "blondebug", "dooskee", "tomcallister", "jessiemarcia", "spu_", "sp614x", "deadmau5", "gwen", "mineplex", "samczsun", "sethbling", - "xisuma", "cubehamster", "natet_bird", "qwertyuiopthepie" + "xisuma", "cubehamster", "natet_bird", "qwertyuiopthepie", "hitler", "adolfhitler" )); VERY_SPECIAL_PEOPLE = ImmutableSet.copyOf(Arrays.asList( @@ -121,14 +115,15 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler private CoreClientManager _clients = require(CoreClientManager.class); private DisguiseManager _disguise = require(DisguiseManager.class); private Punish _punish = require(Punish.class); - private CosmeticManager _cosmetics = require(CosmeticManager.class); + // private CosmeticManager _cosmetics = require(CosmeticManager.class); private PreferencesManager _prefs = require(PreferencesManager.class); private RedisDataRepository _redis; // The list of usernames which cannot join because someone else is joining - private Set _cannotJoin = Collections.synchronizedSet(new HashSet<>()); - private Set _loggingIn = Collections.synchronizedSet(new HashSet<>()); + // Values expire in 30 seconds if they haven't been properly cleaned up + private Set _cannotJoin = Collections.synchronizedSet(new ExpiringSet<>(1, TimeUnit.MINUTES)); + private Set _loggingIn = Collections.synchronizedSet(new ExpiringSet<>(1, TimeUnit.MINUTES)); private Set _pendingDisguise1 = new HashSet<>(); @@ -164,7 +159,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler if (disguisePlayer.getProfile().getName().equalsIgnoreCase(event.getPlayer().getName())) { event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - event.setKickMessage("Failed to login: The authentication servers are currently down for maintainence"); + event.setKickMessage("Failed to login: The authentication servers are currently down for maintenance"); return; } } @@ -172,7 +167,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler if (_cannotJoin.contains(event.getPlayer().getName().toLowerCase())) { event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - event.setKickMessage("Failed to login: The authentication servers are currently down for maintainence"); + event.setKickMessage("Failed to login: The authentication servers are currently down for maintenance"); return; } @@ -231,7 +226,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler runSyncLater(() -> { UtilPlayer.message(event.getPlayer(), F.main(getName(), "Attempting to disguise you as " + bean.getGameProfile().getName())); - disguise(event.getPlayer(), bean.getGameProfile()); + tryDisguise(event.getPlayer(), bean.getGameProfile(), () -> { }); }, 1); } } @@ -423,10 +418,26 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler DisguisePlayer disguise = _disguises.remove(caller.getUniqueId()); + undisguise(caller, disguise); + + _mapping.remove(disguise.getName().toLowerCase()); + + UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); + getPluginManager().callEvent(new PlayerUndisguisedEvent(caller)); + removeDisguiseData(caller); + } + + public void undisguise(Player caller, DisguisePlayer disguise) + { GameProfile originalProfile = disguise.getOriginalProfile(); GameProfile currentProfile = ((CraftPlayer) caller).getProfile(); + boolean sameName = caller.getName().equals(currentProfile.getName()); + + if (!sameName) + { + require(ScoreboardManager.class).handlePlayerQuit(disguise.getName()); + } - require(ScoreboardManager.class).handlePlayerQuit(disguise.getName()); try { UtilGameProfile.changeName(currentProfile, originalProfile.getName()); @@ -447,7 +458,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler return; } - getDisguiseManager().undisguise(caller); + getDisguiseManager().undisguise(disguise); GameProfile disguisedProfile = disguise.getProfile(); @@ -458,25 +469,21 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler require(FriendManager.class).updatePlayerStatus(originalProfile.getId(), new PlayerStatus(originalProfile.getId(), originalProfile.getName(), _serverName)); getPreferencesManager().handlePlayerJoin(caller, true); - require(ScoreboardManager.class).handlePlayerJoin(disguise.getOriginalProfile().getName()); - - - _mapping.remove(disguise.getName().toLowerCase()); - - UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); - getPluginManager().callEvent(new PlayerUndisguisedEvent(caller)); - removeDisguiseData(caller); + if (!sameName) + { + require(ScoreboardManager.class).handlePlayerJoin(disguise.getOriginalProfile().getName()); + } } - public void disguise(Player caller, GameProfile requestedProfile) + public void tryDisguise(Player caller, GameProfile requestedProfile, Runnable onComplete) { if (getDisguiseManager().isDisguised(caller)) { if (isDisguised(caller)) { - UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); - } - else + UtilPlayer.message(caller, + F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); + } else { UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Perhaps you are morphed?")); } @@ -485,134 +492,75 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler if (isDisguised(caller)) { - UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); - return; - } - - String requestedUsername = requestedProfile.getName(); - - if (!requestedUsername.equalsIgnoreCase(caller.getName())) - { - _cannotJoin.add(requestedUsername.toLowerCase()); - for (Player other : UtilServer.getPlayersCollection()) - { - if (other.getName().equalsIgnoreCase(requestedUsername)) - { - UtilPlayer.message(caller, C.cRed + F.main("Disguise", "This name is already in use!")); - _cannotJoin.remove(requestedUsername.toLowerCase()); - return; - } - } - } - - if (!_pendingDisguise.add(requestedUsername.toLowerCase())) - { - UtilPlayer.message(caller, F.main("Disguise", "Someone is already disguising as that user")); - return; - } - - PlayerPreDisguiseEvent playerPreDisguiseEvent = new PlayerPreDisguiseEvent(caller, requestedUsername); - UtilServer.CallEvent(playerPreDisguiseEvent); - if (playerPreDisguiseEvent.isCancelled()) - { - UtilPlayer.message(caller, F.main(getName(), "Your disguise was cancelled by something")); - _pendingDisguise.remove(requestedUsername.toLowerCase()); + UtilPlayer.message(caller, + F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); return; } CoreClient callerClient = getClientManager().Get(caller); - if (!requestedUsername.equalsIgnoreCase(caller.getName())) + String requestedUsername = requestedProfile.getName(); + if (requestedUsername.equalsIgnoreCase(caller.getName())) { - getClientManager().getOrLoadClient(requestedUsername, other -> + if (doDisguise(caller, requestedProfile, callerClient, callerClient)) { - Rank otherRank = other != null ? other.GetRank() : Rank.ALL; + onComplete.run(); + } + return; + } + for (Player other : UtilServer.getPlayersCollection()) + { + if (other.getName().equalsIgnoreCase(requestedUsername)) + { + UtilPlayer.message(caller, C.cRed + F.main("Disguise", "This name is already in use!")); + return; + } + } + + if (_pendingDisguise.contains(requestedUsername.toLowerCase())) + { + UtilPlayer.message(caller, F.main("Disguise", "Someone is already disguising as that user")); + return; + } + + getClientManager().getOrLoadClient(requestedUsername, other -> + { + if (other != null) + { + Rank otherRank = other.GetRank(); if (otherRank.has(Rank.TWITCH)) { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, YouTubers or Twitchers!")); + UtilPlayer.message(caller, + F.main("Disguise", "You can't disguise as staff, YouTubers or Twitchers!")); return; } - if (other != null) + PunishClient pclient = getPunishManager().GetClient(requestedUsername); + if (pclient != null && (pclient.IsBanned() || pclient.IsMuted())) { - PunishClient pclient = getPunishManager().GetClient(requestedUsername); - if (pclient != null && (pclient.IsBanned() || pclient.IsMuted())) - { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as players who are banned/muted!")); - return; - } + UtilPlayer.message(caller, + F.main("Disguise", "You can't disguise as players who are banned/muted!")); + return; } + } - callerClient.disguise(requestedUsername, requestedProfile.getId(), otherRank); + if (doDisguise(caller, requestedProfile, callerClient, other)) + { + onComplete.run(); + } + }); + } - _mapping.put(callerClient.getDisguisedAs().toLowerCase(), callerClient.getName()); + public boolean doDisguise(Player caller, GameProfile requestedProfile, CoreClient callerClient, CoreClient otherClient) + { + String requestedUsername = requestedProfile.getName(); + _pendingDisguise.add(requestedUsername.toLowerCase()); - System.out.println("================="); - System.out.println("Disguising " + caller.getName() + " as:"); - System.out.println(requestedProfile.getName() + " id " + requestedProfile.getId()); - System.out.println("Properties:"); - for (Map.Entry p : requestedProfile.getProperties().entries()) - { - System.out.println("\t" + p.getKey() + " " + p.getValue().getName()); - System.out.println("\t" + p.getValue().getValue()); - System.out.println("\t" + p.getValue().getSignature()); - } - System.out.println("================="); - - DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); - disguisePlayer.showInTabList(true, 0); - allow(caller); - getDisguiseManager().disguise(disguisePlayer, () -> - { - GameProfile callerProfile = ((CraftPlayer) caller).getProfile(); - - require(ScoreboardManager.class).handlePlayerQuit(disguisePlayer.getOriginalProfile().getName()); - - try - { - UtilGameProfile.changeName(callerProfile, disguisePlayer.getProfile().getName()); - UtilGameProfile.changeId(callerProfile, disguisePlayer.getProfile().getId()); - - Field playersByName = PlayerList.class.getDeclaredField("playersByName"); - playersByName.setAccessible(true); - Map map = (Map) playersByName.get(MinecraftServer.getServer().getPlayerList()); - map.remove(disguisePlayer.getOriginalProfile().getName()); - map.put(disguisePlayer.getProfile().getName(), disguisePlayer.getEntity()); - } - catch (Throwable t) - { - t.printStackTrace(); - } - - require(ScoreboardManager.class).handlePlayerJoin(disguisePlayer.getName()); - - callerProfile.getProperties().clear(); - callerProfile.getProperties().putAll(disguisePlayer.getProfile().getProperties()); - - callerProfile.getProperties().removeAll(ORIGINAL_UUID_KEY); - callerProfile.getProperties().put(ORIGINAL_UUID_KEY, new Property(ORIGINAL_UUID_KEY, caller.getUniqueId().toString())); - - require(FriendManager.class).updatePlayerStatus(disguisePlayer.getOriginalProfile().getId(), null); - require(FriendManager.class).updatePlayerStatus(disguisePlayer.getProfile().getId(), new PlayerStatus(disguisePlayer.getProfile().getId(), requestedUsername, _serverName)); - - getPreferencesManager().handlePlayerJoin(caller, true); - - _disguises.put(caller.getUniqueId(), disguisePlayer); - - UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + requestedUsername)); - - UtilServer.CallEvent(new PlayerDisguisedEvent(caller)); - - storeDisguiseData(caller, requestedUsername, requestedProfile); - - _pendingDisguise.remove(requestedUsername.toLowerCase()); - - _cannotJoin.remove(requestedUsername.toLowerCase()); - }); - }); - } - else + if (!requestedUsername.equalsIgnoreCase(caller.getName())) + { + _cannotJoin.add(requestedUsername.toLowerCase()); + } else { DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); disguisePlayer.showInTabList(true, 0); @@ -629,10 +577,93 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler _pendingDisguise.remove(requestedUsername.toLowerCase()); }); + + return true; } + + PlayerPreDisguiseEvent playerPreDisguiseEvent = new PlayerPreDisguiseEvent(caller, requestedUsername); + UtilServer.CallEvent(playerPreDisguiseEvent); + if (playerPreDisguiseEvent.isCancelled()) + { + UtilPlayer.message(caller, F.main(getName(), "Your disguise was cancelled by something")); + _pendingDisguise.remove(requestedUsername.toLowerCase()); + _cannotJoin.remove(requestedUsername.toLowerCase()); + return false; + } + + Rank otherRank = otherClient != null ? otherClient.GetRank() : Rank.ALL; + callerClient.disguise(requestedUsername, requestedProfile.getId(), otherRank); + + _mapping.put(callerClient.getDisguisedAs().toLowerCase(), callerClient.getName()); + + System.out.println("================="); + System.out.println("Disguising " + caller.getName() + " as:"); + System.out.println(requestedProfile.getName() + " id " + requestedProfile.getId()); + System.out.println("Properties:"); + for (Map.Entry p : requestedProfile.getProperties().entries()) + { + System.out.println("\t" + p.getKey() + " " + p.getValue().getName()); + System.out.println("\t" + p.getValue().getValue()); + System.out.println("\t" + p.getValue().getSignature()); + } + System.out.println("================="); + + DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); + disguisePlayer.showInTabList(true, 0); + allow(caller); + getDisguiseManager().disguise(disguisePlayer, () -> + { + GameProfile callerProfile = ((CraftPlayer) caller).getProfile(); + + require(ScoreboardManager.class).handlePlayerQuit(disguisePlayer.getOriginalProfile().getName()); + + try + { + UtilGameProfile.changeName(callerProfile, disguisePlayer.getProfile().getName()); + UtilGameProfile.changeId(callerProfile, disguisePlayer.getProfile().getId()); + + Field playersByName = PlayerList.class.getDeclaredField("playersByName"); + playersByName.setAccessible(true); + Map map = (Map) playersByName.get(MinecraftServer.getServer().getPlayerList()); + map.remove(disguisePlayer.getOriginalProfile().getName()); + map.put(disguisePlayer.getProfile().getName(), disguisePlayer.getEntity()); + } catch (Throwable t) + { + t.printStackTrace(); + } + + require(ScoreboardManager.class).handlePlayerJoin(disguisePlayer.getName()); + + callerProfile.getProperties().clear(); + callerProfile.getProperties().putAll(disguisePlayer.getProfile().getProperties()); + + callerProfile.getProperties().removeAll(ORIGINAL_UUID_KEY); + callerProfile.getProperties() + .put(ORIGINAL_UUID_KEY, new Property(ORIGINAL_UUID_KEY, caller.getUniqueId().toString())); + + require(FriendManager.class).updatePlayerStatus(disguisePlayer.getOriginalProfile().getId(), null); + require(FriendManager.class).updatePlayerStatus(disguisePlayer.getProfile().getId(), + new PlayerStatus(disguisePlayer.getProfile().getId(), requestedUsername, _serverName)); + + getPreferencesManager().handlePlayerJoin(caller, true); + + _disguises.put(caller.getUniqueId(), disguisePlayer); + + UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + requestedUsername)); + + UtilServer.CallEvent(new PlayerDisguisedEvent(caller)); + + storeDisguiseData(caller, requestedUsername, requestedProfile); + + _pendingDisguise.remove(requestedUsername.toLowerCase()); + + _cannotJoin.remove(requestedUsername.toLowerCase()); + }); + + return true; } - public void disguise(Player caller, String requestedUsername, String requestedSkin) + public void tryDisguise(Player caller, String requestedUsername, String requestedSkin, Runnable onComplete) { if (!validateUsername(caller, requestedUsername, true)) return; if (!validateUsername(caller, requestedSkin, false)) return; @@ -655,7 +686,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler requestedProfile.getProperties().clear(); requestedProfile.getProperties().put("textures", skinData.getProperty()); - disguise(caller, requestedProfile); + tryDisguise(caller, requestedProfile, onComplete); }; if (!requestedUsername.equalsIgnoreCase(requestedSkin)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index e0d211e34..2e871dcc8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -10,7 +10,19 @@ import java.util.Set; import java.util.UUID; import java.util.function.Predicate; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; +import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.morph.MorphBobRoss; +import mineplex.core.gadget.gadgets.morph.MorphFreedomFighter; +import mineplex.core.gadget.gadgets.morph.MorphMelonHead; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; +import mineplex.core.gadget.set.SetCanadian; +import mineplex.core.gadget.types.FlagGadget; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -47,50 +59,50 @@ import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.event.PlayerToggleSwimEvent; import mineplex.core.gadget.event.TauntCommandEvent; -import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; -import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; -import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.arrowtrail.halloween.ArrowTrailHalloween; -import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; -import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; -import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; -import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; -import mineplex.core.gadget.gadgets.arrowtrail.titan.ArrowTrailTitan; -import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.balloons.BalloonItem; import mineplex.core.gadget.gadgets.balloons.BalloonType; -import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; -import mineplex.core.gadget.gadgets.death.christmas.DeathPresentDanger; -import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart; -import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald; -import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; -import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; -import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; -import mineplex.core.gadget.gadgets.death.music.DeathMusic; -import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; -import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; -import mineplex.core.gadget.gadgets.death.spring.DeathSpring; -import mineplex.core.gadget.gadgets.death.titan.DeathTitan; -import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; -import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; -import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; -import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; -import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; -import mineplex.core.gadget.gadgets.doublejump.halloween.DoubleJumpHalloween; -import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; -import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; -import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; -import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; -import mineplex.core.gadget.gadgets.doublejump.titan.DoubleJumpTitan; -import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.death.DeathCandyCane; +import mineplex.core.gadget.gadgets.death.DeathPresentDanger; +import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; +import mineplex.core.gadget.gadgets.death.DeathEmerald; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.death.DeathFrostLord; +import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.death.DeathMusic; +import mineplex.core.gadget.gadgets.death.DeathPinataBurst; +import mineplex.core.gadget.gadgets.death.DeathShadow; +import mineplex.core.gadget.gadgets.death.DeathSpring; +import mineplex.core.gadget.gadgets.death.DeathTitan; +import mineplex.core.gadget.gadgets.death.DeathBlood; +import mineplex.core.gadget.gadgets.death.DeathEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.GameModifierMount; import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.MountType; @@ -185,19 +197,19 @@ import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsLove; import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; import mineplex.core.gadget.gadgets.particle.ParticleYinYang; -import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; -import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; -import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.ParticleEmerald; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; -import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; -import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; -import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; -import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; -import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleRain; +import mineplex.core.gadget.gadgets.particle.ParticleMusic; +import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; +import mineplex.core.gadget.gadgets.particle.ParticleFoot; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; -import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan; -import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; -import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; +import mineplex.core.gadget.gadgets.particle.ParticleTitan; +import mineplex.core.gadget.gadgets.particle.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; import mineplex.core.gadget.gadgets.taunts.EternalTaunt; import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; @@ -366,6 +378,7 @@ public class GadgetManager extends MiniPlugin addSet(new SetMusic(this)); addSet(new SetFreedom(this)); addSet(new SetSpring(this)); + addSet(new SetCanadian(this)); } private void createGadgets() @@ -456,34 +469,45 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphGoldPot(this)); addGadget(new MorphAwkwardRabbit(this)); addGadget(new MorphBobRoss(this, _hologramManager)); + addGadget(new MorphFreedomFighter(this)); + addGadget(new MorphMelonHead(this)); // Particles addGadget(new ParticleFoot(this)); - addGadget(new ParticleFireRings(this)); - addGadget(new ParticleFairy(this)); - addGadget(new ParticleLegend(this)); - addGadget(new ParticleFrostLord(this)); - addGadget(new ParticleTitan(this)); - addGadget(new ParticleCandyCane(this)); - addGadget(new ParticleCoalFumes(this)); - addGadget(new ParticlePartyTime(this)); - addGadget(new ParticleHeart(this)); addGadget(new ParticleEmerald(this)); - addGadget(new ParticleWingsDemons(this)); - addGadget(new ParticleEnchant(this)); addGadget(new ParticleRain(this)); addGadget(new ParticleBlood(this)); + addGadget(new ParticleEnchant(this)); addGadget(new ParticleMusic(this)); - addGadget(new ParticleWingsAngel(this)); - addGadget(new ParticleWingsInfernal(this)); - addGadget(new ParticleWingsPixie(this)); + addGadget(new ParticlePartyTime(this)); + + addGadget(new ParticleHeart(this)); + addGadget(new ParticleCandyCane(this)); + addGadget(new ParticleFrostLord(this)); + addGadget(new ParticleLegend(this)); + addGadget(new ParticleTitan(this)); addGadget(new ParticleYinYang(this)); - addGadget(new ParticleFreedom(this)); - addGadget(new ParticleChristmasTree(this)); + addGadget(new ParticleKing(this, _castleManager)); + + addGadget(new ParticleWingsPixie(this)); + addGadget(new ParticleWingsDemons(this)); + addGadget(new ParticleWingsInfernal(this)); + addGadget(new ParticleWingsAngel(this)); addGadget(new ParticleWingsLove(this)); + addGadget(new ParticleFireRings(this)); + addGadget(new ParticleFairy(this)); + + addGadget(new ParticleChristmasTree(this)); + addGadget(new ParticleCoalFumes(this)); addGadget(new ParticleSpringHalo(this)); addGadget(new ParticleWingsBee(this)); - addGadget(new ParticleKing(this, _castleManager)); + + addGadget(new ParticleFreedom(this)); + addGadget(new ParticleFreedomFireworks(this)); + addGadget(new ParticleStarSpangled(this)); + addGadget(new ParticleAuraNiceness(this)); + addGadget(new ParticleCanadian(this)); + // Arrow Trails addGadget(new ArrowTrailFrostLord(this)); @@ -500,6 +524,7 @@ public class GadgetManager extends MiniPlugin addGadget(new ArrowTrailFreedom(this)); addGadget(new ArrowTrailHalloween(this)); addGadget(new ArrowTrailSpring(this)); + addGadget(new ArrowTrailRedWhite(this)); // Death Effect addGadget(new DeathFrostLord(this)); @@ -516,6 +541,7 @@ public class GadgetManager extends MiniPlugin addGadget(new DeathFreedom(this)); addGadget(new DeathPresentDanger(this)); addGadget(new DeathSpring(this)); + addGadget(new DeathMapleLeaf(this)); // Double Jump addGadget(new DoubleJumpFrostLord(this)); @@ -532,6 +558,7 @@ public class GadgetManager extends MiniPlugin addGadget(new DoubleJumpFreedom(this)); addGadget(new DoubleJumpHalloween(this)); addGadget(new DoubleJumpSpring(this)); + addGadget(new DoubleJumpMaple(this)); // Hat for (HatType hatType : HatType.values()) @@ -625,6 +652,11 @@ public class GadgetManager extends MiniPlugin addGadget(new BlowAKissTaunt(this)); addGadget(new RainbowTaunt(this)); + // Flags + addGadget(new FlagGadget(this, FlagType.CANADA)); + addGadget(new FlagGadget(this, FlagType.USA)); + + // Kit Selectors addGadget(new WaterWingsKitSelector(this)); addGadget(new HaloKitSelector(this)); @@ -830,6 +862,23 @@ public class GadgetManager extends MiniPlugin return null; } + public FlagGadget getFlagGadget(FlagType type) + { + for (Gadget gadget : getGadgets(GadgetType.FLAG)) + { + if(gadget instanceof FlagGadget) + { + FlagGadget flagGadget = (FlagGadget) gadget; + + if (type.equals(flagGadget.getFlagType())) + { + return flagGadget; + } + } + } + return null; + } + public BalloonGadget getBalloonGadget(BalloonType balloonType) { for (Gadget gadget : getGadgets(GadgetType.BALLOON)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java index fef74b9fd..d57b89228 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java @@ -9,19 +9,19 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; -import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; -import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.death.DeathCandyCane; +import mineplex.core.gadget.gadgets.death.DeathFrostLord; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; import mineplex.core.gadget.gadgets.hat.HatType; import mineplex.core.gadget.gadgets.item.ItemCoal; import mineplex.core.gadget.gadgets.item.ItemFreezeCannon; import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.gadgets.morph.MorphSnowman; -import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; import mineplex.core.gadget.types.Gadget; import mineplex.core.mount.Mount; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java index 43e1a4756..69e6f863d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java @@ -41,13 +41,30 @@ public class UnlockCosmeticsCommand extends CommandBase { addCosmetics(null, caller); } - else if (args.length == 1) + else if (args.length >= 1) { - Player player = Bukkit.getPlayer(args[0]); - if (player != null) + if (args[0].equalsIgnoreCase("all")) { - addCosmetics(null, player); - UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added all the cosmetics to " + F.name(player.getName()) + "!")); + for (Player player : UtilServer.getPlayers()) + { + if (player != null) + { + addCosmetics(null, player); + UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added all the cosmetics to " + F.name(player.getName()) + "!")); + } + } + } + else + { + for (int i = 0; i < args.length; ++i) + { + Player player = Bukkit.getPlayer(args[i]); + if (player != null) + { + addCosmetics(null, player); + UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added all the cosmetics to " + F.name(player.getName()) + "!")); + } + } } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/vampire/ArrowTrailBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBlood.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/vampire/ArrowTrailBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBlood.java index f54c9ae92..180e336de 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/vampire/ArrowTrailBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.vampire; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java index d45b1b023..58cbee4d9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.candycane; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/party/ArrowTrailConfetti.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailConfetti.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/party/ArrowTrailConfetti.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailConfetti.java index d8f06ce45..be2cd9b90 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/party/ArrowTrailConfetti.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailConfetti.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.party; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCupid.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCupid.java index c10562f6d..4249c19c3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCupid.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.cupidslove; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Color; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/emerald/ArrowTrailEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEmerald.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/emerald/ArrowTrailEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEmerald.java index 8592bc16b..b7b8a6df2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/emerald/ArrowTrailEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.emerald; +package mineplex.core.gadget.gadgets.arrowtrail; import mineplex.core.common.util.*; import org.bukkit.Location; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/wisdom/ArrowTrailEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEnchant.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/wisdom/ArrowTrailEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEnchant.java index 00e47e049..b33723020 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/wisdom/ArrowTrailEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.wisdom; +package mineplex.core.gadget.gadgets.arrowtrail; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFreedom.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFreedom.java index 8921b26cc..fa5f7ade2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFreedom.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.freedom; +package mineplex.core.gadget.gadgets.arrowtrail; import java.awt.Color; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/frostlord/ArrowTrailFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/frostlord/ArrowTrailFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java index 6ae8d9b43..3a7c910b5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/frostlord/ArrowTrailFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.frostlord; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java index 112f272ad..bd5b62563 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.halloween; +package mineplex.core.gadget.gadgets.arrowtrail; import java.awt.Color; import java.util.HashMap; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/music/ArrowTrailMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailMusic.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/music/ArrowTrailMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailMusic.java index d535035af..6c6a3006e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/music/ArrowTrailMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.music; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java new file mode 100644 index 000000000..37934c81f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java @@ -0,0 +1,77 @@ +package mineplex.core.gadget.gadgets.arrowtrail; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ArrowEffectGadget; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.util.Vector; + +import java.awt.Color; + +/** + * Trails a red and white double helix behind the arrow. + */ +public class ArrowTrailRedWhite extends ArrowEffectGadget +{ + public ArrowTrailRedWhite(GadgetManager manager) + { + super(manager, "Red & White Arrows", + UtilText.splitLineToArray(C.cRed + "Killing you nicely.", LineFormat.LORE), + -8, Material.WOOL, (byte)0); + + setDisplayItem(CountryFlag.CANADA.getBanner()); + } + + @Override + public void doTrail(Arrow arrow) + { + Vector v = arrow.getVelocity(); + Vector up = UtilAlg.getUp(v); + Vector left = UtilAlg.getLeft(v); + + Location loc = arrow.getLocation(); + + double amount = 2; + double ticks = 15; + + for(int i = 0; i < amount; i++) + { + double rad = Math.PI*2.0; + rad += i/amount * rad; + rad += Math.PI*2*(arrow.getTicksLived()%ticks)/ticks; + double l = -Math.sin(rad); + double u = Math.cos(rad); + + Vector vel = v.clone().add(up.clone().multiply(u)).add(left.clone().multiply(l)); + vel.multiply(0.4); + + if (i == 0) + { + for(int j = 0; j < 3; ++j) + { + UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, loc.clone().add(vel), 0, UtilParticle.ViewDist.NORMAL); + } + } + else + { + for(int j = 0; j < 3; ++j) + { + UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, loc.clone().add(vel), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + } + + @Override + public void doHitEffect(Arrow arrow) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, arrow.getLocation(), 0, 0, 0, 0, 3, UtilParticle.ViewDist.NORMAL); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/shadow/ArrowTrailShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailShadow.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/shadow/ArrowTrailShadow.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailShadow.java index aec688901..8db14cbdb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/shadow/ArrowTrailShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailShadow.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.shadow; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailSpring.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailSpring.java index c335ce062..59cb064c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailSpring.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.spring; +package mineplex.core.gadget.gadgets.arrowtrail; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/howlingwinds/ArrowTrailStorm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailStorm.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/howlingwinds/ArrowTrailStorm.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailStorm.java index a3cc14165..084611017 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/howlingwinds/ArrowTrailStorm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailStorm.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.howlingwinds; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java index 956055929..29c39b7d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.titan; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/vampire/DeathBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBlood.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/vampire/DeathBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBlood.java index 5365e3e14..7101aba36 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/vampire/DeathBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.vampire; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/candycane/DeathCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/candycane/DeathCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java index 45a7028d0..2d100b3fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/candycane/DeathCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.candycane; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/cupidslove/DeathCupidsBrokenHeart.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCupidsBrokenHeart.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/cupidslove/DeathCupidsBrokenHeart.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCupidsBrokenHeart.java index 1c92abc02..d0053f9df 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/cupidslove/DeathCupidsBrokenHeart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCupidsBrokenHeart.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.cupidslove; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/emerald/DeathEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEmerald.java similarity index 93% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/emerald/DeathEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEmerald.java index 79ea0b404..85fb2db18 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/emerald/DeathEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.emerald; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/wisdom/DeathEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEnchant.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/wisdom/DeathEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEnchant.java index 7229b155d..35532906d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/wisdom/DeathEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.wisdom; +package mineplex.core.gadget.gadgets.death; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/freedom/DeathFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFreedom.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/freedom/DeathFreedom.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFreedom.java index 24d43eb0b..137b68207 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/freedom/DeathFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFreedom.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.freedom; +package mineplex.core.gadget.gadgets.death; import org.bukkit.ChatColor; import org.bukkit.Location; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/frostlord/DeathFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFrostLord.java similarity index 93% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/frostlord/DeathFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFrostLord.java index 0ce7b546f..72cd2c3cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/frostlord/DeathFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.frostlord; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java new file mode 100644 index 000000000..3cfeeb034 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java @@ -0,0 +1,45 @@ +package mineplex.core.gadget.gadgets.death; + +import mineplex.core.blood.BloodEvent; +import mineplex.core.common.shape.ShapeWings; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.DeathEffectGadget; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +/** + * Displays a giant maple leaf at the point of death. + */ +public class DeathMapleLeaf extends DeathEffectGadget +{ + /** height off the ground of the leaf */ + private static final double HEIGHT = 3; + + private final ShapeWings _leafOuter = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1.0, 1.0, 1.0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); + private final ShapeWings _leafInner = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.7, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); + + public DeathMapleLeaf(GadgetManager manager) + { + super(manager, "Fallen Maple Leaf", + UtilText.splitLineToArray(C.cGray + "When you die in " + C.cRed + "Canada" + C.cGray + " you die in real life.", LineFormat.LORE), + -8, Material.WOOL, (byte) 0); + + setDisplayItem(CountryFlag.CANADA.getBanner()); + } + + @Override + public void onBlood(Player player, BloodEvent event) + { + event.setCancelled(true); + Location loc = player.getLocation().add(0, HEIGHT, 0); + _leafOuter.display(loc); + _leafInner.display(loc); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/music/DeathMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMusic.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/music/DeathMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMusic.java index 2bf566254..d6c4176ad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/music/DeathMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.music; +package mineplex.core.gadget.gadgets.death; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/party/DeathPinataBurst.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPinataBurst.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/party/DeathPinataBurst.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPinataBurst.java index 09ccfe10a..0adc3dfb8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/party/DeathPinataBurst.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPinataBurst.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.party; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/christmas/DeathPresentDanger.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPresentDanger.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/christmas/DeathPresentDanger.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPresentDanger.java index e8db5ed6a..c1b07ce33 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/christmas/DeathPresentDanger.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPresentDanger.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.christmas; +package mineplex.core.gadget.gadgets.death; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/shadow/DeathShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathShadow.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/shadow/DeathShadow.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathShadow.java index 3adb240f2..f80b4ad9b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/shadow/DeathShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathShadow.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.shadow; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathSpring.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathSpring.java index eb15f5986..bae34473b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathSpring.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.spring; +package mineplex.core.gadget.gadgets.death; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/howlingwinds/DeathStorm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathStorm.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/howlingwinds/DeathStorm.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathStorm.java index 00cf6d607..c3cf2f0da 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/howlingwinds/DeathStorm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathStorm.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.howlingwinds; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java index 00b64eace..0e56f8308 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.titan; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/vampire/DoubleJumpBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBlood.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/vampire/DoubleJumpBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBlood.java index 882133687..2f910416c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/vampire/DoubleJumpBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.vampire; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/candycane/DoubleJumpCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java similarity index 91% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/candycane/DoubleJumpCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java index d6a7620c7..209da4b7c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/candycane/DoubleJumpCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.candycane; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Location; import org.bukkit.Material; @@ -30,7 +30,7 @@ public class DoubleJumpCandyCane extends DoubleJumpEffectGadget Location loc = player.getLocation(); UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 1), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); - UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 2), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/cupidslove/DoubleJumpCupidsWings.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCupidsWings.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/cupidslove/DoubleJumpCupidsWings.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCupidsWings.java index 71a7b66b5..81884a52b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/cupidslove/DoubleJumpCupidsWings.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCupidsWings.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.cupidslove; +package mineplex.core.gadget.gadgets.doublejump; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/emerald/DoubleJumpEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEmerald.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/emerald/DoubleJumpEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEmerald.java index 0453e0b57..f74859c2c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/emerald/DoubleJumpEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.emerald; +package mineplex.core.gadget.gadgets.doublejump; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/wisdom/DoubleJumpEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEnchant.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/wisdom/DoubleJumpEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEnchant.java index ec1120f3b..d9d4db576 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/wisdom/DoubleJumpEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.wisdom; +package mineplex.core.gadget.gadgets.doublejump; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/party/DoubleJumpFirecracker.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFirecracker.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/party/DoubleJumpFirecracker.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFirecracker.java index 06ee124f7..65ce9bd80 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/party/DoubleJumpFirecracker.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFirecracker.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.party; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/freedom/DoubleJumpFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java similarity index 92% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/freedom/DoubleJumpFreedom.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java index 7f887e345..820ccd155 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/freedom/DoubleJumpFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.freedom; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -18,7 +18,7 @@ public class DoubleJumpFreedom extends DoubleJumpEffectGadget { super(manager, "Leap of Freedom", UtilText.splitLineToArray(UtilText.colorWords("FREEEEEEEEEEEDOM!", ChatColor.RED, ChatColor.WHITE, ChatColor.BLUE), LineFormat.LORE), -8, Material.WOOL, - (byte) 14); + (byte) 0); setDisplayItem(CountryFlag.USA.getBanner()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/frostlord/DoubleJumpFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFrostLord.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/frostlord/DoubleJumpFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFrostLord.java index 62325731c..64cc9f962 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/frostlord/DoubleJumpFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.frostlord; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java index 10155afbd..0f2cc13e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.halloween; +package mineplex.core.gadget.gadgets.doublejump; import java.awt.Color; import java.util.HashMap; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java new file mode 100644 index 000000000..4b9d08338 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java @@ -0,0 +1,110 @@ +package mineplex.core.gadget.gadgets.doublejump; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.DoubleJumpEffectGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class DoubleJumpMaple extends DoubleJumpEffectGadget +{ + /** + * Amount of particles played per tick as a player flies through the air. + */ + private static final int PARTICLES = 50; + + /** + * Vertical offset of the animation's center from the player's location. + */ + private static final float Y_OFFSET = 0.95f; + + /** + * Divisor of the gaussian distribution of particles as the player flies through the air. + */ + private static final int DISTRIBUTION = 2; + + /** + * Particle ring count when a player launches from the ground. + */ + private static final int LAUNCH_RINGS = 6; + + /** + * The distance between launch rings. + */ + private static final float RING_SPACING = 0.4f; + + /** + * Particles played per 1 unit radius. + */ + private static final int RING_DENSITY = 8; + + private HashMap _playerMap = new HashMap<>(); + + public DoubleJumpMaple(GadgetManager manager) + { + super(manager, "Maple Leap", + UtilText.splitLineToArray(C.cGray + "Jump higher than the maple trees!", LineFormat.LORE), + -8, Material.WOOL, (byte)0); + setDisplayItem(CountryFlag.CANADA.getBanner()); + } + + @Override + public void doEffect(Player player) + { + _playerMap.put(player, System.currentTimeMillis() + 1000); + + float limit = (LAUNCH_RINGS * RING_SPACING) + RING_SPACING; + + for (float r = RING_SPACING; r < limit; r++) + { + double[][] points = UtilMath.normalCircle(player.getLocation(), player.getVelocity(), r, Math.round(RING_DENSITY * r)); + + for (int i = 0; i < points.length; i++) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, new Location(player.getWorld(), points[i][0], points[i][1], points[i][2]), + null, 0, 1, UtilParticle.ViewDist.NORMAL); + } + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if(event.getType() != UpdateType.FASTEST) + { + return; + } + + for(Iterator> it = _playerMap.entrySet().iterator(); it.hasNext();) + { + Map.Entry e = it.next(); + + if(e.getValue() <= System.currentTimeMillis()) + { + it.remove(); + continue; + } + + Location loc = e.getKey().getLocation().add(0, Y_OFFSET, 0); + + for (int i = 0; i < PARTICLES; ++i) + { + UtilParticle.playColoredParticleToAll(java.awt.Color.RED, UtilParticle.ParticleType.RED_DUST, + UtilMath.gauss(loc, DISTRIBUTION, DISTRIBUTION, DISTRIBUTION), 0, UtilParticle.ViewDist.NORMAL); + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/music/DoubleJumpMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMusic.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/music/DoubleJumpMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMusic.java index 5b7459f0d..2a4d5c1ba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/music/DoubleJumpMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.music; +package mineplex.core.gadget.gadgets.doublejump; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/shadow/DoubleJumpShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpShadow.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/shadow/DoubleJumpShadow.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpShadow.java index 005c3403c..c64052bca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/shadow/DoubleJumpShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpShadow.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.shadow; +package mineplex.core.gadget.gadgets.doublejump; import mineplex.core.common.util.C; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java index 63dabdaf9..527b44b0f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.spring; +package mineplex.core.gadget.gadgets.doublejump; import java.util.ArrayList; import java.util.Iterator; @@ -38,7 +38,7 @@ public class DoubleJumpSpring extends DoubleJumpEffectGadget { for (int i = 50; i < 60; i++) { - Item sunflower = player.getWorld().dropItem(player.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); + Item sunflower = player.getWorld().dropItem(player.getLocation().add(0.0, 0.2, 0.0), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); _items.add(sunflower); Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/howlingwinds/DoubleJumpStorm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpStorm.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/howlingwinds/DoubleJumpStorm.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpStorm.java index 6b04d1f00..9cd07ef15 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/howlingwinds/DoubleJumpStorm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpStorm.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.howlingwinds; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java index 336aaa5bc..9c81a3309 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.titan; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java new file mode 100644 index 000000000..f51cf2ab6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java @@ -0,0 +1,171 @@ +package mineplex.core.gadget.gadgets.flag; + +import mineplex.core.common.util.banner.CountryFlag; + +/** + * Cosmetic flags representing countries. + */ +public enum FlagType +{ + AFGHANISTAN(CountryFlag.AFGHANISTAN, -1), + ALBANIA(CountryFlag.ALBANIA, -1), + ALGERIA(CountryFlag.ALGERIA, -1), + ANGOLA(CountryFlag.ANGOLA, -1), + ARGENTINA(CountryFlag.ARGENTINA, -1), + ARMENIA(CountryFlag.ARMENIA, -1), + AUSTRALIA(CountryFlag.AUSTRALIA, -1), + AUSTRIA(CountryFlag.AUSTRIA, -1), + AZERBAIJAN(CountryFlag.AZERBAIJAN, -1), + BAHRAIN(CountryFlag.BAHRAIN, -1), + BANGLADESH(CountryFlag.BANGLADESH, -1), + BELARUS(CountryFlag.BELARUS, -1), + BELGIUM(CountryFlag.BELGIUM, -1), + BERMUDA(CountryFlag.BERMUDA, -1), + BHUTAN(CountryFlag.BHUTAN, -1), + BOLIVIA(CountryFlag.BOLIVIA, -1), + BOSNIA_AND_HERZEGOVINA(CountryFlag.BOSNIA_AND_HERZEGOVINA, -1), + BRAZIL(CountryFlag.BRAZIL, -1), + BRUNEI(CountryFlag.BRUNEI, -1), + BULGARIA(CountryFlag.BULGARIA, -1), + CAMBODIA(CountryFlag.CAMBODIA, -1), + CAMEROON(CountryFlag.CAMEROON, -1), + CANADA(CountryFlag.CANADA, -8), + CHILE(CountryFlag.CHILE, -1), + CHINA(CountryFlag.CHINA, -1), + COLOMBIA(CountryFlag.COLOMBIA, -1), + COSTA_RICA(CountryFlag.COSTA_RICA, -1), + CROATIA(CountryFlag.CROATIA, -1), + CUBA(CountryFlag.CUBA, -1), + CYPRUS(CountryFlag.CYPRUS, -1), + CZECH_REPUBLIC(CountryFlag.CZECH_REPUBLIC, -1), + DENMARK(CountryFlag.DENMARK, -1), + DOMINICAN_REPUBLIC(CountryFlag.DOMINICAN_REPUBLIC, -1), + ECUADOR(CountryFlag.ECUADOR, -1), + EGYPT(CountryFlag.EGYPT, -1), + EL_SALVADOR(CountryFlag.EL_SALVADOR, -1), + ENGLAND(CountryFlag.ENGLAND, -1), + ESTONIA(CountryFlag.ESTONIA, -1), + ETHIOPIA(CountryFlag.ETHIOPIA, -1), + EU(CountryFlag.EU, -1), + FAROE_ISLANDS(CountryFlag.FAROE_ISLANDS, -1), + FINLAND(CountryFlag.FINLAND, -1), + FRANCE(CountryFlag.FRANCE, -1), + GABON(CountryFlag.GABON, -1), + GEORGIA(CountryFlag.GEORGIA, -1), + GERMANY(CountryFlag.GERMANY, -1), + GHANA(CountryFlag.GHANA, -1), + GREECE(CountryFlag.GREECE, -1), + GUATEMALA(CountryFlag.GUATEMALA, -1), + HONDURAS(CountryFlag.HONDURAS, -1), + HONG_KONG(CountryFlag.HONG_KONG, -1), + HUNGARY(CountryFlag.HUNGARY, -1), + ICELAND(CountryFlag.ICELAND, -1), + INDIA(CountryFlag.INDIA, -1), + INDONESIA(CountryFlag.INDONESIA, -1), + IRAN(CountryFlag.IRAN, -1), + IRAQ(CountryFlag.IRAQ, -1), + IRELAND(CountryFlag.IRELAND, -1), + ISLE_OF_MAN(CountryFlag.ISLE_OF_MAN, -1), + ISRAEL(CountryFlag.ISRAEL, -1), + ITALY(CountryFlag.ITALY, -1), + IVORY_COAST(CountryFlag.IVORY_COAST, -1), + JAMAICA(CountryFlag.JAMAICA, -1), + JAPAN(CountryFlag.JAPAN, -1), + JORDAN(CountryFlag.JORDAN, -1), + KAZAKHSTAN(CountryFlag.KAZAKHSTAN, -1), + KENYA(CountryFlag.KENYA, -1), + KUWAIT(CountryFlag.KUWAIT, -1), + KYRGYZSTAN(CountryFlag.KYRGYZSTAN, -1), + LATVIA(CountryFlag.LATVIA, -1), + LEBANON(CountryFlag.LEBANON, -1), + LIBYA(CountryFlag.LIBYA, -1), + LITHUANIA(CountryFlag.LITHUANIA, -1), + LUXEMBOURG(CountryFlag.LUXEMBOURG, -1), + MACAU(CountryFlag.MACAU, -1), + MACEDONIA(CountryFlag.MACEDONIA, -1), + MALAYSIA(CountryFlag.MALAYSIA, -1), + MALTA(CountryFlag.MALTA, -1), + MEXICO(CountryFlag.MEXICO, -1), + MOLDOVA(CountryFlag.MOLDOVA, -1), + MONGOLIA(CountryFlag.MONGOLIA, -1), + MONTENEGRO(CountryFlag.MONTENEGRO, -1), + MOROCCO(CountryFlag.MOROCCO, -1), + MOZAMBIQUE(CountryFlag.MOZAMBIQUE, -1), + NEPAL(CountryFlag.NEPAL, -1), + NETHERLANDS(CountryFlag.NETHERLANDS, -1), + NEW_ZEALAND(CountryFlag.NEW_ZEALAND, -1), + NIGERIA(CountryFlag.NIGERIA, -1), + NORWAY(CountryFlag.NORWAY, -1), + OMAN(CountryFlag.OMAN, -1), + PAKISTAN(CountryFlag.PAKISTAN, -1), + PANAMA(CountryFlag.PANAMA, -1), + PARAGUAY(CountryFlag.PARAGUAY, -1), + PERU(CountryFlag.PERU, -1), + PHILIPPINES(CountryFlag.PHILIPPINES, -1), + POLAND(CountryFlag.POLAND, -1), + PORTUGAL(CountryFlag.PORTUGAL, -1), + PUERTO_RICO(CountryFlag.PUERTO_RICO, -1), + QATAR(CountryFlag.QATAR, -1), + ROMANIA(CountryFlag.ROMANIA, -1), + RUSSIA(CountryFlag.RUSSIA, -1), + RWANDA(CountryFlag.RWANDA, -1), + SAUDI_ARABIA(CountryFlag.SAUDI_ARABIA, -1), + SCOTLAND(CountryFlag.SCOTLAND, -1), + SENEGAL(CountryFlag.SENEGAL, -1), + SERBIA(CountryFlag.SERBIA, -1), + SINGAPORE(CountryFlag.SINGAPORE, -1), + SLOVAKIA(CountryFlag.SLOVAKIA, -1), + SLOVENIA(CountryFlag.SLOVENIA, -1), + SOLOMON_ISLANDS(CountryFlag.SOLOMON_ISLANDS, -1), + SOMALIA(CountryFlag.SOMALIA, -1), + SOUTH_AFRICA(CountryFlag.SOUTH_AFRICA, -1), + SOUTH_KOREA(CountryFlag.SOUTH_KOREA, -1), + SOUTH_SUDAN(CountryFlag.SOUTH_SUDAN, -1), + SPAIN(CountryFlag.SPAIN, -1), + SRI_LANKA(CountryFlag.SRI_LANKA, -1), + SUDAN(CountryFlag.SUDAN, -1), + SURINAME(CountryFlag.SURINAME, -1), + SWEDEN(CountryFlag.SWEDEN, -1), + SWITZERLAND(CountryFlag.SWITZERLAND, -1), + SYRIA(CountryFlag.SYRIA, -1), + TAIWAN(CountryFlag.TAIWAN, -1), + TAJIKISTAN(CountryFlag.TAJIKISTAN, -1), + TANZANIA(CountryFlag.TANZANIA, -1), + THAILAND(CountryFlag.THAILAND, -1), + TUNISIA(CountryFlag.TUNISIA, -1), + TURKEY(CountryFlag.TURKEY, -1), + UAE(CountryFlag.UAE, -1), + UGANDA(CountryFlag.UGANDA, -1), + UK(CountryFlag.UK, -1), + UKRAINE(CountryFlag.UKRAINE, -1), + URUGUAY(CountryFlag.URUGUAY, -1), + USA(CountryFlag.USA, -8), + UZBEKISTAN(CountryFlag.UZBEKISTAN, -1), + VENEZUELA(CountryFlag.VENEZUELA, -1), + VIETNAM(CountryFlag.VIETNAM, -1), + WALES(CountryFlag.WALES, -1), + YEMEN(CountryFlag.YEMEN, -1), + ZAMBIA(CountryFlag.ZAMBIA, -1), + ZIMBABWE(CountryFlag.ZIMBABWE, -1), + + ; + + private final CountryFlag _flag; + private final int _cost; + + FlagType(CountryFlag flag, int cost) + { + _flag = flag; + _cost = cost; + } + + public CountryFlag getFlag() + { + return _flag; + } + + public int getCost() + { + return _cost; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java index c6f623e20..cabad2568 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java @@ -22,7 +22,11 @@ public enum HatType SNOWMAN("Snowman Head", UtilText.splitLineToArray(C.cGray + "Do you want to be a snowman?", LineFormat.LORE), -2, SkinData.SNOWMAN), TEDDY_BEAR("Teddy Bear", UtilText.splitLineToArray(C.cGray + "Aww, it's a cute teddy bear! What shall I name him?", LineFormat.LORE), -6, SkinData.TEDDY_BEAR), UNCLE_SAM("Uncle Sam Hat", UtilText.splitLineToArray(UtilText.colorWords("Uncle Sam has a big hat but now you can too.", ChatColor.RED, ChatColor.WHITE, ChatColor.BLUE), LineFormat.LORE), -8, SkinData.UNCLE_SAM), - PUMPKIN("Pumpkin Hat", UtilText.splitLineToArray(C.cGray + "Pumpkin on the head, don't end up dead!", LineFormat.LORE), -9, Material.PUMPKIN); + PUMPKIN("Pumpkin Hat", UtilText.splitLineToArray(C.cGray + "Pumpkin on the head, don't end up dead!", LineFormat.LORE), -9, Material.PUMPKIN), + CANADA("Warm Canadian Hat", UtilText.splitLineToArray(C.cGray + "Keep your ears nice and warm while up north.", LineFormat.LORE), -8, SkinData.CANADA_HAT), + AMERICA("Patriotic American Hat", UtilText.splitLineToArray(C.cGray + "Careful not to get a big head.", LineFormat.LORE), -8, SkinData.AMERICA_HAT), + + ; private final String _name; private final String[] _lore; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java new file mode 100644 index 000000000..f2af2f184 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java @@ -0,0 +1,266 @@ +package mineplex.core.gadget.gadgets.morph; + +import com.mojang.authlib.GameProfile; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.block.Banner; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import java.time.Month; +import java.time.YearMonth; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; + +/** + * Freedom fighter morph, capable of planting flags by crouching. + */ +public class MorphFreedomFighter extends MorphGadget +{ + /** How long it takes to plant a flag */ + private static final long FLAG_DELAY = 3500; + + /** How long between flag plantings */ + private static final long FLAG_COOLDOWN = 25000; + + /** Recharge key for planting flags */ + private static final String RECHARGE_KEY = "Plant Flag"; + + /** Design for beacon base */ + private static final int[][] BEACON_BASE = { + { 0, -2, 0}, {1, -2, 0}, {0, -2, 1}, {1, -2, 1}, + {-1, -2, 0}, {0, -2, -1}, {-1,-2,-1}, {0, -2, 1}, + {-1, -2, 1}, {1, -2, -1} + }; + + /** Active timers for players planting flags */ + private final Map _flagTimers = new HashMap<>(); + + /** Active timers for players that have planted flags */ + private final Map _flagCooldowns = new HashMap<>(); + + public MorphFreedomFighter(GadgetManager manager) + { + super(manager, "Freedom Fighter", UtilText.splitLinesToArray(new String[] { + C.cGray + "Fight for your freedom from tyranny and oppressors!", + "", + C.cGreen + "Hold sneak" + C.cWhite + " to plant a flag of freedom!", + }, LineFormat.LORE), -14, Material.CHAINMAIL_CHESTPLATE, (byte) 0, YearMonth.of(2017, Month.JULY)); + } + + /** + * Sets the player's skin. + */ + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + GameProfile profile = UtilGameProfile.getGameProfile(player); + profile.getProperties().clear(); + profile.getProperties().put("textures", SkinData.REVOLUTIONARY.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile); + disguisePlayer.showInTabList(true, 0); + UtilMorph.disguise(player, disguisePlayer, Manager); + + } + + /** + * Restores the player's skin + */ + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + // Clear cooldown timers + if (event.getType() == UpdateType.SEC) + { + Iterator> itr = _flagCooldowns.entrySet().iterator(); + + while (itr.hasNext()) + { + Map.Entry entry = itr.next(); + + if (entry.getValue() + FLAG_COOLDOWN < System.currentTimeMillis()) + { + itr.remove(); + } + } + } + + // For all active cosmetics + for (Player player : getActive()) + { + UUID uuid = player.getUniqueId(); + + // If the player is attempting to place a flag + if (_flagTimers.containsKey(uuid) && !_flagCooldowns.containsKey(uuid)) + { + // Mark them as no longer attempting to place if not sneaking + if (!player.isSneaking()) + { + _flagTimers.remove(uuid); + continue; + } + + // If the players has waiting long enough to place the flag + if (_flagTimers.get(uuid) + FLAG_DELAY < System.currentTimeMillis()) + { + boolean flag = false; + Location location = player.getLocation().subtract(0, 0.5, 0); + + // Make sure the ground is flat enough to place the flag + for (int i = 0; i < BEACON_BASE.length; ++i) + { + Block b = location.clone().add(BEACON_BASE[i][0], 0, BEACON_BASE[i][2]).getBlock(); + + if (b.isEmpty()) + { + flag = true; + break; + } + } + + if (flag) + { + _flagTimers.remove(uuid); + player.sendMessage(F.main("Morphs", C.cRed + "You must plant your flag on flatter ground.")); + } + else + { + // handle placing the flag + if (Recharge.Instance.use(player, RECHARGE_KEY, FLAG_COOLDOWN, true, false)) + { + _flagTimers.remove(uuid); + _flagCooldowns.put(uuid, System.currentTimeMillis()); + buildStructure(player); + } + } + } + else + { + // Play particles leading up to placing the flag + int particleCount = (int) ((System.currentTimeMillis() - _flagTimers.get(uuid)) / 40); + UtilParticle.playParticleFor(player, UtilParticle.ParticleType.FIREWORKS_SPARK, + UtilMath.gauss(player.getLocation().add(0, 1, 0), 2, 6, 2), null, 0, particleCount, UtilParticle.ViewDist.NORMAL); + } + } + else // if the player is not attempting to or has already placed a flag + { + if (player.isSneaking()) + { + if (_flagCooldowns.containsKey(uuid)) + { + if (Recharge.Instance.usable(player, RECHARGE_KEY, true)) + { + _flagCooldowns.remove(uuid); + } + } + else + { + _flagTimers.put(uuid, System.currentTimeMillis()); + _flagCooldowns.remove(uuid); + } + } + } + } + } + + /** + * Builds the structure and beacon by the player. + */ + private void buildStructure(Player player) + { + World world = player.getWorld(); + BlockRestore restore = Manager.getBlockRestore(); + int r = ThreadLocalRandom.current().nextInt(3); + byte data = r == 0 ? (byte) 14 : r == 1 ? (byte) 0 : 11; + Location point = player.getLocation().subtract(0, 0.5, 0); + + while (point.getY() > 1 && !(UtilBlock.fullSolid(point.getBlock()) || UtilBlock.airFoliage(point.getBlock()))) + { + point.setY(point.getY() - 1); + } + + Block glass = point.getBlock().getRelative(BlockFace.UP); + restore.add(glass, Material.STAINED_GLASS.getId(), data, FLAG_COOLDOWN); + glass = glass.getRelative(BlockFace.UP); + restore.add(glass, Material.STAINED_GLASS.getId(), data, FLAG_COOLDOWN); + + BlockFace[] faces = { BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST, BlockFace.EAST }; + Block[] blocks = { glass.getRelative(BlockFace.NORTH), glass.getRelative(BlockFace.SOUTH), + glass.getRelative(BlockFace.WEST), glass.getRelative(BlockFace.EAST) }; + + restore.add(glass.getRelative(BlockFace.UP), Material.CARPET.getId(), data, FLAG_COOLDOWN - 50); + + for (int i = 0; i < 4; ++i) + { + restore.add(blocks[i], Material.WALL_BANNER.getId(), (byte) i, blocks[i].getTypeId(), blocks[i].getData(), FLAG_COOLDOWN - 100); + } + + for (int i = 0; i < 4; ++i) + { + Banner state = ((Banner) blocks[i].getState()); + org.bukkit.material.Banner stateData = (org.bukkit.material.Banner) state.getData(); + stateData.setFacingDirection(faces[i]); + CountryFlag flag = i < 2 ? CountryFlag.USA : CountryFlag.CANADA; + state.setBaseColor(flag.getBaseColor()); + state.setPatterns(flag.getPatterns()); + state.update(); + } + + restore.add(point.getBlock(), Material.PISTON_BASE.getId(), (byte) 0, FLAG_COOLDOWN); + + point.subtract(0, 1, 0); + restore.add(point.getBlock(), Material.PISTON_BASE.getId(), (byte) 0, FLAG_COOLDOWN); + + restore.add(point.getBlock().getRelative(BlockFace.DOWN), Material.BEACON.getId(), (byte) 0, FLAG_COOLDOWN); + + for (int i = 0; i < BEACON_BASE.length; ++i) + { + restore.add(world.getBlockAt(point.clone().add(BEACON_BASE[i][0], BEACON_BASE[i][1], BEACON_BASE[i][2])), + Material.IRON_BLOCK.getId(), (byte) 0, FLAG_COOLDOWN); + } + + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.HUGE_EXPLOSION, player.getLocation(), null, 0, 1, UtilParticle.ViewDist.NORMAL); + player.playSound(player.getLocation(), Sound.EXPLODE, 1.0f, 1.0f); + player.teleport(player.getLocation().add(0, 2.5, 0)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java new file mode 100644 index 000000000..4b2ce16c6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java @@ -0,0 +1,168 @@ +package mineplex.core.gadget.gadgets.morph; + +import com.mojang.authlib.GameProfile; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.utils.UtilGameProfile; +import org.apache.commons.lang3.tuple.Pair; +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; + +import java.time.Month; +import java.time.YearMonth; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; + +/** + * PPC Reward for month of August 2017. Allows users to turn other player's heads into various fruits. + */ +public class MorphMelonHead extends MorphGadget +{ + /** Fruit head texture options */ + private static final Pair[] TEXTURES = { + Pair.of(SkinData.APPLE, C.cDRedB + "Apple Head"), + Pair.of(SkinData.MELON, C.cDGreenB + "Melon Head"), + Pair.of(SkinData.ORANGE, C.cGoldB + "Orange Head"), + Pair.of(SkinData.STRAWBERRY, C.cRedB + "Berry Head"), + Pair.of(SkinData.PINEAPPLE, C.cYellowB + "Pineapple Head"), + Pair.of(SkinData.GREEN_APPLE, C.cGreenB + "Apple Head"), + Pair.of(SkinData.PLUM, C.cPurpleB + "Plum Head") + }; + + /** Ticks that a fruit head change lasts */ + private static final long TIME = 240; + + /** Map of players to their current fruit heads */ + private final Map _heads = new HashMap<>(); + + public MorphMelonHead(GadgetManager manager) + { + super(manager, "Melonhead Morph", UtilText.splitLinesToArray(new String[] { + C.cGray + "Transform yourself into a melon.", + C.cGray + "Tag other players to build your melon army!", + "", + C.cGreen + "Left click" + C.cWhite + " players to turn their heads to fruit." + }, LineFormat.LORE), -14, Material.MELON, (byte) 0, YearMonth.of(2017, Month.AUGUST)); + } + + /** + * Sets the player's skin to a Melon texture. + */ + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + GameProfile profile = UtilGameProfile.getGameProfile(player); + profile.getProperties().clear(); + profile.getProperties().put("textures", SkinData.MELON_PERSON.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile); + disguisePlayer.showInTabList(true, 0); + UtilMorph.disguise(player, disguisePlayer, Manager); + } + + /** + * Restores the player's skin. + */ + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + } + + /** + * Detect when a player punches another player. + */ + @EventHandler + public void handlePlayerInteract(EntityDamageByEntityEvent event) + { + // Check it's two players interacting + if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) + { + if (!isActive((Player) event.getDamager())) + { + return; + } + + Player player = (Player) event.getEntity(); + + // do nothing if the player has a helmet already + if (player.getInventory().getHelmet() != null) + { + return; + } + + // do nothing if the player is supposed to already have a fruit helmet + if (_heads.containsKey(player.getUniqueId())) + { + return; + } + + // select a head skin and name it + Pair data = TEXTURES[ThreadLocalRandom.current().nextInt(TEXTURES.length)]; + ItemStack head = data.getLeft().getSkull(data.getRight(), new ArrayList<>()); + + // equip the head and notify the player of the action + _heads.put(player.getUniqueId(), head); + player.getInventory().setHelmet(head); + player.getWorld().playSound(player.getEyeLocation(), Sound.CHICKEN_EGG_POP, 1, 0); + UtilFirework.playFirework(player.getEyeLocation(), FireworkEffect.builder().withColor(Color.LIME).with(FireworkEffect.Type.BALL).build()); + player.sendMessage(F.main("Melonhead", C.cYellow + "Wham! " + C.cGray + "You just got " + C.cGreen + "MELON'D!")); + + // schedule the head to be removed later + Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), () -> + { + // don't do anything if the player has logged off + if (_heads.containsKey(player.getUniqueId())) + { + ItemStack item = _heads.remove(player.getUniqueId()); + + // don't remove the helmet if it has already been changed. + if (player.getInventory().getHelmet() != null && player.getInventory().getHelmet().equals(item)) + { + player.getInventory().setHelmet(null); + + } + } + + }, TIME); + } + } + + + /** + * Clean hash maps on player disconnect. + */ + @EventHandler + public void onPlayerDisconnect(PlayerQuitEvent event) + { + if (isActive(event.getPlayer())) + { + if (_heads.containsKey(event.getPlayer().getUniqueId())) + { + _heads.remove(event.getPlayer().getUniqueId()); + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/vampire/ParticleBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleBlood.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/vampire/ParticleBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleBlood.java index a33078067..0c3c3546a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/vampire/ParticleBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.vampire; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/candycane/ParticleCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java similarity index 93% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/candycane/ParticleCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java index 4d8b223fc..e9e572f19 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/candycane/ParticleCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.candycane; +package mineplex.core.gadget.gadgets.particle; import java.util.HashMap; import java.util.UUID; @@ -63,7 +63,7 @@ public class ParticleCandyCane extends ParticleGadget UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 1), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); - UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 2), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); + UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java index 236bc1e8a..651993fb9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java @@ -1,5 +1,6 @@ package mineplex.core.gadget.gadgets.particle; +import mineplex.core.common.util.UtilMath; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -27,7 +28,7 @@ public class ParticleCoalFumes extends ParticleGadget @Override public void playParticle(Player player, UpdateEvent event) { - if(event.getType() != UpdateType.TICK) return; + if(event.getType() != UpdateType.FASTER) return; float xz = 1; int amount = 5; @@ -39,6 +40,6 @@ public class ParticleCoalFumes extends ParticleGadget amount = 2; } - UtilParticle.playParticleFor(player, type, player.getLocation(), xz, 0, xz, 0, amount, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, type, UtilMath.gauss(player.getLocation(), 2, 6, 2), xz, 0, xz, 0, amount, ViewDist.NORMAL); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/emerald/ParticleEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEmerald.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/emerald/ParticleEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEmerald.java index 417587dbb..f81361c66 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/emerald/ParticleEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.emerald; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/wisdom/ParticleEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/wisdom/ParticleEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java index f8d734e74..706c32fbd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/wisdom/ParticleEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.wisdom; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoot.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoot.java index 9c3b8be54..fd315fc04 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoot.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.shadow; +package mineplex.core.gadget.gadgets.particle; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/frostlord/ParticleFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/frostlord/ParticleFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java index 62c1388b3..32f947e47 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/frostlord/ParticleFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.frostlord; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Material; import org.bukkit.Sound; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java similarity index 84% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java index dea6a85aa..c48b0ddb4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java @@ -1,5 +1,6 @@ -package mineplex.core.gadget.gadgets.particle.cupidslove; +package mineplex.core.gadget.gadgets.particle; +import mineplex.core.common.util.UtilMath; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -37,11 +38,11 @@ public class ParticleHeart extends ParticleGadget { if(getSet() == null || !getSet().isActive(player)) return; - UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1, 0), null, 0, 1, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1.2, 0), null, 0, 1, ViewDist.NORMAL); } else { - UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, ParticleType.HEART, UtilMath.gauss(player.getLocation(), 1, 3, 1).add(0, 1.2, 0), null, 0, 1, ViewDist.NORMAL); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java index f99338a75..9f1a9afa4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java @@ -1,6 +1,8 @@ package mineplex.core.gadget.gadgets.particle; -import org.bukkit.Effect; +import java.awt.*; + +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -9,6 +11,8 @@ import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ParticleGadget; @@ -19,10 +23,36 @@ import mineplex.core.updater.event.UpdateEvent; public class ParticleLegend extends ParticleGadget { + private static final double PI = Math.PI; + private static final int BASE_PILLARS = 9; + private static final int PILLAR_VARIANCE = 8; + private static final int MOVING_PARTICLES = 8; + private static final double VERTICAL_SPEED = 0.1; + private static final double HEIGHT_VARIANCE = 0.8; + private static final double ROTATIONAL_SPEED = .03; + private static final double RADIAL_VARIANCE = 0.09; + private static final double BASE_RADIUS = 1.30; + private static final double HEIGHT_MODIFIER_BASE = 0.1; + private static final double HEIGHT_MODIFIER_MAX = 1.3; + private static final double HEIGHT_MODIFIER_INTERVAL = 0.15; + private static final Color[] SELECTABLE_COLORS = { + new Color(60, 170, 25), + new Color(33, 92, 13), + new Color(0, 0, 0) + }; + + private final int _pillars = pillars(); + private final Color[] _colors = colors(); + private final double[] _heights = heights(); + private final double[] _verticals = verticals(); + private final double[] _variance = variances(); + private final double[] _thetas = thetas(); + private final double[] _radii = radii(); + public ParticleLegend(GadgetManager manager) { super(manager, "Legendary Aura", - UtilText.splitLineToArray(C.cGray + "This particle will be updated soon! Yay!", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "Legendary energy protects you.", LineFormat.LORE), -1, Material.ENDER_PORTAL_FRAME, (byte)0); } @@ -31,11 +61,150 @@ public class ParticleLegend extends ParticleGadget public void playParticle(Player player, UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } - player.getWorld().playEffect(player.getLocation().add(0, 1, 0), Effect.ENDER_SIGNAL, 0); + if (Manager.isMoving(player)) + { + + for (int i = 0; i < MOVING_PARTICLES; i++) + { + if (_colors[i % _colors.length].getGreen() == 0) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.SMOKE, + UtilMath.gauss(player.getLocation(), 8, 4, 8), null, 0, 1, UtilParticle.ViewDist.NORMAL); + } + else + { + UtilParticle.playColoredParticleToAll(_colors[i % _colors.length], UtilParticle.ParticleType.RED_DUST, + UtilMath.gauss(player.getLocation(), 8, 4, 8), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + else + { + if (event.getTick() % (ROTATIONAL_SPEED * 100) == 0) + { + for (int i = 0; i < _pillars; i++) + { + _thetas[i] = rollover(_thetas[i], ROTATIONAL_SPEED); + _heights[i] = rollover(_heights[i], _verticals[i]); + + double x = (_radii[i] * Math.cos(_thetas[i])) + player.getLocation().getX(); + double z = (_radii[i] * Math.sin(_thetas[i])) + player.getLocation().getZ(); + double y = (Math.sin(_heights[i]) * _variance[i]) + player.getLocation().getY(); + + for (double h = HEIGHT_MODIFIER_BASE; h <= HEIGHT_MODIFIER_MAX; h+= HEIGHT_MODIFIER_INTERVAL) + { + if (_colors[i].getGreen() == 0) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.SMOKE, + new Location(player.getWorld(), x, y + h, z), null, 0, 1, UtilParticle.ViewDist.NORMAL); + } + else + { + UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, + new Location(player.getWorld(), x, y + h, z), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + } + } } - + + private double[] heights() + { + double[] array = new double[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + array[i] = 6.28 * Math.random(); + } + + return array; + } + + private double[] variances() + { + double[] array = new double[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + array[i] = Math.random() * HEIGHT_VARIANCE; + } + + return array; + } + + private double[] verticals() + { + double[] array = new double[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + array[i] = Math.random() * VERTICAL_SPEED; + } + + return array; + } + + private double[] thetas() + { + double[] array = new double[_pillars]; + double theta = 0; + double interval = (2 * PI) / _pillars; + + for (int i = 0; i < _pillars; i++) + { + array[i] = theta; + theta += interval; + } + + return array; + } + + private double[] radii() + { + double[] array = new double[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + array[i] = BASE_RADIUS + (Math.random() * RADIAL_VARIANCE); + } + + return array; + } + + private Color[] colors() + { + Color[] array = new Color[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + array[i] = SELECTABLE_COLORS[i % SELECTABLE_COLORS.length]; + } + + return array; + } + + private int pillars() + { + return BASE_PILLARS + (int) ((Math.random() * PILLAR_VARIANCE) - (PILLAR_VARIANCE / 2)); + } + + private double rollover(double value, double additive) + { + value += additive; + + if (value >= 2 * PI) + { + value = value - (2 * PI); + } + + return value; + } + @EventHandler public void legendOwner(PlayerJoinEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/music/ParticleMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMusic.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/music/ParticleMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMusic.java index 04874fffc..e0bbb3537 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/music/ParticleMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.music; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/party/ParticlePartyTime.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/party/ParticlePartyTime.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java index 3aab6f928..a3944317c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/party/ParticlePartyTime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.party; +package mineplex.core.gadget.gadgets.particle; import java.util.Arrays; import java.util.Collections; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/howlingwinds/ParticleRain.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/howlingwinds/ParticleRain.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java index f2c45007c..4311666c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/howlingwinds/ParticleRain.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.howlingwinds; +package mineplex.core.gadget.gadgets.particle; import java.util.ArrayList; import java.util.List; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java index b5f02de23..7d062f713 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.titan; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java new file mode 100644 index 000000000..2e68270e5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java @@ -0,0 +1,194 @@ +package mineplex.core.gadget.gadgets.particle.freedom; + +import mineplex.core.arcadeevents.CoreGameStartEvent; +import mineplex.core.arcadeevents.CoreGameStopEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.treasure.event.TreasureFinishEvent; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockPhysicsEvent; + +import java.awt.Color; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; +import java.util.stream.Collectors; + +/** + * Places flowers around the player with poofs of red and white + */ +public class ParticleAuraNiceness extends ParticleGadget +{ + /** Radius within which flowers not allowed near treasure chests */ + private static final int TREASURE_RADIUS = 4; + + /** Horizontal offset for particle spawns */ + private static final double H_FIELD = 0.5; + + /** Vertical offset for particle spawns */ + private static final double V_FIELD = 0.35; + + /** How likely a flower is to be spawned (1/n) */ + private static final int ROSE_PROBABILITY = 40; + + /** Radius in which flowers are spawned */ + private static final double ROSE_RADIUS = 2.5; + + /** How many particles accompany each flower spawn */ + private static final int PARTICLE_COUNT = 20; + + /** List of blocks that have flowers in them */ + private final Set _blocks = new HashSet<>(); + + /** Milliseconds for which flowers persist */ + private final long DURATION = 5000; + + /** Locations at which treasure is currently being opened */ + private final Map _openingTreasure = new HashMap<>(); + + /** Whether flowers can be spawned in addition to particles */ + private boolean _enabled = true; + + public ParticleAuraNiceness(GadgetManager manager) + { + super(manager, "Aura of Niceness", + UtilText.splitLineToArray(C.cGray + "Canadians are always nice online.", LineFormat.LORE), -8, Material.WOOL, + (byte) 0); + + setDisplayItem(CountryFlag.CANADA.getBanner()); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + { + return; + } + + for (Location location : _openingTreasure.values()) + { + if (location.toVector().isInSphere(player.getLocation().toVector(), TREASURE_RADIUS)) + { + return; + } + } + + UtilShapes.getCircle(player.getLocation().subtract(0, 0.5, 0), false, ROSE_RADIUS).stream().map(Location::getBlock) + .collect(Collectors.toSet()).forEach(block -> + { + if (ThreadLocalRandom.current().nextInt(ROSE_PROBABILITY) == 0) + { + Block b = block.getRelative(BlockFace.UP); + + if (b.isEmpty() && UtilBlock.fullSolid(block) && !UtilBlock.bottomSlab(block)) + { + Location loc = b.getLocation().add(H_FIELD, V_FIELD, H_FIELD); + + if (_enabled) + { + byte data = ThreadLocalRandom.current().nextInt(2) == 0 ? (byte) 4 : 6; + + _blocks.add(b); + Manager.getBlockRestore().add(b, Material.RED_ROSE.getId(), data, DURATION); + } + + for (int i = 0; i < PARTICLE_COUNT; ++i) + { + UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 4, 4, 4), 0, UtilParticle.ViewDist.NORMAL); + UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 4, 4, 4), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + }); + + for(Iterator it = _blocks.iterator(); it.hasNext();) + { + Block b = it.next(); + + if (b.getType() != Material.RED_ROSE) + { + it.remove(); + Location loc = b.getLocation().add(H_FIELD, V_FIELD, H_FIELD); + for (int i = 0; i < PARTICLE_COUNT / 2; ++i) + { + UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 6, 6, 6), 0, UtilParticle.ViewDist.NORMAL); + UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 6, 6, 6), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + } + + /** + * Stop flowers from popping off of blocks + */ + @EventHandler + public void onBlockFade(BlockPhysicsEvent event) + { + if (_blocks.contains(event.getBlock())) + { + event.setCancelled(true); + } + } + + /** + * Disable flowers in the area around treasure being opened. + */ + @EventHandler(priority = EventPriority.LOW) + public void disableOnTreasureStart(TreasureStartEvent event) + { + _openingTreasure.put(event.getPlayer().getUniqueId(), event.getPlayer().getLocation()); + Manager.getBlockRestore().restoreBlockAround(Material.CARPET, event.getPlayer().getLocation(), TREASURE_RADIUS); + } + + /** + * Enable flowers in the area around treasure no longer being opened. + */ + @EventHandler(priority = EventPriority.HIGH) + public void enableOnTreasureFinish(TreasureFinishEvent event) + { + if (_openingTreasure.containsKey(event.getPlayer().getUniqueId())) + { + _openingTreasure.remove(event.getPlayer().getUniqueId()); + } + } + + /** + * Disable flowers on game start + */ + @EventHandler + public void onGameStart(CoreGameStartEvent event) + { + _enabled = false; + } + + /** + * Enable flowers on game end + */ + @EventHandler + public void onGameEnd(CoreGameStopEvent event) + { + _enabled = true; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java new file mode 100644 index 000000000..4770908b9 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java @@ -0,0 +1,71 @@ +package mineplex.core.gadget.gadgets.particle.freedom; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; + +import java.awt.Color; + +/** + * Leaves a trail behind the player with the colors of the Canadian flag. + */ +public class ParticleCanadian extends ParticleGadget +{ + /** # of lines of particles */ + private static final int STRAND_COUNT = 9; + + /** How far apart each line of particles is */ + private static final double STRAND_SPACING = 0.124; + + /** How far off the floor the particles begin */ + private static final double DISTANCE_FROM_FLOOR = 0.43; + + public ParticleCanadian(GadgetManager manager) + { + super(manager, "Canadian Trail", + UtilText.splitLineToArray(C.cGray + "Lead the way to freedom!", LineFormat.LORE), + -8, Material.WOOL, (byte) 0); + + setDisplayItem(CountryFlag.CANADA.getBanner()); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Location center = player.getLocation().subtract(player.getLocation().getDirection().multiply(0.4)) + .subtract(0, 0.1, 0).add(0, DISTANCE_FROM_FLOOR, 0); + + if (Manager.isMoving(player)) + { + for (int i = 0; i < STRAND_COUNT; i++) + { + if (i < 3 || i > 5) + { + UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, + center.add(0, STRAND_SPACING, 0), 0, UtilParticle.ViewDist.NORMAL); + } + else + { + UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, + center.add(0, STRAND_SPACING, 0), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java new file mode 100644 index 000000000..a7a18702e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java @@ -0,0 +1,59 @@ +package mineplex.core.gadget.gadgets.particle.freedom; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.util.concurrent.ThreadLocalRandom; + +/** + * Small fireworks which explode around the player + */ +public class ParticleFreedomFireworks extends ParticleGadget +{ + /** Block types to source for particles */ + private static final Material[] BLOCKTYPES = { + Material.REDSTONE_BLOCK, + Material.LAPIS_BLOCK, + Material.QUARTZ_BLOCK + }; + + /** Amount of particles for each firework */ + private static final int PARTICLE_COUNT = 20; + + public ParticleFreedomFireworks(GadgetManager manager) + { + super(manager, "Freedom Fireworks", + UtilText.splitLineToArray(C.cGray + "Keep your patriotism close.", LineFormat.LORE), + -8, Material.WOOL, (byte) 0); + + setDisplayItem(CountryFlag.USA.getBanner()); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + String particle = UtilParticle.ParticleType.BLOCK_CRACK.getParticle(BLOCKTYPES[ThreadLocalRandom.current().nextInt(0, BLOCKTYPES.length)], 0); + Location location = UtilMath.gauss(player.getEyeLocation(), 1, 1, 1); + + for (int i = 0; i < PARTICLE_COUNT; ++i) + { + UtilParticle.PlayParticleToAll(particle, location, null, 3.0f, 1, UtilParticle.ViewDist.NORMAL); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java new file mode 100644 index 000000000..7ad601f9a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java @@ -0,0 +1,81 @@ +package mineplex.core.gadget.gadgets.particle.freedom; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import java.awt.*; + + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class ParticleStarSpangled extends ParticleGadget +{ + private static final int STRAND_COUNT = 9; + private static final double STRAND_SPACING = 0.124; + private static final double DISTANCE_FROM_FLOOR = 0.43; + + private static final Color BLUE = new Color(29, 26, 120); + + public ParticleStarSpangled(GadgetManager manager) + { + super(manager, "Star Spangled Stripe", + UtilText.splitLineToArray(C.cGray + "Blaze a trail of freedom!", LineFormat.LORE), + -8, Material.WOOL, (byte) 0); + setDisplayItem(CountryFlag.USA.getBanner()); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Location center = player.getLocation().subtract(player.getLocation().getDirection().multiply(0.4)) + .subtract(0, 0.1, 0).add(0, DISTANCE_FROM_FLOOR, 0); + + if (Manager.isMoving(player)) + { + for (int i = 0; i < STRAND_COUNT; i++) + { + if (i == 3 || i == 7) + { + if (player.getTicksLived() % 3 == 0) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.FIREWORKS_SPARK, + center.add(0, STRAND_SPACING, 0), 0f, 0f, 0f, 0f, 0, UtilParticle.ViewDist.NORMAL); + continue; + } + } + else if (i == 5) + { + if (player.getTicksLived() + 1 % 3 == 0) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.FIREWORKS_SPARK, + center.add(0, STRAND_SPACING, 0), 0f, 0f, 0f, 0f, 0, UtilParticle.ViewDist.NORMAL); + continue; + } + } + + UtilParticle.playColoredParticleToAll(BLUE, UtilParticle.ParticleType.RED_DUST, + center.add(0, STRAND_SPACING, 0), 0, UtilParticle.ViewDist.NORMAL); + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java index fdc5da288..c246b2975 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java @@ -35,10 +35,12 @@ public class BlowAKissTaunt extends TauntGadget } @Override - public void onStart(Player player) + public boolean onStart(Player player) { if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) - return; + { + return false; + } HashSet ignore = new HashSet<>(); ignore.add(Material.AIR); @@ -46,6 +48,8 @@ public class BlowAKissTaunt extends TauntGadget BlowAKissEffect blowAKissEffect = new BlowAKissEffect(player, loc, this); blowAKissEffect.start(); + + return true; } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java index 103efacd2..6e0a7e133 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java @@ -6,6 +6,8 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.game.GameDisplay; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -28,9 +30,7 @@ import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.events.EnableArcadeSpawnEvent; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.TauntGadget; -import mineplex.core.game.GameDisplay; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -41,7 +41,8 @@ public class EternalTaunt extends TauntGadget private static final int COOLDOWN = 30000; private static final int PVP_COOLDOWN = 10000; - private Map> _clocks = new HashMap<>(); + private final Map> _clocks = new HashMap<>(); + private final Map _disguises = new HashMap<>(); public EternalTaunt(GadgetManager manager) { @@ -50,33 +51,48 @@ public class EternalTaunt extends TauntGadget C.cWhite + "Use /taunt in game to show how long you've been waiting.", C.cRed + "Cannot be used while in PvP!"}, LineFormat.LORE), -15, Material.WATCH, (byte) 0); + setCanPlayWithPvp(false); setPvpCooldown(PVP_COOLDOWN); setShouldPlay(true); setEventType(UpdateType.FAST); - addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination); + addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination, GameDisplay.SmashTraining); } @Override - public void onStart(Player player) + public boolean onStart(Player player) { if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) - return; + { + return false; + } + UtilFirework.playFirework(player.getLocation(), FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.fromRGB(255, 175, 175)).withFade(Color.RED).build()); _clocks.put(player.getUniqueId(), new ArrayList<>()); Bukkit.broadcastMessage(F.main("Taunt", F.name(player.getName()) + " waited so long they turned to bones.")); - DisguiseSkeleton disguiseSkeleton = new DisguiseSkeleton(player); - UtilMorph.disguise(player, disguiseSkeleton, Manager); + if (!Manager.getDisguiseManager().isDisguised(player)) + { + DisguiseSkeleton disguiseSkeleton = new DisguiseSkeleton(player); + disguiseSkeleton.setName(player.getName()); + disguiseSkeleton.setCustomNameVisible(true); + disguiseSkeleton.showArmor(); + Manager.getDisguiseManager().disguise(disguiseSkeleton); + _disguises.put(player.getUniqueId(), disguiseSkeleton); + } + + return true; } @Override public void onPlay(Player player) { if (!_clocks.containsKey(player.getUniqueId())) + { return; + } int i = getPlayerTicks(player); @@ -114,7 +130,11 @@ public class EternalTaunt extends TauntGadget @Override public void onFinish(Player player) { - UtilMorph.undisguise(player, Manager.getDisguiseManager()); + if (_disguises.containsKey(player.getUniqueId())) + { + Manager.getDisguiseManager().undisguise(_disguises.remove(player.getUniqueId())); + } + if (_clocks.containsKey(player.getUniqueId())) { _clocks.get(player.getUniqueId()).forEach(c -> c.remove()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java index de81b6a1b..6a49fe8c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java @@ -36,10 +36,12 @@ public class RainbowTaunt extends TauntGadget } @Override - public void onStart(Player player) + public boolean onStart(Player player) { if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) - return; + { + return false; + } Vector dir = player.getLocation().getDirection(); Vector sideA = dir.clone().setX(-dir.getZ()).setZ(dir.getX()); @@ -51,6 +53,8 @@ public class RainbowTaunt extends TauntGadget RainbowTauntEffect rainbowTauntEffect = new RainbowTauntEffect(start, Manager.getPlugin()); rainbowTauntEffect.setTargetLocation(new EffectLocation(end)); rainbowTauntEffect.start(); + + return true; } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java new file mode 100644 index 000000000..0b18eca18 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java @@ -0,0 +1,22 @@ +package mineplex.core.gadget.set; + +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; +import mineplex.core.gadget.types.GadgetSet; + +public class SetCanadian extends GadgetSet +{ + + public SetCanadian(GadgetManager manager) + { + super(manager, "Canadian", "2x Holiday Points while active (Titles)", + manager.getGadget(ArrowTrailRedWhite.class), + manager.getGadget(DeathMapleLeaf.class), + manager.getGadget(DoubleJumpMaple.class), + manager.getGadget(ParticleCanadian.class)); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java index e6f6f5707..c9b059480 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; -import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.death.DeathCandyCane; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; import mineplex.core.gadget.types.GadgetSet; public class SetCandyCane extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java index ccbaf0863..dca2f191c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; -import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart; -import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; -import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; +import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; import mineplex.core.gadget.types.GadgetSet; public class SetCupidsLove extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java index b34a8f88e..26df2fd6f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; -import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald; -import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; -import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.death.DeathEmerald; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.particle.ParticleEmerald; import mineplex.core.gadget.types.GadgetSet; public class SetEmerald extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java index 6196a145b..a64e2caf3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; -import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import mineplex.core.gadget.types.GadgetSet; public class SetFreedom extends GadgetSet @@ -16,7 +16,7 @@ public class SetFreedom extends GadgetSet manager.getGadget(ArrowTrailFreedom.class), manager.getGadget(DeathFreedom.class), manager.getGadget(DoubleJumpFreedom.class), - manager.getGadget(ParticleFreedom.class)); + manager.getGadget(ParticleStarSpangled.class)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java index 6112655a0..311600e5e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; -import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; -import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.death.DeathFrostLord; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; import mineplex.core.gadget.types.GadgetSet; public class SetFrostLord extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java index 120a35c95..668503111 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; -import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; -import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; -import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; +import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.particle.ParticleRain; import mineplex.core.gadget.types.GadgetSet; public class SetHowlingWinds extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java index 9e606f0e2..50eef82a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.death.music.DeathMusic; -import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; +import mineplex.core.gadget.gadgets.death.DeathMusic; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; +import mineplex.core.gadget.gadgets.particle.ParticleMusic; import mineplex.core.gadget.types.GadgetSet; public class SetMusic extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java index f9debaef0..f22ce959e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; -import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; -import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; -import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.death.DeathPinataBurst; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; +import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; import mineplex.core.gadget.types.GadgetSet; public class SetParty extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java index befc2e27c..80b751d7d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; -import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; -import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; -import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; +import mineplex.core.gadget.gadgets.death.DeathShadow; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; +import mineplex.core.gadget.gadgets.particle.ParticleFoot; import mineplex.core.gadget.types.GadgetSet; public class SetShadow extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java index 77727b480..fb21b5f9e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; -import mineplex.core.gadget.gadgets.death.spring.DeathSpring; -import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.death.DeathSpring; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java index 7c66a8f6c..360d86270 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.titan.ArrowTrailTitan; -import mineplex.core.gadget.gadgets.death.titan.DeathTitan; -import mineplex.core.gadget.gadgets.doublejump.titan.DoubleJumpTitan; -import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan; +import mineplex.core.gadget.gadgets.death.DeathTitan; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan; +import mineplex.core.gadget.gadgets.particle.ParticleTitan; import mineplex.core.gadget.types.GadgetSet; public class SetTitan extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java index b070122de..1a5541085 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; -import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; +import mineplex.core.gadget.gadgets.death.DeathBlood; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; +import mineplex.core.gadget.gadgets.particle.ParticleBlood; import mineplex.core.gadget.types.GadgetSet; public class SetVampire extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java index 2d2ff0693..5bbae55da 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java @@ -1,10 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; -import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; -import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; +import mineplex.core.gadget.gadgets.death.DeathEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.types.GadgetSet; public class SetWisdom extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java new file mode 100644 index 000000000..3dabbad32 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java @@ -0,0 +1,93 @@ +package mineplex.core.gadget.types; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.flag.FlagType; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +/** + * Flags which sit upon players head. + */ +public class FlagGadget extends Gadget +{ + private final FlagType _flag; + + public FlagGadget(GadgetManager manager, FlagType flag) + { + super(manager, GadgetType.FLAG, "Flag of " + flag.getFlag().getCountryName(), + UtilText.splitLineToArray(C.cGray + "Fly the " + flag.getFlag().getCountryAdjective() + " flag atop your head!", LineFormat.LORE), + flag.getCost(), Material.WOOL, (byte) 0, 1, flag.getFlag().getCountryAdjective() + " Flag"); + + setDisplayItem(flag.getFlag().getBanner()); + _flag = flag; + } + + public void applyArmor(Player player, boolean message) + { + Manager.removeGadgetType(player, GadgetType.MORPH, this); + Manager.removeGadgetType(player, GadgetType.FLAG, this); + Manager.removeGadgetType(player, GadgetType.HAT, this); + Manager.removeOutfit(player, OutfitGadget.ArmorSlot.HELMET); + + _active.add(player); + + if (message) + { + UtilPlayer.message(player, F.main("Gadget", "You unfurled the " + F.elem(getName()) + ".")); + } + } + + public void removeArmor(Player player) + { + if (_active.remove(player)) + { + UtilPlayer.message(player, F.main("Gadget", "You took down the " + F.elem(getName()) + ".")); + } + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + ItemStack flag = _flag.getFlag().getBanner(); + ItemMeta meta = flag.getItemMeta(); + meta.setDisplayName(C.cGreenB + getDisplayName()); + meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); + flag.setItemMeta(meta); + player.getInventory().setHelmet(flag); + player.updateInventory(); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + player.getInventory().setHelmet(new ItemStack(Material.AIR)); + player.updateInventory(); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void playerDeath(PlayerDeathEvent event) + { + disable(event.getEntity()); + } + + /** + * @return The specific gadget which this represents. + */ + public FlagType getFlagType() + { + return _flag; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java index edc823e6d..386f764a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java @@ -18,7 +18,8 @@ public enum GadgetType WIN_EFFECT("Win Effects", "activeWinEffect"), GAME_MODIFIER("Game Modifiers", ""), BALLOON("Balloons", ""), - KIT_SELECTOR("Kit Selectors", "activeKitSelector"); + KIT_SELECTOR("Kit Selectors", "activeKitSelector"), + FLAG("Flags", "activeFlag"); private String _name; private String _databaseKey; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java index b6becadc1..38df4c367 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java @@ -47,7 +47,7 @@ public abstract class HatGadget extends OutfitGadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - + Manager.removeGadgetType(player, GadgetType.FLAG, this); Manager.removeOutfit(player, _slot); _active.add(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java index 4fb2b5ed9..7240ed1d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java @@ -26,7 +26,8 @@ public abstract class MorphGadget extends Gadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - Manager.removeGadgetType(player, GadgetType.COSTUME); + Manager.removeGadgetType(player, GadgetType.COSTUME, this); + Manager.removeGadgetType(player, GadgetType.FLAG, this); _active.add(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java index 6ce4d70b7..78471a943 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java @@ -60,7 +60,12 @@ public abstract class OutfitGadget extends Gadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - + + if (_slot == ArmorSlot.HELMET) + { + Manager.removeGadgetType(player, GadgetType.FLAG, this); + } + Manager.removeOutfit(player, _slot); _active.add(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java index 991a7425b..c0b11870d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java @@ -76,11 +76,13 @@ public abstract class TauntGadget extends Gadget public void start(Player player) { - onStart(player); - _ticksPerPlayer.put(player.getUniqueId(), 0); + if (onStart(player)) + { + _ticksPerPlayer.put(player.getUniqueId(), 0); + } } - public abstract void onStart(Player player); + public abstract boolean onStart(Player player); public void play(Player player) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 413dbbc8f..ac7c74b16 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -107,6 +107,8 @@ public enum GameDisplay MOBA("Heroes of GWEN", Material.PRISMARINE, (byte)0, GameCategory.CLASSICS, 70, true), MOBATraining("Heroes of GWEN Training", Material.PRISMARINE, (byte)0, GameCategory.CLASSICS, 70, false), + BattleRoyale("Battle Royale", Material.DIAMOND_SWORD, (byte)0, GameCategory.EVENT, 72, false), + GemHunters("Gem Hunters", Material.EMERALD, (byte) 0, GameCategory.SURVIVAL, 71, false), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999, false), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java new file mode 100644 index 000000000..9bd70c7db --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java @@ -0,0 +1,132 @@ +package mineplex.core.imagemap; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import net.minecraft.server.v1_8_R3.DataWatcher; +import net.minecraft.server.v1_8_R3.EntityItemFrame; +import net.minecraft.server.v1_8_R3.ItemStack; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; + +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItemFrame; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; + +import com.google.common.base.Optional; + +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.packethandler.PacketInfo; + +@ReflectivelyCreateMiniPlugin +public class CustomItemFrames extends MiniPlugin implements IPacketHandler +{ + + private final List _ourPackets; + private final Map> _frameData; + + private CustomItemFrames() + { + super("CustomItemFrames"); + + _ourPackets = new ArrayList<>(); + _frameData = new HashMap<>(); + } + + @Override + public void enable() + { + require(PacketHandler.class).addPacketHandler(this, PacketPlayOutEntityMetadata.class, PacketPlayInUseEntity.class); + } + + @Override + public void disable() + { + require(PacketHandler.class).removePacketHandler(this); + } + + @Override + public void handle(PacketInfo packetInfo) + { + if (packetInfo.getPacket() instanceof PacketPlayOutEntityMetadata) + { + if (_ourPackets.remove(packetInfo.getPacket())) + { + return; + } + + PacketPlayOutEntityMetadata packet = (PacketPlayOutEntityMetadata) packetInfo.getPacket(); + Map map = _frameData.get(packet.a); + + if (map != null) + { + UUID uuid = packetInfo.getPlayer().getUniqueId(); + ItemStack item = map.get(uuid); + + if (item != null) + { + for (DataWatcher.WatchableObject meta : packet.b) + { + if (meta.getIndex().a() == 8) + { + meta.a(item, Optional.fromNullable(item)); + break; + } + } + } + } + } + else if (packetInfo.getPacket() instanceof PacketPlayInUseEntity) + { + PacketPlayInUseEntity packet = (PacketPlayInUseEntity) packetInfo.getPacket(); + + if (_frameData.containsKey(packet.a)) + { + packetInfo.setCancelled(true); + } + } + } + + public void setItem(Player player, ItemFrame frame, org.bukkit.inventory.ItemStack item) + { + ItemStack nmsItem = CraftItemStack.asNMSCopy(item.clone()); + + DataWatcher.WatchableObject> frameMetaItem = new DataWatcher.WatchableObject<>(5, 8, nmsItem, EntityItemFrame.META_ITEM, Optional.fromNullable(nmsItem)); + + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(); + packet.a = frame.getEntityId(); + packet.b = Collections.singletonList(frameMetaItem); + + _ourPackets.add(packet); + + UtilPlayer.sendPacket(player, packet); + + _frameData.computeIfAbsent(frame.getEntityId(), HashMap::new).put(player.getUniqueId(), nmsItem); + } + + public void removeItems(ItemFrame frame) + { + _frameData.remove(frame.getEntityId()); + + ItemStack nmsItem = null; + EntityItemFrame nmsEntity = ((CraftItemFrame) frame).getHandle(); + + DataWatcher watcher = new DataWatcher(nmsEntity); + watcher.add(8, 5, EntityItemFrame.META_ITEM, Optional.fromNullable(nmsItem)); + + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(frame.getEntityId(), watcher, true); + + MinecraftServer.getServer().getPlayerList().players.forEach(player -> player.playerConnection.sendPacket(packet)); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java new file mode 100644 index 000000000..4cfc9486b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java @@ -0,0 +1,256 @@ +package mineplex.core.imagemap; + +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.imagemap.objects.PlayerMapBoard; +import mineplex.core.imagemap.objects.PlayerMapImage; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@ReflectivelyCreateMiniPlugin +public class ImageMapManager extends MiniPlugin +{ + + private static final String IMAGE_DIR = ".." + File.separator + ".." + File.separator + "update" + File.separator + "files"; + private static final int PIXELS_PER_MAP = 128; + + public static int getMapDimension() + { + return PIXELS_PER_MAP; + } + + private final CustomItemFrames _itemFrames; + + private final Map _imageCache; + private List _boards; + + private ImageMapManager() + { + super("Image Map"); + + _itemFrames = require(CustomItemFrames.class); + + _imageCache = new HashMap<>(); + _boards = new ArrayList<>(); + } + + @EventHandler + public void playerJoin(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + + runSyncLater(() -> _boards.forEach(board -> board.onPlayerJoin(player)), 40); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + _boards.forEach(board -> board.onPlayerQuit(player)); + } + + @EventHandler + public void refreshBoards(UpdateEvent event) + { + if (event.getType() != UpdateType.TWOSEC) + { + return; + } + + _boards.forEach(PlayerMapBoard::onRefresh); + } + + public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, String... images) + { + BufferedImage[] bufferedImages = new BufferedImage[images.length]; + + for (int i = 0; i < images.length; i++) + { + bufferedImages[i] = getImage(new File(IMAGE_DIR + File.separator + images[i])); + } + + return createPlayerBoard(topLeft, direction, width, height, bufferedImages); + } + + public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, File... images) + { + BufferedImage[] bufferedImages = new BufferedImage[images.length]; + + for (int i = 0; i < images.length; i++) + { + bufferedImages[i] = getImage(images[i]); + } + + return createPlayerBoard(topLeft, direction, width, height, bufferedImages); + } + + public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, URL... images) + { + BufferedImage[] bufferedImages = new BufferedImage[images.length]; + + for (int i = 0; i < images.length; i++) + { + bufferedImages[i] = getImage(images[i]); + } + + return createPlayerBoard(topLeft, direction, width, height, bufferedImages); + } + + public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, BufferedImage... images) + { + List itemFrames = createItemFrames(topLeft, direction, width, height); + List mapImageList = new ArrayList<>(); + + for (BufferedImage image : images) + { + PlayerMapImage mapImage = new PlayerMapImage(_itemFrames, image, itemFrames, width, height); + mapImage.create(); + + mapImageList.add(mapImage); + } + + PlayerMapBoard board = new PlayerMapBoard(topLeft, mapImageList); + + runSyncLater(() -> Bukkit.getOnlinePlayers().forEach(board::onPlayerJoin), 50); + + _boards.add(board); + return board; + } + + private List createItemFrames(Location topLeft, BlockFace direction, int width, int height) + { + List itemFrames = new ArrayList<>(); + + for (int x = 0; x < width; x++) + { + for (int y = 0; y < height; y++) + { + Location location = modLocation(topLeft, direction, x, y); + + Block opposite = location.getBlock().getRelative(direction.getOppositeFace()); + + if (!UtilBlock.solid(opposite)) + { + opposite.setType(Material.SMOOTH_BRICK); + } + + ItemFrame itemFrame = location.getWorld().spawn(location, ItemFrame.class); + itemFrame.setFacingDirection(direction, true); + itemFrames.add(itemFrame); + } + } + + return itemFrames; + } + + private Location modLocation(Location location, BlockFace direction, int x, int y) + { + int modX = 0; + int modZ = 0; + + switch (direction) + { + case NORTH: + modX = -x; + break; + case SOUTH: + modX = x; + break; + case WEST: + modZ = x; + break; + case EAST: + modZ = -x; + break; + } + + return new Location(location.getWorld(), location.getBlockX() + modX, location.getBlockY() - y, location.getBlockZ() + modZ); + } + + private BufferedImage getImage(File file) + { + if (_imageCache.containsKey(file.getName())) + { + return _imageCache.get(file.getName()); + } + + try + { + BufferedImage image = ImageIO.read(file); + _imageCache.put(file.getName(), image); + return image; + } + catch (IOException e) + { + e.printStackTrace(); + return null; + } + } + + private BufferedImage getImage(URL url) + { + if (_imageCache.containsKey(url.toString())) + { + return _imageCache.get(url.toString()); + } + + try + { + BufferedImage image = ImageIO.read(url); + _imageCache.put(url.toString(), image); + return image; + } + catch (IOException e) + { + e.printStackTrace(); + return null; + } + } + + public void cleanupBoard(PlayerMapBoard board) + { + _boards.remove(board); + + //TODO Fix when multiple boards are needed at one time + File dataDir = new File(board.getLocation().getWorld().getName() + File.separator + "data"); + if (dataDir.isDirectory()) + { + File[] files = dataDir.listFiles(); + + if (files != null) + { + for (File file : files) + { + if (file.getName().startsWith("map")) + { + file.delete(); + } + } + } + } + + board.cleanup(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapRenderer.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapRenderer.java new file mode 100644 index 000000000..7d83fe199 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapRenderer.java @@ -0,0 +1,41 @@ +package mineplex.core.imagemap; + +import org.bukkit.entity.Player; +import org.bukkit.map.MapCanvas; +import org.bukkit.map.MapRenderer; +import org.bukkit.map.MapView; + +import java.awt.*; +import java.awt.image.BufferedImage; + +public class ImageMapRenderer extends MapRenderer +{ + + private Image _image; + private boolean _rendered; + + public ImageMapRenderer(BufferedImage image, int x1, int y1) + { + int startX = Math.min(x1 * ImageMapManager.getMapDimension(), image.getWidth()); + startX = Math.max(image.getMinX(), startX); + int startY = Math.min(y1 * ImageMapManager.getMapDimension(), image.getHeight()); + startY = Math.max(image.getMinY(), startY); + + if (startX + ImageMapManager.getMapDimension() > image.getWidth() || startY + ImageMapManager.getMapDimension() > image.getHeight()) + { + return; + } + + _image = image.getSubimage(startX, startY, ImageMapManager.getMapDimension(), ImageMapManager.getMapDimension()); + } + + @Override + public void render(MapView view, MapCanvas canvas, Player player) + { + if (_image != null && !_rendered) + { + canvas.drawImage(0, 0, _image); + _rendered = true; + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapBoardSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapBoardSelector.java new file mode 100644 index 000000000..c0a57e7c2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapBoardSelector.java @@ -0,0 +1,146 @@ +package mineplex.core.imagemap.objects; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class MapBoardSelector implements Listener +{ + + private final PlayerMapBoard _board; + private ArmorStand _goNext; + private Slime _goNextBox; + private ArmorStand _goBack; + private Slime _goBackBox; + + public MapBoardSelector(PlayerMapBoard board) + { + _board = board; + + UtilServer.RegisterEvents(this); + } + + public void createHolograms(Location goNext, Location goBack) + { + _goNext = createArmourStand(goNext); + _goNext.setCustomName(C.cGreen + "Next Page"); + + _goNextBox = createSlimeBox(goNext); + + _goBack = createArmourStand(goBack); + _goBack.setCustomName(C.cGreen + "Previous Page"); + + _goBackBox = createSlimeBox(goBack); + } + + private ArmorStand createArmourStand(Location location) + { + ArmorStand stand = location.getWorld().spawn(location.clone().subtract(0, 0.5, 0), ArmorStand.class); + + UtilEnt.vegetate(stand); + UtilEnt.ghost(stand, true, false); + + stand.setCustomNameVisible(true); + stand.setVisible(false); + stand.setGravity(false); + stand.setRemoveWhenFarAway(false); + + return stand; + } + + private Slime createSlimeBox(Location location) + { + Slime slime = location.getWorld().spawn(location.clone().add(0, 1, 0), Slime.class); + + UtilEnt.vegetate(slime); + UtilEnt.ghost(slime, true, false); + UtilEnt.setFakeHead(slime, true); + UtilEnt.silence(slime, true); + + slime.setSize(5); + slime.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false)); + slime.setRemoveWhenFarAway(false); + + return slime; + } + + public void cleanup() + { + _goNext.remove(); + _goNextBox.remove(); + _goBack.remove(); + _goBackBox.remove(); + UtilServer.Unregister(this); + } + + @EventHandler + public void onClick(PlayerInteractAtEntityEvent event) + { + if (onClick(event.getPlayer(), event.getRightClicked())) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onClick(EntityDamageByEntityEvent event) + { + if (onClick(event.getDamager(), event.getEntity())) + { + event.setCancelled(true); + } + } + + private boolean onClick(Entity clicker, Entity clicked) + { + if (!(clicker instanceof Player)) + { + return false; + } + + Player player = (Player) clicker; + boolean action = false; + + if (!Recharge.Instance.use(player, "Change Page", 500, false, false)) + { + return true; + } + + if (_goNextBox != null && _goNextBox.equals(clicked)) + { + _board.goTo(player, true); + action = true; + } + else if (_goBackBox != null && _goBackBox.equals(clicked)) + { + _board.goTo(player, false); + action = true; + } + + if (action) + { + UtilParticle.PlayParticle(ParticleType.CRIT, clicked.getLocation().add(0, 1.5, 0), 0.25F, 0.25F, 0.25F, 0.2F, 15, ViewDist.SHORT, player); + player.playSound(clicked.getLocation(), Sound.WOOD_CLICK, 1, 1); + } + + return action; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapImage.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapImage.java new file mode 100644 index 000000000..37c6d315f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapImage.java @@ -0,0 +1,56 @@ +package mineplex.core.imagemap.objects; + +import mineplex.core.imagemap.ImageMapRenderer; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.ItemFrame; +import org.bukkit.inventory.ItemStack; +import org.bukkit.map.MapView; + +import java.awt.image.BufferedImage; +import java.util.List; + +public class MapImage +{ + + protected final BufferedImage _image; + protected final List _itemFrames; + protected final int _width, _height; + + public MapImage(BufferedImage image, List itemFrames, int width, int height) + { + _image = image; + _itemFrames = itemFrames; + _width = width; + _height = height; + } + + public void create() + { + int i = 0; + + for (int x = 0; x < _width; x++) + { + for (int y = 0; y < _height; y++) + { + ItemFrame frame = _itemFrames.get(i++); + + frame.setItem(getMapItem(frame.getWorld(), x, y)); + } + } + } + + protected ItemStack getMapItem(World world, int x, int y) + { + ItemStack item = new ItemStack(Material.MAP); + + MapView map = Bukkit.getServer().createMap(world); + map.getRenderers().forEach(map::removeRenderer); + + map.addRenderer(new ImageMapRenderer(_image, x, y)); + item.setDurability(map.getId()); + + return item; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java new file mode 100644 index 000000000..fb58bd7ac --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java @@ -0,0 +1,90 @@ +package mineplex.core.imagemap.objects; + +import mineplex.core.common.util.UtilMath; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class PlayerMapBoard +{ + + private static final int VIEW_DIST_SQUARED = 28 * 28; + + private final Location _location; + private final List _images; + private final Map _viewers; + + public PlayerMapBoard(Location location, List images) + { + _location = location; + _images = images; + _viewers = new HashMap<>(); + } + + public void goTo(Player player, boolean next) + { + if (!_viewers.containsKey(player)) + { + return; + } + + int index = _viewers.get(player); + + if (next && _images.size() - 1 == index) + { + index = -1; + } + else if (!next && index == 0) + { + index = _images.size(); + } + + int newIndex = next ? index + 1 : index - 1; + _viewers.put(player, newIndex); + _images.get(newIndex).addViewer(player, true); + } + + public void onPlayerJoin(Player player) + { + _viewers.put(player, 0); + _images.get(0).addViewer(player, true); + } + + public void onPlayerQuit(Player player) + { + _viewers.remove(player); + } + + public void onRefresh() + { + Bukkit.getOnlinePlayers().forEach(player -> + { + if (player.getWorld().equals(_location.getWorld()) && UtilMath.offset2dSquared(player.getLocation(), _location) < VIEW_DIST_SQUARED && _viewers.containsKey(player)) + { + int index = _viewers.get(player); + _images.get(index).addViewer(player, false); + } + }); + } + + public void cleanup() + { + _viewers.clear(); + _images.forEach(image -> + { + image.getItemFrames().forEach(Entity::remove); + image.getItemFrames().clear(); + }); + } + + public Location getLocation() + { + return _location; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java new file mode 100644 index 000000000..2f21cd59b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java @@ -0,0 +1,69 @@ +package mineplex.core.imagemap.objects; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.imagemap.CustomItemFrames; +import org.bukkit.World; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.List; + +public class PlayerMapImage extends MapImage +{ + + private final CustomItemFrames _itemFramesManager; + private final List _itemMaps; + + public PlayerMapImage(CustomItemFrames itemFramesManager, BufferedImage image, List itemFrames, int width, int height) + { + super(image, itemFrames, width, height); + + _itemFramesManager = itemFramesManager; + _itemMaps = new ArrayList<>(); + } + + @Override + public void create() + { + World world = _itemFrames.get(0).getWorld(); + + for (int x = 0; x < _width; x++) + { + for (int y = 0; y < _height; y++) + { + _itemMaps.add(getMapItem(world, x, y)); + } + } + } + + public List getItemFrames() + { + return _itemFrames; + } + + public void addViewer(Player player, boolean sendMap) + { + if (sendMap) + { + //FIXME + int slot = 8; + for (ItemStack itemStack : _itemMaps) + { + player.getInventory().setItem(slot++, itemStack); + } + + UtilServer.runSyncLater(() -> player.getInventory().removeItem(_itemMaps.toArray(new ItemStack[0])), 5); + } + + for (int i = 0; i < _itemMaps.size(); i++) + { + ItemFrame itemFrame = _itemFrames.get(i); + ItemStack itemStack = _itemMaps.get(i); + + _itemFramesManager.setItem(player, itemFrame, itemStack); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java index c90639b66..fd72e005b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java @@ -15,13 +15,13 @@ import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; public class Leaderboard { - private String _display; - private Pair _statDisplay; - private String[] _statNames; - private int[] _statIds; - private int _size, _start; - private LeaderboardSQLType _type; - private Location _loc; + private final String _display; + private final Pair _statDisplay; + private final String[] _statNames; + private final int[] _statIds; + private final int _size, _start; + private final LeaderboardSQLType _type; + private final Location _loc; private Hologram _holo; public Leaderboard(String display, Pair statDisplayNames, String[] statNames, LeaderboardSQLType type, Location displayLoc, int size) @@ -37,6 +37,7 @@ public class Leaderboard _statIds = new int[_statNames.length]; _type = type; _size = size; + _start = start; _loc = displayLoc; update(new LinkedHashMap<>()); @@ -52,12 +53,15 @@ public class Leaderboard return _start; } + /** + * The returned array is not safe for mutation + */ public String[] getStatNames() { return _statNames; } - public int[] getStatIds() + public synchronized int[] getStatIds() { return _statIds; } @@ -89,6 +93,14 @@ public class Leaderboard _holo = new Hologram(Managers.get(LeaderboardManager.class).getHologramManager(), _loc, display.toArray(new String[display.size()])).start(); } + public synchronized void setStatId(int index, int id) + { + if (_statIds.length > index && index >= 0) + { + _statIds[index] = id; + } + } + public void deconstruct() { if (_holo != null) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java index 88a84c29d..e2849a5d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java @@ -120,7 +120,7 @@ public class LeaderboardManager extends MiniPlugin final int index = i; Managers.get(StatsManager.class).loadStatId(board.getStatNames()[index], id -> { - board.getStatIds()[index] = id.intValue(); + board.setStatId(index, id.intValue()); }); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index f9b286039..4ef0e86cf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -90,73 +90,79 @@ public class LeaderboardRepository extends RepositoryBase public void insertStats(int accountId, Map stats) { - try ( - Connection c = getConnection(); - PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT); - PreparedStatement insertStat = c.prepareStatement(INSERT_STAT); - ) + UtilServer.runAsync(() -> { - for (Integer statId : stats.keySet()) + try ( + Connection c = getConnection(); + PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT); + PreparedStatement insertStat = c.prepareStatement(INSERT_STAT); + ) { - updateStat.setLong(1, stats.get(statId)); - updateStat.setInt(2, accountId); - updateStat.setInt(3, statId); - updateStat.addBatch(); - } - int[] rowsAffected = updateStat.executeBatch(); - int i = 0; - for (Integer statId : stats.keySet()) - { - if (rowsAffected[i] < 1) + for (Integer statId : stats.keySet()) { - insertStat.setInt(1, accountId); - insertStat.setInt(2, statId); - insertStat.setLong(3, stats.get(statId)); - insertStat.addBatch(); + updateStat.setLong(1, stats.get(statId)); + updateStat.setInt(2, accountId); + updateStat.setInt(3, statId); + updateStat.addBatch(); } - i++; + int[] rowsAffected = updateStat.executeBatch(); + int i = 0; + for (Integer statId : stats.keySet()) + { + if (rowsAffected[i] < 1) + { + insertStat.setInt(1, accountId); + insertStat.setInt(2, statId); + insertStat.setLong(3, stats.get(statId)); + insertStat.addBatch(); + } + i++; + } + insertStat.executeBatch(); } - insertStat.executeBatch(); - } - catch (SQLException e) - { - e.printStackTrace(); - } + catch (SQLException e) + { + e.printStackTrace(); + } + }); } public void loadLeaderboard(Leaderboard board, Consumer> leaderboard) { - Map names = new LinkedHashMap<>(); - try ( - Connection c = getConnection(); - Statement s = c.createStatement(); - ) + UtilServer.runAsync(() -> { - s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); - for (int i = 0; i < board.getStatIds().length; i++) + Map names = new LinkedHashMap<>(); + try ( + Connection c = getConnection(); + Statement s = c.createStatement(); + ) { - try (ResultSet rs = s.getResultSet()) + s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); + for (int i = 0; i < board.getStatIds().length; i++) { - while (rs.next()) + try (ResultSet rs = s.getResultSet()) { - names.merge(rs.getString("name"), rs.getInt("value"), Integer::sum); - } - - if (!s.getMoreResults()) - { - break; + while (rs.next()) + { + names.merge(rs.getString("name"), rs.getInt("value"), Integer::sum); + } + + if (!s.getMoreResults()) + { + break; + } } } } - } - catch (SQLException ex) - { - ex.printStackTrace(); - } - finally - { - UtilServer.runSync(() -> leaderboard.accept(names)); - } + catch (SQLException ex) + { + ex.printStackTrace(); + } + finally + { + UtilServer.runSync(() -> leaderboard.accept(names)); + } + }); } @SuppressWarnings("unchecked") diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java b/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java index 80b57ae69..6fab6c914 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java @@ -7,12 +7,12 @@ import org.bukkit.map.MapCanvas; import org.bukkit.map.MapRenderer; import org.bukkit.map.MapView; -public class ImageMapRenderer extends MapRenderer +class ImageMapRenderer extends MapRenderer { private BufferedImage _image; private boolean _first = true; - public ImageMapRenderer(BufferedImage image) + ImageMapRenderer(BufferedImage image) { _image = image; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java index e34150584..4a89c9d7d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java @@ -42,6 +42,12 @@ public class LagMeter extends MiniPlugin _start = System.currentTimeMillis(); } + @Override + public void addCommands() + { + addCommand(new VersionsCommand(this)); + } + @EventHandler public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java new file mode 100644 index 000000000..43454f57c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java @@ -0,0 +1,106 @@ +package mineplex.core.monitor; + +import java.lang.reflect.Field; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.print.attribute.IntegerSyntax; + +import com.mineplex.ProtocolVersion; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +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.core.common.util.UtilServer; + +/** + * Statistics on versions + * @author Dan + */ +public class VersionsCommand extends CommandBase +{ + private static Map PRETTY_VERSIONS; + + public VersionsCommand(LagMeter plugin) + { + super(plugin, Rank.DEVELOPER, "versions", "getver"); + } + + private void ensureVersions() + { + if (PRETTY_VERSIONS == null) + { + PRETTY_VERSIONS = new HashMap<>(); + for (Field field : ProtocolVersion.class.getFields()) + { + try + { + int protocol = field.getInt(null); + String version = field.getName().replace("v", "").replace("_", "."); + version += " (" + protocol + ")"; + + PRETTY_VERSIONS.put(protocol, version); + } catch (ReflectiveOperationException ex) { } + } + } + } + + @Override + public void Execute(Player caller, String[] args) + { + ensureVersions(); + + if (args.length == 0) + { + Map versions = new HashMap<>(); + for (Player player : Bukkit.getOnlinePlayers()) + { + int version = ((CraftPlayer) player).getHandle().getProtocol(); + int players = versions.getOrDefault(version, 0); + versions.put(version, players + 1); + } + + UtilPlayer.message(caller, F.main("Version", "Distribution on " + C.cGold + + UtilServer.getServerName())); + + List> sorted = versions + .entrySet().stream() + .sorted(Comparator.comparing(Map.Entry::getValue, (i1, i2) -> -i1.compareTo(i2))) + .collect(Collectors.toList()); + for (Map.Entry entry : sorted) + { + int protocol = entry.getKey(); + String pretty = PRETTY_VERSIONS.computeIfAbsent(protocol, x -> Integer.toString(protocol)); + + UtilPlayer.message(caller, + F.main("Version", C.cYellow + pretty + C.cGray + ": " + C.cGreen + + entry.getValue() + C.cGray + " players")); + } + } else if (args.length == 1) + { + List players = UtilPlayer.matchOnline(caller, args[0], true); + if (!players.isEmpty()) + { + Player player = players.get(0); + int protocol = ((CraftPlayer) player).getHandle().getProtocol(); + String pretty = PRETTY_VERSIONS.computeIfAbsent(protocol, x -> Integer.toString(protocol)); + + UtilPlayer.message(caller, + F.main("Version", C.cYellow + player.getName() + C.cGray + " is on version " + + C.cGreen + pretty)); + } + } else + { + UtilPlayer.message(caller, F.main("Version", "Invalid argument list.")); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java index 137ae9bbe..ff998efee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java @@ -39,7 +39,7 @@ public class MountTitanData extends MountData //Nodes _nodes = new ArrayList(); - for (int i=0 ; i<30 ; i++) + for (int i=0 ; i<20 ; i++) { ArmorStand node = loc.getWorld().spawn(loc, ArmorStand.class); @@ -81,7 +81,7 @@ public class MountTitanData extends MountData Location infront = _head.getLocation().add(0, -1.5, 0); //Move - for (int i=0 ; i<30 ; i++) + for (int i=0 ; i<20 ; i++) { ArmorStand node = _nodes.get(i); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 68a0c10c1..062a529d3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -132,7 +132,7 @@ public class Portal extends MiniPlugin { if (server.getGroup().equalsIgnoreCase("Clans") && server.getMotd().equalsIgnoreCase("Restarting soon")) { - UtilPlayer.message(player, F.main(getName(), C.cGold + "serverName" + C.cRed + " is restarting!")); + UtilPlayer.message(player, F.main(getName(), C.cGold + serverName + C.cRed + " is restarting!")); return; } if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.has(Rank.ULTRA)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 83fc019ad..9f40681c2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -39,6 +39,8 @@ public class PowerPlayClubRewards .put(YearMonth.of(2017, Month.APRIL), new UnknownSalesPackageItem("Bumblebee's Wings")) .put(YearMonth.of(2017, Month.MAY), new UnknownSalesPackageItem("King")) .put(YearMonth.of(2017, Month.JUNE), new UnknownSalesPackageItem("Bob Ross Morph")) + .put(YearMonth.of(2017, Month.JULY), new UnknownSalesPackageItem("Freedom Fighter")) + .put(YearMonth.of(2017, Month.AUGUST), new UnknownSalesPackageItem("Melonhead Morph")) .build(); public interface PowerPlayClubItem diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index 1a26d65c4..d905ec7bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -4,7 +4,6 @@ import java.util.HashMap; import java.util.function.Consumer; import java.util.logging.Level; -import mineplex.core.account.CoreClient; import org.bukkit.Bukkit; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -21,6 +20,7 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.common.Constants; @@ -36,6 +36,7 @@ import mineplex.core.punish.Command.PunishCommand; import mineplex.core.punish.Command.RulesCommand; import mineplex.core.punish.Tokens.PunishClientToken; import mineplex.core.punish.Tokens.PunishmentToken; +import mineplex.core.punish.clans.ClansBanManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.commands.AddPunishCommand; @@ -47,18 +48,30 @@ public class Punish extends MiniPlugin private HashMap _punishClients; private PunishRepository _repository; private CoreClientManager _clientManager; + private ClansBanManager _clansPunish; public Punish(JavaPlugin plugin, CoreClientManager clientManager) + { + this(plugin, clientManager, false); + } + + public Punish(JavaPlugin plugin, CoreClientManager clientManager, boolean clansServer) { super("Punish", plugin); - + _punishClients = new HashMap(); _clientManager = clientManager; _repository = new PunishRepository(); + _clansPunish = new ClansBanManager(plugin, clientManager, clansServer); ServerCommandManager.getInstance().registerCommandType("PunishCommand", mineplex.serverdata.commands.PunishCommand.class, new PunishmentHandler(this)); } + public ClansBanManager getClansPunish() + { + return _clansPunish; + } + public PunishRepository GetRepository() { return _repository; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBan.java similarity index 94% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java rename to Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBan.java index 60ae2b90f..1b1c092e4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBan.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.clans.ban; +package mineplex.core.punish.clans; import java.sql.Timestamp; import java.util.UUID; @@ -7,7 +7,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; /** - * Stores the information about a ban in Clans. + * Stores the information about a blacklist in Clans. */ public class ClansBan { @@ -98,4 +98,4 @@ public class ClansBan { _removed = true; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanClient.java similarity index 90% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java rename to Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanClient.java index 10ad60f2b..6710f4dd0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanClient.java @@ -1,14 +1,13 @@ -package mineplex.game.clans.clans.ban; +package mineplex.core.punish.clans; import java.util.List; -import java.util.Set; import java.util.UUID; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; /** - * Signifies a player on clans, and a Set of their current clan bans. + * A client representing a player and a List of their Clans blacklists */ public class ClansBanClient { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java new file mode 100644 index 000000000..f8940291b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java @@ -0,0 +1,160 @@ +package mineplex.core.punish.clans; + +import java.util.Optional; +import java.util.UUID; +import java.util.function.Consumer; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.AsyncPlayerPreLoginEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.punish.clans.command.ClansBanCommand; +import mineplex.core.punish.clans.redis.ClansBanNotification; +import mineplex.serverdata.commands.ServerCommandManager; + +public class ClansBanManager extends MiniPlugin +{ + private final CoreClientManager _clientManager; + private final ClansBanRepository _repository; + private final boolean _fullOperation; + + public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, boolean fullOperation) + { + super("Clans Blacklist", plugin); + + _clientManager = clientManager; + + _repository = new ClansBanRepository(plugin); + + _fullOperation = fullOperation; + + if (_fullOperation) + { + ServerCommandManager.getInstance().registerCommandType(ClansBanNotification.class, notification -> + { + runSync(() -> + { + if (Bukkit.getPlayer(notification.getTarget()) != null) + { + Bukkit.getPlayer(notification.getTarget()).kickPlayer(C.cRedB + "You have been banned from Clans " + notification.getBanTimeFormatted() + "."); + } + }); + }); + } + } + + @Override + public void addCommands() + { + addCommand(new ClansBanCommand(this)); + } + + public CoreClientManager getClientManager() + { + return _clientManager; + } + + public ClansBanRepository getRepository() + { + return _repository; + } + + public void loadClient(String name, Consumer> callback) + { + _repository.loadClient(name).thenAccept(client -> runSync(() -> callback.accept(client))); + } + + public void loadClient(UUID uuid, Consumer callback) + { + _repository.loadClient(uuid).thenAccept(client -> runSync(() -> callback.accept(client))); + } + + public void ban(ClansBanClient target, String targetName, String admin, long duration, String reason, Player caller, Consumer> callback) + { + _repository.ban(target._uuid, admin, duration, reason).thenAccept(ban -> runSync(() -> + { + if (ban.isPresent()) + { + target._bans.add(ban.get()); + String banTimeFormatted = target.getBanTimeFormatted(); + + if (targetName != null) + { + for (Player notify : Bukkit.getOnlinePlayers()) + { + if (_clientManager.Get(notify).GetRank().has(notify, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false)) + { + UtilPlayer.message(notify, F.main(getName(), F.elem(targetName) + " is now banned " + banTimeFormatted + ".")); + } + } + } + if (_fullOperation && Bukkit.getPlayer(target._uuid) != null) + { + Bukkit.getPlayer(target._uuid).kickPlayer(C.cRedB + "You have been banned from Clans " + banTimeFormatted + "."); + } + new ClansBanNotification(target._uuid, banTimeFormatted).publish(); + } + else + { + if (caller != null && targetName != null) + { + UtilPlayer.message(caller, F.main(getName(), C.cRed + "An issue occurred when trying to ban " + F.elem(targetName))); + } + } + callback.accept(ban); + })); + } + + public void unban(ClansBanClient target, ClansBan ban, Runnable callback) + { + if (!target._uuid.equals(ban.getUUID())) + { + return; + } + + ban.remove(); + _repository.removeBan(ban); + + callback.run(); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onLogin(AsyncPlayerPreLoginEvent event) + { + if (!_fullOperation) + { + return; + } + try + { + ClansBanClient client = _repository.loadClient(event.getUniqueId()).get(); + + 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.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, reason); + } + } + catch (Exception ignored) {} + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java similarity index 83% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java rename to Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java index 3d5c798cc..702968d98 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java @@ -1,20 +1,24 @@ -package mineplex.game.clans.clans.ban; +package mineplex.core.punish.clans; -import mineplex.core.Managers; -import mineplex.core.account.CoreClientManager; -import mineplex.core.database.MinecraftRepository; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnInt; -import org.bukkit.plugin.java.JavaPlugin; - -import java.sql.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; + public class ClansBanRepository extends RepositoryBase { private static final String BAN_PLAYER = "INSERT INTO clanBans (uuid, admin, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?, ?);"; @@ -50,18 +54,22 @@ public class ClansBanRepository extends RepositoryBase { int id = resultSet.getInt(1); return Optional.of(new ClansBan(id, uuid, admin, reason, banTime, unbanTime, time == -1, false)); - } else + } + else { return Optional.empty(); } - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); return Optional.empty(); } }); } - public CompletableFuture loadClient(UUID uuid) { + public CompletableFuture loadClient(UUID uuid) + { return CompletableFuture.supplyAsync(() -> { try (Connection conn = DBPool.getAccount().getConnection()) @@ -87,7 +95,9 @@ public class ClansBanRepository extends RepositoryBase } return new ClansBanClient(uuid, bans); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); return new ClansBanClient(uuid, new ArrayList<>()); } @@ -98,22 +108,23 @@ public class ClansBanRepository extends RepositoryBase { // Yes, this is garbage. // Yes, it would be better implemented in a functional language. - return CompletableFuture.supplyAsync(() -> Managers.get(CoreClientManager.class).loadUUIDFromDB(name)) - .thenCompose(uuid -> - { - if (uuid == null) - { - CompletableFuture> future = new CompletableFuture<>(); - future.complete(Optional.empty()); - return future; - } else { - return loadClient(uuid).thenApply(Optional::of); - } - }); + return CompletableFuture.supplyAsync(() -> Managers.get(CoreClientManager.class).loadUUIDFromDB(name)).thenCompose(uuid -> + { + if (uuid == null) + { + CompletableFuture> future = new CompletableFuture<>(); + future.complete(Optional.empty()); + return future; + } + else + { + return loadClient(uuid).thenApply(Optional::of); + } + }); } public void removeBan(ClansBan ban) { executeUpdate(REMOVE_BAN, new ColumnInt("id", ban.getId())); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java similarity index 65% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java index 3275072c5..7daa6e7d7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java @@ -1,13 +1,13 @@ -package mineplex.game.clans.clans.ban.commands; +package mineplex.core.punish.clans.command; -import mineplex.game.clans.clans.ban.ui.ClansBanShop; 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.UtilPlayer; -import mineplex.game.clans.clans.ban.ClansBanManager; +import mineplex.core.punish.clans.ClansBanManager; +import mineplex.core.punish.clans.ui.ClansBanShop; public class ClansBanCommand extends CommandBase { @@ -35,23 +35,22 @@ public class ClansBanCommand extends CommandBase } final String finalReason = reason; - - Plugin.getRepository().loadClient(playerName) - .thenAccept(maybeClient -> - Plugin.runSync(() -> - { - if (!maybeClient.isPresent()) - { - UtilPlayer.message(caller, C.cRed + "Could not find player with name " + C.cYellow + playerName); - } else - { - new ClansBanShop(Plugin, playerName, maybeClient.get(), finalReason).attemptShopOpen(caller); - } - })); + + Plugin.loadClient(playerName, client -> + { + if (client.isPresent()) + { + new ClansBanShop(Plugin, playerName, client.get(), finalReason).attemptShopOpen(caller); + } + else + { + UtilPlayer.message(caller, C.cRed + "Could not find player with name " + C.cYellow + playerName); + } + }); } else { UtilPlayer.message(caller, C.cBlue + "/cb " + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view their past bans."); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/redis/ClansBanNotification.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/redis/ClansBanNotification.java new file mode 100644 index 000000000..cf7829069 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/redis/ClansBanNotification.java @@ -0,0 +1,27 @@ +package mineplex.core.punish.clans.redis; + +import java.util.UUID; + +import mineplex.serverdata.commands.ServerCommand; + +public class ClansBanNotification extends ServerCommand +{ + private final UUID _target; + private final String _banTimeFormatted; + + public ClansBanNotification(UUID target, String banTimeFormatted) + { + _target = target; + _banTimeFormatted = banTimeFormatted; + } + + public UUID getTarget() + { + return _target; + } + + public String getBanTimeFormatted() + { + return _banTimeFormatted; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java new file mode 100644 index 000000000..f26c4a0b2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java @@ -0,0 +1,164 @@ +package mineplex.core.punish.clans.ui; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.Managers; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTime; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.punish.clans.ClansBan; +import mineplex.core.punish.clans.ClansBanClient; +import mineplex.core.punish.clans.ClansBanManager; +import mineplex.core.shop.page.ShopPageBase; + +public class ClansBanPage extends ShopPageBase +{ + private long _time; + private boolean _permanent; + + private String _victimName; + private ClansBanClient _victimClient; + + private String _reason; + + public ClansBanPage(final ClansBanManager banManager, final ClansBanShop shop, final String name, final Player player, String victimName, ClansBanClient client, String reason) + { + super(banManager, shop, banManager.getClientManager(), Managers.get(DonationManager.class), name, player); + + _reason = reason; + + _victimName = victimName; + _victimClient = client; + + buildPage(); + } + + protected void buildPage() + { + _time = Math.max(0, _time); + + int slot = 27; + + // Middle of first row + addButton(4, new ItemBuilder(Material.SKULL_ITEM) + .setData((short) 3) + .setPlayerHead(_victimName) + .setTitle(C.cDGreenB + _victimName) + .addLore(" ") + .addLore(C.cYellow + _reason).build(), (player, click) -> {}); + + addTimeAdjuster((9 * 1 + 2), -(1000l * 60l * 60l)); + addTimeAdjuster((9 * 1 + 1), -(1000l * 60l * 60l * 24l)); + addTimeAdjuster((9 * 1 + 0), -(1000l * 60l * 60l * 24l * 30l)); + addTimeAdjuster((9 * 1 + 6), (1000l * 60l * 60l)); + addTimeAdjuster((9 * 1 + 7), (1000l * 60l * 60l * 24l)); + addTimeAdjuster((9 * 1 + 8), (1000l * 60l * 60l * 24l * 30l)); + + addButton((9 * 1) + 4, + new ItemBuilder(Material.RECORD_5) + .setTitle(C.cRedB + "Ban Player") + .setLore( + " ", + C.cGray + "Player: " + F.elem(_victimName), + C.cGray + "Reason: " + F.elem(_reason), + C.cGray + "Time: " + F.elem(_permanent ? "Permanent" : UtilTime.MakeStr(_time)), + "", + C.cRed + C.Italics + "Left-Click to BAN PLAYER", + C.cGray + C.Italics + "Right-Click to toggle permanent ban setting" + ).build(), + (player, click) -> + { + if (click == ClickType.RIGHT) + { + _permanent = !_permanent; + refresh(); + } + else + { + performBan(); + } + }); + + for (ClansBan ban : _victimClient._bans) + { + ItemStack item; + if (ban.isPermanent()) + { + item = new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK) + .setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive") + .addLore(" ") + .addLore(C.cGray + "Date Banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime())) + .addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin()) + .addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No")) + .addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16) + .addLore(C.cGray + "Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No")) + .addLore(ban.isActive() ? " " : null) + .addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null) + .setGlow(ban.isActive()) + .build(); + } + else + { + item = new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK) + .setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive") + .addLore(" ") + .addLore(C.cGray + "Date Banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime())) + .addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin()) + .addLore(C.cGray + "Time Left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None")) + .addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No")) + .addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16) + .addLore(C.cGray + "Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No")) + .addLore(ban.isActive() ? " " : null) + .addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null) + .setGlow(ban.isActive()) + .build(); + } + + addButton(slot++, item, (player, click) -> + { + if (ban.isActive()) + { + getPlugin().runAsync(() -> + { + getPlugin().unban(_victimClient, ban, () -> + { + refresh(); + playAcceptSound(player); + }); + }); + } + }); + } + } + + private void performBan() + { + getPlugin().ban(_victimClient, _victimName, getPlayer().getName(), _permanent ? -1 : _time, _reason, getPlayer(), ban -> + { + if (ban.isPresent()) + { + playAcceptSound(getPlayer()); + refresh(); + } + else + { + playDenySound(getPlayer()); + } + }); + } + + private void addTimeAdjuster(int index, long time) + { + addButton(index, new ItemBuilder(Material.PAPER).setTitle(C.cRed + (time < 0 ? "-" : "") + UtilTime.MakeStr(Math.abs(time))).build(), + (player, click) -> + { + _time += time; + refresh(); + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanShop.java similarity index 68% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java rename to Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanShop.java index 375e52b43..e1c404ebc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanShop.java @@ -1,11 +1,13 @@ -package mineplex.game.clans.clans.ban.ui; +package mineplex.core.punish.clans.ui; -import mineplex.game.clans.clans.ban.ClansBanClient; import org.bukkit.entity.Player; +import mineplex.core.Managers; +import mineplex.core.donation.DonationManager; +import mineplex.core.punish.clans.ClansBanClient; +import mineplex.core.punish.clans.ClansBanManager; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; -import mineplex.game.clans.clans.ban.ClansBanManager; public class ClansBanShop extends ShopBase { @@ -15,7 +17,7 @@ public class ClansBanShop extends ShopBase public ClansBanShop(final ClansBanManager plugin, String victimName, ClansBanClient client, String reason) { - super(plugin, plugin.getClientManager(), plugin.getDonationManager(), "Clans Punish"); + super(plugin, plugin.getClientManager(), Managers.get(DonationManager.class), "Clans Punish"); _clientName = victimName; _client = client; _reason = reason; @@ -25,6 +27,5 @@ public class ClansBanShop extends ShopBase protected ShopPageBase> buildPagesFor(final Player player) { return new ClansBanPage(getPlugin(), this, "Clans Punish", player, _clientName, _client, _reason); - } - + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java index 861999fae..bf8a64b55 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java @@ -8,7 +8,7 @@ package mineplex.core.quests; public enum TriggerType { - KILL("Kill"), DIE("Die"), WIN("Win"), LOSE("Lose"), COLLECT("Collect"), PLAY("Play"), COMPLETE("Complete"); + KILL("Kill"), DIE("Die"), WIN("Win"), LOSE("Lose"), COLLECT("Collect"), PLAY("Play"), COMPLETE("Complete"), HIT("Hit"), FIRST_BLOOD("First Blood"); private String _name; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java index 1b7fe9cc8..414ac6b48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java @@ -1,5 +1,7 @@ package mineplex.core.quests.command; +import java.util.ArrayList; + import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -7,6 +9,7 @@ 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.common.util.UtilServer; import mineplex.core.quests.Quest; import mineplex.core.quests.QuestManager; @@ -37,19 +40,44 @@ public class GetQuestCommand extends CommandBase return; } - Player player = caller; + ArrayList players = new ArrayList<>(); if (args.length == 2) { if (UtilPlayer.searchExact(args[1]) != null) - player = UtilPlayer.searchExact(args[1]); + { + players.add(UtilPlayer.searchExact(args[1])); + } + else + { + if (args[1].equalsIgnoreCase("all")) + { + players.addAll(UtilServer.getPlayersCollection()); + } + } + } + else + { + players.add(caller); } Quest quest = Plugin.getQuestByID(Integer.parseInt(args[0])); - Plugin.addNewQuest(player, quest); - UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName())); + for (Player player : players) + { + Plugin.addNewQuest(player, quest); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName())); + + + if (!args[1].equalsIgnoreCase("all")) + { + if (caller != players.get(0)) + UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + player.getName())); + } + } - if (caller != player) - UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + player.getName())); + if (args[1].equalsIgnoreCase("all")) + { + UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + "everyone")); + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java index ef209276e..281374325 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java @@ -6,9 +6,6 @@ import org.bukkit.entity.Player; import mineplex.core.common.util.Callback; -/** - * Created by Shaun on 9/2/2014. - */ public abstract class Reward { protected static final Random RANDOM = new Random(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java index 8179dbb98..6f3acd00b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java @@ -2,9 +2,6 @@ package mineplex.core.reward; import org.bukkit.inventory.ItemStack; -/** - * Created by shaun on 14-09-18. - */ public class RewardData { private final String _header; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 5f4e5fb16..f31a0b0f8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -5,6 +5,14 @@ import java.util.EnumMap; import java.util.List; import java.util.Random; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; +import mineplex.core.gadget.gadgets.flag.FlagType; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -15,46 +23,46 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.halloween.ArrowTrailHalloween; -import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; -import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; -import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; -import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; -import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; -import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; -import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.balloons.BalloonType; -import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; -import mineplex.core.gadget.gadgets.death.christmas.DeathPresentDanger; -import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart; -import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald; -import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; -import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; -import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; -import mineplex.core.gadget.gadgets.death.music.DeathMusic; -import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; -import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; -import mineplex.core.gadget.gadgets.death.spring.DeathSpring; -import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; -import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.halloween.DoubleJumpHalloween; -import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; -import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; -import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; -import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; -import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; -import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; -import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; -import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; -import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.death.DeathCandyCane; +import mineplex.core.gadget.gadgets.death.DeathPresentDanger; +import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; +import mineplex.core.gadget.gadgets.death.DeathEmerald; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.death.DeathFrostLord; +import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.death.DeathMusic; +import mineplex.core.gadget.gadgets.death.DeathPinataBurst; +import mineplex.core.gadget.gadgets.death.DeathShadow; +import mineplex.core.gadget.gadgets.death.DeathSpring; +import mineplex.core.gadget.gadgets.death.DeathBlood; +import mineplex.core.gadget.gadgets.death.DeathEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin; import mineplex.core.gadget.gadgets.hat.HatType; import mineplex.core.gadget.gadgets.item.ItemBatGun; @@ -116,18 +124,18 @@ import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsLove; import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; import mineplex.core.gadget.gadgets.particle.ParticleYinYang; -import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; -import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; -import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.ParticleEmerald; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; -import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; -import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; -import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; -import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; -import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleRain; +import mineplex.core.gadget.gadgets.particle.ParticleMusic; +import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; +import mineplex.core.gadget.gadgets.particle.ParticleFoot; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; -import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; -import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; +import mineplex.core.gadget.gadgets.particle.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken; @@ -318,7 +326,14 @@ public class RewardManager addHat(Type.WINTER_HOLIDAY, HatType.PRESENT, rarity, 5); addHat(Type.WINTER_HOLIDAY, HatType.SNOWMAN, rarity, 5); + // FREEDOM + addGadget(Type.FREEDOM, getGadget(ArrowTrailRedWhite.class), rarity, 150); + addGadget(Type.FREEDOM, getGadget(ArrowTrailFreedom.class), rarity, 150); + // Omega items + addGadget(Type.OMEGA, getGadget(ArrowTrailRedWhite.class), rarity, 2); + addGadget(Type.OMEGA, getGadget(ArrowTrailFreedom.class), rarity, 2); + addMusicReward(Type.OMEGA, "Blocks Disc", rarity, 25); addMusicReward(Type.OMEGA, "Cat Disc", rarity, 25); addMusicReward(Type.OMEGA, "Chirp Disc", rarity, 25); @@ -484,9 +499,12 @@ public class RewardManager // FREEDOM addHat(Type.FREEDOM, HatType.UNCLE_SAM, rarity, 100); + addHat(Type.FREEDOM, HatType.AMERICA, rarity, 120); + addHat(Type.FREEDOM, HatType.CANADA, rarity, 120); addGadget(Type.FREEDOM, getGadget(DoubleJumpFreedom.class), rarity, 50); - addGadget(Type.FREEDOM, getGadget(ArrowTrailFreedom.class), rarity, 10); + addGadget(Type.FREEDOM, getGadget(DoubleJumpMaple.class), rarity, 50); addGadget(Type.FREEDOM, getGadget(DeathFreedom.class), rarity, 75); + addGadget(Type.FREEDOM, getGadget(DeathMapleLeaf.class), rarity, 75); // Omega Chest addGadget(Type.OMEGA, getGadget(DoubleJumpFreedom.class), rarity, 5); @@ -498,6 +516,9 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(DoubleJumpStorm.class), rarity, 30); addGadget(Type.OMEGA, getGadget(DoubleJumpCandyCane.class), rarity, 20); addGadget(Type.OMEGA, getGadget(DoubleJumpHalloween.class), rarity, 50); + addGadget(Type.OMEGA, getGadget(DoubleJumpSpring.class), rarity, 40); + addGadget(Type.OMEGA, getGadget(DoubleJumpFreedom.class), rarity, 50); + addGadget(Type.OMEGA, getGadget(DoubleJumpMaple.class), rarity, 50); addGadget(Type.OMEGA, getGadget(DeathFreedom.class), rarity, 15); addGadget(Type.OMEGA, getGadget(DeathStorm.class), rarity, 30); @@ -507,6 +528,8 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(DeathPinataBurst.class), rarity, 27); addGadget(Type.OMEGA, getGadget(DeathShadow.class), rarity, 15); addGadget(Type.OMEGA, getGadget(DeathCandyCane.class), rarity, 25); + addGadget(Type.OMEGA, getGadget(DeathSpring.class), rarity, 60); + addGadget(Type.OMEGA, getGadget(DeathMapleLeaf.class), rarity, 10); addGadget(Type.OMEGA, getGadget(ArrowTrailFreedom.class), rarity, 10); addGadget(Type.OMEGA, getGadget(ArrowTrailConfetti.class), rarity, 27); @@ -516,6 +539,7 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(ArrowTrailStorm.class), rarity, 30); addGadget(Type.OMEGA, getGadget(ArrowTrailShadow.class), rarity, 15); addGadget(Type.OMEGA, getGadget(ArrowTrailCandyCane.class), rarity, 10); + addGadget(Type.OMEGA, getGadget(ArrowTrailSpring.class), rarity, 60); addHat(Type.OMEGA, HatType.UNCLE_SAM, rarity, 25); addHat(Type.OMEGA, HatType.COMPANION_BLOCK, rarity, 15); @@ -525,6 +549,8 @@ public class RewardManager addHat(Type.OMEGA, HatType.SANTA, rarity, 25); addHat(Type.OMEGA, HatType.RUDOLPH, rarity, 25); addHat(Type.OMEGA, HatType.COAL, rarity, 25); + addHat(Type.OMEGA, HatType.AMERICA, rarity, 50); + addHat(Type.OMEGA, HatType.CANADA, rarity, 50); addGadget(Type.OMEGA, getGadget(MorphChicken.class), rarity, 50); addGadget(Type.OMEGA, getGadget(MorphCow.class), rarity, 167); @@ -538,6 +564,7 @@ public class RewardManager addMount(Type.OMEGA, getMount(MountCart.class), rarity, 100); addMount(Type.OMEGA, getMount(MountMule.class), rarity, 200); addMount(Type.OMEGA, getMount(MountSlime.class), rarity, 67); + addMount(Type.OMEGA, getMount(MountLoveTrain.class), rarity, 20); addGadget(Type.OMEGA, getGadget(OutfitRaveSuitBoots.class), rarity, 30); addGadget(Type.OMEGA, getGadget(OutfitRaveSuitChestplate.class), rarity, 30); @@ -547,8 +574,15 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(OutfitSpaceSuitChestplate.class), rarity, 50); addGadget(Type.OMEGA, getGadget(OutfitSpaceSuitLeggings.class), rarity, 50); addGadget(Type.OMEGA, getGadget(OutfitSpaceSuitHelmet.class), rarity, 50); + addGadget(Type.OMEGA, getGadget(OutfitStPatricksChestplate.class),rarity, 50); + addGadget(Type.OMEGA, getGadget(OutfitStPatricksLeggings.class), rarity, 50); + addGadget(Type.OMEGA, getGadget(OutfitStPatricksBoots.class), rarity, 50); + addGadget(Type.OMEGA, getGadget(OutfitFreezeSuitChestplate.class),rarity, 50); + addGadget(Type.OMEGA, getGadget(OutfitFreezeSuitLeggings.class), rarity, 50); + addGadget(Type.OMEGA, getGadget(OutfitFreezeSuitBoots.class), rarity, 50); - addGadget(Type.OMEGA, getGadget(ParticleCandyCane.class), rarity, 25); + addGadget(Type.OMEGA, getGadget(ParticleCandyCane.class), rarity, 20); + addGadget(Type.OMEGA, getGadget(ParticleChristmasTree.class), rarity, 40); addBalloon(Type.OMEGA, BalloonType.BABY_ZOMBIE, rarity, 25, 500); addBalloon(Type.OMEGA, BalloonType.BABY_MUSHROOM, rarity, 50, 500); @@ -758,6 +792,12 @@ public class RewardManager addMount(Type.FREEDOM, getMount(MountFreedomHorse.class), rarity, 1); addGadget(Type.FREEDOM, getGadget(MorphUncleSam.class), rarity, 5); addGadget(Type.FREEDOM, getGadget(ParticleFreedom.class), rarity, 50); + addGadget(Type.FREEDOM, getGadget(ParticleFreedomFireworks.class), rarity, 95); + addGadget(Type.FREEDOM, getGadget(ParticleAuraNiceness.class), rarity, 40); + addGadget(Type.FREEDOM, getGadget(ParticleCanadian.class), rarity, 10); + addGadget(Type.FREEDOM, getGadget(ParticleStarSpangled.class), rarity, 10); + addFlag(Type.FREEDOM, FlagType.CANADA, rarity, 35); + addFlag(Type.FREEDOM, FlagType.USA, rarity, 35); // Omega items addPetReward(Type.OMEGA, PetType.VILLAGER, rarity, 1); @@ -765,6 +805,9 @@ public class RewardManager addPetReward(Type.OMEGA, PetType.PIG_ZOMBIE, rarity, 1); addPetReward(Type.OMEGA, PetType.BLAZE, rarity, 2); addPetReward(Type.OMEGA, PetType.RABBIT, rarity, 10); + addPetReward(Type.OMEGA, PetType.KILLER_BUNNY, rarity, 3); + addPetReward(Type.OMEGA, PetType.CUPID_PET, rarity, 40); + addPetReward(Type.OMEGA, PetType.LEPRECHAUN, rarity, 8); addGadget(Type.OMEGA, getGadget(MorphBunny.class), rarity, 1); addGadget(Type.OMEGA, getGadget(MorphUncleSam.class), rarity, 5); @@ -774,6 +817,8 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(MorphBlock.class), rarity, 20); addGadget(Type.OMEGA, getGadget(MorphSnowman.class), rarity, 10); addGadget(Type.OMEGA, getGadget(MorphGrimReaper.class), rarity, 25); + addGadget(Type.OMEGA, getGadget(MorphAwkwardRabbit.class), rarity, 30); + addGadget(Type.OMEGA, getGadget(MorphLoveDoctor.class), rarity, 40); addGadget(Type.OMEGA, getGadget(ParticleFreedom.class), rarity, 15); addGadget(Type.OMEGA, getGadget(ParticleWingsAngel.class), rarity, 15); @@ -793,14 +838,23 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(ParticleCoalFumes.class), rarity, 1); addGadget(Type.OMEGA, getGadget(ParticleFrostLord.class), rarity, 10); addGadget(Type.OMEGA, getGadget(ParticlePartyTime.class), rarity, 25); + addGadget(Type.OMEGA, getGadget(ParticleSpringHalo.class), rarity, 8); + addGadget(Type.OMEGA, getGadget(ParticleWingsLove.class), rarity, 10); + addGadget(Type.OMEGA,getGadget(ParticleFreedomFireworks.class),rarity,24); + addGadget(Type.OMEGA, getGadget(ParticleAuraNiceness.class), rarity, 4); + addGadget(Type.OMEGA, getGadget(ParticleCanadian.class), rarity, 1); + addGadget(Type.OMEGA, getGadget(ParticleStarSpangled.class), rarity, 1); - addMount(Type.OMEGA, getMount(MountFreedomHorse.class), rarity, 1); + addMount(Type.OMEGA, getMount(MountFreedomHorse.class), rarity, 5); addMount(Type.OMEGA, getMount(MountZombie.class), rarity, 1); addMount(Type.OMEGA, getMount(MountSpider.class), rarity, 1); addMount(Type.OMEGA, getMount(MountUndead.class), rarity, 1); - addMount(Type.OMEGA, getMount(MountValentinesSheep.class), rarity, 33); + addMount(Type.OMEGA, getMount(MountValentinesSheep.class), rarity, 20); addMount(Type.OMEGA, getMount(MountBabyReindeer.class), rarity, 1); addMount(Type.OMEGA, getMount(MountNightmareSteed.class), rarity, 10); + addMount(Type.OMEGA, getMount(MountChicken.class), rarity, 5); + addMount(Type.OMEGA, getMount(MountCake.class), rarity, 10); + addMount(Type.OMEGA, getMount(MountStPatricksHorse.class), rarity, 3); addGadget(Type.OMEGA, getGadget(WinEffectBabyChicken.class), rarity, 10); addGadget(Type.OMEGA, getGadget(WinEffectLavaTrap.class), rarity, 20); @@ -811,7 +865,8 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(DeathEnchant.class), rarity, 10); addGadget(Type.OMEGA, getGadget(DeathCupidsBrokenHeart.class), rarity, 25); - addGadget(Type.OMEGA, getGadget(DeathFrostLord.class), rarity, 20); + addGadget(Type.OMEGA, getGadget(DeathFrostLord.class), rarity, 15); + addGadget(Type.OMEGA, getGadget(DeathPresentDanger.class), rarity, 27); addGadget(Type.OMEGA, getGadget(DoubleJumpEnchant.class), rarity, 10); addGadget(Type.OMEGA, getGadget(DoubleJumpCupidsWings.class), rarity, 5); @@ -823,6 +878,9 @@ public class RewardManager addHat(Type.OMEGA, HatType.GRINCH, rarity, 25); + addGadget(Type.OMEGA, getGadget(OutfitStPatricksHat.class), rarity, 5); + addGadget(Type.OMEGA, getGadget(OutfitFreezeSuitHelmet.class), rarity, 2); + addBalloon(Type.OMEGA, BalloonType.SQUID, rarity, 10, 5000); addBalloon(Type.OMEGA, BalloonType.SILVERFISH, rarity, 30, 5000); addBalloon(Type.OMEGA, BalloonType.GUARDIAN, rarity, 30, 5000); @@ -842,6 +900,10 @@ public class RewardManager addBalloon(Type.NORMAL, BalloonType.GOLD_BLOCK, rarity, 30, 5000);*/ addBalloon(Type.NORMAL, BalloonType.EMERALD_BLOCK, rarity, 15, 5000); + addGadget(Type.OMEGA, getGadget(BlowAKissTaunt.class), rarity, 7); + addGadget(Type.OMEGA, getGadget(RainbowTaunt.class), rarity, 1); + + // HAUNTED addPetReward(Type.HAUNTED, PetType.RABBIT, rarity, 100); addGadget(Type.HAUNTED, getGadget(MorphGrimReaper.class), rarity, 25); @@ -1013,6 +1075,17 @@ public class RewardManager return addGadget(type, gadget, gadget.getDisplayName(), rarity, weight, shards); } + public UnknownPackageReward addFlag(Type type, FlagType flagType, RewardRarity rarity, int weight) + { + return addFlag(type, flagType, rarity, weight, getShards(rarity)); + } + + public UnknownPackageReward addFlag(Type type, FlagType flagType, RewardRarity rarity, int weight, int shards) + { + Gadget gadget = _gadgetManager.getFlagGadget(flagType); + return addGadget(type, gadget, gadget.getDisplayName(), rarity, weight, shards); + } + public UnknownPackageReward addBalloon(Type type, BalloonType balloonType, RewardRarity rarity, int weight) { return addBalloon(type, balloonType, rarity, weight, getShards(rarity)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java index 759769234..eff019430 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java @@ -7,9 +7,6 @@ import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.common.util.C; import static mineplex.core.common.util.C.*; -/** - * Created by Shaun on 9/2/2014. - */ public enum RewardRarity { /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingManager.java b/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingManager.java deleted file mode 100644 index 883975960..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingManager.java +++ /dev/null @@ -1,133 +0,0 @@ -package mineplex.core.sponsorbranding; - -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.concurrent.ConcurrentHashMap; - -import javax.imageio.ImageIO; - -import org.bukkit.Location; -import org.bukkit.block.BlockFace; -import mineplex.core.MiniPlugin; -import mineplex.core.ReflectivelyCreateMiniPlugin; - -/** - * - * Manager for creating billboards with branding logos - */ -@ReflectivelyCreateMiniPlugin -public class BrandingManager extends MiniPlugin -{ - private ConcurrentHashMap _posts = new ConcurrentHashMap(); - private ConcurrentHashMap _imgCache = new ConcurrentHashMap(); - - private BrandingManager() - { - super("Branding Manager"); - } - - private BufferedImage getImage(String fileName) - { - if (_imgCache.containsKey(fileName)) - { - return _imgCache.get(fileName); - } - - File folder = new File("../../update"); - File f = new File(folder, "logos" + File.separatorChar + fileName); - BufferedImage image = null; - - if (!f.exists()) - { - return null; - } - - try - { - image = ImageIO.read(f); - _imgCache.put(fileName, image); - } - catch (IOException e) - { - e.printStackTrace(); - } - - return image; - } - - private BufferedImage getImage(URL url) - { - if (_imgCache.containsKey(url.toString())) - { - return _imgCache.get(url.toString()); - } - - BufferedImage image = null; - - try - { - image = ImageIO.read(url); - _imgCache.put(url.toString(), image); - } - catch (IOException e) - { - e.printStackTrace(); - } - - return image; - } - - /** - * Generates a billboard with a stored logo - * @param location The center of the billboard - * @param facing The BlockFace the logo will appear on - * @param imageFileName The file name of the logo's base image - */ - public void createPost(Location location, BlockFace facing, String imageFileName) - { - BufferedImage img = getImage(imageFileName); - if (img == null) - { - System.out.println("ERROR! Invalid image file name!"); - return; - } - BrandingPost bp = new BrandingPost(location, facing, img); - bp.spawn(); - _posts.put(_posts.size(), bp); - } - - public void createPost(Location location, BlockFace facing, URL url) - { - BufferedImage image = getImage(url); - - if (image == null) - { - System.out.println("ERROR! Invalid image url!"); - return; - } - - BrandingPost brandingPost = new BrandingPost(location, facing, image); - brandingPost.spawn(); - // Umm why not use a List? - _posts.put(_posts.size(), brandingPost); - } - - /** - * Clears away all existing billboards - */ - public void reset() - { - disable(); - } - - @Override - public void disable() - { - for (Integer key : _posts.keySet()) - { - _posts.remove(key).despawn(); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingPost.java b/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingPost.java deleted file mode 100644 index 54f469646..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingPost.java +++ /dev/null @@ -1,242 +0,0 @@ -package mineplex.core.sponsorbranding; - -import java.awt.image.BufferedImage; -import java.util.List; - -import mineplex.core.common.util.UtilMath; - -import org.bukkit.Bukkit; -import org.bukkit.DyeColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.ItemFrame; -import org.bukkit.inventory.ItemStack; -import org.bukkit.map.MapRenderer; -import org.bukkit.map.MapView; - -import com.google.common.collect.Lists; - -/** - * An instance of a billboard with all its required data - */ -public class BrandingPost -{ - private Location _center; - private BlockFace _facing; - private BufferedImage _img; - - private Location[] _corners; - private List _ents = Lists.newArrayList(); - - public BrandingPost(Location center, BlockFace facing, BufferedImage image) - { - _center = center; - _facing = facing; - _img = image; - } - - @SuppressWarnings("deprecation") - private ItemStack getMapItem(int x, int y, BufferedImage image) - { - ItemStack item = new ItemStack(Material.MAP); - - MapView map = Bukkit.getServer().createMap(Bukkit.getServer().getWorlds().get(0)); - for (MapRenderer r : map.getRenderers()) - { - map.removeRenderer(r); - } - - map.addRenderer(new LogoMapRenderer(image, x, y)); - item.setDurability(map.getId()); - - return item; - } - - /** - * Generates a billboard using parameters from instance constructor - */ - @SuppressWarnings("deprecation") - public void spawn() - { - Location corner1 = _center.clone(); - Location corner2 = _center.clone(); - Location corner3 = _center.clone(); - Location corner4 = _center.clone(); - - int width = (int) Math.ceil(_img.getWidth() / 128); - int height = (int) Math.ceil(_img.getHeight() / 128); - - Bukkit.broadcastMessage("width=" + width + " height=" + height); - - switch (_facing) - { - case EAST: - corner1.add(0, 1, -2); - corner2.add(0, -1, 2); - corner3.add(0, 2, -3); - corner4.add(0, -2, 3); - break; - case WEST: - corner1.add(0, 1, -2); - corner2.add(0, -1, 2); - corner3.add(0, 2, -3); - corner4.add(0, -2, 3); - break; - case SOUTH: - corner1.add(-2, 1, 0); - corner2.add(2, -1, 0); - corner3.add(-3, 2, 0); - corner4.add(3, -2, 0); - break; - case NORTH: - corner1.add(-2, 1, 0); - corner2.add(2, -1, 0); - corner3.add(-3, 2, 0); - corner4.add(3, -2, 0); - break; - default: - System.out.println("ERROR! Invalid BlockFace given while loading BrandingPost!"); - return; - } - - _corners = new Location[] {corner1, corner2, corner3, corner4}; - - for (int x = Math.max(corner1.getBlockX(), corner2.getBlockX()); x >= Math.min(corner1.getBlockX(), corner2.getBlockX()); x--) - { - for (int y = Math.max(corner1.getBlockY(), corner2.getBlockY()); y >= Math.min(corner1.getBlockY(), corner2.getBlockY()); y--) - { - for (int z = Math.max(corner1.getBlockZ(), corner2.getBlockZ()); z >= Math.min(corner1.getBlockZ(), corner2.getBlockZ()); z--) - { - Location set = new Location(_center.getWorld(), x, y, z); - set.getBlock().setType(Material.STAINED_CLAY); - set.getBlock().setData(DyeColor.LIGHT_BLUE.getWoolData()); - } - } - } - - int xMod = 0; - int zMod = 0; - - switch (_facing) - { - case EAST: - zMod = -1; - break; - case WEST: - zMod = 1; - break; - case SOUTH: - xMod = 1; - break; - case NORTH: - xMod = -1; - break; - default: - break; - } - - BufferedImage image = _img; - - if (image == null) - { - System.out.println("ERROR! Invalid image given while loading BrandingPost!"); - return; - } - - Block base = corner1.getBlock().getRelative(_facing); - - try - { - for (int x = 0; x < width; x++) - { - for (int y = 0; y < height; y++) - { - ItemFrame i = null; - Block block = base.getRelative(x * xMod, -y, x * zMod); - i = block.getWorld().spawn(block.getLocation(), ItemFrame.class); - - i.setFacingDirection(_facing, false); - - ItemStack item = getMapItem(x, y, _img); - i.setItem(item); - - Bukkit.broadcastMessage(x + " <- X Y -> " + y); - _ents.add(i); - } - } - } - catch (NullPointerException e) - { - System.out.println("ERROR! ItemFrame space already occupied!"); - return; - } - - for (int x = Math.max(corner3.getBlockX(), corner4.getBlockX()); x >= Math.min(corner3.getBlockX(), corner4.getBlockX()); x--) - { - for (int y = Math.max(corner3.getBlockY(), corner4.getBlockY()); y >= Math.min(corner3.getBlockY(), corner4.getBlockY()); y--) - { - for (int z = Math.max(corner3.getBlockZ(), corner4.getBlockZ()); z >= Math.min(corner3.getBlockZ(), corner4.getBlockZ()); z--) - { - Location set = new Location(_center.getWorld(), x, y, z); - if (set.getBlock().getType() == Material.STAINED_CLAY) - continue; - - if (UtilMath.offset2d(corner3.getBlock().getLocation(), set.getBlock().getLocation()) == 0 || UtilMath.offset2d(corner4.getBlock().getLocation(), set.getBlock().getLocation()) == 0) - { - if (corner3.getBlockY() != set.getBlockY() && corner4.getBlockY() != set.getBlockY()) - { - Material type = Material.COBBLE_WALL; - if (_center.getBlockY() == set.getBlockY()) - { - type = Material.FENCE; - } - - set.getBlock().setType(type); - continue; - } - } - - Material type = Material.STEP; - byte data = (byte)5; - if (set.getBlockY() == corner4.getBlockY()) - { - type = Material.SMOOTH_BRICK; - data = (byte)0; - } - - set.getBlock().setType(type); - set.getBlock().setData(data); - } - } - } - } - - /** - * Clears away all blocks and ItemFrames generated by this billboard - */ - public void despawn() - { - if (_corners != null) - { - for (int x = Math.max(_corners[2].getBlockX(), _corners[3].getBlockX()); x >= Math.min(_corners[2].getBlockX(), _corners[3].getBlockX()); x--) - { - for (int y = Math.max(_corners[2].getBlockY(), _corners[3].getBlockY()); y >= Math.min(_corners[2].getBlockY(), _corners[3].getBlockY()); y--) - { - for (int z = Math.max(_corners[2].getBlockZ(), _corners[3].getBlockZ()); z >= Math.min(_corners[2].getBlockZ(), _corners[3].getBlockZ()); z--) - { - Location set = new Location(_center.getWorld(), x, y, z); - set.getBlock().setType(Material.AIR); - } - } - } - } - for (ItemFrame it : _ents) - { - it.setItem(new ItemStack(Material.AIR)); - it.remove(); - } - _ents.clear(); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/LogoMapRenderer.java b/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/LogoMapRenderer.java deleted file mode 100644 index 5dfb5822e..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/LogoMapRenderer.java +++ /dev/null @@ -1,51 +0,0 @@ -package mineplex.core.sponsorbranding; - -import java.awt.Image; -import java.awt.image.BufferedImage; - -import org.bukkit.entity.Player; -import org.bukkit.map.MapCanvas; -import org.bukkit.map.MapRenderer; -import org.bukkit.map.MapView; - -/** - * Renderer for each map panel of the full billboard logo - */ -public class LogoMapRenderer extends MapRenderer -{ - private Image _img; - private boolean _first = true; - - public LogoMapRenderer(BufferedImage image, int x1, int y1) - { - recalculateInput(image, x1, y1); - } - - private void recalculateInput(BufferedImage input, int x1, int y1) - { - if (x1 > input.getWidth() || y1 > input.getHeight()) - { - return; - } - - int startX = Math.min(x1 * 128, input.getWidth()); - startX = Math.max(input.getMinX(), startX); - int startY = Math.min(y1 * 128, input.getHeight()); - startY = Math.max(input.getMinY(), startY); - - _img = input.getSubimage(startX, startY, 128, 128); - - _first = true; - } - - @Override - public void render(MapView view, MapCanvas canvas, Player player) - { - if (_img != null && _first) - { - canvas.drawImage(0, 0, _img); - _first = false; - } - } - -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java new file mode 100644 index 000000000..d3ae17479 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java @@ -0,0 +1,67 @@ +package mineplex.core.stats.game; + +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.common.timing.TimingManager; +import mineplex.core.game.GameDisplay; +import mineplex.core.stats.StatsManager; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; + +@ReflectivelyCreateMiniPlugin +public class GameStatisticsManager extends MiniPlugin +{ + + private final StatsManager _statsManager; + + private final GameStatisticsRepository _repository; + + private final Map _gameMaps; + + private GameStatisticsManager() + { + super("Game Statistics"); + + _statsManager = require(StatsManager.class); + _repository = new GameStatisticsRepository(_statsManager); + _gameMaps = Collections.synchronizedMap(new HashMap<>()); + } + + public void getMapId(Consumer callback, GameDisplay gameType, String mapName) + { + if (_gameMaps.containsKey(mapName)) + { + if (callback != null) + { + callback.accept(_gameMaps.get(mapName)); + } + } + else + { + runAsync(() -> + _repository.getMapId(mapId -> + { + _gameMaps.put(mapName, mapId); + + if (callback != null) + { + runSync(() -> callback.accept(mapId)); + } + }, gameType.getGameId(), mapName)); + } + } + + public void saveGameStats(GameStats gameStats) + { + runAsync(() -> + { + TimingManager.start("Save Game Stats"); + _repository.saveGame(gameStats); + TimingManager.stop("Save Game Stats"); + }); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java new file mode 100644 index 000000000..162717f55 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java @@ -0,0 +1,166 @@ +package mineplex.core.stats.game; + +import mineplex.core.common.util.UtilTime; +import mineplex.core.game.GameDisplay; +import mineplex.core.stats.StatsManager; +import mineplex.serverdata.Region; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnTimestamp; +import mineplex.serverdata.database.column.ColumnVarChar; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; + +public class GameStatisticsRepository extends RepositoryBase +{ + + private static final String INSERT_MAP = "INSERT INTO gameMaps (gameType,mapName) VALUES (?,?)"; + private static final String GET_MAP_BY_ID = "SELECT mapId FROM gameMaps WHERE mapName=?"; + private static final String SAVE_GAME = "INSERT INTO gameStatistics (region,gameType,map,startTime,endTime) VALUES (?,?,?,?,?)"; + private static final String SAVE_STAT = "INSERT INTO gamePlayerStatistics VALUES (?,?,?,?);"; + private static final String GET_BY_ID = "SELECT * FROM gameStatistics WHERE gameId=?"; + private static final String SQL_REGEX = "\\?"; + private static final long MAX_RESPONSE_TIME = TimeUnit.SECONDS.toMillis(5); + + private final StatsManager _statsManager; + + public GameStatisticsRepository(StatsManager statsManager) + { + super(DBPool.getAccount()); + + _statsManager = statsManager; + } + + public void getMapId(Consumer callback, int gameId, String mapName) + { + executeQuery(GET_MAP_BY_ID, resultSet -> + { + if (resultSet.next()) + { + callback.accept(resultSet.getInt(1)); + } + else + { + executeInsert(INSERT_MAP, resultSetInsert -> + { + if (resultSetInsert.next()) + { + callback.accept(resultSetInsert.getInt(1)); + } + }, + new ColumnInt("gameType", gameId), + new ColumnVarChar("mapName", 32, mapName) + ); + } + }, new ColumnVarChar("mapName", 32, mapName)); + } + + public void saveGame(GameStats gameStats) + { + executeInsert(SAVE_GAME, resultSet -> + { + if (resultSet.next()) + { + int gameId = resultSet.getInt(1); + + saveGameStats(gameId, gameStats); + } + }, + + new ColumnVarChar("region", 2, gameStats.getRegion().name()), + new ColumnInt("gameType", gameStats.getGameType().getGameId()), + new ColumnInt("map", gameStats.getMapId()), + new ColumnTimestamp("startTime", new Timestamp(gameStats.getStartTime())), + new ColumnTimestamp("endTime", new Timestamp(gameStats.getEndTime())) + + ); + } + + private void saveGameStats(int gameId, GameStats gameStats) + { + String gameIdString = String.valueOf(gameId); + Map> stats = gameStats.getStats(); + + StringBuilder builder = new StringBuilder(1000); + long start = System.currentTimeMillis(); + AtomicInteger sqlAppends = new AtomicInteger(); + AtomicInteger expectedSqlAppends = new AtomicInteger(); + + stats.forEach((playerId, statsMap) -> expectedSqlAppends.getAndAdd(statsMap.size())); + + stats.forEach((playerId, statsMap) -> + { + String playerIdString = String.valueOf(playerId); + + statsMap.forEach((name, value) -> + { + _statsManager.loadStatId(name, statId -> + { + String statIdString = String.valueOf(statId); + String statValueString = String.valueOf(value); + + String sql = SAVE_STAT + .replaceFirst(SQL_REGEX, gameIdString) + .replaceFirst(SQL_REGEX, playerIdString) + .replaceFirst(SQL_REGEX, statIdString) + .replaceFirst(SQL_REGEX, statValueString); + + builder.append(sql); + sqlAppends.getAndIncrement(); + }); + }); + }); + + while (sqlAppends.get() < expectedSqlAppends.get()) + { + if (UtilTime.elapsed(start, MAX_RESPONSE_TIME)) + { + return; + } + + try + { + Thread.sleep(500); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + try ( + Connection connection = getConnection() + ) + { + PreparedStatement preparedStatement = connection.prepareStatement(builder.toString()); + + preparedStatement.executeUpdate(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + + public void getGameStats(Consumer callback, int gameId) + { + executeQuery(GET_BY_ID, resultSet -> + { + + if (resultSet.next()) + { + GameStats stats = new GameStats(gameId, Region.valueOf(resultSet.getString("region")), GameDisplay.getById(gameId)); + callback.accept(stats); + } + + }, new ColumnInt("gameId", gameId)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java new file mode 100644 index 000000000..d7abd582d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java @@ -0,0 +1,84 @@ +package mineplex.core.stats.game; + +import mineplex.core.game.GameDisplay; +import mineplex.serverdata.Region; + +import java.util.HashMap; +import java.util.Map; + +public class GameStats +{ + + private final int _gameId; + private final Region _region; + private final GameDisplay _gameType; + + private int _mapId; + private long _startTime; + private long _endTime; + + private final Map> _stats; + + public GameStats(int gameId, Region region, GameDisplay display) + { + _gameId = gameId; + _region = region; + _gameType = display; + _stats = new HashMap<>(); + } + + public int getGameId() + { + return _gameId; + } + + public Region getRegion() + { + return _region; + } + + public GameDisplay getGameType() + { + return _gameType; + } + + public void setMapId(int mapId) + { + _mapId = mapId; + } + + public int getMapId() + { + return _mapId; + } + + public void setStartTime(long startTime) + { + _startTime = startTime; + } + + public long getStartTime() + { + return _startTime; + } + + public void setEndTime(long endTime) + { + _endTime = endTime; + } + + public long getEndTime() + { + return _endTime; + } + + public Map> getStats() + { + return _stats; + } + + public boolean isValid() + { + return _region != null && _gameType != null && _mapId != 0 && _startTime != 0 && _endTime != 0; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java index 05c6833d0..fc5c8b3d6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java @@ -9,6 +9,11 @@ import java.util.function.Consumer; import mineplex.core.titles.tracks.award.AlienInvasionTrack; import mineplex.core.titles.tracks.award.AprilFools2017Track; +import mineplex.core.titles.tracks.award.ClansRaidTrack; +import mineplex.core.titles.tracks.staff.BuilderTrack; +import mineplex.core.titles.tracks.staff.ModeratorTrack; +import mineplex.core.titles.tracks.staff.SeniorModeratorTrack; +import mineplex.core.titles.tracks.staff.TraineeTrack; import mineplex.core.titles.tracks.standard.GemHuntersTrack; import net.md_5.bungee.api.ChatColor; @@ -86,6 +91,13 @@ public class TrackManager extends MiniPlugin registerTrack(new Bridges2017Track()); registerTrack(new AprilFools2017Track()); registerTrack(new AlienInvasionTrack()); + registerTrack(new ClansRaidTrack()); + + // Staff tracks + registerTrack(new BuilderTrack()); + registerTrack(new TraineeTrack()); + registerTrack(new ModeratorTrack()); + registerTrack(new SeniorModeratorTrack()); // Custom tracks // registerTrack(track("lenny", "Lenny", "( ͡° ͜ʖ ͡°)")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/ClansRaidTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/ClansRaidTrack.java new file mode 100644 index 000000000..9daaaeccd --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/ClansRaidTrack.java @@ -0,0 +1,28 @@ +package mineplex.core.titles.tracks.award; + +import mineplex.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; + +public class ClansRaidTrack extends ItemizedTrack +{ + public ClansRaidTrack() + { + super( + "clans-raid", + ChatColor.GOLD, + "Fallen Lord", + "The Fallen Lord", + "Among the first players to defeat the Charles Witherton raid!", + true); + + getRequirements() + .addTier(new TrackTier( + "The Fallen Lord", + null, + this::owns, + new TrackFormat(ChatColor.GOLD, ChatColor.GOLD) + )); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/BuilderTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/BuilderTrack.java new file mode 100644 index 000000000..e4254358c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/BuilderTrack.java @@ -0,0 +1,36 @@ +package mineplex.core.titles.tracks.staff; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Player; + +public class BuilderTrack extends ItemizedTrack +{ + + private final CoreClientManager _clientManager = Managers.get(CoreClientManager.class); + + public BuilderTrack() + { + super("staff-builder", ChatColor.BLUE, "Builder", "What's a Happer?", "What's a leader?", true); + getRequirements() + .addTier(new TrackTier( + "What's a Happer?", + null, + this::owns, + new TrackFormat(ChatColor.BLUE, ChatColor.BLUE) + )); + } + + @Override + public boolean owns(Player player) + { + Rank rank = _clientManager.Get(player).GetRank(true); + return rank == Rank.MAPDEV || rank == Rank.MAPLEAD || rank == Rank.MAPPER || rank.has(Rank.ADMIN); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/ModeratorTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/ModeratorTrack.java new file mode 100644 index 000000000..042d54e11 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/ModeratorTrack.java @@ -0,0 +1,36 @@ +package mineplex.core.titles.tracks.staff; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Player; + +public class ModeratorTrack extends ItemizedTrack +{ + + private final CoreClientManager _clientManager = Managers.get(CoreClientManager.class); + + public ModeratorTrack() + { + super("staff-moderator", ChatColor.GOLD, "Moderator", "My name isn't mod", "I have a name y'know!", true); + getRequirements() + .addTier(new TrackTier( + "My name isn't mod", + null, + this::owns, + new TrackFormat(ChatColor.GOLD, ChatColor.GOLD) + )); + } + + @Override + public boolean owns(Player player) + { + Rank rank = _clientManager.Get(player).GetRank(true); + return rank == Rank.MODERATOR || rank == Rank.CMA || rank.has(Rank.ADMIN); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java new file mode 100644 index 000000000..3521e362d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java @@ -0,0 +1,37 @@ +package mineplex.core.titles.tracks.staff; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Player; + +public class SeniorModeratorTrack extends ItemizedTrack +{ + + private final CoreClientManager _clientManager = Managers.get(CoreClientManager.class); + + public SeniorModeratorTrack() + { + super("staff-srmod", ChatColor.GOLD, "Sr.Mod", "My Team's the Best Team", "Team loyalty at its finest", true); + getRequirements() + .addTier(new TrackTier( + "My Team's the Best Team", + null, + this::owns, + new TrackFormat(ChatColor.GOLD, ChatColor.GOLD) + )); + } + + @Override + public boolean owns(Player player) + { + Rank rank = _clientManager.Get(player).GetRank(true); + return rank == Rank.SNR_MODERATOR || rank == Rank.CMOD || rank.has(Rank.ADMIN); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/TraineeTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/TraineeTrack.java new file mode 100644 index 000000000..3aa827567 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/TraineeTrack.java @@ -0,0 +1,35 @@ +package mineplex.core.titles.tracks.staff; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Player; + +public class TraineeTrack extends ItemizedTrack +{ + + private final CoreClientManager _clientManager = Managers.get(CoreClientManager.class); + + public TraineeTrack() + { + super("staff-trainee", ChatColor.GOLD, "Trainee", "Choo Choo", "Choo Choo I'm a train-ee", true); + getRequirements() + .addTier(new TrackTier( + "Choo Choo", + null, + this::owns, + new TrackFormat(ChatColor.GOLD, ChatColor.GOLD) + )); + } + + @Override + public boolean owns(Player player) + { + Rank rank = _clientManager.Get(player).GetRank(true); + return rank == Rank.HELPER || rank.has(Rank.ADMIN); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java index a9d3bf5c1..784018ca9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java @@ -18,7 +18,7 @@ public enum TreasureType ILLUMINATED(C.cAqua + "Illuminated Treasure", "Illuminated Chest", "Illuminated", RewardType.ILLUMINATED_CHEST, Material.CHEST, TreasureStyle.ILLUMINATED, RewardPool.Type.ILLUMINATED, true, 20000), - FREEDOM(C.cRed + "Freedom " + C.cBlue + "Treasure", "Freedom Treasure", "Freedom", RewardType.FREEDOM_CHEST, Material.CHEST, TreasureStyle.FREEDOM, RewardPool.Type.FREEDOM, true, 35000), + FREEDOM(C.cRed + "Freedom " + C.cBlue + "Treasure", "Freedom Treasure", "Freedom", RewardType.FREEDOM_CHEST, Material.CHEST, TreasureStyle.FREEDOM, RewardPool.Type.FREEDOM, true, 20000), OMEGA(C.cAqua + "Omega Chest", "Omega Chest", "Omega", RewardType.OMEGA_CHEST, Material.ENDER_CHEST, TreasureStyle.OMEGA, RewardPool.Type.OMEGA, false, 50000), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java index ca001e6a5..15a85c4dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.HandlerList; import mineplex.core.treasure.Treasure; /** - * Created by shaun on 14-09-12. + * Called once a player has finished with the treasure opening process. */ public class TreasureFinishEvent extends Event { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java index d384c61db..29355cfd1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** - * Created by shaun on 14-09-12. + * Called when a player selects a chest to open. */ public class TreasurePreStartEvent extends Event implements Cancellable { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java index 70c891f52..37d59dc74 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java @@ -10,6 +10,9 @@ import org.bukkit.event.HandlerList; import mineplex.core.reward.Reward; import mineplex.core.treasure.Treasure; +/** + * Called when a player is able to begin opening chests. + */ public class TreasureStartEvent extends Event { private static final HandlerList handlers = new HandlerList(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java index c119b1ae2..c10c4d15d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -51,24 +51,42 @@ public class BuyChestButton implements IButton if (_chestType == TreasureType.TRICK_OR_TREAT) { - if (!new File("../../update/files/EnableTrickOrTreat.dat").exists()) + if (!new File("../../update/files/EnableTrickOrTreatChest.dat").exists()) { player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); return; } + if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) + { + player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); + return; + } } if (_chestType == TreasureType.THANKFUL) { - if (!new File("../../update/files/EnableThankful.dat").exists()) + if (!new File("../../update/files/EnableThankfulChest.dat").exists()) { player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); return; } + if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) + { + player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); + return; + } } if (_chestType == TreasureType.GINGERBREAD) { - player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); - return; + if (!new File("../../update/files/EnableGingerbreadChest.dat").exists()) + { + player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); + return; + } + if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) + { + player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); + return; + } } if (_chestType == TreasureType.LOVE_CHEST) { @@ -109,16 +127,29 @@ public class BuyChestButton implements IButton return; } } - if (_chestType == TreasureType.FREEDOM || _chestType == TreasureType.HAUNTED) + if (_chestType == TreasureType.HAUNTED) { + if (!new File("../../update/files/EnableHauntedChest.dat").exists()) + { + player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); + return; + } if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) { player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); return; } - else + } + if (_chestType == TreasureType.FREEDOM) + { + if (!new File("../../update/files/EnableFreedomChest.dat").exists()) { - player.sendMessage(F.main("Treasure", "This chest is no longer available for purchases!")); + player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); + return; + } + if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) + { + player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); return; } } 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 030e3dc1d..d4efbd24a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -4,6 +4,15 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; +import mineplex.core.gadget.gadgets.flag.FlagType; +import mineplex.core.gadget.gadgets.hat.HatType; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -20,9 +29,9 @@ import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; -import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; import mineplex.core.gadget.gadgets.morph.MorphUncleSam; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; import mineplex.core.gadget.types.Gadget; @@ -140,20 +149,20 @@ public class TreasurePage extends ShopPageBase int stpatricksCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.ST_PATRICKS.getItemName()); int springCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.SPRING.getItemName()); - boolean availableChristmas = false; - boolean availableFreedom = false; - boolean availableHaunted = false; - boolean availableTrick = false; - boolean availableThank = false; - boolean availableGingerbread = false; - boolean availableLove = false; + boolean availableChristmas = new File("../../update/files/EnableChristmasChest.dat").exists(); + boolean availableFreedom = new File("../../update/files/EnableFreedomChest.dat").exists(); + boolean availableHaunted = new File("../../update/files/EnableHauntedChest.dat").exists(); + boolean availableTrick = new File("../../update/files/EnableTrickOrTreatChest.dat").exists(); + boolean availableThank = new File("../../update/files/EnableThankfulChest.dat").exists(); + boolean availableGingerbread = new File("../../update/files/EnableGingerbreadChest.dat").exists(); + boolean availableLove = new File("../../update/files/EnableLoveChest.dat").exists(); boolean availableStPatricks = new File("../../update/files/EnableStPatricksChest.dat").exists(); boolean availableSpring = new File("../../update/files/EnableSpringChest.dat").exists(); List shardLore = new ArrayList<>(); shardLore.add(" "); - shardLore.add(C.cGray + "This seems like it might come in"); - shardLore.add(C.cGray + "handy. Maybe I can collect more!"); + shardLore.add(C.cGray + "These seem like they might come in"); + shardLore.add(C.cGray + "handy. Maybe I should collect more!"); List basicLore = new ArrayList<>(); basicLore.add(" "); @@ -252,16 +261,40 @@ public class TreasurePage extends ShopPageBase freedomLore.add(" "); freedomLore.add(C.cGray + "It is said that George Washington"); freedomLore.add(C.cGray + "carved this chest himself from the wood"); - freedomLore.add(C.cGray + "of the apple tree he cut down..."); + freedomLore.add(C.cGray + "of the cherry tree he cut down..."); freedomLore.add(" "); - if (freedomCount > 0 && !hasAllFreedomItems(getPlayer())) - freedomLore.add(C.cGreen + "Click to Open!"); + + if (freedomCount > 0) + { + if (hasAllFreedomItems(getPlayer())) + { + freedomLore.add(C.cWhite + "You own all treasures from this chest."); + } + else + { + freedomLore.add(C.cGreen + "Click to Open!"); + } + } else { - freedomLore.add(C.cRed + "This item is no longer available!"); + if (!availableFreedom) + { + freedomLore.add(C.cRed + "This item is no longer available!"); + } + else if (hasAllFreedomItems(getPlayer())) + { + freedomLore.add(C.cWhite + "You own all treasures from this chest."); + } + else + { + freedomLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards"); + freedomLore.add(" "); + freedomLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop"); + } } + freedomLore.add(" "); - freedomLore.add(ChatColor.RESET + C.cGreen + getFreedomUnlockedAmount(getPlayer()) + "/7 Unlocked"); + freedomLore.add(ChatColor.RESET + C.cGreen + getFreedomUnlockedAmount(getPlayer()) + "/18 Unlocked"); List omegaLore = new ArrayList<>(); omegaLore.add(" "); @@ -699,7 +732,7 @@ public class TreasurePage extends ShopPageBase public int getFreedomUnlockedAmount(Player player) { if (hasAllFreedomItems(player)) - return 7; + return 18; int amount = 0; Gadget[] gadgets = new Gadget[] { @@ -708,7 +741,18 @@ public class TreasurePage extends ShopPageBase _gadgetManager.getGadget(ArrowTrailFreedom.class), _gadgetManager.getGadget(DoubleJumpFreedom.class), _gadgetManager.getGadget(DeathFreedom.class), - _gadgetManager.getGadget(MorphUncleSam.class) + _gadgetManager.getGadget(MorphUncleSam.class), + _gadgetManager.getGadget(ArrowTrailRedWhite.class), + _gadgetManager.getGadget(DeathMapleLeaf.class), + _gadgetManager.getGadget(DoubleJumpMaple.class), + _gadgetManager.getGadget(ParticleAuraNiceness.class), + _gadgetManager.getGadget(ParticleCanadian.class), + _gadgetManager.getGadget(ParticleFreedomFireworks.class), + _gadgetManager.getGadget(ParticleStarSpangled.class), + _gadgetManager.getHatGadget(HatType.AMERICA), + _gadgetManager.getHatGadget(HatType.CANADA), + _gadgetManager.getFlagGadget(FlagType.CANADA), + _gadgetManager.getFlagGadget(FlagType.USA), }; Mount freedomMount = _gadgetManager.getMountManager().getMount("Freedom Mount"); if (freedomMount != null) 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 ed924a65f..487ea34ce 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -66,7 +66,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.clans.freeze.ClansFreezeManager; import mineplex.game.clans.items.GearManager; import mineplex.game.clans.shop.building.BuildingShop; import mineplex.game.clans.shop.farming.FarmingShop; @@ -143,9 +143,9 @@ public class Clans extends JavaPlugin Portal portal = new Portal(); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion(), GenericServer.CLANS_HUB); - ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager); + ClansFreezeManager clansFreeze = new ClansFreezeManager(this, _clientManager); - Punish punish = new Punish(this, _clientManager); + Punish punish = new Punish(this, _clientManager, true); DisguiseManager disguiseManager = require(DisguiseManager.class); Creature creature = new Creature(this); @@ -187,7 +187,7 @@ public class Clans extends JavaPlugin GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); HologramManager hologram = new HologramManager(this, packetHandler); - _clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, inventory); + _clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, inventory); new Recipes(this); new Farming(this); new BuildingShop(_clansManager, _clientManager, _donationManager); @@ -243,4 +243,4 @@ public class Clans extends JavaPlugin { return MAP; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index 15b9df83f..a02020ecc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -759,6 +759,13 @@ public class ClansGame extends MiniPlugin ClanInfo clan = _clans.getClan(event.getPlayer()); Block block = event.getClickedBlock(); + + if (UtilEvent.isAction(event, ActionType.R_BLOCK) && block.getType() == Material.BED_BLOCK) + { + event.setCancelled(true); + return; + } + Player player = event.getPlayer(); if (clan == null) 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 8d872a932..2fed14075 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 @@ -90,7 +90,6 @@ import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.amplifiers.AmplifierManager; -import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.banners.BannerManager; import mineplex.game.clans.clans.boxes.BoxManager; import mineplex.game.clans.clans.commands.ClanManagementCommand; @@ -98,7 +97,6 @@ import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand; import mineplex.game.clans.clans.commands.ClansCommand; import mineplex.game.clans.clans.commands.KillCommand; -import mineplex.game.clans.clans.commands.MapCommand; import mineplex.game.clans.clans.commands.RegionsCommand; import mineplex.game.clans.clans.commands.SpeedCommand; import mineplex.game.clans.clans.data.PlayerClan; @@ -106,7 +104,6 @@ import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.gui.ClanShop; import mineplex.game.clans.clans.invsee.InvseeManager; import mineplex.game.clans.clans.loot.LootManager; -import mineplex.game.clans.clans.map.ItemMapManager; import mineplex.game.clans.clans.mounts.MountManager; import mineplex.game.clans.clans.nameblacklist.ClansBlacklist; import mineplex.game.clans.clans.nether.NetherManager; @@ -115,7 +112,6 @@ import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.potato.PotatoManager; import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler; import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; -import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.siege.SiegeManager; @@ -124,6 +120,7 @@ import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager; import mineplex.game.clans.clans.war.WarManager; import mineplex.game.clans.clans.warpoints.WarPointEvasion; import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.ClanDeleteCommand; import mineplex.game.clans.core.ClanLoadCommand; import mineplex.game.clans.core.repository.ClanTerritory; @@ -257,7 +254,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati // Spawn area - public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, InventoryManager inventoryManager) + public ClansManager(JavaPlugin plugin, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, InventoryManager inventoryManager) { super("Clans Manager", plugin); @@ -288,7 +285,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati _npcManager = new NpcManager(plugin, Managers.get(Creature.class)); _condition = new SkillConditionManager(plugin); _damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition); - _damageManager.addCommand(new KillCommand(_damageManager)); _condition.setDamageManager(_damageManager); _worldEvent = new WorldEventManager(plugin, this, _damageManager, _lootManager, blockRestore, _clanRegions, null); @@ -494,6 +490,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati addCommand(new ClanManagementCommand(this)); // addCommand(new MapCommand(this)); addCommand(new SpeedCommand(this)); + addCommand(new KillCommand(this)); } public void loadClan(ClanToken clanToken, boolean loadBanner) @@ -515,7 +512,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati } if (loadBanner) + { _bannerManager.loadBanner(clan); + } } public void loadClan(ClanToken clanToken) @@ -793,10 +792,12 @@ public class ClansManager extends MiniClientPluginimplements IRelati { player.setOp(true); } - if(player.getInventory().getHelmet() != null) { //Reset helmet to fix 1 damage bug + if (player.getInventory().getHelmet() != null) //Reset helmet to fix 1 damage bug + { ItemStack helmet = player.getInventory().getHelmet().clone(); player.getInventory().setHelmet(null); - runSyncLater(() -> { + runSyncLater(() -> + { player.getInventory().setHelmet(helmet); }, 20L); } @@ -807,7 +808,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati { // happens 20 ticks later because player channels don't // seem to work immediately after joining. - runSyncLater(() -> { + runSyncLater(() -> + { ByteArrayDataOutput bado = ByteStreams.newDataOutput(); bado.writeUTF("no_xray"); @@ -845,7 +847,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (String message : messages) { - if (!event.getMessage().equalsIgnoreCase("/" + message) && !event.getMessage().startsWith("/" + message + " ")) + if (!event.getMessage().equalsIgnoreCase("/" + message) && !event.getMessage().toLowerCase().startsWith("/" + message + " ")) { continue; } @@ -904,7 +906,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (Player other : event.getRecipients()) { if (_tutorial.inTutorial(other)) + { continue; + } UtilPlayer.message(other, String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), event.getMessage())); } @@ -918,7 +922,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (Player other : event.getRecipients()) { if (_tutorial.inTutorial(other)) + { continue; + } ClanInfo otherClan = _clanUtility.getClanByPlayer(other); @@ -941,7 +947,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void disableObsidian(BlockBreakEvent event) { - if(event.getBlock().getType().equals(Material.OBSIDIAN)) + if (event.getBlock().getType().equals(Material.OBSIDIAN)) { event.setCancelled(true); event.getBlock().setType(Material.AIR); @@ -977,7 +983,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati String rank = _clientManager.Get(event.getPlayer()).GetRank().getTag(true, true) + " "; if (!_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH)) + { rank = ""; + } if (client.isClanChat() && clan != null) { @@ -1029,7 +1037,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + { rank = ""; + } handleClanChat(caller, message, clan, rank); } @@ -1039,7 +1049,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + { rank = ""; + } handleAllyChat(caller, message, clan, rank); } @@ -1317,7 +1329,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati public void updateBedStatus(UpdateEvent event) { if (event.getType() != UpdateType.TWOSEC) + { return; + } for (String name : getClanNameSet()) { @@ -1392,7 +1406,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati { _clanMemberLeftMap.remove(uuid); _warPointEvasion.resetCooldown(uuid); - } @EventHandler(priority = EventPriority.LOWEST) @@ -1406,7 +1419,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati { if (event.getEntered() instanceof Player && event.getVehicle() instanceof Horse) { - if(!Recharge.Instance.use((Player) event.getEntered(), "Ride Horse", 2 * 20L, true, false)) + if (!Recharge.Instance.use((Player) event.getEntered(), "Ride Horse", 2 * 20L, true, false)) { event.setCancelled(true); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index 4f63bf168..f019fa1d5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -282,7 +282,7 @@ public class ClansUtility public boolean isSafe(Player player) { - if (!UtilTime.elapsed(_clansManager.getCombatManager().Get(player).GetLastDamaged(), Spawn.COMBAT_TAG_DURATION)) return false; + if (!UtilTime.elapsed(_clansManager.getCombatManager().Get(player).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION)) return false; return isSafe(player.getLocation()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanCache.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanCache.java deleted file mode 100644 index 73178787c..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanCache.java +++ /dev/null @@ -1,26 +0,0 @@ -package mineplex.game.clans.clans.ban; - -/** - * Stores the data provided through the /cban (Clans ban) command for use further in the plugin. - */ -public class ClansBanCache -{ - private String _victim; - private String _reason; - - public ClansBanCache(String victim, String reason) - { - _victim = victim; - _reason = reason; - } - - public String getVictim() - { - return _victim; - } - - public String getReason() - { - return _reason; - } -} 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 deleted file mode 100644 index b15f69518..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java +++ /dev/null @@ -1,146 +0,0 @@ -package mineplex.game.clans.clans.ban.ui; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.shop.page.ShopPageBase; -import mineplex.game.clans.clans.ban.ClansBan; -import mineplex.game.clans.clans.ban.ClansBanClient; -import mineplex.game.clans.clans.ban.ClansBanManager; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; - -public class ClansBanPage extends ShopPageBase -{ - private long _time; - private boolean _permanent; - - private String _victimName; - private ClansBanClient _victimClient; - - private String _reason; - - public ClansBanPage(final ClansBanManager banManager, final ClansBanShop shop, final String name, final Player player, String victimName, ClansBanClient client, String reason) - { - super(banManager, shop, banManager.getClientManager(), banManager.getDonationManager(), name, player); - - _reason = reason; - - _victimName = victimName; - _victimClient = client; - - buildPage(); - } - - protected void buildPage() - { - _time = Math.max(0, _time); - - int slot = 27; - - // Middle of first row - addButton(4, new ItemBuilder(Material.SKULL_ITEM) - .setData((short) 3) - .setPlayerHead(_victimName) - .setTitle(C.cDGreenB + _victimName) - .addLore(" ") - .addLore(C.cYellow + _reason).build(), (player, click) -> {}); - - addTimeAdjuster((9 * 1 + 2), -(1000l * 60l * 60l)); - addTimeAdjuster((9 * 1 + 1), -(1000l * 60l * 60l * 24l)); - addTimeAdjuster((9 * 1 + 0), -(1000l * 60l * 60l * 24l * 30l)); - addTimeAdjuster((9 * 1 + 6), (1000l * 60l * 60l)); - addTimeAdjuster((9 * 1 + 7), (1000l * 60l * 60l * 24l)); - addTimeAdjuster((9 * 1 + 8), (1000l * 60l * 60l * 24l * 30l)); - - addButton((9 * 1) + 4, - new ItemBuilder(Material.RECORD_5) - .setTitle(C.cRedB + "Ban Player") - .setLore( - " ", - C.cGray + "Player: " + F.elem(_victimName), - C.cGray + "Reason: " + F.elem(_reason), - C.cGray + "Time: " + F.elem(_permanent ? "Permanent" : UtilTime.MakeStr(_time)), - "", - C.cRed + C.Italics + "Left-Click to BAN PLAYER", - C.cGray + C.Italics + "Right-Click to toggle permanent ban setting" - ).build(), - (player, click) -> { - if (click == ClickType.RIGHT) - { - _permanent = !_permanent; - refresh(); - } - else - { - performBan(); - } - }); - - for (ClansBan ban : _victimClient._bans) - { - ItemStack item = new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK) - .setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive") - .addLore(" ") - .addLore(C.cGray + "Date banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime())) - .addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin()) - .addLore(C.cGray + "Time left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None")) - .addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No")) - .addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16) - .addLore(C.cGray + "Is Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No")) - .addLore(ban.isActive() ? " " : null) - .addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null) - .setGlow(ban.isActive()) - .build(); - - addButton(slot++, item, (player, click) -> { - if (ban.isActive()) - { - getPlugin().runAsync(() -> { - getPlugin().unban(_victimClient, ban, client -> { - refresh(); - player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f); - }); - }); - } - }); - } - } - - private void performBan() - { - getPlugin().getRepository().ban(_victimClient._uuid, getPlayer().getName(), _permanent ? -1 : _time, _reason) - .thenAccept(maybeBan -> getPlugin().runSync(() -> - { - if (maybeBan.isPresent()) - { - _victimClient._bans.add(maybeBan.get()); - - String banTimeFormatted = _victimClient.getBanTimeFormatted(); - UtilPlayer.message(getPlayer(), F.main("Clans", F.elem(_victimName) + " is now banned " + banTimeFormatted + ".")); - - Player target = Bukkit.getPlayer(_victimClient._uuid); - target.kickPlayer(C.cRedB + "You have been banned from Clans " + banTimeFormatted + "."); - refresh(); - } else - { - F.main("Clans", C.cRed + "An issue occurred when trying to ban " + F.elem(_victimName)); - } - })); - } - - private void addTimeAdjuster(int index, long time) - { - addButton(index, new ItemBuilder(Material.PAPER).setTitle(C.cRed + (time < 0 ? "-" : "") + UtilTime.MakeStr(Math.abs(time))).build(), - (player, click) -> { - _time += time; - refresh(); - }); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java index 7f9b6f85a..2f16ab4b0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java @@ -1,17 +1,19 @@ package mineplex.game.clans.clans.commands; +import org.bukkit.entity.Player; + 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.common.util.UtilTime; +import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClansManager; -import mineplex.minecraft.game.core.damage.DamageManager; +import mineplex.game.clans.spawn.Spawn; -import org.bukkit.entity.Player; - -public class KillCommand extends CommandBase +public class KillCommand extends CommandBase { - public KillCommand(DamageManager plugin) + public KillCommand(ClansManager plugin) { super(plugin, Rank.ALL, "suicide", "kill"); } @@ -19,26 +21,26 @@ public class KillCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if ((System.currentTimeMillis() - Plugin.GetCombatManager().Get(caller).GetLastCombat()) <= 20000) + if (!UtilTime.elapsed(Plugin.getCombatManager().Get(caller).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION)) { UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in combat.")); return; } - if(ClansManager.getInstance().getTutorial().inTutorial(caller)) + if (Plugin.getTutorial().inTutorial(caller)) { UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in the tutorial.")); return; } - if (mineplex.core.recharge.Recharge.Instance.use(caller, "Suicide", 5000, false, false)) - { - UtilPlayer.message(caller, F.main("Clans", "Please wait a bit before suiciding")); - return; - } - if (ClansManager.getInstance().getClanUtility().isSafe(caller.getLocation()) || (ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null && ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equalsIgnoreCase("Spawn"))) + if (Plugin.getClanUtility().isSafe(caller.getLocation()) || (Plugin.getClanUtility().getClaim(caller.getLocation()) != null && Plugin.getClanUtility().getClaim(caller.getLocation()).Owner.equalsIgnoreCase("Spawn"))) { UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in a safezone!")); return; } + if (Recharge.Instance.use(caller, "Suicide", 5000, false, false)) + { + UtilPlayer.message(caller, F.main("Clans", "Run the command again to confirm.")); + return; + } UtilPlayer.message(caller, F.main("Clans", "You have imploded.")); 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/freeze/ClansFreezeManager.java similarity index 79% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java index ab8e38228..6442c239e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.clans.ban; +package mineplex.game.clans.clans.freeze; import java.util.HashMap; import java.util.Map; @@ -12,7 +12,6 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityTargetLivingEntityEvent; -import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -23,89 +22,38 @@ import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.donation.DonationManager; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ban.commands.ClansBanCommand; -import mineplex.game.clans.clans.ban.commands.FreezeCommand; -import mineplex.game.clans.clans.ban.commands.UnfreezeCommand; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.clans.freeze.commands.FreezeCommand; +import mineplex.game.clans.clans.freeze.commands.UnfreezeCommand; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -public class ClansBanManager extends MiniPlugin +public class ClansFreezeManager extends MiniPlugin { private static final long FREEZE_MESSAGE_INTERVAL = 10000; private final CoreClientManager _clientManager; - private final DonationManager _donationManager; - private final ClansBanRepository _repository; private final Map _frozen = new HashMap<>(); - public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) + public ClansFreezeManager(JavaPlugin plugin, CoreClientManager clientManager) { - super("Blacklist", plugin); + super("Freeze", plugin); _clientManager = clientManager; - - _repository = new ClansBanRepository(plugin); - - _donationManager = donationManager; } @Override public void addCommands() { - addCommand(new ClansBanCommand(this)); addCommand(new FreezeCommand(this)); addCommand(new UnfreezeCommand(this)); } - - public CoreClientManager getClientManager() - { - return _clientManager; - } - - public DonationManager getDonationManager() - { - return _donationManager; - } - - public ClansBanRepository getRepository() - { - return _repository; - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onLogin(AsyncPlayerPreLoginEvent event) - { - try - { - ClansBanClient client = _repository.loadClient(event.getUniqueId()).get(); - - 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.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, reason); - } - } catch (Exception ignored) {} - } @EventHandler(priority = EventPriority.LOW) public void onQuit(PlayerQuitEvent event) @@ -131,7 +79,7 @@ public class ClansBanManager extends MiniPlugin if (isFrozen(event.getPlayer()) && UtilMath.offset2d(event.getFrom().getBlock().getLocation(), event.getTo().getBlock().getLocation()) >= 1) { event.setCancelled(true); - event.getPlayer().teleport(event.getFrom().getBlock().getLocation().add(0, 1, 0)); + event.getPlayer().teleport(event.getFrom().getBlock().getLocation().add(0, 0.5, 0)); } } @@ -299,17 +247,4 @@ public class ClansBanManager extends MiniPlugin } } } - - public void unban(ClansBanClient target, ClansBan ban, Callback callback) - { - if (!target._uuid.equals(ban.getUUID())) - { - return; - } - - ban.remove(); - _repository.removeBan(ban); - - callback.run(target); - } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/FreezeCommand.java similarity index 81% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/FreezeCommand.java index 1a75c70d7..a5c55a670 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/FreezeCommand.java @@ -1,20 +1,20 @@ -package mineplex.game.clans.clans.ban.commands; +package mineplex.game.clans.clans.freeze.commands; 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; +import mineplex.game.clans.clans.freeze.ClansFreezeManager; import org.bukkit.entity.Player; /** * Command to freeze players */ -public class FreezeCommand extends CommandBase +public class FreezeCommand extends CommandBase { - public FreezeCommand(ClansBanManager plugin) + public FreezeCommand(ClansFreezeManager plugin) { super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "freeze"); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/UnfreezeCommand.java similarity index 81% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/UnfreezeCommand.java index 13e4aa098..7f9f7bd92 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/UnfreezeCommand.java @@ -1,20 +1,20 @@ -package mineplex.game.clans.clans.ban.commands; +package mineplex.game.clans.clans.freeze.commands; 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; +import mineplex.game.clans.clans.freeze.ClansFreezeManager; import org.bukkit.entity.Player; /** * Command to unfreeze players */ -public class UnfreezeCommand extends CommandBase +public class UnfreezeCommand extends CommandBase { - public UnfreezeCommand(ClansBanManager plugin) + public UnfreezeCommand(ClansFreezeManager plugin) { super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "unfreeze"); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java index 2460ffea9..0100cb175 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -20,6 +20,7 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.inventory.HorseInventory; import org.bukkit.plugin.java.JavaPlugin; @@ -34,6 +35,7 @@ import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; import mineplex.core.donation.DonationManager; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -266,7 +268,7 @@ public class MountManager extends MiniDbClientPlugin { if (UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME") != null) { - Long dismount = (Long) UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME"); + Long dismount = UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME"); if (UtilTime.elapsed(dismount.longValue(), MAX_TIME_DISMOUNTED)) { mountIterator.remove(); @@ -396,7 +398,7 @@ public class MountManager extends MiniDbClientPlugin } @EventHandler(priority = EventPriority.LOWEST) - public void handleHorseHits(CustomDamageEvent event) + public void redirectHorseDamage(CustomDamageEvent event) { if (event.GetDamageeEntity() == null || !(event.GetDamageeEntity() instanceof Horse)) { @@ -413,14 +415,16 @@ public class MountManager extends MiniDbClientPlugin mount.despawn(false); return; } - event.setDamagee(mount.getOwner()); - if (event.GetCause() != DamageCause.FALL) + if (mount.getEntity().getPassenger() == null) { - mount.handleHit(); + event.SetCancelled("Killing riderless mount"); + mount.despawn(true); + return; } + event.setDamagee(mount.getOwner()); } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void handleRiderHits(CustomDamageEvent event) { if (event.GetDamageePlayer() == null || event.GetDamageePlayer().getVehicle() == null || !(event.GetDamageePlayer().getVehicle() instanceof Horse)) @@ -479,6 +483,18 @@ public class MountManager extends MiniDbClientPlugin UtilPlayer.message(event.getPlayer(), F.main(getName(), "This is not your Mount!")); event.setCancelled(true); } + + @EventHandler + public void onChunkUnload(ChunkUnloadEvent event) + { + _spawnedMounts.entrySet().forEach(entry -> + { + if (UtilWorld.isInChunk(entry.getKey().getLocation(), event.getChunk())) + { + entry.getValue().despawn(false); + } + }); + } @Override public String getQuery(int accountId, String uuid, String name) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index fdbe13146..77d53a997 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -40,7 +40,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; 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; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java new file mode 100644 index 000000000..663bd3850 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java @@ -0,0 +1,37 @@ +package mineplex.game.clans.clans.worldevent.capturepoint; + +import mineplex.core.common.util.UtilWorld; +import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; + +public class CapturePointEvent extends WorldEvent +{ + public CapturePointEvent(WorldEventManager manager) + { + super("Capture Point", CapturePointLocation.getRandomLocation().toLocation(UtilWorld.getWorld("world")), 5, true, manager.getDisguiseManager(), manager.getClans().getProjectile(), manager.getDamage(), manager.getBlockRestore(), manager.getClans().getCondition()); + } + + @Override + protected void customStart() + { + + } + + @Override + protected void customTick() + { + + } + + @Override + public void customCleanup(boolean onDisable) + { + + } + + @Override + protected void customStop() + { + + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java new file mode 100644 index 000000000..cd205cb7f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java @@ -0,0 +1,30 @@ +package mineplex.game.clans.clans.worldevent.capturepoint; + +import java.util.concurrent.ThreadLocalRandom; + +import org.bukkit.Location; +import org.bukkit.World; + +public enum CapturePointLocation +{ + ; + + private final double _x, _y, _z; + + private CapturePointLocation(double x, double y, double z) + { + _x = x; + _y = y; + _z = z; + } + + public Location toLocation(World world) + { + return new Location(world, _x, _y, _z); + } + + public static CapturePointLocation getRandomLocation() + { + return CapturePointLocation.values()[ThreadLocalRandom.current().nextInt(CapturePointLocation.values().length)]; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java index f3331ad5c..6903d35ab 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java @@ -251,7 +251,8 @@ public abstract class RaidWorldEvent extends WorldEvent } if (_players.remove(event.getPlayer())) { - event.getPlayer().teleport(Spawn.getNorthSpawn()); + event.getPlayer().setHealth(0); + event.getPlayer().spigot().respawn(); } } @@ -264,13 +265,7 @@ public abstract class RaidWorldEvent extends WorldEvent } if (_players.remove(event.getEntity())) { - event.getEntity().setHealth(event.getEntity().getMaxHealth()); - getCondition().Clean(event.getEntity()); - event.getEntity().getActivePotionEffects().forEach(pe -> event.getEntity().removePotionEffect(pe.getType())); - event.getEntity().setExp(0); - event.getEntity().setLevel(0); - event.getEntity().setFireTicks(-1); - event.getEntity().teleport(Spawn.getNorthSpawn()); + Manager.runSyncLater(() -> event.getEntity().spigot().respawn(), 10); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java index c421b4b82..8fb52f8c6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java @@ -29,7 +29,7 @@ public class HeatingUp extends Cataclysm @Override protected void onStart() { - ((MagmusMeteor)Magmus.Abilities.get(2)).Disabled = true; + Magmus.HeatingRoom = true; _center = Challenge.getRaid().getWorldData().getCustomLocs("C_SIX_C1S").get(0); for (int x = -1; x <= 1; x++) { @@ -50,17 +50,14 @@ public class HeatingUp extends Cataclysm _center.getBlock().getRelative(x, -1, z).setType(Material.STONE); } } - if (Magmus.Abilities.size() > 1 && Magmus.Abilities.get(2) instanceof MagmusMeteor) - { - ((MagmusMeteor)Magmus.Abilities.get(2)).Disabled = false; - } + Magmus.HeatingRoom = false; } @Override protected void tick() { _ticks++; - if (_ticks > (20 * 10)) + if (_ticks > (20 * 10) && _ticks <= (20 * 30)) { for (Player player : Challenge.getRaid().getPlayers()) { @@ -71,7 +68,7 @@ public class HeatingUp extends Cataclysm } } } - if (_ticks > (20 * 30)) + if (_ticks > (20 * 33)) { end(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java index 490adbfb0..daae379f7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java @@ -26,6 +26,7 @@ public class Magmus extends RaidCreature protected List> Abilities = new ArrayList<>(); protected boolean TeleportBackASAP = true; + protected boolean HeatingRoom = false; public Magmus(ChallengeSix challenge, Location location) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java index 1bec42e4c..da2120316 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java @@ -40,6 +40,10 @@ public class MagmusCataclysm extends BossPassive @Override public void tick() { + if (getBoss().HeatingRoom) + { + return; + } if (UtilTime.elapsed(_lastUse, getCooldown() * 1000)) { _lastUse = System.currentTimeMillis(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java index f174ced35..4100a889b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java @@ -39,7 +39,7 @@ public class MagmusEat extends BossPassive private void eat() { - if (_ticks < 20 * 10) + if (_ticks < 20 * 10 && !getBoss().HeatingRoom) { _eating.setFireTicks(40); _eating.teleport(getEntity()); @@ -73,6 +73,10 @@ public class MagmusEat extends BossPassive @Override public void tick() { + if (getBoss().HeatingRoom) + { + return; + } if (_eating != null) { eat(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java index c0da5fa5b..f358e511f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java @@ -28,8 +28,6 @@ public class MagmusMeteor extends BossPassive private long _lastUse; private List _shot = new ArrayList<>(); - protected boolean Disabled = false; - public MagmusMeteor(Magmus creature) { super(creature); @@ -38,7 +36,7 @@ public class MagmusMeteor extends BossPassive private void newBall() { - if (Disabled) + if (getBoss().HeatingRoom) { return; } @@ -72,7 +70,7 @@ public class MagmusMeteor extends BossPassive @Override public void tick() { - if (Disabled) + if (getBoss().HeatingRoom) { return; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java index 50eab5b2b..7fd1de661 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java @@ -62,6 +62,10 @@ public class MagmusSmash extends BossPassive @Override public void tick() { + if (getBoss().HeatingRoom) + { + return; + } if (UtilTime.elapsed(_lastUse, getCooldown() * 1000)) { _lastUse = System.currentTimeMillis(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java index 995598c15..da8fc5cca 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java @@ -61,7 +61,6 @@ public class DurabilityManager implements Listener _itemDurabilities.put(Material.LEATHER_CHESTPLATE, 900); _itemDurabilities.put(Material.LEATHER_LEGGINGS, 900); _itemDurabilities.put(Material.LEATHER_BOOTS, 900); - _itemDurabilities.put(Material.BOW, 900); } private boolean canRepair(ItemStack item) 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 d54d83ebb..83b1d6a5a 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 @@ -610,15 +610,13 @@ public class Gameplay extends MiniPlugin final byte data = block.getData(); - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { - public void run() + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> + { + Material mat = block.getRelative(BlockFace.DOWN).getType(); + if (mat == Material.DIRT || mat == Material.GRASS) { - Material mat = block.getRelative(BlockFace.DOWN).getType(); - if (mat == Material.DIRT || mat == Material.GRASS) - { - block.setType(Material.SAPLING); - block.setData(data); - } + block.setType(Material.SAPLING); + block.setData(data); } }, 20 * 10); } @@ -637,7 +635,9 @@ public class Gameplay extends MiniPlugin event.setCancelled(true); for (int x = -1; x <= 1; x++) + { for (int y = -1; y <= 1; y++) + { for (int z = -1; z <= 1; z++) { // Self @@ -659,6 +659,8 @@ public class Gameplay extends MiniPlugin if (block.getTypeId() == 0) block.setType(Material.FIRE); } + } + } } @EventHandler @@ -756,4 +758,4 @@ public class Gameplay extends MiniPlugin { UtilPlayer.message(player, F.main("Clans", message)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java index d964df566..350e6228c 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 @@ -23,8 +23,8 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.clans.freeze.ClansFreezeManager; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.worldevent.raid.RaidManager; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import mineplex.game.clans.restart.RestartManager; @@ -66,7 +66,7 @@ public class SafeLog extends MiniPlugin return; } - if (Managers.get(ClansBanManager.class).isFrozen(player)) + if (Managers.get(ClansFreezeManager.class).isFrozen(player)) { isSafeLog = true; } 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 dfb7547ea..0b439df86 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 @@ -102,9 +102,9 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable // Weightings for randomly selecting item type (legendary/weapon/armor/bow) private static final WeightSet TYPE_WEIGHTS = new WeightSet( - new Weight<>(6, ItemType.LEGENDARY), + new Weight<>(9, ItemType.LEGENDARY), new Weight<>(9, ItemType.RARE), - new Weight<>(46 - 9, ItemType.ARMOR), + new Weight<>(34, ItemType.ARMOR), new Weight<>(25, ItemType.WEAPON), new Weight<>(23, ItemType.BOW) ); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java index b054624ad..06d840826 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java @@ -1,16 +1,21 @@ package mineplex.game.clans.items.legendaries; +import org.bukkit.GameMode; import org.bukkit.Material; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import mineplex.core.common.util.C; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.ClansUtility; import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class DemonicScythe extends LegendaryItem { public DemonicScythe() { - super("Scythe of the Fallen Lord", new String[]{ + super("Scythe of the Fallen Lord", new String[] + { C.cWhite + "An old blade fashioned of nothing more", C.cWhite + "than bones and cloth which served no", C.cWhite + "purpose. Brave adventurers however have", @@ -20,10 +25,47 @@ public class DemonicScythe extends LegendaryItem C.cYellow + "Attack" + C.cWhite + " to use" + C.cGreen + " Leach Health", }, Material.RECORD_8); } + + private boolean isTeammate(Entity attacker, Entity defender) + { + if (attacker == null || defender == null) return false; + // Don't count attacks towards teammates + if (attacker instanceof Player && defender instanceof Player) + { + ClansUtility.ClanRelation relation = ClansManager.getInstance().getRelation((Player) attacker, (Player) defender); + if (relation == ClansUtility.ClanRelation.ALLY + || relation == ClansUtility.ClanRelation.SAFE + || relation == ClansUtility.ClanRelation.SELF) + { + return true; + } + } + return false; + } @Override public void onAttack(CustomDamageEvent event, Player wielder) { + if (event.isCancelled()) + { + return; + } + if (ClansManager.getInstance().isSafe(wielder)) + { + return; + } + if (event.GetDamageeEntity() instanceof Player && ClansManager.getInstance().isSafe(event.GetDamageePlayer())) + { + return; + } + if (wielder.getGameMode().equals(GameMode.CREATIVE)) + { + return; + } + if (isTeammate(wielder, event.GetDamageeEntity())) + { + return; + } event.AddMod("Scythe of the Fallen Lord", 8); wielder.setHealth(Math.min(wielder.getMaxHealth(), wielder.getHealth() + 2)); } 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 07750faf6..1a1524f42 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 @@ -16,7 +16,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.item.event.WebTossEvent; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Bukkit; @@ -24,7 +23,6 @@ import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Entity; @@ -51,7 +49,6 @@ public class Spawn extends MiniPlugin { public static final int SPAWN_RADIUS = 32; 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); @@ -201,7 +198,6 @@ public class Spawn extends MiniPlugin + ChatColor.YELLOW + F.time(UtilTime.convertString(COMBAT_TAG_DURATION - duration, 1, TimeUnit.FIT)); UtilTextMiddle.display(null, message, 0, 20, 0, cur); - _clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, 1.d, 0, false, Material.FIRE, (byte)0, true); playUnsafeParticles(cur); } else if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION + 600)) @@ -277,6 +273,7 @@ public class Spawn extends MiniPlugin public void onRespawn(PlayerRespawnEvent event) { event.setRespawnLocation(getSpawnLocation()); + _clansManager.getCombatManager().Get(event.getPlayer()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); } /* @@ -490,16 +487,14 @@ public class Spawn extends MiniPlugin public boolean isCombatTagged(Player player) { - return _clansManager.getCondition().HasCondition(player, ConditionType.CUSTOM, COMBAT_TAG_NAME); + return !UtilTime.elapsed(_clansManager.getCombatManager().Get(player).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION); } public void teleport(final Player player, final Location location, int delay) { - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { - @Override - public void run() { - player.teleport(location); - } + Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> + { + player.teleport(location); }, delay); } @@ -521,7 +516,9 @@ public class Spawn extends MiniPlugin public void playDatMusicALLDAYLONG(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } if (UtilTime.elapsed(_songEastLast, _songEastLength)) { @@ -542,4 +539,4 @@ public class Spawn extends MiniPlugin { return _clansManager; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java index 42a6f3a74..df7dd09c4 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -154,7 +154,7 @@ public class ClansHub extends JavaPlugin ConditionManager condition = new ConditionManager(this); ThankManager thankManager = new ThankManager(this, clientManager, donationManager); BoosterManager boosterManager = new BoosterManager(this, "", clientManager, donationManager, inventoryManager, thankManager); - HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, hologramManager, npcManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager, castleManager); ClansTransferManager serverManager = new ClansTransferManager(this, clientManager, donationManager, partyManager, portal, hubManager); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index 29e6ab472..19d55cb24 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -172,7 +172,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter private HashMap> _creativeAdmin = new HashMap>(); - public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager) + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager, CastleManager castleManager) { super("Hub Manager", plugin); @@ -195,7 +195,6 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter _inventoryManager = inventoryManager; new BenefitManager(plugin, clientManager, _inventoryManager); - CastleManager castleManager = new CastleManager(_plugin, _clientManager, hologramManager, false); _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager, packetHandler, hologramManager, incognito, castleManager); FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); @@ -233,7 +232,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter _treasureManager.addTreasureLocation(loc); } - new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); + new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager, punish); new MenuManager(_plugin); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementData.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementData.java index f12564495..23c2f5e7a 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementData.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementData.java @@ -12,12 +12,12 @@ import mineplex.core.itemstack.ItemBuilder; public class SalesAnnouncementData { - private final int _id; + private final Integer _id; private final Rank[] _displayTo; private final String _message; private boolean _enabled; - public SalesAnnouncementData(int id, Rank[] displayTo, String message, boolean enabled) + public SalesAnnouncementData(Integer id, Rank[] displayTo, String message, boolean enabled) { _id = id; _displayTo = displayTo; @@ -25,7 +25,7 @@ public class SalesAnnouncementData _enabled = enabled; } - public int getId() + public Integer getId() { return _id; } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteCommand.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteCommand.java index 90c08ad87..115d5985c 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteCommand.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteCommand.java @@ -4,16 +4,18 @@ import mineplex.serverdata.commands.ServerCommand; public class SalesAnnouncementDeleteCommand extends ServerCommand { - private String _id; + private Integer _id; private String _from; + private boolean _clans; - public SalesAnnouncementDeleteCommand(String id, String from) + public SalesAnnouncementDeleteCommand(Integer id, String from, boolean clans) { _id = id; _from = from; + _clans = clans; } - public String getId() + public Integer getId() { return _id; } @@ -22,4 +24,9 @@ public class SalesAnnouncementDeleteCommand extends ServerCommand { return _from; } + + public boolean isClans() + { + return _clans; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteHandler.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteHandler.java index 215789987..b8ab47fdd 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteHandler.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteHandler.java @@ -1,9 +1,8 @@ package mineplex.clanshub.salesannouncements; import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; -public class SalesAnnouncementDeleteHandler implements CommandCallback +public class SalesAnnouncementDeleteHandler implements CommandCallback { private final SalesAnnouncementManager _manager; @@ -13,16 +12,16 @@ public class SalesAnnouncementDeleteHandler implements CommandCallback } @Override - public void run(ServerCommand command) + public void run(SalesAnnouncementDeleteCommand command) { - if (!(command instanceof SalesAnnouncementDeleteCommand)) + if (_manager.getServer().equalsIgnoreCase(command.getFrom())) { return; } - if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementDeleteCommand) command).getFrom())) + if (_manager.CLANS != command.isClans()) { return; } - _manager.handleRemoteDeletion(Integer.parseInt(((SalesAnnouncementDeleteCommand)command).getId())); + _manager.handleRemoteDeletion(command.getId()); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java index 82398a078..bc76e23fa 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java @@ -1,14 +1,13 @@ package mineplex.clanshub.salesannouncements; -import java.util.List; +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.plugin.java.JavaPlugin; -import com.google.common.collect.Lists; - import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; @@ -22,22 +21,23 @@ import mineplex.serverdata.commands.ServerCommandManager; public class SalesAnnouncementManager extends MiniPlugin { private static final String LINE = C.cDGreenB + C.Strike + "============================================="; - private final List _data = Lists.newArrayList(); + private final Map _data = new HashMap<>(); private final SalesAnnouncementRepository _repo; + public final boolean CLANS = true; public SalesAnnouncementManager(JavaPlugin plugin) { super("Sales", plugin); - _repo = new SalesAnnouncementRepository(plugin); + _repo = new SalesAnnouncementRepository(plugin, CLANS); _repo.loadAnnouncements(_data); addCommand(new SalesAnnouncementCommand(this)); - ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementUpdate", SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this)); - ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementDelete", SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this)); + ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this)); + ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this)); } - public List getLoadedAnnouncements() + public Map getLoadedAnnouncements() { return _data; } @@ -57,8 +57,8 @@ public class SalesAnnouncementManager extends MiniPlugin _repo.createAnnouncement(displayTo, message, data -> { UtilPlayer.message(creator, F.main(getName(), "Announcement successfully created!")); - _data.add(data); - new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish(); + _data.put(data.getId(), data); + new SalesAnnouncementUpdateCommand(data.getId(), getServer(), CLANS).publish(); }); } @@ -66,16 +66,16 @@ public class SalesAnnouncementManager extends MiniPlugin { if (forceRemoveFromList) { - _data.remove(data); + _data.remove(data.getId()); } _repo.deleteAnnouncement(data, () -> { UtilPlayer.message(deletor, F.main(getName(), "Successfully deleted announcement!")); if (!forceRemoveFromList) { - _data.remove(data); + _data.remove(data.getId()); } - new SalesAnnouncementDeleteCommand(data.getId() + "", getServer()).publish(); + new SalesAnnouncementDeleteCommand(data.getId(), getServer(), CLANS).publish(); }); } @@ -85,40 +85,46 @@ public class SalesAnnouncementManager extends MiniPlugin _repo.updateAnnouncementStatus(data, () -> { UtilPlayer.message(toggler, F.main(getName(), "Successfully toggled announcement!")); - new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish(); + new SalesAnnouncementUpdateCommand(data.getId(), getServer(), CLANS).publish(); }); } public void handleRemoteDeletion(int id) { - _data.removeIf(data -> data.getId() == id); - UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + runSync(() -> + { + _data.remove(Integer.valueOf(id)); + UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + }); } public void handleRemoteUpdate(int id) { - if (_data.stream().filter(data -> data.getId() == id).toArray().length > 0) + runSync(() -> { - _repo.loadAnnouncement(id, data -> + if (_data.containsKey(Integer.valueOf(id))) { - _data.stream().filter(existing -> existing.getId() == data.getId()).forEach(existing -> existing.setEnabled(data.isEnabled())); - UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); - }); - } - else - { - _repo.loadAnnouncement(id, data -> + _repo.loadAnnouncement(id, data -> + { + _data.get(data.getId()).setEnabled(data.isEnabled()); + UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + }); + } + else { - _data.add(data); - UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); - }); - } + _repo.loadAnnouncement(id, data -> + { + _data.put(data.getId(), data); + UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + }); + } + }); } @EventHandler public void onJoin(PlayerJoinEvent event) { - if (_data.isEmpty() || _data.stream().filter(data -> data.isEnabled()).toArray().length == 0) + if (_data.isEmpty() || !_data.values().stream().filter(data -> data.isEnabled()).findAny().isPresent()) { return; } @@ -127,7 +133,7 @@ public class SalesAnnouncementManager extends MiniPlugin runSyncLater(() -> { - _data.stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data -> + _data.values().stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data -> { player.sendMessage(" "); player.sendMessage(LINE); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementPage.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementPage.java index c81eb6b76..966409666 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementPage.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementPage.java @@ -36,10 +36,11 @@ public class SalesAnnouncementPage implements Listener private void setup() { _buttons.clear(); - for (int i = 0; i < _manager.getLoadedAnnouncements().size(); i++) + int i = 0; + for (SalesAnnouncementData data : _manager.getLoadedAnnouncements().values()) { - SalesAnnouncementData data = _manager.getLoadedAnnouncements().get(i); _buttons.put(i, new SalesAnnouncementButton(data, this)); + i++; } updateButtons(false); } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java index 6876ba6f2..78762f61c 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java @@ -1,6 +1,8 @@ package mineplex.clanshub.salesannouncements; +import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; @@ -9,7 +11,6 @@ import com.google.common.collect.Lists; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; -import mineplex.core.database.MinecraftRepository; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnBoolean; @@ -18,20 +19,22 @@ import mineplex.serverdata.database.column.ColumnVarChar; public class SalesAnnouncementRepository extends RepositoryBase { - private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, PRIMARY KEY (id));"; + private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, clans BOOL, PRIMARY KEY (id), INDEX typeIndex (clans));"; - private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements;"; + private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements WHERE clans=?;"; private static final String GET_ANNOUNCEMENT = "SELECT * FROM salesAnnouncements WHERE id=?;"; private static final String UPDATE_ANNOUNCEMENT_STATUS = "UPDATE salesAnnouncements SET enabled=? WHERE id=?;"; - private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled) VALUES(?, ?, ?);"; + private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled, clans) VALUES(?, ?, ?, ?);"; private static final String DELETE_ANNOUNCEMENT = "DELETE FROM salesAnnouncements WHERE id=?;"; private final JavaPlugin _plugin; + private final boolean _clans; - public SalesAnnouncementRepository(JavaPlugin plugin) + public SalesAnnouncementRepository(JavaPlugin plugin, boolean clans) { super(DBPool.getAccount()); _plugin = plugin; + _clans = clans; } private void runAsync(Runnable runnable) @@ -44,13 +47,13 @@ public class SalesAnnouncementRepository extends RepositoryBase Bukkit.getScheduler().runTask(_plugin, runnable); } - public void loadAnnouncements(final List announcementList) + public void loadAnnouncements(final Map map) { runAsync(() -> { executeQuery(GET_ANNOUNCEMENTS, resultSet -> { - final List data = Lists.newArrayList(); + final List data = new ArrayList<>(); while (resultSet.next()) { int id = resultSet.getInt("id"); @@ -71,15 +74,15 @@ public class SalesAnnouncementRepository extends RepositoryBase String message = resultSet.getString("message"); boolean enabled = resultSet.getBoolean("enabled"); - data.add(new SalesAnnouncementData(id, displayTo, message, enabled)); + data.add(new SalesAnnouncementData(Integer.valueOf(id), displayTo, message, enabled)); } runSync(() -> { - announcementList.clear(); - data.forEach(sData -> announcementList.add(sData)); + map.clear(); + data.forEach(sData -> map.put(sData.getId(), sData)); }); - }); + }, new ColumnBoolean("clans", _clans)); }); } @@ -109,7 +112,7 @@ public class SalesAnnouncementRepository extends RepositoryBase String message = resultSet.getString("message"); boolean enabled = resultSet.getBoolean("enabled"); - final SalesAnnouncementData data = new SalesAnnouncementData(aId, displayTo, message, enabled); + final SalesAnnouncementData data = new SalesAnnouncementData(Integer.valueOf(aId), displayTo, message, enabled); runSync(() -> { callback.run(data); @@ -139,7 +142,7 @@ public class SalesAnnouncementRepository extends RepositoryBase runSync(() -> callback.run(data)); } } - }, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true)); + }, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true), new ColumnBoolean("clans", _clans)); }); } @@ -147,7 +150,7 @@ public class SalesAnnouncementRepository extends RepositoryBase { runAsync(() -> { - executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId())); + executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId().intValue())); if (after != null) { runSync(after); @@ -159,7 +162,7 @@ public class SalesAnnouncementRepository extends RepositoryBase { runAsync(() -> { - executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId())); + executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId().intValue())); if (after != null) { runSync(after); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateCommand.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateCommand.java index 8c1c52054..16edeabc9 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateCommand.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateCommand.java @@ -4,16 +4,18 @@ import mineplex.serverdata.commands.ServerCommand; public class SalesAnnouncementUpdateCommand extends ServerCommand { - private String _id; + private Integer _id; private String _from; + private boolean _clans; - public SalesAnnouncementUpdateCommand(String id, String from) + public SalesAnnouncementUpdateCommand(Integer id, String from, boolean clans) { _id = id; _from = from; + _clans = clans; } - public String getId() + public Integer getId() { return _id; } @@ -22,4 +24,9 @@ public class SalesAnnouncementUpdateCommand extends ServerCommand { return _from; } + + public boolean isClans() + { + return _clans; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateHandler.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateHandler.java index 1c56c5ca6..d2771b953 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateHandler.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateHandler.java @@ -1,9 +1,8 @@ package mineplex.clanshub.salesannouncements; import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; -public class SalesAnnouncementUpdateHandler implements CommandCallback +public class SalesAnnouncementUpdateHandler implements CommandCallback { private final SalesAnnouncementManager _manager; @@ -13,16 +12,16 @@ public class SalesAnnouncementUpdateHandler implements CommandCallback } @Override - public void run(ServerCommand command) + public void run(SalesAnnouncementUpdateCommand command) { - if (!(command instanceof SalesAnnouncementUpdateCommand)) + if (_manager.getServer().equalsIgnoreCase(command.getFrom())) { return; } - if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementUpdateCommand) command).getFrom())) + if (_manager.CLANS != command.isClans()) { return; } - _manager.handleRemoteUpdate(Integer.parseInt(((SalesAnnouncementUpdateCommand)command).getId())); + _manager.handleRemoteUpdate(command.getId()); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 6c22d7cbb..6f3a344b2 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -1,10 +1,5 @@ package mineplex.hub; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.CustomTagFix; import mineplex.core.PacketsInteractionFix; import mineplex.core.TwitchIntegrationFix; @@ -16,7 +11,6 @@ import mineplex.core.antihack.guardians.GuardianManager; import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.boosters.BoosterManager; -import mineplex.hub.brawl.fountain.FountainManager; import mineplex.core.chat.Chat; import mineplex.core.chatsnap.SnapshotManager; import mineplex.core.chatsnap.SnapshotPlugin; @@ -62,7 +56,6 @@ import mineplex.core.report.ReportManager; import mineplex.core.report.ReportPlugin; import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.serverConfig.ServerConfiguration; -import mineplex.core.sponsorbranding.BrandingManager; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; @@ -77,8 +70,8 @@ import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; import mineplex.core.website.WebsiteLinkManager; +import mineplex.hub.brawl.fountain.FountainManager; import mineplex.hub.modules.AprilFoolsTreasureHunt; -import mineplex.hub.modules.BillboardManager; import mineplex.hub.queue.QueueManager; import mineplex.hub.server.ServerManager; import mineplex.minecraft.game.classcombat.Class.ClassManager; @@ -91,6 +84,10 @@ import mineplex.minecraft.game.core.IRelation; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; import static mineplex.core.Managers.require; @@ -209,7 +206,6 @@ public class Hub extends JavaPlugin implements IRelation CombatManager combatManager = new CombatManager(this); - DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, conditionManager); conditionManager.setDamageManager(damage); @@ -233,9 +229,6 @@ public class Hub extends JavaPlugin implements IRelation //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); - BrandingManager brandingManager = require(BrandingManager.class); - new BillboardManager(this, brandingManager); - require(TrackManager.class); require(Titles.class); require(TwoFactorAuth.class); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index bc02c3628..05a1c7222 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -235,7 +235,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess _bonusManager = new BonusManager(plugin, null, playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager, "Carl"); _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager()); - CosmeticManager cosmeticManager = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); + CosmeticManager cosmeticManager = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager, punish); _mavericksManager = new MavericksManager(plugin, cosmeticManager, hologramManager, this); @@ -915,7 +915,9 @@ public class HubManager extends MiniClientPlugin implements IChatMess @EventHandler public void ignoreVelocity(PlayerVelocityEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY)) + Player player = event.getPlayer(); + + if (_clientManager.Get(player).GetRank().has(Rank.TWITCH) && _preferences.get(player).isActive(Preference.IGNORE_VELOCITY) && !getJumpManager().isDoubleJumping(player)) { event.setCancelled(true); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/BillboardManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/BillboardManager.java deleted file mode 100644 index d1dd5df72..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/BillboardManager.java +++ /dev/null @@ -1,66 +0,0 @@ -package mineplex.hub.modules; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.events.ServerShutdownEvent; -import mineplex.core.sponsorbranding.BrandingManager; - -import org.bukkit.entity.ItemFrame; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.hanging.HangingBreakEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.plugin.java.JavaPlugin; - -/** - * Manager to handle generation and protection of billboards in the hub - */ -public class BillboardManager extends MiniPlugin -{ - private BrandingManager _branding; - - public BillboardManager(JavaPlugin plugin, BrandingManager branding) - { - super("Billboard", plugin); - _branding = branding; - - generateBoards(); - } - - private void generateBoards() - { - - } - - @EventHandler - public void stopBreaking(HangingBreakEvent event) - { - if (event.getEntity() instanceof ItemFrame) - { - event.setCancelled(true); - } - } - - @EventHandler - public void stopBreaking(EntityDamageEvent event) - { - if (event.getEntity() instanceof ItemFrame) - { - event.setCancelled(true); - } - } - - @EventHandler - public void stopInteract(PlayerInteractEntityEvent event) - { - if (event.getRightClicked() != null && event.getRightClicked() instanceof ItemFrame) - { - event.setCancelled(true); - } - } - - @EventHandler - public void handleShutdown(ServerShutdownEvent event) - { - _branding.reset(); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index b2c29d783..f2d58351f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -2,46 +2,47 @@ package mineplex.hub.modules; import mineplex.core.MiniPlugin; import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; import mineplex.core.preferences.Preference; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.visibility.VisibilityManager; import mineplex.hub.HubManager; -import org.bukkit.Material; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; public class HubVisibilityManager extends MiniPlugin { + + private static final String JUST_SPAWNED_FLAG = "JustSpawned"; + private static final int HIDE_SPAWN_RADIUS_SQUARED = 4; + public HubManager Manager; - private HashMap _particle = new HashMap(); - private HashSet _hiddenPlayers = new HashSet(); + private final Set _hiddenPlayers = new HashSet<>(); + private final Map _nextShownPlayer = new HashMap<>(); public HubVisibilityManager(HubManager manager) { super("Visibility Manager", manager.getPlugin()); - Manager = manager; } public void addHiddenPlayer(Player player) { _hiddenPlayers.add(player); - } public void removeHiddenPlayer(Player player) @@ -50,88 +51,110 @@ public class HubVisibilityManager extends MiniPlugin } @EventHandler - public void removeHiddenPlayerOnQuit(PlayerQuitEvent event) - { - _hiddenPlayers.remove(event.getPlayer()); - } - - @EventHandler - public void updateVisibility(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - for (Player player : UtilServer.getPlayers()) - { - Rank rank = Manager.GetClients().Get(player).GetRank(); - boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || - (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) || - _hiddenPlayers.contains(player); - - for (Player other : UtilServer.getPlayers()) - { - boolean localHideMe = hideMe; - if (player.equals(other)) - continue; - - if(Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR)) - localHideMe = false; - - if (localHideMe || !Manager.getPreferences().get(other).isActive(Preference.SHOW_PLAYERS)) - { - VisibilityManager.Instance.setVisibility(player, false, other); - } - else - { - VisibilityManager.Instance.setVisibility(player, true, other); - } - } - } - } - - @EventHandler - public void ParticleSwap(PlayerInteractEvent event) + public void playerQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); - if (!player.isOp()) - return; - - if (!UtilGear.isMat(player.getItemInHand(), Material.GOLD_NUGGET)) - return; - - int past = 0; - if (_particle.containsKey(player)) - past = _particle.get(player); - - if (UtilEvent.isAction(event, ActionType.R)) - { - past = (past+1)%ParticleType.values().length; - } - else if (UtilEvent.isAction(event, ActionType.L)) - { - past = past - 1; - if (past < 0) - past = ParticleType.values().length - 1; - } - - _particle.put(player, past); - - player.sendMessage("Particle: " + ParticleType.values()[past]); + _hiddenPlayers.remove(player); + _nextShownPlayer.remove(player); } @EventHandler - public void Particles(UpdateEvent event) + public void playerJoin(PlayerJoinEvent event) { - if (event.getType() != UpdateType.FAST) - return; + UtilEnt.addFlag(event.getPlayer(), JUST_SPAWNED_FLAG); + } - for (Player player : _particle.keySet()) + @EventHandler + public void updateVisibility0(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) { + return; + } - UtilParticle.PlayParticle(ParticleType.values()[_particle.get(player)], player.getLocation().add(1, 1, 0), 0f, 0f, 0f, 0, 1, - ViewDist.NORMAL, UtilServer.getPlayers()); + Collection online = UtilServer.getPlayersCollection(); + for (Player subject : online) + { + boolean hideMe = shouldHide(subject); + + for (Player perspective : online) + { + boolean closeToSpawn = closeToSpawn(perspective); + boolean justSpawned = UtilEnt.hasFlag(perspective, JUST_SPAWNED_FLAG); + + // Don't hide themselves OR they are currently being sent player data one by one + if (perspective.equals(subject) || _nextShownPlayer.containsKey(perspective)) + { + continue; + } + + // Player has just spawned flag however they are no longer near the spawn + if (justSpawned && !closeToSpawn) + { + UtilEnt.removeFlag(perspective, JUST_SPAWNED_FLAG); + _nextShownPlayer.put(perspective, 0); + } + + // Has preference AND is not close to the spawn AND has not just spawned + boolean showOthers = Manager.getPreferences().get(perspective).isActive(Preference.SHOW_PLAYERS) && (!closeToSpawn || !justSpawned); + + VisibilityManager.Instance.setVisibility(subject, !hideMe && showOthers, perspective); + } } } + + @EventHandler + public void updateVisibility1(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + Player[] online = UtilServer.getPlayers(); + Iterator iterator = _nextShownPlayer.keySet().iterator(); + + while (iterator.hasNext()) + { + Player perspective = iterator.next(); + int index = _nextShownPlayer.get(perspective); + + if (perspective == null || !perspective.isOnline() || online.length <= index) + { + iterator.remove(); + continue; + } + + Player subject = online[index]; + + if (!perspective.equals(subject) && !shouldHide(subject)) + { + VisibilityManager.Instance.setVisibility(subject, true, perspective); + } + + _nextShownPlayer.put(perspective, ++index); + } + } + + private boolean shouldHide(Player subject) + { + Rank subjectRank = Manager.GetClients().Get(subject).GetRank(); + + return + // Close to spawn + closeToSpawn(subject) || + // Enabled Invisibility + Manager.getPreferences().get(subject).isActive(Preference.INVISIBILITY) && + // AND Is Moderator+ OR Youtube OR Twitch + (subjectRank.has(Rank.MODERATOR) || subjectRank == Rank.YOUTUBE || subjectRank == Rank.TWITCH) || + // OR Player has been explicitly hidden + _hiddenPlayers.contains(subject); + } + + private boolean closeToSpawn(Player player) + { + return UtilMath.offset2dSquared(player.getLocation(), Manager.GetSpawn()) < HIDE_SPAWN_RADIUS_SQUARED; + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java index 9e6730cb8..b5bef12d6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java @@ -1,16 +1,5 @@ package mineplex.hub.modules; -import java.util.HashSet; - -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerQuitEvent; -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; @@ -27,9 +16,20 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleFlightEvent; +import org.bukkit.util.Vector; + +import java.util.HashSet; public class JumpManager extends MiniPlugin { + public HubManager Manager; private HashSet _preparedDoubleJump = new HashSet<>(); @@ -45,11 +45,10 @@ public class JumpManager extends MiniPlugin { Player player = event.getPlayer(); - if (player.getGameMode() == GameMode.CREATIVE) - return; - - if (player.isFlying()) + if (player.getGameMode() == GameMode.CREATIVE || player.isFlying()) + { return; + } Rank rank = Manager.GetClients().Get(player).GetRank(); if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) @@ -75,11 +74,11 @@ public class JumpManager extends MiniPlugin //Velocity _preparedDoubleJump.add(player.getName()); UtilAction.velocity(player, vec, 1.4, false, 0, 0.2, 1, true); - + //Sound player.playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0); - Recharge.Instance.useForce(player, "Double Jump", 500); + Recharge.Instance.useForce(player, "Double Jump", 250); } @EventHandler @@ -129,4 +128,9 @@ public class JumpManager extends MiniPlugin { return _preparedDoubleJump.contains(player.getName()); } + + public boolean isDoubleJumping(Player player) + { + return !Recharge.Instance.usable(player, "Double Jump"); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementData.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementData.java index a7663e430..964962bf7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementData.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementData.java @@ -12,12 +12,12 @@ import mineplex.core.itemstack.ItemBuilder; public class SalesAnnouncementData { - private final int _id; + private final Integer _id; private final Rank[] _displayTo; private final String _message; private boolean _enabled; - public SalesAnnouncementData(int id, Rank[] displayTo, String message, boolean enabled) + public SalesAnnouncementData(Integer id, Rank[] displayTo, String message, boolean enabled) { _id = id; _displayTo = displayTo; @@ -25,7 +25,7 @@ public class SalesAnnouncementData _enabled = enabled; } - public int getId() + public Integer getId() { return _id; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteCommand.java index f8244ec41..9623add3f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteCommand.java @@ -4,16 +4,18 @@ import mineplex.serverdata.commands.ServerCommand; public class SalesAnnouncementDeleteCommand extends ServerCommand { - private String _id; + private Integer _id; private String _from; + private boolean _clans; - public SalesAnnouncementDeleteCommand(String id, String from) + public SalesAnnouncementDeleteCommand(Integer id, String from, boolean clans) { _id = id; _from = from; + _clans = clans; } - public String getId() + public Integer getId() { return _id; } @@ -22,4 +24,9 @@ public class SalesAnnouncementDeleteCommand extends ServerCommand { return _from; } + + public boolean isClans() + { + return _clans; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteHandler.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteHandler.java index ec8a8934d..88071df75 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteHandler.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteHandler.java @@ -1,9 +1,8 @@ package mineplex.hub.modules.salesannouncements; import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; -public class SalesAnnouncementDeleteHandler implements CommandCallback +public class SalesAnnouncementDeleteHandler implements CommandCallback { private final SalesAnnouncementManager _manager; @@ -13,16 +12,16 @@ public class SalesAnnouncementDeleteHandler implements CommandCallback } @Override - public void run(ServerCommand command) + public void run(SalesAnnouncementDeleteCommand command) { - if (!(command instanceof SalesAnnouncementDeleteCommand)) + if (_manager.getServer().equalsIgnoreCase(command.getFrom())) { return; } - if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementDeleteCommand) command).getFrom())) + if (_manager.CLANS != command.isClans()) { return; } - _manager.handleRemoteDeletion(Integer.parseInt(((SalesAnnouncementDeleteCommand)command).getId())); + _manager.handleRemoteDeletion(command.getId()); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java index f91f399f8..266f340d9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java @@ -1,14 +1,13 @@ package mineplex.hub.modules.salesannouncements; -import java.util.List; +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.plugin.java.JavaPlugin; -import com.google.common.collect.Lists; - import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; @@ -22,22 +21,23 @@ import mineplex.serverdata.commands.ServerCommandManager; public class SalesAnnouncementManager extends MiniPlugin { private static final String LINE = C.cDGreenB + C.Strike + "============================================="; - private final List _data = Lists.newArrayList(); + private final Map _data = new HashMap<>(); private final SalesAnnouncementRepository _repo; + public final boolean CLANS = false; public SalesAnnouncementManager(JavaPlugin plugin) { super("Sales", plugin); - _repo = new SalesAnnouncementRepository(plugin); + _repo = new SalesAnnouncementRepository(plugin, CLANS); _repo.loadAnnouncements(_data); addCommand(new SalesAnnouncementCommand(this)); - ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementUpdate", SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this)); - ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementDelete", SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this)); + ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this)); + ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this)); } - public List getLoadedAnnouncements() + public Map getLoadedAnnouncements() { return _data; } @@ -57,8 +57,8 @@ public class SalesAnnouncementManager extends MiniPlugin _repo.createAnnouncement(displayTo, message, data -> { UtilPlayer.message(creator, F.main(getName(), "Announcement successfully created!")); - _data.add(data); - new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish(); + _data.put(data.getId(), data); + new SalesAnnouncementUpdateCommand(data.getId(), getServer(), CLANS).publish(); }); } @@ -66,16 +66,16 @@ public class SalesAnnouncementManager extends MiniPlugin { if (forceRemoveFromList) { - _data.remove(data); + _data.remove(data.getId()); } _repo.deleteAnnouncement(data, () -> { UtilPlayer.message(deletor, F.main(getName(), "Successfully deleted announcement!")); if (!forceRemoveFromList) { - _data.remove(data); + _data.remove(data.getId()); } - new SalesAnnouncementDeleteCommand(data.getId() + "", getServer()).publish(); + new SalesAnnouncementDeleteCommand(data.getId(), getServer(), CLANS).publish(); }); } @@ -85,40 +85,46 @@ public class SalesAnnouncementManager extends MiniPlugin _repo.updateAnnouncementStatus(data, () -> { UtilPlayer.message(toggler, F.main(getName(), "Successfully toggled announcement!")); - new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish(); + new SalesAnnouncementUpdateCommand(data.getId(), getServer(), CLANS).publish(); }); } public void handleRemoteDeletion(int id) { - _data.removeIf(data -> data.getId() == id); - UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + runSync(() -> + { + _data.remove(Integer.valueOf(id)); + UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + }); } public void handleRemoteUpdate(int id) { - if (_data.stream().filter(data -> data.getId() == id).toArray().length > 0) + runSync(() -> { - _repo.loadAnnouncement(id, data -> + if (_data.containsKey(Integer.valueOf(id))) { - _data.stream().filter(existing -> existing.getId() == data.getId()).forEach(existing -> existing.setEnabled(data.isEnabled())); - UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); - }); - } - else - { - _repo.loadAnnouncement(id, data -> + _repo.loadAnnouncement(id, data -> + { + _data.get(data.getId()).setEnabled(data.isEnabled()); + UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + }); + } + else { - _data.add(data); - UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); - }); - } + _repo.loadAnnouncement(id, data -> + { + _data.put(data.getId(), data); + UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + }); + } + }); } @EventHandler public void onJoin(PlayerJoinEvent event) { - if (_data.isEmpty() || _data.stream().filter(data -> data.isEnabled()).toArray().length == 0) + if (_data.isEmpty() || !_data.values().stream().filter(data -> data.isEnabled()).findAny().isPresent()) { return; } @@ -127,7 +133,7 @@ public class SalesAnnouncementManager extends MiniPlugin runSyncLater(() -> { - _data.stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data -> + _data.values().stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data -> { player.sendMessage(" "); player.sendMessage(LINE); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementPage.java index c2be6a7b8..53990c319 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementPage.java @@ -36,10 +36,11 @@ public class SalesAnnouncementPage implements Listener private void setup() { _buttons.clear(); - for (int i = 0; i < _manager.getLoadedAnnouncements().size(); i++) + int i = 0; + for (SalesAnnouncementData data : _manager.getLoadedAnnouncements().values()) { - SalesAnnouncementData data = _manager.getLoadedAnnouncements().get(i); _buttons.put(i, new SalesAnnouncementButton(data, this)); + i++; } updateButtons(false); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java index 844a3b5ee..43584cd7e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java @@ -1,6 +1,8 @@ package mineplex.hub.modules.salesannouncements; +import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; @@ -9,7 +11,6 @@ import com.google.common.collect.Lists; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; -import mineplex.core.database.MinecraftRepository; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnBoolean; @@ -18,20 +19,22 @@ import mineplex.serverdata.database.column.ColumnVarChar; public class SalesAnnouncementRepository extends RepositoryBase { - private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, PRIMARY KEY (id));"; + private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, clans BOOL, PRIMARY KEY (id), INDEX typeIndex (clans));"; - private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements;"; + private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements WHERE clans=?;"; private static final String GET_ANNOUNCEMENT = "SELECT * FROM salesAnnouncements WHERE id=?;"; private static final String UPDATE_ANNOUNCEMENT_STATUS = "UPDATE salesAnnouncements SET enabled=? WHERE id=?;"; - private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled) VALUES(?, ?, ?);"; + private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled, clans) VALUES(?, ?, ?, ?);"; private static final String DELETE_ANNOUNCEMENT = "DELETE FROM salesAnnouncements WHERE id=?;"; private final JavaPlugin _plugin; + private final boolean _clans; - public SalesAnnouncementRepository(JavaPlugin plugin) + public SalesAnnouncementRepository(JavaPlugin plugin, boolean clans) { super(DBPool.getAccount()); _plugin = plugin; + _clans = clans; } private void runAsync(Runnable runnable) @@ -44,13 +47,13 @@ public class SalesAnnouncementRepository extends RepositoryBase Bukkit.getScheduler().runTask(_plugin, runnable); } - public void loadAnnouncements(final List announcementList) + public void loadAnnouncements(final Map map) { runAsync(() -> { executeQuery(GET_ANNOUNCEMENTS, resultSet -> { - final List data = Lists.newArrayList(); + final List data = new ArrayList<>(); while (resultSet.next()) { int id = resultSet.getInt("id"); @@ -71,15 +74,15 @@ public class SalesAnnouncementRepository extends RepositoryBase String message = resultSet.getString("message"); boolean enabled = resultSet.getBoolean("enabled"); - data.add(new SalesAnnouncementData(id, displayTo, message, enabled)); + data.add(new SalesAnnouncementData(Integer.valueOf(id), displayTo, message, enabled)); } runSync(() -> { - announcementList.clear(); - data.forEach(sData -> announcementList.add(sData)); + map.clear(); + data.forEach(sData -> map.put(sData.getId(), sData)); }); - }); + }, new ColumnBoolean("clans", _clans)); }); } @@ -109,7 +112,7 @@ public class SalesAnnouncementRepository extends RepositoryBase String message = resultSet.getString("message"); boolean enabled = resultSet.getBoolean("enabled"); - final SalesAnnouncementData data = new SalesAnnouncementData(aId, displayTo, message, enabled); + final SalesAnnouncementData data = new SalesAnnouncementData(Integer.valueOf(aId), displayTo, message, enabled); runSync(() -> { callback.run(data); @@ -139,7 +142,7 @@ public class SalesAnnouncementRepository extends RepositoryBase runSync(() -> callback.run(data)); } } - }, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true)); + }, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true), new ColumnBoolean("clans", _clans)); }); } @@ -147,7 +150,7 @@ public class SalesAnnouncementRepository extends RepositoryBase { runAsync(() -> { - executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId())); + executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId().intValue())); if (after != null) { runSync(after); @@ -159,7 +162,7 @@ public class SalesAnnouncementRepository extends RepositoryBase { runAsync(() -> { - executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId())); + executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId().intValue())); if (after != null) { runSync(after); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateCommand.java index 698154e7c..c1735a5ba 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateCommand.java @@ -4,16 +4,18 @@ import mineplex.serverdata.commands.ServerCommand; public class SalesAnnouncementUpdateCommand extends ServerCommand { - private String _id; + private Integer _id; private String _from; + private boolean _clans; - public SalesAnnouncementUpdateCommand(String id, String from) + public SalesAnnouncementUpdateCommand(Integer id, String from, boolean clans) { _id = id; _from = from; + _clans = clans; } - public String getId() + public Integer getId() { return _id; } @@ -22,4 +24,9 @@ public class SalesAnnouncementUpdateCommand extends ServerCommand { return _from; } + + public boolean isClans() + { + return _clans; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateHandler.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateHandler.java index a9143764f..1939a18d4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateHandler.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateHandler.java @@ -1,9 +1,8 @@ package mineplex.hub.modules.salesannouncements; import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; -public class SalesAnnouncementUpdateHandler implements CommandCallback +public class SalesAnnouncementUpdateHandler implements CommandCallback { private final SalesAnnouncementManager _manager; @@ -13,16 +12,16 @@ public class SalesAnnouncementUpdateHandler implements CommandCallback } @Override - public void run(ServerCommand command) + public void run(SalesAnnouncementUpdateCommand command) { - if (!(command instanceof SalesAnnouncementUpdateCommand)) + if (_manager.getServer().equalsIgnoreCase(command.getFrom())) { return; } - if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementUpdateCommand) command).getFrom())) + if (_manager.CLANS != command.isClans()) { return; } - _manager.handleRemoteUpdate(Integer.parseInt(((SalesAnnouncementUpdateCommand)command).getId())); + _manager.handleRemoteUpdate(command.getId()); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index f833f0200..38839f738 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -865,6 +865,11 @@ public class ServerManager extends MiniPlugin return _serverNpcShopMap.get("Bawk Bawk Battles"); } + public ServerNpcShop getMobaShop() + { + return _serverNpcShopMap.get("Heroes of GWEN"); + } + public BoosterManager getBoosterManager() { return _boosterManager; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java new file mode 100644 index 000000000..3fbb186f3 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java @@ -0,0 +1,52 @@ +package mineplex.hub.server.ui; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +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.hub.server.ServerManager; +import mineplex.serverdata.data.ServerGroup; + +public class MOBAServerTypePage extends ShopPageBase +{ + private final ServerGroup _serverGroup; + + public MOBAServerTypePage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, ServerGroup serverGroup) + { + super(plugin, shop, clientManager, donationManager, "Heroes of GWEN ", player, 27); + _serverGroup = serverGroup; + + buildPage(); + } + + @Override + protected void buildPage() + { + setItem(12, new ItemBuilder(Material.PRISMARINE_SHARD).setTitle(C.Reset + C.cGold + "Play " + C.cYellow + "Heroes of GWEN") + .addLore(new String[] + { + C.Reset + "", + C.Reset + C.cGreen + "Click to Play", + }).build()); + + setItem(14, new ItemBuilder(Material.SKULL_ITEM, (byte) 3).setTitle(C.Reset + C.cYellow + "Heroes of GWEN " + C.cGold + "Training") + .addLore(new String[] + { + C.Reset + "", + C.Reset + C.cGreen + "Click to Play", + }).build()); + + getButtonMap().put(12, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Heroes of GWEN", player, "MOBA"))); + getButtonMap().put(14, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Heroes of GWEN Training", player, "MOBAT"))); + } + + public void Update() + { + getButtonMap().clear(); + buildPage(); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 07e52532f..078ed8369 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -3,6 +3,7 @@ package mineplex.hub.server.ui; import java.util.ArrayList; import java.util.List; +import mineplex.hub.server.ui.button.SelectMOBAButton; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Material; @@ -80,14 +81,14 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "at all costs!", }, "CA", "Castle_Assault", new SelectCAButton(this)); - add(4, Material.DIAMOND_CHESTPLATE, C.cYellowB + "Castle Assault TDM " + C.cGray + "Team PvP", new String[] + add(4, Material.PRISMARINE_SHARD, C.cYellowB + "Heroes of GWEN " + C.cGray + "Team Game", new String[] { - (_extraValue ? C.cAquaB : C.cWhiteB) + "NEW GAME", + (_extraValue ? C.cAquaB : C.cWhiteB) + "FULL RELEASE", C.Reset + "", - C.Reset + "Combatants must battle to", - C.Reset + "win glory for their team", - C.Reset + "by slaying the enemy!", - }, "CATDM", "Castle_Assault_TDM", new SelectCATDMButton(this)); + C.Reset + "Face off in a crazy 4v4", + C.Reset + "battle with many different", + C.Reset + "Heroes and Abilities!", + }, "MOBA", "Heroes_of_GWEN", new SelectMOBAButton(this)); add(6, Material.QUARTZ_BLOCK, C.cYellowB + "Speed Builders " + C.cGray + "Competitive Building", new String[] { @@ -126,7 +127,7 @@ public class ServerGameMenu extends ShopPageBase add(13, Material.FEATHER, (byte) 0, C.cYellowB + "Skywars " + C.cGray + "Solo/Team Survival", new String[] { C.Reset + "", - C.Reset + "16 contenders fight to rule the skies!", + C.Reset + "12 contenders fight to rule the skies!", C.Reset + "Spawn on a sky island and build your path!", C.Reset + "Find weapons to take your enemies down!", C.Reset + "Up in the skies, death looming if you fall..", @@ -761,6 +762,11 @@ public class ServerGameMenu extends ShopPageBase getPlugin().getBawkShop().attemptShopOpen(player); } + public void openMoba(Player player) + { + getPlugin().getMobaShop().attemptShopOpen(player); + } + /* ADDITIONAL LORES; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java index 4bda13c2c..46eb48b44 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java @@ -41,6 +41,9 @@ public class ServerNpcShop extends ShopBase case "SSM": return new SuperSmashMobsServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup); + case "MOBA": + return new MOBAServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup); + default: return new ServerNpcPage(getPlugin(), this, getClientManager(), getDonationManager(), _serverGroup.getServerNpcName(), player, _serverGroup.getPrefix()); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectMOBAButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectMOBAButton.java new file mode 100644 index 000000000..c65848b38 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectMOBAButton.java @@ -0,0 +1,22 @@ +package mineplex.hub.server.ui.button; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +public class SelectMOBAButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectMOBAButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openMoba(player); + } +} diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java index b8c09946c..d0bb8bc54 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java @@ -16,6 +16,8 @@ public enum GameType Build("Master Builders"), BuildMavericks("Mavericks Master Builders"), CastleSiege("Castle Siege"), + CastleAssault("Castle Assault"), + CastleAssaultTDM("Castle Assault TDM"), ChampionsTDM("Champions TDM", "Champions"), ChampionsDominate("Champions Domination", "Champions"), ChampionsCTF("Champions CTF", "Champions"), diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java index f18483199..1f1509fe2 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java @@ -3,7 +3,6 @@ package mineplex.mapparser.command; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.mapparser.MapParser; -import org.bukkit.Sound; import org.bukkit.entity.Player; /** @@ -44,7 +43,6 @@ public class PMCommand extends BaseCommand continue; } ops.sendMessage(F.main("Message", builder.toString().trim())); - ops.playSound(ops.getLocation(), Sound.BLOCK_NOTE_PLING, 1.0f, 1.0f); } return true; diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java index 89a04fe90..b6f0de986 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java @@ -236,7 +236,5 @@ public class CombatLog public void SetKillerColor(String color) { _killerColor = color; - } - - -} + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java index 2153d4758..fcf12abca 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java @@ -1,8 +1,6 @@ package mineplex.serverdata.commands; - public interface CommandCallback { - void run(T command); -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandType.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandType.java index 9f541b8b8..4fe680f44 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandType.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandType.java @@ -1,18 +1,16 @@ package mineplex.serverdata.commands; - public class CommandType { - private Class _commandClazz; public Class getCommandType() { return _commandClazz; } - private CommandCallback _commandCallback; - public CommandCallback getCallback() { return _commandCallback; } + private CommandCallback _commandCallback; + public CommandCallback getCallback() { return _commandCallback; } - public CommandType(Class commandClazz, CommandCallback commandCallback) + public CommandType(Class commandClazz, CommandCallback commandCallback) { _commandClazz = commandClazz; _commandCallback = commandCallback; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java index 259a5ef5f..72f86461a 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java @@ -9,8 +9,6 @@ import mineplex.serverdata.Utility; import mineplex.serverdata.servers.ServerManager; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; -import redis.clients.jedis.JedisPoolConfig; -import redis.clients.jedis.exceptions.JedisConnectionException; public class ServerCommandManager { @@ -35,7 +33,7 @@ public class ServerCommandManager public boolean isServerInitialized() { return _localServerName != null; } public String getServerName() { - return this._localServerName; + return _localServerName; } /** @@ -46,7 +44,7 @@ public class ServerCommandManager _writePool = Utility.generatePool(ServerManager.getMasterConnection()); // Publish to master instance _readPool = Utility.generatePool(ServerManager.getSlaveConnection()); // Read from slave instance - _commandTypes = new HashMap(); + _commandTypes = new HashMap<>(); initialize(); } @@ -98,6 +96,7 @@ public class ServerCommandManager * @param commandType - the type of command being received * @param serializedCommand - the serialized {@link ServerCommand} data. */ + @SuppressWarnings({ "unchecked", "rawtypes" }) public void handleCommand(final String commandType, String serializedCommand) { if (!isServerInitialized()) @@ -163,4 +162,4 @@ public class ServerCommandManager return _instance; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 0da0df265..2f7e0cd5c 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -72,6 +72,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable _allowWeatherChange = false; addCommand(new checkCommand(this)); + addCommand(new checkBonusCommand(this)); addCommand(new checkOwnsPackageCommand(this)); addCommand(new ListPPCCommand(this, _powerPlayRepo)); } @@ -108,7 +109,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(F.main(getName(), "Usage : /check defek7")); } - public void showPlayerInfo(Player caller, CoreClient client) + public void showPlayerInfo(Player caller, CoreClient client, boolean bonuses) { String playerName = client.getName(); Donor donor = _donationManager.Get(client.getUniqueId()); @@ -130,8 +131,11 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable StringBuilder basic = new StringBuilder(C.cBlue + "Name: " + C.cYellow + playerName); basic.append(" "); basic.append(C.cBlue + "Rank: " + C.cYellow + (client.GetRank() == null ? C.cRed + "Error rank null!" : (client.GetRank().Name.isEmpty() ? "Regular" : client.GetRank().Name))); - basic.append(" "); - basic.append(C.cBlue + "Gems: " + C.cYellow + donor.getBalance(GlobalCurrency.GEM)); + if (!bonuses) + { + basic.append(" "); + basic.append(C.cBlue + "Gems: " + C.cYellow + donor.getBalance(GlobalCurrency.GEM)); + } caller.sendMessage(basic.toString()); int enjinCoinsReceived = 0; @@ -410,44 +414,54 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable } } - StringBuilder shards = new StringBuilder(C.cBlue + "Enjin Shard Total Received: " + C.cYellow + enjinCoinsReceived); - shards.append(" "); - shards.append(C.cBlue + "Shards: " + C.cYellow + donor.getBalance(GlobalCurrency.TREASURE_SHARD)); - caller.sendMessage(shards.toString()); - // Strutt20 asked me to remove some stuff from the menu - caller.sendMessage(C.cBlue + "Old Chests Received: " + C.cYellow + oldChestsReceived + " " + C.cBlue + "Ancient Chests Received: " + C.cYellow + ancientChestsReceived); - caller.sendMessage(C.cBlue + "Mythical Chests Received: " + C.cYellow + mythicalChestsReceived + " " + C.cBlue + "Illuminated Chests Received: " + C.cYellow + illuminatedChestsReceived); - caller.sendMessage(C.cBlue + "Omega Chests Received: " + C.cYellow + omegaChestsReceived); - caller.sendMessage(C.cBlue + "Haunted Chests Received: " + C.cYellow + hauntedChestsReceived + " " + C.cBlue + "Haunted Chests Opened: " + C.cYellow + hauntedChestsOpened); - caller.sendMessage(C.cBlue + "Trick or Treat Chests Received: " + C.cYellow + trickOrTreatChestsReceived + " " + C.cBlue + "Thankful Chests Received: " + C.cYellow + thankfulChestsReceived); - caller.sendMessage(C.cBlue + "Gingerbread Chests Received: " + C.cYellow + gingerbreadChestsReceived + " " + C.cBlue + "Minestrike Chests Received: " + C.cYellow + minestrikeChestsReceived); - caller.sendMessage(C.cBlue + "Love Chests Received: " + C.cYellow + loveChestsReceived); - caller.sendMessage(C.cBlue + "St Patrick's Chests Received: " + C.cYellow + stPatricksChestReceived); - caller.sendMessage(C.cBlue + "Spring Chests Received: " + C.cYellow + springChestsReceived); - caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived); - caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min/60 min) Received: " + C.cYellow + runeAmplifier20 + "/" + runeAmplifier60); - caller.sendMessage(C.cBlue + "Clans Dye Boxes Received: " + C.cYellow + clansDyeBoxesReceived + " " + C.cBlue + "Clans Builder Boxes Received: " + C.cYellow + clansBuilderBoxesReceived); - caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Usage") + " " + C.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor")); - YearMonth yearMonth = YearMonth.now(); - caller.sendMessage(C.cBlue + "Power Play Subscription (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.isSubscribed() ? C.cGreen + "Active" : C.cRed + "Inactive")); - if (powerPlayData.isSubscribed()) + if (!bonuses) { - caller.sendMessage(C.cBlue + "Power Play Chest/Amplifiers (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.getUnclaimedMonths().contains(YearMonth.now()) ? C.cGreen + "Unclaimed" : C.cRed + "Claimed")); - LocalDate nextClaimDate = powerPlayData.getNextClaimDate().get(); // Guaranteed by isSubscribed() - caller.sendMessage(C.cBlue + "Power Play Next Claim Date " + C.cYellow + nextClaimDate.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + " " + nextClaimDate.getDayOfMonth()); - } - caller.sendMessage(C.cBlue + "Monthly Bonus Log (Last 6 entries):"); - - if (_accountBonusLog.containsKey(client.getAccountId())) - { - for (String logEntry : _accountBonusLog.get(client.getAccountId())) + StringBuilder shards = new StringBuilder(C.cBlue + "Enjin Shard Total Received: " + C.cYellow + enjinCoinsReceived); + shards.append(" "); + shards.append(C.cBlue + "Shards: " + C.cYellow + donor.getBalance(GlobalCurrency.TREASURE_SHARD)); + caller.sendMessage(shards.toString()); + // Strutt20 asked me to remove some stuff from the menu + caller.sendMessage(C.cBlue + "Old Chests Received: " + C.cYellow + oldChestsReceived + " " + C.cBlue + "Ancient Chests Received: " + C.cYellow + ancientChestsReceived); + caller.sendMessage(C.cBlue + "Mythical Chests Received: " + C.cYellow + mythicalChestsReceived + " " + C.cBlue + "Illuminated Chests Received: " + C.cYellow + illuminatedChestsReceived); + caller.sendMessage(C.cBlue + "Omega Chests Received: " + C.cYellow + omegaChestsReceived); + caller.sendMessage(C.cBlue + "Haunted Chests Received: " + C.cYellow + hauntedChestsReceived + " " + C.cBlue + "Haunted Chests Opened: " + C.cYellow + hauntedChestsOpened); + caller.sendMessage(C.cBlue + "Trick or Treat Chests Received: " + C.cYellow + trickOrTreatChestsReceived + " " + C.cBlue + "Thankful Chests Received: " + C.cYellow + thankfulChestsReceived); + caller.sendMessage(C.cBlue + "Gingerbread Chests Received: " + C.cYellow + gingerbreadChestsReceived + " " + C.cBlue + "Minestrike Chests Received: " + C.cYellow + minestrikeChestsReceived); + caller.sendMessage(C.cBlue + "Love Chests Received: " + C.cYellow + loveChestsReceived); + caller.sendMessage(C.cBlue + "St Patrick's Chests Received: " + C.cYellow + stPatricksChestReceived); + caller.sendMessage(C.cBlue + "Spring Chests Received: " + C.cYellow + springChestsReceived); + caller.sendMessage(C.cBlue + "Freedom Chests Received: " + C.cYellow + freedomChestsReceived); + caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived); + caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min/60 min) Received: " + C.cYellow + runeAmplifier20 + "/" + runeAmplifier60); + caller.sendMessage(C.cBlue + "Clans Dye Boxes Received: " + C.cYellow + clansDyeBoxesReceived + " " + C.cBlue + "Clans Builder Boxes Received: " + C.cYellow + clansBuilderBoxesReceived); + caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Usage") + " " + C.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor")); + YearMonth yearMonth = YearMonth.now(); + caller.sendMessage(C.cBlue + "Power Play Subscription (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.isSubscribed() ? C.cGreen + "Active" : C.cRed + "Inactive")); + if (powerPlayData.isSubscribed()) { - caller.sendMessage(C.cYellow + logEntry); - } + caller.sendMessage(C.cBlue + "Power Play Chest/Amplifiers (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.getUnclaimedMonths().contains(YearMonth.now()) ? C.cGreen + "Unclaimed" : C.cRed + "Claimed")); + LocalDate nextClaimDate = powerPlayData.getNextClaimDate().get(); // Guaranteed by isSubscribed() + caller.sendMessage(C.cBlue + "Power Play Next Claim Date " + C.cYellow + nextClaimDate.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + " " + nextClaimDate.getDayOfMonth()); + } + } + else + { + caller.sendMessage(C.cBlue + "Monthly Bonus Log (Last 6 entries):"); + + if (_accountBonusLog.containsKey(client.getAccountId())) + { + for (String logEntry : _accountBonusLog.get(client.getAccountId())) + { + caller.sendMessage(C.cYellow + logEntry); + } + } } caller.sendMessage(C.cDGreen + C.Strike + "============================================="); - _salesPackageManager.displaySalesPackages(caller, playerName); + if (!bonuses) + { + _salesPackageManager.displaySalesPackages(caller, playerName); + } _accountBonusLog.remove(client.getAccountId()); } }); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java new file mode 100644 index 000000000..2c679185f --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java @@ -0,0 +1,47 @@ +package mineplex.staffServer.customerSupport; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +public class checkBonusCommand extends CommandBase +{ + public checkBonusCommand(CustomerSupport plugin) + { + super(plugin, Rank.MODERATOR, "checkbonus"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args == null || args.length != 1) + { + caller.sendMessage(F.main(Plugin.getName(), "Usage : /checkbonus defek7")); + } + else + { + String playerName = args[0]; + + _commandCenter.GetClientManager().checkPlayerName(caller, playerName, name -> + { + if (name != null) + { + _commandCenter.GetClientManager().loadClientByName(name, client -> + { + if (client != null) + { + Plugin.showPlayerInfo(caller, client, true); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not load data for " + name)); + } + }); + } + }); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java index d4d2542e6..373a7a998 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java @@ -33,7 +33,7 @@ public class checkCommand extends CommandBase { if (client != null) { - Plugin.showPlayerInfo(caller, client); + Plugin.showPlayerInfo(caller, client, false); } else { 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 ebf57b8d0..ae10ed3a9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -3,6 +3,7 @@ package nautilus.game.arcade; import java.io.File; import java.util.HashMap; +import mineplex.core.imagemap.CustomItemFrames; import net.minecraft.server.v1_8_R3.MinecraftServer; import org.bukkit.Bukkit; @@ -201,7 +202,7 @@ public class Arcade extends JavaPlugin GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager); ThankManager thankManager = new ThankManager(this, _clientManager, _donationManager); BoosterManager boosterManager = new BoosterManager(this, _serverConfiguration.getServerGroup().getBoosterGroup(), _clientManager, _donationManager, inventoryManager, thankManager); - CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager); + CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager, punish); cosmeticManager.setInterfaceSlot(6); gadgetManager.setActiveItemSlot(3); cosmeticManager.disableTeamArmor(); @@ -229,6 +230,8 @@ public class Arcade extends JavaPlugin AprilFoolsManager.getInstance(); + require(CustomItemFrames.class); + //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index bdca5e21c..2bfab0d6b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -1,44 +1,10 @@ package nautilus.game.arcade; -import java.io.File; -import java.util.ArrayList; -import java.util.HashSet; - -import mineplex.core.google.GoogleSheetsManager; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockSpreadEvent; -import org.bukkit.event.block.LeavesDecayEvent; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.server.ServerListPingEvent; -import org.bukkit.potion.PotionEffect; -import org.bukkit.scoreboard.Team; -import org.bukkit.util.Vector; - import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; -import mineplex.core.antihack.compedaccount.PriorityCause; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.bonuses.BonusManager; @@ -74,6 +40,7 @@ import mineplex.core.facebook.FacebookManager; import mineplex.core.gadget.event.ToggleMobsEvent; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; +import mineplex.core.google.GoogleSheetsManager; import mineplex.core.hologram.HologramManager; import mineplex.core.incognito.IncognitoManager; import mineplex.core.incognito.events.IncognitoStatusChangeEvent; @@ -100,7 +67,6 @@ import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager; import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.scoreboard.MineplexScoreboard; import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.sponsorbranding.BrandingManager; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; @@ -169,6 +135,37 @@ import nautilus.game.arcade.managers.lobby.legacy.LegacyGameLobbyManager; import nautilus.game.arcade.player.ArcadePlayer; import nautilus.game.arcade.shop.ArcadeShop; import net.minecraft.server.v1_8_R3.EntityLiving; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.scoreboard.Team; +import org.bukkit.util.Vector; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashSet; public class ArcadeManager extends MiniPlugin implements IRelation { @@ -224,7 +221,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation private ResourcePackManager _resourcePackManager; private CustomDataManager _customDataManager; private Punish _punishmentManager; - private BrandingManager _brandingManager; private BonusManager _bonusManager; private KitProgressionManager _kitProgressionManager; private ProgressingKitManager _progressionKitManager; @@ -289,8 +285,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation _conditionManager = new SkillConditionManager(plugin); - _brandingManager = require(BrandingManager.class); - _boosterManager = boosterManager; _clientManager = clientManager; @@ -723,11 +717,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _punishmentManager; } - public BrandingManager getBrandingManager() - { - return _brandingManager; - } - public Portal GetPortal() { return _portal; 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 503422b10..80a5490f1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -9,6 +9,7 @@ import nautilus.game.arcade.game.games.alieninvasion.AlienInvasion; import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.barbarians.Barbarians; import nautilus.game.arcade.game.games.basketball.Basketball; +import nautilus.game.arcade.game.games.battleroyale.BattleRoyaleSolo; import nautilus.game.arcade.game.games.bossbattles.BossBattles; import nautilus.game.arcade.game.games.bouncyballs.BouncyBalls; import nautilus.game.arcade.game.games.bridge.Bridge; @@ -237,6 +238,12 @@ public enum GameType MOBA(MobaClassic.class, GameDisplay.MOBA), MOBATraining(MobaTraining.class, GameDisplay.MOBATraining), + BattleRoyale(BattleRoyaleSolo.class, GameDisplay.BattleRoyale, new Pair[] + { + Pair.create(MinecraftVersion.Version1_8, "http://file.mineplex.com/ResStrikeGames18.zip"), + Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResStrikeGames19.zip") + }, true), + Event(EventGame.class, GameDisplay.Event, new GameType[]{ GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, GameType.Cards, GameType.CastleSiege, GameType.ChampionsDominate, GameType.ChampionsTDM, GameType.Christmas, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index d3fba95de..46c6dd349 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game; import com.google.common.collect.Lists; import com.mojang.authlib.GameProfile; import mineplex.core.Managers; +import mineplex.core.MiniPlugin; import mineplex.core.antihack.AntiHack; import mineplex.core.arcadeevents.CoreGameStartEvent; import mineplex.core.arcadeevents.CoreGameStopEvent; @@ -43,6 +44,8 @@ import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.managers.lobby.LobbyManager; import nautilus.game.arcade.quest.ChestOpenQuestTracker; import nautilus.game.arcade.quest.CollectQuestTracker; +import nautilus.game.arcade.quest.FirstBloodQuestTracker; +import nautilus.game.arcade.quest.HitQuestTracker; import nautilus.game.arcade.quest.KillEntityQuestTracker; import nautilus.game.arcade.quest.KillQuestTracker; import nautilus.game.arcade.quest.ParticipateQuestTracker; @@ -436,7 +439,9 @@ public abstract class Game extends ListenerComponent implements Lifetimed new ChestOpenQuestTracker(this), new KillEntityQuestTracker(this), new PlayGameQuestTracker(this), - new ParticipateQuestTracker(this)); + new ParticipateQuestTracker(this), + new HitQuestTracker(this), + new FirstBloodQuestTracker(this)); Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(this), gameType.isEnforceResourcePack(this)); @@ -1210,13 +1215,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed UtilServer.getServer().getPluginManager().callEvent(event); // Re-Give Kit - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - GetKit(player).ApplyKit(player); - } - }, 0); + Manager.runSyncLater(() -> GetKit(player).ApplyKit(player), 0); } public void RespawnPlayerTeleport(Player player) @@ -1774,6 +1773,16 @@ public abstract class Game extends ListenerComponent implements Lifetimed { return _questTrackers; } + + public > T getQuestTracker(Class clazz) + { + for (QuestTracker tracker : _questTrackers) + { + if (tracker.getClass().equals(clazz)) + return clazz.cast(tracker); + } + return null; + } @EventHandler public void onHangingBreak(HangingBreakEvent event) @@ -2053,7 +2062,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public void onQuestBuy(QuestInteractEvent event) { if (GetState() == GameState.Live || GetState() == GameState.Prepare || GetState() == GameState.End) - event.setCancelled("You cant interact with " + QuestManager.QUEST_NAME + "s while you are ingame!"); + event.setCancelled("You can't interact with " + QuestManager.QUEST_NAME + "s while you are ingame!"); } public NautHashMap getDeadBodies() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java new file mode 100644 index 000000000..683793c0c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java @@ -0,0 +1,873 @@ +package nautilus.game.arcade.game.games.battleroyale; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.WorldBorder; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.EnderDragon; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.AnvilInventory; +import org.bukkit.inventory.EnchantingInventory; +import org.bukkit.inventory.FurnaceInventory; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.CombatComponent; +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.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.minestrike.GunModule; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats; +import nautilus.game.arcade.game.modules.StrikeGamesModule; +import nautilus.game.arcade.game.modules.chest.ChestLootModule; +import nautilus.game.arcade.game.modules.chest.ChestLootPool; +import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.kit.Kit; + +public abstract class BattleRoyale extends Game +{ + + private static final long PREPARE_TIME = TimeUnit.SECONDS.toMillis(30); + private static final int MIN_CORD = 100; + private static final int MAX_CORD = 1000; + private static final int SPAWN_Y = 130; + private static final int WORLD_SIZE_BUFFER = 300; + private static final int MIN_DISTANCE_APART_FOR_SPAWNS_SQUARED = 100; + private static final long MIN_DRAGON_TIME = TimeUnit.SECONDS.toMillis(5); + private static final long MAX_DRAGON_TIME = TimeUnit.SECONDS.toMillis(60); + private static final long BORDER_TIME = TimeUnit.MINUTES.toSeconds(20); + protected static final long SUPPLY_DROP_TIME = TimeUnit.MINUTES.toMillis(5); + private static final int MAX_DROPS_PER_GAME = 3; + + private static final ItemStack SMALL_BACKPACK = new ItemBuilder(Material.CHEST) + .setTitle(C.cGreen + "Small Backpack") + .addLore("Clicking this will unlock a new row in your inventory!") + .build(); + private static final ItemStack LARGE_BACKPACK = new ItemBuilder(Material.ENDER_CHEST) + .setTitle(C.cGreen + "Large Backpack") + .addLore("Clicking this will unlock two new rows in your inventory!") + .build(); + + private static final ItemStack SMALL_HEALTH_POT = new ItemBuilder(Material.POTION) + .setTitle(C.cGreen + "Small Health Pot") + .addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0)) + .build(); + + private static final ItemStack LARGE_HEALTH_POT = new ItemBuilder(Material.POTION) + .setTitle(C.cGreen + "Large Health Pot") + .addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1)) + .build(); + + protected final Map _playerData = new HashMap<>(70); + + protected GunModule _gunModule; + + protected WorldBorder _border; + private boolean _colouredMessage; + + protected BattleRoyaleSupplyDrop _supplyDrop; + protected long _lastSupplyDrop; + private int _totalDrops; + + public BattleRoyale(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc) + { + super(manager, gameType, kits, gameDesc); + + PrepareTime = PREPARE_TIME; + PrepareFreeze = false; + SpawnTeleport = false; + Damage = false; + DamageTeamSelf = true; + DeathDropItems = true; + QuitDropItems = true; + HungerSet = 20; + DeathTeleport = false; + WorldChunkUnload = true; + GameTimeout = TimeUnit.MINUTES.toMillis(40); + + ItemDrop = true; + ItemPickup = true; + + StrictAntiHack = true; + InventoryClick = true; + InventoryOpenBlock = true; + InventoryOpenChest = true; + + BlockBreakAllow.add(Material.GLASS.getId()); + BlockBreakAllow.add(Material.STAINED_GLASS.getId()); + BlockBreakAllow.add(Material.THIN_GLASS.getId()); + BlockBreakAllow.add(Material.STAINED_GLASS_PANE.getId()); + BlockBreakAllow.add(Material.LEAVES.getId()); + + _gunModule = new GunModule(this); + _gunModule.EnableCleaning = false; + _gunModule.EnableDrop = false; + _gunModule.EnablePickup = false; + _gunModule.BlockRegeneration = false; + _gunModule.EnableNormalArmor = true; + + new StrikeGamesModule(_gunModule) + .register(this); + + new CompassModule() + .register(this); + + manager.GetCreature().SetDisableCustomDrops(true); + } + + @Override + public void ParseData() + { + List chestSpawns = new ArrayList<>(500); + chestSpawns.addAll(WorldData.GetDataLocs("ORANGE")); + chestSpawns.addAll(WorldData.GetDataLocs("GREEN")); + chestSpawns.addAll(WorldData.GetDataLocs("YELLOW")); + chestSpawns.addAll(WorldData.GetDataLocs("BLUE")); + + new ChestLootModule() + .destroyAfterOpened(20) + .spawnNearbyDataPoints() + .registerChestType("Standard", chestSpawns, + + // Guns + new ChestLootPool() + .addItem(buildFromGun(GunStats.GLOCK_18)) + .addItem(buildFromGun(GunStats.CZ75)) + .addItem(buildFromGun(GunStats.DEAGLE)) + .addItem(buildFromGun(GunStats.P250)) + .addItem(buildFromGun(GunStats.P2000)) + .addItem(buildFromGun(GunStats.P90), 0.5) + .addItem(buildFromGun(GunStats.PPBIZON), 0.5) + .addItem(buildFromGun(GunStats.GALIL), 0.2) + .addItem(buildFromGun(GunStats.FAMAS), 0.2) + .addItem(buildFromGun(GunStats.AK47), 0.2) + .addItem(buildFromGun(GunStats.M4A4), 0.2) + .addItem(buildFromGun(GunStats.SG553), 0.2) + .addItem(buildFromGun(GunStats.AUG), 0.2) + .addItem(buildFromGun(GunStats.SSG08), 0.2) + .addItem(buildFromGun(GunStats.NOVA), 0.2) + .addItem(buildFromGun(GunStats.XM1014), 0.2) + .setProbability(0.5) + , + + // Grenades + new ChestLootPool() + .addItem(buildGrenade(Material.CARROT_ITEM, "Flash Bang")) + .addItem(buildGrenade(Material.APPLE, "High Explosive")) + .addItem(buildGrenade(Material.POTATO_ITEM, "Smoke")) + .addItem(buildGrenade(Material.PORK, "Incendiary"), 0.5) + .addItem(buildGrenade(Material.GRILLED_PORK, "Molotov"), 0.5) + .setProbability(0.2) + , + + // Weapons + new ChestLootPool() + .addItem(new ItemStack(Material.IRON_SWORD)) + .addItem(new ItemStack(Material.IRON_AXE)) + .addItem(new ItemStack(Material.BOW)) + .setProbability(0.1) + , + + // Ammo + new ChestLootPool() + .addItem(new ItemStack(Material.ARROW), 1, 8) + .setProbability(0.2) + .setAmountsPerChest(1, 3) + , + + // Medical + new ChestLootPool() + .addItem(SMALL_HEALTH_POT) + .addItem(LARGE_HEALTH_POT) + .setProbability(0.1) + .setAmountsPerChest(1, 2) + , + + // Armour + new ChestLootPool() + .addItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cRed + "Red Baseball Cap") + .setColor(Color.RED) + .build()) + .addItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cAqua + "Blue Baseball Cap") + .setColor(Color.BLUE) + .build()) + .addItem(new ItemBuilder(Material.CHAINMAIL_HELMET) + .setTitle(C.cDGreen + "Tactical Helmet") + .build()) + .addItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cDGreen + "Motorcycle Helmet") + .build()) + .addItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cDGreen + "Wooden Body Armour") + .build()) + .addItem(new ItemBuilder(Material.CHAINMAIL_CHESTPLATE) + .setTitle(C.cDGreen + "Plated Body Armour") + .build()) + .addItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cDGreen + "Laminated Tactical Body Armour") + .build()) + .addItem(new ItemStack(Material.LEATHER_LEGGINGS)) + .addItem(new ItemStack(Material.LEATHER_BOOTS)) + , + + // Food + new ChestLootPool() + .addItem(new ItemStack(Material.MELON), 1, 3) + .addItem(new ItemStack(Material.BREAD), 1, 2, 0.6) + .addItem(new ItemStack(Material.COOKED_FISH), 0.5) + .addItem(new ItemStack(Material.COOKED_BEEF), 0.5) + .addItem(new ItemStack(Material.COOKED_CHICKEN), 0.5) + .addItem(new ItemStack(Material.COOKED_MUTTON), 0.5) + .addItem(new ItemStack(Material.COOKIE), 0.5) + , + + // Misc + new ChestLootPool() + .addItem(SMALL_BACKPACK, 0.5) + .addItem(LARGE_BACKPACK, 0.2) + .setProbability(0.2) + ) + .registerChestType("Supply Drop", new ArrayList<>(0), + + // Guns + new ChestLootPool() + .addItem(buildFromGun(GunStats.AUG)) + .addItem(buildFromGun(GunStats.AK47)) + .addItem(buildFromGun(GunStats.M4A4)) + .addItem(buildFromGun(GunStats.XM1014)) + .addItem(buildFromGun(GunStats.AWP)) + .setAmountsPerChest(1, 2) + , + // Backpack + new ChestLootPool() + .addItem(SMALL_BACKPACK) + .addItem(LARGE_BACKPACK) + , + + // Armour + new ChestLootPool() + .addItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cDGreen + "Motorcycle Helmet") + .build()) + .addItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cDGreen + "Laminated Tactical Body Armour") + .build()) + , + + // Grenades + new ChestLootPool() + .addItem(buildGrenade(Material.CARROT_ITEM, "Flash Bang")) + .addItem(buildGrenade(Material.APPLE, "High Explosive")) + .addItem(buildGrenade(Material.POTATO_ITEM, "Smoke")) + .addItem(buildGrenade(Material.PORK, "Incendiary"), 0.5) + .addItem(buildGrenade(Material.GRILLED_PORK, "Molotov"), 0.5) + .setAmountsPerChest(1, 2) + , + + // Medical + new ChestLootPool() + .addItem(SMALL_HEALTH_POT) + .addItem(LARGE_HEALTH_POT) + .setAmountsPerChest(1, 2) + + ) + .register(this); + + WorldData.MinX = -MAX_CORD; + WorldData.MinZ = -MAX_CORD; + WorldData.MaxX = MAX_CORD; + WorldData.MaxZ = MAX_CORD; + + _border = WorldData.World.getWorldBorder(); + } + + private ItemStack buildFromGun(GunStats gunStats) + { + return new ItemBuilder(gunStats.getSkin()) + .setTitle(C.cWhiteB + gunStats.getName()) + .build(); + } + + private ItemStack buildGrenade(Material material, String name) + { + return new ItemBuilder(material) + .setTitle(C.cDGreenB + name) + .build(); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + } + + @EventHandler(priority = EventPriority.HIGH) + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + _border.setCenter(getRandomCenter()); + _border.setSize(MAX_CORD * 2); + + List toTeleport = GetPlayers(true); + AtomicInteger index = new AtomicInteger(); + + Manager.runSyncTimer(new BukkitRunnable() + { + @Override + public void run() + { + if (index.get() >= toTeleport.size()) + { + cancel(); + return; + } + + Player player = toTeleport.get(index.getAndIncrement()); + + if (player == null || !player.isOnline()) + { + return; + } + + Location spawn = null; + int attempts = 0; + int initialXZ = 0; + + while (spawn == null && attempts++ < 20) + { + if (attempts > 10) + { + initialXZ += 20; + } + + spawn = getPlayerSpawn(initialXZ); + } + + // Couldn't create a spawn, this should never happen and is pretty much impossible + if (spawn == null) + { + cancel(); + SetState(GameState.Dead); + return; + } + + Location goal = spawn.clone(); + + goal.setX(-spawn.getX()); + goal.setZ(-spawn.getZ()); + + BattleRoyalePlayer royalePlayer = new BattleRoyalePlayer(Manager, player, spawn, goal); + _playerData.put(player, royalePlayer); + } + }, 40, 2); + } + + private Location getPlayerSpawn(int initialXZ) + { + // Calculate where a player should spawn + int max = MAX_CORD - WORLD_SIZE_BUFFER; + int x = initialXZ; + int z = initialXZ; + boolean varyX = UtilMath.random.nextBoolean(); + boolean sign = UtilMath.random.nextBoolean(); + + if (varyX) + { + x += UtilMath.rRange(-max, max); + z += sign ? max : -max; + } + else + { + x += sign ? max : -max; + z += UtilMath.rRange(-max, max); + } + + Location location = new Location(WorldData.World, x, SPAWN_Y, z); + + // Check to make sure no players are nearby + for (BattleRoyalePlayer other : _playerData.values()) + { + if (UtilMath.offsetSquared(location, other.getLocation()) < MIN_DISTANCE_APART_FOR_SPAWNS_SQUARED) + { + return null; + } + } + + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, GetSpectatorLocation()))); + return location; + } + + private Location getRandomCenter() + { + int attempts = 0; + + while (attempts++ < 20) + { + Location location = UtilAlg.getRandomLocation(GetSpectatorLocation(), WORLD_SIZE_BUFFER, 0, WORLD_SIZE_BUFFER); + Block block = location.getBlock(); + + while (!UtilBlock.solid(block)) + { + block = block.getRelative(BlockFace.DOWN); + } + + if (block.isLiquid()) + { + continue; + } + + return location; + } + + return SpectatorSpawn; + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + _lastSupplyDrop = System.currentTimeMillis(); + + CreatureAllowOverride = true; + + ItemStack locked = new ItemBuilder(Material.STAINED_GLASS_PANE, (byte) 15) + .setTitle(C.cGray + "Locked") + .build(); + + _playerData.forEach((player, battleRoyalePlayer) -> + { + battleRoyalePlayer.removeCage(); + battleRoyalePlayer.spawnDragon(); + + for (int i = 18; i < player.getInventory().getSize(); i++) + { + player.getInventory().setItem(i, locked); + } + }); + + CreatureAllowOverride = false; + } + + @EventHandler + public void updateDragons(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !IsLive()) + { + return; + } + + _colouredMessage = !_colouredMessage; + + Iterator iterator = _playerData.keySet().iterator(); + + while (iterator.hasNext()) + { + Player player = iterator.next(); + BattleRoyalePlayer royalePlayer = _playerData.get(player); + + if (royalePlayer == null || !player.isOnline()) + { + iterator.remove(); + continue; + } + + EnderDragon dragon = royalePlayer.getDragon(); + Chicken chicken = royalePlayer.getChicken(); + + if (dragon == null || !dragon.isValid() || chicken == null || !chicken.isValid()) + { + continue; + } + + UtilTextBottom.display((_colouredMessage ? C.cGreenB : C.cWhiteB) + "PRESS YOUR SNEAK KEY TO DISMOUNT YOUR DRAGON", player); + if (dragon.getPassenger() == null || chicken.getPassenger() == null) + { + if (!UtilTime.elapsed(GetStateTime(), MIN_DRAGON_TIME)) + { + player.sendMessage(F.main("Game", "Did you accidentally press sneak? It's too soon to jump! Don't worry I'll put you back on your dragon.")); + dragon.setPassenger(chicken); + chicken.setPassenger(player); + continue; + } + + dismountDragon(player, royalePlayer); + } + } + + if (!Damage && UtilTime.elapsed(GetStateTime(), MAX_DRAGON_TIME)) + { + _playerData.forEach(this::dismountDragon); + + Announce(C.cRedB + "Grace Period Over!", false); + + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1); + } + + Damage = true; + HungerSet = -1; + _border.setSize(MIN_CORD, BORDER_TIME); + } + } + + private void dismountDragon(Player player, BattleRoyalePlayer royalePlayer) + { + if (!royalePlayer.getDragon().isValid()) + { + return; + } + + // Recharge this so that players won't take fall damage for the next 10 seconds + Recharge.Instance.useForce(player, "Fall Damage", TimeUnit.SECONDS.toMillis(10)); + player.playSound(player.getLocation(), Sound.BLAZE_DEATH, 1, 0.6F); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, player.getLocation(), 5, 5, 5, 0.01F, 100, ViewDist.NORMAL); + royalePlayer.getDragon().remove(); + royalePlayer.getChicken().remove(); + } + + @EventHandler + public void fallDamage(CustomDamageEvent event) + { + Player player = event.GetDamageePlayer(); + + if (player == null || event.GetCause() != DamageCause.FALL || Recharge.Instance.usable(player, "Fall Damage")) + { + return; + } + + event.SetCancelled("Dragon Fall"); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void preventDragonExplosion(EntityExplodeEvent event) + { + if (event.getEntity() instanceof EnderDragon) + { + event.blockList().clear(); + } + } + + @Override + public void disable() + { + super.disable(); + + _playerData.clear(); + if (_supplyDrop != null) + { + _supplyDrop.cleanup(); + } + } + + @EventHandler + public void updateSupplyDrop(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !IsLive()) + { + return; + } + + if (_totalDrops < MAX_DROPS_PER_GAME && UtilTime.elapsed(_lastSupplyDrop, SUPPLY_DROP_TIME)) + { + _lastSupplyDrop = System.currentTimeMillis(); + + List locations = WorldData.GetDataLocs("RED"); + Location location = null; + int attempts = 0; + + while (location == null || attempts++ < 20) + { + location = UtilAlg.Random(locations); + + if (UtilWorld.inWorldBorder(location)) + { + break; + } + } + + _supplyDrop = new BattleRoyaleSupplyDrop(this, location); + _totalDrops++; + Announce(C.cGoldB + "A New Supply Drop Will Spawn At " + C.cYellow + UtilWorld.locToStrClean(_supplyDrop.getDropLocation()) + C.cGold + "!"); + } + else if (_supplyDrop != null && _supplyDrop.isOpened()) + { + _supplyDrop = null; + } + } + + @EventHandler + public void playerDeath(CombatDeathEvent event) + { + Player player = (Player) event.GetEvent().getEntity(); + CombatComponent killer = event.GetLog().GetKiller(); + + if (killer.IsPlayer()) + { + Player killerPlayer = UtilPlayer.searchExact(killer.getUniqueIdOfEntity()); + + if (killerPlayer != null) + { + BattleRoyalePlayer royalePlayer = _playerData.get(killerPlayer); + + if (royalePlayer != null) + { + royalePlayer.incrementKills(); + UtilTextBottom.display(C.cRedB + royalePlayer.getKills() + " Kill" + (royalePlayer.getKills() == 1 ? "" : "s")); + } + } + } + + List attackers = event.GetLog().GetAttackers(); + + for (CombatComponent attacker : attackers) + { + if (!attacker.IsPlayer() || killer.equals(attacker)) + { + continue; + } + + Player attackerPlayer = UtilPlayer.searchExact(attacker.getUniqueIdOfEntity()); + + if (attackerPlayer == null) + { + continue; + } + + BattleRoyalePlayer royalePlayer = _playerData.get(attackerPlayer); + + if (royalePlayer != null) + { + attackerPlayer.sendMessage(F.main("Game", "You assisted in killing " + F.name(player.getName()) + ".")); + royalePlayer.incrementAssists(); + } + } + } + + @EventHandler + public void preventLockedInventoryClick(InventoryClickEvent event) + { + Player player = (Player) event.getWhoClicked(); + ItemStack itemStack = event.getCurrentItem(); + + if (event.getClickedInventory() == null || itemStack == null) + { + return; + } + + if (itemStack.getType() == Material.STAINED_GLASS_PANE) + { + event.setCancelled(true); + player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0.6F); + } + } + + @EventHandler + public void clickBackpack(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + ItemStack itemStack = event.getItem(); + + if (itemStack == null) + { + return; + } + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + int slots = 0; + + if (itemStack.isSimilar(SMALL_BACKPACK)) + { + slots = 9; + } + else if (itemStack.isSimilar(LARGE_BACKPACK)) + { + slots = 18; + } + + if (slots == 0) + { + return; + } + + ItemStack[] items = player.getInventory().getContents(); + int removed = 0; + + for (int i = 0; i < items.length && removed < slots; i++) + { + ItemStack inventoryItem = items[i]; + + if (inventoryItem != null && inventoryItem.getType() == Material.STAINED_GLASS_PANE) + { + player.getInventory().setItem(i, null); + removed++; + } + } + + if (itemStack.getAmount() > 1) + { + itemStack.setAmount(itemStack.getAmount() - 1); + } + else + { + player.getInventory().setItemInHand(null); + } + player.updateInventory(); + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1); + player.sendMessage(F.main("Game", "You unlocked an additional " + F.elem(removed) + " slots in your inventory.")); + } + + @EventHandler + public void noHungerRegeneration(EntityRegainHealthEvent event) + { + if (event.getRegainReason() == RegainReason.SATIATED) + { + event.setCancelled(true); + } + } + + @EventHandler + public void inventoryOpen(InventoryOpenEvent event) + { + Inventory inventory = event.getInventory(); + + if (inventory instanceof EnchantingInventory || inventory instanceof AnvilInventory || inventory instanceof FurnaceInventory) + { + event.setCancelled(true); + } + } + + @EventHandler + public void damageToLevel(CustomDamageEvent event) + { + event.SetDamageToLevel(false); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _playerData.remove(event.getPlayer()); + } + + @EventHandler + public void removeEmptyPotions(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (Player player : GetPlayers(true)) + { + player.getInventory().remove(Material.GLASS_BOTTLE); + } + } + + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + if (!IsLive()) + { + return; + } + + event.getDrops().removeIf(itemStack -> itemStack.getType() == Material.STAINED_GLASS_PANE); + + Player player = event.getEntity(); + awardTimeGems(player); + } + + @EventHandler + public void onIceMelt(BlockFadeEvent event) + { + if (!event.getBlock().getWorld().equals(WorldData.World)) + { + return; + } + if (event.getBlock().getType() == Material.ICE) + { + event.setCancelled(true); + } + } + + protected void awardTimeGems(Player player) + { + long timeAlive = Math.min(System.currentTimeMillis() - GetStateTime(), TimeUnit.MINUTES.toMillis(30)); + + // i.e 1 gem per 10 seconds alive + AddGems(player, timeAlive / TimeUnit.SECONDS.toMillis(10), "Surviving " + UtilTime.MakeStr(timeAlive), false, false); + } + + @Override + public double GetKillsGems(Player killer, Player killed, boolean assist) + { + if (assist) + { + return 50; + } + + return _border.getSize() == MIN_CORD ? 200 : 100; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java new file mode 100644 index 000000000..c01c52658 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java @@ -0,0 +1,153 @@ +package nautilus.game.arcade.game.games.battleroyale; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilEnt; +import nautilus.game.arcade.ArcadeManager; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEnderDragon; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.EnderDragon; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import java.util.HashSet; +import java.util.Set; + +class BattleRoyalePlayer +{ + + private final Player _player; + private final Location _location; + private final Location _goal; + private final Set _cageBlocks; + private EnderDragon _dragon; + private Chicken _chicken; + private int _kills; + private int _assists; + + BattleRoyalePlayer(ArcadeManager manager, Player player, Location location, Location goal) + { + _player = player; + _location = location; + _goal = goal; + _cageBlocks = new HashSet<>(); + + // Colour the cage based on the player's rank + Rank rank = manager.GetClients().Get(player).GetRank(); + byte data = UtilColor.chatColorToWoolData(rank.getColor()); + + // Build the cage + buildCage(data); + // Teleport the player to the cage + player.teleport(_location.add(0, 1, 0)); + } + + private void buildCage(byte colourData) + { + // Floor + for (int x = -2; x <= 2; x++) + { + for (int z = -2; z <= 2; z++) + { + _location.add(x, -1, z); + MapUtil.QuickChangeBlockAt(_location, Material.STAINED_GLASS, colourData); + _cageBlocks.add(_location.clone()); + _location.subtract(x, -1, z); + } + } + + // Roof + for (int x = -2; x <= 2; x++) + { + for (int z = -2; z <= 2; z++) + { + _location.add(x, 4, z); + MapUtil.QuickChangeBlockAt(_location, Material.STAINED_GLASS, colourData); + _cageBlocks.add(_location.clone()); + _location.subtract(x, 4, z); + } + } + + // Walls + for (int y = 0; y < 4; y++) + { + for (int x = -2; x <= 2; x++) + { + for (int z = -2; z <= 2; z++) + { + if (x != -2 && x != 2 && z != -2 && z != 2) + { + continue; + } + + _location.add(x, y, z); + MapUtil.QuickChangeBlockAt(_location, Material.STAINED_GLASS, colourData); + _cageBlocks.add(_location.clone()); + _location.subtract(x, y, z); + } + } + } + } + + public void removeCage() + { + for (Location location : _cageBlocks) + { + MapUtil.QuickChangeBlockAt(location, Material.AIR); + } + } + + public void spawnDragon() + { + _dragon = _location.getWorld().spawn(_location, EnderDragon.class); + UtilEnt.vegetate(_dragon); + UtilEnt.ghost(_dragon, true, false); + + _chicken = _location.getWorld().spawn(_location, Chicken.class); + _chicken.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false)); + + _dragon.setPassenger(_chicken); + _chicken.setPassenger(_player); + + ((CraftEnderDragon) _dragon).getHandle().setTargetBlock(_goal.getBlockX(), _goal.getBlockY(), _goal.getBlockZ()); + } + + public Location getLocation() + { + return _location; + } + + public EnderDragon getDragon() + { + return _dragon; + } + + public Chicken getChicken() + { + return _chicken; + } + + public void incrementKills() + { + _kills++; + } + + public int getKills() + { + return _kills; + } + + public void incrementAssists() + { + _assists++; + } + + public int getAssists() + { + return _assists; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java new file mode 100644 index 000000000..e1d418b26 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java @@ -0,0 +1,323 @@ +package nautilus.game.arcade.game.games.battleroyale; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.server.util.TransactionResponse; +import mineplex.core.treasure.TreasureType; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.KitPlayer; +import nautilus.game.arcade.game.modules.CustomScoreboardModule; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.scoreboard.GameScoreboard; + +public class BattleRoyaleSolo extends BattleRoyale +{ + + private static final String[] DESCRIPTION = { + "Battle Royale!" + }; + + private GameTeam _players; + + // Scoreboard data + private final String _playersAliveTitle = C.cYellowB + "Players"; + private String _playersAlive; + private final String _statsTitle = C.cYellowB + "Stats"; + private String _supplyDropTitle = C.cGoldB + "Supply Drop"; + private String _supplyDropLocation; + private String _supplyDropState; + private final String _borderTitle = C.cRedB + "World Border"; + private String _borderCenter; + private String _borderSize; + private boolean _showBorderCenter; + + public BattleRoyaleSolo(ArcadeManager manager) + { + super(manager, GameType.BattleRoyale, new Kit[]{new KitPlayer(manager)}, DESCRIPTION); + + new CustomScoreboardModule() + .setSidebar((player, scoreboard) -> + { + switch (GetState()) + { + case Prepare: + writePrepare(player, scoreboard); + break; + case Live: + writeLive(player, scoreboard); + break; + } + }) + .setPrefix((perspective, subject) -> + { + if (!IsAlive(subject)) + { + return C.cGray; + } + + return perspective.equals(subject) ? C.cGreen : C.cRed; + }) + .register(this); + } + + @EventHandler + public void customTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + { + return; + } + + _players = GetTeamList().get(0); + _players.SetColor(ChatColor.YELLOW); + _players.SetName("Players"); + } + + // LOW so that this is run before the scoreboards are updated + @EventHandler(priority = EventPriority.LOW) + public void scoreboardDataUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || _border == null) + { + return; + } + + // Due to many players being in this game and the fact that the scoreboard module scales O(n^2) + // we can optimise this by storing global variables that all players would see on their scoreboard + // regardless of their state. + _playersAlive = GetPlayers(true).size() + " Alive"; + + if (_supplyDrop != null) + { + Location location = _supplyDrop.getDropLocation(); + _supplyDropLocation = "(" + location.getBlockX() + ", " + location.getBlockZ() + ")"; + _supplyDropState = _supplyDrop.getScoreboardString(); + } + else + { + _supplyDropLocation = ""; + _supplyDropState = UtilTime.MakeStr(_lastSupplyDrop + BattleRoyale.SUPPLY_DROP_TIME - System.currentTimeMillis()); + } + + int size = (int) _border.getSize(); + Location center = _border.getCenter(); + + if (size < 1000 && !_showBorderCenter) + { + _showBorderCenter = true; + Announce(C.cRedB + "The Center Of The Border Is Now Visible!"); + } + + if (_showBorderCenter) + { + _borderCenter = "(" + center.getBlockX() + ", " + center.getBlockZ() + ")"; + } + else + { + _borderCenter = "Center Unknown"; + } + + _borderSize = size + " Blocks Wide"; + } + + public void writePrepare(Player player, GameScoreboard scoreboard) + { + scoreboard.writeNewLine(); + + scoreboard.write(_playersAliveTitle); + scoreboard.write(_playersAlive); + + scoreboard.writeNewLine(); + } + + public void writeLive(Player player, GameScoreboard scoreboard) + { + BattleRoyalePlayer royalePlayer = _playerData.get(player); + + scoreboard.writeNewLine(); + + scoreboard.write(_playersAliveTitle); + scoreboard.write(_playersAlive); + + scoreboard.writeNewLine(); + + if (royalePlayer != null) + { + scoreboard.write(_statsTitle); + scoreboard.write("Kills: " + C.cGreen + royalePlayer.getKills()); + scoreboard.write("Assists: " + C.cGreen + royalePlayer.getAssists()); + + scoreboard.writeNewLine(); + } + + scoreboard.write(_supplyDropTitle); + if (_supplyDrop != null) + { + scoreboard.write(_supplyDropLocation); + } + if (_supplyDropState != null) + { + scoreboard.write(_supplyDropState); + } + else if (_supplyDrop != null && IsAlive(player)) + { + int dist = (int) UtilMath.offset2d(_supplyDrop.getDropLocation(), player.getLocation()); + + scoreboard.write(dist + " Blocks Away"); + } + + scoreboard.writeNewLine(); + + scoreboard.write(_borderTitle); + scoreboard.write(_borderCenter); + scoreboard.write(_borderSize); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + List alive = GetPlayers(true); + + if (alive.size() <= 1) + { + alive.forEach(this::awardTimeGems); + + List places = _players.GetPlacements(true); + + AnnounceEnd(places); + + if (places.size() >= 1) + { + Player player = places.get(0); + long wins = Manager.GetStatsManager().Get(player).getStat("Battle Royale.Wins"); + + if (wins > 1) + { + Manager.GetDonation().purchaseUnknownSalesPackage(player, TreasureType.MYTHICAL.getItemName(), GlobalCurrency.GEM, 0, false, data -> + { + if (data == TransactionResponse.Success) + { + Manager.getInventoryManager().addItemToInventory(success -> + { + if (success) + { + player.sendMessage(F.main("Game", "Unlocked 1 " + C.cAqua + "Mythical Chest" + C.mBody + ".")); + } + else + { + player.sendMessage(F.main("Game", "Failed to give you your Mythical Chest, you should take a screenshot of this and make a support ticket!")); + player.sendMessage(C.cGray + "Error Verification Code: " + C.cGreen + new StringBuilder(player.getUniqueId().toString().split("-")[1]).reverse().toString()); + } + }, player, TreasureType.MYTHICAL.getItemName(), 1); + } + else + { + player.sendMessage(F.main("Game", "Failed to give you your Mythical Chest, you should take a screenshot of this and make a support ticket!")); + player.sendMessage(C.cGray + "Error Verification Code: " + C.cGreen + new StringBuilder(player.getUniqueId().toString().split("-")[1]).reverse().toString()); + } + }); + } + else + { + Manager.GetDonation().purchaseUnknownSalesPackage(player, TreasureType.FREEDOM.getItemName(), GlobalCurrency.GEM, 0, false, data -> + { + if (data == TransactionResponse.Success) + { + Manager.getInventoryManager().addItemToInventory(success -> + { + if (success) + { + player.sendMessage(F.main("Game", "Unlocked 1 " + C.cRed + "Freedom Chest" + C.mBody + ".")); + } + else + { + player.sendMessage(F.main("Game", "Failed to give you your Freedom Chest, you should take a screenshot of this and make a support ticket!")); + player.sendMessage(C.cGray + "Error Verification Code: " + C.cGreen + new StringBuilder(player.getUniqueId().toString().split("-")[1]).reverse().toString()); + } + }, player, TreasureType.FREEDOM.getItemName(), 1); + } + else + { + player.sendMessage(F.main("Game", "Failed to give you your Freedom Chest, you should take a screenshot of this and make a support ticket!")); + player.sendMessage(C.cGray + "Error Verification Code: " + C.cGreen + new StringBuilder(player.getUniqueId().toString().split("-")[1]).reverse().toString()); + } + }); + } + + AddGems(places.get(0), 20, "1st Place", false, false); + } + if (places.size() >= 2) + { + AddGems(places.get(1), 15, "2nd Place", false, false); + } + if (places.size() >= 3) + { + AddGems(places.get(2), 10, "3rd Place", false, false); + } + + _border.setSize(10000); + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (GetState().ordinal() >= GameState.End.ordinal()) + { + List places = _players.GetPlacements(true); + + if (places.isEmpty() || !places.get(0).isOnline()) + { + return new ArrayList<>(0); + } + else + { + return Collections.singletonList(places.get(0)); + } + } + else + { + return null; + } + } + + @Override + public List getLosers() + { + List winners = getWinners(); + + if (winners == null) + { + return null; + } + + List losers = _players.GetPlayers(false); + losers.removeAll(winners); + + return losers; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSupplyDrop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSupplyDrop.java new file mode 100644 index 000000000..edd9f332c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSupplyDrop.java @@ -0,0 +1,183 @@ +package nautilus.game.arcade.game.games.battleroyale; + +import mineplex.core.common.Pair; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.modules.chest.ChestLootModule; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Chicken; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +class BattleRoyaleSupplyDrop implements Listener +{ + + private static final int DRAGON_Y = 120; + private static long DROP_WAIT = TimeUnit.MINUTES.toMillis(2); + private static final ItemStack CHEST = new ItemStack(Material.CHEST); + private static final FireworkEffect FIREWORK_EFFECT = FireworkEffect.builder() + .with(Type.BALL_LARGE) + .withColor(Color.YELLOW) + .withFlicker() + .build(); + + private final BattleRoyale _host; + private final long _start; + private final Set _beaconBlocks; + + private Location _dropLocation; + + private ArmorStand _chest; + private Chicken _seat; + private final List _chute; + + private boolean _dropped; + private boolean _opened; + private boolean _landed; + + BattleRoyaleSupplyDrop(BattleRoyale host, Location dropLocation) + { + _host = host; + _dropLocation = dropLocation.clone(); + _start = System.currentTimeMillis(); + _beaconBlocks = new HashSet<>(); + _chute = new ArrayList<>(); + + // Construct a beacon + for (Pair> pair : UtilBlock.getBeaconBlocks(_dropLocation, (byte) 0)) + { + // Look it's like a maze + _beaconBlocks.add(pair.getLeft().getBlock()); + host.getArcadeManager().GetBlockRestore().add(pair.getLeft().getBlock(), pair.getRight().getLeft().getId(), pair.getRight().getRight(), Long.MAX_VALUE); + } + + _dropLocation.setY(DRAGON_Y); + + UtilServer.RegisterEvents(this); + } + + @EventHandler + public void updateDrop(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + if (UtilTime.elapsed(_start, DROP_WAIT) && !_dropped) + { + _dropped = true; + _host.CreatureAllowOverride = true; + + UtilFirework.playFirework(_dropLocation, FIREWORK_EFFECT); + _chest = _dropLocation.getWorld().spawn(_dropLocation, ArmorStand.class); + _chest.setGravity(false); + _chest.setVisible(false); + _chest.setHelmet(CHEST); + + _seat = _dropLocation.getWorld().spawn(_dropLocation, Chicken.class); + UtilEnt.vegetate(_seat); + UtilEnt.ghost(_seat, true, true); + UtilEnt.silence(_seat, true); + _seat.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false)); + _seat.setPassenger(_chest); + + for (int i = 0; i < 6; i++) + { + Chicken chicken = _dropLocation.getWorld().spawn(UtilAlg.getRandomLocation(_dropLocation, 2, 0.5, 2).add(0, 5, 0), Chicken.class); + UtilEnt.vegetate(chicken); + UtilEnt.ghost(chicken, true, false); + chicken.setLeashHolder(_seat); + _chute.add(chicken); + } + + _host.CreatureAllowOverride = false; + } + else if (_dropped && !_landed && UtilEnt.isGrounded(_seat)) + { + _landed = true; + + Location chest = _seat.getLocation(); + UtilFirework.playFirework(chest, FIREWORK_EFFECT); + MapUtil.QuickChangeBlockAt(chest, Material.CHEST); + _dropLocation = chest; + + ChestLootModule lootModule = _host.getModule(ChestLootModule.class); + lootModule.addChestLocation("Supply Drop", chest); + + _beaconBlocks.forEach(block -> _host.getArcadeManager().GetBlockRestore().restore(block)); + + _chest.remove(); + _seat.remove(); + _chute.forEach(Chicken::remove); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void playerInteract(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + Block block = event.getClickedBlock(); + + if (block == null || block.getType() != Material.CHEST) + { + return; + } + + if (UtilMath.offsetSquared(block.getLocation(), _dropLocation) < 4) + { + _opened = true; + cleanup(); + } + } + + public void cleanup() + { + _chute.clear(); + UtilServer.Unregister(this); + } + + public Location getDropLocation() + { + return _dropLocation; + } + + public boolean isOpened() + { + return _opened; + } + + public String getScoreboardString() + { + return _dropped ? null : UtilTime.MakeStr(_start + DROP_WAIT - System.currentTimeMillis()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index dfc12db46..99b9e3b6e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -832,14 +832,6 @@ public class Bridge extends TeamGame implements OreObsfucation if (!_bridgesDown) { _bridgesDown = true; - -// WorldBorderModule borderModule = getModule(WorldBorderModule.class); -// -// for (Player player : GetPlayers(true)) -// { -// borderModule.setSize(player, 10000); -// } - Manager.GetExplosion().SetLiquidDamage(true); Announce(C.cRedB + "ALERT: " + C.Reset + C.Bold + "THE BRIDGES ARE SPAWNING!"); UtilTextMiddle.display(C.cRedB + "ALERT", "The BRIDGES ARE SPAWNING!"); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 9d651ad84..b8d2ea776 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -14,6 +14,7 @@ import org.bukkit.ChatColor; import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Chest; @@ -56,7 +57,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.material.Dispenser; import org.bukkit.material.MaterialData; import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.metadata.MetadataValue; import org.bukkit.util.Vector; import mineplex.core.Managers; @@ -97,6 +97,7 @@ import nautilus.game.arcade.game.games.castleassault.data.KillStreakData; import nautilus.game.arcade.game.games.castleassault.data.ObjectiveTNTSpawner; import nautilus.game.arcade.game.games.castleassault.data.TeamCrystal; import nautilus.game.arcade.game.games.castleassault.data.TeamKing; +import nautilus.game.arcade.game.games.castleassault.kits.KitAlchemist; import nautilus.game.arcade.game.games.castleassault.kits.KitArcher; import nautilus.game.arcade.game.games.castleassault.kits.KitDemolitionist; import nautilus.game.arcade.game.games.castleassault.kits.KitFighter; @@ -143,7 +144,7 @@ public class CastleAssault extends TeamGame super(manager, GameType.CastleAssault, new Kit[] { - //new KitAlchemist(manager), + new KitAlchemist(manager), new KitArcher(manager), new KitDemolitionist(manager), //new KitEnchanter(manager), @@ -233,7 +234,7 @@ public class CastleAssault extends TeamGame private void generateLoot() { { - _rangedGear.addLoot(new ItemStack(Material.BOW), 3); + _rangedGear.addLoot(new ItemStack(Material.EGG), 3, 5, 9); _rangedGear.addLoot(Material.ARROW, 3, 8, 16); } { @@ -246,7 +247,6 @@ public class CastleAssault extends TeamGame } { _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8193).build(), 2); - _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8195).build(), 2); } { _miscGear.addLoot(new ItemStack(Material.ENDER_PEARL), 2); @@ -956,7 +956,8 @@ public class CastleAssault extends TeamGame float radius = event.getRadius(); event.setRadius(0f); - Player player = UtilPlayer.searchExact(((MetadataValue)UtilEnt.GetMetadata(event.getEntity(), "THROWER")).asString()); + String thrower = UtilEnt.GetMetadata(event.getEntity(), "THROWER"); + Player player = UtilPlayer.searchExact(thrower); if (player == null) { return; @@ -1003,7 +1004,7 @@ public class CastleAssault extends TeamGame } blastProtEPF = Math.min(blastProtEPF, 20); - double damage = 8 * mult; + double damage = 10 * mult; damage = damage * (1 - (blastProtEPF / 25)); double knockbackReduction = 1 - (highestBlastProt * 0.15); @@ -1194,6 +1195,7 @@ public class CastleAssault extends TeamGame { if (Recharge.Instance.use(alert, "KingDamageAlert", 5000, false, false)) { + alert.playSound(alert.getLocation(), Sound.ANVIL_LAND, 10, 3); alert.sendMessage(king.getName(true) + " is under attack!"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java index 959288efe..e1401ca49 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java @@ -46,7 +46,6 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.material.Dispenser; import org.bukkit.material.MaterialData; -import org.bukkit.metadata.MetadataValue; import mineplex.core.Managers; import mineplex.core.common.Pair; @@ -807,7 +806,8 @@ public class CastleAssaultTDM extends TeamGame float radius = event.getRadius(); event.setRadius(0f); - Player player = UtilPlayer.searchExact(((MetadataValue)UtilEnt.GetMetadata(event.getEntity(), "THROWER")).asString()); + String thrower = UtilEnt.GetMetadata(event.getEntity(), "THROWER"); + Player player = UtilPlayer.searchExact(thrower); if (player == null) { return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java index d42c40ae0..c0478f3ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java @@ -2,7 +2,12 @@ package nautilus.game.arcade.game.games.castleassault.kits; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.KitAvailability; @@ -12,21 +17,130 @@ public class KitAlchemist extends KitPlayer { public KitAlchemist(ArcadeManager manager) { - super(manager, "Alchemist", KitAvailability.Free, new String[] {}, new Perk[] {}, Material.POTION); + super(manager, "Alchemist", KitAvailability.Free, + new String[] + { + C.cWhiteB + "Starting Kit:", + C.cGray + "Diamond Sword", + C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", + C.cGray + "Speed I Potion", + C.cGreenB + "Passive Ability:", + C.cGreen + "Netherborne: Permanent Fire Resistance" + }, + new Perk[][] + { + new Perk[] {}, + new Perk[] {}, + new Perk[] {}, + new Perk[] {}, + new Perk[] {}, + new Perk[] {} + }, + new String[][] + { + { + C.cGray + "Receive a Regeneration II Potion" + }, + { + C.cGray + "Obtain a time extension on your Speed I Potion" + }, + { + C.cGray + "Obtain a time extension on your Regeneration II Potion" + }, + { + C.cGray + "Receive a Resistance I Potion" + }, + { + C.cGray + "Obtain a time extension on your Resistance I Potion" + } + }, + Material.POTION); } @Override public void GiveItems(Player player) { - player.getInventory().setItem(0, new ItemBuilder(Material.IRON_SWORD).setUnbreakable(true).build()); - player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8194).build()); - player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8193).build()); - player.getInventory().setHelmet(new ItemBuilder(Material.IRON_HELMET).setUnbreakable(true).build()); - player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setUnbreakable(true).build()); - player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setUnbreakable(true).build()); - player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).setUnbreakable(true).build()); + giveRegeneration(player); + player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 100000, 0)); + + player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + + int level = getUpgradeLevel(player.getUniqueId()); + if (level == 0) + { + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8194).build()); + } + else if (level == 1) + { + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8194).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8225).build()); + } + else if (level == 2) + { + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8258).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8225).build()); + } + else if (level == 3) + { + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8258).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8289).build()); + } + else if (level == 4) + { + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8258).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8289).build()); + ItemStack item = new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8205).build(); + PotionMeta pm = (PotionMeta) item.getItemMeta(); + pm.clearCustomEffects(); + pm.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 60, 0), true); + item.setItemMeta(pm); + player.getInventory().addItem(item); + } + else if (level == 5) + { + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8258).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8289).build()); + ItemStack item = new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8205).build(); + PotionMeta pm = (PotionMeta) item.getItemMeta(); + pm.clearCustomEffects(); + pm.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 130, 0), true); + item.setItemMeta(pm); + player.getInventory().addItem(item); + } + + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); } @Override - public void awardKillStreak(Player player, int streak) {} + public void awardKillStreak(Player player, int streak) + { + if (streak == 2) + { + player.sendMessage(C.cRed + "You have received a Slowness I Splash Potion as a Kill Streak Reward!"); + player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)16394).build()); + } + else if (streak == 4) + { + player.sendMessage(C.cRed + "You have received a Weakness I Splash Potion as a Kill Streak Reward!"); + player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)16392).build()); + } + else if (streak == 6) + { + player.sendMessage(C.cRed + "You have received 4 Instant Damage II Splash Potions as a Kill Streak Reward!"); + player.getInventory().addItem(new ItemBuilder(Material.POTION, 4).setData((short)16428).build()); + } + else if (streak == 8) + { + player.sendMessage(C.cRed + "You have received a Regeneration III Potion as a Kill Streak Reward!"); + ItemStack item = new ItemBuilder(Material.POTION).setData((short)8193).build(); + PotionMeta pm = (PotionMeta) item.getItemMeta(); + pm.clearCustomEffects(); + pm.addCustomEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 10, 2), true); + item.setItemMeta(pm); + player.getInventory().addItem(item); + } + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java index 94efc77d0..7aa25d439 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java @@ -20,21 +20,22 @@ public class KitArcher extends KitPlayer super(manager, "Archer", KitAvailability.Free, new String[] { - C.cGrayB + "Starting Kit:", + C.cWhiteB + "Starting Kit:", C.cGray + "Diamond Sword", + C.cGray + "Bow", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", C.cGray + "10 Fletched Arrows", C.cGreenB + "Starting Ability:", - C.cGreen + "Fletcher: Obtain 1 Fletched Arrow every 7 seconds (Max of 10)" + C.cGreen + "Fletcher: Obtain 1 Fletched Arrow every 6 seconds (Max of 10)" }, new Perk[][] { - new Perk[] {new PerkFletcher(7, 10, true, false)}, - new Perk[] {new PerkFletcher(7, 16, true, false)}, - new Perk[] {new PerkFletcher(7, 24, true, false)}, - new Perk[] {new PerkFletcher(7, 32, true, false)}, - new Perk[] {new PerkFletcher(7, 32, true, false)}, - new Perk[] {new PerkFletcher(7, 32, true, false)} + new Perk[] {new PerkFletcher(6, 10, true, false)}, + new Perk[] {new PerkFletcher(6, 16, true, false)}, + new Perk[] {new PerkFletcher(6, 24, true, false)}, + new Perk[] {new PerkFletcher(6, 32, true, false)}, + new Perk[] {new PerkFletcher(6, 32, true, false)}, + new Perk[] {new PerkFletcher(6, 32, true, false)} }, new String[][] { @@ -43,7 +44,8 @@ public class KitArcher extends KitPlayer }, { C.cGray + "Increase maximum and starting amount of Fletched Arrows to 24", - C.cGray + "Obtain a Power I Enchantment on your Bow" + C.cGray + "Obtain a Power I Enchantment on your Bow", + C.cGray + "Receive a Feather Falling II Enchantment on your Diamond Boots" }, { C.cGray + "Increase maximum and starting amount of Fletched Arrows to 32", @@ -100,10 +102,14 @@ public class KitArcher extends KitPlayer player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - if (level < 5) + if (level < 2) { player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); } + else if (level < 5) + { + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_FALL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } else { player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_FALL, 4).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); @@ -115,23 +121,24 @@ public class KitArcher extends KitPlayer { if (streak == 2) { - player.sendMessage(C.cRedB + "You have received 8 Arrows as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 8 Arrows as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(8).setTitle(F.item("Fletched Arrow")).build()); } else if (streak == 4) { - player.sendMessage(C.cRedB + "You have received 12 Arrows as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 12 Arrows as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(12).setTitle(F.item("Fletched Arrow")).build()); } else if (streak == 6) { - player.sendMessage(C.cRedB + "You have received a Punch I book as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Punch I book as a Kill Streak Reward!"); player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_KNOCKBACK, 1).build()); } else if (streak == 8) { - player.sendMessage(C.cRedB + "You have received 32 Arrows as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 32 Arrows and a Flame I book as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(32).setTitle(F.item("Fletched Arrow")).build()); + player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_FIRE, 1).build()); } } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitDemolitionist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitDemolitionist.java index 5af012192..648fd93f0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitDemolitionist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitDemolitionist.java @@ -19,7 +19,7 @@ public class KitDemolitionist extends KitPlayer super(manager, "Demolitionist", KitAvailability.Free, new String[] { - C.cGrayB + "Starting Kit:", + C.cWhiteB + "Starting Kit:", C.cGray + "Diamond Sword, Flint and Steel", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", C.cGray + "Blast Protection IV on all Armor", @@ -130,23 +130,24 @@ public class KitDemolitionist extends KitPlayer { if (streak == 2) { - player.sendMessage(C.cRedB + "You have received 2 Throwing TNT as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 2 Throwing TNT as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(2).build()); } else if (streak == 4) { - player.sendMessage(C.cRedB + "You have received 3 Throwing TNT as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 3 Throwing TNT as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(3).build()); } else if (streak == 6) { - player.sendMessage(C.cRedB + "You have received 4 Throwing TNT as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 4 Throwing TNT as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(4).build()); } else if (streak == 8) { - player.sendMessage(C.cRedB + "You have received 5 Throwing TNT as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 5 Throwing TNT and a 30-Use Flint and Steel as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(5).build()); + player.getInventory().addItem(new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - 30)).build()); } } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java index 986bfb915..119380430 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java @@ -18,11 +18,11 @@ public class KitFighter extends KitPlayer super(manager, "Fighter", KitAvailability.Free, new String[] { - C.cGrayB + "Starting Kit:", + C.cWhiteB + "Starting Kit:", C.cGray + "Diamond Sword", C.cGray + "1 Golden Applegate", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", - C.cGreenB + "Passive Ability:", + C.cGreenB + "Starting Ability:", C.cGreen + "Bloodlust: Deal half a heart more damage for 3 seconds after killing an enemy" }, new Perk[][] @@ -32,7 +32,7 @@ public class KitFighter extends KitPlayer new Perk[] {new PerkBloodlust(1, 3)}, new Perk[] {new PerkBloodlust(1, 3)}, new Perk[] {new PerkBloodlust(1, 3)}, - new Perk[] {new PerkBloodlust(1, 3)} + new Perk[] {new PerkBloodlust(1, 5)} }, new String[][] { @@ -50,7 +50,7 @@ public class KitFighter extends KitPlayer C.cGray + "Increase starting amount of Golden Applegates to 3" }, { - C.cGray + "Obtain a Sharpness II Enchantment on your Diamond Sword" + C.cGray + "Increase duration of Bloodlust to 5 seconds" } }, Material.DIAMOND_SWORD); @@ -92,7 +92,7 @@ public class KitFighter extends KitPlayer } else if (level == 5) { - player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setItem(1, new ItemBuilder(Material.FISHING_ROD).addEnchantment(Enchantment.KNOCKBACK, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setItem(2, new ItemBuilder(Material.GOLDEN_APPLE).setAmount(3).setTitle(C.cPurple + "Golden Applegate").build()); } @@ -108,22 +108,22 @@ public class KitFighter extends KitPlayer { if (streak == 2) { - player.sendMessage(C.cRedB + "You have received a Golden Applegate as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Golden Applegate as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setAmount(1).setTitle(C.cPurple + "Golden Applegate").build()); } else if (streak == 4) { - player.sendMessage(C.cRedB + "You have received a Splash Healing II Potion as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Healing II Splash Potion as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)16421).build()); } else if (streak == 6) { - player.sendMessage(C.cRedB + "You have received a Speed II Potion as a Kill Streak Reward!"); - player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)8290).build()); + player.sendMessage(C.cRed + "You have received a Speed II Potion as a Kill Streak Reward!"); + player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)8226).build()); } else if (streak == 8) { - player.sendMessage(C.cRedB + "You have received a Fire Aspect I book as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Fire Aspect I book as a Kill Streak Reward!"); player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.FIRE_ASPECT, 1).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java index ac445dd49..ad992cb7c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java @@ -39,7 +39,9 @@ public abstract class KitPlayer extends ProgressingKit protected void giveRegeneration(Player player) { - player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 5, 3)); + player.getActivePotionEffects().forEach(p -> player.removePotionEffect(p.getType())); + player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 8, 4)); + player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 8, 3)); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java index c6b01406f..a98498e57 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java @@ -22,10 +22,10 @@ public class KitTank extends KitPlayer super(manager, "Tank", KitAvailability.Free, new String[] { - C.cGrayB + "Starting Kit:", + C.cWhiteB + "Starting Kit:", C.cGray + "Diamond Sword", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", - C.cGray + "Protection I on Iron Armor" + C.cGray + "Protection I on Iron Chestplace" }, new Perk[][] { @@ -39,21 +39,19 @@ public class KitTank extends KitPlayer new String[][] { { - C.cGray + "Obtain a Protection II Enchantment on your Iron Armor" + C.cGray + "Obtain a Protection I Enchantment on your Iron Leggings" + }, + { + C.cGray + "Obtain a Protection II Enchantment on your Iron Chestplate" + }, + { + C.cGray + "Obtain a Protection II Enchantment on your Iron Leggings" }, { C.cGray + "Obtain a Protection I Enchantment on your Diamond Helmet" }, { C.cGray + "Obtain a Protection I Enchantment on your Diamond Boots" - }, - { - C.cGray + "Obtain a Protection II Enchantment on your Diamond Helmet", - C.cGray + "Obtain a Protection II Enchantment on your Diamond Boots" - }, - { - C.cGray + "Obtain a Protection III Enchantment on your Iron Chestplate", - C.cGray + "Obtain a Protection III Enchantment on your Iron Leggings" } }, Material.DIAMOND_CHESTPLATE); @@ -71,44 +69,44 @@ public class KitTank extends KitPlayer { player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); } else if (level == 1) + { + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + else if (level == 2) + { + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + else if (level == 3) { player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); } - else if (level == 2) + else if (level == 4) { player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); } - else if (level == 3) + else if (level == 5) { player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); } - else if (level == 4) - { - player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - } - else if (level == 5) - { - player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - } } @Override @@ -116,17 +114,17 @@ public class KitTank extends KitPlayer { if (streak == 2) { - player.sendMessage(C.cRedB + "You have received a Golden Applegate as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Golden Applegate as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setAmount(1).setTitle(C.cPurple + "Golden Applegate").build()); } else if (streak == 4) { - player.sendMessage(C.cRedB + "You have received a Regeneration II Potion as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Regeneration II Potion as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)8289).build()); } else if (streak == 6) { - player.sendMessage(C.cRedB + "You have received a Resistance I Potion as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Resistance I Potion as a Kill Streak Reward!"); ItemStack item = new ItemBuilder(Material.POTION).setData((short)8205).build(); PotionMeta pm = (PotionMeta) item.getItemMeta(); pm.clearCustomEffects(); @@ -136,7 +134,7 @@ public class KitTank extends KitPlayer } else if (streak == 8) { - player.sendMessage(C.cRedB + "You have received a Thorns II book as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Thorns II book as a Kill Streak Reward!"); player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.THORNS, 2).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java index 9dc21c017..2fc724eef 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java @@ -27,7 +27,7 @@ public class PerkBloodlust extends Perk public PerkBloodlust(double damageBoost, int duration) { super("Bloodlust", - new String[] + new String[] { C.cGray + "Deal an extra " + (damageBoost / 2) + " hearts of damage for " + duration + " seconds after a kill.", } @@ -92,7 +92,7 @@ public class PerkBloodlust extends Perk Bukkit.getScheduler().cancelTask(id.intValue()); } - player.sendMessage(C.cRed + "You are now channeling bloodlust for 3 seconds!"); + player.sendMessage(C.cRed + "You are now channeling bloodlust for " + _duration + " seconds!"); _lusting.put(player, Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () -> _lusting.remove(player), _duration * 20).getTaskId()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index 9646a217c..8a9272463 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; -import mineplex.core.common.Pair; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -34,6 +33,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; +import mineplex.core.common.Pair; import mineplex.core.common.block.BlockData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -52,6 +52,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -61,6 +62,7 @@ import nautilus.game.arcade.game.games.dragonescape.kits.KitDigger; import nautilus.game.arcade.game.games.dragonescape.kits.KitDisruptor; import nautilus.game.arcade.game.games.dragonescape.kits.KitLeaper; import nautilus.game.arcade.game.games.dragonescape.kits.KitWarper; +import nautilus.game.arcade.game.games.dragonescape.quests.DragonEscapeWinQuestTracker; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -143,6 +145,8 @@ public class DragonEscape extends SoloGame BlankLine, new ChatStatData("kit", "Kit", true) ); + + registerQuestTrackers(new DragonEscapeWinQuestTracker(this)); new CompassModule() .setGiveCompass(true) @@ -486,7 +490,10 @@ public class DragonEscape extends SoloGame AddGems(_winner, 10, "Course Complete", false, false); if (places.size() >= 1) + { AddGems(places.get(0), 20, "1st Place", false, false); + getQuestTracker(DragonEscapeWinQuestTracker.class).increment(places.get(0)); + } if (places.size() >= 2) AddGems(places.get(1), 15, "2nd Place", false, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java new file mode 100644 index 000000000..b47de5575 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.dragonescape.quests; + +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.Arcade; +import nautilus.game.arcade.game.games.dragonescape.DragonEscape; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * DragonEscapeWinQuestTracker + * + * @author xXVevzZXx + */ +public class DragonEscapeWinQuestTracker extends QuestTracker +{ + + public DragonEscapeWinQuestTracker(DragonEscape game) + { + super(game, TriggerType.COMPLETE); + } + + public void increment(Player player) + { + incrementQuests(player, 1, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), getGame().GetKit(player).GetName() + "Kit", "Parkour"); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index f1db74bae..e35238b84 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,7 +1,6 @@ package nautilus.game.arcade.game.games.moba; import mineplex.core.Managers; -import mineplex.core.beta.BetaWhitelist; import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.util.F; @@ -9,6 +8,10 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager; +import mineplex.core.imagemap.ImageMapManager; +import mineplex.core.imagemap.objects.MapBoardSelector; +import mineplex.core.imagemap.objects.PlayerMapBoard; import mineplex.core.leaderboard.Leaderboard; import mineplex.core.leaderboard.LeaderboardManager; import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; @@ -41,10 +44,13 @@ import nautilus.game.arcade.game.games.moba.kit.hp.HPManager; import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa; import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena; import nautilus.game.arcade.game.games.moba.minion.MinionManager; +import nautilus.game.arcade.game.games.moba.modes.MobaMapType; import nautilus.game.arcade.game.games.moba.overtime.OvertimeManager; +import nautilus.game.arcade.game.games.moba.progression.MobaProgression; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; +import nautilus.game.arcade.game.games.moba.training.MobaTraining; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; @@ -53,6 +59,7 @@ import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -72,6 +79,17 @@ import java.util.Set; public class Moba extends TeamGame { + private static final String[] ITEM_IMAGES = { + "Anath_the_Burnt.png", + "Bardolf.png", + "Biff.png", + "Dana.png", + "Devon.png", + "Hattori.png", + "Larissa.png", + "Rowena.png" + }; + private final HeroKit[] _kits; protected final Set _playerData = new HashSet<>(); @@ -86,7 +104,10 @@ public class Moba extends TeamGame protected final TowerManager _tower; protected final CapturePointManager _capturePoint; protected final MinionManager _minion; - private BetaWhitelist _betaWhitelist; + private final MobaProgression _progression; + private final ImageMapManager _mapManager = Managers.require(ImageMapManager.class); + private PlayerMapBoard _board; + private MapBoardSelector _selector; private int _inPlayers; @@ -120,6 +141,7 @@ public class Moba extends TeamGame _buffs = registerManager(new BuffManager()); _arrowKb = registerManager(new ArrowKBManager(this)); _minion = registerManager(new MinionManager(this)); + _progression = registerManager(new MobaProgression(this)); registerManager(new HPManager(this)); registerManager(new MobaDamageManager(this)); registerManager(new MobaFountain(this)); @@ -132,17 +154,6 @@ public class Moba extends TeamGame // Beta Message registerManager(new BetaManager(this)); - // Beta Whitelist - _betaWhitelist = Managers.get(BetaWhitelist.class); - if (_betaWhitelist == null) - { - _betaWhitelist = new BetaWhitelist(manager.GetClients(), manager.getBonusManager().getPowerPlayClubRepository()); - } - else - { - _betaWhitelist.registerSelf(); - } - new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -186,9 +197,6 @@ public class Moba extends TeamGame @Override public void ParseData() { - // Register all "Managers" - _listeners.forEach(UtilServer::RegisterEvents); - // Make all spawns face the center of the map for (List locations : WorldData.SpawnLocs.values()) { @@ -197,43 +205,72 @@ public class Moba extends TeamGame SpectatorSpawn = WorldData.GetCustomLocs("CENTER").get(0); - // Leaderboards - if (Manager.IsRewardStats()) + if (!(this instanceof MobaTraining)) { - if (Manager.GetLobby() instanceof NewGameLobbyManager) - { - Map> lobbyCustomLocs = ((NewGameLobbyManager) Manager.GetLobby()).getCustomLocs(); - LeaderboardManager leaderboard = Managers.get(LeaderboardManager.class); - Pair winPair = Pair.create("Win", "Wins"); - Pair killPair = Pair.create("Kill", "Kills"); - Pair goldPair = Pair.create("Gold", "Gold"); + MobaMapType mapType = null; + for (String key : WorldData.GetAllCustomLocs().keySet()) + { + try { - Location location = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); - leaderboard.registerLeaderboard("TOP_HOG_DAILY_WINS", new Leaderboard("Top Daily Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.DAILY, location, 10)); + mapType = MobaMapType.valueOf(key); + break; } + catch (IllegalArgumentException e) { - Location location = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); - leaderboard.registerLeaderboard("TOP_HOG_DAILY_KILLS", new Leaderboard("Top Daily Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.DAILY, location, 10)); - } - { - Location location = lobbyCustomLocs.get("TOP_DAILY_GOLD").get(0); - leaderboard.registerLeaderboard("TOP_HOG_DAILY_GOLD", new Leaderboard("Top Daily Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.DAILY, location, 10)); - } - { - Location location = lobbyCustomLocs.get("TOP_WINS").get(0); - leaderboard.registerLeaderboard("TOP_HOG_WINS", new Leaderboard("Top Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.ALL, location, 10)); - } - { - Location location = lobbyCustomLocs.get("TOP_KILLS").get(0); - leaderboard.registerLeaderboard("TOP_HOG_KILLS", new Leaderboard("Top Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.ALL, location, 10)); - } - { - Location location = lobbyCustomLocs.get("TOP_GOLD").get(0); - leaderboard.registerLeaderboard("TOP_HOG_GOLD", new Leaderboard("Top Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.ALL, location, 10)); } } + + if (mapType == null) + { + mapType = MobaMapType.HEROES_VALLEY; + } + + registerManager(mapType.createInstance(this)); } + + if (Manager.IsRewardStats() && Manager.GetLobby() instanceof NewGameLobbyManager) + { + Map> lobbyCustomLocs = ((NewGameLobbyManager) Manager.GetLobby()).getCustomLocs(); + LeaderboardManager leaderboard = Managers.get(LeaderboardManager.class); + Pair winPair = Pair.create("Win", "Wins"); + Pair killPair = Pair.create("Kill", "Kills"); + Pair goldPair = Pair.create("Gold", "Gold"); + + { + Location location = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_DAILY_WINS", new Leaderboard("Top Daily Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.DAILY, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_DAILY_KILLS", new Leaderboard("Top Daily Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.DAILY, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_DAILY_GOLD").get(0); + leaderboard.registerLeaderboard("TOP_HOG_DAILY_GOLD", new Leaderboard("Top Daily Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.DAILY, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_WINS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_WINS", new Leaderboard("Top Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.ALL, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_KILLS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_KILLS", new Leaderboard("Top Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.ALL, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_GOLD").get(0); + leaderboard.registerLeaderboard("TOP_HOG_GOLD", new Leaderboard("Top Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.ALL, location, 10)); + } + + _progression.spawnRoleViewers(lobbyCustomLocs); + + _board = _mapManager.createPlayerBoard(lobbyCustomLocs.get("HERO_VIEWER").get(0), BlockFace.EAST, 7, 4, ITEM_IMAGES); + _selector = new MapBoardSelector(_board); + _selector.createHolograms(lobbyCustomLocs.get("HERO_VIEWER NEXT").get(0), lobbyCustomLocs.get("HERO_VIEWER BACK").get(0)); + } + + // Register all "Managers" + _listeners.forEach(UtilServer::RegisterEvents); } @EventHandler(priority = EventPriority.LOWEST) @@ -248,11 +285,16 @@ public class Moba extends TeamGame setKits(_kits); // Store player data - for (Player player : GetPlayers(true)) - { - _playerData.add(new MobaPlayer(player)); - MobaUtil.setTeamEntity(player, GetTeam(player)); - } + GetPlayers(true).forEach(this::setupPlayerData); + + // Make sure to cleanup + cleanupLobby(); + } + + public void setupPlayerData(Player player) + { + _playerData.add(new MobaPlayer(player)); + MobaUtil.setTeamEntity(player, GetTeam(player)); } @EventHandler @@ -275,24 +317,41 @@ public class Moba extends TeamGame player.setGameMode(GameMode.ADVENTURE); } + private void cleanupLobby() + { + if (_board != null) + { + _mapManager.cleanupBoard(_board); + _selector.cleanup(); + } + + _progression.removeRoleViewers(); + } + @Override public void disable() { super.disable(); _listeners.forEach(UtilServer::Unregister); _listeners.clear(); - _betaWhitelist.deregisterSelf(); - // Undisguise all players - for (Player player : Bukkit.getOnlinePlayers()) + cleanupLobby(); + + Manager.runSyncLater(() -> { - DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + PlayerDisguiseManager playerDisguiseManager = Managers.require(PlayerDisguiseManager.class); - if (disguise != null && disguise instanceof DisguisePlayer) + // Undisguise all players + for (Player player : Bukkit.getOnlinePlayers()) { - Manager.GetDisguise().undisguise(disguise); + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + + if (disguise != null && disguise instanceof DisguisePlayer) + { + playerDisguiseManager.undisguise(player, (DisguisePlayer) disguise); + } } - } + }, 50); } @Override @@ -312,6 +371,12 @@ public class Moba extends TeamGame return DeathMessageType.Detailed; } + @Override + public double GetKillsGems(Player killer, Player killed, boolean assist) + { + return assist ? 1 : 2; + } + // Clear up memory @EventHandler public void playerQuit(PlayerQuitEvent event) @@ -531,4 +596,9 @@ public class Moba extends TeamGame { return _minion; } + + public MobaProgression getProgression() + { + return _progression; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java index 8fa8ee3cb..853488d6d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java @@ -6,6 +6,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; +import nautilus.game.arcade.game.games.moba.general.HotJoiningManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; import nautilus.game.arcade.game.modules.CustomScoreboardModule; @@ -46,6 +47,12 @@ public class MobaClassic extends Moba registerManager(new PrepareManager(this)); registerManager(new PrepareSelection(this)); + // Hot joining + registerManager(new HotJoiningManager(this)); + +// new GameStatisticsModule() +// .register(this); + new CustomScoreboardModule() .setSidebar((player, scoreboard) -> { @@ -90,7 +97,7 @@ public class MobaClassic extends Moba { suffix = C.cYellow + " Unknown"; } - else if (mobaPlayer.getKit() == null) + else if (mobaPlayer == null || mobaPlayer.getKit() == null) { suffix = C.cYellow + " Selecting"; } @@ -250,11 +257,15 @@ public class MobaClassic extends Moba for (Player player : otherTeam.GetPlayers(true)) { + MobaPlayer mobaPlayer = getMobaData(player); + + AddStat(player, mobaPlayer.getRole().getName() + ".Wins", 1, true, false); AddGems(player, 20, "Winning", false, false); } AnnounceEnd(otherTeam); SetState(GameState.End); + return; } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index dd09209b9..fd4b64d91 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,26 +1,29 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.common.skin.SkinData; import org.bukkit.ChatColor; import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", Color.GRAY, ChatColor.GRAY), - HUNTER("Hunter", Color.LIME, ChatColor.GREEN), - MAGE("Mage", Color.PURPLE, ChatColor.DARK_PURPLE), - WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD), + ASSASSIN("Assassin", Color.GRAY, ChatColor.GRAY, SkinData.HATTORI), + HUNTER("Hunter", Color.LIME, ChatColor.GREEN, SkinData.DEVON), + MAGE("Mage", Color.PURPLE, ChatColor.DARK_PURPLE, SkinData.ANATH), + WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD, SkinData.DANA), ; private final String _name; private final Color _color; private final ChatColor _chatColor; + private final SkinData _skinData; - MobaRole(String name, Color color, ChatColor chatColor) + MobaRole(String name, Color color, ChatColor chatColor, SkinData skinData) { _name = name; _color = color; _chatColor = chatColor; + _skinData = skinData; } public String getName() @@ -37,4 +40,9 @@ public enum MobaRole { return _chatColor; } + + public SkinData getSkin() + { + return _skinData; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java index 7b45daa6b..52f8c774e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -4,35 +4,36 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.boss.pumpkin.PumpkinBoss; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.world.WorldData; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; public class BossManager implements Listener { private final Moba _host; - private Map _teamBosses; - private PumpkinBoss _pumpkinBoss; + private final Set _bosses; + private final Map _teamBosses; private boolean _dummyBosses; public BossManager(Moba host) { _host = host; + _bosses = new HashSet<>(); _teamBosses = new HashMap<>(2); } - private void spawnBosses() + private void spawnTeamWithers() { if (_dummyBosses) { @@ -52,10 +53,6 @@ public class BossManager implements Listener _teamBosses.put(team, boss); } - // Pumpkin King - _pumpkinBoss = new PumpkinBoss(_host, worldData.GetDataLocs("BLACK").get(0)); - _pumpkinBoss.setup(); - _host.CreatureAllowOverride = false; } @@ -67,7 +64,7 @@ public class BossManager implements Listener return; } - spawnBosses(); + spawnTeamWithers(); } @EventHandler @@ -79,17 +76,19 @@ public class BossManager implements Listener } _teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup()); + _bosses.forEach(MobaBoss::cleanup); + _bosses.clear(); + } - if (_pumpkinBoss != null) - { - _pumpkinBoss.cleanup(); - } + public void registerBoss(MobaBoss boss) + { + _bosses.add(boss); + boss.setup(); } public String getWitherDisplayString(GameTeam team) { WitherBoss boss = getWitherBoss(team); - return MobaUtil.getColour(boss.getHealthPercentage()) + "♚"; } @@ -98,14 +97,9 @@ public class BossManager implements Listener return _teamBosses.get(team); } - public List getBosses() + public Collection getWitherBosses() { - List bosses = new ArrayList<>(); - - bosses.addAll(_teamBosses.values()); - bosses.add(_pumpkinBoss); - - return bosses; + return _teamBosses.values(); } public void setDummyBosses(boolean dummyBosses) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index e46cdffd7..7fc4bce66 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -113,6 +113,11 @@ public abstract class MobaBoss implements Listener getAi().setEntity(_entity); } + public void registerBoss() + { + _host.getBossManager().registerBoss(this); + } + public abstract LivingEntity spawnEntity(); public abstract MobaAI getAi(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 133a8277e..6cd5e0a22 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -113,7 +113,7 @@ public class PumpkinBoss extends MobaBoss getAi().setEntity(skeleton); UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10); - _host.Announce(F.main("Game", C.cRedB + "The Pumpkin King Has Awoken!"), false); + _host.Announce(F.main("Game", "The " + F.elem("Pumpkin King") + " has spawned! Killing him will give your team a buff!"), false); for (Player player : Bukkit.getOnlinePlayers()) { @@ -125,7 +125,8 @@ public class PumpkinBoss extends MobaBoss Block block = entry.getKey(); double setChance = entry.getValue(); - if (!UtilBlock.solid(block)|| block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > setChance) + if (!UtilBlock.solid(block) || block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > + setChance) { continue; } @@ -230,12 +231,7 @@ public class PumpkinBoss extends MobaBoss BuffManager buffManager = _host.getBuffManager(); for (Player teamMember : team.GetPlayers(true)) { - if (UtilPlayer.isSpectator(teamMember)) - { - continue; - } - - buffManager.apply(new BuffPumpkinKing(_host, teamMember)); + buffManager.apply(new BuffPumpkinKing(_host, teamMember, HELMET)); } } @@ -283,7 +279,7 @@ public class PumpkinBoss extends MobaBoss } else { - _entity.setHealth(Math.min(_entity.getHealth() + HEALTH_OUT_OF_COMBAT, _entity.getMaxHealth())); + MobaUtil.heal(_entity, null, HEALTH_OUT_OF_COMBAT); updateDisplay(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java index 66ce3aba8..c89e1fe11 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java @@ -4,6 +4,8 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -36,25 +38,7 @@ public class BuffManager implements Listener _buffs.get(buff.getEntity()).add(buff); buff.apply(); } - - public boolean hasBuff(LivingEntity entity, Class> clazz) - { - if (!_buffs.containsKey(entity)) - { - return false; - } - - for (Buff buff : _buffs.get(entity)) - { - if (buff.getClass().equals(clazz)) - { - return true; - } - } - - return false; - } - + @EventHandler public void update(UpdateEvent event) { @@ -91,4 +75,15 @@ public class BuffManager implements Listener } } } + + @EventHandler + public void end(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + { + return; + } + + _buffs.forEach((livingEntity, buffs) -> buffs.forEach(Buff::expire)); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java index 13868ec67..ef68cd0c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java @@ -12,6 +12,7 @@ import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.buff.Buff; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; import org.bukkit.Bukkit; +import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; @@ -29,13 +30,16 @@ public class BuffPumpkinKing extends Buff { private static final long DURATION = TimeUnit.MINUTES.toMillis(1); - private static final String DAMAGE_REASON = "Pumpkin King Buff"; + private static final String DAMAGE_REASON = "Boss Buff"; private static final double DAMAGE_FACTOR = 1.5; - private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN); - public BuffPumpkinKing(Moba host, Player entity) + private final ItemStack _helmet; + + public BuffPumpkinKing(Moba host, Player entity, ItemStack helmet) { super(host, entity, DURATION); + + _helmet = helmet; } @Override @@ -44,7 +48,7 @@ public class BuffPumpkinKing extends Buff _entity.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60 * 20, 1)); UtilParticle.PlayParticleToAll(ParticleType.LAVA, _entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG); _entity.playSound(_entity.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F); - _entity.sendMessage(F.main("Game", "You feel the power of the Pumpkin King flow through you. Your damage and regeneration are increased!")); + _entity.sendMessage(F.main("Game", "You feel a " + F.elem("Great Power") + " flow through you. Your " + F.elem("Damage") + " and " + F.elem("Regeneration") + " are increased!")); } @Override @@ -61,7 +65,7 @@ public class BuffPumpkinKing extends Buff return; } - sendFakeHelmet(_entity, HELMET); + sendFakeHelmet(_entity, _helmet); } @EventHandler(priority = EventPriority.HIGHEST) @@ -80,7 +84,7 @@ public class BuffPumpkinKing extends Buff return; } - UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, damagee.getLocation().add(0, 0.5, 0), 0.25F, 0.25F, 0.25F, 0.1F, 10, ViewDist.NORMAL); + damagee.getWorld().playEffect(damagee.getLocation().add(0, 0.5, 0), Effect.STEP_SOUND, Material.REDSTONE_BLOCK); event.AddMod(DAMAGE_REASON, DAMAGE_FACTOR); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java index f8f08448a..f4c1a10d6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java @@ -1,11 +1,15 @@ package nautilus.game.arcade.game.games.moba.general; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.moba.Moba; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ClickEvent.Action; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -13,7 +17,16 @@ import org.bukkit.event.Listener; public class BetaManager implements Listener { - private static final String MESSAGE = F.main("Game", "You can suggest improvements for the game on our Trello here ") + C.cYellow + "https://trello.com/b/MrxWVhlI/mineplex-heroes-of-gwen-feedback-update"; + private static final TextComponent MESSAGE; + + static + { + MESSAGE = new TextComponent("You can suggest improvements for the game on our Trello by clicking here!"); + MESSAGE.setColor(ChatColor.AQUA); + MESSAGE.setClickEvent(new ClickEvent(Action.OPEN_URL, "https://trello.com/b/MrxWVhlI/mineplex-heroes-of-gwen-feedback-update")); + MESSAGE.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click here to open the Trello board").color(ChatColor.YELLOW).create())); + } + private final Moba _host; public BetaManager(Moba host) @@ -29,6 +42,6 @@ public class BetaManager implements Listener return; } - Bukkit.broadcastMessage(MESSAGE); + Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(MESSAGE)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java new file mode 100644 index 000000000..f413cd84b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java @@ -0,0 +1,152 @@ +package nautilus.game.arcade.game.games.moba.general; + +import mineplex.core.common.util.F; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.progression.MobaExperienceCalculateEvent; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class HotJoiningManager implements Listener +{ + + private static final int HOT_JOIN_EXP_REWARD = 100; + + private final Moba _host; + private final List _pending; + private final List _hotJoined; + private final List _played; + + public HotJoiningManager(Moba host) + { + _host = host; + _pending = new ArrayList<>(); + _hotJoined = new ArrayList<>(); + _played = new ArrayList<>(8); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void playerLogin(PlayerLoginEvent event) + { + if (!_host.IsLive() || !_host.getArcadeManager().IsRewardStats()) + { + return; + } + + Player player = event.getPlayer(); + GameTeam team = _host.ChooseTeam(player); + + if (team == null || team.GetSize() >= 4) + { + return; + } + + _pending.add(player); + team.AddPlayer(player, true); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void playerJoin(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + + if (!_pending.remove(player)) + { + return; + } + + GameTeam team = _host.GetTeam(player); + + if (_host.getArcadeManager().isVanished(player)) + { + if (team != null) + { + team.RemovePlayer(player); + } + return; + } + + for (Tower tower : _host.getTowerManager().getTowers()) + { + // If the team's second tower is dead + if (tower.getOwner().equals(team) && !tower.isFirstTower() && tower.isDead()) + { + player.sendMessage(F.main("Game", "Sorry but you can only join a game in progress if they have at least " + F.elem(1) + " tower alive.")); + return; + } + } + + boolean played = _played.contains(player.getUniqueId()); + + team.SpawnTeleport(player); + + if (!played) + { + _hotJoined.add(player); + } + + _host.setupPlayerData(player); + + _host.getArcadeManager().runSyncLater(() -> + { + Kit kit = _host.getFirstKit(player); + + if (!played) + { + player.sendMessage(F.main("Game", "Thanks for choosing to join a game in progress! If you stay until the end of the game you will were an additional " + F.elem(HOT_JOIN_EXP_REWARD) + " " + F.greenElem("Heroes of GWEN Role") + " experience.")); + } + _host.SetKit(player, kit, true); + + Perk perk = kit.GetPerks()[kit.GetPerks().length - 1]; + + // Put Ultimates on cooldown + if (perk instanceof HeroSkill) + { + ((HeroSkill) perk).useSkill(player); + } + }, 1); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + _pending.remove(player); + _hotJoined.remove(player); + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + _host.GetPlayers(true).forEach(player -> _played.add(player.getUniqueId())); + } + + @EventHandler + public void expCalculate(MobaExperienceCalculateEvent event) + { + if (_hotJoined.contains(event.getPlayer())) + { + event.getExpEarned().getAndAdd(HOT_JOIN_EXP_REWARD); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java index 7fa54255c..bf75923c3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java @@ -9,10 +9,12 @@ import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.potion.PotionEffectType; public class MobaDamageManager implements Listener { @@ -97,4 +99,30 @@ public class MobaDamageManager implements Listener event.setKilledWord(word); } } + + @EventHandler + public void mageStrength(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains(MobaConstants.BASIC_ATTACK)) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + + if (damager == null) + { + return; + } + + damager.getActivePotionEffects().forEach(effect -> + { + + if (effect.getType().toString().equals(PotionEffectType.INCREASE_DAMAGE.toString())) + { + event.AddMod("Strength", (effect.getAmplifier() + 1) * 2 + 1); + } + + }); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 4758aefcd..f3b3cd47f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -16,6 +16,7 @@ import mineplex.core.utils.UtilGameProfile; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.progression.MobaProgression; import nautilus.game.arcade.game.games.moba.shop.MobaItem; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.kit.Kit; @@ -24,6 +25,7 @@ import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -32,13 +34,15 @@ import java.util.List; public class HeroKit extends Kit { - private final MobaRole _role; - private static final int AMMO_SLOT = 7; + + private final MobaRole _role; + private final SkinData _skin; + private final int _unlockLevel; + private ItemStack _ammo; private long _giveTime; private int _maxAmmo; - private SkinData _skin; private static final int SHOP_SLOT = 8; private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT) @@ -49,12 +53,18 @@ public class HeroKit extends Kit private boolean _visible = true; public HeroKit(ArcadeManager manager, String name, Perk[] kitPerks, MobaRole role, SkinData skin) + { + this(manager, name, kitPerks, role, skin, 0); + } + + public HeroKit(ArcadeManager manager, String name, Perk[] kitPerks, MobaRole role, SkinData skin, int unlockLevel) { super(manager, name, KitAvailability.Free, new String[0], kitPerks, null, null); _role = role; _maxAmmo = 64; _skin = skin; + _unlockLevel = unlockLevel; } public MobaRole getRole() @@ -62,11 +72,22 @@ public class HeroKit extends Kit return _role; } + public int getUnlockLevel() + { + return _unlockLevel; + } + public ItemStack getAmmo() { return _ammo; } + public boolean ownsKit(Player player) + { + MobaProgression progression = ((Moba) Manager.GetGame()).getProgression(); + return _unlockLevel == 0 || Manager.GetDonation().Get(player).ownsUnknownSalesPackage(progression.getPackageName(this)); + } + public void setAmmo(ItemStack ammo, long giveTime) { _ammo = ammo; @@ -197,27 +218,6 @@ public class HeroKit extends Kit { inventory.setBoots(itemstack); } - - // Give consumable items - else if (!UtilItem.isSword(itemstack) && !UtilGear.isBow(itemstack)) - { - // Keep moving left from the ammo slot until a free slot is available - for (int i = AMMO_SLOT - 1; i >= GetPerks().length - 1; i--) - { - ItemStack consumable = inventory.getItem(i); - - if (consumable == null) - { - inventory.setItem(i, itemstack); - break; - } - else if (consumable.isSimilar(itemstack)) - { - consumable.setAmount(consumable.getAmount() + 1); - break; - } - } - } } // Give all skill related items @@ -247,6 +247,40 @@ public class HeroKit extends Kit super.GiveItemsCall(player); disguise(player); + giveConsumables(player); + } + + public void giveConsumables(Player player) + { + Inventory inventory = player.getInventory(); + Moba game = (Moba) Manager.GetGame(); + List items = game.getShop().getOwnedItems(player); + + for (MobaItem item : items) + { + ItemStack itemStack = item.getItem(); + + // Give consumable items + if (itemStack.getType() == Material.POTION || itemStack.getType() == Material.ENDER_PEARL) + { + // Keep moving left from the ammo slot until a free slot is available + for (int i = AMMO_SLOT - 1; i >= GetPerks().length - 1; i--) + { + ItemStack consumable = inventory.getItem(i); + + if (consumable == null) + { + inventory.setItem(i, itemStack); + break; + } + else if (consumable.isSimilar(itemStack)) + { + consumable.setAmount(consumable.getAmount() + 1); + break; + } + } + } + } } public void disguise(Player player) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 2a19d34cd..965129a52 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -9,6 +9,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; @@ -185,8 +186,17 @@ public class HeroSkill extends Perk return false; } - return itemStack.isSimilar(_item); + if (itemStack.isSimilar(_item)) + { + if (_dropItemActivate && !Recharge.Instance.use(player, "Ultimate", _cooldown, false, false)) + { + return false; + } + return true; + } + + return false; } protected boolean isSkillSneak(PlayerToggleSneakEvent event) @@ -248,7 +258,7 @@ public class HeroSkill extends Perk } game.Announce(team.GetColor() + C.Bold + player.getName() + " " + kit.getRole().getChatColor() + kit.GetName() + C.cWhiteB + " activated their " + team.GetColor() + C.Bold + GetName() + C.cWhiteB + ".", false); - player.getWorld().playSound(player.getLocation(), Sound.NOTE_PLING, 10, 0.5F); + player.getWorld().playSound(player.getLocation(), Sound.NOTE_PLING, 1, 0.5F); } @EventHandler @@ -386,7 +396,6 @@ public class HeroSkill extends Perk GameTeam team = Manager.GetGame().GetTeam((Player) damager); return team != null && MobaUtil.isTeamEntity(damagee, team); - } public int getSlot() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java index 7ac660d7f..a62692c09 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java @@ -49,7 +49,7 @@ public class HeroBardolf extends HeroKit public HeroBardolf(ArcadeManager manager) { - super(manager, "Bardolf", PERKS, MobaRole.ASSASSIN, SkinData.BARDOLF); + super(manager, "Bardolf", PERKS, MobaRole.ASSASSIN, SkinData.BARDOLF, 10); _data = new ArrayList<>(2); } @@ -151,7 +151,7 @@ public class HeroBardolf extends HeroKit } GameTeam team = Manager.GetGame().GetTeam((Player) damager); - if (team != null && MobaUtil.isTeamEntity(damagee, team)) + if (team != null && !Manager.GetGame().DamageTeamSelf && MobaUtil.isTeamEntity(damagee, team)) { event.SetCancelled("Team Wolf"); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java index 3ea9175bc..f068bb772 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java @@ -19,6 +19,6 @@ public class HeroBiff extends HeroKit public HeroBiff(ArcadeManager manager) { - super(manager, "Biff", PERKS, MobaRole.WARRIOR, SkinData.BIFF); + super(manager, "Biff", PERKS, MobaRole.WARRIOR, SkinData.BIFF, 10); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index 19922f0e1..94d26369a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -151,6 +151,11 @@ public class SkillRally extends HeroSkill for (LivingEntity nearby : UtilEnt.getInRadius(player.getLocation(), 3).keySet()) { + if (isTeamDamage(nearby, player)) + { + continue; + } + Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, 7, true, true, false, UtilEnt.getName(player), GetName()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 6097e9a28..753b4d324 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -50,7 +50,7 @@ public class SkillInfinity extends HeroSkill @EventHandler public void interact(PlayerInteractEvent event) { - if (!isSkillItem(event) || _active.contains(event.getPlayer())) + if (!isSkillItem(event)) { return; } @@ -66,13 +66,11 @@ public class SkillInfinity extends HeroSkill // Give 1 arrow just incase the player didn't have one _kit.giveAmmo(player, 1); bow.addEnchantment(Enchantment.ARROW_INFINITE, 1); - _active.add(player); broadcast(player); useActiveSkill(() -> { bow.removeEnchantment(Enchantment.ARROW_INFINITE); - _active.remove(player); }, player, 7000); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java index a1f2cb08b..fa70c8926 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java @@ -27,7 +27,7 @@ public class HeroLarissa extends HeroKit public HeroLarissa(ArcadeManager manager) { - super(manager, "Larissa", PERKS, MobaRole.MAGE, SkinData.LARISSA); + super(manager, "Larissa", PERKS, MobaRole.MAGE, SkinData.LARISSA, 10); setAmmo(AMMO, 3000); setMaxAmmo(5); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java index e2f7b1c9f..c49d9fef5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java @@ -29,7 +29,7 @@ public class SkillAquaCannon extends HeroSkill "Fires a beam of water that deals damage", "to the first enemy it comes in contact with." }; - private static final int DAMAGE = 6; + private static final int DAMAGE = 4; private static final ItemStack SKILL_ITEM = new ItemStack(Material.DIAMOND_HOE); public SkillAquaCannon(int slot) @@ -66,7 +66,7 @@ public class SkillAquaCannon extends HeroSkill continue; } - Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, DAMAGE, true, false, false, player.getName(), MobaConstants.BASIC_ATTACK); + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, DAMAGE, false, false, false, player.getName(), MobaConstants.BASIC_ATTACK); break; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java index d15ab3174..5c7bcb9e0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java @@ -28,7 +28,7 @@ public class HeroRowena extends HeroKit public HeroRowena(ArcadeManager manager) { - super(manager, "Rowena", PERKS, MobaRole.HUNTER, SkinData.ROWENA); + super(manager, "Rowena", PERKS, MobaRole.HUNTER, SkinData.ROWENA, 10); setAmmo(AMMO, 2000); setMaxAmmo(2); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index efdb7356b..e5fe816f0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -66,7 +66,7 @@ public class MinionManager implements Listener @EventHandler public void spawnMinions(UpdateEvent event) { - if (event.getType() != UpdateType.SEC || !_enabled || !_host.IsLive() || !UtilTime.elapsed(_lastWave, MINION_SPAWN_TIME)) + if (event.getType() != UpdateType.SEC || !_enabled || !_host.IsLive() || !UtilTime.elapsed(_lastWave, MINION_SPAWN_TIME) || _waves.size() > 6) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 2ec589c7e..0fb7e7f17 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -28,6 +28,7 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -243,16 +244,9 @@ public class MinionWave implements Listener private Location targetWither(Minion minion) { - for (MobaBoss boss : _host.getBossManager().getBosses()) + for (WitherBoss boss : _host.getBossManager().getWitherBosses()) { - if (boss.isDead() || !(boss instanceof WitherBoss)) - { - continue; - } - - WitherBoss witherBoss = (WitherBoss) boss; - - if (witherBoss.getTeam().equals(_owner)) + if (boss.isDead() || boss.getTeam().equals(_owner)) { continue; } @@ -352,11 +346,11 @@ public class MinionWave implements Listener return; } - List bosses = _host.getBossManager().getBosses(); + Collection bosses = _host.getBossManager().getWitherBosses(); for (Minion minion : _minions) { - for (MobaBoss boss : bosses) + for (WitherBoss boss : bosses) { // Dead, not close enough if (boss.isDead() || MobaUtil.isTeamEntity(boss.getEntity(), _owner) || UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()) > DAMAGE_RANGE_SQUARED) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaHeroesValleyMap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaHeroesValleyMap.java new file mode 100644 index 000000000..1db64f3e8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaHeroesValleyMap.java @@ -0,0 +1,18 @@ +package nautilus.game.arcade.game.games.moba.modes; + +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.boss.pumpkin.PumpkinBoss; +import org.bukkit.Bukkit; + +public class MobaHeroesValleyMap extends MobaMap +{ + + public MobaHeroesValleyMap(Moba host) + { + super(host); + + new PumpkinBoss(host, host.WorldData.GetDataLocs("BLACK").get(0)) + .registerBoss(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMap.java new file mode 100644 index 000000000..44cd32d00 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMap.java @@ -0,0 +1,15 @@ +package nautilus.game.arcade.game.games.moba.modes; + +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.event.Listener; + +public class MobaMap implements Listener +{ + + protected final Moba _host; + + public MobaMap(Moba host) + { + _host = host; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMapType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMapType.java new file mode 100644 index 000000000..cc5d177df --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMapType.java @@ -0,0 +1,42 @@ +package nautilus.game.arcade.game.games.moba.modes; + +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; + +import java.lang.reflect.InvocationTargetException; + +public enum MobaMapType +{ + + HEROES_VALLEY("Heroes Valley", MobaHeroesValleyMap.class), + MONOCHROME("Monochrome", MobaMonochromeMap.class) + + ; + + private final String _name; + private final Class _clazz; + + MobaMapType(String name, Class clazz) + { + _name = name; + _clazz = clazz; + } + + public String getName() + { + return _name; + } + + public MobaMap createInstance(Moba host) + { + try + { + return _clazz.getConstructor(Moba.class).newInstance(host); + } + catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) + { + e.printStackTrace(); + return null; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMonochromeMap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMonochromeMap.java new file mode 100644 index 000000000..bdd4c3d0d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMonochromeMap.java @@ -0,0 +1,225 @@ +package nautilus.game.arcade.game.games.moba.modes; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +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.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.buff.BuffManager; +import nautilus.game.arcade.game.games.moba.buff.buffs.BuffPumpkinKing; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +public class MobaMonochromeMap extends MobaMap +{ + + private static final long START_TIME = TimeUnit.MINUTES.toMillis(5); + private static final long ACTIVE_TIME = TimeUnit.SECONDS.toMillis(30); + private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD); + private static final ItemStack BUFF_HELMET = new ItemBuilder(Material.SKULL_ITEM, (byte) 1).build(); + + private final Set _skeletons; + private final Map _killedSkeletons; + + private boolean _active; + private long _lastStart; + + public MobaMonochromeMap(Moba host) + { + super(host); + + _skeletons = new HashSet<>(); + _killedSkeletons = new HashMap<>(); + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + _lastStart = System.currentTimeMillis(); + } + + @EventHandler + public void updateStart(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !_host.IsLive() || _active || !UtilTime.elapsed(_lastStart, START_TIME)) + { + return; + } + + _lastStart = System.currentTimeMillis(); + _active = true; + + UtilTextMiddle.display(C.cRedB + "Wither Skeletons", "Have Spawned!", 10, 40, 10); + _host.Announce(F.main("Game", F.elem("Wither Skeletons") + " have spawned! The team that kills the most within " + F.time("30 seconds") + " receives a buff!"), false); + + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 0.4F); + } + + _host.CreatureAllowOverride = true; + + for (Location location : _host.WorldData.GetDataLocs("BLACK")) + { + Skeleton skeleton = UtilVariant.spawnWitherSkeleton(location); + skeleton.getEquipment().setItemInHand(IN_HAND); + skeleton.setCustomName(C.Bold + "Wither Skeleton"); + skeleton.setCustomNameVisible(true); + + _skeletons.add(skeleton); + } + + _host.CreatureAllowOverride = false; + + for (GameTeam team : _host.GetTeamList()) + { + _killedSkeletons.put(team, 0); + } + } + + @EventHandler + public void updateEnd(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !_host.IsLive() || !_active || !UtilTime.elapsed(_lastStart, ACTIVE_TIME)) + { + return; + } + + GameTeam red = _host.GetTeam(ChatColor.RED); + int redKills = _killedSkeletons.get(red); + GameTeam blue = _host.GetTeam(ChatColor.AQUA); + int blueKills = _killedSkeletons.get(blue); + List winners; + + // Draw + if (redKills == blueKills) + { + winners = Arrays.asList(red, blue); + } + // Red win + else if (redKills > blueKills) + { + winners = Collections.singletonList(red); + } + // Blue win + else + { + winners = Collections.singletonList(blue); + } + + if (winners.size() == 1) + { + GameTeam winner = winners.get(0); + + _host.Announce(F.main("Game", F.name(winner.GetFormattedName()) + " killed the most " + F.elem("Wither Skeletons") + ". They have been given the buff!"), false); + UtilTextMiddle.display("", winner.GetFormattedName() + C.cWhite + " killed the most " + F.elem("Wither Skeletons"), 10, 40, 10); + } + else + { + _host.Announce(F.main("Game", F.elem(C.Bold + "Draw") + "! No one was given the buff!"), false); + UtilTextMiddle.display("", C.cYellowB + "Draw" + C.cWhite + "! No one was given the buff!", 10, 40, 10); + cleanup(); + return; + } + + // Give the team members the buff + BuffManager buffManager = _host.getBuffManager(); + winners.forEach(team -> + { + for (Player teamMember : team.GetPlayers(true)) + { + buffManager.apply(new BuffPumpkinKing(_host, teamMember, BUFF_HELMET)); + } + }); + + cleanup(); + } + + private void cleanup() + { + _skeletons.forEach(entity -> + { + if (!entity.isDead()) + { + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, entity.getLocation().add(0, 1.5, 0), 0.5F, 1, 0.5F, 0.001F, 15, ViewDist.LONG); + } + + entity.remove(); + }); + _skeletons.clear(); + _killedSkeletons.clear(); + + _active = false; + } + + @EventHandler + public void entityDeath(EntityDeathEvent event) + { + LivingEntity entity = event.getEntity(); + + if (_skeletons.remove(entity)) + { + Player player = entity.getKiller(); + + if (player == null) + { + return; + } + + GameTeam team = _host.GetTeam(player); + + if (team == null) + { + return; + } + + event.getDrops().clear(); + event.setDroppedExp(0); + _killedSkeletons.put(team, _killedSkeletons.get(team) + 1); + player.sendMessage(F.main("Game", "You killed a " + F.name("Wither Skeleton") + "!")); + } + } + + @EventHandler + public void entityCombust(EntityCombustEvent event) + { + if (_skeletons.contains(event.getEntity())) + { + event.setCancelled(true); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java index f22986f4c..3270cc7de 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java @@ -49,12 +49,9 @@ public class OvertimeManager implements Listener UtilTextMiddle.display(C.cRedB + "OVERTIME", "Victory or Death, Withers are moving to the center!"); _host.Announce(F.main("Game", "Victory or Death, Withers are moving to the center!"), false); - for (MobaBoss boss : _host.getBossManager().getBosses()) + for (WitherBoss boss : _host.getBossManager().getWitherBosses()) { - if (boss instanceof WitherBoss) - { - ((WitherBoss) boss).setDamageable(true); - } + boss.setDamageable(true); } for (Player player : Bukkit.getOnlinePlayers()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java index eacc7cdd0..d968f8239 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java @@ -1,7 +1,11 @@ package nautilus.game.arcade.game.games.moba.prepare; import mineplex.core.common.entity.ClientArmorStand; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GamePrepareCountdownCommence; @@ -80,9 +84,6 @@ public class PrepareManager implements Listener } HeroKit heroKit = _host.getFirstKit(player); - MobaPlayer mobaPlayer = _host.getMobaData(player); - - mobaPlayer.setRole(heroKit.getRole()); _host.SetKit(player, heroKit, true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index 4480e761f..03086b5b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilAlg; 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.UtilTextMiddle; import mineplex.core.itemstack.ItemBuilder; @@ -42,6 +43,11 @@ import java.util.concurrent.atomic.AtomicInteger; public class PrepareSelection implements Listener, IPacketHandler { + public static ItemStack buildColouredStack(Material material, MobaRole role) + { + return new ItemBuilder(material).setColor(role.getColor()).build(); + } + private final Moba _host; private final Map _roleStands = new HashMap<>(); private final Map _kitStands = new HashMap<>(); @@ -75,8 +81,6 @@ public class PrepareSelection implements Listener, IPacketHandler Location average = UtilAlg.getAverageLocation(team.GetSpawns()); Player[] players = team.GetPlayers(true).toArray(new Player[0]); - ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 3).build(); - UtilServer.runSyncLater(() -> { for (Player player : team.GetPlayers(true)) @@ -98,7 +102,7 @@ public class PrepareSelection implements Listener, IPacketHandler stand.setCustomNameVisible(true); stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + C.cGreenB + "AVAILABLE"); stand.setArms(true); - stand.setHelmet(head); + stand.setHelmet(role.getSkin().getSkull()); stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); @@ -146,7 +150,7 @@ public class PrepareSelection implements Listener, IPacketHandler ClientArmorStand stand = ClientArmorStand.spawn(location.clone().add(0, 1, 0), player); stand.setCustomNameVisible(true); - stand.setCustomName(C.cGreenB + kit.GetName()); + stand.setCustomName((kit.ownsKit(player) ? C.cGreenB : C.cRedB) + kit.GetName()); stand.setArms(true); stand.setHelmet(kit.getSkinData().getSkull()); stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, kit.getRole())); @@ -175,11 +179,6 @@ public class PrepareSelection implements Listener, IPacketHandler return location.clone().add(0, 1, 0); } - private ItemStack buildColouredStack(Material material, MobaRole role) - { - return new ItemBuilder(material).setColor(role.getColor()).build(); - } - private void removePodiums() { _host.getLocationStartsWith("KIT").forEach((key, location) -> location.getBlock().setType(Material.AIR)); @@ -193,6 +192,11 @@ public class PrepareSelection implements Listener, IPacketHandler Player player = packetInfo.getPlayer(); int entityId = packet.a; + if (UtilPlayer.isSpectator(player)) + { + return; + } + ClientArmorStand goBackStand = _goBackStands.get(player); if (goBackStand != null && goBackStand.getEntityId() == entityId) @@ -258,6 +262,13 @@ public class PrepareSelection implements Listener, IPacketHandler HeroKit kit = _kitStands.get(stand); + if (!kit.ownsKit(player)) + { + player.sendMessage(F.main("Game", "You have not unlocked this kit. Try picking one with a " + C.cGreen + "Green" + C.cGray + " name.")); + player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 0.2F); + return; + } + if (goBackStand != null) { _goBackStands.remove(player).remove(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaExperienceCalculateEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaExperienceCalculateEvent.java new file mode 100644 index 000000000..f39ff1b84 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaExperienceCalculateEvent.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.game.games.moba.progression; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +import java.util.concurrent.atomic.AtomicInteger; + +public class MobaExperienceCalculateEvent extends PlayerEvent +{ + + private static final HandlerList _handlers = new HandlerList(); + + private AtomicInteger _expEarned; + + public MobaExperienceCalculateEvent(Player player, AtomicInteger expEarned) + { + super(player); + + _expEarned = expEarned; + } + + public AtomicInteger getExpEarned() + { + return _expEarned; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java new file mode 100644 index 000000000..e63b280c9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java @@ -0,0 +1,58 @@ +package nautilus.game.arcade.game.games.moba.progression; + +public class MobaLevelData +{ + + private final int _exp; + private final int _level; + private final int _thisLevel; + private final int _nextLevel; + + public MobaLevelData(long exp) + { + _exp = (int) exp; + _level = MobaProgression.getLevel(exp); + _thisLevel = MobaProgression.getExpFor(_level); + _nextLevel = MobaProgression.getExpFor(_level + 1); + } + + public int getExp() + { + return _exp; + } + + public int getLevel() + { + return _level; + } + + public int getDisplayLevel() + { + return _level + 1; + } + + public int getExpThisLevel() + { + return _thisLevel; + } + + public int getExpJustThisLevel() + { + return _nextLevel - _thisLevel; + } + + public int getExpLevelProgress() + { + return _exp - _thisLevel; + } + + public int getExpReminder() + { + return _nextLevel - _exp; + } + + public double getPercentageComplete() + { + return (double) (getExpLevelProgress()) / (double) (getExpJustThisLevel()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java new file mode 100644 index 000000000..6ccdc62af --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java @@ -0,0 +1,277 @@ +package nautilus.game.arcade.game.games.moba.progression; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeFormat; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.DebugCommand; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GemData; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaPlayer; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; +import nautilus.game.arcade.game.games.moba.progression.ui.MobaRoleShop; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; + +import java.text.DecimalFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +public class MobaProgression implements Listener +{ + + private static final int EXP_PER_LEVEL = 1000; + private static final int EXP_FACTOR = 3; + public static final DecimalFormat FORMAT = new DecimalFormat("0.0"); + + public static int getExpFor(int level) + { + return EXP_PER_LEVEL * level; + } + + public static int getLevel(long exp) + { + return (int) Math.floor(exp / EXP_PER_LEVEL); + } + + private final Moba _host; + private final Map _roleViewers; + private final MobaRoleShop _roleShop; + + private MobaUnlockAnimation _currentAnimation; + + public MobaProgression(Moba host) + { + _host = host; + _roleViewers = new HashMap<>(); + _roleShop = new MobaRoleShop(host.getArcadeManager()); + + host.registerDebugCommand(new DebugCommand("fakeexp", Rank.DEVELOPER) + { + @Override + public void Execute(Player caller, String[] args) + { + int exp = Integer.parseInt(args[0]); + _host.GetGems(caller).put("Fake Exp", new GemData(exp, false)); + caller.sendMessage(F.main("Debug", "Gave you " + F.elem(exp) + " fake exp.")); + } + }); + host.registerDebugCommand(new DebugCommand("setmobalevel", Rank.DEVELOPER) + { + @Override + public void Execute(Player caller, String[] args) + { + MobaRole role = MobaRole.valueOf(args[0].toUpperCase()); + int exp = getExpFor(Integer.parseInt(args[1]) - 1); + _host.getArcadeManager().GetStatsManager().setStat(caller, _host.GetName() + "." + role.getName() + ".ExpEarned", exp); + caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp) + 1) + ".")); + } + }); + } + + public void spawnRoleViewers(Map> lobbyLocations) + { + Location center = lobbyLocations.get("SPAWN").get(0); + + for (MobaRole role : MobaRole.values()) + { + List locations = lobbyLocations.get(role.name()); + + if (locations == null || locations.isEmpty()) + { + continue; + } + + Location location = locations.get(0).clone(); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, center))); + + ArmorStand stand = location.getWorld().spawn(location, ArmorStand.class); + + UtilEnt.vegetate(stand); + UtilEnt.ghost(stand, true, false); + + stand.setCustomName(C.cGreenB + role.getName()); + stand.setCustomNameVisible(true); + stand.setArms(true); + stand.setBasePlate(false); + stand.setHelmet(role.getSkin().getSkull()); + stand.setChestplate(PrepareSelection.buildColouredStack(Material.LEATHER_CHESTPLATE, role)); + stand.setLeggings(PrepareSelection.buildColouredStack(Material.LEATHER_LEGGINGS, role)); + stand.setBoots(PrepareSelection.buildColouredStack(Material.LEATHER_BOOTS, role)); + + _roleViewers.put(stand, role); + } + } + + public void removeRoleViewers() + { + for (ArmorStand stand : _roleViewers.keySet()) + { + stand.remove(); + } + + _roleViewers.clear(); + } + + @EventHandler + public void onClick(CustomDamageEvent event) + { + onClick(event.GetDamagerEntity(true), event.GetDamageeEntity()); + } + + @EventHandler + public void onClick(PlayerInteractAtEntityEvent event) + { + onClick(event.getPlayer(), event.getRightClicked()); + } + + private void onClick(Entity clicker, Entity clicked) + { + if (clicker == null || !(clicker instanceof Player) || !_roleViewers.containsKey(clicked)) + { + return; + } + + Player player = (Player) clicker; + MobaRole role = _roleViewers.get(clicked); + + if (role == null) + { + return; + } + + _roleShop.openShop(player, role); + } + + @EventHandler + public void end(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End || !_host.getArcadeManager().IsRewardStats()) + { + return; + } + + _host.GetPlayers(true).forEach(this::rewardPlayer); + } + + public long getExperience(Player player, MobaRole role) + { + String stat = _host.GetName() + "." + role.getName() + ".ExpEarned"; + return _host.getArcadeManager().GetStatsManager().Get(player).getStat(stat); + } + + public int getLevel(Player player, HeroKit kit) + { + return getLevel(player, kit.getRole()); + } + + public int getLevel(Player player, MobaRole role) + { + return getLevel(getExperience(player, role)); + } + + private void rewardPlayer(Player player) + { + MobaPlayer mobaPlayer = _host.getMobaData(player); + + if (mobaPlayer == null) + { + return; + } + + MobaRole role = mobaPlayer.getRole(); + String stat = _host.GetName() + "." + role.getName() + ".ExpEarned"; + // EXP before earning + long currentExp = getExperience(player, role); + // Level before earning + int currentLevel = getLevel(currentExp); + + AtomicInteger earnedExp = new AtomicInteger(); + + for (GemData data : _host.GetGems(player).values()) + { + earnedExp.getAndAdd((int) data.Gems); + } + + earnedExp.getAndAdd(earnedExp.get() * EXP_FACTOR); + + MobaExperienceCalculateEvent event = new MobaExperienceCalculateEvent(player, earnedExp); + UtilServer.CallEvent(event); + + MobaLevelData levelData = new MobaLevelData(currentExp + earnedExp.get()); + + AtomicBoolean levelUp = new AtomicBoolean(levelData.getLevel() > currentLevel); + + _host.getArcadeManager().GetStatsManager().incrementStat(player, stat, earnedExp.get()); + + UtilServer.runSyncLater(() -> + { + player.sendMessage(ArcadeFormat.Line); + player.sendMessage(""); + + player.sendMessage(" " + role.getChatColor() + C.Bold + role.getName() + " Progression" + (levelUp.get() ? C.cGreenB + " LEVEL UP" : "")); + player.sendMessage(""); + player.sendMessage(MobaUtil.getProgressBar(levelData.getExpLevelProgress() - earnedExp.get(), levelData.getExpLevelProgress(), levelData.getExpJustThisLevel(), 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + levelData.getExpJustThisLevel()); + player.sendMessage(C.cGreen + FORMAT.format((levelData.getPercentageComplete() * 100D)) + C.cWhite + "% complete for Level " + levelData.getDisplayLevel()); + + player.sendMessage(""); + player.sendMessage(ArcadeFormat.Line); + + if (levelUp.get()) + { + for (HeroKit kit : _host.getKits()) + { + if (!kit.getRole().equals(role) || kit.getUnlockLevel() != levelData.getDisplayLevel()) + { + continue; + } + + player.playSound(player.getLocation(), Sound.ENDERDRAGON_DEATH, 1, 1); + UtilTextMiddle.display(role.getColor() + kit.GetName(), "You unlocked a new Hero!", 10, 40, 10, player); + return; + } + + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1); + } + else + { + player.playSound(player.getLocation(), Sound.CLICK, 1, 1); + } + }, 60); + } + + public String getPackageName(HeroKit kit) + { + return "MOBA_KIT_" + kit.GetName().toUpperCase(); + } + + public void setCurrentAnimation(MobaUnlockAnimation animation) + { + _currentAnimation = animation; + } + + public MobaUnlockAnimation getCurrentAnimation() + { + return _currentAnimation; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaUnlockAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaUnlockAnimation.java new file mode 100644 index 000000000..30a3db379 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaUnlockAnimation.java @@ -0,0 +1,188 @@ +package nautilus.game.arcade.game.games.moba.progression; + +import com.mojang.authlib.GameProfile; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.hologram.Hologram; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.util.Vector; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public class MobaUnlockAnimation implements Listener +{ + + private static final FireworkEffect FIREWORK_EFFECT = FireworkEffect.builder() + .withColor(Color.ORANGE) + .withFlicker() + .with(Type.BURST) + .build(); + + private final Moba _host; + private final Player _player; + private final HeroKit _kit; + private final Location _spawn; + private final Location _toTeleport; + private final Location _npc; + private final Location _info; + private final long _start; + + private ArmorStand _npcEntity; + private int _animationStage; + private Hologram _skillInfo; + + public MobaUnlockAnimation(Moba host, Player player, HeroKit kit) + { + _host = host; + _player = player; + _kit = kit; + + Map> lobbyLocations = ((NewGameLobbyManager) host.getArcadeManager().GetLobby()).getCustomLocs(); + _spawn = lobbyLocations.get("SPAWN").get(0); + _toTeleport = lobbyLocations.get("HERO_UNLOCK PLAYER").get(0); + _npc = lobbyLocations.get("HERO_UNLOCK NPC").get(0); + _info = lobbyLocations.get("HERO_UNLOCK INFO_1").get(0); + + Vector dir = UtilAlg.getTrajectory(_toTeleport, _npc); + _toTeleport.setYaw(UtilAlg.GetYaw(dir)); + _npc.setYaw(UtilAlg.GetYaw(dir.clone().multiply(-1))); + + _start = System.currentTimeMillis(); + + UtilServer.RegisterEvents(this); + _host.getProgression().setCurrentAnimation(this); + start(); + } + + public void start() + { + _player.sendMessage(F.main("Game", "Unlocking " + _kit.getRole().getChatColor() + _kit.GetName() + ".")); + _player.teleport(_toTeleport); + + _npcEntity = _npc.getWorld().spawn(_npc, ArmorStand.class); + GameProfile profile = new GameProfile(UUID.randomUUID(), _kit.GetName()); + profile.getProperties().clear(); + profile.getProperties().put("textures", _kit.getSkinData().getProperty()); + DisguisePlayer disguise = new DisguisePlayer(_npcEntity, profile); + disguise.setSendSkinDataToSelf(false); + _host.getArcadeManager().GetDisguise().disguise(disguise); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + switch (_animationStage) + { + case 0: + if (!UtilTime.elapsed(_start, 2000)) + { + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, _npcEntity.getLocation().add(0, 1.5, 0), 1, 1, 1, 0.0001F, 50, ViewDist.NORMAL); + } + else + { + _animationStage++; + } + break; + case 1: + _npcEntity.getWorld().strikeLightningEffect(_npcEntity.getLocation()); + + String[] text = new String[_kit.GetPerks().length + 1]; + int i = 0; + text[i++] = C.cAqua + "Skills"; + + for (Perk perk : _kit.GetPerks()) + { + text[i++] = C.cYellow + perk.GetName(); + } + + _skillInfo = new Hologram(_host.getArcadeManager().getHologramManager(), _info, text); + _skillInfo.start(); + + for (int j = 0; j < 10; j++) + { + UtilFirework.playFirework(UtilAlg.getRandomLocation(_npcEntity.getLocation(), 4, 0, 4), FIREWORK_EFFECT); + } + + _animationStage++; + break; + case 2: + if (UtilTime.elapsed(_start, 12000)) + { + _player.sendMessage(F.main("Game", "Unlocked" + _kit.getRole().getChatColor() + _kit.GetName() + ". You can now select them at the start of the game!")); + _player.teleport(_spawn); + _player.playSound(_player.getLocation(), Sound.LEVEL_UP, 1, 1.2F); + cleanup(); + _animationStage++; + } + + break; + } + } + + @EventHandler + public void playerMove(PlayerMoveEvent event) + { + if (!event.getPlayer().equals(_player)) + { + return; + } + + Location from = event.getFrom(); + Location to = event.getTo(); + + if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ()) + { + return; + } + + event.setTo(event.getFrom()); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + if (event.getPlayer().equals(_player)) + { + cleanup(); + } + } + + private void cleanup() + { + UtilServer.Unregister(this); + _npcEntity.remove(); + _skillInfo.stop(); + _host.getProgression().setCurrentAnimation(null); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java new file mode 100644 index 000000000..de2fb9774 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java @@ -0,0 +1,157 @@ +package nautilus.game.arcade.game.games.moba.progression.ui; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilUI; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.server.util.TransactionResponse; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.progression.MobaLevelData; +import nautilus.game.arcade.game.games.moba.progression.MobaProgression; +import nautilus.game.arcade.game.games.moba.progression.MobaUnlockAnimation; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +public class MobaRolePage extends ShopPageBase +{ + + private static final int SIZE = 45; + private static final int[] MAPPINGS = UtilUI.getIndicesFor(4, 3); + private static final ItemStack COMING_SOON = new ItemBuilder(Material.STAINED_CLAY, (byte) 15) + .setTitle(C.cRed + "Coming Soon") + .build(); + private static final int ANIMATION_TIME = 20; + + private final Moba _host; + private final MobaRole _role; + + public MobaRolePage(ArcadeManager plugin, MobaRoleShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, Moba host, MobaRole role) + { + super(plugin, shop, clientManager, donationManager, role.getName(), player, SIZE); + + _host = host; + _role = role; + + buildPage(); + } + + @Override + protected void buildPage() + { + MobaLevelData levelData = new MobaLevelData(_host.getProgression().getExperience(_player, _role)); + + addButtonNoAction(13, new ItemBuilder(_role.getSkin().getSkull()) + .setTitle(_role.getChatColor() + _role.getName()) + .addLore( + "", + "Every " + F.elem(10) + " levels you unlock a new", + "hero within the " + F.name(_role.getName()) + " category.", + "", + "Your Level: " + C.cGreen + levelData.getDisplayLevel(), + "Next Level: " + C.cGreen + levelData.getExpLevelProgress() + C.cGray + "/" + C.cGreen + levelData.getExpJustThisLevel() + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(levelData.getPercentageComplete() * 100D) + C.cGray + "%)" + ) + .build()); + + List kits = new ArrayList<>(); + + for (HeroKit kit : _host.getKits()) + { + if (!kit.getRole().equals(_role) || !kit.isVisible() || kit.getUnlockLevel() == 0) + { + continue; + } + + kits.add(kit); + } + + int i = 0; + for (int slot : MAPPINGS) + { + if (i >= kits.size()) + { + addButtonNoAction(slot, COMING_SOON); + continue; + } + + HeroKit kit = kits.get(i++); + String packageName = _host.getProgression().getPackageName(kit); + boolean hasUnlocked = _plugin.GetDonation().Get(_player).ownsUnknownSalesPackage(packageName); + boolean canUnlock = _host.getProgression().getLevel(_player, kit) >= kit.getUnlockLevel(); + ItemBuilder builder = new ItemBuilder(Material.STAINED_CLAY); + + builder.setTitle(C.cGreen + kit.GetName()); + builder.addLore("", "Unlocks at " + _role.getName() + " Level " + C.cGreen + (i * 10)); + + if (hasUnlocked) + { + builder.setData((byte) 5); + builder.addLore(C.cRed + "You have already unlocked this hero!"); + } + else + { + builder.setData((byte) 14); + builder.setGlow(canUnlock); + + if (canUnlock) + { + builder.addLore(C.cGreen + "Click to unlock!"); + } + else + { + builder.addLore(C.cRed + "You cannot unlock this hero!"); + } + } + + addButton(slot, builder.build(), (player, clickType) -> + { + if (!Recharge.Instance.use(player, "Hero Unlock", 1000, false, false)) + { + playDenySound(player); + return; + } + + boolean allowAnimation = (_host.GetCountdown() > ANIMATION_TIME || _host.GetCountdown() < 0) && _host.getProgression().getCurrentAnimation() == null; + + if (!hasUnlocked && canUnlock) + { + if (allowAnimation) + { + _host.getArcadeManager().GetDonation().purchaseUnknownSalesPackage(player, packageName, GlobalCurrency.GEM, 0, true, data -> + { + if (data != TransactionResponse.Success) + { + player.sendMessage(F.main("Game", "Failed to unlock " + kit.GetName() + " please try again in a few seconds.")); + return; + } + + new MobaUnlockAnimation(_host, player, kit); + playAcceptSound(player); + player.closeInventory(); + }); + } + else + { + player.sendMessage(F.main("Game", "You cannot unlock a Hero right now.")); + playDenySound(player); + } + } + else + { + playDenySound(player); + } + }); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRoleShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRoleShop.java new file mode 100644 index 000000000..faff3d138 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRoleShop.java @@ -0,0 +1,28 @@ +package nautilus.game.arcade.game.games.moba.progression.ui; + +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaRole; +import org.bukkit.entity.Player; + +public class MobaRoleShop extends ShopBase +{ + + public MobaRoleShop(ArcadeManager plugin) + { + super(plugin, plugin.GetClients(), plugin.GetDonation(), "Moba Heroes"); + } + + public void openShop(Player player, MobaRole role) + { + openPageForPlayer(player, new MobaRolePage(getPlugin(), this, getClientManager(), getDonationManager(), player, (Moba) getPlugin().GetGame(), role)); + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return null; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 55c40f2af..224ee61bc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -4,7 +4,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -20,6 +19,7 @@ import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop; import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; @@ -42,8 +42,6 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerItemConsumeEvent; -import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.HashMap; @@ -95,6 +93,7 @@ public class MobaShop implements Listener villager.setCustomNameVisible(true); UtilEnt.vegetate(villager); UtilEnt.silence(villager, true); + UtilEnt.ghost(villager, true, false); UtilEnt.CreatureForceLook(villager, 0, UtilAlg.GetYaw(UtilAlg.getTrajectory(villager.getLocation(), _host.GetSpectatorLocation()))); ((CraftLivingEntity) villager).getHandle().k = false; @@ -212,10 +211,11 @@ public class MobaShop implements Listener // The respawn event needs to be called here so that effects like "Total Health Increase" will work straight away, instead of after the next respawn, // Prevents infinite speed + double currentHealth = player.getHealth(); player.setWalkSpeed(0.2F); player.setMaxHealth(20); - PlayerGameRespawnEvent fakeEvent = new PlayerGameRespawnEvent(null, player); + PlayerGameRespawnEvent fakeEvent = new PlayerGameRespawnEvent(_host, player); for (MobaItem ownedItem : owned) { @@ -225,7 +225,20 @@ public class MobaShop implements Listener } } - _host.GetKit(player).GiveItems(player); + HeroKit kit = (HeroKit) _host.GetKit(player); + + // If we aren't tracking purchases then after we give the item remove it. + if (category.isTrackingPurchases()) + { + kit.GiveItems(player); + } + else + { + kit.giveConsumables(player); + owned.remove(item); + } + + player.setHealth(Math.min(currentHealth, player.getMaxHealth())); } public boolean ownsItem(Player player, MobaItem item) @@ -235,6 +248,7 @@ public class MobaShop implements Listener public List getOwnedItems(Player player) { + _upgrades.putIfAbsent(player, new ArrayList<>()); return _upgrades.get(player); } @@ -315,20 +329,6 @@ public class MobaShop implements Listener Handle MobaItem events */ - @EventHandler - public void prepare(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - { - return; - } - - for (Player player : _host.GetPlayers(true)) - { - _upgrades.put(player, new ArrayList<>()); - } - } - @EventHandler public void ammoGive(AmmoGiveEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java index 2d0ca6f60..8c9118358 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java @@ -44,21 +44,21 @@ public class MobaWarriorShop extends MobaShopMenu new MobaItem(new ItemBuilder(Material.IRON_HELMET) .setTitle(C.cGreenB + "Archer's Bane") .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) - .build(), 400) + .build(), 100) .addEffects( new MobaHPRegenEffect(0.03) ), -// new MobaItem(new ItemBuilder(Material.IRON_HELMET) -// .setTitle(C.cYellowB + "Superior Archer's Bane") -// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) -// .build(), 750) -// .addEffects( -// new MobaHPRegenEffect(0.05) -// ), + new MobaItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 300) + .addEffects( + new MobaHPRegenEffect(0.05) + ), new MobaItem(new ItemBuilder(Material.IRON_HELMET) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) - .build(), 400) + .build(), 300) .addEffects( new MobaHPRegenEffect(0.03) ), @@ -71,7 +71,7 @@ public class MobaWarriorShop extends MobaShopMenu // ), new MobaItem(new ItemBuilder(Material.DIAMOND_HELMET) .setTitle(C.cDRedB + "Prince's Plate") - .build(), 2000) + .build(), 1200) .addEffects( new MobaHPRegenEffect(0.15) ) @@ -81,21 +81,21 @@ public class MobaWarriorShop extends MobaShopMenu new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) .setTitle(C.cGreenB + "Archer's Bane") .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) - .build(), 600) + .build(), 150) .addEffects( new MobaTotalHealthEffect(2) ), -// new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) -// .setTitle(C.cYellowB + "Superior Archer's Bane") -// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) -// .build(), 1000) -// .addEffects( -// new MobaTotalHealthEffect(4) -// ), + new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 400) + .addEffects( + new MobaTotalHealthEffect(4) + ), new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) - .build(), 600) + .build(), 400) .addEffects( new MobaTotalHealthEffect(2) ), @@ -108,7 +108,7 @@ public class MobaWarriorShop extends MobaShopMenu // ), new MobaItem(new ItemBuilder(Material.DIAMOND_CHESTPLATE) .setTitle(C.cDRedB + "Prince's Plate") - .build(), 2500) + .build(), 1500) .addEffects( new MobaTotalHealthEffect(4) ) @@ -118,21 +118,21 @@ public class MobaWarriorShop extends MobaShopMenu new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) .setTitle(C.cGreenB + "Archer's Bane") .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) - .build(), 600) + .build(), 150) .addEffects( new MobaCDREffect(0.05) ), -// new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) -// .setTitle(C.cYellowB + "Superior Archer's Bane") -// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) -// .build(), 1000) -// .addEffects( -// new MobaCDREffect(0.07) -// ), + new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 400) + .addEffects( + new MobaCDREffect(0.07) + ), new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) - .build(), 600) + .build(), 400) .addEffects( new MobaCDREffect(0.05) ), @@ -145,7 +145,7 @@ public class MobaWarriorShop extends MobaShopMenu // ), new MobaItem(new ItemBuilder(Material.DIAMOND_LEGGINGS) .setTitle(C.cDRedB + "Prince's Plate") - .build(), 2500) + .build(), 1500) .addEffects( new MobaCDREffect(0.1) ) @@ -155,21 +155,21 @@ public class MobaWarriorShop extends MobaShopMenu new MobaItem(new ItemBuilder(Material.IRON_BOOTS) .setTitle(C.cGreenB + "Archer's Bane") .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) - .build(), 400) + .build(), 100) .addEffects( new MobaSpeedEffect(0.04) ), -// new MobaItem(new ItemBuilder(Material.IRON_BOOTS) -// .setTitle(C.cYellowB + "Superior Archer's Bane") -// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) -// .build(), 750) -// .addEffects( -// new MobaSpeedEffect(0.06) -// ), + new MobaItem(new ItemBuilder(Material.IRON_BOOTS) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 300) + .addEffects( + new MobaSpeedEffect(0.06) + ), new MobaItem(new ItemBuilder(Material.IRON_BOOTS) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) - .build(), 400) + .build(), 300) .addEffects( new MobaSpeedEffect(0.04) ), @@ -182,7 +182,7 @@ public class MobaWarriorShop extends MobaShopMenu // ), new MobaItem(new ItemBuilder(Material.DIAMOND_BOOTS) .setTitle(C.cDRedB + "Prince's Plate") - .build(), 2000) + .build(), 1200) .addEffects( new MobaSpeedEffect(0.1) ) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index efb13fcb6..6aaf95375 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -33,6 +33,7 @@ public class Tower { private static final int DAMAGE = 3; + private static final double HEALING = 2.6; private static final int TARGET_RANGE = 10; public static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); @@ -79,10 +80,7 @@ public class Tower _guardian = new DisguiseGuardian(_stand); _host.getArcadeManager().GetDisguise().disguise(_guardian); - if (!_firstTower) - { - _guardian.setElder(true); - } + //_guardian.setElder(!_firstTower); _guardian.setCustomNameVisible(true); @@ -135,6 +133,24 @@ public class Tower _host.getArcadeManager().GetDamage().NewDamageEvent(_target, null, null, DamageCause.CUSTOM, _damage++, false, true, false, "Tower", "Tower"); } + public void updateHealing() + { + if (_dead) + { + return; + } + + for (Player player : _team.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player) || UtilMath.offsetSquared(player, _crystal) > TARGET_RANGE_SQUARED) + { + continue; + } + + MobaUtil.heal(player, null, HEALING); + } + } + private void setLaserTarget(LivingEntity target) { if (target == null) @@ -199,7 +215,6 @@ public class Tower { player.playSound(player.getLocation(), Sound.ANVIL_LAND, 1, 0.5F); player.sendMessage(F.main("Game", "Your Tower is under attack!")); - //UtilTextMiddle.display("", _team.GetColor() + "Your Tower is under attack!", 0, 30, 10, player); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index eaa2f4626..28da828f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -144,6 +144,13 @@ public class TowerManager implements Listener tower.updateDamage(); } } + else if (event.getType() == UpdateType.SLOW) + { + for (Tower tower : _towers) + { + tower.updateHealing(); + } + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index 439390385..59b4c33c2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.training; import mineplex.core.common.Rank; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilTime; @@ -25,16 +26,20 @@ import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.entity.Villager; import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.List; @@ -108,8 +113,7 @@ public class MobaTraining extends Moba private Location _borderA; private Location _borderB; - private Location _selectKit; - private LivingEntity _selectKitEntity; + private List _selectKit; private final Map _entities = new HashMap<>(); @@ -129,8 +133,6 @@ public class MobaTraining extends Moba // Prevent the wither from being damaged as well as to not spawn the pumpkin king _boss.setDummyBosses(true); _overtimeManager.disableOvertime(); - - // Disable minions _minion.disableMinions(); Function safeFunction = player -> UtilAlg.inBoundingBox(player.getLocation(), _borderA, _borderB); @@ -243,13 +245,13 @@ public class MobaTraining extends Moba { super.ParseData(); - List locations = WorldData.GetDataLocs("BROWN"); + List locations = WorldData.GetCustomLocs("PVP_AREA"); _borderA = locations.get(0); _borderB = locations.get(1); - _selectKit = WorldData.GetCustomLocs("SELECT_KIT").get(0); - SpectatorSpawn = _selectKit; + _selectKit = WorldData.GetCustomLocs("SELECT_KIT"); + SpectatorSpawn = _selectKit.get(0); } @EventHandler @@ -262,12 +264,12 @@ public class MobaTraining extends Moba for (Location location : GetTeam(ChatColor.YELLOW).GetSpawns()) { - location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _selectKit))); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, SpectatorSpawn))); } for (Location location : GetTeam(ChatColor.GRAY).GetSpawns()) { - location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _selectKit))); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, SpectatorSpawn))); } Location center = WorldData.GetCustomLocs("CENTER").get(0); @@ -318,6 +320,15 @@ public class MobaTraining extends Moba } } + @Override + public void SetKit(Player player, Kit kit, boolean announce) + { + super.SetKit(player, kit, announce); + + player.setFlying(false); + player.setAllowFlight(false); + } + @EventHandler public void giveGold(UpdateEvent event) { @@ -336,7 +347,7 @@ public class MobaTraining extends Moba } @EventHandler - public void plaeyrJoin(PlayerJoinEvent event) + public void playerJoin(PlayerJoinEvent event) { if (InProgress()) { @@ -361,9 +372,11 @@ public class MobaTraining extends Moba for (LivingEntity entity : _entities.keySet()) { entity.setCustomNameVisible(true); + entity.setRemoveWhenFarAway(false); UtilEnt.vegetate(entity); UtilEnt.setFakeHead(entity, true); UtilEnt.silence(entity, true); + UtilEnt.ghost(entity, true, false); } CreatureAllowOverride = false; @@ -379,16 +392,29 @@ public class MobaTraining extends Moba event.SetCancelled("NPC"); - if (_selectKitEntity != null && _selectKitEntity.equals(event.GetDamageeEntity())) + String name = event.GetDamageeEntity().getCustomName(); + + if (name != null && name.contains("Select A Hero")) { openMenu(event.GetDamagerPlayer(false)); } } + @EventHandler + public void entityCombust(EntityCombustEvent event) + { + if (!_entities.containsKey(event.getEntity())) + { + return; + } + + event.setCancelled(true); + } + @EventHandler public void entityInteract(PlayerInteractAtEntityEvent event) { - if (_selectKitEntity != null && event.getRightClicked().equals(_selectKitEntity)) + if (isKitSelectionEntity(event.getRightClicked())) { openMenu(event.getPlayer()); } @@ -421,6 +447,11 @@ public class MobaTraining extends Moba new SelectKitMenu(Manager).open(player); } + private boolean isKitSelectionEntity(Entity entity) + { + return entity.getCustomName() != null && entity.getCustomName().contains("Select A Hero"); + } + private void spawnHelpText() { Map locationMap = getLocationStartsWith("HELP"); @@ -441,7 +472,7 @@ public class MobaTraining extends Moba { Skeleton skeleton = UtilVariant.spawnWitherSkeleton(WorldData.GetCustomLocs("PUMPKIN_KING").get(0)); skeleton.setCustomName(C.cDRedB + "Pumpkin King"); - UtilEnt.CreatureLook(skeleton, 90); + skeleton.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); _entities.put(skeleton, skeleton.getLocation()); } @@ -449,11 +480,8 @@ public class MobaTraining extends Moba Location location = WorldData.GetCustomLocs("DUMMY_WITHER").get(0); ArmorStand stand = location.getWorld().spawn(location, ArmorStand.class); - // Reducing the wither's health to 10% gives a shield like effect. stand.setGravity(false); - UtilEnt.setBoundingBox(stand, 3, 5); - DisguiseWither disguise = new DisguiseWither(stand); disguise.setName(C.cAqua + "Blue's Wither"); disguise.setCustomNameVisible(true); @@ -473,12 +501,14 @@ public class MobaTraining extends Moba private void spawnNPCs() { - Villager villager = WorldData.World.spawn(_selectKit, Villager.class); - villager.setCustomName(C.cYellowB + "Select A Hero"); - UtilEnt.CreatureLook(villager, GetTeam(ChatColor.YELLOW).GetSpawns().get(0)); + for (Location location : _selectKit) + { + Villager villager = WorldData.World.spawn(location, Villager.class); + villager.setCustomName(C.cYellowB + "Select A Hero"); + UtilEnt.CreatureLook(villager, GetTeam(ChatColor.YELLOW).GetSpawns().get(0)); - _entities.put(villager, villager.getLocation()); - _selectKitEntity = villager; + _entities.put(villager, villager.getLocation()); + } } public void teleportIntoArena(Player player, HeroKit kit) @@ -493,4 +523,15 @@ public class MobaTraining extends Moba SetPlayerTeam(player, GetTeam(ChatColor.YELLOW), true); SetKit(player, kit, true); } + + @EventHandler + public void informLobbyPlayers(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC_20 || InProgress()) + { + return; + } + + Announce(F.main("Game", "Waiting for more players before starting the training area."), false); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 76721ad08..0a56168fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -137,16 +137,21 @@ public class MobaUtil } public static String getHealthBar(LivingEntity entity, double newHealth, int bars) + { + return getProgressBar(newHealth, entity.getMaxHealth(), bars); + } + + public static String getProgressBar(double value, double max, int bars) { StringBuilder out = new StringBuilder(); - double health = newHealth / entity.getMaxHealth(); - String colour = getColour(health); + double progress = value / max; + String colour = getColour(progress); for (int i = 0; i < bars; i++) { double cur = i * (1D / (double) bars); - if (cur < health) + if (cur < progress) { out.append(colour).append("|"); } @@ -159,6 +164,33 @@ public class MobaUtil return out.toString(); } + public static String getProgressBar(double valueA, double valueB, double max, int bars) + { + StringBuilder out = new StringBuilder(); + double progressA = valueA / max; + double progressB = valueB / max; + + for (int i = 0; i < bars; i++) + { + double cur = i * (1D / (double) bars); + + if (cur < progressA) + { + out.append(C.cAqua).append("|"); + } + else if (cur < progressB) + { + out.append(C.cGreen).append("|"); + } + else + { + out.append(C.cGray).append("|"); + } + } + + return out.toString(); + } + public static String getColour(double percentage) { if (percentage < 0.25) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java index e7f509b4e..063a76d36 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java @@ -71,6 +71,7 @@ import nautilus.game.arcade.game.games.paintball.kits.KitMachineGun; import nautilus.game.arcade.game.games.paintball.kits.KitRifle; import nautilus.game.arcade.game.games.paintball.kits.KitShotgun; import nautilus.game.arcade.game.games.paintball.kits.KitSniper; +import nautilus.game.arcade.game.games.paintball.quests.ReviveQuestTracker; import nautilus.game.arcade.game.games.paintball.trackers.KillingSpreeTracker; import nautilus.game.arcade.game.games.paintball.trackers.LastStandStatTracker; import nautilus.game.arcade.game.games.paintball.trackers.MedicStatTracker; @@ -125,6 +126,8 @@ public class Paintball extends TeamGame DamageTaken, DamageDealt ); + + registerQuestTrackers(new ReviveQuestTracker(this)); new CompassModule() .setGiveCompass(true) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/quests/ReviveQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/quests/ReviveQuestTracker.java new file mode 100644 index 000000000..400515b3a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/quests/ReviveQuestTracker.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.paintball.quests; + +import org.bukkit.event.EventHandler; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.paintball.events.ReviveEvent; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * ReviveQuestTracker + * + * @author xXVevzZXx + */ +public class ReviveQuestTracker extends QuestTracker +{ + + public ReviveQuestTracker(Game game) + { + super(game, TriggerType.COLLECT); + } + + @EventHandler + public void onHit(ReviveEvent event) + { + if (!getGame().IsLive()) + return; + + incrementQuests(event.getPlayer(), 1, "Revive", getGame().GetKit(event.getPlayer()).GetName() + "Kit"); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkEggGun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkEggGun.java index 6162c7276..4d9cf7bd3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkEggGun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkEggGun.java @@ -1,26 +1,12 @@ package nautilus.game.arcade.game.games.smash.perks.chicken; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.Sound; -import org.bukkit.entity.Egg; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -29,6 +15,16 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.smash.perks.SmashPerk; +import org.bukkit.Sound; +import org.bukkit.entity.Egg; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; public class PerkEggGun extends SmashPerk { @@ -148,28 +144,21 @@ public class PerkEggGun extends SmashPerk @EventHandler public void EggHit(CustomDamageEvent event) { - if (event.GetProjectile() == null) + if (event.GetProjectile() == null || !(event.GetProjectile() instanceof Egg)) { return; } - - if (!(event.GetProjectile() instanceof Egg)) - { - return; - } - - if (event.GetDamage() >= _damage) - { - return; - } - - event.SetCancelled("Egg Blaster"); - Egg egg = (Egg) event.GetProjectile(); + Player damager = event.GetDamagerPlayer(true); - // Damage Event - Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), (LivingEntity) egg.getShooter(), egg, DamageCause.PROJECTILE, _damage, true, true, false, UtilEnt.getName((LivingEntity) egg - .getShooter()), GetName()); + if (damager == null || !hasPerk(damager)) + { + return; + } + + event.AddMod("Negate", -event.GetDamage()); + event.AddMod(damager.getName(), "Egg Blaster", _damage, true); + event.SetIgnoreRate(true); UtilAction.zeroVelocity(event.GetDamageeEntity()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java index 186b91746..a69086bd0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java @@ -1,10 +1,5 @@ package nautilus.game.arcade.game.games.speedbuilders; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map.Entry; - import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -32,7 +27,6 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.games.skyfall.quests.RingQuestTracker; import nautilus.game.arcade.game.games.speedbuilders.data.BuildData; import nautilus.game.arcade.game.games.speedbuilders.data.DemolitionData; import nautilus.game.arcade.game.games.speedbuilders.data.MobData; @@ -49,7 +43,6 @@ import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.BlockPlaceStatTracker; import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Effect; @@ -97,6 +90,11 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map.Entry; + public class SpeedBuilders extends SoloGame { private static final String GUARDIAN_NAME = "Gwen the Guardian"; @@ -206,15 +204,6 @@ public class SpeedBuilders extends SoloGame .setGiveCompassToAlive(false) .register(this); } - - @EventHandler - public void onEnd(GameStateChangeEvent event) - { - if (event.GetState() == GameState.End || event.GetState() == GameState.Dead) - { - Manager.getBrandingManager().reset(); - } - } @Override public void ParseData() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java index 304140edd..cfb326659 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java @@ -1,31 +1,5 @@ package nautilus.game.arcade.game.games.survivalgames.modes; -import java.util.HashMap; -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.Chest; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.enchantment.EnchantItemEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerItemConsumeEvent; -import org.bukkit.event.player.PlayerItemDamageEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.inventory.meta.ItemMeta; - import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; @@ -36,29 +10,28 @@ import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.loot.RandomItem; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerKitGiveEvent; -import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minestrike.GunModule; -import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; -import nautilus.game.arcade.game.games.minestrike.items.grenades.FlashBang; -import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade; -import nautilus.game.arcade.game.games.minestrike.items.grenades.HighExplosive; -import nautilus.game.arcade.game.games.minestrike.items.grenades.Incendiary; -import nautilus.game.arcade.game.games.minestrike.items.grenades.Molotov; -import nautilus.game.arcade.game.games.minestrike.items.grenades.Smoke; -import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats; -import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; -import nautilus.game.arcade.game.games.minestrike.items.guns.Shotgun; import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames; import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent; import nautilus.game.arcade.game.games.survivalgames.kit.KitLooter; import nautilus.game.arcade.game.games.survivalgames.modes.kit.KitPlayer; +import nautilus.game.arcade.game.modules.StrikeGamesModule; import nautilus.game.arcade.kit.Kit; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Chest; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; /** * StrikeGames @@ -68,12 +41,8 @@ import nautilus.game.arcade.kit.Kit; public class StrikeGames extends SoloSurvivalGames { - private GunModule _gunModule; - private long _peacePhase; private boolean _peace = false; - - private HashMap _helmets; public StrikeGames(ArcadeManager manager) { @@ -83,19 +52,20 @@ public class StrikeGames extends SoloSurvivalGames }, GameType.StrikeGames); Damage = false; - - _helmets = new HashMap<>(); - + _peacePhase = 20000; HungerSet = 20; - _gunModule = new GunModule(this); - _gunModule.EnableCleaning = false; - _gunModule.EnableDrop = false; - _gunModule.EnablePickup = false; - _gunModule.BlockRegeneration = false; - _gunModule.EnableNormalArmor = true; + GunModule gunModule = new GunModule(this); + gunModule.EnableCleaning = false; + gunModule.EnableDrop = false; + gunModule.EnablePickup = false; + gunModule.BlockRegeneration = false; + gunModule.EnableNormalArmor = true; + + new StrikeGamesModule(gunModule) + .register(this); } @EventHandler @@ -119,20 +89,6 @@ public class StrikeGames extends SoloSurvivalGames Damage = true; } - @EventHandler - public void eatingGrenades(PlayerItemConsumeEvent event) - { - if (event.getItem().getType() == Material.POTATO_ITEM - || event.getItem().getType() == Material.CARROT_ITEM - || event.getItem().getType() == Material.APPLE - || event.getItem().getType() == Material.PORK - || event.getItem().getType() == Material.GRILLED_PORK) - { - event.setCancelled(true); - } - - } - @EventHandler(priority = EventPriority.LOWEST) public void DeathmatchDamage(UpdateEvent event) { @@ -163,39 +119,6 @@ public class StrikeGames extends SoloSurvivalGames Announce(F.main("Game", "A Peace Phase of " + F.time((_peacePhase/1000) + "") + " seconds has started!")); } - @EventHandler(priority=EventPriority.HIGHEST) - public void addHelmet(PlayerToggleSneakEvent event) - { - if (!IsLive()) - return; - - if (!IsAlive(event.getPlayer())) - return; - - if (_gunModule.getScoped().containsKey(event.getPlayer())) - return; - - if (event.getPlayer().getInventory().getHelmet() != null) - _helmets.put(event.getPlayer(), event.getPlayer().getInventory().getHelmet()); - } - - @EventHandler(priority=EventPriority.HIGHEST) - public void pumpkinDrop(PlayerDeathEvent event) - { - Iterator itemIterator = event.getDrops().iterator(); - while (itemIterator.hasNext()) - { - ItemStack item = itemIterator.next(); - if (item.getType() == Material.PUMPKIN - || item.getType() == Material.PUMPKIN_STEM) - { - itemIterator.remove(); - } - } - if (_helmets.containsKey(event.getEntity())) - event.getDrops().add(_helmets.get(event.getEntity())); - } - @EventHandler public void disableCrafting(PlayerInteractEvent event) { @@ -205,13 +128,6 @@ public class StrikeGames extends SoloSurvivalGames if (event.getClickedBlock().getType() == Material.WORKBENCH) event.setCancelled(true); } - - @EventHandler - public void weaponEnchantment(EnchantItemEvent event) - { - if (!UtilItem.isArmor(event.getItem())) - event.setCancelled(true); - } public void setupLoot() { @@ -414,131 +330,6 @@ public class StrikeGames extends SoloSurvivalGames getSupplyBlocks().remove(block); } - @EventHandler - public void addEquipment(InventoryClickEvent event) - { - if (event.getCurrentItem() == null) - return; - - if (!(event.getWhoClicked() instanceof Player)) - return; - - Player player = (Player) event.getWhoClicked(); - - if (!(event.getClickedInventory() instanceof PlayerInventory)) - { - ItemStack stack = event.getCurrentItem(); - for (GunStats stat : GunStats.values()) - { - if (stat.getSkin() == stack.getType()) - { - Gun gun = null; - if (stat.getGunType() == GunType.SHOTGUN) - { - gun = new Shotgun(stat, _gunModule); - } - else - { - gun = new Gun(stat, _gunModule); - } - gun.setStack(stack); - gun.updateWeaponName(player, null, false); - gun.addID(); - _gunModule.registerGun(gun, player); - return; - } - } - - Grenade grenade = null; - - if (stack.getType() == Material.APPLE) - { - grenade = new HighExplosive(); - } - else if (stack.getType() == Material.CARROT_ITEM) - { - grenade = new FlashBang(); - } - else if (stack.getType() == Material.POTATO_ITEM) - { - grenade = new Smoke(); - } - else if (stack.getType() == Material.PORK) - { - grenade = new Incendiary(); - } - else if (stack.getType() == Material.GRILLED_PORK) - { - grenade = new Molotov(); - } - - if (grenade != null) - { - ItemMeta meta = stack.getItemMeta(); - meta.setDisplayName(grenade.getName()); - stack.setItemMeta(meta); - grenade.setStack(stack); - _gunModule.registerGrenade(grenade, player); - } - } - } - - @EventHandler - public void triggerPickup(PlayerPickupItemEvent event) - { - - if (!InProgress()) - return; - - if (!IsAlive(event.getPlayer())) - return; - - //Guns - Gun gun = _gunModule.getDroppedGuns().get(event.getItem()); - if (gun != null) - { - _gunModule.deregisterDroppedGun(gun); - _gunModule.registerGun(gun, event.getPlayer()); - gun.setStack(event.getItem().getItemStack()); - } - - //Grenades - Grenade grenade = _gunModule.getDroppedGrenades().get(event.getItem()); - if (grenade != null) - { - _gunModule.deregisterDroppedGrenade(grenade); - _gunModule.registerGrenade(grenade, event.getPlayer()); - grenade.setStack(event.getItem().getItemStack()); - } - } - - @EventHandler - public void triggerDrop(PlayerDropItemEvent event) - { - if (!InProgress()) - return; - - //Guns - Gun gun = _gunModule.getGunInHand(event.getPlayer(), event.getItemDrop().getItemStack()); - if (gun != null) - { - gun.drop(_gunModule, event.getPlayer(), false, false); - event.getItemDrop().remove(); - event.getPlayer().setItemInHand(null); - return; - } - - //Grenades - Grenade grenade = _gunModule.getGrenadeInHand(event.getPlayer(), event.getItemDrop().getItemStack()); - if (grenade != null) - { - grenade.drop(_gunModule, event.getPlayer(), false, false); - event.getItemDrop().remove(); - event.getPlayer().setItemInHand(null); - return; - } - } - @EventHandler @Override public void ItemSpawn(ItemSpawnEvent event) 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 93c2fb37c..8e85f9e16 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 @@ -58,6 +58,7 @@ import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.turfforts.kits.KitInfiltrator; import nautilus.game.arcade.game.games.turfforts.kits.KitMarksman; import nautilus.game.arcade.game.games.turfforts.kits.KitShredder; +import nautilus.game.arcade.game.games.turfforts.quests.BlockBreakQuestTracker; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -171,6 +172,7 @@ public class TurfForts extends TeamGame new ChatStatData("BlocksBroken", "Blocks Broken", true) ); + registerQuestTrackers(new BlockBreakQuestTracker(this)); new CompassModule() .setGiveCompass(true) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/quests/BlockBreakQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/quests/BlockBreakQuestTracker.java new file mode 100644 index 000000000..f15b21e37 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/quests/BlockBreakQuestTracker.java @@ -0,0 +1,33 @@ +package nautilus.game.arcade.game.games.turfforts.quests; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.turfforts.TurfForts; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * BlockBreakQuestTracker + * + * @author xXVevzZXx + */ +public class BlockBreakQuestTracker extends QuestTracker +{ + + public BlockBreakQuestTracker(Game game) + { + super(game, TriggerType.COLLECT); + } + + @EventHandler + public void onHit(TurfForts.ShredBlockEvent event) + { + if (!getGame().IsLive()) + return; + + incrementQuests((Player) event.getArrow().getShooter(), 1, "Block Break", getGame().GetKit((Player) event.getArrow().getShooter()).GetName() + "Kit"); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java index efb25437b..a4ba2f3dc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java @@ -82,6 +82,7 @@ public class CustomScoreboardModule extends Module } setupScoreboard(player); + refreshAsSubject(player); } /** diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/GameStatisticsModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/GameStatisticsModule.java new file mode 100644 index 000000000..8f593f2c0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/GameStatisticsModule.java @@ -0,0 +1,102 @@ +package nautilus.game.arcade.game.modules; + +import mineplex.core.Managers; +import mineplex.core.common.util.UtilServer; +import mineplex.core.stats.event.StatChangeEvent; +import mineplex.core.stats.game.GameStatisticsManager; +import mineplex.core.stats.game.GameStats; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public class GameStatisticsModule extends Module +{ + + private static final GameStatisticsManager STATS_MANAGER; + + static + { + STATS_MANAGER = Managers.require(GameStatisticsManager.class); + } + + private GameStats _currentGame; + private final List _statsToListen; + private final Map _playerId; + + public GameStatisticsModule() + { + _statsToListen = new ArrayList<>(); + _playerId = new HashMap<>(); + } + + public void addStatListener(String stat) + { + _statsToListen.add(stat); + } + + @Override + protected void setup() + { + _currentGame = new GameStats(-1, UtilServer.getRegion(), getGame().GetType().getDisplay()); + } + + @Override + public void cleanup() + { + if (getGame().getArcadeManager().IsRewardStats() && _currentGame.isValid()) + { + STATS_MANAGER.saveGameStats(_currentGame); + } + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + int id = 0; + for (Player player : getGame().GetPlayers(true)) + { + _playerId.put(player.getUniqueId(), ++id); + } + + STATS_MANAGER.getMapId(mapId -> _currentGame.setMapId(mapId), getGame().GetType().getDisplay(), getGame().WorldData.MapName); + _currentGame.setStartTime(System.currentTimeMillis()); + } + + @EventHandler + public void end(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + { + return; + } + + _currentGame.setEndTime(System.currentTimeMillis()); + } + + @EventHandler + public void statChange(StatChangeEvent event) + { + Player player = event.getPlayer(); + String stat = event.getStatName(); + long change = event.getValueAfter() - event.getValueBefore(); + + if (_statsToListen.contains(getGame().GetName() + "." + stat) && _playerId.containsKey(player.getUniqueId())) + { + int playerId = _playerId.get(player.getUniqueId()); + _currentGame.getStats().putIfAbsent(playerId, new HashMap<>()); + _currentGame.getStats().get(playerId).put(stat, change); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/StrikeGamesModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/StrikeGamesModule.java new file mode 100644 index 000000000..a398eba40 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/StrikeGamesModule.java @@ -0,0 +1,220 @@ +package nautilus.game.arcade.game.modules; + +import mineplex.core.common.util.UtilItem; +import nautilus.game.arcade.game.games.minestrike.GunModule; +import nautilus.game.arcade.game.games.minestrike.items.grenades.FlashBang; +import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade; +import nautilus.game.arcade.game.games.minestrike.items.grenades.HighExplosive; +import nautilus.game.arcade.game.games.minestrike.items.grenades.Incendiary; +import nautilus.game.arcade.game.games.minestrike.items.grenades.Molotov; +import nautilus.game.arcade.game.games.minestrike.items.grenades.Smoke; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; +import nautilus.game.arcade.game.games.minestrike.items.guns.Shotgun; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.enchantment.EnchantItemEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.HashMap; +import java.util.Map; + +public class StrikeGamesModule extends Module +{ + + private final Map _helmets; + private final GunModule _gunModule; + + public StrikeGamesModule(GunModule gunModule) + { + _gunModule = gunModule; + _helmets = new HashMap<>(); + } + + @EventHandler + public void eatingGrenades(PlayerItemConsumeEvent event) + { + Material material = event.getItem().getType(); + + switch (material) + { + case POTATO_ITEM: + case CARROT_ITEM: + case APPLE: + case PORK: + case GRILLED_PORK: + event.setCancelled(true); + break; + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void addHelmet(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + ItemStack helmet = player.getInventory().getHelmet(); + + if (!getGame().IsLive() || !getGame().IsAlive(player) || _gunModule.getScoped().containsKey(player) || helmet == null) + { + return; + } + + _helmets.put(event.getPlayer(), helmet); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void pumpkinDrop(PlayerDeathEvent event) + { + Player player = event.getEntity(); + + event.getDrops().removeIf(item -> item.getType() == Material.PUMPKIN || item.getType() == Material.PUMPKIN_STEM); + + if (_helmets.containsKey(player)) + { + event.getDrops().add(_helmets.get(player)); + } + } + + @EventHandler + public void weaponEnchantment(EnchantItemEvent event) + { + if (!UtilItem.isArmor(event.getItem())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void addEquipment(InventoryClickEvent event) + { + if (event.getCurrentItem() == null || !(event.getWhoClicked() instanceof Player) || event.getClickedInventory() instanceof PlayerInventory) + { + return; + } + + Player player = (Player) event.getWhoClicked(); + ItemStack stack = event.getCurrentItem(); + for (GunStats stat : GunStats.values()) + { + if (stat.getSkin() == stack.getType()) + { + Gun gun; + if (stat.getGunType() == GunType.SHOTGUN) + { + gun = new Shotgun(stat, _gunModule); + } + else + { + gun = new Gun(stat, _gunModule); + } + gun.setStack(stack); + gun.updateWeaponName(player, null, false); + gun.addID(); + _gunModule.registerGun(gun, player); + return; + } + } + + Grenade grenade = null; + + switch (stack.getType()) + { + case APPLE: + grenade = new HighExplosive(); + break; + case CARROT_ITEM: + grenade = new FlashBang(); + break; + case POTATO_ITEM: + grenade = new Smoke(); + break; + case PORK: + grenade = new Incendiary(); + break; + case GRILLED_PORK: + grenade = new Molotov(); + break; + } + + if (grenade == null) + { + return; + } + + ItemMeta meta = stack.getItemMeta(); + meta.setDisplayName(grenade.getName()); + stack.setItemMeta(meta); + grenade.setStack(stack); + _gunModule.registerGrenade(grenade, player); + } + + @EventHandler + public void triggerPickup(PlayerPickupItemEvent event) + { + if (!getGame().InProgress() || !getGame().IsAlive(event.getPlayer())) + { + return; + } + + //Guns + Gun gun = _gunModule.getDroppedGuns().get(event.getItem()); + if (gun != null) + { + _gunModule.deregisterDroppedGun(gun); + _gunModule.registerGun(gun, event.getPlayer()); + gun.setStack(event.getItem().getItemStack()); + } + + //Grenades + Grenade grenade = _gunModule.getDroppedGrenades().get(event.getItem()); + if (grenade != null) + { + _gunModule.deregisterDroppedGrenade(grenade); + _gunModule.registerGrenade(grenade, event.getPlayer()); + grenade.setStack(event.getItem().getItemStack()); + } + } + + @EventHandler + public void triggerDrop(PlayerDropItemEvent event) + { + if (!getGame().InProgress()) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = event.getItemDrop().getItemStack(); + + //Guns + Gun gun = _gunModule.getGunInHand(player, itemStack); + + if (gun != null) + { + gun.drop(_gunModule, player, false, false); + event.getItemDrop().remove(); + player.setItemInHand(null); + return; + } + + //Grenades + Grenade grenade = _gunModule.getGrenadeInHand(player, itemStack); + if (grenade != null) + { + grenade.drop(_gunModule, player, false, false); + event.getItemDrop().remove(); + player.setItemInHand(null); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java index 15f877ec2..0dd6008c7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java @@ -166,6 +166,11 @@ public class TrainingGameModule extends Module @EventHandler(priority = EventPriority.MONITOR) public void playerJoin(PlayerJoinEvent event) { + if (!getGame().InProgress()) + { + return; + } + Player player = event.getPlayer(); if (UtilPlayer.isSpectator(player)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/WorldBorderModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/WorldBorderModule.java deleted file mode 100644 index 6a1f13bae..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/WorldBorderModule.java +++ /dev/null @@ -1,116 +0,0 @@ -package nautilus.game.arcade.game.modules; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -import mineplex.core.common.Pair; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.packethandler.IPacketHandler; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.packethandler.PacketInfo; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game.GameState; -import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder; -import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder.EnumWorldBorderAction; -import net.minecraft.server.v1_8_R3.WorldBorder; - -public class WorldBorderModule extends Module implements IPacketHandler -{ - - private PacketHandler _packetHandler; - private Map _sizeToSet; - private Map> _centerToSet; - - @Override - protected void setup() - { - _packetHandler = getGame().getArcadeManager().getPacketHandler(); - _sizeToSet = new HashMap<>(); - _centerToSet = new HashMap<>(); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void live(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - { - return; - } - - _packetHandler.addPacketHandler(this, PacketPlayOutWorldBorder.class); - } - - @Override - public void handle(PacketInfo packetInfo) - { - UUID player = packetInfo.getPlayer().getUniqueId(); - PacketPlayOutWorldBorder packet = (PacketPlayOutWorldBorder) packetInfo.getPacket(); - - try - { - Field actionField = packet.getClass().getDeclaredField("a"); - actionField.setAccessible(true); - EnumWorldBorderAction action = (EnumWorldBorderAction) actionField.get(packet); - - if (action == EnumWorldBorderAction.SET_SIZE) - { - Field sizeField = packet.getClass().getDeclaredField("e"); - sizeField.setAccessible(true); - double newSize = _sizeToSet.get(player); - - sizeField.set(packet, newSize); - } - else if (action == EnumWorldBorderAction.SET_CENTER) - { - Field xField = packet.getClass().getDeclaredField("c"); - Field zField = packet.getClass().getDeclaredField("d"); - - xField.setAccessible(true); - zField.setAccessible(true); - - Pair pair = _centerToSet.get(player); - - xField.set(packet, pair.getLeft()); - zField.set(packet, pair.getRight()); - } - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - @Override - public void cleanup() - { - _packetHandler.removePacketHandler(this); - } - - public void setSize(Player player, double size) - { - _sizeToSet.put(player.getUniqueId(), size); - - sendPacket(player, EnumWorldBorderAction.SET_SIZE); - } - - public void setCenter(Player player, Location location) - { - _centerToSet.put(player.getUniqueId(), Pair.create(location.getX(), location.getZ())); - - sendPacket(player, EnumWorldBorderAction.SET_CENTER); - } - - private void sendPacket(Player player, EnumWorldBorderAction action) - { - WorldBorder border = ((CraftWorld) player.getWorld()).getHandle().getWorldBorder(); - UtilPlayer.sendPacket(player, new PacketPlayOutWorldBorder(border, action)); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootItem.java new file mode 100644 index 000000000..a86370368 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootItem.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.modules.chest; + +import mineplex.core.common.util.UtilMath; +import org.bukkit.inventory.ItemStack; + +public class ChestLootItem +{ + + private ItemStack _item; + private int _lowestAmount, _highestAmount; + private double _rarity; + + public ChestLootItem(ItemStack item, int lowestAmount, int highestAmount, double rarity) + { + _item = item; + _lowestAmount = lowestAmount; + _highestAmount = highestAmount; + _rarity = rarity; + } + + public ItemStack getItem() + { + ItemStack itemStack = _item.clone(); + + if (_lowestAmount != _highestAmount) + { + itemStack.setAmount(UtilMath.rRange(_lowestAmount, _highestAmount)); + } + + return itemStack; + } + + public double getProbability() + { + return _rarity; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootModule.java new file mode 100644 index 000000000..05c309d65 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootModule.java @@ -0,0 +1,337 @@ +package nautilus.game.arcade.game.modules.chest; + +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.modules.Module; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Chest; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerInteractEvent; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +public class ChestLootModule extends Module +{ + + private static final BlockFace[] FACES = { + BlockFace.NORTH, + BlockFace.SOUTH, + BlockFace.WEST, + BlockFace.EAST + }; + + private final Map> _chests; + + private long _destroyAfterOpened; + private boolean _autoRotateChests = true; + private boolean _spawnNearby; + private int _spawnNearbyRadius = 8; + + public ChestLootModule() + { + _chests = new HashMap<>(); + } + + public ChestLootModule registerChestType(String name, List chestLocations, ChestLootPool... pools) + { + return registerChestType(name, chestLocations, 1, pools); + } + + public ChestLootModule registerChestType(String name, List chestLocations, double spawnChance, ChestLootPool... pools) + { + _chests.put(new ChestType(name, chestLocations, spawnChance, pools), new HashSet<>()); + return this; + } + + public ChestLootModule destroyAfterOpened(int seconds) + { + _destroyAfterOpened = TimeUnit.SECONDS.toMillis(seconds); + return this; + } + + public ChestLootModule autoRotateChests(boolean autoRotate) + { + _autoRotateChests = autoRotate; + return this; + } + + public ChestLootModule spawnNearbyDataPoints() + { + _spawnNearby = true; + return this; + } + + public ChestLootModule spawnNearbyDataPoints(int radius) + { + _spawnNearby = true; + _spawnNearbyRadius = radius; + return this; + } + + public void addChestLocation(String typeName, Location location) + { + for (Entry> entry : _chests.entrySet()) + { + if (!entry.getKey().Name.equals(typeName)) + { + continue; + } + + entry.getValue().add(new ChestMetadata(location.getBlock(), entry.getKey())); + return; + } + } + + public void refill() + { + _chests.forEach((type, metadataSet) -> metadataSet.forEach(metadata -> metadata.Opened = false)); + } + + public void refill(String typeName) + { + _chests.forEach((type, metadataSet) -> + { + if (!type.Name.equals(typeName)) + { + return; + } + + metadataSet.forEach(metadata -> metadata.Opened = false); + }); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void populateChests(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (Entry> entry : _chests.entrySet()) + { + ChestType chestType = entry.getKey(); + + if (chestType.ChestSpawns == null) + { + continue; + } + + Set metadataSet = entry.getValue(); + + for (Location location : chestType.ChestSpawns) + { + if (chestType.SpawnChance == 1 || Math.random() < chestType.SpawnChance) + { + Block block = location.getBlock(); + + if (_spawnNearby) + { + Location nearby = getNearbyLocation(location); + + if (nearby == null) + { + continue; + } + + block = nearby.getBlock(); + } + + block.setType(Material.CHEST); + + if (_autoRotateChests) + { + for (BlockFace face : FACES) + { + if (UtilBlock.airFoliage(block.getRelative(face))) + { + block.setData(getData(face)); + break; + } + } + } + + ChestMetadata metadata = new ChestMetadata(block, chestType); + metadataSet.add(metadata); + } + } + + _chests.put(chestType, metadataSet); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void openChest(PlayerInteractEvent event) + { + Block block = event.getClickedBlock(); + + if (event.isCancelled() || !UtilEvent.isAction(event, ActionType.R_BLOCK) || block == null || !(block.getState() instanceof Chest)) + { + return; + } + + ChestMetadata metadata = getFromBlock(block); + + if (metadata == null || metadata.Opened) + { + return; + } + + metadata.Opened = true; + metadata.OpenedAt = System.currentTimeMillis(); + metadata.populateChest((Chest) block.getState()); + } + + @EventHandler + public void destroyOpenedChests(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || _destroyAfterOpened == 0) + { + return; + } + + for (Set metadataSet : _chests.values()) + { + metadataSet.removeIf(metadata -> + { + if (metadata.Opened && UtilTime.elapsed(metadata.OpenedAt, _destroyAfterOpened)) + { + Block block = metadata.Chest; + Location location = block.getLocation(); + location.getWorld().playEffect(location.add(0.5, 0.5, 0.5), Effect.STEP_SOUND, block.getType()); + ((Chest) block.getState()).getBlockInventory().clear(); + MapUtil.QuickChangeBlockAt(location, Material.AIR); + return true; + } + + return false; + }); + } + } + + private ChestMetadata getFromBlock(Block block) + { + Location blockLocation = block.getLocation(); + + for (Set metadataSet : _chests.values()) + { + for (ChestMetadata metadata : metadataSet) + { + if (UtilMath.offsetSquared(blockLocation, metadata.Chest.getLocation()) < 4) + { + return metadata; + } + } + } + + return null; + } + + private byte getData(BlockFace face) + { + switch (face) + { + case NORTH: + return 0; + case SOUTH: + return 3; + case WEST: + return 4; + case EAST: + return 5; + } + + return 0; + } + + private Location getNearbyLocation(Location center) + { + int attempts = 0; + while (attempts++ < 20) + { + Location newLocation = UtilAlg.getRandomLocation(center, _spawnNearbyRadius, 1, _spawnNearbyRadius); + + if (isSuitable(newLocation.getBlock())) + { + return newLocation; + } + } + + return null; + } + + private boolean isSuitable(Block block) + { + Block up = block.getRelative(BlockFace.UP); + Block down = block.getRelative(BlockFace.DOWN); + + return block.getType() == Material.AIR && up.getType() == Material.AIR && down.getType() != Material.AIR && !UtilBlock.liquid(down) && !UtilBlock.liquid(up) && !UtilBlock.liquid(block); + } + + private class ChestMetadata + { + + Block Chest; + ChestType Type; + long OpenedAt; + boolean Opened; + + ChestMetadata(Block chest, ChestType type) + { + Chest = chest; + Type = type; + } + + void populateChest(Chest chest) + { + chest.getBlockInventory().clear(); + + for (ChestLootPool pool : Type.Pools) + { + if (pool.getProbability() == 1 || Math.random() < pool.getProbability()) + { + pool.populateChest(chest); + } + } + } + } + + private class ChestType + { + String Name; + double SpawnChance; + List Pools; + List ChestSpawns; + + ChestType(String name, List chestLocations, double spawnChance, ChestLootPool... pools) + { + Name = name; + SpawnChance = spawnChance; + Pools = Arrays.asList(pools); + ChestSpawns = chestLocations; + } + } + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootPool.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootPool.java new file mode 100644 index 000000000..8683a66c0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootPool.java @@ -0,0 +1,107 @@ +package nautilus.game.arcade.game.modules.chest; + +import mineplex.core.common.util.UtilMath; +import org.bukkit.block.Chest; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +public class ChestLootPool +{ + + private List _items; + private int _minimumPerChest; + private int _maximumPerChest; + private double _rarity; + + public ChestLootPool() + { + _items = new ArrayList<>(); + _minimumPerChest = 1; + _maximumPerChest = 1; + _rarity = 1; + } + + public ChestLootPool addItem(ItemStack itemStack) + { + return addItem(itemStack, itemStack.getAmount(), itemStack.getAmount(), 1); + } + + public ChestLootPool addItem(ItemStack itemStack, double rarity) + { + return addItem(itemStack, itemStack.getAmount(), itemStack.getAmount(), rarity); + } + + public ChestLootPool addItem(ItemStack itemStack, int lowestAmount, int highestAmount) + { + return addItem(itemStack, lowestAmount, highestAmount, 1); + } + + public ChestLootPool addItem(ItemStack itemStack, int lowestAmount, int highestAmount, double rarity) + { + _items.add(new ChestLootItem(itemStack, lowestAmount, highestAmount, rarity)); + return this; + } + + public ChestLootPool setAmountsPerChest(int minimumPerChest, int maximumPerChest) + { + _minimumPerChest = minimumPerChest; + _maximumPerChest = maximumPerChest; + return this; + } + + public ChestLootPool setProbability(double probability) + { + _rarity = probability; + return this; + } + + public void populateChest(Chest chest) + { + Inventory inventory = chest.getBlockInventory(); + + for (int i = 0; i < UtilMath.rRange(_minimumPerChest, _maximumPerChest); i++) + { + int slot = UtilMath.r(inventory.getSize()); + ChestLootItem item = getRandomItem(); + + if (item == null) + { + continue; + } + + inventory.setItem(slot, item.getItem()); + } + + chest.update(); + } + + private ChestLootItem getRandomItem() + { + double totalWeight = 0; + + for (ChestLootItem item : _items) + { + totalWeight += item.getProbability(); + } + + double select = Math.random() * totalWeight; + + for (ChestLootItem item : _items) + { + if ((select -= item.getProbability()) <= 0) + { + return item; + } + } + + return null; + } + + public double getProbability() + { + return _rarity; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index a2819e252..ce46fb56a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -1096,9 +1096,14 @@ public class GameFlagManager implements Listener return; } - if (game.WorldWaterDamage <= 0 && !game.WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty()) + if (game.WorldWaterDamage <= 0) { - game.WorldWaterDamage = 4; + if (!game.WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty()) + { + game.WorldWaterDamage = 4; + } + + return; } for (Player player : game.GetPlayers(true)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index f046626b4..0867fb6cc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.managers; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.stream.Stream; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -22,6 +23,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.Plugin; import mineplex.core.Managers; +import mineplex.core.antihack.AntiHack; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -40,14 +42,17 @@ import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.gui.privateServer.PrivateServerShop; import nautilus.game.arcade.gui.privateServer.page.GameVotingPage; public class GameHostManager implements Listener { + private final AntiHack _antiHack; private ArrayList ultraGames = new ArrayList(); private ArrayList heroGames = new ArrayList(); private ArrayList legendGames = new ArrayList(); @@ -79,6 +84,7 @@ public class GameHostManager implements Listener public GameHostManager(ArcadeManager manager) { + _antiHack = Managers.require(AntiHack.class); Manager = manager; _shop = new PrivateServerShop(manager, manager.GetClients(), manager.GetDonation()); Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); @@ -160,6 +166,18 @@ public class GameHostManager implements Listener return games; } + @EventHandler + public void onStateChange(GameStateChangeEvent event) + { + if (!isEventServer()) + { + return; + } + + // Disable all checks in event servers + Stream.concat(AntiHack.ACTIONS.keySet().stream(), AntiHack.CHECKS.keySet().stream()).distinct().forEach(_antiHack::addIgnoredCheck); + } + @EventHandler public void updateHost(UpdateEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java index 69e9958d2..17a1cb5d8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java @@ -171,7 +171,7 @@ public class GameChatManager implements Listener event.setFormat(dead + levelStr + rankStr + _manager.GetColor(sender) + senderName + " " + C.cWhite + "%2$s"); //Public/Private (Not If Player Dead) - if (_manager.GetGame() != null && _manager.GetGame().GetState() == GameState.Live) + if (_manager.GetGame() != null && _manager.GetGame().InProgress()) { boolean globalMessage = false; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java index 30cbb77d2..c7a935560 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java @@ -38,6 +38,9 @@ public class ChestOpenQuestTracker extends QuestTracker if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; + if (!getGame().IsAlive(event.getPlayer())) + return; + if (event.getClickedBlock().getType() != Material.CHEST) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java index d8ad07885..9bcc6165e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java @@ -1,18 +1,24 @@ package nautilus.game.arcade.quest; +import java.awt.dnd.DragSourceDropEvent; import java.util.ArrayList; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.block.Chest; import org.bukkit.block.DoubleChest; 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.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -29,7 +35,9 @@ import nautilus.game.arcade.game.Game; public class CollectQuestTracker extends QuestTracker { private ArrayList _itemsAvailable = new ArrayList<>(); + private ArrayList _badItems = new ArrayList<>(); private ArrayList _usedChests = new ArrayList<>(); + private ArrayList _usedBlocks = new ArrayList<>(); public CollectQuestTracker(Game game) { @@ -45,6 +53,71 @@ public class CollectQuestTracker extends QuestTracker _usedChests.clear(); } + @EventHandler(priority=EventPriority.HIGHEST) + public void blockRegister(BlockPlaceEvent event) + { + if (!getGame().IsLive()) + return; + + if (event.isCancelled()) + return; + + if (event.getBlockPlaced().getType() == Material.IRON_ORE + || event.getBlockPlaced().getType() == Material.GOLD_ORE) + { + _usedBlocks.add(event.getBlock().getLocation()); + } + + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void itemRegister(PlayerDropItemEvent event) + { + _badItems.add(event.getItemDrop().getItemStack()); + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void itemRegister(BlockBreakEvent event) + { + if (!getGame().IsLive()) + return; + + if (event.isCancelled()) + return; + + if (!_usedBlocks.contains(event.getBlock().getLocation())) + return; + + for (ItemStack item : event.getBlock().getDrops()) + { + _badItems.add(item); + } + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void itemPickup(PlayerPickupItemEvent event) + { + if (!getGame().IsLive()) + return; + + if (event.isCancelled()) + return; + + ItemStack item = event.getItem().getItemStack(); + + if (_badItems.contains(item)) + { + _badItems.remove(item); + return; + } + String itemName = item.getType().toString(); + + if (item.hasItemMeta()) + itemName = item.getItemMeta().getDisplayName(); + + incrementQuests(event.getPlayer(), item.getAmount(), ChatColor.stripColor(itemName)); + } + @EventHandler(priority=EventPriority.HIGHEST) public void chestRegister(PlayerInteractEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/FirstBloodQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/FirstBloodQuestTracker.java new file mode 100644 index 000000000..22b7f79c4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/FirstBloodQuestTracker.java @@ -0,0 +1,31 @@ +package nautilus.game.arcade.quest; + +import org.bukkit.event.EventHandler; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.events.FirstBloodEvent; +import nautilus.game.arcade.game.Game; + +/** + * FirstBloodQuestTracker + * + * @author xXVevzZXx + */ +public class FirstBloodQuestTracker extends QuestTracker +{ + + public FirstBloodQuestTracker(Game game) + { + super(game, TriggerType.FIRST_BLOOD); + } + + @EventHandler + public void onHit(FirstBloodEvent event) + { + if (!getGame().IsLive()) + return; + + incrementQuests(event.getPlayer(), 1, getGame().GetKit(event.getPlayer()).GetName() + "Kit"); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java new file mode 100644 index 000000000..665657a3d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java @@ -0,0 +1,58 @@ +package nautilus.game.arcade.quest; + +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; + +import mineplex.core.quests.TriggerType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.Game; + +/** + * HitQuestTracker + * + * @author xXVevzZXx + */ +public class HitQuestTracker extends QuestTracker +{ + + public HitQuestTracker(Game game) + { + super(game, TriggerType.HIT); + } + + @EventHandler + public void onHit(EntityDamageByEntityEvent event) + { + if (!getGame().IsLive()) + return; + + if (!(event.getDamager() instanceof Player) || !(event.getEntity() instanceof Item)) + return; + + + Item itemEntity = (Item) event.getEntity(); + String item = itemEntity.getItemStack().getType().toString(); + + incrementQuests((Player) event.getDamager(), 1, "Player", item, getGame().GetKit((Player) event.getDamager()).GetName() + "Kit"); + } + + @EventHandler + public void onProjectileHit(CustomDamageEvent event) + { + if (!getGame().IsLive()) + return; + + if (event.GetReason() == null) + return; + + if (!event.GetReason().contains("Axe Thrower")) + return; + + System.out.println("Test2"); + + incrementQuests(event.GetDamagerPlayer(true), 1, "Player", "Axe", getGame().GetKit(event.GetDamagerPlayer(true)).GetName() + "Kit"); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java index c34a50efc..d615bcd9d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java @@ -42,6 +42,9 @@ public class QuestTracker implements Listener public void incrementQuests(Player player, int value, String... items) { + if (getGame().getArcadeManager().GetGameHostManager().isPrivateServer()) + return; + if (canProgressQuests()) { for (Quest quest : getGame().getArcadeManager().getQuestManager().getAvailableQuests()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java index 61d4b8923..ddaf85fe4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java @@ -1,12 +1,15 @@ package nautilus.game.arcade.stats; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.Game; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.Map; @@ -51,11 +54,6 @@ public class DeathBomberStatTracker extends StatTracker if(killer.equals(killed)) return; - if (killer.getItemInHand().getType() != Material.TNT) - { - return; - } - if (event.GetLog().GetKiller() != null && event.GetLog().GetKiller().GetReason().contains("Throwing TNT")) { Integer count = _killCount.get(killer.getUniqueId()); @@ -70,4 +68,32 @@ public class DeathBomberStatTracker extends StatTracker addStat(killer, "DeathBomber", 1, true, false); } } + + @EventHandler + public void removeFakeThrowingTNT(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (Player player : getGame().GetPlayers(true)) + { + ItemStack[] contents = player.getInventory().getContents(); + int i = 0; + + for (ItemStack itemStack : contents) + { + if (itemStack == null || itemStack.getItemMeta() == null || itemStack.getItemMeta().getDisplayName() == null) + { + continue; + } + + if (itemStack.getItemMeta().getDisplayName().contains("Throwing TNT") && itemStack.getType() != Material.TNT) + { + player.getInventory().setItem(i, null); + } + } + } + } } diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java index ebc01ac9c..4fbb830fa 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java @@ -138,7 +138,7 @@ public class Hub extends JavaPlugin RewardManager rewardManager = new RewardManager(_clientManager, _donationManager, inventoryManager, petManager, gadgetManager, statsManager); TreasureManager treasureManager = new TreasureManager(this, _clientManager, serverStatusManager, _donationManager, inventoryManager, petManager, gadgetManager, blockRestore, hologramManager, statsManager, rewardManager); CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, - mountManager, petManager, treasureManager, boosterManager); + mountManager, petManager, treasureManager, boosterManager, punish); cosmeticManager.setInterfaceSlot(7); cosmeticManager.disableTeamArmor(); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index d4e557763..a010a5ac6 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -1,13 +1,5 @@ package mineplex.gemhunters; -import net.minecraft.server.v1_8_R3.MinecraftServer; - -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.plugin.java.JavaPlugin; -import org.spigotmc.SpigotConfig; - import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; import mineplex.core.account.CoreClientManager; @@ -70,7 +62,6 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.visibility.VisibilityManager; import mineplex.gemhunters.beta.BetaModule; -import mineplex.gemhunters.bounties.BountyModule; import mineplex.gemhunters.chat.ChatModule; import mineplex.gemhunters.death.DeathModule; import mineplex.gemhunters.death.quitnpc.QuitNPCModule; @@ -100,6 +91,12 @@ import mineplex.gemhunters.worldevent.WorldEventModule; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.plugin.java.JavaPlugin; +import org.spigotmc.SpigotConfig; import static mineplex.core.Managers.require; @@ -258,7 +255,7 @@ public class GemHunters extends JavaPlugin GadgetManager gadgetManager = new GadgetManager(this, clientManager, donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager); ThankManager thankManager = new ThankManager(this, clientManager, donationManager); BoosterManager boosterManager = new BoosterManager(this, null, clientManager, donationManager, inventoryManager, thankManager); - CosmeticManager cosmeticManager = new CosmeticManager(this, clientManager, donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager); + CosmeticManager cosmeticManager = new CosmeticManager(this, clientManager, donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager, punish); cosmeticManager.setActive(false); cosmeticManager.setHideParticles(true); @@ -275,7 +272,6 @@ public class GemHunters extends JavaPlugin // Though if any other module needs one of these it will be generated in // order, however they are all here just for good measure. require(BetaModule.class); - require(BountyModule.class); require(CashOutModule.class); require(ChatModule.class); require(DeathModule.class); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/Bounty.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/Bounty.java deleted file mode 100644 index 6e9069d16..000000000 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/Bounty.java +++ /dev/null @@ -1,36 +0,0 @@ -package mineplex.gemhunters.bounties; - -import java.util.UUID; - -import org.bukkit.entity.Player; - -public class Bounty -{ - - private UUID _target; - private UUID _setter; - private int _amount; - - public Bounty(Player target, Player setter, int amount) - { - _target = target.getUniqueId(); - _setter = setter.getUniqueId(); - _amount = amount; - } - - public UUID getTarget() - { - return _target; - } - - public UUID getSetter() - { - return _setter; - } - - public int getAmount() - { - return _amount; - } - -} diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/BountyModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/BountyModule.java deleted file mode 100644 index 771d58997..000000000 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/BountyModule.java +++ /dev/null @@ -1,46 +0,0 @@ -package mineplex.gemhunters.bounties; - -import java.net.MalformedURLException; -import java.net.URL; - -import org.bukkit.block.BlockFace; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; - -import mineplex.core.MiniPlugin; -import mineplex.core.ReflectivelyCreateMiniPlugin; -import mineplex.core.sponsorbranding.BrandingManager; - -@ReflectivelyCreateMiniPlugin -public class BountyModule extends MiniPlugin -{ - - private final BrandingManager _brandingManager; - - private BountyModule() - { - super("Bounty"); - - _brandingManager = require(BrandingManager.class); - } - - //@EventHandler - public void test(PlayerCommandPreprocessEvent event) - { - if (!event.getMessage().startsWith("/want")) - { - return; - } - - try - { - event.setCancelled(true); - _brandingManager.createPost(event.getPlayer().getLocation(), BlockFace.SOUTH, new URL("http://minotar.net/helm/Moppletop.png")); - } - catch (MalformedURLException e) - { - e.printStackTrace(); - } - } - -} diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPC.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPC.java index 0c79be7ef..e3cc6d88e 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPC.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPC.java @@ -1,19 +1,5 @@ package mineplex.gemhunters.death.quitnpc; -import java.util.UUID; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; - import mineplex.core.Managers; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; @@ -26,6 +12,19 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilGameProfile; import mineplex.gemhunters.death.event.QuitNPCDespawnEvent; import mineplex.gemhunters.economy.EconomyModule; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +import java.util.UUID; public class QuitNPC implements Listener { @@ -94,7 +93,6 @@ public class QuitNPC implements Listener return; } - _disguise.undisguise(_disguise.getActiveDisguise(_entity)); _entity.remove(); _hologram.remove(); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCModule.java index 109e1039f..2bc115159 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCModule.java @@ -101,7 +101,7 @@ public class QuitNPCModule extends MiniPlugin { try { - String npcServer = _repo.loadNpcServer(event.getUniqueId()).get(); + String npcServer = _repo.loadNpcServer(event.getUniqueId()).join(); if (npcServer == null || npcServer.isEmpty()) { return; diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java index 6db02ac7f..160e5352c 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java @@ -1,69 +1,52 @@ package mineplex.gemhunters.death.quitnpc; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.util.UUID; import java.util.concurrent.CompletableFuture; import mineplex.core.common.util.UtilServer; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnVarChar; +import mineplex.serverdata.Region; +import mineplex.serverdata.redis.RedisRepository; +import redis.clients.jedis.Jedis; -public class QuitNPCRepository extends RepositoryBase +public class QuitNPCRepository extends RedisRepository { - private static final String GET_DATA = "SELECT serverName FROM gemHuntersQuitNpcs WHERE uuid=?;"; - private static final String INSERT_DATA = "INSERT INTO gemHuntersQuitNpcs (uuid, serverName) VALUES (?, ?);"; - private static final String DELETE_DATA = "DELETE FROM gemHuntersQuitNpcs WHERE uuid=?;"; + private static final String REDIS_KEY_PREFIX = "GemHuntersNPC."; public QuitNPCRepository() { - super(DBPool.getAccount()); + super(Region.ALL); } - + public CompletableFuture loadNpcServer(UUID uuid) { return CompletableFuture.supplyAsync(() -> { - try (Connection conn = getConnection()) + try (Jedis jedis = getResource(false)) { - PreparedStatement stmt = conn.prepareStatement(GET_DATA); - stmt.setString(1, uuid.toString()); - - String serverName = null; - - ResultSet resultSet = stmt.executeQuery(); - if (resultSet.next()) - { - serverName = resultSet.getString("serverName"); - } - - return serverName; - } - catch (Exception e) - { - e.printStackTrace(); - return null; + return jedis.get(getKey(REDIS_KEY_PREFIX + uuid.toString())); } }); } public void deleteNpc(UUID uuid) { - final String uuidStr = uuid.toString(); UtilServer.runAsync(() -> { - executeUpdate(DELETE_DATA, new ColumnVarChar("uuid", uuidStr.length(), uuidStr)); + try (Jedis jedis = getResource(true)) + { + jedis.del(getKey(REDIS_KEY_PREFIX + uuid.toString())); + } }); } - + public void insertNpc(UUID uuid, String serverName) { - final String uuidStr = uuid.toString(); UtilServer.runAsync(() -> { - executeInsert(INSERT_DATA, null, new ColumnVarChar("uuid", uuidStr.length(), uuidStr), new ColumnVarChar("serverName", serverName.length(), serverName)); + try (Jedis jedis = getResource(true)) + { + jedis.setex(getKey(REDIS_KEY_PREFIX + uuid.toString()), 60, serverName); + } }); } } \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/join/JoinModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/join/JoinModule.java index e7bd8f00a..435278517 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/join/JoinModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/join/JoinModule.java @@ -1,12 +1,5 @@ package mineplex.gemhunters.join; -import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; - import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClient; @@ -23,8 +16,14 @@ import mineplex.gemhunters.persistence.PersistenceModule; import mineplex.gemhunters.persistence.PersistenceRepository; import mineplex.gemhunters.quest.QuestModule; import mineplex.gemhunters.spawn.SpawnModule; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; + @ReflectivelyCreateMiniPlugin public class JoinModule extends MiniPlugin { @@ -88,6 +87,7 @@ public class JoinModule extends MiniPlugin } _inventory.resetSlots(player); + _spawn.teleportToSpawn(player); runAsync(() -> { @@ -97,7 +97,7 @@ public class JoinModule extends MiniPlugin { runSync(() -> _spawn.teleportToSpawn(player)); } - }); + }, 40); } private void loseDurability(ItemStack[] items, long time) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java index 9aa42e3ac..07e0afb7c 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java @@ -672,6 +672,10 @@ public class LootModule extends MiniPlugin { for (LootItemReward reward : _itemRewards) { + if (reward.getPlayer() == null) + { + continue; + } if (reward.getPlayer().equals(event.getEntity())) { reward.death(event); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceData.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceData.java index fed987d21..3ab3ed48f 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceData.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceData.java @@ -1,12 +1,14 @@ package mineplex.gemhunters.persistence; import mineplex.gemhunters.quest.QuestPlayerData; +import mineplex.serverdata.Region; import org.bukkit.Location; import org.bukkit.inventory.ItemStack; public class PersistenceData { + private final Region _region; private final int _gems; private final Location _location; private final QuestPlayerData _questData; @@ -19,8 +21,9 @@ public class PersistenceData private final long _saveTime; private final int _cashOutTime; - public PersistenceData(int gems, Location location, QuestPlayerData questData, int health, int maxHealth, int hunger, int slots, ItemStack[] items, ItemStack[] armour, long saveTime, int cashOutTime) + public PersistenceData(Region region, int gems, Location location, QuestPlayerData questData, int health, int maxHealth, int hunger, int slots, ItemStack[] items, ItemStack[] armour, long saveTime, int cashOutTime) { + _region = region; _gems = gems; _location = location; _questData = questData; @@ -34,6 +37,11 @@ public class PersistenceData _cashOutTime = cashOutTime; } + public Region getRegion() + { + return _region; + } + public int getGems() { return _gems; diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceModule.java index 322f25d54..aeaf4da47 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceModule.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import mineplex.core.common.util.UtilServer; +import mineplex.serverdata.Region; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -84,6 +86,7 @@ public class PersistenceModule extends MiniPlugin return; } + Region region = UtilServer.getRegion(); int gems = _economy.Get(player); Location location = player.getLocation(); QuestPlayerData quest = _quest.Get(player); @@ -106,7 +109,7 @@ public class PersistenceModule extends MiniPlugin cashOutTime = (int) rechargeData.GetRemaining(); } - PersistenceData data = new PersistenceData(gems, location, quest, health, maxHealth, hunger, slots, items, armour, saveTime, cashOutTime); + PersistenceData data = new PersistenceData(region, gems, location, quest, health, maxHealth, hunger, slots, items, armour, saveTime, cashOutTime); runAsync(() -> { diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java index cab1e644a..3e9d86782 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java @@ -1,20 +1,5 @@ package mineplex.gemhunters.persistence; -import com.google.gson.Gson; -import mineplex.core.account.CoreClient; -import mineplex.gemhunters.quest.QuestPlayerData; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnInt; -import mineplex.serverdata.database.column.ColumnTimestamp; -import mineplex.serverdata.database.column.ColumnVarChar; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - import java.lang.reflect.Constructor; import java.sql.Timestamp; import java.util.ArrayList; @@ -22,12 +7,31 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import com.google.gson.Gson; + +import mineplex.core.account.CoreClient; +import mineplex.core.common.util.UtilServer; +import mineplex.gemhunters.quest.QuestPlayerData; +import mineplex.serverdata.Region; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnTimestamp; +import mineplex.serverdata.database.column.ColumnVarChar; + public class PersistenceRepository extends RepositoryBase { - private static final String GET_DATA = "SELECT * FROM gemHunters WHERE accountId=?;"; - private static final String INSERT_DATA = "INSERT INTO gemHunters VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; - private static final String UPDATE_DATA = "UPDATE gemHunters SET gems=?,health=?,maxHealth=?,hunger=?,x=?,y=?,z=?,yaw=?,pitch=?,quests=?,slots=?,items=?,armour=?,saveTime=?,cashOutTime=? WHERE accountId=?;"; + private static final String GET_DATA = "SELECT * FROM gemHunters WHERE accountId=? AND region=?;"; + private static final String INSERT_DATA = "INSERT INTO gemHunters (accountId, region, gems, health, maxHealth, hunger, x, y, z, yaw, pitch, quests, slots, items, armour, saveTime, cashOutTime) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; + private static final String UPDATE_DATA = "UPDATE gemHunters SET gems=?,health=?,maxHealth=?,hunger=?,x=?,y=?,z=?,yaw=?,pitch=?,quests=?,slots=?,items=?,armour=?,saveTime=?,cashOutTime=? WHERE accountId=? AND region=?;"; private static final String DELETE_DATA = "DELETE FROM gemHunters WHERE accountId=?;"; private static final Gson GSON; private static final ItemStack AIR = new ItemStack(Material.AIR); @@ -49,6 +53,7 @@ public class PersistenceRepository extends RepositoryBase public void getPersistenceData(Consumer response, CoreClient client) { int accountId = client.getAccountId(); + Region region = UtilServer.getRegion(); executeQuery(GET_DATA, resultSet -> { @@ -111,16 +116,17 @@ public class PersistenceRepository extends RepositoryBase _exists.add(accountId); Location location = new Location(Bukkit.getWorlds().get(0), x, y, z, yaw, pitch); - PersistenceData data = new PersistenceData(gems, location, questData, health, maxHealth, hunger, slots, itemsList.toArray(new ItemStack[0]), armourList.toArray(new ItemStack[0]), saveTime.getTime(), cashOutTime); + PersistenceData data = new PersistenceData(region, gems, location, questData, health, maxHealth, hunger, slots, itemsList.toArray(new ItemStack[0]), armourList.toArray(new ItemStack[0]), saveTime.getTime(), cashOutTime); response.accept(data); } - }, new ColumnInt("accountId", accountId)); + }, new ColumnInt("accountId", accountId), new ColumnVarChar("region", 2, region.toString())); } public void savePersistence(CoreClient client, PersistenceData data) { int accountId = client.getAccountId(); + Region region = data.getRegion(); int gems = data.getGems(); int health = data.getHealth(); int maxHealth = data.getMaxHealth(); @@ -176,13 +182,15 @@ public class PersistenceRepository extends RepositoryBase new ColumnVarChar("armour", 1000, GSON.toJson(armourMap)), new ColumnTimestamp("saveTime", saveTime), new ColumnInt("cashOutTime", cashOutTime), - new ColumnInt("accountId", accountId) + new ColumnInt("accountId", accountId), + new ColumnVarChar("region", 2, region.toString()) ); } else { executeInsert(INSERT_DATA, null, new ColumnInt("accountId", accountId), + new ColumnVarChar("region", 2, region.toString()), new ColumnInt("gems", gems), new ColumnInt("health", health), new ColumnInt("maxHealth", maxHealth),