Merge remote-tracking branch 'refs/remotes/origin/develop' into update/ssm

This commit is contained in:
Sam 2016-10-06 15:03:53 +01:00
commit e5e953a8ab
126 changed files with 3111 additions and 1157 deletions

View File

@ -36,6 +36,19 @@ public class ShapeWings extends ShapeGrid implements CosmeticShape
"000$000000000000$000",
};
public static final String[] SMALL_ANGEL_WING_PATTERN = new String[]
{
"00$0000$00",
"0$#$00$#$0",
"$##$00$##$",
"$###$$###$",
"$########$",
"$########$",
"$##$$$$##$",
"0$#$00$#$0",
"00$0000$00"
};
public static final String[] BUTTERFLY_WING_PATTERN = new String[]
{
"0$$0000000000000000$$0",

View File

@ -57,6 +57,9 @@ public class SkinData
public final static SkinData UNCLE_SAM = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjYxODA0NjY4NTcsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jYzM1YWRmZTQ3ODBjNmU2NTk4YTJlYzk2ZjdhZGQ5ZDc4NjljMjBlZjRmYjEyNjk2NmJhOGFlMDRlOWRhIn19fQ==", "NmJ+hXmvwQlYFYY7YVQWRr11yBbAfJP+jk11SQ91gUUtJJjb4v8RFbNu5UXNCKxYj3BPtldqshG1maNB0NWJRud7ZyAdHc0JMmR1vtHEge9Hhet4fLyyaZ9rZn4BvD9Guqgv9H/mZzUzrft9TIho0Qbu/U++lVsbZXC2GrJDDMyLnYr9C7f+FUnr0z4WvkNcg23SHBOYkOYT95NSdykIka3c3v+/HvSvuwOnMsfVxqLyCZLpo20vamBJ1uK1dmx2+TVGnUPlofFHRdOXOpJc+YmicJvrsQR6a9zlvnTbU4MYClMOKvjLe6aX5Af+n8Gw3oKcm0PuR8CPLyf9kjcmUF6XMiEXAWWJtCgvhCiFV5/mQQH3cQ1kqk4BDLUxMVhG5tzjKLoQQy39cFM32ee+QFjXlzy59meC8jgvPmOVU3GpJ32XWOtaXMCyeJrhz2QVKRLEr2KZgz8Pd8VrHARXVZsNYEasj8z0cHjgSJqTU9kD90CC+4YpvdyRBRqbNQig5KuGCqUHKgflsEsM7YrFRKP5As1LgqYQfqRAMmLSo47eW0onOwchC9wCqqisPlYSuDRt4Mun/KFGqYh1Sghn8/gzu49La8BpwlekjVEoPEcDaIIgnFzOvgmmgMANkoJ3PzhHoHMoXtObe3eSTi+eYp4qAQVzkTxfF3WXY2fui1M=");
public final static SkinData METAL_MAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzM5OTExNTk3OTQsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84ZDdlOGQ3MmI0MzI3MjIzZmI1ZjI5OWViN2NiNTVhMTU4OTM4MGYxMWE2ZDIzYmVmZTQ1OWFjNzg3YWY2YTcifX19", "EYXUVtnqtDhaSjBE313TpxriRtW0X7wNdmVR0ARa9qvE8CtP//AhnNxyKkERue1XIyefrYApzM4DWGzU5ZvzraOXg98p/3PSFW5p0PAp14ud/1uJWoq0FuEiJDn7Qo/+K0cuoCVsAn6Bx8nWexxr0XB8ANq/0vpRZpDOPO+irFFGwF8CPbt+7sh09glaHD9q7CM4JzPXrNjLt+ZkhYt7wEuevCXuOONT50tH0BlmfHajs9ai0IiwEwC3R+o0DooMVdCViuVEKWQfMnBDNHN4ZLwEazAcRiFO4VXOG0k/+dbKfX0EwnnygN0qmHKyhQeuR7PUumaRUMHn7sCvWmvgpNzzJMv4f9Biw2SWSI2gpaxHdCoCfFMjCdal+/BbXue6jCvDYq6yQEu+C9BjB3vT633/mbXZZMCl7bRjBzqG/jfeI1ove9o0oSqc4Nx3aA1cOnRE2iMEE74ChgY/sVk4aRVx+GTxKtyRGSzt2V7AvOVlfJh17FQhT/PkiztJ6L1RFLsFKaxQxyiCPgZSXpQ4Dz0iPonxFZl0FjAluElHYb3zn4Uop9sPBqOIeskVUl9zbdlRb7CgDG8a57YkUfs7ZyzzYYmZyt6t08H/PQr++cflY0kfy9eOBDmf9gtes7FLrHHRTE6GJ1+xAkLi5gNEkEUZKZy2embgI5JzuwCIIY8=");
public final static SkinData OMEGA_CHEST = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzI1MTAzNzAwOTksInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS85MDM2MjNjMmRkMjdhNWM0Y2NlYzY5MWY3NjM0YTNkMzVkNTRiNDg0YjIzNTdhNWQ1ZWFmYmYwNTRkY2NlIn19fQ==", "cQty4zNF2QgzNuVOHTGGX5YVofApKr01KkQ70bO1n+I9nlkc9qqhcigA+uBYdw4THANFsTRwIrskgTS3TTmuaXYmMUoNnj7gr2Gp7D2t7L53QyJJhIw0hHNDvQucf19SOxhtR9FvW+xnh1JcgOTF3VZxIeRaN4bCtqkeFitCJwts4Z7SlDxB4EFZVsifM+gK4iel9YWYGNnZiQm48lxU+dMFd0cCa4L00ngBExQoWC8zbJc3K9LGdqI1YOMh3bCt81F4jcrPnDycxWwOTj/tBri4yeXK1htq5dAixHwq1EF86gQMnfeIIk6D/BREtVKoXK9K4lstYPHLFiBqkwpijArbC0sZp8s/j88NYUz9PgSJ2z/b5jhPChH2OkoGQOL0/QrxqUZUet+WHaIQtvFoqmcFRCKJQembgJGZV0X86XQxEEtevkNgXPigJVyQ5GVuDCeowRkMGfSadQCBsnmdOVZNshS60tBSDcbd2oWeQUJn1+OJkmz+OktbMbP4ttN6x3+MPMSZoGT1bc1BSRNFRYOBZuNz1zLWsHFRyNLaVS3ep/ktE+Rt5sbapo+r4GjrKGV7Unx6pbfoxcnMVxWZ9X/sMgztQdwYEQlnvAxGvCY/1ZIm3/izqB2zAgG7ZfWzKjU2P5VseKokMjHXrzZX9Uqtn0zpITEaG5HjUpRSaJg=");
public final static SkinData HEADLESS_HORSEMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzM4ODc2MjAzODksInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZGM2M2M5NWFjOTA1YjEyMWU5YTE3NmY5ZDFiN2M0MDc2ZGJjMTk3NzhkYjgzMzBlOWIzNTdhOTQ3MzMxZCJ9fX0=", "pQgM6o3nO6+NaxEmkoK33gQefe726HeVA5TVcbnGRY99S8l1UVlTu1W9Unc4IczHRYZ29I75aXUz6UDA7kIRQj4NOQHBXOxlw4cah34WkDECXYwKbgcM3HkRI/JGQf6Uooe5Mz/IaWlisEdXp9i7+WPeqz1qvzwuJ2jUqF8gaJyCbgKSWE8135k+YwinFVA78+so5meRZ6qBNfSeU48Bhf9j3H+Jmq/vwi9EJGDXKAzjYSufdYWQA7gXJQHiUFVgVKSC0wBAMHBVK7ABE2g5GIaLxOfjhOKN8Gdea9dqOUN+uXrGvg7uHxJd9Obw7MbBDVPgXnYDWYDU18DAWJcGVA8tnuPnN2a+mQrbTn9UPftYReUYJA4zpkfEKkljW6lkQ5DkVN/ueQg9QDYjxvjLblSyKHV8lX/ATt4aGiQrCcaQn6c8EeLWijPwozO+pI3MX26ydF8l+B9lTvGvQOqfUS4+TgEI5SEKlKFF4i6rTBAYCHAH8uXry7fZQDoIkcpWiB5b+e7Tr29WoScyFNuR3BMIh0Nky1TPadLxxhkqht8o9AXtccYOmtoMMh06kKWZK5m8w16j+VTUNDYwTV+jxtSFBMh4FPuiH+TzpeHY6P2Cb4gT2UlozWj8ZxZHYIGbYXAFOlDT8IQmRh5zyrXeAZrwoXJPP2OoXl31roChTxw=");
public final static SkinData GHOST = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzM5NjQxOTY3ODYsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84NjViODU3N2NlNmFhYzY4N2IxNGQ0ZGIzYmQ1MGU1NjdlZGY4Njc4MDU3ZWM2NjMyZDcxMDQ4MzFhNDk3MmIifX19", "J3nw3OIZYuYxbhOKgPGL+Kn4kWv9cjEB9ygBD07xVJUY/rdPW/BeE15qKpZQt5d8kjj0VGp1Q7g3uIS24NuiQxDZ82l1GT4dLyUN2eOj0im6VGA2yXrnGPaedfu1oPAiG+STFq0ST2IYQKYuOcncsdovxHLrpNHF6ud3WJMnSOYSfAX5NOny1UNkswzCN2OCX+QzW9hwQ+gKOc2U6g47hIcpBcTNlmD3lqXjP7OTn0Ul3kJG5J3lnwBkPnNI5OV9+oI9OWs/fbTee3pK6UVHjgH2w+fO/0jlRnShw7o1BKv/ILBkWZYuq31YiAMWKRm508SS3+kjqU37t6mqBc9AUcAeKfR4G6UiW18+eRfDPaaSnY2mTBwD3boWHYI7fM7pnPF1LmSxwSa9QSu3wsrYF9ID0QI7vyyrPIeZU/eUXE+WbFZ+Nuo/2LlZMjUmcLWa/SuuPo6lA5zJtgkVc/Rgkph+s/sZnPwgeHTFmCr2VJqgWg+J9dnO/fLPkddgzjoy5uOCAO70E/cwbpqGxKD+0iQU0Vk9TzQnCMAUDtzeoyNkuk204cDSqPKtH5JIoQHa6wFAEgaKZoSETBJMZmKzZhne5pVr+NVkmGHOuZ/uE6JH1F4T+vTeeLSEroPDhrNfwVtrrqBFnI/xijfEHdPmtP9OTSDju7MHnEZu4RS7y6Q=");
public final static SkinData HAUNTED_CHEST = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzUyNTUzOTE3OTcsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9lZWM5MmU4ODNiOGFjODI0MDU5YTk5NGM5NTNjNTQ0NDQ0Yjk3ZWFkZDdhNWFjNGY3ZTZhOTUxOGQ5YTkxMSJ9fX0=", "GqycEQvWoZeXDLAJ6ricUx3coA4Y6AswL0GV1KebetoTkd9XNtkJJ9eUf6ViwpSgmL0H89sdMjghThHKczUEmjaFeNl2Z9cwGnR1WOK3KpD+v8C7f10l2DNd7z8s1clJfkVay/5KkgNMneu+ZStF8mCt+uyOSfZX4toLRBba6ZDaz4RlmcNt3e6h+dCaB/npbrWxddX7YZWsAMEKxmMKrG/Rm1Gx7ZOchmd4l6+pypA3Vrjoc0LVjqDV/TsePiNxV9LWFB7Rc6YGkIyz2+z5m168iLnn4+qMMXOYndwH7RGcTLEJDPRfNjawuPNcRlYZ6bf30S540MQdC0dJbRLu0uT9CAyi1vjxezdKjGJZSiY5WmtWrhkiRRtCMr9fGxBRNxPDdf5bs7IgWClFgafkGFZKZjLlOV8qtlMrPQSduPtGBCM64veJchSMFS6MfxgE2O/+4EZ246ZN1bdV6KiLRDIzFmy9PBn2o6MNtcdFc/G5XdD7aCTwuGD6sbG2T97Aiai56CN1vYsc6yXUfeZafSm6qviXAx3zTEd1aw1oAZLj3PAt0uZRHggsBEKvwPVKsgHsOVFj5vu0BfHFbdaSdhL3GFotk06Ilr5cLxOrTwqoVNp/hiIJ8pu7T0AEWy1pMYD1+RszsTjJ76l305cQ3UHvinjnbXllsFQIIVE899s=");
public final static SkinData WITCH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzM5OTEyMTE1NDQsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS81NDg1ZDZlMTBhNmNmMmY3Mzg2NmZhMGRiNjEzOWQ5NWViZDM0ZGZiMGY0YzAxMmRkM2YzYWYxMWQ5ZjQxYyJ9fX0=", "cojkGLflVWxwnhDXmHMke7crkeA78iUYOWY7H3YvMJFD+VZi9E7vUahLTTx5ELH+PvcaHJerSDmuV+Nasc3K2n6zlXXb0B7RB/ose/kdPxHAIJee7IbZX0iFNDn6irUSOS4wOYF/BwaqG3HmpoSxV52SGMs6kqTer2Rjg3X+XwYFFiDHAR/gwhfXLzrM1iBc171vgu6T+kx65iBHa/YB/V/mj8FSxwM0f5IsLpgAEdxDL9PvEKQWgWeZ1CAqEXlGnjPkd9oGzW0TgDz2MksBbYZ2kmn/S53kK9vCrVB7egZPS4VBtKpq1P7Jeu8rtgjnAKVFQJZ2lMHnVRuvGTd8JKoPHarUPpU2LURUMaCtHzSv9v/4gjkafnDhqxG4TTcr5hxFV+ho72HQchoeaUXzIO+Yo71zrVqkrS0hw6OtgMIBlvaGaEUsFvGiCZePBEiHojO43AKqJcJAVeT2RAzHcAaBAO79ACGjNKw/oj02rOurLha9i+99bKui96Eg7SS/nPchbmu5YQ9nSpkW+JeYXnBzGGzNG4y02VWgz15L718+8161zXobhuK07qlY9i1nipFbEJedqG0cfS+AUzauETFvS9nMtxhtftYPCIxm40GQj6e77asNCAEElGssaUGKO3bjm348+oF9tR/eBOYWJQ8kL46IQLDRoop7UhG4ewY=");
// Comments this out for now, so it doesn't load the player profile

View File

@ -1,5 +1,7 @@
package mineplex.core.common.util;
import java.util.*;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
import org.bukkit.Location;
import org.bukkit.block.Block;
@ -10,15 +12,6 @@ import org.bukkit.entity.Player;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
public class UtilAlg
{
public static TreeSet<String> sortKey(Set<String> toSort)
@ -663,4 +656,27 @@ public class UtilAlg
int z = r.nextInt(radius * 2) - radius;
return center.clone().add(x, y, z);
}
/**
* Gets a random location, with specific radius
* @param center The center location
* @param radiusX The X radius
* @param radiusY The Y radius
* @param radiusZ The Z radius
* @return A random location in that range
*/
public static Location getRandomLocation(Location center, double radiusX, double radiusY, double radiusZ)
{
double minX = radiusX * -1, minY = radiusY * -1, minZ = radiusZ * -1;
double x = minX + (UtilMath.random.nextDouble() * 2 * radiusX);
double y = minY + (UtilMath.random.nextDouble() * 2 * radiusY);
double z = minZ + (UtilMath.random.nextDouble() * 2 * radiusZ);
Location newLocation = center.clone().add((radiusX == 0) ? 0 : x, (radiusY == 0) ? 0 : y, (radiusZ == 0) ? 0 : z);
return newLocation;
}
public static Location getRandomLocation(Location center, double radius)
{
return getRandomLocation(center, radius, radius, radius);
}
}

View File

