Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/gem-hunters

This commit is contained in:
Sam 2016-12-07 13:36:28 +00:00
commit 05523c1cdf
76 changed files with 2487 additions and 420 deletions

View File

@ -62,7 +62,7 @@ public class SkinData
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=");
public final static SkinData TURKEY = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzU3NzM2MTc5MDQsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8xYzdmYjczMTRkNmY1ZTMzNmVjN2ViNTI1ZGM0ODMzOWNhMjI4ZDk3ODU1MDM3ZDZhNDIwOGZjNzYwNDc1NiJ9fX0=", "eZWi1LOD8ke7MCUAfhspBCnyfCoGM8suFLKtbW6b27CURoRBG3eKIfwLYYeMp3ObjoZ8gCB90s28Qyw5XMzwvvowy9W/b5cYC0OzQ8+GR7tDZoWc28tGqGBM8cmDJIFQgZdceBIIr2lXeAvEJfLbyrus46hPjk8YTiQW2DsBq88BhKIy6Igb1rGqJ1goVERF07b6+/yMdLKCaT8OZFzKLXfo5rY5gr6HLnvsQiNL9aTrl74agXn1GUcP+QVNe7/c9lYmv5vLCBst1YiIPq27NZASZ++Fwyv6+PRlaFZZYtMHVd4UZeYPl7ak1Cdi/1sUcRpkBbJM8AHIrqq0iuXxrLbc6ldQ2cYQKHg9ljIpW/EZanuf6Wgm/LK1JnxXne9GUb/xPzB1EnZ95i8/u9WJa+NixEcfc3pAzDPYncIR8lishFwyBRta6BCG76U3UY2lQr3YD/48AJ49r7+WVU0gOP/h2SDSdAZHEdvkpVJ0w/xA+SevJ7Y7xA5EJ655YMQ0F8f3WUFTf1pFklE5E+fwkMVCWOPw7UMy558IcRSpdWAPPyf8sc7CpDqRk37/vXWRDa+7YBfgskK6B2eXowrzThUOBx+AmDTF3Rv8ZSr1Un0FWGi+GQ5ny7W9dJBMomzyMUbzz9stsCml5XB+6xLP2MD+9lO1bHipKS6qkhtZChE=");
public final static SkinData GINGERBREAD = new SkinData("eyJ0aW1lc3RhbXAiOjE0ODAxOTk5MjM0NTUsInByb2ZpbGVJZCI6IjRjOGQ1NjllZWZlMTRkOGE4YzJmMmM4ODA3ODA3ODRmIiwicHJvZmlsZU5hbWUiOiJHaW5nZXJicmVhZE1hbiIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzAyM2IxZGQ5MWQyYjM2Y2FkZTU2NjVjM2Y3ODk3ZmNiOGRlMWFlNjE5YTRlOTYxODU2MzdiMTliZGNmZjQ3In19fQ==", "lND5lQCzd5DKdn+ps82zn55hrSDr12bBLFoSbxetOj7MaYAuHCkJPQQOXdcMh3TLLSgxmQzEWkIHSUo760/2Qfd2uDDOTVfZZqiFjiOwDQ7YQjkokqNaC3U9gEq+LBJ+IgEkwaCsluXYMIK0Wvqx1DFa82pg8bSYGczJfTw/1kQsUUTpmao6ChZw3yrHTPow38onD95f9i6yVcnhSpPfM/JTQuL4N6Jdcql6VRJNSvCHJvEgh6R2p0w7DJhEGIzkFaF3lPdBqw+Mm97fBPvznscd4s6gpH07gUl/T+vlyHyRBLm85Pgm70r4MQ+c/nGOQOXzFMNpO8RIot/uhd7t3bvSi6yFzZQm7P9QLCLm/0C84x0sCugjeN/hVA347FWnuRPcya5xPzlpTWAW7pCjheAz0mvnPUMYT6Wp4CJx6bPdePnaiLFSeK8EyQIU9IUQJgXqMA3cOwqMBdh/0r71fTInPdgXsVxabmGbCgIuK3A2hSgxpcZv9412T0NIJYSTi0s2B3dyAaZJrdF5wa1hIr8au63SWFJww3GEEOF5YObEyVvKj2yS40iaHaRrfn1DeALT0eD0oN1zzK66FKbFuDmZmm4Thel9gKt+QcnR2uHlFLEBUogpIXyeC8zca7SOppANloOpO4mBbf22dXBJogenVd425JWaXOHJ6NVqIBw=");
// Comments this out for now, so it doesn't load the player profile
// A better way to do this would check for the properties when getting the skull or the skin

View File

@ -1,8 +1,20 @@
package mineplex.core.common.util;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.IBlockData;
import net.minecraft.server.v1_8_R3.Item;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.MinecraftKey;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.TileEntityFlowerPot;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Location;
import org.bukkit.Material;
@ -27,16 +39,10 @@ import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.material.Bed;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.block.MultiBlockUpdaterAgent;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.IBlockData;
import net.minecraft.server.v1_8_R3.Item;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.MinecraftKey;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.TileEntityFlowerPot;
import net.minecraft.server.v1_8_R3.WorldServer;
import mineplex.core.common.skin.SkinData;
public class UtilBlock
{
@ -496,8 +502,6 @@ public class UtilBlock
* @param location of explosion
* @param strength of explosion
* @param damageBlocksEqually - Treat all blocks as durability of dirt
* @param ensureDestruction - Ensure that the closest blocks are destroyed
* at least
* @return
*/
public static ArrayList<Block> getExplosionBlocks(Location location, float strength, boolean damageBlocksEqually)
@ -1646,5 +1650,24 @@ public class UtilBlock
{
return liquid(block.getType());
}
public static Skull blockToSkull(Block block, SkinData skinData) throws Exception
{
block.setType(Material.SKULL);
block.setData((byte) 1);
if (block.getState() instanceof Skull)
{
Skull skull = (Skull) block.getState();
skull.setSkullType(SkullType.PLAYER);
Field field = Class.forName("org.bukkit.craftbukkit.v1_8_R3.block.CraftSkull").getDeclaredField("profile");
field.setAccessible(true);
GameProfile data = new GameProfile(UUID.randomUUID(), SkinData.getUnusedSkullName());
data.getProperties().put("textures", skinData.getProperty());
field.set(skull, data);
skull.update();
return skull;
}
return null;
}
}

View File

@ -161,8 +161,6 @@ public enum Achievement
new String[]{"Win a Game With No Armor"},
new int[]{1},
AchievementCategory.SKYWARS),
//UHC
UHC_WINS("Ultimate Winner", 600,
@ -170,7 +168,55 @@ public enum Achievement
new String[]{"Win 10 games of Ultra Hardcore"},
new int[]{10},
AchievementCategory.UHC),
UHC_FOOD("Fine Dining", 1200,
new String[]{"Ultra Hardcore.Food"},
new String[]{"Collect and eat every type of food in a game", "Foods needed:", "Apple, Mushroom Stew, Bread, Cooked Porkchop", "Golden Apple, Cooked Fish, Cookie, Melon", "Steak, Cooked Chicken, Carrot, Cooked Potato", "Pumpkin Pie, Cooked Rabbit and Cooked Mutton"},
new int[]{1},
AchievementCategory.UHC),
UHC_MINER("Lucky Miner", 1200,
new String[]{"Ultra Hardcore.Miner"},
new String[]{"Equip a full set of iron armor within 10 minutes of the game starting"},
new int[]{1},
AchievementCategory.UHC),
UHC_HOE("I Don\'t Need This", 1200,
new String[]{"Ultra Hardcore.Hoe"},
new String[]{"Craft a diamond hoe"},
new int[]{1},
AchievementCategory.UHC),
UHC_DIE("I Will Not Die!", 1200,
new String[]{"Ultra Hardcore.Die"},
new String[]{"Drop down to half a heart before healing back up"},
new int[]{1},
AchievementCategory.UHC),
UHC_SPEED_FOOD("Fine Dining", 1200,
new String[]{"Ultra Hardcore Speed.Food"},
new String[]{"Collect and eat every type of food in a game", "Foods needed:", "Apple, Mushroom Stew, Bread, Cooked Porkchop", "Golden Apple, Cooked Fish, Cookie, Melon", "Steak, Cooked Chicken, Carrot, Cooked Potato", "Pumpkin Pie, Cooked Rabbit and Cooked Mutton"},
new int[]{1},
AchievementCategory.UHC_SPEED),
UHC_SPEED_MINER("Lucky Miner", 1200,
new String[]{"Ultra Hardcore Speed.Miner"},
new String[]{"Equip a full set of iron armor within 10 minutes of the game starting"},
new int[]{1},
AchievementCategory.UHC_SPEED),
UHC_SPEED_HOE("I Don\'t Need This", 1200,
new String[]{"Ultra Hardcore Speed.Hoe"},
new String[]{"Craft a diamond hoe"},
new int[]{1},
AchievementCategory.UHC_SPEED),
UHC_SPEED_DIE("I Will Not Die!", 1200,
new String[]{"Ultra Hardcore Speed.Die"},
new String[]{"Drop down to half a heart before healing back up"},
new int[]{1},
AchievementCategory.UHC_SPEED),
//MC League
/*MC_LEAGUE_STRIKE("First Strike", 600,
new String[] {"MC League.FirstStrike"},

View File

@ -46,20 +46,36 @@ public enum AchievementCategory
Material.FEATHER, 0, GameCategory.SURVIVAL, "Destructor Kit", false, GameDisplay.Skywars.getGameId(), GameDisplay.SkywarsTeams.getGameId()),
UHC("Ultra Hardcore", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHC.getGameId()),
new StatDisplay[] {
new StatDisplay(C.Bold + "Solo Stats", true),
null,
StatDisplay.fromGame("Wins", GameDisplay.UHCSolo, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHCSolo, "Wins", "Losses"),
StatDisplay.fromGame("Kills", GameDisplay.UHCSolo, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHCSolo, "Deaths"),
StatDisplay.fromGame("Gems Earned", GameDisplay.UHCSolo, "GemsEarned"),
null,
null,
new StatDisplay(C.Bold + "Teams Stats", true),
null,
StatDisplay.fromGame("Wins", GameDisplay.UHC, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHC, "Wins", "Losses"),
StatDisplay.fromGame("Kills", GameDisplay.UHC, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHC, "Deaths"),
StatDisplay.fromGame("Gems Earned", GameDisplay.UHC, "GemsEarned") },
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCSolo.getGameId(), GameDisplay.UHC.getGameId()),
UHC_SOLO("Ultra Hardcore Solo", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCSolo.getGameId()),
UHC_SOLO_SPPED("Ultra Hardcore Solo Speed", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCSoloSpeed.getGameId()),
UHC_TEAMS_SPPED("Ultra Hardcore Teams Speed", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCTeamsSpeed.getGameId()),
UHC_SPEED("Ultra Hardcore Speed", null,
new StatDisplay[] {
new StatDisplay(C.Bold + "Solo Stats", true),
null,
StatDisplay.fromGame("Wins", GameDisplay.UHCSoloSpeed, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHCSoloSpeed, "Wins", "Losses"),
StatDisplay.fromGame("Kills", GameDisplay.UHCSoloSpeed, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHCSoloSpeed, "Deaths"),
StatDisplay.fromGame("Gems Earned", GameDisplay.UHCSoloSpeed, "GemsEarned"),
null,
null,
new StatDisplay(C.Bold + "Teams Stats", true),
null,
StatDisplay.fromGame("Wins", GameDisplay.UHCTeamsSpeed, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHCTeamsSpeed, "Wins", "Losses"),
StatDisplay.fromGame("Kills", GameDisplay.UHCTeamsSpeed, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHCTeamsSpeed, "Deaths"),
StatDisplay.fromGame("Gems Earned", GameDisplay.UHCTeamsSpeed, "GemsEarned") },
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCSoloSpeed.getGameId(), GameDisplay.UHCTeamsSpeed.getGameId()),
/*MC_LEAGUE("MC League", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },

View File

@ -24,13 +24,13 @@ public class UHCMainPage extends AchievementMainPage
{
public UHCMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String targetName, PlayerStats targetStats)
{
super(plugin, statsManager, shop, clientManager, donationManager, name, player, 9 * 5, targetName, targetStats);
super(plugin, statsManager, shop, clientManager, donationManager, name, player, 3 * 9, targetName, targetStats);
}
@Override
protected void buildPage()
{
int slot = 10;
int slot = 11;
for (AchievementCategory category : AchievementCategory.values())
{
@ -41,7 +41,7 @@ public class UHCMainPage extends AchievementMainPage
ArrayList<String> lore = new ArrayList<String>();
lore.add(" ");
category.addStats(getClientManager(), _statsManager, lore, 2, getPlayer(), _targetName, _targetStats);
category.addStats(getClientManager(), _statsManager, lore, getPlayer(), _targetName, _targetStats);
lore.add(" ");
addAchievements(category, lore, 9);
lore.add(" ");
@ -50,7 +50,7 @@ public class UHCMainPage extends AchievementMainPage
ShopItem shopItem = new ShopItem(category.getIcon(), category.getIconData(), C.Bold + category.getFriendlyName(), lore.toArray(new String[0]), 1, false, false);
addButton(slot, shopItem, button);
slot += ((slot + 1) % 9 == 0) ? 1 : 2;
slot += 4;
}
addBackButton();

View File

@ -8,15 +8,18 @@ import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
@ -31,7 +34,10 @@ 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.death.christmas.DeathPresentDanger;
import mineplex.core.gadget.gadgets.morph.MorphWitch;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuit;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitHelmet;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.HatGadget;
@ -168,6 +174,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlue + "Bonus Item Unlocked with Power Play Club");
}
}
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -16)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Gingerbread Chests");
}
//Rank Unlocks
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -10)
@ -305,10 +316,22 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
gadgetItemStack = ((MorphWitch) gadget).getWitchItem();
}
else if (gadget instanceof DeathPresentDanger)
{
gadgetItemStack = SkinData.PRESENT.getSkull();
}
else
{
gadgetItemStack = new ItemStack(gadget.getDisplayMaterial(), 1, gadget.getDisplayData());
}
if (gadget instanceof OutfitFreezeSuit && !(gadget instanceof OutfitFreezeSuitHelmet))
{
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) gadgetItemStack.getItemMeta();
leatherArmorMeta.setColor(Color.fromRGB(129, 212, 250));
gadgetItemStack.setItemMeta(leatherArmorMeta);
}
ItemMeta meta = gadgetItemStack.getItemMeta();
meta.setDisplayName(C.cGreen + C.Bold + gadget.getName());
if (gadget.getActive().contains(getPlayer()))

View File

@ -35,7 +35,7 @@ public class ParticlePage extends GadgetPage
slot++;
if (slot == 17 || slot == 26)
if (slot == 17 || slot == 26 || slot == 35)
slot += 2;
}

View File

@ -56,6 +56,7 @@ import mineplex.core.gadget.gadgets.arrowtrail.titan.ArrowTrailTitan;
import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood;
import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant;
import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane;
import mineplex.core.gadget.gadgets.death.christmas.DeathPresentDanger;
import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart;
import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald;
import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom;
@ -110,6 +111,7 @@ import mineplex.core.gadget.gadgets.morph.MorphBlaze;
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.MorphChristmasKing;
import mineplex.core.gadget.gadgets.morph.MorphCow;
import mineplex.core.gadget.gadgets.morph.MorphCreeper;
import mineplex.core.gadget.gadgets.morph.MorphEnderman;
@ -117,6 +119,7 @@ import mineplex.core.gadget.gadgets.morph.MorphGrimReaper;
import mineplex.core.gadget.gadgets.morph.MorphMetalMan;
import mineplex.core.gadget.gadgets.morph.MorphPig;
import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing;
import mineplex.core.gadget.gadgets.morph.MorphSanta;
import mineplex.core.gadget.gadgets.morph.MorphSlime;
import mineplex.core.gadget.gadgets.morph.MorphSnowman;
import mineplex.core.gadget.gadgets.morph.MorphSquid;
@ -129,6 +132,10 @@ 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.freezesuit.OutfitFreezeSuitBoots;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitHelmet;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitLeggings;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitBoots;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitHelmet;
@ -138,6 +145,7 @@ 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.outfit.windupsuit.OutfitWindUpSuitBoosterManager;
import mineplex.core.gadget.gadgets.particle.ParticleChristmasTree;
import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes;
import mineplex.core.gadget.gadgets.particle.ParticleFairy;
import mineplex.core.gadget.gadgets.particle.ParticleFireRings;
@ -168,6 +176,7 @@ 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.gadgets.wineffect.WinEffectWinterWarfare;
import mineplex.core.gadget.persistence.UserGadgetPersistence;
import mineplex.core.gadget.set.SetCandyCane;
import mineplex.core.gadget.set.SetCupidsLove;
@ -181,6 +190,7 @@ 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.SetFreezeSuit;
import mineplex.core.gadget.set.suits.SetRaveSuit;
import mineplex.core.gadget.set.suits.SetSpaceSuit;
import mineplex.core.gadget.types.ArrowEffectGadget;
@ -289,6 +299,7 @@ public class GadgetManager extends MiniPlugin
//Costumes
addSet(new SetRaveSuit(this));
addSet(new SetSpaceSuit(this));
addSet(new SetFreezeSuit(this));
// Hidden in this update
//addSet(new SetWindUpSuit(this));
addSet(new SetParty(this));
@ -341,6 +352,11 @@ public class GadgetManager extends MiniPlugin
addGadget(new OutfitWindUpSuitChestplate(this));
addGadget(new OutfitWindUpSuitLeggings(this));
addGadget(new OutfitWindUpSuitBoots(this));*/
addGadget(new OutfitFreezeSuitHelmet(this));
addGadget(new OutfitFreezeSuitChestplate(this));
addGadget(new OutfitFreezeSuitLeggings(this));
addGadget(new OutfitFreezeSuitBoots(this));
addGadget(new OutfitTeam(this, "Team Helmet", -1, ArmorSlot.Helmet, Material.LEATHER_HELMET, (byte)0));
addGadget(new OutfitTeam(this, "Team Shirt", -1, ArmorSlot.Chest, Material.LEATHER_CHESTPLATE, (byte)0));
@ -369,9 +385,10 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphGrimReaper(this));
addGadget(new MorphMetalMan(this));
addGadget(new MorphTurkey(this));
addGadget(new MorphChristmasKing(this));
// Not in this update
//addGadget(new MorphStray(this));
//addGadget(new MorphSanta(this));
addGadget(new MorphSanta(this));
// Particles
addGadget(new ParticleFoot(this));
@ -395,8 +412,8 @@ public class GadgetManager extends MiniPlugin
addGadget(new ParticleWingsPixie(this));
addGadget(new ParticleYinYang(this));
addGadget(new ParticleFreedom(this));
addGadget(new ParticleChristmasTree(this));
// Arrow Trails
addGadget(new ArrowTrailFrostLord(this));
addGadget(new ArrowTrailTitan(this));
@ -425,6 +442,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new DeathBlood(this));
addGadget(new DeathMusic(this));
addGadget(new DeathFreedom(this));
addGadget(new DeathPresentDanger(this));
// Double Jump
addGadget(new DoubleJumpFrostLord(this));
@ -459,6 +477,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new WinEffectRiseOfTheElderGuardian(this));
addGadget(new WinEffectLavaTrap(this));
addGadget(new WinEffectHalloween(this));
addGadget(new WinEffectWinterWarfare(this));
// Music
addGadget(new MusicGadget(this, "13 Disc", new String[] {""}, -2, 2256, 178000));
@ -569,6 +588,12 @@ public class GadgetManager extends MiniPlugin
event.getPlayer().setFlySpeed(0.1f);
// Loads saved gadgets
_userGadgetPersistence.load(event.getPlayer());
// Disables gadgets if there are more than 100 players in a server
if (UtilServer.getPlayers().length >= 100)
{
setGadgetEnabled(false);
}
}
public List<Gadget> getGadgets(GadgetType gadgetType)
@ -887,6 +912,12 @@ public class GadgetManager extends MiniPlugin
event.getPlayer().setWalkSpeed(0.2f);
event.getPlayer().setFlySpeed(0.1f);
_soulManager.giveSoul(event.getPlayer());
// Enables gadgets if there are less than 100 players
if (UtilServer.getPlayers().length < 100)
{
setGadgetEnabled(true);
}
}
@EventHandler