@ -1,11 +1,11 @@
package mineplex.core.common.util;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.jsonchat.JsonMessage.MessageType;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.jsonchat.JsonMessage.MessageType;
public class UtilTextBottom
{
public static void display(String text, Player... players)
@ -53,4 +53,28 @@ public class UtilTextBottom
display((prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar + (suffix == null ? "" : ChatColor.RESET + " " + suffix), players);
}
/**
* Displays a bottom text progress bar with a specific number of bars
* @param prefix The prefix of the progress bar
* @param suffix The suffix of the progress bar
* @param bars The number of bars to display
* @param filledBars The number of filled bars
* @param players The players who will receive the progress bar
*/
public static void displayProgress(String prefix, String suffix, int bars, int filledBars, Player... players)
{
String progressBar = C.cGreen + "";
for (int i = 0; i < bars; i++)
{
if (i > filledBars - 1)
{
progressBar += C.cRed;
}
progressBar += "";
}
display((prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar + (suffix == null ? "" : ChatColor.RESET + " " + suffix), players);
}
}

View File

@ -1,6 +1,5 @@
package mineplex.core.common.util.particles;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import org.bukkit.Location;
@ -36,6 +35,16 @@ public class ColoredParticle extends ParticleData
UtilParticle.PlayParticle(_particleType, _location, x, _color.getY(), _color.getZ(), 1, 0, viewDist, players);
}
@Override
public void display(int count, UtilParticle.ViewDist viewDist, Player... players)
{
// It's not possible to have colored particles with count, so just repeat it
for (int i = 0; i < count; i++)
{
display(viewDist, players);
}
}
@Override
public void display(UtilParticle.ViewDist viewDist)
{

View File

@ -1,6 +1,6 @@
package mineplex.core.common.util.particles;
import java.awt.*;
import org.bukkit.Color;
public class DustSpellColor extends ParticleColor
{

View File

@ -1,6 +1,6 @@
package mineplex.core.common.util.particles;
import java.awt.*;
import org.bukkit.Color;
public class NoteColor extends ParticleColor
{

View File

@ -1,7 +1,5 @@
package mineplex.core.common.util.particles;
import java.awt.*;
public abstract class ParticleColor
{

View File

@ -17,6 +17,15 @@ public class ParticleData
_location = location;
}
/**
* Displays the particles for all the players with a different ammount
* @param count the ammount of particles
*/
public void display(int count)
{
display(count, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers());
}
/**
* Displays the particles for selected players
* @param viewDist The distance of the particle view
@ -24,7 +33,18 @@ public class ParticleData
*/
public void display(UtilParticle.ViewDist viewDist, Player... players)
{
UtilParticle.PlayParticle(_particleType, _location, 0f, 0f, 0f, 0f, 1, viewDist);
UtilParticle.PlayParticle(_particleType, _location, 0f, 0f, 0f, 0f, 1, viewDist, players);
}
/**
* Displays the particles for the selected players, with a custom amount
* @param count the amount of particles
* @param viewDist the distance of the particle view
* @param players the players that will receive the particle
*/
public void display(int count, UtilParticle.ViewDist viewDist, Player... players)
{
UtilParticle.PlayParticle(_particleType, _location, 0f, 0f, 0f, 0f, count, viewDist, players);
}
/**

View File

@ -161,7 +161,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_repository = new BonusRepository(plugin, this, donationManager);
_clientManager = clientManager;
_donationManager = donationManager;
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager);
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager, donationManager);
System.out.print("VOTIFIER: ");
System.out.print("DONATION MANAGER - > " + _donationManager.toString());
@ -202,7 +202,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_playWireManager = playWireManager;
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, _clientManager);
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, _clientManager, _donationManager);
_voteList = new ArrayList<>();
_voteList.add("http://vote1.mineplex.com");

View File

@ -22,7 +22,7 @@ public class AnimationCommand extends CommandBase<BonusManager>{
public void Execute(Player caller, String[] args)
{
caller = Bukkit.getPlayer(args[0]);
_plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SpinnerFiller, true));
_plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SPINNER_FILLER, true));
if (args.length >= 2)
{

View File

@ -102,16 +102,16 @@ public class SpinGui extends SimpleGui
{
if (i != _stopSpinnerAt + 4)
{
_rewards[i] = rewardManager.nextReward(player, Type.CARL_SPINNER, null, false, RewardType.SpinnerFiller, true);
_rewards[i] = rewardManager.nextReward(player, Type.CARL_SPINNER, null, false, RewardType.SPINNER_FILLER, true);
}
else
{
_rewards[i] = rewardManager.nextReward(player, Type.CARL_SPINNER, null, false, RewardType.SpinnerReal, true);
_rewards[i] = rewardManager.nextReward(player, Type.CARL_SPINNER, null, false, RewardType.SPINNER_REAL, true);
_reward = _rewards[i];
}
}
_reward.giveReward(RewardType.SpinnerReal, getPlayer(), new Callback<RewardData>()
_reward.giveReward(RewardType.SPINNER_REAL, getPlayer(), new Callback<RewardData>()
{
@Override
public void run(RewardData data)

View File

@ -2,10 +2,14 @@ package mineplex.core.bonuses.gui.buttons;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.TextStyle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.util.C;
@ -62,7 +66,7 @@ public class PowerPlayClubButton implements GuiItem
{
_player.closeInventory();
_player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f);
PowerPlayClubRewards.giveAllItems(_player, _donationManager, _inventoryManager, _powerPlayClubRepository);
PowerPlayClubRewards.giveAllItems(_player, _inventoryManager, _powerPlayClubRepository);
}
else
{
@ -88,11 +92,17 @@ public class PowerPlayClubButton implements GuiItem
{
final Material material;
final String itemName;
final List<String> lore;
final List<String> lore = new ArrayList<>();
PowerPlayData cached = _powerPlayClubRepository.getCachedData(_player);
List<YearMonth> unclaimed = cached.getUnclaimedMonths();
Optional<LocalDate> maybeNextClaimDate = cached.getNextClaimDate();
Set<YearMonth> unclaimed = cached.getUnclaimedMonths();
if (!cached.getUsableCosmeticMonths().isEmpty())
{
lore.addAll(buildCosmeticsLore(cached.getUsableCosmeticMonths()));
}
if (!unclaimed.isEmpty())
{
@ -100,20 +110,19 @@ public class PowerPlayClubButton implements GuiItem
material = Material.GOLD_INGOT;
itemName = C.cGreenB + "Power Play Club";
lore = buildLore(unclaimed);
lore.add(" ");
lore.addAll(buildOtherRewardsLore(unclaimed.size()));
lore.add(C.cGold + "Click to claim!");
} else if (cached.isSubscribed())
} else if (maybeNextClaimDate.isPresent()) // Player is still subscribed, and has claimed everything so far
{
// Player is subscribed and has claimed all of his/her rewards
LocalDate nextClaimDate = maybeNextClaimDate.get();
material = Material.REDSTONE_BLOCK;
itemName = C.cRedB + "Power Play Club";
lore = new ArrayList<>();
lore.add(C.cRed + "Already claimed!");
// TODO: 'come back later!'
lore.add(C.cYellow + "Come back " + C.cGreen + nextClaimDate.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + " " + nextClaimDate.getDayOfMonth());
lore.add(C.cWhite + " " + PowerPlayClubRewards.AMPLIFIERS_PER_MONTH + " Game Amplifier");
lore.add(C.cWhite + " " + PowerPlayClubRewards.CHESTS_PER_MONTH + " Omega Chest");
} else
{
@ -121,8 +130,10 @@ public class PowerPlayClubButton implements GuiItem
material = Material.REDSTONE_BLOCK;
itemName = C.cRedB + "Power Play Club";
lore = buildLore(Collections.singletonList(YearMonth.now()));
lore.add(C.cYellow + YearMonth.now().getMonth().getDisplayName(TextStyle.FULL, Locale.US) + "'s Cosmetic");
lore.add(C.cWhite + " " + PowerPlayClubRewards.rewards().get(YearMonth.now()).getPrize());
lore.add(" ");
lore.addAll(buildOtherRewardsLore(1));
lore.add(C.cRed + "Get Power Play Club months at");
lore.add(C.cAqua + "mineplex.com/shop");
}
@ -130,17 +141,29 @@ public class PowerPlayClubButton implements GuiItem
_item = new ShopItem(material, (byte)0, itemName, lore.toArray(new String[lore.size()]), 1, false, false);
}
private List<String> buildLore(List<YearMonth> unclaimed)
private List<String> buildCosmeticsLore(Set<YearMonth> cosmeticsMonths)
{
List<String> lore = new ArrayList<>();
lore.add(C.cYellow + "Rewards");
lore.add(" " + C.cWhite + (PowerPlayClubRewards.AMPLIFIERS_PER_MONTH * unclaimed.size()) + " Game Amplifier");
lore.add(" " + C.cWhite + (PowerPlayClubRewards.CHESTS_PER_MONTH * unclaimed.size()) + " Omega Chest");
lore.add(C.cYellow + "Unlocked cosmetics");
PowerPlayClubRewards.rewards().entrySet().stream()
.filter(entry -> cosmeticsMonths.contains(entry.getKey()))
.sorted(Comparator.comparing(Map.Entry::getKey))
.forEach(entry ->
{
YearMonth yearMonth = entry.getKey();
lore.add(C.cWhite + " " + entry.getValue().getPrize() + " " + C.cGold + yearMonth.getMonth().getDisplayName(TextStyle.SHORT, Locale.US) + " " + yearMonth.getYear());
});
lore.add(" ");
return lore;
}
PowerPlayClubRewards.rewardsForMonths(unclaimed).forEach(prize ->
{
lore.add(" " + C.cWhite + prize.getPrize());
});
private List<String> buildOtherRewardsLore(int unclaimed)
{
List<String> lore = new ArrayList<>();
lore.add(C.cYellow + "Other Rewards");
lore.add(" " + C.cWhite + (PowerPlayClubRewards.AMPLIFIERS_PER_MONTH * unclaimed) + " Game Amplifier");
lore.add(" " + C.cWhite + (PowerPlayClubRewards.CHESTS_PER_MONTH * unclaimed) + " Omega Chest");
lore.add(" ");
return lore;
}

View File

@ -1,18 +1,8 @@
package mineplex.core.cosmetic;
import mineplex.core.boosters.BoosterManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
@ -28,6 +18,15 @@ import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.mount.MountManager;
import mineplex.core.pet.PetManager;
import mineplex.core.treasure.TreasureManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class CosmeticManager extends MiniPlugin
{
@ -57,6 +56,12 @@ public class CosmeticManager extends MiniPlugin
_shop = new CosmeticShop(this, clientManager, donationManager, _moduleName);
}
/*@Override
public void addCommands()
{
addCommand(new CosmeticsSlackCommand(this));
}*/
public void showInterface(boolean showInterface)
{
boolean changed = _showInterface == showInterface;
@ -213,4 +218,5 @@ public class CosmeticManager extends MiniPlugin
}
}
}
}

View File

@ -0,0 +1,45 @@
package mineplex.core.cosmetic.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class SlackCosmeticEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private String _message;
private String _player;
public SlackCosmeticEvent(String message)
{
_message = message;
_player = null;
}
public SlackCosmeticEvent(String message, String player)
{
_message = message;
_player = player;
}
public String getMessage()
{
return _message;
}
public String getPlayer()
{
return _player;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -18,7 +18,6 @@ import mineplex.core.cosmetic.ui.button.activate.ActivateGadgetButton;
import mineplex.core.cosmetic.ui.button.deactivate.DeactivateGadgetButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.GadgetChangeEvent;
import mineplex.core.gadget.gadgets.morph.MorphBlock;
import mineplex.core.gadget.gadgets.morph.MorphWitch;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
@ -76,11 +75,6 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
protected void addGadget(Gadget gadget, int slot)
{
if (gadget instanceof MorphBlock)
{
if (getPlayer().getPassenger() != null)
return;
}
List<String> itemLore = new ArrayList<String>();
@ -146,6 +140,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Freedom Chests");
}
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -9)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Haunted Chests");
}
//Rank Unlocks
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -10)

View File

@ -1,18 +1,18 @@
package mineplex.core.cosmetic.ui.page;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
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.gadgets.morph.MorphBlock;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.shop.item.ShopItem;
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;
public class MorphPage extends GadgetPage
{
@ -31,7 +31,8 @@ public class MorphPage extends GadgetPage
addGadget(gadget, slot);
if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.MORPH) == gadget)
addGlow(slot);
if (!(gadget instanceof MorphBlock))
addGlow(slot);
slot++;

View File

@ -1,5 +1,9 @@
package mineplex.core.cosmetic.ui.page;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
@ -17,10 +21,6 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
public MountPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
@ -96,6 +96,11 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Freedom Chests");
}
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -9)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Halloween Chests");
}
//Rank Unlocks
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -10)
{

View File

@ -1,9 +1,15 @@
package mineplex.core.cosmetic.ui.page;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.PetSorter;
@ -25,10 +31,6 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
public PetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
@ -51,8 +53,14 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
List<String> itemLore = new ArrayList<String>();
itemLore.add(C.cBlack);
itemLore.add(C.cGray + "Your very own " + pet.getName() + "!");
if (pet.getLore() != null)
{
Collections.addAll(itemLore, UtilText.splitLineToArray(C.cGray + pet.getLore(), LineFormat.LORE));
}
else
{
itemLore.add(C.cGray + "Your very own " + pet.getName() + "!");
}
//Chest Unlocks
if (!getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType()))
{
@ -74,13 +82,24 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -4)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Halloween Pumpkin Treasure");
itemLore.add(C.cBlue + "Earned by defeating the Pumpkin King");
itemLore.add(C.cBlue + "in the 2014 Christmas Chaos Event.");
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -5)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Easter Holiday Treasure");
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -8)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Pumpkin's Revenge");
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -9)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Halloween Chests");
}
//Rank Unlocks
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -10)

View File

@ -13,6 +13,7 @@ import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.disguise.disguises.DisguiseInsentient;
import mineplex.core.disguise.disguises.DisguiseLiving;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.disguise.disguises.DisguiseSquid;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
@ -85,10 +86,6 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
// The map of which players should a disguise be shown to
private Map<DisguiseBase, Predicate<Player>> _disguisePlayerMap = new HashMap<>();
// todo understand how this works
private Map<Integer, PacketPlayOutEntityVelocity> _movePacketMap = new HashMap<>();
private Set<Integer> _goingUp = new HashSet<>();
private HashSet<String> _blockedNames = new HashSet<>();
private boolean _handlingPacket = false;
@ -106,9 +103,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
PacketPlayOutSpawnEntityLiving.class,
PacketPlayOutUpdateAttributes.class,
PacketPlayOutEntityEquipment.class,
PacketPlayOutEntityVelocity.class,
PacketPlayOutEntity.PacketPlayOutRelEntityMove.class,
PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook.class
PacketPlayOutEntityVelocity.class
);
createBedChunk();
@ -441,127 +436,18 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
}
}
}
// honestly im not really sure how this works or what it's really meant to do
// it unbreaks squid in SSM though so I guess it's useful
// todo understand how it works
else if (packet instanceof PacketPlayOutEntityVelocity)
{
PacketPlayOutEntityVelocity velocityPacket = (PacketPlayOutEntityVelocity) packet;
// Only for viewers
if (velocityPacket.a == owner.getEntityId())
{
if (velocityPacket.c > 0)
_goingUp.add(velocityPacket.a);
}
else if (velocityPacket.b == 0 && velocityPacket.c == 0 && velocityPacket.d == 0)
{
return;
}
else if (_spawnPacketMap.containsKey(velocityPacket.a))
DisguiseBase latestDisguise = getActiveDisguise(velocityPacket.a);
// Squids will move using their current velocity every tick. So let's just not give them any velocities
if (latestDisguise != null && latestDisguise instanceof DisguiseSquid && getActiveDisguise(owner) != latestDisguise)
{
packetInfo.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutEntity.PacketPlayOutRelEntityMove)
{
final PacketPlayOutEntity.PacketPlayOutRelEntityMove movePacket = (PacketPlayOutEntity.PacketPlayOutRelEntityMove) packet;
// Only for viewers
if (movePacket.a == owner.getEntityId())
return;
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c < 20)
{
_goingUp.remove(movePacket.a);
_movePacketMap.remove(movePacket.a);
}
if (!containsSpawnDisguise(owner, getActiveDisguise(movePacket.a)))
return;
final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity();
velocityPacket.a = movePacket.a;
velocityPacket.b = movePacket.b * 100;
velocityPacket.c = movePacket.c * 100;
velocityPacket.d = movePacket.d * 100;
if (_movePacketMap.containsKey(movePacket.a))
{
PacketPlayOutEntityVelocity lastVelocityPacket = _movePacketMap.get(movePacket.a);
velocityPacket.b = (int) (.8 * lastVelocityPacket.b);
velocityPacket.c = (int) (.8 * lastVelocityPacket.c);
velocityPacket.d = (int) (.8 * lastVelocityPacket.d);
}
_movePacketMap.put(movePacket.a, velocityPacket);
packetVerifier.bypassProcess(velocityPacket);
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20)
{
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
{
public void run()
{
packetVerifier.bypassProcess(velocityPacket);
}
});
}
if (getActiveDisguise(movePacket.a) instanceof DisguiseBlock)
{
}
}
else if (packet instanceof PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook)
{
final PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook movePacket = (PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook) packet;
// Only for viewers
if (movePacket.a == owner.getEntityId())
return;
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c <= 20)
{
_goingUp.remove(movePacket.a);
_movePacketMap.remove(movePacket.a);
}
if (!containsSpawnDisguise(owner, getActiveDisguise(movePacket.a)))
return;
final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity();
velocityPacket.a = movePacket.a;
velocityPacket.b = movePacket.b * 100;
velocityPacket.c = movePacket.c * 100;
velocityPacket.d = movePacket.d * 100;
if (_movePacketMap.containsKey(movePacket.a))
{
PacketPlayOutEntityVelocity lastVelocityPacket = _movePacketMap.get(movePacket.a);
velocityPacket.b = (int) (.8 * lastVelocityPacket.b);
velocityPacket.c = (int) (.8 * lastVelocityPacket.c);
velocityPacket.d = (int) (.8 * lastVelocityPacket.d);
}
_movePacketMap.put(movePacket.a, velocityPacket);
packetVerifier.bypassProcess(velocityPacket);
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20)
{
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
{
public void run()
{
packetVerifier.bypassProcess(velocityPacket);
}
});
}
}
}
private void handlePacket(Packet packet, PacketVerifier verifier)

View File

@ -20,22 +20,22 @@ public class DisguiseZombie extends DisguiseMonster
DataWatcher.a(14, Byte.valueOf((byte) 0), EntityZombie.META_CONVERTING, false);
}
public boolean IsBaby()
public boolean isBaby()
{
return DataWatcher.getByte(12) == 1;
}
public void SetBaby(boolean baby)
public void setBaby(boolean baby)
{
DataWatcher.watch(12, Byte.valueOf((byte) (baby ? 1 : 0)), EntityZombie.META_CHILD, baby);
}
public boolean IsVillager()
public boolean isVillager()
{
return DataWatcher.getByte(13) == 1;
}
public void SetVillager(boolean villager)
public void setVillager(boolean villager)
{
DataWatcher.watch(13, Byte.valueOf((byte) (villager ? 1 : 0)), EntityZombie.META_VILLAGER, villager);
}

View File

@ -1,5 +1,7 @@
package mineplex.core.elo;
import java.util.List;
import com.google.common.collect.Lists;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
@ -11,15 +13,13 @@ import mineplex.core.slack.SlackMessage;
import mineplex.core.slack.SlackTeam;
import org.bukkit.entity.Player;
import java.util.List;
/**
* Generates a list of top elos
*/
public class TopEloCommand extends CommandBase<EloManager>
{
private static final List<String> NAMES = Lists.newArrayList("Relyh", "TadahTech");
private static final List<String> NAMES = Lists.newArrayList("Relyh", "TadahTech", "LCastr0");
public TopEloCommand(EloManager plugin)
{

View File

@ -0,0 +1,232 @@
package mineplex.core.events;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class AddConditionEvent extends Event
{
public enum CoreConditionType
{
CLOAK,
SHOCK,
POISON_SHOCK,
SILENCE,
BURNING,
FALLING,
LIGHTNING,
INVULNERABLE,
EXPLOSION,
FIRE_ITEM_IMMUNITY,
ARCADE_HUNGER_DISABLE,
CUSTOM,
ABSORBTION,
BLINDNESS,
CONFUSION,
DAMAGE_RESISTANCE,
FAST_DIGGING,
FIRE_RESISTANCE,
HARM,
HEAL,
HEALTH_BOOST,
HUNGER,
INCREASE_DAMAGE,
INVISIBILITY,
JUMP,
NIGHT_VISION,
POISON,
REGENERATION,
SLOW,
SLOW_DIGGING,
SPEED,
WATER_BREATHING,
WEAKNESS,
WITHER
}
/**
* Allows adding Condition outside Arcade module
*/
private static final HandlerList handlers = new HandlerList();
protected long _time;
protected String _reason;
protected String _informOn;
protected String _informOff;
protected LivingEntity _ent;
protected LivingEntity _source;
protected CoreConditionType _type;
protected int _mult;
protected int _ticks;
protected int _ticksTotal;
protected boolean _ambient;
protected Material _indicatorType;
protected byte _indicatorData;
protected boolean _add = false;
protected boolean _live = false;
protected boolean _cancelPotion = false;
protected boolean _showIndicator = true;
public AddConditionEvent(String reason, LivingEntity ent, LivingEntity source,
CoreConditionType type, int mult, int ticks, boolean add, Material visualType, byte visualData, boolean showIndicator, boolean ambient)
{
_time = System.currentTimeMillis();
_reason = reason;
_ent = ent;
_source = source;
_type = type;
_mult = mult;
_ticks = ticks;
_ticksTotal = ticks;
_ambient = ambient;
_indicatorType = visualType;
_indicatorData = visualData;
_showIndicator = showIndicator;
_add = add;
//Live if NOT Additive
_live = !add;
}
public AddConditionEvent(String reason, LivingEntity ent, LivingEntity source,
CoreConditionType type, int mult, int ticks, boolean add, Material visualType, byte visualData, boolean showIndicator, boolean ambient, boolean cancelPotion)
{
_time = System.currentTimeMillis();
_reason = reason;
_ent = ent;
_source = source;
_type = type;
_mult = mult;
_ticks = ticks;
_ticksTotal = ticks;
_ambient = ambient;
_indicatorType = visualType;
_indicatorData = visualData;
_showIndicator = showIndicator;
_cancelPotion = cancelPotion;
_add = add;
//Live if NOT Additive
_live = !add;
}
public long getTime()
{
return _time;
}
public String getReason()
{
return _reason;
}
public String getInformOn()
{
return _informOn;
}
public String getInformOff()
{
return _informOff;
}
public LivingEntity getEnt()
{
return _ent;
}
public LivingEntity getSource()
{
return _source;
}
public CoreConditionType getType()
{
return _type;
}
public int getMult()
{
return _mult;
}
public int getTicks()
{
return _ticks;
}
public int getTicksTotal()
{
return _ticksTotal;
}
public boolean isAmbient()
{
return _ambient;
}
public Material getIndicatorType()
{
return _indicatorType;
}
public byte getIndicatorData()
{
return _indicatorData;
}
public boolean isAdd()
{
return _add;
}
public boolean isLive()
{
return _live;
}
public boolean isCancelPotion()
{
return _cancelPotion;
}
public boolean isShowIndicator()
{
return _showIndicator;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -0,0 +1,37 @@
package mineplex.core.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class EnableArcadeSpawnEvent extends Event
{
/**
* Allows spawning mobs inside arcade games without having to do it inside Arcade's code
*/
private static final HandlerList handlers = new HandlerList();
private boolean _enable;
public EnableArcadeSpawnEvent(boolean enable)
{
_enable = enable;
}
public boolean canEnable()
{
return _enable;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -1,11 +1,13 @@
package mineplex.core.gadget;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.function.Predicate;
import mineplex.core.gadget.event.PlayerToggleSwimEvent;
import mineplex.core.gadget.gadgets.morph.swim.SwimManager;
import mineplex.core.treasure.TreasureManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -25,15 +27,23 @@ import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.*;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.commands.AmmoCommand;
import mineplex.core.gadget.commands.LockCosmeticsCommand;
import mineplex.core.gadget.commands.UnlockCosmeticsCommand;
import mineplex.core.gadget.commands.WinRoomTestCommand;
import mineplex.core.gadget.event.GadgetChangeEvent;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.gadget.event.PlayerToggleSwimEvent;
import mineplex.core.gadget.gadgets.arrowtrail.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;
@ -58,6 +68,7 @@ import mineplex.core.gadget.gadgets.death.shadow.DeathShadow;
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.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;
@ -78,7 +89,6 @@ import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStr
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin;
import mineplex.core.gadget.gadgets.hat.HatItem;
import mineplex.core.gadget.gadgets.hat.HatType;
import mineplex.core.gadget.gadgets.morph.*;
import mineplex.core.gadget.gadgets.item.ItemBatGun;
import mineplex.core.gadget.gadgets.item.ItemBow;
import mineplex.core.gadget.gadgets.item.ItemCoal;
@ -104,14 +114,19 @@ import mineplex.core.gadget.gadgets.morph.MorphChicken;
import mineplex.core.gadget.gadgets.morph.MorphCow;
import mineplex.core.gadget.gadgets.morph.MorphCreeper;
import mineplex.core.gadget.gadgets.morph.MorphEnderman;
import mineplex.core.gadget.gadgets.morph.MorphGrimReaper;
import mineplex.core.gadget.gadgets.morph.MorphPig;
import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing;
import mineplex.core.gadget.gadgets.morph.MorphSlime;
import mineplex.core.gadget.gadgets.morph.MorphSnowman;
import mineplex.core.gadget.gadgets.morph.MorphSquid;
import mineplex.core.gadget.gadgets.morph.MorphTitan;
import mineplex.core.gadget.gadgets.morph.MorphUncleSam;
import mineplex.core.gadget.gadgets.morph.MorphVillager;
import mineplex.core.gadget.gadgets.morph.MorphWitch;
import mineplex.core.gadget.gadgets.morph.MorphWither;
import mineplex.core.gadget.gadgets.morph.managers.SoulManager;
import mineplex.core.gadget.gadgets.morph.managers.SwimManager;
import mineplex.core.gadget.gadgets.outfit.OutfitTeam;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitBoots;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitChestplate;
@ -143,17 +158,16 @@ import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot;
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.persistence.UserGadgetPersistence;
import mineplex.core.gadget.set.suits.SetRaveSuit;
import mineplex.core.gadget.set.suits.SetSpaceSuit;
import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken;
import mineplex.core.gadget.gadgets.wineffect.WinEffectFlames;
import mineplex.core.gadget.gadgets.wineffect.WinEffectHalloween;
import mineplex.core.gadget.gadgets.wineffect.WinEffectLavaTrap;
import mineplex.core.gadget.gadgets.wineffect.WinEffectLightningStrike;
import mineplex.core.gadget.gadgets.wineffect.WinEffectMrPunchMan;
import mineplex.core.gadget.gadgets.wineffect.WinEffectPodium;
import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian;
import mineplex.core.gadget.gadgets.wineffect.WinEffectSnowTrails;
import mineplex.core.gadget.persistence.UserGadgetPersistence;
import mineplex.core.gadget.set.SetCandyCane;
import mineplex.core.gadget.set.SetCupidsLove;
import mineplex.core.gadget.set.SetEmerald;
@ -166,6 +180,8 @@ import mineplex.core.gadget.set.SetShadow;
import mineplex.core.gadget.set.SetTitan;
import mineplex.core.gadget.set.SetVampire;
import mineplex.core.gadget.set.SetWisdom;
import mineplex.core.gadget.set.suits.SetRaveSuit;
import mineplex.core.gadget.set.suits.SetSpaceSuit;
import mineplex.core.gadget.types.ArrowEffectGadget;
import mineplex.core.gadget.types.DeathEffectGadget;
import mineplex.core.gadget.types.DoubleJumpEffectGadget;
@ -190,6 +206,7 @@ import mineplex.core.packethandler.PacketHandler;
import mineplex.core.pet.PetManager;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.treasure.TreasureManager;
public class GadgetManager extends MiniPlugin
{
@ -208,6 +225,7 @@ public class GadgetManager extends MiniPlugin
private final OutfitWindUpSuitBoosterManager _boosterManager;
private final IncognitoManager _incognitoManager;
private TreasureManager _treasureManager;
private SoulManager _soulManager;
private NautHashMap<GadgetType, List<Gadget>> _gadgets;
@ -246,6 +264,7 @@ public class GadgetManager extends MiniPlugin
_userGadgetPersistence = new UserGadgetPersistence(this);
_boosterManager = new OutfitWindUpSuitBoosterManager(this);
_incognitoManager = incognitoManager;
_soulManager = new SoulManager();
createGadgets();
createSets();
@ -257,6 +276,7 @@ public class GadgetManager extends MiniPlugin
addCommand(new UnlockCosmeticsCommand(this));
addCommand(new LockCosmeticsCommand(this));
addCommand(new AmmoCommand(this));
addCommand(new WinRoomTestCommand(this));
}
private void createSets()
@ -344,7 +364,9 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphUncleSam(this));
addGadget(new MorphSquid(this));
addGadget(new MorphWitch(this));
//addGadget(new MorphMetalMan(this)); // Soon: reward for signup
addGadget(new MorphGrimReaper(this));
// Not being added in this update!
//addGadget(new MorphMetalMan(this));
// Particles
addGadget(new ParticleFoot(this));
@ -383,6 +405,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new ArrowTrailBlood(this));
addGadget(new ArrowTrailMusic(this));
addGadget(new ArrowTrailFreedom(this));
addGadget(new ArrowTrailHalloween(this));
// Death Effect
addGadget(new DeathFrostLord(this));
@ -411,6 +434,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new DoubleJumpBlood(this));
addGadget(new DoubleJumpMusic(this));
addGadget(new DoubleJumpFreedom(this));
addGadget(new DoubleJumpHalloween(this));
// Hat
for (HatType hatType : HatType.values())
@ -429,6 +453,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new WinEffectLightningStrike(this));
addGadget(new WinEffectRiseOfTheElderGuardian(this));
addGadget(new WinEffectLavaTrap(this));
addGadget(new WinEffectHalloween(this));
// Music
addGadget(new MusicGadget(this, "13 Disc", new String[] {""}, -2, 2256, 178000));
@ -856,6 +881,7 @@ public class GadgetManager extends MiniPlugin
_playerActiveGadgetMap.remove(event.getPlayer());
event.getPlayer().setWalkSpeed(0.2f);
event.getPlayer().setFlySpeed(0.1f);
_soulManager.giveSoul(event.getPlayer());
}
@EventHandler
@ -1164,4 +1190,9 @@ public class GadgetManager extends MiniPlugin
{
return _treasureManager;
}
public SoulManager getSoulManager()
{
return _soulManager;
}
}

View File

@ -11,6 +11,8 @@ import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.mount.Mount;
import mineplex.core.pet.Pet;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class LockCosmeticsCommand extends CommandBase<GadgetManager>
@ -32,36 +34,15 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
{
removeCosmetics(null, caller);
}
// Adds specific type
else
else if (args.length == 1)
{
String type = args[0];
if (type.equalsIgnoreCase("all"))
Player player = Bukkit.getPlayer(args[0]);
if (player != null)
{
removeCosmetics(null, caller);
}
else if (type.equalsIgnoreCase("pet"))
{
removePets(caller);
}
else if (type.equalsIgnoreCase("mount"))
{
removeMounts(caller);
}
else
{
GadgetType gadgetType = GadgetType.valueOf(type);
if (gadgetType == null)
{
UtilPlayer.message(caller, F.main("Cosmetics", "Invalid cosmetic type!"));
}
else
{
removeCosmetics(gadgetType, caller);
}
removeCosmetics(null, player);
UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Removed all the cosmetics to " + F.name(player.getName()) + "!"));
}
}
}
private void removeCosmetics(GadgetType gadgetType, Player caller)

View File

@ -11,6 +11,8 @@ import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.mount.Mount;
import mineplex.core.pet.Pet;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
@ -32,37 +34,16 @@ public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
{
addCosmetics(null, caller);
}
// Adds specific type
else
{
String type = args[0];
if (type.equalsIgnoreCase("all"))
{
addCosmetics(null, caller);
}
else if (type.equalsIgnoreCase("pet"))
else if (args.length == 1)
{
Player player = Bukkit.getPlayer(args[0]);
if (player != null)
{
addPets(caller);
addCosmetics(null, player);
UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added all the cosmetics to " + F.name(player.getName()) + "!"));
}
else if (type.equalsIgnoreCase("mount"))
{
addMounts(caller);
}
else
{
GadgetType gadgetType = GadgetType.valueOf(type);
if (gadgetType == null)
{
UtilPlayer.message(caller, F.main("Cosmetics", "Invalid cosmetic type!"));
}
else
{
addCosmetics(gadgetType, caller);
}
}
}
}
}
}
private void addCosmetics(GadgetType gadgetType, Player caller)
{

View File

@ -0,0 +1,72 @@
package mineplex.core.gadget.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.wineffect.*;
import mineplex.core.gadget.types.WinEffectGadget;
import org.bukkit.entity.Player;
public class WinRoomTestCommand extends CommandBase<GadgetManager>
{
private GadgetManager _manager;
public WinRoomTestCommand(GadgetManager manager)
{
super(manager, Rank.JNR_DEV, "winroomtest");
_manager = manager;
}
@Override
public void Execute(Player player, String[] args)
{
if (args.length < 1 || args.length > 2)
{
UtilPlayer.message(player, F.main("Win Rooms", "Usage: /winroomtest <room name> [play]"));
return;
}
boolean play = false;
if (args.length == 2)
{
if (args[1].equalsIgnoreCase("true"))
{
play = true;
}
}
loadWinRoom(args[0], player, play);
}
private void loadWinRoom(String roomName, Player player, boolean play)
{
List<String> names = Arrays.asList("BabyChicken", "DragonRider", "Fireworks", "Flames", "Halloween", "LavaTrap",
"LightningStrike", "MrPunchMan", "Podium", "RiseOfTheElderGuardian", "SnowTrails");
List<Class> winClasses = Arrays.asList(WinEffectBabyChicken.class, WinEffectDragonRider.class,
WinEffectFireworks.class, WinEffectFlames.class, WinEffectHalloween.class, WinEffectLavaTrap.class,
WinEffectLightningStrike.class, WinEffectMrPunchMan.class, WinEffectPodium.class,
WinEffectRiseOfTheElderGuardian.class, WinEffectSnowTrails.class);
if (names.contains(roomName))
{
int index = names.indexOf(roomName);
WinEffectGadget gadget = (WinEffectGadget) _manager.getGadget(winClasses.get(index));
gadget.setup(player, new ArrayList<>(), new ArrayList<>(), player.getLocation().clone().add(100, 0, 100));
gadget.buildWinnerRoom();
gadget.teleport();
if (play)
{
gadget.runPlay();
}
}
else
{
UtilPlayer.message(player, F.main("Win Rooms", "Wrong room name!"));
}
}
}

View File

@ -0,0 +1,59 @@
package mineplex.core.gadget.gadgets.arrowtrail;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;
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.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ArrowEffectGadget;
public class ArrowTrailHalloween extends ArrowEffectGadget
{
private static Map<Arrow, Color> _arrowColors = new HashMap<>();
public ArrowTrailHalloween(GadgetManager manager)
{
super(manager, "Halloween Arrows", UtilText.splitLineToArray(C.cGray + "Don't listen to the critics; orange and black is in all year.", LineFormat.LORE),
-9, Material.PUMPKIN, (byte) 0);
}
@Override
public void doTrail(Arrow arrow)
{
if (_arrowColors.containsKey(arrow))
{
Color nextColor = _arrowColors.get(arrow);
nextColor = (nextColor == Color.ORANGE) ? Color.BLACK : Color.ORANGE;
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(nextColor), arrow.getLocation());
coloredParticle.display(15);
_arrowColors.put(arrow, nextColor);
}
else
{
Color nextColor = Color.ORANGE;
_arrowColors.put(arrow, nextColor);
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(nextColor), arrow.getLocation());
coloredParticle.display(2);
}
}
@Override
public void doHitEffect(Arrow arrow)
{
if (_arrowColors.containsKey(arrow))
{
_arrowColors.remove(arrow);
}
}
}

View File

@ -1,8 +1,5 @@
package mineplex.core.gadget.gadgets.arrowtrail.freedom;
import java.awt.*;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilText;
@ -10,9 +7,9 @@ import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.particle.unrelated.BabyFireworkEffect;
import mineplex.core.gadget.gadgets.particle.unrelated.FreedomFireworkEffect;
import mineplex.core.gadget.types.ArrowEffectGadget;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;

View File

@ -0,0 +1,78 @@
package mineplex.core.gadget.gadgets.doublejump;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.util.Vector;
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.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.DoubleJumpEffectGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class DoubleJumpHalloween extends DoubleJumpEffectGadget
{
private static final int PARTICLE_AMOUNT = 50;
private HashMap<Player, Long> _playerMap = new HashMap<>();
public DoubleJumpHalloween(GadgetManager manager)
{
super(manager, "Trick-Or-Leap", UtilText.splitLineToArray(C.cGray + "Unfortunately we're all out of candy, so have this instead!", LineFormat.LORE), -9,
Material.PUMPKIN, (byte) 0);
}
@Override
public void doEffect(Player player)
{
_playerMap.put(player, System.currentTimeMillis() + 1000);
for(int amount = 0; amount < PARTICLE_AMOUNT; amount++)
{
Vector r = Vector.getRandom().subtract(Vector.getRandom()).normalize().multiply(2).setY(Math.random() * 0.4);
Location loc = player.getLocation().add(r).add(0, UtilMath.random(.5, 2.3), 0);
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(Color.ORANGE), loc);
coloredParticle.display(7);
r = Vector.getRandom().subtract(Vector.getRandom()).normalize().multiply(2).setY(Math.random() * 0.4);
loc = player.getLocation().add(r).add(0, 0.3, 0);
coloredParticle.setLocation(loc);
coloredParticle.setColor(new DustSpellColor(Color.BLACK));
coloredParticle.display(5);
}
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(Color.ORANGE), player.getLocation().clone().add(0, .4, 0));
coloredParticle.display(7);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if(event.getType() != UpdateType.FASTEST) return;
for(Iterator<Map.Entry<Player, Long>> it = _playerMap.entrySet().iterator(); it.hasNext();)
{
Map.Entry<Player, Long> e = it.next();
if(e.getValue() >= System.currentTimeMillis())
{
it.remove();
continue;
}
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(Color.ORANGE), e.getKey().getLocation());
coloredParticle.display(5);
}
}
}

View File

@ -4,13 +4,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.util.Vector;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilColor;
import mineplex.core.common.util.UtilParticle;
@ -21,6 +14,12 @@ 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.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.util.Vector;
public class DoubleJumpCupidsWings extends DoubleJumpEffectGadget
{

View File

@ -11,17 +11,18 @@ import org.bukkit.inventory.ItemStack;
public enum HatType
{
Coal("Lump of Coal Hat", UtilText.splitLineToArray(C.cGray + "When life gives you coal, make a weird cube hat out it!", LineFormat.LORE), -1, Material.COAL_BLOCK),
Companion_Block("Companion Block", UtilText.splitLineToArray(C.cGray + "The Enrichment Center is required to remind you that the Weighted Companion cube cannot talk. In the event that it does talk The Enrichment Center asks you to ignore its advice.", LineFormat.LORE), -2, SkinData.COMPANION_CUBE, "Companion"),
Grinch("The Grinch", UtilText.splitLineToArray(C.cGray + "Great! Now where's the Roast Beast?!", LineFormat.LORE), -3, SkinData.THE_GRINCH, "The Grinch Hat"),
Lovestruck("Love Struck", UtilText.splitLineToArray(C.cGray + "I think I'm in love... Wait a minute, did someone use a love potion on me?!", LineFormat.LORE), -6, SkinData.LOVESTRUCK, "Love Struck Hat", "Lovestruck"),
Present("Present", UtilText.splitLineToArray(C.cGray + "WHAT'S IN THE PRESENT? Oh, it's just you...", LineFormat.LORE), -3, SkinData.PRESENT),
Rudolph("Rudolph", UtilText.splitLineToArray(C.cGray + "HEY YOU! Wanna lead Santa's sleigh team?", LineFormat.LORE), -3, SkinData.RUDOLPH),
Santa("Santa", UtilText.splitLineToArray(C.cGray + "Now you can work the Mall circuit!", LineFormat.LORE), -3, SkinData.SANTA),
Secret_Package("Secret Package", UtilText.splitLineToArray(C.cGray + "I hope Chiss is inside!", LineFormat.LORE), -6, SkinData.SECRET_PACKAGE),
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);
COAL("Lump of Coal Hat", UtilText.splitLineToArray(C.cGray + "When life gives you coal, make a weird cube hat out it!", LineFormat.LORE), -1, Material.COAL_BLOCK),
COMPANION_BLOCK("Companion Block", UtilText.splitLineToArray(C.cGray + "The Enrichment Center is required to remind you that the Weighted Companion cube cannot talk. In the event that it does talk The Enrichment Center asks you to ignore its advice.", LineFormat.LORE), -2, SkinData.COMPANION_CUBE, "Companion"),
GRINCH("The Grinch", UtilText.splitLineToArray(C.cGray + "Great! Now where's the Roast Beast?!", LineFormat.LORE), -3, SkinData.THE_GRINCH, "The Grinch Hat"),
LOVESTRUCK("Love Struck", UtilText.splitLineToArray(C.cGray + "I think I'm in love... Wait a minute, did someone use a love potion on me?!", LineFormat.LORE), -6, SkinData.LOVESTRUCK, "Love Struck Hat", "Lovestruck"),
PRESENT("Present", UtilText.splitLineToArray(C.cGray + "WHAT'S IN THE PRESENT? Oh, it's just you...", LineFormat.LORE), -3, SkinData.PRESENT),
RUDOLPH("Rudolph", UtilText.splitLineToArray(C.cGray + "HEY YOU! Wanna lead Santa's sleigh team?", LineFormat.LORE), -3, SkinData.RUDOLPH),
SANTA("Santa", UtilText.splitLineToArray(C.cGray + "Now you can work the Mall circuit!", LineFormat.LORE), -3, SkinData.SANTA),
SECRET_PACKAGE("Secret Package", UtilText.splitLineToArray(C.cGray + "I hope Chiss is inside!", LineFormat.LORE), -6, SkinData.SECRET_PACKAGE),
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);
private final String _name;
private final String[] _lore;

View File

@ -80,7 +80,7 @@ public class ItemCoal extends ItemGadget
int goal = -1;
//Coal Hat
if (!Manager.getHatGadget(HatType.Coal).ownsGadget(player))
if (!Manager.getHatGadget(HatType.COAL).ownsGadget(player))
{
goal = _hat;

View File

@ -11,6 +11,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.disguises.DisguiseCat;
import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.gadget.event.GadgetBlockEvent;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import net.minecraft.server.v1_8_R3.Entity;
@ -65,7 +66,8 @@ public class BlockForm
disguise.setBaby();
disguise.setSoundDisguise(new DisguiseCat(_player));
disguise.setInvisible(true);
_host.Manager.getDisguiseManager().disguise(disguise);
//_host.Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(_player, disguise, _host.Manager.getDisguiseManager());
// Apply Falling Block
FallingBlockCheck();
@ -91,7 +93,8 @@ public class BlockForm
{
SolidifyRemove();
_host.Manager.getDisguiseManager().undisguise(_player);
//_host.Manager.getDisguiseManager().undisguise(_player);
UtilMorph.undisguise(_player, _host.Manager.getDisguiseManager());
// Remove FB
if (_player.getPassenger() != null)

View File

@ -1,5 +1,6 @@
package mineplex.core.gadget.gadgets.morph;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import org.bukkit.EntityEffect;
import org.bukkit.GameMode;
import org.bukkit.Material;
@ -59,16 +60,18 @@ public class MorphBat extends MorphGadget implements IThrown
this.applyArmor(player, message);
DisguiseBat disguise = new DisguiseBat(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
disguise.setCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager);
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
player.setAllowFlight(false);
player.setFlying(false);

View File

@ -1,5 +1,6 @@
package mineplex.core.gadget.gadgets.morph;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -42,16 +43,18 @@ public class MorphBlaze extends MorphGadget
this.applyArmor(player, message);
DisguiseBlaze disguise = new DisguiseBlaze(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
disguise.setCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager);
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
}
@EventHandler

View File

@ -1,5 +1,9 @@
package mineplex.core.gadget.gadgets.morph;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilEvent.ActionType;
@ -7,6 +11,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.disguise.disguises.DisguiseRabbit;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
@ -25,10 +30,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
public class MorphBunny extends MorphGadget
{
private HashSet<Player> _jumpCharge = new HashSet<Player>();
@ -55,9 +56,10 @@ public class MorphBunny extends MorphGadget
this.applyArmor(player, message);
DisguiseRabbit disguise = new DisguiseRabbit(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
disguise.setCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager);
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999999, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999999, 1));
@ -68,7 +70,8 @@ public class MorphBunny extends MorphGadget
{
_jumpCharge.remove(player);
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
player.removePotionEffect(PotionEffectType.SPEED);
player.removePotionEffect(PotionEffectType.JUMP);

View File

@ -1,5 +1,6 @@
package mineplex.core.gadget.gadgets.morph;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -48,16 +49,18 @@ public class MorphChicken extends MorphGadget
this.applyArmor(player, message);
DisguiseChicken disguise = new DisguiseChicken(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
disguise.setCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager);
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
player.setAllowFlight(false);
player.setFlying(false);

View File

@ -1,5 +1,6 @@
package mineplex.core.gadget.gadgets.morph;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -36,16 +37,18 @@ public class MorphCow extends MorphGadget
this.applyArmor(player, message);
DisguiseCow disguise = new DisguiseCow(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
disguise.setCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager);
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
}
@EventHandler

View File