View File

@ -0,0 +1,33 @@
package mineplex.core.gadget.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class ToggleMobsEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private boolean _enable;
public ToggleMobsEvent(boolean enable)
{
_enable = enable;
}
public boolean enable()
{
return _enable;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -0,0 +1,92 @@
package mineplex.core.gadget.gadgets.death.christmas;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import mineplex.core.blood.BloodEvent;
import mineplex.core.common.skin.SkinData;
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.gadget.GadgetManager;
import mineplex.core.gadget.event.ToggleMobsEvent;
import mineplex.core.gadget.types.DeathEffectGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class DeathPresentDanger extends DeathEffectGadget
{
private List<ArmorStand> _armorStands = new ArrayList<>();
public DeathPresentDanger(GadgetManager manager)
{
super(manager, "Present Danger",
UtilText.splitLineToArray(C.cGray + "Leave behind a little gift for your enemies.", LineFormat.LORE),
-16,
Material.INK_SACK, (byte)1);
}
@Override
public void onBlood(Player player, BloodEvent event)
{
event.setCancelled(true);
Location loc = event.getLocation();
UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.WOOL, (byte) 14), loc, 0, 0, 0, 0.1f, 15, UtilParticle.ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.WOOL, (byte) 4), loc, 0, 0, 0, 0.1f, 15, UtilParticle.ViewDist.NORMAL);
Bukkit.getPluginManager().callEvent(new ToggleMobsEvent(true));
ArmorStand armorStand = loc.getWorld().spawn(loc.clone().subtract(0, 2.3, 0), ArmorStand.class);
armorStand.setVisible(false);
armorStand.setGravity(false);
armorStand.setSmall(true);
armorStand.setHelmet(SkinData.PRESENT.getSkull());
_armorStands.add(armorStand);
Bukkit.getPluginManager().callEvent(new ToggleMobsEvent(false));
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<ArmorStand> iterator = _armorStands.iterator();
while (iterator.hasNext())
{
ArmorStand armorStand = iterator.next();
if (armorStand.getTicksLived() >= 100 || !armorStand.isValid())
{
Location loc = armorStand.getEyeLocation();
UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.WOOL, (byte) 14), loc, 0, 0, 0, 0.1f, 15, UtilParticle.ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.WOOL, (byte) 4), loc, 0, 0, 0, 0.1f, 15, UtilParticle.ViewDist.NORMAL);
armorStand.remove();
iterator.remove();
}
}
}
@EventHandler
public void removeArrows(EntityDamageByEntityEvent event)
{
if (event.getEntity() instanceof ArmorStand)
{
if (_armorStands.contains(event.getEntity()))
{
event.setCancelled(true);
}
}
}
}

View File

@ -0,0 +1,171 @@
package mineplex.core.gadget.gadgets.morph;
import java.util.Map;
import java.util.WeakHashMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguiseSkeleton;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.recharge.RechargeData;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.visibility.VisibilityManager;
public class MorphChristmasKing extends MorphGadget
{
private Map<Projectile, Player> _snowball = new WeakHashMap<Projectile, Player>();
public MorphChristmasKing(GadgetManager manager)
{
super(manager, "Christmas Kings Head", UtilText.splitLinesToArray(new String[]
{
C.cGray + "Transforms the wearer into the",
C.cGray + "Pumpkin King's not so jolly Winter Form!",
"",
C.cBlue + "Earned by defeating the Pumpkin King",
C.cBlue + "in the 2016 Christmas Chaos Event",
C.blankLine,
"#" + C.cWhite + "Sneak to use Snowstorm"
}, LineFormat.LORE),
-1,
Material.PUMPKIN, (byte)0);
}
@Override
public void enableCustom(final Player player, boolean message)
{
this.applyArmor(player, message);
DisguiseSkeleton disguise = new DisguiseSkeleton(player);
disguise.showArmor();
disguise.SetSkeletonType(SkeletonType.WITHER);
UtilMorph.disguise(player, disguise, Manager);
player.getInventory().setHelmet(new ItemStack(Material.JACK_O_LANTERN));
VisibilityManager.Instance.setVisibility(player, false, UtilServer.getPlayers());
VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers());
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
player.getInventory().setHelmet(null);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.FASTEST)
{
for (Player player : getActive())
{
NautHashMap<String, RechargeData> map = Recharge.Instance.Get(player);
if (map == null)
continue;
RechargeData data = map.get("Snowstorm");
if (data == null)
continue;
if (data.GetRemaining() < 25000)
continue;
for (int i = 0; i < 6; i++)
{
Snowball snow = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Snowball.class);
double x = 0.1 - (UtilMath.r(20)/100d);
double y = UtilMath.r(20)/100d;
double z = 0.1 - (UtilMath.r(20)/100d);
snow.setShooter(player);
snow.setVelocity(player.getLocation().getDirection().add(new Vector(x,y,z)).multiply(2));
_snowball.put(snow, player);
}
//Effect
player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 0.2f, 0.5f);
}
}
if (event.getType() == UpdateType.TICK)
{
for (Player player : getActive())
{
if (Manager.isMoving(player))
{
continue;
}
for (double y = 0; y < 5; y++)
{
double sin = Math.sin(y);
double cos = Math.cos(y);
Location loc1 = player.getLocation().add(sin, y, cos);
Location loc2 = player.getLocation().add(cos, y, sin);
UtilParticle.PlayParticleToAll(ParticleType.SNOWBALL_POOF, loc1, null, 0, 1, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.SNOWBALL_POOF, loc2, null, 0, 1, ViewDist.NORMAL);
}
}
}
}
@EventHandler
public void onSneak(PlayerToggleSneakEvent event)
{
if (!isActive(event.getPlayer()))
return;
if (!event.isSneaking())
return;
if (Recharge.Instance.use(event.getPlayer(), "Snowstorm", 30000, true, true))
{
event.getPlayer().sendMessage(F.main("Recharge", "You used " + F.skill("Snowstorm") + "."));
}
}
@EventHandler
public void onSnowballHit(EntityDamageByEntityEvent event)
{
if (!(event.getDamager() instanceof Snowball))
return;
Snowball proj = (Snowball) event.getDamager();
if (!_snowball.containsKey(proj))
return;
if (Manager.collideEvent(_snowball.remove(proj), this, event.getEntity()))
return;
UtilAction.velocity(event.getEntity(), proj.getVelocity().multiply(0.15).add(new Vector(0, 0.15, 0)));
}
}

View File

@ -1,22 +1,48 @@
package mineplex.core.gadget.gadgets.morph;
import java.util.List;
import java.util.Map;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.disguise.disguises.DisguiseSkeleton;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.visibility.VisibilityManager;
public class MorphPumpkinKing extends MorphGadget
{
private static final int CROWN_POINTS = 12;
private List<JackOBomb> _bombs = Lists.newArrayList();
public MorphPumpkinKing(GadgetManager manager)
{
super(manager, "Pumpkin Kings Head", UtilText.splitLinesToArray(new String[]
@ -24,7 +50,9 @@ public class MorphPumpkinKing extends MorphGadget
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"
C.cBlue + "in the 2013 Halloween Horror Event",
C.blankLine,
"#" + C.cWhite + "Sneak to use Jack O Bomb"
}, LineFormat.LORE),
-1,
Material.PUMPKIN, (byte)0);
@ -54,6 +82,95 @@ public class MorphPumpkinKing extends MorphGadget
UtilMorph.undisguise(player, Manager.getDisguiseManager());
player.getInventory().setHelmet(null);
}
}
@EventHandler
public void onSneak(PlayerToggleSneakEvent event)
{
if (!isActive(event.getPlayer()))
return;
if (!event.isSneaking())
return;
if (Recharge.Instance.use(event.getPlayer(), "Jack O Bomb", 30000, true, true))
{
event.getPlayer().sendMessage(F.main("Recharge", "You used " + F.skill("Jack O Bomb") + "."));
_bombs.add(new JackOBomb(event.getPlayer(), event.getPlayer().getLocation().add(event.getPlayer().getEyeLocation().getDirection().normalize())));
}
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
{
for (Player player : getActive())
{
if (Manager.isMoving(player))
{
continue;
}
for (int i = 0; i < 360; i += 360/CROWN_POINTS)
{
double angle = (i * Math.PI / 180);
double x = 0.5 * Math.cos(angle);
double z = 0.5 * Math.sin(angle);
Location loc = player.getEyeLocation().add(x, 1.4, z);
UtilParticle.PlayParticleToAll(ParticleType.FLAME, loc, null, 0, 1, ViewDist.NORMAL);
}
}
_bombs.removeIf(bomb -> bomb.update());
}
}
private class JackOBomb
{
private Player _user;
private Item _ent;
private DisguiseBlock _disguise;
private long _detonation;
private boolean _done;
public JackOBomb(Player user, Location spawnLocation)
{
_user = user;
_ent = spawnLocation.getWorld().dropItem(spawnLocation, new ItemBuilder(Material.APPLE).setTitle(new Random().nextDouble() + "").build());
_ent.setPickupDelay(Integer.MAX_VALUE);
_disguise = new DisguiseBlock(_ent, Material.JACK_O_LANTERN.getId(), 0);
Manager.getDisguiseManager().disguise(_disguise);
_detonation = System.currentTimeMillis() + 7000;
_done = false;
}
public boolean update()
{
if (_done)
{
return true;
}
if (System.currentTimeMillis() >= _detonation)
{
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _ent.getLocation(), null, 0, 1, ViewDist.NORMAL);
Map<Player, Double> players = UtilPlayer.getInRadius(_ent.getLocation(), 8);
for (Player player : players.keySet())
{
if (Manager.collideEvent(_user, MorphPumpkinKing.this, player))
continue;
double mult = players.get(player);
//Knockback
UtilAction.velocity(player, UtilAlg.getTrajectory(_ent.getLocation(), player.getLocation()), 1 * mult, false, 0, 0.5 + 0.5 * mult, 10, true);
}
Manager.getDisguiseManager().undisguise(_disguise);
_ent.remove();
_done = true;
}
return false;
}
}
}

View File

@ -6,6 +6,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import mineplex.core.common.util.*;
import mineplex.core.recharge.Recharge;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
@ -24,17 +26,6 @@ import com.mojang.authlib.GameProfile;
import mineplex.core.common.currency.GlobalCurrency;
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.UtilAction;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.SantaPresent;
@ -49,12 +40,20 @@ public class MorphSanta extends MorphGadget
{
private HashMap<Item, SantaPresent> _items = new HashMap<>();
// For some reason, present.getTicksLived() is not doing the right job here
private HashMap<Item, Long> _spawnTime = new HashMap<>();
private static final int SHARD_CHARGE = 50;
public MorphSanta(GadgetManager manager)
{
super(manager, "Santa Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), -14, Material.STAINED_CLAY, (byte) 14, YearMonth.of(2016, Month.DECEMBER));
super(manager, "Santa Morph", UtilText.splitLinesToArray(new String[]{
C.cGray + "We're all Santa now this Holiday Season!",
"",
C.cWhite + "Left click to deliver a random gift for players who have been Naughty or Nice!",
"",
C.cRedB + "WARNING: " + ChatColor.RESET + "Delivering a gift uses shards!"
}, LineFormat.LORE), -14, Material.STAINED_CLAY, (byte) 14, YearMonth.of(2016, Month.DECEMBER));
}
@Override
@ -79,8 +78,6 @@ public class MorphSanta extends MorphGadget
UtilMorph.undisguise(player, Manager.getDisguiseManager());
}
// PRESENT
@EventHandler
public void throwPresent(PlayerInteractEvent event)
{
@ -102,9 +99,6 @@ public class MorphSanta extends MorphGadget
if (player.getItemInHand().getType() != Material.AIR)
return;
//if (!Recharge.Instance.use(player, getName(), 150000, true, false, "Cosmetics"))
//return;
if (type == 0)
{
int shards = UtilMath.rRange(250, 500);
@ -115,8 +109,11 @@ public class MorphSanta extends MorphGadget
return;
}
if (!Recharge.Instance.use(player, "Hide Gift", 30000, true, false, "Cosmetics"))
return;
Item present = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()),
SkinData.PRESENT.getSkull("Present " + System.currentTimeMillis(), new ArrayList<>()));
SkinData.PRESENT.getSkull("Hidden Present " + System.currentTimeMillis(), new ArrayList<>()));
UtilAction.velocity(present, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false);
Manager.getDonationManager().RewardCoinsLater(this.getName() + " Present Hide", player, -(shards + SHARD_CHARGE));
@ -124,6 +121,7 @@ public class MorphSanta extends MorphGadget
present.setPickupDelay(40);
_items.put(present, new SantaPresent(player.getName(), SantaPresent.PresentType.PRESENT, shards));
_spawnTime.put(present, System.currentTimeMillis());
//Announce
Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() +
@ -137,6 +135,9 @@ public class MorphSanta extends MorphGadget
}
else
{
if (!Recharge.Instance.use(player, "Hide Gift", 30000, true, false, "Cosmetics"))
return;
ItemStack coalStack = ItemStackFactory.Instance.CreateStack(Material.COAL, (byte)0, 1, "Hidden Coal" + System.currentTimeMillis());
Item coal = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), coalStack);
UtilAction.velocity(coal, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false);
@ -146,6 +147,7 @@ public class MorphSanta extends MorphGadget
coal.setPickupDelay(40);
_items.put(coal, new SantaPresent(player.getName(), SantaPresent.PresentType.COAL, coals));
_spawnTime.put(coal, System.currentTimeMillis());
//Announce
Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() +
@ -167,6 +169,7 @@ public class MorphSanta extends MorphGadget
SantaPresent santaPresent = _items.get(event.getItem());
_items.remove(event.getItem());
_spawnTime.remove(event.getItem());
event.setCancelled(true);
event.getItem().remove();
@ -225,7 +228,7 @@ public class MorphSanta extends MorphGadget
{
Item presentItem = presentIter.next();
if (!presentItem.isValid() || presentItem.getTicksLived() > 24000)
if (!presentItem.isValid() || UtilTime.elapsed(_spawnTime.get(presentItem), 60 * 10000))
{
SantaPresent santaPresent = _items.get(presentItem);
@ -273,7 +276,7 @@ public class MorphSanta extends MorphGadget
}
@EventHandler
public void presentDespawnCancel(ItemDespawnEvent event)
public void cancelDespawn(ItemDespawnEvent event)
{
if (_items.containsKey(event.getEntity()))
event.setCancelled(true);

View File

@ -0,0 +1,102 @@
package mineplex.core.gadget.gadgets.outfit.freezesuit;
import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilMath;
public class FreezeSuitPathData
{
private ArrayList<Block> _blocks;
public FreezeSuitPathData(Player player)
{
_blocks = new ArrayList<>();
//Add Blocks
if (Math.abs(player.getLocation().getDirection().getX()) > Math.abs(player.getLocation().getDirection().getZ()))
{
getBlocks(player.getLocation().add(0, 0, 1), 16);
getBlocks(player.getLocation().add(0, 0, -1), 16);
}
else
{
getBlocks(player.getLocation().add(1, 0, 0), 16);
getBlocks(player.getLocation().add(-1, 0, 0), 16);
}
getBlocks(player.getLocation(), 16);
//Sort Blocks
for (int i=0 ; i<_blocks.size() ; i++)
{
for (int j=0 ; j+1<_blocks.size() ; j++)
{
if (UtilMath.offset(player.getLocation(), _blocks.get(j).getLocation().add(0.5, 0.5, 0.5)) >
UtilMath.offset(player.getLocation(), _blocks.get(j+1).getLocation().add(0.5, 0.5, 0.5)))
{
Block temp = _blocks.get(j);
_blocks.set(j, _blocks.get(j+1));
_blocks.set(j+1, temp);
}
}
}
}
public void getBlocks(Location loc, int length)
{
//Below Player
loc.subtract(0, 1, 0);
Vector dir = loc.getDirection();
double hLength = Math.sqrt(dir.getX()*dir.getX() + dir.getZ()*dir.getZ());
if (Math.abs(dir.getY()) > hLength)
{
if (dir.getY() > 0)
dir.setY(hLength);
else
dir.setY(-hLength);
dir.normalize();
}
//Backtrack
loc.subtract(dir.clone().multiply(2));
double dist = 0;
while (dist < length)
{
dist += 0.2;
loc.add(dir.clone().multiply(0.2));
if (loc.getBlock().getType() == Material.ICE)
continue;
if (loc.getBlock().getType() == Material.AIR || loc.getBlock().getType() == Material.SNOW)
{
if (!_blocks.contains(loc.getBlock()))
{
_blocks.add(loc.getBlock());
}
}
}
}
public Block getNextBlock()
{
if (_blocks.isEmpty())
return null;
return _blocks.remove(0);
}
}

View File

@ -0,0 +1,175 @@
package mineplex.core.gadget.gadgets.outfit.freezesuit;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.OutfitGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class OutfitFreezeSuit extends OutfitGadget
{
private Set<FreezeSuitPathData> _data = new HashSet<>();
private Map<UUID, Integer> _failedAttempts = new HashMap<>();
private static final int DURATION = 2000;
private static final int RANGE = 3;
private static final int MELT_TIME = 6000;
private static final int COOLDOWN = 15000;
public OutfitFreezeSuit(GadgetManager manager, String name, int cost, ArmorSlot slot, Material mat, byte data)
{
super(manager, name,
UtilText.splitLineToArray(C.cGray + "Stolen directly from the Winter Lord's closet, this coat is designed to " +
"survive the coldest of weather! Press sneak to generate your ice bridge.", LineFormat.LORE),
cost, slot, mat, data);
setColor(Color.fromRGB(129, 212, 250));
}
@Override
public void enableCustom(Player player, boolean message)
{
applyArmor(player, message);
}
@Override
public void disableCustom(Player player, boolean message)
{
removeArmor(player, message);
}
@EventHandler
public void activateBridge(PlayerToggleSneakEvent event)
{
// Prevents running event 4 times
if (getSlot() != ArmorSlot.Helmet)
return;
if (!setActive(event.getPlayer()))
return;
if (!event.isSneaking())
return;
if (!Recharge.Instance.use(event.getPlayer(), "Ice Path", COOLDOWN, true, false, "Cosmetics"))
return;
Player player = event.getPlayer();
player.teleport(player.getLocation().add(0, 1, 0));
UtilAction.velocity(player, new Vector(0, 0.5, 0));
_data.add(new FreezeSuitPathData(player));
}
@EventHandler
public void snowAura(UpdateEvent event)
{
// Prevents running event 4 times
if (getSlot() != ArmorSlot.Helmet)
return;
if (event.getType() != UpdateType.FAST)
return;
for(Player player : UtilServer.getPlayers())
{
if (!setActive(player))
{
continue;
}
UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.SNOW_SHOVEL, player.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0.1f, 1, UtilParticle.ViewDist.NORMAL);
Map<Block, Double> blocks = UtilBlock.getInRadius(player.getLocation(), RANGE);
boolean setBlocks = true, forceBreak = false;
for (Block block : blocks.keySet())
{
if (Manager.getTreasureManager() != null)
{
if (Manager.getTreasureManager().isOpening(player))
{
forceBreak= true;
}
for (Location blockLocation : Manager.getTreasureManager().getBlockLocations())
{
if (blockLocation.distanceSquared(block.getLocation()) <= 25)
{
setBlocks = false;
}
}
}
if (forceBreak)
break;
if (!setBlocks)
continue;
Manager.getBlockRestore().snow(block, (byte) 1, (byte) 1, (int) (DURATION * (1 + blocks.get(block))), 250, 0);
}
}
}
@EventHandler
public void icePath(UpdateEvent event)
{
// Prevents running event 4 times
if (getSlot() != ArmorSlot.Helmet)
return;
if (event.getType() != UpdateType.TICK)
return;
Iterator<FreezeSuitPathData> dataIterator = _data.iterator();
while (dataIterator.hasNext())
{
FreezeSuitPathData data = dataIterator.next();
Block block = data.getNextBlock();
if (block == null)
{
dataIterator.remove();
}
else
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 79);
Manager.getBlockRestore().add(block, 79, (byte) 0, MELT_TIME);
}
}
}
private boolean setActive(Player player)
{
return getSet() != null && getSet().isActive(player);
}
}

View File

@ -0,0 +1,15 @@
package mineplex.core.gadget.gadgets.outfit.freezesuit;
import org.bukkit.Material;
import mineplex.core.gadget.GadgetManager;
public class OutfitFreezeSuitBoots extends OutfitFreezeSuit
{
public OutfitFreezeSuitBoots(GadgetManager manager)
{
super(manager, "Freeze Boots", -16, ArmorSlot.Boots, Material.LEATHER_BOOTS, (byte) 0);
}
}

View File

@ -0,0 +1,15 @@
package mineplex.core.gadget.gadgets.outfit.freezesuit;
import org.bukkit.Material;
import mineplex.core.gadget.GadgetManager;
public class OutfitFreezeSuitChestplate extends OutfitFreezeSuit
{
public OutfitFreezeSuitChestplate(GadgetManager manager)
{
super(manager, "Freeze Chest", -16, ArmorSlot.Chest, Material.LEATHER_CHESTPLATE, (byte) 0);
}
}

View File

@ -0,0 +1,15 @@
package mineplex.core.gadget.gadgets.outfit.freezesuit;
import org.bukkit.Material;
import mineplex.core.gadget.GadgetManager;
public class OutfitFreezeSuitHelmet extends OutfitFreezeSuit
{
public OutfitFreezeSuitHelmet(GadgetManager manager)
{
super(manager, "Freeze Helmet", -16, ArmorSlot.Helmet, Material.ICE, (byte) 0);
}
}

View File

@ -0,0 +1,15 @@
package mineplex.core.gadget.gadgets.outfit.freezesuit;
import org.bukkit.Material;
import mineplex.core.gadget.GadgetManager;
public class OutfitFreezeSuitLeggings extends OutfitFreezeSuit
{
public OutfitFreezeSuitLeggings(GadgetManager manager)
{
super(manager, "Freeze Leggings", -16, ArmorSlot.Legs, Material.LEATHER_LEGGINGS, (byte) 0);
}
}

View File

@ -0,0 +1,58 @@
package mineplex.core.gadget.gadgets.particle;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.particleeffects.ChristmasTreeEffect;
import mineplex.core.updater.event.UpdateEvent;
public class ParticleChristmasTree extends ParticleGadget
{
private Map<UUID, ChristmasTreeEffect> _effects = new HashMap<>();
public ParticleChristmasTree(GadgetManager manager)
{
super(manager, "Holiday Tree", UtilText.splitLinesToArray(new String[]{C.cGray +
"There's nothing like a well decorated tree to bring in the Holiday Spirit."}, LineFormat.LORE),
-16, Material.SAPLING, (byte) 1);
}
@Override
public void playParticle(Player player, UpdateEvent event)
{
}
@Override
public void startEffect(Player player)
{
if (!_effects.containsKey(player.getUniqueId()))
{
ChristmasTreeEffect christmasTreeEffect = new ChristmasTreeEffect(Manager.getPlugin(), player, Manager);
christmasTreeEffect.start();
_effects.put(player.getUniqueId(), christmasTreeEffect);
}
}
@Override
public void stopEffect(Player player)
{
if (_effects.containsKey(player.getUniqueId()))
{
ChristmasTreeEffect christmasTreeEffect = _effects.get(player.getUniqueId());
christmasTreeEffect.stop();
_effects.remove(player.getUniqueId());
}
}
}

View File

@ -0,0 +1,174 @@
package mineplex.core.gadget.gadgets.wineffect;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.block.schematic.SchematicData;
import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilMath;
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;
import mineplex.core.updater.UpdateType;
public class WinEffectWinterWarfare extends WinEffectGadget
{
private Schematic _sleigh;
private Location _sleighLocation;
private DisguisePlayer _npc;
private Entity _entity;
private SchematicData _data;
private List<ArmorStand> _playersLeft;
public WinEffectWinterWarfare(GadgetManager manager)
{
super(manager, "Winter Warfare", UtilText.splitLinesToArray(new String[]{C.cGray +
"Santa isn't only packing coal for the bad girls and boys this year!"}, LineFormat.LORE), -16, Material.TNT, (byte) 0);
_schematicName = "WinterWarfare";
try
{
_sleigh = UtilSchematic.loadSchematic(new File("../../update/schematic/WinterWarfareSleigh.schematic"));
} catch (IOException e)
{
_sleigh = null;
e.printStackTrace();
}
}
@Override
public void play()
{
_sleighLocation = getBaseLocation().clone().subtract(0, -2, 0);
pasteSleigh();
Location npcLocation = _sleighLocation.clone().add(44, 11, 4);
npcLocation.setYaw(90);
npcLocation.setPitch(0);
_npc = getNPC(_player, npcLocation);
List<Location> circle = UtilShapes.getPointsInCircle(getBaseLocation().clone().subtract(0, 2, 0), _other.size(), 3);
_playersLeft = new ArrayList<>();
for(int i = 0; i < _other.size(); i++)
{
_playersLeft.add((ArmorStand) getNPC(_other.get(i), circle.get(i)).getEntity().getBukkitEntity());
}
}
@Override
public void finish()
{
Manager.getDisguiseManager().undisguise(_npc);
_npc = null;
}
@Override
public void teleport()
{
Location loc = getBaseLocation().clone().subtract(0, -5, 15);
loc.setDirection(getBaseLocation().subtract(loc).toVector());
super.teleport(loc);
}
@Override
public void update(UpdateType type)
{
if (!isRunning())
return;
if (_sleighLocation == null)
return;
if (type == UpdateType.FAST)
{
if (_npc == null)
return;
TNTPrimed tnt = _sleighLocation.getWorld().spawn(_npc.getEntity().getBukkitEntity().getLocation().add(0, 3, 0), TNTPrimed.class);
int r = UtilMath.random.nextInt(50);
Vector vel = new Vector(Math.sin(r * 9/5d), 0, Math.cos(r * 9/5d));
UtilAction.velocity(tnt, vel, Math.abs(Math.sin(r * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(r * 12/3000d))*0.6, 1, false);
}
if (type != UpdateType.TICK)
return;
// Teleports sleigh
_sleighLocation = _sleighLocation.subtract(1, 0, 0);
pasteSleigh();
if (_npc == null)
return;
Location npcLocation = _sleighLocation.clone().add(44, 11, 4);
npcLocation.setYaw(90);
npcLocation.setPitch(0);
_npc.getEntity().getBukkitEntity().teleport(npcLocation);
}
private void pasteSleigh()
{
if (_sleigh != null)
{
_data = _sleigh.paste(_sleighLocation);
}
}
@EventHandler
public void onTNTExplode(EntityExplodeEvent event)
{
if (!isRunning())
return;
if (_playersLeft == null)
return;
if (_playersLeft.size() < 1)
return;
if (!(event.getEntity() instanceof TNTPrimed))
return;
boolean removePlayers = false;
for(ArmorStand armorStand : _playersLeft)
{
if (armorStand.getLocation().distanceSquared(event.getEntity().getLocation()) <= 25)
{
removePlayers = true;
break;
}
}
if (!removePlayers)
return;
for(ArmorStand player : _playersLeft)
{
player.getWorld().playSound(player.getLocation(), Sound.VILLAGER_HIT, 2, 1);
player.getWorld().playSound(player.getLocation(), Sound.VILLAGER_DEATH, 1, 1);
player.remove();
}
_playersLeft.clear();
}
}

View File

@ -0,0 +1,22 @@
package mineplex.core.gadget.set.suits;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitBoots;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitHelmet;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitLeggings;
import mineplex.core.gadget.types.GadgetSet;
public class SetFreezeSuit extends GadgetSet
{
public SetFreezeSuit(GadgetManager manager)
{
super(manager, "Freeze Suit", "Grants the wearer a \"snow aura\" abd the ability to summon a bridge of ice.",
manager.getGadget(OutfitFreezeSuitHelmet.class),
manager.getGadget(OutfitFreezeSuitChestplate.class),
manager.getGadget(OutfitFreezeSuitLeggings.class),
manager.getGadget(OutfitFreezeSuitBoots.class));
}
}

View File

@ -1,12 +1,14 @@
package mineplex.core.gadget.types;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.itemstack.ItemStackFactory;
public abstract class OutfitGadget extends Gadget
{
@ -31,18 +33,29 @@ public abstract class OutfitGadget extends Gadget
}
protected ArmorSlot _slot;
protected Color _color = null;
public OutfitGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data, String... altNames)
{
super(manager, GadgetType.COSTUME, name, desc, cost, mat, data, 1, altNames);
_slot = slot;
}
}
public ArmorSlot getSlot()
{
return _slot;
}
public void setColor(Color color)
{
_color = color;
}
public Color getColor()
{
return _color;
}
public void applyArmor(Player player, boolean message)
{
@ -54,18 +67,26 @@ public abstract class OutfitGadget extends Gadget
if (message)
UtilPlayer.message(player, F.main("Gadget", "You put on " + F.elem(getName()) + "."));
ItemStack itemStack = new ItemStack(getDisplayMaterial(), 1, getDisplayData());
if (getColor() != null)
{
if (itemStack.getItemMeta() instanceof LeatherArmorMeta)
{
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) itemStack.getItemMeta();
leatherArmorMeta.setColor(getColor());
leatherArmorMeta.setDisplayName(getName());
itemStack.setItemMeta(leatherArmorMeta);
}
}
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(itemStack);
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(
ItemStackFactory.Instance.CreateStack(getDisplayMaterial().getId(), getDisplayData(), 1, getName()));
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(itemStack);
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(
ItemStackFactory.Instance.CreateStack(getDisplayMaterial().getId(), getDisplayData(), 1, getName()));
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(itemStack);
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(
ItemStackFactory.Instance.CreateStack(getDisplayMaterial().getId(), getDisplayData(), 1, getName()));
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(
ItemStackFactory.Instance.CreateStack(getDisplayMaterial().getId(), getDisplayData(), 1, getName()));
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(itemStack);
}
public void removeArmor(Player player, boolean message)