@ -2,6 +2,7 @@ package mineplex.core.gadget.gadgets.morph;
import java.util.HashMap;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import org.bukkit.EntityEffect;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -30,7 +31,7 @@ import mineplex.core.gadget.types.MorphGadget;
public class MorphCreeper extends MorphGadget
{
private HashMap<Player, Long> _active = new HashMap<Player, Long>();
private HashMap<Player, Long> _active = new HashMap<>();
public MorphCreeper(GadgetManager manager)
{
@ -50,16 +51,18 @@ public class MorphCreeper extends MorphGadget
this.applyArmor(player, message);
DisguiseCreeper disguise = new DisguiseCreeper(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
disguise.setCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager);
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
}
@EventHandler

View File

@ -1,5 +1,6 @@
package mineplex.core.gadget.gadgets.morph;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
@ -47,16 +48,18 @@ public class MorphEnderman extends MorphGadget
this.applyArmor(player, message);
DisguiseEnderman disguise = new DisguiseEnderman(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
disguise.setCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager);
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
player.setAllowFlight(false);
player.setFlying(false);

View File

@ -0,0 +1,228 @@
package mineplex.core.gadget.gadgets.morph;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.util.Vector;
import mineplex.core.common.shape.ShapeWings;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguiseSkeleton;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.SoulManager;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MorphGrimReaper extends MorphGadget
{
private Map<Player, Long> _flying = new HashMap<>();
private List<Player> _flyReady = new ArrayList<>();
private SoulManager _soulManager;
private ItemStack _hoe;
private static final int FLY_DELAY = 15000;
private ShapeWings _wings = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.2,0.2,0.2), 1, 0, false, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_ANGEL_WING_PATTERN);
private ShapeWings _wingsEdge = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.1,0.1,0.1), 1, 0, true, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_ANGEL_WING_PATTERN);
public MorphGrimReaper(GadgetManager manager)
{
super(manager, "Grim Reaper Morph", UtilText.splitLinesToArray(new String[]{
C.cGray + "The Grim Reaper is the collector of souls.",
"",
C.cWhite + "Right Click a player with Grim Reaper Scythe to steal their soul"
}, LineFormat.LORE), -9,
Material.WOOD_HOE, (byte) 0);
_soulManager = manager.getSoulManager();
createHoe();
}
private void createHoe()
{
ItemStack hoe = new ItemStack(Material.WOOD_HOE);
ItemMeta meta = hoe.getItemMeta();
meta.setDisplayName(C.cGreen + "Grim Reaper Scythe");
meta.setLore(UtilText.splitLines(new String[]{C.cWhite + "Right Click a player to steal their soul!",
C.cWhite + "Cooldown of 10 seconds."}, LineFormat.LORE));
hoe.setItemMeta(meta);
_hoe = hoe;
}
@Override
public void enableCustom(Player player, boolean message)
{
this.applyArmor(player, message);
ItemStack blackChest = new ItemStack(Material.LEATHER_CHESTPLATE),
blackPants = new ItemStack(Material.LEATHER_LEGGINGS), blackBoots = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta chestMeta = (LeatherArmorMeta) blackChest.getItemMeta(),
pantsMeta = (LeatherArmorMeta) blackPants.getItemMeta(), bootsMeta = (LeatherArmorMeta) blackBoots.getItemMeta();
chestMeta.setColor(Color.BLACK);
pantsMeta.setColor(Color.BLACK);
bootsMeta.setColor(Color.BLACK);
blackChest.setItemMeta(chestMeta);
blackPants.setItemMeta(pantsMeta);
blackBoots.setItemMeta(bootsMeta);
player.getInventory().setItem(2, _hoe);
DisguiseSkeleton skeleton = new DisguiseSkeleton(player);
skeleton.SetSkeletonType(Skeleton.SkeletonType.WITHER);
skeleton.setChestplate(blackChest);
skeleton.setLeggings(blackPants);
skeleton.setBoots(blackBoots);
UtilMorph.disguise(player, skeleton, Manager.getDisguiseManager());
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
_flying.remove(player);
_flyReady.remove(player);
_soulManager.resetSouls(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
player.getInventory().setItem(2, new ItemStack(Material.AIR));
}
@EventHandler
public void stealSoul(PlayerInteractEntityEvent event)
{
if (event.getRightClicked().getType() != EntityType.PLAYER)
return;
if (_flyReady.contains(event.getPlayer()))
return;
Player player = event.getPlayer();
if (!player.getItemInHand().equals(_hoe))
return;
Player clicked = (Player) event.getRightClicked();
boolean stolen = _soulManager.stealSoul(player, clicked);
if (stolen)
{
player.playSound(player.getLocation(), Sound.WITHER_DEATH, 1f, 1f);
UtilTextBottom.displayProgress("Grim Reaper Fly", _soulManager.checkSouls(player) + "/20 souls", 20, _soulManager.checkSouls(player), player);
if (_soulManager.checkSouls(player) == 20)
{
_flyReady.add(player);
UtilTextBottom.displayProgress("Grim Reaper Fly", 100, "Sneak to fly!", player);
}
}
}
@EventHandler
public void sneak(PlayerToggleSneakEvent event)
{
if (!isActive(event.getPlayer()))
return;
if (!event.isSneaking())
return;
Player player = event.getPlayer();
if (_soulManager.checkSouls(player) == 20)
{
setFlying(player, true, true);
_flying.put(player, System.currentTimeMillis());
_soulManager.resetSouls(player);
}
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
_soulManager.giveSoul();
List<Player> stopFlying = new ArrayList<>();
for (Player player : _flying.keySet())
{
if (UtilTime.elapsed(_flying.get(player), FLY_DELAY))
{
stopFlying.add(player);
setFlying(player, false, event.getType()==UpdateType.FAST);
}
else
{
setFlying(player, true, event.getType()==UpdateType.FAST);
}
}
stopFlying.forEach(p -> _flying.remove(p));
if (event.getType() != UpdateType.SEC)
return;
for (Player player : _flyReady)
{
UtilTextBottom.displayProgress("Grim Reaper Fly", 100, "Sneak to fly!", player);
}
}
private void setFlying(Player player, boolean flying, boolean isFast)
{
if (flying)
{
if (UtilPlayer.isSpectator(player))
return;
player.setAllowFlight(true);
player.setFlying(true);
_flyReady.remove(player);
if (UtilEnt.isGrounded(player))
UtilAction.velocity(player, new Vector(0,1,0));
Location loc = player.getLocation().add(0, 1.2, 0).add(player.getLocation().getDirection().multiply(-0.2));
if (isFast)
{
_wings.display(loc);
_wingsEdge.display(loc);
}
}
else
{
player.setAllowFlight(false);
}
}
/**
* Removes the blindness effect for that player when they leave
* @param event
*/
@EventHandler
public void onQuit(PlayerQuitEvent event)
{
_soulManager.giveSoul(event.getPlayer());
}
}

View File

@ -2,6 +2,7 @@ package mineplex.core.gadget.gadgets.morph;
import java.util.HashSet;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -49,16 +50,18 @@ public class MorphPig extends MorphGadget
this.applyArmor(player, message);
DisguisePig disguise = new DisguisePig(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
disguise.setCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager);
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
}
@EventHandler

View File

@ -1,5 +1,6 @@
package mineplex.core.gadget.gadgets.morph;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton.SkeletonType;
@ -21,8 +22,11 @@ public class MorphPumpkinKing extends MorphGadget
super(manager, "Pumpkin Kings Head", UtilText.splitLinesToArray(new String[]
{
C.cGray + "Transforms the wearer into the dreaded Pumpkin King!",
"",
C.cBlue + "Earned by defeating the Pumpkin King",
C.cBlue + "in the 2013 Halloween Horror Event"
}, LineFormat.LORE),
-4,
-1,
Material.PUMPKIN, (byte)0);
}
@ -34,10 +38,11 @@ public class MorphPumpkinKing extends MorphGadget
DisguiseSkeleton disguise = new DisguiseSkeleton(player);
disguise.showArmor();
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
disguise.setCustomNameVisible(true);
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
disguise.SetSkeletonType(SkeletonType.WITHER);
Manager.getDisguiseManager().disguise(disguise);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager);
player.getInventory().setHelmet(new ItemStack(Material.JACK_O_LANTERN));
@ -49,7 +54,8 @@ public class MorphPumpkinKing extends MorphGadget
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
player.getInventory().setHelmet(null);
}

View File

@ -1,5 +1,6 @@
package mineplex.core.gadget.gadgets.morph;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -48,8 +49,8 @@ public class MorphSlime extends MorphGadget
this.applyArmor(player, message);
DisguiseSlime disguise = new DisguiseSlime(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
disguise.setCustomNameVisible(true);
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
int size = 1 + (_achievementManager.getMineplexLevelNumber(player, _clientManager.Get(player).GetRank())) / 8;
@ -61,14 +62,16 @@ public class MorphSlime extends MorphGadget
disguise.SetSize(size);
Manager.getDisguiseManager().disguise(disguise);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager);
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
}
@EventHandler

View File

@ -2,6 +2,7 @@ package mineplex.core.gadget.gadgets.morph;
import java.util.WeakHashMap;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -59,16 +60,18 @@ public class MorphSnowman extends MorphGadget
this.applyArmor(player, message);
DisguiseSnowman disguise = new DisguiseSnowman(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
disguise.setCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager);
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
}
@EventHandler

View File

@ -4,7 +4,8 @@ import mineplex.core.common.util.*;
import mineplex.core.disguise.disguises.DisguiseSquid;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.PlayerToggleSwimEvent;
import mineplex.core.gadget.gadgets.morph.swim.SwimManager;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.gadgets.morph.managers.SwimManager;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.gadget.types.OutfitGadget;
import mineplex.core.itemstack.ItemStackFactory;
@ -44,8 +45,10 @@ public class MorphSquid extends MorphGadget implements IThrown
{
applyArmor(player, message);
DisguiseSquid disguiseSquid = new DisguiseSquid(player);
disguiseSquid.setName(player.getName(), Manager.getClientManager().Get(player).GetRank());
Manager.getDisguiseManager().disguise(disguiseSquid);
//disguiseSquid.setName(player.getName(), Manager.getClientManager().Get(player).GetRank());
//disguiseSquid.setCustomNameVisible(true);
//Manager.getDisguiseManager().disguise(disguiseSquid);
UtilMorph.disguise(player, disguiseSquid, Manager);
onToggleSwim(new PlayerToggleSwimEvent(player, SwimManager.isSwimming(player.getUniqueId())));
}
@ -53,7 +56,8 @@ public class MorphSquid extends MorphGadget implements IThrown
public void disableCustom(Player player, boolean message)
{
removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
}
@EventHandler

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -63,17 +64,19 @@ public class MorphTitan extends MorphGadget
this.applyArmor(player, message);
DisguiseGuardian disguise = new DisguiseGuardian(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
disguise.setCustomNameVisible(true);
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
disguise.setElder(true);
Manager.getDisguiseManager().disguise(disguise);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager);
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
player.setAllowFlight(false);
player.setFlying(false);

View File

@ -1,10 +1,14 @@
package mineplex.core.gadget.gadgets.morph;
import java.util.HashSet;
import java.util.Iterator;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.disguise.disguises.DisguiseVillager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
@ -24,9 +28,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Iterator;
public class MorphVillager extends MorphGadget implements IThrown
{
private HashSet<Item> _gems = new HashSet<Item>();
@ -51,16 +52,18 @@ public class MorphVillager extends MorphGadget implements IThrown
this.applyArmor(player, message);
DisguiseVillager disguise = new DisguiseVillager(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
disguise.setCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager);
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
}
@EventHandler

View File

@ -1,14 +1,5 @@
package mineplex.core.gadget.gadgets.morph;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.*;
import mineplex.core.disguise.disguises.DisguiseWitch;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -17,6 +8,20 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
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.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguiseWitch;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MorphWitch extends MorphGadget
{
@ -97,6 +102,14 @@ public class MorphWitch extends MorphGadget
UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
return;
}
for (Location blockLocation : Manager.getTreasureManager().getBlockLocations())
{
if (blockLocation.distanceSquared(cauldronLocation) <= 25)
{
UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
return;
}
}
}
// Checks if the player is close to a cactus

View File

@ -21,6 +21,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.inventory.ClientItem;
import mineplex.core.inventory.data.Item;
@ -64,9 +65,10 @@ public class MorphWither extends MorphGadget
player.setHealth(300);
DisguiseWither disguise = new DisguiseWither(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedRank());
//disguise.setCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
//Manager.getDisguiseManager().disguise(disguise);
UtilMorph.disguise(player, disguise, Manager, true);
player.setMaxHealth(20);
player.setHealth(20);
@ -76,7 +78,8 @@ public class MorphWither extends MorphGadget
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
Manager.getDisguiseManager().undisguise(player);
//Manager.getDisguiseManager().undisguise(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
player.setAllowFlight(false);
player.setFlying(false);

View File

@ -0,0 +1,112 @@
package mineplex.core.gadget.gadgets.morph.managers;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
public class SoulManager
{
/**
* Steals souls from players
*/
private Map<UUID, Long> _timer = new HashMap<>();
private Map<UUID, Integer> _stolenSouls = new HashMap<>();
/**
* Removes the soul from the player
* @param stealer Player that stole the soul
* @param player Player whose soul was stolen
* @return if the player had their soul stolen already or not
*/
public boolean stealSoul(Player stealer, Player player)
{
if (_timer.containsKey(player.getUniqueId()))
{
return false;
}
if (_stolenSouls.containsKey(stealer))
{
if (_stolenSouls.get(stealer) == 20)
{
return false;
}
}
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 100000, 1, true, false));
UtilPlayer.message(player, F.main("Soul", "Your soul was stolen by " + F.name(stealer.getName()) + "!"));
UtilPlayer.message(stealer, F.main("Soul", "You stole " + F.name(player.getName()) + "'s soul!"));
_timer.put(player.getUniqueId(), System.currentTimeMillis());
_stolenSouls.put(stealer.getUniqueId(),
(_stolenSouls.containsKey(stealer.getUniqueId()) ? _stolenSouls.get(stealer.getUniqueId()) + 1 : 1));
return true;
}
/**
* Gives the soul back to the players
*/
public void giveSoul()
{
for (Player player : UtilServer.getPlayers())
{
if (!_timer.containsKey(player.getUniqueId()))
{
continue;
}
long timeStarted = _timer.get(player.getUniqueId());
long currentTime = System.currentTimeMillis();
if (timeStarted + 5000 < currentTime)
{
player.removePotionEffect(PotionEffectType.BLINDNESS);
UtilPlayer.message(player, F.main("Soul", "Oh well, I wasn't using it anyway I guess"));
_timer.remove(player.getUniqueId());
}
}
}
/**
* Forces giving a soul to that player
* @param player The player that will receive the soul
*/
public void giveSoul(Player player)
{
if (_timer.containsKey(player.getUniqueId()))
{
player.removePotionEffect(PotionEffectType.BLINDNESS);
UtilPlayer.message(player, F.main("Soul", "Oh well, I wasn't using it anyway I guess"));
_timer.remove(player.getUniqueId());
}
}
/**
* Checks how many souls that player has stolen
* @param player The player
* @return souls that they stole
*/
public int checkSouls(Player player)
{
if (_stolenSouls.containsKey(player.getUniqueId()))
{
return _stolenSouls.get(player.getUniqueId());
}
return 0;
}
/**
* Resets the souls that the player stole
* @param player The player
*/
public void resetSouls(Player player)
{
_stolenSouls.remove(player.getUniqueId());
}
}

View File

@ -1,4 +1,4 @@
package mineplex.core.gadget.gadgets.morph.swim;
package mineplex.core.gadget.gadgets.morph.managers;
import java.util.ArrayList;
import java.util.List;

View File

@ -0,0 +1,81 @@
package mineplex.core.gadget.gadgets.morph.managers;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseInsentient;
import mineplex.core.gadget.GadgetManager;
import org.bukkit.entity.Player;
public class UtilMorph
{
/**
* UtilMorph helps disguising and undisguising players, avoiding the use of deprecated methods
*/
private static Map<UUID, DisguiseInsentient> _disguises = new HashMap<>();
/**
* Disguises a player with custom name
* @param player The player that will be disguised
* @param disguiseInsentient The disguise that will be applied
* @param gadgetManager The gadget manager
*/
public static void disguise(Player player, DisguiseInsentient disguiseInsentient, GadgetManager gadgetManager)
{
_disguises.put(player.getUniqueId(), disguiseInsentient);
disguiseInsentient.setName(player.getName(), gadgetManager.getClientManager().Get(player).getRealOrDisguisedRank());
disguiseInsentient.setCustomNameVisible(true);
gadgetManager.getDisguiseManager().disguise(disguiseInsentient);
}
/**
* Disguises a player with custom name (special case for the Wither Morph)
* @param player The player that will be disguised
* @param disguiseInsentient The disguise that will be applied
* @param gadgetManager The gadget manager
* @param wither
*/
public static void disguise(Player player, DisguiseInsentient disguiseInsentient, GadgetManager gadgetManager, boolean wither)
{
_disguises.put(player.getUniqueId(), disguiseInsentient);
disguiseInsentient.setName(player.getName(), gadgetManager.getClientManager().Get(player).getRealOrDisguisedRank());
if (!wither)
{
disguiseInsentient.setCustomNameVisible(true);
}
gadgetManager.getDisguiseManager().disguise(disguiseInsentient);
}
/**
* Disguises a player without a custom name
* @param player The player that will be disguised
* @param disguiseInsentient The disguise that will be applied
* @param disguiseManager The disguise manager
*/
public static void disguise(Player player, DisguiseInsentient disguiseInsentient, DisguiseManager disguiseManager)
{
_disguises.put(player.getUniqueId(), disguiseInsentient);
disguiseManager.disguise(disguiseInsentient);
}
/**
* Removes the disguise of a player
* @param player The player that will be undisguised
* @param disguiseManager The disguise manager
*/
public static void undisguise(Player player, DisguiseManager disguiseManager)
{
if (_disguises.containsKey(player.getUniqueId()))
{
DisguiseBase disguiseBase = _disguises.get(player.getUniqueId());
disguiseManager.undisguise(disguiseBase);
_disguises.remove(player.getUniqueId());
}
}
}

View File

@ -110,12 +110,7 @@ public class OutfitWindUpSuitBoosterManager
NoteSong song = NBSReader.loadSong(new DataInputStream(new FileInputStream(songFile)), songFile.getName().replace("_", " ").replace(".nbs", ""));
if (song != null)
{
NotePlayer notePlayer = new NotePlayer(_gadget.getPlugin(), song, new INoteVerifier() {
@Override
public boolean shouldPlay(Player toPlay) {
return true;
}
}, 0.5F, true, player);
NotePlayer notePlayer = new NotePlayer(_gadget.getPlugin(), song, p -> true, 0.5F, true, player);
_notePlayers.put(player, notePlayer);
}
}

View File

@ -1,12 +1,12 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
import java.awt.*;
import java.util.Random;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.common.util.particles.NormalParticle;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
@ -18,6 +18,8 @@ public class BabyFireworkEffect extends Effect
private Random _random = new Random();
private int _count = 0, _fireworkCount = 0;
private boolean _multipleColors = false;
private int _currentColor = 0;
private Color[] _colors;
public BabyFireworkEffect(Location location, JavaPlugin javaPlugin, Color color)
{
@ -31,6 +33,20 @@ public class BabyFireworkEffect extends Effect
}
}
public BabyFireworkEffect(Location location, JavaPlugin javaPlugin, Color... colors)
{
super(10, new EffectLocation(location), javaPlugin, 2);
_fireworkLocation = location.clone();
_colors = colors;
_fireworkColor = _colors[0];
_multipleColors = true;
}
public void setCount(int count)
{
_count = count;
}
@Override
public void runEffect()
{
@ -79,12 +95,24 @@ public class BabyFireworkEffect extends Effect
_fireworkCount++;
if (_multipleColors)
{
if (_fireworkColor == Color.RED)
_fireworkColor = Color.WHITE;
else if (_fireworkColor == Color.WHITE)
_fireworkColor = Color.BLUE;
if (_colors.length == 0)
{
if (_fireworkColor == Color.RED)
_fireworkColor = Color.WHITE;
else if (_fireworkColor == Color.WHITE)
_fireworkColor = Color.BLUE;
else
_fireworkColor = Color.RED;
}
else
_fireworkColor = Color.RED;
{
_currentColor++;
if (_currentColor == _colors.length)
{
_currentColor = 0;
}
_fireworkColor = _colors[_currentColor];
}
}
}

View File

@ -1,6 +1,6 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
import java.awt.*;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;

View File

@ -1,7 +1,5 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
import java.awt.Color;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.particles.ColoredParticle;

View File

@ -0,0 +1,25 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
import mineplex.core.common.util.UtilFirework;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
public class HalloweenSmashedEffect extends Effect
{
private FireworkEffect _fireworkEffect;
public HalloweenSmashedEffect(Location location, FireworkEffect fireworkEffect, JavaPlugin javaPlugin)
{
super(140, new EffectLocation(location), javaPlugin, 5);
_fireworkEffect = fireworkEffect;
}
@Override
public void runEffect()
{
UtilFirework.playFirework(_effectLocation.getLocation(), _fireworkEffect);
}
}

View File

@ -6,6 +6,7 @@ import java.util.HashMap;
import mineplex.core.common.util.*;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import org.bukkit.Color;
import mineplex.core.gadget.types.Gadget;
import org.bukkit.Location;
import org.bukkit.Material;

View File