View File

@ -6,16 +6,11 @@ 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.FireworkEffect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
@ -27,6 +22,21 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
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.C;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
/**
* A wrapper for different win effects
*/
@ -128,6 +138,12 @@ public abstract class WinEffectGadget extends Gadget
* cleared.
*/
public abstract void finish();
/**
* This method is called when an update happens
* @param type The type of the update
*/
public void update(UpdateType type){};
public boolean isRunning()
{
@ -236,6 +252,8 @@ public abstract class WinEffectGadget extends Gadget
@EventHandler
public void onUpdate(UpdateEvent event)
{
update(event.getType());
if (event.getType() != UpdateType.TICK)
return;

View File

@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
@ -29,6 +30,7 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
@ -1065,4 +1067,29 @@ public class ItemStackFactory extends MiniPlugin
{
_nameFormat = format;
}
public ItemStack createColoredLeatherArmor(int slot, Color color)
{
Material material = Material.LEATHER_HELMET;
switch (slot)
{
case 0:
material = Material.LEATHER_HELMET;
break;
case 1:
material = Material.LEATHER_CHESTPLATE;
break;
case 2:
material = Material.LEATHER_LEGGINGS;
break;
case 3:
material = Material.LEATHER_BOOTS;
break;
}
ItemStack stack = CreateStack(material);
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) stack.getItemMeta();
leatherArmorMeta.setColor(color);
stack.setItemMeta(leatherArmorMeta);
return stack;
}
}

View File

@ -17,12 +17,18 @@ public class BabyFireworkEffect extends Effect
private Color _fireworkColor;
private Location _fireworkLocation;
private Random _random = new Random();
private int _count = 0, _fireworkCount = 0;
private int _count = 0, _fireworkCount = 0, _maxCount = -1;
private boolean _multipleColors = false;
private int _currentColor = 0;
private Color[] _colors;
private boolean _trail = true;
public BabyFireworkEffect(Location location, JavaPlugin javaPlugin, Color color)
{
this(location, javaPlugin, color, -1);
}
public BabyFireworkEffect(Location location, JavaPlugin javaPlugin, Color color, int maxCount)
{
super(10, new EffectLocation(location), javaPlugin, 2);
_fireworkColor = color;
@ -34,6 +40,7 @@ public class BabyFireworkEffect extends Effect
}
_colors = new Color[0];
_maxCount = maxCount;
}
public BabyFireworkEffect(Location location, JavaPlugin javaPlugin, Color... colors)
@ -50,9 +57,30 @@ public class BabyFireworkEffect extends Effect
_count = count;
}
public void setTrail(boolean trail)
{
_trail = trail;
}
@Override
public void onStart()
{
if (!_trail)
{
_count = 6;
}
}
@Override
public void runEffect()
{
if (_maxCount != -1)
{
if (_maxCount >= _fireworkCount)
{
stop();
}
}
if (_count == 0)
{
double randX = _random.nextDouble() * 2 - 1, randY = _random.nextDouble() + .5,

View File

@ -0,0 +1,76 @@
package mineplex.core.particleeffects;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.gadget.GadgetManager;
public class ChristmasTreeEffect extends Effect
{
private Player _player;
private JavaPlugin _plugin;
private int _count = 0;
private double _currentRadius = 0;
private double _currentY = 0;
private BabyFireworkEffect _babyFireworkEffect = null;
private GadgetManager _manager;
private static final double MAX_RADIUS = 1.;
private static final double MAX_Y = 2.5;
public ChristmasTreeEffect(JavaPlugin plugin, Player player, GadgetManager manager)
{
super(-1, new EffectLocation(player), plugin, 5);
_player = player;
_plugin = plugin;
_manager = manager;
}
@Override
public void runEffect()
{
if (_manager.isMoving(_player))
{
Location loc = _player.getLocation().add(0, 1.2, 0).add(_player.getLocation().getDirection().multiply(-0.2));
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(Color.MAROON), loc);
coloredParticle.display();
coloredParticle.setColor(new DustSpellColor(Color.GREEN));
coloredParticle.display();
return;
}
if (_currentY < MAX_Y)
{
double radius = MAX_RADIUS - _currentRadius;
_currentRadius += 0.1;
CircleEffect circleEffect = new CircleEffect(_plugin, _player.getLocation().clone().add(0, _currentY, 0), radius, Color.GREEN);
circleEffect.addRandomColor(Color.RED);
circleEffect.addRandomColor(Color.YELLOW);
circleEffect.start();
_currentY += 0.25;
}
else
{
BabyFireworkEffect babyFireworkEffect = new BabyFireworkEffect(_player.getLocation().clone().add(0, MAX_Y + .5, 0), _plugin, Color.YELLOW, 1);
babyFireworkEffect.setTrail(false);
babyFireworkEffect.start();
_babyFireworkEffect = babyFireworkEffect;
_babyFireworkEffect.setCallback(new Callback<Effect>()
{
@Override
public void run(Effect data)
{
_currentY = 0;
_currentRadius = 0;
}
});
}
}
}

View File

@ -0,0 +1,119 @@
package mineplex.core.particleeffects;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
public class CircleEffect extends Effect
{
private double _radius;
private Color _color;
private int _steps = 0;
private boolean _instantly = true;
private List<Color> _randomColors = new ArrayList<>();
private int _maxCircles = -1;
private int _totalCircles = 0;
private static final double RANDOM_COLOR_CHANCE = 0.5;
private static final int PARTICLES_PER_CIRCLE = 20;
public CircleEffect(JavaPlugin plugin, Location location, double radius, Color color)
{
super(-1, new EffectLocation(location), plugin);
_radius = radius;
_color = color;
}
public CircleEffect(JavaPlugin plugin, Location location, double radius, Color color, boolean instantly)
{
this(plugin, location, radius, color);
_instantly = instantly;
}
public void addRandomColor(Color color)
{
_randomColors.add(color);
}
public void setMaxCircles(int circles)
{
_maxCircles = circles;
}
@Override
public void runEffect()
{
if (_instantly)
{
for (int i = 0; i < PARTICLES_PER_CIRCLE; i++)
{
Location location = getEffectLocation().getFixedLocation();
double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE;
double angle = _steps * increment;
Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius);
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(_color), location.add(vector));
coloredParticle.display();
if (_randomColors.size() > 0)
{
double r = UtilMath.random.nextDouble();
if (r < RANDOM_COLOR_CHANCE)
{
coloredParticle.setColor(new DustSpellColor(getRandomColor()));
coloredParticle.display();
}
}
_steps++;
}
stop();
}
else
{
if (_maxCircles != -1)
{
if (_totalCircles >= _maxCircles)
{
stop();
return;
}
}
Location location = getEffectLocation().getFixedLocation();
double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE;
double angle = _steps * increment;
Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius);
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(_color), location.add(vector));
coloredParticle.display();
if (_randomColors.size() > 0)
{
double r = UtilMath.random.nextDouble();
if (r < RANDOM_COLOR_CHANCE)
{
coloredParticle.setColor(new DustSpellColor(getRandomColor()));
coloredParticle.display();
}
}
_steps++;
if (_steps >= PARTICLES_PER_CIRCLE)
{
_totalCircles++;
_steps = 0;
}
}
}
private Color getRandomColor()
{
int r = UtilMath.random.nextInt(_randomColors.size());
return _randomColors.get(r);
}
}

View File

@ -3,6 +3,8 @@ package mineplex.core.particleeffects;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.Callback;
public abstract class Effect
{
@ -12,6 +14,7 @@ public abstract class Effect
public EffectLocation _targetLocation;
protected JavaPlugin _javaPlugin;
private boolean _running = false;
private Callback<Effect> _callback;
public Effect(int ticks, EffectLocation effectLocation, JavaPlugin javaPlugin)
{
@ -47,6 +50,8 @@ public abstract class Effect
{
_running = false;
Bukkit.getScheduler().cancelTask(_task);
if (_callback != null)
_callback.run(this);
onStop();
}
@ -83,4 +88,9 @@ public abstract class Effect
return _effectLocation;
}
public void setCallback(Callback<Effect> callback)
{
_callback = callback;
}
}

View File

@ -0,0 +1,33 @@
package mineplex.core.particleeffects.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.core.particleeffects.Effect;
public class EffectStopEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Effect _effect;
public EffectStopEvent(Effect effect)
{
_effect = effect;
}
public Effect getEffect()
{
return _effect;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -1,31 +1,32 @@
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.Creature;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class GrimReaperPetManager
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
public class FlyingPetManager
{
/**
* Makes the Grim Reaper Pet fly around the player
* Makes the Fkying pets fly around the player
* Copied from {@link mineplex.core.gadget.gadgets.particle.ParticleFairyData}
*/
private Player _player;
private Blaze _blaze;
private Creature _pet;
private Location _grimReaperLoc, _target;
private Vector _direction;
private double _speed;
private long _idleTime;
public GrimReaperPetManager(Player player, Blaze blaze)
public FlyingPetManager(Player player, Creature pet)
{
_player = player;
_blaze = blaze;
_pet = pet;
_grimReaperLoc = player.getEyeLocation();
_target = getNewTarget();
_speed = 0.2;
@ -73,8 +74,8 @@ public class GrimReaperPetManager
if (UtilMath.offset(_grimReaperLoc, _target) > 0.1)
_grimReaperLoc.add(_direction.clone().multiply(_speed));
_blaze.teleport(_grimReaperLoc);
_blaze.setVelocity(new Vector(0, .25, 0));
_pet.teleport(_grimReaperLoc);
_pet.setVelocity(new Vector(0, .25, 0));
}
private Location getNewTarget()

View File

@ -8,15 +8,18 @@ import java.util.Map.Entry;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.EntityCreature;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NavigationAbstract;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPigZombie;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Blaze;
@ -30,6 +33,7 @@ import org.bukkit.entity.Villager;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent;
@ -49,6 +53,8 @@ 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.F;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
@ -56,6 +62,7 @@ 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.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseChicken;
@ -65,6 +72,7 @@ import mineplex.core.disguise.disguises.DisguiseZombie;
import mineplex.core.donation.DonationManager;
import mineplex.core.events.AddConditionEvent;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.pet.repository.PetRepository;
import mineplex.core.pet.repository.token.ClientPetTokenWrapper;
import mineplex.core.updater.UpdateType;
@ -90,7 +98,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
private CoreClientManager _clientManager;
private InventoryManager _inventoryManager;
private Map<Blaze, GrimReaperPetManager> _grimReaperMorphs = new HashMap<>();
private Map<Creature, FlyingPetManager> _flyingPets = 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);
@ -222,6 +230,28 @@ public class PetManager extends MiniClientPlugin<PetClient>
_creatureModule.SetForce(false);
}
// Baby zombie
else if (entityType.equals(EntityType.RABBIT))
{
for (int x = -5; x < 5; x++)
{
for (int y = 0; y < 255; y++)
{
for (int z = -5; z < 5; z++)
{
Location spawnLoc = location.clone().add(x, 0, z);
spawnLoc.setY(y);
Block block = spawnLoc.getBlock();
if (block.getType().equals(Material.WATER) || block.getType().equals(Material.STATIONARY_WATER))
{
UtilPlayer.message(player, F.main("Pets", "You cannot spawn that pet there!"));
return;
}
}
}
}
pet = (Creature)_creatureModule.SpawnEntity(location, petType.getEntityType());
}
//Default Spawn
else
{
@ -235,7 +265,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
pet.setCustomName(Get(player).getPets().get(petType));
}
if (pet instanceof Zombie)
if (petType.equals(PetType.ZOMBIE))
{
((Zombie) pet).setBaby(true);
pet.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
@ -303,8 +333,30 @@ public class PetManager extends MiniClientPlugin<PetClient>
}
_disguiseManager.disguise(disguiseZombie);
GrimReaperPetManager grimReaperPetManager = new GrimReaperPetManager(player, (Blaze) pet);
_grimReaperMorphs.put((Blaze) pet, grimReaperPetManager);
FlyingPetManager flyingPetManager = new FlyingPetManager(player, pet);
_flyingPets.put(pet, flyingPetManager);
}
else if (petType.equals(PetType.GINGERBREAD_MAN))
{
Zombie zombie = (Zombie) pet;
zombie.setBaby(true);
zombie.getEquipment().setHelmet(SkinData.GINGERBREAD.getSkull());
zombie.getEquipment().setChestplate(ItemStackFactory.Instance.createColoredLeatherArmor(1, Color.fromRGB(203, 122, 56)));
zombie.getEquipment().setLeggings(ItemStackFactory.Instance.createColoredLeatherArmor(2, Color.fromRGB(203, 122, 56)));
zombie.getEquipment().setBoots(ItemStackFactory.Instance.createColoredLeatherArmor(3, Color.fromRGB(203, 122, 56)));
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
{
zombie.setCustomName(Get(player).getPets().get(entityType));
zombie.setCustomNameVisible(true);
}
// Makes it silent
net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) zombie).getHandle();
NBTTagCompound tag = new NBTTagCompound();
nmsEntity.c(tag);
tag.setByte("Silent", (byte) 1);
nmsEntity.f(tag);
}
_activePetOwnerTypes.put(player.getName(), petType);
@ -337,7 +389,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
if (pet instanceof Blaze)
{
_grimReaperMorphs.remove(pet);
_flyingPets.remove(pet);
}
pet.remove();
@ -511,17 +563,33 @@ public class PetManager extends MiniClientPlugin<PetClient>
}
/**
* Makes the Grim Reaper pet fly around the player
* Makes the Flying 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())
for (Entry<Creature, FlyingPetManager> entry : _flyingPets.entrySet())
{
GrimReaperPetManager grimReaperPetManager = entry.getValue();
grimReaperPetManager.update();
FlyingPetManager flyingPetManager = entry.getValue();
flyingPetManager.update();
}
}
/**
* Blocks zombie pets catching fire
* @param event
*/
@EventHandler
public void noFire(EntityCombustEvent event)
{
if (event.getEntity() instanceof Zombie)
{
if (_activePetOwners.containsValue((Creature) event.getEntity()))
{
event.setCancelled(true);
}
}
}

View File

@ -26,6 +26,7 @@ public enum PetType
SKELETON("Guardian", EntityType.SKELETON, -13),
RABBIT("Baby Zombie", EntityType.RABBIT, -9, "They're so cute - until a pack of them chases down your family and eats them."),
BLAZE("Grim Reaper", EntityType.BLAZE, -8, "Aww isn't he so cute with his little wings and little scythe?"),
GINGERBREAD_MAN("Gingerbread Man", EntityType.ZOMBIE, -16, "Looks like you can catch him after all."),
// TODO CHECK IF LOBBY IS 1.9+
// Not in this update
//SHULKER("Shulker Pet", EntityType.BAT, 0, "Is it a turtle or an alien? Either way its shot can be really UPLIFTING.")

View File