@ -1,34 +1,11 @@
package mineplex.core.gadget.gadgets.wineffect;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftChicken;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scoreboard.Team;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.*;
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.UtilShapes;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.WinEffectGadget;
@ -38,6 +15,15 @@ import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.EntityCreature;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove;
import net.minecraft.server.v1_8_R3.PathfinderGoal;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftChicken;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
public class WinEffectBabyChicken extends WinEffectGadget
{
@ -81,15 +67,7 @@ public class WinEffectBabyChicken extends WinEffectGadget
public Chicken spawnChicken(Player player, Location loc)
{
Chicken chicken = loc.getWorld().spawn(loc, Chicken.class);
String rank = "";
for(Team t : player.getScoreboard().getTeams())
{
if(t.hasEntry(player.getName()))
{
rank = t.getPrefix();
break;
}
}
String rank = getRank(player);
chicken.setCustomName(rank + player.getName());
chicken.setCustomNameVisible(true);

View File

@ -0,0 +1,181 @@
package mineplex.core.gadget.gadgets.wineffect;
import java.util.ArrayList;
import java.util.List;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.*;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.particle.unrelated.BabyFireworkEffect;
import mineplex.core.gadget.types.WinEffectGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
public class WinEffectHalloween extends WinEffectGadget
{
private DisguisePlayer _npc;
private Skeleton _skeleton;
private List<DisguisePlayer> _disguisePlayers = new ArrayList<>();
private int _tick;
public WinEffectHalloween(GadgetManager manager)
{
super(manager, "Return of The Pumpkin", UtilText.splitLineToArray(C.cGray + "The Pumpkin King will rise again...", LineFormat.LORE),
-9, Material.PUMPKIN, (byte) 0);
_schematicName = "HalloweenRoom";
setGameTime(16000);
}
@Override
public void setup(Player player, List<Player> team, List<Player> nonTeam, Location loc)
{
Location fixedLoc = loc.setDirection(loc.getDirection().multiply(-1));
super.setup(player, team, nonTeam, fixedLoc);
}
@Override
public void teleport()
{
Location loc = getBaseLocation().add(getBaseLocation().getDirection().normalize().multiply(17)).add(0, 3, 0);
loc.setDirection(getBaseLocation().clone().subtract(loc).toVector());
super.teleport(loc);
}
@Override
public void play()
{
spawnNPC();
_tick = 0;
}
@Override
public void finish()
{
UtilPlayer.showForAll(_player);
_team.forEach(p -> UtilPlayer.showForAll(p));
_nonTeam.forEach(p -> UtilPlayer.showForAll(p));
_disguisePlayers.forEach(d -> d.getEntity().getBukkitEntity().remove());
_disguisePlayers.clear();
_skeleton.remove();
_skeleton = null;
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (!isRunning())
return;
if (event.getType() != UpdateType.TICK)
return;
_tick++;
if (_tick == 50)
{
transformPlayer();
}
if (_tick > 50 && _tick <= 60)
{
int particles = 50;
double radius = 0.5;
for (int i = 0; i < particles; i++)
{
double angle = (double) 2 * Math.PI * i / particles;
double x = Math.cos(angle) * radius;
double z = Math.sin(angle) * radius;
Location loc = getBaseLocation().clone().add(x, .2 * (_tick - 50), z);
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor((i % 2 == 0) ? Color.ORANGE : Color.BLACK), loc);
coloredParticle.display();
}
}
}
private void spawnNPC()
{
Location loc = getBaseLocation().setDirection(getBaseLocation().getDirection());
_npc = getNPC(_player, loc);
}
private void transformPlayer()
{
_npc.getEntity().getBukkitEntity().remove();
spawnSkeleton();
spawnGhosts();
UtilPlayer.hideFromAll(_player);
_player.getWorld().playSound(getBaseLocation(), Sound.CAT_MEOW, .5f, .5f);
}
private void spawnSkeleton()
{
Skeleton skeleton = getBaseLocation().getWorld().spawn(getBaseLocation(), Skeleton.class);
skeleton.setCustomName(getRank(_player) + _player.getName());
skeleton.setCustomNameVisible(true);
skeleton.setSkeletonType(Skeleton.SkeletonType.WITHER);
skeleton.getEquipment().setHelmet(new ItemStack(Material.JACK_O_LANTERN));
UtilEnt.ghost(skeleton, true, false);
UtilEnt.Vegetate(skeleton);
for (int i = 0; i < 15; i++)
{
playFirework(skeleton.getLocation().clone().add(0, 2, 0), i, true);
}
}
private void spawnGhosts()
{
int i = 0;
List<Location> circle = UtilShapes.getPointsInCircle(getBaseLocation(), _nonTeam.size(), 7);
for (Player player : _nonTeam)
{
ItemStack playerHead = UtilSkull.getPlayerHead(player.getName(), player.getName() + " skull", null);
Location ghostLoc = circle.get(i);
// Makes sure the block under the zombie is not air
while (ghostLoc.clone().subtract(0, 1, 0).getBlock().getType() == Material.AIR)
{
ghostLoc.subtract(0, 1, 0);
}
DisguisePlayer disguisePlayer = getNPC(player, ghostLoc, SkinData.GHOST);
disguisePlayer.setHelmet(playerHead);
UtilEnt.CreatureLook(disguisePlayer.getEntity().getBukkitEntity(), getBaseLocation());
UtilPlayer.hideFromAll(player);
for (int j = 0; j < 5; j++)
{
playFirework(ghostLoc.clone().add(0, 1, 0), j, false);
}
i++;
}
}
private void playFirework(Location entityLocation, int i, boolean randomLoc)
{
Location randLocation = UtilAlg.getRandomLocation(entityLocation.clone(), 0.7d, 0.7d, 0d);
Color color = (i == 0) ? Color.ORANGE : Color.BLACK;
BabyFireworkEffect babyFireworkEffect;
if (i %2 == 0)
{
babyFireworkEffect = new BabyFireworkEffect((randomLoc) ? randLocation : entityLocation, Manager.getPlugin(), color);
}
else
{
babyFireworkEffect = new BabyFireworkEffect((randomLoc) ? randLocation : entityLocation, Manager.getPlugin(), Color.ORANGE, Color.BLACK);
}
// Starts without the firework trail
babyFireworkEffect.setCount(6);
babyFireworkEffect.start();
}
}

View File

@ -24,7 +24,7 @@ public class WinEffectLavaTrap extends WinEffectGadget
private int _tick = 0;
private Block _lever;
private DisguisePlayer playerNPC;
private DisguisePlayer _playerNPC;
public WinEffectLavaTrap(GadgetManager manager)
{
@ -42,7 +42,7 @@ public class WinEffectLavaTrap extends WinEffectGadget
_lever = getBaseLocation().add(_baseLocation.getDirection().normalize()).getBlock();
_lever.setTypeIdAndData(Material.LEVER.getId(), (byte) 5, false);
playerNPC = getNPC(_player, getBaseLocation());
_playerNPC = getNPC(_player, getBaseLocation());
{
Vector forward = getBaseLocation().getDirection().normalize().multiply(1.3);
@ -101,13 +101,13 @@ public class WinEffectLavaTrap extends WinEffectGadget
Location loc = getBaseLocation();
loc.setDirection(_lever.getLocation().add(0.5, 0, 0.5).subtract(loc.clone().add(0, 1.8, 0)).toVector());
playerNPC.getEntity().getBukkitEntity().teleport(loc);
_playerNPC.getEntity().getBukkitEntity().teleport(loc);
}
if(_tick == 20*3)
{
playerNPC.sendHit();
_playerNPC.sendHit();
_lever.setTypeIdAndData(Material.LEVER.getId(), (byte) (5 | 0x8), false);
_lever.getWorld().playSound(_lever.getLocation(), Sound.CLICK, 0.3f, 0.6f);

View File

@ -1,5 +1,14 @@
package mineplex.core.gadget.types;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
@ -8,14 +17,6 @@ import mineplex.core.gadget.event.GadgetAppliedEvent;
import mineplex.core.gadget.event.GadgetDisableEvent;
import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.shop.item.SalesPackageBase;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashSet;
public abstract class Gadget extends SalesPackageBase implements Listener
{
@ -107,8 +108,6 @@ public abstract class Gadget extends SalesPackageBase implements Listener
return;
}
System.out.println(player.getName() + " has activated " + Name);
Manager.setActive(player, this);
enableCustom(player, message);
Bukkit.getServer().getPluginManager().callEvent(new GadgetAppliedEvent(player, this));

View File

@ -2,34 +2,30 @@ package mineplex.core.gadget.types;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.*;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.*;
import org.bukkit.Color;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import org.spigotmc.event.entity.EntityDismountEvent;
/**
* A wrapper for different win effects
@ -42,6 +38,7 @@ public abstract class WinEffectGadget extends Gadget
protected long _start;
protected long _finish;
protected Location _baseLocation;
private int _gameTime = 12000;
/**
* The file name of the schematic used for this win room. Schematics can be found in the "schematic" folder
@ -294,6 +291,30 @@ public abstract class WinEffectGadget extends Gadget
return disguise;
}
/**
* Get a disguised ArmorStand with the skin of the provided skindata at the provided location. The ArmorStand got no gravity and
* 2048 health.
* @param player The player to create the disguise from
* @param loc The location to spawn the ArmorStand at
* @param skinData The skin data to disguise the armorstand
* @return Returns a disguised ArmorStand at the given location
*/
public DisguisePlayer getNPC(Player player, Location loc, SkinData skinData) {
ArmorStand stand = loc.getWorld().spawn(loc, ArmorStand.class);
stand.setMaxHealth(2048);
stand.setHealth(2048);
stand.setGravity(false);
GameProfile profile = new GameProfile(UUID.randomUUID(), player.getName());
profile.getProperties().clear();
profile.getProperties().put("textures", skinData.getProperty());
DisguisePlayer disguise = new DisguisePlayer(stand, profile);
Manager.getDisguiseManager().disguise(disguise);
return disguise;
}
/**
* Paste a schematic relative to the base location
* @param schematicName Schematic name without the file suffix ".schematic". The file should be located in the "schematic" folder
@ -414,4 +435,29 @@ public abstract class WinEffectGadget extends Gadget
blockLocation.getBlock().setType(Material.BARRIER);
}
/**
* Gets the formatted rank of the player
* @param player
* @return
*/
protected String getRank(Player player)
{
return Manager.getClientManager().Get(player).getRealOrDisguisedRank().getTag(true, true) + " " + C.Reset;
}
public int getGameTime()
{
return _gameTime;
}
protected void setGameTime(int gameTime)
{
_gameTime = gameTime;
}
protected void setBaseLocation(Location baseLocation)
{
_baseLocation = baseLocation;
}
}

View File

@ -138,8 +138,8 @@ public class GlobalGiveItem implements Listener
{
for (final Player p : UtilServer.getPlayers())
{
Reward reward = _rewardManager.nextReward(p, null, false, RewardType.GameLoot, true);
reward.giveReward(RewardType.GameLoot, p, new Callback<RewardData>()
Reward reward = _rewardManager.nextReward(p, null, false, RewardType.GAME_LOOT, true);
reward.giveReward(RewardType.GAME_LOOT, p, new Callback<RewardData>()
{
@Override
public void run(RewardData data)

View File

@ -63,6 +63,7 @@ public class MountManager extends MiniPlugin
_types.add(new MountBabyReindeer(this));
_types.add(new MountValentinesSheep(this));
_types.add(new MountFreedomHorse(this));
_types.add(new MountNightmareSteed(this));
//_types.add(new MountSheep(this));
}

View File

@ -0,0 +1,123 @@
package mineplex.core.mount.types;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import mineplex.core.common.util.*;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
import org.bukkit.event.EventHandler;
import org.bukkit.util.Vector;
public class MountNightmareSteed extends HorseMount
{
private boolean _foot = false;
private HashMap<Location, Long> _steps = new HashMap<>();
public MountNightmareSteed(MountManager manager)
{
super(manager, "Nightmare Steed", UtilText.splitLineToArray(C.cGray + "The Nightmare Steed comes in the darkness of night, the fires of the underworld still trailing from its hooves.", LineFormat.LORE),
Material.WOOL, (byte) 15, -9, Horse.Color.BLACK, Horse.Style.NONE, Horse.Variant.HORSE, 1, null);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.SEC)
{
for (SingleEntityMountData<Horse> singleEntityMountData : getActive().values())
{
UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.FOOTSTEP,
singleEntityMountData.getEntity().getLocation(), 0f, 0f, 0f, 0f, 1, UtilParticle.ViewDist.NORMAL);
}
}
if (event.getType() != UpdateType.FASTEST)
return;
for (SingleEntityMountData<Horse> singleEntityMountData : getActive().values())
{
Entity entity = singleEntityMountData.getEntity();
if (event.getType() != UpdateType.FASTEST) return;
_foot = !_foot;
cleanSteps();
if (!UtilEnt.isGrounded(entity)) return;
Vector offset;
Vector dir = entity.getLocation().getDirection();
dir.setY(0);
dir.normalize();
if (_foot)
{
offset = new Vector(dir.getZ() * -1, 0.1, dir.getX());
}
else
{
offset = new Vector(dir.getZ(), 0.1, dir.getX() * -1);
}
Location loc = entity.getLocation().add(offset.multiply(0.2));
if (nearStep(loc)) return;
if (!UtilBlock.solid(loc.getBlock().getRelative(BlockFace.DOWN))) return;
_steps.put(loc, System.currentTimeMillis());
UtilParticle.PlayParticle(UtilParticle.ParticleType.FOOTSTEP, loc, 0f, 0f, 0f, 0, 1, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers());
for (int i = 0; i < 10; i++)
{
Location randLoc = UtilAlg.getRandomLocation(singleEntityMountData.getEntity().getLocation().clone().add(0, 1, 0), 1d);
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST,
new DustSpellColor(Color.BLACK), randLoc);
coloredParticle.display(2);
}
}
}
public void cleanSteps()
{
if (_steps.isEmpty()) return;
Iterator<Map.Entry<Location, Long>> stepIterator = _steps.entrySet().iterator();
while (stepIterator.hasNext())
{
Map.Entry<Location, Long> entry = stepIterator.next();
if (UtilTime.elapsed(entry.getValue(), 10000)) stepIterator.remove();
}
}
public boolean nearStep(Location loc)
{
for (Location other : _steps.keySet())
{
if (UtilMath.offset(loc, other) < 0.3) return true;
}
return false;
}
}

View File

@ -50,8 +50,10 @@ public class MountSpider extends HorseMount
C.blankLine,
"#" + C.cWhite + "Look Up to use Wall Climb",
"#" + C.cWhite + "Jump to use Leap",
"",
C.cBlue + "Only buyable during Halloween 2015"
}, LineFormat.LORE),
Material.WEB, (byte) 0, -4, Color.BLACK, Style.NONE, Variant.HORSE, 2.0, Material.AIR);
Material.WEB, (byte) 0, -1, Color.BLACK, Style.NONE, Variant.HORSE, 2.0, Material.AIR);
}
@Override

View File

@ -16,10 +16,15 @@ public class MountZombie extends HorseMount
public MountZombie(MountManager manager)
{
super(manager, "Decrepit Warhorse",
UtilText.splitLineToArray(C.cGray + "Once a fierce warhorse, this undead beast will send fear into the hearts of your enemies.", LineFormat.LORE),
UtilText.splitLinesToArray(new String[]{
C.cGray + "Once a fierce warhorse, this undead beast will send fear into the hearts of your enemies.",
"",
C.cBlue + "Earned by defeating the Pumpkin King",
C.cBlue + "in the 2015 Halloween Horror Event."
}, LineFormat.LORE),
Material.ROTTEN_FLESH,
(byte)0,
-4,
-1,
Color.BLACK, Style.BLACK_DOTS, Variant.UNDEAD_HORSE, 0.8, null);
}
}

View File

@ -0,0 +1,106 @@
package mineplex.core.noteblock;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Random;
import java.util.function.Predicate;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.noteblock.event.SongFinishEvent;
/**
* Very basic Manager to play music across the entire server. Specifically used for Lobby Music
*
* Created by shaun on 2016-10-05.
*/
public class MusicManager extends MiniPlugin
{
private Random _random = new Random();
private final ArrayList<NoteSong> _songs = new ArrayList<>();
private int _lastSong = 0;
private final Predicate<Player> _shouldPlay;
public MusicManager(Predicate<Player> shouldPlay, String folderName)
{
super("Music Manager");
_shouldPlay = shouldPlay;
addSongs(folderName);
playNextSong();
}
private void playNextSong()
{
if (_songs.isEmpty())
return;
int index = (_lastSong + _random.nextInt(_songs.size() - 1) + 1) % _songs.size();
NoteSong song = _songs.get(index);
if (song != null)
{
UtilServer.getPlayersCollection().stream()
.filter(_shouldPlay)
.forEach(player -> displaySongInfo(song, player));
new NotePlayer(_plugin, song, _shouldPlay, 0.5F, false);
_lastSong = index;
}
}
private void addSongs(String folderName)
{
try
{
File songsFolder = new File(folderName);
if (songsFolder.exists())
{
File[] files = songsFolder.listFiles();
if (files == null) return;
for (File file : files)
{
if (file.getName().endsWith(".nbs"))
{
System.out.println("Loading Song " + file.getPath());
NoteSong song = NBSReader.loadSong(new DataInputStream(new FileInputStream(file)), file.getName().replace("_", " ").replace(".nbs", ""));
if (song != null)
{
_songs.add(song);
}
}
}
}
}
catch (FileNotFoundException e)
{
e.printStackTrace();
System.out.println("FAILED TO LOAD SONG!!");
}
}
private void displaySongInfo(NoteSong song, Player player)
{
UtilTextBottom.display(C.cWhite + "Now Playing " + C.cYellow + song.getName(), player);
}
@EventHandler
public void onSongFinish(SongFinishEvent event)
{
if (_lastSong < _songs.size() && event.getSong().equals(_songs.get(_lastSong)))
{
playNextSong();
}
}
}

View File

@ -2,6 +2,7 @@ package mineplex.core.noteblock;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -14,7 +15,7 @@ public class NotePlayer
{
private final JavaPlugin _plugin;
private final NoteSong _song;
private final INoteVerifier _verifier;
private final Predicate<Player> _shouldPlay;
private final long _sleepMs;
private volatile float _volumeMult;
private volatile boolean _loop;
@ -22,17 +23,17 @@ public class NotePlayer
private volatile boolean _finished;
private volatile Player[] _players = null;
public NotePlayer(JavaPlugin plugin, NoteSong song, INoteVerifier verifier, float volumeMult, boolean loop, Player... players)
public NotePlayer(JavaPlugin plugin, NoteSong song, Predicate<Player> shouldPlay, float volumeMult, boolean loop, Player... players)
{
this(plugin, song, verifier, volumeMult, loop);
this(plugin, song, shouldPlay, volumeMult, loop);
_players = players;
}
public NotePlayer(JavaPlugin plugin, NoteSong song, INoteVerifier verifier, float volumeMult, boolean loop)
public NotePlayer(JavaPlugin plugin, NoteSong song, Predicate<Player> shouldPlay, float volumeMult, boolean loop)
{
_plugin = plugin;
_song = song;
_verifier = verifier;
_shouldPlay = shouldPlay;
_sleepMs = (long) (1000 / (song.getTempo() / 100D));
_loop = loop;
_tick = 0;
@ -103,7 +104,7 @@ public class NotePlayer
List<Player> players = new ArrayList<>(playerArray.length);
for (Player player : playerArray)
{
if (_verifier.shouldPlay(player))
if (_shouldPlay != null && _shouldPlay.test(player))
players.add(player);
}

View File

@ -0,0 +1,85 @@
package mineplex.core.pet;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import org.bukkit.Location;
import org.bukkit.entity.Blaze;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class GrimReaperPetManager
{
/**
* Makes the Grim Reaper Pet fly around the player
* Copied from {@link mineplex.core.gadget.gadgets.particle.ParticleFairyData}
*/
private Player _player;
private Blaze _blaze;
private Location _grimReaperLoc, _target;
private Vector _direction;
private double _speed;
private long _idleTime;
public GrimReaperPetManager(Player player, Blaze blaze)
{
_player = player;
_blaze = blaze;
_grimReaperLoc = player.getEyeLocation();
_target = getNewTarget();
_speed = 0.2;
_idleTime = 0;
_direction = new Vector(1, 0, 0);
}
public void update()
{
//Update Target
if (UtilMath.offset(_player.getEyeLocation(), _target) > 3 || UtilMath.offset(_grimReaperLoc, _target) < 1)
_target = getNewTarget();
//Pause?
if (Math.random() > 0.98)
_idleTime = System.currentTimeMillis() + (long)(Math.random() * 3000);
//Speed
if (UtilMath.offset(_player.getEyeLocation(), _grimReaperLoc) < 3)
{
if (_idleTime > System.currentTimeMillis())
{
_speed = Math.max(0, _speed - 0.005);
}
else
{
_speed = Math.min(0.15, _speed + 0.005);
}
}
else
{
_idleTime = 0;
_speed = Math.min(0.15 + UtilMath.offset(_player.getEyeLocation(), _grimReaperLoc) * 0.05, _speed + 0.02);
}
//Modify Direction
_direction.add(UtilAlg.getTrajectory(_grimReaperLoc, _target).multiply(0.15));
if (_direction.length() < 1)
_speed = _speed * _direction.length();
UtilAlg.Normalize(_direction);
//Move
if (UtilMath.offset(_grimReaperLoc, _target) > 0.1)
_grimReaperLoc.add(_direction.clone().multiply(_speed));
_blaze.teleport(_grimReaperLoc);
_blaze.setVelocity(new Vector(0, .25, 0));
}
private Location getNewTarget()
{
return _player.getEyeLocation().add(Math.random() * 6 - 3, Math.random() * 1.5, Math.random() * 6 - 3);
}
}

View File

@ -10,6 +10,7 @@ public class Pet extends SalesPackageBase
{
private String _name;
private EntityType _petType;
private String _lore = null;
public Pet(String name, EntityType petType, int cost)
{
@ -22,6 +23,18 @@ public class Pet extends SalesPackageBase
KnownPackage = false;
}
public Pet(String name, EntityType petType, int cost, String lore)
{
super(name, Material.MONSTER_EGG, (byte)petType.getTypeId(), new String[] {});
_name = name;
_petType = petType;
CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost);
_lore = lore;
KnownPackage = false;
}
public EntityType getPetType()
{
return _petType;
@ -36,4 +49,9 @@ public class Pet extends SalesPackageBase
{
return _name;
}
public String getLore()
{
return _lore;
}
}

View File

@ -20,8 +20,8 @@ public class PetFactory
public PetFactory(PetRepository repository)
{
_repository = repository;
_pets = new NautHashMap<EntityType, Pet>();
_petExtras = new NautHashMap<Material, PetExtra>();
_pets = new NautHashMap<>();
_petExtras = new NautHashMap<>();
CreatePets();
CreatePetExtras();
@ -41,6 +41,8 @@ public class PetFactory
_pets.put(EntityType.MUSHROOM_COW, new Pet("Mooshroom", EntityType.MUSHROOM_COW, 5000));
_pets.put(EntityType.WITHER, new Pet("Widder", EntityType.WITHER, -12));
_pets.put(EntityType.SKELETON, new Pet("Guardian", EntityType.SKELETON, -13));
_pets.put(EntityType.RABBIT, new Pet("Baby Zombie", EntityType.RABBIT, -9, "They're so cute - until a pack of them chases down your family and eats them."));
_pets.put(EntityType.BLAZE, new Pet("Grim Reaper", EntityType.BLAZE, -8, "Aww isn't he so cute with his little wings and little scythe?"));
}
private void CreatePetExtras()

View File

@ -1,26 +1,37 @@
package mineplex.core.pet;
import java.util.Collection;
import java.util.Iterator;
import java.util.*;
import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import com.google.gson.Gson;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.ClientWebResponseEvent;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.Rank;
import mineplex.core.common.shape.ShapeWings;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.disguise.disguises.DisguiseGuardian;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.disguise.disguises.DisguiseZombie;
import mineplex.core.donation.DonationManager;
import mineplex.core.events.AddConditionEvent;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.repository.PetRepository;
import mineplex.core.pet.repository.token.ClientPetTokenWrapper;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.EntityCreature;
import net.minecraft.server.v1_8_R3.NavigationAbstract;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPigZombie;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Creature;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Zombie;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
@ -34,33 +45,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.google.gson.Gson;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.ClientWebResponseEvent;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.Rank;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
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.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseGuardian;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.repository.PetRepository;
import mineplex.core.pet.repository.token.ClientPetTokenWrapper;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.EntityCreature;
import net.minecraft.server.v1_8_R3.NavigationAbstract;
public class PetManager extends MiniClientPlugin<PetClient>
{
private static Object _petOwnerSynch = new Object();
@ -81,6 +65,11 @@ public class PetManager extends MiniClientPlugin<PetClient>
private CoreClientManager _clientManager;
private InventoryManager _inventoryManager;
private Map<Blaze, GrimReaperPetManager> _grimReaperMorphs = new HashMap<>();
private ShapeWings _wings = new ShapeWings(ParticleType.RED_DUST.particleName, new org.bukkit.util.Vector(0.2,0.2,0.2), 1, 0, false, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_ANGEL_WING_PATTERN);
private ShapeWings _wingsEdge = new ShapeWings(ParticleType.RED_DUST.particleName, new org.bukkit.util.Vector(0.1,0.1,0.1), 1, 0, true, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_ANGEL_WING_PATTERN);
public PetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager
, InventoryManager inventoryManager, DisguiseManager disguiseManager, mineplex.core.creature.Creature creatureModule, BlockRestore restore, String webAddress)
{
@ -249,10 +238,49 @@ public class PetManager extends MiniClientPlugin<PetClient>
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
{
disguise.setName(Get(player).getPets().get(entityType));
disguise.setCustomNameVisible(true);
}
_disguiseManager.disguise(disguise);
}
else if (pet instanceof Rabbit)
{
UtilEnt.silence(pet, true);
DisguiseChicken disguise = new DisguiseChicken(pet);
_disguiseManager.disguise(disguise);
Zombie zombie = pet.getWorld().spawn(pet.getLocation(), Zombie.class);
zombie.setBaby(true);
zombie.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
{
zombie.setCustomName(Get(player).getPets().get(entityType));
zombie.setCustomNameVisible(true);
}
disguise.getEntity().getBukkitEntity().setPassenger(zombie);
}
else if (pet instanceof Blaze)
{
AddConditionEvent event = new AddConditionEvent("Pet", pet, pet, AddConditionEvent.CoreConditionType.SILENCE, 0, -1, true, Material.SNOW_BALL, (byte) 0, false, false);
Bukkit.getPluginManager().callEvent(event);
DisguiseZombie disguiseZombie = new DisguiseZombie(pet);
disguiseZombie.setBaby(true);
disguiseZombie.setHelmet(new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.WITHER.ordinal()));
disguiseZombie.setChestplate(new ItemStack(Material.BANNER));
disguiseZombie.setHeldItem(new ItemStack(Material.WOOD_HOE));
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
{
disguiseZombie.setName(Get(player).getPets().get(entityType));
disguiseZombie.setCustomNameVisible(true);
}
_disguiseManager.disguise(disguiseZombie);
GrimReaperPetManager grimReaperPetManager = new GrimReaperPetManager(player, (Blaze) pet);
_grimReaperMorphs.put((Blaze) pet, grimReaperPetManager);
}
_activePetOwners.put(player.getName(), pet);
_failedAttempts.put(player.getName(), 0);
@ -281,8 +309,12 @@ public class PetManager extends MiniClientPlugin<PetClient>
if (pet.getPassenger() != null)
pet.getPassenger().remove();
pet.remove();
if (pet instanceof Blaze)
{
_grimReaperMorphs.remove(pet);
}
pet.remove();
if (removeOwner)
{
@ -348,20 +380,25 @@ public class PetManager extends MiniClientPlugin<PetClient>
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
for(Creature pet : _activePetOwners.values())
{
for(Creature pet : _activePetOwners.values())
if(pet instanceof PigZombie && event.getType() == UpdateType.TICK)
{
if(pet instanceof PigZombie)
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, pet.getLocation(), 0.2f,0.0f,0.2f, 0.0f, 4, ViewDist.NORMAL);
if(event.getTick()%3 == 0) pet.getWorld().playSound(pet.getLocation(), Sound.BLAZE_BREATH, 0.03f, 0f);
if(!((CraftPigZombie)pet).getHandle().isSilent())
{
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, pet.getLocation(), 0.2f,0.0f,0.2f, 0.0f, 4, ViewDist.NORMAL);
if(event.getTick()%3 == 0) pet.getWorld().playSound(pet.getLocation(), Sound.BLAZE_BREATH, 0.03f, 0f);
if(!((CraftPigZombie)pet).getHandle().isSilent())
{
((CraftPigZombie)pet).getHandle().setSilent(true);
}
((CraftPigZombie)pet).getHandle().setSilent(true);
}
}
if (pet instanceof Blaze && event.getType() == UpdateType.FAST)
{
Location loc = pet.getLocation().clone().add(0, .5, 0).add(pet.getLocation().getDirection().multiply(-0.2));
if (event.getType() == UpdateType.FAST) _wings.display(loc);
if (event.getType() == UpdateType.FAST) _wingsEdge.display(loc);
}
}
if (event.getType() != UpdateType.FAST)
@ -446,6 +483,21 @@ public class PetManager extends MiniClientPlugin<PetClient>
Get(event.getUniqueId()).load(token.DonorToken);
}
/**
* Makes the Grim Reaper pet fly around the player
* Copied from {@link mineplex.core.gadget.gadgets.particle.ParticleFairyData}
* @param event
*/
@EventHandler
public void grimReaperFly(UpdateEvent event)
{
for (Entry<Blaze, GrimReaperPetManager> entry : _grimReaperMorphs.entrySet())
{
GrimReaperPetManager grimReaperPetManager = entry.getValue();
grimReaperPetManager.update();
}
}
@Override
protected PetClient addPlayer(UUID uuid)
{

View File

@ -2,11 +2,13 @@ package mineplex.core.powerplayclub;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor;
import mineplex.core.donation.DonationManager;
import mineplex.serverdata.database.DBPool;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
@ -28,9 +30,11 @@ public class PowerPlayClubRepository implements Listener {
private final Map<UUID, PowerPlayData> _cachedPlayerData = new HashMap<>();
private final CoreClientManager _clientManager;
private final DonationManager _donationManager;
public PowerPlayClubRepository(JavaPlugin plugin, CoreClientManager clientManager) {
public PowerPlayClubRepository(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) {
_clientManager = clientManager;
_donationManager = donationManager;
Bukkit.getPluginManager().registerEvents(this, plugin);
@ -83,6 +87,18 @@ public class PowerPlayClubRepository implements Listener {
});
}
// Add usable cosmetics to player on join
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
PowerPlayData cached = getCachedData(player);
PowerPlayClubRewards.rewardsForMonths(cached.getUsableCosmeticMonths()).stream()
.map(PowerPlayClubRewards.PowerPlayClubItem::getPrize)
.forEach(_donationManager.Get(player)::AddUnknownSalesPackagesOwned);
}
@EventHandler
public void onQuit(PlayerQuitEvent event)
{

View File

@ -51,13 +51,18 @@ public class PowerPlayClubRewards
}
}
public static List<PowerPlayClubItem> rewardsForMonths(List<YearMonth> months)
public static List<PowerPlayClubItem> rewardsForMonths(Set<YearMonth> months)
{
return months.stream().map(rewards::get).collect(Collectors.toList());
return months.stream().sorted().map(rewards::get).collect(Collectors.toList());
}
public static Map<YearMonth, PowerPlayClubItem> rewards()
{
return rewards;
}
public static void giveAllItems(Player player, DonationManager donationManager, InventoryManager inventoryManager, PowerPlayClubRepository repo)
public static void giveAllItems(Player player, InventoryManager inventoryManager, PowerPlayClubRepository repo)
{
UtilPlayer.message(player, F.main("Power Play Club", "Verifying subscription.."));
@ -70,18 +75,7 @@ public class PowerPlayClubRewards
}
PowerPlayData cached = repo.getCachedData(player);
List<PowerPlayClubItem> items = rewardsForMonths(cached.getUnclaimedMonths());
// Give normal power play items
items.forEach(item ->
{
donationManager.PurchaseUnknownSalesPackage(null, player.getName(),
donationManager.getClientManager().Get(player).getAccountId(), item.getPrize(),
GlobalCurrency.TREASURE_SHARD, 0, true);
UtilPlayer.message(player, F.main("Power Play Club", "You received the " +
F.elem(item.getPrize()) + "."));
});
int unclaimed = cached.getUnclaimedMonths().size();
// Give amplifiers and chests
Item gameAmplifier = inventoryManager.getItem("Game Booster");
@ -91,8 +85,8 @@ public class PowerPlayClubRewards
}
else
{
inventoryManager.addItemToInventory(player, gameAmplifier.Name, AMPLIFIERS_PER_MONTH * items.size());
UtilPlayer.message(player, F.main("Power Play Club", "You received " + (AMPLIFIERS_PER_MONTH * items.size()) + "x " + F.elem("Game Amplifier") + "."));
inventoryManager.addItemToInventory(player, gameAmplifier.Name, AMPLIFIERS_PER_MONTH * unclaimed);
UtilPlayer.message(player, F.main("Power Play Club", "You received " + (AMPLIFIERS_PER_MONTH * unclaimed) + "x " + F.elem("Game Amplifier") + "."));
}
Item omegaChest = inventoryManager.getItem("Omega Chest");
if (omegaChest == null)
@ -101,8 +95,8 @@ public class PowerPlayClubRewards
}
else
{
inventoryManager.addItemToInventory(player, omegaChest.Name, CHESTS_PER_MONTH * items.size());
UtilPlayer.message(player, F.main("Power Play Club", "You received " + (CHESTS_PER_MONTH * items.size()) + "x " + F.elem("Omega Chest") + "."));
inventoryManager.addItemToInventory(player, omegaChest.Name, CHESTS_PER_MONTH * unclaimed);
UtilPlayer.message(player, F.main("Power Play Club", "You received " + (CHESTS_PER_MONTH * unclaimed) + "x " + F.elem("Omega Chest") + "."));
}
// Refresh Power Play data on the server

View File

@ -9,25 +9,65 @@ import java.util.stream.Collectors;
public class PowerPlayData
{
private final boolean _subscribed;
private final List<YearMonth> _unclaimedMonths;
/* If this is set, the player's subscription is planned to recur.
*
* In the case of a yearly subscription, this will be the first day of
* the next month, or the exact end-of-subscription date if it's his/her
* last month.
*
* Corollary: If this isn't Optional.empty(), the player is actively subscribed.
*/
private final Optional<LocalDate> _nextClaimDate;
// The months where the player hasn't claimed chests/amplifiers
private final Set<YearMonth> _unclaimedMonths;
/* The months of PPC cosmetics the player owns / can use.
* In the case of, e.g., a monthly subscription, this will include
* the current month's cosmetic until _nextClaimDate passes (the
* subscription expires), unless the player's subscription recurs.
*/
private final Set<YearMonth> _cosmeticMonths;
static PowerPlayData fromSubsAndClaims(List<Subscription> subscriptions, List<YearMonth> claimedMonths)
{
if (subscriptions.isEmpty())
{
return new PowerPlayData(false, Collections.emptyList());
return new PowerPlayData(Optional.empty(), Collections.emptySet(), Collections.emptySet());
}
// Build the list of potential claim dates from subscriptions
// Note that it's a LinkedList with dates in ascending order
List<LocalDate> claimDates = subscriptions.stream()
.flatMap(sub -> buildMonths(sub).stream())
.sorted()
.collect(Collectors.toCollection(LinkedList::new));
// Determine if player is subscribed
LocalDate latestSub = claimDates.get(claimDates.size() - 1);
final boolean subscribed = latestSub.plusMonths(1).isAfter(LocalDate.now());
// Determine the player's next claim date (which will tell us whether
// they're subscribed as well)
final Optional<LocalDate> nextClaimDate;
// In the case of a yearly subscription, they're likely to have a claim date scheduled
// (this is not the case for the last month)
Optional<LocalDate> nextSubClaim = claimDates.stream().filter(date -> date.isAfter(LocalDate.now())).findFirst();
if (nextSubClaim.isPresent())
{
nextClaimDate = nextSubClaim;
} else
{
// In the case of a monthly subscription, we need to extrapolate the next claim date
nextClaimDate = Optional.of(claimDates.get(claimDates.size() - 1))
.map(date -> date.plusMonths(1))
.filter(date -> date.isAfter(LocalDate.now())); // and make sure it's after today
nextClaimDate.ifPresent(claimDates::add);
}
// Determine the months whose cosmetics can be used by this player
Set<YearMonth> cosmeticMonths = claimDates.stream()
.map(YearMonth::from)
.filter(yearMonth -> yearMonth.isBefore(YearMonth.now()) || yearMonth.equals(YearMonth.now()))
.collect(Collectors.toSet());
// Remove already-claimed months
Optional<YearMonth> latestClaimed = claimedMonths.stream().collect(Collectors.maxBy(YearMonth::compareTo));
@ -48,13 +88,12 @@ public class PowerPlayData
}
});
List<YearMonth> unclaimedMonths = claimDates.stream()
Set<YearMonth> unclaimedMonths = claimDates.stream()
.filter(date -> date.isBefore(LocalDate.now()) || date.equals(LocalDate.now())) // Filter dates yet to come
.map(YearMonth::from)
.distinct()
.collect(Collectors.toList());
.collect(Collectors.toSet());
return new PowerPlayData(subscribed, unclaimedMonths);
return new PowerPlayData(nextClaimDate, unclaimedMonths, cosmeticMonths);
}
private static List<LocalDate> buildMonths(Subscription subscription)
@ -66,9 +105,16 @@ public class PowerPlayData
case YEAR:
List<LocalDate> months = new ArrayList<>();
for (int i = 0; i < 12; i++)
// The first and last months have the exact claim dates
// The latter is to prevent premature claiming
months.add(subscription._startDate);
months.add(subscription._startDate.plusMonths(11));
// The middle months can claim on the first day of the month
for (int i = 1; i < 11; i++)
{
months.add(subscription._startDate.plusMonths(i));
months.add(subscription._startDate.plusMonths(i).withDayOfMonth(1));
}
return months;
@ -77,7 +123,8 @@ public class PowerPlayData
}
}
static class Subscription {
static class Subscription
{
private final LocalDate _startDate;
private final SubscriptionDuration _duration;
@ -88,29 +135,45 @@ public class PowerPlayData
}
}
enum SubscriptionDuration {
enum SubscriptionDuration
{
MONTH, YEAR
}
private PowerPlayData(boolean subscribed, List<YearMonth> unclaimedMonths)
private PowerPlayData(Optional<LocalDate> nextClaimDate, Set<YearMonth> unclaimedMonths, Set<YearMonth> cosmeticMonths)
{
_subscribed = subscribed;
_nextClaimDate = nextClaimDate;
_unclaimedMonths = unclaimedMonths;
_cosmeticMonths = cosmeticMonths;
}
public List<YearMonth> getUnclaimedMonths()
public Optional<LocalDate> getNextClaimDate()
{
return _nextClaimDate;
}
public Set<YearMonth> getUnclaimedMonths()
{
return _unclaimedMonths;
}
public Set<YearMonth> getUsableCosmeticMonths()
{
return _cosmeticMonths;
}
public boolean isSubscribed()
{
return _subscribed;
return _nextClaimDate.isPresent();
}
@Override
public String toString()
{
return Objects.toStringHelper(this).add("subscribed", _subscribed).add("unclaimed", _unclaimedMonths).toString();
return Objects.toStringHelper(this)
.add("_nextClaimDate", _nextClaimDate)
.add("_unclaimedMonths", _unclaimedMonths)
.add("_cosmeticMonths", _cosmeticMonths)
.toString();
}
}

View File