@ -70,6 +70,13 @@ public class ServerCommand extends CommandBase<Portal>
else
deniedAccess = true;
}
else if (servUp.startsWith("CLANS-"))
{
if (playerRank.has(Rank.HELPER))
Plugin.sendPlayerToServer(player, args[0]);
else
UtilPlayer.message(player, F.main(Plugin.getName(), "Clans servers can only be joined via the Clans Hub!"));
}
else
{
Plugin.sendPlayerToServer(player, args[0]);

View File

@ -30,6 +30,7 @@ public class PowerPlayClubRewards
.put(YearMonth.of(2016, Month.SEPTEMBER), new PowerPlayClubItem("Squid Morph", new ItemStack(Material.INK_SACK)))
.put(YearMonth.of(2016, Month.OCTOBER), new PowerPlayClubItem("Witch Morph", SkinData.WITCH.getSkull()))
.put(YearMonth.of(2016, Month.NOVEMBER), new PowerPlayClubItem("Turkey Morph", SkinData.TURKEY.getSkull()))
.put(YearMonth.of(2016, Month.DECEMBER), new PowerPlayClubItem("Santa Morph", SkinData.SANTA.getSkull()))
.put(YearMonth.of(2017, Month.JANUARY), new PowerPlayClubItem("Chicken Mount", new ItemStack(Material.GLASS)))
.build();

View File

@ -27,6 +27,7 @@ import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow;
import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood;
import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant;
import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane;
import mineplex.core.gadget.gadgets.death.christmas.DeathPresentDanger;
import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart;
import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald;
import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom;
@ -76,6 +77,10 @@ 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.freezesuit.OutfitFreezeSuitBoots;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitHelmet;
import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitLeggings;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitBoots;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitHelmet;
@ -84,6 +89,7 @@ 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.ParticleChristmasTree;
import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes;
import mineplex.core.gadget.gadgets.particle.ParticleFairy;
import mineplex.core.gadget.gadgets.particle.ParticleFireRings;
@ -111,6 +117,7 @@ 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.gadgets.wineffect.WinEffectWinterWarfare;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.HatGadget;
@ -471,6 +478,12 @@ public class RewardManager
addReward(Type.THANKFUL, new UnknownPackageReward(_donationManager, "Clan Banner Access", "Wear/Place Clan Banner", "Clan Banner Usage", new ItemStack(Material.BANNER), rarity, 110, 0));
addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.OLD, 1, 5, rarity, 150, 0));
addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.ANCIENT, 1, 5, rarity, 80, 0));
// GINGERBREAD CHEST
addGadget(Type.GINGERBREAD, getGadget(ParticleChristmasTree.class), rarity, 25);
addGadget(Type.GINGERBREAD, getGadget(OutfitFreezeSuitChestplate.class), rarity, 100);
addGadget(Type.GINGERBREAD, getGadget(OutfitFreezeSuitLeggings.class), rarity, 100);
addGadget(Type.GINGERBREAD, getGadget(OutfitFreezeSuitBoots.class), rarity, 50);
}
public void addLegendary()
@ -638,6 +651,12 @@ public class RewardManager
addMount(Type.THANKFUL, getMount(MountCake.class), rarity, 10);
addPetReward(Type.THANKFUL, PetType.VILLAGER, rarity, 10);
addPetReward(Type.THANKFUL, PetType.PIG_ZOMBIE, rarity, 10);
// GINGERBREAD
addGadget(Type.GINGERBREAD, getGadget(DeathPresentDanger.class), rarity, 25);
addGadget(Type.GINGERBREAD, getGadget(WinEffectWinterWarfare.class), rarity, 25);
addGadget(Type.GINGERBREAD, getGadget(OutfitFreezeSuitHelmet.class), rarity, 1);
addPetReward(Type.GINGERBREAD, PetType.GINGERBREAD_MAN, rarity, 10);
}
public UnknownPackageReward addMount(Type type, Mount<?> mount, RewardRarity rarity, int weight)
@ -847,7 +866,7 @@ public class RewardManager
{
int amount = 4;
if(type == RewardType.ILLUMINATED_CHEST || type == RewardType.FREEDOM_CHEST || type == RewardType.OMEGA_CHEST
|| type == RewardType.HAUNTED_CHEST) amount = 1;
|| type == RewardType.HAUNTED_CHEST || type == RewardType.GINGERBREAD_CHEST) amount = 1;
int currentReward = 0;
Reward[] rewards = new Reward[amount];

View File