@ -12,7 +12,6 @@ import java.util.logging.Level;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
@ -248,11 +247,8 @@ public class ReportManager
checkNotNull(report);
checkNotNull(reportResult);
return _reportRepository.getAccountUUID(report.getSuspectId()).thenAccept(suspectUUID ->
return _reportRepository.getAccountName(report.getSuspectId()).thenAccept(suspectName ->
{
OfflinePlayer suspect = Bukkit.getOfflinePlayer(suspectUUID);
String suspectName = suspect.getName();
if (reportCloser != null)
{
int closerId = _clientManager.Get(reportCloser).getAccountId();
@ -266,64 +262,68 @@ public class ReportManager
saveCompletableFuture.thenAccept(reportId ->
{
if (reportResult.getType() == ReportResultType.ABUSIVE)
try
{
// if report was marked abusive, check if each of the reporters
// should be banned from using the report system
report.getReporterIds().forEach(reporterId ->
_reportRepository.getAccountUUID(reporterId).thenAccept(reporterUUID ->
{
CoreClient reporterClient = _clientManager.Get(reporterUUID);
checkAbuseBan(reporterClient, reportCloser, reportId);
}));
}
Bukkit.getScheduler().runTask(_plugin, () ->
{
String prefix = getReportPrefix(reportId);
String reason = reportResult.getReason().orElse("No reason specified.");
if (reportCloser != null)
if (reportResult.getType() == ReportResultType.ABUSIVE)
{
if (reportResult.getType() == ReportResultType.ACCEPTED)
{
// TODO: force moderator to choose a punishment (requires new punish gui)
CommandCenter.Instance.onPlayerCommandPreprocess(
new PlayerCommandPreprocessEvent(reportCloser,
String.format("/punish %s Report #%s - %s", suspectName, reportId, reason)));
}
// TODO: send these after punishment has been decided (requires new punish gui)
reportCloser.sendMessage(
F.main(prefix, "Report marked as: "
+ C.cGold + reportResult.getType().getName()));
reportCloser.sendMessage(F.main(prefix, "Reason: " + F.elem(reason)));
// if report was marked abusive, check if each of the reporters
// should be banned from using the report system
report.getReporterIds().forEach(reporterId ->
_reportRepository.getAccountUUID(reporterId).thenAccept(reporterUUID ->
{
CoreClient reporterClient = _clientManager.Get(reporterUUID);
checkAbuseBan(reporterClient, reportCloser, reportId);
}));
}
getUUIDs(report.getReporterIds()).thenAccept(ids ->
Bukkit.getScheduler().runTask(_plugin, () ->
{
ReportResultType resultType = reportResult.getType();
ChildJsonMessage jsonMessage = new JsonMessage(F.main(
prefix,
"Your report against " + F.elem(suspectName) + " was marked as " + F.elem(resultType.getName()) + "."))
.extra("\n");
String prefix = getReportPrefix(reportId);
String reason = reportResult.getReason().orElse("No reason specified.");
if (resultType == ReportResultType.ABUSIVE)
if (reportCloser != null)
{
jsonMessage = jsonMessage.add(F.main(prefix, C.cRed + "Submitting false reports may result in punishment."))
.add("\n");
if (reportResult.getType() == ReportResultType.ACCEPTED)
{
// TODO: force moderator to choose a punishment (requires new punish gui)
CommandCenter.Instance.onPlayerCommandPreprocess(
new PlayerCommandPreprocessEvent(reportCloser,
String.format("/punish %s Report #%d - %s", suspectName, reportId, reason)));
}
// TODO: send these after punishment has been decided (requires new punish gui)
reportCloser.sendMessage(
F.main(prefix, "Report marked as: "
+ C.cGold + reportResult.getType().getName()));
reportCloser.sendMessage(F.main(prefix, "Reason: " + F.elem(reason)));
}
jsonMessage = jsonMessage.add(F.main(prefix, "Reason: " + F.elem(reason)));
getUUIDs(report.getReporterIds()).thenAccept(ids ->
{
ReportResultType resultType = reportResult.getType();
ChildJsonMessage jsonMessage = new JsonMessage(F.main(
prefix,
"Your report against " + F.elem(suspectName) + " was marked as " + F.elem(resultType.getName()) + "."))
.extra("\n");
new ReportersNotification(ids, jsonMessage).publish();
if (resultType == ReportResultType.ABUSIVE)
{
jsonMessage = jsonMessage.add(F.main(prefix, C.cRed + "Submitting false reports may result in punishment."))
.add("\n");
}
jsonMessage = jsonMessage.add(F.main(prefix, "Reason: " + F.elem(reason)));
new ReportersNotification(ids, jsonMessage).publish();
});
});
});
_reportRepository.clearCache(reportId);
}).exceptionally(throwable -> {
_plugin.getLogger().log(Level.SEVERE, "Post-report save failed.", throwable);
return null;
_reportRepository.clearCache(reportId);
}
catch (Throwable throwable)
{
_plugin.getLogger().log(Level.SEVERE, "Post-report save failed.", throwable);
}
});
});
}
@ -512,27 +512,12 @@ public class ReportManager
*/
public CompletableFuture<Boolean> isHandlingReport(int accountId)
{
CompletableFuture<List<Long>> future = _reportRepository.getReportsHandling(accountId);
return future.thenApply(reportIds -> {
// if for some reason we cannot fetch the report a user is handling
// assume the worst and return true
// this means we do not end up allowing a user to handle multiple reports simultaneously
if (reportIds == null)
{
return true;
}
for (long reportId : reportIds)
{
if (isActiveReport(reportId).join())
{
return true;
}
}
return false;
});
return _reportRepository.getReportsHandling(accountId)
.thenApply(reportIds -> reportIds.size() > 0)
.exceptionally(throwable -> true);
// ^ if for some reason we cannot fetch the report a user is handling
// assume the worst and return true
// this means we do not end up allowing a user to handle multiple reports simultaneously
}
/**
@ -558,28 +543,24 @@ public class ReportManager
reportIds.stream().map(_reportRepository::getReport).collect(Collectors.toList())
).thenCompose(UtilFuture::sequence)
.thenApply(UtilCollections::unboxPresent)
.thenCompose(reports -> UtilFuture.filter(reports, this::isActiveReport)).thenApply(reports ->
{
Report report = null;
int size = reports.size();
.thenApply(reports ->
{
Report report = null;
int size = reports.size();
if (size == 1)
{
report = reports.get(0);
}
else if (size > 1)
{
throw new IllegalStateException("Account is handling multiple reports.");
}
if (size == 1)
{
report = reports.get(0);
}
else if (size > 1)
{
throw new IllegalStateException("Account is handling multiple reports.");
}
return Optional.ofNullable(report);
});
return Optional.ofNullable(report);
});
future.exceptionally(throwable ->
{
_plugin.getLogger().log(Level.SEVERE, "Error getting the report account is handling.", throwable);
return Optional.empty();
});
future.exceptionally(throwable -> Optional.empty());
return future;
}
@ -632,31 +613,43 @@ public class ReportManager
{
int playerId = _clientManager.Get(player).getAccountId();
getReportHandling(playerId).thenAccept(reportOptional ->
getReportHandling(playerId).whenComplete((reportOptional, throwable) ->
{
if (reportOptional.isPresent())
if (throwable == null)
{
Report report = reportOptional.get();
if (!report.getHandlerTask().isPresent())
if (reportOptional.isPresent())
{
long reportId = report.getId().orElseThrow(() -> new IllegalStateException("Report id is not present."));
new ReportHandlerTask(this, reportId).start(_plugin);
Report report = reportOptional.get();
if (!report.getHandlerTask().isPresent())
{
long reportId = report.getId().orElseThrow(() -> new IllegalStateException("Report id is not present."));
new ReportHandlerTask(this, reportId).start(_plugin);
}
}
}
else
{
_plugin.getLogger().log(Level.SEVERE, "Error whilst checking for report being handled by " + player.getName(), throwable);
}
});
_reportRepository.getOngoingReports(playerId)
.thenAccept(reports ->
{
for (Report report : reports)
{
sendHandlerNotification(report,
F.main(getReportPrefix(report),
String.format("%s has joined %s.", player.getName(), F.elem(_serverName))));
}
}
);
_reportRepository.getOngoingReports(playerId).whenComplete((reports, throwable) ->
{
if (throwable == null)
{
for (Report report : reports)
{
sendHandlerNotification(report,
F.main(getReportPrefix(report),
String.format("%s has joined %s.", player.getName(), F.elem(_serverName))));
}
}
else
{
_plugin.getLogger().log(Level.SEVERE, "Error whilst checking for on-going reports against " + player.getName(), throwable);
}
});
}
protected void onPlayerQuit(Player player)

View File

@ -1,5 +1,7 @@
package mineplex.core.report.command;
import java.util.logging.Level;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
@ -30,19 +32,27 @@ public class ReportAbortCommand extends CommandBase<ReportPlugin>
{
ReportManager reportManager = Plugin.getReportManager();
reportManager.getReportHandling(player).thenApply(BukkitFuture.accept(reportOptional ->
reportManager.getReportHandling(player).whenComplete(BukkitFuture.complete((reportOptional, throwable) ->
{
if (reportOptional.isPresent())
if (throwable == null)
{
Report report = reportOptional.get();
if (reportOptional.isPresent())
{
Report report = reportOptional.get();
reportManager.abortReport(report).thenApply(BukkitFuture.accept(voidValue ->
UtilPlayer.message(player, F.main(ReportManager.getReportPrefix(report),
"Report has been aborted and may be handled by another staff member."))));
reportManager.abortReport(report).thenApply(BukkitFuture.accept(voidValue ->
UtilPlayer.message(player, F.main(ReportManager.getReportPrefix(report),
"Report has been aborted and may be handled by another staff member."))));
}
else
{
UtilPlayer.message(player, F.main(Plugin.getName(), "You aren't currently handling a report."));
}
}
else
{
UtilPlayer.message(player, F.main(Plugin.getName(), "You aren't currently handling a report."));
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "An error occurred, please try again later."));
Plugin.getPlugin().getLogger().log(Level.SEVERE, "Error whilst aborting report for player " + player.getName(), throwable);
}
}));
}

View File

@ -1,5 +1,7 @@
package mineplex.core.report.command;
import java.util.logging.Level;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
@ -57,6 +59,7 @@ public class ReportCloseCommand extends CommandBase<ReportPlugin>
else
{
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "An error occurred, please try again later."));
Plugin.getPlugin().getLogger().log(Level.SEVERE, "An error occurred whilst fetching the report being handled by " + player.getName(), throwable);
}
});
}

View File

@ -4,6 +4,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -39,62 +40,70 @@ public class ReportHandleCommand extends CommandBase<ReportPlugin>
ReportRepository reportRepository = reportManager.getReportRepository();
int accountId = _commandCenter.GetClientManager().getAccountId(player);
reportManager.isHandlingReport(player).thenAccept(isHandlingReport ->
reportManager.isHandlingReport(player).whenComplete((handlingReport, throwable) ->
{
if (!isHandlingReport)
if (throwable == null)
{
Map<Report, Double> reportPriorities = Collections.synchronizedMap(new HashMap<>());
boolean devMode = reportManager.isDevMode(player.getUniqueId());
// the below fetches the ids of all unhandled reports and gets a Report object for each of these ids
// the priority of the report is then calculated and the results placed in a map
reportRepository.getUnhandledReports(accountId, devMode).thenCompose(reportRepository::getReports).thenAccept(reports ->
CompletableFuture.allOf(reports.stream().map(report ->
reportManager.calculatePriority(report).thenAccept(priority ->
{
if (priority > 0)
{
reportPriorities.put(report, priority);
}
else
{
// mark the report as expired to keep the database clean
// and reduce future query time
reportManager.expireReport(report);
}
}
)
).toArray(CompletableFuture[]::new)).join()
).thenApply(aVoid ->
if (!handlingReport)
{
Map.Entry<Report, Double> mostImportant = null;
Map<Report, Double> reportPriorities = Collections.synchronizedMap(new HashMap<>());
boolean devMode = reportManager.isDevMode(player.getUniqueId());
for (Map.Entry<Report, Double> entry : reportPriorities.entrySet())
// the below fetches the ids of all unhandled reports and gets a Report object for each of these ids
// the priority of the report is then calculated and the results placed in a map
reportRepository.getUnhandledReports(accountId, devMode).thenCompose(reportRepository::getReports).thenAccept(reports ->
CompletableFuture.allOf(reports.stream().map(report ->
reportManager.calculatePriority(report).thenAccept(priority ->
{
if (priority > 0)
{
reportPriorities.put(report, priority);
}
else
{
// mark the report as expired to keep the database clean
// and reduce future query time
reportManager.expireReport(report);
}
}
)
).toArray(CompletableFuture[]::new)).join()
).thenApply(aVoid ->
{
if (mostImportant == null || (double) entry.getValue() > mostImportant.getValue())
Map.Entry<Report, Double> mostImportant = null;
for (Map.Entry<Report, Double> entry : reportPriorities.entrySet())
{
mostImportant = entry;
if (mostImportant == null || (double) entry.getValue() > mostImportant.getValue())
{
mostImportant = entry;
}
}
}
return mostImportant == null ? null : mostImportant.getKey();
}).thenCompose(BukkitFuture.accept(report ->
return mostImportant == null ? null : mostImportant.getKey();
}).thenCompose(BukkitFuture.accept(report ->
{
if (report != null)
{
reportManager.handleReport(report, player);
}
else
{
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "No report found, report queue is empty."));
}
}));
}
else
{
if (report != null)
{
reportManager.handleReport(report, player);
}
else
{
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "No report found, report queue is empty."));
}
}));
Bukkit.getScheduler().runTask(Plugin.getPlugin(), () ->
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "You are already handling a report.")));
}
}
else
{
Bukkit.getScheduler().runTask(Plugin.getPlugin(), () ->
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "You are already handling a report.")));
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "An error occurred, please try again later."));
Plugin.getPlugin().getLogger().log(Level.SEVERE, "Error whilst checking for reports being handled by " + player.getName(), throwable);
}
});
}

View File

@ -227,11 +227,7 @@ public class ReportRepository
return reportsHandling;
});
future.exceptionally(throwable ->
{
_logger.log(Level.SEVERE, "Error fetching reports being handled by specified account.", throwable);
return new ArrayList<>();
});
future.exceptionally(throwable -> null);
return future;
}

View File

@ -5,11 +5,16 @@ import java.util.EnumMap;
import java.util.List;
import java.util.Random;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.account.CoreClientManager;
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.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;
@ -32,6 +37,7 @@ import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst;
import mineplex.core.gadget.gadgets.death.shadow.DeathShadow;
import mineplex.core.gadget.gadgets.death.vampire.DeathBlood;
import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant;
import mineplex.core.gadget.gadgets.doublejump.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;
@ -45,8 +51,31 @@ import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood;
import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant;
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin;
import mineplex.core.gadget.gadgets.hat.HatType;
import mineplex.core.gadget.gadgets.item.*;
import mineplex.core.gadget.gadgets.morph.*;
import mineplex.core.gadget.gadgets.item.ItemBatGun;
import mineplex.core.gadget.gadgets.item.ItemBow;
import mineplex.core.gadget.gadgets.item.ItemCoal;
import mineplex.core.gadget.gadgets.item.ItemEtherealPearl;
import mineplex.core.gadget.gadgets.item.ItemFirework;
import mineplex.core.gadget.gadgets.item.ItemFleshHook;
import mineplex.core.gadget.gadgets.item.ItemFreezeCannon;
import mineplex.core.gadget.gadgets.item.ItemLovePotion;
import mineplex.core.gadget.gadgets.item.ItemMelonLauncher;
import mineplex.core.gadget.gadgets.item.ItemPaintballGun;
import mineplex.core.gadget.gadgets.item.ItemPartyPopper;
import mineplex.core.gadget.gadgets.item.ItemSnowball;
import mineplex.core.gadget.gadgets.item.ItemTNT;
import mineplex.core.gadget.gadgets.morph.MorphBat;
import mineplex.core.gadget.gadgets.morph.MorphBlock;
import mineplex.core.gadget.gadgets.morph.MorphBunny;
import mineplex.core.gadget.gadgets.morph.MorphChicken;
import mineplex.core.gadget.gadgets.morph.MorphCow;
import mineplex.core.gadget.gadgets.morph.MorphEnderman;
import mineplex.core.gadget.gadgets.morph.MorphGrimReaper;
import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing;
import mineplex.core.gadget.gadgets.morph.MorphSlime;
import mineplex.core.gadget.gadgets.morph.MorphSnowman;
import mineplex.core.gadget.gadgets.morph.MorphUncleSam;
import mineplex.core.gadget.gadgets.morph.MorphVillager;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitBoots;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitHelmet;
@ -55,7 +84,14 @@ import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitBoots;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitHelmet;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitLeggings;
import mineplex.core.gadget.gadgets.particle.*;
import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes;
import mineplex.core.gadget.gadgets.particle.ParticleFairy;
import mineplex.core.gadget.gadgets.particle.ParticleFireRings;
import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel;
import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons;
import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal;
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;
@ -67,22 +103,40 @@ import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime;
import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot;
import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood;
import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant;
import mineplex.core.gadget.gadgets.wineffect.*;
import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken;
import mineplex.core.gadget.gadgets.wineffect.WinEffectFlames;
import mineplex.core.gadget.gadgets.wineffect.WinEffectHalloween;
import mineplex.core.gadget.gadgets.wineffect.WinEffectLavaTrap;
import mineplex.core.gadget.gadgets.wineffect.WinEffectLightningStrike;
import mineplex.core.gadget.gadgets.wineffect.WinEffectMrPunchMan;
import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian;
import mineplex.core.gadget.gadgets.wineffect.WinEffectSnowTrails;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.HatGadget;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.mount.Mount;
import mineplex.core.mount.types.*;
import mineplex.core.mount.types.MountBabyReindeer;
import mineplex.core.mount.types.MountCart;
import mineplex.core.mount.types.MountFreedomHorse;
import mineplex.core.mount.types.MountFrost;
import mineplex.core.mount.types.MountMule;
import mineplex.core.mount.types.MountNightmareSteed;
import mineplex.core.mount.types.MountSlime;
import mineplex.core.mount.types.MountSpider;
import mineplex.core.mount.types.MountUndead;
import mineplex.core.mount.types.MountValentinesSheep;
import mineplex.core.mount.types.MountZombie;
import mineplex.core.pet.Pet;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.RewardPool.Type;
import mineplex.core.reward.rewards.*;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.PetReward;
import mineplex.core.reward.rewards.RankReward;
import mineplex.core.reward.rewards.TreasureShardReward;
import mineplex.core.reward.rewards.UnknownPackageReward;
import mineplex.core.stats.StatsManager;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class RewardManager
{
@ -211,8 +265,8 @@ public class RewardManager
// addInventoryReward(Type.VALENTINES_GIFT, getGadget(ItemFlowerGift.class), rarity, 100, 0, 1, 1);
// WINTER Gadgets
addHat(Type.WINTER_HOLIDAY, HatType.Present, rarity, 5);
addHat(Type.WINTER_HOLIDAY, HatType.Snowman, rarity, 5);
addHat(Type.WINTER_HOLIDAY, HatType.PRESENT, rarity, 5);
addHat(Type.WINTER_HOLIDAY, HatType.SNOWMAN, rarity, 5);
// Omega items
addMusicReward(Type.OMEGA, "Block Disk", rarity, 25);
@ -226,8 +280,8 @@ public class RewardManager
addMusicReward(Type.OMEGA, "Wait Disk", rarity, 25);
addMusicReward(Type.OMEGA, "Ward Disk", rarity, 25);
addHat(Type.OMEGA, HatType.Present, rarity, 5);
addHat(Type.OMEGA, HatType.Snowman, rarity, 5);
addHat(Type.OMEGA, HatType.PRESENT, rarity, 5);
addHat(Type.OMEGA, HatType.SNOWMAN, rarity, 5);
}
@ -305,10 +359,10 @@ public class RewardManager
// VALENTINES
//Hats
addHat(Type.VALENTINES_GIFT, HatType.Companion_Block, rarity, 100, 0);
addHat(Type.VALENTINES_GIFT, HatType.Lovestruck, rarity, 100, 0);
addHat(Type.VALENTINES_GIFT, HatType.Secret_Package, rarity, 100, 0);
addHat(Type.VALENTINES_GIFT, HatType.Teddy_Bear, rarity, 100, 0);
addHat(Type.VALENTINES_GIFT, HatType.COMPANION_BLOCK, rarity, 100, 0);
addHat(Type.VALENTINES_GIFT, HatType.LOVESTRUCK, rarity, 100, 0);
addHat(Type.VALENTINES_GIFT, HatType.SECRET_PACKAGE, rarity, 100, 0);
addHat(Type.VALENTINES_GIFT, HatType.TEDDY_BEAR, rarity, 100, 0);
// WINTER
@ -319,7 +373,7 @@ public class RewardManager
addGadget(Type.WINTER_HOLIDAY, getGadget(ParticleCandyCane.class), rarity, 5);
// FREEDOM
addHat(Type.FREEDOM, HatType.Uncle_Sam, rarity, 100);
addHat(Type.FREEDOM, HatType.UNCLE_SAM, rarity, 100);
addGadget(Type.FREEDOM, getGadget(DoubleJumpFreedom.class), rarity, 50);
addGadget(Type.FREEDOM, getGadget(ArrowTrailFreedom.class), rarity, 10);
addGadget(Type.FREEDOM, getGadget(DeathFreedom.class), rarity, 75);
@ -352,14 +406,14 @@ public class RewardManager
addGadget(Type.OMEGA, getGadget(ArrowTrailShadow.class), rarity, 15);
addGadget(Type.OMEGA, getGadget(ArrowTrailCandyCane.class), rarity, 10);
addHat(Type.OMEGA, HatType.Uncle_Sam, rarity, 25);
addHat(Type.OMEGA, HatType.Companion_Block, rarity, 15);
addHat(Type.OMEGA, HatType.Lovestruck, rarity, 20);
addHat(Type.OMEGA, HatType.Secret_Package, rarity, 25);
addHat(Type.OMEGA, HatType.Teddy_Bear, rarity, 25);
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.UNCLE_SAM, rarity, 25);
addHat(Type.OMEGA, HatType.COMPANION_BLOCK, rarity, 15);
addHat(Type.OMEGA, HatType.LOVESTRUCK, rarity, 20);
addHat(Type.OMEGA, HatType.SECRET_PACKAGE, rarity, 25);
addHat(Type.OMEGA, HatType.TEDDY_BEAR, rarity, 25);
addHat(Type.OMEGA, HatType.SANTA, rarity, 25);
addHat(Type.OMEGA, HatType.RUDOLPH, rarity, 25);
addHat(Type.OMEGA, HatType.COAL, rarity, 25);
addGadget(Type.OMEGA, getGadget(MorphChicken.class), rarity, 50);
addGadget(Type.OMEGA, getGadget(MorphCow.class), rarity, 167);
@ -384,6 +438,11 @@ public class RewardManager
addGadget(Type.OMEGA, getGadget(OutfitSpaceSuitHelmet.class), rarity, 50);
addGadget(Type.OMEGA, getGadget(ParticleCandyCane.class), rarity, 25);
// HAUNTED CHEST
addGadget(Type.HAUNTED, getGadget(DoubleJumpHalloween.class), rarity, 10);
addHat(Type.HAUNTED, HatType.PUMPKIN, rarity, 10);
addGadget(Type.HAUNTED, getGadget(ArrowTrailHalloween.class), rarity, 100);
}
public void addLegendary()
@ -451,7 +510,7 @@ public class RewardManager
addGadget(Type.WINTER_HOLIDAY, getGadget(DeathFrostLord.class), rarity, 5);
addGadget(Type.WINTER_HOLIDAY, getGadget(DoubleJumpFrostLord.class), rarity, 5);
addGadget(Type.WINTER_HOLIDAY, getGadget(ParticleFrostLord.class), rarity, 5);
addHat(Type.WINTER_HOLIDAY, HatType.Grinch, rarity, 5);
addHat(Type.WINTER_HOLIDAY, HatType.GRINCH, rarity, 5);
addGadget(Type.WINTER_HOLIDAY, getGadget(MorphSnowman.class), rarity, 5);
addMount(Type.WINTER_HOLIDAY, getMount(MountBabyReindeer.class), rarity, 5);
@ -529,8 +588,13 @@ public class RewardManager
addGadget(Type.OMEGA, getGadget(ArrowTrailFrostLord.class), rarity, 20);
addGadget(Type.OMEGA, getGadget(ArrowTrailCupid.class), rarity, 15);
addHat(Type.OMEGA, HatType.Grinch, rarity, 25);
addHat(Type.OMEGA, HatType.GRINCH, rarity, 25);
// HAUNTED
addPetReward(Type.HAUNTED, EntityType.RABBIT, rarity, 100);
addGadget(Type.HAUNTED, getGadget(MorphGrimReaper.class), rarity, 25);
addGadget(Type.HAUNTED, getGadget(WinEffectHalloween.class), rarity, 50);
addMount(Type.HAUNTED, getMount(MountNightmareSteed.class), rarity, 60);
}
public UnknownPackageReward addMount(Type type, Mount<?> mount, RewardRarity rarity, int weight)
@ -740,7 +804,8 @@ public class RewardManager
public Reward[] getRewards(Player player, RewardPool.Type pool, RewardType type)
{
int amount = 4;
if(type == RewardType.IlluminatedChest || type == RewardType.FreedomChest || type == RewardType.OmegaChest) amount = 1;
if(type == RewardType.ILLUMINATED_CHEST || type == RewardType.FREEDOM_CHEST || type == RewardType.OMEGA_CHEST
|| type == RewardType.HAUNTED_CHEST) amount = 1;
int currentReward = 0;
Reward[] rewards = new Reward[amount];
@ -820,7 +885,7 @@ public class RewardManager
//Dont give Rank Upgrade if already has Titan
if (rarity == RewardRarity.MYTHICAL)
{
if (canGiveMythical && type == RewardType.MythicalChest && !_clientManager.Get(player).GetRank().has(Rank.TITAN))
if (canGiveMythical && type == RewardType.MYTHICAL_CHEST && !_clientManager.Get(player).GetRank().has(Rank.TITAN))
{
return new RankReward(_clientManager, 0, 0, rarity);
}

View File

@ -56,6 +56,7 @@ public class RewardPool
ILLUMINATED(false),
FREEDOM(false),
OMEGA(false),
HAUNTED(false),
CARL_SPINNER(true);
private boolean _useDuplicates;

View File

@ -5,19 +5,20 @@ import java.util.ArrayList;
public enum RewardType
{
//% Chances Mythic Legend Rare Uncommon
GameLoot( 0.000001, 0.00001, 0.0001, 3),
GAME_LOOT( 0.000001, 0.00001, 0.0001, 3),
OldChest( 0, 0.06, 0.8, 16),
AncientChest( 0, 2, 8, 32),
MythicalChest( 0.1, 4, 16, 72),
WinterChest( 0, 5, 18, 32),
IlluminatedChest( 0, 2, 16, 72),
FreedomChest( 0, 5, 18, 0),
OmegaChest( 0, 2, 16, 32),
ValentinesGift( 0, 7, 20, 20),
OLD_CHEST( 0, 0.06, 0.8, 16),
ANCIENT_CHEST( 0, 2, 8, 32),
MYTHICAL_CHEST( 0.1, 4, 16, 72),
WINTER_CHEST( 0, 5, 18, 32),
ILLUMINATED_CHEST( 0, 2, 16, 72),
FREEDOM_CHEST( 0, 5, 18, 0),
HAUNTED_CHEST( 0, 5, 18, 0),
OMEGA_CHEST( 0, 2, 16, 32),
VALENTINES_GIFT( 0, 7, 20, 20),
SpinnerFiller( 0.1, 1, 4, 20),
SpinnerReal( 0.000001, 0.05, 0.4, 5);
SPINNER_FILLER( 0.1, 1, 4, 20),
SPINNER_REAL( 0.000001, 0.05, 0.4, 5);
private double _mythicalChance;
private double _legendaryChance;
@ -50,7 +51,7 @@ public enum RewardType
{
int maxCount = Integer.MAX_VALUE;
int openCount = 0;
RewardType type = RewardType.MythicalChest;
RewardType type = RewardType.MYTHICAL_CHEST;
ArrayList<RewardTest> data = new ArrayList<RewardTest>();
for (RewardRarity rarity : RewardRarity.values())

View File

@ -34,9 +34,9 @@ public class RankReward extends Reward
if (_clientManager.Get(player).GetRank() == Rank.ALL) rank = Rank.ULTRA;
else if (_clientManager.Get(player).GetRank() == Rank.ULTRA) rank = Rank.HERO;
else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND;
else if (rewardType == RewardType.MythicalChest && _clientManager.Get(player).GetRank() == Rank.LEGEND) rank = Rank.TITAN;
else if (rewardType == RewardType.MYTHICAL_CHEST && _clientManager.Get(player).GetRank() == Rank.LEGEND) rank = Rank.TITAN;
if (rewardType == RewardType.MythicalChest && _random.nextDouble() < 0.01) // 1 Percent
if (rewardType == RewardType.MYTHICAL_CHEST && _random.nextDouble() < 0.01) // 1 Percent
rank = Rank.TITAN;
if (rank == null)

View File

@ -31,12 +31,12 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
public SalesPackageBase(String name, Material material, byte displayData, String[] description)
{
this(name, material, (byte)0, description, 0);
this(name, material, displayData, description, 0);
}
public SalesPackageBase(String name, Material material, byte displayData, String[] description, int coins)
{
this(name, material, (byte)0, description, coins, 1);
this(name, material, displayData, description, coins, 1);
}
public SalesPackageBase(String name, Material material, byte displayData, String[] description, int coins, int quantity)

View File

@ -1,10 +1,10 @@
package mineplex.core.slack;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
@ -62,12 +62,12 @@ public class SlackAPI
*/
private String runWebCall(SlackTeam team, JsonObject call)
{
HttpURLConnection connection = null;
HttpsURLConnection connection = null;
try
{
// Create connection.
URL url = new URL(team.getURL());
connection = (HttpURLConnection) url.openConnection();
connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setConnectTimeout(5000);
connection.setUseCaches(false);
@ -83,6 +83,8 @@ public class SlackAPI
dos.flush();
dos.close();
int responseCode = connection.getResponseCode();
// Receive response.
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));

View File

@ -1,5 +1,7 @@
package mineplex.core.slack;
import java.net.URL;
import com.google.gson.JsonObject;
/**
@ -9,6 +11,7 @@ public class SlackMessage
{
private String _username;
private String _icon;
private URL _iconURL;
private String _content;
@ -50,6 +53,20 @@ public class SlackMessage
_content = content;
}
/**
* Class constructor.
*
* @param username The username of the message.
* @param iconURL The icon url of the message.
* @param content The content of the message.
*/
public SlackMessage(String username, URL iconURL, String content)
{
_username = username;
_iconURL = iconURL;
_content = content;
}
/**
* Converts the message to JSON format.
*
@ -64,7 +81,11 @@ public class SlackMessage
msg.addProperty("username", _username);
}
if (_icon != null)
if (_iconURL != null)
{
msg.addProperty("icon_url", _iconURL.toString());
}
else if (_icon != null)
{
msg.addProperty("icon_emoji", _icon);
}

View File

@ -6,7 +6,7 @@ package mineplex.core.slack;
public enum SlackTeam
{
// Dev team - mineplex.slack.com
DEVELOPER("Mineplex Dev", "T045RUM7F", "B0VK6GFKN", "6GxwJsDfEpbVnQl8pYuEyq5T"),
DEVELOPER("Mineplex Dev", "T045RUM7F", "B2ED9B9Q9", "STwdq9LFar2Qt4H3JWyDK3Ow"),
// QA team - mineplexqa.slack.com
QA("Mineplex QA", "todo", "todo", "todo"), // TODO: new details

View File

@ -1,8 +1,6 @@
package mineplex.core.treasure;
import java.awt.*;
import java.util.*;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import mineplex.core.blockrestore.BlockRestore;
@ -19,6 +17,7 @@ import mineplex.core.treasure.animation.*;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -176,6 +175,15 @@ public class Treasure
block.getLocation().add(.5 + rX, .7, .5 + rX));
coloredParticle.display();
}
else if (_treasureType == TreasureType.HAUNTED)
{
int r = (int) (Math.random() * 2);
double rX = Math.random() * 2 - 1, rZ = Math.random() * 2 - 1;
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST,
new DustSpellColor((r == 0) ? Color.ORANGE : Color.BLACK),
block.getLocation().add(.5 + rX, .7, .5 + rZ));
coloredParticle.display();
}
else
{
UtilParticle.PlayParticle(type, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.2F, 0,

View File

@ -95,7 +95,7 @@ public class TreasureLocation implements Listener
return;
}
TreasureStartEvent event = new TreasureStartEvent(player);
TreasureStartEvent event = new TreasureStartEvent(player, treasureType);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
@ -125,7 +125,8 @@ public class TreasureLocation implements Listener
return;
}
if(treasureType == TreasureType.ILLUMINATED || treasureType == TreasureType.FREEDOM || treasureType == TreasureType.OMEGA)
if(treasureType == TreasureType.ILLUMINATED || treasureType == TreasureType.FREEDOM || treasureType == TreasureType.OMEGA
|| treasureType == TreasureType.HAUNTED)
{
if(!_treasureManager.hasItemsToGivePlayer(treasureType.getRewardPool(), player))
{
@ -155,7 +156,8 @@ public class TreasureLocation implements Listener
String pron = "a ";
if (treasureType == TreasureType.ANCIENT || treasureType == TreasureType.ILLUMINATED || treasureType == TreasureType.OMEGA)
pron = "an ";
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening " + pron + treasureType.getName()));
String name = treasureType.getName().replace("Chest", "Treasure");
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening " + pron + name));
}
Treasure treasure = new Treasure(player, rewards, treasureType.getRewardType(), _chestBlock, _chestSpawns, treasureType, _treasureManager.getBlockRestore(), _hologramManager, _statusManager);

View File

@ -2,7 +2,14 @@ package mineplex.core.treasure;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.collect.Lists;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore;
@ -18,11 +25,6 @@ import mineplex.core.reward.RewardPool;
import mineplex.core.reward.RewardType;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;
/**
* Created by Shaun on 8/27/2014.
@ -36,6 +38,7 @@ public class TreasureManager extends MiniPlugin
private HologramManager _hologramManager;
private StatsManager _statsManager;
private List<TreasureLocation> _treasureLocations;
private List<Location> _blockLocations;
public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, GadgetManager gadgetManager, BlockRestore blockRestore, HologramManager hologramManager, StatsManager statsManager, RewardManager rewardManager)
{
@ -49,11 +52,13 @@ public class TreasureManager extends MiniPlugin
_rewardManager = rewardManager;
_treasureLocations = Lists.newArrayList();
_blockLocations = Lists.newArrayList();
for(Location location : LocationConstants.CHEST_LOCATIONS)
{
Location resetLocation = LocationConstants.getResetLocation(location);
Block[] blocks = setup(location.getBlock());
_blockLocations.add(location);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, location.getBlock(), blocks, resetLocation, _hologramManager, gadgetManager, statusManager));
}
@ -151,4 +156,9 @@ public class TreasureManager extends MiniPlugin
{
return _treasureLocations;
}
public List<Location> getBlockLocations()
{
return _blockLocations;
}
}

View File

@ -55,6 +55,13 @@ public enum TreasureStyle
ParticleType.CRIT,
Sound.FIRE,
Sound.FIREWORK_TWINKLE
),
HALLOWEEN(
ParticleType.RED_DUST,
ParticleType.RED_DUST,
ParticleType.RED_DUST,
Sound.IRONGOLEM_HIT,
Sound.IRONGOLEM_THROW
);
private ParticleType _secondaryParticle;

View File

@ -8,19 +8,21 @@ import mineplex.core.reward.RewardType;
public enum TreasureType
{
OLD(C.cYellow + "Old Treasure", "Old Chest", "Old", RewardType.OldChest, Material.CHEST, TreasureStyle.OLD, RewardPool.Type.NORMAL, true, 1000),
OLD(C.cYellow + "Old Treasure", "Old Chest", "Old", RewardType.OLD_CHEST, Material.CHEST, TreasureStyle.OLD, RewardPool.Type.NORMAL, true, 1000),
ANCIENT(C.cGold + "Ancient Treasure", "Ancient Chest", "Ancient", RewardType.AncientChest, Material.TRAPPED_CHEST, TreasureStyle.ANCIENT, RewardPool.Type.NORMAL, true, 5000),
ANCIENT(C.cGold + "Ancient Treasure", "Ancient Chest", "Ancient", RewardType.ANCIENT_CHEST, Material.TRAPPED_CHEST, TreasureStyle.ANCIENT, RewardPool.Type.NORMAL, true, 5000),
MYTHICAL(C.cRed + "Mythical Treasure", "Mythical Chest", "Mythical", RewardType.MythicalChest, Material.ENDER_CHEST, TreasureStyle.MYTHICAL, RewardPool.Type.NORMAL, true, 10000),
MYTHICAL(C.cRed + "Mythical Treasure", "Mythical Chest", "Mythical", RewardType.MYTHICAL_CHEST, Material.ENDER_CHEST, TreasureStyle.MYTHICAL, RewardPool.Type.NORMAL, true, 10000),
CHRISTMAS(C.cDGreen + "Winter Holiday Treasure", "Winter Chest", "Christmas", RewardType.WinterChest, Material.CHEST, TreasureStyle.CHRISTMAS, RewardPool.Type.WINTER_HOLIDAY, false, 15000),
CHRISTMAS(C.cDGreen + "Winter Holiday Treasure", "Winter Chest", "Christmas", RewardType.WINTER_CHEST, Material.CHEST, TreasureStyle.CHRISTMAS, RewardPool.Type.WINTER_HOLIDAY, false, 15000),
ILLUMINATED(C.cAqua + "Illuminated Treasure", "Illuminated Chest", "Illuminated", RewardType.IlluminatedChest, Material.CHEST, TreasureStyle.ILLUMINATED, RewardPool.Type.ILLUMINATED, true, 20000),
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.FreedomChest, 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, 35000),
OMEGA(C.cAqua + "Omega Chest", "Omega Chest", "Omega", RewardType.OmegaChest, Material.ENDER_CHEST, TreasureStyle.OMEGA, RewardPool.Type.OMEGA, false, 50000);
OMEGA(C.cAqua + "Omega Chest", "Omega Chest", "Omega", RewardType.OMEGA_CHEST, Material.ENDER_CHEST, TreasureStyle.OMEGA, RewardPool.Type.OMEGA, false, 50000),
HAUNTED(C.cGold + "Haunted Chest", "Haunted Chest", "Haunted", RewardType.HAUNTED_CHEST, Material.CHEST, TreasureStyle.HALLOWEEN, RewardPool.Type.HAUNTED, false, 100000);
private final String _name;
private final RewardType _rewardType;

View File

@ -75,6 +75,11 @@ public class BlockChangeAnimation extends Animation
mat = Material.ENDER_STONE;
data = 0;
}
else if (getTreasure().getTreasureType() == TreasureType.HAUNTED)
{
mat = Material.WOOL;
data = 1;
}
else
continue;
@ -107,6 +112,11 @@ public class BlockChangeAnimation extends Animation
mat = Material.ENDER_STONE;
data = 0;
}
else if (getTreasure().getTreasureType() == TreasureType.HAUNTED)
{
mat = Material.WOOL;
data = 15;
}
else
continue;
@ -139,15 +149,15 @@ public class BlockChangeAnimation extends Animation
}
}
}
else if (getTreasure().getTreasureType() == TreasureType.FREEDOM)
else if (getTreasure().getTreasureType() == TreasureType.HAUNTED)
{
for(Block c : _chests)
{
if(c.equals(b))
{
_blockInfoList.add(new BlockInfo(b));
b.setType(Material.ENDER_PORTAL_FRAME);
b.setData((byte) 0);
b.setType(Material.JACK_O_LANTERN);
b.setData(getDirection(c));
}
}
}
@ -164,4 +174,26 @@ public class BlockChangeAnimation extends Animation
{
}
private byte getDirection(Block block)
{
byte direction;
int relX = getTreasure().getCenterBlock().getX() - block.getX();
int relZ = getTreasure().getCenterBlock().getZ() - block.getZ();
if (Math.abs(relX) > Math.abs(relZ))
{
if (relX > 0)
direction = (byte) 3;
else
direction = (byte) 1;
}
else
{
if (relZ > 0)
direction = (byte) 0;
else
direction = (byte) 2;
}
return direction;
}
}

View File

@ -1,6 +1,5 @@
package mineplex.core.treasure.animation;
import java.awt.*;
import java.util.List;
import mineplex.core.common.util.*;
@ -14,6 +13,7 @@ import mineplex.core.treasure.Treasure;
import mineplex.core.treasure.TreasureType;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.MathHelper;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
@ -42,6 +42,7 @@ public class ChestSpawnAnimation extends Animation
private int _babyFireworks = 0;
private int _circleAmount = 0;
private int _currentHauntedColor = 0;
public ChestSpawnAnimation(Treasure treasure, Block block, List<BlockInfo> chestBlockInfo, Block openingCenter, double radialOffset, JavaPlugin javaPlugin)
{
@ -175,6 +176,27 @@ public class ChestSpawnAnimation extends Animation
_circleAmount++;
}
else if (getTreasure().getTreasureType() == TreasureType.HAUNTED)
{
float x = (float) (Math.sin(getTicks()/4D));
float z = (float) (Math.cos(getTicks()/4D));
Location newLoc = _particleLocation.clone();
newLoc.add(UtilAlg.getLeft(_particleDirection).multiply(x * scale));
newLoc.add(UtilAlg.getUp(_particleDirection).multiply(z * scale));
Color color = (_currentHauntedColor == 0) ? Color.ORANGE : Color.BLACK;
ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST, new DustSpellColor(color), newLoc);
coloredParticle.display();
if (_currentHauntedColor == 0)
{
_currentHauntedColor = 1;
}
else
{
_currentHauntedColor = 0;
}
}
//Spawn Chest
if (getTicks() >= ANIMATION_DURATION)
@ -201,12 +223,12 @@ public class ChestSpawnAnimation extends Animation
if (particleType != null)
{
if (getTreasure().getTreasureType() != TreasureType.FREEDOM)
if (getTreasure().getTreasureType() != TreasureType.FREEDOM && getTreasure().getTreasureType() != TreasureType.HAUNTED)
{
UtilParticle.PlayParticle(particleType, _centerLocation, 0.2f, 0.2f, 0.2f, 0, 50,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else
else if (getTreasure().getTreasureType() == TreasureType.FREEDOM)
{
int r = (int) (Math.random() * 3);
ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST,
@ -214,6 +236,14 @@ public class ChestSpawnAnimation extends Animation
_centerLocation.clone().add(.5, .5, .5));
coloredParticle.display();
}
else
{
int r = (int) (Math.random() * 2);
ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST,
new DustSpellColor((r == 0) ? Color.ORANGE : Color.BLACK),
_centerLocation.clone().add(.5, .5, .5));
coloredParticle.display();
}
}
else
{

Some files were not shown because too many files have changed in this diff Show More