@ -4,12 +4,12 @@ import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import org.bukkit.entity.Player;
import mineplex.core.reward.rewards.GemReward;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.TreasureShardReward;
import mineplex.core.reward.rewards.UnknownPackageReward;
import org.bukkit.entity.Player;
/**
* Used to separate different "Reward Pools". This allows us to have treasure chests with different loot.
@ -59,6 +59,7 @@ public class RewardPool
HAUNTED(false),
TRICK_OR_TREAT(false),
THANKFUL(false),
GINGERBREAD(false),
CARL_SPINNER(true);
private boolean _useDuplicates;

View File

@ -5,22 +5,23 @@ import java.util.ArrayList;
public enum RewardType
{
//% Chances Mythic Legend Rare Uncommon
GAME_LOOT( 0.000001, 0.00001, 0.0001, 3),
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, 32, 16, 2),
GAME_LOOT( 0.000001, 0.00001, 0.0001, 3),
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, 32, 16, 2),
TRICK_OR_TREAT_CHEST(0.1, 2, 16, 0),
THANKFUL_CHEST( 0.1, 2, 16, 0),
VALENTINES_GIFT( 0, 7, 20, 20),
GINGERBREAD_CHEST( 0, 2, 16, 0),
VALENTINES_GIFT( 0, 7, 20, 20),
SPINNER_FILLER( 0.1, 1, 4, 20),
SPINNER_REAL( 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;

View File

@ -51,13 +51,13 @@ public class RuneAmplifierReward extends Reward
_inventoryManager.addItemToInventory(player, "Rune Amplifier " + _minutes, amountToGive);
return new RewardData(getRarity().getDarkColor() + "Rune Amplifier", getRarity().getColor() + amountToGive + " " + _minutes + " minute Amplifier", new ItemStack(Material.NETHER_STAR), getRarity());
return new RewardData(getRarity().getDarkColor() + "Clans Amplifier", getRarity().getColor() + amountToGive + " " + _minutes + " minute Clans Amplifier", new ItemStack(Material.NETHER_STAR), getRarity());
}
@Override
public RewardData getFakeRewardData(Player player)
{
return new RewardData(getRarity().getDarkColor() + "Rune Amplifier", getRarity().getColor() + _minutes + " minute Amplifier", new ItemStack(Material.NETHER_STAR), getRarity());
return new RewardData(getRarity().getDarkColor() + "Clans Amplifier", getRarity().getColor() + _minutes + " minute Clans Amplifier", new ItemStack(Material.NETHER_STAR), getRarity());
}
@Override

View File

@ -135,7 +135,7 @@ public class TreasureLocation implements Listener
}
if(treasureType == TreasureType.ILLUMINATED || treasureType == TreasureType.FREEDOM || treasureType == TreasureType.OMEGA
|| treasureType == TreasureType.HAUNTED)
|| treasureType == TreasureType.HAUNTED || treasureType == TreasureType.GINGERBREAD)
{
if(!_treasureManager.hasItemsToGivePlayer(treasureType.getRewardPool(), player))
{

View File

@ -68,7 +68,15 @@ public enum TreasureStyle
ParticleType.HAPPY_VILLAGER,
ParticleType.HAPPY_VILLAGER,
Sound.CHICKEN_IDLE,
Sound.CHICKEN_EGG_POP);
Sound.CHICKEN_EGG_POP
),
GINGERBREAD(
ParticleType.SNOW_SHOVEL,
ParticleType.SNOW_SHOVEL,
ParticleType.SNOW_SHOVEL,
Sound.DIG_SNOW,
Sound.DIG_SNOW
);
private ParticleType _secondaryParticle;
private ParticleType _chestSpawnParticle;

View File

@ -26,7 +26,9 @@ public enum TreasureType
TRICK_OR_TREAT(C.cGold + "Trick or Treat Treasure", "Trick or Treat Chest", "TrickOrTreat", RewardType.TRICK_OR_TREAT_CHEST, Material.CHEST, TreasureStyle.HALLOWEEN, RewardPool.Type.TRICK_OR_TREAT, true, 20000),
THANKFUL(C.cGold + "Thankful Treasure", "Thankful Chest", "ThankFul", RewardType.THANKFUL_CHEST, Material.CHEST, TreasureStyle.THANKFUL, RewardPool.Type.THANKFUL, true, 20000);
THANKFUL(C.cGold + "Thankful Treasure", "Thankful Chest", "ThankFul", RewardType.THANKFUL_CHEST, Material.CHEST, TreasureStyle.THANKFUL, RewardPool.Type.THANKFUL, true, 20000),
GINGERBREAD(C.cRed + "Gingerbread " + C.cGreen + "Treasure", "Gingerbread Chest", "Gingerbread", RewardType.GINGERBREAD_CHEST, Material.CHEST, TreasureStyle.GINGERBREAD, RewardPool.Type.GINGERBREAD, true, 20000);
private final String _name;
private final RewardType _rewardType;

View File

@ -5,7 +5,10 @@ import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.treasure.BlockInfo;
import mineplex.core.treasure.Treasure;
import mineplex.core.treasure.TreasureType;
@ -81,6 +84,11 @@ public class BlockChangeAnimation extends Animation
mat = Material.WOOL;
data = 1;
}
else if (getTreasure().getTreasureType() == TreasureType.GINGERBREAD)
{
mat = Material.STAINED_CLAY;
data = 13;
}
else
continue;
@ -118,6 +126,11 @@ public class BlockChangeAnimation extends Animation
mat = Material.WOOL;
data = 15;
}
else if (getTreasure().getTreasureType() == TreasureType.GINGERBREAD)
{
mat = Material.STAINED_CLAY;
data = 14;
}
else
continue;
@ -174,6 +187,32 @@ public class BlockChangeAnimation extends Animation
}
}
}
else if (getTreasure().getTreasureType() == TreasureType.GINGERBREAD)
{
for (Block c : _chests)
{
if (c.equals(b))
{
_blockInfoList.add(new BlockInfo(b));
try
{
Skull skull = UtilBlock.blockToSkull(c, SkinData.GINGERBREAD);
if (skull != null)
{
skull.setRotation(getSkullDirection(skull.getBlock()));
skull.update();
}
else
{
c.setType(Material.AIR);
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}
}
}
}
@ -209,4 +248,22 @@ public class BlockChangeAnimation extends Animation
}
return direction;
}
private BlockFace getSkullDirection(Block block)
{
byte direction = getDirection(block);
switch (direction)
{
case (byte) 0:
return BlockFace.SOUTH;
case (byte) 1:
return BlockFace.WEST;
case (byte) 2:
return BlockFace.NORTH;
case (byte) 3:
return BlockFace.EAST;
default:
return BlockFace.SOUTH;
}
}
}

View File

@ -2,6 +2,9 @@ package mineplex.core.treasure.animation;
import java.util.List;
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;
@ -28,11 +31,10 @@ import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseBat;
import mineplex.core.particleeffects.BabyFireworkEffect;
import mineplex.core.particleeffects.CircleEffect;
import mineplex.core.treasure.BlockInfo;
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;
/**
* Created by Shaun on 8/29/2014.
@ -203,6 +205,12 @@ public class ChestSpawnAnimation extends Animation
_circleAmount++;
}
else if (getTreasure().getTreasureType() == TreasureType.GINGERBREAD)
{
CircleEffect circleEffect = new CircleEffect(_javaPlugin, _centerLocation.clone().add(0, 0.5, 0), 1.3, Color.GREEN);
circleEffect.setMaxCircles(2);
circleEffect.start();
}
else if (getTreasure().getTreasureType() == TreasureType.HAUNTED || getTreasure().getTreasureType() == TreasureType.TRICK_OR_TREAT)
{
float x = (float) (Math.sin(getTicks()/4D));
@ -233,7 +241,7 @@ public class ChestSpawnAnimation extends Animation
//Spawn Chest
if (getTicks() >= ANIMATION_DURATION)
{
if(getTreasure().getTreasureType() == TreasureType.ILLUMINATED)
if(getTreasure().getTreasureType() == TreasureType.ILLUMINATED || getTreasure().getTreasureType() == TreasureType.GINGERBREAD)
{
UtilBlock.setQuick(_block.getWorld(), _block.getX(), _block.getY(), _block.getZ(), 0, (byte) 0);
}
@ -260,7 +268,8 @@ public class ChestSpawnAnimation extends Animation
if (particleType != null)
{
if (getTreasure().getTreasureType() != TreasureType.FREEDOM && getTreasure().getTreasureType() != TreasureType.HAUNTED)
if (getTreasure().getTreasureType() != TreasureType.FREEDOM && getTreasure().getTreasureType() != TreasureType.HAUNTED
|| getTreasure().getTreasureType() != TreasureType.GINGERBREAD)
{
UtilParticle.PlayParticle(particleType, _centerLocation, 0.2f, 0.2f, 0.2f, 0, 50,
ViewDist.NORMAL, UtilServer.getPlayers());
@ -273,6 +282,14 @@ public class ChestSpawnAnimation extends Animation
_centerLocation.clone().add(.5, .5, .5));
coloredParticle.display();
}
else if (getTreasure().getTreasureType() == TreasureType.GINGERBREAD)
{
int r = (int) (Math.random() * 3);
ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST,
new DustSpellColor(Color.GREEN),
_centerLocation.clone().add(.5, .5, .5));
coloredParticle.display();
}
else
{
int r = (int) (Math.random() * 2);

View File

@ -80,7 +80,7 @@ public class BuyChestButton implements IButton
}
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)
&& (_chestType == TreasureType.ILLUMINATED || _chestType == TreasureType.OMEGA
|| _chestType == TreasureType.HAUNTED))
|| _chestType == TreasureType.HAUNTED || _chestType == TreasureType.GINGERBREAD))
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
return;

View File

@ -16,6 +16,8 @@ import mineplex.core.common.currency.GlobalCurrency;
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.UtilText;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom;
@ -65,6 +67,7 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
int hauntedCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.HAUNTED.getItemName());
int trickCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.TRICK_OR_TREAT.getItemName());
int thankCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.THANKFUL.getItemName());
int gingerbreadCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.GINGERBREAD.getItemName());
List<String> shardLore = new ArrayList<>();
shardLore.add(" ");
@ -142,6 +145,7 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
christmasLore.add(ChatColor.RESET + C.cGreen + "Click to Open!");
else
{
christmasLore.add(C.cRed + "This item is no longer available!");
/*
christmasLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "15000 Treasure Shards");
christmasLore.add(" ");
@ -232,7 +236,7 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
boolean available = new File("../../update/files/EnableTrickOrTreat.dat").exists();
if (!available)
{
trickLore.add(ChatColor.RESET + "This chest is currently unavailable");
trickLore.add(C.cRed + "This item is no longer available!");
}
else
{
@ -259,7 +263,7 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
boolean available = new File("../../update/files/EnableThankful.dat").exists();
if (!available)
{
thankLore.add(ChatColor.RESET + "This chest is currently unavailable");
thankLore.add(C.cRed + "This item is no longer available!");
}
else
{
@ -269,6 +273,26 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
}
}
List<String> gingerbreadLore = Lists.newArrayList();
gingerbreadLore.add(" ");
gingerbreadLore.add(F.value("Gingerbread Chests Owned", "" + gingerbreadCount));
gingerbreadLore.add(" ");
gingerbreadLore.addAll(UtilText.splitLine(C.cGray + "The legendary burglar, " +
"the Gingerbread Man, has finally been caught! Now, for the first time his loot is available for auction." +
" There are 8 pieces available for to collect and no duplicates can be obtained from this chest!",
LineFormat.LORE));
gingerbreadLore.add(" ");
if (gingerbreadCount > 0)
{
gingerbreadLore.add(ChatColor.RESET + C.cGreen + "Click to Open!");
}
else
{
gingerbreadLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards");
gingerbreadLore.add(" ");
gingerbreadLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false);
ShopItem basic = new ShopItem(Material.CHEST, C.cGreen + C.Bold + "Old Treasure", basicLore.toArray(new String[0]), 0, false, false);
ShopItem heroic = new ShopItem(Material.TRAPPED_CHEST, C.cGold + C.Bold + "Ancient Treasure", heroicLore.toArray(new String[0]), 0, false, false);
@ -280,15 +304,17 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
ItemStack haunted = SkinData.HAUNTED_CHEST.getSkull(C.cGoldB + "Haunted Treasure", hauntedLore);
ItemStack trick = new ShopItem(Material.SKULL_ITEM, C.cGoldB + "Trick or Treat Treasure", trickLore.toArray(new String[0]), 0, false, false);
ItemStack thank = new ShopItem(Material.COOKED_CHICKEN, C.cGoldB + "Thankful Treasure", thankLore.toArray(new String[0]), 0, false, false);
ItemStack gingerbread = SkinData.GINGERBREAD.getSkull(C.cRedB + "Gingerbread" + C.cGreenB + " Treasure", gingerbreadLore);
addItem(49, shards);
addChest(3, trick, TreasureType.TRICK_OR_TREAT, trickCount);
addChest(5, thank, TreasureType.THANKFUL, thankCount);
addChest(10, christmas, TreasureType.CHRISTMAS, christmasCount);
addChest(12, freedom, TreasureType.FREEDOM, freedomCount);
addChest(14, haunted, TreasureType.HAUNTED, hauntedCount);
addChest(16, omega, TreasureType.OMEGA, omegaCount);
addChest(20, trick, TreasureType.TRICK_OR_TREAT, trickCount);
addChest(22, gingerbread, TreasureType.GINGERBREAD, gingerbreadCount);
addChest(24, thank, TreasureType.THANKFUL, thankCount);
addChest(28, basic, TreasureType.OLD, basicCount);
addChest(30, heroic, TreasureType.ANCIENT, heroicCount);
addChest(32, legendary, TreasureType.MYTHICAL, legendaryCount);

View File

@ -34,6 +34,7 @@ public class UtilVariant
World world = ((CraftWorld) location.getWorld()).getHandle();
EntityZombie zombie = new EntityZombie(world);
zombie.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
zombie.setVillager(true);
world.addEntity(zombie, CreatureSpawnEvent.SpawnReason.CUSTOM);
@ -45,6 +46,7 @@ public class UtilVariant
World world = ((CraftWorld) location.getWorld()).getHandle();
EntitySkeleton skeleton = new EntitySkeleton(world);
skeleton.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
skeleton.setSkeletonType(1);
world.addEntity(skeleton, CreatureSpawnEvent.SpawnReason.CUSTOM);
@ -56,6 +58,7 @@ public class UtilVariant
World world = ((CraftWorld) location.getWorld()).getHandle();
EntityGuardian guardian = new EntityGuardian(world);
guardian.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
guardian.setElder(true);
world.addEntity(guardian, CreatureSpawnEvent.SpawnReason.CUSTOM);

View File

@ -51,11 +51,9 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.creature.Creature;
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
import mineplex.core.disguise.DisguiseManager;
@ -147,7 +145,6 @@ import mineplex.minecraft.game.core.IRelation;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.Condition;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.minecraft.game.core.damage.DamageManager;
import mineplex.minecraft.game.core.fire.Fire;
@ -158,9 +155,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{
public static final int CLAIMABLE_RADIUS = 800;
public static final int WORLD_RADIUS = 1200;
private static final long PLAYER_VISIBILITY_REFRESH_RATE = 30000;
private static final int VIEW_DISTANCE_BLOCK_VALUE = 8;
private long _lastVisibilityRefresh = 0;
private static final TimeZone TIME_ZONE = TimeZone.getDefault();
private static ClansManager _instance;
@ -1407,27 +1401,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
}
}
}
@EventHandler
public void refreshVisibility(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
if (UtilTime.elapsed(_lastVisibilityRefresh, PLAYER_VISIBILITY_REFRESH_RATE))
{
_lastVisibilityRefresh = System.currentTimeMillis();
Bukkit.getOnlinePlayers().stream().filter(player -> !Managers.get(ConditionManager.class).HasCondition(player, ConditionType.INVISIBILITY) && !Managers.get(ConditionManager.class).HasCondition(player, ConditionType.CLOAK) && !UtilPlayer.isSpectator(player) && !Managers.get(IncognitoManager.class).Get(player).Hidden && !Managers.get(ObserverManager.class).isObserver(player)).forEach(player ->
{
Bukkit.getOnlinePlayers().stream().filter(viewer -> UtilMath.offset2d(viewer, player) <= (Bukkit.getViewDistance() * VIEW_DISTANCE_BLOCK_VALUE)).forEach(viewer ->
{
viewer.hidePlayer(player);
viewer.showPlayer(player);
});
});
}
}
public Pair<ClanInfo, Long> leftRecently(UUID uniqueId, long time)
{

View File

@ -4,16 +4,16 @@ import mineplex.serverdata.commands.ServerCommand;
public class SalesAnnouncementDeleteCommand extends ServerCommand
{
private int _id;
private String _id;
private String _from;
public SalesAnnouncementDeleteCommand(int id, String from)
public SalesAnnouncementDeleteCommand(String id, String from)
{
_id = id;
_from = from;
}
public int getId()
public String getId()
{
return _id;
}

View File

@ -23,6 +23,6 @@ public class SalesAnnouncementDeleteHandler implements CommandCallback
{
return;
}
_manager.handleRemoteDeletion(((SalesAnnouncementDeleteCommand)command).getId());
_manager.handleRemoteDeletion(Integer.parseInt(((SalesAnnouncementDeleteCommand)command).getId()));
}
}

View File

@ -58,7 +58,7 @@ public class SalesAnnouncementManager extends MiniPlugin
{
UtilPlayer.message(creator, F.main(getName(), "Announcement successfully created!"));
_data.add(data);
new SalesAnnouncementUpdateCommand(data.getId(), getServer()).publish();
new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish();
});
}
@ -75,7 +75,7 @@ public class SalesAnnouncementManager extends MiniPlugin
{
_data.remove(data);
}
new SalesAnnouncementDeleteCommand(data.getId(), getServer()).publish();
new SalesAnnouncementDeleteCommand(data.getId() + "", getServer()).publish();
});
}
@ -85,7 +85,7 @@ public class SalesAnnouncementManager extends MiniPlugin
_repo.updateAnnouncementStatus(data, () ->
{
UtilPlayer.message(toggler, F.main(getName(), "Successfully toggled announcement!"));
new SalesAnnouncementUpdateCommand(data.getId(), getServer()).publish();
new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish();
});
}

View File

@ -4,16 +4,16 @@ import mineplex.serverdata.commands.ServerCommand;
public class SalesAnnouncementUpdateCommand extends ServerCommand
{
private int _id;
private String _id;
private String _from;
public SalesAnnouncementUpdateCommand(int id, String from)
public SalesAnnouncementUpdateCommand(String id, String from)
{
_id = id;
_from = from;
}
public int getId()
public String getId()
{
return _id;
}

View File

@ -23,6 +23,6 @@ public class SalesAnnouncementUpdateHandler implements CommandCallback
{
return;
}
_manager.handleRemoteUpdate(((SalesAnnouncementUpdateCommand)command).getId());
_manager.handleRemoteUpdate(Integer.parseInt(((SalesAnnouncementUpdateCommand)command).getId()));
}
}

View File

@ -135,7 +135,7 @@ import net.minecraft.server.v1_8_R3.EntityPlayer;
public class HubManager extends MiniClientPlugin<HubClient> implements IChatMessageFormatter
{
// Snowman!
public HubType Type = HubType.Normal;
public HubType Type = HubType.Christmas;
private BlockRestore _blockRestore;
private CoreClientManager _clientManager;

View File

@ -257,43 +257,7 @@ public class NewsManager extends MiniPlugin
String text = "";
double healthPercent = 1;
if (Manager.Type == HubType.Christmas)
{
_animationIndex = (_animationIndex + 1) % 40;
if (_animationIndex == 2) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " U" + C.cWhiteB + "P TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 3) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP" + C.cWhiteB + " TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 4) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP " + C.cWhiteB + "TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 5) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP T" + C.cWhiteB + "O 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 6) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO" + C.cWhiteB + " 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 7) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO " + C.cWhiteB + "50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 8) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 5" + C.cWhiteB + "0% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 9) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50" + C.cWhiteB + "% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 10) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50%" + C.cWhiteB + " OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 11) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% " + C.cWhiteB + "OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 11) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% O" + C.cWhiteB + "FF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 12) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OF" + C.cWhiteB + "F " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 13) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 14) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 15) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 16) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 17) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 18) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 19) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 20) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 21) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 22) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 23) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 24) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 25) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex == 26) text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
if (_animationIndex >= 27)
text = C.cWhite + "" + C.cRed + " Massive Winter Sale " + C.cGreenB + " " + C.cWhiteB + "50% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + "";
}
else if (Manager.Type == HubType.Halloween)
if (Manager.Type == HubType.Halloween)
{
/**
* @author Mysticate

View File

@ -74,7 +74,7 @@ public class WorldManager extends MiniPlugin
world.setGameRuleValue("doDaylightCycle", "false");
if (Manager.Type == HubType.Halloween)
if (Manager.Type == HubType.Halloween || Manager.Type == HubType.Christmas)
{
world.setTime(13850);
} else

View File

@ -4,16 +4,16 @@ import mineplex.serverdata.commands.ServerCommand;
public class SalesAnnouncementDeleteCommand extends ServerCommand
{
private int _id;
private String _id;
private String _from;
public SalesAnnouncementDeleteCommand(int id, String from)
public SalesAnnouncementDeleteCommand(String id, String from)
{
_id = id;
_from = from;
}
public int getId()
public String getId()
{
return _id;
}

View File

@ -23,6 +23,6 @@ public class SalesAnnouncementDeleteHandler implements CommandCallback
{
return;
}
_manager.handleRemoteDeletion(((SalesAnnouncementDeleteCommand)command).getId());
_manager.handleRemoteDeletion(Integer.parseInt(((SalesAnnouncementDeleteCommand)command).getId()));
}
}

View File

@ -58,7 +58,7 @@ public class SalesAnnouncementManager extends MiniPlugin
{
UtilPlayer.message(creator, F.main(getName(), "Announcement successfully created!"));
_data.add(data);
new SalesAnnouncementUpdateCommand(data.getId(), getServer()).publish();
new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish();
});
}
@ -75,7 +75,7 @@ public class SalesAnnouncementManager extends MiniPlugin
{
_data.remove(data);
}
new SalesAnnouncementDeleteCommand(data.getId(), getServer()).publish();
new SalesAnnouncementDeleteCommand(data.getId() + "", getServer()).publish();
});
}
@ -85,7 +85,7 @@ public class SalesAnnouncementManager extends MiniPlugin
_repo.updateAnnouncementStatus(data, () ->
{
UtilPlayer.message(toggler, F.main(getName(), "Successfully toggled announcement!"));
new SalesAnnouncementUpdateCommand(data.getId(), getServer()).publish();
new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish();
});
}

View File

@ -4,16 +4,16 @@ import mineplex.serverdata.commands.ServerCommand;
public class SalesAnnouncementUpdateCommand extends ServerCommand
{
private int _id;
private String _id;
private String _from;
public SalesAnnouncementUpdateCommand(int id, String from)
public SalesAnnouncementUpdateCommand(String id, String from)
{
_id = id;
_from = from;
}
public int getId()
public String getId()
{
return _id;
}

View File

@ -23,6 +23,6 @@ public class SalesAnnouncementUpdateHandler implements CommandCallback
{
return;
}
_manager.handleRemoteUpdate(((SalesAnnouncementUpdateCommand)command).getId());
_manager.handleRemoteUpdate(Integer.parseInt(((SalesAnnouncementUpdateCommand)command).getId()));
}
}

View File

@ -160,6 +160,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
int hauntedChestsOpened = 0;
int trickOrTreatChestsReceived = 0;
int thankfulChestsReceived = 0;
int gingerbreadChestsReceived = 0;
for (CoinTransactionToken transaction : donor.getCoinTransactions())
{
@ -281,6 +282,17 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
thankfulChestsReceived += 1;
}
}
if (transaction.SalesPackageName.startsWith("Gingerbread Chest"))
{
if (transaction.Coins == 0 && transaction.Gems == 0)
{
if (transaction.SalesPackageName.split(" ").length == 3)
gingerbreadChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
gingerbreadChestsReceived += 1;
}
}
if (transaction.SalesPackageName.startsWith("Valentines Gift"))
{
@ -352,6 +364,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
caller.sendMessage(C.cBlue + "Haunted Chests Opened: " + C.cYellow + hauntedChestsOpened);
caller.sendMessage(C.cBlue + "Trick or Treat Chests Received: " + C.cYellow + trickOrTreatChestsReceived);
caller.sendMessage(C.cBlue + "Thankful Chests Received: " + C.cYellow + thankfulChestsReceived);
caller.sendMessage(C.cBlue + "Gingerbread Chests Received: " + C.cYellow + gingerbreadChestsReceived);
caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived);
caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min) Received: " + C.cYellow + runeAmplifier20);
caller.sendMessage(C.cBlue + "Rune Amplifiers (60 min) Received: " + C.cYellow + runeAmplifier60);

View File

@ -22,6 +22,7 @@ import mineplex.staffServer.salespackage.salespackages.ClanBannerUsage;
import mineplex.staffServer.salespackage.salespackages.Coins;
import mineplex.staffServer.salespackage.salespackages.DefaultRank;
import mineplex.staffServer.salespackage.salespackages.FreedomChest;
import mineplex.staffServer.salespackage.salespackages.GingerbreadChest;
import mineplex.staffServer.salespackage.salespackages.HauntedChest;
import mineplex.staffServer.salespackage.salespackages.IlluminatedChest;
import mineplex.staffServer.salespackage.salespackages.LifetimeEternal;
@ -83,6 +84,7 @@ public class SalesPackageManager extends MiniPlugin
AddSalesPackage(new MythicalChest(this));
AddSalesPackage(new IlluminatedChest(this));
AddSalesPackage(new FreedomChest(this));
AddSalesPackage(new GingerbreadChest(this));
//AddSalesPackage(new ValentinesGift(this));
//AddSalesPackage(new FrostLord(this));
//AddSalesPackage(new EasterBunny(this));
@ -164,7 +166,8 @@ public class SalesPackageManager extends MiniPlugin
{
coinBuilder = coinBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray");
}
else if (salesPackage instanceof MythicalChest || salesPackage instanceof AncientChest || salesPackage instanceof OldChest || salesPackage instanceof IlluminatedChest || salesPackage instanceof FreedomChest || salesPackage instanceof HauntedChest || salesPackage instanceof TrickOrTreatChest)
else if (salesPackage instanceof MythicalChest || salesPackage instanceof AncientChest || salesPackage instanceof OldChest || salesPackage instanceof IlluminatedChest || salesPackage instanceof FreedomChest || salesPackage instanceof HauntedChest || salesPackage instanceof TrickOrTreatChest
|| salesPackage instanceof GingerbreadChest)
{
chestBuilder = chestBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray");
}

View File

@ -0,0 +1,22 @@
package mineplex.staffServer.salespackage.salespackages;
import org.bukkit.entity.Player;
import mineplex.staffServer.salespackage.SalesPackageManager;
public class GingerbreadChest extends SalesPackageBase
{
public GingerbreadChest(SalesPackageManager manager)
{
super(manager, "1 Gingerbread Chest");
}
public void displayToAgent(Player agent, String playerName)
{
addButton(agent, "/sales item " + playerName + " 1 Item Gingerbread Chest", "Give 1 Gingerbread Chest.");
agent.sendMessage(" ");
addBackButton(agent, playerName);
}
}

View File

@ -69,6 +69,7 @@ import mineplex.core.events.EnableArcadeSpawnEvent;
import mineplex.core.explosion.Explosion;
import mineplex.core.explosion.ExplosionEvent;
import mineplex.core.facebook.FacebookManager;
import mineplex.core.gadget.event.ToggleMobsEvent;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.hologram.HologramManager;
@ -1983,6 +1984,19 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_conditionManager.AddCondition(new Condition(_conditionManager, event));
}
/**
* Allows toggling mob spawning from another module
* @param event
*/
@EventHandler
public void toggleMobSpawning(ToggleMobsEvent event)
{
if (_game != null)
{
_game.CreatureAllowOverride = event.enable();
}
}
public ProgressingKitManager getProgressionKitManager()
{
return _progressionKitManager;

View File

@ -23,9 +23,8 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
@ -477,29 +476,15 @@ public class Christmas extends SoloGame
if (!player.isOnline())
continue;
if (Manager.GetTaskManager().hasCompletedTask(player, "CC Reward 2015"))
if (Manager.GetDonation().Get(player).OwnsUnknownPackage("Christmas Kings Head"))
{
SetCustomWinMessage(player, "You already earned your reward");
}
else
{
SetCustomWinMessage(player, "You earned " + C.cYellow + "2x Winter Holiday Treasure");
SetCustomWinMessage(player, "You earned " + C.cYellow + "Christmas King Morph");
Manager.GetTaskManager().completedTask(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
if (data)
{
Manager.getInventoryManager().addItemToInventory(player, "Winter Chest", 2);
}
else
{
UtilPlayer.message(player, F.main("Inventory", "An error occured while giving you " + C.cRed + "2x Winter Holiday Treasure" + C.cGray + "."));
}
}
}, player, "CC Reward 2015");
Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), Manager.GetClients().Get(player).getAccountId(), "Christmas Kings Head", GlobalCurrency.TREASURE_SHARD, 0, true);
}
}

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.christmas.parts;
import java.util.ArrayList;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
@ -179,11 +180,11 @@ public class Part4 extends Part
//Create
Location loc = UtilAlg.Random(_mobSpawns);
Host.CreatureAllowOverride = true;
Zombie ent = UtilVariant.spawnZombieVillager(loc);
Host.CreatureAllowOverride = false;
ent.getEquipment().setItemInHand(new ItemStack(Material.WOOD_PICKAXE));
ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));

View File

@ -353,7 +353,7 @@ public class Part5 extends Part
public void Skip(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().equals("/boss"))
if (event.getPlayer().getName().equals("Chiss"))
if (event.getPlayer().isOp())
{
event.setCancelled(true);

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.game.games.uhc;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
@ -24,8 +25,11 @@ import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers;
import org.bukkit.craftbukkit.v1_8_R3.util.HashTreeSet;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Ghast;
@ -58,6 +62,7 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.spigotmc.ActivationRange;
import mineplex.core.boosters.event.BoosterItemGiveEvent;
import mineplex.core.common.Pair;
@ -71,6 +76,9 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParser;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
@ -95,6 +103,10 @@ import nautilus.game.arcade.game.games.AbsorptionFix;
import nautilus.game.arcade.game.games.uhc.components.UHCBorder;
import nautilus.game.arcade.game.games.uhc.components.UHCFreezer;
import nautilus.game.arcade.game.games.uhc.components.UHCSpeedMode;
import nautilus.game.arcade.game.games.uhc.stat.CollectFoodStat;
import nautilus.game.arcade.game.games.uhc.stat.HalfHeartHealStat;
import nautilus.game.arcade.game.games.uhc.stat.HoeCraftingStat;
import nautilus.game.arcade.game.games.uhc.stat.LuckyMinerStat;
import nautilus.game.arcade.game.modules.AntiExpOrbModule;
import nautilus.game.arcade.game.modules.OreVeinEditorModule;
import nautilus.game.arcade.game.modules.PlayerHeadModule;
@ -107,7 +119,10 @@ import nautilus.game.arcade.game.modules.combatlog.CombatLogNPCKilledEvent;
import nautilus.game.arcade.game.modules.combatlog.CombatLogNPCPreSpawnEvent;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import net.md_5.bungee.api.ChatColor;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.NextTickListEntry;
import net.minecraft.server.v1_8_R3.WorldServer;
public abstract class UHC extends Game
@ -124,16 +139,12 @@ public abstract class UHC extends Game
// Initialised in constructor
public static int MINING_TIME;
// This is the region in which nothing can be done (block placing, flowing,
// etc)
public static final int SAFE_REGION = 32;
// The maximum/starting arena size
public static final int MAX_ARENA_SIZE = 1000;
// The deathmatch arena size
public static final int DEATHMATCH_ARENA_SIZE = 100;
public static final int DEATHMATCH_ARENA_SIZE = 200;
// The time for the border to shrink to 0 during deathmatch.
public static final int DEATHMATCH_TIME_SECONDS = 600;
@ -142,16 +153,16 @@ public abstract class UHC extends Game
// The amount of damage to give from hitting the world border
public static final int WORLD_BORDER_DAMAGE = 2;
// The amount of damage to give from hitting the world border
public static final int WORLD_BORDER_TIME = 5;
// The distance a player needs to be away from the vertical border to see the particles
public static final int WORLD_BORDER_PARTICLES_DISTANCE = 20;
// The number of ticks to delay before teleporting each player
public static final long DELAY_BETWEEN_PLAYER_TELEPORT = 5L;
// The Objective representing the tab list health display
private Objective _healthObjective;
// The number of players which have been teleported
private int _teleportedPlayers = -1;
// The total number of players to teleport
@ -170,7 +181,7 @@ public abstract class UHC extends Game
// UHC State
private UHCState _state;
// Speed Mode
private UHCSpeedMode _speedMode;
@ -178,9 +189,10 @@ public abstract class UHC extends Game
{
this(manager, GameType.UHC, false);
registerChatStats(Kills, Assists, BlankLine, DamageTaken, DamageDealt);
registerChatStats(Kills, Assists, BlankLine, DamageTaken, DamageDealt);
}
@SuppressWarnings("unchecked")
public UHC(ArcadeManager manager, GameType type, boolean speedMode)
{
super(manager, type, new Kit[] { new KitUHC(manager) },
@ -196,9 +208,9 @@ public abstract class UHC extends Game
{
_speedMode = new UHCSpeedMode(this);
}
_state = UHCState.SAFE;
HideTeamSheep = true;
StrictAntiHack = true;
@ -219,12 +231,13 @@ public abstract class UHC extends Game
DeathOut = true;
QuitOut = false;
CreatureAllow = true;
AnnounceStay = false;
DeathMessages = false;
DeathTeleport = false;
SoupEnabled = false;
@ -247,9 +260,9 @@ public abstract class UHC extends Game
WorldSoilTrample = true;
WorldBoneMeal = true;
WorldChunkUnload = true;
ShowEveryoneSpecChat = false;
CraftRecipes();
// Disable Custom Mob Drops (and EXP Disable)
@ -269,7 +282,7 @@ public abstract class UHC extends Game
// Player Freezer
_freezer = new UHCFreezer(this);
new PlayerHeadModule().register(this);
new CompassModule().setGiveCompass(false).register(this);
new OreVeinEditorModule().removeNonAirVeins().register(this);
@ -277,6 +290,8 @@ public abstract class UHC extends Game
new RejoinModule().register(this);
new AbsorptionFix(this);
registerStatTrackers(new CollectFoodStat(this), new HoeCraftingStat(this), new LuckyMinerStat(this), new HalfHeartHealStat(this));
registerDebugCommand(new DebugCommand("startpvp", Rank.ADMIN)
{
@Override
@ -292,10 +307,10 @@ public abstract class UHC extends Game
UtilPlayer.message(caller, F.main("Debug", "PvP has already been started!"));
return;
}
MINING_TIME -= SAFE_TIME;
SAFE_TIME = 0;
startPvp();
UtilPlayer.message(caller, F.main("Debug", "Started PvP"));
}
@ -351,6 +366,16 @@ public abstract class UHC extends Game
.count())));
UtilPlayer.message(caller, F.desc("View Distance", String.valueOf(nmsWorld.spigotConfig.viewDistance)));
UtilPlayer.message(caller, F.desc("Unload queue size", String.valueOf(nmsWorld.chunkProviderServer.unloadQueue.size())));
try
{
HashTreeSet<NextTickListEntry> m = (HashTreeSet<NextTickListEntry>) nmsWorld.getClass().getField("M").get(nmsWorld);
UtilPlayer.message(caller, F.desc("Pending tick", String.valueOf(m.size())));
}
catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e)
{
e.printStackTrace();
}
}
else
{
@ -471,6 +496,127 @@ public abstract class UHC extends Game
UtilPlayer.message(caller, F.main("Debug", "Starting deathmatch"));
}
});
registerDebugCommand(new DebugCommand("uhcentities", Rank.DEVELOPER)
{
@Override
public void Execute(Player caller, String[] args)
{
for (Entity entity : caller.getNearbyEntities(5.0, 5.0, 5.0))
{
net.minecraft.server.v1_8_R3.Entity nms = ((CraftEntity) entity).getHandle();
String debug = "Entity: " + entity.getType() + " id:" + nms.getId() + " inac:" + ActivationRange.checkIfActive(nms);
debug += " at:" + nms.activatedTick + " dac:" + nms.defaultActivationState;
int x = MathHelper.floor(nms.locX);
int z = MathHelper.floor(nms.locZ);
net.minecraft.server.v1_8_R3.Chunk chunk = nms.world.getChunkIfLoaded(x >> 4, z >> 4);
debug += " c:" + chunk + " il:" + (chunk != null ? chunk.areNeighborsLoaded(1) : "null");
caller.sendMessage(debug);
}
}
});
registerDebugCommand(new DebugCommand("uhcchunk", Rank.DEVELOPER)
{
@Override
public void Execute(Player caller, String[] args)
{
net.minecraft.server.v1_8_R3.Chunk chunk = ((CraftChunk) caller.getLocation().getChunk()).getHandle();
try
{
Field neighbors = chunk.getClass().getDeclaredField("neighbors");
neighbors.setAccessible(true);
int n = neighbors.getInt(chunk);
for (int x = -1; x < 2; x++)
{
for (int z = -1; z < 2; z++)
{
if (x == 0 && z == 0)
{
continue;
}
int mask = 0x1 << (x * 5 + z + 12);
boolean should = chunk.world.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z) != null;
boolean is = (n & mask) == mask;
if (is && should)
{
caller.sendMessage(ChatColor.GREEN + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is a neighbor");
}
else if (is && !should)
{
caller.sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is a neighbor but should not be");
}
else if (!is && should)
{
caller.sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is not a neighbor but should be");
}
else if (!is && !should)
{
caller.sendMessage(ChatColor.GREEN + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is not a neighbor");
}
}
}
}
catch (Throwable t)
{
t.printStackTrace();
}
}
});
registerDebugCommand(new DebugCommand("uhccallchunks", Rank.DEVELOPER)
{
@Override
public void Execute(Player caller, String[] args)
{
for (net.minecraft.server.v1_8_R3.Chunk chunk : ((CraftWorld) caller.getWorld()).getHandle().chunkProviderServer.chunks.values())
{
try
{
Field neighbors = chunk.getClass().getDeclaredField("neighbors");
neighbors.setAccessible(true);
int n = neighbors.getInt(chunk);
for (int x = -1; x < 2; x++)
{
for (int z = -1; z < 2; z++)
{
if (x == 0 && z == 0)
{
continue;
}
int mask = 0x1 << (x * 5 + z + 12);
boolean should = chunk.world.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z) != null;
boolean is = (n & mask) == mask;
if (is && !should)
{
caller.sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") relative to " + (chunk.locX) + "," + chunk.locZ
+ " is a neighbor but should not be");
}
else if (!is && should)
{
caller.sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") relative to " + (chunk.locX) + "," + chunk.locZ
+ " is not a neighbor but should be");
}
}
}
}
catch (Throwable t)
{
t.printStackTrace();
}
}
caller.sendMessage("Done");
}
});
}
@Override
@ -487,20 +633,20 @@ public abstract class UHC extends Game
{
createSpawns(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
}
});
}
public void createSpawns(Callback<Boolean> callback)
{
// Disable game commands
Rank lastGameCommandsRank = Manager.getGameCommandRank();
Manager.setGameCommandMode(null);
// Wipe Spawns
for (GameTeam team : GetTeamList())
{
@ -508,7 +654,7 @@ public abstract class UHC extends Game
}
double border = _border.getMaxCords();
// Solo Game
if (FillTeamsInOrderToCount == -1)
{
@ -520,7 +666,7 @@ public abstract class UHC extends Game
@Override
public void run()
{
{
if (gameTeam.GetSpawns().size() < Math.max(Manager.GetPlayerFull(), GetPlayers(true).size()))
{
Location loc = GetRandomSpawn(null, false);
@ -638,7 +784,7 @@ public abstract class UHC extends Game
System.out.println("Game was switched! Stop spawn generation!");
return;
}
Announce(C.cGreenB + "Generating spawns... there may be some lag for a few moments");
createSpawns();
}, 5 * 20);
@ -649,7 +795,7 @@ public abstract class UHC extends Game
{
return true;
}
@EventHandler
public void end(GameStateChangeEvent event)
{
@ -657,14 +803,14 @@ public abstract class UHC extends Game
{
return;
}
_border = null;
}
@EventHandler
public void outsideBorder(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST || !IsLive())
if (event.getType() != UpdateType.FAST || !IsLive() || _state == UHCState.TELEPORTING)
{
return;
}
@ -675,8 +821,20 @@ public abstract class UHC extends Game
{
Location loc = player.getLocation();
boolean toLow = loc.getY() - _border.getYMin() < WORLD_BORDER_PARTICLES_DISTANCE;
boolean toHigh = _border.getYMax() - loc.getY() < WORLD_BORDER_PARTICLES_DISTANCE;
if (toLow)
{
UtilParticle.PlayParticle(ParticleType.FLAME, new Location(loc.getWorld(), loc.getX(), _border.getYMin(), loc.getZ()), 5F, 1F, 5F, 0.001F, 75, ViewDist.NORMAL, player);
}
else if (toHigh)
{
UtilParticle.PlayParticle(ParticleType.FLAME, new Location(loc.getWorld(), loc.getX(), _border.getYMax(), loc.getZ()), 5F, 1F, 5F, 0.001F, 75, ViewDist.NORMAL, player);
}
// Bump Players Back In
if (loc.getX() > border || loc.getX() < -border || loc.getZ() > border || loc.getZ() < -border)
if (loc.getX() > border || loc.getX() < -border || loc.getZ() > border || loc.getZ() < -border || loc.getY() < _border.getYMin() || loc.getY() > _border.getYMax())
{
if (Recharge.Instance.use(player, "Hit by Border", 1000, false, false))
{
@ -686,16 +844,14 @@ public abstract class UHC extends Game
UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(loc, GetSpectatorLocation()), 1.2, true, 0.4, 0, 10, true);
if (IsAlive(player))
if (!UtilPlayer.isSpectator(player))
{
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, WORLD_BORDER_DAMAGE, false, false, true, "Nether Field", "Vaporize");
player.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, 1f);
player.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, 1f);
}
else
{
player.teleport(GetSpectatorLocation());
player.sendMessage(C.cRedB + "STAY WITHIN THE BORDER!");
}
}
}
@ -709,7 +865,7 @@ public abstract class UHC extends Game
Location loc = ent.getLocation();
// Bump Players Back In
if (loc.getX() > border || loc.getX() < -border || loc.getZ() > border || loc.getZ() < -border)
if (loc.getX() > border || loc.getX() < -border || loc.getZ() > border || loc.getZ() < -border || loc.getY() < _border.getYMin() || loc.getY() > _border.getYMax())
{
// Can't use recharge on entities; blame bad design (mapping
// by name instead of uuid)
@ -750,7 +906,7 @@ public abstract class UHC extends Game
{
return;
}
if (UtilTime.elapsed(GetStateTime(), SAFE_TIME) && _state == UHCState.SAFE)
{
startPvp();
@ -760,17 +916,17 @@ public abstract class UHC extends Game
startPreDeathmatch();
}
}
public void updateActionbar()
{
if (!IsLive())
{
return;
}
String message = null;
long timeSinceStart = System.currentTimeMillis() - GetStateTime();
if (timeSinceStart < SAFE_TIME)
{
message = C.cYellow + "PVP enabled in " + C.Bold + UtilTime.MakeStr(SAFE_TIME - timeSinceStart);
@ -779,7 +935,7 @@ public abstract class UHC extends Game
{
message = C.cRed + "Deathmatch starts in " + C.Bold + UtilTime.MakeStr(MINING_TIME - timeSinceStart);
}
if (message != null)
{
for (Player player : UtilServer.getPlayers())
@ -788,7 +944,7 @@ public abstract class UHC extends Game
{
continue;
}
UtilTextBottom.display(message, player);
}
}
@ -800,9 +956,7 @@ public abstract class UHC extends Game
{
return;
}
refreshVisability();
_state = UHCState.MINING;
UtilTextMiddle.display(null, C.cYellow + "PvP has been enabled!", 5, 80, 5);
@ -810,11 +964,11 @@ public abstract class UHC extends Game
{
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 1f);
}
DamagePvP = true;
RejoinModule rejoinModule = getModule(RejoinModule.class);
rejoinModule.setRejoinTime((int) TimeUnit.MINUTES.toMillis(5));
getModule(CompassModule.class).setGiveCompass(true);
new CombatLogModule().setCombatLogTime((int) rejoinModule.getRejoinTime()).register(this);
@ -826,7 +980,7 @@ public abstract class UHC extends Game
// Set the state
_state = UHCState.TELEPORTING;
// Freeze all players
for (Player player : GetPlayers(true))
{
@ -841,7 +995,7 @@ public abstract class UHC extends Game
// Set time
WorldTimeSet = 0;
// Remove all monsters
for (Entity entity : WorldData.World.getEntities())
{
@ -850,14 +1004,14 @@ public abstract class UHC extends Game
entity.remove();
}
}
// Set the border
_border.setSize(DEATHMATCH_ARENA_SIZE, 0);
// Recreate spawns
createSpawns(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
@ -880,59 +1034,54 @@ public abstract class UHC extends Game
public void startDeathmatch()
{
Announce(C.cRedB + "Fight!", false);
UtilTextMiddle.display(C.cRedB + "Watch Out", "The border is closing in on all sides!");
// Set the state
_state = UHCState.DEATHMATCH;
for (Player player : UtilServer.getPlayers())
{
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 1f);
}
refreshVisability();
// Unfreeze all players
_freezer.unfreeze();
// Toggle temporary game settings
Damage = true;
// Set the border
_border.setSize(32, DEATHMATCH_TIME_SECONDS);
}
public void refreshVisability()
{
for (Player player : GetPlayers(true))
{
for (Player other : GetPlayers(true))
{
player.hidePlayer(other);
player.showPlayer(other);
}
}
}
@EventHandler
public void deathmatchTimer(UpdateEvent event)
{
// Checks to see if it is pre-deathmatch
if (event.getType() != UpdateType.SEC || _state != UHCState.TELEPORTING)
if (event.getType() != UpdateType.SEC)
{
return;
}
_secondsSincePreDeathmatch++;
if (_secondsSincePreDeathmatch < PRE_DEATHMATCH_TIME_SECONDS)
if (_state == UHCState.TELEPORTING)
{
int seconds = PRE_DEATHMATCH_TIME_SECONDS - _secondsSincePreDeathmatch;
_secondsSincePreDeathmatch++;
Announce(C.cRedB + "Deathmatch starting in " + seconds + " second" + (seconds == 1 ? "" : "s"), false);
if (_secondsSincePreDeathmatch < PRE_DEATHMATCH_TIME_SECONDS)
{
int seconds = PRE_DEATHMATCH_TIME_SECONDS - _secondsSincePreDeathmatch;
Announce(C.cRedB + "Deathmatch starting in " + seconds + " second" + (seconds == 1 ? "" : "s"), false);
}
else if (_secondsSincePreDeathmatch == PRE_DEATHMATCH_TIME_SECONDS)
{
startDeathmatch();
}
}
else if (_secondsSincePreDeathmatch == PRE_DEATHMATCH_TIME_SECONDS)
else if (_state == UHCState.DEATHMATCH)
{
startDeathmatch();
_border.advanceYBorder();
}
}
@ -972,10 +1121,7 @@ public abstract class UHC extends Game
Location location = npc.getNPC().getLocation();
for (ItemStack item : npc.getPlayerInfo().getItems())
{
location.getWorld().dropItemNaturally(location, item);
}
placeItemsInChest(npc.getPlayerInfo().getItems(), location);
getModule(RejoinModule.class).stopPlayerFromRejoining(npc.getPlayerInfo().getName());
}
@ -1045,7 +1191,7 @@ public abstract class UHC extends Game
player.setExhaustion(0f);
}
}
@EventHandler
public void gameLive(GameStateChangeEvent event)
{
@ -1053,7 +1199,7 @@ public abstract class UHC extends Game
{
return;
}
if (!isSpeedMode())
{
_border.setSize(32, MINING_TIME / 1000);
@ -1301,6 +1447,24 @@ public abstract class UHC extends Game
}
}
public void placeItemsInChest(Collection<ItemStack> drops, Location location)
{
// Place their items in a chest
Block block = location.getBlock();
block.setType(Material.CHEST);
block.getRelative(BlockFace.NORTH).setType(Material.CHEST);
Chest chest = (Chest) block.getState();
Inventory inventory = chest.getInventory();
int i = 0;
for (ItemStack itemStack : drops)
{
inventory.setItem(i++, itemStack);
}
}
@EventHandler
public void GhastDrops(EntityDeathEvent event)
{
@ -1322,7 +1486,6 @@ public abstract class UHC extends Game
// Lightning
Location loc = player.getLocation();
loc.setY(-150);
player.getWorld().strikeLightningEffect(loc);
// Gems
@ -1330,21 +1493,8 @@ public abstract class UHC extends Game
{
long timeAlive = System.currentTimeMillis() - GetStateTime();
AddGems(player, timeAlive / 60000d, "Survived " + UtilTime.MakeStr(timeAlive), false, false);
// Place their items in a chest
Block block = player.getLocation().getBlock();
block.setType(Material.CHEST);
block.getRelative(BlockFace.NORTH).setType(Material.CHEST);
Chest chest = (Chest) block.getState();
Inventory inventory = chest.getInventory();
int i = 0;
for (ItemStack itemStack : event.getDrops())
{
inventory.setItem(i++, itemStack);
}
placeItemsInChest(event.getDrops(), loc);
}
}
@ -1529,7 +1679,7 @@ public abstract class UHC extends Game
return;
boolean end = false;
// Solo
if (GetTeamList().size() == 1)
{
@ -1553,7 +1703,7 @@ public abstract class UHC extends Game
for (Player player : GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false, false);
end = true;
}
}
@ -1570,7 +1720,7 @@ public abstract class UHC extends Game
teamsAlive.add(data.getTeam());
}
}
if (teamsAlive.size() <= 1)
{
if (teamsAlive.size() > 0)
@ -1590,15 +1740,15 @@ public abstract class UHC extends Game
{
AnnounceEnd(teamsAlive.get(0));
}
end = true;
}
}
if (end)
{
_border.stop();
// End
SetState(GameState.End);
}
@ -1612,10 +1762,10 @@ public abstract class UHC extends Game
{
return;
}
// Take this time to update the actionbar
updateActionbar();
Scoreboard.reset();
Scoreboard.writeNewLine();
@ -1635,7 +1785,7 @@ public abstract class UHC extends Game
// Team
else
{
if (GetPlayers(true).size() < 8)
if (GetPlayers(true).size() < 7)
{
Scoreboard.writeGroup(GetPlayers(true), player -> Pair.create(GetTeam(player).GetColor() + player.getName(), (int) player.getHealth()), true);
}
@ -1665,10 +1815,14 @@ public abstract class UHC extends Game
}
double currentBorder = _border.getMaxCords();
Scoreboard.writeNewLine();
Scoreboard.write(C.cYellow + C.Bold + "Borders");
Scoreboard.write("-" + (int) currentBorder + " to " + "+" + (int) currentBorder);
Scoreboard.write("-" + (int) currentBorder + " to " + "+" + (int) currentBorder);
if (_state == UHCState.DEATHMATCH)
{
Scoreboard.write("Vert: " + (int) _border.getYMin() + " to " + (int) _border.getYMax());
}
Scoreboard.draw();
@ -1693,20 +1847,42 @@ public abstract class UHC extends Game
return 200;
}
public void addUHCAchievement(Player player, String achievement)
{
if (!Manager.IsRewardStats())
{
return;
}
Map<String, Integer> stats = GetStats().get(player);
String gameType = null;
if (isSpeedMode())
{
gameType = "Ultra Hardcore Speed";
}
else
{
gameType = "Ultra Hardcore";
}
stats.put(gameType + "." + achievement, 1);
}
public UHCBorder getBorder()
{
return _border;
}
public boolean isSpeedMode()
{
return _speedMode != null;
}
public enum UHCState
{
SAFE, MINING, TELEPORTING, DEATHMATCH;
public boolean isPVP()
{
return this != SAFE;

View File

@ -1,59 +1,106 @@
package nautilus.game.arcade.game.games.uhc.components;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldBorder;
import mineplex.core.common.util.UtilBlock;
import nautilus.game.arcade.game.games.uhc.UHC;
public class UHCBorder
{
private static final int WARNING_TIME = 60;
// Allow some blocks of lee-way for the Y border
private static final int VARIATION_OF_Y_BORDER = 8;
// Time in seconds for the world Y border to reach it's goal
private static final int TIME_FOR_COMPLETION_OF_Y_BORDER = UHC.DEATHMATCH_TIME_SECONDS;
private UHC _host;
private int _startingSize;
private WorldBorder _worldBorder;
private double _yMin;
private double _yMax;
private double _yMinSpeed;
private double _yMaxSpeed;
private double _yGoal;
public UHCBorder(UHC host, int startingSize)
{
_host = host;
_startingSize = startingSize;
}
public void prepare()
{
_worldBorder = _host.WorldData.World.getWorldBorder();
World world = _host.WorldData.World;
_worldBorder = world.getWorldBorder();
_worldBorder.setCenter(0, 0);
_worldBorder.setWarningTime(WARNING_TIME);
setSize(_startingSize, 0);
_yMin = 0;
_yMax = world.getMaxHeight();
// Get the highest non-air block at 0,0
_yGoal = (int) (UtilBlock.getHighest(world, new Location(world, 0, 0, 0)).getLocation().getY());
_yMinSpeed = (_yGoal - _yMin) / TIME_FOR_COMPLETION_OF_Y_BORDER;
_yMaxSpeed = (_yMax - _yGoal) / TIME_FOR_COMPLETION_OF_Y_BORDER;
}
public void setSize(double size, long seconds)
{
{
_worldBorder.setSize(size * 2, seconds);
}
public void stop()
{
_worldBorder.setSize(_worldBorder.getSize());
_worldBorder.setSize(99999);
_worldBorder.setSize(5000);
}
public double getSize()
{
if (_worldBorder == null)
{
return _startingSize;
}
return _worldBorder.getSize();
}
public double getMaxCords()
{
return getSize() / 2;
}
public void advanceYBorder()
{
if (_yMax - _yGoal < VARIATION_OF_Y_BORDER)
{
return;
}
_yMin += _yMinSpeed;
_yMax -= _yMaxSpeed;
}
public double getYMin()
{
return _yMin;
}
public double getYMax()
{
return _yMax;
}
}

View File

@ -0,0 +1,83 @@
package nautilus.game.arcade.game.games.uhc.stat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.inventory.ItemStack;
import com.google.common.collect.Sets;
import mineplex.core.common.util.UtilServer;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.stats.StatTracker;
public class CollectFoodStat extends StatTracker<UHC>
{
private static final Set<Material> FOOD_TO_EAT;
private Map<UUID, Set<Material>> _eaten = new HashMap<>();
static
{
FOOD_TO_EAT = Sets.newHashSet(Material.APPLE, Material.MUSHROOM_SOUP, Material.BREAD, Material.GRILLED_PORK, Material.GOLDEN_APPLE, Material.COOKED_FISH, Material.COOKIE, Material.MELON,
Material.COOKED_CHICKEN, Material.CARROT_ITEM, Material.BAKED_POTATO, Material.PUMPKIN_PIE, Material.COOKED_RABBIT, Material.COOKED_MUTTON);
}
public CollectFoodStat(UHC game)
{
super(game);
}
@EventHandler
public void onPlayerItemConsume(PlayerItemConsumeEvent event)
{
Player player = event.getPlayer();
Material material = event.getItem().getType();
if (FOOD_TO_EAT.contains(material))
{
Set<Material> eaten = _eaten.get(player.getUniqueId());
if (eaten == null)
{
eaten = new HashSet<>();
_eaten.put(player.getUniqueId(), eaten);
}
if (!eaten.contains(material))
{
eaten.add(material);
}
if (eaten.size() == FOOD_TO_EAT.size())
{
getGame().addUHCAchievement(player, "Food");
}
}
}
@EventHandler
public void debugCommands(PlayerCommandPreprocessEvent event)
{
if (!UtilServer.isTestServer() || !event.getMessage().startsWith("/testfoodstat"))
{
return;
}
for (Material material : FOOD_TO_EAT)
{
event.getPlayer().getInventory().addItem(new ItemStack(material));
}
}
}

View File

@ -0,0 +1,48 @@
package nautilus.game.arcade.game.games.uhc.stat;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.stats.StatTracker;
public class HalfHeartHealStat extends StatTracker<UHC>
{
private Set<UUID> _players = new HashSet<>();
public HalfHeartHealStat(UHC game)
{
super(game);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
for (Player player : getGame().GetPlayers(true))
{
if (player.getHealth() < 2 && !_players.contains(player.getUniqueId()))
{
_players.add(player.getUniqueId());
}
else if (player.getHealth() >= 20 && _players.contains(player.getUniqueId()))
{
getGame().addUHCAchievement(player, "Die");
_players.remove(player.getUniqueId());
}
}
}
}

View File

@ -0,0 +1,28 @@
package nautilus.game.arcade.game.games.uhc.stat;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.CraftItemEvent;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.stats.StatTracker;
public class HoeCraftingStat extends StatTracker<UHC>
{
public HoeCraftingStat(UHC game)
{
super(game);
}
@EventHandler
public void craft(CraftItemEvent event)
{
if (event.getCurrentItem().getType() == Material.DIAMOND_HOE)
{
getGame().addUHCAchievement((Player) event.getWhoClicked(), "Hoe");
}
}
}

View File

@ -0,0 +1,48 @@
package nautilus.game.arcade.game.games.uhc.stat;
import java.util.concurrent.TimeUnit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.stats.StatTracker;
public class LuckyMinerStat extends StatTracker<UHC>
{
private static final long BEFORE_TIME = TimeUnit.MINUTES.toMillis(10);
public LuckyMinerStat(UHC game)
{
super(game);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC_05 || UtilTime.elapsed(getGame().GetStateTime(), BEFORE_TIME))
{
return;
}
playerLoop : for (Player player : getGame().GetPlayers(true))
{
for (ItemStack itemStack : player.getInventory().getArmorContents())
{
if (!UtilItem.isIronProduct(itemStack))
{
continue playerLoop;
}
}
getGame().addUHCAchievement(player, "Miner");
}
}
}

View File

@ -1,30 +1,7 @@
package nautilus.game.arcade.managers;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTabTitle;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.party.PartyManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.ProgressingKit;
import org.bukkit.Bukkit;
import java.util.ArrayList;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
@ -41,7 +18,25 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTabTitle;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.party.PartyManager;
import mineplex.core.recharge.Recharge;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.ProgressingKit;
public class GamePlayerManager implements Listener
{
@ -49,39 +44,12 @@ public class GamePlayerManager implements Listener
private static final int TEAMMATE_MESSAGE_DELAY = 40;
private static final long PLAYER_VISIBILITY_REFRESH_RATE = 30000;
private static final int VIEW_DISTANCE_BLOCK_VALUE = 8;
private long _lastVisibilityRefresh = 0;
public GamePlayerManager(ArcadeManager manager)
{
Manager = manager;
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
}
@EventHandler
public void onRefreshVisibility(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
if (UtilTime.elapsed(_lastVisibilityRefresh, PLAYER_VISIBILITY_REFRESH_RATE))
{
_lastVisibilityRefresh = System.currentTimeMillis();
if (Manager.GetGame() == null)
{
return;
}
Manager.GetGame().GetPlayers(true).stream().filter(player -> !Manager.GetCondition().HasCondition(player, ConditionType.INVISIBILITY) && !Manager.GetCondition().HasCondition(player, ConditionType.CLOAK) && Manager.GetGame().IsAlive(player) && !UtilPlayer.isSpectator(player)).forEach(player ->
{
Bukkit.getOnlinePlayers().stream().filter(viewer -> UtilMath.offset2d(viewer, player) <= (Bukkit.getViewDistance() * VIEW_DISTANCE_BLOCK_VALUE)).forEach(viewer ->
{
viewer.hidePlayer(player);
viewer.showPlayer(player);
});
});
}
}
@EventHandler(priority = EventPriority.HIGH)
public void PlayerDeath(CombatDeathEvent event)

View File

@ -54,6 +54,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.christmas.Christmas;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.managers.events.SpecialEntityDeathEvent;
import net.minecraft.server.v1_8_R3.BlockPosition;
@ -246,7 +247,7 @@ public class HolidayManager implements Listener
return;
Game game = _arcadeManager.GetGame();
int requirement = (int)((double) _arcadeManager.GetPlayerFull() * 0.5d);
if (UtilServer.getPlayers().length < requirement)
return;
@ -256,6 +257,9 @@ public class HolidayManager implements Listener
if (game instanceof UHC)
return;
if (game instanceof Christmas)
return;
if (!UtilTime.elapsed(_lastSpawn, 90000))
return;